Skip to contentSkip to conversation

Don't rely on randr_crtc->scanout_pixmap in drmmode_set_scanout_pixmap

PATCH In review Michel Dänzer 2 participants 5 messages Oct 26, 2016 2 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 Don't rely on randr_crtc->scanout_pixmap in drmmode_set_scanout_pixmap

From: Michel Dänzer <[email protected]>

RRReplaceScanoutPixmap may set randr_crtc->scanout_pixmap = NULL before we get here.

(Inspired by xserver commit f4c37eeee7953df1fe0e3196eda452acf0078e61)
v2: Always return TRUE in the if (!ppix) block.
(Cherry picked from radeon commit 61df12e2377cbb19a19ca9d5624df8959822da9f)

---
 src/drmmode_display.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)
src/drmmode_display.c +13 -4
index f291f6d..5f0fdb0 100644
@@ -1105,10 +1105,19 @@ static Bool drmmode_set_scanout_pixmap(xf86CrtcPtr crtc, PixmapPtr ppix)
 	AMDGPUInfoPtr info = AMDGPUPTR(crtc->scrn);
 
 	if (!ppix) {
-		if (crtc->randr_crtc->scanout_pixmap)
-			PixmapStopDirtyTracking(crtc->randr_crtc->scanout_pixmap,
-						drmmode_crtc->scanout[drmmode_crtc->scanout_id].pixmap);
-		drmmode_crtc_scanout_free(drmmode_crtc);
+		ScreenPtr screen = crtc->scrn->pScreen;
+		PixmapDirtyUpdatePtr dirty;
+
+		xorg_list_for_each_entry(dirty, &screen->pixmap_dirty_list, ent) {
+			if (dirty->slave_dst !=
+			    drmmode_crtc->scanout[drmmode_crtc->scanout_id].pixmap)
+				continue;
+
+			PixmapStopDirtyTracking(dirty->src, dirty->slave_dst);
+			drmmode_crtc_scanout_free(drmmode_crtc);
+			break;
+		}
+
 		return TRUE;
 	}
 
Signature · 6 lines
2.10.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 20161026072430.26564-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org

#2 lore raw

PATCH 2/4 Always call PixmapStopDirtyTracking in drmmode_set_scanout_pixmap

From: Michel Dänzer <[email protected]>

Otherwise, we may leak screen->pixmap_dirty_list entries if drmmode_set_scanout_pixmap is called repatedly with ppix != NULL, which can happen from RRReplaceScanoutPixmap.

(Inspired by xserver commit b773a9c8126222e5fed2904d012fbf917a9f22fd) (Ported from radeon commit 6c940446ddadf418ee4959e46fa552b6c1cf6704)

---
 src/drmmode_display.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)
src/drmmode_display.c +11 -13
index 5f0fdb0..9dfef40 100644
@@ -1103,23 +1103,21 @@ static Bool drmmode_set_scanout_pixmap(xf86CrtcPtr crtc, PixmapPtr ppix)
 {
 	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
 	AMDGPUInfoPtr info = AMDGPUPTR(crtc->scrn);
+	ScreenPtr screen = crtc->scrn->pScreen;
+	PixmapDirtyUpdatePtr dirty;
 
-	if (!ppix) {
-		ScreenPtr screen = crtc->scrn->pScreen;
-		PixmapDirtyUpdatePtr dirty;
-
-		xorg_list_for_each_entry(dirty, &screen->pixmap_dirty_list, ent) {
-			if (dirty->slave_dst !=
-			    drmmode_crtc->scanout[drmmode_crtc->scanout_id].pixmap)
-				continue;
+	xorg_list_for_each_entry(dirty, &screen->pixmap_dirty_list, ent) {
+		if (dirty->slave_dst !=
+		    drmmode_crtc->scanout[drmmode_crtc->scanout_id].pixmap)
+			continue;
 
-			PixmapStopDirtyTracking(dirty->src, dirty->slave_dst);
-			drmmode_crtc_scanout_free(drmmode_crtc);
-			break;
-		}
+		PixmapStopDirtyTracking(dirty->src, dirty->slave_dst);
+		drmmode_crtc_scanout_free(drmmode_crtc);
+		break;
+	}
 
+	if (!ppix)
 		return TRUE;
-	}
 
 	if (!drmmode_crtc_scanout_create(crtc, &drmmode_crtc->scanout[0],
 					 ppix->drawable.width,
Signature · 6 lines
2.10.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#3 lore raw

PATCH 3/4 PRIME: Fix swapping of provider sink / source capabilities

In reply to a message not in the archive

From: Hans de Goede <[email protected]>

When a card has import capability it can be an offload _sink_, not a source and vice versa for export capability.

This went unnoticed sofar because most gpus have both import and export capability.

(Ported from xserver commit 94a1c77259ce39ba59ad87615df39b570ffab435) (Ported from radeon commit 82d3c8f5500d2a6fb1495e217a0b79c396f1534c)

---
 src/amdgpu_kms.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
src/amdgpu_kms.c +2 -2
index 4ae7995..6fa63e9 100644
@@ -1235,9 +1235,9 @@ static void AMDGPUSetupCapabilities(ScrnInfoPtr pScrn)
 	ret = drmGetCap(pAMDGPUEnt->fd, DRM_CAP_PRIME, &value);
 	if (ret == 0) {
 		if (value & DRM_PRIME_CAP_EXPORT)
-			pScrn->capabilities |= RR_Capability_SourceOutput | RR_Capability_SinkOffload;
+			pScrn->capabilities |= RR_Capability_SourceOutput | RR_Capability_SourceOffload;
 		if (value & DRM_PRIME_CAP_IMPORT) {
-			pScrn->capabilities |= RR_Capability_SourceOffload;
+			pScrn->capabilities |= RR_Capability_SinkOffload;
 			if (info->drmmode.count_crtcs)
 				pScrn->capabilities |= RR_Capability_SinkOutput;
 		}
Signature · 6 lines
2.10.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#4 lore raw

PATCH 4/4 Consume all available udev events at once

In reply to a message not in the archive

From: Michel Dänzer <[email protected]>

We get multiple udev events for actions like docking a laptop into its station or plugging a monitor to the station. By consuming as many events as we can, we reduce the number of output re-evalutions.

It depends on the timing how many events can be consumed at once.

(Inspired by xserver commit 363f4273dd4aec3e26cc57ecb6c20f27e6c813d8) (Ported from radeon commit 22b5ce9548393ba2ff73ee234ecd82eeaf0ef6c4)

---
 src/drmmode_display.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
src/drmmode_display.c +8 -5
index 9dfef40..b03a8a7 100644
@@ -2479,12 +2479,15 @@ static void drmmode_handle_uevents(int fd, void *closure)
 	drmmode_ptr drmmode = closure;
 	ScrnInfoPtr scrn = drmmode->scrn;
 	struct udev_device *dev;
-	dev = udev_monitor_receive_device(drmmode->uevent_monitor);
-	if (!dev)
-		return;
+	Bool received = FALSE;
+
+	while ((dev = udev_monitor_receive_device(drmmode->uevent_monitor))) {
+		udev_device_unref(dev);
+		received = TRUE;
+	}
 
-	amdgpu_mode_hotplug(scrn, drmmode);
-	udev_device_unref(dev);
+	if (received)
+		amdgpu_mode_hotplug(scrn, drmmode);
 }
 #endif
 
Signature · 6 lines
2.10.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 20161026072430.26564-4-michel-otUistvHUpPR7s880joybQ@public.gmane.org

Reviewed-by
#6 lore raw

Re: [PATCH xf86-video-amdgpu 4/4] Consume all available udev events at once

Quoted 6 lines · Michel Dänzer

From: Michel Dänzer <[email protected]>

We get multiple udev events for actions like docking a laptop into its station or plugging a monitor to the station. By consuming as many events as we can, we reduce the number of output re-evalutions.

Quoted 6 lines

It depends on the timing how many events can be consumed at once.

(Inspired by xserver commit 363f4273dd4aec3e26cc57ecb6c20f27e6c813d8) (Ported from radeon commit 22b5ce9548393ba2ff73ee234ecd82eeaf0ef6c4)

Series is:

Quoted 32 lines
---
 src/drmmode_display.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
src/drmmode_display.c +8 -6
index 9dfef40..b03a8a7 100644
@@ -2479,12 +2479,15 @@ static void drmmode_handle_uevents(int fd, void *closure)
        drmmode_ptr drmmode = closure;
        ScrnInfoPtr scrn = drmmode->scrn;
        struct udev_device *dev;
-       dev = udev_monitor_receive_device(drmmode->uevent_monitor);
-       if (!dev)
-               return;
+       Bool received = FALSE;
+
+       while ((dev = udev_monitor_receive_device(drmmode->uevent_monitor))) {
+               udev_device_unref(dev);
+               received = TRUE;
+       }
 
-       amdgpu_mode_hotplug(scrn, drmmode);
-       udev_device_unref(dev);
+       if (received)
+               amdgpu_mode_hotplug(scrn, drmmode);
 }
 #endif
 
--

2.10.1

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx