From patchwork Thu Dec 7 16:14:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 121013 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp8556163qgn; Thu, 7 Dec 2017 08:16:32 -0800 (PST) X-Google-Smtp-Source: AGs4zMaLyoFCl7gljYbAJb5FvvCSmKDUnRu1mBrByWwmCukLElmHKzkeryKJlCpQbTr4B6TG1D8S X-Received: by 10.36.239.195 with SMTP id i186mr1849131ith.29.1512663392444; Thu, 07 Dec 2017 08:16:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512663392; cv=none; d=google.com; s=arc-20160816; b=a+qyTYfqz9vSKYgYqOLvFSTYwpIFtnbPLzcV4vKOMUBVtdFFda9n/0vxPV7RKmV5rX Rkvp25cdFB74E81GFXwD6Dh4nAg/yB9tiHKusFKdyYK8BP4blFbqnUAB/m2e4z3qxDM+ IKZUQb9qH4cjS2B1kB1lHIeiXAdeglfN3GtcVtF3fYi87btUYV8cXB5fUMEA1Xq70vvk zV5NJN7QskwNAHnojMgHeM3RbsXYTnKT9OKmg215mQPyrQrvnPaW1GiSLPTpHnOCvb6T LZyoCO90N6zwnYYhgRAidpvA4W5y9TOkU7ZE54M8HyV1t1aJxnF4nCUibDiYithpvO2F TzaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=yvy2vz628LqVXmN+mc2ZRtIIHYm17yQkSSrIK59+q7w=; b=oIMJrRDzVDvN4uEd52JNWm6zO7MZGYCDrfPbvC+miZkwEJ4jcENuJHnJ+a+tQmm3ew A1gHgvImreT4fsmu0o5FQbJLNplrpBO5Yio1QaMvBD7Gq6pcbc06UVVaYUsX41U+Wivx 48fk8zjFEyjzHKr1p/iMfyDnRO75oWyTpT4azU7xxkmytl/2SzpCVaH2td3JakqdbQva cI0xBUqoipDIVysdSGc5GrSywE41eqrs3XiLCos16mRymhn8FkV3HCDMDywtEHi+W6tj NU8SkuMvWzptmu9ch+QqjY8WWlrFfXITPe0PhZnuF27UBWoC8vqhPRoG83wQwRCeb1uc ZEYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=WTU2VN+E; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id 135si4505124itp.126.2017.12.07.08.16.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Dec 2017 08:16:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=WTU2VN+E; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eMyoc-0002GF-9S; Thu, 07 Dec 2017 16:14:26 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eMyob-0002FU-Hi for xen-devel@lists.xenproject.org; Thu, 07 Dec 2017 16:14:25 +0000 X-Inumbo-ID: a277b170-db69-11e7-b4a6-bc764e045a96 Received: from mail-wm0-x244.google.com (unknown [2a00:1450:400c:c09::244]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id a277b170-db69-11e7-b4a6-bc764e045a96; Thu, 07 Dec 2017 17:14:00 +0100 (CET) Received: by mail-wm0-x244.google.com with SMTP id f206so13776617wmf.5 for ; Thu, 07 Dec 2017 08:14:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wDmcEZ3+nKbVwu5E/2UxqCkvIg5xQFQGnlsagG21TVY=; b=WTU2VN+EuvIFAc+ImOeyKfRcDSBpRHGSnz0lKfb8l8jQo/WA1GyeRiliT9H4JpDPVj 3difjjNEnTy9BKUv7aPtzl4DPZ6S9J0gNtfsp6Rt+NQ9fArJmFA7mLnCWQn9tQUisPKR RjZHLUUaxqBAa3BIEOsDm99lo4iOSlWOCwmfc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=wDmcEZ3+nKbVwu5E/2UxqCkvIg5xQFQGnlsagG21TVY=; b=AKTcmYOELXuG87iRxwCxqCaFxieYBQbafMadAMvV8YcQ8L58CZalXDI+J6L8uuLMB+ irc3EQY0rL7GezSYexp+WX/0r50wCb9kuCLnI4M/0BCzOMNUaWRYG3G5ejnonlq+WwOt eYsRug1JIyoH58FAlj0u7sldMtkM6ZxTl4ANWe2b72FgPNaWQ3ezcaUoz7dVBiPwyTRx 6oLCjJwbK758b0J9kg5NT4V1IFbs8GgswJDlJlgL5sk3dQXGD4aXU2uqTza/zeR6YARA MI2dNisyS+Q4SLlaz6eWPpI8v4Ru1xDwef9kQODCqzyurVp4BI6yti1G8afB7WxvIaQd BtoQ== X-Gm-Message-State: AKGB3mKavzDwJlO8otr1cTNn92Kf0Q9V8Q9TB+q1XpM+rnU4vBFJei5U GIlKLEt83SGKfSWvlO1EJbo3vA== X-Received: by 10.28.216.212 with SMTP id p203mr1658074wmg.50.1512663263196; Thu, 07 Dec 2017 08:14:23 -0800 (PST) Received: from e104803-lin.lan (mail.andrep.de. [217.160.17.100]) by smtp.gmail.com with ESMTPSA id f18sm6090624wrg.66.2017.12.07.08.14.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 07 Dec 2017 08:14:22 -0800 (PST) From: Andre Przywara To: Stefano Stabellini , Julien Grall Date: Thu, 7 Dec 2017 16:14:14 +0000 Message-Id: <20171207161415.20380-10-andre.przywara@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171207161415.20380-1-andre.przywara@linaro.org> References: <20171207161415.20380-1-andre.przywara@linaro.org> Cc: xen-devel@lists.xenproject.org Subject: [Xen-devel] [PATCH v2 09/10] ARM: VGIC: factor out vgic_get_hw_irq_desc() X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" At the moment we happily access the VGIC internal struct pending_irq (which describes a virtual IRQ) in irq.c. Factor out the actually needed functionality to learn the associated hardware IRQ and move that into gic-vgic.c to improve abstraction. Signed-off-by: Andre Przywara Acked-by: Stefano Stabellini --- xen/arch/arm/gic-vgic.c | 15 +++++++++++++++ xen/arch/arm/irq.c | 7 ++----- xen/include/asm-arm/vgic.h | 2 ++ 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/xen/arch/arm/gic-vgic.c b/xen/arch/arm/gic-vgic.c index 37f005d99c..8d43a6ba76 100644 --- a/xen/arch/arm/gic-vgic.c +++ b/xen/arch/arm/gic-vgic.c @@ -414,6 +414,21 @@ void gic_dump_vgic_info(struct vcpu *v) printk("Pending irq=%d\n", p->irq); } +struct irq_desc *vgic_get_hw_irq_desc(struct domain *d, struct vcpu *v, + unsigned int virq) +{ + struct pending_irq *p; + + if ( !v ) + v = d->vcpu[0]; + + p = irq_to_pending(v, virq); + if ( !p ) + return NULL; + + return p->desc; +} + int vgic_connect_hw_irq(struct domain *d, struct vcpu *v, unsigned int virq, struct irq_desc *desc) { diff --git a/xen/arch/arm/irq.c b/xen/arch/arm/irq.c index 7f133de549..62103a20e3 100644 --- a/xen/arch/arm/irq.c +++ b/xen/arch/arm/irq.c @@ -534,19 +534,16 @@ int release_guest_irq(struct domain *d, unsigned int virq) struct irq_desc *desc; struct irq_guest *info; unsigned long flags; - struct pending_irq *p; int ret; /* Only SPIs are supported */ if ( virq < NR_LOCAL_IRQS || virq >= vgic_num_irqs(d) ) return -EINVAL; - p = spi_to_pending(d, virq); - if ( !p->desc ) + desc = vgic_get_hw_irq_desc(d, NULL, virq); + if ( !desc ) return -EINVAL; - desc = p->desc; - spin_lock_irqsave(&desc->lock, flags); ret = -EINVAL; diff --git a/xen/include/asm-arm/vgic.h b/xen/include/asm-arm/vgic.h index f4240df371..ebc0cfaee8 100644 --- a/xen/include/asm-arm/vgic.h +++ b/xen/include/asm-arm/vgic.h @@ -219,6 +219,8 @@ int vgic_v2_init(struct domain *d, int *mmio_count); int vgic_v3_init(struct domain *d, int *mmio_count); bool vgic_evtchn_irq_pending(struct vcpu *v); +struct irq_desc *vgic_get_hw_irq_desc(struct domain *d, struct vcpu *v, + unsigned int virq); int vgic_connect_hw_irq(struct domain *d, struct vcpu *v, unsigned int virq, struct irq_desc *desc);