Skip to contentSkip to conversation

drm/amdgpu: fix shutdown with s0ix

PATCH In review Alex Deucher 2 participants 3 messages Feb 18, 2021 – Feb 19, 2021

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

PATCH 1/1 drm/amdgpu: fix shutdown with s0ix

For shutdown needs to be handled differently and s0ix. Add a new flag to shutdown and use it to adjust behavior appropriately.

Fixes 628c36d7b238e2 ("drm/amdgpu: update amdgpu device suspend/resume sequence for s0i3 support")
Cc Prike Liang <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h        | 1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 ++++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    | 2 ++
 3 files changed, 7 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index da258331e86b..7f5500d8e8f4 100644
@@ -1018,6 +1018,7 @@ struct amdgpu_device {
 	/* s3/s4 mask */
 	bool                            in_suspend;
 	bool				in_hibernate;
+	bool				in_shutdown;
 
 	atomic_t 			in_gpu_reset;
 	enum pp_mp1_state               mp1_state;
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4 -2
index 7052dc35d278..ecd0201050ac 100644
@@ -2678,7 +2678,8 @@ static int amdgpu_device_ip_suspend_phase1(struct amdgpu_device *adev)
 {
 	int i, r;
 
-	if (!amdgpu_acpi_is_s0ix_supported(adev) || amdgpu_in_reset(adev)) {
+	if (adev->in_shutdown ||
+	    !amdgpu_acpi_is_s0ix_supported(adev) || amdgpu_in_reset(adev)) {
 		amdgpu_device_set_pg_state(adev, AMD_PG_STATE_UNGATE);
 		amdgpu_device_set_cg_state(adev, AMD_CG_STATE_UNGATE);
 	}
@@ -3741,7 +3742,8 @@ int amdgpu_device_suspend(struct drm_device *dev, bool fbcon)
 
 	amdgpu_fence_driver_suspend(adev);
 
-	if (!amdgpu_acpi_is_s0ix_supported(adev) || amdgpu_in_reset(adev))
+	if (adev->in_shutdown ||
+	    !amdgpu_acpi_is_s0ix_supported(adev) || amdgpu_in_reset(adev))
 		r = amdgpu_device_ip_suspend_phase2(adev);
 	else
 		amdgpu_gfx_state_change_set(adev, sGpuChangeState_D3Entry);
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2 -0
index 2ddaa72437e3..b44358e8dc5b 100644
@@ -1265,6 +1265,7 @@ amdgpu_pci_shutdown(struct pci_dev *pdev)
 	if (amdgpu_ras_intr_triggered())
 		return;
 
+	adev->in_shutdown = true;
 	/* if we are running in a VM, make sure the device
 	 * torn down properly on reboot/shutdown.
 	 * unfortunately we can't detect certain
@@ -1274,6 +1275,7 @@ amdgpu_pci_shutdown(struct pci_dev *pdev)
 		adev->mp1_state = PP_MP1_STATE_UNLOAD;
 	amdgpu_device_ip_suspend(adev);
 	adev->mp1_state = PP_MP1_STATE_NONE;
+	adev->in_shutdown = false;
 }
 
 static int amdgpu_pmops_prepare(struct device *dev)
Signature · 6 lines
2.29.2

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#1 lore raw

[AMD Official Use Only - Internal Distribution Only]

Thanks Alex fix, I also have drafted the fix locally for the poweroff and shutdown on the s0ix enablement. Besides the shutdown opt fix for the reboot process and we also need a similarity for the poweroff opt.

So how about create a new combination flag for legacy PM poweroff() and shutdown() opt?

Thanks,
Prike

Quoted 95 lines

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Friday, February 19, 2021 1:11 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Liang, Prike <[email protected]>
Subject: [PATCH] drm/amdgpu: fix shutdown with s0ix

For shutdown needs to be handled differently and s0ix. Add a new flag to shutdown and use it to adjust behavior appropriately.

Bug:
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgitla
b.freedesktop.org%2Fdrm%2Famd%2F- %2Fissues%2F1499&amp;data=04%7C01%7CPrike.Liang%40amd.com%7C247 59f57e2644f26deaf08d8d4302cc3%7C3dd8961fe4884e608e11a82d994e183d %7C0%7C0%7C637492650673813454%7CUnknown%7CTWFpbGZsb3d8eyJWI joiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1 000&amp;sdata=I0rH%2FFt2cs%2BdNwvNdqWKPE%2B3bOosUyBodViUsEwb 6tE%3D&amp;reserved=0

Fixes 628c36d7b238e2 ("drm/amdgpu: update amdgpu device

suspend/resume sequence for s0i3 support")

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h        | 1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 ++++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    | 2 ++
 3 files changed, 7 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index da258331e86b..7f5500d8e8f4 100644
@@ -1018,6 +1018,7 @@ struct amdgpu_device {
 /* s3/s4 mask */
 bool                            in_suspend;
 boolin_hibernate;
+boolin_shutdown;
 
 atomic_t in_gpu_reset;
 enum pp_mp1_state               mp1_state;
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -1
index 7052dc35d278..ecd0201050ac 100644
@@ -2678,7 +2678,8 @@ static int
 amdgpu_device_ip_suspend_phase1(struct amdgpu_device *adev)  {
 int i, r;
 
-if (!amdgpu_acpi_is_s0ix_supported(adev) ||
 amdgpu_in_reset(adev)) {
+if (adev->in_shutdown ||
+    !amdgpu_acpi_is_s0ix_supported(adev) || amdgpu_in_reset(adev))
 {
 amdgpu_device_set_pg_state(adev,

AMD_PG_STATE_UNGATE);
amdgpu_device_set_cg_state(adev,
AMD_CG_STATE_UNGATE);
}

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -1
@@ -3741,7 +3742,8 @@ int amdgpu_device_suspend(struct drm_device
 *dev, bool fbcon)
 
 amdgpu_fence_driver_suspend(adev);
 
-if (!amdgpu_acpi_is_s0ix_supported(adev) ||
 amdgpu_in_reset(adev))
+if (adev->in_shutdown ||
+    !amdgpu_acpi_is_s0ix_supported(adev) || amdgpu_in_reset(adev))
 r = amdgpu_device_ip_suspend_phase2(adev);

else
amdgpu_gfx_state_change_set(adev,
sGpuChangeState_D3Entry); diff --git
a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 2ddaa72437e3..b44358e8dc5b 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1 -0
@@ -1265,6 +1265,7 @@ amdgpu_pci_shutdown(struct pci_dev *pdev)
 if (amdgpu_ras_intr_triggered())
 return;
 
+adev->in_shutdown = true;
 /* if we are running in a VM, make sure the device
  * torn down properly on reboot/shutdown.
  * unfortunately we can't detect certain @@ -1274,6 +1275,7 @@

amdgpu_pci_shutdown(struct pci_dev *pdev)
adev->mp1_state = PP_MP1_STATE_UNLOAD;
amdgpu_device_ip_suspend(adev);
adev->mp1_state = PP_MP1_STATE_NONE;
+adev->in_shutdown = false;
}

Quoted 3 lines

static int amdgpu_pmops_prepare(struct device *dev)
--
2.29.2

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#2 lore raw
Quoted 7 lines · Prike

[AMD Official Use Only - Internal Distribution Only]

Thanks Alex fix, I also have drafted the fix locally for the poweroff and shutdown on the s0ix enablement. Besides the shutdown opt fix for the reboot process and we also need a similarity for the poweroff opt.

So how about create a new combination flag for legacy PM poweroff() and shutdown() opt?

Sure.

Alex

Quoted 98 lines

Thanks,
Prike

Quoted 95 lines

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Friday, February 19, 2021 1:11 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Liang, Prike <[email protected]>
Subject: [PATCH] drm/amdgpu: fix shutdown with s0ix

For shutdown needs to be handled differently and s0ix. Add a new flag to shutdown and use it to adjust behavior appropriately.

Bug:
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgitla
b.freedesktop.org%2Fdrm%2Famd%2F- %2Fissues%2F1499&amp;data=04%7C01%7CPrike.Liang%40amd.com%7C247 59f57e2644f26deaf08d8d4302cc3%7C3dd8961fe4884e608e11a82d994e183d %7C0%7C0%7C637492650673813454%7CUnknown%7CTWFpbGZsb3d8eyJWI joiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1 000&amp;sdata=I0rH%2FFt2cs%2BdNwvNdqWKPE%2B3bOosUyBodViUsEwb 6tE%3D&amp;reserved=0

Fixes 628c36d7b238e2 ("drm/amdgpu: update amdgpu device

suspend/resume sequence for s0i3 support")

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h        | 1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 ++++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    | 2 ++
 3 files changed, 7 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index da258331e86b..7f5500d8e8f4 100644
@@ -1018,6 +1018,7 @@ struct amdgpu_device {
 /* s3/s4 mask */
 bool                            in_suspend;
 boolin_hibernate;
+boolin_shutdown;
 
 atomic_t in_gpu_reset;
 enum pp_mp1_state               mp1_state;
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -1
index 7052dc35d278..ecd0201050ac 100644
@@ -2678,7 +2678,8 @@ static int
 amdgpu_device_ip_suspend_phase1(struct amdgpu_device *adev)  {
 int i, r;
 
-if (!amdgpu_acpi_is_s0ix_supported(adev) ||
 amdgpu_in_reset(adev)) {
+if (adev->in_shutdown ||
+    !amdgpu_acpi_is_s0ix_supported(adev) || amdgpu_in_reset(adev))
 {
 amdgpu_device_set_pg_state(adev,

AMD_PG_STATE_UNGATE);
amdgpu_device_set_cg_state(adev,
AMD_CG_STATE_UNGATE);
}

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -1
@@ -3741,7 +3742,8 @@ int amdgpu_device_suspend(struct drm_device
 *dev, bool fbcon)
 
 amdgpu_fence_driver_suspend(adev);
 
-if (!amdgpu_acpi_is_s0ix_supported(adev) ||
 amdgpu_in_reset(adev))
+if (adev->in_shutdown ||
+    !amdgpu_acpi_is_s0ix_supported(adev) || amdgpu_in_reset(adev))
 r = amdgpu_device_ip_suspend_phase2(adev);

else
amdgpu_gfx_state_change_set(adev,
sGpuChangeState_D3Entry); diff --git
a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
index 2ddaa72437e3..b44358e8dc5b 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1 -0
@@ -1265,6 +1265,7 @@ amdgpu_pci_shutdown(struct pci_dev *pdev)
 if (amdgpu_ras_intr_triggered())
 return;
 
+adev->in_shutdown = true;
 /* if we are running in a VM, make sure the device
  * torn down properly on reboot/shutdown.
  * unfortunately we can't detect certain @@ -1274,6 +1275,7 @@

amdgpu_pci_shutdown(struct pci_dev *pdev)
adev->mp1_state = PP_MP1_STATE_UNLOAD;
amdgpu_device_ip_suspend(adev);
adev->mp1_state = PP_MP1_STATE_NONE;
+adev->in_shutdown = false;
}

Quoted 4 lines
Quoted 3 lines

static int amdgpu_pmops_prepare(struct device *dev)
--
2.29.2

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx