Skip to content

Commit fa171d4

Browse files
drm/xe/guc: Fix uninitialised count in GuC load debug prints
The debug prints about how long the GuC load takes have a loop counter. However that was neither initialised nor incremented! Plus, counting loops is no longer meaningful given the wait function returns early for any change in the status value. So fix it to only count loops due to actual timeouts. Signed-off-by: John Harrison <John.C.Harrison@Intel.com> Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202405250151.IbH0l8FG-lkp@intel.com/ Fixes: b0ac1b4 ("drm/xe/guc: Port over the slow GuC loading support from i915") Cc: John Harrison <John.C.Harrison@Intel.com> Cc: Lucas De Marchi <lucas.demarchi@intel.com> Cc: Oded Gabbay <ogabbay@kernel.org> Cc: "Thomas Hellström" <thomas.hellstrom@linux.intel.com> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com> Cc: Matthew Brost <matthew.brost@intel.com> Cc: Matt Roper <matthew.d.roper@intel.com> Cc: Michal Wajdeczko <michal.wajdeczko@intel.com> Cc: Fei Yang <fei.yang@intel.com> Cc: intel-xe@lists.freedesktop.org Reviewed-by: Matt Roper <matthew.d.roper@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20240524202603.4011656-1-John.C.Harrison@Intel.com
1 parent 8de6625 commit fa171d4

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

drivers/gpu/drm/xe/xe_guc.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ static void guc_wait_ucode(struct xe_guc *guc)
591591
ktime_t before, after, delta;
592592
int load_done;
593593
u32 status = 0;
594-
int count;
594+
int count = 0;
595595
u64 delta_ms;
596596
u32 before_freq;
597597

@@ -604,6 +604,7 @@ static void guc_wait_ucode(struct xe_guc *guc)
604604
*/
605605
do {
606606
u32 last_status = status & (GS_UKERNEL_MASK | GS_BOOTROM_MASK);
607+
int ret;
607608

608609
/*
609610
* Wait for any change (intermediate or terminal) in the status register.
@@ -612,9 +613,10 @@ static void guc_wait_ucode(struct xe_guc *guc)
612613
* timeouts rather than allowing a huge timeout each time. So basically, need
613614
* to treat a timeout no different to a value change.
614615
*/
615-
xe_mmio_wait32_not(gt, GUC_STATUS, GS_UKERNEL_MASK | GS_BOOTROM_MASK,
616-
last_status, 1000 * 1000, &status, false);
617-
616+
ret = xe_mmio_wait32_not(gt, GUC_STATUS, GS_UKERNEL_MASK | GS_BOOTROM_MASK,
617+
last_status, 1000 * 1000, &status, false);
618+
if (ret < 0)
619+
count++;
618620
after = ktime_get();
619621
delta = ktime_sub(after, before);
620622
delta_ms = ktime_to_ms(delta);
@@ -626,7 +628,7 @@ static void guc_wait_ucode(struct xe_guc *guc)
626628
if (delta_ms >= (GUC_LOAD_RETRY_LIMIT * 1000))
627629
break;
628630

629-
xe_gt_dbg(gt, "load still in progress, count = %d, freq = %dMHz (req %dMHz), status = 0x%08X [0x%02X/%02X]\n",
631+
xe_gt_dbg(gt, "load still in progress, timeouts = %d, freq = %dMHz (req %dMHz), status = 0x%08X [0x%02X/%02X]\n",
630632
count, xe_guc_pc_get_act_freq(guc_pc),
631633
guc_pc_get_cur_freq(guc_pc), status,
632634
REG_FIELD_GET(GS_BOOTROM_MASK, status),
@@ -678,13 +680,13 @@ static void guc_wait_ucode(struct xe_guc *guc)
678680

679681
xe_device_declare_wedged(gt_to_xe(gt));
680682
} else if (delta_ms > GUC_LOAD_TIME_WARN_MS) {
681-
xe_gt_warn(gt, "excessive init time: %lldms! [status = 0x%08X, count = %d]\n",
683+
xe_gt_warn(gt, "excessive init time: %lldms! [status = 0x%08X, timeouts = %d]\n",
682684
delta_ms, status, count);
683685
xe_gt_warn(gt, "excessive init time: [freq = %dMHz (req = %dMHz), before = %dMHz, perf_limit_reasons = 0x%08X]\n",
684686
xe_guc_pc_get_act_freq(guc_pc), guc_pc_get_cur_freq(guc_pc),
685687
before_freq, xe_gt_throttle_get_limit_reasons(gt));
686688
} else {
687-
xe_gt_dbg(gt, "init took %lldms, freq = %dMHz (req = %dMHz), before = %dMHz, status = 0x%08X, count = %d\n",
689+
xe_gt_dbg(gt, "init took %lldms, freq = %dMHz (req = %dMHz), before = %dMHz, status = 0x%08X, timeouts = %d\n",
688690
delta_ms, xe_guc_pc_get_act_freq(guc_pc), guc_pc_get_cur_freq(guc_pc),
689691
before_freq, status, count);
690692
}

0 commit comments

Comments
 (0)