modesetting: Extract flip failure logging to a single place
Reviewed-by: Eero Tamminen <eero.t.tamminen@intel.com> Signed-off-by: Povilas Kanapickas <povilas@radix.lt>
This commit is contained in:
parent
9adb13e296
commit
9992245c5f
|
@ -167,7 +167,14 @@ do_queue_flip_on_crtc(modesettingPtr ms, xf86CrtcPtr crtc,
|
|||
(void *) (uintptr_t) seq);
|
||||
}
|
||||
|
||||
static Bool
|
||||
enum queue_flip_status {
|
||||
QUEUE_FLIP_SUCCESS,
|
||||
QUEUE_FLIP_ALLOC_FAILED,
|
||||
QUEUE_FLIP_QUEUE_ALLOC_FAILED,
|
||||
QUEUE_FLIP_DRM_FLUSH_FAILED,
|
||||
};
|
||||
|
||||
static int
|
||||
queue_flip_on_crtc(ScreenPtr screen, xf86CrtcPtr crtc,
|
||||
struct ms_flipdata *flipdata,
|
||||
int ref_crtc_vblank_pipe, uint32_t flags)
|
||||
|
@ -177,13 +184,10 @@ queue_flip_on_crtc(ScreenPtr screen, xf86CrtcPtr crtc,
|
|||
drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
|
||||
struct ms_crtc_pageflip *flip;
|
||||
uint32_t seq;
|
||||
int err;
|
||||
|
||||
flip = calloc(1, sizeof(struct ms_crtc_pageflip));
|
||||
if (flip == NULL) {
|
||||
xf86DrvMsg(scrn->scrnIndex, X_WARNING,
|
||||
"flip queue: carrier alloc failed.\n");
|
||||
return FALSE;
|
||||
return QUEUE_FLIP_ALLOC_FAILED;
|
||||
}
|
||||
|
||||
/* Only the reference crtc will finally deliver its page flip
|
||||
|
@ -195,24 +199,21 @@ queue_flip_on_crtc(ScreenPtr screen, xf86CrtcPtr crtc,
|
|||
seq = ms_drm_queue_alloc(crtc, flip, ms_pageflip_handler, ms_pageflip_abort);
|
||||
if (!seq) {
|
||||
free(flip);
|
||||
return FALSE;
|
||||
return QUEUE_FLIP_QUEUE_ALLOC_FAILED;
|
||||
}
|
||||
|
||||
/* take a reference on flipdata for use in flip */
|
||||
flipdata->flip_count++;
|
||||
|
||||
while (do_queue_flip_on_crtc(ms, crtc, flags, seq)) {
|
||||
err = errno;
|
||||
/* We may have failed because the event queue was full. Flush it
|
||||
* and retry. If there was nothing to flush, then we failed for
|
||||
* some other reason and should just return an error.
|
||||
*/
|
||||
if (ms_flush_drm_events(screen) <= 0) {
|
||||
xf86DrvMsg(scrn->scrnIndex, X_WARNING,
|
||||
"flip queue failed: %s\n", strerror(err));
|
||||
/* Aborting will also decrement flip_count and free(flip). */
|
||||
ms_drm_abort_seq(scrn, seq);
|
||||
return FALSE;
|
||||
return QUEUE_FLIP_DRM_FLUSH_FAILED;
|
||||
}
|
||||
|
||||
/* We flushed some events, so try again. */
|
||||
|
@ -220,7 +221,7 @@ queue_flip_on_crtc(ScreenPtr screen, xf86CrtcPtr crtc,
|
|||
}
|
||||
|
||||
/* The page flip succeeded. */
|
||||
return TRUE;
|
||||
return QUEUE_FLIP_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
@ -311,18 +312,34 @@ ms_do_pageflip(ScreenPtr screen,
|
|||
* may never complete; this is a configuration error.
|
||||
*/
|
||||
for (i = 0; i < config->num_crtc; i++) {
|
||||
enum queue_flip_status flip_status;
|
||||
xf86CrtcPtr crtc = config->crtc[i];
|
||||
|
||||
if (!xf86_crtc_on(crtc))
|
||||
continue;
|
||||
|
||||
if (!queue_flip_on_crtc(screen, crtc, flipdata,
|
||||
ref_crtc_vblank_pipe,
|
||||
flags)) {
|
||||
xf86DrvMsg(scrn->scrnIndex, X_WARNING,
|
||||
"%s: Queue flip on CRTC %d failed: %s\n",
|
||||
log_prefix, i, strerror(errno));
|
||||
goto error_undo;
|
||||
flip_status = queue_flip_on_crtc(screen, crtc, flipdata,
|
||||
ref_crtc_vblank_pipe,
|
||||
flags);
|
||||
|
||||
switch (flip_status) {
|
||||
case QUEUE_FLIP_ALLOC_FAILED:
|
||||
xf86DrvMsg(scrn->scrnIndex, X_WARNING,
|
||||
"%s: carrier alloc for queue flip on CRTC %d failed.\n",
|
||||
log_prefix, i);
|
||||
goto error_undo;
|
||||
case QUEUE_FLIP_QUEUE_ALLOC_FAILED:
|
||||
xf86DrvMsg(scrn->scrnIndex, X_WARNING,
|
||||
"%s: entry alloc for queue flip on CRTC %d failed.\n",
|
||||
log_prefix, i);
|
||||
goto error_undo;
|
||||
case QUEUE_FLIP_DRM_FLUSH_FAILED:
|
||||
xf86DrvMsg(scrn->scrnIndex, X_WARNING,
|
||||
"%s: queue flip during flip on CRTC %d failed: %s\n",
|
||||
log_prefix, i, strerror(errno));
|
||||
goto error_undo;
|
||||
case QUEUE_FLIP_SUCCESS:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue