aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/accel
diff options
context:
space:
mode:
authorJacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com>2024-01-15 14:44:31 +0100
committerJacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com>2024-01-22 10:28:46 +0100
commita8c099d5d0e4b0400cfddfd95b881c8bd9349a88 (patch)
tree32c4458874bdea325815f55788e0135a4ecbb6ce /drivers/accel
parent7f66319927a8ced3be715eb7616a890b9bf0348b (diff)
downloadlinux-a8c099d5d0e4b0400cfddfd95b881c8bd9349a88.tar.gz
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 <jacek.lawrynowicz@linux.intel.com> Reviewed-by: Jeffrey Hugo <quic_jhugo@quicinc.com> Link: https://patchwork.freedesktop.org/patch/msgid/20240115134434.493839-7-jacek.lawrynowicz@linux.intel.com
Diffstat (limited to 'drivers/accel')
-rw-r--r--drivers/accel/ivpu/ivpu_gem.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/drivers/accel/ivpu/ivpu_gem.c b/drivers/accel/ivpu/ivpu_gem.c
index 6890d33cf3528..4de454bfbf917 100644
--- a/drivers/accel/ivpu/ivpu_gem.c
+++ b/drivers/accel/ivpu/ivpu_gem.c
@@ -112,8 +112,6 @@ static void ivpu_bo_unbind_locked(struct ivpu_bo *bo)
ivpu_dbg_bo(vdev, bo, "unbind");
- /* TODO: dma_unmap */
-
if (bo->mmu_mapped) {
drm_WARN_ON(&vdev->drm, !bo->ctx);
drm_WARN_ON(&vdev->drm, !bo->vpu_addr);
@@ -127,6 +125,18 @@ static void ivpu_bo_unbind_locked(struct ivpu_bo *bo)
bo->vpu_addr = 0;
bo->ctx = NULL;
}
+
+ if (bo->base.base.import_attach)
+ return;
+
+ dma_resv_lock(bo->base.base.resv, NULL);
+ if (bo->base.sgt) {
+ dma_unmap_sgtable(vdev->drm.dev, bo->base.sgt, DMA_BIDIRECTIONAL, 0);
+ sg_free_table(bo->base.sgt);
+ kfree(bo->base.sgt);
+ bo->base.sgt = NULL;
+ }
+ dma_resv_unlock(bo->base.base.resv);
}
static void ivpu_bo_unbind(struct ivpu_bo *bo)