summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichel Dänzer <michel.daenzer@amd.com>2016-09-12 18:54:33 +0900
committerMichel Dänzer <michel@daenzer.net>2016-09-21 16:25:25 +0900
commit8523a733b6a5de6116a6332fefc871d4c32652d8 (patch)
treeda2201680ea4e4772c84760cdd7df281ddb97064 /src
parent53be26b00e83f871f0afd39caa5a7a1d6ec4aea1 (diff)
Propagate failure from radeon_set_pixmap_bo
(Ported from amdgpu commits c315c00e44afc91a7c8e2eab5af836d9643ebb88 and 0d42082108c264568e2aadd15ace70e72388bc65)
Diffstat (limited to 'src')
-rw-r--r--src/drmmode_display.c30
-rw-r--r--src/radeon.h14
-rw-r--r--src/radeon_bo_helper.c16
-rw-r--r--src/radeon_kms.c3
4 files changed, 40 insertions, 23 deletions
diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index a8d43865..89922d6d 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -126,12 +126,11 @@ static PixmapPtr drmmode_create_bo_pixmap(ScrnInfoPtr pScrn,
if (!(*pScreen->ModifyPixmapHeader)(pixmap, width, height,
depth, bpp, pitch, NULL)) {
- return NULL;
+ goto fail;
}
if (!info->use_glamor)
exaMoveInPixmap(pixmap);
- radeon_set_pixmap_bo(pixmap, bo);
if (info->ChipFamily >= CHIP_FAMILY_R600) {
surface = radeon_get_pixmap_surface(pixmap);
if (surface && psurf)
@@ -163,22 +162,25 @@ static PixmapPtr drmmode_create_bo_pixmap(ScrnInfoPtr pScrn,
surface->flags |= RADEON_SURF_SET(RADEON_SURF_MODE_2D, MODE);
}
if (radeon_surface_best(info->surf_man, surface)) {
- return NULL;
+ goto fail;
}
if (radeon_surface_init(info->surf_man, surface)) {
- return NULL;
+ goto fail;
}
}
}
- if (info->use_glamor &&
- !radeon_glamor_create_textured_pixmap(pixmap,
- radeon_get_pixmap_private(pixmap))) {
- pScreen->DestroyPixmap(pixmap);
- return NULL;
- }
+ if (!radeon_set_pixmap_bo(pixmap, bo))
+ goto fail;
- return pixmap;
+ if (!info->use_glamor ||
+ radeon_glamor_create_textured_pixmap(pixmap,
+ radeon_get_pixmap_private(pixmap)))
+ return pixmap;
+
+fail:
+ pScreen->DestroyPixmap(pixmap);
+ return NULL;
}
static void drmmode_destroy_bo_pixmap(PixmapPtr pixmap)
@@ -2121,7 +2123,6 @@ drmmode_xf86crtc_resize (ScrnInfoPtr scrn, int width, int height)
goto fail;
if (!info->r600_shadow_fb) {
- radeon_set_pixmap_bo(ppix, info->front_bo);
psurface = radeon_get_pixmap_surface(ppix);
*psurface = info->front_surface;
screen->ModifyPixmapHeader(ppix,
@@ -2145,6 +2146,11 @@ drmmode_xf86crtc_resize (ScrnInfoPtr scrn, int width, int height)
if (info->use_glamor)
radeon_glamor_create_screen_resources(scrn->pScreen);
+ if (!info->r600_shadow_fb) {
+ if (!radeon_set_pixmap_bo(ppix, info->front_bo))
+ goto fail;
+ }
+
/* Clear new buffer */
gc = GetScratchGC(ppix->drawable.depth, scrn->pScreen);
force = info->accel_state->force;
diff --git a/src/radeon.h b/src/radeon.h
index 590966fd..c914a585 100644
--- a/src/radeon.h
+++ b/src/radeon.h
@@ -678,7 +678,7 @@ static inline struct radeon_surface *radeon_get_pixmap_surface(PixmapPtr pPix)
uint32_t radeon_get_pixmap_tiling(PixmapPtr pPix);
-static inline void radeon_set_pixmap_bo(PixmapPtr pPix, struct radeon_bo *bo)
+static inline Bool radeon_set_pixmap_bo(PixmapPtr pPix, struct radeon_bo *bo)
{
#ifdef USE_GLAMOR
RADEONInfoPtr info = RADEONPTR(xf86ScreenToScrn(pPix->drawable.pScreen));
@@ -688,11 +688,11 @@ static inline void radeon_set_pixmap_bo(PixmapPtr pPix, struct radeon_bo *bo)
priv = radeon_get_pixmap_private(pPix);
if (priv == NULL && bo == NULL)
- return;
+ return TRUE;
if (priv) {
if (priv->bo == bo)
- return;
+ return TRUE;
if (priv->bo)
radeon_bo_unref(priv->bo);
@@ -709,7 +709,7 @@ static inline void radeon_set_pixmap_bo(PixmapPtr pPix, struct radeon_bo *bo)
if (!priv) {
priv = calloc(1, sizeof (struct radeon_pixmap));
if (!priv)
- goto out;
+ return FALSE;
}
radeon_bo_ref(bo);
@@ -717,8 +717,9 @@ static inline void radeon_set_pixmap_bo(PixmapPtr pPix, struct radeon_bo *bo)
radeon_bo_get_tiling(bo, &priv->tiling_flags, &pitch);
}
-out:
+
radeon_set_pixmap_private(pPix, priv);
+ return TRUE;
} else
#endif /* USE_GLAMOR */
{
@@ -735,7 +736,10 @@ out:
driver_priv->bo = bo;
radeon_bo_get_tiling(bo, &driver_priv->tiling_flags, &pitch);
+ return TRUE;
}
+
+ return FALSE;
}
}
diff --git a/src/radeon_bo_helper.c b/src/radeon_bo_helper.c
index 531bc450..933dc7b3 100644
--- a/src/radeon_bo_helper.c
+++ b/src/radeon_bo_helper.c
@@ -312,14 +312,17 @@ Bool radeon_set_shared_pixmap_backing(PixmapPtr ppix, void *fd_handle,
struct radeon_bo *bo;
int ihandle = (int)(long)fd_handle;
uint32_t size = ppix->devKind * ppix->drawable.height;
+ Bool ret = FALSE;
bo = radeon_gem_bo_open_prime(info->bufmgr, ihandle, size);
if (!bo)
- return FALSE;
+ goto error;
memset(surface, 0, sizeof(struct radeon_surface));
- radeon_set_pixmap_bo(ppix, bo);
+ ret = radeon_set_pixmap_bo(ppix, bo);
+ if (!ret)
+ goto error;
if (info->ChipFamily >= CHIP_FAMILY_R600 && info->surf_man) {
uint32_t tiling_flags;
@@ -360,10 +363,12 @@ Bool radeon_set_shared_pixmap_backing(PixmapPtr ppix, void *fd_handle,
surface->stencil_tile_split = (tiling_flags >> RADEON_TILING_EG_STENCIL_TILE_SPLIT_SHIFT) & RADEON_TILING_EG_STENCIL_TILE_SPLIT_MASK;
surface->mtilea = (tiling_flags >> RADEON_TILING_EG_MACRO_TILE_ASPECT_SHIFT) & RADEON_TILING_EG_MACRO_TILE_ASPECT_MASK;
if (radeon_surface_best(info->surf_man, surface)) {
- return FALSE;
+ ret = FALSE;
+ goto error;
}
if (radeon_surface_init(info->surf_man, surface)) {
- return FALSE;
+ ret = FALSE;
+ goto error;
}
/* we have to post hack the surface to reflect the actual size
of the shared pixmap */
@@ -371,11 +376,12 @@ Bool radeon_set_shared_pixmap_backing(PixmapPtr ppix, void *fd_handle,
surface->level[0].nblk_x = ppix->devKind / surface->bpe;
}
+ error:
close(ihandle);
/* we have a reference from the alloc and one from set pixmap bo,
drop one */
radeon_bo_unref(bo);
- return TRUE;
+ return ret;
}
#endif /* RADEON_PIXMAP_SHARING */
diff --git a/src/radeon_kms.c b/src/radeon_kms.c
index 4a5f9da7..b64c6367 100644
--- a/src/radeon_kms.c
+++ b/src/radeon_kms.c
@@ -347,7 +347,8 @@ static Bool RADEONCreateScreenResources_KMS(ScreenPtr pScreen)
if (info->dri2.enabled || info->use_glamor) {
if (info->front_bo) {
PixmapPtr pPix = pScreen->GetScreenPixmap(pScreen);
- radeon_set_pixmap_bo(pPix, info->front_bo);
+ if (!radeon_set_pixmap_bo(pPix, info->front_bo))
+ return FALSE;
surface = radeon_get_pixmap_surface(pPix);
if (surface) {
*surface = info->front_surface;