Skip to content

Commit a8c099d

Browse files
committed
accel/ivpu: Free buffer sgt on unbind
Call dma_unmap() on all buffers before the VPU is unbinded to avoid "device driver has pending DMA allocations while released from device" warning when DMA-API debug is enabled. Signed-off-by: Jacek Lawrynowicz <[email protected]> Reviewed-by: Jeffrey Hugo <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 7f66319 commit a8c099d

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

drivers/accel/ivpu/ivpu_gem.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,6 @@ static void ivpu_bo_unbind_locked(struct ivpu_bo *bo)
112112

113113
ivpu_dbg_bo(vdev, bo, "unbind");
114114

115-
/* TODO: dma_unmap */
116-
117115
if (bo->mmu_mapped) {
118116
drm_WARN_ON(&vdev->drm, !bo->ctx);
119117
drm_WARN_ON(&vdev->drm, !bo->vpu_addr);
@@ -127,6 +125,18 @@ static void ivpu_bo_unbind_locked(struct ivpu_bo *bo)
127125
bo->vpu_addr = 0;
128126
bo->ctx = NULL;
129127
}
128+
129+
if (bo->base.base.import_attach)
130+
return;
131+
132+
dma_resv_lock(bo->base.base.resv, NULL);
133+
if (bo->base.sgt) {
134+
dma_unmap_sgtable(vdev->drm.dev, bo->base.sgt, DMA_BIDIRECTIONAL, 0);
135+
sg_free_table(bo->base.sgt);
136+
kfree(bo->base.sgt);
137+
bo->base.sgt = NULL;
138+
}
139+
dma_resv_unlock(bo->base.base.resv);
130140
}
131141

132142
static void ivpu_bo_unbind(struct ivpu_bo *bo)

0 commit comments

Comments
 (0)