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

Merge branches 'pm-em' and 'powercap'

Merge Energy Model and power capping updates for 5.16-rc1:

 - Add support for inefficient operating performance points to the
   Energy Model and modify cpufreq to use them properly (Vincent
   Donnefort).

 - Rearrange the DTPM framework code to simplify it and make it easier
   to follow (Daniel Lezcano).

 - Fix power intialization in DTPM (Daniel Lezcano).

 - Add CPU load consideration when estimating the instaneous power
   consumption in DTPM (Daniel Lezcano).

* pm-em:
  cpufreq: mediatek-hw: Fix cpufreq_table_find_index_dl() call
  PM: EM: Mark inefficiencies in CPUFreq
  cpufreq: Use CPUFREQ_RELATION_E in DVFS governors
  cpufreq: Introducing CPUFREQ_RELATION_E
  cpufreq: Add an interface to mark inefficient frequencies
  cpufreq: Make policy min/max hard requirements
  PM: EM: Allow skipping inefficient states
  PM: EM: Extend em_perf_domain with a flag field
  PM: EM: Mark inefficient states
  PM: EM: Fix inefficient states detection

* powercap:
  powercap/drivers/dtpm: Fix power limit initialization
  powercap/drivers/dtpm: Scale the power with the load
  powercap/drivers/dtpm: Use container_of instead of a private data field
  powercap/drivers/dtpm: Simplify the dtpm table
  powercap/drivers/dtpm: Encapsulate even more the code
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -470,7 +470,8 @@ static unsigned int acpi_cpufreq_fast_switch(struct cpufreq_policy *policy,
	if (policy->cached_target_freq == target_freq)
	if (policy->cached_target_freq == target_freq)
		index = policy->cached_resolved_idx;
		index = policy->cached_resolved_idx;
	else
	else
		index = cpufreq_table_find_index_dl(policy, target_freq);
		index = cpufreq_table_find_index_dl(policy, target_freq,
						    false);


	entry = &policy->freq_table[index];
	entry = &policy->freq_table[index];
	next_freq = entry->frequency;
	next_freq = entry->frequency;
+2 −1
Original line number Original line Diff line number Diff line
@@ -91,7 +91,8 @@ static unsigned int amd_powersave_bias_target(struct cpufreq_policy *policy,
			unsigned int index;
			unsigned int index;


			index = cpufreq_table_find_index_h(policy,
			index = cpufreq_table_find_index_h(policy,
							   policy->cur - 1);
							   policy->cur - 1,
							   relation & CPUFREQ_RELATION_E);
			freq_next = policy->freq_table[index].frequency;
			freq_next = policy->freq_table[index].frequency;
		}
		}


+17 −2
Original line number Original line Diff line number Diff line
@@ -554,7 +554,7 @@ static unsigned int __resolve_freq(struct cpufreq_policy *policy,
unsigned int cpufreq_driver_resolve_freq(struct cpufreq_policy *policy,
unsigned int cpufreq_driver_resolve_freq(struct cpufreq_policy *policy,
					 unsigned int target_freq)
					 unsigned int target_freq)
{
{
	return __resolve_freq(policy, target_freq, CPUFREQ_RELATION_L);
	return __resolve_freq(policy, target_freq, CPUFREQ_RELATION_LE);
}
}
EXPORT_SYMBOL_GPL(cpufreq_driver_resolve_freq);
EXPORT_SYMBOL_GPL(cpufreq_driver_resolve_freq);


@@ -2260,8 +2260,16 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy,
	    !(cpufreq_driver->flags & CPUFREQ_NEED_UPDATE_LIMITS))
	    !(cpufreq_driver->flags & CPUFREQ_NEED_UPDATE_LIMITS))
		return 0;
		return 0;


	if (cpufreq_driver->target)
	if (cpufreq_driver->target) {
		/*
		 * If the driver hasn't setup a single inefficient frequency,
		 * it's unlikely it knows how to decode CPUFREQ_RELATION_E.
		 */
		if (!policy->efficiencies_available)
			relation &= ~CPUFREQ_RELATION_E;

		return cpufreq_driver->target(policy, target_freq, relation);
		return cpufreq_driver->target(policy, target_freq, relation);
	}


	if (!cpufreq_driver->target_index)
	if (!cpufreq_driver->target_index)
		return -EINVAL;
		return -EINVAL;
@@ -2523,8 +2531,15 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy,
	if (ret)
	if (ret)
		return ret;
		return ret;


	/*
	 * Resolve policy min/max to available frequencies. It ensures
	 * no frequency resolution will neither overshoot the requested maximum
	 * nor undershoot the requested minimum.
	 */
	policy->min = new_data.min;
	policy->min = new_data.min;
	policy->max = new_data.max;
	policy->max = new_data.max;
	policy->min = __resolve_freq(policy, policy->min, CPUFREQ_RELATION_L);
	policy->max = __resolve_freq(policy, policy->max, CPUFREQ_RELATION_H);
	trace_cpu_frequency_limits(policy);
	trace_cpu_frequency_limits(policy);


	policy->cached_target_freq = UINT_MAX;
	policy->cached_target_freq = UINT_MAX;
+4 −2
Original line number Original line Diff line number Diff line
@@ -111,7 +111,8 @@ static unsigned int cs_dbs_update(struct cpufreq_policy *policy)
		if (requested_freq > policy->max)
		if (requested_freq > policy->max)
			requested_freq = policy->max;
			requested_freq = policy->max;


		__cpufreq_driver_target(policy, requested_freq, CPUFREQ_RELATION_H);
		__cpufreq_driver_target(policy, requested_freq,
					CPUFREQ_RELATION_HE);
		dbs_info->requested_freq = requested_freq;
		dbs_info->requested_freq = requested_freq;
		goto out;
		goto out;
	}
	}
@@ -134,7 +135,8 @@ static unsigned int cs_dbs_update(struct cpufreq_policy *policy)
		else
		else
			requested_freq = policy->min;
			requested_freq = policy->min;


		__cpufreq_driver_target(policy, requested_freq, CPUFREQ_RELATION_L);
		__cpufreq_driver_target(policy, requested_freq,
					CPUFREQ_RELATION_LE);
		dbs_info->requested_freq = requested_freq;
		dbs_info->requested_freq = requested_freq;
	}
	}


+9 −7
Original line number Original line Diff line number Diff line
@@ -83,9 +83,11 @@ static unsigned int generic_powersave_bias_target(struct cpufreq_policy *policy,
	freq_avg = freq_req - freq_reduc;
	freq_avg = freq_req - freq_reduc;


	/* Find freq bounds for freq_avg in freq_table */
	/* Find freq bounds for freq_avg in freq_table */
	index = cpufreq_table_find_index_h(policy, freq_avg);
	index = cpufreq_table_find_index_h(policy, freq_avg,
					   relation & CPUFREQ_RELATION_E);
	freq_lo = freq_table[index].frequency;
	freq_lo = freq_table[index].frequency;
	index = cpufreq_table_find_index_l(policy, freq_avg);
	index = cpufreq_table_find_index_l(policy, freq_avg,
					   relation & CPUFREQ_RELATION_E);
	freq_hi = freq_table[index].frequency;
	freq_hi = freq_table[index].frequency;


	/* Find out how long we have to be in hi and lo freqs */
	/* Find out how long we have to be in hi and lo freqs */
@@ -118,12 +120,12 @@ static void dbs_freq_increase(struct cpufreq_policy *policy, unsigned int freq)


	if (od_tuners->powersave_bias)
	if (od_tuners->powersave_bias)
		freq = od_ops.powersave_bias_target(policy, freq,
		freq = od_ops.powersave_bias_target(policy, freq,
				CPUFREQ_RELATION_H);
						    CPUFREQ_RELATION_HE);
	else if (policy->cur == policy->max)
	else if (policy->cur == policy->max)
		return;
		return;


	__cpufreq_driver_target(policy, freq, od_tuners->powersave_bias ?
	__cpufreq_driver_target(policy, freq, od_tuners->powersave_bias ?
			CPUFREQ_RELATION_L : CPUFREQ_RELATION_H);
			CPUFREQ_RELATION_LE : CPUFREQ_RELATION_HE);
}
}


/*
/*
@@ -161,9 +163,9 @@ static void od_update(struct cpufreq_policy *policy)
		if (od_tuners->powersave_bias)
		if (od_tuners->powersave_bias)
			freq_next = od_ops.powersave_bias_target(policy,
			freq_next = od_ops.powersave_bias_target(policy,
								 freq_next,
								 freq_next,
								 CPUFREQ_RELATION_L);
								 CPUFREQ_RELATION_LE);


		__cpufreq_driver_target(policy, freq_next, CPUFREQ_RELATION_C);
		__cpufreq_driver_target(policy, freq_next, CPUFREQ_RELATION_CE);
	}
	}
}
}


@@ -182,7 +184,7 @@ static unsigned int od_dbs_update(struct cpufreq_policy *policy)
	 */
	 */
	if (sample_type == OD_SUB_SAMPLE && policy_dbs->sample_delay_ns > 0) {
	if (sample_type == OD_SUB_SAMPLE && policy_dbs->sample_delay_ns > 0) {
		__cpufreq_driver_target(policy, dbs_info->freq_lo,
		__cpufreq_driver_target(policy, dbs_info->freq_lo,
					CPUFREQ_RELATION_H);
					CPUFREQ_RELATION_HE);
		return dbs_info->freq_lo_delay_us;
		return dbs_info->freq_lo_delay_us;
	}
	}


Loading