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: 6984001 Return-Path: X-Original-To: patchwork-kvm@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 29EE39F344 for ; Mon, 10 Aug 2015 13:24:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 58A21205FF for ; Mon, 10 Aug 2015 13:24:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 70A4B204A2 for ; Mon, 10 Aug 2015 13:24:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754199AbbHJNY0 (ORCPT ); Mon, 10 Aug 2015 09:24:26 -0400 Received: from mail-wi0-f179.google.com ([209.85.212.179]:37877 "EHLO mail-wi0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752957AbbHJNWA (ORCPT ); Mon, 10 Aug 2015 09:22:00 -0400 Received: by wibhh20 with SMTP id hh20so150556131wib.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=nGkT/fg1D0rf4Re7E7syc3MOqz41hn18kaB8ndyo6ttGXOlW1xconYBmhHWlq0JAK3 1H8upTx21XwPQ4xBEY9I7AgYfbApjrOPq4OpqHWdvwOYuSJIzTTW/5Ye6dwIREAlobTl UTkgTxPGDYhcn2Eh0MaKT0guoL90fCEUz9bP/mzV0oaw/PaugqrRWQfiQAyuuQtmMFEY u58wP87x+BnLYaxahXQLKfAch6aGV26qu6K+JHWBc7w83dljQf3W5XKWfngJMBO+oKyg glawcMmIE6aEThdUhE4xIozpDHMmwmdNvfh0e9WYiPisaPugKe2UXB7ntnH6e/YGrDA/ OPBQ== X-Gm-Message-State: ALoCoQnecD77UVs7hsZMlweIzRC3NcON75JXwtBj/EN25NLQxsET9QMxgJ3t9l9RIil6EIfwkN4x 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 Cc: linux-kernel@vger.kernel.org, patches@linaro.org, pbonzini@redhat.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> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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, 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) { }