Module: Mesa
Branch: main
Commit: b9ad22d24eeeba5cf4ad1ec5e740e825500f57b8
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b9ad22d24eeeba5cf4ad1ec5e740e825500f57b8

Author: Dmitry Osipenko <[email protected]>
Date:   Thu Jan 11 22:15:46 2024 +0300

virtio/vdrm: Fix lockup in vdrm_host_sync()

The vdrm_execbuf() missed to set the seqno field for requests sent to host.
This causes vdrm_host_sync() to lock up due to the unset seqno in a case
where two or more threads are using vdrm_execbuf() and vdrm_send_req()
concurrently, like in this scenario:

        thread1: vdrm_send_req()  shmem->seqno=1 req->seqno=2
        thread2: vdrm_execbuf()   shmem->seqno=1 req->seqno=0
        thread1: vdrm_host_sync() shmem->seqno=0 req->seqno=2

Fix the lockup by setting the seqno in vdrm_execbuf().

Signed-off-by: Dmitry Osipenko <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27021>

---

 src/virtio/vdrm/vdrm.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/virtio/vdrm/vdrm.c b/src/virtio/vdrm/vdrm.c
index ff69ad325dc..3f7784712fc 100644
--- a/src/virtio/vdrm/vdrm.c
+++ b/src/virtio/vdrm/vdrm.c
@@ -109,6 +109,8 @@ vdrm_execbuf(struct vdrm_device *vdev, struct 
vdrm_execbuf_params *p)
 
    simple_mtx_lock(&vdev->eb_lock);
 
+   p->req->seqno = ++vdev->next_seqno;
+
    ret = vdev->funcs->flush_locked(vdev, NULL);
    if (ret)
       goto out_unlock;

Reply via email to