From 9a5ca59d2b7b209e6f56dd3f94d4ae6f06e1ecdc Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Wed, 15 Oct 2014 16:51:42 +0100 Subject: [PATCH] sna: Prevent recursion during last-gasp disabling of outputs If we fail an execbuffer, we disable outputs and try again. (In case we have severe fragmentation issues and need to rearrange the scanouts in GTT.) Afterwards we re-enable the outputs, but this causes us to flush the pending rendering and so recurse into the execbuffer. Prevent this with a slight hack during enabling of outputs. References: https://bugs.freedesktop.org/show_bug.cgi?id=85058 Signed-off-by: Chris Wilson --- src/sna/kgem.c | 6 +++++- src/sna/sna_display.c | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/sna/kgem.c b/src/sna/kgem.c index 548ea382..a6aa2757 100644 --- a/src/sna/kgem.c +++ b/src/sna/kgem.c @@ -3088,6 +3088,7 @@ out_4096: } if (!__kgem_busy(kgem, bo->handle)) { + assert(RQ(bo->rq)->bo == bo); __kgem_retire_rq(kgem, RQ(bo->rq)); goto out_4096; } @@ -3233,6 +3234,7 @@ retry: ret = do_ioctl(kgem->fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, execbuf); + DBG(("%s: last_gasp ret=%d\n", __FUNCTION__, ret)); sna_mode_enable(container_of(kgem, struct sna, kgem)); } errno = err; @@ -3273,11 +3275,13 @@ void _kgem_submit(struct kgem *kgem) __kgem_batch_debug(kgem, batch_end); #endif - rq = kgem->next_request; if (kgem->surface != kgem->batch_size) size = compact_batch_surface(kgem); else size = kgem->nbatch * sizeof(kgem->batch[0]); + + rq = kgem->next_request; + assert(rq->bo == NULL); rq->bo = kgem_create_batch(kgem, size); if (rq->bo) { uint32_t handle = rq->bo->handle; diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c index 2ab928f3..37b1f5bd 100644 --- a/src/sna/sna_display.c +++ b/src/sna/sna_display.c @@ -2260,7 +2260,9 @@ retry: /* Attach per-crtc pixmap or direct */ goto error; } - kgem_bo_submit(&sna->kgem, bo); + /* Prevent recursion when enabling outputs during execbuffer */ + if (bo->exec && RQ(bo->rq)->bo == NULL) + _kgem_submit(&sna->kgem); sna_crtc->bo = bo; if (!sna_crtc_apply(crtc)) {