Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1371256imm; Sun, 23 Sep 2018 02:38:38 -0700 (PDT) X-Google-Smtp-Source: ACcGV602J/pTIJ5Ejgpo0a+Ojb3n1sRSsW9eYavP6f+8cSSVJ7yOXwcHPadFi12fNSbdmsjfUlCX X-Received: by 2002:a17:902:42e2:: with SMTP id h89-v6mr5781537pld.69.1537695518722; Sun, 23 Sep 2018 02:38:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537695518; cv=none; d=google.com; s=arc-20160816; b=NzIFUbufXnQgoDQZF5ZD5Q30jEonXVpwcb5Wy2tMHW0x6kRZsHv62XEq92mpYtEely 7yJ7q+0QAG+rAzErCdCHc8rgk7zz+N+8EGV2eynXrBnaVdZekULqtlcL9QDYTvezLr9A Z28ocy9hTtmAlBo0D+G7i6KUYxHpJprE2YbmUhclmh8PxdfMSyWl4q+bvODvXPs0TVxN uGpubgz/xtOEaTst3PxFmEiG4XpDyobF4cjEdhw3Z3dKWkikY2JDpG27cvNpsEv71DDH uxbPPJg/lY5zNJt19oePnGwv10ofuguaDoxO/qFK3VeOBNhStXR9OuRr2M/cmOxzN85M KDmw== 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; bh=uuDSOLwUMvxQSwvPFxUiRbYl1yNJRCkploDnXgeuPO0=; b=0+gIAlnReb2Z1gBWpHdgnMMv95GyEqvK+vk7vGBML2bdoz0tANAczPxXKl40xvkAMz YH2T6Su+b+jYBSbmO1jZGtcsEQxV7MLI2FTkd/y39BRgEoxhdheMg+U9vAGTrdVJQGl1 diK4+n0LGEPchXpTwfLS7CL9LwZSu+do5E17m8N04xRI4TTdjSqwqmmGY4/Ro0uoK9Mq wgwEVYj5MDl/JRTDddMtIg/GwSllYSEUuoBacTzTnfCtoXYHDOQY6gYGEe/k92w0seTf 0eHGpQ8zZ5nWpzPmfmrgBqzoVQMbbTTi6a0QmaV0kI8hyroo71CqENKj4HC4Gs46oDuk 1ORQ== 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 gn24si33623527plb.43.2018.09.23.02.38.23; Sun, 23 Sep 2018 02:38:38 -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 S1726266AbeIWPey (ORCPT + 99 others); Sun, 23 Sep 2018 11:34:54 -0400 Received: from smtp21.cstnet.cn ([159.226.251.21]:50760 "EHLO cstnet.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726047AbeIWPey (ORCPT ); Sun, 23 Sep 2018 11:34:54 -0400 Received: from pw-vbox.higon.com (unknown [182.150.46.145]) by APP-01 (Coremail) with SMTP id qwCowACX+UbqXqdbL26zDA--.13S2; Sun, 23 Sep 2018 17:37:50 +0800 (CST) From: Pu Wen To: rjw@rjwysocki.net, viresh.kumar@linaro.org, bp@alien8.de, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, thomas.lendacky@amd.com, rafael@kernel.org, rafael.j.wysocki@intel.com Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-pm@vger.kernel.org, Pu Wen Subject: [PATCH v8 14/16] cpufreq, x86: Add Hygon Dhyana support Date: Sun, 23 Sep 2018 17:37:38 +0800 Message-Id: <4db6f0f8537a93c172430c446a0297a6ab1c3c2d.1537533369.git.puwen@hygon.cn> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: X-CM-TRANSID: qwCowACX+UbqXqdbL26zDA--.13S2 X-Coremail-Antispam: 1UD129KBjvJXoWxZF4DKFyDCF1UCr4xJF18Xwb_yoW5Jw4kpF W5WFW8Ar18Ja9rW3sFvF4UXF98Zas7tay3Kr9rt3sY9F45uFy5XrWDAw13Wr90g3ykWFyI y3WDWw42qan0yrUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvI14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26r4j6ryUM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4U JVWxJr1l84ACjcxK6I8E87Iv67AKxVW8JVWxJwA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Gr 1j6F4UJwAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv 7VC0I7IYx2IY67AKxVWUtVWrXwAv7VC2z280aVAFwI0_Gr0_Cr1lOx8S6xCaFVCjc4AY6r 1j6r4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02 628vn2kIc2xKxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c 02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_ GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVW8JVW5JwCI42IY6xIIjxv20xvEc7 CjxVAFwI0_Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Gr0_Zr1lIxAIcVC2z280aVAF wI0_Gr0_Cr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf 9x0JUD-B_UUUUU= 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 The Hygon Dhyana CPU supports ACPI P-States feature, and there is SMBus device(PCI device ID 0x790b) on Hygon platform, so add Hygon Dhyana support to the cpufreq driver by using the code path of AMD family 17h. Signed-off-by: Pu Wen Acked-by: Rafael J. Wysocki --- drivers/cpufreq/acpi-cpufreq.c | 5 +++++ drivers/cpufreq/amd_freq_sensitivity.c | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c index b61f4ec..d62fd37 100644 --- a/drivers/cpufreq/acpi-cpufreq.c +++ b/drivers/cpufreq/acpi-cpufreq.c @@ -61,6 +61,7 @@ enum { #define INTEL_MSR_RANGE (0xffff) #define AMD_MSR_RANGE (0x7) +#define HYGON_MSR_RANGE (0x7) #define MSR_K7_HWCR_CPB_DIS (1ULL << 25) @@ -95,6 +96,7 @@ static bool boost_state(unsigned int cpu) rdmsr_on_cpu(cpu, MSR_IA32_MISC_ENABLE, &lo, &hi); msr = lo | ((u64)hi << 32); return !(msr & MSR_IA32_MISC_ENABLE_TURBO_DISABLE); + case X86_VENDOR_HYGON: case X86_VENDOR_AMD: rdmsr_on_cpu(cpu, MSR_K7_HWCR, &lo, &hi); msr = lo | ((u64)hi << 32); @@ -113,6 +115,7 @@ static int boost_set_msr(bool enable) msr_addr = MSR_IA32_MISC_ENABLE; msr_mask = MSR_IA32_MISC_ENABLE_TURBO_DISABLE; break; + case X86_VENDOR_HYGON: case X86_VENDOR_AMD: msr_addr = MSR_K7_HWCR; msr_mask = MSR_K7_HWCR_CPB_DIS; @@ -225,6 +228,8 @@ static unsigned extract_msr(struct cpufreq_policy *policy, u32 msr) if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD) msr &= AMD_MSR_RANGE; + else if (boot_cpu_data.x86_vendor == X86_VENDOR_HYGON) + msr &= HYGON_MSR_RANGE; else msr &= INTEL_MSR_RANGE; diff --git a/drivers/cpufreq/amd_freq_sensitivity.c b/drivers/cpufreq/amd_freq_sensitivity.c index be926d9..4ac7c3c 100644 --- a/drivers/cpufreq/amd_freq_sensitivity.c +++ b/drivers/cpufreq/amd_freq_sensitivity.c @@ -111,11 +111,16 @@ static int __init amd_freq_sensitivity_init(void) { u64 val; struct pci_dev *pcidev; + unsigned int pci_vendor; - if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD) + if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD) + pci_vendor = PCI_VENDOR_ID_AMD; + else if (boot_cpu_data.x86_vendor == X86_VENDOR_HYGON) + pci_vendor = PCI_VENDOR_ID_HYGON; + else return -ENODEV; - pcidev = pci_get_device(PCI_VENDOR_ID_AMD, + pcidev = pci_get_device(pci_vendor, PCI_DEVICE_ID_AMD_KERNCZ_SMBUS, NULL); if (!pcidev) { -- 2.7.4