From patchwork Mon Jul 6 13:24:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 6723841 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 409189F38C for ; Mon, 6 Jul 2015 13:25:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 60B92201ED for ; Mon, 6 Jul 2015 13:25:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7518D205EA for ; Mon, 6 Jul 2015 13:25:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755979AbbGFNZc (ORCPT ); Mon, 6 Jul 2015 09:25:32 -0400 Received: from mail-wg0-f44.google.com ([74.125.82.44]:36768 "EHLO mail-wg0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755878AbbGFNZS (ORCPT ); Mon, 6 Jul 2015 09:25:18 -0400 Received: by wguu7 with SMTP id u7so140467907wgu.3 for ; Mon, 06 Jul 2015 06:25:17 -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=+p/y8MFZo9GaGIaX3y33xe+WpA/PbZjLDvBgEmG7JTE=; b=MtYvC9lYXXr1ZzfQumPZhKuYcYMeiyV+TzyVK0eV+2mVEWcfL3wUTdx6bNHo9V9RKu vhKVCgAuFhOVSlBS1cBSB1QpLo5AueY5HekAAleu3rooxdxw7sW7QwyNWHS3LzEo6wWk N4bvDtnw4hMzGl5YmvmtxZZn8mIVXAQcn3e/mAgoKuLTgd22ud3R8TABjoQ2r9+QOe2a BvGWMympK6wWCFc9pXc9rIQF17mogpCMeYXQqtg5U7oJIPkVwkps+GwFk681z1RDPv0J +nd9DJ5dHh0zZM7e93MCIR8LaxacNW+u/OvrmJSuYSX9O/POATngYwGXzPTH2923essa QPeQ== X-Gm-Message-State: ALoCoQkw6L2/+L+IzOntiEeu4y38VE/4dlq6Rm+Q7eVlx22UwZ4UevyYQshpjop9LJdr5G+UhcfQ X-Received: by 10.180.198.199 with SMTP id je7mr53654873wic.34.1436189117694; Mon, 06 Jul 2015 06:25:17 -0700 (PDT) Received: from gnx2579.home (LCaen-156-56-7-90.w80-11.abo.wanadoo.fr. [80.11.198.90]) by mx.google.com with ESMTPSA id q4sm28148131wju.14.2015.07.06.06.25.15 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Jul 2015 06:25:16 -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, avi.kivity@gmail.com, mtosatti@redhat.com, feng.wu@intel.com, joro@8bytes.org, b.reynal@virtualopensystems.com Cc: linux-kernel@vger.kernel.org, patches@linaro.org, alex.williamson@redhat.com, pbonzini@redhat.com Subject: [RFC v2 5/9] VFIO: platform: add vfio_platform_is_active Date: Mon, 6 Jul 2015 15:24:39 +0200 Message-Id: <1436189083-32527-6-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1436189083-32527-1-git-send-email-eric.auger@linaro.org> References: <1436189083-32527-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.6 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 aa540db..d00ed24 100644 --- a/drivers/vfio/platform/vfio_platform_irq.c +++ b/drivers/vfio/platform/vfio_platform_irq.c @@ -203,6 +203,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) { }