1 // SPDX-License-Identifier: MIT
3 * Copyright © 2022 Intel Corporation
8 #include "intel_gt_mcr.h"
9 #include "intel_gt_print.h"
10 #include "intel_gt_regs.h"
13 * DOC: GT Multicast/Replicated (MCR) Register Support
15 * Some GT registers are designed as "multicast" or "replicated" registers:
16 * multiple instances of the same register share a single MMIO offset. MCR
17 * registers are generally used when the hardware needs to potentially track
18 * independent values of a register per hardware unit (e.g., per-subslice,
19 * per-L3bank, etc.). The specific types of replication that exist vary
22 * MMIO accesses to MCR registers are controlled according to the settings
23 * programmed in the platform's MCR_SELECTOR register(s). MMIO writes to MCR
24 * registers can be done in either a (i.e., a single write updates all
25 * instances of the register to the same value) or unicast (a write updates only
26 * one specific instance). Reads of MCR registers always operate in a unicast
27 * manner regardless of how the multicast/unicast bit is set in MCR_SELECTOR.
28 * Selection of a specific MCR instance for unicast operations is referred to
31 * If MCR register operations are steered toward a hardware unit that is
32 * fused off or currently powered down due to power gating, the MMIO operation
33 * is "terminated" by the hardware. Terminated read operations will return a
34 * value of zero and terminated unicast write operations will be silently
38 #define HAS_MSLICE_STEERING(i915) (INTEL_INFO(i915)->has_mslice_steering)
40 static const char * const intel_steering_types[] = {
50 static const struct intel_mmio_range icl_l3bank_steering_table[] = {
51 { 0x00B100, 0x00B3FF },
56 * Although the bspec lists more "MSLICE" ranges than shown here, some of those
57 * are of a "GAM" subclass that has special rules. Thus we use a separate
58 * GAM table farther down for those.
60 static const struct intel_mmio_range dg2_mslice_steering_table[] = {
61 { 0x00DD00, 0x00DDFF },
62 { 0x00E900, 0x00FFFF }, /* 0xEA00 - OxEFFF is unused */
66 static const struct intel_mmio_range dg2_lncf_steering_table[] = {
67 { 0x00B000, 0x00B0FF },
68 { 0x00D880, 0x00D8FF },
72 static const struct intel_mmio_range xelpg_instance0_steering_table[] = {
73 { 0x000B00, 0x000BFF }, /* SQIDI */
74 { 0x001000, 0x001FFF }, /* SQIDI */
75 { 0x004000, 0x0048FF }, /* GAM */
76 { 0x008700, 0x0087FF }, /* SQIDI */
77 { 0x00B000, 0x00B0FF }, /* NODE */
78 { 0x00C800, 0x00CFFF }, /* GAM */
79 { 0x00D880, 0x00D8FF }, /* NODE */
80 { 0x00DD00, 0x00DDFF }, /* OAAL2 */
84 static const struct intel_mmio_range xelpg_l3bank_steering_table[] = {
85 { 0x00B100, 0x00B3FF },
89 /* DSS steering is used for SLICE ranges as well */
90 static const struct intel_mmio_range xelpg_dss_steering_table[] = {
91 { 0x005200, 0x0052FF }, /* SLICE */
92 { 0x005500, 0x007FFF }, /* SLICE */
93 { 0x008140, 0x00815F }, /* SLICE (0x8140-0x814F), DSS (0x8150-0x815F) */
94 { 0x0094D0, 0x00955F }, /* SLICE (0x94D0-0x951F), DSS (0x9520-0x955F) */
95 { 0x009680, 0x0096FF }, /* DSS */
96 { 0x00D800, 0x00D87F }, /* SLICE */
97 { 0x00DC00, 0x00DCFF }, /* SLICE */
98 { 0x00DE80, 0x00E8FF }, /* DSS (0xE000-0xE0FF reserved) */
102 static const struct intel_mmio_range xelpmp_oaddrm_steering_table[] = {
103 { 0x393200, 0x39323F },
104 { 0x393400, 0x3934FF },
108 void intel_gt_mcr_init(struct intel_gt *gt)
110 struct drm_i915_private *i915 = gt->i915;
114 spin_lock_init(>->mcr_lock);
117 * An mslice is unavailable only if both the meml3 for the slice is
118 * disabled *and* all of the DSS in the slice (quadrant) are disabled.
120 if (HAS_MSLICE_STEERING(i915)) {
121 gt->info.mslice_mask =
122 intel_slicemask_from_xehp_dssmask(gt->info.sseu.subslice_mask,
124 gt->info.mslice_mask |=
125 (intel_uncore_read(gt->uncore, GEN10_MIRROR_FUSE3) &
126 GEN12_MEML3_EN_MASK);
128 if (!gt->info.mslice_mask) /* should be impossible! */
129 gt_warn(gt, "mslice mask all zero!\n");
132 if (MEDIA_VER(i915) >= 13 && gt->type == GT_MEDIA) {
133 gt->steering_table[OADDRM] = xelpmp_oaddrm_steering_table;
134 } else if (GRAPHICS_VER_FULL(i915) >= IP_VER(12, 70)) {
136 if (IS_GFX_GT_IP_STEP(gt, IP_VER(12, 70), STEP_A0, STEP_B0) ||
137 IS_GFX_GT_IP_STEP(gt, IP_VER(12, 71), STEP_A0, STEP_B0))
138 fuse = REG_FIELD_GET(MTL_GT_L3_EXC_MASK,
139 intel_uncore_read(gt->uncore,
140 MTL_GT_ACTIVITY_FACTOR));
142 fuse = REG_FIELD_GET(GT_L3_EXC_MASK,
143 intel_uncore_read(gt->uncore, XEHP_FUSE4));
146 * Despite the register field being named "exclude mask" the
147 * bits actually represent enabled banks (two banks per bit).
149 for_each_set_bit(i, &fuse, 3)
150 gt->info.l3bank_mask |= 0x3 << 2 * i;
152 gt->steering_table[INSTANCE0] = xelpg_instance0_steering_table;
153 gt->steering_table[L3BANK] = xelpg_l3bank_steering_table;
154 gt->steering_table[DSS] = xelpg_dss_steering_table;
155 } else if (IS_DG2(i915)) {
156 gt->steering_table[MSLICE] = dg2_mslice_steering_table;
157 gt->steering_table[LNCF] = dg2_lncf_steering_table;
159 * No need to hook up the GAM table since it has a dedicated
160 * steering control register on DG2 and can use implicit
163 } else if (GRAPHICS_VER(i915) >= 11 &&
164 GRAPHICS_VER_FULL(i915) < IP_VER(12, 55)) {
165 gt->steering_table[L3BANK] = icl_l3bank_steering_table;
166 gt->info.l3bank_mask =
167 ~intel_uncore_read(gt->uncore, GEN10_MIRROR_FUSE3) &
169 if (!gt->info.l3bank_mask) /* should be impossible! */
170 gt_warn(gt, "L3 bank mask is all zero!\n");
171 } else if (GRAPHICS_VER(i915) >= 11) {
173 * We expect all modern platforms to have at least some
174 * type of steering that needs to be initialized.
176 MISSING_CASE(INTEL_INFO(i915)->platform);
181 * Although the rest of the driver should use MCR-specific functions to
182 * read/write MCR registers, we still use the regular intel_uncore_* functions
183 * internally to implement those, so we need a way for the functions in this
184 * file to "cast" an i915_mcr_reg_t into an i915_reg_t.
186 static i915_reg_t mcr_reg_cast(const i915_mcr_reg_t mcr)
188 i915_reg_t r = { .reg = mcr.reg };
194 * rw_with_mcr_steering_fw - Access a register with specific MCR steering
195 * @gt: GT to read register from
196 * @reg: register being accessed
197 * @rw_flag: FW_REG_READ for read access or FW_REG_WRITE for write access
198 * @group: group number (documented as "sliceid" on older platforms)
199 * @instance: instance number (documented as "subsliceid" on older platforms)
200 * @value: register value to be written (ignored for read)
202 * Context: The caller must hold the MCR lock
203 * Return: 0 for write access. register value for read access.
205 * Caller needs to make sure the relevant forcewake wells are up.
207 static u32 rw_with_mcr_steering_fw(struct intel_gt *gt,
208 i915_mcr_reg_t reg, u8 rw_flag,
209 int group, int instance, u32 value)
211 struct intel_uncore *uncore = gt->uncore;
212 u32 mcr_mask, mcr_ss, mcr, old_mcr, val = 0;
214 lockdep_assert_held(>->mcr_lock);
216 if (GRAPHICS_VER_FULL(uncore->i915) >= IP_VER(12, 70)) {
218 * Always leave the hardware in multicast mode when doing reads
219 * (see comment about Wa_22013088509 below) and only change it
220 * to unicast mode when doing writes of a specific instance.
222 * No need to save old steering reg value.
224 intel_uncore_write_fw(uncore, MTL_MCR_SELECTOR,
225 REG_FIELD_PREP(MTL_MCR_GROUPID, group) |
226 REG_FIELD_PREP(MTL_MCR_INSTANCEID, instance) |
227 (rw_flag == FW_REG_READ ? GEN11_MCR_MULTICAST : 0));
228 } else if (GRAPHICS_VER(uncore->i915) >= 11) {
229 mcr_mask = GEN11_MCR_SLICE_MASK | GEN11_MCR_SUBSLICE_MASK;
230 mcr_ss = GEN11_MCR_SLICE(group) | GEN11_MCR_SUBSLICE(instance);
235 * The setting of the multicast/unicast bit usually wouldn't
236 * matter for read operations (which always return the value
237 * from a single register instance regardless of how that bit
238 * is set), but some platforms have a workaround requiring us
239 * to remain in multicast mode for reads. There's no real
240 * downside to this, so we'll just go ahead and do so on all
241 * platforms; we'll only clear the multicast bit from the mask
242 * when exlicitly doing a write operation.
244 if (rw_flag == FW_REG_WRITE)
245 mcr_mask |= GEN11_MCR_MULTICAST;
247 mcr = intel_uncore_read_fw(uncore, GEN8_MCR_SELECTOR);
252 intel_uncore_write_fw(uncore, GEN8_MCR_SELECTOR, mcr);
254 mcr_mask = GEN8_MCR_SLICE_MASK | GEN8_MCR_SUBSLICE_MASK;
255 mcr_ss = GEN8_MCR_SLICE(group) | GEN8_MCR_SUBSLICE(instance);
257 mcr = intel_uncore_read_fw(uncore, GEN8_MCR_SELECTOR);
262 intel_uncore_write_fw(uncore, GEN8_MCR_SELECTOR, mcr);
265 if (rw_flag == FW_REG_READ)
266 val = intel_uncore_read_fw(uncore, mcr_reg_cast(reg));
268 intel_uncore_write_fw(uncore, mcr_reg_cast(reg), value);
271 * For pre-MTL platforms, we need to restore the old value of the
272 * steering control register to ensure that implicit steering continues
273 * to behave as expected. For MTL and beyond, we need only reinstate
274 * the 'multicast' bit (and only if we did a write that cleared it).
276 if (GRAPHICS_VER_FULL(uncore->i915) >= IP_VER(12, 70) && rw_flag == FW_REG_WRITE)
277 intel_uncore_write_fw(uncore, MTL_MCR_SELECTOR, GEN11_MCR_MULTICAST);
278 else if (GRAPHICS_VER_FULL(uncore->i915) < IP_VER(12, 70))
279 intel_uncore_write_fw(uncore, GEN8_MCR_SELECTOR, old_mcr);
284 static u32 rw_with_mcr_steering(struct intel_gt *gt,
285 i915_mcr_reg_t reg, u8 rw_flag,
286 int group, int instance,
289 struct intel_uncore *uncore = gt->uncore;
290 enum forcewake_domains fw_domains;
294 fw_domains = intel_uncore_forcewake_for_reg(uncore, mcr_reg_cast(reg),
296 fw_domains |= intel_uncore_forcewake_for_reg(uncore,
298 FW_REG_READ | FW_REG_WRITE);
300 intel_gt_mcr_lock(gt, &flags);
301 spin_lock(&uncore->lock);
302 intel_uncore_forcewake_get__locked(uncore, fw_domains);
304 val = rw_with_mcr_steering_fw(gt, reg, rw_flag, group, instance, value);
306 intel_uncore_forcewake_put__locked(uncore, fw_domains);
307 spin_unlock(&uncore->lock);
308 intel_gt_mcr_unlock(gt, flags);
314 * intel_gt_mcr_lock - Acquire MCR steering lock
316 * @flags: storage to save IRQ flags to
318 * Performs locking to protect the steering for the duration of an MCR
319 * operation. On MTL and beyond, a hardware lock will also be taken to
320 * serialize access not only for the driver, but also for external hardware and
323 * Context: Takes gt->mcr_lock. uncore->lock should *not* be held when this
324 * function is called, although it may be acquired after this
327 void intel_gt_mcr_lock(struct intel_gt *gt, unsigned long *flags)
328 __acquires(>->mcr_lock)
330 unsigned long __flags;
333 lockdep_assert_not_held(>->uncore->lock);
336 * Starting with MTL, we need to coordinate not only with other
337 * driver threads, but also with hardware/firmware agents. A dedicated
338 * locking register is used.
340 if (GRAPHICS_VER_FULL(gt->i915) >= IP_VER(12, 70)) {
342 * The steering control and semaphore registers are inside an
343 * "always on" power domain with respect to RC6. However there
344 * are some issues if higher-level platform sleep states are
345 * entering/exiting at the same time these registers are
346 * accessed. Grabbing GT forcewake and holding it over the
347 * entire lock/steer/unlock cycle ensures that those sleep
348 * states have been fully exited before we access these
349 * registers. This wakeref will be released in the unlock
354 intel_uncore_forcewake_get(gt->uncore, FORCEWAKE_GT);
356 err = wait_for(intel_uncore_read_fw(gt->uncore,
357 MTL_STEER_SEMAPHORE) == 0x1, 100);
361 * Even on platforms with a hardware lock, we'll continue to grab
362 * a software spinlock too for lockdep purposes. If the hardware lock
363 * was already acquired, there should never be contention on the
366 spin_lock_irqsave(>->mcr_lock, __flags);
371 * In theory we should never fail to acquire the HW semaphore; this
372 * would indicate some hardware/firmware is misbehaving and not
373 * releasing it properly.
375 if (err == -ETIMEDOUT) {
376 gt_err_ratelimited(gt, "hardware MCR steering semaphore timed out");
377 add_taint_for_CI(gt->i915, TAINT_WARN); /* CI is now unreliable */
382 * intel_gt_mcr_unlock - Release MCR steering lock
384 * @flags: IRQ flags to restore
386 * Releases the lock acquired by intel_gt_mcr_lock().
388 * Context: Releases gt->mcr_lock
390 void intel_gt_mcr_unlock(struct intel_gt *gt, unsigned long flags)
391 __releases(>->mcr_lock)
393 spin_unlock_irqrestore(>->mcr_lock, flags);
395 if (GRAPHICS_VER_FULL(gt->i915) >= IP_VER(12, 70)) {
396 intel_uncore_write_fw(gt->uncore, MTL_STEER_SEMAPHORE, 0x1);
398 intel_uncore_forcewake_put(gt->uncore, FORCEWAKE_GT);
403 * intel_gt_mcr_lock_sanitize - Sanitize MCR steering lock
406 * This will be used to sanitize the initial status of the hardware lock
407 * during driver load and resume since there won't be any concurrent access
408 * from other agents at those times, but it's possible that boot firmware
409 * may have left the lock in a bad state.
412 void intel_gt_mcr_lock_sanitize(struct intel_gt *gt)
415 * This gets called at load/resume time, so we shouldn't be
416 * racing with other driver threads grabbing the mcr lock.
418 lockdep_assert_not_held(>->mcr_lock);
420 if (GRAPHICS_VER_FULL(gt->i915) >= IP_VER(12, 70))
421 intel_uncore_write_fw(gt->uncore, MTL_STEER_SEMAPHORE, 0x1);
425 * intel_gt_mcr_read - read a specific instance of an MCR register
427 * @reg: the MCR register to read
428 * @group: the MCR group
429 * @instance: the MCR instance
431 * Context: Takes and releases gt->mcr_lock
433 * Returns the value read from an MCR register after steering toward a specific
436 u32 intel_gt_mcr_read(struct intel_gt *gt,
438 int group, int instance)
440 return rw_with_mcr_steering(gt, reg, FW_REG_READ, group, instance, 0);
444 * intel_gt_mcr_unicast_write - write a specific instance of an MCR register
446 * @reg: the MCR register to write
447 * @value: value to write
448 * @group: the MCR group
449 * @instance: the MCR instance
451 * Write an MCR register in unicast mode after steering toward a specific
454 * Context: Calls a function that takes and releases gt->mcr_lock
456 void intel_gt_mcr_unicast_write(struct intel_gt *gt, i915_mcr_reg_t reg, u32 value,
457 int group, int instance)
459 rw_with_mcr_steering(gt, reg, FW_REG_WRITE, group, instance, value);
463 * intel_gt_mcr_multicast_write - write a value to all instances of an MCR register
465 * @reg: the MCR register to write
466 * @value: value to write
468 * Write an MCR register in multicast mode to update all instances.
470 * Context: Takes and releases gt->mcr_lock
472 void intel_gt_mcr_multicast_write(struct intel_gt *gt,
473 i915_mcr_reg_t reg, u32 value)
477 intel_gt_mcr_lock(gt, &flags);
480 * Ensure we have multicast behavior, just in case some non-i915 agent
481 * left the hardware in unicast mode.
483 if (GRAPHICS_VER_FULL(gt->i915) >= IP_VER(12, 70))
484 intel_uncore_write_fw(gt->uncore, MTL_MCR_SELECTOR, GEN11_MCR_MULTICAST);
486 intel_uncore_write(gt->uncore, mcr_reg_cast(reg), value);
488 intel_gt_mcr_unlock(gt, flags);
492 * intel_gt_mcr_multicast_write_fw - write a value to all instances of an MCR register
494 * @reg: the MCR register to write
495 * @value: value to write
497 * Write an MCR register in multicast mode to update all instances. This
498 * function assumes the caller is already holding any necessary forcewake
499 * domains; use intel_gt_mcr_multicast_write() in cases where forcewake should
500 * be obtained automatically.
502 * Context: The caller must hold gt->mcr_lock.
504 void intel_gt_mcr_multicast_write_fw(struct intel_gt *gt, i915_mcr_reg_t reg, u32 value)
506 lockdep_assert_held(>->mcr_lock);
509 * Ensure we have multicast behavior, just in case some non-i915 agent
510 * left the hardware in unicast mode.
512 if (GRAPHICS_VER_FULL(gt->i915) >= IP_VER(12, 70))
513 intel_uncore_write_fw(gt->uncore, MTL_MCR_SELECTOR, GEN11_MCR_MULTICAST);
515 intel_uncore_write_fw(gt->uncore, mcr_reg_cast(reg), value);
519 * intel_gt_mcr_multicast_rmw - Performs a multicast RMW operations
521 * @reg: the MCR register to read and write
522 * @clear: bits to clear during RMW
523 * @set: bits to set during RMW
525 * Performs a read-modify-write on an MCR register in a multicast manner.
526 * This operation only makes sense on MCR registers where all instances are
527 * expected to have the same value. The read will target any non-terminated
528 * instance and the write will be applied to all instances.
530 * This function assumes the caller is already holding any necessary forcewake
531 * domains; use intel_gt_mcr_multicast_rmw() in cases where forcewake should
532 * be obtained automatically.
534 * Context: Calls functions that take and release gt->mcr_lock
536 * Returns the old (unmodified) value read.
538 u32 intel_gt_mcr_multicast_rmw(struct intel_gt *gt, i915_mcr_reg_t reg,
541 u32 val = intel_gt_mcr_read_any(gt, reg);
543 intel_gt_mcr_multicast_write(gt, reg, (val & ~clear) | set);
549 * reg_needs_read_steering - determine whether a register read requires
552 * @reg: the register to check steering requirements for
553 * @type: type of multicast steering to check
555 * Determines whether @reg needs explicit steering of a specific type for
558 * Returns false if @reg does not belong to a register range of the given
559 * steering type, or if the default (subslice-based) steering IDs are suitable
560 * for @type steering too.
562 static bool reg_needs_read_steering(struct intel_gt *gt,
564 enum intel_steering_type type)
566 u32 offset = i915_mmio_reg_offset(reg);
567 const struct intel_mmio_range *entry;
569 if (likely(!gt->steering_table[type]))
572 if (IS_GSI_REG(offset))
573 offset += gt->uncore->gsi_offset;
575 for (entry = gt->steering_table[type]; entry->end; entry++) {
576 if (offset >= entry->start && offset <= entry->end)
584 * get_nonterminated_steering - determines valid IDs for a class of MCR steering
586 * @type: multicast register type
587 * @group: Group ID returned
588 * @instance: Instance ID returned
590 * Determines group and instance values that will steer reads of the specified
591 * MCR class to a non-terminated instance.
593 static void get_nonterminated_steering(struct intel_gt *gt,
594 enum intel_steering_type type,
595 u8 *group, u8 *instance)
601 *group = 0; /* unused */
602 *instance = __ffs(gt->info.l3bank_mask);
605 GEM_WARN_ON(!HAS_MSLICE_STEERING(gt->i915));
606 *group = __ffs(gt->info.mslice_mask);
607 *instance = 0; /* unused */
611 * An LNCF is always present if its mslice is present, so we
612 * can safely just steer to LNCF 0 in all cases.
614 GEM_WARN_ON(!HAS_MSLICE_STEERING(gt->i915));
615 *group = __ffs(gt->info.mslice_mask) << 1;
616 *instance = 0; /* unused */
619 *group = IS_DG2(gt->i915) ? 1 : 0;
623 dss = intel_sseu_find_first_xehp_dss(>->info.sseu, 0, 0);
624 *group = dss / GEN_DSS_PER_GSLICE;
625 *instance = dss % GEN_DSS_PER_GSLICE;
629 * There are a lot of MCR types for which instance (0, 0)
630 * will always provide a non-terminated value.
636 if ((VDBOX_MASK(gt) | VEBOX_MASK(gt) | gt->info.sfc_mask) & BIT(0))
650 * intel_gt_mcr_get_nonterminated_steering - find group/instance values that
651 * will steer a register to a non-terminated instance
653 * @reg: register for which the steering is required
654 * @group: return variable for group steering
655 * @instance: return variable for instance steering
657 * This function returns a group/instance pair that is guaranteed to work for
658 * read steering of the given register. Note that a value will be returned even
659 * if the register is not replicated and therefore does not actually require
662 void intel_gt_mcr_get_nonterminated_steering(struct intel_gt *gt,
664 u8 *group, u8 *instance)
668 for (type = 0; type < NUM_STEERING_TYPES; type++) {
669 if (reg_needs_read_steering(gt, reg, type)) {
670 get_nonterminated_steering(gt, type, group, instance);
675 *group = gt->default_steering.groupid;
676 *instance = gt->default_steering.instanceid;
680 * intel_gt_mcr_read_any_fw - reads one instance of an MCR register
682 * @reg: register to read
684 * Reads a GT MCR register. The read will be steered to a non-terminated
685 * instance (i.e., one that isn't fused off or powered down by power gating).
686 * This function assumes the caller is already holding any necessary forcewake
687 * domains; use intel_gt_mcr_read_any() in cases where forcewake should be
688 * obtained automatically.
690 * Context: The caller must hold gt->mcr_lock.
692 * Returns the value from a non-terminated instance of @reg.
694 u32 intel_gt_mcr_read_any_fw(struct intel_gt *gt, i915_mcr_reg_t reg)
699 lockdep_assert_held(>->mcr_lock);
701 for (type = 0; type < NUM_STEERING_TYPES; type++) {
702 if (reg_needs_read_steering(gt, reg, type)) {
703 get_nonterminated_steering(gt, type, &group, &instance);
704 return rw_with_mcr_steering_fw(gt, reg,
710 return intel_uncore_read_fw(gt->uncore, mcr_reg_cast(reg));
714 * intel_gt_mcr_read_any - reads one instance of an MCR register
716 * @reg: register to read
718 * Reads a GT MCR register. The read will be steered to a non-terminated
719 * instance (i.e., one that isn't fused off or powered down by power gating).
721 * Context: Calls a function that takes and releases gt->mcr_lock.
723 * Returns the value from a non-terminated instance of @reg.
725 u32 intel_gt_mcr_read_any(struct intel_gt *gt, i915_mcr_reg_t reg)
730 for (type = 0; type < NUM_STEERING_TYPES; type++) {
731 if (reg_needs_read_steering(gt, reg, type)) {
732 get_nonterminated_steering(gt, type, &group, &instance);
733 return rw_with_mcr_steering(gt, reg,
739 return intel_uncore_read(gt->uncore, mcr_reg_cast(reg));
742 static void report_steering_type(struct drm_printer *p,
744 enum intel_steering_type type,
747 const struct intel_mmio_range *entry;
750 BUILD_BUG_ON(ARRAY_SIZE(intel_steering_types) != NUM_STEERING_TYPES);
752 if (!gt->steering_table[type]) {
753 drm_printf(p, "%s steering: uses default steering\n",
754 intel_steering_types[type]);
758 get_nonterminated_steering(gt, type, &group, &instance);
759 drm_printf(p, "%s steering: group=0x%x, instance=0x%x\n",
760 intel_steering_types[type], group, instance);
765 for (entry = gt->steering_table[type]; entry->end; entry++)
766 drm_printf(p, "\t0x%06x - 0x%06x\n", entry->start, entry->end);
769 void intel_gt_mcr_report_steering(struct drm_printer *p, struct intel_gt *gt,
773 * Starting with MTL we no longer have default steering;
774 * all ranges are explicitly steered.
776 if (GRAPHICS_VER_FULL(gt->i915) < IP_VER(12, 70))
777 drm_printf(p, "Default steering: group=0x%x, instance=0x%x\n",
778 gt->default_steering.groupid,
779 gt->default_steering.instanceid);
781 if (GRAPHICS_VER_FULL(gt->i915) >= IP_VER(12, 70)) {
782 for (int i = 0; i < NUM_STEERING_TYPES; i++)
783 if (gt->steering_table[i])
784 report_steering_type(p, gt, i, dump_table);
785 } else if (HAS_MSLICE_STEERING(gt->i915)) {
786 report_steering_type(p, gt, MSLICE, dump_table);
787 report_steering_type(p, gt, LNCF, dump_table);
792 * intel_gt_mcr_get_ss_steering - returns the group/instance steering for a SS
794 * @dss: DSS ID to obtain steering for
795 * @group: pointer to storage for steering group ID
796 * @instance: pointer to storage for steering instance ID
798 * Returns the steering IDs (via the @group and @instance parameters) that
799 * correspond to a specific subslice/DSS ID.
801 void intel_gt_mcr_get_ss_steering(struct intel_gt *gt, unsigned int dss,
802 unsigned int *group, unsigned int *instance)
804 if (GRAPHICS_VER_FULL(gt->i915) >= IP_VER(12, 55)) {
805 *group = dss / GEN_DSS_PER_GSLICE;
806 *instance = dss % GEN_DSS_PER_GSLICE;
808 *group = dss / GEN_MAX_SS_PER_HSW_SLICE;
809 *instance = dss % GEN_MAX_SS_PER_HSW_SLICE;
815 * intel_gt_mcr_wait_for_reg - wait until MCR register matches expected state
817 * @reg: the register to read
818 * @mask: mask to apply to register value
819 * @value: value to wait for
820 * @fast_timeout_us: fast timeout in microsecond for atomic/tight wait
821 * @slow_timeout_ms: slow timeout in millisecond
823 * This routine waits until the target register @reg contains the expected
824 * @value after applying the @mask, i.e. it waits until ::
826 * (intel_gt_mcr_read_any_fw(gt, reg) & mask) == value
828 * Otherwise, the wait will timeout after @slow_timeout_ms milliseconds.
829 * For atomic context @slow_timeout_ms must be zero and @fast_timeout_us
830 * must be not larger than 20,0000 microseconds.
832 * This function is basically an MCR-friendly version of
833 * __intel_wait_for_register_fw(). Generally this function will only be used
834 * on GAM registers which are a bit special --- although they're MCR registers,
835 * reads (e.g., waiting for status updates) are always directed to the primary
838 * Note that this routine assumes the caller holds forcewake asserted, it is
839 * not suitable for very long waits.
841 * Context: Calls a function that takes and releases gt->mcr_lock
842 * Return: 0 if the register matches the desired condition, or -ETIMEDOUT.
844 int intel_gt_mcr_wait_for_reg(struct intel_gt *gt,
848 unsigned int fast_timeout_us,
849 unsigned int slow_timeout_ms)
853 lockdep_assert_not_held(>->mcr_lock);
855 #define done ((intel_gt_mcr_read_any(gt, reg) & mask) == value)
857 /* Catch any overuse of this function */
858 might_sleep_if(slow_timeout_ms);
859 GEM_BUG_ON(fast_timeout_us > 20000);
860 GEM_BUG_ON(!fast_timeout_us && !slow_timeout_ms);
863 if (fast_timeout_us && fast_timeout_us <= 20000)
864 ret = _wait_for_atomic(done, fast_timeout_us, 0);
865 if (ret && slow_timeout_ms)
866 ret = wait_for(done, slow_timeout_ms);