All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] drmmode: make event handler leave a note that there are stuck events
@ 2020-08-16  3:23 Ilia Mirkin
       [not found] ` <20200816032336.18964-1-imirkin-FrUbXkNCsVf2fBVCVOL8/A@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Ilia Mirkin @ 2020-08-16  3:23 UTC (permalink / raw)
  To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

We don't really expect to have too many events in the queue. If there
are, then the algorithm we use isn't appropriate. Add a warning when the
queue gets very long, as it's an indication of something having gone
wrong.

Signed-off-by: Ilia Mirkin <imirkin-FrUbXkNCsVf2fBVCVOL8/A@public.gmane.org>
---
 src/drmmode_display.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 2d3229c..45292c4 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -159,6 +159,8 @@ drmmode_events = {
 	.prev = &drmmode_events,
 };
 
+static bool warned = false;
+
 static void
 drmmode_event_handler(int fd, unsigned int frame, unsigned int tv_sec,
 		      unsigned int tv_usec, void *event_data)
@@ -166,7 +168,10 @@ drmmode_event_handler(int fd, unsigned int frame, unsigned int tv_sec,
 	const uint64_t ust = (uint64_t)tv_sec * 1000000 + tv_usec;
 	struct drmmode_event *e = event_data;
 
+	int counter = 0;
+
 	xorg_list_for_each_entry(e, &drmmode_events, head) {
+		counter++;
 		if (e == event_data) {
 			xorg_list_del(&e->head);
 			e->func((void *)(e + 1), e->name, ust, frame);
@@ -174,6 +179,12 @@ drmmode_event_handler(int fd, unsigned int frame, unsigned int tv_sec,
 			break;
 		}
 	}
+
+	if (counter > 100 && !warned) {
+		xf86DrvMsg(0, X_WARNING,
+			   "Event handler iterated %d times\n", counter);
+		warned = true;
+	}
 }
 
 void
-- 
2.26.2

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH 2/2] present: fix handling of drmWaitVBlank failures
       [not found] ` <20200816032336.18964-1-imirkin-FrUbXkNCsVf2fBVCVOL8/A@public.gmane.org>
@ 2020-08-16  3:23   ` Ilia Mirkin
  0 siblings, 0 replies; 2+ messages in thread
From: Ilia Mirkin @ 2020-08-16  3:23 UTC (permalink / raw)
  To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

When drmWaitVBlank fails, make sure to remove the event from the queue.

Signed-off-by: Ilia Mirkin <imirkin-FrUbXkNCsVf2fBVCVOL8/A@public.gmane.org>
---

Note this needs a bit more testing, and also double-checking what the
"correct" way of dealing with these errors is. I was able to trigger
errors with "xset dpms force off", but perhaps there are also other
conditions.

 src/nouveau_present.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/nouveau_present.c b/src/nouveau_present.c
index 8167fd8..15516d6 100644
--- a/src/nouveau_present.c
+++ b/src/nouveau_present.c
@@ -113,8 +113,19 @@ nouveau_present_vblank_queue(RRCrtcPtr rrcrtc, uint64_t event_id, uint64_t msc)
 	args.request.signal = (unsigned long)token;
 
 	while ((ret = drmWaitVBlank(pNv->dev->fd, &args)) != 0) {
-		if (errno != EBUSY || drmmode_event_flush(crtc->scrn) < 0)
+		if (errno != EBUSY) {
+			xf86DrvMsg(crtc->scrn->scrnIndex, X_DEBUG,
+				   "PRESENT: Wait for VBlank failed: %s\n", strerror(errno));
+			drmmode_event_abort(crtc->scrn, event_id, false);
 			return BadAlloc;
+		}
+		ret = drmmode_event_flush(crtc->scrn);
+		if (ret < 0) {
+			xf86DrvMsg(crtc->scrn->scrnIndex, X_DEBUG,
+				   "PRESENT: Event flush failed\n");
+			drmmode_event_abort(crtc->scrn, event_id, false);
+			return BadAlloc;
+		}
 	}
 
 	return Success;
-- 
2.26.2

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-08-16  3:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-16  3:23 [PATCH 1/2] drmmode: make event handler leave a note that there are stuck events Ilia Mirkin
     [not found] ` <20200816032336.18964-1-imirkin-FrUbXkNCsVf2fBVCVOL8/A@public.gmane.org>
2020-08-16  3:23   ` [PATCH 2/2] present: fix handling of drmWaitVBlank failures Ilia Mirkin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.