Skip to content

Commit c3015eb

Browse files
committed
drm/i915/dg2: wait for HuC load completion before running selftests
On DG2, submissions to VCS engines tied to a gem context are blocked until the HuC is loaded. Since some selftests do use a gem context, wait for the HuC load to complete before running the tests to avoid contamination. Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/10564 Signed-off-by: Daniele Ceraolo Spurio <[email protected]> Cc: John Harrison <[email protected]> Reviewed-by: John Harrison <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 2af231e commit c3015eb

File tree

1 file changed

+32
-4
lines changed

1 file changed

+32
-4
lines changed

drivers/gpu/drm/i915/selftests/i915_selftest.c

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,30 @@ __wait_gsc_proxy_completed(struct drm_i915_private *i915)
154154
pr_warn(DRIVER_NAME "Timed out waiting for gsc_proxy_completion!\n");
155155
}
156156

157+
static void
158+
__wait_gsc_huc_load_completed(struct drm_i915_private *i915)
159+
{
160+
/* this only applies to DG2, so we only care about GT0 */
161+
struct intel_huc *huc = &to_gt(i915)->uc.huc;
162+
bool need_to_wait = (IS_ENABLED(CONFIG_INTEL_MEI_PXP) &&
163+
intel_huc_wait_required(huc));
164+
/*
165+
* The GSC and PXP mei bringup depends on the kernel boot ordering, so
166+
* to account for the worst case scenario the HuC code waits for up to
167+
* 10s for the GSC driver to load and then another 5s for the PXP
168+
* component to bind before giving up, even though those steps normally
169+
* complete in less than a second from the i915 load. We match that
170+
* timeout here, but we expect to bail early due to the fence being
171+
* signalled even in a failure case, as it is extremely unlikely that
172+
* both components will use their full timeout.
173+
*/
174+
unsigned long timeout_ms = 15000;
175+
176+
if (need_to_wait &&
177+
wait_for(i915_sw_fence_done(&huc->delayed_load.fence), timeout_ms))
178+
pr_warn(DRIVER_NAME "Timed out waiting for huc load via GSC!\n");
179+
}
180+
157181
static int __run_selftests(const char *name,
158182
struct selftest *st,
159183
unsigned int count,
@@ -228,14 +252,16 @@ int i915_mock_selftests(void)
228252

229253
int i915_live_selftests(struct pci_dev *pdev)
230254
{
255+
struct drm_i915_private *i915 = pdev_to_i915(pdev);
231256
int err;
232257

233258
if (!i915_selftest.live)
234259
return 0;
235260

236-
__wait_gsc_proxy_completed(pdev_to_i915(pdev));
261+
__wait_gsc_proxy_completed(i915);
262+
__wait_gsc_huc_load_completed(i915);
237263

238-
err = run_selftests(live, pdev_to_i915(pdev));
264+
err = run_selftests(live, i915);
239265
if (err) {
240266
i915_selftest.live = err;
241267
return err;
@@ -251,14 +277,16 @@ int i915_live_selftests(struct pci_dev *pdev)
251277

252278
int i915_perf_selftests(struct pci_dev *pdev)
253279
{
280+
struct drm_i915_private *i915 = pdev_to_i915(pdev);
254281
int err;
255282

256283
if (!i915_selftest.perf)
257284
return 0;
258285

259-
__wait_gsc_proxy_completed(pdev_to_i915(pdev));
286+
__wait_gsc_proxy_completed(i915);
287+
__wait_gsc_huc_load_completed(i915);
260288

261-
err = run_selftests(perf, pdev_to_i915(pdev));
289+
err = run_selftests(perf, i915);
262290
if (err) {
263291
i915_selftest.perf = err;
264292
return err;

0 commit comments

Comments
 (0)