Skip to content

Commit abf32d8

Browse files
mlankhorstgregkh
authored andcommitted
drm/xe: Wire up device shutdown handler
[ Upstream commit 501d799 ] The system is turning off, and we should probably put the device in a safe power state. We don't need to evict VRAM or suspend running jobs to a safe state, as the device is rebooted anyway. This does not imply the system is necessarily reset, as we can kexec into a new kernel. Without shutting down, things like USB Type-C may mysteriously start failing. References: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/3500 Signed-off-by: Maarten Lankhorst <[email protected]> [mlankhorst: Add !xe_driver_flr_disabled assert] Reviewed-by: Rodrigo Vivi <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Stable-dep-of: 16c1241 ("drm/xe/bmg: Update Wa_16023588340") Signed-off-by: Sasha Levin <[email protected]>
1 parent 0f8df5d commit abf32d8

File tree

5 files changed

+89
-6
lines changed

5 files changed

+89
-6
lines changed

drivers/gpu/drm/xe/display/xe_display.c

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,36 @@ void xe_display_pm_suspend(struct xe_device *xe)
352352
__xe_display_pm_suspend(xe, false);
353353
}
354354

355+
void xe_display_pm_shutdown(struct xe_device *xe)
356+
{
357+
struct intel_display *display = &xe->display;
358+
359+
if (!xe->info.probe_display)
360+
return;
361+
362+
intel_power_domains_disable(xe);
363+
intel_fbdev_set_suspend(&xe->drm, FBINFO_STATE_SUSPENDED, true);
364+
if (has_display(xe)) {
365+
drm_kms_helper_poll_disable(&xe->drm);
366+
intel_display_driver_disable_user_access(xe);
367+
intel_display_driver_suspend(xe);
368+
}
369+
370+
xe_display_flush_cleanup_work(xe);
371+
intel_dp_mst_suspend(xe);
372+
intel_hpd_cancel_work(xe);
373+
374+
if (has_display(xe))
375+
intel_display_driver_suspend_access(xe);
376+
377+
intel_encoder_suspend_all(display);
378+
intel_encoder_shutdown_all(display);
379+
380+
intel_opregion_suspend(display, PCI_D3cold);
381+
382+
intel_dmc_suspend(xe);
383+
}
384+
355385
void xe_display_pm_runtime_suspend(struct xe_device *xe)
356386
{
357387
if (!xe->info.probe_display)
@@ -376,6 +406,19 @@ void xe_display_pm_suspend_late(struct xe_device *xe)
376406
intel_display_power_suspend_late(xe);
377407
}
378408

409+
void xe_display_pm_shutdown_late(struct xe_device *xe)
410+
{
411+
if (!xe->info.probe_display)
412+
return;
413+
414+
/*
415+
* The only requirement is to reboot with display DC states disabled,
416+
* for now leaving all display power wells in the INIT power domain
417+
* enabled.
418+
*/
419+
intel_power_domains_driver_remove(xe);
420+
}
421+
379422
void xe_display_pm_resume_early(struct xe_device *xe)
380423
{
381424
if (!xe->info.probe_display)

drivers/gpu/drm/xe/display/xe_display.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ void xe_display_irq_reset(struct xe_device *xe);
3535
void xe_display_irq_postinstall(struct xe_device *xe, struct xe_gt *gt);
3636

3737
void xe_display_pm_suspend(struct xe_device *xe);
38+
void xe_display_pm_shutdown(struct xe_device *xe);
3839
void xe_display_pm_suspend_late(struct xe_device *xe);
40+
void xe_display_pm_shutdown_late(struct xe_device *xe);
3941
void xe_display_pm_resume_early(struct xe_device *xe);
4042
void xe_display_pm_resume(struct xe_device *xe);
4143
void xe_display_pm_runtime_suspend(struct xe_device *xe);
@@ -66,7 +68,9 @@ static inline void xe_display_irq_reset(struct xe_device *xe) {}
6668
static inline void xe_display_irq_postinstall(struct xe_device *xe, struct xe_gt *gt) {}
6769

6870
static inline void xe_display_pm_suspend(struct xe_device *xe) {}
71+
static inline void xe_display_pm_shutdown(struct xe_device *xe) {}
6972
static inline void xe_display_pm_suspend_late(struct xe_device *xe) {}
73+
static inline void xe_display_pm_shutdown_late(struct xe_device *xe) {}
7074
static inline void xe_display_pm_resume_early(struct xe_device *xe) {}
7175
static inline void xe_display_pm_resume(struct xe_device *xe) {}
7276
static inline void xe_display_pm_runtime_suspend(struct xe_device *xe) {}

drivers/gpu/drm/xe/xe_device.c

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,11 @@ struct xe_device *xe_device_create(struct pci_dev *pdev,
374374
return ERR_PTR(err);
375375
}
376376

377+
static bool xe_driver_flr_disabled(struct xe_device *xe)
378+
{
379+
return xe_mmio_read32(xe_root_mmio_gt(xe), GU_CNTL_PROTECTED) & DRIVERINT_FLR_DIS;
380+
}
381+
377382
/*
378383
* The driver-initiated FLR is the highest level of reset that we can trigger
379384
* from within the driver. It is different from the PCI FLR in that it doesn't
@@ -387,17 +392,12 @@ struct xe_device *xe_device_create(struct pci_dev *pdev,
387392
* if/when a new instance of i915 is bound to the device it will do a full
388393
* re-init anyway.
389394
*/
390-
static void xe_driver_flr(struct xe_device *xe)
395+
static void __xe_driver_flr(struct xe_device *xe)
391396
{
392397
const unsigned int flr_timeout = 3 * MICRO; /* specs recommend a 3s wait */
393398
struct xe_gt *gt = xe_root_mmio_gt(xe);
394399
int ret;
395400

396-
if (xe_mmio_read32(gt, GU_CNTL_PROTECTED) & DRIVERINT_FLR_DIS) {
397-
drm_info_once(&xe->drm, "BIOS Disabled Driver-FLR\n");
398-
return;
399-
}
400-
401401
drm_dbg(&xe->drm, "Triggering Driver-FLR\n");
402402

403403
/*
@@ -438,6 +438,16 @@ static void xe_driver_flr(struct xe_device *xe)
438438
xe_mmio_write32(gt, GU_DEBUG, DRIVERFLR_STATUS);
439439
}
440440

441+
static void xe_driver_flr(struct xe_device *xe)
442+
{
443+
if (xe_driver_flr_disabled(xe)) {
444+
drm_info_once(&xe->drm, "BIOS Disabled Driver-FLR\n");
445+
return;
446+
}
447+
448+
__xe_driver_flr(xe);
449+
}
450+
441451
static void xe_driver_flr_fini(void *arg)
442452
{
443453
struct xe_device *xe = arg;
@@ -797,6 +807,24 @@ void xe_device_remove(struct xe_device *xe)
797807

798808
void xe_device_shutdown(struct xe_device *xe)
799809
{
810+
struct xe_gt *gt;
811+
u8 id;
812+
813+
drm_dbg(&xe->drm, "Shutting down device\n");
814+
815+
if (xe_driver_flr_disabled(xe)) {
816+
xe_display_pm_shutdown(xe);
817+
818+
xe_irq_suspend(xe);
819+
820+
for_each_gt(gt, xe, id)
821+
xe_gt_shutdown(gt);
822+
823+
xe_display_pm_shutdown_late(xe);
824+
} else {
825+
/* BOOM! */
826+
__xe_driver_flr(xe);
827+
}
800828
}
801829

802830
/**

drivers/gpu/drm/xe/xe_gt.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,13 @@ int xe_gt_suspend(struct xe_gt *gt)
865865
return err;
866866
}
867867

868+
void xe_gt_shutdown(struct xe_gt *gt)
869+
{
870+
xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL);
871+
do_gt_reset(gt);
872+
xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL);
873+
}
874+
868875
/**
869876
* xe_gt_sanitize_freq() - Restore saved frequencies if necessary.
870877
* @gt: the GT object

drivers/gpu/drm/xe/xe_gt.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ void xe_gt_record_user_engines(struct xe_gt *gt);
4848

4949
void xe_gt_suspend_prepare(struct xe_gt *gt);
5050
int xe_gt_suspend(struct xe_gt *gt);
51+
void xe_gt_shutdown(struct xe_gt *gt);
5152
int xe_gt_resume(struct xe_gt *gt);
5253
void xe_gt_reset_async(struct xe_gt *gt);
5354
void xe_gt_sanitize(struct xe_gt *gt);

0 commit comments

Comments
 (0)