Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3008628imm; Sun, 19 Aug 2018 09:58:31 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxMb9vjQdgmpQPkwjfVIkGNZ2OdJJPz/97NsWgOn8Qx646uakBd+Bxg3FrTKEE36CqPGS+V X-Received: by 2002:a63:706:: with SMTP id 6-v6mr11926515pgh.137.1534697910967; Sun, 19 Aug 2018 09:58:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534697910; cv=none; d=google.com; s=arc-20160816; b=xe/F6klWJ8cXqE3tOb1GRTLgOGcQgXdrhiTKyhnu3L4LO4UekjG+wSHKpee6pAcKO7 vXB97QCoHS0KQZt8R+c0PO44xewyNfjZ7GakGfQnMRLI6cR2F682MGk9+KCJok08TGVR 5OcDTJomKOUJewuaryDb+yf7brS4PRW5xzghiHIbCvMkLkLguJzgqpzuVf7+0PCPu/gI CeHk1v/9ZVbcoXkN+udY4TJJxY/YJXDRlERo+iyBn/2Si3TpOLYPlO/U0HleMh6llU/X nFfNA7H9ZGKS03S7+jOkPvdz9PSCGOse4EcxDV2ItqoUx85WbDy1t7SL+dQRbv5wACSd 9eMg== 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=IIKvkCmRJQKsZIR1lbLFwkFH8zm5hTbrBw/5vh7Fd9U=; b=Vm02Jd0FVNhnfB4PtxUVaCS3RAfGxyxY8DF+CUW9YySAvU8AXowzXH5D0cGPBXCJJi 0//Gtf9Hxm604speyyxC5tbVATNBnjmduXtw4jolZeTjUHS2yVCQGJPcpQuiGKPVnH6G fEinbP7wxArv00B+h/giFsZHLk21dFxzfFYO2mXTXcW7U0Bv55zm9mpavk2f0hFbAV+d edIgshdvZlo4i9mrSeJ1ky//oSeIoX1qmosGOJW1fL5T5a2UOfltbfuE5jL7EMiSvEwQ W0TgDLqVABri6VIqmUqxwy/cVOPcHMgLfcJcq+E/ZbKMddl+HTYgqh2vD8AoUqemTqEO yYXw== 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 t196-v6si7224658pgc.308.2018.08.19.09.58.00; Sun, 19 Aug 2018 09:58:30 -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 S1726863AbeHST1R (ORCPT + 99 others); Sun, 19 Aug 2018 15:27:17 -0400 Received: from smtp20.cstnet.cn ([159.226.251.20]:57154 "EHLO cstnet.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726587AbeHST1R (ORCPT ); Sun, 19 Aug 2018 15:27:17 -0400 Received: from localhost.localdomain (unknown [110.184.154.248]) by APP-10 (Coremail) with SMTP id tACowAAHLOx6l3lbY9+wAg--.30S2; Mon, 20 Aug 2018 00:14:55 +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, rjw@rjwysocki.net, viresh.kumar@linaro.org, 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 v4 14/16] driver/cpufreq: enable Hygon support to cpufreq driver Date: Mon, 20 Aug 2018 00:14:28 +0800 Message-Id: X-Mailer: git-send-email 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VFxhVjvjDU0xZFpf 9x0JUD-B_UUUUU= X-Originating-IP: [110.184.154.248] X-CM-SenderInfo: psxzv046klw03qof0z/ Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Enable ACPI cpufreq driver support for Hygon by adding family ID check along with AMD. As Hygon platforms have SMBus device(PCI device ID 0x790b), enable Hygon support to function amd_freq_sensitivity_init(). Acked-by: Rafael J. Wysocki Signed-off-by: Pu Wen --- 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