Commit e14e3560 authored by Tom Denis's avatar Tom Denis Committed by Michel Dänzer
Browse files

Simplify amdgpu_do_pageflip() error handling slightly more



Based on radeon commit e8c0f6319fbf4c3ea11e22ab1a68837031bdec8c

We don't need the local variable old_fb_id.
Signed-off-by: Tom Denis's avatarTom St Denis <tom.stdenis@amd.com>

[ Michel Dänzer: fix up slightly to better match radeon formatting ]
Reviewed-by: Michel Dänzer's avatarMichel Dänzer <michel.daenzer@amd.com>
parent e9621ec0
......@@ -2264,9 +2264,9 @@ Bool amdgpu_do_pageflip(ScrnInfoPtr scrn, ClientPtr client,
drmmode_crtc_private_ptr drmmode_crtc = config->crtc[0]->driver_private;
drmmode_ptr drmmode = drmmode_crtc->drmmode;
unsigned int pitch;
int i, old_fb_id;
int i;
int height;
drmmode_flipdata_ptr flipdata;
drmmode_flipdata_ptr flipdata = NULL;
drmmode_flipevtcarrier_ptr flipcarrier = NULL;
struct amdgpu_drm_queue_entry *drm_queue = NULL;
union gbm_bo_handle bo_handle;
......@@ -2283,25 +2283,25 @@ Bool amdgpu_do_pageflip(ScrnInfoPtr scrn, ClientPtr client,
if (amdgpu_bo_export(new_front->bo.amdgpu,
amdgpu_bo_handle_type_kms,
&handle))
goto error_out;
goto error;
}
/*
* Create a new handle for the back buffer
*/
old_fb_id = drmmode->fb_id;
if (drmModeAddFB(drmmode->fd, scrn->virtualX, height,
scrn->depth, scrn->bitsPerPixel, pitch,
handle, &drmmode->fb_id)) {
goto error_out;
}
flipdata = calloc(1, sizeof(drmmode_flipdata_rec));
if (!flipdata) {
xf86DrvMsg(scrn->scrnIndex, X_WARNING,
"flip queue: data alloc failed.\n");
goto error_undo;
goto error;
}
/*
* Create a new handle for the back buffer
*/
flipdata->old_fb_id = drmmode->fb_id;
if (drmModeAddFB(drmmode->fd, scrn->virtualX, height,
scrn->depth, scrn->bitsPerPixel, pitch,
handle, &drmmode->fb_id))
goto error;
/*
* Queue flips on all enabled CRTCs
* Note that if/when we get per-CRTC buffers, we'll have to update this.
......@@ -2314,7 +2314,6 @@ Bool amdgpu_do_pageflip(ScrnInfoPtr scrn, ClientPtr client,
flipdata->event_data = data;
flipdata->drmmode = drmmode;
flipdata->old_fb_id = old_fb_id;
for (i = 0; i < config->num_crtc; i++) {
if (!config->crtc[i]->enabled)
......@@ -2327,7 +2326,7 @@ Bool amdgpu_do_pageflip(ScrnInfoPtr scrn, ClientPtr client,
if (!flipcarrier) {
xf86DrvMsg(scrn->scrnIndex, X_WARNING,
"flip queue: carrier alloc failed.\n");
goto error_undo;
goto error;
}
/* Only the reference crtc will finally deliver its page flip
......@@ -2346,7 +2345,7 @@ Bool amdgpu_do_pageflip(ScrnInfoPtr scrn, ClientPtr client,
if (!drm_queue) {
xf86DrvMsg(scrn->scrnIndex, X_WARNING,
"Allocating DRM queue event entry failed.\n");
goto error_undo;
goto error;
}
if (drmModePageFlip(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id,
......@@ -2354,7 +2353,7 @@ Bool amdgpu_do_pageflip(ScrnInfoPtr scrn, ClientPtr client,
drm_queue)) {
xf86DrvMsg(scrn->scrnIndex, X_WARNING,
"flip queue failed: %s\n", strerror(errno));
goto error_undo;
goto error;
}
flipcarrier = NULL;
drm_queue = NULL;
......@@ -2363,10 +2362,10 @@ Bool amdgpu_do_pageflip(ScrnInfoPtr scrn, ClientPtr client,
if (flipdata->flip_count > 0)
return TRUE;
error_undo:
if (!flipdata || flipdata->flip_count <= 1) {
error:
if (flipdata && flipdata->flip_count <= 1) {
drmModeRmFB(drmmode->fd, drmmode->fb_id);
drmmode->fb_id = old_fb_id;
drmmode->fb_id = flipdata->old_fb_id;
}
if (drm_queue)
......@@ -2376,7 +2375,6 @@ error_undo:
else if (flipdata && flipdata->flip_count <= 1)
free(flipdata);
error_out:
xf86DrvMsg(scrn->scrnIndex, X_WARNING, "Page flip failed: %s\n",
strerror(errno));
return FALSE;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment