Add routines to queue works on virtqueue assigned workers Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko@xxxxxxxxxxxxx> --- drivers/vhost/vhost.c | 22 ++++++++++++++++++++++ drivers/vhost/vhost.h | 5 +++++ 2 files changed, 27 insertions(+) diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index d80831d21fba..fbf5fae1a6bf 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -272,6 +272,17 @@ static void vhost_worker_flush(struct vhost_worker *w) wait_for_completion(&flush.wait_event); } +void vhost_work_flush_vq(struct vhost_virtqueue *vq) +{ + struct vhost_worker *w = READ_ONCE(vq->worker); + + if (!w) + return; + + vhost_worker_flush(w); +} +EXPORT_SYMBOL_GPL(vhost_work_flush_vq); + void vhost_work_queue(struct vhost_dev *dev, struct vhost_work *work) { struct vhost_worker *w = &dev->workers[0]; @@ -283,6 +294,17 @@ void vhost_work_queue(struct vhost_dev *dev, struct vhost_work *work) } EXPORT_SYMBOL_GPL(vhost_work_queue); +void vhost_work_vqueue(struct vhost_virtqueue *vq, struct vhost_work *work) +{ + struct vhost_worker *w = READ_ONCE(vq->worker); + + if (!w) + return; + + vhost_work_queue_at_worker(w, work); +} +EXPORT_SYMBOL_GPL(vhost_work_vqueue); + /* A lockless hint for busy polling code to exit the loop */ bool vhost_has_work(struct vhost_dev *dev) { diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h index b9a10c85b298..bedf8b9d99de 100644 --- a/drivers/vhost/vhost.h +++ b/drivers/vhost/vhost.h @@ -141,6 +141,11 @@ struct vhost_virtqueue { struct vhost_worker *worker; }; +/* Queue the work on virtqueue assigned worker */ +void vhost_work_vqueue(struct vhost_virtqueue *vq, struct vhost_work *work); +/* Flush virtqueue assigned worker */ +void vhost_work_flush_vq(struct vhost_virtqueue *vq); + struct vhost_msg_node { union { struct vhost_msg msg; -- 2.31.1