Commit b7e2041e authored by David S. Miller's avatar David S. Miller
parents 92d76e81 0174b0c3
...@@ -97,22 +97,26 @@ void vhost_poll_stop(struct vhost_poll *poll) ...@@ -97,22 +97,26 @@ void vhost_poll_stop(struct vhost_poll *poll)
remove_wait_queue(poll->wqh, &poll->wait); remove_wait_queue(poll->wqh, &poll->wait);
} }
static bool vhost_work_seq_done(struct vhost_dev *dev, struct vhost_work *work,
unsigned seq)
{
int left;
spin_lock_irq(&dev->work_lock);
left = seq - work->done_seq;
spin_unlock_irq(&dev->work_lock);
return left <= 0;
}
static void vhost_work_flush(struct vhost_dev *dev, struct vhost_work *work) static void vhost_work_flush(struct vhost_dev *dev, struct vhost_work *work)
{ {
unsigned seq; unsigned seq;
int left;
int flushing; int flushing;
spin_lock_irq(&dev->work_lock); spin_lock_irq(&dev->work_lock);
seq = work->queue_seq; seq = work->queue_seq;
work->flushing++; work->flushing++;
spin_unlock_irq(&dev->work_lock); spin_unlock_irq(&dev->work_lock);
wait_event(work->done, ({ wait_event(work->done, vhost_work_seq_done(dev, work, seq));
spin_lock_irq(&dev->work_lock);
left = seq - work->done_seq <= 0;
spin_unlock_irq(&dev->work_lock);
left;
}));
spin_lock_irq(&dev->work_lock); spin_lock_irq(&dev->work_lock);
flushing = --work->flushing; flushing = --work->flushing;
spin_unlock_irq(&dev->work_lock); spin_unlock_irq(&dev->work_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment