summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Airlie <airlied@gmail.com>2016-04-29 12:41:09 +1000
committerDave Airlie <airlied@gmail.com>2016-04-29 13:52:39 +1000
commit9dac707a73a75741159728915659b2b8bd46c1d6 (patch)
tree055bee402ec7125c37f6751e7d316ef9b793a3e9
parent976585341fb9e7711ea5bbe46e388a3f44bb108b (diff)
prime: clean up slave bo properly.misc-prime-fixes
This is an ABI break, in that we now pass NULL to a function that hasn't accepted it before. Alex Goins had a different patch for this but it wasn't symmetrical, it freed something in a very different place than it allocated it, this attempts to retain symmetry in the releasing of the backing bo. Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r--dix/pixmap.c5
-rw-r--r--hw/xfree86/dri2/dri2.c1
-rw-r--r--hw/xfree86/drivers/modesetting/driver.c4
-rw-r--r--hw/xfree86/drivers/modesetting/drmmode_display.c6
-rw-r--r--randr/rrcrtc.c2
5 files changed, 18 insertions, 0 deletions
diff --git a/dix/pixmap.c b/dix/pixmap.c
index 11d83fe00..270a7d74c 100644
--- a/dix/pixmap.c
+++ b/dix/pixmap.c
@@ -140,6 +140,11 @@ PixmapPtr PixmapShareToSlave(PixmapPtr pixmap, ScreenPtr slave)
ScreenPtr master = pixmap->drawable.pScreen;
int depth = pixmap->drawable.depth;
+ if (!slave) {
+ slave->SetSharedPixmapBacking(spix, NULL);
+ return NULL;
+ }
+
ret = master->SharePixmapBacking(pixmap, slave, &handle);
if (ret == FALSE)
return NULL;
diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index d55be1913..a961a4e41 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -859,6 +859,7 @@ DrawablePtr DRI2UpdatePrime(DrawablePtr pDraw, DRI2BufferPtr pDest)
if (pPriv->prime_slave_pixmap->master_pixmap == mpix)
return &pPriv->prime_slave_pixmap->drawable;
else {
+ PixmapShareToSlave(pPriv->prime_slave_pixmap->master_pixmap, NULL);
(*pPriv->prime_slave_pixmap->master_pixmap->drawable.pScreen->DestroyPixmap)(pPriv->prime_slave_pixmap->master_pixmap);
(*slave->DestroyPixmap)(pPriv->prime_slave_pixmap);
pPriv->prime_slave_pixmap = NULL;
diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c
index 13c9a102f..1735e027c 100644
--- a/hw/xfree86/drivers/modesetting/driver.c
+++ b/hw/xfree86/drivers/modesetting/driver.c
@@ -1063,6 +1063,10 @@ msSetSharedPixmapBacking(PixmapPtr ppix, void *fd_handle)
Bool ret;
int ihandle = (int) (long) fd_handle;
+ if (ihandle == 0)
+ if (!ms->drmmode.reverse_prime_offload_mode)
+ return drmmode_SetSlaveBO(ppix, &ms->drmmode, 0, 0, 0);
+
if (ms->drmmode.reverse_prime_offload_mode) {
ret = glamor_back_pixmap_from_fd(ppix, ihandle,
ppix->drawable.width,
diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c
index 262e01507..5cbab0789 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.c
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
@@ -212,6 +212,12 @@ drmmode_SetSlaveBO(PixmapPtr ppix,
{
msPixmapPrivPtr ppriv = msGetPixmapPriv(drmmode, ppix);
+ if (fd_handle == 0) {
+ dumb_bo_destroy(drmmode->fd, ppriv->backing_bo);
+ ppriv->backing_bo = NULL;
+ return TRUE;
+ }
+
ppriv->backing_bo =
dumb_get_bo_from_fd(drmmode->fd, fd_handle, pitch, size);
if (!ppriv->backing_bo)
diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c
index 566a3dbc6..fe5902933 100644
--- a/randr/rrcrtc.c
+++ b/randr/rrcrtc.c
@@ -373,6 +373,8 @@ rrDestroySharedPixmap(RRCrtcPtr crtc, PixmapPtr pPixmap) {
* Unref the pixmap twice: once for the original reference, and once
* for the reference implicitly added by PixmapShareToSlave.
*/
+ PixmapShareToSlave(pPixmap->master_pixmap, NULL);
+
master->DestroyPixmap(pPixmap->master_pixmap);
master->DestroyPixmap(pPixmap->master_pixmap);
}