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: 7658001 Return-Path: X-Original-To: patchwork-kvm@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 8BC0EBF90C for ; Thu, 19 Nov 2015 14:58:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AF03A206AB for ; Thu, 19 Nov 2015 14:58:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3F49520648 for ; Thu, 19 Nov 2015 14:58:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934361AbbKSO6L (ORCPT ); Thu, 19 Nov 2015 09:58:11 -0500 Received: from mail-wm0-f51.google.com ([74.125.82.51]:36694 "EHLO mail-wm0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933053AbbKSOyW (ORCPT ); Thu, 19 Nov 2015 09:54:22 -0500 Received: by wmww144 with SMTP id w144so241830466wmw.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=grlrE6kpwvswN5dNgXaag70x9BmuYZN1jw99gZd64zXWFtzTQl+Yzbp2FEMXro9Ef2 6VPfDOdEOhnYFZA9smlVeuhfwKtN1XTcmOpQftiASDQ9xWQIsR4Q8puCvxluZ543c2Ka Do6QrV5yXduINDF3pou84J7iJTZJ74St5+jWZzCJi/yikeJ1WzUNaBe8OeanHciNfaDH 7bC2CFWjLTwwvn8v5tCF3PWy28r08lmTTeXDLlO7UObiOcKw/oEXIGE/nrnjWPhrkN7z xolDNcgi/PXPCI18ZNxsVegz9Vt0suMA5uNkyhzna/sTvV60P72u164CxJLGEKDO7TuL zCrQ== X-Gm-Message-State: ALoCoQmW0pNJ867C2WKDMfY0RAYWavCYVnrElmBVrjUGiaqksgEB4JwkfmDaXgZ6uDAs7WjS3Na3 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 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> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,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) { }