Skip to contentSkip to conversation

drm/xe: Improve s2idle handling.

PATCH In review Maarten Lankhorst 2 participants 2 messages Jul 28, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/xe: Improve s2idle handling.

We accidentally always pass true as s2idle argument, instead of calculating it in the same way as i915.

Suspend modes were removed to achieve compatibility with i915, but accidentally left in the source code.

While at it, fix all other cases too, s2idle will go into a D1 state and setting a lower power state should be handled by PCI core.

Maybe my laptop stops draining so much power during suspend now? I can only hope..

---
 drivers/gpu/drm/xe/compat-i915-headers/intel_runtime_pm.h | 6 ------
 drivers/gpu/drm/xe/xe_display.c                           | 6 ++++--
 drivers/gpu/drm/xe/xe_pci.c                               | 6 ------
 3 files changed, 4 insertions(+), 14 deletions(-)
drivers/gpu/drm/xe/compat-i915-headers/intel_runtime_pm.h +0 -6
index 9251c05dfd11..ce2b9bf3918d 100644
@@ -5,12 +5,6 @@
 
 #include "intel_wakeref.h"
 
-enum i915_drm_suspend_mode {
-	I915_DRM_SUSPEND_IDLE,
-	I915_DRM_SUSPEND_MEM,
-	I915_DRM_SUSPEND_HIBERNATE,
-};
-
 static inline void disable_rpm_wakeref_asserts(void *rpm)
 {
 }
drivers/gpu/drm/xe/xe_display.c +4 -2
index 8e39fb7f1fc8..ec7a654bf587 100644
@@ -333,6 +333,7 @@ static void intel_suspend_encoders(struct xe_device *xe)
 
 void xe_display_pm_suspend(struct xe_device *xe)
 {
+	bool s2idle = acpi_target_system_state() < ACPI_STATE_S3;
 	if (!xe->info.enable_display)
 		return;
 
@@ -352,7 +353,7 @@ void xe_display_pm_suspend(struct xe_device *xe)
 
 	intel_suspend_encoders(xe);
 
-	intel_opregion_suspend(xe, PCI_D3cold);
+	intel_opregion_suspend(xe, s2idle ? PCI_D1 : PCI_D3cold);
 
 	intel_fbdev_set_suspend(&xe->drm, FBINFO_STATE_SUSPENDED, true);
 
@@ -361,10 +362,11 @@ void xe_display_pm_suspend(struct xe_device *xe)
 
 void xe_display_pm_suspend_late(struct xe_device *xe)
 {
+	bool s2idle = acpi_target_system_state() < ACPI_STATE_S3;
 	if (!xe->info.enable_display)
 		return;
 
-	intel_power_domains_suspend(xe, I915_DRM_SUSPEND_MEM);
+	intel_power_domains_suspend(xe, s2idle);
 
 	intel_display_power_suspend_late(xe);
 }
drivers/gpu/drm/xe/xe_pci.c +0 -6
index 78df43c20cd2..63387d99b3ed 100644
@@ -728,10 +728,6 @@ static int xe_pci_suspend(struct device *dev)
 	pci_save_state(pdev);
 	pci_disable_device(pdev);
 
-	err = pci_set_power_state(pdev, PCI_D3hot);
-	if (err)
-		return err;
-
 	return 0;
 }
 
@@ -744,8 +740,6 @@ static int xe_pci_resume(struct device *dev)
 	if (err)
 		return err;
 
-	pci_restore_state(pdev);
-
 	err = pci_enable_device(pdev);
 	if (err)
 		return err;
Signature · 1 line
2.39.2
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 24 lines · Maarten Lankhorst

We accidentally always pass true as s2idle argument, instead of calculating it in the same way as i915.

Suspend modes were removed to achieve compatibility with i915, but accidentally left in the source code.

While at it, fix all other cases too, s2idle will go into a D1 state and setting a lower power state should be handled by PCI core.

Maybe my laptop stops draining so much power during suspend now? I can only hope..

---
 drivers/gpu/drm/xe/compat-i915-headers/intel_runtime_pm.h | 6 ------
 drivers/gpu/drm/xe/xe_display.c                           | 6 ++++--
 drivers/gpu/drm/xe/xe_pci.c                               | 6 ------
 3 files changed, 4 insertions(+), 14 deletions(-)
drivers/gpu/drm/xe/compat-i915-headers/intel_runtime_pm.h +0 -0
index 9251c05dfd11..ce2b9bf3918d 100644

drivers/gpu/drm/xe/compat-i915-headers/intel_runtime_pm.h line 12

Quoted 8 lines
drivers/gpu/drm/xe/compat-i915-headers/intel_runtime_pm.h +0 -5
@@ -5,12 +5,6 @@
 
 #include "intel_wakeref.h"
 
-enum i915_drm_suspend_mode {
-	I915_DRM_SUSPEND_IDLE,
-	I915_DRM_SUSPEND_MEM,
-	I915_DRM_SUSPEND_HIBERNATE,
-};

good catch on this one. let's kill it.

Quoted 17 lines
drivers/gpu/drm/xe/compat-i915-headers/intel_runtime_pm.h +0 -1
-
 static inline void disable_rpm_wakeref_asserts(void *rpm)
 {
 }
drivers/gpu/drm/xe/xe_display.c +1 -0
index 8e39fb7f1fc8..ec7a654bf587 100644
@@ -333,6 +333,7 @@ static void intel_suspend_encoders(struct xe_device *xe)
 
 void xe_display_pm_suspend(struct xe_device *xe)
 {
+	bool s2idle = acpi_target_system_state() < ACPI_STATE_S3;
 	if (!xe->info.enable_display)
 		return;
 

drivers/gpu/drm/xe/xe_display.c void xe_display_pm_suspend(struct xe_device *xe) · line 356

Quoted 5 lines
drivers/gpu/drm/xe/xe_display.c +1 -1
@@ -352,7 +353,7 @@ void xe_display_pm_suspend(struct xe_device *xe)
 
 	intel_suspend_encoders(xe);
 
-	intel_opregion_suspend(xe, PCI_D3cold);
+	intel_opregion_suspend(xe, s2idle ? PCI_D1 : PCI_D3cold);

I don't believe we need this. From what I could dig from i915 history this was needed in some old bios. But setting the lowest d3cold should be okay for any platform supported in xe.

drivers/gpu/drm/xe/xe_display.c void xe_display_pm_suspend(struct xe_device *xe) · line 369

Quoted 13 lines
drivers/gpu/drm/xe/xe_display.c +2 -1
 	intel_fbdev_set_suspend(&xe->drm, FBINFO_STATE_SUSPENDED, true);
 
@@ -361,10 +362,11 @@ void xe_display_pm_suspend(struct xe_device *xe)
 
 void xe_display_pm_suspend_late(struct xe_device *xe)
 {
+	bool s2idle = acpi_target_system_state() < ACPI_STATE_S3;
 	if (!xe->info.enable_display)
 		return;
 
-	intel_power_domains_suspend(xe, I915_DRM_SUSPEND_MEM);
+	intel_power_domains_suspend(xe, s2idle);

hmm good catch here as well. I believe it should deserve a separated patch.

But anyway, the patch itself in general is already a good step forward, specially if this is fixing your battery drainage. So, let's move ahead with it and leave any bikesheding for later ;)

Btw, please check https://patchwork.freedesktop.org/series/121336/ that maybe affects you as well.

Quoted 8 lines
drivers/gpu/drm/xe/xe_display.c +0 -0
 	intel_display_power_suspend_late(xe);
 }
drivers/gpu/drm/xe/xe_pci.c +0 -0
index 78df43c20cd2..63387d99b3ed 100644

drivers/gpu/drm/xe/xe_pci.c static int xe_pci_suspend(struct device *dev) · line 733

Quoted 6 lines
drivers/gpu/drm/xe/xe_pci.c +0 -3
@@ -728,10 +728,6 @@ static int xe_pci_suspend(struct device *dev)
 	pci_save_state(pdev);
 	pci_disable_device(pdev);
 
-	err = pci_set_power_state(pdev, PCI_D3hot);
-	if (err)
-		return err;

yeap, we likely don't need to toggle ourselves the pci state on the regular suspend/resume path.

Quoted 16 lines
drivers/gpu/drm/xe/xe_pci.c +0 -3
-
 	return 0;
 }
 
@@ -744,8 +740,6 @@ static int xe_pci_resume(struct device *dev)
 	if (err)
 		return err;
 
-	pci_restore_state(pdev);
-
 	err = pci_enable_device(pdev);
 	if (err)
 		return err;
Signature · 1 line
2.39.2