[PATCH 2/2] drm/amdgpu: protected amdgpu_dma_buf_move_notify against hotplug

Christian König ckoenig.leichtzumerken at gmail.com
Thu Jan 20 09:03:37 UTC 2022


Add the proper drm_dev_enter()/drm_dev_exit() calls here.

Signed-off-by: Christian König <christian.koenig at amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
index 8756f505c87d..eb31ba3da403 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
@@ -36,6 +36,7 @@
 #include "amdgpu_gem.h"
 #include "amdgpu_dma_buf.h"
 #include "amdgpu_xgmi.h"
+#include <drm/drm_drv.h>
 #include <drm/amdgpu_drm.h>
 #include <linux/dma-buf.h>
 #include <linux/dma-fence-array.h>
@@ -447,14 +448,18 @@ amdgpu_dma_buf_move_notify(struct dma_buf_attachment *attach)
 	struct ttm_operation_ctx ctx = { false, false };
 	struct ttm_placement placement = {};
 	struct amdgpu_vm_bo_base *bo_base;
-	int r;
+	int idx, r;
 
 	if (bo->tbo.resource->mem_type == TTM_PL_SYSTEM)
 		return;
 
+	if (!drm_dev_enter(adev_to_drm(adev), &idx))
+		return;
+
 	r = ttm_bo_validate(&bo->tbo, &placement, &ctx);
 	if (r) {
 		DRM_ERROR("Failed to invalidate DMA-buf import (%d))\n", r);
+		drm_dev_exit(idx);
 		return;
 	}
 
@@ -490,6 +495,7 @@ amdgpu_dma_buf_move_notify(struct dma_buf_attachment *attach)
 
 		dma_resv_unlock(resv);
 	}
+	drm_dev_exit(idx);
 }
 
 static const struct dma_buf_attach_ops amdgpu_dma_buf_attach_ops = {
-- 
2.25.1



More information about the amd-gfx mailing list