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).
Unified · Split
| @@ -498,10 +498,15 @@ int adreno_hw_init(struct msm_gpu *gpu) · 497 unmodified lines | ||
| 498 | 498 | |
| 499 | 499 | ring->cur = ring->start; |
| 500 | 500 | ring->next = ring->start; |
| 501 | − | |
| 502 | − /* reset completed fence seqno: */ | |
| 503 | − ring->memptrs->fence = ring->fctx->completed_fence; | |
| 504 | 501 | 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 | + } | |
| 505 | 510 | } |
| 506 | 511 | |
| 507 | 512 | return 0; |
| @@ -418,7 +418,7 @@ static void recover_worker(struct kthread_work *work) · 417 unmodified lines | ||
| 418 | 418 | * one more to clear the faulting submit |
| 419 | 419 | */ |
| 420 | 420 | if (ring == cur_ring) |
| 421 | − fence++; | |
| 421 | + ring->memptrs->fence = ++fence; | |
| 422 | 422 | |
| 423 | 423 | msm_update_fence(ring->fctx, fence); |
| 424 | 424 | } |