[PATCH v2] accel/qaic: hold dma_resv lock when mapping imported buffers

From: Haoran Wang

Date: Wed Dec 02 2026 - 04:54:50 EST


qaic_prepare_import_bo() maps an imported dma-buf with
dma_buf_map_attachment() and qaic_unprepare_import_bo() unmaps it with
dma_buf_unmap_attachment(). Those are the locked variants: the dma-buf
locking convention requires importers to hold the buffer's reservation
lock when calling them, and both assert it via dma_resv_assert_held(),
i.e. lockdep_assert_held() on attach->dmabuf->resv.

qaic calls both without holding the reservation lock, so on a
lockdep-enabled kernel every slice attach/detach against an imported
buffer trips the lockdep assertion (a WARNING with a backtrace).

Use the dedicated dma_buf_map_attachment_unlocked() and
dma_buf_unmap_attachment_unlocked() helpers, which take the reservation
lock around the map and unmap calls.

Fixes: ff13be830333 ("accel/qaic: Add datapath")
Signed-off-by: Haoran Wang <wanghr2026@xxxxxxxxxxxxxxxxxx>
---

Changes in v2:
- Use dma_buf_map_attachment_unlocked() and
dma_buf_unmap_attachment_unlocked() instead of open-coding
dma_resv_lock()/dma_resv_unlock() (suggested by Jeff).

drivers/accel/qaic/qaic_data.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/accel/qaic/qaic_data.c b/drivers/accel/qaic/qaic_data.c
index ee35e13091b3..1fd24418f6f4 100644
--- a/drivers/accel/qaic/qaic_data.c
+++ b/drivers/accel/qaic/qaic_data.c
@@ -895,7 +895,7 @@ static int qaic_prepare_import_bo(struct qaic_bo *bo, struct qaic_attach_slice_h
struct sg_table *sgt;
int ret;

- sgt = dma_buf_map_attachment(obj->import_attach, hdr->dir);
+ sgt = dma_buf_map_attachment_unlocked(obj->import_attach, hdr->dir);
if (IS_ERR(sgt)) {
ret = PTR_ERR(sgt);
return ret;
@@ -936,7 +936,7 @@ static int qaic_prepare_bo(struct qaic_device *qdev, struct qaic_bo *bo,

static void qaic_unprepare_import_bo(struct qaic_bo *bo)
{
- dma_buf_unmap_attachment(bo->base.import_attach, bo->sgt, bo->dir);
+ dma_buf_unmap_attachment_unlocked(bo->base.import_attach, bo->sgt, bo->dir);
bo->sgt = NULL;
}