Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp3132157imm; Sun, 13 May 2018 05:02:55 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoosQtWRiooSUTYDDKTiaJei1yiBqERxzGVmpNKeC9fb7qjWBceTTqpaoKywhrtYk6GZfK4 X-Received: by 2002:a62:bd2:: with SMTP id 79-v6mr6362488pfl.4.1526212975157; Sun, 13 May 2018 05:02:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526212975; cv=none; d=google.com; s=arc-20160816; b=N6R3iSH2cmH0EtMyYzSxyUFkBR6MrLJloP1dkvO6mwuHeFDlFAvZdJ+0rr0ov2xW1X DPdsSc5TU1p9TwCj/IAETdm0tskyYzj37lgZQUmdCFESN+ioH9t8tYU23AcF91KFB/+l DZuvikHJEiBXjzxFZ662rZFvWipv/xd3h4vSRC9z4Q5tQ5jXxCCc9glpmCV4OkxmKcVk mNngP4dDJ7yXgm1oUSaLb5WZNBafNlsuRg9etBlVb0drlxStapx73MUqpUBcdnqoBXJd 5Mz4QhzdKUUCSPbRR2L588+K732JVOk+/FSALNcBEEy2q0a4h65g9oDbDkT6KPkSMUo+ UuLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:arc-authentication-results; bh=oK0BQm5e9GHlEtsA/QVWYcxIMCqySDjhijb57JsVu/Y=; b=hChBJQflCEOLt2JGj//2Aav//RLIJQ9yla/3kwcoFzi6pAEMq7fgMQOn+EG5hUrSdu Fl9VLYFB1Xkd8/MHXuIqzmjVleXSVIRPFMCoul/XOjhL5pMOHDQtJDDM+AGq1taUVCoV /ejc3JpPpuR04eEXUkLWQXemEpEkwSaAHLrbvYTrwocGGhN0//7ZJiy/MEeHlVtLH7Or Lpzlq7Mj2gxioW98a5EvqU6f2I7EhUaF+ZSlyMOc5ELFL119ZDuHn9K3lqCX+5UOiJTK e8WwIoKh/LEOWe1LYtcN6zDD8CdXxSdGtagb/HbVMA2oylAwBUnYeqHeKrzWVy6EdKKJ zh4A== 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 f28-v6si8517569plj.255.2018.05.13.05.02.40; Sun, 13 May 2018 05:02:55 -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 S1751617AbeEMMB5 (ORCPT + 99 others); Sun, 13 May 2018 08:01:57 -0400 Received: from terminus.zytor.com ([198.137.202.136]:41987 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751092AbeEMMB4 (ORCPT ); Sun, 13 May 2018 08:01:56 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id w4DC1png330215 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 13 May 2018 05:01:51 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w4DC1pLl330212; Sun, 13 May 2018 05:01:51 -0700 Date: Sun, 13 May 2018 05:01:51 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for David Wang Message-ID: Cc: tglx@linutronix.de, hpa@zytor.com, mingo@kernel.org, linux-kernel@vger.kernel.org, davidwang@zhaoxin.com Reply-To: linux-kernel@vger.kernel.org, davidwang@zhaoxin.com, hpa@zytor.com, mingo@kernel.org, tglx@linutronix.de In-Reply-To: <1525314766-18910-3-git-send-email-davidwang@zhaoxin.com> References: <1525314766-18910-3-git-send-email-davidwang@zhaoxin.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/cpu] x86/CPU: Move cpu_detect_cache_sizes() into init_intel_cacheinfo() Git-Commit-ID: 606e20959ef49f22cddb611f2cefef8e6501e3dd X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, T_DATE_IN_FUTURE_96_Q autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 606e20959ef49f22cddb611f2cefef8e6501e3dd Gitweb: https://git.kernel.org/tip/606e20959ef49f22cddb611f2cefef8e6501e3dd Author: David Wang AuthorDate: Thu, 3 May 2018 10:32:45 +0800 Committer: Thomas Gleixner CommitDate: Sun, 13 May 2018 12:06:12 +0200 x86/CPU: Move cpu_detect_cache_sizes() into init_intel_cacheinfo() There is no point in having the conditional cpu_detect_cache_sizes() call at the callsite of init_intel_cacheinfo(). Move it into init_intel_cacheinfo() and make init_intel_cacheinfo() void. [ tglx: Made the init_intel_cacheinfo() void as the return value was pointless. Adjust changelog accordingly ] Signed-off-by: David Wang Signed-off-by: Thomas Gleixner Cc: lukelin@viacpu.com Cc: qiyuanwang@zhaoxin.com Cc: gregkh@linuxfoundation.org Cc: brucechang@via-alliance.com Cc: timguo@zhaoxin.com Cc: cooperyan@zhaoxin.com Cc: hpa@zytor.com Cc: benjaminpan@viatech.com Link: https://lkml.kernel.org/r/1525314766-18910-3-git-send-email-davidwang@zhaoxin.com --- arch/x86/kernel/cpu/cacheinfo.c | 5 +++-- arch/x86/kernel/cpu/cpu.h | 2 +- arch/x86/kernel/cpu/intel.c | 13 +++---------- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/arch/x86/kernel/cpu/cacheinfo.c b/arch/x86/kernel/cpu/cacheinfo.c index 58d472c84ba2..38354c66df81 100644 --- a/arch/x86/kernel/cpu/cacheinfo.c +++ b/arch/x86/kernel/cpu/cacheinfo.c @@ -691,7 +691,7 @@ void init_amd_cacheinfo(struct cpuinfo_x86 *c) } } -unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c) +void init_intel_cacheinfo(struct cpuinfo_x86 *c) { /* Cache sizes */ unsigned int trace = 0, l1i = 0, l1d = 0, l2 = 0, l3 = 0; @@ -843,7 +843,8 @@ unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c) c->x86_cache_size = l3 ? l3 : (l2 ? l2 : (l1i+l1d)); - return l2; + if (!l2) + cpu_detect_cache_sizes(c); } static int __cache_amd_cpumap_setup(unsigned int cpu, int index, diff --git a/arch/x86/kernel/cpu/cpu.h b/arch/x86/kernel/cpu/cpu.h index efd6ef8ad14e..49bf8a080105 100644 --- a/arch/x86/kernel/cpu/cpu.h +++ b/arch/x86/kernel/cpu/cpu.h @@ -51,7 +51,7 @@ extern void init_scattered_cpuid_features(struct cpuinfo_x86 *c); extern u32 get_scattered_cpuid_leaf(unsigned int level, unsigned int sub_leaf, enum cpuid_regs_idx reg); -extern unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c); +extern void init_intel_cacheinfo(struct cpuinfo_x86 *c); extern void init_amd_cacheinfo(struct cpuinfo_x86 *c); extern int detect_num_cpu_cores(struct cpuinfo_x86 *c); diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c index b54535be254a..615870420be2 100644 --- a/arch/x86/kernel/cpu/intel.c +++ b/arch/x86/kernel/cpu/intel.c @@ -635,8 +635,6 @@ static void init_intel_misc_features(struct cpuinfo_x86 *c) static void init_intel(struct cpuinfo_x86 *c) { - unsigned int l2 = 0; - early_init_intel(c); intel_workarounds(c); @@ -659,13 +657,7 @@ static void init_intel(struct cpuinfo_x86 *c) #endif } - l2 = init_intel_cacheinfo(c); - - /* Detect legacy cache sizes if init_intel_cacheinfo did not */ - if (l2 == 0) { - cpu_detect_cache_sizes(c); - l2 = c->x86_cache_size; - } + init_intel_cacheinfo(c); if (c->cpuid_level > 9) { unsigned eax = cpuid_eax(10); @@ -678,7 +670,8 @@ static void init_intel(struct cpuinfo_x86 *c) set_cpu_cap(c, X86_FEATURE_LFENCE_RDTSC); if (boot_cpu_has(X86_FEATURE_DS)) { - unsigned int l1; + unsigned int l1, l2; + rdmsr(MSR_IA32_MISC_ENABLE, l1, l2); if (!(l1 & (1<<11))) set_cpu_cap(c, X86_FEATURE_BTS);