Skip to content

Commit 3c7a522

Browse files
committed
drm/msm: Drop update_fences()
I noticed while looking at some traces, that we could miss calls to msm_update_fence(), as the irq could have raced with retire_submits() which could have already popped the last submit on a ring out of the queue of in-flight submits. But walking the list of submits in the irq handler isn't really needed, as dma_fence_is_signaled() will dtrt. So lets just drop it entirely. v2: use spin_lock_irqsave/restore as we are no longer protected by the spin_lock_irqsave/restore() in update_fences() Reported-by: Steev Klimaszewski <steev@kali.org> Fixes: 95d1deb ("drm/msm/gem: Add fenced vma unpin") Signed-off-by: Rob Clark <robdclark@chromium.org> Tested-by: Steev Klimaszewski <steev@kali.org> Patchwork: https://patchwork.freedesktop.org/patch/490136/ Link: https://lore.kernel.org/r/20220618161120.3451993-1-robdclark@gmail.com
1 parent b4d329c commit 3c7a522

2 files changed

Lines changed: 7 additions & 23 deletions

File tree

drivers/gpu/drm/msm/msm_fence.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,14 @@ bool msm_fence_completed(struct msm_fence_context *fctx, uint32_t fence)
4646
(int32_t)(*fctx->fenceptr - fence) >= 0;
4747
}
4848

49-
/* called from workqueue */
49+
/* called from irq handler and workqueue (in recover path) */
5050
void msm_update_fence(struct msm_fence_context *fctx, uint32_t fence)
5151
{
52-
spin_lock(&fctx->spinlock);
52+
unsigned long flags;
53+
54+
spin_lock_irqsave(&fctx->spinlock, flags);
5355
fctx->completed_fence = max(fence, fctx->completed_fence);
54-
spin_unlock(&fctx->spinlock);
56+
spin_unlock_irqrestore(&fctx->spinlock, flags);
5557
}
5658

5759
struct msm_fence {

drivers/gpu/drm/msm/msm_gpu.c

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -164,24 +164,6 @@ int msm_gpu_hw_init(struct msm_gpu *gpu)
164164
return ret;
165165
}
166166

167-
static void update_fences(struct msm_gpu *gpu, struct msm_ringbuffer *ring,
168-
uint32_t fence)
169-
{
170-
struct msm_gem_submit *submit;
171-
unsigned long flags;
172-
173-
spin_lock_irqsave(&ring->submit_lock, flags);
174-
list_for_each_entry(submit, &ring->submits, node) {
175-
if (fence_after(submit->seqno, fence))
176-
break;
177-
178-
msm_update_fence(submit->ring->fctx,
179-
submit->hw_fence->seqno);
180-
dma_fence_signal(submit->hw_fence);
181-
}
182-
spin_unlock_irqrestore(&ring->submit_lock, flags);
183-
}
184-
185167
#ifdef CONFIG_DEV_COREDUMP
186168
static ssize_t msm_gpu_devcoredump_read(char *buffer, loff_t offset,
187169
size_t count, void *data, size_t datalen)
@@ -438,7 +420,7 @@ static void recover_worker(struct kthread_work *work)
438420
if (ring == cur_ring)
439421
fence++;
440422

441-
update_fences(gpu, ring, fence);
423+
msm_update_fence(ring->fctx, fence);
442424
}
443425

444426
if (msm_gpu_active(gpu)) {
@@ -736,7 +718,7 @@ void msm_gpu_retire(struct msm_gpu *gpu)
736718
int i;
737719

738720
for (i = 0; i < gpu->nr_rings; i++)
739-
update_fences(gpu, gpu->rb[i], gpu->rb[i]->memptrs->fence);
721+
msm_update_fence(gpu->rb[i]->fctx, gpu->rb[i]->memptrs->fence);
740722

741723
kthread_queue_work(gpu->worker, &gpu->retire_work);
742724
update_sw_cntrs(gpu);

0 commit comments

Comments
 (0)