From nobody Wed Apr 1 22:25:39 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=huawei.com ARC-Seal: i=1; a=rsa-sha256; t=1775031445; cv=none; d=zohomail.com; s=zohoarc; b=iKQ631/7HJD7VVeKUaZvr/xZP0jsjfOFaeiy59Nq8tQTT9cuKOu7YdJ3xkqQfsvA1C7JhuUcW25/6C/960JWqf94CFf+BjOd5llU9REQy3CCyNCdSAzysyg5RYV//okd4uqxAp/BLQLJlR8m+00KSAxJu/xiQWl/xtqcVLftjKU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775031445; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=cX9nX5J0dlT1awVPQ/6cRzsJrYfbjG8pE8PbO0C/Hhc=; b=McwG97yNDK1Mh1NBo9d+pfOm/SCDNLETYMxeQPfcAIGtXgEdn1MWvpPO7yxf167220KHl0SmPR5yJ8qMPcxEhZZ7SCTBNuiHBNGx1mSi6bYDMbQ7TIF7CxfbrHy+oF3RaVIszALrwis9FRXECT0FtsGkKcgR564pk3jV+nilHd4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 177503144513680.18248243769187; Wed, 1 Apr 2026 01:17:25 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1269881.1558765 (Exim 4.92) (envelope-from ) id 1w7ql0-0005fe-TO; Wed, 01 Apr 2026 08:16:58 +0000 Received: by outflank-mailman (output) from mailman id 1269881.1558765; Wed, 01 Apr 2026 08:16:58 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w7ql0-0005fP-OJ; Wed, 01 Apr 2026 08:16:58 +0000 Received: by outflank-mailman (input) for mailman id 1269881; Wed, 01 Apr 2026 08:16:57 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w7qkz-0005OH-3h for xen-devel@lists.xenproject.org; Wed, 01 Apr 2026 08:16:57 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1w7qky-00Ez1l-Fb for xen-devel@lists.xenproject.org; Wed, 01 Apr 2026 10:16:56 +0200 Received: from [10.42.69.3] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 69ccd472-e002-0a2a0a5209dd-0a2a4503cd14-18 for ; Wed, 01 Apr 2026 10:16:56 +0200 Received: from [113.46.200.227] (helo=canpmsgout12.his.huawei.com) by tlsNG-33051d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.0) (envelope-from ) id 69ccd473-02b3-0a2a45030019-712ec8e3c802-3 for ; Wed, 01 Apr 2026 10:16:55 +0200 Received: from mail.maildlp.com (unknown [172.19.163.200]) by canpmsgout12.his.huawei.com (SkyGuard) with ESMTPS id 4flyP93zz2znTYc; Wed, 1 Apr 2026 16:11:25 +0800 (CST) Received: from kwepemk500009.china.huawei.com (unknown [7.202.194.94]) by mail.maildlp.com (Postfix) with ESMTPS id 2C8174056C; Wed, 1 Apr 2026 16:16:49 +0800 (CST) Received: from localhost.localdomain (10.50.163.32) by kwepemk500009.china.huawei.com (7.202.194.94) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Wed, 1 Apr 2026 16:16:47 +0800 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=dkim header.d=huawei.com header.i="@huawei.com" header.h=From dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=cX9nX5J0dlT1awVPQ/6cRzsJrYfbjG8pE8PbO0C/Hhc=; b=i+j26ictNtsg7O/F6lBPFRPqM46wxpGQx6OUUfHHZ8jfyEiP2gCA6kxZgTIcJa4j5pbOBLJLQ c+HcxUl949mY9sPM4NfmX+Zase+tnrgONPI+R/E8bfr+487HRMp/f+b+3k2YIASwaiRxC/kJzyc ytRMmF8nbgor8UF3Ii+ThkQ= From: Chengwen Feng To: Bjorn Helgaas , Catalin Marinas , Will Deacon , "Rafael J . Wysocki" CC: Jonathan Corbet , WANG Xuerui , Thomas Gleixner , Dave Hansen , "H . Peter Anvin" , Juergen Gross , Boris Ostrovsky , Len Brown , Sunil V L , Mark Rutland , Jonathan Cameron , 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: [PATCH RESEND v10 1/8] arm64: acpi: Add acpi_get_cpu_uid() for unified ACPI CPU UID retrieval Date: Wed, 1 Apr 2026 16:16:33 +0800 Message-ID: <20260401081640.26875-2-fengchengwen@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20260401081640.26875-1-fengchengwen@huawei.com> References: <20260401081640.26875-1-fengchengwen@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.50.163.32] X-ClientProxiedBy: kwepems200001.china.huawei.com (7.221.188.67) To kwepemk500009.china.huawei.com (7.202.194.94) X-purgate-ID: tlsNG-33051d/1775031416-41B15C9A-04D77A0F/0/0 X-purgate-type: clean X-purgate-size: 2371 X-ZohoMail-DKIM: pass (identity @huawei.com) X-ZM-MESSAGEID: 1775031446409154100 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" As a step towards unifying the interface for retrieving ACPI CPU UID across architectures, introduce a new function acpi_get_cpu_uid() for arm64. While at it, add input validation to make the code more robust. Reimplement get_cpu_for_acpi_id() based on acpi_get_cpu_uid() for consistency, and move its implementation next to the new function for code coherence. Cc: stable@vger.kernel.org Signed-off-by: Chengwen Feng Reviewed-by: Jonathan Cameron Acked-by: Catalin Marinas --- arch/arm64/include/asm/acpi.h | 14 ++------------ arch/arm64/kernel/acpi.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h index c07a58b96329..2219a3301e72 100644 --- a/arch/arm64/include/asm/acpi.h +++ b/arch/arm64/include/asm/acpi.h @@ -118,18 +118,8 @@ static inline u32 get_acpi_id_for_cpu(unsigned int cpu) { return acpi_cpu_get_madt_gicc(cpu)->uid; } - -static inline int get_cpu_for_acpi_id(u32 uid) -{ - int cpu; - - for (cpu =3D 0; cpu < nr_cpu_ids; cpu++) - if (acpi_cpu_get_madt_gicc(cpu) && - uid =3D=3D get_acpi_id_for_cpu(cpu)) - return cpu; - - return -EINVAL; -} +int acpi_get_cpu_uid(unsigned int cpu, u32 *uid); +int get_cpu_for_acpi_id(u32 uid); =20 static inline void arch_fix_phys_package_id(int num, u32 slot) { } void __init acpi_init_cpus(void); diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c index af90128cfed5..24b9d934be54 100644 --- a/arch/arm64/kernel/acpi.c +++ b/arch/arm64/kernel/acpi.c @@ -458,3 +458,33 @@ 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) + return -ENODEV; + + *uid =3D gicc->uid; + return 0; +} +EXPORT_SYMBOL_GPL(acpi_get_cpu_uid); + +int get_cpu_for_acpi_id(u32 uid) +{ + u32 cpu_uid; + int ret; + + for (int cpu =3D 0; cpu < nr_cpu_ids; cpu++) { + ret =3D acpi_get_cpu_uid(cpu, &cpu_uid); + if (ret =3D=3D 0 && uid =3D=3D cpu_uid) + return cpu; + } + + return -EINVAL; +} --=20 2.17.1 From nobody Wed Apr 1 22:25:39 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=huawei.com ARC-Seal: i=1; a=rsa-sha256; t=1775031441; cv=none; d=zohomail.com; s=zohoarc; b=L41iVU6lpE2AeY5HfTVjTygGYhCiMua719TKaeuEon1swCNEH4gw7uydnhRwe4uvt4a6KbHd3lZ9M/6mcYtUVW2WKsy0I1Oo3yCPzecyjnW+Bh7CcHnx04frz4p+fYTxVQPgSEZP1xgkN3LCJyOoX6Rk/kjhACdapSwQTYmwUqU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775031441; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=BAu9Jx0jggsoB9DdjhBMDzv6GW2fgZQZhQIfabnTV1w=; b=ZHsSZqDNi4DgYG32sZ/0f29buHeOSErk57OT8SyQnAqBkUEUFkLQSSZAKGquV8NWbGXsdJYEklmzkLcYJ3aLp5KxLqCgs4AKQsDO+4te5G2OWN/tyymnK1YkirUaYKBXdoy7To3EbkD5Ym/fIwUp/CjPr0l/Jj2viKAbtNWZ9/c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1775031441806544.3107559214097; Wed, 1 Apr 2026 01:17:21 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1269880.1558755 (Exim 4.92) (envelope-from ) id 1w7qkz-0005Rx-Gt; Wed, 01 Apr 2026 08:16:57 +0000 Received: by outflank-mailman (output) from mailman id 1269880.1558755; Wed, 01 Apr 2026 08:16:57 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w7qkz-0005Rq-E7; Wed, 01 Apr 2026 08:16:57 +0000 Received: by outflank-mailman (input) for mailman id 1269880; Wed, 01 Apr 2026 08:16:56 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w7qky-0005EX-9N for xen-devel@lists.xenproject.org; Wed, 01 Apr 2026 08:16:56 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1w7qkx-00Ez1l-LQ for xen-devel@lists.xenproject.org; Wed, 01 Apr 2026 10:16:55 +0200 Received: from [10.42.69.3] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 69ccd472-e002-0a2a0a5209dd-0a2a4503cd14-16 for ; Wed, 01 Apr 2026 10:16:55 +0200 Received: from [113.46.200.220] (helo=canpmsgout05.his.huawei.com) by tlsNG-33051d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.0) (envelope-from ) id 69ccd474-02b3-0a2a45030019-712ec8dc5d7e-3 for ; Wed, 01 Apr 2026 10:16:55 +0200 Received: from mail.maildlp.com (unknown [172.19.163.0]) by canpmsgout05.his.huawei.com (SkyGuard) with ESMTPS id 4flyPC3klwz12LG4; Wed, 1 Apr 2026 16:11:27 +0800 (CST) Received: from kwepemk500009.china.huawei.com (unknown [7.202.194.94]) by mail.maildlp.com (Postfix) with ESMTPS id CEA0F40537; Wed, 1 Apr 2026 16:16:50 +0800 (CST) Received: from localhost.localdomain (10.50.163.32) by kwepemk500009.china.huawei.com (7.202.194.94) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Wed, 1 Apr 2026 16:16:48 +0800 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=dkim header.d=huawei.com header.i="@huawei.com" header.h=From dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=BAu9Jx0jggsoB9DdjhBMDzv6GW2fgZQZhQIfabnTV1w=; b=0iNno9KssbzJIwOx46kM6OnZNBBxZqavG7rHHC5bdLxsRgIt4sx/XNjUZTTVDZXEoVFcegx0c Yif2aSgMI7B+vjuMbgqzpMuvUrJW1SQ8yRstGcNtfNLWFUMM/xjzPhZAjZffDLNoeTFLUbEByDb +8fyvzP5gn6CQVDmf4awY48= From: Chengwen Feng To: Bjorn Helgaas , Catalin Marinas , Will Deacon , "Rafael J . Wysocki" CC: Jonathan Corbet , WANG Xuerui , Thomas Gleixner , Dave Hansen , "H . Peter Anvin" , Juergen Gross , Boris Ostrovsky , Len Brown , Sunil V L , Mark Rutland , Jonathan Cameron , 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: [PATCH RESEND v10 2/8] LoongArch: Add acpi_get_cpu_uid() for unified ACPI CPU UID retrieval Date: Wed, 1 Apr 2026 16:16:34 +0800 Message-ID: <20260401081640.26875-3-fengchengwen@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20260401081640.26875-1-fengchengwen@huawei.com> References: <20260401081640.26875-1-fengchengwen@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.50.163.32] X-ClientProxiedBy: kwepems200001.china.huawei.com (7.221.188.67) To kwepemk500009.china.huawei.com (7.202.194.94) X-purgate-ID: tlsNG-33051d/1775031415-CBF2DC9A-FC401EC5/0/0 X-purgate-type: clean X-purgate-size: 1483 X-ZohoMail-DKIM: pass (identity @huawei.com) X-ZM-MESSAGEID: 1775031444482154100 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" As a step towards unifying the interface for retrieving ACPI CPU UID across architectures, introduce a new function acpi_get_cpu_uid() for loongarch. While at it, add input validation to make the code more robust. Cc: stable@vger.kernel.org Signed-off-by: Chengwen Feng Reviewed-by: Jonathan Cameron --- arch/loongarch/include/asm/acpi.h | 1 + arch/loongarch/kernel/acpi.c | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/arch/loongarch/include/asm/acpi.h b/arch/loongarch/include/asm= /acpi.h index 7376840fa9f7..8bb101b4557e 100644 --- a/arch/loongarch/include/asm/acpi.h +++ b/arch/loongarch/include/asm/acpi.h @@ -44,6 +44,7 @@ static inline u32 get_acpi_id_for_cpu(unsigned int cpu) { return acpi_core_pic[cpu_logical_map(cpu)].processor_id; } +int acpi_get_cpu_uid(unsigned int cpu, u32 *uid); =20 #endif /* !CONFIG_ACPI */ =20 diff --git a/arch/loongarch/kernel/acpi.c b/arch/loongarch/kernel/acpi.c index 1367ca759468..058f0dbe8e8f 100644 --- a/arch/loongarch/kernel/acpi.c +++ b/arch/loongarch/kernel/acpi.c @@ -385,3 +385,12 @@ int acpi_unmap_cpu(int cpu) EXPORT_SYMBOL(acpi_unmap_cpu); =20 #endif /* CONFIG_ACPI_HOTPLUG_CPU */ + +int acpi_get_cpu_uid(unsigned int cpu, u32 *uid) +{ + if (cpu >=3D nr_cpu_ids) + return -EINVAL; + *uid =3D acpi_core_pic[cpu_logical_map(cpu)].processor_id; + return 0; +} +EXPORT_SYMBOL_GPL(acpi_get_cpu_uid); --=20 2.17.1 From nobody Wed Apr 1 22:25:39 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=huawei.com ARC-Seal: i=1; a=rsa-sha256; t=1775031442; cv=none; d=zohomail.com; s=zohoarc; b=Emf/bwT4PeVsfSpQVdt5cET/PoKZD2U3tpUpbbNJPzdbnnFvE+2iWm5gPJUoATkhUFRB7S73Gx8m98P9m+8QG5try0A/VDY4g93KbFavuyvqLGOleVDuVG9e1EGLab9S/pWum7vX4/N53g8KcOwvV1O2UFdCgBSEsM26+rxsdAw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775031442; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=BMMryEb1CdnOx2gMiVv+9iHKONhR3XK5c+5CZUibkPo=; b=FKPONyQ0x6FohlOTkHwGvV4AI+YOEk5fsVpI1a/OE/v+CDM7DQTh5iX6sYNVcY24+wlLz7AcjCX1l8INhWKu4UPN4qHowhS/YUzoqh6Q4hnSpqnM1cxmJ/SH7ahTdUnWPksM7Lu2RtA8hsAE8ito3ZojS0Ll3IXCSnYklpBlVPI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1775031442463309.9368063802608; Wed, 1 Apr 2026 01:17:22 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1269882.1558769 (Exim 4.92) (envelope-from ) id 1w7ql1-0005jE-7N; Wed, 01 Apr 2026 08:16:59 +0000 Received: by outflank-mailman (output) from mailman id 1269882.1558769; Wed, 01 Apr 2026 08:16:59 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w7ql1-0005in-1v; Wed, 01 Apr 2026 08:16:59 +0000 Received: by outflank-mailman (input) for mailman id 1269882; Wed, 01 Apr 2026 08:16:57 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w7qkz-0005Q0-8o for xen-devel@lists.xenproject.org; Wed, 01 Apr 2026 08:16:57 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1w7qkx-000XNy-39 for xen-devel@lists.xenproject.org; Wed, 01 Apr 2026 10:16:56 +0200 Received: from [10.42.69.2] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 69ccd476-bab6-0a2a0a5309dd-0a2a450280cc-12 for ; Wed, 01 Apr 2026 10:16:56 +0200 Received: from [113.46.200.226] (helo=canpmsgout11.his.huawei.com) by tlsNG-720697.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.0) (envelope-from ) id 69ccd475-42fa-0a2a45020019-712ec8e28bec-3 for ; Wed, 01 Apr 2026 10:16:56 +0200 Received: from mail.maildlp.com (unknown [172.19.163.163]) by canpmsgout11.his.huawei.com (SkyGuard) with ESMTPS id 4flyNJ5zjPzKm91; Wed, 1 Apr 2026 16:10:40 +0800 (CST) Received: from kwepemk500009.china.huawei.com (unknown [7.202.194.94]) by mail.maildlp.com (Postfix) with ESMTPS id 743394048B; Wed, 1 Apr 2026 16:16:52 +0800 (CST) Received: from localhost.localdomain (10.50.163.32) by kwepemk500009.china.huawei.com (7.202.194.94) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Wed, 1 Apr 2026 16:16:50 +0800 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=dkim header.d=huawei.com header.i="@huawei.com" header.h=From dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=BMMryEb1CdnOx2gMiVv+9iHKONhR3XK5c+5CZUibkPo=; b=l/7oJpMqJuYSGHZyOqLiw5LD07h+45LWAipYVAvEt9pYxSp4UxJSqwXgX66M8/EZ74aeSBY3M qLpVsSs+rpKpxDOoVmFTloYQFQ4DUIG80JTpBOmlHJ7rSI3KUDZxGFyGCXDxs8sVu0UH3BlI+It fJwAj4fQtMaqP5gUwirfIBk= From: Chengwen Feng To: Bjorn Helgaas , Catalin Marinas , Will Deacon , "Rafael J . Wysocki" CC: Jonathan Corbet , WANG Xuerui , Thomas Gleixner , Dave Hansen , "H . Peter Anvin" , Juergen Gross , Boris Ostrovsky , Len Brown , Sunil V L , Mark Rutland , Jonathan Cameron , 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: [PATCH RESEND v10 3/8] RISC-V: ACPI: Add acpi_get_cpu_uid() for unified ACPI CPU UID retrieval Date: Wed, 1 Apr 2026 16:16:35 +0800 Message-ID: <20260401081640.26875-4-fengchengwen@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20260401081640.26875-1-fengchengwen@huawei.com> References: <20260401081640.26875-1-fengchengwen@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.50.163.32] X-ClientProxiedBy: kwepems200001.china.huawei.com (7.221.188.67) To kwepemk500009.china.huawei.com (7.202.194.94) X-purgate-ID: tlsNG-720697/1775031416-46B27CD1-77581FE3/0/0 X-purgate-type: clean X-purgate-size: 3045 X-ZohoMail-DKIM: pass (identity @huawei.com) X-ZM-MESSAGEID: 1775031444584154100 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" As a step towards unifying the interface for retrieving ACPI CPU UID across architectures, introduce a new function acpi_get_cpu_uid() for riscv. While at it, add input validation to make the code more robust. And also update acpi_numa.c and rhct.c to use the new interface instead of the legacy get_acpi_id_for_cpu(). Cc: stable@vger.kernel.org Signed-off-by: Chengwen Feng Reviewed-by: Jonathan Cameron --- arch/riscv/include/asm/acpi.h | 1 + arch/riscv/kernel/acpi.c | 16 ++++++++++++++++ arch/riscv/kernel/acpi_numa.c | 9 ++++++--- drivers/acpi/riscv/rhct.c | 7 ++++++- 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/arch/riscv/include/asm/acpi.h b/arch/riscv/include/asm/acpi.h index 6e13695120bc..f3520cc85af3 100644 --- a/arch/riscv/include/asm/acpi.h +++ b/arch/riscv/include/asm/acpi.h @@ -65,6 +65,7 @@ static inline u32 get_acpi_id_for_cpu(int cpu) { return acpi_cpu_get_madt_rintc(cpu)->uid; } +int acpi_get_cpu_uid(unsigned int cpu, u32 *uid); =20 int acpi_get_riscv_isa(struct acpi_table_header *table, unsigned int cpu, const char **isa); diff --git a/arch/riscv/kernel/acpi.c b/arch/riscv/kernel/acpi.c index 71698ee11621..322ea92aa39f 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 bu= s, } =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) + 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..6a2d4289f806 100644 --- a/arch/riscv/kernel/acpi_numa.c +++ b/arch/riscv/kernel/acpi_numa.c @@ -37,11 +37,14 @@ static int __init acpi_numa_get_nid(unsigned int cpu) =20 static inline int get_cpu_for_acpi_id(u32 uid) { - int cpu; + u32 cpu_uid; + int ret; =20 - for (cpu =3D 0; cpu < nr_cpu_ids; cpu++) - if (uid =3D=3D get_acpi_id_for_cpu(cpu)) + for (int cpu =3D 0; cpu < nr_cpu_ids; cpu++) { + 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/riscv/rhct.c b/drivers/acpi/riscv/rhct.c index caa2c16e1697..8f3f38c64a88 100644 --- a/drivers/acpi/riscv/rhct.c +++ b/drivers/acpi/riscv/rhct.c @@ -44,10 +44,15 @@ int acpi_get_riscv_isa(struct acpi_table_header *table,= unsigned int cpu, const struct acpi_rhct_isa_string *isa_node; struct acpi_table_rhct *rhct; u32 *hart_info_node_offset; - u32 acpi_cpu_id =3D get_acpi_id_for_cpu(cpu); + u32 acpi_cpu_id; + int ret; =20 BUG_ON(acpi_disabled); =20 + ret =3D acpi_get_cpu_uid(cpu, &acpi_cpu_id); + if (ret !=3D 0) + return ret; + if (!table) { rhct =3D acpi_get_rhct(); if (!rhct) --=20 2.17.1 From nobody Wed Apr 1 22:25:39 2026 Received: from canpmsgout05.his.huawei.com (canpmsgout05.his.huawei.com [113.46.200.220]) (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 946683A3E9A; Wed, 1 Apr 2026 08:16:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.220 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775031418; cv=none; b=XE3CeDo0Q+L18OV6L/v6mS7akROfvTSinqEC6ipFa4CZC9zR1OQDUKzWQAxGyE+sbEugjJcKYydswO9t6NRURTC2tbEXNplzhjFFoizHirdVaGm/HIzKv15ymyxBNcTRCldKtOXUD+MxJy/GCIug2D5QKwI56/4Uv0XRunOFPWU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775031418; c=relaxed/simple; bh=9PXgtATdM0hsyiohw3KRQdbtl/M0iHcE3pB9laQWxPE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=B7s6N1OhJxMUihhwEfcYvwpAlolwlzs+Nro4GlGBO0UY8+yPQbnUWhhgiAg2WKIQzkypdBN9GXODwASPfmgutsXS6rAPCH6zkR68UhIRPZG/oCKicuZmbRpTlh+ZXZLXcKxW7IOmLPlPFSzjeahGRrVimjRWfPl4Ulaofqk8SMQ= 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; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=I76d5Qkg; arc=none smtp.client-ip=113.46.200.220 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="I76d5Qkg" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=/bDHT0vostLWviBcH0LGnrUXN/7+wtQhJKC8xvlaZ1w=; b=I76d5QkgB06G/X/wos41vVtgRQepXQMzc5bCmZUjG61rsMvqBqMxjyiWV13dSj/N0vARfMR+I TIpo+e0ZZ/G2PYTKyAK+od5BAX4GJxZnIIHvWHRL80Tl9ySzHsM4ReaK/m6QcwIZU7CfdK4/sr4 hK45B5FTc4PW95z2AIDDxVc= Received: from mail.maildlp.com (unknown [172.19.162.144]) by canpmsgout05.his.huawei.com (SkyGuard) with ESMTPS id 4flyPG5v0Lz12LJb; Wed, 1 Apr 2026 16:11:30 +0800 (CST) Received: from kwepemk500009.china.huawei.com (unknown [7.202.194.94]) by mail.maildlp.com (Postfix) with ESMTPS id 225C340538; Wed, 1 Apr 2026 16:16:54 +0800 (CST) Received: from localhost.localdomain (10.50.163.32) by kwepemk500009.china.huawei.com (7.202.194.94) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Wed, 1 Apr 2026 16:16:52 +0800 From: Chengwen Feng To: Bjorn Helgaas , Catalin Marinas , Will Deacon , "Rafael J . Wysocki" CC: Jonathan Corbet , WANG Xuerui , Thomas Gleixner , Dave Hansen , "H . Peter Anvin" , Juergen Gross , Boris Ostrovsky , Len Brown , Sunil V L , Mark Rutland , Jonathan Cameron , 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: [PATCH RESEND v10 4/8] x86/acpi: Add acpi_get_cpu_uid() for unified ACPI CPU UID retrieval Date: Wed, 1 Apr 2026 16:16:36 +0800 Message-ID: <20260401081640.26875-5-fengchengwen@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20260401081640.26875-1-fengchengwen@huawei.com> References: <20260401081640.26875-1-fengchengwen@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: kwepems200001.china.huawei.com (7.221.188.67) To kwepemk500009.china.huawei.com (7.202.194.94) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" As a step towards unifying the interface for retrieving ACPI CPU UID across architectures, introduce a new function acpi_get_cpu_uid() for x86. While at it, add input validation to make the code more robust. Update Xen-related code to use acpi_get_cpu_uid() instead of the legacy cpu_acpi_id() function, and remove the now-unused cpu_acpi_id() to clean up redundant code. Cc: stable@vger.kernel.org Signed-off-by: Chengwen Feng Reviewed-by: Jonathan Cameron Reviewed-by: Juergen Gross --- arch/x86/include/asm/acpi.h | 2 ++ arch/x86/include/asm/cpu.h | 1 - arch/x86/include/asm/smp.h | 1 - arch/x86/kernel/acpi/boot.c | 20 ++++++++++++++++++++ arch/x86/xen/enlighten_hvm.c | 5 +++-- 5 files changed, 25 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm/acpi.h b/arch/x86/include/asm/acpi.h index a03aa6f999d1..92b5c27c4fea 100644 --- a/arch/x86/include/asm/acpi.h +++ b/arch/x86/include/asm/acpi.h @@ -157,6 +157,8 @@ static inline bool acpi_has_cpu_in_madt(void) return !!acpi_lapic; } =20 +int acpi_get_cpu_uid(unsigned int cpu, u32 *uid); + #define ACPI_HAVE_ARCH_SET_ROOT_POINTER static __always_inline void acpi_arch_set_root_pointer(u64 addr) { diff --git a/arch/x86/include/asm/cpu.h b/arch/x86/include/asm/cpu.h index ad235dda1ded..57a0786dfd75 100644 --- a/arch/x86/include/asm/cpu.h +++ b/arch/x86/include/asm/cpu.h @@ -11,7 +11,6 @@ =20 #ifndef CONFIG_SMP #define cpu_physical_id(cpu) boot_cpu_physical_apicid -#define cpu_acpi_id(cpu) 0 #endif /* CONFIG_SMP */ =20 #ifdef CONFIG_HOTPLUG_CPU diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h index 84951572ab81..05d1d479b4cf 100644 --- a/arch/x86/include/asm/smp.h +++ b/arch/x86/include/asm/smp.h @@ -130,7 +130,6 @@ __visible void smp_call_function_interrupt(struct pt_re= gs *regs); __visible void smp_call_function_single_interrupt(struct pt_regs *r); =20 #define cpu_physical_id(cpu) per_cpu(x86_cpu_to_apicid, cpu) -#define cpu_acpi_id(cpu) per_cpu(x86_cpu_to_acpiid, cpu) =20 /* * This function is needed by all SMP systems. It must _always_ be valid diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c index a3f2fb1fea1b..ceba24f65ae3 100644 --- a/arch/x86/kernel/acpi/boot.c +++ b/arch/x86/kernel/acpi/boot.c @@ -1848,3 +1848,23 @@ void __iomem * (*acpi_os_ioremap)(acpi_physical_addr= ess phys, acpi_size size) =3D x86_acpi_os_ioremap; EXPORT_SYMBOL_GPL(acpi_os_ioremap); #endif + +int acpi_get_cpu_uid(unsigned int cpu, u32 *uid) +{ + u32 acpi_id; + + if (cpu >=3D nr_cpu_ids) + return -EINVAL; + +#ifdef CONFIG_SMP + acpi_id =3D per_cpu(x86_cpu_to_acpiid, cpu); + if (acpi_id =3D=3D CPU_ACPIID_INVALID) + return -ENODEV; +#else + acpi_id =3D 0; +#endif + + *uid =3D acpi_id; + return 0; +} +EXPORT_SYMBOL_GPL(acpi_get_cpu_uid); diff --git a/arch/x86/xen/enlighten_hvm.c b/arch/x86/xen/enlighten_hvm.c index fe57ff85d004..2f9fa27e5a3c 100644 --- a/arch/x86/xen/enlighten_hvm.c +++ b/arch/x86/xen/enlighten_hvm.c @@ -151,6 +151,7 @@ static void xen_hvm_crash_shutdown(struct pt_regs *regs) =20 static int xen_cpu_up_prepare_hvm(unsigned int cpu) { + u32 cpu_uid; int rc =3D 0; =20 /* @@ -161,8 +162,8 @@ static int xen_cpu_up_prepare_hvm(unsigned int cpu) */ xen_uninit_lock_cpu(cpu); =20 - if (cpu_acpi_id(cpu) !=3D CPU_ACPIID_INVALID) - per_cpu(xen_vcpu_id, cpu) =3D cpu_acpi_id(cpu); + if (acpi_get_cpu_uid(cpu, &cpu_uid) =3D=3D 0) + per_cpu(xen_vcpu_id, cpu) =3D cpu_uid; else per_cpu(xen_vcpu_id, cpu) =3D cpu; xen_vcpu_setup(cpu); --=20 2.17.1 From nobody Wed Apr 1 22:25:39 2026 Received: from canpmsgout02.his.huawei.com (canpmsgout02.his.huawei.com [113.46.200.217]) (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 61FC83AB298; Wed, 1 Apr 2026 08:16:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.217 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775031420; cv=none; b=h83O+PJm0KTklByPJ5hCyrBGTDzzcM+aKxZX5qBTFNfQxDC5VR6g1gWvtwwJUZAFY16waV5OH+IGl8MJPBM0RBjQE0sWJ1z0jhN4V0Dpsfh3AbYtLGn8k1HZiJ9/FKmP0qYdHPlGMMl5izjNBo2rRzPebJZGaxDtPFSOhlZ+Kek= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775031420; c=relaxed/simple; bh=425fWiSrilzQ1wl2CPxfhnZrrHqEHVxKbyTM+Z2Qq/M=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WbU7Sh1NVtcGO0Ixf5TczMq4I4ouK3I9tQ6cmXYB9em4UQKJCC/MC07zj3vThXzaBlsHfa//NZTO9PhbXGBtHgdJkKsEJhRmVKZvbhz8G7hVVz2v9RxdNAZKN67uxPddQ50FaiWh4ZqOJBoCrOlfxmQrHIvCafkgoekhrH+EScs= 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; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=gAhZczIG; arc=none smtp.client-ip=113.46.200.217 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="gAhZczIG" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=ANvjKw/V+x/xgnK84bsEKs2slfuc72S2wtUZ6Ltd7AU=; b=gAhZczIG65dC2yh+2aADvwVAp++19t5FyGF4ZzbeSLiKAirv37HFkiFuy/A1lWBlr5MpsM4Ut Lnhv1/GDpeZI1w99rpED8gfQlunCOXOTiUjR1yp3rBy23eO6v/Ttq6ZYJsfo+fm/1xgWotDODEb YV0jLZY6lrTP0qpYzZ1KoG4= Received: from mail.maildlp.com (unknown [172.19.162.140]) by canpmsgout02.his.huawei.com (SkyGuard) with ESMTPS id 4flyNW224WzcZxn; Wed, 1 Apr 2026 16:10:51 +0800 (CST) Received: from kwepemk500009.china.huawei.com (unknown [7.202.194.94]) by mail.maildlp.com (Postfix) with ESMTPS id BC54C203B2; Wed, 1 Apr 2026 16:16:55 +0800 (CST) Received: from localhost.localdomain (10.50.163.32) by kwepemk500009.china.huawei.com (7.202.194.94) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Wed, 1 Apr 2026 16:16:53 +0800 From: Chengwen Feng To: Bjorn Helgaas , Catalin Marinas , Will Deacon , "Rafael J . Wysocki" CC: Jonathan Corbet , WANG Xuerui , Thomas Gleixner , Dave Hansen , "H . Peter Anvin" , Juergen Gross , Boris Ostrovsky , Len Brown , Sunil V L , Mark Rutland , Jonathan Cameron , 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: [PATCH RESEND v10 5/8] ACPI: Centralize acpi_get_cpu_uid() declaration in include/linux/acpi.h Date: Wed, 1 Apr 2026 16:16:37 +0800 Message-ID: <20260401081640.26875-6-fengchengwen@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20260401081640.26875-1-fengchengwen@huawei.com> References: <20260401081640.26875-1-fengchengwen@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: kwepems200001.china.huawei.com (7.221.188.67) To kwepemk500009.china.huawei.com (7.202.194.94) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Centralize acpi_get_cpu_uid() in include/linux/acpi.h (global scope) and remove arch-specific declarations from arm64/loongarch/riscv/x86 asm/acpi.h. This unifies the interface across architectures and simplifies maintenance by eliminating duplicate prototypes. Cc: stable@vger.kernel.org Signed-off-by: Chengwen Feng Reviewed-by: Jonathan Cameron --- arch/arm64/include/asm/acpi.h | 1 - arch/loongarch/include/asm/acpi.h | 1 - arch/riscv/include/asm/acpi.h | 1 - arch/x86/include/asm/acpi.h | 2 -- include/linux/acpi.h | 11 +++++++++++ 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h index 2219a3301e72..bdb0ecf95b5c 100644 --- a/arch/arm64/include/asm/acpi.h +++ b/arch/arm64/include/asm/acpi.h @@ -118,7 +118,6 @@ static inline u32 get_acpi_id_for_cpu(unsigned int cpu) { return acpi_cpu_get_madt_gicc(cpu)->uid; } -int acpi_get_cpu_uid(unsigned int cpu, u32 *uid); int get_cpu_for_acpi_id(u32 uid); =20 static inline void arch_fix_phys_package_id(int num, u32 slot) { } diff --git a/arch/loongarch/include/asm/acpi.h b/arch/loongarch/include/asm= /acpi.h index 8bb101b4557e..7376840fa9f7 100644 --- a/arch/loongarch/include/asm/acpi.h +++ b/arch/loongarch/include/asm/acpi.h @@ -44,7 +44,6 @@ static inline u32 get_acpi_id_for_cpu(unsigned int cpu) { return acpi_core_pic[cpu_logical_map(cpu)].processor_id; } -int acpi_get_cpu_uid(unsigned int cpu, u32 *uid); =20 #endif /* !CONFIG_ACPI */ =20 diff --git a/arch/riscv/include/asm/acpi.h b/arch/riscv/include/asm/acpi.h index f3520cc85af3..6e13695120bc 100644 --- a/arch/riscv/include/asm/acpi.h +++ b/arch/riscv/include/asm/acpi.h @@ -65,7 +65,6 @@ static inline u32 get_acpi_id_for_cpu(int cpu) { return acpi_cpu_get_madt_rintc(cpu)->uid; } -int acpi_get_cpu_uid(unsigned int cpu, u32 *uid); =20 int acpi_get_riscv_isa(struct acpi_table_header *table, unsigned int cpu, const char **isa); diff --git a/arch/x86/include/asm/acpi.h b/arch/x86/include/asm/acpi.h index 92b5c27c4fea..a03aa6f999d1 100644 --- a/arch/x86/include/asm/acpi.h +++ b/arch/x86/include/asm/acpi.h @@ -157,8 +157,6 @@ static inline bool acpi_has_cpu_in_madt(void) return !!acpi_lapic; } =20 -int acpi_get_cpu_uid(unsigned int cpu, u32 *uid); - #define ACPI_HAVE_ARCH_SET_ROOT_POINTER static __always_inline void acpi_arch_set_root_pointer(u64 addr) { diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 4d2f0bed7a06..74a73f0e5944 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -324,6 +324,17 @@ int acpi_unmap_cpu(int cpu); =20 acpi_handle acpi_get_processor_handle(int cpu); =20 +/** + * acpi_get_cpu_uid() - Get ACPI Processor UID of from MADT table + * @cpu: Logical CPU number (0-based) + * @uid: Pointer to store ACPI Processor UID + * + * Return: 0 on success (ACPI Processor ID stored in *uid); + * -EINVAL if CPU number is invalid or out of range; + * -ENODEV if ACPI Processor UID for the CPU is not found. + */ +int acpi_get_cpu_uid(unsigned int cpu, u32 *uid); + #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC int acpi_get_ioapic_id(acpi_handle handle, u32 gsi_base, u64 *phys_addr); #endif --=20 2.17.1 From nobody Wed Apr 1 22:25:39 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=huawei.com ARC-Seal: i=1; a=rsa-sha256; t=1775031446; cv=none; d=zohomail.com; s=zohoarc; b=L48GlzZa6E+/FA1kq2aHQbZCCT4ZT++s7Nfbf35ULeeIr7C6fr3iLwBi2fWx3YTsD6UY0pGiU8gHs6FjeufgIsqxh4QS2aNIh4UUH2bN1tKZbLi6OoJeFmARbuFySN6Zj9OlojmCVATrr8HugmvMVT9t9nDuAMTnijOwZX35Ur8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775031446; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=zauzEDoW1iZZVg1rc8HmzuZCwLSftmOLfB8Jb8RY2BQ=; b=Z86z/hbBwD1kpAwkfrwYi17L7FkuW0SK96/MVKgGfvtwuSVtiZNZK2QkpV1ZOFZSChYszdbuhjNasLipPuDJlMt+I/AgkMQwLQDPkv7m6DOi5HEfnEtN2GZpSdpnL4c0Y0EksGUx2V+ROgO5NzwrgFl1NCxZviwhMPWL11jyc7Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1775031446168863.1621518397808; Wed, 1 Apr 2026 01:17:26 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1269885.1558797 (Exim 4.92) (envelope-from ) id 1w7ql6-0006UN-CI; Wed, 01 Apr 2026 08:17:04 +0000 Received: by outflank-mailman (output) from mailman id 1269885.1558797; Wed, 01 Apr 2026 08:17:04 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w7ql5-0006Sh-Vy; Wed, 01 Apr 2026 08:17:03 +0000 Received: by outflank-mailman (input) for mailman id 1269885; Wed, 01 Apr 2026 08:17:02 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w7ql4-0006M0-MF for xen-devel@lists.xenproject.org; Wed, 01 Apr 2026 08:17:02 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1w7ql4-003Ul3-0o for xen-devel@lists.xenproject.org; Wed, 01 Apr 2026 10:17:02 +0200 Received: from [10.42.69.1] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 69ccd472-5cb7-0a2a0a5109dd-0a2a4501cb74-40 for ; Wed, 01 Apr 2026 10:17:01 +0200 Received: from [113.46.200.222] (helo=canpmsgout07.his.huawei.com) by tlsNG-d62444.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.0) (envelope-from ) id 69ccd47a-6fc9-0a2a45010019-712ec8de30dc-3 for ; Wed, 01 Apr 2026 10:17:01 +0200 Received: from mail.maildlp.com (unknown [172.19.163.127]) by canpmsgout07.his.huawei.com (SkyGuard) with ESMTPS id 4flyNS2tVFzLlXm; Wed, 1 Apr 2026 16:10:48 +0800 (CST) Received: from kwepemk500009.china.huawei.com (unknown [7.202.194.94]) by mail.maildlp.com (Postfix) with ESMTPS id 6117940572; Wed, 1 Apr 2026 16:16:57 +0800 (CST) Received: from localhost.localdomain (10.50.163.32) by kwepemk500009.china.huawei.com (7.202.194.94) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Wed, 1 Apr 2026 16:16:55 +0800 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=dkim header.d=huawei.com header.i="@huawei.com" header.h=From dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=zauzEDoW1iZZVg1rc8HmzuZCwLSftmOLfB8Jb8RY2BQ=; b=J5TZKxoHIReSEQmbTRfXFVLNZ+/IUwuE+uW11i8+jkMuLeZGtwJVXLQfuq4LHOSczhwfghmzc YFCMaPt2RTCEgwugJISj0LKEbk2ZW0qVVKN1TRrnTPUfnEonx2LqeBG0wXshmZawXX2M7xbOaMf BcPDzWOBbKROUN5RO0vtU+I= From: Chengwen Feng To: Bjorn Helgaas , Catalin Marinas , Will Deacon , "Rafael J . Wysocki" CC: Jonathan Corbet , WANG Xuerui , Thomas Gleixner , Dave Hansen , "H . Peter Anvin" , Juergen Gross , Boris Ostrovsky , Len Brown , Sunil V L , Mark Rutland , Jonathan Cameron , 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: [PATCH RESEND v10 6/8] perf: arm_cspmu: Switch to acpi_get_cpu_uid() from get_acpi_id_for_cpu() Date: Wed, 1 Apr 2026 16:16:38 +0800 Message-ID: <20260401081640.26875-7-fengchengwen@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20260401081640.26875-1-fengchengwen@huawei.com> References: <20260401081640.26875-1-fengchengwen@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.50.163.32] X-ClientProxiedBy: kwepems200001.china.huawei.com (7.221.188.67) To kwepemk500009.china.huawei.com (7.202.194.94) X-purgate-ID: tlsNG-d62444/1775031421-B7CFA185-2B2C221B/0/0 X-purgate-type: clean X-purgate-size: 1347 X-ZohoMail-DKIM: pass (identity @huawei.com) X-ZM-MESSAGEID: 1775031448426154100 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Update arm_cspmu to use acpi_get_cpu_uid() instead of get_acpi_id_for_cpu(), aligning with unified ACPI CPU UID interface. No functional changes are introduced by this switch (valid inputs retain original behavior). Cc: stable@vger.kernel.org Signed-off-by: Chengwen Feng Reviewed-by: Jonathan Cameron --- drivers/perf/arm_cspmu/arm_cspmu.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/perf/arm_cspmu/arm_cspmu.c b/drivers/perf/arm_cspmu/ar= m_cspmu.c index 34430b68f602..ed72c3d1f796 100644 --- a/drivers/perf/arm_cspmu/arm_cspmu.c +++ b/drivers/perf/arm_cspmu/arm_cspmu.c @@ -1107,15 +1107,17 @@ static int arm_cspmu_acpi_get_cpus(struct arm_cspmu= *cspmu) { struct acpi_apmt_node *apmt_node; int affinity_flag; + u32 cpu_uid; int cpu; + int ret; =20 apmt_node =3D arm_cspmu_apmt_node(cspmu->dev); affinity_flag =3D apmt_node->flags & ACPI_APMT_FLAGS_AFFINITY; =20 if (affinity_flag =3D=3D ACPI_APMT_FLAGS_AFFINITY_PROC) { for_each_possible_cpu(cpu) { - if (apmt_node->proc_affinity =3D=3D - get_acpi_id_for_cpu(cpu)) { + ret =3D acpi_get_cpu_uid(cpu, &cpu_uid); + if (ret =3D=3D 0 && apmt_node->proc_affinity =3D=3D cpu_uid) { cpumask_set_cpu(cpu, &cspmu->associated_cpus); break; } --=20 2.17.1 From nobody Wed Apr 1 22:25:39 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=huawei.com ARC-Seal: i=1; a=rsa-sha256; t=1775031452; cv=none; d=zohomail.com; s=zohoarc; b=UKjQsc9OC0BiVA8caf2DpKfhguTO2xlnkjAi6q/8+/cY1I5luY4zMVm9d+9c11XrWXh5r3jG3gBmXSdJV/gByKfrSKT9RTO5E2r2TvVKAyNZ+nhY0SaFmuXTGNGWSLzyVDoLH0YAD6vrfcoRKcbEpx75QWOUfc08TENrthnfnN0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775031452; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=/eBsZSTPYF/YtxnkPhtkEULxH4VEHo0dKDplLzt2h+U=; b=eUW2CUrnR54jPMvqnxPDFBfKzToOcPUSQVg51E36QVPnnZmXOIq0FWtYbDcWSeXCvCjvQMZXH4TPGNjoBooOePX7yC8EZgcDfZtrB9jbj8uzapjCBSUWbzh+J/Ey32W5BnSdPMyGFfYL83/o1/ionLK5GW4BIH+2MmqzqjVKie8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1775031452597718.8986214750511; Wed, 1 Apr 2026 01:17:32 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1269886.1558802 (Exim 4.92) (envelope-from ) id 1w7ql6-0006fb-V4; Wed, 01 Apr 2026 08:17:04 +0000 Received: by outflank-mailman (output) from mailman id 1269886.1558802; Wed, 01 Apr 2026 08:17:04 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w7ql6-0006bx-NW; Wed, 01 Apr 2026 08:17:04 +0000 Received: by outflank-mailman (input) for mailman id 1269886; Wed, 01 Apr 2026 08:17:03 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w7ql5-0006Pe-Kq for xen-devel@lists.xenproject.org; Wed, 01 Apr 2026 08:17:03 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1w7ql4-003Ulf-WB for xen-devel@lists.xenproject.org; Wed, 01 Apr 2026 10:17:03 +0200 Received: from [10.42.69.9] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 69ccd474-bab6-0a2a0a5309dd-0a2a4509c454-34 for ; Wed, 01 Apr 2026 10:17:02 +0200 Received: from [113.46.200.219] (helo=canpmsgout04.his.huawei.com) by tlsNG-bad1c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.0) (envelope-from ) id 69ccd47b-bf79-0a2a45090019-712ec8db9016-3 for ; Wed, 01 Apr 2026 10:17:02 +0200 Received: from mail.maildlp.com (unknown [172.19.163.0]) by canpmsgout04.his.huawei.com (SkyGuard) with ESMTPS id 4flyNQ3F6jz1prLN; Wed, 1 Apr 2026 16:10:46 +0800 (CST) Received: from kwepemk500009.china.huawei.com (unknown [7.202.194.94]) by mail.maildlp.com (Postfix) with ESMTPS id 093EB40537; Wed, 1 Apr 2026 16:16:59 +0800 (CST) Received: from localhost.localdomain (10.50.163.32) by kwepemk500009.china.huawei.com (7.202.194.94) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Wed, 1 Apr 2026 16:16:57 +0800 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=dkim header.d=huawei.com header.i="@huawei.com" header.h=From dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=/eBsZSTPYF/YtxnkPhtkEULxH4VEHo0dKDplLzt2h+U=; b=ypbclQg4Iukdlkqpoizb0I/F7L+DePAd+M0//lXkMgfo2Tebtl3dWlIRb5T+BpmkoHuv3dAUf q4obfVRqfYA+w4THr01Bmp7st54V9VWVLRFBbSiDcMjxC61DIiVgmZCmNOX7nmSXAg0dF57r5Ul C2JQqU6Aei7BxV0EFNUv0ls= From: Chengwen Feng To: Bjorn Helgaas , Catalin Marinas , Will Deacon , "Rafael J . Wysocki" CC: Jonathan Corbet , WANG Xuerui , Thomas Gleixner , Dave Hansen , "H . Peter Anvin" , Juergen Gross , Boris Ostrovsky , Len Brown , Sunil V L , Mark Rutland , Jonathan Cameron , 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: [PATCH RESEND v10 7/8] ACPI: PPTT: Use acpi_get_cpu_uid() and remove get_acpi_id_for_cpu() Date: Wed, 1 Apr 2026 16:16:39 +0800 Message-ID: <20260401081640.26875-8-fengchengwen@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20260401081640.26875-1-fengchengwen@huawei.com> References: <20260401081640.26875-1-fengchengwen@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.50.163.32] X-ClientProxiedBy: kwepems200001.china.huawei.com (7.221.188.67) To kwepemk500009.china.huawei.com (7.202.194.94) X-purgate-ID: tlsNG-bad1c0/1775031422-2D951152-EC45E0DA/0/0 X-purgate-type: clean X-purgate-size: 7428 X-ZohoMail-DKIM: pass (identity @huawei.com) X-ZM-MESSAGEID: 1775031455020158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Update acpi/pptt.c to use acpi_get_cpu_uid() and remove unused get_acpi_id_for_cpu() from arm64/loongarch/riscv, completing PPTT's migration to the unified ACPI CPU UID interface Cc: stable@vger.kernel.org Signed-off-by: Chengwen Feng Reviewed-by: Jonathan Cameron --- arch/arm64/include/asm/acpi.h | 4 --- arch/loongarch/include/asm/acpi.h | 5 ---- arch/riscv/include/asm/acpi.h | 4 --- drivers/acpi/pptt.c | 50 +++++++++++++++++++++++-------- 4 files changed, 37 insertions(+), 26 deletions(-) diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h index bdb0ecf95b5c..8a54ca6ba602 100644 --- a/arch/arm64/include/asm/acpi.h +++ b/arch/arm64/include/asm/acpi.h @@ -114,10 +114,6 @@ static inline bool acpi_has_cpu_in_madt(void) } =20 struct acpi_madt_generic_interrupt *acpi_cpu_get_madt_gicc(int cpu); -static inline u32 get_acpi_id_for_cpu(unsigned int cpu) -{ - return acpi_cpu_get_madt_gicc(cpu)->uid; -} int get_cpu_for_acpi_id(u32 uid); =20 static inline void arch_fix_phys_package_id(int num, u32 slot) { } diff --git a/arch/loongarch/include/asm/acpi.h b/arch/loongarch/include/asm= /acpi.h index 7376840fa9f7..eda9d4d0a493 100644 --- a/arch/loongarch/include/asm/acpi.h +++ b/arch/loongarch/include/asm/acpi.h @@ -40,11 +40,6 @@ extern struct acpi_madt_core_pic acpi_core_pic[MAX_CORE_= PIC]; =20 extern int __init parse_acpi_topology(void); =20 -static inline u32 get_acpi_id_for_cpu(unsigned int cpu) -{ - return acpi_core_pic[cpu_logical_map(cpu)].processor_id; -} - #endif /* !CONFIG_ACPI */ =20 #define ACPI_TABLE_UPGRADE_MAX_PHYS ARCH_LOW_ADDRESS_LIMIT diff --git a/arch/riscv/include/asm/acpi.h b/arch/riscv/include/asm/acpi.h index 6e13695120bc..26ab37c171bc 100644 --- a/arch/riscv/include/asm/acpi.h +++ b/arch/riscv/include/asm/acpi.h @@ -61,10 +61,6 @@ static inline void arch_fix_phys_package_id(int num, u32= slot) { } =20 void acpi_init_rintc_map(void); struct acpi_madt_rintc *acpi_cpu_get_madt_rintc(int cpu); -static inline u32 get_acpi_id_for_cpu(int cpu) -{ - return acpi_cpu_get_madt_rintc(cpu)->uid; -} =20 int acpi_get_riscv_isa(struct acpi_table_header *table, unsigned int cpu, const char **isa); diff --git a/drivers/acpi/pptt.c b/drivers/acpi/pptt.c index de5f8c018333..7bd5bc1f225a 100644 --- a/drivers/acpi/pptt.c +++ b/drivers/acpi/pptt.c @@ -459,11 +459,14 @@ static void cache_setup_acpi_cpu(struct acpi_table_he= ader *table, { struct acpi_pptt_cache *found_cache; struct cpu_cacheinfo *this_cpu_ci =3D get_cpu_cacheinfo(cpu); - u32 acpi_cpu_id =3D get_acpi_id_for_cpu(cpu); + u32 acpi_cpu_id; struct cacheinfo *this_leaf; unsigned int index =3D 0; struct acpi_pptt_processor *cpu_node =3D NULL; =20 + if (acpi_get_cpu_uid(cpu, &acpi_cpu_id) !=3D 0) + return; + while (index < get_cpu_cacheinfo(cpu)->num_leaves) { this_leaf =3D this_cpu_ci->info_list + index; found_cache =3D acpi_find_cache_node(table, acpi_cpu_id, @@ -546,7 +549,10 @@ static int topology_get_acpi_cpu_tag(struct acpi_table= _header *table, unsigned int cpu, int level, int flag) { struct acpi_pptt_processor *cpu_node; - u32 acpi_cpu_id =3D get_acpi_id_for_cpu(cpu); + u32 acpi_cpu_id; + + if (acpi_get_cpu_uid(cpu, &acpi_cpu_id) !=3D 0) + return -ENOENT; =20 cpu_node =3D acpi_find_processor_node(table, acpi_cpu_id); if (cpu_node) { @@ -614,18 +620,22 @@ static int find_acpi_cpu_topology_tag(unsigned int cp= u, int level, int flag) * * Check the node representing a CPU for a given flag. * - * Return: -ENOENT if the PPTT doesn't exist, the CPU cannot be found or - * the table revision isn't new enough. + * Return: -ENOENT if can't get CPU's ACPI Processor UID, the PPTT doesn't + * exist, the CPU cannot be found or the table revision isn't new + * enough. * 1, any passed flag set * 0, flag unset */ 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 re= v, u32 flag) * in the PPTT. Errors caused by lack of a PPTT table, or otherwise, retur= n 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 n= o PPTT + * processor struct found. * 0 on success. */ int acpi_get_cache_info(unsigned int cpu, unsigned int *levels, @@ -671,7 +682,9 @@ int acpi_get_cache_info(unsigned int cpu, unsigned int = *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; + cpu_node =3D acpi_find_processor_node(table, acpi_cpu_id); if (!cpu_node) return -ENOENT; @@ -780,8 +793,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 +811,9 @@ 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; + cpu_node =3D acpi_find_processor_node(table, acpi_cpu_id); if (!cpu_node || !cpu_node->parent) return -ENOENT; @@ -872,7 +888,9 @@ static void acpi_pptt_get_child_cpus(struct acpi_table_= 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; + cpu_node =3D acpi_find_processor_node(table_hdr, acpi_id); =20 while (cpu_node) { @@ -966,10 +984,13 @@ int find_acpi_cache_level_from_id(u32 cache_id) for_each_possible_cpu(cpu) { bool empty; int level =3D 1; - u32 acpi_cpu_id =3D get_acpi_id_for_cpu(cpu); + u32 acpi_cpu_id; struct acpi_pptt_cache *cache; struct acpi_pptt_processor *cpu_node; =20 + if (acpi_get_cpu_uid(cpu, &acpi_cpu_id) !=3D 0) + continue; + cpu_node =3D acpi_find_processor_node(table, acpi_cpu_id); if (!cpu_node) continue; @@ -1030,10 +1051,13 @@ int acpi_pptt_get_cpumask_from_cache_id(u32 cache_i= d, cpumask_t *cpus) for_each_possible_cpu(cpu) { bool empty; int level =3D 1; - u32 acpi_cpu_id =3D get_acpi_id_for_cpu(cpu); + u32 acpi_cpu_id; struct acpi_pptt_cache *cache; struct acpi_pptt_processor *cpu_node; =20 + if (acpi_get_cpu_uid(cpu, &acpi_cpu_id) !=3D 0) + continue; + cpu_node =3D acpi_find_processor_node(table, acpi_cpu_id); if (!cpu_node) continue; --=20 2.17.1 From nobody Wed Apr 1 22:25:39 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=huawei.com ARC-Seal: i=1; a=rsa-sha256; t=1775031452; cv=none; d=zohomail.com; s=zohoarc; b=GoU0M2TSgNcrTbEA4+sI8I06Uvl+HufrwpgtyR0IQKFueT0CRjyGkqEyInoDst+6xtnQplXhArTaodFbPSYNxAO+048qafVrljy4hnKibT+NALrvJgCPxt9yV+Aqs7jahbCWubi3WIXutfSbnRK54Kv5SpcT+pITSGPDcqmW/1s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775031452; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=hE9w7JoPF7q5rCf6KhhEJWJqCptovuDZd/Iy/+tLfKo=; b=TZxMY/rc/ejlrBNK51e4OEzazqOzMzHsnR8lMx7gCt8KNJ1k4SYuW2RoHXA85u4opRjqZJlRAaOH7zoDSWzreeQGYnDf9HUlFd3frAKokvnkHkpUWnBAL2Dk0dVaWrjzIOS53GlPvFPtV/BGNUIEiCfQc+PWqgVFFWnjQPamNrw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1775031452938266.6645215265647; Wed, 1 Apr 2026 01:17:32 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1269891.1558819 (Exim 4.92) (envelope-from ) id 1w7qlB-0007JV-BO; Wed, 01 Apr 2026 08:17:09 +0000 Received: by outflank-mailman (output) from mailman id 1269891.1558819; Wed, 01 Apr 2026 08:17:09 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w7qlB-0007JI-6m; Wed, 01 Apr 2026 08:17:09 +0000 Received: by outflank-mailman (input) for mailman id 1269891; Wed, 01 Apr 2026 08:17:08 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1w7ql9-0007FB-V2 for xen-devel@lists.xenproject.org; Wed, 01 Apr 2026 08:17:08 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1w7ql9-003Ulf-Av for xen-devel@lists.xenproject.org; Wed, 01 Apr 2026 10:17:07 +0200 Received: from [10.42.69.12] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 69ccd47c-bab6-0a2a0a5309dd-0a2a450ccf46-30 for ; Wed, 01 Apr 2026 10:17:07 +0200 Received: from [113.46.200.220] (helo=canpmsgout05.his.huawei.com) by tlsNG-d25034.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.0) (envelope-from ) id 69ccd47d-f40c-0a2a450c0019-712ec8dcccee-3 for ; Wed, 01 Apr 2026 10:17:06 +0200 Received: from mail.maildlp.com (unknown [172.19.163.0]) by canpmsgout05.his.huawei.com (SkyGuard) with ESMTPS id 4flyPP34Mzz12LG4; Wed, 1 Apr 2026 16:11:37 +0800 (CST) Received: from kwepemk500009.china.huawei.com (unknown [7.202.194.94]) by mail.maildlp.com (Postfix) with ESMTPS id B64C540537; Wed, 1 Apr 2026 16:17:00 +0800 (CST) Received: from localhost.localdomain (10.50.163.32) by kwepemk500009.china.huawei.com (7.202.194.94) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Wed, 1 Apr 2026 16:16:58 +0800 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=dkim header.d=huawei.com header.i="@huawei.com" header.h=From dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=hE9w7JoPF7q5rCf6KhhEJWJqCptovuDZd/Iy/+tLfKo=; b=qLgUdTXyB2huFMYWwsBs6yJ/F+9lt0zGJ2NBn+WC66I23Xw4lD/MYLZdp/AaESL9MDwbvh4PG 4g/cCYoR/67GmTbgs1X5afshxewzUwAWGLnOlgBOHKQjEtF2bK4P57/PDC46EmJDfRwKl3h1FiZ k+9EKAAKSPQbPzHjYnS4Cu4= From: Chengwen Feng To: Bjorn Helgaas , Catalin Marinas , Will Deacon , "Rafael J . Wysocki" CC: Jonathan Corbet , WANG Xuerui , Thomas Gleixner , Dave Hansen , "H . Peter Anvin" , Juergen Gross , Boris Ostrovsky , Len Brown , Sunil V L , Mark Rutland , Jonathan Cameron , 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: [PATCH RESEND v10 8/8] PCI/TPH: Pass ACPI Processor UID to Cache Locality _DSM Date: Wed, 1 Apr 2026 16:16:40 +0800 Message-ID: <20260401081640.26875-9-fengchengwen@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20260401081640.26875-1-fengchengwen@huawei.com> References: <20260401081640.26875-1-fengchengwen@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.50.163.32] X-ClientProxiedBy: kwepems200001.china.huawei.com (7.221.188.67) To kwepemk500009.china.huawei.com (7.202.194.94) X-purgate-ID: tlsNG-d25034/1775031427-83F42A3D-4AA409DA/0/0 X-purgate-type: clean X-purgate-size: 5074 X-ZohoMail-DKIM: pass (identity @huawei.com) X-ZM-MESSAGEID: 1775031455123158500 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" pcie_tph_get_cpu_st() uses the Query Cache Locality Features _DSM [1] to retrieve the TPH Steering Tag for memory associated with the CPU identified by its "cpu_uid" parameter, a Linux logical CPU ID. The _DSM requires an ACPI Processor UID, which pcie_tph_get_cpu_st() previously assumed was the same as the Linux logical CPU ID. This is true on x86 but not on arm64, so pcie_tph_get_cpu_st() returned the wrong Steering Tag, resulting in incorrect TPH functionality on arm64. Convert the Linux logical CPU ID to the ACPI Processor UID with acpi_get_cpu_uid() before passing it to the _DSM. Additionally, rename the pcie_tph_get_cpu_st() parameter from "cpu_uid" to "cpu" to reflect that it represents a logical CPU ID (not an ACPI Processor UID). [1] According to ECN_TPH-ST_Revision_20200924 (https://members.pcisig.com/wg/PCI-SIG/document/15470), the input is defined as: "If the target is a processor, then this field represents the ACPI Processor UID of the processor as specified in the MADT. If the target is a processor container, then this field represents the ACPI Processor UID of the processor container as specified in the PPTT." Fixes: d2e8a34876ce ("PCI/TPH: Add Steering Tag support") Cc: stable@vger.kernel.org Signed-off-by: Chengwen Feng Reviewed-by: Jonathan Cameron Reviewed-by: Bjorn Helgaas --- Documentation/PCI/tph.rst | 4 ++-- drivers/pci/tph.c | 16 +++++++++++----- include/linux/pci-tph.h | 4 ++-- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Documentation/PCI/tph.rst b/Documentation/PCI/tph.rst index e8993be64fd6..b6cf22b9bd90 100644 --- a/Documentation/PCI/tph.rst +++ b/Documentation/PCI/tph.rst @@ -79,10 +79,10 @@ To retrieve a Steering Tag for a target memory associat= ed with a specific CPU, use the following function:: =20 int pcie_tph_get_cpu_st(struct pci_dev *pdev, enum tph_mem_type type, - unsigned int cpu_uid, u16 *tag); + unsigned int cpu, u16 *tag); =20 The `type` argument is used to specify the memory type, either volatile -or persistent, of the target memory. The `cpu_uid` argument specifies the +or persistent, of the target memory. The `cpu` argument specifies the CPU where the memory is associated to. =20 After the ST value is retrieved, the device driver can use the following diff --git a/drivers/pci/tph.c b/drivers/pci/tph.c index ca4f97be7538..b67c9ad14bda 100644 --- a/drivers/pci/tph.c +++ b/drivers/pci/tph.c @@ -236,21 +236,27 @@ static int write_tag_to_st_table(struct pci_dev *pdev= , int index, u16 tag) * with a specific CPU * @pdev: PCI device * @mem_type: target memory type (volatile or persistent RAM) - * @cpu_uid: associated CPU id + * @cpu: associated CPU id * @tag: Steering Tag to be returned * * Return the Steering Tag for a target memory that is associated with a - * specific CPU as indicated by cpu_uid. + * specific CPU as indicated by cpu. * * Return: 0 if success, otherwise negative value (-errno) */ int pcie_tph_get_cpu_st(struct pci_dev *pdev, enum tph_mem_type mem_type, - unsigned int cpu_uid, u16 *tag) + unsigned int cpu, u16 *tag) { #ifdef CONFIG_ACPI struct pci_dev *rp; acpi_handle rp_acpi_handle; union st_info info; + u32 cpu_uid; + int ret; + + ret =3D acpi_get_cpu_uid(cpu, &cpu_uid); + if (ret !=3D 0) + return ret; =20 rp =3D pcie_find_root_port(pdev); if (!rp || !rp->bus || !rp->bus->bridge) @@ -265,9 +271,9 @@ int pcie_tph_get_cpu_st(struct pci_dev *pdev, enum tph_= mem_type mem_type, =20 *tag =3D tph_extract_tag(mem_type, pdev->tph_req_type, &info); =20 - pci_dbg(pdev, "get steering tag: mem_type=3D%s, cpu_uid=3D%d, tag=3D%#04x= \n", + pci_dbg(pdev, "get steering tag: mem_type=3D%s, cpu=3D%d, tag=3D%#04x\n", (mem_type =3D=3D TPH_MEM_TYPE_VM) ? "volatile" : "persistent", - cpu_uid, *tag); + cpu, *tag); =20 return 0; #else diff --git a/include/linux/pci-tph.h b/include/linux/pci-tph.h index ba28140ce670..be68cd17f2f8 100644 --- a/include/linux/pci-tph.h +++ b/include/linux/pci-tph.h @@ -25,7 +25,7 @@ int pcie_tph_set_st_entry(struct pci_dev *pdev, unsigned int index, u16 tag); int pcie_tph_get_cpu_st(struct pci_dev *dev, enum tph_mem_type mem_type, - unsigned int cpu_uid, u16 *tag); + unsigned int cpu, u16 *tag); void pcie_disable_tph(struct pci_dev *pdev); int pcie_enable_tph(struct pci_dev *pdev, int mode); u16 pcie_tph_get_st_table_size(struct pci_dev *pdev); @@ -36,7 +36,7 @@ static inline int pcie_tph_set_st_entry(struct pci_dev *p= dev, { return -EINVAL; } static inline int pcie_tph_get_cpu_st(struct pci_dev *dev, enum tph_mem_type mem_type, - unsigned int cpu_uid, u16 *tag) + unsigned int cpu, u16 *tag) { return -EINVAL; } static inline void pcie_disable_tph(struct pci_dev *pdev) { } static inline int pcie_enable_tph(struct pci_dev *pdev, int mode) --=20 2.17.1