Skip to contentSkip to conversation

Refactor drmmode_output_set_tear_free helper

PATCH In review Michel Dänzer 2 participants 4 messages Apr 26, 2018 – Apr 27, 2018 3 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 Refactor drmmode_output_set_tear_free helper

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

Preparation for the following fix, no functional change intended.

---
 src/drmmode_display.c | 31 +++++++++++++++++++------------
 1 file changed, 19 insertions(+), 12 deletions(-)
src/drmmode_display.c +19 -12
index 793027d50..cf1e5d1f1 100644
@@ -1739,6 +1739,22 @@ static void drmmode_output_create_resources(xf86OutputPtr output)
 	}
 }
 
+static void
+drmmode_output_set_tear_free(AMDGPUEntPtr pAMDGPUEnt,
+			     drmmode_output_private_ptr drmmode_output,
+			     xf86CrtcPtr crtc, int tear_free)
+{
+	if (drmmode_output->tear_free == tear_free)
+		return;
+
+	drmmode_output->tear_free = tear_free;
+
+	if (crtc) {
+		drmmode_set_mode_major(crtc, &crtc->mode, crtc->rotation,
+				       crtc->x, crtc->y);
+	}
+}
+
 static Bool
 drmmode_output_set_property(xf86OutputPtr output, Atom property,
 			    RRPropertyValuePtr value)
@@ -1782,18 +1798,9 @@ drmmode_output_set_property(xf86OutputPtr output, Atom property,
 			for (j = 0; j < p->mode_prop->count_enums; j++) {
 				if (!strcmp(p->mode_prop->enums[j].name, name)) {
 					if (i == (drmmode_output->num_props - 1)) {
-						if (drmmode_output->tear_free != j) {
-							xf86CrtcPtr crtc = output->crtc;
-
-							drmmode_output->tear_free = j;
-							if (crtc) {
-								drmmode_set_mode_major(crtc,
-										       &crtc->mode,
-										       crtc->rotation,
-										       crtc->x,
-										       crtc->y);
-							}
-						}
+						drmmode_output_set_tear_free(pAMDGPUEnt,
+									     drmmode_output,
+									     output->crtc, j);
 					} else {
 						drmModeConnectorSetProperty(pAMDGPUEnt->fd,
 									    drmmode_output->output_id,
Signature · 6 lines
2.17.0

_______________________________________________
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): 20180426155850.15218-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org

#2 lore raw

PATCH 2/2 Wait for pending flips in drmmode_output_set_tear_free

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

This prevents a nested call to drmHandleEvent, which would hang.

Fixes hangs when disabling TearFree on a CRTC while a DRI3 client is page flipping.

---
 src/drmmode_display.c | 9 +++++++++
 1 file changed, 9 insertions(+)
src/drmmode_display.c +9 -0
index cf1e5d1f1..4fac645b9 100644
@@ -1750,6 +1750,15 @@ drmmode_output_set_tear_free(AMDGPUEntPtr pAMDGPUEnt,
 	drmmode_output->tear_free = tear_free;
 
 	if (crtc) {
+		drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+
+		/* Wait for pending flips before drmmode_set_mode_major calls 
+		 * drmmode_crtc_update_tear_free, to prevent a nested
+		 * drmHandleEvent call, which would hang
+		 */
+		drmmode_crtc_wait_pending_event(drmmode_crtc,
+						pAMDGPUEnt->fd,
+						drmmode_crtc->flip_pending);
 		drmmode_set_mode_major(crtc, &crtc->mode, crtc->rotation,
 				       crtc->x, crtc->y);
 	}
Signature · 6 lines
2.17.0

_______________________________________________
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): 20180426155850.15218-2-michel-otUistvHUpPR7s880joybQ@public.gmane.org

Reviewed-by
#4 lore raw

Re: [PATCH xf86-video-amdgpu 2/2] Wait for pending flips in drmmode_output_set_tear_free

Quoted 17 lines · Michel Dänzer

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

This prevents a nested call to drmHandleEvent, which would hang.

Fixes hangs when disabling TearFree on a CRTC while a DRI3 client is page flipping.

---
 src/drmmode_display.c | 9 +++++++++
 1 file changed, 9 insertions(+)
src/drmmode_display.c +0 -0
index cf1e5d1f1..4fac645b9 100644

src/drmmode_display.c drmmode_output_set_tear_free(AMDGPUEntPtr pAMDGPUEnt, · line 1755

Quoted 6 lines
src/drmmode_display.c +3 -0
@@ -1750,6 +1750,15 @@ drmmode_output_set_tear_free(AMDGPUEntPtr pAMDGPUEnt,
 	drmmode_output->tear_free = tear_free;
 
 	if (crtc) {
+		drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+
+		/* Wait for pending flips before drmmode_set_mode_major calls 

Trailing white space.
Otherwise the two patches are

Sam

src/drmmode_display.c drmmode_output_set_tear_free(AMDGPUEntPtr pAMDGPUEnt, · line 1764

Quoted 10 lines
src/drmmode_display.c +6 -0
+		 * drmmode_crtc_update_tear_free, to prevent a nested
+		 * drmHandleEvent call, which would hang
+		 */
+		drmmode_crtc_wait_pending_event(drmmode_crtc,
+						pAMDGPUEnt->fd,
+						drmmode_crtc->flip_pending);
 		drmmode_set_mode_major(crtc, &crtc->mode, crtc->rotation,
 				       crtc->x, crtc->y);
 	}

_______________________________________________
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): e1c84b66-c870-5ec9-ea49-9c83876ec61b-5C7GfCeVMHo@public.gmane.org

#6 lore raw

Re: [PATCH xf86-video-amdgpu 2/2] Wait for pending flips in drmmode_output_set_tear_free

Quoted 20 lines · Samuel Li
Quoted 19 lines · Michel Dänzer

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

This prevents a nested call to drmHandleEvent, which would hang.

Fixes hangs when disabling TearFree on a CRTC while a DRI3 client is page flipping.

---
 src/drmmode_display.c | 9 +++++++++
 1 file changed, 9 insertions(+)
src/drmmode_display.c +0 -0
index cf1e5d1f1..4fac645b9 100644
@@ -1750,6 +1750,15 @@ drmmode_output_set_tear_free(AMDGPUEntPtr pAMDGPUEnt,
 	drmmode_output->tear_free = tear_free;
 
Quoted 7 lines

src/drmmode_display.c drmmode_output_set_tear_free(AMDGPUEntPtr pAMDGPUEnt, · line 1755

Quoted 4 lines
src/drmmode_display.c +3 -0
 	if (crtc) {
+		drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+
+		/* Wait for pending flips before drmmode_set_mode_major calls 

Trailing white space.
Otherwise the two patches are

Thanks Sam! I removed the trailing white space before pushing.

Signature · 6 lines
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx