Blame SOURCES/0006-modesetting-Properly-cleanup-fb-for-reverse-prime-of.patch

82b592
From 1e234ae444fa4170582bdb2ada3cf46973adcd22 Mon Sep 17 00:00:00 2001
82b592
From: Hans de Goede <hdegoede@redhat.com>
82b592
Date: Wed, 1 Jun 2016 14:59:38 +0200
82b592
Subject: [PATCH xserver 6/8] modesetting: Properly cleanup fb for
82b592
 reverse-prime-offload
82b592
82b592
drmmode_set_scanout_pixmap_gpu(pix) adds drmmod->fb_id through a call
82b592
to drmmode_xf86crtc_resize(), but on a subsequent
82b592
drmmode_set_scanout_pixmap_gpu(NULL) it would not remove the fb.
82b592
82b592
This keeps the crtc marked as busy, which causes the dgpu to not
82b592
being able to runtime suspend, after an output attached to the dgpu
82b592
has been used once. Which causes burning through an additional 10W
82b592
of power and the laptop to run quite hot.
82b592
82b592
This commit adds the missing remove fb call, allowing the dgpu to runtime
82b592
suspend after an external monitor has been plugged into the laptop.
82b592
82b592
Note this also makes drmmode_set_scanout_pixmap_gpu(NULL) match the
82b592
behavior of drmmode_set_scanout_pixmap_cpu(NULL) which was already
82b592
removing the fb.
82b592
82b592
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
82b592
Reviewed-by: Dave Airlie <airlied@redhat.com>
82b592
(cherry picked from commit b8ef71fb07a8ba9587aeaca942b4de20b59266ca)
82b592
---
82b592
 hw/xfree86/drivers/modesetting/drmmode_display.c | 8 +++++++-
82b592
 1 file changed, 7 insertions(+), 1 deletion(-)
82b592
82b592
diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c
82b592
index d824e8b..10efd8f 100644
82b592
--- a/hw/xfree86/drivers/modesetting/drmmode_display.c
82b592
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
82b592
@@ -518,11 +518,17 @@ drmmode_set_scanout_pixmap_gpu(xf86CrtcPtr crtc, PixmapPtr ppix)
82b592
     PixmapPtr screenpix = screen->GetScreenPixmap(screen);
82b592
     xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(crtc->scrn);
82b592
     drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
82b592
+    drmmode_ptr drmmode = drmmode_crtc->drmmode;
82b592
     int c, total_width = 0, max_height = 0, this_x = 0;
82b592
 
82b592
     if (!ppix) {
82b592
-        if (crtc->randr_crtc->scanout_pixmap)
82b592
+        if (crtc->randr_crtc->scanout_pixmap) {
82b592
             PixmapStopDirtyTracking(crtc->randr_crtc->scanout_pixmap, screenpix);
82b592
+            if (drmmode->fb_id) {
82b592
+                drmModeRmFB(drmmode->fd, drmmode->fb_id);
82b592
+                drmmode->fb_id = 0;
82b592
+            }
82b592
+        }
82b592
         drmmode_crtc->prime_pixmap_x = 0;
82b592
         return TRUE;
82b592
     }
82b592
-- 
82b592
2.7.4
82b592