]> git.baikalelectronics.ru Git - kernel.git/commitdiff
cpufreq: amd-pstate: Expose struct amd_cpudata
authorMeng Li <li.meng@amd.com>
Wed, 17 Aug 2022 03:46:27 +0000 (11:46 +0800)
committerShuah Khan <skhan@linuxfoundation.org>
Wed, 5 Oct 2022 17:05:17 +0000 (11:05 -0600)
Expose struct amd_cpudata to AMD P-State unit test module.

This data struct will be used on the following AMD P-State unit test
(amd-pstate-ut) module. The amd-pstate-ut module can get some
AMD infomations by this data struct. For example: highest perf,
nominal perf, boost supported etc.

Signed-off-by: Meng Li <li.meng@amd.com>
Acked-by: Huang Rui <ray.huang@amd.com>
Acked-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
MAINTAINERS
drivers/cpufreq/amd-pstate.c
include/linux/amd-pstate.h [new file with mode: 0644]

index 8a5012ba6ff98ac6f4a1415b3fce51423329c2d2..5c404d2686d15432b2f4e3b54926720154ab4b59 100644 (file)
@@ -1045,6 +1045,7 @@ 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 9ac75c1cde9c22fc3bcee6885521477ea1352625..218f777a59152aeaed512ce0cffb90c5390b50b4 100644 (file)
@@ -36,6 +36,7 @@
 #include <linux/delay.h>
 #include <linux/uaccess.h>
 #include <linux/static_call.h>
+#include <linux/amd-pstate.h>
 
 #include <acpi/processor.h>
 #include <acpi/cppc_acpi.h>
@@ -65,65 +66,6 @@ MODULE_PARM_DESC(shared_mem,
 
 static struct cpufreq_driver amd_pstate_driver;
 
-/**
- * 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
- * @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
- * @max_freq: the frequency that mapped to highest_perf
- * @min_freq: the frequency that mapped to lowest_perf
- * @nominal_freq: the frequency that mapped to nominal_perf
- * @lowest_nonlinear_freq: the frequency 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
- * @boost_supported: check whether the Processor or SBIOS supports boost mode
- *
- * 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     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;
-};
-
 static inline int pstate_enable(bool enable)
 {
        return wrmsrl_safe(MSR_AMD_CPPC_ENABLE, enable);
diff --git a/include/linux/amd-pstate.h b/include/linux/amd-pstate.h
new file mode 100644 (file)
index 0000000..1c4b865
--- /dev/null
@@ -0,0 +1,77 @@
+/* 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>
+
+/*********************************************************************
+ *                        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
+ * @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
+ * @max_freq: the frequency that mapped to highest_perf
+ * @min_freq: the frequency that mapped to lowest_perf
+ * @nominal_freq: the frequency that mapped to nominal_perf
+ * @lowest_nonlinear_freq: the frequency 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
+ * @boost_supported: check whether the Processor or SBIOS supports boost mode
+ *
+ * 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     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;
+};
+
+#endif /* _LINUX_AMD_PSTATE_H */