[PATCH v5 05/13] modesetting: Always tear down scanout pixmap

Alex Goins agoins at nvidia.com
Wed Apr 13 04:17:52 UTC 2016


drmmode_set_scanout_pixmap_(cpu/gpu) would only do teardown if ppix ==
NULL. This meant that if there were consecutive calls to
SetScanoutPixmap(ppix != NULL) without calls to SetScanoutPixmap(ppix ==
NULL) in between, earlier calls would be leaked.  RRReplaceScanoutPixmap()
does this today.

Instead, when setting a scanout pixmap, always do teardown of the existing
scanout pixmap before setting up the new one. Then, if there is no new one
to set up, stop there.

This maintains the previous behavior in all cases except those with
multiple consecutive calls to SetScanoutPixmap(ppix != NULL).

v1: N/A
v2: N/A
v3: N/A
v4: N/A
v5: Initial commit

Signed-off-by: Alex Goins <agoins at nvidia.com>
---
 hw/xfree86/drivers/modesetting/drmmode_display.c | 30 +++++++++++++-----------
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c
index 9bd2958..f0144f8 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.c
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
@@ -579,12 +579,14 @@ drmmode_set_scanout_pixmap_gpu(xf86CrtcPtr crtc, PixmapPtr ppix)
     drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
     int c, total_width = 0, max_height = 0, this_x = 0;
 
-    if (!ppix) {
-        if (drmmode_crtc->prime_pixmap)
-            PixmapStopDirtyTracking(drmmode_crtc->prime_pixmap, screenpix);
+    if (drmmode_crtc->prime_pixmap) {
+        PixmapStopDirtyTracking(drmmode_crtc->prime_pixmap, screenpix);
         drmmode_crtc->prime_pixmap_x = 0;
-        return TRUE;
     }
+
+    if (!ppix)
+        return TRUE;
+
     /* iterate over all the attached crtcs to work out the bounding box */
     for (c = 0; c < xf86_config->num_crtc; c++) {
         xf86CrtcPtr iter = xf86_config->crtc[c];
@@ -625,18 +627,18 @@ drmmode_set_scanout_pixmap_cpu(xf86CrtcPtr crtc, PixmapPtr ppix)
     msPixmapPrivPtr ppriv;
     void *ptr;
 
-    if (!ppix) {
-        if (drmmode_crtc->prime_pixmap) {
-            ppriv = msGetPixmapPriv(drmmode, drmmode_crtc->prime_pixmap);
-            drmModeRmFB(drmmode->fd, ppriv->fb_id);
-        }
-        if (drmmode_crtc->slave_damage) {
-            DamageUnregister(drmmode_crtc->slave_damage);
-            drmmode_crtc->slave_damage = NULL;
-        }
-        return TRUE;
+    if (drmmode_crtc->prime_pixmap) {
+        ppriv = msGetPixmapPriv(drmmode, drmmode_crtc->prime_pixmap);
+        drmModeRmFB(drmmode->fd, ppriv->fb_id);
+    }
+    if (drmmode_crtc->slave_damage) {
+        DamageUnregister(drmmode_crtc->slave_damage);
+        drmmode_crtc->slave_damage = NULL;
     }
 
+    if (!ppix)
+        return TRUE;
+
     ppriv = msGetPixmapPriv(drmmode, ppix);
     if (!drmmode_crtc->slave_damage) {
         drmmode_crtc->slave_damage = DamageCreate(NULL, NULL,
-- 
1.9.1



More information about the xorg-devel mailing list