From patchwork Thu Nov 19 14:53:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 7657911 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 D2B3C9F2E2 for ; Thu, 19 Nov 2015 14:57:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F100D2063C for ; Thu, 19 Nov 2015 14:57:13 +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 2530D204D9 for ; Thu, 19 Nov 2015 14:57:13 +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 1ZzQcQ-0003HR-OQ; Thu, 19 Nov 2015 14:55:26 +0000 Received: from mail-wm0-x22b.google.com ([2a00:1450:400c:c09::22b]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZzQbe-00016w-A6 for linux-arm-kernel@lists.infradead.org; Thu, 19 Nov 2015 14:54:41 +0000 Received: by wmdw130 with SMTP id w130so243637247wmd.0 for ; Thu, 19 Nov 2015 06:54:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=hRRAqOqPn9ZKzVpLD9RckfvNossiSj+Bth8kvxS5CaQ=; b=LuFdt/ukWxds4Yns7j55AqgARwTBzLFfODvxJf08dPv5owwOlDcssemUOSkbv9b+Vr bU5GrJPwIj3ZNKCwMv1yVmzeh2vDS3ZGp/Usd22njGEtx7ln0OPrHO0D+GrUXH20Nfal BG74qoVrA3bd/yIE6Urooma/FcDSPIP2W3LRiKx0knZf7ipHGa6ULJ1rk9fc7TnLII1C k0qNEOa2ww/5OyjUBm2//2TxdLDTNTRzzNe/8k5G5b0IV38EcvcJmV0OcVrmwxQLWeZE Z9uj9YBgHR75Z/IvhD73/u+Tm7A66fGBaEpFi1EJM3S1bf0VJbCzv1fmL4XHkRHIi50z 0HiQ== 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=hRRAqOqPn9ZKzVpLD9RckfvNossiSj+Bth8kvxS5CaQ=; b=Athyw7l14LJWIul7dWgbwVxcl3VvoL5AjuZsTkuVFJA7MAnF06JnbUS/n53z8guSqK Eq8/Mn6heY/189Nkvre1k834IrQo9e/WY7ptb+E2D9b8T5Z7P9I30DK9KSMhANrY5VTg 3Swd68eE+RC70uFYE/tIfGp8i9glWMW2yX6WXOQPeSxBbZ4mbXoWXw3mnJ+1bXzotHBC iIEyBgzZq/pCIQdGK+DdgfnULs7sISnZ5K7Ryps+rgGSNHdY7wGlR91GzB/RnnecyuHm OSJksVdEUuBExt/bhYrb7YA2BEz+FwDpCFt7ubVjHGFfNXaRi+9ZZ6ocE/OvXOHrJE7Y iG7w== X-Gm-Message-State: ALoCoQkDSwWaYunMAO/923+9sLhQJYyB7sNTau4Ct1/3B18yrMh4RFfaHeysRsSnk97GaEy39lRx X-Received: by 10.28.89.129 with SMTP id n123mr3441373wmb.2.1447944856695; Thu, 19 Nov 2015 06:54:16 -0800 (PST) Received: from new-host-3.home (LMontsouris-657-1-37-90.w80-11.abo.wanadoo.fr. [80.11.198.90]) by smtp.gmail.com with ESMTPSA id h67sm34493865wmf.17.2015.11.19.06.54.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Nov 2015 06:54:15 -0800 (PST) From: Eric Auger To: eric.auger@st.com, eric.auger@linaro.org, alex.williamson@redhat.com, b.reynal@virtualopensystems.com, christoffer.dall@linaro.org, marc.zyngier@arm.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org Subject: [PATCH v4 04/13] VFIO: platform: single handler using function pointer Date: Thu, 19 Nov 2015 14:53:54 +0000 Message-Id: <1447944843-17731-5-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1447944843-17731-1-git-send-email-eric.auger@linaro.org> References: <1447944843-17731-1-git-send-email-eric.auger@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151119_065438_685978_784B6BC4 X-CRM114-Status: GOOD ( 13.89 ) 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: andre.przywara@arm.com, 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.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,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 single handler now is registered whatever the use case: automasked or not. A function pointer is set according to the wished behavior and the handler calls this function. The irq lock is taken/released in the root handler. eventfd_signal can be called in regions not allowed to sleep. Signed-off-by: Eric Auger --- v4: creation --- drivers/vfio/platform/vfio_platform_irq.c | 21 +++++++++++++++------ drivers/vfio/platform/vfio_platform_private.h | 1 + 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/drivers/vfio/platform/vfio_platform_irq.c b/drivers/vfio/platform/vfio_platform_irq.c index d4462fd..c58e0ad 100644 --- a/drivers/vfio/platform/vfio_platform_irq.c +++ b/drivers/vfio/platform/vfio_platform_irq.c @@ -148,11 +148,8 @@ static int vfio_platform_set_irq_unmask(struct vfio_platform_device *vdev, static irqreturn_t vfio_automasked_irq_handler(int irq, void *dev_id) { struct vfio_platform_irq *irq_ctx = dev_id; - unsigned long flags; int ret = IRQ_NONE; - spin_lock_irqsave(&irq_ctx->lock, flags); - if (!irq_ctx->masked) { ret = IRQ_HANDLED; @@ -161,8 +158,6 @@ static irqreturn_t vfio_automasked_irq_handler(int irq, void *dev_id) irq_ctx->masked = true; } - spin_unlock_irqrestore(&irq_ctx->lock, flags); - if (ret == IRQ_HANDLED) eventfd_signal(irq_ctx->trigger, 1); @@ -178,6 +173,19 @@ static irqreturn_t vfio_irq_handler(int irq, void *dev_id) return IRQ_HANDLED; } +static irqreturn_t vfio_handler(int irq, void *dev_id) +{ + struct vfio_platform_irq *irq_ctx = dev_id; + unsigned long flags; + irqreturn_t ret; + + spin_lock_irqsave(&irq_ctx->lock, flags); + ret = irq_ctx->handler(irq, dev_id); + spin_unlock_irqrestore(&irq_ctx->lock, flags); + + return ret; +} + static void vfio_platform_irq_bypass_stop(struct irq_bypass_producer *prod) { } @@ -230,9 +238,10 @@ static int vfio_set_trigger(struct vfio_platform_device *vdev, int index, } irq->trigger = trigger; + irq->handler = handler; irq_set_status_flags(irq->hwirq, IRQ_NOAUTOEN); - ret = request_irq(irq->hwirq, handler, 0, irq->name, irq); + ret = request_irq(irq->hwirq, vfio_handler, 0, irq->name, irq); if (ret) { kfree(irq->name); eventfd_ctx_put(trigger); diff --git a/drivers/vfio/platform/vfio_platform_private.h b/drivers/vfio/platform/vfio_platform_private.h index 55e8043..8a8c050 100644 --- a/drivers/vfio/platform/vfio_platform_private.h +++ b/drivers/vfio/platform/vfio_platform_private.h @@ -40,6 +40,7 @@ struct vfio_platform_irq { struct virqfd *mask; struct irq_bypass_producer producer; bool forwarded; + irqreturn_t (*handler)(int irq, void *dev_id); }; struct vfio_platform_region {