linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 00/13] AMD Pstate Enhancement And Issue Fixs
@ 2022-07-12 15:32 Perry Yuan
  2022-07-12 15:35 ` [PATCH v3 01/13] x86/msr: Add the MSR definition for AMD CPPC hardware control Perry Yuan
                   ` (12 more replies)
  0 siblings, 13 replies; 25+ messages in thread
From: Perry Yuan @ 2022-07-12 15:32 UTC (permalink / raw)
  To: rafael.j.wysocki, viresh.kumar, Ray.Huang
  Cc: Deepak.Sharma, Mario.Limonciello, Nathan.Fontenot,
	Alexander.Deucher, Jinzhou.Su, Xinmei.Huang, Xiaojian.Du,
	Li.Meng, linux-pm, linux-kernel, Perry Yuan

This patchsets adds support for precision boost hardware control
for AMD processors.

Meanwhile the patchset fixs lowest perf query and desired perf scope issues.
Update transition delay and latency default value to meet SMU firmware requirement.
and do some code cleanups,
It also exports cpufreq cpu release and acquire for coming amd-pstate epp mode driver

The patch series are tested on the AMD mobile and EYPC server systems

v2->v3:
- drop cpufreq cpu release and acquire export patch
- remove the clamp_t in the amd_pstate_adjust_perf()

v1->v2:
- add two new patches to remove the acpi_disabled check
- fix some typos in the commit info
- move the clamp_t() into amd_pstate_update() function
- rebased to 5.19-rc5

[1]:https://patchwork.kernel.org/project/linux-pm/list/?series=657510
[2]:https://lore.kernel.org/lkml/20220709140835.830084-1-Perry.Yuan@amd.com/

Perry Yuan (13):
  x86/msr: Add the MSR definition for AMD CPPC hardware control.
  cpufreq: amd-pstate: enable AMD Precision Boost mode switch
  cpufreq: amd-pstate: cleanup the unused and duplicated headers
    declaration
  cpufreq: amd-pstate: prefetch cppc_req_cached value in
    amd_pstate_cpu_init()
  cpufreq: amd-pstate: simplify cpudata pointer assignment
  cpufreq: amd_pstate: fix wrong lowest perf fetch
  cpufreq: amd_pstate: map desired perf into pstate scope for powersave
    governor
  cpufreq: amd-pstate: fix white-space
  cpufreq: amd-pstate: update pstate frequency transition delay time
  cpufreq: amd-pstate: add ACPI disabled check in acpi_cpc_valid()
  cpufreq: amd_pstate: update transition delay time to 1ms
  arch_topology: remove the acpi_disabled check
  cpufreq: CPPC: remove the acpi_disabled check

 arch/x86/include/asm/msr-index.h |  3 ++
 drivers/acpi/cppc_acpi.c         |  3 ++
 drivers/base/arch_topology.c     |  2 +-
 drivers/cpufreq/amd-pstate.c     | 59 ++++++++++++++++++--------------
 drivers/cpufreq/cppc_cpufreq.c   |  2 +-
 5 files changed, 42 insertions(+), 27 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH v3 01/13] x86/msr: Add the MSR definition for AMD CPPC hardware control.
  2022-07-12 15:32 [PATCH v3 00/13] AMD Pstate Enhancement And Issue Fixs Perry Yuan
@ 2022-07-12 15:35 ` Perry Yuan
  2022-07-12 15:39 ` [PATCH v3 02/13] cpufreq: amd-pstate: enable AMD Precision Boost mode switch Perry Yuan
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 25+ messages in thread
From: Perry Yuan @ 2022-07-12 15:35 UTC (permalink / raw)
  To: rafael.j.wysocki, viresh.kumar, Ray.Huang
  Cc: Deepak.Sharma, Mario.Limonciello, Nathan.Fontenot,
	Alexander.Deucher, Jinzhou.Su, Xinmei.Huang, Xiaojian.Du,
	Li.Meng, linux-pm, linux-kernel, Perry Yuan, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
	Peter Zijlstra, Adrian Hunter, Pawan Gupta, Alexander Shishkin,
	Sumeet Pawnikar, Huang Rui, Tony Luck, Ricardo Neri

This MSR can be used for controlling whether the CPU boost state
is enabled in the hardware.

AMD Processor Programming Reference (PPR)
Link: https://www.amd.com/system/files/TechDocs/40332.pdf [p1095]
Link: https://www.amd.com/system/files/TechDocs/56569-A1-PUB.zip [p162]

Signed-off-by: Perry Yuan <Perry.Yuan@amd.com>
---
 arch/x86/include/asm/msr-index.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h
index d27e0581b777..869508de8269 100644
--- a/arch/x86/include/asm/msr-index.h
+++ b/arch/x86/include/asm/msr-index.h
@@ -548,6 +548,7 @@
 #define MSR_AMD_CPPC_CAP2		0xc00102b2
 #define MSR_AMD_CPPC_REQ		0xc00102b3
 #define MSR_AMD_CPPC_STATUS		0xc00102b4
+#define MSR_AMD_CPPC_HW_CTL		0xc0010015
 
 #define AMD_CPPC_LOWEST_PERF(x)		(((x) >> 0) & 0xff)
 #define AMD_CPPC_LOWNONLIN_PERF(x)	(((x) >> 8) & 0xff)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v3 02/13] cpufreq: amd-pstate: enable AMD Precision Boost mode switch
  2022-07-12 15:32 [PATCH v3 00/13] AMD Pstate Enhancement And Issue Fixs Perry Yuan
  2022-07-12 15:35 ` [PATCH v3 01/13] x86/msr: Add the MSR definition for AMD CPPC hardware control Perry Yuan
@ 2022-07-12 15:39 ` Perry Yuan
  2022-07-12 15:40 ` [PATCH v3 03/13] cpufreq: amd-pstate: cleanup the unused and duplicated headers declaration Perry Yuan
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 25+ messages in thread
From: Perry Yuan @ 2022-07-12 15:39 UTC (permalink / raw)
  To: rafael.j.wysocki, viresh.kumar, Ray.Huang
  Cc: Deepak.Sharma, Mario.Limonciello, Nathan.Fontenot,
	Alexander.Deucher, Jinzhou.Su, Xinmei.Huang, Xiaojian.Du,
	Li.Meng, linux-pm, linux-kernel, Perry Yuan, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
	Huang Rui, Rafael J. Wysocki, Peter Zijlstra, Adrian Hunter,
	Pawan Gupta, Chang S. Bae, Alexander Shishkin, Sumeet Pawnikar,
	Stephane Eranian, Tony Luck, Ricardo Neri

Add support to switch AMD precision boost state to scale cpu max
frequency that will help to improve the processor throughput.

when set boost state to be enabled, user will need to execute below commands,
the CPU will reach absolute maximum performance level or the highest perf which
CPU physical support. This performance level may not be sustainable for
long durations, it will help to improve the IO workload tasks.

* turn on CPU boost state under root
  echo 1 > /sys/devices/system/cpu/cpufreq/boost

If user set boost off,the CPU can reach to the maximum sustained
performance level of the process, that level is the process can maintain
continously working and definitely it can save some power compared to
boost on mode.

* turn off CPU boost state under root
  echo 0 > /sys/devices/system/cpu/cpufreq/boost

Signed-off-by: Perry Yuan <Perry.Yuan@amd.com>
---
 arch/x86/include/asm/msr-index.h |  2 ++
 drivers/cpufreq/amd-pstate.c     | 22 +++++++++++++++++++---
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h
index 869508de8269..b952fd6d6916 100644
--- a/arch/x86/include/asm/msr-index.h
+++ b/arch/x86/include/asm/msr-index.h
@@ -559,6 +559,8 @@
 #define AMD_CPPC_MIN_PERF(x)		(((x) & 0xff) << 8)
 #define AMD_CPPC_DES_PERF(x)		(((x) & 0xff) << 16)
 #define AMD_CPPC_ENERGY_PERF_PREF(x)	(((x) & 0xff) << 24)
+#define AMD_CPPC_PRECISION_BOOST_BIT	25
+#define AMD_CPPC_PRECISION_BOOST_ENABLED	BIT_ULL(AMD_CPPC_PRECISION_BOOST_BIT)
 
 /* AMD Performance Counter Global Status and Control MSRs */
 #define MSR_AMD64_PERF_CNTR_GLOBAL_STATUS	0xc0000300
diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
index 9ac75c1cde9c..188e055e24a2 100644
--- a/drivers/cpufreq/amd-pstate.c
+++ b/drivers/cpufreq/amd-pstate.c
@@ -122,6 +122,7 @@ struct amd_cpudata {
 
 	u64 freq;
 	bool	boost_supported;
+	u64 	cppc_hw_conf_cached;
 };
 
 static inline int pstate_enable(bool enable)
@@ -438,18 +439,27 @@ static int amd_pstate_set_boost(struct cpufreq_policy *policy, int state)
 {
 	struct amd_cpudata *cpudata = policy->driver_data;
 	int ret;
+	u64 value;
 
 	if (!cpudata->boost_supported) {
 		pr_err("Boost mode is not supported by this processor or SBIOS\n");
 		return -EINVAL;
 	}
 
-	if (state)
+	ret = rdmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_HW_CTL, &value);
+	if (ret)
+		return ret;
+
+	if (state) {
+		value |= AMD_CPPC_PRECISION_BOOST_ENABLED;
 		policy->cpuinfo.max_freq = cpudata->max_freq;
-	else
+	} else {
+		value &= ~AMD_CPPC_PRECISION_BOOST_ENABLED;
 		policy->cpuinfo.max_freq = cpudata->nominal_freq;
-
+	}
 	policy->max = policy->cpuinfo.max_freq;
+	WRITE_ONCE(cpudata->cppc_hw_conf_cached, value);
+	wrmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_HW_CTL, value);
 
 	ret = freq_qos_update_request(&cpudata->req[1],
 				      policy->cpuinfo.max_freq);
@@ -478,6 +488,7 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy)
 	int min_freq, max_freq, nominal_freq, lowest_nonlinear_freq, ret;
 	struct device *dev;
 	struct amd_cpudata *cpudata;
+	u64 value;
 
 	dev = get_cpu_device(policy->cpu);
 	if (!dev)
@@ -542,6 +553,11 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy)
 
 	policy->driver_data = cpudata;
 
+	ret = rdmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_HW_CTL, &value);
+	if (ret)
+		return ret;
+	WRITE_ONCE(cpudata->cppc_hw_conf_cached, value);
+
 	amd_pstate_boost_init(cpudata);
 
 	return 0;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v3 03/13] cpufreq: amd-pstate: cleanup the unused and duplicated headers declaration
  2022-07-12 15:32 [PATCH v3 00/13] AMD Pstate Enhancement And Issue Fixs Perry Yuan
  2022-07-12 15:35 ` [PATCH v3 01/13] x86/msr: Add the MSR definition for AMD CPPC hardware control Perry Yuan
  2022-07-12 15:39 ` [PATCH v3 02/13] cpufreq: amd-pstate: enable AMD Precision Boost mode switch Perry Yuan
@ 2022-07-12 15:40 ` Perry Yuan
  2022-07-13  5:27   ` Viresh Kumar
  2022-07-12 15:40 ` [PATCH v3 04/13] cpufreq: amd-pstate: prefetch cppc_req_cached value in amd_pstate_cpu_init() Perry Yuan
                   ` (9 subsequent siblings)
  12 siblings, 1 reply; 25+ messages in thread
From: Perry Yuan @ 2022-07-12 15:40 UTC (permalink / raw)
  To: rafael.j.wysocki, viresh.kumar, Ray.Huang
  Cc: Deepak.Sharma, Mario.Limonciello, Nathan.Fontenot,
	Alexander.Deucher, Jinzhou.Su, Xinmei.Huang, Xiaojian.Du,
	Li.Meng, linux-pm, linux-kernel, Perry Yuan, Huang Rui,
	Rafael J. Wysocki

Cleanup the headers declaration which are not used
actually and some duplicated declaration which is declarated in some
other headers already, it will help to simplify the header part.

Signed-off-by: Perry Yuan <Perry.Yuan@amd.com>
---
 drivers/cpufreq/amd-pstate.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
index 188e055e24a2..43e6df9f67f6 100644
--- a/drivers/cpufreq/amd-pstate.c
+++ b/drivers/cpufreq/amd-pstate.c
@@ -31,19 +31,14 @@
 #include <linux/compiler.h>
 #include <linux/dmi.h>
 #include <linux/slab.h>
-#include <linux/acpi.h>
 #include <linux/io.h>
 #include <linux/delay.h>
 #include <linux/uaccess.h>
 #include <linux/static_call.h>
 
-#include <acpi/processor.h>
 #include <acpi/cppc_acpi.h>
 
 #include <asm/msr.h>
-#include <asm/processor.h>
-#include <asm/cpufeature.h>
-#include <asm/cpu_device_id.h>
 #include "amd-pstate-trace.h"
 
 #define AMD_PSTATE_TRANSITION_LATENCY	0x20000
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v3 04/13] cpufreq: amd-pstate: prefetch cppc_req_cached value in amd_pstate_cpu_init()
  2022-07-12 15:32 [PATCH v3 00/13] AMD Pstate Enhancement And Issue Fixs Perry Yuan
                   ` (2 preceding siblings ...)
  2022-07-12 15:40 ` [PATCH v3 03/13] cpufreq: amd-pstate: cleanup the unused and duplicated headers declaration Perry Yuan
@ 2022-07-12 15:40 ` Perry Yuan
  2022-07-13  5:27   ` Viresh Kumar
  2022-07-12 15:40 ` [PATCH v3 05/13] cpufreq: amd-pstate: simplify cpudata pointer assignment Perry Yuan
                   ` (8 subsequent siblings)
  12 siblings, 1 reply; 25+ messages in thread
From: Perry Yuan @ 2022-07-12 15:40 UTC (permalink / raw)
  To: rafael.j.wysocki, viresh.kumar, Ray.Huang
  Cc: Deepak.Sharma, Mario.Limonciello, Nathan.Fontenot,
	Alexander.Deucher, Jinzhou.Su, Xinmei.Huang, Xiaojian.Du,
	Li.Meng, linux-pm, linux-kernel, Perry Yuan, Huang Rui,
	Rafael J. Wysocki

This cppc_req_cached valued should be prefetched during
amd_pstate_cpu_init call period, then the amd_pstate_update() will get
correct cached value before updating the perf to change the cpu perf
level.

Signed-off-by: Perry Yuan <Perry.Yuan@amd.com>
---
 drivers/cpufreq/amd-pstate.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
index 43e6df9f67f6..e4904da54541 100644
--- a/drivers/cpufreq/amd-pstate.c
+++ b/drivers/cpufreq/amd-pstate.c
@@ -547,12 +547,17 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy)
 	cpudata->lowest_nonlinear_freq = lowest_nonlinear_freq;
 
 	policy->driver_data = cpudata;
+	if (!shared_mem) {
+		ret = rdmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_HW_CTL, &value);
+		if (ret)
+			return ret;
+		WRITE_ONCE(cpudata->cppc_hw_conf_cached, value);
 
-	ret = rdmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_HW_CTL, &value);
-	if (ret)
-		return ret;
-	WRITE_ONCE(cpudata->cppc_hw_conf_cached, value);
-
+		ret = rdmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ, &value);
+		if (ret)
+			return ret;
+		WRITE_ONCE(cpudata->cppc_req_cached, value);
+	}
 	amd_pstate_boost_init(cpudata);
 
 	return 0;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v3 05/13] cpufreq: amd-pstate: simplify cpudata pointer assignment
  2022-07-12 15:32 [PATCH v3 00/13] AMD Pstate Enhancement And Issue Fixs Perry Yuan
                   ` (3 preceding siblings ...)
  2022-07-12 15:40 ` [PATCH v3 04/13] cpufreq: amd-pstate: prefetch cppc_req_cached value in amd_pstate_cpu_init() Perry Yuan
@ 2022-07-12 15:40 ` Perry Yuan
  2022-07-13  5:27   ` Viresh Kumar
  2022-07-12 15:41 ` [PATCH v3 06/13] cpufreq: amd_pstate: fix wrong lowest perf fetch Perry Yuan
                   ` (7 subsequent siblings)
  12 siblings, 1 reply; 25+ messages in thread
From: Perry Yuan @ 2022-07-12 15:40 UTC (permalink / raw)
  To: rafael.j.wysocki, viresh.kumar, Ray.Huang
  Cc: Deepak.Sharma, Mario.Limonciello, Nathan.Fontenot,
	Alexander.Deucher, Jinzhou.Su, Xinmei.Huang, Xiaojian.Du,
	Li.Meng, linux-pm, linux-kernel, Perry Yuan, Huang Rui,
	Rafael J. Wysocki

move the cpudata assignment to cpudata declaration which
will simplify the functions.

No functional change intended.

Signed-off-by: Perry Yuan <Perry.Yuan@amd.com>
---
 drivers/cpufreq/amd-pstate.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
index e4904da54541..fc0de9fd643b 100644
--- a/drivers/cpufreq/amd-pstate.c
+++ b/drivers/cpufreq/amd-pstate.c
@@ -571,9 +571,7 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy)
 
 static int amd_pstate_cpu_exit(struct cpufreq_policy *policy)
 {
-	struct amd_cpudata *cpudata;
-
-	cpudata = policy->driver_data;
+	struct amd_cpudata *cpudata = policy->driver_data;
 
 	freq_qos_remove_request(&cpudata->req[1]);
 	freq_qos_remove_request(&cpudata->req[0]);
@@ -615,9 +613,7 @@ static ssize_t show_amd_pstate_max_freq(struct cpufreq_policy *policy,
 					char *buf)
 {
 	int max_freq;
-	struct amd_cpudata *cpudata;
-
-	cpudata = policy->driver_data;
+	struct amd_cpudata *cpudata = policy->driver_data;
 
 	max_freq = amd_get_max_freq(cpudata);
 	if (max_freq < 0)
@@ -630,9 +626,7 @@ static ssize_t show_amd_pstate_lowest_nonlinear_freq(struct cpufreq_policy *poli
 						     char *buf)
 {
 	int freq;
-	struct amd_cpudata *cpudata;
-
-	cpudata = policy->driver_data;
+	struct amd_cpudata *cpudata = policy->driver_data;
 
 	freq = amd_get_lowest_nonlinear_freq(cpudata);
 	if (freq < 0)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v3 06/13] cpufreq: amd_pstate: fix wrong lowest perf fetch
  2022-07-12 15:32 [PATCH v3 00/13] AMD Pstate Enhancement And Issue Fixs Perry Yuan
                   ` (4 preceding siblings ...)
  2022-07-12 15:40 ` [PATCH v3 05/13] cpufreq: amd-pstate: simplify cpudata pointer assignment Perry Yuan
@ 2022-07-12 15:41 ` Perry Yuan
  2022-07-13  5:27   ` Viresh Kumar
  2022-07-12 15:41 ` [PATCH v3 07/13] cpufreq: amd_pstate: map desired perf into pstate scope for powersave governor Perry Yuan
                   ` (6 subsequent siblings)
  12 siblings, 1 reply; 25+ messages in thread
From: Perry Yuan @ 2022-07-12 15:41 UTC (permalink / raw)
  To: rafael.j.wysocki, viresh.kumar, Ray.Huang
  Cc: Deepak.Sharma, Mario.Limonciello, Nathan.Fontenot,
	Alexander.Deucher, Jinzhou.Su, Xinmei.Huang, Xiaojian.Du,
	Li.Meng, linux-pm, linux-kernel, Perry Yuan, Su Jinzhou,
	Huang Rui, Rafael J. Wysocki

Fix the wrong lowest perf value reading which is used for new
des_perf calculation by governor requested, the incorrect min_perf will
get incorrect des_perf to be set , that will cause the system frequency
changing unexpectedly.

Signed-off-by: Perry Yuan <Perry.Yuan@amd.com>
Signed-off-by: Su Jinzhou <jinzhou.su@amd.com>
---
 drivers/cpufreq/amd-pstate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
index fc0de9fd643b..7c51f4125263 100644
--- a/drivers/cpufreq/amd-pstate.c
+++ b/drivers/cpufreq/amd-pstate.c
@@ -308,7 +308,7 @@ static int amd_pstate_target(struct cpufreq_policy *policy,
 		return -ENODEV;
 
 	cap_perf = READ_ONCE(cpudata->highest_perf);
-	min_perf = READ_ONCE(cpudata->lowest_nonlinear_perf);
+	min_perf = READ_ONCE(cpudata->lowest_perf);
 	max_perf = cap_perf;
 
 	freqs.old = policy->cur;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v3 07/13] cpufreq: amd_pstate: map desired perf into pstate scope for powersave governor
  2022-07-12 15:32 [PATCH v3 00/13] AMD Pstate Enhancement And Issue Fixs Perry Yuan
                   ` (5 preceding siblings ...)
  2022-07-12 15:41 ` [PATCH v3 06/13] cpufreq: amd_pstate: fix wrong lowest perf fetch Perry Yuan
@ 2022-07-12 15:41 ` Perry Yuan
  2022-07-12 15:41 ` [PATCH v3 08/13] cpufreq: amd-pstate: fix white-space Perry Yuan
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 25+ messages in thread
From: Perry Yuan @ 2022-07-12 15:41 UTC (permalink / raw)
  To: rafael.j.wysocki, viresh.kumar, Ray.Huang
  Cc: Deepak.Sharma, Mario.Limonciello, Nathan.Fontenot,
	Alexander.Deucher, Jinzhou.Su, Xinmei.Huang, Xiaojian.Du,
	Li.Meng, linux-pm, linux-kernel, Perry Yuan, Huang Rui,
	Rafael J. Wysocki

The patch will fix the invalid desired perf value for powersave
governor. This issue is found when testing on one AMD EPYC system, the
actual des_perf is smaller than the min_perf value, that is invalid
value. because the min_perf is the lowest_perf system can support in
idle state.

Signed-off-by: Perry Yuan <Perry.Yuan@amd.com>
---
 drivers/cpufreq/amd-pstate.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
index 7c51f4125263..f359b1b20140 100644
--- a/drivers/cpufreq/amd-pstate.c
+++ b/drivers/cpufreq/amd-pstate.c
@@ -265,6 +265,7 @@ static void amd_pstate_update(struct amd_cpudata *cpudata, u32 min_perf,
 	u64 prev = READ_ONCE(cpudata->cppc_req_cached);
 	u64 value = prev;
 
+	des_perf = clamp_t(unsigned long, des_perf, min_perf, max_perf);
 	value &= ~AMD_CPPC_MIN_PERF(~0L);
 	value |= AMD_CPPC_MIN_PERF(min_perf);
 
@@ -353,8 +354,6 @@ static void amd_pstate_adjust_perf(unsigned int cpu,
 	if (max_perf < min_perf)
 		max_perf = min_perf;
 
-	des_perf = clamp_t(unsigned long, des_perf, min_perf, max_perf);
-
 	amd_pstate_update(cpudata, min_perf, des_perf, max_perf, true);
 }
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v3 08/13] cpufreq: amd-pstate: fix white-space
  2022-07-12 15:32 [PATCH v3 00/13] AMD Pstate Enhancement And Issue Fixs Perry Yuan
                   ` (6 preceding siblings ...)
  2022-07-12 15:41 ` [PATCH v3 07/13] cpufreq: amd_pstate: map desired perf into pstate scope for powersave governor Perry Yuan
@ 2022-07-12 15:41 ` Perry Yuan
  2022-07-13  5:28   ` Viresh Kumar
  2022-07-12 15:42 ` [PATCH v3 09/13] cpufreq: amd-pstate: update pstate frequency transition delay time Perry Yuan
                   ` (4 subsequent siblings)
  12 siblings, 1 reply; 25+ messages in thread
From: Perry Yuan @ 2022-07-12 15:41 UTC (permalink / raw)
  To: rafael.j.wysocki, viresh.kumar, Ray.Huang
  Cc: Deepak.Sharma, Mario.Limonciello, Nathan.Fontenot,
	Alexander.Deucher, Jinzhou.Su, Xinmei.Huang, Xiaojian.Du,
	Li.Meng, linux-pm, linux-kernel, Perry Yuan, Huang Rui,
	Rafael J. Wysocki

Remove the white space and correct mixed-up indentation

Signed-off-by: Perry Yuan <Perry.Yuan@amd.com>
---
 drivers/cpufreq/amd-pstate.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
index f359b1b20140..312ccef62f58 100644
--- a/drivers/cpufreq/amd-pstate.c
+++ b/drivers/cpufreq/amd-pstate.c
@@ -115,7 +115,7 @@ struct amd_cpudata {
 	struct amd_aperf_mperf cur;
 	struct amd_aperf_mperf prev;
 
-	u64 freq;
+	u64 	freq;
 	bool	boost_supported;
 	u64 	cppc_hw_conf_cached;
 };
@@ -671,7 +671,7 @@ static struct cpufreq_driver amd_pstate_driver = {
 	.resume		= amd_pstate_cpu_resume,
 	.set_boost	= amd_pstate_set_boost,
 	.name		= "amd-pstate",
-	.attr           = amd_pstate_attr,
+	.attr		= amd_pstate_attr,
 };
 
 static int __init amd_pstate_init(void)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v3 09/13] cpufreq: amd-pstate: update pstate frequency transition delay time
  2022-07-12 15:32 [PATCH v3 00/13] AMD Pstate Enhancement And Issue Fixs Perry Yuan
                   ` (7 preceding siblings ...)
  2022-07-12 15:41 ` [PATCH v3 08/13] cpufreq: amd-pstate: fix white-space Perry Yuan
@ 2022-07-12 15:42 ` Perry Yuan
  2022-07-13  5:28   ` Viresh Kumar
  2022-07-12 15:42 ` [PATCH v3 10/13] cpufreq: amd-pstate: add ACPI disabled check in acpi_cpc_valid() Perry Yuan
                   ` (3 subsequent siblings)
  12 siblings, 1 reply; 25+ messages in thread
From: Perry Yuan @ 2022-07-12 15:42 UTC (permalink / raw)
  To: rafael.j.wysocki, viresh.kumar, Ray.Huang
  Cc: Deepak.Sharma, Mario.Limonciello, Nathan.Fontenot,
	Alexander.Deucher, Jinzhou.Su, Xinmei.Huang, Xiaojian.Du,
	Li.Meng, linux-pm, linux-kernel, Perry Yuan, Huang Rui,
	Rafael J. Wysocki

change the default transition latency to be 20ms that is more
reasonable transition delay for AMD processors in non-EPP driver mode.

Signed-off-by: Perry Yuan <Perry.Yuan@amd.com>
---
 drivers/cpufreq/amd-pstate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
index 312ccef62f58..1e5ca4897b7e 100644
--- a/drivers/cpufreq/amd-pstate.c
+++ b/drivers/cpufreq/amd-pstate.c
@@ -41,7 +41,7 @@
 #include <asm/msr.h>
 #include "amd-pstate-trace.h"
 
-#define AMD_PSTATE_TRANSITION_LATENCY	0x20000
+#define AMD_PSTATE_TRANSITION_LATENCY	20000
 #define AMD_PSTATE_TRANSITION_DELAY	500
 
 /*
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v3 10/13] cpufreq: amd-pstate: add ACPI disabled check in acpi_cpc_valid()
  2022-07-12 15:32 [PATCH v3 00/13] AMD Pstate Enhancement And Issue Fixs Perry Yuan
                   ` (8 preceding siblings ...)
  2022-07-12 15:42 ` [PATCH v3 09/13] cpufreq: amd-pstate: update pstate frequency transition delay time Perry Yuan
@ 2022-07-12 15:42 ` Perry Yuan
  2022-07-12 15:42 ` [PATCH v3 11/13] cpufreq: amd_pstate: update transition delay time to 1ms Perry Yuan
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 25+ messages in thread
From: Perry Yuan @ 2022-07-12 15:42 UTC (permalink / raw)
  To: rafael.j.wysocki, viresh.kumar, Ray.Huang
  Cc: Deepak.Sharma, Mario.Limonciello, Nathan.Fontenot,
	Alexander.Deucher, Jinzhou.Su, Xinmei.Huang, Xiaojian.Du,
	Li.Meng, linux-pm, linux-kernel, Perry Yuan, Rafael J. Wysocki,
	Len Brown, Huang Rui, linux-acpi

Add acpi function check in case ACPI is not enabled, that will cause
pstate driver failed to call cppc acpi to change perf or update epp
value for shared memory solution processors.

When CPPC or ACPI is invalid, warning log will be needed to tell
user that AMD pstate driver failed to load and what is wrong.

Signed-off-by: Perry Yuan <Perry.Yuan@amd.com>
---
 drivers/acpi/cppc_acpi.c     | 3 +++
 drivers/cpufreq/amd-pstate.c | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
index 6ff1901d7d43..17d67e3ededf 100644
--- a/drivers/acpi/cppc_acpi.c
+++ b/drivers/acpi/cppc_acpi.c
@@ -424,6 +424,9 @@ bool acpi_cpc_valid(void)
 	struct cpc_desc *cpc_ptr;
 	int cpu;
 
+	if (acpi_disabled)
+		return false;
+
 	for_each_present_cpu(cpu) {
 		cpc_ptr = per_cpu(cpc_desc_ptr, cpu);
 		if (!cpc_ptr)
diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
index 1e5ca4897b7e..a9918728948a 100644
--- a/drivers/cpufreq/amd-pstate.c
+++ b/drivers/cpufreq/amd-pstate.c
@@ -682,7 +682,7 @@ static int __init amd_pstate_init(void)
 		return -ENODEV;
 
 	if (!acpi_cpc_valid()) {
-		pr_debug("the _CPC object is not present in SBIOS\n");
+		pr_warn_once("the _CPC object is not present in SBIOS or ACPI disabled\n");
 		return -ENODEV;
 	}
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v3 11/13] cpufreq: amd_pstate: update transition delay time to 1ms
  2022-07-12 15:32 [PATCH v3 00/13] AMD Pstate Enhancement And Issue Fixs Perry Yuan
                   ` (9 preceding siblings ...)
  2022-07-12 15:42 ` [PATCH v3 10/13] cpufreq: amd-pstate: add ACPI disabled check in acpi_cpc_valid() Perry Yuan
@ 2022-07-12 15:42 ` Perry Yuan
  2022-07-13  5:29   ` Viresh Kumar
  2022-07-12 15:43 ` [PATCH v3 12/13] arch_topology: remove the acpi_disabled check Perry Yuan
  2022-07-12 15:43 ` [PATCH v3 13/13] cpufreq: CPPC: " Perry Yuan
  12 siblings, 1 reply; 25+ messages in thread
From: Perry Yuan @ 2022-07-12 15:42 UTC (permalink / raw)
  To: rafael.j.wysocki, viresh.kumar, Ray.Huang
  Cc: Deepak.Sharma, Mario.Limonciello, Nathan.Fontenot,
	Alexander.Deucher, Jinzhou.Su, Xinmei.Huang, Xiaojian.Du,
	Li.Meng, linux-pm, linux-kernel, Perry Yuan, Huang Rui,
	Rafael J. Wysocki

Update transition delay time to 1ms, in the AMD CPU autonomous mode and
non-autonomous mode, CPPC firmware will decide frequency at 1ms timescale
based on the workload utilization.

Signed-off-by: Perry Yuan <Perry.Yuan@amd.com>
Signed-off-by: Su Jinzhou <Jinzhou.Su@amd.com>
---
 drivers/cpufreq/amd-pstate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
index a9918728948a..83570acecc78 100644
--- a/drivers/cpufreq/amd-pstate.c
+++ b/drivers/cpufreq/amd-pstate.c
@@ -42,7 +42,7 @@
 #include "amd-pstate-trace.h"
 
 #define AMD_PSTATE_TRANSITION_LATENCY	20000
-#define AMD_PSTATE_TRANSITION_DELAY	500
+#define AMD_PSTATE_TRANSITION_DELAY	1000
 
 /*
  * TODO: We need more time to fine tune processors with shared memory solution
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v3 12/13] arch_topology: remove the acpi_disabled check
  2022-07-12 15:32 [PATCH v3 00/13] AMD Pstate Enhancement And Issue Fixs Perry Yuan
                   ` (10 preceding siblings ...)
  2022-07-12 15:42 ` [PATCH v3 11/13] cpufreq: amd_pstate: update transition delay time to 1ms Perry Yuan
@ 2022-07-12 15:43 ` Perry Yuan
  2022-07-13  5:29   ` Viresh Kumar
  2022-07-13 14:40   ` Sudeep Holla
  2022-07-12 15:43 ` [PATCH v3 13/13] cpufreq: CPPC: " Perry Yuan
  12 siblings, 2 replies; 25+ messages in thread
From: Perry Yuan @ 2022-07-12 15:43 UTC (permalink / raw)
  To: rafael.j.wysocki, viresh.kumar, Ray.Huang
  Cc: Deepak.Sharma, Mario.Limonciello, Nathan.Fontenot,
	Alexander.Deucher, Jinzhou.Su, Xinmei.Huang, Xiaojian.Du,
	Li.Meng, linux-pm, linux-kernel, Perry Yuan, Sudeep Holla,
	Greg Kroah-Hartman, Rafael J. Wysocki

"acpi_cpc_valid" function already includes the acpi_disabled check and we can
remove the duplicated check here

Signed-off-by: Perry Yuan <Perry.Yuan@amd.com>
---
 drivers/base/arch_topology.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c
index 579c851a2bd7..73a8cb31529d 100644
--- a/drivers/base/arch_topology.c
+++ b/drivers/base/arch_topology.c
@@ -352,7 +352,7 @@ void topology_init_cpu_capacity_cppc(void)
 	struct cppc_perf_caps perf_caps;
 	int cpu;
 
-	if (likely(acpi_disabled || !acpi_cpc_valid()))
+	if (likely(!acpi_cpc_valid()))
 		return;
 
 	raw_capacity = kcalloc(num_possible_cpus(), sizeof(*raw_capacity),
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v3 13/13] cpufreq: CPPC: remove the acpi_disabled check
  2022-07-12 15:32 [PATCH v3 00/13] AMD Pstate Enhancement And Issue Fixs Perry Yuan
                   ` (11 preceding siblings ...)
  2022-07-12 15:43 ` [PATCH v3 12/13] arch_topology: remove the acpi_disabled check Perry Yuan
@ 2022-07-12 15:43 ` Perry Yuan
  2022-07-13  5:29   ` Viresh Kumar
  12 siblings, 1 reply; 25+ messages in thread
From: Perry Yuan @ 2022-07-12 15:43 UTC (permalink / raw)
  To: rafael.j.wysocki, viresh.kumar, Ray.Huang
  Cc: Deepak.Sharma, Mario.Limonciello, Nathan.Fontenot,
	Alexander.Deucher, Jinzhou.Su, Xinmei.Huang, Xiaojian.Du,
	Li.Meng, linux-pm, linux-kernel, Perry Yuan, Rafael J. Wysocki

"acpi_cpc_valid" function already includes the acpi_disabled check and we can
remove the duplicated check here

Signed-off-by: Perry Yuan <Perry.Yuan@amd.com>
---
 drivers/cpufreq/cppc_cpufreq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c
index 24eaf0ec344d..9adb7612993e 100644
--- a/drivers/cpufreq/cppc_cpufreq.c
+++ b/drivers/cpufreq/cppc_cpufreq.c
@@ -947,7 +947,7 @@ static int __init cppc_cpufreq_init(void)
 {
 	int ret;
 
-	if ((acpi_disabled) || !acpi_cpc_valid())
+	if (!acpi_cpc_valid())
 		return -ENODEV;
 
 	cppc_check_hisi_workaround();
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 25+ messages in thread

* Re: [PATCH v3 04/13] cpufreq: amd-pstate: prefetch cppc_req_cached value in amd_pstate_cpu_init()
  2022-07-12 15:40 ` [PATCH v3 04/13] cpufreq: amd-pstate: prefetch cppc_req_cached value in amd_pstate_cpu_init() Perry Yuan
@ 2022-07-13  5:27   ` Viresh Kumar
  2022-07-13  5:57     ` Yuan, Perry
  0 siblings, 1 reply; 25+ messages in thread
From: Viresh Kumar @ 2022-07-13  5:27 UTC (permalink / raw)
  To: Perry Yuan
  Cc: rafael.j.wysocki, Ray.Huang, Deepak.Sharma, Mario.Limonciello,
	Nathan.Fontenot, Alexander.Deucher, Jinzhou.Su, Xinmei.Huang,
	Xiaojian.Du, Li.Meng, linux-pm, linux-kernel, Rafael J. Wysocki

On 12-07-22, 11:40, Perry Yuan wrote:
> This cppc_req_cached valued should be prefetched during
> amd_pstate_cpu_init call period, then the amd_pstate_update() will get
> correct cached value before updating the perf to change the cpu perf
> level.

You are doing more than this in the patch, either mention all the
stuff with reasoning or split into two patches.

> Signed-off-by: Perry Yuan <Perry.Yuan@amd.com>
> ---
>  drivers/cpufreq/amd-pstate.c | 15 ++++++++++-----
>  1 file changed, 10 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index 43e6df9f67f6..e4904da54541 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -547,12 +547,17 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy)
>  	cpudata->lowest_nonlinear_freq = lowest_nonlinear_freq;
>  
>  	policy->driver_data = cpudata;
> +	if (!shared_mem) {

This is a new change, which the commit log doesn't talk about.

> +		ret = rdmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_HW_CTL, &value);
> +		if (ret)
> +			return ret;
> +		WRITE_ONCE(cpudata->cppc_hw_conf_cached, value);
>  
> -	ret = rdmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_HW_CTL, &value);
> -	if (ret)
> -		return ret;
> -	WRITE_ONCE(cpudata->cppc_hw_conf_cached, value);
> -
> +		ret = rdmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ, &value);
> +		if (ret)
> +			return ret;
> +		WRITE_ONCE(cpudata->cppc_req_cached, value);
> +	}
>  	amd_pstate_boost_init(cpudata);
>  
>  	return 0;
> -- 
> 2.25.1

-- 
viresh

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v3 05/13] cpufreq: amd-pstate: simplify cpudata pointer assignment
  2022-07-12 15:40 ` [PATCH v3 05/13] cpufreq: amd-pstate: simplify cpudata pointer assignment Perry Yuan
@ 2022-07-13  5:27   ` Viresh Kumar
  0 siblings, 0 replies; 25+ messages in thread
From: Viresh Kumar @ 2022-07-13  5:27 UTC (permalink / raw)
  To: Perry Yuan
  Cc: rafael.j.wysocki, Ray.Huang, Deepak.Sharma, Mario.Limonciello,
	Nathan.Fontenot, Alexander.Deucher, Jinzhou.Su, Xinmei.Huang,
	Xiaojian.Du, Li.Meng, linux-pm, linux-kernel, Rafael J. Wysocki

On 12-07-22, 11:40, Perry Yuan wrote:
> move the cpudata assignment to cpudata declaration which
> will simplify the functions.
> 
> No functional change intended.
> 
> Signed-off-by: Perry Yuan <Perry.Yuan@amd.com>
> ---
>  drivers/cpufreq/amd-pstate.c | 12 +++---------
>  1 file changed, 3 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index e4904da54541..fc0de9fd643b 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -571,9 +571,7 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy)
>  
>  static int amd_pstate_cpu_exit(struct cpufreq_policy *policy)
>  {
> -	struct amd_cpudata *cpudata;
> -
> -	cpudata = policy->driver_data;
> +	struct amd_cpudata *cpudata = policy->driver_data;
>  
>  	freq_qos_remove_request(&cpudata->req[1]);
>  	freq_qos_remove_request(&cpudata->req[0]);
> @@ -615,9 +613,7 @@ static ssize_t show_amd_pstate_max_freq(struct cpufreq_policy *policy,
>  					char *buf)
>  {
>  	int max_freq;
> -	struct amd_cpudata *cpudata;
> -
> -	cpudata = policy->driver_data;
> +	struct amd_cpudata *cpudata = policy->driver_data;
>  
>  	max_freq = amd_get_max_freq(cpudata);
>  	if (max_freq < 0)
> @@ -630,9 +626,7 @@ static ssize_t show_amd_pstate_lowest_nonlinear_freq(struct cpufreq_policy *poli
>  						     char *buf)
>  {
>  	int freq;
> -	struct amd_cpudata *cpudata;
> -
> -	cpudata = policy->driver_data;
> +	struct amd_cpudata *cpudata = policy->driver_data;
>  
>  	freq = amd_get_lowest_nonlinear_freq(cpudata);
>  	if (freq < 0)

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

-- 
viresh

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v3 03/13] cpufreq: amd-pstate: cleanup the unused and duplicated headers declaration
  2022-07-12 15:40 ` [PATCH v3 03/13] cpufreq: amd-pstate: cleanup the unused and duplicated headers declaration Perry Yuan
@ 2022-07-13  5:27   ` Viresh Kumar
  0 siblings, 0 replies; 25+ messages in thread
From: Viresh Kumar @ 2022-07-13  5:27 UTC (permalink / raw)
  To: Perry Yuan
  Cc: rafael.j.wysocki, Ray.Huang, Deepak.Sharma, Mario.Limonciello,
	Nathan.Fontenot, Alexander.Deucher, Jinzhou.Su, Xinmei.Huang,
	Xiaojian.Du, Li.Meng, linux-pm, linux-kernel, Rafael J. Wysocki

On 12-07-22, 11:40, Perry Yuan wrote:
> Cleanup the headers declaration which are not used
> actually and some duplicated declaration which is declarated in some
> other headers already, it will help to simplify the header part.
> 
> Signed-off-by: Perry Yuan <Perry.Yuan@amd.com>
> ---
>  drivers/cpufreq/amd-pstate.c | 5 -----
>  1 file changed, 5 deletions(-)
> 
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index 188e055e24a2..43e6df9f67f6 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -31,19 +31,14 @@
>  #include <linux/compiler.h>
>  #include <linux/dmi.h>
>  #include <linux/slab.h>
> -#include <linux/acpi.h>
>  #include <linux/io.h>
>  #include <linux/delay.h>
>  #include <linux/uaccess.h>
>  #include <linux/static_call.h>
>  
> -#include <acpi/processor.h>
>  #include <acpi/cppc_acpi.h>
>  
>  #include <asm/msr.h>
> -#include <asm/processor.h>
> -#include <asm/cpufeature.h>
> -#include <asm/cpu_device_id.h>
>  #include "amd-pstate-trace.h"
>  
>  #define AMD_PSTATE_TRANSITION_LATENCY	0x20000

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

-- 
viresh

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v3 06/13] cpufreq: amd_pstate: fix wrong lowest perf fetch
  2022-07-12 15:41 ` [PATCH v3 06/13] cpufreq: amd_pstate: fix wrong lowest perf fetch Perry Yuan
@ 2022-07-13  5:27   ` Viresh Kumar
  0 siblings, 0 replies; 25+ messages in thread
From: Viresh Kumar @ 2022-07-13  5:27 UTC (permalink / raw)
  To: Perry Yuan
  Cc: rafael.j.wysocki, Ray.Huang, Deepak.Sharma, Mario.Limonciello,
	Nathan.Fontenot, Alexander.Deucher, Jinzhou.Su, Xinmei.Huang,
	Xiaojian.Du, Li.Meng, linux-pm, linux-kernel, Rafael J. Wysocki

On 12-07-22, 11:41, Perry Yuan wrote:
> Fix the wrong lowest perf value reading which is used for new
> des_perf calculation by governor requested, the incorrect min_perf will
> get incorrect des_perf to be set , that will cause the system frequency
> changing unexpectedly.
> 
> Signed-off-by: Perry Yuan <Perry.Yuan@amd.com>
> Signed-off-by: Su Jinzhou <jinzhou.su@amd.com>
> ---
>  drivers/cpufreq/amd-pstate.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index fc0de9fd643b..7c51f4125263 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -308,7 +308,7 @@ static int amd_pstate_target(struct cpufreq_policy *policy,
>  		return -ENODEV;
>  
>  	cap_perf = READ_ONCE(cpudata->highest_perf);
> -	min_perf = READ_ONCE(cpudata->lowest_nonlinear_perf);
> +	min_perf = READ_ONCE(cpudata->lowest_perf);
>  	max_perf = cap_perf;
>  
>  	freqs.old = policy->cur;

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

-- 
viresh

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v3 08/13] cpufreq: amd-pstate: fix white-space
  2022-07-12 15:41 ` [PATCH v3 08/13] cpufreq: amd-pstate: fix white-space Perry Yuan
@ 2022-07-13  5:28   ` Viresh Kumar
  0 siblings, 0 replies; 25+ messages in thread
From: Viresh Kumar @ 2022-07-13  5:28 UTC (permalink / raw)
  To: Perry Yuan
  Cc: rafael.j.wysocki, Ray.Huang, Deepak.Sharma, Mario.Limonciello,
	Nathan.Fontenot, Alexander.Deucher, Jinzhou.Su, Xinmei.Huang,
	Xiaojian.Du, Li.Meng, linux-pm, linux-kernel, Rafael J. Wysocki

On 12-07-22, 11:41, Perry Yuan wrote:
> Remove the white space and correct mixed-up indentation
> 
> Signed-off-by: Perry Yuan <Perry.Yuan@amd.com>
> ---
>  drivers/cpufreq/amd-pstate.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index f359b1b20140..312ccef62f58 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -115,7 +115,7 @@ struct amd_cpudata {
>  	struct amd_aperf_mperf cur;
>  	struct amd_aperf_mperf prev;
>  
> -	u64 freq;
> +	u64 	freq;
>  	bool	boost_supported;
>  	u64 	cppc_hw_conf_cached;
>  };
> @@ -671,7 +671,7 @@ static struct cpufreq_driver amd_pstate_driver = {
>  	.resume		= amd_pstate_cpu_resume,
>  	.set_boost	= amd_pstate_set_boost,
>  	.name		= "amd-pstate",
> -	.attr           = amd_pstate_attr,
> +	.attr		= amd_pstate_attr,
>  };
>  
>  static int __init amd_pstate_init(void)
> -- 

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

-- 
viresh

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v3 09/13] cpufreq: amd-pstate: update pstate frequency transition delay time
  2022-07-12 15:42 ` [PATCH v3 09/13] cpufreq: amd-pstate: update pstate frequency transition delay time Perry Yuan
@ 2022-07-13  5:28   ` Viresh Kumar
  0 siblings, 0 replies; 25+ messages in thread
From: Viresh Kumar @ 2022-07-13  5:28 UTC (permalink / raw)
  To: Perry Yuan
  Cc: rafael.j.wysocki, Ray.Huang, Deepak.Sharma, Mario.Limonciello,
	Nathan.Fontenot, Alexander.Deucher, Jinzhou.Su, Xinmei.Huang,
	Xiaojian.Du, Li.Meng, linux-pm, linux-kernel, Rafael J. Wysocki

On 12-07-22, 11:42, Perry Yuan wrote:
> change the default transition latency to be 20ms that is more
> reasonable transition delay for AMD processors in non-EPP driver mode.
> 
> Signed-off-by: Perry Yuan <Perry.Yuan@amd.com>
> ---
>  drivers/cpufreq/amd-pstate.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index 312ccef62f58..1e5ca4897b7e 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -41,7 +41,7 @@
>  #include <asm/msr.h>
>  #include "amd-pstate-trace.h"
>  
> -#define AMD_PSTATE_TRANSITION_LATENCY	0x20000
> +#define AMD_PSTATE_TRANSITION_LATENCY	20000
>  #define AMD_PSTATE_TRANSITION_DELAY	500
>  
>  /*

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

-- 
viresh

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v3 11/13] cpufreq: amd_pstate: update transition delay time to 1ms
  2022-07-12 15:42 ` [PATCH v3 11/13] cpufreq: amd_pstate: update transition delay time to 1ms Perry Yuan
@ 2022-07-13  5:29   ` Viresh Kumar
  0 siblings, 0 replies; 25+ messages in thread
From: Viresh Kumar @ 2022-07-13  5:29 UTC (permalink / raw)
  To: Perry Yuan
  Cc: rafael.j.wysocki, Ray.Huang, Deepak.Sharma, Mario.Limonciello,
	Nathan.Fontenot, Alexander.Deucher, Jinzhou.Su, Xinmei.Huang,
	Xiaojian.Du, Li.Meng, linux-pm, linux-kernel, Rafael J. Wysocki

On 12-07-22, 11:42, Perry Yuan wrote:
> Update transition delay time to 1ms, in the AMD CPU autonomous mode and
> non-autonomous mode, CPPC firmware will decide frequency at 1ms timescale
> based on the workload utilization.
> 
> Signed-off-by: Perry Yuan <Perry.Yuan@amd.com>
> Signed-off-by: Su Jinzhou <Jinzhou.Su@amd.com>
> ---
>  drivers/cpufreq/amd-pstate.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c
> index a9918728948a..83570acecc78 100644
> --- a/drivers/cpufreq/amd-pstate.c
> +++ b/drivers/cpufreq/amd-pstate.c
> @@ -42,7 +42,7 @@
>  #include "amd-pstate-trace.h"
>  
>  #define AMD_PSTATE_TRANSITION_LATENCY	20000
> -#define AMD_PSTATE_TRANSITION_DELAY	500
> +#define AMD_PSTATE_TRANSITION_DELAY	1000
>  
>  /*
>   * TODO: We need more time to fine tune processors with shared memory solution

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

-- 
viresh

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v3 12/13] arch_topology: remove the acpi_disabled check
  2022-07-12 15:43 ` [PATCH v3 12/13] arch_topology: remove the acpi_disabled check Perry Yuan
@ 2022-07-13  5:29   ` Viresh Kumar
  2022-07-13 14:40   ` Sudeep Holla
  1 sibling, 0 replies; 25+ messages in thread
From: Viresh Kumar @ 2022-07-13  5:29 UTC (permalink / raw)
  To: Perry Yuan
  Cc: rafael.j.wysocki, Ray.Huang, Deepak.Sharma, Mario.Limonciello,
	Nathan.Fontenot, Alexander.Deucher, Jinzhou.Su, Xinmei.Huang,
	Xiaojian.Du, Li.Meng, linux-pm, linux-kernel, Sudeep Holla,
	Greg Kroah-Hartman, Rafael J. Wysocki

On 12-07-22, 11:43, Perry Yuan wrote:
> "acpi_cpc_valid" function already includes the acpi_disabled check and we can
> remove the duplicated check here
> 
> Signed-off-by: Perry Yuan <Perry.Yuan@amd.com>
> ---
>  drivers/base/arch_topology.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c
> index 579c851a2bd7..73a8cb31529d 100644
> --- a/drivers/base/arch_topology.c
> +++ b/drivers/base/arch_topology.c
> @@ -352,7 +352,7 @@ void topology_init_cpu_capacity_cppc(void)
>  	struct cppc_perf_caps perf_caps;
>  	int cpu;
>  
> -	if (likely(acpi_disabled || !acpi_cpc_valid()))
> +	if (likely(!acpi_cpc_valid()))
>  		return;
>  
>  	raw_capacity = kcalloc(num_possible_cpus(), sizeof(*raw_capacity),

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

-- 
viresh

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v3 13/13] cpufreq: CPPC: remove the acpi_disabled check
  2022-07-12 15:43 ` [PATCH v3 13/13] cpufreq: CPPC: " Perry Yuan
@ 2022-07-13  5:29   ` Viresh Kumar
  0 siblings, 0 replies; 25+ messages in thread
From: Viresh Kumar @ 2022-07-13  5:29 UTC (permalink / raw)
  To: Perry Yuan
  Cc: rafael.j.wysocki, Ray.Huang, Deepak.Sharma, Mario.Limonciello,
	Nathan.Fontenot, Alexander.Deucher, Jinzhou.Su, Xinmei.Huang,
	Xiaojian.Du, Li.Meng, linux-pm, linux-kernel, Rafael J. Wysocki

On 12-07-22, 11:43, Perry Yuan wrote:
> "acpi_cpc_valid" function already includes the acpi_disabled check and we can
> remove the duplicated check here
> 
> Signed-off-by: Perry Yuan <Perry.Yuan@amd.com>
> ---
>  drivers/cpufreq/cppc_cpufreq.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c
> index 24eaf0ec344d..9adb7612993e 100644
> --- a/drivers/cpufreq/cppc_cpufreq.c
> +++ b/drivers/cpufreq/cppc_cpufreq.c
> @@ -947,7 +947,7 @@ static int __init cppc_cpufreq_init(void)
>  {
>  	int ret;
>  
> -	if ((acpi_disabled) || !acpi_cpc_valid())
> +	if (!acpi_cpc_valid())
>  		return -ENODEV;
>  
>  	cppc_check_hisi_workaround();

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

-- 
viresh

^ permalink raw reply	[flat|nested] 25+ messages in thread

* RE: [PATCH v3 04/13] cpufreq: amd-pstate: prefetch cppc_req_cached value in amd_pstate_cpu_init()
  2022-07-13  5:27   ` Viresh Kumar
@ 2022-07-13  5:57     ` Yuan, Perry
  0 siblings, 0 replies; 25+ messages in thread
From: Yuan, Perry @ 2022-07-13  5:57 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: rafael.j.wysocki, Huang, Ray, Sharma, Deepak, Limonciello, Mario,
	Fontenot, Nathan, Deucher, Alexander, Su, Jinzhou (Joe),
	Huang, Shimmer, Du, Xiaojian, Meng, Li (Jassmine),
	linux-pm, linux-kernel, Rafael J. Wysocki

[AMD Official Use Only - General]

Hi Viresh,

> -----Original Message-----
> From: Viresh Kumar <viresh.kumar@linaro.org>
> Sent: Wednesday, July 13, 2022 1:27 PM
> To: Yuan, Perry <Perry.Yuan@amd.com>
> Cc: rafael.j.wysocki@intel.com; Huang, Ray <Ray.Huang@amd.com>; Sharma,
> Deepak <Deepak.Sharma@amd.com>; Limonciello, Mario
> <Mario.Limonciello@amd.com>; Fontenot, Nathan
> <Nathan.Fontenot@amd.com>; Deucher, Alexander
> <Alexander.Deucher@amd.com>; Su, Jinzhou (Joe) <Jinzhou.Su@amd.com>;
> Huang, Shimmer <Shimmer.Huang@amd.com>; Du, Xiaojian
> <Xiaojian.Du@amd.com>; Meng, Li (Jassmine) <Li.Meng@amd.com>; linux-
> pm@vger.kernel.org; linux-kernel@vger.kernel.org; Rafael J. Wysocki
> <rafael@kernel.org>
> Subject: Re: [PATCH v3 04/13] cpufreq: amd-pstate: prefetch
> cppc_req_cached value in amd_pstate_cpu_init()
> 
> [CAUTION: External Email]
> 
> On 12-07-22, 11:40, Perry Yuan wrote:
> > This cppc_req_cached valued should be prefetched during
> > amd_pstate_cpu_init call period, then the amd_pstate_update() will get
> > correct cached value before updating the perf to change the cpu perf
> > level.
> 
> You are doing more than this in the patch, either mention all the stuff with
> reasoning or split into two patches.

My mistakes, the patch adds the shared_mem check which is added by another patch which is in the coming EPP driver patch set.  I will add one more patch to introduce what shared_mem is used for in V4 later. 

Thank you!

Perry. 

> 
> > Signed-off-by: Perry Yuan <Perry.Yuan@amd.com>
> > ---
> >  drivers/cpufreq/amd-pstate.c | 15 ++++++++++-----
> >  1 file changed, 10 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/cpufreq/amd-pstate.c
> > b/drivers/cpufreq/amd-pstate.c index 43e6df9f67f6..e4904da54541 100644
> > --- a/drivers/cpufreq/amd-pstate.c
> > +++ b/drivers/cpufreq/amd-pstate.c
> > @@ -547,12 +547,17 @@ static int amd_pstate_cpu_init(struct
> cpufreq_policy *policy)
> >       cpudata->lowest_nonlinear_freq = lowest_nonlinear_freq;
> >
> >       policy->driver_data = cpudata;
> > +     if (!shared_mem) {
> 
> This is a new change, which the commit log doesn't talk about.
> 
> > +             ret = rdmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_HW_CTL,
> &value);
> > +             if (ret)
> > +                     return ret;
> > +             WRITE_ONCE(cpudata->cppc_hw_conf_cached, value);
> >
> > -     ret = rdmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_HW_CTL, &value);
> > -     if (ret)
> > -             return ret;
> > -     WRITE_ONCE(cpudata->cppc_hw_conf_cached, value);
> > -
> > +             ret = rdmsrl_on_cpu(cpudata->cpu, MSR_AMD_CPPC_REQ, &value);
> > +             if (ret)
> > +                     return ret;
> > +             WRITE_ONCE(cpudata->cppc_req_cached, value);
> > +     }
> >       amd_pstate_boost_init(cpudata);
> >
> >       return 0;
> > --
> > 2.25.1
> 
> --
> viresh

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v3 12/13] arch_topology: remove the acpi_disabled check
  2022-07-12 15:43 ` [PATCH v3 12/13] arch_topology: remove the acpi_disabled check Perry Yuan
  2022-07-13  5:29   ` Viresh Kumar
@ 2022-07-13 14:40   ` Sudeep Holla
  1 sibling, 0 replies; 25+ messages in thread
From: Sudeep Holla @ 2022-07-13 14:40 UTC (permalink / raw)
  To: Perry Yuan
  Cc: rafael.j.wysocki, viresh.kumar, Ray.Huang, Deepak.Sharma,
	Mario.Limonciello, Nathan.Fontenot, Alexander.Deucher,
	Jinzhou.Su, Xinmei.Huang, Xiaojian.Du, Li.Meng, linux-pm,
	linux-kernel, Greg Kroah-Hartman, Rafael J. Wysocki

On Tue, Jul 12, 2022 at 11:43:05AM -0400, Perry Yuan wrote:
> "acpi_cpc_valid" function already includes the acpi_disabled check and we can
> remove the duplicated check here
>

Acked-by: Sudeep Holla <sudeep.holla@arm.com>

-- 
Regards,
Sudeep

^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2022-07-13 14:41 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-12 15:32 [PATCH v3 00/13] AMD Pstate Enhancement And Issue Fixs Perry Yuan
2022-07-12 15:35 ` [PATCH v3 01/13] x86/msr: Add the MSR definition for AMD CPPC hardware control Perry Yuan
2022-07-12 15:39 ` [PATCH v3 02/13] cpufreq: amd-pstate: enable AMD Precision Boost mode switch Perry Yuan
2022-07-12 15:40 ` [PATCH v3 03/13] cpufreq: amd-pstate: cleanup the unused and duplicated headers declaration Perry Yuan
2022-07-13  5:27   ` Viresh Kumar
2022-07-12 15:40 ` [PATCH v3 04/13] cpufreq: amd-pstate: prefetch cppc_req_cached value in amd_pstate_cpu_init() Perry Yuan
2022-07-13  5:27   ` Viresh Kumar
2022-07-13  5:57     ` Yuan, Perry
2022-07-12 15:40 ` [PATCH v3 05/13] cpufreq: amd-pstate: simplify cpudata pointer assignment Perry Yuan
2022-07-13  5:27   ` Viresh Kumar
2022-07-12 15:41 ` [PATCH v3 06/13] cpufreq: amd_pstate: fix wrong lowest perf fetch Perry Yuan
2022-07-13  5:27   ` Viresh Kumar
2022-07-12 15:41 ` [PATCH v3 07/13] cpufreq: amd_pstate: map desired perf into pstate scope for powersave governor Perry Yuan
2022-07-12 15:41 ` [PATCH v3 08/13] cpufreq: amd-pstate: fix white-space Perry Yuan
2022-07-13  5:28   ` Viresh Kumar
2022-07-12 15:42 ` [PATCH v3 09/13] cpufreq: amd-pstate: update pstate frequency transition delay time Perry Yuan
2022-07-13  5:28   ` Viresh Kumar
2022-07-12 15:42 ` [PATCH v3 10/13] cpufreq: amd-pstate: add ACPI disabled check in acpi_cpc_valid() Perry Yuan
2022-07-12 15:42 ` [PATCH v3 11/13] cpufreq: amd_pstate: update transition delay time to 1ms Perry Yuan
2022-07-13  5:29   ` Viresh Kumar
2022-07-12 15:43 ` [PATCH v3 12/13] arch_topology: remove the acpi_disabled check Perry Yuan
2022-07-13  5:29   ` Viresh Kumar
2022-07-13 14:40   ` Sudeep Holla
2022-07-12 15:43 ` [PATCH v3 13/13] cpufreq: CPPC: " Perry Yuan
2022-07-13  5:29   ` Viresh Kumar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).