From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 07CAA3630A1; Thu, 12 Mar 2026 11:07:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.176.79.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773313672; cv=none; b=rjaIu/hlisHE1LrkPw0ioMoa7d3Z6h11PQ7nbj7Edr4jRoOheTfSoufH1Gaz7m6UKCGBHTcIUyD0Kbvz5AHABQwNzen+ykCcC6vpd/zbhw4yJRFgNsOc1snL5693Fpl2NasJ5gMrfjsuEVaARCiDUv2lUrIj9cfHD+LccbfuYLA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773313672; c=relaxed/simple; bh=quM1dCUzex7hsDIaji+Lt2uHH4N7ImU0pUBpHPkVSAQ=; h=Date:From:To:CC:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=cAxieauDUHkh4UXQXzzDaX7q2qZ4DlRED3Fhs0wnJkdfkBePv5HthFIYoL6XX/7v0uxBteCFjjDdVJtMRu7sBkGkMW/RJsWGoLXKtLx02map7mcA8sCSe6BZuBeKdi/3gExVxmU2nIr2i26XeGzBfrhdGttBIEbgs0zHAEAXsFQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=185.176.79.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.18.224.107]) by frasgout.his.huawei.com (SkyGuard) with ESMTPS id 4fWlDy35XXzJ46fJ; Thu, 12 Mar 2026 19:06:58 +0800 (CST) Received: from dubpeml500005.china.huawei.com (unknown [7.214.145.207]) by mail.maildlp.com (Postfix) with ESMTPS id 29C2E40584; Thu, 12 Mar 2026 19:07:46 +0800 (CST) Received: from localhost (10.203.177.15) by dubpeml500005.china.huawei.com (7.214.145.207) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 12 Mar 2026 11:07:43 +0000 Date: Thu, 12 Mar 2026 11:07:42 +0000 From: Jonathan Cameron To: Chengwen Feng CC: Bjorn Helgaas , Catalin Marinas , Will Deacon , "Rafael J . Wysocki" , Jonathan Corbet , Shuah Khan , Huacai Chen , "WANG Xuerui" , Paul Walmsley , "Palmer Dabbelt" , Albert Ou , "Alexandre Ghiti" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , , "H . Peter Anvin" , Juergen Gross , Boris Ostrovsky , Len Brown , Sunil V L , Mark Rutland , Kees Cook , Yanteng Si , Sean Christopherson , Kai Huang , Tom Lendacky , Thomas Huth , Thorsten Blum , Kevin Loughlin , Zheyun Shen , Peter Zijlstra , Pawan Gupta , Xin Li , "Ahmed S . Darwish" , Sohil Mehta , Ilkka Koskinen , Robin Murphy , James Clark , Besar Wicaksono , Ma Ke , "Wei Huang" , Andy Gospodarek , Somnath Kotur , , , , , , , , , , , , , , , , , , , , , , , Subject: Re: [PATCH v6 1/3] ACPI: Rename get_acpi_id_for_cpu() to acpi_get_cpu_uid() on non-x86 Message-ID: <20260312110742.00002716@huawei.com> In-Reply-To: <20260312072316.4806-2-fengchengwen@huawei.com> References: <20260312072316.4806-1-fengchengwen@huawei.com> <20260312072316.4806-2-fengchengwen@huawei.com> X-Mailer: Claws Mail 4.3.0 (GTK 3.24.42; x86_64-w64-mingw32) Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: lhrpeml500012.china.huawei.com (7.191.174.4) To dubpeml500005.china.huawei.com (7.214.145.207) On Thu, 12 Mar 2026 15:23:14 +0800 Chengwen Feng wrote: > To unify the CPU ACPI ID retrieval interface across architectures, > rename the existing get_acpi_id_for_cpu() function to > acpi_get_cpu_uid() on arm64/riscv/loongarch platforms. >=20 > This is a pure rename with no functional change, preparing for a It's not just a rename. This should mention that the addition of error checks and hence the resulting signature change. > consistent ACPI Processor UID retrieval interface across all ACPI-enabled > platforms. >=20 > Note: Move the ARM64-specific get_cpu_for_acpi_id() implementation to > arch/arm64/kernel/acpi_numa.c to fix compilation errors from > circular header dependencies introduced by the rename. >=20 > Cc: stable@vger.kernel.org > Signed-off-by: Chengwen Feng > Reviewed-by: Jonathan Cameron =46rom a reread, a few minor style consistency things inline. > --- > arch/arm64/include/asm/acpi.h | 16 +--------- > arch/arm64/kernel/acpi.c | 16 ++++++++++ > arch/arm64/kernel/acpi_numa.c | 15 ++++++++++ > arch/loongarch/include/asm/acpi.h | 5 ---- > arch/loongarch/kernel/acpi.c | 9 ++++++ > arch/riscv/include/asm/acpi.h | 4 --- > arch/riscv/kernel/acpi.c | 16 ++++++++++ > arch/riscv/kernel/acpi_numa.c | 8 +++-- > drivers/acpi/pptt.c | 47 +++++++++++++++++++++--------- > drivers/acpi/riscv/rhct.c | 7 ++++- > drivers/perf/arm_cspmu/arm_cspmu.c | 6 ++-- > include/linux/acpi.h | 13 +++++++++ > 12 files changed, 120 insertions(+), 42 deletions(-) > diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c > index af90128cfed5..984a11788265 100644 > --- a/arch/arm64/kernel/acpi.c > +++ b/arch/arm64/kernel/acpi.c > @@ -458,3 +458,19 @@ int acpi_unmap_cpu(int cpu) > } > EXPORT_SYMBOL(acpi_unmap_cpu); > #endif /* CONFIG_ACPI_HOTPLUG_CPU */ > + > +int acpi_get_cpu_uid(unsigned int cpu, u32 *uid) > +{ > + struct acpi_madt_generic_interrupt *gicc; > + > + if (cpu >=3D nr_cpu_ids) > + return -EINVAL; > + > + gicc =3D acpi_cpu_get_madt_gicc(cpu); > + if (gicc =3D=3D NULL) Seems local style for null pointer checks is if (!gicc) Just for consistency we should follow that. > + return -ENODEV; > + > + *uid =3D gicc->uid; > + return 0; > +} > +EXPORT_SYMBOL_GPL(acpi_get_cpu_uid); > diff --git a/arch/arm64/kernel/acpi_numa.c b/arch/arm64/kernel/acpi_numa.c > index 2465f291c7e1..56e2e486e49b 100644 > --- a/arch/arm64/kernel/acpi_numa.c > +++ b/arch/arm64/kernel/acpi_numa.c > @@ -34,6 +34,21 @@ int __init acpi_numa_get_nid(unsigned int cpu) > return acpi_early_node_map[cpu]; > } > =20 > +int get_cpu_for_acpi_id(u32 uid) > +{ > + u32 cpu_uid; > + int cpu; > + int ret; > + > + for (cpu =3D 0; cpu < nr_cpu_ids; cpu++) { Given more recent acceptance of the following perhaps it is neater here. for (int cpu =3D 0; cpu < nr_cpu_ids; cpu++) { Amazingly there aren't any for loops in this file so we can do what we like from a consistency point of view. > + ret =3D acpi_get_cpu_uid(cpu, &cpu_uid); > + if (ret =3D=3D 0 && uid =3D=3D cpu_uid) > + return cpu; > + } > + > + return -EINVAL; > +} > + > static int __init acpi_parse_gicc_pxm(union acpi_subtable_headers *heade= r, > const unsigned long end) > { > diff --git a/arch/riscv/kernel/acpi.c b/arch/riscv/kernel/acpi.c > index 71698ee11621..bde810d02c4f 100644 > --- a/arch/riscv/kernel/acpi.c > +++ b/arch/riscv/kernel/acpi.c > @@ -337,3 +337,19 @@ int raw_pci_write(unsigned int domain, unsigned int = bus, > } > =20 > #endif /* CONFIG_PCI */ > + > +int acpi_get_cpu_uid(unsigned int cpu, u32 *uid) > +{ > + struct acpi_madt_rintc *rintc; > + > + if (cpu >=3D nr_cpu_ids) > + return -EINVAL; > + > + rintc =3D acpi_cpu_get_madt_rintc(cpu); > + if (rintc =3D=3D NULL) Similar to above. Local style for NULL checks is if (!rintc) so this should follow that. > + return -ENODEV; > + > + *uid =3D rintc->uid; > + return 0; > +} > +EXPORT_SYMBOL_GPL(acpi_get_cpu_uid); > diff --git a/arch/riscv/kernel/acpi_numa.c b/arch/riscv/kernel/acpi_numa.c > index 130769e3a99c..cd8adc9857e3 100644 > --- a/arch/riscv/kernel/acpi_numa.c > +++ b/arch/riscv/kernel/acpi_numa.c > @@ -37,11 +37,15 @@ static int __init acpi_numa_get_nid(unsigned int cpu) > =20 > static inline int get_cpu_for_acpi_id(u32 uid) > { > + u32 cpu_uid; > int cpu; > + int ret; > =20 > - for (cpu =3D 0; cpu < nr_cpu_ids; cpu++) > - if (uid =3D=3D get_acpi_id_for_cpu(cpu)) > + for (cpu =3D 0; cpu < nr_cpu_ids; cpu++) { Can pull the int into the loop her as well. > + ret =3D acpi_get_cpu_uid(cpu, &cpu_uid); > + if (ret =3D=3D 0 && uid =3D=3D cpu_uid) > return cpu; > + } > =20 > return -EINVAL; > } > diff --git a/drivers/acpi/pptt.c b/drivers/acpi/pptt.c > index de5f8c018333..d034a217e85b 100644 > --- a/drivers/acpi/pptt.c > +++ b/drivers/acpi/pptt.c > static int check_acpi_cpu_flag(unsigned int cpu, int rev, u32 flag) > { > struct acpi_table_header *table; > - u32 acpi_cpu_id =3D get_acpi_id_for_cpu(cpu); > + u32 acpi_cpu_id; > struct acpi_pptt_processor *cpu_node =3D NULL; > int ret =3D -ENOENT; > =20 > + if (acpi_get_cpu_uid(cpu, &acpi_cpu_id) !=3D 0) > + return -ENOENT; > + > table =3D acpi_get_pptt(); > if (!table) > return -ENOENT; > @@ -651,7 +661,8 @@ static int check_acpi_cpu_flag(unsigned int cpu, int = rev, u32 flag) > * in the PPTT. Errors caused by lack of a PPTT table, or otherwise, ret= urn 0 > * indicating we didn't find any cache levels. > * > - * Return: -ENOENT if no PPTT table or no PPTT processor struct found. > + * Return: -ENOENT if no PPTT table, can't get CPU's ACPI Process UID or= no PPTT > + * processor struct found. > * 0 on success. > */ > int acpi_get_cache_info(unsigned int cpu, unsigned int *levels, > @@ -671,7 +682,8 @@ int acpi_get_cache_info(unsigned int cpu, unsigned in= t *levels, > =20 > pr_debug("Cache Setup: find cache levels for CPU=3D%d\n", cpu); > =20 > - acpi_cpu_id =3D get_acpi_id_for_cpu(cpu); > + if (acpi_get_cpu_uid(cpu, &acpi_cpu_id)) > + return -ENOENT; I'd put a blank line here (similar to the code you added just above). > cpu_node =3D acpi_find_processor_node(table, acpi_cpu_id); > if (!cpu_node) > return -ENOENT; > @@ -780,8 +792,9 @@ int find_acpi_cpu_topology_package(unsigned int cpu) > * It may not exist in single CPU systems. In simple multi-CPU systems, > * it may be equal to the package topology level. > * > - * Return: -ENOENT if the PPTT doesn't exist, the CPU cannot be found > - * or there is no toplogy level above the CPU.. > + * Return: -ENOENT if the PPTT doesn't exist, can't get CPU's ACPI > + * Processor UID, the CPU cannot be found or there is no toplogy level > + * above the CPU. > * Otherwise returns a value which represents the package for this CPU. > */ > =20 > @@ -797,7 +810,8 @@ int find_acpi_cpu_topology_cluster(unsigned int cpu) > if (!table) > return -ENOENT; > =20 > - acpi_cpu_id =3D get_acpi_id_for_cpu(cpu); > + if (acpi_get_cpu_uid(cpu, &acpi_cpu_id) !=3D 0) > + return -ENOENT; Again, I'd put a blank line here. > cpu_node =3D acpi_find_processor_node(table, acpi_cpu_id); > if (!cpu_node || !cpu_node->parent) > return -ENOENT; > @@ -872,7 +886,8 @@ static void acpi_pptt_get_child_cpus(struct acpi_tabl= e_header *table_hdr, > cpumask_clear(cpus); > =20 > for_each_possible_cpu(cpu) { > - acpi_id =3D get_acpi_id_for_cpu(cpu); > + if (acpi_get_cpu_uid(cpu, &acpi_id) !=3D 0) > + continue; and here. > cpu_node =3D acpi_find_processor_node(table_hdr, acpi_id); > =20 > while (cpu_node) {