Skip to content

Commit c8af219

Browse files
committed
drm/msm: Don't overwrite hw fence in hw_init
Prior to the last commit, this could result in setting the GPU written fence value back to an older value, if we had missed updating completed_fence prior to suspend. This was mostly harmless as the GPU would eventually overwrite it again with the correct value. But we should just not do this. Instead just leave a sanity check that the fence looks plausible (in case the GPU scribbled on memory). 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/490138/ Link: https://lore.kernel.org/r/20220618161120.3451993-2-robdclark@gmail.com
1 parent 3c7a522 commit c8af219

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

drivers/gpu/drm/msm/adreno/adreno_gpu.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -498,10 +498,15 @@ int adreno_hw_init(struct msm_gpu *gpu)
498498

499499
ring->cur = ring->start;
500500
ring->next = ring->start;
501-
502-
/* reset completed fence seqno: */
503-
ring->memptrs->fence = ring->fctx->completed_fence;
504501
ring->memptrs->rptr = 0;
502+
503+
/* Detect and clean up an impossible fence, ie. if GPU managed
504+
* to scribble something invalid, we don't want that to confuse
505+
* us into mistakingly believing that submits have completed.
506+
*/
507+
if (fence_before(ring->fctx->last_fence, ring->memptrs->fence)) {
508+
ring->memptrs->fence = ring->fctx->last_fence;
509+
}
505510
}
506511

507512
return 0;

drivers/gpu/drm/msm/msm_gpu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ static void recover_worker(struct kthread_work *work)
418418
* one more to clear the faulting submit
419419
*/
420420
if (ring == cur_ring)
421-
fence++;
421+
ring->memptrs->fence = ++fence;
422422

423423
msm_update_fence(ring->fctx, fence);
424424
}

0 commit comments

Comments
 (0)