Skip to contentSkip to conversation

drm/amd: Run KFD suspend and resume routines for s0ix

PATCH Superseded Mario Limonciello 3 participants 3 messages Sep 16, 2025

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amd: Run KFD suspend and resume routines for s0ix

KFD suspend and resume routines have been disabled since commit 5d3a2d95224da ("drm/amdgpu: skip kfd suspend/resume for S0ix") which made sense at that time. However there is a problem that if there is any compute work running there may still be active fences. Running suspend without draining them can cause the system to hang.

So run KFD suspend/resume routines even in s0ix.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +6 -7
index 0fdfde3dcb9f..59688f8ae919 100644
@@ -5220,10 +5220,9 @@ int amdgpu_device_suspend(struct drm_device *dev, bool notify_clients)
 
 	amdgpu_device_ip_suspend_phase1(adev);
 
-	if (!adev->in_s0ix) {
-		amdgpu_amdkfd_suspend(adev, !amdgpu_sriov_vf(adev) && !adev->in_runpm);
+	amdgpu_amdkfd_suspend(adev, !amdgpu_sriov_vf(adev) && !adev->in_runpm);
+	if (!adev->in_s0ix)
 		amdgpu_userq_suspend(adev);
-	}
 
 	r = amdgpu_device_evict_resources(adev);
 	if (r)
@@ -5318,11 +5317,11 @@ int amdgpu_device_resume(struct drm_device *dev, bool notify_clients)
 		goto exit;
 	}
 
-	if (!adev->in_s0ix) {
-		r = amdgpu_amdkfd_resume(adev, !amdgpu_sriov_vf(adev) && !adev->in_runpm);
-		if (r)
-			goto exit;
+	r = amdgpu_amdkfd_resume(adev, !amdgpu_sriov_vf(adev) && !adev->in_runpm);
+	if (r)
+		goto exit;
 
+	if (!adev->in_s0ix) {
 		r = amdgpu_userq_resume(adev);
 		if (r)
 			goto exit;
Signature · 1 line
2.50.1
Reviewed-by on v1 1/1
#1 lore raw

[Public]

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Mario Limonciello
Sent: Tuesday, September 16, 2025 9:21 AM
To: Limonciello, Mario <[email protected]>; [email protected]
Subject: [PATCH] drm/amd: Run KFD suspend and resume routines for s0ix

KFD suspend and resume routines have been disabled since commit 5d3a2d95224da ("drm/amdgpu: skip kfd suspend/resume for S0ix") which made sense at that time. However there is a problem that if there is any compute work running there may still be active fences. Running suspend without draining them can cause the system to hang.

So run KFD suspend/resume routines even in s0ix.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +6 -7
index 0fdfde3dcb9f..59688f8ae919 100644
@@ -5220,10 +5220,9 @@ int amdgpu_device_suspend(struct drm_device *dev, bool notify_clients)
 
        amdgpu_device_ip_suspend_phase1(adev);
 
-       if (!adev->in_s0ix) {
-               amdgpu_amdkfd_suspend(adev, !amdgpu_sriov_vf(adev) && !adev->in_runpm);
+       amdgpu_amdkfd_suspend(adev, !amdgpu_sriov_vf(adev) && !adev->in_runpm);
+       if (!adev->in_s0ix)
                amdgpu_userq_suspend(adev);
-       }
 
        r = amdgpu_device_evict_resources(adev);
        if (r)
@@ -5318,11 +5317,11 @@ int amdgpu_device_resume(struct drm_device *dev, bool notify_clients)
                goto exit;
        }
 
-       if (!adev->in_s0ix) {
-               r = amdgpu_amdkfd_resume(adev, !amdgpu_sriov_vf(adev) && !adev->in_runpm);
-               if (r)
-                       goto exit;
+       r = amdgpu_amdkfd_resume(adev, !amdgpu_sriov_vf(adev) && !adev->in_runpm);
+       if (r)
+               goto exit;
 
+       if (!adev->in_s0ix) {
                r = amdgpu_userq_resume(adev);
                if (r)
                        goto exit;

--
2.50.1

#2 lore raw
In reply to Mario Limonciello
Quoted 19 lines · Mario Limonciello

KFD suspend and resume routines have been disabled since commit 5d3a2d95224da ("drm/amdgpu: skip kfd suspend/resume for S0ix") which made sense at that time. However there is a problem that if there is any compute work running there may still be active fences. Running suspend without draining them can cause the system to hang.

So run KFD suspend/resume routines even in s0ix.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
index 0fdfde3dcb9f..59688f8ae919 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_suspend(struct drm_device *dev, bool notify_clients) · line 5225

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -2
@@ -5220,10 +5220,9 @@ int amdgpu_device_suspend(struct drm_device *dev, bool notify_clients)
 
        amdgpu_device_ip_suspend_phase1(adev);
 
-       if (!adev->in_s0ix) {
-               amdgpu_amdkfd_suspend(adev, !amdgpu_sriov_vf(adev) && !adev->in_runpm);
+       amdgpu_amdkfd_suspend(adev, !amdgpu_sriov_vf(adev) && !adev->in_runpm);
+       if (!adev->in_s0ix)
                amdgpu_userq_suspend(adev);

KGD user queues have the same requirements as KFD user queues so this should be called as well.

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -1
-       }
 
        r = amdgpu_device_evict_resources(adev);
        if (r)
@@ -5318,11 +5317,11 @@ int amdgpu_device_resume(struct drm_device *dev, bool notify_clients)
                goto exit;
        }
 

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_resume(struct drm_device *dev, bool notify_clients) · line 5325

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4 -4
-       if (!adev->in_s0ix) {
-               r = amdgpu_amdkfd_resume(adev, !amdgpu_sriov_vf(adev) && !adev->in_runpm);
-               if (r)
-                       goto exit;
+       r = amdgpu_amdkfd_resume(adev, !amdgpu_sriov_vf(adev) && !adev->in_runpm);
+       if (r)
+               goto exit;
 
+       if (!adev->in_s0ix) {
                r = amdgpu_userq_resume(adev);

Same here.

Alex

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -1
                if (r)
                        goto exit;
--

2.50.1