Skip to content

Commit 260ca2e

Browse files
dceraologregkh
authored andcommitted
drm/xe/gsc: do not flush the GSC worker from the reset path
commit 03552d8 upstream. The workqueue used for the reset worker is marked as WQ_MEM_RECLAIM, while the GSC one isn't (and can't be as we need to do memory allocations in the gsc worker). Therefore, we can't flush the latter from the former. The reason why we had such a flush was to avoid interrupting either the GSC FW load or in progress GSC proxy operations. GSC proxy operations fall into 2 categories: 1) GSC proxy init: this only happens once immediately after GSC FW load and does not support being interrupted. The only way to recover from an interruption of the proxy init is to do an FLR and re-load the GSC. 2) GSC proxy request: this can happen in response to a request that the driver sends to the GSC. If this is interrupted, the GSC FW will timeout and the driver request will be failed, but overall the GSC will keep working fine. Flushing the work allowed us to avoid interruption in both cases (unless the hang came from the GSC engine itself, in which case we're toast anyway). However, a failure on a proxy request is tolerable if we're in a scenario where we're triggering a GT reset (i.e., something is already gone pretty wrong), so what we really need to avoid is interrupting the init flow, which we can do by polling on the register that reports when the proxy init is complete (as that ensure us that all the load and init operations have been completed). Note that during suspend we still want to do a flush of the worker to make sure it completes any operations involving the HW before the power is cut. v2: fix spelling in commit msg, rename waiter function (Julia) Fixes: dd0e89e ("drm/xe/gsc: GSC FW load") Closes: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/4830 Signed-off-by: Daniele Ceraolo Spurio <[email protected]> Cc: John Harrison <[email protected]> Cc: Alan Previn <[email protected]> Cc: <[email protected]> # v6.8+ Reviewed-by: Julia Filipchuk <[email protected]> Link: https://lore.kernel.org/r/[email protected] (cherry picked from commit 12370bf) Signed-off-by: Lucas De Marchi <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 6b2d1fb commit 260ca2e

File tree

7 files changed

+44
-2
lines changed

7 files changed

+44
-2
lines changed

drivers/gpu/drm/xe/xe_gsc.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,28 @@ void xe_gsc_remove(struct xe_gsc *gsc)
564564
xe_gsc_proxy_remove(gsc);
565565
}
566566

567+
void xe_gsc_stop_prepare(struct xe_gsc *gsc)
568+
{
569+
struct xe_gt *gt = gsc_to_gt(gsc);
570+
int ret;
571+
572+
if (!xe_uc_fw_is_loadable(&gsc->fw) || xe_uc_fw_is_in_error_state(&gsc->fw))
573+
return;
574+
575+
xe_force_wake_assert_held(gt_to_fw(gt), XE_FW_GSC);
576+
577+
/*
578+
* If the GSC FW load or the proxy init are interrupted, the only way
579+
* to recover it is to do an FLR and reload the GSC from scratch.
580+
* Therefore, let's wait for the init to complete before stopping
581+
* operations. The proxy init is the last step, so we can just wait on
582+
* that
583+
*/
584+
ret = xe_gsc_wait_for_proxy_init_done(gsc);
585+
if (ret)
586+
xe_gt_err(gt, "failed to wait for GSC init completion before uc stop\n");
587+
}
588+
567589
/*
568590
* wa_14015076503: if the GSC FW is loaded, we need to alert it before doing a
569591
* GSC engine reset by writing a notification bit in the GS1 register and then

drivers/gpu/drm/xe/xe_gsc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ struct xe_hw_engine;
1616
int xe_gsc_init(struct xe_gsc *gsc);
1717
int xe_gsc_init_post_hwconfig(struct xe_gsc *gsc);
1818
void xe_gsc_wait_for_worker_completion(struct xe_gsc *gsc);
19+
void xe_gsc_stop_prepare(struct xe_gsc *gsc);
1920
void xe_gsc_load_start(struct xe_gsc *gsc);
2021
void xe_gsc_remove(struct xe_gsc *gsc);
2122
void xe_gsc_hwe_irq_handler(struct xe_hw_engine *hwe, u16 intr_vec);

drivers/gpu/drm/xe/xe_gsc_proxy.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,17 @@ bool xe_gsc_proxy_init_done(struct xe_gsc *gsc)
7171
HECI1_FWSTS1_PROXY_STATE_NORMAL;
7272
}
7373

74+
int xe_gsc_wait_for_proxy_init_done(struct xe_gsc *gsc)
75+
{
76+
struct xe_gt *gt = gsc_to_gt(gsc);
77+
78+
/* Proxy init can take up to 500ms, so wait double that for safety */
79+
return xe_mmio_wait32(gt, HECI_FWSTS1(MTL_GSC_HECI1_BASE),
80+
HECI1_FWSTS1_CURRENT_STATE,
81+
HECI1_FWSTS1_PROXY_STATE_NORMAL,
82+
USEC_PER_SEC, NULL, false);
83+
}
84+
7485
static void __gsc_proxy_irq_rmw(struct xe_gsc *gsc, u32 clr, u32 set)
7586
{
7687
struct xe_gt *gt = gsc_to_gt(gsc);

drivers/gpu/drm/xe/xe_gsc_proxy.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ struct xe_gsc;
1313
int xe_gsc_proxy_init(struct xe_gsc *gsc);
1414
bool xe_gsc_proxy_init_done(struct xe_gsc *gsc);
1515
void xe_gsc_proxy_remove(struct xe_gsc *gsc);
16+
int xe_gsc_wait_for_proxy_init_done(struct xe_gsc *gsc);
1617
int xe_gsc_proxy_start(struct xe_gsc *gsc);
1718

1819
int xe_gsc_proxy_request_handler(struct xe_gsc *gsc);

drivers/gpu/drm/xe/xe_gt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,7 @@ void xe_gt_suspend_prepare(struct xe_gt *gt)
828828
{
829829
XE_WARN_ON(xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL));
830830

831-
xe_uc_stop_prepare(&gt->uc);
831+
xe_uc_suspend_prepare(&gt->uc);
832832

833833
XE_WARN_ON(xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL));
834834
}

drivers/gpu/drm/xe/xe_uc.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ void xe_uc_gucrc_disable(struct xe_uc *uc)
241241

242242
void xe_uc_stop_prepare(struct xe_uc *uc)
243243
{
244-
xe_gsc_wait_for_worker_completion(&uc->gsc);
244+
xe_gsc_stop_prepare(&uc->gsc);
245245
xe_guc_stop_prepare(&uc->guc);
246246
}
247247

@@ -275,6 +275,12 @@ static void uc_reset_wait(struct xe_uc *uc)
275275
goto again;
276276
}
277277

278+
void xe_uc_suspend_prepare(struct xe_uc *uc)
279+
{
280+
xe_gsc_wait_for_worker_completion(&uc->gsc);
281+
xe_guc_stop_prepare(&uc->guc);
282+
}
283+
278284
int xe_uc_suspend(struct xe_uc *uc)
279285
{
280286
/* GuC submission not enabled, nothing to do */

drivers/gpu/drm/xe/xe_uc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ int xe_uc_reset_prepare(struct xe_uc *uc);
1818
void xe_uc_stop_prepare(struct xe_uc *uc);
1919
void xe_uc_stop(struct xe_uc *uc);
2020
int xe_uc_start(struct xe_uc *uc);
21+
void xe_uc_suspend_prepare(struct xe_uc *uc);
2122
int xe_uc_suspend(struct xe_uc *uc);
2223
int xe_uc_sanitize_reset(struct xe_uc *uc);
2324
void xe_uc_remove(struct xe_uc *uc);

0 commit comments

Comments
 (0)