Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1861916rwd; Wed, 17 May 2023 02:22:25 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4xjZqa+Ti/6BRyBPy75ZhvljNsFo3OT3h9m+G3NrgGZstqALdCkJ06iTJLapox4jlix1Q/ X-Received: by 2002:a17:90b:306:b0:253:2ddd:4a36 with SMTP id ay6-20020a17090b030600b002532ddd4a36mr3847521pjb.6.1684315345118; Wed, 17 May 2023 02:22:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684315345; cv=none; d=google.com; s=arc-20160816; b=dvpeNDoS7Mb9N/K79qixC/a0zPbXFxOBxqh31rPDKzbbP7jvHfDbVm6ZH7dsK72HGK U7z/zy+HfEqM2pLWR7VLP6xoJaBXgT16fOM+/+BncHWAdrCOXfOVd8vTADRznLNmGyqo y/qhTi4pQD4DeGehfp0YUrpAkp6doYHxLKHCRDX/6LFQ72iwW6QjTqxn7BeEkhCM3p3s Lhv/L4t1xzjaiGnb/AINLYGx5pRlED0qlmJLj2nRcKPkMapaMiQByoSn0wVy/HRIWKnJ XZ+eyTbPGB1X4JwqlJkOaR3nliozwt94H47m6pVz9RkQQmgIeBxeNITxF77ksRo2j1m6 EAZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature; bh=g+ZgKEQwNXqpM/JnpBIIjehrMtShQ7iPA1V+dmIi/iM=; b=b533orM8Xaity+OUz+qs0E8BiOLzX7+x/FXUYOCrc+jbKwv6KnTe3xsf+3HVvohbTT C5hqCvksAXwhLqNmvOa9b6yfhfiKT0c/FFIk+/aM50ul5AYC+kgADOk4Uvj8Y5QUdNed FXuAd8VNK1sQRZbcq/FCS3j96hjxojptEhTXdQbwbtosCj48E/waw4izCGL1qoedcpbi XpNvhY/J2/A2t2/yCG4UABTg5UaPiFsN1r2T4aMbB3AMOPu3kUvXrw86cDtOr+EuQ88v e2/7a8dU+EfzhjgUK+KrdiJZ1krm0I08X98YzA53ziGSB6SVvbUx+fv/AvAwrgX4GH0v L+nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hfKqlGs0; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o15-20020a17090a4b4f00b00250cb2a2003si1275950pjl.164.2023.05.17.02.22.10; Wed, 17 May 2023 02:22:25 -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=@kernel.org header.s=k20201202 header.b=hfKqlGs0; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230447AbjEQIde (ORCPT + 99 others); Wed, 17 May 2023 04:33:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229691AbjEQIdB (ORCPT ); Wed, 17 May 2023 04:33:01 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BAF95FCD for ; Wed, 17 May 2023 01:32:28 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 28F2D643B7 for ; Wed, 17 May 2023 08:32:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 91B3CC433D2; Wed, 17 May 2023 08:32:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684312347; bh=/KT/9/5y3aOR80T1KmoIa7l7+IUF8AgYbppNXtlsX6s=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=hfKqlGs0tmbepRV+oV02doIiz/paEfgVhuSfjpjIgBrtK7wp4ExjrZB7kV24AkDa+ ++a7CFVgbDYtWtsNLJD6gKsdwYqUs3b1jtC35/1+hZcx6BEzs0d3uX5Guc2HV0hQNY oubZ6FXyyuDWPOzK4kz/yfYBN5j5+Ihnkrx467MyyJ5Q9RMXKqqYXl8l547P70qIBR +tBU21pn2P2bkHsEdwX/XFA0yBHexWMWUzhvl5T6W52X+P2jD+X5XvZCHt3jWdTD1o eTu3c/vLkOVZ9PUrKSefBUvutfndw6CAg1Wf/l8sgqMMt99+qzTExwsLETMI3LHteu 4XNf+L9sgOcAA== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pzCa9-00Fmvp-A9; Wed, 17 May 2023 09:32:25 +0100 Date: Wed, 17 May 2023 09:32:25 +0100 Message-ID: <86ttwbl5nq.wl-maz@kernel.org> From: Marc Zyngier To: zhengyan Cc: tglx@linutronix.de, linux-kernel@vger.kernel.org, meitaogao@asrmicro.com, qiaozhou@asrmicro.com, zhizhouzhang@asrmicro.com Subject: Re: [PATCH] irqchip/gic-v3: workaround for ASR8601 when reading mpidr In-Reply-To: <20230517075500.43516-1-zhengyan@asrmicro.com> References: <20230517075500.43516-1-zhengyan@asrmicro.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/28.2 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: zhengyan@asrmicro.com, tglx@linutronix.de, linux-kernel@vger.kernel.org, meitaogao@asrmicro.com, qiaozhou@asrmicro.com, zhizhouzhang@asrmicro.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 On Wed, 17 May 2023 08:55:00 +0100, zhengyan wrote: > > This patch add workaround for ASR8601, which uses an armv8.2 > processor with a gic-500. ARMv8.2 uses Multiprocessor Affinity > Register to identify the logical address of the core by > | cluster | core | thread |. Not quite. The ARMv8.2 architecture doesn't say *any* of that. It is ARM's *implementations* that follow this scheme. > However, gic-500 only supports topologies with > affinity levels less than 2 as > | cluster | core|. > > So it needs this patch to shift the MPIDR values > to ensure proper functionality > > Signed-off-by: zhengyan > --- > drivers/irqchip/irq-gic-v3.c | 28 +++++++++++++++++++++++++++- > 1 file changed, 27 insertions(+), 1 deletion(-) > > diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c > index 6fcee221f201..435b98a8641e 100644 > --- a/drivers/irqchip/irq-gic-v3.c > +++ b/drivers/irqchip/irq-gic-v3.c > @@ -39,6 +39,7 @@ > > #define FLAGS_WORKAROUND_GICR_WAKER_MSM8996 (1ULL << 0) > #define FLAGS_WORKAROUND_CAVIUM_ERRATUM_38539 (1ULL << 1) > +#define FLAGS_WORKAROUND_MPIDR_ASR8601 (1ULL << 2) What is ASR8601? Is it a system? Or an erratum number? For issues that are the result of a HW integration issue, please provide an official erratum number, and update Documentation/arm64/silicon-errata.rst. > > #define GIC_IRQ_TYPE_PARTITION (GIC_IRQ_TYPE_LPI + 1) > > @@ -659,6 +660,9 @@ static u64 gic_mpidr_to_affinity(unsigned long mpidr) > { > u64 aff; > > + if (gic_data.flags & FLAGS_WORKAROUND_MPIDR_ASR8601) > + mpidr >>= 8; > + > aff = ((u64)MPIDR_AFFINITY_LEVEL(mpidr, 3) << 32 | > MPIDR_AFFINITY_LEVEL(mpidr, 2) << 16 | > MPIDR_AFFINITY_LEVEL(mpidr, 1) << 8 | > @@ -970,6 +974,9 @@ 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]. > */ > + if (gic_data.flags & FLAGS_WORKAROUND_MPIDR_ASR8601) > + mpidr >>= 8; > + > aff = (MPIDR_AFFINITY_LEVEL(mpidr, 3) << 24 | > MPIDR_AFFINITY_LEVEL(mpidr, 2) << 16 | > MPIDR_AFFINITY_LEVEL(mpidr, 1) << 8 | > @@ -1265,6 +1272,8 @@ static u16 gic_compute_target_list(int *base_cpu, const struct cpumask *mask, > unsigned long mpidr = cpu_logical_map(cpu); > u16 tlist = 0; > > + if (gic_data.flags & FLAGS_WORKAROUND_MPIDR_ASR8601) > + mpidr >>= 8; > while (cpu < nr_cpu_ids) { > tlist |= 1 << (mpidr & 0xf); > > @@ -1274,7 +1283,8 @@ static u16 gic_compute_target_list(int *base_cpu, const struct cpumask *mask, > cpu = next_cpu; > > mpidr = cpu_logical_map(cpu); > - > + if (gic_data.flags & FLAGS_WORKAROUND_MPIDR_ASR8601) > + mpidr >>= 8; > if (cluster_id != MPIDR_TO_SGI_CLUSTER_ID(mpidr)) { > cpu--; > goto out; > @@ -1321,6 +1331,8 @@ static void gic_ipi_send_mask(struct irq_data *d, const struct cpumask *mask) > u64 cluster_id = MPIDR_TO_SGI_CLUSTER_ID(cpu_logical_map(cpu)); > u16 tlist; > > + if (gic_data.flags & FLAGS_WORKAROUND_MPIDR_ASR8601) > + cluster_id = MPIDR_TO_SGI_CLUSTER_ID(cpu_logical_map(cpu) >> 8); You've written the same check 5 times. Maybe you could start by refactoring that code so that the hack can be in a single place? > tlist = gic_compute_target_list(&cpu, mask, cluster_id); > gic_send_sgi(cluster_id, tlist, d->hwirq); > } > @@ -1729,6 +1741,15 @@ static bool gic_enable_quirk_cavium_38539(void *data) > return true; > } > > +static bool gic_enable_quirk_asr8601(void *data) > +{ > + struct gic_chip_data *d = data; > + > + d->flags |= FLAGS_WORKAROUND_MPIDR_ASR8601; > + > + return true; > +} > + > static bool gic_enable_quirk_hip06_07(void *data) > { > struct gic_chip_data *d = data; > @@ -1823,6 +1844,11 @@ static const struct gic_quirk gic_quirks[] = { > .mask = 0xffffffff, > .init = gic_enable_quirk_nvidia_t241, > }, > + { > + .desc = "GICv3: ASR 8601 MPIDR SHIFT", s/SHIFT/shift/ > + .compatible = "asr,asr8601-gic-v3", So ASR8601 *is* a system... Is it DT only? Thanks, M. -- Without deviation from the norm, progress is not possible.