From: Qiang Ma <maqianga@uniontech.com>
To: chenhuacai@kernel.org, kernel@xen0n.name
Cc: loongarch@lists.linux.dev, linux-kernel@vger.kernel.org,
Qiang Ma <maqianga@uniontech.com>
Subject: [PATCH] LoongArch: Correct the calculation logic of thread_count
Date: Wed, 26 Nov 2025 10:36:31 +0800 [thread overview]
Message-ID: <20251126023631.3143434-1-maqianga@uniontech.com> (raw)
For thread_count, the current calculation method has a maximum of 255,
which may not be sufficient in the future. Therefore, we are correcting
it now.
Reference: SMBIOS Specification, 7.5 Processor Information (Type 4)[1]
[1]: https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.9.0.pdf
Signed-off-by: Qiang Ma <maqianga@uniontech.com>
---
arch/loongarch/kernel/setup.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/arch/loongarch/kernel/setup.c b/arch/loongarch/kernel/setup.c
index 25a87378e48e..760f5ce44384 100644
--- a/arch/loongarch/kernel/setup.c
+++ b/arch/loongarch/kernel/setup.c
@@ -56,6 +56,7 @@
#define SMBIOS_FREQLOW_MASK 0xFF
#define SMBIOS_CORE_PACKAGE_OFFSET 0x23
#define SMBIOS_THREAD_PACKAGE_OFFSET 0x25
+#define SMBIOS_THREAD_PACKAGE_2_OFFSET 0x2E
#define LOONGSON_EFI_ENABLE (1 << 3)
unsigned long fw_arg0, fw_arg1, fw_arg2;
@@ -120,13 +121,19 @@ static void __init parse_cpu_table(const struct dmi_header *dm)
{
long freq_temp = 0;
char *dmi_data = (char *)dm;
+ u8 thread_count;
+ u16 thread_count2;
freq_temp = ((*(dmi_data + SMBIOS_FREQHIGH_OFFSET) << 8) +
((*(dmi_data + SMBIOS_FREQLOW_OFFSET)) & SMBIOS_FREQLOW_MASK));
cpu_clock_freq = freq_temp * 1000000;
loongson_sysconf.cpuname = (void *)dmi_string_parse(dm, dmi_data[16]);
- loongson_sysconf.cores_per_package = *(dmi_data + SMBIOS_THREAD_PACKAGE_OFFSET);
+ thread_count = *(dmi_data + SMBIOS_THREAD_PACKAGE_OFFSET);
+ thread_count2 = *(u16 *)(dmi_data + SMBIOS_THREAD_PACKAGE_2_OFFSET);
+ if (thread_count != 0)
+ loongson_sysconf.cores_per_package = dm->length >= 0x30 && thread_count == 0xFF ?
+ thread_count2 : thread_count;
pr_info("CpuClock = %llu\n", cpu_clock_freq);
}
--
2.20.1
next reply other threads:[~2025-11-26 2:37 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-26 2:36 Qiang Ma [this message]
2025-11-26 4:49 ` Huacai Chen
2025-11-26 8:37 ` Qiang Ma
2025-11-26 5:27 ` Hengqi Chen
2025-11-26 9:47 ` Qiang Ma
2025-11-26 10:06 ` Hengqi Chen
2025-11-26 10:14 ` Qiang Ma
[not found] ` <d28a0011-5b9a-4e3e-a517-0c6d8933adae@uniontech.com>
2025-11-26 11:06 ` Qiang Ma
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251126023631.3143434-1-maqianga@uniontech.com \
--to=maqianga@uniontech.com \
--cc=chenhuacai@kernel.org \
--cc=kernel@xen0n.name \
--cc=linux-kernel@vger.kernel.org \
--cc=loongarch@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®