Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1803659ybb; Sun, 29 Mar 2020 13:55:12 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtjsT9jcj0CZz0ZyD8xn759Y2SM7WOn7oSu/YByTa4Gp4t+Gzms5SzivV87aA3Jppnvo2J2 X-Received: by 2002:a9d:6142:: with SMTP id c2mr7135719otk.92.1585515312681; Sun, 29 Mar 2020 13:55:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585515312; cv=none; d=google.com; s=arc-20160816; b=C29h8Kv13WVUx6k9gJLZgEoBZ8oWjwQe3jv4zALNhRTTesvD782o3WxWuAdSB4yxtj y4nraAxgHKAs3QEBJhrPegiQk9FjqbqMh3KvJzCBYdFlY2KN4QnH3VKR+xdoeSff+Gp9 1wjUJO3x9EQpggSv0D0udGiWix+h/eFks0jKtYl1W9Pu0C9gzWtuEJCTvThxLT+gw/Xu GePMI8ihx1oFuSHsAGM2N5+QzQSnWo/UUPt2eZ2ZYhDZpfAUMeb5LWUlCnC+LsE2vVu8 HcCgijoENnBPl3vJfjUPn/I1yE1Eag/L9CrwYxaXEpE0yVnS9IwRjEGsxyts6huPoFbr lhcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:date; bh=p7wEJiJJjGss80GIeVnIH5G+rdUiuE/d77o8bvaQ8TY=; b=u27j0lBaG0b1i2dAN/qHEWL2TglImiqXOJrL2fRNeD0txM3v2+V/Zss80AbFqveFS3 Ka/NbZYo33iBoYndWafCzaii1kaAmDWkTGYFlzBIJh3cUA3btsAhST7jdCPKjBAjFAgp /s86wVgaWun2Myul7oFAtBS42MinfWt5gL5r/zqGPR80u6cyU6KQmgWlD6rKg3anrnQq fUdjuhq1WY85V6XVicWxErrdw4QOUgv/H8tZQ9S0vCLN1/40VkllEvcqNRrfI5U3QOXk P314HiFsHrUj1FK9x2nBM4Do1WqIY4y7nxx4Et+DkUpFg2hFW/giXJ/+1GHL7G0xqBHj bR1A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a1si4885833oie.70.2020.03.29.13.54.59; Sun, 29 Mar 2020 13:55:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728493AbgC2U0L (ORCPT + 99 others); Sun, 29 Mar 2020 16:26:11 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:56900 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726283AbgC2U0K (ORCPT ); Sun, 29 Mar 2020 16:26:10 -0400 Received: from [5.158.153.53] (helo=tip-bot2.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1jIeVS-0001JG-Vr; Sun, 29 Mar 2020 22:26:07 +0200 Received: from [127.0.1.1] (localhost [IPv6:::1]) by tip-bot2.lab.linutronix.de (Postfix) with ESMTP id 8E0CF1C0451; Sun, 29 Mar 2020 22:26:06 +0200 (CEST) Date: Sun, 29 Mar 2020 20:26:06 -0000 From: "tip-bot2 for Marc Zyngier" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: irq/core] irqchip/gic-v4.1: Add VSGI allocation/teardown Cc: Marc Zyngier , Zenghui Yu , x86 , LKML In-Reply-To: <20200304203330.4967-15-maz@kernel.org> References: <20200304203330.4967-15-maz@kernel.org> MIME-Version: 1.0 Message-ID: <158551356619.28353.3805591305388999695.tip-bot2@tip-bot2> X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the irq/core branch of tip: Commit-ID: 6d31b6ff985dbd144b2c4d519cf573b8f81865d9 Gitweb: https://git.kernel.org/tip/6d31b6ff985dbd144b2c4d519cf573b8f81865d9 Author: Marc Zyngier AuthorDate: Wed, 04 Mar 2020 20:33:21 Committer: Marc Zyngier CommitterDate: Tue, 24 Mar 2020 12:15:51 irqchip/gic-v4.1: Add VSGI allocation/teardown Allocate per-VPE SGIs when initializing the GIC-specific part of the VPE data structure. Signed-off-by: Marc Zyngier Reviewed-by: Zenghui Yu Link: https://lore.kernel.org/r/20200304203330.4967-15-maz@kernel.org --- drivers/irqchip/irq-gic-v4.c | 68 ++++++++++++++++++++++++++++- include/linux/irqchip/arm-gic-v4.h | 2 +- 2 files changed, 69 insertions(+), 1 deletion(-) diff --git a/drivers/irqchip/irq-gic-v4.c b/drivers/irqchip/irq-gic-v4.c index 117ba6d..99b33f6 100644 --- a/drivers/irqchip/irq-gic-v4.c +++ b/drivers/irqchip/irq-gic-v4.c @@ -92,6 +92,47 @@ static bool has_v4_1(void) return !!sgi_domain_ops; } +static int its_alloc_vcpu_sgis(struct its_vpe *vpe, int idx) +{ + char *name; + int sgi_base; + + if (!has_v4_1()) + return 0; + + name = kasprintf(GFP_KERNEL, "GICv4-sgi-%d", task_pid_nr(current)); + if (!name) + goto err; + + vpe->fwnode = irq_domain_alloc_named_id_fwnode(name, idx); + if (!vpe->fwnode) + goto err; + + kfree(name); + name = NULL; + + vpe->sgi_domain = irq_domain_create_linear(vpe->fwnode, 16, + sgi_domain_ops, vpe); + if (!vpe->sgi_domain) + goto err; + + sgi_base = __irq_domain_alloc_irqs(vpe->sgi_domain, -1, 16, + NUMA_NO_NODE, vpe, + false, NULL); + if (sgi_base <= 0) + goto err; + + return 0; + +err: + if (vpe->sgi_domain) + irq_domain_remove(vpe->sgi_domain); + if (vpe->fwnode) + irq_domain_free_fwnode(vpe->fwnode); + kfree(name); + return -ENOMEM; +} + int its_alloc_vcpu_irqs(struct its_vm *vm) { int vpe_base_irq, i; @@ -118,8 +159,13 @@ int its_alloc_vcpu_irqs(struct its_vm *vm) if (vpe_base_irq <= 0) goto err; - for (i = 0; i < vm->nr_vpes; i++) + for (i = 0; i < vm->nr_vpes; i++) { + int ret; vm->vpes[i]->irq = vpe_base_irq + i; + ret = its_alloc_vcpu_sgis(vm->vpes[i], i); + if (ret) + goto err; + } return 0; @@ -132,8 +178,28 @@ err: return -ENOMEM; } +static void its_free_sgi_irqs(struct its_vm *vm) +{ + int i; + + if (!has_v4_1()) + return; + + for (i = 0; i < vm->nr_vpes; i++) { + unsigned int irq = irq_find_mapping(vm->vpes[i]->sgi_domain, 0); + + if (WARN_ON(!irq)) + continue; + + irq_domain_free_irqs(irq, 16); + irq_domain_remove(vm->vpes[i]->sgi_domain); + irq_domain_free_fwnode(vm->vpes[i]->fwnode); + } +} + void its_free_vcpu_irqs(struct its_vm *vm) { + its_free_sgi_irqs(vm); irq_domain_free_irqs(vm->vpes[0]->irq, vm->nr_vpes); irq_domain_remove(vm->domain); irq_domain_free_fwnode(vm->fwnode); diff --git a/include/linux/irqchip/arm-gic-v4.h b/include/linux/irqchip/arm-gic-v4.h index 34ed4b5..b120a01 100644 --- a/include/linux/irqchip/arm-gic-v4.h +++ b/include/linux/irqchip/arm-gic-v4.h @@ -49,6 +49,8 @@ struct its_vpe { }; /* GICv4.1 implementations */ struct { + struct fwnode_handle *fwnode; + struct irq_domain *sgi_domain; struct { u8 priority; bool enabled;