Skip to contentSkip to conversation

drm/amd: apply s0ix codepath to more cases

PATCH In review Mario Limonciello 2 participants 3 messages Jan 11, 2022

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

PATCH 1/1 drm/amd: apply s0ix codepath to more cases

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. When configured this way, the system will use more power but should still work for suspend and resume.

As such, remove the checks that put the GPU driver into the S3 codepaths when the user has selected s2idle.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c +9 -6
index 4811b0faafd9..a46bac8f79af 100644
@@ -1040,11 +1040,14 @@ 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;
-	}
+	if (!(adev->flags & AMD_IS_APU))
+		return false;
+	if (!(acpi_gbl_FADT.flags & ACPI_FADT_LOW_POWER_S0))
+		dev_warn_once(adev->dev,
+			      "BIOS is not configured for suspend-to-idle, power consumption will be higher\n");
+#if !IS_ENABLED(CONFIG_AMD_PMC)
+	dev_warn_once(adev->dev,
+		      "amd-pmc is not enabled in the kernel, power consumption will be higher\n");
 #endif
-	return false;
+	return pm_suspend_target_state == PM_SUSPEND_TO_IDLE;
 }
Signature · 1 line
2.25.1
#1 lore raw
Quoted 28 lines · Mario Limonciello

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. When configured this way, the system will use more power but should still work for suspend and resume.

As such, remove the checks that put the GPU driver into the S3 codepaths when the user has selected s2idle.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 15 +++++++++------
  1 file changed, 9 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c +0 -4
index 4811b0faafd9..a46bac8f79af 100644
@@ -1040,11 +1040,14 @@ 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;

drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c void amdgpu_acpi_detect(void) · line 1051

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c +8 -1
-	}
+	if (!(adev->flags & AMD_IS_APU))
+		return false;
+	if (!(acpi_gbl_FADT.flags & ACPI_FADT_LOW_POWER_S0))
+		dev_warn_once(adev->dev,
+			      "BIOS is not configured for suspend-to-idle, power consumption will be higher\n");
+#if !IS_ENABLED(CONFIG_AMD_PMC)
+	dev_warn_once(adev->dev,
+		      "amd-pmc is not enabled in the kernel, power consumption will be higher\n");
  #endif

It makes sense to emit these warnings only when pm_suspend_target_state == PM_SUSPEND_TO_IDLE.

Thanks,
Lijo

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c +1 -1
-	return false;
+	return pm_suspend_target_state == PM_SUSPEND_TO_IDLE;
  }
#2 lore raw

[AMD Official Use Only]

Quoted 48 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Tuesday, January 11, 2022 12:54
To: Limonciello, Mario <[email protected]>; amd- [email protected]
Cc: Bjoren Dasse <[email protected]>
Subject: Re: [PATCH] drm/amd: apply s0ix codepath to more cases

Quoted 12 lines · Mario Limonciello

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. When configured this way, the system will use more power but should still work for suspend and resume.

As such, remove the checks that put the GPU driver into the S3 codepaths when the user has selected s2idle.

Review

Quoted 5 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c | 15 +++++++++------
  1 file changed, 9 insertions(+), 6 deletions(-)
(quoted diff) +0 -0

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

drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c void amdgpu_acpi_detect(void) · line 1046

Quoted 11 lines

index 4811b0faafd9..a46bac8f79af 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c +0 -4
@@ -1040,11 +1040,14 @@ 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;

drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c void amdgpu_acpi_detect(void)

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c +5 -1
-	}
+	if (!(adev->flags & AMD_IS_APU))
+		return false;
+	if (!(acpi_gbl_FADT.flags & ACPI_FADT_LOW_POWER_S0))
+		dev_warn_once(adev->dev,
+			      "BIOS is not configured for suspend-to-idle, power

consumption will be higher\n");

Quoted 9 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c void amdgpu_acpi_detect(void)

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c +3 -0
+#if !IS_ENABLED(CONFIG_AMD_PMC)
+	dev_warn_once(adev->dev,
+		      "amd-pmc is not enabled in the kernel, power consumption

will be higher\n");

drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c void amdgpu_acpi_detect(void) · line 1051

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c +0 -0
  #endif

It makes sense to emit these warnings only when pm_suspend_target_state == PM_SUSPEND_TO_IDLE.

That's true - thanks. The other open question ends up being whether this even will work since the SMU never powers down the GPU without the rest of the firmware support.

The possibilities I see are:
1) Just try it (what is happening now).
2) Reset GPU after coming back for safety.
3) Don't power down GPU without firmware support.
4) Fail the suspend without firmware support.

Quoted 7 lines

Thanks,
Lijo

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c +1 -1
-	return false;
+	return pm_suspend_target_state == PM_SUSPEND_TO_IDLE;
  }