From patchwork Thu Nov 19 14:53:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 7657971 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A288FBF90C for ; Thu, 19 Nov 2015 14:58:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AC0DD2063C for ; Thu, 19 Nov 2015 14:58:02 +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 E5404204D9 for ; Thu, 19 Nov 2015 14:58:01 +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 1ZzQct-0003vk-W7; Thu, 19 Nov 2015 14:55:56 +0000 Received: from mail-wm0-x235.google.com ([2a00:1450:400c:c09::235]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZzQbi-00018P-II for linux-arm-kernel@lists.infradead.org; Thu, 19 Nov 2015 14:54:44 +0000 Received: by wmww144 with SMTP id w144so119952688wmw.0 for ; Thu, 19 Nov 2015 06:54:21 -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=shsRvJzmas8pgub4JaWLKoHwh4HqPoHyseshIM9ncIo=; b=wqRqo9hgA8t+ip4zZ3wKJgrhMQFfs6A4yeuZMP1X4edq6bBc1AnXdODRZU56Hm6O2B oRPZsm6BGT9fsdbWeHnce1B2TRkNkc64GR5YvJr/tmkZH3EjGFd0pc26yypnNHVAWBRH M+RCuJ03uBBvVYJLiAgvNmbiAYB4p32lvXWSHxxNfMfyniJhgy+5sq64O0z33zlKqP7z J1HqjvAs7ePFBHsaaL5P4LT08zeWiV02qhFS8EJ7YTHQJvl3zNM/FWnSBc6PmtBHuTQo yVFMJIcGHYb3MD+gDAbxHiIzcGeC5ZUZi6/kBO1W7g/cZ/Sq48r+7rIycrJhTGuLsj6b YH8g== 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=shsRvJzmas8pgub4JaWLKoHwh4HqPoHyseshIM9ncIo=; b=UNR8QqHQ+cF+eqW7ka+7nk7ahNf5U5Pv2AFv35WO7GUqojXa+LHaNlQY2SiOzwb9Xx fRiB42jkxDv1RJ930b//pzsjISnp6aNeMuorc4bfxWm/xp35cM2udPL7AiIBeeoZ3YkV OdRDTT3SrRt3Dlh7ychIOvSyc4KgmI8CyH5xucMdTIh2TVNYzexblzi/l0mWxuk7Ggi7 3md/2fjW0L1ob2p29rbUEpM8Qik7zrFxLCfhMXSbXlu5VlTT6iXoP8LXaa/FA2bzP4Ut 5nAjvKCNT8W0nDb1liA5D3lIhfwNJszoS59N6lhEKlJiJ7oE4Ksc0IF3kHWM9Dv/eyDr UgDg== X-Gm-Message-State: ALoCoQnoviS2YdU5CxkPZN0BaIXXkQ6s6akfzzJImKdisK4usUkrHfUVq78CgdPwnLbeIcGbQaem X-Received: by 10.194.110.35 with SMTP id hx3mr10333383wjb.0.1447944860918; Thu, 19 Nov 2015 06:54:20 -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.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Nov 2015 06:54:19 -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 06/13] VFIO: platform: add vfio_platform_irq_is_active Date: Thu, 19 Nov 2015 14:53:56 +0000 Message-Id: <1447944843-17731-7-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_065443_015164_1247AE59 X-CRM114-Status: GOOD ( 12.43 ) 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=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 function returns whether the IRQ is active at irqchip level or VFIO masked. If either is true, the IRQ is considered 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 --- v3 -> v4: - rename vfio_platform_is_active into vfio_platform_irq_is_active - remove BUG_ON and return the error if irq_get_irqchip_state fails --- drivers/vfio/platform/vfio_platform_irq.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/vfio/platform/vfio_platform_irq.c b/drivers/vfio/platform/vfio_platform_irq.c index 257200b..cb7d5e9 100644 --- a/drivers/vfio/platform/vfio_platform_irq.c +++ b/drivers/vfio/platform/vfio_platform_irq.c @@ -203,6 +203,25 @@ static int vfio_platform_set_forwarded(struct vfio_platform_irq *irq, return 0; } +static int vfio_platform_irq_is_active(struct vfio_platform_irq *irq) +{ + unsigned long flags; + bool active; + int ret; + + spin_lock_irqsave(&irq->lock, flags); + + ret = irq_get_irqchip_state(irq->hwirq, IRQCHIP_STATE_ACTIVE, &active); + if (ret) + goto out; + + ret = active || irq->masked; + +out: + spin_unlock_irqrestore(&irq->lock, flags); + return ret; +} + static void vfio_platform_irq_bypass_stop(struct irq_bypass_producer *prod) { }