summaryrefslogtreecommitdiff
path: root/drivers/accel/habanalabs/common/memory.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/accel/habanalabs/common/memory.c')
-rw-r--r--drivers/accel/habanalabs/common/memory.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/accel/habanalabs/common/memory.c b/drivers/accel/habanalabs/common/memory.c
index fd333dd2835e..7fd8e8f87682 100644
--- a/drivers/accel/habanalabs/common/memory.c
+++ b/drivers/accel/habanalabs/common/memory.c
@@ -1835,6 +1835,10 @@ static void hl_release_dmabuf(struct dma_buf *dmabuf)
atomic_dec(&ctx->hdev->dmabuf_export_cnt);
hl_ctx_put(ctx);
+
+ /* Paired with get_file() in export_dmabuf() */
+ fput(ctx->hpriv->filp);
+
kfree(hl_dmabuf);
}
@@ -1875,6 +1879,12 @@ static int export_dmabuf(struct hl_ctx *ctx,
hl_ctx_get(hl_dmabuf->ctx);
atomic_inc(&ctx->hdev->dmabuf_export_cnt);
+ /* Get compute device file to enforce release order, such that all exported dma-buf will be
+ * released first and only then the compute device.
+ * Paired with fput() in hl_release_dmabuf().
+ */
+ get_file(ctx->hpriv->filp);
+
*dmabuf_fd = fd;
return 0;