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: Auger Eric X-Patchwork-Id: 50757 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f70.google.com (mail-wg0-f70.google.com [74.125.82.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B8CE222A0A for ; Mon, 6 Jul 2015 13:25:27 +0000 (UTC) Received: by wgfk9 with SMTP id k9sf50156311wgf.1 for ; Mon, 06 Jul 2015 06:25:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=+p/y8MFZo9GaGIaX3y33xe+WpA/PbZjLDvBgEmG7JTE=; b=V2uta8MbpgGxutA981LIkEQ9OHqs43+DFLsIa3lp24rx1ESLOa0pab51t/1iRIfNCS ze3Z436LMsEkUUTFW80vhbXZENCKKO90GeeDkmeZYlJfo3U8O/Z3vbt0WHtafpH+bIbh D/zFNcqEe4XNhK5jtRVtWQDde9GM8oQT+LKCjkPV3N24CBAEV71YP8xph8OI0MJrKYy3 TdGvxU0TJhkw9TmMggR6V1Adq0UCo3Srv1OhqlW9D51xiphd7KFFa8CPEVSN4/HN/ZA0 xITRsyYX7vT8FsUYJJO496K1uuBHsAxvWlnW0hempKkJE5hdXk+VrM1c7G20up9Ty3PH Hbmg== X-Gm-Message-State: ALoCoQnJTM85wMED3SzAfQIm85HZNUn+gj3ty2a7zJO3cLP8EJ4BpYgeRfXyTthKQDdTFZxZX+I6 X-Received: by 10.112.28.111 with SMTP id a15mr30387309lbh.21.1436189127021; Mon, 06 Jul 2015 06:25:27 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.120.227 with SMTP id lf3ls694096lab.93.gmail; Mon, 06 Jul 2015 06:25:26 -0700 (PDT) X-Received: by 10.153.7.133 with SMTP id dc5mr48847596lad.17.1436189126749; Mon, 06 Jul 2015 06:25:26 -0700 (PDT) Received: from mail-la0-f41.google.com (mail-la0-f41.google.com. [209.85.215.41]) by mx.google.com with ESMTPS id t12si15253187lby.128.2015.07.06.06.25.26 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Jul 2015 06:25:26 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) client-ip=209.85.215.41; Received: by laar3 with SMTP id r3so155076235laa.0 for ; Mon, 06 Jul 2015 06:25:26 -0700 (PDT) X-Received: by 10.112.131.98 with SMTP id ol2mr50036577lbb.56.1436189126311; Mon, 06 Jul 2015 06:25:26 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp1725272lbb; Mon, 6 Jul 2015 06:25:25 -0700 (PDT) X-Received: by 10.180.11.200 with SMTP id s8mr89894471wib.17.1436189117919; Mon, 06 Jul 2015 06:25:17 -0700 (PDT) Received: from mail-wg0-f41.google.com (mail-wg0-f41.google.com. [74.125.82.41]) by mx.google.com with ESMTPS id qg11si30870090wic.73.2015.07.06.06.25.17 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Jul 2015 06:25:17 -0700 (PDT) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 74.125.82.41 as permitted sender) client-ip=74.125.82.41; Received: by wgjx7 with SMTP id x7so140140923wgj.2 for ; Mon, 06 Jul 2015 06:25:17 -0700 (PDT) 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> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: eric.auger@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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) { }