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: 6709141 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2DFFA9F380 for ; Thu, 2 Jul 2015 13:19:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 50A41206B8 for ; Thu, 2 Jul 2015 13:19:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5B5E22065A for ; Thu, 2 Jul 2015 13:19:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752590AbbGBNTE (ORCPT ); Thu, 2 Jul 2015 09:19:04 -0400 Received: from mail-wg0-f45.google.com ([74.125.82.45]:33611 "EHLO mail-wg0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752995AbbGBNS2 (ORCPT ); Thu, 2 Jul 2015 09:18:28 -0400 Received: by wgck11 with SMTP id k11so63133717wgc.0 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=a11ID21VBZA+cjPdvAfZsxL0mMIcelXDC79R7UzWf6zKGbAb8ARFueAQYBkSha3vCv AWYOHhjNkci0gq0mhPSqtU3tpP4vCs9xuP8u1cmdrXiLBGxWwh/hPJZL1d8hdE1HkqIy pJ7ALcmTk+d8zWlugQJA5nw2O5PxYKpYuWRl6hUHHrurPCUnbnl1n3XzuVE0oeeUoAoW pLCBaKVuaziOgWyfAfoBo1n43Gqxem6t1Hj055ZGJnVi4i5SQi+bynL05D1PGBq92AGC r5NaHspPxy+S8Ge/xh+AZPVM6DGKZQEhw/SIt9ysT65z5P6y40NF60s+pxCmebMaUydo kgLg== X-Gm-Message-State: ALoCoQmB1XUCXCP7k8NTNIOVr4HggGywtFCtniR/d32DW1t8RwIlEQt/W1Y8Mo28fSgBiYJcaaaG 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 Cc: linux-kernel@vger.kernel.org, patches@linaro.org 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> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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); } }