]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/msm: Drop queued submits on lastclose()
authorRob Clark <robdclark@chromium.org>
Sun, 29 Jun 2025 20:13:03 +0000 (13:13 -0700)
committerRob Clark <robin.clark@oss.qualcomm.com>
Sat, 5 Jul 2025 00:48:36 +0000 (17:48 -0700)
If we haven't written the submit into the ringbuffer yet, then drop it.
The submit still retires through the normal path, to preserve fence
signalling order, but we can skip the IB's to userspace cmdstream.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com>
Tested-by: Antonino Maniscalco <antomani103@gmail.com>
Reviewed-by: Antonino Maniscalco <antomani103@gmail.com>
Patchwork: https://patchwork.freedesktop.org/patch/661489/

drivers/gpu/drm/msm/msm_drv.c
drivers/gpu/drm/msm/msm_gpu.h
drivers/gpu/drm/msm/msm_ringbuffer.c

index 728f7d86c31cdc078069448b2411abf66a4e589d..91ced01041c91e8e4516d5c1f60a8f94bbeaef6d 100644 (file)
@@ -254,6 +254,7 @@ static int msm_open(struct drm_device *dev, struct drm_file *file)
 
 static void context_close(struct msm_context *ctx)
 {
+       ctx->closed = true;
        msm_submitqueue_close(ctx);
        msm_context_put(ctx);
 }
index 231577656fae91b9bd85bf4442d9d9d5465cd6f5..a35e1c7bbcdd30706f15e9d5115832a222da7994 100644 (file)
@@ -356,6 +356,14 @@ struct msm_context {
         */
        int queueid;
 
+       /**
+        * @closed: The device file associated with this context has been closed.
+        *
+        * Once the device is closed, any submits that have not been written
+        * to the ring buffer are no-op'd.
+        */
+       bool closed;
+
        /** @vm: the per-process GPU address-space */
        struct drm_gpuvm *vm;
 
index 552b8da9e5f786c26439990b0cf3b26abb50d71e..b2f612e5dc79339018c50e545ef0a949ab23177c 100644 (file)
@@ -17,6 +17,7 @@ static struct dma_fence *msm_job_run(struct drm_sched_job *job)
        struct msm_fence_context *fctx = submit->ring->fctx;
        struct msm_gpu *gpu = submit->gpu;
        struct msm_drm_private *priv = gpu->dev->dev_private;
+       unsigned nr_cmds = submit->nr_cmds;
        int i;
 
        msm_fence_init(submit->hw_fence, fctx);
@@ -36,8 +37,13 @@ static struct dma_fence *msm_job_run(struct drm_sched_job *job)
        /* TODO move submit path over to using a per-ring lock.. */
        mutex_lock(&gpu->lock);
 
+       if (submit->queue->ctx->closed)
+               submit->nr_cmds = 0;
+
        msm_gpu_submit(gpu, submit);
 
+       submit->nr_cmds = nr_cmds;
+
        mutex_unlock(&gpu->lock);
 
        return dma_fence_get(submit->hw_fence);