vdpa_sim: replace the spinlock with a mutex to protect the state
authorStefano Garzarella <sgarzare@redhat.com>
Tue, 4 Apr 2023 13:17:29 +0000 (15:17 +0200)
committerMichael S. Tsirkin <mst@redhat.com>
Fri, 21 Apr 2023 07:02:33 +0000 (03:02 -0400)
commitd7621c28fca1c16f9e94245479792024a5676c50
treecbf1d21fd127c808cab3a1a21c65ef0b7f6705eb
parent76acfa7bc54f1e3b9dde396e0a3534493419fd6f
vdpa_sim: replace the spinlock with a mutex to protect the state

The spinlock we use to protect the state of the simulator is sometimes
held for a long time (for example, when devices handle requests).

This also prevents us from calling functions that might sleep (such as
kthread_flush_work() in the next patch), and thus having to release
and retake the lock.

For these reasons, let's replace the spinlock with a mutex that gives
us more flexibility.

Suggested-by: Jason Wang <jasowang@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Message-Id: <20230404131730.45920-1-sgarzare@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
drivers/vdpa/vdpa_sim/vdpa_sim.c
drivers/vdpa/vdpa_sim/vdpa_sim.h
drivers/vdpa/vdpa_sim/vdpa_sim_blk.c
drivers/vdpa/vdpa_sim/vdpa_sim_net.c