From patchwork Thu Jul 2 13:17:26 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 6709431 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0F56D9FBF9 for ; Thu, 2 Jul 2015 13:22:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6A9AF206F5 for ; Thu, 2 Jul 2015 13:22:26 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2E4F3206D4 for ; Thu, 2 Jul 2015 13:22:25 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZAePy-0000eh-B7; Thu, 02 Jul 2015 13:20:42 +0000 Received: from mail-wg0-f48.google.com ([74.125.82.48]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZAeO8-0004P2-Vd for linux-arm-kernel@lists.infradead.org; Thu, 02 Jul 2015 13:18:49 +0000 Received: by wgjx7 with SMTP id x7so62927190wgj.2 for ; Thu, 02 Jul 2015 06:18:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=gbz2Ct7cC4vwpHSn22dYFdUaFe1xgX5YSoZmdLOHWH8=; b=e3OE6hSeQX3qh7JmrUK4SsBVy1/t15ScwSIrwePq/jPtzyDzua6W5zELAMxilBrS9Y 4zBrDpjhymUQmwgEOLV+rZ6WT7RsL23uO+6Q7QmqhebAcwpIl2dl0tRr6Vy51QBsEnRK 7g8/5/L4NspfMw9ZzGSU/pQ7V8L4YBkT/Qte3GMPi+Yg5HZH4BAUFEpljFkoGMD6W+vy mZUNv9JRh60aF7I9Pi1wzK1HQySU4J7CRPPICwpdSaVSEBaMVLsYEeUej2y908AMSekk cWPW7g48lwx4b8h4508yMJdrRWUIuiMP5OT9iYKrLnh0m0p9fkZBXRpL5oNX9GOK9Qlz 3LXw== X-Gm-Message-State: ALoCoQmaym0ca/hFyP/HXM7EAlPV4bnCLLbn2l+jQVvc7SEDP3r21p/nExAUI4VrQaNnoTfZNtck X-Received: by 10.180.90.241 with SMTP id bz17mr50343298wib.95.1435843107281; Thu, 02 Jul 2015 06:18:27 -0700 (PDT) Received: from gnx2579.home (LCaen-156-56-7-90.w80-11.abo.wanadoo.fr. [80.11.198.90]) by mx.google.com with ESMTPSA id tl3sm8157099wjc.20.2015.07.02.06.18.25 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Jul 2015 06:18:26 -0700 (PDT) From: Eric Auger To: eric.auger@st.com, eric.auger@linaro.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, christoffer.dall@linaro.org, marc.zyngier@arm.com, alex.williamson@redhat.com, pbonzini@redhat.com, avi.kivity@gmail.com, mtosatti@redhat.com, feng.wu@intel.com, joro@8bytes.org, b.reynal@virtualopensystems.com Subject: [RFC 16/17] KVM: eventfd: add irq bypass consumer management Date: Thu, 2 Jul 2015 15:17:26 +0200 Message-Id: <1435843047-6327-17-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1435843047-6327-1-git-send-email-eric.auger@linaro.org> References: <1435843047-6327-1-git-send-email-eric.auger@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150702_061849_174528_D9DC2B73 X-CRM114-Status: GOOD ( 15.50 ) X-Spam-Score: -2.6 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, patches@linaro.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 This patch adds the registration/unregistration of an irq_bypass_consumer on irqfd assignment/deassignment. Signed-off-by: Eric Auger --- virt/kvm/eventfd.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c index f3da161..425a47b 100644 --- a/virt/kvm/eventfd.c +++ b/virt/kvm/eventfd.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -93,6 +94,7 @@ struct _irqfd { struct list_head list; poll_table pt; struct work_struct shutdown; + struct irq_bypass_consumer *cons; }; static struct workqueue_struct *irqfd_cleanup_wq; @@ -429,7 +431,21 @@ kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd *args) */ fdput(f); - /* irq_bypass_register_consumer(); */ + irqfd->cons = kzalloc(sizeof(struct irq_bypass_consumer), + GFP_KERNEL); + if (!irqfd->cons) { + ret = -ENOMEM; + goto fail; + } + irqfd->cons->token = (void *)irqfd->eventfd; + irqfd->cons->gsi = irqfd->gsi; + irqfd->cons->kvm = kvm; + irqfd->cons->add_producer = kvm_arch_add_producer; + irqfd->cons->del_producer = kvm_arch_del_producer; + irqfd->cons->stop_consumer = kvm_arch_stop_consumer; + irqfd->cons->resume_consumer = kvm_arch_resume_consumer; + ret = irq_bypass_register_consumer(irqfd->cons); + WARN_ON(ret); return 0; @@ -530,8 +546,6 @@ kvm_irqfd_deassign(struct kvm *kvm, struct kvm_irqfd *args) struct _irqfd *irqfd, *tmp; struct eventfd_ctx *eventfd; - /* irq_bypass_unregister_consumer() */ - eventfd = eventfd_ctx_fdget(args->fd); if (IS_ERR(eventfd)) return PTR_ERR(eventfd); @@ -550,6 +564,8 @@ kvm_irqfd_deassign(struct kvm *kvm, struct kvm_irqfd *args) irqfd->irq_entry.type = 0; write_seqcount_end(&irqfd->irq_entry_sc); irqfd_deactivate(irqfd); + irq_bypass_unregister_consumer(irqfd->cons); + kfree(irqfd->cons); } }