Commit b1b397ae authored by David Woodhouse's avatar David Woodhouse Committed by Paolo Bonzini

vfio/virqfd: Drain events from eventfd in virqfd_wakeup()

Don't allow the events to accumulate in the eventfd counter, drain them
as they are handled.
Signed-off-by: default avatarDavid Woodhouse <dwmw@amazon.co.uk>
Message-Id: <20201027135523.646811-3-dwmw2@infradead.org>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
Acked-by: default avatarAlex Williamson <alex.williamson@redhat.com>
parent 28f13267
...@@ -46,6 +46,9 @@ static int virqfd_wakeup(wait_queue_entry_t *wait, unsigned mode, int sync, void ...@@ -46,6 +46,9 @@ static int virqfd_wakeup(wait_queue_entry_t *wait, unsigned mode, int sync, void
__poll_t flags = key_to_poll(key); __poll_t flags = key_to_poll(key);
if (flags & EPOLLIN) { if (flags & EPOLLIN) {
u64 cnt;
eventfd_ctx_do_read(virqfd->eventfd, &cnt);
/* An event has been signaled, call function */ /* An event has been signaled, call function */
if ((!virqfd->handler || if ((!virqfd->handler ||
virqfd->handler(virqfd->opaque, virqfd->data)) && virqfd->handler(virqfd->opaque, virqfd->data)) &&
......
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