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

From: Jeff Hugo

Date: Mon Nov 30 2026 - 21:11:11 EST


On 11/19/2026 1:14 AM, Wang Haoran wrote:
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). The
reservation lock also serializes the importer against the exporter
moving or invalidating the buffer's backing storage for a dynamic
attachment, so an unlocked map can race that move and use a stale
sg_table.

Hold the reservation lock around the map and unmap calls, which is
equivalent to the dedicated dma_buf_map_attachment_unlocked() and
dma_buf_unmap_attachment_unlocked() helpers.
Why not use the unlocked() helpers in this instance? Your proposal grabs the lock to call the function, and then immediately unlocks it. Seems like less effort to just use the helpers that you point out are equivalent to what you are doing.

-Jeff