[v10,03/12] cpufreq: intel_pstate: use common macro definition for Energy Preference Performance(EPP)

Message ID 20230106061420.95715-4-perry.yuan@amd.com
State New
Headers
Series Implement AMD Pstate EPP Driver |

Commit Message

Yuan, Perry Jan. 6, 2023, 6:14 a.m. UTC
  make the energy preference performance strings and profiles using one
common header for intel_pstate driver, then the amd_pstate epp driver can
use the common header as well. This will simpify the intel_pstate and
amd_pstate driver.

Signed-off-by: Perry Yuan <perry.yuan@amd.com>
---
 drivers/acpi/cppc_acpi.c       | 29 +++++++++++++++++++++++++++
 drivers/cpufreq/intel_pstate.c | 36 ----------------------------------
 include/acpi/cppc_acpi.h       | 10 ++++++++++
 3 files changed, 39 insertions(+), 36 deletions(-)
  

Comments

kernel test robot Jan. 6, 2023, 9:38 a.m. UTC | #1
Hi Perry,

I love your patch! Yet something to improve:

[auto build test ERROR on rafael-pm/linux-next]
[also build test ERROR on linus/master v6.2-rc2 next-20230106]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Perry-Yuan/ACPI-CPPC-Add-AMD-pstate-energy-performance-preference-cppc-control/20230106-141924
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
patch link:    https://lore.kernel.org/r/20230106061420.95715-4-perry.yuan%40amd.com
patch subject: [PATCH v10 03/12] cpufreq: intel_pstate: use common macro definition for Energy Preference Performance(EPP)
config: x86_64-randconfig-a004
compiler: gcc-11 (Debian 11.3.0-8) 11.3.0
reproduce (this is a W=1 build):
        # https://github.com/intel-lab-lkp/linux/commit/f43a51c9a7f805b5fd089878fafe7cf9b06b68f0
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Perry-Yuan/ACPI-CPPC-Add-AMD-pstate-energy-performance-preference-cppc-control/20230106-141924
        git checkout f43a51c9a7f805b5fd089878fafe7cf9b06b68f0
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        make W=1 O=build_dir ARCH=x86_64 olddefconfig
        make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   ld: vmlinux.o: in function `intel_pstate_update_epp_defaults':
>> drivers/cpufreq/intel_pstate.c:1629: undefined reference to `epp_values'
>> ld: drivers/cpufreq/intel_pstate.c:1629: undefined reference to `epp_values'
   ld: drivers/cpufreq/intel_pstate.c:1640: undefined reference to `epp_values'
>> ld: drivers/cpufreq/intel_pstate.c:1629: undefined reference to `epp_values'
   ld: vmlinux.o: in function `show_energy_performance_preference':
>> drivers/cpufreq/intel_pstate.c:812: undefined reference to `energy_perf_strings'
>> ld: drivers/cpufreq/intel_pstate.c:812: undefined reference to `energy_perf_strings'
   ld: vmlinux.o: in function `intel_pstate_get_energy_pref_index':
   drivers/cpufreq/intel_pstate.c:628: undefined reference to `epp_values'
   ld: drivers/cpufreq/intel_pstate.c:628: undefined reference to `epp_values'
   ld: drivers/cpufreq/intel_pstate.c:630: undefined reference to `epp_values'
   ld: drivers/cpufreq/intel_pstate.c:630: undefined reference to `epp_values'
   ld: drivers/cpufreq/intel_pstate.c:632: undefined reference to `epp_values'
   ld: vmlinux.o:drivers/cpufreq/intel_pstate.c:632: more undefined references to `epp_values' follow
   ld: vmlinux.o: in function `show_energy_performance_available_preferences':
   drivers/cpufreq/intel_pstate.c:721: undefined reference to `energy_perf_strings'
   ld: drivers/cpufreq/intel_pstate.c:721: undefined reference to `energy_perf_strings'
   ld: drivers/cpufreq/intel_pstate.c:721: undefined reference to `energy_perf_strings'
   ld: drivers/cpufreq/intel_pstate.c:721: undefined reference to `energy_perf_strings'
   ld: drivers/cpufreq/intel_pstate.c:721: undefined reference to `energy_perf_strings'
   ld: vmlinux.o:drivers/cpufreq/intel_pstate.c:746: more undefined references to `energy_perf_strings' follow
   ld: vmlinux.o: in function `store_energy_performance_preference':
   drivers/cpufreq/intel_pstate.c:781: undefined reference to `epp_values'
   ld: drivers/cpufreq/intel_pstate.c:781: undefined reference to `epp_values'
   ld: vmlinux.o: in function `intel_pstate_set_energy_pref_index':
   drivers/cpufreq/intel_pstate.c:695: undefined reference to `epp_values'
   ld: drivers/cpufreq/intel_pstate.c:695: undefined reference to `epp_values'
   ld: vmlinux.o: in function `intel_pstate_init':
   drivers/cpufreq/intel_pstate.c:3421: undefined reference to `epp_values'
   ld: vmlinux.o:drivers/cpufreq/intel_pstate.c:3421: more undefined references to `epp_values' follow


vim +1629 drivers/cpufreq/intel_pstate.c

57577c996d731c Srinivas Pandruvada 2021-09-28  1620  
3d13058ed2a6d0 Srinivas Pandruvada 2022-03-10  1621  static void intel_pstate_update_epp_defaults(struct cpudata *cpudata)
3d13058ed2a6d0 Srinivas Pandruvada 2022-03-10  1622  {
3d13058ed2a6d0 Srinivas Pandruvada 2022-03-10  1623  	cpudata->epp_default = intel_pstate_get_epp(cpudata, 0);
3d13058ed2a6d0 Srinivas Pandruvada 2022-03-10  1624  
3d13058ed2a6d0 Srinivas Pandruvada 2022-03-10  1625  	/*
3d13058ed2a6d0 Srinivas Pandruvada 2022-03-10  1626  	 * If this CPU gen doesn't call for change in balance_perf
3d13058ed2a6d0 Srinivas Pandruvada 2022-03-10  1627  	 * EPP return.
3d13058ed2a6d0 Srinivas Pandruvada 2022-03-10  1628  	 */
3d13058ed2a6d0 Srinivas Pandruvada 2022-03-10 @1629  	if (epp_values[EPP_INDEX_BALANCE_PERFORMANCE] == HWP_EPP_BALANCE_PERFORMANCE)
3d13058ed2a6d0 Srinivas Pandruvada 2022-03-10  1630  		return;
3d13058ed2a6d0 Srinivas Pandruvada 2022-03-10  1631  
3d13058ed2a6d0 Srinivas Pandruvada 2022-03-10  1632  	/*
21cdb6c18f85fe Srinivas Pandruvada 2022-10-27  1633  	 * If the EPP is set by firmware, which means that firmware enabled HWP
21cdb6c18f85fe Srinivas Pandruvada 2022-10-27  1634  	 * - Is equal or less than 0x80 (default balance_perf EPP)
3d13058ed2a6d0 Srinivas Pandruvada 2022-03-10  1635  	 * - But less performance oriented than performance EPP
3d13058ed2a6d0 Srinivas Pandruvada 2022-03-10  1636  	 *   then use this as new balance_perf EPP.
3d13058ed2a6d0 Srinivas Pandruvada 2022-03-10  1637  	 */
21cdb6c18f85fe Srinivas Pandruvada 2022-10-27  1638  	if (hwp_forced && cpudata->epp_default <= HWP_EPP_BALANCE_PERFORMANCE &&
3d13058ed2a6d0 Srinivas Pandruvada 2022-03-10  1639  	    cpudata->epp_default > HWP_EPP_PERFORMANCE) {
3d13058ed2a6d0 Srinivas Pandruvada 2022-03-10  1640  		epp_values[EPP_INDEX_BALANCE_PERFORMANCE] = cpudata->epp_default;
3d13058ed2a6d0 Srinivas Pandruvada 2022-03-10  1641  		return;
3d13058ed2a6d0 Srinivas Pandruvada 2022-03-10  1642  	}
3d13058ed2a6d0 Srinivas Pandruvada 2022-03-10  1643  
3d13058ed2a6d0 Srinivas Pandruvada 2022-03-10  1644  	/*
3d13058ed2a6d0 Srinivas Pandruvada 2022-03-10  1645  	 * Use hard coded value per gen to update the balance_perf
3d13058ed2a6d0 Srinivas Pandruvada 2022-03-10  1646  	 * and default EPP.
3d13058ed2a6d0 Srinivas Pandruvada 2022-03-10  1647  	 */
3d13058ed2a6d0 Srinivas Pandruvada 2022-03-10  1648  	cpudata->epp_default = epp_values[EPP_INDEX_BALANCE_PERFORMANCE];
3d13058ed2a6d0 Srinivas Pandruvada 2022-03-10  1649  	intel_pstate_set_epp(cpudata, cpudata->epp_default);
3d13058ed2a6d0 Srinivas Pandruvada 2022-03-10  1650  }
3d13058ed2a6d0 Srinivas Pandruvada 2022-03-10  1651
  
kernel test robot Jan. 6, 2023, 10:19 a.m. UTC | #2
Hi Perry,

I love your patch! Yet something to improve:

[auto build test ERROR on rafael-pm/linux-next]
[also build test ERROR on linus/master v6.2-rc2 next-20230106]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Perry-Yuan/ACPI-CPPC-Add-AMD-pstate-energy-performance-preference-cppc-control/20230106-141924
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
patch link:    https://lore.kernel.org/r/20230106061420.95715-4-perry.yuan%40amd.com
patch subject: [PATCH v10 03/12] cpufreq: intel_pstate: use common macro definition for Energy Preference Performance(EPP)
config: i386-randconfig-a002
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/f43a51c9a7f805b5fd089878fafe7cf9b06b68f0
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Perry-Yuan/ACPI-CPPC-Add-AMD-pstate-energy-performance-preference-cppc-control/20230106-141924
        git checkout f43a51c9a7f805b5fd089878fafe7cf9b06b68f0
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> ld.lld: error: undefined symbol: epp_values
   >>> referenced by intel_pstate.c:628 (drivers/cpufreq/intel_pstate.c:628)
   >>>               drivers/cpufreq/intel_pstate.o:(show_energy_performance_preference) in archive vmlinux.a
   >>> referenced by intel_pstate.c:630 (drivers/cpufreq/intel_pstate.c:630)
   >>>               drivers/cpufreq/intel_pstate.o:(show_energy_performance_preference) in archive vmlinux.a
   >>> referenced by intel_pstate.c:632 (drivers/cpufreq/intel_pstate.c:632)
   >>>               drivers/cpufreq/intel_pstate.o:(show_energy_performance_preference) in archive vmlinux.a
   >>> referenced 6 more times
--
>> ld.lld: error: undefined symbol: energy_perf_strings
   >>> referenced by intel_pstate.c:812 (drivers/cpufreq/intel_pstate.c:812)
   >>>               drivers/cpufreq/intel_pstate.o:(show_energy_performance_preference) in archive vmlinux.a
   >>> referenced by intel_pstate.c:746 (drivers/cpufreq/intel_pstate.c:746)
   >>>               drivers/cpufreq/intel_pstate.o:(store_energy_performance_preference) in archive vmlinux.a
   >>> referenced by intel_pstate.c:721 (drivers/cpufreq/intel_pstate.c:721)
   >>>               drivers/cpufreq/intel_pstate.o:(show_energy_performance_available_preferences) in archive vmlinux.a
   >>> referenced 1 more times
  

Patch

diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
index 0ce6c55a76ca..c7aa190ec2d2 100644
--- a/drivers/acpi/cppc_acpi.c
+++ b/drivers/acpi/cppc_acpi.c
@@ -42,6 +42,35 @@ 
 
 #include <acpi/cppc_acpi.h>
 
+/*
+ * EPP/EPB display strings corresponding to EPP index in the
+ * energy_perf_strings[]
+ *	index		String
+ *-------------------------------------
+ *	0		default
+ *	1		performance
+ *	2		balance_performance
+ *	3		balance_power
+ *	4		power
+ */
+
+const char * const energy_perf_strings[] = {
+	[EPP_INDEX_DEFAULT] = "default",
+	[EPP_INDEX_PERFORMANCE] = "performance",
+	[EPP_INDEX_BALANCE_PERFORMANCE] = "balance_performance",
+	[EPP_INDEX_BALANCE_POWERSAVE] = "balance_power",
+	[EPP_INDEX_POWERSAVE] = "power",
+	NULL
+};
+
+unsigned int epp_values[] = {
+	[EPP_INDEX_DEFAULT] = 0, /* Unused index */
+	[EPP_INDEX_PERFORMANCE] = HWP_EPP_PERFORMANCE,
+	[EPP_INDEX_BALANCE_PERFORMANCE] = HWP_EPP_BALANCE_PERFORMANCE,
+	[EPP_INDEX_BALANCE_POWERSAVE] = HWP_EPP_BALANCE_POWERSAVE,
+	[EPP_INDEX_POWERSAVE] = HWP_EPP_POWERSAVE,
+};
+
 struct cppc_pcc_data {
 	struct pcc_mbox_chan *pcc_channel;
 	void __iomem *pcc_comm_addr;
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index ad9be31753b6..01431e279be6 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -628,42 +628,6 @@  static int intel_pstate_set_epb(int cpu, s16 pref)
 	return 0;
 }
 
-/*
- * EPP/EPB display strings corresponding to EPP index in the
- * energy_perf_strings[]
- *	index		String
- *-------------------------------------
- *	0		default
- *	1		performance
- *	2		balance_performance
- *	3		balance_power
- *	4		power
- */
-
-enum energy_perf_value_index {
-	EPP_INDEX_DEFAULT = 0,
-	EPP_INDEX_PERFORMANCE,
-	EPP_INDEX_BALANCE_PERFORMANCE,
-	EPP_INDEX_BALANCE_POWERSAVE,
-	EPP_INDEX_POWERSAVE,
-};
-
-static const char * const energy_perf_strings[] = {
-	[EPP_INDEX_DEFAULT] = "default",
-	[EPP_INDEX_PERFORMANCE] = "performance",
-	[EPP_INDEX_BALANCE_PERFORMANCE] = "balance_performance",
-	[EPP_INDEX_BALANCE_POWERSAVE] = "balance_power",
-	[EPP_INDEX_POWERSAVE] = "power",
-	NULL
-};
-static unsigned int epp_values[] = {
-	[EPP_INDEX_DEFAULT] = 0, /* Unused index */
-	[EPP_INDEX_PERFORMANCE] = HWP_EPP_PERFORMANCE,
-	[EPP_INDEX_BALANCE_PERFORMANCE] = HWP_EPP_BALANCE_PERFORMANCE,
-	[EPP_INDEX_BALANCE_POWERSAVE] = HWP_EPP_BALANCE_POWERSAVE,
-	[EPP_INDEX_POWERSAVE] = HWP_EPP_POWERSAVE,
-};
-
 static int intel_pstate_get_energy_pref_index(struct cpudata *cpu_data, int *raw_epp)
 {
 	s16 epp;
diff --git a/include/acpi/cppc_acpi.h b/include/acpi/cppc_acpi.h
index 6b487a5bd638..891e5add0e49 100644
--- a/include/acpi/cppc_acpi.h
+++ b/include/acpi/cppc_acpi.h
@@ -135,6 +135,16 @@  struct cppc_cpudata {
 	cpumask_var_t shared_cpu_map;
 };
 
+enum energy_perf_value_index {
+	EPP_INDEX_DEFAULT = 0,
+	EPP_INDEX_PERFORMANCE,
+	EPP_INDEX_BALANCE_PERFORMANCE,
+	EPP_INDEX_BALANCE_POWERSAVE,
+	EPP_INDEX_POWERSAVE,
+};
+extern const char * const energy_perf_strings[];
+extern unsigned int epp_values[];
+
 #ifdef CONFIG_ACPI_CPPC_LIB
 extern int cppc_get_desired_perf(int cpunum, u64 *desired_perf);
 extern int cppc_get_nominal_perf(int cpunum, u64 *nominal_perf);