Skip to contentSkip to conversation

accel/ivpu: Fix race condition when mapping dmabuf

PATCH In review Karol Wachowski 2 participants 3 messages Oct 14, 2025 – Oct 15, 2025

Subsystems (2)
lore
Share & tools
lore

Karol Wachowski

author maintainer
#0 lore raw

PATCH 1/1 accel/ivpu: Fix race condition when mapping dmabuf

From: "Wludzik, Jozef" <[email protected]>

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 e0c0891cd63b ("accel/ivpu: Rework bind/unbind of imported buffers")
---
 drivers/accel/ivpu/ivpu_gem.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/accel/ivpu/ivpu_gem.c +2 -1
index e9830ad48d4b..e7277e02840a 100644
@@ -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))
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Karol Wachowski

From: "Wludzik, Jozef" <[email protected]>

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 e0c0891cd63b ("accel/ivpu: Rework bind/unbind of imported buffers")
author maintainer Applied
#2 lore raw
Quoted 7 lines · Jeff Hugo
Quoted 6 lines · Karol Wachowski

From: "Wludzik, Jozef" <[email protected]>

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.

Quoted 6 lines
Quoted 4 lines
Fixes e0c0891cd63b ("accel/ivpu: Rework bind/unbind of imported

buffers")

Pushed to drm-misc-next.

-Karol