summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Woodhouse <dwmw@amazon.co.uk>2020-10-27 14:55:22 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2020-11-15 15:49:10 +0100
commitb1b397aeef8177f4f7bd91a0d5fa708f4752a499 (patch)
tree82a2c5c8365e5e057b58fd68cfc745d17409a233
parenteventfd: Export eventfd_ctx_do_read() (diff)
downloadlinux-b1b397aeef8177f4f7bd91a0d5fa708f4752a499.tar.xz
linux-b1b397aeef8177f4f7bd91a0d5fa708f4752a499.zip
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: David Woodhouse <dwmw@amazon.co.uk> Message-Id: <20201027135523.646811-3-dwmw2@infradead.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Acked-by: Alex Williamson <alex.williamson@redhat.com>
-rw-r--r--drivers/vfio/virqfd.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/vfio/virqfd.c b/drivers/vfio/virqfd.c
index 997cb5d0a657..414e98d82b02 100644
--- a/drivers/vfio/virqfd.c
+++ b/drivers/vfio/virqfd.c
@@ -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);
if (flags & EPOLLIN) {
+ u64 cnt;
+ eventfd_ctx_do_read(virqfd->eventfd, &cnt);
+
/* An event has been signaled, call function */
if ((!virqfd->handler ||
virqfd->handler(virqfd->opaque, virqfd->data)) &&