From patchwork Wed Sep 4 10:27:39 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 2853590 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 761A79F4D4 for ; Wed, 4 Sep 2013 10:27:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8AE782031C for ; Wed, 4 Sep 2013 10:27:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5A890200DF for ; Wed, 4 Sep 2013 10:27:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1762373Ab3IDK1u (ORCPT ); Wed, 4 Sep 2013 06:27:50 -0400 Received: from fw-tnat.cambridge.arm.com ([217.140.96.21]:52380 "EHLO cam-smtp0.cambridge.arm.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1762369Ab3IDK1t (ORCPT ); Wed, 4 Sep 2013 06:27:49 -0400 Received: from mudshark.cambridge.arm.com (mudshark.cambridge.arm.com [10.1.203.36]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id r84ARiFP019560; Wed, 4 Sep 2013 11:27:44 +0100 Received: by mudshark.cambridge.arm.com (Postfix, from userid 1000) id 78BFBC2B19; Wed, 4 Sep 2013 11:27:40 +0100 (BST) From: Will Deacon To: kvm@vger.kernel.org Cc: penberg@kernel.org, Will Deacon , Ying-Shiuan Pan Subject: [PATCH] kvm tools: ioeventfd: replace bool parameters to __add_event with flags Date: Wed, 4 Sep 2013 11:27:39 +0100 Message-Id: <1378290459-12193-1-git-send-email-will.deacon@arm.com> X-Mailer: git-send-email 1.8.2.2 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-9.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP A recent fix to virtio MMIO (72a7541ce305 ["kvm tools: virtio-mmio: init_ioeventfd should use MMIO for ioeventfd__add_event()"]) highlighted the confusing parameters expected by ioeventfd__add_event. As per Pekka's suggestion, replace the bool parameters to this function with a single `flags' argument instead. Cc: Ying-Shiuan Pan Signed-off-by: Will Deacon --- tools/kvm/include/kvm/ioeventfd.h | 5 ++++- tools/kvm/ioeventfd.c | 6 +++--- tools/kvm/virtio/mmio.c | 4 ++-- tools/kvm/virtio/pci.c | 5 +++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/tools/kvm/include/kvm/ioeventfd.h b/tools/kvm/include/kvm/ioeventfd.h index d71fa40..bb1f78d 100644 --- a/tools/kvm/include/kvm/ioeventfd.h +++ b/tools/kvm/include/kvm/ioeventfd.h @@ -20,9 +20,12 @@ struct ioevent { struct list_head list; }; +#define IOEVENTFD_FLAG_PIO (1 << 0) +#define IOEVENTFD_FLAG_USER_POLL (1 << 1) + int ioeventfd__init(struct kvm *kvm); int ioeventfd__exit(struct kvm *kvm); -int ioeventfd__add_event(struct ioevent *ioevent, bool is_pio, bool poll_in_userspace); +int ioeventfd__add_event(struct ioevent *ioevent, int flags); int ioeventfd__del_event(u64 addr, u64 datamatch); #endif diff --git a/tools/kvm/ioeventfd.c b/tools/kvm/ioeventfd.c index ff665d4..bce6861 100644 --- a/tools/kvm/ioeventfd.c +++ b/tools/kvm/ioeventfd.c @@ -120,7 +120,7 @@ int ioeventfd__exit(struct kvm *kvm) } base_exit(ioeventfd__exit); -int ioeventfd__add_event(struct ioevent *ioevent, bool is_pio, bool poll_in_userspace) +int ioeventfd__add_event(struct ioevent *ioevent, int flags) { struct kvm_ioeventfd kvm_ioevent; struct epoll_event epoll_event; @@ -145,7 +145,7 @@ int ioeventfd__add_event(struct ioevent *ioevent, bool is_pio, bool poll_in_user .flags = KVM_IOEVENTFD_FLAG_DATAMATCH, }; - if (is_pio) + if (flags & IOEVENTFD_FLAG_PIO) kvm_ioevent.flags |= KVM_IOEVENTFD_FLAG_PIO; r = ioctl(ioevent->fn_kvm->vm_fd, KVM_IOEVENTFD, &kvm_ioevent); @@ -154,7 +154,7 @@ int ioeventfd__add_event(struct ioevent *ioevent, bool is_pio, bool poll_in_user goto cleanup; } - if (!poll_in_userspace) + if (!(flags & IOEVENTFD_FLAG_USER_POLL)) return 0; epoll_event = (struct epoll_event) { diff --git a/tools/kvm/virtio/mmio.c b/tools/kvm/virtio/mmio.c index 3838774..afae6a7 100644 --- a/tools/kvm/virtio/mmio.c +++ b/tools/kvm/virtio/mmio.c @@ -55,10 +55,10 @@ static int virtio_mmio_init_ioeventfd(struct kvm *kvm, * Vhost will poll the eventfd in host kernel side, * no need to poll in userspace. */ - err = ioeventfd__add_event(&ioevent, false, false); + err = ioeventfd__add_event(&ioevent, 0); else /* Need to poll in userspace. */ - err = ioeventfd__add_event(&ioevent, false, true); + err = ioeventfd__add_event(&ioevent, IOEVENTFD_FLAG_USER_POLL); if (err) return err; diff --git a/tools/kvm/virtio/pci.c b/tools/kvm/virtio/pci.c index fec8ce0..bb6e7c4 100644 --- a/tools/kvm/virtio/pci.c +++ b/tools/kvm/virtio/pci.c @@ -46,10 +46,11 @@ static int virtio_pci__init_ioeventfd(struct kvm *kvm, struct virtio_device *vde * Vhost will poll the eventfd in host kernel side, * no need to poll in userspace. */ - r = ioeventfd__add_event(&ioevent, true, false); + r = ioeventfd__add_event(&ioevent, IOEVENTFD_FLAG_PIO); else /* Need to poll in userspace. */ - r = ioeventfd__add_event(&ioevent, true, true); + r = ioeventfd__add_event(&ioevent, IOEVENTFD_FLAG_PIO | + IOEVENTFD_FLAG_USER_POLL); if (r) return r;