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: Auger Eric X-Patchwork-Id: 57007 Delivered-To: patches@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp3227089lbb; Thu, 19 Nov 2015 06:54:25 -0800 (PST) X-Received: by 10.194.2.144 with SMTP id 16mr8559607wju.90.1447944861094; Thu, 19 Nov 2015 06:54:21 -0800 (PST) Return-Path: Received: from mail-wm0-x231.google.com (mail-wm0-x231.google.com. [2a00:1450:400c:c09::231]) by mx.google.com with ESMTPS id gd4si11821438wjb.2.2015.11.19.06.54.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Nov 2015 06:54:21 -0800 (PST) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 2a00:1450:400c:c09::231 as permitted sender) client-ip=2a00:1450:400c:c09::231; Authentication-Results: mx.google.com; spf=pass (google.com: domain of eric.auger@linaro.org designates 2a00:1450:400c:c09::231 as permitted sender) smtp.mailfrom=eric.auger@linaro.org; dkim=pass header.i=@linaro-org.20150623.gappssmtp.com Received: by wmvv187 with SMTP id v187so29523574wmv.1 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=be6Bx8crZTe1Xh6+J3K4TxoCaT95ZYBw7A2afmoXEx0tUP3vQDrrjPLQNnnu3jQej/ vrYPM8qiU8IqZ/LDG3LWf3bpQplZouLGp+VtzFPei/+YF06yMdjeNnEEvZJ9NxTs+skx LwD7B/fa6U7OmKX/vcAW8aGEuFDCzHelnmyM4BPmZEZaLmVBuApxKC9QelbJrZLl0YSI sfON6e6ZPqJccmNtXiA8xIQdqpdV8ryFYbPI+vz7NS4nDmmikverT3bsyt9Rq8ldfNuP 7hk/ZTspEZ3iTpULDpZAy3ZbvnxEKpuRx4Jtjhb/+PeQe9BJSUDUY8yMT5DHgZHHxQcD xipw== X-Gm-Message-State: ALoCoQnVMlXjT3q3+b8/m3cH8hwfS93spT3wl0J5YfyX7R2uzng3xKEkg5beiTAx5oqz9BlIUpkI X-Received: by 10.194.110.35 with SMTP id hx3mr10333383wjb.0.1447944860918; Thu, 19 Nov 2015 06:54:20 -0800 (PST) Return-Path: 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 Cc: andre.przywara@arm.com, linux-kernel@vger.kernel.org, patches@linaro.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> 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(+) -- 1.9.1 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) { }