Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2028666imm; Sat, 9 Jun 2018 06:32:34 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJCuu+dSUlKG4DZzP5PDw0z11AnMxse13kCDHY0sl+JP3VtDOjhmXap3V7V119qYwYi4bQi X-Received: by 2002:a17:902:59ce:: with SMTP id d14-v6mr11062224plj.253.1528551154362; Sat, 09 Jun 2018 06:32:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528551154; cv=none; d=google.com; s=arc-20160816; b=yp128/VBwSRASBd7jl31z/561mAMc6mEgiDzkBM/YLDUgXeGsuRWYARncKETLJOUSY HpU4acaOQfik3/Xej4QUBZsDsfZLORQhYYjeu7BmmOjzGKlpJZ9rUSC6sQzqGotuPwvN ygiHmsULlvmDMQv99JObW9208+WwyxZ/YvLyux1ZiRBKdIf1CKhVqHPxCTlJp7kf2nRE TNnfBhNlpN+zHwUOsGMWpM5T8DCRr1aJ/yiJ7Cpp71zlPmSYcjOD9dkSc+wfkpmiMKIa SFZyuJgYDrHVSzMnikTa/0ld6k1/RQMMpmGW0VMm0fz9qjOTeHg6VDpxIXGyhG5rsXPD DqAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=a6QeC89fkGwvzLYtsxeoaAovS1ntHLTIpcRSdfWfkYc=; b=qLBgU9TsqCtr5ozjm64w2lw2GUEjy+gNucFVkZiKJdCTSlUsT5c78e9oHZdgHEtOfl 2QHfPu4LK/68Pqxd4vMpv7a+omocfaWXX/cYS9ncrJntXnrGW7+KBVYas2U5GhpDIfwy M5SArDf9CIrKSzpKyBEho/XfdJObQBaWZa3k8znRv9gokkziSlTML2WLYkeT3OTGmdVq QT7RFEjwH5ZHcHs2wh1+8XvUpiNqhf/hu8q4AxAQqmAIM8F0ArMQFFDHS1PiLn/+tt9a LAyQjMZd0zdckxDJfEjEvtS+/n+Dcyh8OsgQA6/QNEgMflqrwuFCbvHdv7aWR/LAvmSA BUwQ== 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 136-v6si29368732pgf.604.2018.06.09.06.32.20; Sat, 09 Jun 2018 06:32:34 -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 S1753412AbeFINa3 (ORCPT + 99 others); Sat, 9 Jun 2018 09:30:29 -0400 Received: from smtp21.cstnet.cn ([159.226.251.21]:44117 "EHLO cstnet.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753214AbeFINaV (ORCPT ); Sat, 9 Jun 2018 09:30:21 -0400 Received: from pw-vbox.higon.com (unknown [182.150.46.145]) by APP-01 (Coremail) with SMTP id qwCowACXni4D1RtbaFdEBA--.1159S2; Sat, 09 Jun 2018 21:24:24 +0800 (CST) From: Pu Wen To: rjw@rjwysocki.net, viresh.kumar@linaro.org, zhangpanyong@hygon.cn Cc: lenb@kernel.org, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, thomas.lendacky@amd.com, peterz@infradead.org, tony.luck@intel.com, bp@alien8.de, pbonzini@redhat.com, rkrcmar@redhat.com, boris.ostrovsky@oracle.com, jgross@suse.com, mchehab@kernel.org, trenn@suse.com, shuah@kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-x86_64@vger.kernel.org, linux-pci@vger.kernel.org, linux-acpi@vger.kernel.org, linux-edac@vger.kernel.org, linux-pm@vger.kernel.org, kvm@vger.kernel.org, xen-devel@lists.xenproject.org, Pu Wen Subject: [PATCH 09/11] driver/cpufreq: Add support for Hygon's Dhyana Family 18h processor Date: Sat, 9 Jun 2018 21:24:12 +0800 Message-Id: <1528550652-28485-1-git-send-email-puwen@hygon.cn> X-Mailer: git-send-email 2.7.4 X-CM-TRANSID: qwCowACXni4D1RtbaFdEBA--.1159S2 X-Coremail-Antispam: 1UD129KBjvJXoW7uF1rJw17ur4kGw47CFyfZwb_yoW5JrW3pF W5WFW8tr48JasrW3srArWUXF98Z3Wqyay0kr9rK3sYyF45Za45XrWDAw1UWr98K3ykWF1x A3WDGw4UJa1YyFUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUva14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26r1I6r4UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4U JVWxJr1l84ACjcxK6I8E87Iv67AKxVW8JVWxJwA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Gr 1j6F4UJwAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv 7VC0I7IYx2IY67AKxVWUtVWrXwAv7VC2z280aVAFwI0_Cr0_Gr1UMcvjeVCFs4IE7xkEbV WUJVW8JwACjcxG0xvY0x0EwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1lFIxGxcIEc7Cj xVA2Y2ka0xkIwI1l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxV Aqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r4a 6rW5MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_JFI_Gr1lIxAIcVC0I7IYx2IY6x kF7I0E14v26r4UJVWxJr1lIxAIcVCF04k26cxKx2IYs7xG6r4j6FyUMIIF0xvEx4A2jsIE 14v26r4j6F4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr1j6F4UJbIYCTnIWIevJa73UjIFyT uYvjfUFa0PUUUUU 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 This patch enables the cpufreq driver support to Hygon Family 18h CPU: - It recognize Hygon's boost state in boost_state(), boost_set_msr(), extract_msr() functions. - It also add SMBUS support for Hygon Family 18h in amd_freq_sensitivity_init(). Signed-off-by: Pu Wen --- drivers/cpufreq/acpi-cpufreq.c | 5 ++++- drivers/cpufreq/amd_freq_sensitivity.c | 9 +++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c index 9449657..04c9b81 100644 --- a/drivers/cpufreq/acpi-cpufreq.c +++ b/drivers/cpufreq/acpi-cpufreq.c @@ -95,6 +95,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 +114,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; @@ -223,7 +225,8 @@ static unsigned extract_msr(struct cpufreq_policy *policy, u32 msr) struct cpufreq_frequency_table *pos; struct acpi_processor_performance *perf; - 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) msr &= AMD_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