Propagate failure from amdgpu_set_pixmap_bo

Preparation for the following fixes.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
Michel Dänzer
2016-06-15 17:20:36 +09:00
committed by Michel Dänzer
parent 74602c4221
commit c315c00e44
4 changed files with 30 additions and 22 deletions

View File

@@ -384,6 +384,7 @@ Bool amdgpu_set_shared_pixmap_backing(PixmapPtr ppix, void *fd_handle)
struct amdgpu_buffer *pixmap_buffer = NULL;
int ihandle = (int)(long)fd_handle;
uint32_t size = ppix->devKind * ppix->drawable.height;
Bool ret;
if (info->gbm) {
struct amdgpu_pixmap *priv;
@@ -442,13 +443,15 @@ Bool amdgpu_set_shared_pixmap_backing(PixmapPtr ppix, void *fd_handle)
return FALSE;
}
amdgpu_set_pixmap_bo(ppix, pixmap_buffer);
close(ihandle);
ret = amdgpu_set_pixmap_bo(ppix, pixmap_buffer);
/* we have a reference from the alloc and one from set pixmap bo,
drop one */
amdgpu_bo_unref(&pixmap_buffer);
return TRUE;
return ret;
}
#endif /* AMDGPU_PIXMAP_SHARING */

View File

@@ -205,7 +205,9 @@ static Bool AMDGPUCreateScreenResources_KMS(ScreenPtr pScreen)
if (info->dri2.enabled || info->use_glamor) {
if (info->front_buffer) {
PixmapPtr pPix = pScreen->GetScreenPixmap(pScreen);
amdgpu_set_pixmap_bo(pPix, info->front_buffer);
if (!amdgpu_set_pixmap_bo(pPix, info->front_buffer))
return FALSE;
}
}

View File

@@ -54,17 +54,17 @@ static inline void amdgpu_set_pixmap_private(PixmapPtr pixmap,
dixSetPrivate(&pixmap->devPrivates, &amdgpu_pixmap_index, priv);
}
static inline void amdgpu_set_pixmap_bo(PixmapPtr pPix, struct amdgpu_buffer *bo)
static inline Bool amdgpu_set_pixmap_bo(PixmapPtr pPix, struct amdgpu_buffer *bo)
{
struct amdgpu_pixmap *priv;
priv = amdgpu_get_pixmap_private(pPix);
if (priv == NULL && bo == NULL)
return;
return TRUE;
if (priv) {
if (priv->bo == bo)
return;
return TRUE;
if (priv->bo) {
amdgpu_bo_unref(&priv->bo);
@@ -81,13 +81,14 @@ static inline void amdgpu_set_pixmap_bo(PixmapPtr pPix, struct amdgpu_buffer *bo
if (!priv) {
priv = calloc(1, sizeof(struct amdgpu_pixmap));
if (!priv)
goto out;
return FALSE;
}
amdgpu_bo_ref(bo);
priv->bo = bo;
}
out:
amdgpu_set_pixmap_private(pPix, priv);
return TRUE;
}
static inline struct amdgpu_buffer *amdgpu_get_pixmap_bo(PixmapPtr pPix)

View File

@@ -111,18 +111,18 @@ static PixmapPtr drmmode_create_bo_pixmap(ScrnInfoPtr pScrn,
return NULL;
if (!(*pScreen->ModifyPixmapHeader) (pixmap, width, height,
depth, bpp, pitch, NULL)) {
return NULL;
}
depth, bpp, pitch, NULL))
goto fail;
amdgpu_set_pixmap_bo(pixmap, bo);
if (!amdgpu_glamor_create_textured_pixmap(pixmap, bo))
goto fail;
if (!amdgpu_glamor_create_textured_pixmap(pixmap, bo)) {
pScreen->DestroyPixmap(pixmap);
return NULL;
}
if (amdgpu_set_pixmap_bo(pixmap, bo))
return pixmap;
return pixmap;
fail:
pScreen->DestroyPixmap(pixmap);
return NULL;
}
static void drmmode_destroy_bo_pixmap(PixmapPtr pixmap)
@@ -1944,9 +1944,14 @@ static Bool drmmode_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
goto fail;
}
if (!amdgpu_glamor_create_screen_resources(scrn->pScreen))
goto fail;
if (info->use_glamor ||
(info->front_buffer->flags & AMDGPU_BO_FLAGS_GBM)) {
amdgpu_set_pixmap_bo(ppix, info->front_buffer);
if (!amdgpu_set_pixmap_bo(ppix, info->front_buffer))
goto fail;
screen->ModifyPixmapHeader(ppix,
width, height, -1, -1, pitch, info->front_buffer->cpu_ptr);
} else {
@@ -1963,9 +1968,6 @@ static Bool drmmode_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
scrn->pixmapPrivate.ptr = ppix->devPrivate.ptr;
#endif
if (info->use_glamor)
amdgpu_glamor_create_screen_resources(scrn->pScreen);
/* Clear new buffer */
gc = GetScratchGC(ppix->drawable.depth, scrn->pScreen);
ValidateGC(&ppix->drawable, gc);