Skip to contentSkip to conversation

drm/amd: Warn users about potential s0ix problems

PATCH In review Mario Limonciello 3 participants 12 messages Jan 26, 2022

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

PATCH v5 1/4 drm/amd: Warn users about potential s0ix problems

On some OEM setups users can configure the BIOS for S3 or S2idle. When configured to S3 users can still choose 's2idle' in the kernel by using /sys/power/mem_sleep. Before commit 6dc8265f9803 ("drm/amdgpu:
always reset the asic in suspend (v2)"), the GPU would crash. Now when configured this way, the system should resume but will use more power.

As such, adjust the amdpu_acpi_is_s0ix function to warn users about potential power consumption issues during their first attempt at suspending.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c +15 -6
index 4811b0faafd9..2531da6cbec3 100644
@@ -1040,11 +1040,20 @@ void amdgpu_acpi_detect(void)
  */
 bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev)
 {
-#if IS_ENABLED(CONFIG_AMD_PMC) && IS_ENABLED(CONFIG_SUSPEND)
-	if (acpi_gbl_FADT.flags & ACPI_FADT_LOW_POWER_S0) {
-		if (adev->flags & AMD_IS_APU)
-			return pm_suspend_target_state == PM_SUSPEND_TO_IDLE;
-	}
-#endif
+#if IS_ENABLED(CONFIG_SUSPEND)
+	if (!(adev->flags & AMD_IS_APU) ||
+	    pm_suspend_target_state != PM_SUSPEND_TO_IDLE)
+		return false;
+#else
 	return false;
+#endif
+	if (!(acpi_gbl_FADT.flags & ACPI_FADT_LOW_POWER_S0))
+		dev_warn_once(adev->dev,
+			      "Power consumption will be higher as BIOS has not been configured for suspend-to-idle.\n"
+			      "To use suspend-to-idle change the sleep mode in BIOS setup.\n");
+#if !IS_ENABLED(CONFIG_AMD_PMC)
+	dev_warn_once(adev->dev,
+		      "Power consumption will be higher as the kernel has not been compiled with CONFIG_AMD_PMC.\n");
+#endif
+	return true;
 }
Signature · 1 line
2.25.1
#1 lore raw

PATCH v5 2/4 drm/amd: add support to check whether the system is set to s3

This will be used to help make decisions on what to do in misconfigured systems.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h      |  2 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 17 +++++++++++++++++
 2 files changed, 19 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -0
index 3bc76759c143..f184c88d3d4f 100644
@@ -1409,11 +1409,13 @@ int amdgpu_acpi_smart_shift_update(struct drm_device *dev, enum amdgpu_ss ss_sta
 int amdgpu_acpi_pcie_notify_device_ready(struct amdgpu_device *adev);
 
 void amdgpu_acpi_get_backlight_caps(struct amdgpu_dm_backlight_caps *caps);
+bool amdgpu_acpi_is_s3_active(struct amdgpu_device *adev);
 bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev);
 void amdgpu_acpi_detect(void);
 #else
 static inline int amdgpu_acpi_init(struct amdgpu_device *adev) { return 0; }
 static inline void amdgpu_acpi_fini(struct amdgpu_device *adev) { }
+static inline bool amdgpu_acpi_is_s3_active(struct amdgpu_device *adev) { return false };
 static inline bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev) { return false; }
 static inline void amdgpu_acpi_detect(void) { }
 static inline bool amdgpu_acpi_is_power_shift_control_supported(void) { return false; }
drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c +17 -0
index 2531da6cbec3..df673062bc03 100644
@@ -1031,6 +1031,23 @@ void amdgpu_acpi_detect(void)
 	}
 }
 
+/**
+ * amdgpu_acpi_is_s3_active
+ *
+ * @adev: amdgpu_device_pointer
+ *
+ * returns true if supported, false if not.
+ */
+bool amdgpu_acpi_is_s3_active(struct amdgpu_device *adev)
+{
+#if IS_ENABLED(CONFIG_SUSPEND)
+	return !(adev->flags & AMD_IS_APU) ||
+		pm_suspend_target_state == PM_SUSPEND_MEM;
+#else
+	return false;
+#endif
+}
+
 /**
  * amdgpu_acpi_is_s0ix_active
  *
Signature · 1 line
2.25.1
#2 lore raw

Re: [PATCH v5 2/4] drm/amd: add support to check whether the system is set to s3

[Public]

Returns true for dGPU always. Better to keep the whole check under something like this.

if (pm_suspend_target_state != PM_SUSPEND_ON)

Thanks,
Lijo
________________________________
From: amd-gfx <[email protected]> on behalf of Mario Limonciello <[email protected]>
Sent: Wednesday, January 26, 2022 9:39:42 AM
To: [email protected] <[email protected]>
Cc: Liang, Prike <[email protected]>; Limonciello, Mario <[email protected]>
Subject: [PATCH v5 2/4] drm/amd: add support to check whether the system is set to s3

This will be used to help make decisions on what to do in misconfigured systems.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h      |  2 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 17 +++++++++++++++++
 2 files changed, 19 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -0
index 3bc76759c143..f184c88d3d4f 100644
@@ -1409,11 +1409,13 @@ int amdgpu_acpi_smart_shift_update(struct drm_device *dev, enum amdgpu_ss ss_sta
 int amdgpu_acpi_pcie_notify_device_ready(struct amdgpu_device *adev);
 
 void amdgpu_acpi_get_backlight_caps(struct amdgpu_dm_backlight_caps *caps);
+bool amdgpu_acpi_is_s3_active(struct amdgpu_device *adev);
 bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev);
 void amdgpu_acpi_detect(void);
 #else
 static inline int amdgpu_acpi_init(struct amdgpu_device *adev) { return 0; }
 static inline void amdgpu_acpi_fini(struct amdgpu_device *adev) { }
+static inline bool amdgpu_acpi_is_s3_active(struct amdgpu_device *adev) { return false };
 static inline bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev) { return false; }
 static inline void amdgpu_acpi_detect(void) { }
 static inline bool amdgpu_acpi_is_power_shift_control_supported(void) { return false; }
drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c +17 -0
index 2531da6cbec3..df673062bc03 100644
@@ -1031,6 +1031,23 @@ void amdgpu_acpi_detect(void)
         }
 }
 
+/**
+ * amdgpu_acpi_is_s3_active
+ *
+ * @adev: amdgpu_device_pointer
+ *
+ * returns true if supported, false if not.
+ */
+bool amdgpu_acpi_is_s3_active(struct amdgpu_device *adev)
+{
+#if IS_ENABLED(CONFIG_SUSPEND)
+       return !(adev->flags & AMD_IS_APU) ||
+               pm_suspend_target_state == PM_SUSPEND_MEM;
+#else
+       return false;
+#endif
+}
+
 /**
  * amdgpu_acpi_is_s0ix_active
  *

--
2.25.1

#3 lore raw

RE: [PATCH v5 2/4] drm/amd: add support to check whether the system is set to s3

[Public]

That was intentional - shouldn't dGPU always be going through S3 path currently?

From: Lazar, Lijo <[email protected]>
Sent: Wednesday, January 26, 2022 09:06
To: Limonciello, Mario <[email protected]>; [email protected]
Cc: Liang, Prike <[email protected]>; Limonciello, Mario <[email protected]>
Subject: Re: [PATCH v5 2/4] drm/amd: add support to check whether the system is set to s3

[Public]

Returns true for dGPU always. Better to keep the whole check under something like this.

if (pm_suspend_target_state != PM_SUSPEND_ON)

Thanks,
Lijo
________________________________
From: amd-gfx <[email protected]<mailto:[email protected]>> on behalf of Mario Limonciello <[email protected]<mailto:[email protected]>>
Sent: Wednesday, January 26, 2022 9:39:42 AM
To: [email protected]<mailto:[email protected]> <[email protected]<mailto:[email protected]>>
Cc: Liang, Prike <[email protected]<mailto:[email protected]>>; Limonciello, Mario <[email protected]<mailto:[email protected]>>
Subject: [PATCH v5 2/4] drm/amd: add support to check whether the system is set to s3

This will be used to help make decisions on what to do in misconfigured systems.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h      |  2 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 17 +++++++++++++++++
 2 files changed, 19 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -0
index 3bc76759c143..f184c88d3d4f 100644
@@ -1409,11 +1409,13 @@ int amdgpu_acpi_smart_shift_update(struct drm_device *dev, enum amdgpu_ss ss_sta
 int amdgpu_acpi_pcie_notify_device_ready(struct amdgpu_device *adev);
 
 void amdgpu_acpi_get_backlight_caps(struct amdgpu_dm_backlight_caps *caps);
+bool amdgpu_acpi_is_s3_active(struct amdgpu_device *adev);
 bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev);
 void amdgpu_acpi_detect(void);
 #else
 static inline int amdgpu_acpi_init(struct amdgpu_device *adev) { return 0; }
 static inline void amdgpu_acpi_fini(struct amdgpu_device *adev) { }
+static inline bool amdgpu_acpi_is_s3_active(struct amdgpu_device *adev) { return false };
 static inline bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev) { return false; }
 static inline void amdgpu_acpi_detect(void) { }
 static inline bool amdgpu_acpi_is_power_shift_control_supported(void) { return false; }
drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c +17 -0
index 2531da6cbec3..df673062bc03 100644
@@ -1031,6 +1031,23 @@ void amdgpu_acpi_detect(void)
         }
 }
 
+/**
+ * amdgpu_acpi_is_s3_active
+ *
+ * @adev: amdgpu_device_pointer
+ *
+ * returns true if supported, false if not.
+ */
+bool amdgpu_acpi_is_s3_active(struct amdgpu_device *adev)
+{
+#if IS_ENABLED(CONFIG_SUSPEND)
+       return !(adev->flags & AMD_IS_APU) ||
+               pm_suspend_target_state == PM_SUSPEND_MEM;
+#else
+       return false;
+#endif
+}
+
 /**
  * amdgpu_acpi_is_s0ix_active
  *

--
2.25.1

#4 lore raw

Re: [PATCH v5 2/4] drm/amd: add support to check whether the system is set to s3

Talking from generic API perspective - S3 is considered active for dGPU only if it's going to non-S0 state. If called from anywhere else than suspend op, this should return false.

Thanks,
Lijo
________________________________
From: Limonciello, Mario <[email protected]>
Sent: Wednesday, January 26, 2022 8:37:28 PM
To: Lazar, Lijo <[email protected]>; [email protected] <[email protected]>
Cc: Liang, Prike <[email protected]>
Subject: RE: [PATCH v5 2/4] drm/amd: add support to check whether the system is set to s3

[Public]

That was intentional – shouldn’t dGPU always be going through S3 path currently?

From: Lazar, Lijo <[email protected]>
Sent: Wednesday, January 26, 2022 09:06
To: Limonciello, Mario <[email protected]>; [email protected]
Cc: Liang, Prike <[email protected]>; Limonciello, Mario <[email protected]>
Subject: Re: [PATCH v5 2/4] drm/amd: add support to check whether the system is set to s3

[Public]

Returns true for dGPU always. Better to keep the whole check under something like this.

if (pm_suspend_target_state != PM_SUSPEND_ON)

Thanks,
Lijo

________________________________

From: amd-gfx <[email protected]<mailto:[email protected]>> on behalf of Mario Limonciello <[email protected]<mailto:[email protected]>>
Sent: Wednesday, January 26, 2022 9:39:42 AM
To: [email protected]<mailto:[email protected]> <[email protected]<mailto:[email protected]>>
Cc: Liang, Prike <[email protected]<mailto:[email protected]>>; Limonciello, Mario <[email protected]<mailto:[email protected]>>
Subject: [PATCH v5 2/4] drm/amd: add support to check whether the system is set to s3

This will be used to help make decisions on what to do in misconfigured systems.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h      |  2 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 17 +++++++++++++++++
 2 files changed, 19 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -0
index 3bc76759c143..f184c88d3d4f 100644
@@ -1409,11 +1409,13 @@ int amdgpu_acpi_smart_shift_update(struct drm_device *dev, enum amdgpu_ss ss_sta
 int amdgpu_acpi_pcie_notify_device_ready(struct amdgpu_device *adev);
 
 void amdgpu_acpi_get_backlight_caps(struct amdgpu_dm_backlight_caps *caps);
+bool amdgpu_acpi_is_s3_active(struct amdgpu_device *adev);
 bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev);
 void amdgpu_acpi_detect(void);
 #else
 static inline int amdgpu_acpi_init(struct amdgpu_device *adev) { return 0; }
 static inline void amdgpu_acpi_fini(struct amdgpu_device *adev) { }
+static inline bool amdgpu_acpi_is_s3_active(struct amdgpu_device *adev) { return false };
 static inline bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev) { return false; }
 static inline void amdgpu_acpi_detect(void) { }
 static inline bool amdgpu_acpi_is_power_shift_control_supported(void) { return false; }
drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c +17 -0
index 2531da6cbec3..df673062bc03 100644
@@ -1031,6 +1031,23 @@ void amdgpu_acpi_detect(void)
         }
 }
 
+/**
+ * amdgpu_acpi_is_s3_active
+ *
+ * @adev: amdgpu_device_pointer
+ *
+ * returns true if supported, false if not.
+ */
+bool amdgpu_acpi_is_s3_active(struct amdgpu_device *adev)
+{
+#if IS_ENABLED(CONFIG_SUSPEND)
+       return !(adev->flags & AMD_IS_APU) ||
+               pm_suspend_target_state == PM_SUSPEND_MEM;
+#else
+       return false;
+#endif
+}
+
 /**
  * amdgpu_acpi_is_s0ix_active
  *

--
2.25.1

#5 lore raw

RE: [PATCH v5 2/4] drm/amd: add support to check whether the system is set to s3

[Public]

Right -from an API perspective both amdgpu_acpi_is_s0ix_active and amdgpu_acpi_is_s3_active are only in suspend ops.

But so coming back to the 4th patch (and the associated bug), what is supposed to happen with a dGPU on an Intel system that does s2i?
For AMD APU w/ dGPU in the system doing s2i I would expect that power rails have been cut off for the dGPU so putting it into S3 and doing a reset makes sense, but I don't know about on an Intel system if that is logical. It seems like Intel expects more that the card is going to be in runtime pm and putting it into S3 and doing reset might not be the right move.

From: Lazar, Lijo <[email protected]>
Sent: Wednesday, January 26, 2022 09:11
To: Limonciello, Mario <[email protected]>; [email protected]
Cc: Liang, Prike <[email protected]>
Subject: Re: [PATCH v5 2/4] drm/amd: add support to check whether the system is set to s3

Talking from generic API perspective - S3 is considered active for dGPU only if it's going to non-S0 state. If called from anywhere else than suspend op, this should return false.

Thanks,
Lijo
________________________________
From: Limonciello, Mario <[email protected]<mailto:[email protected]>>
Sent: Wednesday, January 26, 2022 8:37:28 PM
To: Lazar, Lijo <[email protected]<mailto:[email protected]>>; [email protected]<mailto:[email protected]> <[email protected]<mailto:[email protected]>>
Cc: Liang, Prike <[email protected]<mailto:[email protected]>>
Subject: RE: [PATCH v5 2/4] drm/amd: add support to check whether the system is set to s3

[Public]

That was intentional - shouldn't dGPU always be going through S3 path currently?

From: Lazar, Lijo <[email protected]<mailto:[email protected]>>
Sent: Wednesday, January 26, 2022 09:06
To: Limonciello, Mario <[email protected]<mailto:[email protected]>>; [email protected]<mailto:[email protected]>
Cc: Liang, Prike <[email protected]<mailto:[email protected]>>; Limonciello, Mario <[email protected]<mailto:[email protected]>>
Subject: Re: [PATCH v5 2/4] drm/amd: add support to check whether the system is set to s3

[Public]

Returns true for dGPU always. Better to keep the whole check under something like this.

if (pm_suspend_target_state != PM_SUSPEND_ON)

Thanks,
Lijo

________________________________

From: amd-gfx <[email protected]<mailto:[email protected]>> on behalf of Mario Limonciello <[email protected]<mailto:[email protected]>>
Sent: Wednesday, January 26, 2022 9:39:42 AM
To: [email protected]<mailto:[email protected]> <[email protected]<mailto:[email protected]>>
Cc: Liang, Prike <[email protected]<mailto:[email protected]>>; Limonciello, Mario <[email protected]<mailto:[email protected]>>
Subject: [PATCH v5 2/4] drm/amd: add support to check whether the system is set to s3

This will be used to help make decisions on what to do in misconfigured systems.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h      |  2 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 17 +++++++++++++++++
 2 files changed, 19 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -0
index 3bc76759c143..f184c88d3d4f 100644
@@ -1409,11 +1409,13 @@ int amdgpu_acpi_smart_shift_update(struct drm_device *dev, enum amdgpu_ss ss_sta
 int amdgpu_acpi_pcie_notify_device_ready(struct amdgpu_device *adev);
 
 void amdgpu_acpi_get_backlight_caps(struct amdgpu_dm_backlight_caps *caps);
+bool amdgpu_acpi_is_s3_active(struct amdgpu_device *adev);
 bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev);
 void amdgpu_acpi_detect(void);
 #else
 static inline int amdgpu_acpi_init(struct amdgpu_device *adev) { return 0; }
 static inline void amdgpu_acpi_fini(struct amdgpu_device *adev) { }
+static inline bool amdgpu_acpi_is_s3_active(struct amdgpu_device *adev) { return false };
 static inline bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev) { return false; }
 static inline void amdgpu_acpi_detect(void) { }
 static inline bool amdgpu_acpi_is_power_shift_control_supported(void) { return false; }
drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c +17 -0
index 2531da6cbec3..df673062bc03 100644
@@ -1031,6 +1031,23 @@ void amdgpu_acpi_detect(void)
         }
 }
 
+/**
+ * amdgpu_acpi_is_s3_active
+ *
+ * @adev: amdgpu_device_pointer
+ *
+ * returns true if supported, false if not.
+ */
+bool amdgpu_acpi_is_s3_active(struct amdgpu_device *adev)
+{
+#if IS_ENABLED(CONFIG_SUSPEND)
+       return !(adev->flags & AMD_IS_APU) ||
+               pm_suspend_target_state == PM_SUSPEND_MEM;
+#else
+       return false;
+#endif
+}
+
 /**
  * amdgpu_acpi_is_s0ix_active
  *

--
2.25.1

#6 lore raw

Re: [PATCH v5 2/4] drm/amd: add support to check whether the system is set to s3

I remember Alex adding a patch for smart suspend such that it skips the suspend call if runtime pm suspended.

In summary, the resume doesn't work with/without reset?

Thanks,
Lijo
________________________________
From: Limonciello, Mario <[email protected]>
Sent: Wednesday, January 26, 2022 8:47:05 PM
To: Lazar, Lijo <[email protected]>; [email protected] <[email protected]>
Cc: Liang, Prike <[email protected]>
Subject: RE: [PATCH v5 2/4] drm/amd: add support to check whether the system is set to s3

[Public]

Right -from an API perspective both amdgpu_acpi_is_s0ix_active and amdgpu_acpi_is_s3_active are only in suspend ops.

But so coming back to the 4th patch (and the associated bug), what is supposed to happen with a dGPU on an Intel system that does s2i?

For AMD APU w/ dGPU in the system doing s2i I would expect that power rails have been cut off for the dGPU so putting it into S3 and doing a reset makes sense, but I don’t know about on an Intel system if that is logical.

It seems like Intel expects more that the card is going to be in runtime pm and putting it into S3 and doing reset might not be the right move.

From: Lazar, Lijo <[email protected]>
Sent: Wednesday, January 26, 2022 09:11
To: Limonciello, Mario <[email protected]>; [email protected]
Cc: Liang, Prike <[email protected]>
Subject: Re: [PATCH v5 2/4] drm/amd: add support to check whether the system is set to s3

Talking from generic API perspective - S3 is considered active for dGPU only if it's going to non-S0 state. If called from anywhere else than suspend op, this should return false.

Thanks,
Lijo

________________________________

From: Limonciello, Mario <[email protected]<mailto:[email protected]>>
Sent: Wednesday, January 26, 2022 8:37:28 PM
To: Lazar, Lijo <[email protected]<mailto:[email protected]>>; [email protected]<mailto:[email protected]> <[email protected]<mailto:[email protected]>>
Cc: Liang, Prike <[email protected]<mailto:[email protected]>>
Subject: RE: [PATCH v5 2/4] drm/amd: add support to check whether the system is set to s3

[Public]

That was intentional – shouldn’t dGPU always be going through S3 path currently?

From: Lazar, Lijo <[email protected]<mailto:[email protected]>>
Sent: Wednesday, January 26, 2022 09:06
To: Limonciello, Mario <[email protected]<mailto:[email protected]>>; [email protected]<mailto:[email protected]>
Cc: Liang, Prike <[email protected]<mailto:[email protected]>>; Limonciello, Mario <[email protected]<mailto:[email protected]>>
Subject: Re: [PATCH v5 2/4] drm/amd: add support to check whether the system is set to s3

[Public]

Returns true for dGPU always. Better to keep the whole check under something like this.

if (pm_suspend_target_state != PM_SUSPEND_ON)

Thanks,
Lijo

________________________________

From: amd-gfx <[email protected]<mailto:[email protected]>> on behalf of Mario Limonciello <[email protected]<mailto:[email protected]>>
Sent: Wednesday, January 26, 2022 9:39:42 AM
To: [email protected]<mailto:[email protected]> <[email protected]<mailto:[email protected]>>
Cc: Liang, Prike <[email protected]<mailto:[email protected]>>; Limonciello, Mario <[email protected]<mailto:[email protected]>>
Subject: [PATCH v5 2/4] drm/amd: add support to check whether the system is set to s3

This will be used to help make decisions on what to do in misconfigured systems.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h      |  2 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 17 +++++++++++++++++
 2 files changed, 19 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -0
index 3bc76759c143..f184c88d3d4f 100644
@@ -1409,11 +1409,13 @@ int amdgpu_acpi_smart_shift_update(struct drm_device *dev, enum amdgpu_ss ss_sta
 int amdgpu_acpi_pcie_notify_device_ready(struct amdgpu_device *adev);
 
 void amdgpu_acpi_get_backlight_caps(struct amdgpu_dm_backlight_caps *caps);
+bool amdgpu_acpi_is_s3_active(struct amdgpu_device *adev);
 bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev);
 void amdgpu_acpi_detect(void);
 #else
 static inline int amdgpu_acpi_init(struct amdgpu_device *adev) { return 0; }
 static inline void amdgpu_acpi_fini(struct amdgpu_device *adev) { }
+static inline bool amdgpu_acpi_is_s3_active(struct amdgpu_device *adev) { return false };
 static inline bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev) { return false; }
 static inline void amdgpu_acpi_detect(void) { }
 static inline bool amdgpu_acpi_is_power_shift_control_supported(void) { return false; }
drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c +17 -0
index 2531da6cbec3..df673062bc03 100644
@@ -1031,6 +1031,23 @@ void amdgpu_acpi_detect(void)
         }
 }
 
+/**
+ * amdgpu_acpi_is_s3_active
+ *
+ * @adev: amdgpu_device_pointer
+ *
+ * returns true if supported, false if not.
+ */
+bool amdgpu_acpi_is_s3_active(struct amdgpu_device *adev)
+{
+#if IS_ENABLED(CONFIG_SUSPEND)
+       return !(adev->flags & AMD_IS_APU) ||
+               pm_suspend_target_state == PM_SUSPEND_MEM;
+#else
+       return false;
+#endif
+}
+
 /**
  * amdgpu_acpi_is_s0ix_active
  *

--
2.25.1

#7 lore raw

Re: [PATCH v5 2/4] drm/amd: add support to check whether the system is set to s3

I don't think smart suspend works as expected. I asked Raphael about it several times, but he never got around to following up with me. I think that is probably the preferred way to go, but the tricky part is that the dGPUs have integrated bridges and audio and usb and all of that probably needs proper smart suspend support for this to work properly. Alternatively, the OS needs to properly use the ACPI _PR3 methods to power down all of the devices on suspend if the system doesn't automatically take down the power rails when the system enters suspend. I'm not sure Linux does this today.

Alex

Quoted 154 lines · Lijo

I remember Alex adding a patch for smart suspend such that it skips the suspend call if runtime pm suspended.

In summary, the resume doesn't work with/without reset?

Thanks,
Lijo
________________________________
From: Limonciello, Mario <[email protected]>
Sent: Wednesday, January 26, 2022 8:47:05 PM
To: Lazar, Lijo <[email protected]>; [email protected] <[email protected]>
Cc: Liang, Prike <[email protected]>
Subject: RE: [PATCH v5 2/4] drm/amd: add support to check whether the system is set to s3

[Public]

Right -from an API perspective both amdgpu_acpi_is_s0ix_active and amdgpu_acpi_is_s3_active are only in suspend ops.

But so coming back to the 4th patch (and the associated bug), what is supposed to happen with a dGPU on an Intel system that does s2i?

For AMD APU w/ dGPU in the system doing s2i I would expect that power rails have been cut off for the dGPU so putting it into S3 and doing a reset makes sense, but I don’t know about on an Intel system if that is logical.

It seems like Intel expects more that the card is going to be in runtime pm and putting it into S3 and doing reset might not be the right move.

From: Lazar, Lijo <[email protected]>
Sent: Wednesday, January 26, 2022 09:11
To: Limonciello, Mario <[email protected]>; [email protected]
Cc: Liang, Prike <[email protected]>
Subject: Re: [PATCH v5 2/4] drm/amd: add support to check whether the system is set to s3

Talking from generic API perspective - S3 is considered active for dGPU only if it's going to non-S0 state. If called from anywhere else than suspend op, this should return false.

Thanks,
Lijo

________________________________

From: Limonciello, Mario <[email protected]>
Sent: Wednesday, January 26, 2022 8:37:28 PM
To: Lazar, Lijo <[email protected]>; [email protected] <[email protected]>
Cc: Liang, Prike <[email protected]>
Subject: RE: [PATCH v5 2/4] drm/amd: add support to check whether the system is set to s3

[Public]

That was intentional – shouldn’t dGPU always be going through S3 path currently?

From: Lazar, Lijo <[email protected]>
Sent: Wednesday, January 26, 2022 09:06
To: Limonciello, Mario <[email protected]>; [email protected]
Cc: Liang, Prike <[email protected]>; Limonciello, Mario <[email protected]>
Subject: Re: [PATCH v5 2/4] drm/amd: add support to check whether the system is set to s3

[Public]

Returns true for dGPU always. Better to keep the whole check under something like this.

if (pm_suspend_target_state != PM_SUSPEND_ON)

Thanks,
Lijo

________________________________

From: amd-gfx <[email protected]> on behalf of Mario Limonciello <[email protected]>
Sent: Wednesday, January 26, 2022 9:39:42 AM
To: [email protected] <[email protected]>
Cc: Liang, Prike <[email protected]>; Limonciello, Mario <[email protected]>
Subject: [PATCH v5 2/4] drm/amd: add support to check whether the system is set to s3

This will be used to help make decisions on what to do in misconfigured systems.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h      |  2 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 17 +++++++++++++++++
 2 files changed, 19 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -0
index 3bc76759c143..f184c88d3d4f 100644
@@ -1409,11 +1409,13 @@ int amdgpu_acpi_smart_shift_update(struct drm_device *dev, enum amdgpu_ss ss_sta
 int amdgpu_acpi_pcie_notify_device_ready(struct amdgpu_device *adev);
 
 void amdgpu_acpi_get_backlight_caps(struct amdgpu_dm_backlight_caps *caps);
+bool amdgpu_acpi_is_s3_active(struct amdgpu_device *adev);
 bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev);
 void amdgpu_acpi_detect(void);
 #else
 static inline int amdgpu_acpi_init(struct amdgpu_device *adev) { return 0; }
 static inline void amdgpu_acpi_fini(struct amdgpu_device *adev) { }
+static inline bool amdgpu_acpi_is_s3_active(struct amdgpu_device *adev) { return false };
 static inline bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev) { return false; }
 static inline void amdgpu_acpi_detect(void) { }
 static inline bool amdgpu_acpi_is_power_shift_control_supported(void) { return false; }
drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c +17 -1
index 2531da6cbec3..df673062bc03 100644
@@ -1031,6 +1031,23 @@ void amdgpu_acpi_detect(void)
         }
 }
 
+/**
+ * amdgpu_acpi_is_s3_active
+ *
+ * @adev: amdgpu_device_pointer
+ *
+ * returns true if supported, false if not.
+ */
+bool amdgpu_acpi_is_s3_active(struct amdgpu_device *adev)
+{
+#if IS_ENABLED(CONFIG_SUSPEND)
+       return !(adev->flags & AMD_IS_APU) ||
+               pm_suspend_target_state == PM_SUSPEND_MEM;
+#else
+       return false;
+#endif
+}
+
 /**
  * amdgpu_acpi_is_s0ix_active
  *
--

2.25.1

#8 lore raw

RE: [PATCH v5 2/4] drm/amd: add support to check whether the system is set to s3

[AMD Official Use Only]

They key here is that smart suspend seems to have a dependency on pm_suspend_via_firmware().

So if you have an APU doing S2I or Intel SOC doing S2I it will always return 0. Can we drop that dependency of pm_suspend_via_firmware for it perhaps?

Quoted 196 lines

I don't think smart suspend works as expected. I asked Raphael about it several times, but he never got around to following up with me. I think that is probably the preferred way to go, but the tricky part is that the dGPUs have integrated bridges and audio and usb and all of that probably needs proper smart suspend support for this to work properly. Alternatively, the OS needs to properly use the ACPI _PR3 methods to power down all of the devices on suspend if the system doesn't automatically take down the power rails when the system enters suspend. I'm not sure Linux does this today.

Alex

Quoted 2 lines · Lijo

I remember Alex adding a patch for smart suspend such that it skips the

suspend call if runtime pm suspended.

Quoted 9 lines

In summary, the resume doesn't work with/without reset?

Thanks,
Lijo
________________________________
From: Limonciello, Mario <[email protected]>
Sent: Wednesday, January 26, 2022 8:47:05 PM
To: Lazar, Lijo <[email protected]>; [email protected] <amd-

[email protected]>

Quoted 2 lines

Cc: Liang, Prike <[email protected]>
Subject: RE: [PATCH v5 2/4] drm/amd: add support to check whether the

system is set to s3

Quoted 7 lines

[Public]

Right -from an API perspective both amdgpu_acpi_is_s0ix_active and

amdgpu_acpi_is_s3_active are only in suspend ops.

Quoted 4 lines

But so coming back to the 4th patch (and the associated bug), what is

supposed to happen with a dGPU on an Intel system that does s2i?

Quoted 2 lines

For AMD APU w/ dGPU in the system doing s2i I would expect that power rails

have been cut off for the dGPU so putting it into S3 and doing a reset makes sense, but I don’t know about on an Intel system if that is logical.

Quoted 2 lines

It seems like Intel expects more that the card is going to be in runtime pm and

putting it into S3 and doing reset might not be the right move.

Quoted 6 lines

From: Lazar, Lijo <[email protected]>
Sent: Wednesday, January 26, 2022 09:11
To: Limonciello, Mario <[email protected]>; amd-

[email protected]

Quoted 2 lines

Cc: Liang, Prike <[email protected]>
Subject: Re: [PATCH v5 2/4] drm/amd: add support to check whether the

system is set to s3

Quoted 4 lines

Talking from generic API perspective - S3 is considered active for dGPU only if

it's going to non-S0 state. If called from anywhere else than suspend op, this should return false.

Quoted 11 lines

Thanks,
Lijo

________________________________

From: Limonciello, Mario <[email protected]>
Sent: Wednesday, January 26, 2022 8:37:28 PM
To: Lazar, Lijo <[email protected]>; [email protected] <amd-

[email protected]>

Quoted 2 lines

Cc: Liang, Prike <[email protected]>
Subject: RE: [PATCH v5 2/4] drm/amd: add support to check whether the

system is set to s3

Quoted 8 lines

[Public]

That was intentional – shouldn’t dGPU always be going through S3 path

currently?

Quoted 6 lines

From: Lazar, Lijo <[email protected]>
Sent: Wednesday, January 26, 2022 09:06
To: Limonciello, Mario <[email protected]>; amd-

[email protected]

Quoted 1 line
Cc Liang, Prike <[email protected]>; Limonciello, Mario

<[email protected]>

Quoted 1 line

Subject: Re: [PATCH v5 2/4] drm/amd: add support to check whether the

system is set to s3

Quoted 8 lines

[Public]

Returns true for dGPU always. Better to keep the whole check under

something like this.

Quoted 7 lines

if (pm_suspend_target_state != PM_SUSPEND_ON)

Quoted 6 lines

Thanks,
Lijo

________________________________

From: amd-gfx <[email protected]> on behalf of Mario

Limonciello <[email protected]>

Quoted 3 lines

Sent: Wednesday, January 26, 2022 9:39:42 AM
To: [email protected] <[email protected]>
Cc: Liang, Prike <[email protected]>; Limonciello, Mario

<[email protected]>

Quoted 1 line

Subject: [PATCH v5 2/4] drm/amd: add support to check whether the system is

set to s3

Quoted 6 lines

This will be used to help make decisions on what to do in misconfigured systems.

Review

Quoted 7 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h      |  2 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 17 +++++++++++++++++
 2 files changed, 19 insertions(+)
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/amdgpu.h

drivers/gpu/drm/amd/amdgpu/amdgpu.h int amdgpu_acpi_smart_shift_update(struct

Quoted 4 lines

index 3bc76759c143..f184c88d3d4f 100644

drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -0
@@ -1409,11 +1409,13 @@ int amdgpu_acpi_smart_shift_update(struct

drm_device *dev, enum amdgpu_ss ss_sta

drivers/gpu/drm/amd/amdgpu/amdgpu.h int amdgpu_acpi_smart_shift_update(struct drm_device *dev, enum amdgpu_ss ss_sta

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -0
 int amdgpu_acpi_pcie_notify_device_ready(struct amdgpu_device *adev);
 
 void amdgpu_acpi_get_backlight_caps(struct amdgpu_dm_backlight_caps

*caps);

drivers/gpu/drm/amd/amdgpu/amdgpu.h int amdgpu_acpi_smart_shift_update(struct drm_device *dev, enum amdgpu_ss ss_sta

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +2 -0
+bool amdgpu_acpi_is_s3_active(struct amdgpu_device *adev);
 bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev);
 void amdgpu_acpi_detect(void);
 #else
 static inline int amdgpu_acpi_init(struct amdgpu_device *adev) { return 0; }
 static inline void amdgpu_acpi_fini(struct amdgpu_device *adev) { }
+static inline bool amdgpu_acpi_is_s3_active(struct amdgpu_device *adev) {

return false };

drivers/gpu/drm/amd/amdgpu/amdgpu.h int amdgpu_acpi_smart_shift_update(struct · line 1419

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -0
 static inline bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev) {

return false; }

drivers/gpu/drm/amd/amdgpu/amdgpu.h int amdgpu_acpi_smart_shift_update(struct · line 1421

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -0
 static inline void amdgpu_acpi_detect(void) { }
 static inline bool amdgpu_acpi_is_power_shift_control_supported(void) {

return false; }

Review

Quoted 1 line
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c

Quoted 29 lines

index 2531da6cbec3..df673062bc03 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c +17 -1
@@ -1031,6 +1031,23 @@ void amdgpu_acpi_detect(void)
         }
 }
 
+/**
+ * amdgpu_acpi_is_s3_active
+ *
+ * @adev: amdgpu_device_pointer
+ *
+ * returns true if supported, false if not.
+ */
+bool amdgpu_acpi_is_s3_active(struct amdgpu_device *adev)
+{
+#if IS_ENABLED(CONFIG_SUSPEND)
+       return !(adev->flags & AMD_IS_APU) ||
+               pm_suspend_target_state == PM_SUSPEND_MEM;
+#else
+       return false;
+#endif
+}
+
 /**
  * amdgpu_acpi_is_s0ix_active
  *
--

2.25.1

#9 lore raw

PATCH v5 3/4 drm/amd: Only run s3 or s0ix if system is configured properly

In reply to Mario Limonciello

This will cause misconfigured systems to not run the GPU suspend routines.

* In APUs that are properly configured system will go into s2idle.
* In APUs that are intended to be S3 but user selects s2idle the GPU will stay fully powered for the suspend.
* In APUs that are intended to be s2idle and system misconfigured the GPU will stay fully powered for the suspend.
* In systems that are intended to be s2idle, but AMD dGPU is also present, the dGPU will go through S3

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +13 -11
index b0a620c26ae2..123ec5a07dd5 100644
@@ -2309,17 +2309,19 @@ static int amdgpu_pmops_suspend(struct device *dev)
 {
 	struct drm_device *drm_dev = dev_get_drvdata(dev);
 	struct amdgpu_device *adev = drm_to_adev(drm_dev);
-	int r;
+	int r = 0;
 
 	if (amdgpu_acpi_is_s0ix_active(adev))
 		adev->in_s0ix = true;
-	else
+	else if (amdgpu_acpi_is_s3_active(adev))
 		adev->in_s3 = true;
-	r = amdgpu_device_suspend(drm_dev, true);
-	if (r)
-		return r;
-	if (!adev->in_s0ix)
-		r = amdgpu_asic_reset(adev);
+	if (adev->in_s0ix || adev->in_s3) {
+		r = amdgpu_device_suspend(drm_dev, true);
+		if (r)
+			return r;
+		if (!adev->in_s0ix)
+			r = amdgpu_asic_reset(adev);
+	}
 	return r;
 }
 
@@ -2327,17 +2329,17 @@ static int amdgpu_pmops_resume(struct device *dev)
 {
 	struct drm_device *drm_dev = dev_get_drvdata(dev);
 	struct amdgpu_device *adev = drm_to_adev(drm_dev);
-	int r;
+	int r = 0;
 
 	/* Avoids registers access if device is physically gone */
 	if (!pci_device_is_present(adev->pdev))
 		adev->no_hw_access = true;
 
-	r = amdgpu_device_resume(drm_dev, true);
-	if (amdgpu_acpi_is_s0ix_active(adev))
+	if (adev->in_s0ix || adev->in_s3) {
+		r = amdgpu_device_resume(drm_dev, true);
 		adev->in_s0ix = false;
-	else
 		adev->in_s3 = false;
+	}
 	return r;
 }
 
Signature · 1 line
2.25.1
#10 lore raw

PATCH v5 4/4 drm/amd: don't reset dGPUs that don't go through system S3

In reply to Mario Limonciello

dGPUs connected to Intel systems configured for suspend to idle will not necessarily have the power rails cut at suspend and resetting the GPU may lead to problematic behaviors.

Fixes 6dc8265f9803 ("drm/amdgpu: always reset the asic in suspend (v2)")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1 -1
index 123ec5a07dd5..66290f986544 100644
@@ -2319,7 +2319,7 @@ static int amdgpu_pmops_suspend(struct device *dev)
 		r = amdgpu_device_suspend(drm_dev, true);
 		if (r)
 			return r;
-		if (!adev->in_s0ix)
+		if (!adev->in_s0ix && pm_suspend_via_firmware())
 			r = amdgpu_asic_reset(adev);
 	}
 	return r;
Signature · 1 line
2.25.1
#11 lore raw

RE: [PATCH v5 4/4] drm/amd: don't reset dGPUs that don't go through system S3

[AMD Official Use Only]

Quoted 9 lines

-----Original Message-----
From: Limonciello, Mario <[email protected]>
Sent: Tuesday, January 25, 2022 22:10
To: [email protected]
Cc: Liang, Prike <[email protected]>; Limonciello, Mario <[email protected]>
Subject: [PATCH v5 4/4] drm/amd: don't reset dGPUs that don't go through system S3

Quoted 6 lines

dGPUs connected to Intel systems configured for suspend to idle will not necessarily have the power rails cut at suspend and resetting the GPU may lead to problematic behaviors.

Fixes 6dc8265f9803 ("drm/amdgpu: always reset the asic in suspend (v2)")

Testing has failed with this patch on the original issue mentioned above, so if the rest of this series is OK, this one at least should be dropped for now.

Quoted 22 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1 -1
index 123ec5a07dd5..66290f986544 100644
@@ -2319,7 +2319,7 @@ static int amdgpu_pmops_suspend(struct device
 *dev)
 		r = amdgpu_device_suspend(drm_dev, true);
 		if (r)
 			return r;
-		if (!adev->in_s0ix)
+		if (!adev->in_s0ix && pm_suspend_via_firmware())
 			r = amdgpu_asic_reset(adev);
 	}

return r;
--
2.25.1