drm/v3d: create a dedicated lock for dma fence
Subsystems (3)
Melissa Wen
maintainerPATCH 1/1 drm/v3d: create a dedicated lock for dma fence
Don't mix dma fence lock with the active_job lock. The issue was uncovered when PREEMPT_RT on.
--- drivers/gpu/drm/v3d/v3d_drv.h | 1 + drivers/gpu/drm/v3d/v3d_fence.c | 2 +- drivers/gpu/drm/v3d/v3d_gem.c | 1 + 3 files changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/v3d/v3d_drv.h +1 -0
@@ -62,6 +62,7 @@ struct v3d_queue_state {/* Currently active job for this queue */ struct v3d_job *active_job;spinlock_t queue_lock; +spinlock_t fence_lock; };/* Performance monitor object. The perform lifetime is controlled by userspace
drivers/gpu/drm/v3d/v3d_fence.c +1 -1
@@ -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;
drivers/gpu/drm/v3d/v3d_gem.c +1 -0
@@ -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);
Signature · 1 line
2.47.2
Thanks Melissa!
Quoted 57 lines · Melissa Wen
Don't mix dma fence lock with the
active_joblock. The issue was uncovered whenPREEMPT_RTon.Fixes fa6a20c87470 ("drm/v3d: Address race-condition between per-fdGPU stats and fd release")
Signed-off-by Melissa Wen <[email protected]>---
drivers/gpu/drm/v3d/v3d_drv.h | 1 +
drivers/gpu/drm/v3d/v3d_fence.c | 2 +-
drivers/gpu/drm/v3d/v3d_gem.c | 1 +3 files changed, 3 insertions(+), 1 deletion(-)drivers/gpu/drm/v3d/v3d_drv.h +1
-0@@ -62,6 +62,7 @@ struct v3d_queue_state { /* Currently active job for this queue */ struct v3d_job *active_job; spinlock_t queue_lock; +spinlock_t fence_lock; };
/* Performance monitor object. The perform lifetime is controlled by userspacedrivers/gpu/drm/v3d/v3d_fence.c +1
-1@@ -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;drivers/gpu/drm/v3d/v3d_gem.c +0
-0@@ -273,6 +273,7 @@ v3d_gem_init(struct drm_device *dev) seqcount_init(&queue->stats.lock);
spin_lock_init(&queue->queue_lock);drivers/gpu/drm/v3d/v3d_gem.c +1
-0+spin_lock_init (&queue->fence_lock);}
spin_lock_init(&v3d->mm_lock);
Hi Melissa,
Quoted 2 lines · Melissa Wen
Don't mix dma fence lock with the
active_joblock. The issue was uncovered whenPREEMPT_RTon.
Maybe you could add a bit more detail about the issue in the commit message? If I wasn't already familiar to the issue, I believe I wouldn't be able to understand it from the commit message.
Quoted 4 lines
Fixes fa6a20c87470 ("drm/v3d: Address race-condition between per-fd GPU stats and fd release")Signed-off-by Melissa Wen <[email protected]>
Thanks for fixing this issue!
Best Regards,
- Maíra
Quoted 39 lines
--- drivers/gpu/drm/v3d/v3d_drv.h | 1 + drivers/gpu/drm/v3d/v3d_fence.c | 2 +- drivers/gpu/drm/v3d/v3d_gem.c | 1 + 3 files changed, 3 insertions(+), 1 deletion(-)drivers/gpu/drm/v3d/v3d_drv.h +1
-0@@ -62,6 +62,7 @@ struct v3d_queue_state {/* Currently active job for this queue */ struct v3d_job *active_job;spinlock_t queue_lock; +spinlock_t fence_lock; };/* Performance monitor object. The perform lifetime is controlled by userspace drivers/gpu/drm/v3d/v3d_fence.c +1
-1@@ -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;drivers/gpu/drm/v3d/v3d_gem.c +1
-0@@ -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);