Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp3247693imm; Sun, 13 May 2018 07:19:19 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqju8KHlSZYldwagaSJV3QyqUDgRD7/OCBhnAAryHF0AnCoorUDSCK4OCYlCSABegkLpb/T X-Received: by 2002:a63:7159:: with SMTP id b25-v6mr5414575pgn.194.1526221159079; Sun, 13 May 2018 07:19:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526221159; cv=none; d=google.com; s=arc-20160816; b=k+myjPzEw8YsmuU9liwFFoE7D9zh77jpQYg2N6ycDkqMHZyDBryL9hUbYCZULDsyui G133GxbUtQw484thJ9lBYhEK02NG0wi/lCnD4iTleZGsciiEbr3ZJhu5Wzc7J1oDrNk0 KX9WyVrQwy364j7usi2HXVy5HFvGTVqDHbmyWahjamqtsGz6FeiKgy5u48IB7fF5gj2v H+fTWPueUCBP7iajjHeGLGs5WgiYwlASdgXNyl8oaEX0+DKSRR/hljSCo0swSLz0T90h 2SX38PoZdU6Z+oL/XBeT+sh4OOsffg3YT/AKzVxGjBjg6Di00J+en2hHpHNKhUvZWO45 ebfQ== 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=YPVkxUpxfKbwF0yep3dSv8DnNus6A600VRZQmPpTP1w=; b=qe8eWi7/5W0V+y665Nqbn5d/QLtvo37Ab1kh8t5zfpp5N4dtbQwgNFZwPH56e0AP/m ix0onuiEE3snCpfhvSZ3deHoHLjxBNXJOnbD3UmhtKo617Me3Mytr9TSvDf2oodyDeAO yxSSi85CxXDQWOa3XnawTGq1C9i+KwmxnC2V24/0zmAXCMmbVQl8hR4r7E/DyBsY7qCP C21a4R1Lj29NaGVrkp/kqtNwuXc2NwZ+Z6ykZ/EEhPL2fmaBdMs4w9OOF3cwRb7ZXyAS MNJ16G/QFbHqBPlGErk/3cvNrKYWN99A7bCKQAAzS7fzfWUxpAbtNiNmF6aBYI9SezKF xsRA== 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 w22-v6si7321126plq.196.2018.05.13.07.19.03; Sun, 13 May 2018 07:19:19 -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 S1751700AbeEMOSy (ORCPT + 99 others); Sun, 13 May 2018 10:18:54 -0400 Received: from terminus.zytor.com ([198.137.202.136]:38065 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751263AbeEMOSx (ORCPT ); Sun, 13 May 2018 10:18:53 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id w4DEIkWN367302 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 13 May 2018 07:18:46 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w4DEIk9O367299; Sun, 13 May 2018 07:18:46 -0700 Date: Sun, 13 May 2018 07:18:46 -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: mingo@kernel.org, linux-kernel@vger.kernel.org, davidwang@zhaoxin.com, tglx@linutronix.de, hpa@zytor.com Reply-To: tglx@linutronix.de, davidwang@zhaoxin.com, linux-kernel@vger.kernel.org, mingo@kernel.org, hpa@zytor.com 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: 807e9bc8e2fe6b4907f9f77fd073f7ef5073af29 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: 807e9bc8e2fe6b4907f9f77fd073f7ef5073af29 Gitweb: https://git.kernel.org/tip/807e9bc8e2fe6b4907f9f77fd073f7ef5073af29 Author: David Wang AuthorDate: Thu, 3 May 2018 10:32:45 +0800 Committer: Thomas Gleixner CommitDate: Sun, 13 May 2018 16:14:24 +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 | 14 ++++---------- 3 files changed, 8 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..ca141d159be1 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); @@ -706,6 +699,7 @@ static void init_intel(struct cpuinfo_x86 *c) * Dixon is NOT a Celeron. */ if (c->x86 == 6) { + unsigned int l2 = c->x86_cache_size; char *p = NULL; switch (c->x86_model) {