Commit 2dfed740 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki
Browse files

Merge tag 'amd-pstate-v6.14-2024-12-18' of...

Merge tag 'amd-pstate-v6.14-2024-12-18' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/superm1/linux

Merge amd-pstate changes for 6.14 from Mario Limonciello:

"Mostly cleanups and optimizations to increase code reuse by
 shuffling around and using helpers.

 Notable other changes:
  * Add ftrace event for active mode to use
  * Set default EPP policy on Ryzen"

* tag 'amd-pstate-v6.14-2024-12-18' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/superm1/linux: (21 commits)
  cpufreq/amd-pstate: Drop boost_state variable
  cpufreq/amd-pstate: Set different default EPP policy for Epyc and Ryzen
  cpufreq/amd-pstate: Drop ret variable from amd_pstate_set_energy_pref_index()
  cpufreq/amd-pstate: Always write EPP value when updating perf
  cpufreq/amd-pstate: Cache EPP value and use that everywhere
  cpufreq/amd-pstate: Move limit updating code
  cpufreq/amd-pstate: Change amd_pstate_update_perf() to return an int
  cpufreq/amd-pstate: store all values in cpudata struct in khz
  cpufreq/amd-pstate: Only update the cached value in msr_set_epp() on success
  cpufreq/amd-pstate: Use FIELD_PREP and FIELD_GET macros
  cpufreq/amd-pstate: Drop cached epp_policy variable
  cpufreq/amd-pstate: convert mutex use to guard()
  cpufreq/amd-pstate: Add trace event for EPP perf updates
  cpufreq/amd-pstate: Merge amd_pstate_epp_cpu_offline() and amd_pstate_epp_offline()
  cpufreq/amd-pstate: Remove the cppc_state check in offline/online functions
  cpufreq/amd-pstate: Refactor amd_pstate_epp_reenable() and amd_pstate_epp_offline()
  cpufreq/amd-pstate: Move the invocation of amd_pstate_update_perf()
  cpufreq/amd-pstate: Convert the amd_pstate_get/set_epp() to static calls
  cpufreq/amd-pstate: Use boost numerator for upper bound of frequencies
  cpufreq/amd-pstate: Store the boost numerator as highest perf again
  ...
parents 8e461a1c 95fad7fb
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -251,9 +251,7 @@ performance supported in `AMD CPPC Performance Capability <perf_cap_>`_).
In some ASICs, the highest CPPC performance is not the one in the ``_CPC``
table, so we need to expose it to sysfs. If boost is not active, but
still supported, this maximum frequency will be larger than the one in
``cpuinfo``. On systems that support preferred core, the driver will have
different values for some cores than others and this will reflect the values
advertised by the platform at bootup.
``cpuinfo``.
This attribute is read-only.

``amd_pstate_lowest_nonlinear_freq``
+46 −6
Original line number Diff line number Diff line
@@ -32,7 +32,6 @@ TRACE_EVENT(amd_pstate_perf,
		 u64 aperf,
		 u64 tsc,
		 unsigned int cpu_id,
		 bool changed,
		 bool fast_switch
		 ),

@@ -44,7 +43,6 @@ TRACE_EVENT(amd_pstate_perf,
		aperf,
		tsc,
		cpu_id,
		changed,
		fast_switch
		),

@@ -57,7 +55,6 @@ TRACE_EVENT(amd_pstate_perf,
		__field(unsigned long long, aperf)
		__field(unsigned long long, tsc)
		__field(unsigned int, cpu_id)
		__field(bool, changed)
		__field(bool, fast_switch)
		),

@@ -70,11 +67,10 @@ TRACE_EVENT(amd_pstate_perf,
		__entry->aperf = aperf;
		__entry->tsc = tsc;
		__entry->cpu_id = cpu_id;
		__entry->changed = changed;
		__entry->fast_switch = fast_switch;
		),

	TP_printk("amd_min_perf=%lu amd_des_perf=%lu amd_max_perf=%lu freq=%llu mperf=%llu aperf=%llu tsc=%llu cpu_id=%u changed=%s fast_switch=%s",
	TP_printk("amd_min_perf=%lu amd_des_perf=%lu amd_max_perf=%lu freq=%llu mperf=%llu aperf=%llu tsc=%llu cpu_id=%u fast_switch=%s",
		  (unsigned long)__entry->min_perf,
		  (unsigned long)__entry->target_perf,
		  (unsigned long)__entry->capacity,
@@ -83,11 +79,55 @@ TRACE_EVENT(amd_pstate_perf,
		  (unsigned long long)__entry->aperf,
		  (unsigned long long)__entry->tsc,
		  (unsigned int)__entry->cpu_id,
		  (__entry->changed) ? "true" : "false",
		  (__entry->fast_switch) ? "true" : "false"
		 )
);

TRACE_EVENT(amd_pstate_epp_perf,

	TP_PROTO(unsigned int cpu_id,
		 unsigned int highest_perf,
		 unsigned int epp,
		 unsigned int min_perf,
		 unsigned int max_perf,
		 bool boost
		 ),

	TP_ARGS(cpu_id,
		highest_perf,
		epp,
		min_perf,
		max_perf,
		boost),

	TP_STRUCT__entry(
		__field(unsigned int, cpu_id)
		__field(unsigned int, highest_perf)
		__field(unsigned int, epp)
		__field(unsigned int, min_perf)
		__field(unsigned int, max_perf)
		__field(bool, boost)
		),

	TP_fast_assign(
		__entry->cpu_id = cpu_id;
		__entry->highest_perf = highest_perf;
		__entry->epp = epp;
		__entry->min_perf = min_perf;
		__entry->max_perf = max_perf;
		__entry->boost = boost;
		),

	TP_printk("cpu%u: [%u<->%u]/%u, epp=%u, boost=%u",
		  (unsigned int)__entry->cpu_id,
		  (unsigned int)__entry->min_perf,
		  (unsigned int)__entry->max_perf,
		  (unsigned int)__entry->highest_perf,
		  (unsigned int)__entry->epp,
		  (bool)__entry->boost
		 )
);

#endif /* _AMD_PSTATE_TRACE_H */

/* This part must be outside protection */
+5 −7
Original line number Diff line number Diff line
@@ -207,7 +207,6 @@ static void amd_pstate_ut_check_freq(u32 index)
	int cpu = 0;
	struct cpufreq_policy *policy = NULL;
	struct amd_cpudata *cpudata = NULL;
	u32 nominal_freq_khz;

	for_each_possible_cpu(cpu) {
		policy = cpufreq_cpu_get(cpu);
@@ -215,14 +214,13 @@ static void amd_pstate_ut_check_freq(u32 index)
			break;
		cpudata = policy->driver_data;

		nominal_freq_khz = cpudata->nominal_freq*1000;
		if (!((cpudata->max_freq >= nominal_freq_khz) &&
			(nominal_freq_khz > cpudata->lowest_nonlinear_freq) &&
		if (!((cpudata->max_freq >= cpudata->nominal_freq) &&
			(cpudata->nominal_freq > cpudata->lowest_nonlinear_freq) &&
			(cpudata->lowest_nonlinear_freq > cpudata->min_freq) &&
			(cpudata->min_freq > 0))) {
			amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_FAIL;
			pr_err("%s cpu%d max=%d >= nominal=%d > lowest_nonlinear=%d > min=%d > 0, the formula is incorrect!\n",
				__func__, cpu, cpudata->max_freq, nominal_freq_khz,
				__func__, cpu, cpudata->max_freq, cpudata->nominal_freq,
				cpudata->lowest_nonlinear_freq, cpudata->min_freq);
			goto skip_test;
		}
@@ -236,13 +234,13 @@ static void amd_pstate_ut_check_freq(u32 index)

		if (cpudata->boost_supported) {
			if ((policy->max == cpudata->max_freq) ||
					(policy->max == nominal_freq_khz))
					(policy->max == cpudata->nominal_freq))
				amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_PASS;
			else {
				amd_pstate_ut_cases[index].result = AMD_PSTATE_UT_RESULT_FAIL;
				pr_err("%s cpu%d policy_max=%d should be equal cpu_max=%d or cpu_nominal=%d !\n",
					__func__, cpu, policy->max, cpudata->max_freq,
					nominal_freq_khz);
					cpudata->nominal_freq);
				goto skip_test;
			}
		} else {
+249 −271

File changed.

Preview size limit exceeded, changes collapsed.

+0 −3
Original line number Diff line number Diff line
@@ -57,7 +57,6 @@ struct amd_aperf_mperf {
 * @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
@@ -94,13 +93,11 @@ struct amd_cpudata {
	bool	hw_prefcore;

	/* EPP feature related attributes*/
	s16	epp_policy;
	s16	epp_cached;
	u32	policy;
	u64	cppc_cap1_cached;
	bool	suspended;
	s16	epp_default;
	bool	boost_state;
};

/*