cpufreq: amd-pstate: remove global header file
authorArnd Bergmann <arnd@arndb.de>
Tue, 28 May 2024 12:09:23 +0000 (14:09 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 28 May 2024 19:59:39 +0000 (21:59 +0200)
When extra warnings are enabled, gcc points out a global variable
definition in a header:

In file included from drivers/cpufreq/amd-pstate-ut.c:29:
include/linux/amd-pstate.h:123:27: error: 'amd_pstate_mode_string' defined but not used [-Werror=unused-const-variable=]
  123 | static const char * const amd_pstate_mode_string[] = {
      |                           ^~~~~~~~~~~~~~~~~~~~~~

This header is only included from two files in the same directory,
and one of them uses only a single definition from it, so clean it
up by moving most of the contents into the driver that uses them,
and making shared bits a local header file.

Fixes: 36c5014e5460 ("cpufreq: amd-pstate: optimize driver working mode selection in amd_pstate_param()")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
MAINTAINERS
drivers/cpufreq/amd-pstate-ut.c
drivers/cpufreq/amd-pstate.c
drivers/cpufreq/amd-pstate.h [new file with mode: 0644]
include/linux/amd-pstate.h [deleted file]

index d6c90161c7bfe3886e675396cb2d2d7b44acc3b3..fc31870379f84ec07620f6390bafb46661443791 100644 (file)
@@ -1107,7 +1107,6 @@ L:        linux-pm@vger.kernel.org
 S:     Supported
 F:     Documentation/admin-guide/pm/amd-pstate.rst
 F:     drivers/cpufreq/amd-pstate*
-F:     include/linux/amd-pstate.h
 F:     tools/power/x86/amd_pstate_tracer/amd_pstate_trace.py
 
 AMD PTDMA DRIVER
index f04ae67dda372d2787bba3bb45d57f53515e2bc0..fc275d41d51e9b51a93ccc26f36e5592c4228d60 100644 (file)
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/fs.h>
-#include <linux/amd-pstate.h>
 
 #include <acpi/cppc_acpi.h>
 
+#include "amd-pstate.h"
+
 /*
  * Abbreviations:
  * amd_pstate_ut: used as a shortform for AMD P-State unit test.
index 1b7e82a0ad2e62f4e0f3e520bfa9408888bc4434..91993647e09ef8f0f6a3f5b5b45d4622ee2ce002 100644 (file)
@@ -36,7 +36,6 @@
 #include <linux/delay.h>
 #include <linux/uaccess.h>
 #include <linux/static_call.h>
-#include <linux/amd-pstate.h>
 #include <linux/topology.h>
 
 #include <acpi/processor.h>
@@ -46,6 +45,8 @@
 #include <asm/processor.h>
 #include <asm/cpufeature.h>
 #include <asm/cpu_device_id.h>
+
+#include "amd-pstate.h"
 #include "amd-pstate-trace.h"
 
 #define AMD_PSTATE_TRANSITION_LATENCY  20000
 #define CPPC_HIGHEST_PERF_PERFORMANCE  196
 #define CPPC_HIGHEST_PERF_DEFAULT      166
 
+#define AMD_CPPC_EPP_PERFORMANCE               0x00
+#define AMD_CPPC_EPP_BALANCE_PERFORMANCE       0x80
+#define AMD_CPPC_EPP_BALANCE_POWERSAVE         0xBF
+#define AMD_CPPC_EPP_POWERSAVE                 0xFF
+
+/*
+ * enum amd_pstate_mode - driver working mode of amd pstate
+ */
+enum amd_pstate_mode {
+       AMD_PSTATE_UNDEFINED = 0,
+       AMD_PSTATE_DISABLE,
+       AMD_PSTATE_PASSIVE,
+       AMD_PSTATE_ACTIVE,
+       AMD_PSTATE_GUIDED,
+       AMD_PSTATE_MAX,
+};
+
+static const char * const amd_pstate_mode_string[] = {
+       [AMD_PSTATE_UNDEFINED]   = "undefined",
+       [AMD_PSTATE_DISABLE]     = "disable",
+       [AMD_PSTATE_PASSIVE]     = "passive",
+       [AMD_PSTATE_ACTIVE]      = "active",
+       [AMD_PSTATE_GUIDED]      = "guided",
+       NULL,
+};
+
+struct quirk_entry {
+       u32 nominal_freq;
+       u32 lowest_freq;
+};
+
 /*
  * TODO: We need more time to fine tune processors with shared memory solution
  * with community together.
diff --git a/drivers/cpufreq/amd-pstate.h b/drivers/cpufreq/amd-pstate.h
new file mode 100644 (file)
index 0000000..e6a28e7
--- /dev/null
@@ -0,0 +1,104 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (C) 2022 Advanced Micro Devices, Inc.
+ *
+ * Author: Meng Li <li.meng@amd.com>
+ */
+
+#ifndef _LINUX_AMD_PSTATE_H
+#define _LINUX_AMD_PSTATE_H
+
+#include <linux/pm_qos.h>
+
+/*********************************************************************
+ *                        AMD P-state INTERFACE                       *
+ *********************************************************************/
+/**
+ * struct  amd_aperf_mperf
+ * @aperf: actual performance frequency clock count
+ * @mperf: maximum performance frequency clock count
+ * @tsc:   time stamp counter
+ */
+struct amd_aperf_mperf {
+       u64 aperf;
+       u64 mperf;
+       u64 tsc;
+};
+
+/**
+ * struct amd_cpudata - private CPU data for AMD P-State
+ * @cpu: CPU number
+ * @req: constraint request to apply
+ * @cppc_req_cached: cached performance request hints
+ * @highest_perf: the maximum performance an individual processor may reach,
+ *               assuming ideal conditions
+ *               For platforms that do not support the preferred core feature, the
+ *               highest_pef may be configured with 166 or 255, to avoid max frequency
+ *               calculated wrongly. we take the fixed value as the highest_perf.
+ * @nominal_perf: the maximum sustained performance level of the processor,
+ *               assuming ideal operating conditions
+ * @lowest_nonlinear_perf: the lowest performance level at which nonlinear power
+ *                        savings are achieved
+ * @lowest_perf: the absolute lowest performance level of the processor
+ * @prefcore_ranking: the preferred core ranking, the higher value indicates a higher
+ *               priority.
+ * @min_limit_perf: Cached value of the performance corresponding to policy->min
+ * @max_limit_perf: Cached value of the performance corresponding to policy->max
+ * @min_limit_freq: Cached value of policy->min (in khz)
+ * @max_limit_freq: Cached value of policy->max (in khz)
+ * @max_freq: the frequency (in khz) that mapped to highest_perf
+ * @min_freq: the frequency (in khz) that mapped to lowest_perf
+ * @nominal_freq: the frequency (in khz) that mapped to nominal_perf
+ * @lowest_nonlinear_freq: the frequency (in khz) that mapped to lowest_nonlinear_perf
+ * @cur: Difference of Aperf/Mperf/tsc count between last and current sample
+ * @prev: Last Aperf/Mperf/tsc count value read from register
+ * @freq: current cpu frequency value (in khz)
+ * @boost_supported: check whether the Processor or SBIOS supports boost mode
+ * @hw_prefcore: check whether HW supports preferred core featue.
+ *               Only when hw_prefcore and early prefcore param are true,
+ *               AMD P-State driver supports preferred core featue.
+ * @epp_policy: Last saved policy used to set energy-performance preference
+ * @epp_cached: Cached CPPC energy-performance preference value
+ * @policy: Cpufreq policy value
+ * @cppc_cap1_cached Cached MSR_AMD_CPPC_CAP1 register value
+ *
+ * The amd_cpudata is key private data for each CPU thread in AMD P-State, and
+ * represents all the attributes and goals that AMD P-State requests at runtime.
+ */
+struct amd_cpudata {
+       int     cpu;
+
+       struct  freq_qos_request req[2];
+       u64     cppc_req_cached;
+
+       u32     highest_perf;
+       u32     nominal_perf;
+       u32     lowest_nonlinear_perf;
+       u32     lowest_perf;
+       u32     prefcore_ranking;
+       u32     min_limit_perf;
+       u32     max_limit_perf;
+       u32     min_limit_freq;
+       u32     max_limit_freq;
+
+       u32     max_freq;
+       u32     min_freq;
+       u32     nominal_freq;
+       u32     lowest_nonlinear_freq;
+
+       struct amd_aperf_mperf cur;
+       struct amd_aperf_mperf prev;
+
+       u64     freq;
+       bool    boost_supported;
+       bool    hw_prefcore;
+
+       /* EPP feature related attributes*/
+       s16     epp_policy;
+       s16     epp_cached;
+       u32     policy;
+       u64     cppc_cap1_cached;
+       bool    suspended;
+};
+
+#endif /* _LINUX_AMD_PSTATE_H */
diff --git a/include/linux/amd-pstate.h b/include/linux/amd-pstate.h
deleted file mode 100644 (file)
index d58fc02..0000000
+++ /dev/null
@@ -1,137 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * linux/include/linux/amd-pstate.h
- *
- * Copyright (C) 2022 Advanced Micro Devices, Inc.
- *
- * Author: Meng Li <li.meng@amd.com>
- */
-
-#ifndef _LINUX_AMD_PSTATE_H
-#define _LINUX_AMD_PSTATE_H
-
-#include <linux/pm_qos.h>
-
-#define AMD_CPPC_EPP_PERFORMANCE               0x00
-#define AMD_CPPC_EPP_BALANCE_PERFORMANCE       0x80
-#define AMD_CPPC_EPP_BALANCE_POWERSAVE         0xBF
-#define AMD_CPPC_EPP_POWERSAVE                 0xFF
-
-/*********************************************************************
- *                        AMD P-state INTERFACE                       *
- *********************************************************************/
-/**
- * struct  amd_aperf_mperf
- * @aperf: actual performance frequency clock count
- * @mperf: maximum performance frequency clock count
- * @tsc:   time stamp counter
- */
-struct amd_aperf_mperf {
-       u64 aperf;
-       u64 mperf;
-       u64 tsc;
-};
-
-/**
- * struct amd_cpudata - private CPU data for AMD P-State
- * @cpu: CPU number
- * @req: constraint request to apply
- * @cppc_req_cached: cached performance request hints
- * @highest_perf: the maximum performance an individual processor may reach,
- *               assuming ideal conditions
- *               For platforms that do not support the preferred core feature, the
- *               highest_pef may be configured with 166 or 255, to avoid max frequency
- *               calculated wrongly. we take the fixed value as the highest_perf.
- * @nominal_perf: the maximum sustained performance level of the processor,
- *               assuming ideal operating conditions
- * @lowest_nonlinear_perf: the lowest performance level at which nonlinear power
- *                        savings are achieved
- * @lowest_perf: the absolute lowest performance level of the processor
- * @prefcore_ranking: the preferred core ranking, the higher value indicates a higher
- *               priority.
- * @min_limit_perf: Cached value of the performance corresponding to policy->min
- * @max_limit_perf: Cached value of the performance corresponding to policy->max
- * @min_limit_freq: Cached value of policy->min (in khz)
- * @max_limit_freq: Cached value of policy->max (in khz)
- * @max_freq: the frequency (in khz) that mapped to highest_perf
- * @min_freq: the frequency (in khz) that mapped to lowest_perf
- * @nominal_freq: the frequency (in khz) that mapped to nominal_perf
- * @lowest_nonlinear_freq: the frequency (in khz) that mapped to lowest_nonlinear_perf
- * @cur: Difference of Aperf/Mperf/tsc count between last and current sample
- * @prev: Last Aperf/Mperf/tsc count value read from register
- * @freq: current cpu frequency value (in khz)
- * @boost_supported: check whether the Processor or SBIOS supports boost mode
- * @hw_prefcore: check whether HW supports preferred core featue.
- *               Only when hw_prefcore and early prefcore param are true,
- *               AMD P-State driver supports preferred core featue.
- * @epp_policy: Last saved policy used to set energy-performance preference
- * @epp_cached: Cached CPPC energy-performance preference value
- * @policy: Cpufreq policy value
- * @cppc_cap1_cached Cached MSR_AMD_CPPC_CAP1 register value
- *
- * The amd_cpudata is key private data for each CPU thread in AMD P-State, and
- * represents all the attributes and goals that AMD P-State requests at runtime.
- */
-struct amd_cpudata {
-       int     cpu;
-
-       struct  freq_qos_request req[2];
-       u64     cppc_req_cached;
-
-       u32     highest_perf;
-       u32     nominal_perf;
-       u32     lowest_nonlinear_perf;
-       u32     lowest_perf;
-       u32     prefcore_ranking;
-       u32     min_limit_perf;
-       u32     max_limit_perf;
-       u32     min_limit_freq;
-       u32     max_limit_freq;
-
-       u32     max_freq;
-       u32     min_freq;
-       u32     nominal_freq;
-       u32     lowest_nonlinear_freq;
-
-       struct amd_aperf_mperf cur;
-       struct amd_aperf_mperf prev;
-
-       u64     freq;
-       bool    boost_supported;
-       bool    hw_prefcore;
-
-       /* EPP feature related attributes*/
-       s16     epp_policy;
-       s16     epp_cached;
-       u32     policy;
-       u64     cppc_cap1_cached;
-       bool    suspended;
-};
-
-/*
- * enum amd_pstate_mode - driver working mode of amd pstate
- */
-enum amd_pstate_mode {
-       AMD_PSTATE_UNDEFINED = 0,
-       AMD_PSTATE_DISABLE,
-       AMD_PSTATE_PASSIVE,
-       AMD_PSTATE_ACTIVE,
-       AMD_PSTATE_GUIDED,
-       AMD_PSTATE_MAX,
-};
-
-static const char * const amd_pstate_mode_string[] = {
-       [AMD_PSTATE_UNDEFINED]   = "undefined",
-       [AMD_PSTATE_DISABLE]     = "disable",
-       [AMD_PSTATE_PASSIVE]     = "passive",
-       [AMD_PSTATE_ACTIVE]      = "active",
-       [AMD_PSTATE_GUIDED]      = "guided",
-       NULL,
-};
-
-struct quirk_entry {
-       u32 nominal_freq;
-       u32 lowest_freq;
-};
-
-#endif /* _LINUX_AMD_PSTATE_H */