From patchwork Tue Feb 6 17:09:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 127060 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp3107791ljc; Tue, 6 Feb 2018 09:11:31 -0800 (PST) X-Google-Smtp-Source: AH8x225yaQNCUp99O7Qg9sdxUGVGLBHhRpkj+lA87J3QhoIh2le5NpKqDBNnQaY8NWrlz2pGAFx+ X-Received: by 10.36.105.17 with SMTP id e17mr4098682itc.84.1517937091033; Tue, 06 Feb 2018 09:11:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517937091; cv=none; d=google.com; s=arc-20160816; b=qh6IZJFfby2GwFgy7pkzHktdJx37kgKt5kBc1CoGl5VVWpQAhk53v9LBzJzWWT03kD B0piOoMG8VoxGDDXktLxgvZT9SxpHfzp16aBR/Cndx0hphvw7v3F8pbntHOlO7pNokhP lyev9hGhh/FV1FeYzkSUPpQZ1hc5C6vii24Em70fNW2/IH7CGqySwZSswwrqlRo99Ybz RsHdtKDZC2TZTZzyIMXNJwTBrh/zeYs3+Wb/dDtRMIXt6TJQvWYrxxzKqg8PdLYWQTU1 bpeSqH1JCp4taxMF3PDxVRpec6SYZWGR3r9gQXh3Z4ABeLKZ1d+YhyXUueCeicukrDg1 R6Zw== 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=Ju4skTQ07eEnflgvHOSORv5hPztMz+kO9GIamJ/4ptw=; b=tjPEaNfnFnZ2FmgE+CFSshgVxLHhTVyEHf3AOs13grPhXW2e+v77HPGXZXkpYucvWe MhxbPYGDDtCf7hnpk901ylONAZRkxLFTN+orIHF4uf/d19/8DIL4I47GQpeR+KlNpTA7 q1otzKGwW99fny62faoVimX/8at2Z2I129WQEnZcU9+q8xUk3j+f6nU8lyr6kmyNfiFu jByoQf0ALBLADzCP0UfyMB6Ek2Nq50/R9rUIW1TPrhEo5exZVzhhgkcS2dTVgO0uN8yj 9/RYm6UUvp9M6bHMCF5K2pQPrZSnIpKZ/YnCtAlyXpcSbnapRAIK/sobbdLtzcSAP/1l bAqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=kogpuByt; 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 s78si8458498itb.40.2018.02.06.09.11.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Feb 2018 09:11:31 -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=kogpuByt; 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 1ej6kA-0003ry-Op; Tue, 06 Feb 2018 17:09:18 +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 1ej6kA-0003qg-3p for xen-devel@lists.xenproject.org; Tue, 06 Feb 2018 17:09:18 +0000 X-Inumbo-ID: 67ed5aa0-0b60-11e8-ba59-bc764e045a96 Received: from mail-wr0-x244.google.com (unknown [2a00:1450:400c:c0c::244]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 67ed5aa0-0b60-11e8-ba59-bc764e045a96; Tue, 06 Feb 2018 18:08:53 +0100 (CET) Received: by mail-wr0-x244.google.com with SMTP id z6so2741118wrb.1 for ; Tue, 06 Feb 2018 09:09:16 -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=6dCKK6x8FdmFcYKmbwsmTdTxCLbBl5bLZbwCpIW103c=; b=kogpuBytEHWPk29Wl81/192b5KwTJ7x4GF5h80DfcHWNIpg76IqlKLTabBviyzMtS5 WrgZ/4CJZngR7ZsYX1HZqkSK9FLAUtBPGIb7PY2oIL75vHPbt4YXK/w1MSxDfcZ/ARTE A4fpuYEJ6oL4UGVGDviMMFK8VGiirX1tG34Qc= 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=6dCKK6x8FdmFcYKmbwsmTdTxCLbBl5bLZbwCpIW103c=; b=LSRbXc3Z1HUZBmL2i8rLbFxk9k+t30pIC+ct/mJ2lBR+0KhRf7bWkFQgMxBea8UPwN lZOTRd425HDWKVb1z3Ub+N5Wx47e4dxo7OZuLrgpyQ1AtQ7bitEAPoJ7e9cmRJVXWnxx U+bxWbNQG5FSbQp105KGa3gmdgmqDxrtVvfZp03t3syrNkf9EvoTafWGsnX+L0G1FjWe U2uEVwDmfUEqy2L5syYlkMFTVx6MGhMp3rcbKqxtpKrWwO3hio4TedlOygZsKcd2Yw03 wyTaUCRIPIf1jMi7ApkfgyWXirHOqHlK9HbJaL813/Teayvj7v3BWu3hSM6lUoV3pf6L bWVQ== X-Gm-Message-State: APf1xPCdMfgr7n3LAZUWxBh/LnEJWHE3vXfuhW2/IjP4F9gkQgLSKvfc M+XY7UOvmg812OSdhX8OZxD+kw== X-Received: by 10.223.183.27 with SMTP id l27mr3052901wre.181.1517936955663; Tue, 06 Feb 2018 09:09:15 -0800 (PST) Received: from e104803-lin.lan (mail.andrep.de. [217.160.17.100]) by smtp.gmail.com with ESMTPSA id n2sm7885819wra.41.2018.02.06.09.09.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 06 Feb 2018 09:09:15 -0800 (PST) From: Andre Przywara To: Julien Grall , Stefano Stabellini Date: Tue, 6 Feb 2018 17:09:01 +0000 Message-Id: <20180206170903.30637-7-andre.przywara@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180206170903.30637-1-andre.przywara@linaro.org> References: <20180206170903.30637-1-andre.przywara@linaro.org> Cc: xen-devel@lists.xenproject.org Subject: [Xen-devel] [PATCH v5 6/8] 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 Reviewed-by: Julien Grall --- xen/arch/arm/gic-vgic.c | 17 +++++++++++++++++ xen/arch/arm/irq.c | 7 ++----- xen/include/asm-arm/vgic.h | 2 ++ 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/xen/arch/arm/gic-vgic.c b/xen/arch/arm/gic-vgic.c index 820e464fc0..72a904bbeb 100644 --- a/xen/arch/arm/gic-vgic.c +++ b/xen/arch/arm/gic-vgic.c @@ -397,6 +397,23 @@ 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; + + ASSERT(!v && virq >= 32); + + 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, bool connect) { 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 fda082395b..6ea9f140a7 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, bool connect);