From nobody Mon Feb 9 06:31:22 2026 Received: from o47.p25.mailjet.com (o47.p25.mailjet.com [185.189.236.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CC40028B7DA for ; Fri, 23 Jan 2026 15:56:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.189.236.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769183793; cv=none; b=dTWMZTme7hOniSroLdpWF5MF90m4z1Y78nqUyrr+0IF5rBd/sFGNeTWaT2AOxjKYGQvZRdvntniOb1T20vn6bh6SPd7I0ZUe9bkg6r3VmPziK2b0BRhc+pWGXs97NsJzHVE9cFuvAPKfJ58sJ3YxS8wKOPDF4A1xf0i/54upGrQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769183793; c=relaxed/simple; bh=n625F9iOcmfm4oeosR440PIXnRGSOWmz0lx0rm52p6Y=; h=Message-Id:MIME-Version:From:To:Subject:Date:Cc; b=GZG8KTOfcEGldM2ubCmtKPxFL8ypdLxApcB9lYIvVrXiSP45cUA8ZrCLRKly//VG/VlxLiWEotz4svSOKvMT+kI52SlRBRn0q1kZo4Pi7BL6+9Eoyg1bVBIgaXZUQUawba0ETJ7rrW/q3CfNqe4ei9tzGHBCwurVhaOsdZk9b7Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=csmantle.top; spf=pass smtp.mailfrom=a3364097.bnc3.mailjet.com; dkim=pass (2048-bit key) header.d=csmantle.top header.i=rong.bao@csmantle.top header.b=Fdk9LfFq; arc=none smtp.client-ip=185.189.236.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=csmantle.top Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=a3364097.bnc3.mailjet.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=csmantle.top header.i=rong.bao@csmantle.top header.b="Fdk9LfFq" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; q=dns/txt; d=csmantle.top; i=rong.bao@csmantle.top; s=mailjet; x=1769190989; h=message-id:mime-version:from:from:to:to:subject:subject:date:date:list-unsubscribe-post:list-unsubscribe: cc:feedback-id:x-csa-complaints:x-mj-mid:x-mj-smtpguid:x-report-abuse-to: content-transfer-encoding; bh=n625F9iOcmfm4oeosR440PIXnRGSOWmz0lx0rm52p6Y=; b=Fdk9LfFqKD2ek1jSF1tpvPpHqL+XvJpKQbCnmB0sKpddPCBrD9AzyAqGg HsSiptUEfoN5JIBA9SvcS7WqjmyNF10AKe1KnZXkcz2ItJwNxPJ/flx6R8bF CL51dR8iF7uQeZog2EN7KXf5tdQxslxvq5wEw3e4wAx+ZN+NN6hU1IZkdzGC nDD0E72URA7MlpV00iCNNrRTa1vhERMm1i8AwzEItff5PrZNgeH/3CCcW4gM pLkzKbJT2XZjh140Etx4Hxf2/We5uy6Zggasn6HOF1EE6M4hp8kPQ/H9Ue6h 7dkseVprhzUOVS3U2lsDKWG7AXJhFA0rwH3ddBlyeHINQ== Message-Id: <7e6489c0.AWoAAI2o0T8AAAAAAAAAA-ma1p4AAYKJPtkAAAAAADNVAQBpc5ot@mailjet.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Rong Bao To: Huacai Chen Subject: [PATCH] loongarch: retrieve CPU package ID from PPTT when available Date: Fri, 23 Jan 2026 23:56:06 +0800 List-Unsubscribe-Post: List-Unsubscribe=One-Click Cc: Mingcong Bai , Kexy Biscuit , Rong Bao , stable@vger.kernel.org, WANG Xuerui , Yuli Wang , Yanteng Si , Masahiro Yamada , Hongliang Wang , Thierry Reding , Tianyang Zhang , loongarch@lists.linux.dev, linux-kernel@vger.kernel.org Feedback-Id: 42.3364097.3062169:MJ X-CSA-Complaints: csa-complaints@eco.de X-MJ-Mid: AWoAAI2o0T8AAAAAAAAAA-ma1p4AAYKJPtkAAAAAADNVAQBpc5otyAOVyTw8R6qDsqDIdVESswAuuZk X-MJ-SMTPGUID: e6c17ccd-6fab-4083-aa61-d129a700786e X-REPORT-ABUSE-TO: Message sent by Mailjet please report to abuse@mailjet.com with a copy of the message Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Currently, the LoongArch CPU topology initialization code calculates each core's package ID by dividing its physical ID by loongson_sysconf.cores_per_package. This relies on the assumption that cores_per_package counts in the same domain as physical IDs. On Loongson 3B6000 (XB612B0V_1.2), cores_per_package matches the visible core count -- 24 in this case. However, the physical IDs range from 0 to 31 in a noncontiguous fashion: $ cat /proc/cpuinfo | grep -i -F 'global_id' global_id : 0 global_id : 1 global_id : 4 global_id : 5 global_id : 6 global_id : 7 global_id : 8 global_id : 9 global_id : 10 global_id : 11 global_id : 14 global_id : 15 global_id : 16 global_id : 17 global_id : 20 global_id : 21 global_id : 22 global_id : 23 global_id : 26 global_id : 27 global_id : 28 global_id : 29 global_id : 30 global_id : 31 Retrieve the exact package ID from ACPI PPTT when available, in the same style as retrieving the core ID and thread ID in parse_acpi_topology(). Use this information in loongson_init_secondary() when PPTT readout is successful. The original division logic is kept as a fallback. Cc: stable@vger.kernel.org Signed-off-by: Rong Bao --- arch/loongarch/kernel/acpi.c | 9 ++++++++- arch/loongarch/kernel/smp.c | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/arch/loongarch/kernel/acpi.c b/arch/loongarch/kernel/acpi.c index 1367ca759468..82c7ffd4f1ac 100644 --- a/arch/loongarch/kernel/acpi.c +++ b/arch/loongarch/kernel/acpi.c @@ -176,7 +176,7 @@ int pptt_enabled; =20 int __init parse_acpi_topology(void) { - int cpu, topology_id; + int cpu, topology_id, package_id; =20 for_each_possible_cpu(cpu) { topology_id =3D find_acpi_cpu_topology(cpu, 0); @@ -194,6 +194,13 @@ int __init parse_acpi_topology(void) =20 cpu_data[cpu].core =3D topology_id; } + + package_id =3D find_acpi_cpu_topology_package(cpu); + if (package_id < 0) { + pr_warn("Invalid BIOS PPTT\n"); + return -ENOENT; + } + cpu_data[cpu].package =3D package_id; } =20 pptt_enabled =3D 1; diff --git a/arch/loongarch/kernel/smp.c b/arch/loongarch/kernel/smp.c index 8b2fcb3fb874..409e49d4da37 100644 --- a/arch/loongarch/kernel/smp.c +++ b/arch/loongarch/kernel/smp.c @@ -412,7 +412,7 @@ void loongson_init_secondary(void) numa_add_cpu(cpu); #endif per_cpu(cpu_state, cpu) =3D CPU_ONLINE; - cpu_data[cpu].package =3D + cpu_data[cpu].package =3D pptt_enabled ? cpu_data[cpu].package : cpu_logical_map(cpu) / loongson_sysconf.cores_per_package; cpu_data[cpu].core =3D pptt_enabled ? cpu_data[cpu].core : cpu_logical_map(cpu) % loongson_sysconf.cores_per_package; --=20 2.52.0