From: Michel Dänzer <[email protected]> Preparation for the following fixes.
Signed-off-by: Michel Dänzer <[email protected]> --- src/amdgpu_bo_helper.c | 9 ++++++--- src/amdgpu_kms.c | 4 +++- src/amdgpu_pixmap.h | 11 ++++++----- src/drmmode_display.c | 28 +++++++++++++++------------- 4 files changed, 30 insertions(+), 22 deletions(-) diff --git a/src/amdgpu_bo_helper.c b/src/amdgpu_bo_helper.c index f5a67e3..5482ff0 100644 --- a/src/amdgpu_bo_helper.c +++ b/src/amdgpu_bo_helper.c @@ -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 */ diff --git a/src/amdgpu_kms.c b/src/amdgpu_kms.c index 3c53bc9..b34a223 100644 --- a/src/amdgpu_kms.c +++ b/src/amdgpu_kms.c @@ -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; } } diff --git a/src/amdgpu_pixmap.h b/src/amdgpu_pixmap.h index ecdd74d..9c51067 100644 --- a/src/amdgpu_pixmap.h +++ b/src/amdgpu_pixmap.h @@ -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) diff --git a/src/drmmode_display.c b/src/drmmode_display.c index a675c73..3d76c88 100644 --- a/src/drmmode_display.c +++ b/src/drmmode_display.c @@ -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); -- 2.8.1 _______________________________________________ xorg-driver-ati mailing list [email protected] https://lists.x.org/mailman/listinfo/xorg-driver-ati
