From patchwork Tue May 30 07:41:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 100631 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2006663vqr; Tue, 30 May 2023 00:54:16 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5IbZMZYdh4Z1/RzHsqX/udxFSY0zRblYwlqjcTP9QQmLY/l/xOr74rK2UELVRP90HeoVYa X-Received: by 2002:a17:902:7898:b0:1a6:54ce:4311 with SMTP id q24-20020a170902789800b001a654ce4311mr1638443pll.43.1685433256216; Tue, 30 May 2023 00:54:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685433256; cv=none; d=google.com; s=arc-20160816; b=TKhNlzKNCj1iPxXiXPWsnefqD1UtODIzwekoySBh+OYV9/NyYTVlMmINpxKL9yKBwh 8Lpmoacn6fPUlrl9biRYsDCJXc6S/H/xiJlAoHNaxtbY6QdqI7rhP5WBDy5fwtHbeXZL zt/VMRNYnp1vsrmKLfVrKsXlOr7LURjPZoI+eW7B4PG/yyOHOyjVM/cfBTa+Y3aw81gT iWQZ+rAZyAr68uqFon0v1fLtdAlOaTDmRu8w6GI2ikTM+NnWFpe9WEHl3iRHqlbFx4L1 gSjm0BoL4isnrz7YJNskK/WqddAQpMWVyJrJ1ig5g7xovdmt6hBN4HtE6bNDjtb6jkBq c7Zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:cc:subject:to:reply-to:sender:from :dkim-signature:dkim-signature:date; bh=xhU/yZF2uXMwyHdo5kEEt8Hrqxfr36ESyDFCDZDhw10=; b=wwQ1dqfaWD6qEYJ+EunyublN8Lm3ydT6+bTtc/9eRKrLlwqVwaxcJ9X/gYCy3aZ8sW /5As2YJ/fGQTo14HXvwacHfXMzV9k62GrRlyAKYd5y/90gAQJsBm+PnqX9FLl0oqFu42 6YryIFiMMpAaK25KI/4fDy6inJt4JQJJtvcI2zu+yHyLZri0/ElvbwdpYhtE5PpOMZYV I0tdwsGJnxD6mH7wHjJ9XbUgAvgMfh8+Ck5hnHdJbfk84ui17wheqwvEpNHK7wBJtg9m mAFLBSb4WSGvINsPNyIuA48iJ4YTVXxhA73pdtnlzAKDFIONZR+cKdlY5DtMNzoljVCQ rLdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=RHyTx6R4; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jh9-20020a170903328900b001a55571febesi10932562plb.277.2023.05.30.00.54.01; Tue, 30 May 2023 00:54:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=RHyTx6R4; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231159AbjE3Hn3 (ORCPT + 99 others); Tue, 30 May 2023 03:43:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230474AbjE3HnS (ORCPT ); Tue, 30 May 2023 03:43:18 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6AE3127 for ; Tue, 30 May 2023 00:42:48 -0700 (PDT) Date: Tue, 30 May 2023 07:41:24 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1685432485; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=xhU/yZF2uXMwyHdo5kEEt8Hrqxfr36ESyDFCDZDhw10=; b=RHyTx6R49t832JM4lqaPlhImNNYIT5OC4Gz0AIrp/Op+QrMHoy89prJbQgi7CzxQJPDMLg Ly1PnMo3TkPoXWItkoiScDLs07aT5ZDWCseQS/qxdn/+Sl2wwsPFRufivvePBpMwFZlVC7 yrylEvsHbEbCnQuINrgqTEt16f85gsUaOZwvIipVAZSnTFgvHRgLsnsdRTl+mMJp0NZENI eu4nR4DbWOr63Ttc8GarQT/e8IkVttDQGVgsIaPq/s9CNdbesaMIuZczx6IEqc/incalBn /dxZvucPS/HHDQv4PgGBIZPeSmEyRG/NvRLxlO89d9Mn4LRs8vlFHb+VBgrf7A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1685432485; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=xhU/yZF2uXMwyHdo5kEEt8Hrqxfr36ESyDFCDZDhw10=; b=a2+5ES55fMQgxKJJbP95hcoC18+l+dQQA3lSKgMpgpSeDJ/jAeQ2+cybncfA69eRr1cJwk 6LPJPnxArLwLZADw== From: "irqchip-bot for Marc Zyngier" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-kernel@vger.kernel.org Subject: [irqchip: irq/irqchip-next] irqchip/gic-v3: Improve affinity helper Cc: Marc Zyngier , tglx@linutronix.de MIME-Version: 1.0 Message-ID: <168543248488.404.160985809296056807.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767304862065466760?= X-GMAIL-MSGID: =?utf-8?q?1767304862065466760?= The following commit has been merged into the irq/irqchip-next branch of irqchip: Commit-ID: 3c65cbb7c5ebb4247968936899580c7f508ed223 Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms/3c65cbb7c5ebb4247968936899580c7f508ed223 Author: Marc Zyngier AuthorDate: Mon, 29 May 2023 16:21:42 +01:00 Committer: Marc Zyngier CommitterDate: Mon, 29 May 2023 16:58:07 +01:00 irqchip/gic-v3: Improve affinity helper The GICv3 driver uses multiple formats for the affinity, all derived from a reading of MPDR_EL1 on one CPU or another. Simplify the handling of these affinity by moving the access to the CPU affinity via cpu_logical_map() inside the helper, and rename it accordingly. This will be helpful to support some more broken hardware. Signed-off-by: Marc Zyngier --- drivers/irqchip/irq-gic-v3.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index a605aa7..50455bc 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -656,8 +656,9 @@ static int gic_irq_set_vcpu_affinity(struct irq_data *d, void *vcpu) return 0; } -static u64 gic_mpidr_to_affinity(unsigned long mpidr) +static u64 gic_cpu_to_affinity(int cpu) { + u64 mpidr = cpu_logical_map(cpu); u64 aff; aff = ((u64)MPIDR_AFFINITY_LEVEL(mpidr, 3) << 32 | @@ -914,7 +915,7 @@ static void __init gic_dist_init(void) * Set all global interrupts to the boot CPU only. ARE must be * enabled. */ - affinity = gic_mpidr_to_affinity(cpu_logical_map(smp_processor_id())); + affinity = gic_cpu_to_affinity(smp_processor_id()); for (i = 32; i < GIC_LINE_NR; i++) gic_write_irouter(affinity, base + GICD_IROUTER + i * 8); @@ -963,7 +964,7 @@ static int gic_iterate_rdists(int (*fn)(struct redist_region *, void __iomem *)) static int __gic_populate_rdist(struct redist_region *region, void __iomem *ptr) { - unsigned long mpidr = cpu_logical_map(smp_processor_id()); + unsigned long mpidr; u64 typer; u32 aff; @@ -971,6 +972,8 @@ static int __gic_populate_rdist(struct redist_region *region, void __iomem *ptr) * Convert affinity to a 32bit value that can be matched to * GICR_TYPER bits [63:32]. */ + mpidr = gic_cpu_to_affinity(smp_processor_id()); + aff = (MPIDR_AFFINITY_LEVEL(mpidr, 3) << 24 | MPIDR_AFFINITY_LEVEL(mpidr, 2) << 16 | MPIDR_AFFINITY_LEVEL(mpidr, 1) << 8 | @@ -1084,7 +1087,7 @@ static inline bool gic_dist_security_disabled(void) static void gic_cpu_sys_reg_init(void) { int i, cpu = smp_processor_id(); - u64 mpidr = cpu_logical_map(cpu); + u64 mpidr = gic_cpu_to_affinity(cpu); u64 need_rss = MPIDR_RS(mpidr); bool group0; u32 pribits; @@ -1183,11 +1186,11 @@ static void gic_cpu_sys_reg_init(void) for_each_online_cpu(i) { bool have_rss = per_cpu(has_rss, i) && per_cpu(has_rss, cpu); - need_rss |= MPIDR_RS(cpu_logical_map(i)); + need_rss |= MPIDR_RS(gic_cpu_to_affinity(i)); if (need_rss && (!have_rss)) pr_crit("CPU%d (%lx) can't SGI CPU%d (%lx), no RSS\n", cpu, (unsigned long)mpidr, - i, (unsigned long)cpu_logical_map(i)); + i, (unsigned long)gic_cpu_to_affinity(i)); } /** @@ -1263,9 +1266,11 @@ static u16 gic_compute_target_list(int *base_cpu, const struct cpumask *mask, unsigned long cluster_id) { int next_cpu, cpu = *base_cpu; - unsigned long mpidr = cpu_logical_map(cpu); + unsigned long mpidr; u16 tlist = 0; + mpidr = gic_cpu_to_affinity(cpu); + while (cpu < nr_cpu_ids) { tlist |= 1 << (mpidr & 0xf); @@ -1274,7 +1279,7 @@ static u16 gic_compute_target_list(int *base_cpu, const struct cpumask *mask, goto out; cpu = next_cpu; - mpidr = cpu_logical_map(cpu); + mpidr = gic_cpu_to_affinity(cpu); if (cluster_id != MPIDR_TO_SGI_CLUSTER_ID(mpidr)) { cpu--; @@ -1319,7 +1324,7 @@ static void gic_ipi_send_mask(struct irq_data *d, const struct cpumask *mask) dsb(ishst); for_each_cpu(cpu, mask) { - u64 cluster_id = MPIDR_TO_SGI_CLUSTER_ID(cpu_logical_map(cpu)); + u64 cluster_id = MPIDR_TO_SGI_CLUSTER_ID(gic_cpu_to_affinity(cpu)); u16 tlist; tlist = gic_compute_target_list(&cpu, mask, cluster_id); @@ -1377,7 +1382,7 @@ static int gic_set_affinity(struct irq_data *d, const struct cpumask *mask_val, offset = convert_offset_index(d, GICD_IROUTER, &index); reg = gic_dist_base(d) + offset + (index * 8); - val = gic_mpidr_to_affinity(cpu_logical_map(cpu)); + val = gic_cpu_to_affinity(cpu); gic_write_irouter(val, reg);