[PATCH v5 24/27] drm/amdkfd: Scope all KFD queued work with drm_dev_enter/exit

Andrey Grodzovsky andrey.grodzovsky at amd.com
Wed Apr 28 15:12:04 UTC 2021


To allow completion and further block of HW accesses post device PCI
remove.

Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky at amd.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c b/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c
index bc47f6a44456..563f02ab5b95 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_interrupt.c
@@ -43,8 +43,10 @@
 #include <linux/slab.h>
 #include <linux/device.h>
 #include <linux/kfifo.h>
+#include <drm/drm_drv.h>
 #include "kfd_priv.h"
 
+
 #define KFD_IH_NUM_ENTRIES 8192
 
 static void interrupt_wq(struct work_struct *);
@@ -145,15 +147,21 @@ static void interrupt_wq(struct work_struct *work)
 	struct kfd_dev *dev = container_of(work, struct kfd_dev,
 						interrupt_work);
 	uint32_t ih_ring_entry[KFD_MAX_RING_ENTRY_SIZE];
+	int idx;
 
 	if (dev->device_info->ih_ring_entry_size > sizeof(ih_ring_entry)) {
 		dev_err_once(kfd_chardev(), "Ring entry too small\n");
 		return;
 	}
 
-	while (dequeue_ih_ring_entry(dev, ih_ring_entry))
-		dev->device_info->event_interrupt_class->interrupt_wq(dev,
-								ih_ring_entry);
+	if (drm_dev_enter(dev->ddev, &idx)) {
+
+		while (dequeue_ih_ring_entry(dev, ih_ring_entry))
+			dev->device_info->event_interrupt_class->interrupt_wq(dev,
+									ih_ring_entry);
+
+		drm_dev_exit(idx);
+	}
 }
 
 bool interrupt_is_wanted(struct kfd_dev *dev,
-- 
2.25.1



More information about the amd-gfx mailing list