From nobody Tue Nov 26 11:34:19 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 4C4411684A5; Fri, 18 Oct 2024 03:59:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729223989; cv=none; b=mjxotjcXu2WujysICbasfDo9XkZkIorH0Rym2pW6duGchtzlFfLheLmTL7KgqekW9BUdOaGZw5oO4nZjDIb7kd5ipAbnMSA9zumuUhE4Aba+TJx8FSn1ZC6Cb+vuQd1gH7UhFfZOidicqV3vgVGMeO4iA2MLJhlNLivGSY2j0Ys= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729223989; c=relaxed/simple; bh=kQ5HXg7ckmYX9fdJDxid/fSA00OhvaOTWPV/xGVPYWo=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=RZfIK5J/7v7eM/yUowG0vVLw/5s/CzakzOMT8p1vGzt+4jX1hOQfphAKM1w+yzuDmdFoxHLmPvrXv0YlHbk86ND7NoqCntnZi7U9vcYnWRAW+55axBeMeBnU0rEAAmg4Yl1NuyNBnxgUVK2sgz5hVGXbrAVhOI5extE3XUyy+cI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2BCDCC4CEC3; Fri, 18 Oct 2024 03:59:45 +0000 (UTC) From: Huacai Chen To: Huacai Chen Cc: loongarch@lists.linux.dev, Xuefeng Li , Guo Ren , Xuerui Wang , Jiaxun Yang , linux-kernel@vger.kernel.org, loongson-kernel@lists.loongnix.cn, Huacai Chen , stable@vger.kernel.org, Chao Li Subject: [PATCH] LoongArch: Get correct cores_per_package for SMT systems Date: Fri, 18 Oct 2024 11:59:20 +0800 Message-ID: <20241018035920.1059661-1-chenhuacai@loongson.cn> X-Mailer: git-send-email 2.43.5 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In loongson_sysconf, The "core" of cores_per_node and cores_per_package stands for a logical core, which means in a SMT system it stands for a thread indeed. This information is gotten from SMBIOS Type4 Structure, so in order to get a correct cores_per_package for both SMT and non-SMT systems in parse_cpu_table() we should use SMBIOS_THREAD_PACKAGE_OFFSET instead of SMBIOS_CORE_PACKAGE_OFFSET. Cc: stable@vger.kernel.org Reported-by: Chao Li Tested-by: Chao Li Signed-off-by: Huacai Chen --- arch/loongarch/kernel/setup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/loongarch/kernel/setup.c b/arch/loongarch/kernel/setup.c index 00e307203ddb..cbd3c09a93c1 100644 --- a/arch/loongarch/kernel/setup.c +++ b/arch/loongarch/kernel/setup.c @@ -55,6 +55,7 @@ #define SMBIOS_FREQHIGH_OFFSET 0x17 #define SMBIOS_FREQLOW_MASK 0xFF #define SMBIOS_CORE_PACKAGE_OFFSET 0x23 +#define SMBIOS_THREAD_PACKAGE_OFFSET 0x25 #define LOONGSON_EFI_ENABLE (1 << 3) =20 unsigned long fw_arg0, fw_arg1, fw_arg2; @@ -125,7 +126,7 @@ static void __init parse_cpu_table(const struct dmi_hea= der *dm) cpu_clock_freq =3D freq_temp * 1000000; =20 loongson_sysconf.cpuname =3D (void *)dmi_string_parse(dm, dmi_data[16]); - loongson_sysconf.cores_per_package =3D *(dmi_data + SMBIOS_CORE_PACKAGE_O= FFSET); + loongson_sysconf.cores_per_package =3D *(dmi_data + SMBIOS_THREAD_PACKAGE= _OFFSET); =20 pr_info("CpuClock =3D %llu\n", cpu_clock_freq); } --=20 2.43.5 diff --git a/arch/loongarch/include/asm/bootinfo.h b/arch/loongarch/include= /asm/bootinfo.h index 6d5846dd075c..7657e016233f 100644 --- a/arch/loongarch/include/asm/bootinfo.h +++ b/arch/loongarch/include/asm/bootinfo.h @@ -26,6 +26,10 @@ struct loongson_board_info { =20 #define NR_WORDS DIV_ROUND_UP(NR_CPUS, BITS_PER_LONG) =20 +/* + * The "core" of cores_per_node and cores_per_package stands for a + * logical core, which means in a SMT system it stands for a thread. + */ struct loongson_system_configuration { int nr_cpus; int nr_nodes;