[PATCH] drm/amdgpu: Fix the page fault issue in amdgpu_irq_fini

Emily Deng Emily.Deng at amd.com
Thu Mar 18 11:48:12 UTC 2021


For some source, it will be shared by some client ID and source ID.
To fix the page fault issue, set all those to null.

Signed-off-by: Emily Deng <Emily.Deng at amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
index af026109421a..623b1ac6231d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
@@ -359,7 +359,7 @@ int amdgpu_irq_init(struct amdgpu_device *adev)
  */
 void amdgpu_irq_fini(struct amdgpu_device *adev)
 {
-	unsigned i, j;
+	unsigned i, j, m, n;
 
 	if (adev->irq.installed) {
 		drm_irq_uninstall(adev_to_drm(adev));
@@ -380,12 +380,22 @@ void amdgpu_irq_fini(struct amdgpu_device *adev)
 			if (!src)
 				continue;
 
-			kfree(src->enabled_types);
+			if (src->enabled_types)
+				kfree(src->enabled_types);
+
 			src->enabled_types = NULL;
+
 			if (src->data) {
 				kfree(src->data);
 				kfree(src);
-				adev->irq.client[i].sources[j] = NULL;
+			}
+
+			for (m = 0; m < AMDGPU_IRQ_CLIENTID_MAX; ++m) {
+				if (!adev->irq.client[m].sources)
+					continue;
+				for (n = 0; n < AMDGPU_MAX_IRQ_SRC_ID; ++n)
+					if (adev->irq.client[m].sources[n] == src)
+						adev->irq.client[m].sources[n] = NULL;
 			}
 		}
 		kfree(adev->irq.client[i].sources);
-- 
2.25.1



More information about the amd-gfx mailing list