]> www.infradead.org Git - users/hch/misc.git/commitdiff
drm/v3d: create a dedicated lock for dma fence
authorMelissa Wen <mwen@igalia.com>
Tue, 16 Sep 2025 17:18:28 +0000 (14:18 -0300)
committerMelissa Wen <melissa.srw@gmail.com>
Tue, 30 Sep 2025 15:28:14 +0000 (14:28 -0100)
Don't mix dma fence lock with the active_job lock. Use fence_lock to
protect the dma fence used by drm scheduler when signalling a job
completion and queue_lock to protect concurrent access to active bin job
in OOM and stats collection for a given file priv. The issue was
uncovered when PREEMPT_RT on with a system freeze when opening multiple
Chromium tabs on Raspberry Pi 5.

Link: https://github.com/raspberrypi/linux/issues/7035
Fixes: fa6a20c87470 ("drm/v3d: Address race-condition between per-fd GPU stats and fd release")
Signed-off-by: Melissa Wen <mwen@igalia.com>
Acked-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-by: MaĆ­ra Canal <mcanal@igalia.com>
Signed-off-by: Melissa Wen <melissa.srw@gmail.com>
Link: https://lore.kernel.org/r/20250916172022.2779837-1-mwen@igalia.com
drivers/gpu/drm/v3d/v3d_drv.h
drivers/gpu/drm/v3d/v3d_fence.c
drivers/gpu/drm/v3d/v3d_gem.c

index 0317f3d7452a3f01b91bfdc691b5a98e54b3a4ec..1884686985b80a4fd01f673cbb2ad896a57e9049 100644 (file)
@@ -62,6 +62,8 @@ struct v3d_queue_state {
        /* Currently active job for this queue */
        struct v3d_job *active_job;
        spinlock_t queue_lock;
+       /* Protect dma fence for signalling job completion */
+       spinlock_t fence_lock;
 };
 
 /* Performance monitor object. The perform lifetime is controlled by userspace
index 8f8471adae34af7a444f5eeca4ef08d66ac1b7b5..c82500a1df73bc454cd09ff04bf7a78833a3e473 100644 (file)
@@ -15,7 +15,7 @@ struct dma_fence *v3d_fence_create(struct v3d_dev *v3d, enum v3d_queue q)
        fence->dev = &v3d->drm;
        fence->queue = q;
        fence->seqno = ++queue->emit_seqno;
-       dma_fence_init(&fence->base, &v3d_fence_ops, &queue->queue_lock,
+       dma_fence_init(&fence->base, &v3d_fence_ops, &queue->fence_lock,
                       queue->fence_context, fence->seqno);
 
        return &fence->base;
index c77d90aa9b829900147dae0778f42477c8ba1bf6..bb110d35f74980aac9ad53271ddf2b64b96c686d 100644 (file)
@@ -273,6 +273,7 @@ v3d_gem_init(struct drm_device *dev)
                seqcount_init(&queue->stats.lock);
 
                spin_lock_init(&queue->queue_lock);
+               spin_lock_init(&queue->fence_lock);
        }
 
        spin_lock_init(&v3d->mm_lock);