Commit 63c7870f authored by Wludzik, Jozef's avatar Wludzik, Jozef Committed by Karol Wachowski
Browse files

accel/ivpu: Fix race condition when mapping dmabuf



Fix a race that can occur when multiple jobs submit the same dmabuf.
This could cause the sg_table to be mapped twice, leading to undefined
behavior.

Fixes: e0c0891c ("accel/ivpu: Rework bind/unbind of imported buffers")
Signed-off-by: default avatarWludzik, Jozef <jozef.wludzik@intel.com>
Reviewed-by: default avatarJeff Hugo <jeff.hugo@oss.qualcomm.com>
Signed-off-by: default avatarKarol Wachowski <karol.wachowski@linux.intel.com>
Link: https://lore.kernel.org/r/20251014071725.3047287-1-karol.wachowski@linux.intel.com
parent 7fb19ea1
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -46,12 +46,13 @@ static inline void ivpu_bo_unlock(struct ivpu_bo *bo)

static struct sg_table *ivpu_bo_map_attachment(struct ivpu_device *vdev, struct ivpu_bo *bo)
{
	struct sg_table *sgt = bo->base.sgt;
	struct sg_table *sgt;

	drm_WARN_ON(&vdev->drm, !bo->base.base.import_attach);

	ivpu_bo_lock(bo);

	sgt = bo->base.sgt;
	if (!sgt) {
		sgt = dma_buf_map_attachment(bo->base.base.import_attach, DMA_BIDIRECTIONAL);
		if (IS_ERR(sgt))