From patchwork Mon Sep 1 12:52:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 4819151 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 38BB39F314 for ; Mon, 1 Sep 2014 12:56:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7962B2016C for ; Mon, 1 Sep 2014 12:56:36 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 89FEE20160 for ; Mon, 1 Sep 2014 12:56:35 +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 1XOR7j-0001D6-5S; Mon, 01 Sep 2014 12:54:19 +0000 Received: from mail-wi0-f174.google.com ([209.85.212.174]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XOR7T-0000xY-Hd for linux-arm-kernel@lists.infradead.org; Mon, 01 Sep 2014 12:54:04 +0000 Received: by mail-wi0-f174.google.com with SMTP id d1so12553688wiv.13 for ; Mon, 01 Sep 2014 05:53:40 -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=njBr9RmpmM+R+suZ+BZJ7OQGDRcnIYPLfMmHR2u2120=; b=PzNlUuXho/2Q7NaW4zWfh4PULHrLOUcthN3b7KWtFxhaWS9K8Z3v4/7uJ78CjOPwYv ispI8vOFE5wO4uzLsovLaeOLNT6PdOre+1SBlPDOWrejCSQtkKIIPJuidCxzNcwjCs46 sYEh+FtXKbMeIUFBOK27/FLeqBvSjNs/1BEiQXJ2H3eA+XacRSMGAoLXkK/kINnUTGp8 qX256gOCR/OwbD610QG+TPGlf67PqLDzGViYrsrg/HPZUKlDyecaCqKgxKrm91A1NSLd WLR+NdmQi6f6MbzxkI26F6ZpDJF47VAgYGfvTwIzLDaKxF4mjqW23QA9G4SDoFcj3RWL y6kg== X-Gm-Message-State: ALoCoQmglZBvvw9B5XNzkZU/O9JyDhnVTYx8eGCK4T8MMfvd5hPzwyz+KklP+6cAqUR5UGABGCE6 X-Received: by 10.180.19.10 with SMTP id a10mr21004009wie.49.1409576020873; Mon, 01 Sep 2014 05:53:40 -0700 (PDT) Received: from gnx2579.gnb.st.com (LCaen-156-56-7-90.w80-11.abo.wanadoo.fr. [80.11.198.90]) by mx.google.com with ESMTPSA id y5sm1928678wje.32.2014.09.01.05.53.37 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 01 Sep 2014 05:53:40 -0700 (PDT) From: Eric Auger To: eric.auger@st.com, eric.auger@linaro.org, christoffer.dall@linaro.org, marc.zyngier@arm.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, alex.williamson@redhat.com, joel.schopp@amd.com, kim.phillips@freescale.com, paulus@samba.org, gleb@kernel.org, pbonzini@redhat.com Subject: [RFC v2 4/9] VFIO: platform: handler tests whether the IRQ is forwarded Date: Mon, 1 Sep 2014 14:52:43 +0200 Message-Id: <1409575968-5329-5-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1409575968-5329-1-git-send-email-eric.auger@linaro.org> References: <1409575968-5329-1-git-send-email-eric.auger@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140901_055403_739706_78893102 X-CRM114-Status: GOOD ( 12.63 ) X-Spam-Score: -0.7 (/) Cc: patches@linaro.org, john.liuli@huawei.com, will.deacon@arm.com, a.rigo@virtualopensystems.com, linux-kernel@vger.kernel.org, a.motakis@virtualopensystems.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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=-3.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, 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 In case the IRQ is forwarded, the VFIO platform IRQ handler does not need to disable the IRQ anymore. In that mode, when the handler completes the IRQ is not deactivated but only its priority is lowered. Some other actor (typically a guest) is supposed to deactivate the IRQ, allowing at that time a new physical IRQ to hit. In virtualization use case, the physical IRQ is automatically completed by the interrupt controller when the guest completes the corresponding virtual IRQ. Signed-off-by: Eric Auger --- drivers/vfio/platform/vfio_platform_irq.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/vfio/platform/vfio_platform_irq.c b/drivers/vfio/platform/vfio_platform_irq.c index 6768508..1f851b2 100644 --- a/drivers/vfio/platform/vfio_platform_irq.c +++ b/drivers/vfio/platform/vfio_platform_irq.c @@ -88,13 +88,18 @@ static irqreturn_t vfio_irq_handler(int irq, void *dev_id) struct vfio_platform_irq *irq_ctx = dev_id; unsigned long flags; int ret = IRQ_NONE; + struct irq_data *d; + bool is_forwarded; spin_lock_irqsave(&irq_ctx->lock, flags); if (!irq_ctx->masked) { ret = IRQ_HANDLED; + d = irq_get_irq_data(irq_ctx->hwirq); + is_forwarded = irqd_irq_forwarded(d); - if (irq_ctx->flags & VFIO_IRQ_INFO_AUTOMASKED) { + if (irq_ctx->flags & VFIO_IRQ_INFO_AUTOMASKED && + !is_forwarded) { disable_irq_nosync(irq_ctx->hwirq); irq_ctx->masked = true; }