Signal the render-node eventfd manager directly through the userq
manager associated with the queue.

v2:
This avoids walking queue -> file -> driver_priv in the IRQ path and
drops the READ_ONCE() usage there. The userq manager holds an optional
direct pointer to the per-file eventfd manager, which may be NULL.

Cc: Alex Deucher <[email protected]>
Cc: Christian König <[email protected]>
Signed-off-by: Srinivasan Shanmugam <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 27 +++++++++++++++++++++-----
 1 file changed, 22 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c 
b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
index b1a1b8a10a08..e399d8c79a0e 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
@@ -26,6 +26,8 @@
 #include <linux/module.h>
 #include <linux/pci.h>
 #include "amdgpu.h"
+#include "amdgpu_userq.h"
+#include "amdgpu_eventfd.h"
 #include "amdgpu_gfx.h"
 #include "amdgpu_psp.h"
 #include "amdgpu_smu.h"
@@ -54,6 +56,8 @@
 #define GFX11_NUM_GFX_RINGS            1
 #define GFX11_MEC_HPD_SIZE     2048
 
+#define AMDGPU_EVENT_ID_USERQ_EOP 1
+
 #define RLCG_UCODE_LOADING_START_ADDRESS       0x00002000L
 #define RLC_PG_DELAY_3_DEFAULT_GC_11_0_1       0x1388
 
@@ -6488,14 +6492,27 @@ static int gfx_v11_0_eop_irq(struct amdgpu_device *adev,
        DRM_DEBUG("IH: CP EOP\n");
 
        if (adev->enable_mes && doorbell_offset) {
-               struct amdgpu_userq_fence_driver *fence_drv = NULL;
-               struct xarray *xa = &adev->userq_xa;
+               struct amdgpu_usermode_queue *queue = NULL;
+               struct amdgpu_fpriv *fpriv = NULL;
+               struct amdgpu_userq_mgr *mgr = NULL;
+               struct xarray *xa = &adev->userq_doorbell_xa;
                unsigned long flags;
 
                xa_lock_irqsave(xa, flags);
-               fence_drv = xa_load(xa, doorbell_offset);
-               if (fence_drv)
-                       amdgpu_userq_fence_driver_process(fence_drv);
+               queue = xa_load(xa, doorbell_offset);
+
+               if (queue && queue->fence_drv)
+                       amdgpu_userq_fence_driver_process(queue->fence_drv);
+
+               /*
+                * Signal the render-node eventfd manager associated with
+                * this queue. The pointer is optional and may be NULL.
+                */
+               if (queue)
+                       mgr = queue->userq_mgr;
+               if (mgr && mgr->eventfd_mgr)
+                       amdgpu_eventfd_signal(mgr->eventfd_mgr,
+                                             AMDGPU_EVENT_ID_USERQ_EOP);
                xa_unlock_irqrestore(xa, flags);
        } else {
                me_id = (entry->ring_id & 0x0c) >> 2;
-- 
2.34.1

Reply via email to