Mesa (staging/20.1): loader/dri3: Use dri3_wait_for_event_locked in loader_dri3_wait_for_msc

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Jun 29 19:14:58 UTC 2020


Module: Mesa
Branch: staging/20.1
Commit: e6091908d58ecfddceac5e37da93da3217b13aac
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=e6091908d58ecfddceac5e37da93da3217b13aac

Author: Michel Dänzer <mdaenzer at redhat.com>
Date:   Fri Jun  5 18:22:31 2020 +0200

loader/dri3: Use dri3_wait_for_event_locked in loader_dri3_wait_for_msc

Before, if one thread ended up waiting in dri3_wait_for_event_locked
and another one in loader_dri3_wait_for_msc at the same time, one thread
could end up processing an event the other thread was waiting for, which
could result in the latter thread waiting longer than necessary
(possibly indefinitely).

Noticed by inspection.

v2:
* Drop xcb_flush call from loader_dri3_wait_for_msc in favour of the one
  in dri3_wait_for_event_locked (Kenneth Graunke)

Fixes: 7b0e8264dd21 "loader/dri3: Try to make sure we only process our
                     own NotifyMSC events"

Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5368>
(cherry picked from commit 7c226116c6c0793d6d9a7dec52ac7cf54b82b57f)

---

 .pick_status.json               | 2 +-
 src/loader/loader_dri3_helper.c | 8 +-------
 2 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 9d1f8b75207..22b5611bd17 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -13,7 +13,7 @@
         "description": "loader/dri3: Use dri3_wait_for_event_locked in loader_dri3_wait_for_msc",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "master_sha": null,
         "because_sha": "7b0e8264dd21ae05521d08d41fecd84139401fef"
     },
diff --git a/src/loader/loader_dri3_helper.c b/src/loader/loader_dri3_helper.c
index a2c0f6cc817..12860d6594f 100644
--- a/src/loader/loader_dri3_helper.c
+++ b/src/loader/loader_dri3_helper.c
@@ -577,22 +577,16 @@ loader_dri3_wait_for_msc(struct loader_dri3_drawable *draw,
                                                      target_msc,
                                                      divisor,
                                                      remainder);
-   xcb_generic_event_t *ev;
    unsigned full_sequence;
 
    mtx_lock(&draw->mtx);
-   xcb_flush(draw->conn);
 
    /* Wait for the event */
    do {
-      ev = xcb_wait_for_special_event(draw->conn, draw->special_event);
-      if (!ev) {
+      if (!dri3_wait_for_event_locked(draw, &full_sequence)) {
          mtx_unlock(&draw->mtx);
          return false;
       }
-
-      full_sequence = ev->full_sequence;
-      dri3_handle_present_event(draw, (void *) ev);
    } while (full_sequence != cookie.sequence || draw->notify_msc < target_msc);
 
    *ust = draw->notify_ust;



More information about the mesa-commit mailing list