AMD-GFX Archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: Fix module unload hang with RAS enabled
@ 2024-01-23 21:00 Mukul Joshi
  2024-01-24  4:24 ` Zhang, Hawking
  0 siblings, 1 reply; 2+ messages in thread
From: Mukul Joshi @ 2024-01-23 21:00 UTC (permalink / raw
  To: amd-gfx; +Cc: Mukul Joshi, YiPeng.Chai, hawking.zhang

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")
Signed-off-by: Mukul Joshi <mukul.joshi@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
index a32e7eb31354..80816c4ec1f1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
@@ -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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* RE: [PATCH] drm/amdgpu: Fix module unload hang with RAS enabled
  2024-01-23 21:00 [PATCH] drm/amdgpu: Fix module unload hang with RAS enabled Mukul Joshi
@ 2024-01-24  4:24 ` Zhang, Hawking
  0 siblings, 0 replies; 2+ messages in thread
From: Zhang, Hawking @ 2024-01-24  4:24 UTC (permalink / raw
  To: Joshi, Mukul, amd-gfx@lists.freedesktop.org; +Cc: Chai, Thomas

[AMD Official Use Only - General]

Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>

Regards,
Hawking
-----Original Message-----
From: Joshi, Mukul <Mukul.Joshi@amd.com>
Sent: Wednesday, January 24, 2024 05:01
To: amd-gfx@lists.freedesktop.org
Cc: Zhang, Hawking <Hawking.Zhang@amd.com>; Chai, Thomas <YiPeng.Chai@amd.com>; Joshi, Mukul <Mukul.Joshi@amd.com>
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")
Signed-off-by: Mukul Joshi <mukul.joshi@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
index a32e7eb31354..80816c4ec1f1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
@@ -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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-01-24  4:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-23 21:00 [PATCH] drm/amdgpu: Fix module unload hang with RAS enabled Mukul Joshi
2024-01-24  4:24 ` Zhang, Hawking

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).