Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp513266imm; Wed, 29 Aug 2018 05:45:23 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaerAREG8u71YaDnwz8aFza3y6/dR9KUy9DpaHlQtNsSwkSwrr2zjw+3xjyo5Dv0AdD8WQu X-Received: by 2002:a65:560a:: with SMTP id l10-v6mr5643501pgs.130.1535546723606; Wed, 29 Aug 2018 05:45:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535546723; cv=none; d=google.com; s=arc-20160816; b=My2RRbZGj+B+XXt4ABCl69iMT5aqW4C3e8pQvsqXq4ULUc96RBUJBgDPQuz+IPs1iM ZDUL/73BQn51Fk3pailLQINfa9XudXolNuY/QWp+gVNw+Gpcqwd0JJNul2bqRkmENrOs AvJkFuyFARTC7RayJpEOTYc9SF5HhckGWowsvw17ABb3xRR9+pM9eXDTshYSJeg1MAdW 3Lut/pzPxHFc3Lz3+OKefAvVcxZTWNTVFKIIxtPWrjZ4EXWOP1OeE/iRdYPIP2/hVk3u UyaNMwcg3dUb4UFTk4DiI1CLnS0kj5z3mk5V6Mh8l13B3gAazQwH8t/uk+koUTn89iEw f36A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=1R6RtytU6rxbaGuhjMnA1iz8UyKBymJvx8YFUnlclxs=; b=sYrofqaRo4m982MC5Ct/Z8V+fer3VADV3Ly7bo4n2RmK91L/NxiWOzUKnLoTgvGD1K YtvAwlEsCg9cQZkMWPcs0PhPK4LETkdnK2TblQpooFwqGbLLNNy0F3CEUgc4L8nC1EV4 o/Sulhm7nVGFUUBlKEOqQAnYSmpzNbyeXI702kijNtZ43L8s5hCIvKBIJd7vjlElUg2x n7CnTIjGbQn2KMK7M7bfQOgwHl5RPRoN+PwM6+n/+x7i6k3cLF4+fiMST9iVFBZ2Bn+5 NuhID6y7OC26pdRiwUhAuDjTz4vE94yaWGWTMfRopiyVscpsDSvBhX5b3uoRmJ1Lad8u LJYA== 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 15-v6si3796190pgu.205.2018.08.29.05.45.08; Wed, 29 Aug 2018 05:45:23 -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 S1728528AbeH2QkZ (ORCPT + 99 others); Wed, 29 Aug 2018 12:40:25 -0400 Received: from smtp17.cstnet.cn ([159.226.251.17]:47571 "EHLO cstnet.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727537AbeH2QkZ (ORCPT ); Wed, 29 Aug 2018 12:40:25 -0400 Received: from pw-vbox.higon.com (unknown [182.150.46.145]) by APP-09 (Coremail) with SMTP id swCowAAnL5PslIZbJ4T_BA--.25S2; Wed, 29 Aug 2018 20:43:28 +0800 (CST) From: Pu Wen To: tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, thomas.lendacky@amd.com, bp@alien8.de, pbonzini@redhat.com Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, Pu Wen Subject: [PATCH v5 03/16] x86/mtrr: get MTRR number and support TOP_MEM2 Date: Wed, 29 Aug 2018 20:43:23 +0800 Message-Id: <36ea05160d886ebf8d4a645c0fe8efdc9d6760c3.1535459013.git.puwen@hygon.cn> X-Mailer: git-send-email 2.7.4 In-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FyTuYvj fUr7KsUUUUU X-Originating-IP: [182.150.46.145] X-CM-SenderInfo: psxzv046klw03qof0z/ Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hygon CPU have a special magic MSR way to force WB for memory >4GB, and also support TOP_MEM2. Therefore, it is necessary to add Hygon support in amd_special_default_mtrr(). The MtrrFixDramModEn bit on Hygon platform should also be set to 1 during BIOS initialization of the fixed MTRRs, then cleared to 0 for operation. The number of variable MTRRs for Hygon is 2 as AMD's. Signed-off-by: Pu Wen --- arch/x86/kernel/cpu/mtrr/cleanup.c | 3 ++- arch/x86/kernel/cpu/mtrr/generic.c | 5 +++-- arch/x86/kernel/cpu/mtrr/mtrr.c | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/cpu/mtrr/cleanup.c b/arch/x86/kernel/cpu/mtrr/cleanup.c index 765afd5..3668c5d 100644 --- a/arch/x86/kernel/cpu/mtrr/cleanup.c +++ b/arch/x86/kernel/cpu/mtrr/cleanup.c @@ -831,7 +831,8 @@ int __init amd_special_default_mtrr(void) { u32 l, h; - if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD) + if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD && + boot_cpu_data.x86_vendor != X86_VENDOR_HYGON) return 0; if (boot_cpu_data.x86 < 0xf) return 0; diff --git a/arch/x86/kernel/cpu/mtrr/generic.c b/arch/x86/kernel/cpu/mtrr/generic.c index e12ee86..77c3eaa 100644 --- a/arch/x86/kernel/cpu/mtrr/generic.c +++ b/arch/x86/kernel/cpu/mtrr/generic.c @@ -49,8 +49,9 @@ static inline void k8_check_syscfg_dram_mod_en(void) { u32 lo, hi; - if (!((boot_cpu_data.x86_vendor == X86_VENDOR_AMD) && - (boot_cpu_data.x86 >= 0x0f))) + if (!((boot_cpu_data.x86_vendor == X86_VENDOR_AMD && + boot_cpu_data.x86 >= 0x0f) || + boot_cpu_data.x86_vendor == X86_VENDOR_HYGON)) return; rdmsr(MSR_K8_SYSCFG, lo, hi); diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.c b/arch/x86/kernel/cpu/mtrr/mtrr.c index 9a19c80..507039c 100644 --- a/arch/x86/kernel/cpu/mtrr/mtrr.c +++ b/arch/x86/kernel/cpu/mtrr/mtrr.c @@ -127,7 +127,7 @@ static void __init set_num_var_ranges(void) if (use_intel()) rdmsr(MSR_MTRRcap, config, dummy); - else if (is_cpu(AMD)) + else if (is_cpu(AMD) || is_cpu(HYGON)) config = 2; else if (is_cpu(CYRIX) || is_cpu(CENTAUR)) config = 8; -- 2.7.4