Skip to contentSkip to conversation

Always delete entry from list in drm_queue_handler

PATCH New Michel Dänzer 1 participant 4 messages Aug 29, 2018 – Sep 5, 2018 2 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 Always delete entry from list in drm_queue_handler

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

We left entries without a handler hook in the list, so the list could keep taking longer to process and use up more memory.

---
 src/amdgpu_drm_queue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/amdgpu_drm_queue.c +1 -1
index b13d28014..f9db81c08 100644
@@ -82,7 +82,7 @@ amdgpu_drm_queue_handler(struct xorg_list *signalled, unsigned int frame,
 	xorg_list_for_each_entry_safe(e, tmp, &amdgpu_drm_queue, list) {
 		if (e->seq == seq) {
 			if (!e->handler) {
-				e->abort(e->crtc, e->data);
+				amdgpu_drm_queue_handle_one(e);
 				break;
 			}
 
Signature · 6 lines
2.18.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): 20180829165648.1977-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org

#2 lore raw

PATCH 2/3 Don't use xorg_list_for_each_entry_safe for signalled flips

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

drm_wait_pending_flip can get called from drm_handle_event, in which case xorg_list_for_each_entry_safe can end up processing the same entry in both. To avoid this, just process the first list entry until the list is empty.

---
 src/amdgpu_drm_queue.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
src/amdgpu_drm_queue.c +9 -3
index f9db81c08..ba841d1ef 100644
@@ -257,8 +257,11 @@ amdgpu_drm_handle_event(int fd, drmEventContext *event_context)
 
 	r = drmHandleEvent(fd, event_context);
 
-	xorg_list_for_each_entry_safe(e, tmp, &amdgpu_drm_flip_signalled, list)
+	while (!xorg_list_is_empty(&amdgpu_drm_flip_signalled)) {
+		e = xorg_list_first_entry(&amdgpu_drm_flip_signalled,
+					  struct amdgpu_drm_queue_entry, list);
 		amdgpu_drm_queue_handle_one(e);
+	}
 
 	xorg_list_for_each_entry_safe(e, tmp, &amdgpu_drm_vblank_signalled, list) {
 		drmmode_crtc_private_ptr drmmode_crtc = e->crtc->driver_private;
@@ -277,12 +280,15 @@ void amdgpu_drm_wait_pending_flip(xf86CrtcPtr crtc)
 {
 	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
 	AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(crtc->scrn);
-	struct amdgpu_drm_queue_entry *e, *tmp;
+	struct amdgpu_drm_queue_entry *e;
 
 	drmmode_crtc->wait_flip_nesting_level++;
 
-	xorg_list_for_each_entry_safe(e, tmp, &amdgpu_drm_flip_signalled, list)
+	while (!xorg_list_is_empty(&amdgpu_drm_flip_signalled)) {
+		e = xorg_list_first_entry(&amdgpu_drm_flip_signalled,
+					  struct amdgpu_drm_queue_entry, list);
 		amdgpu_drm_queue_handle_one(e);
+	}
 
 	while (drmmode_crtc->flip_pending
 	       && amdgpu_drm_handle_event(pAMDGPUEnt->fd,
Signature · 6 lines
2.18.0

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

PATCH 3/3 Bail early from drm_wait_pending_flip if there's no pending flip

In reply to a message not in the archive

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

No need to process any events in that case.

---
 src/amdgpu_drm_queue.c | 3 +++
 1 file changed, 3 insertions(+)
src/amdgpu_drm_queue.c +3 -0
index ba841d1ef..61732b11c 100644
@@ -284,6 +284,9 @@ void amdgpu_drm_wait_pending_flip(xf86CrtcPtr crtc)
 
 	drmmode_crtc->wait_flip_nesting_level++;
 
+	if (!drmmode_crtc->flip_pending)
+		return;
+
 	while (!xorg_list_is_empty(&amdgpu_drm_flip_signalled)) {
 		e = xorg_list_first_entry(&amdgpu_drm_flip_signalled,
 					  struct amdgpu_drm_queue_entry, list);
Signature · 6 lines
2.18.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): 20180829165648.1977-3-michel-otUistvHUpPR7s880joybQ@public.gmane.org

#5 lore raw

PATCH v2 1/1 Bail early from drm_wait_pending_flip if there's no pending flip

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

No need to process any events in that case.

v2:
* Re-check drmmode_crtc->flip_pending after processing each event

---
 src/amdgpu_drm_queue.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
src/amdgpu_drm_queue.c +2 -1
index ba841d1ef..035356234 100644
@@ -284,7 +284,8 @@ void amdgpu_drm_wait_pending_flip(xf86CrtcPtr crtc)
 
 	drmmode_crtc->wait_flip_nesting_level++;
 
-	while (!xorg_list_is_empty(&amdgpu_drm_flip_signalled)) {
+	while (drmmode_crtc->flip_pending &&
+	       !xorg_list_is_empty(&amdgpu_drm_flip_signalled)) {
 		e = xorg_list_first_entry(&amdgpu_drm_flip_signalled,
 					  struct amdgpu_drm_queue_entry, list);
 		amdgpu_drm_queue_handle_one(e);
Signature · 6 lines
2.19.0.rc1

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