From patchwork Mon Aug 10 13:20:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 6984081 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 CEADC9F46B for ; Mon, 10 Aug 2015 13:25:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 174712070A for ; Mon, 10 Aug 2015 13:25:24 +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 94E48204A2 for ; Mon, 10 Aug 2015 13:25:18 +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 1ZOn2m-00015b-BW; Mon, 10 Aug 2015 13:23:12 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZOn21-0000lD-7Q for linux-arm-kernel@bombadil.infradead.org; Mon, 10 Aug 2015 13:22:25 +0000 Received: from mail-wi0-f175.google.com ([209.85.212.175]) by merlin.infradead.org with esmtps (Exim 4.85 #2 (Red Hat Linux)) id 1ZOn1z-0005QS-Fm for linux-arm-kernel@lists.infradead.org; Mon, 10 Aug 2015 13:22:24 +0000 Received: by wicne3 with SMTP id ne3so21957616wic.0 for ; Mon, 10 Aug 2015 06:21:59 -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=sMIALoXXI3Iq/0nA0DZfafY446ST6shebzfbyrX7Kak=; b=GBm3UWQgOE3esyLzz1EjAQ/PYU/fnlywgdlfnUNzluMMXdzzbOBr7z2yLzEhYOxQ5M hF59ptePSEeL6C/1dB7E6+MTQ7O72AxRORvneIfFhzlGQYHrZGcye8NUueCMpZlDqj9z KSNYpdaqBhJh180MtUFudk6ZXSPuRFi71RAc8HqVt6LDLgPbfHeJYuxvItlze3qv1Y7U Y/zKjUB1Fn0GGUY0PESxgUlbEsOXn+a7KDmx7v2hM8Ws6lk9wUvq39o4naPrEHt+POth zA1j05myofnPu9ngWv+DaQ1U+q73Z8SEi63YPMm2ramyjm9xaCM2FdfWggvwNaXC16u2 x76Q== X-Gm-Message-State: ALoCoQkFS05IkFj18JgRGqMncSgZJqzOfHbn/JHK1qfn++6Ybw7aJqkRRgS9/F3Tq/+oZ+7P+iGi X-Received: by 10.194.175.200 with SMTP id cc8mr47060591wjc.87.1439212919341; Mon, 10 Aug 2015 06:21:59 -0700 (PDT) Received: from gnx2579.home (LCaen-156-56-7-90.w80-11.abo.wanadoo.fr. [80.11.198.90]) by smtp.gmail.com with ESMTPSA id fq15sm29517024wjc.12.2015.08.10.06.21.58 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Aug 2015 06:21:58 -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, feng.wu@intel.com Subject: [PATCH v3 05/10] VFIO: platform: add vfio_platform_is_active Date: Mon, 10 Aug 2015 15:20:59 +0200 Message-Id: <1439212864-12954-6-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1439212864-12954-1-git-send-email-eric.auger@linaro.org> References: <1439212864-12954-1-git-send-email-eric.auger@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150810_092223_632382_E0D4BDE8 X-CRM114-Status: GOOD ( 13.83 ) 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: pbonzini@redhat.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.2 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 function returns whether the IRQ is active at irqchip level or VFIO masked. If either is true, it is considered the IRQ is active. Currently there is no way to differentiate userspace masked IRQ from automasked IRQ. There might be false detection of activity. However it is currently acceptable to have false detection. Signed-off-by: Eric Auger --- --- drivers/vfio/platform/vfio_platform_irq.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/vfio/platform/vfio_platform_irq.c b/drivers/vfio/platform/vfio_platform_irq.c index a285384..efaee58 100644 --- a/drivers/vfio/platform/vfio_platform_irq.c +++ b/drivers/vfio/platform/vfio_platform_irq.c @@ -205,6 +205,23 @@ static int vfio_platform_set_automasked(struct vfio_platform_irq *irq, return 0; } +static int vfio_platform_is_active(struct vfio_platform_irq *irq) +{ + unsigned long flags; + bool active, masked, outstanding; + int ret; + + spin_lock_irqsave(&irq->lock, flags); + + ret = irq_get_irqchip_state(irq->hwirq, IRQCHIP_STATE_ACTIVE, &active); + BUG_ON(ret); + masked = irq->masked; + outstanding = active || masked; + + spin_unlock_irqrestore(&irq->lock, flags); + return outstanding; +} + static void vfio_platform_irq_bypass_stop(struct irq_bypass_producer *prod) { }