Skip to contentSkip to conversation

Properly cleanup fb for reverse-prime-offload

PATCH In review Hans de Goede 2 participants 3 messages Jun 3, 2016 – Jun 27, 2016 2 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Properly cleanup fb for reverse-prime-offload

drmmode_set_scanout_pixmap(pix) adds drmmod->fb_id through a call to drmmode_xf86crtc_resize(), but on a subsequent drmmode_set_scanout_pixmap(NULL) it would not remove the fb.

This keeps the crtc marked as busy, which causes the dgpu to not being able to runtime suspend, after an output attached to the dgpu has been used once. Which causes burning through an additional 10W of power and the laptop to run quite hot.

This commit adds the missing remove fb call, allowing the dgpu to runtime suspend after an external monitor has been plugged into the laptop.

---
 src/drmmode_display.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
src/drmmode_display.c +7 -1
index b950f42..f326e46 100644
@@ -680,10 +680,16 @@ drmmode_set_scanout_pixmap(xf86CrtcPtr crtc, PixmapPtr ppix)
 	PixmapPtr screenpix = screen->GetScreenPixmap(screen);
 	xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(crtc->scrn);
 	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+	drmmode_ptr drmmode = drmmode_crtc->drmmode;
 	int c, total_width = 0, max_height = 0, this_x = 0;
 	if (!ppix) {
-		if (crtc->randr_crtc->scanout_pixmap)
+		if (crtc->randr_crtc->scanout_pixmap) {
 			PixmapStopDirtyTracking(crtc->randr_crtc->scanout_pixmap, screenpix);
+			if (drmmode && drmmode->fb_id) {
+				drmModeRmFB(drmmode->fd, drmmode->fb_id);
+				drmmode->fb_id = 0;
+			}
+		}
 		drmmode_crtc->scanout_pixmap_x = 0;
 		return TRUE;
 	}
Signature · 6 lines
2.7.4

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau

A message that is not in the archive (sent off-list or not yet received): 1464957970-19906-1-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

#2 lore raw

Hi Ilia, Ben, et al.

Can I please get a review of this patch, and assuming the review is favorable, can someone please push this ?

Regards,

Hans

p.s.

Is it ok if I request push rights to the nouveau repos / group at freedesktop.org ?

Quoted 30 lines · Hans De Goede

drmmode_set_scanout_pixmap(pix) adds drmmod->fb_id through a call to drmmode_xf86crtc_resize(), but on a subsequent drmmode_set_scanout_pixmap(NULL) it would not remove the fb.

This keeps the crtc marked as busy, which causes the dgpu to not being able to runtime suspend, after an output attached to the dgpu has been used once. Which causes burning through an additional 10W of power and the laptop to run quite hot.

This commit adds the missing remove fb call, allowing the dgpu to runtime suspend after an external monitor has been plugged into the laptop.

---
 src/drmmode_display.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
src/drmmode_display.c +1 -1
index b950f42..f326e46 100644
@@ -680,10 +680,16 @@ drmmode_set_scanout_pixmap(xf86CrtcPtr crtc, PixmapPtr ppix)
 	PixmapPtr screenpix = screen->GetScreenPixmap(screen);
 	xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(crtc->scrn);
 	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+	drmmode_ptr drmmode = drmmode_crtc->drmmode;
 	int c, total_width = 0, max_height = 0, this_x = 0;
 	if (!ppix) {
-		if (crtc->randr_crtc->scanout_pixmap)

src/drmmode_display.c drmmode_set_scanout_pixmap(xf86CrtcPtr crtc, PixmapPtr ppix) · line 695

Quoted 10 lines
src/drmmode_display.c +6 -0
+		if (crtc->randr_crtc->scanout_pixmap) {
 			PixmapStopDirtyTracking(crtc->randr_crtc->scanout_pixmap, screenpix);
+			if (drmmode && drmmode->fb_id) {
+				drmModeRmFB(drmmode->fd, drmmode->fb_id);
+				drmmode->fb_id = 0;
+			}
+		}
 		drmmode_crtc->scanout_pixmap_x = 0;
 		return TRUE;
 	}

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau

A message that is not in the archive (sent off-list or not yet received): 5a47b449-4b55-8543-a66a-efa791c56da8-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

#4 lore raw
Quoted 8 lines · Hans de Goede

Hi Ilia, Ben, et al.

Can I please get a review of this patch, and assuming the review is favorable,
can someone please push this ?

Regards,

Quoted 7 lines

Hans

p.s.

Is it ok if I request push rights to the nouveau repos / group at freedesktop.org ?

Hey Hans,

Patch looks good to me, and I've pushed it. And yeah, go ahead and request that!

Ben.

Quoted 41 lines · Hans De Goede
Quoted 38 lines

drmmode_set_scanout_pixmap(pix) adds drmmod->fb_id through a call to drmmode_xf86crtc_resize(), but on a subsequent drmmode_set_scanout_pixmap(NULL) it would not remove the fb.

This keeps the crtc marked as busy, which causes the dgpu to not being able to runtime suspend, after an output attached to the dgpu has been used once. Which causes burning through an additional 10W of power and the laptop to run quite hot.

This commit adds the missing remove fb call, allowing the dgpu to runtime suspend after an external monitor has been plugged into the laptop.

---
 src/drmmode_display.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
src/drmmode_display.c +7 -1
index b950f42..f326e46 100644
@@ -680,10 +680,16 @@ drmmode_set_scanout_pixmap(xf86CrtcPtr crtc,
 PixmapPtr ppix)
     PixmapPtr screenpix = screen->GetScreenPixmap(screen);
     xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(crtc->scrn);
     drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+    drmmode_ptr drmmode = drmmode_crtc->drmmode;
     int c, total_width = 0, max_height = 0, this_x = 0;
     if (!ppix) {
-        if (crtc->randr_crtc->scanout_pixmap)
+        if (crtc->randr_crtc->scanout_pixmap) {
             PixmapStopDirtyTracking(crtc->randr_crtc->scanout_pixmap,
 screenpix);
+            if (drmmode && drmmode->fb_id) {
+                drmModeRmFB(drmmode->fd, drmmode->fb_id);
+                drmmode->fb_id = 0;
+            }
+        }
Quoted 8 lines
Quoted 4 lines
src/drmmode_display.c +0 -0
         drmmode_crtc->scanout_pixmap_x = 0;
         return TRUE;
     }

_______________________________________________
Nouveau mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau