hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/cpufreq/amd_freq_sensitivity.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * amd_freq_sensitivity.c: AMD frequency sensitivity feedback powersave bias
34 * for the ondemand governor.
....@@ -5,10 +6,6 @@
56 * Copyright (C) 2013 Advanced Micro Devices, Inc.
67 *
78 * Author: Jacob Shin <jacob.shin@amd.com>
8
- *
9
- * This program is free software; you can redistribute it and/or modify
10
- * it under the terms of the GNU General Public License version 2 as
11
- * published by the Free Software Foundation.
129 */
1310
1411 #include <linux/kernel.h>
....@@ -21,6 +18,7 @@
2118
2219 #include <asm/msr.h>
2320 #include <asm/cpufeature.h>
21
+#include <asm/cpu_device_id.h>
2422
2523 #include "cpufreq_ondemand.h"
2624
....@@ -111,16 +109,23 @@
111109 {
112110 u64 val;
113111 struct pci_dev *pcidev;
112
+ unsigned int pci_vendor;
114113
115
- if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD)
114
+ if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD)
115
+ pci_vendor = PCI_VENDOR_ID_AMD;
116
+ else if (boot_cpu_data.x86_vendor == X86_VENDOR_HYGON)
117
+ pci_vendor = PCI_VENDOR_ID_HYGON;
118
+ else
116119 return -ENODEV;
117120
118
- pcidev = pci_get_device(PCI_VENDOR_ID_AMD,
121
+ pcidev = pci_get_device(pci_vendor,
119122 PCI_DEVICE_ID_AMD_KERNCZ_SMBUS, NULL);
120123
121124 if (!pcidev) {
122
- if (!static_cpu_has(X86_FEATURE_PROC_FEEDBACK))
125
+ if (!boot_cpu_has(X86_FEATURE_PROC_FEEDBACK))
123126 return -ENODEV;
127
+ } else {
128
+ pci_dev_put(pcidev);
124129 }
125130
126131 if (rdmsrl_safe(MSR_AMD64_FREQ_SENSITIVITY_ACTUAL, &val))
....@@ -141,8 +146,8 @@
141146 }
142147 module_exit(amd_freq_sensitivity_exit);
143148
144
-static const struct x86_cpu_id amd_freq_sensitivity_ids[] = {
145
- X86_FEATURE_MATCH(X86_FEATURE_PROC_FEEDBACK),
149
+static const struct x86_cpu_id __maybe_unused amd_freq_sensitivity_ids[] = {
150
+ X86_MATCH_FEATURE(X86_FEATURE_PROC_FEEDBACK, NULL),
146151 {}
147152 };
148153 MODULE_DEVICE_TABLE(x86cpu, amd_freq_sensitivity_ids);