]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/xe: Prepare display for D3Cold
authorRodrigo Vivi <rodrigo.vivi@intel.com>
Wed, 22 May 2024 17:01:03 +0000 (13:01 -0400)
committerRodrigo Vivi <rodrigo.vivi@intel.com>
Thu, 23 May 2024 15:54:07 +0000 (11:54 -0400)
Prepare power-well and DC handling for a full power
lost during D3Cold, then sanitize it upon D3->D0.
Otherwise we get a bunch of state mismatch.

Ideally we could leave DC9 enabled and wouldn't need
to move DC9->DC0 on every runtime resume, however,
the disable_DC is part of the power-well checks and
intrinsic to the dc_off power well. In the future that
can be detangled so we can have even bigger power savings.
But for now, let's focus on getting a D3Cold, which saves
much more power by itself.

v2: create new functions to avoid full-suspend-resume path,
which would result in a deadlock between xe_gem_fault and the
modeset-ioctl.

v3: Only avoid the full modeset to avoid the race, for a more
robust suspend-resume.

Cc: Anshuman Gupta <anshuman.gupta@intel.com>
Cc: Uma Shankar <uma.shankar@intel.com>
Tested-by: Francois Dugast <francois.dugast@intel.com>
Reviewed-by: Anshuman Gupta <anshuman.gupta@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240522170105.327472-5-rodrigo.vivi@intel.com
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
drivers/gpu/drm/xe/display/xe_display.c
drivers/gpu/drm/xe/display/xe_display.h
drivers/gpu/drm/xe/xe_pm.c

index 347e625b53be87d476dc665a41a6a5bbf15f353b..2a9b4a4f2e71947405ea98dad59de320fcea085e 100644 (file)
@@ -308,7 +308,7 @@ static bool suspend_to_idle(void)
        return false;
 }
 
-void xe_display_pm_suspend(struct xe_device *xe)
+void xe_display_pm_suspend(struct xe_device *xe, bool runtime)
 {
        bool s2idle = suspend_to_idle();
        if (!xe->info.enable_display)
@@ -322,7 +322,8 @@ void xe_display_pm_suspend(struct xe_device *xe)
        if (has_display(xe))
                drm_kms_helper_poll_disable(&xe->drm);
 
-       intel_display_driver_suspend(xe);
+       if (!runtime)
+               intel_display_driver_suspend(xe);
 
        intel_dp_mst_suspend(xe);
 
@@ -358,7 +359,7 @@ void xe_display_pm_resume_early(struct xe_device *xe)
        intel_power_domains_resume(xe);
 }
 
-void xe_display_pm_resume(struct xe_device *xe)
+void xe_display_pm_resume(struct xe_device *xe, bool runtime)
 {
        if (!xe->info.enable_display)
                return;
@@ -373,7 +374,8 @@ void xe_display_pm_resume(struct xe_device *xe)
 
        /* MST sideband requires HPD interrupts enabled */
        intel_dp_mst_resume(xe);
-       intel_display_driver_resume(xe);
+       if (!runtime)
+               intel_display_driver_resume(xe);
 
        intel_hpd_poll_disable(xe);
        if (has_display(xe))
index e4085f841aa78c7e0cbd6886087e417670574161..000fb5799df54f8b886fb37f3e00b89450c4e4bc 100644 (file)
@@ -34,10 +34,10 @@ void xe_display_irq_enable(struct xe_device *xe, u32 gu_misc_iir);
 void xe_display_irq_reset(struct xe_device *xe);
 void xe_display_irq_postinstall(struct xe_device *xe, struct xe_gt *gt);
 
-void xe_display_pm_suspend(struct xe_device *xe);
+void xe_display_pm_suspend(struct xe_device *xe, bool runtime);
 void xe_display_pm_suspend_late(struct xe_device *xe);
 void xe_display_pm_resume_early(struct xe_device *xe);
-void xe_display_pm_resume(struct xe_device *xe);
+void xe_display_pm_resume(struct xe_device *xe, bool runtime);
 
 #else
 
@@ -63,10 +63,10 @@ static inline void xe_display_irq_enable(struct xe_device *xe, u32 gu_misc_iir)
 static inline void xe_display_irq_reset(struct xe_device *xe) {}
 static inline void xe_display_irq_postinstall(struct xe_device *xe, struct xe_gt *gt) {}
 
-static inline void xe_display_pm_suspend(struct xe_device *xe) {}
+static inline void xe_display_pm_suspend(struct xe_device *xe, bool runtime) {}
 static inline void xe_display_pm_suspend_late(struct xe_device *xe) {}
 static inline void xe_display_pm_resume_early(struct xe_device *xe) {}
-static inline void xe_display_pm_resume(struct xe_device *xe) {}
+static inline void xe_display_pm_resume(struct xe_device *xe, bool runtime) {}
 
 #endif /* CONFIG_DRM_XE_DISPLAY */
 #endif /* _XE_DISPLAY_H_ */
index c3ef2283770ff2c777c75bb4106e60eac09626c6..a2f5a1b11cbf1aa7b0cb26803edba3cbcc0845e7 100644 (file)
@@ -96,12 +96,12 @@ int xe_pm_suspend(struct xe_device *xe)
        if (err)
                goto err;
 
-       xe_display_pm_suspend(xe);
+       xe_display_pm_suspend(xe, false);
 
        for_each_gt(gt, xe, id) {
                err = xe_gt_suspend(gt);
                if (err) {
-                       xe_display_pm_resume(xe);
+                       xe_display_pm_resume(xe, false);
                        goto err;
                }
        }
@@ -151,7 +151,7 @@ int xe_pm_resume(struct xe_device *xe)
 
        xe_irq_resume(xe);
 
-       xe_display_pm_resume(xe);
+       xe_display_pm_resume(xe, false);
 
        for_each_gt(gt, xe, id)
                xe_gt_resume(gt);
@@ -366,6 +366,7 @@ int xe_pm_runtime_suspend(struct xe_device *xe)
                err = xe_bo_evict_all(xe);
                if (err)
                        goto out;
+               xe_display_pm_suspend(xe, true);
        }
 
        for_each_gt(gt, xe, id) {
@@ -375,7 +376,12 @@ int xe_pm_runtime_suspend(struct xe_device *xe)
        }
 
        xe_irq_suspend(xe);
+
+       if (xe->d3cold.allowed)
+               xe_display_pm_suspend_late(xe);
 out:
+       if (err)
+               xe_display_pm_resume(xe, true);
        lock_map_release(&xe_pm_runtime_lockdep_map);
        xe_pm_write_callback_task(xe, NULL);
        return err;
@@ -411,6 +417,8 @@ int xe_pm_runtime_resume(struct xe_device *xe)
                if (err)
                        goto out;
 
+               xe_display_pm_resume_early(xe);
+
                /*
                 * This only restores pinned memory which is the memory
                 * required for the GT(s) to resume.
@@ -426,6 +434,7 @@ int xe_pm_runtime_resume(struct xe_device *xe)
                xe_gt_resume(gt);
 
        if (xe->d3cold.allowed && xe->d3cold.power_lost) {
+               xe_display_pm_resume(xe, true);
                err = xe_bo_restore_user(xe);
                if (err)
                        goto out;