Received: by 10.192.165.148 with SMTP id m20csp435412imm; Wed, 25 Apr 2018 01:51:28 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/40IltQhuT4vcYidik71G3LqrjLUuBtbZPevRRzHbzagrDcM/ZShR/lD1pSqqbiQ19bK3N X-Received: by 2002:a17:902:8646:: with SMTP id y6-v6mr27854947plt.86.1524646288860; Wed, 25 Apr 2018 01:51:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524646288; cv=none; d=google.com; s=arc-20160816; b=bFV371Z3kbcyMWSw2vmkqB4s4SW+x+N4Y9JNMfdSlaJmx4PwDATH+q6RMrnmVuRsR6 ggi3j5xwWBMLiiEEi54OcT+opCfAktLGEopE2MJpjQmECembADfH9LfUUdZNHWzNMvV2 BCi2c5dztzOQP7xLEvZ4cWPu2L1ttKA/87d+FiQkMpOxAVNEjztfztdbcjF2RpEfuRSz pA1c9AVllTAc5BrIxEvasYjN0KFdCNk5VBcBuFJIhyLalor0/MVwru9rMJ3BPQxYsIyu wCu0kQihwvUaFjTyeoAw6MqiE3wjcHKx7PyFNwmYmclylbdTvjBpoqCNSvKu06nv8OQu 0RBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:arc-authentication-results; bh=W+eCz26tQVo5kel/JBlO61T41c708X2jQuWMUFZZdSk=; b=qROh920iJz+NrGCsVwSi6MzC8iAhGp58o7l1CYhlHwB+L1U50Kg7izUyPzIftIMMeK EU3wa9QMoNQv1rK9HWGMK8FTpWdQAo4r3zuV2hRWEJYVgnU6CccsIx5Jyla4iaqBiS3I 6TMZPm0pKxuJ8SXBtC12xTdwi8sTj70SyJYDNVgQQXixuuRzWE2Dpzj8d3nrhzdXXCoe jKXf3DUU5XPHLhayTanPqtRCT4255ci267ELa7iVwqN6P/+crq4RS0P2ruh9FNWE8Aa1 zNHXC/3yg/yqh1ylmQJ6dbrMVV0CJNtkG5vEWnyJN9wYPmW8Gu6a1Kbzt4gO05MmqToZ zShg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m10si13260608pge.245.2018.04.25.01.51.14; Wed, 25 Apr 2018 01:51:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751468AbeDYIsy (ORCPT + 99 others); Wed, 25 Apr 2018 04:48:54 -0400 Received: from ZXSHCAS1.zhaoxin.com ([203.148.12.81]:39353 "EHLO ZXSHCAS1.zhaoxin.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751276AbeDYIsk (ORCPT ); Wed, 25 Apr 2018 04:48:40 -0400 Received: from zxbjmbx3.zhaoxin.com (10.29.252.165) by ZXSHCAS1.zhaoxin.com (10.28.252.161) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1261.35; Wed, 25 Apr 2018 16:48:39 +0800 Received: from timguo-System-Product-Name.zhaoxin.com (10.29.8.54) by zxbjmbx3.zhaoxin.com (10.29.252.165) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1261.35; Wed, 25 Apr 2018 16:48:37 +0800 From: David Wang To: , , , , , CC: , , , , , , David Wang Subject: [PATCH v2] x86/centaur: report correct CPU/cache topology Date: Wed, 25 Apr 2018 16:48:30 +0800 Message-ID: <1524646110-4808-1-git-send-email-davidwang@zhaoxin.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.29.8.54] X-ClientProxiedBy: zxbjmbx1.zhaoxin.com (10.29.252.163) To zxbjmbx3.zhaoxin.com (10.29.252.165) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Centaur CPUs enumerate the cache topology in the same way as Intel CPUs, but the functionality is unused so far. The Centaur init code also misses to initialize x86_info::max_cores, so the CPU topology can't be described correctly. Initialize x86_cpuinfo:max_core and invoke init_intel_cacheinfo() to make CPU and cache topology information avaliable and correct. Signed-off-by: David Wang Changes from v1 to v2: *1 replace centaur_num_cpu_cores with early_init_centaur_mc according to suggestions from tglx; *2 call cpu_detect_cache_sizes when init_intel_cacheinfo returns 0. For some very old Centaur CPUs can't support the mechanisms defined in init_ intel_cacheinfo. --- arch/x86/kernel/cpu/centaur.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/arch/x86/kernel/cpu/centaur.c b/arch/x86/kernel/cpu/centaur.c index 80d5110..367540b 100644 --- a/arch/x86/kernel/cpu/centaur.c +++ b/arch/x86/kernel/cpu/centaur.c @@ -96,8 +96,25 @@ enum { EAMD3D = 1<<20, }; +static void early_init_centaur_mc(struct cpuinfo_x86 *c) +{ +#ifdef CONFIG_SMP + unsigned int eax, ebx, ecx, edx; + + if (c->cpuid_level < 4) + return; + + cpuid_count(4, 0, &eax, &ebx, &ecx, &edx); + if (eax & 0x1f) + c->x86_max_cores = (eax >> 26) + 1; + else + return; +#endif +} + static void early_init_centaur(struct cpuinfo_x86 *c) { + early_init_centaur_mc(c); switch (c->x86) { #ifdef CONFIG_X86_32 case 5: @@ -146,6 +163,7 @@ static void centaur_detect_vmx_virtcap(struct cpuinfo_x86 *c) static void init_centaur(struct cpuinfo_x86 *c) { + unsigned int l2 = 0; #ifdef CONFIG_X86_32 char *name; u32 fcr_set = 0; @@ -161,6 +179,17 @@ static void init_centaur(struct cpuinfo_x86 *c) #endif early_init_centaur(c); + l2 = init_intel_cacheinfo(c); + + /* Detect legacy cache sizes if init_intel_cacheinfo did not */ + if (l2 == 0) { + cpu_detect_cache_sizes(c); + } + +#ifdef CONFIG_X86_32 + detect_ht(c); +#endif + if (c->cpuid_level > 9) { unsigned int eax = cpuid_eax(10); -- 1.9.1