Skip to contentSkip to conversation

drm/amdgpu: Fix module unload hang with RAS enabled

PATCH In review Mukul Joshi 2 participants 2 messages Jan 23, 2024 – Jan 24, 2024

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

PATCH 1/1 drm/amdgpu: Fix module unload hang with RAS enabled

The driver unload hangs because the page retirement kthread cannot be stopped as it is sleeping and waiting on page retirement event to occur. Add kthread_should_stop() to the event condition to wake up the kthread when kthread stop is called during driver unload.

Fixes 45c3d468793d ("drm/amdgpu: Prepare for asynchronous processing of umc page retirement")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +4 -0
index a32e7eb31354..80816c4ec1f1 100644
@@ -2670,8 +2670,12 @@ static int amdgpu_ras_page_retirement_thread(void *param)
 	while (!kthread_should_stop()) {
 
 		wait_event_interruptible(con->page_retirement_wq,
+				kthread_should_stop() ||
 				atomic_read(&con->page_retirement_req_cnt));
 
+		if (kthread_should_stop())
+			break;
+
 		dev_info(adev->dev, "Start processing page retirement. request:%d\n",
 			atomic_read(&con->page_retirement_req_cnt));
 
Signature · 1 line
2.35.1
Reviewed-by on v1 1/1
#1 lore raw

[AMD Official Use Only - General]

Regards,
Hawking
-----Original Message-----
From: Joshi, Mukul <[email protected]>
Sent: Wednesday, January 24, 2024 05:01
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Chai, Thomas <[email protected]>; Joshi, Mukul <[email protected]>
Subject: [PATCH] drm/amdgpu: Fix module unload hang with RAS enabled

The driver unload hangs because the page retirement kthread cannot be stopped as it is sleeping and waiting on page retirement event to occur. Add kthread_should_stop() to the event condition to wake up the kthread when kthread stop is called during driver unload.

Fixes 45c3d468793d ("drm/amdgpu: Prepare for asynchronous processing of umc page retirement")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +4 -0
index a32e7eb31354..80816c4ec1f1 100644
@@ -2670,8 +2670,12 @@ static int amdgpu_ras_page_retirement_thread(void *param)
        while (!kthread_should_stop()) {
 
                wait_event_interruptible(con->page_retirement_wq,
+                               kthread_should_stop() ||
                                atomic_read(&con->page_retirement_req_cnt));
 
+               if (kthread_should_stop())
+                       break;
+
                dev_info(adev->dev, "Start processing page retirement. request:%d\n",
                        atomic_read(&con->page_retirement_req_cnt));
 

--
2.35.1