Commit 50dd154e authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

Merge branches 'pm-cpufreq' and 'pm-acpi'

* pm-cpufreq:
  cpufreq: CPPC: add SW BOOST support
  cpufreq: change '.set_boost' to act on one policy
  cpufreq: tegra186: add CPUFREQ_NEED_INITIAL_FREQ_CHECK flag

* pm-acpi:
  ACPI: PM: Avoid using power resources if there are none for D0
...@@ -186,7 +186,7 @@ int acpi_device_set_power(struct acpi_device *device, int state) ...@@ -186,7 +186,7 @@ int acpi_device_set_power(struct acpi_device *device, int state)
* possibly drop references to the power resources in use. * possibly drop references to the power resources in use.
*/ */
state = ACPI_STATE_D3_HOT; state = ACPI_STATE_D3_HOT;
/* If _PR3 is not available, use D3hot as the target state. */ /* If D3cold is not supported, use D3hot as the target state. */
if (!device->power.states[ACPI_STATE_D3_COLD].flags.valid) if (!device->power.states[ACPI_STATE_D3_COLD].flags.valid)
target_state = state; target_state = state;
} else if (!device->power.states[state].flags.valid) { } else if (!device->power.states[state].flags.valid) {
......
...@@ -919,12 +919,9 @@ static void acpi_bus_init_power_state(struct acpi_device *device, int state) ...@@ -919,12 +919,9 @@ static void acpi_bus_init_power_state(struct acpi_device *device, int state)
if (buffer.length && package if (buffer.length && package
&& package->type == ACPI_TYPE_PACKAGE && package->type == ACPI_TYPE_PACKAGE
&& package->package.count) { && package->package.count)
int err = acpi_extract_power_resources(package, 0, acpi_extract_power_resources(package, 0, &ps->resources);
&ps->resources);
if (!err)
device->power.flags.power_resources = 1;
}
ACPI_FREE(buffer.pointer); ACPI_FREE(buffer.pointer);
} }
...@@ -971,14 +968,27 @@ static void acpi_bus_get_power_flags(struct acpi_device *device) ...@@ -971,14 +968,27 @@ static void acpi_bus_get_power_flags(struct acpi_device *device)
acpi_bus_init_power_state(device, i); acpi_bus_init_power_state(device, i);
INIT_LIST_HEAD(&device->power.states[ACPI_STATE_D3_COLD].resources); INIT_LIST_HEAD(&device->power.states[ACPI_STATE_D3_COLD].resources);
if (!list_empty(&device->power.states[ACPI_STATE_D3_HOT].resources))
device->power.states[ACPI_STATE_D3_COLD].flags.valid = 1;
/* Set defaults for D0 and D3hot states (always valid) */ /* Set the defaults for D0 and D3hot (always supported). */
device->power.states[ACPI_STATE_D0].flags.valid = 1; device->power.states[ACPI_STATE_D0].flags.valid = 1;
device->power.states[ACPI_STATE_D0].power = 100; device->power.states[ACPI_STATE_D0].power = 100;
device->power.states[ACPI_STATE_D3_HOT].flags.valid = 1; device->power.states[ACPI_STATE_D3_HOT].flags.valid = 1;
/*
* Use power resources only if the D0 list of them is populated, because
* some platforms may provide _PR3 only to indicate D3cold support and
* in those cases the power resources list returned by it may be bogus.
*/
if (!list_empty(&device->power.states[ACPI_STATE_D0].resources)) {
device->power.flags.power_resources = 1;
/*
* D3cold is supported if the D3hot list of power resources is
* not empty.
*/
if (!list_empty(&device->power.states[ACPI_STATE_D3_HOT].resources))
device->power.states[ACPI_STATE_D3_COLD].flags.valid = 1;
}
if (acpi_bus_init_power(device)) if (acpi_bus_init_power(device))
device->flags.power_manageable = 0; device->flags.power_manageable = 0;
} }
......
...@@ -126,12 +126,12 @@ static void boost_set_msr_each(void *p_en) ...@@ -126,12 +126,12 @@ static void boost_set_msr_each(void *p_en)
boost_set_msr(enable); boost_set_msr(enable);
} }
static int set_boost(int val) static int set_boost(struct cpufreq_policy *policy, int val)
{ {
get_online_cpus(); on_each_cpu_mask(policy->cpus, boost_set_msr_each,
on_each_cpu(boost_set_msr_each, (void *)(long)val, 1); (void *)(long)val, 1);
put_online_cpus(); pr_debug("CPU %*pbl: Core Boosting %sabled.\n",
pr_debug("Core Boosting %sabled.\n", val ? "en" : "dis"); cpumask_pr_args(policy->cpus), val ? "en" : "dis");
return 0; return 0;
} }
...@@ -162,7 +162,9 @@ static ssize_t store_cpb(struct cpufreq_policy *policy, const char *buf, ...@@ -162,7 +162,9 @@ static ssize_t store_cpb(struct cpufreq_policy *policy, const char *buf,
if (ret || val > 1) if (ret || val > 1)
return -EINVAL; return -EINVAL;
set_boost(val); get_online_cpus();
set_boost(policy, val);
put_online_cpus();
return count; return count;
} }
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
* requested etc. * requested etc.
*/ */
static struct cppc_cpudata **all_cpu_data; static struct cppc_cpudata **all_cpu_data;
static bool boost_supported;
struct cppc_workaround_oem_info { struct cppc_workaround_oem_info {
char oem_id[ACPI_OEM_ID_SIZE + 1]; char oem_id[ACPI_OEM_ID_SIZE + 1];
...@@ -310,7 +311,7 @@ static int cppc_cpufreq_cpu_init(struct cpufreq_policy *policy) ...@@ -310,7 +311,7 @@ static int cppc_cpufreq_cpu_init(struct cpufreq_policy *policy)
* Section 8.4.7.1.1.5 of ACPI 6.1 spec) * Section 8.4.7.1.1.5 of ACPI 6.1 spec)
*/ */
policy->min = cppc_cpufreq_perf_to_khz(cpu, cpu->perf_caps.lowest_nonlinear_perf); policy->min = cppc_cpufreq_perf_to_khz(cpu, cpu->perf_caps.lowest_nonlinear_perf);
policy->max = cppc_cpufreq_perf_to_khz(cpu, cpu->perf_caps.highest_perf); policy->max = cppc_cpufreq_perf_to_khz(cpu, cpu->perf_caps.nominal_perf);
/* /*
* Set cpuinfo.min_freq to Lowest to make the full range of performance * Set cpuinfo.min_freq to Lowest to make the full range of performance
...@@ -318,7 +319,7 @@ static int cppc_cpufreq_cpu_init(struct cpufreq_policy *policy) ...@@ -318,7 +319,7 @@ static int cppc_cpufreq_cpu_init(struct cpufreq_policy *policy)
* nonlinear perf * nonlinear perf
*/ */
policy->cpuinfo.min_freq = cppc_cpufreq_perf_to_khz(cpu, cpu->perf_caps.lowest_perf); policy->cpuinfo.min_freq = cppc_cpufreq_perf_to_khz(cpu, cpu->perf_caps.lowest_perf);
policy->cpuinfo.max_freq = cppc_cpufreq_perf_to_khz(cpu, cpu->perf_caps.highest_perf); policy->cpuinfo.max_freq = cppc_cpufreq_perf_to_khz(cpu, cpu->perf_caps.nominal_perf);
policy->transition_delay_us = cppc_cpufreq_get_transition_delay_us(cpu_num); policy->transition_delay_us = cppc_cpufreq_get_transition_delay_us(cpu_num);
policy->shared_type = cpu->shared_type; policy->shared_type = cpu->shared_type;
...@@ -343,6 +344,13 @@ static int cppc_cpufreq_cpu_init(struct cpufreq_policy *policy) ...@@ -343,6 +344,13 @@ static int cppc_cpufreq_cpu_init(struct cpufreq_policy *policy)
cpu->cur_policy = policy; cpu->cur_policy = policy;
/*
* If 'highest_perf' is greater than 'nominal_perf', we assume CPU Boost
* is supported.
*/
if (cpu->perf_caps.highest_perf > cpu->perf_caps.nominal_perf)
boost_supported = true;
/* Set policy->cur to max now. The governors will adjust later. */ /* Set policy->cur to max now. The governors will adjust later. */
policy->cur = cppc_cpufreq_perf_to_khz(cpu, policy->cur = cppc_cpufreq_perf_to_khz(cpu,
cpu->perf_caps.highest_perf); cpu->perf_caps.highest_perf);
...@@ -410,6 +418,32 @@ static unsigned int cppc_cpufreq_get_rate(unsigned int cpunum) ...@@ -410,6 +418,32 @@ static unsigned int cppc_cpufreq_get_rate(unsigned int cpunum)
return cppc_get_rate_from_fbctrs(cpu, fb_ctrs_t0, fb_ctrs_t1); return cppc_get_rate_from_fbctrs(cpu, fb_ctrs_t0, fb_ctrs_t1);
} }
static int cppc_cpufreq_set_boost(struct cpufreq_policy *policy, int state)
{
struct cppc_cpudata *cpudata;
int ret;
if (!boost_supported) {
pr_err("BOOST not supported by CPU or firmware\n");
return -EINVAL;
}
cpudata = all_cpu_data[policy->cpu];
if (state)
policy->max = cppc_cpufreq_perf_to_khz(cpudata,
cpudata->perf_caps.highest_perf);
else
policy->max = cppc_cpufreq_perf_to_khz(cpudata,
cpudata->perf_caps.nominal_perf);
policy->cpuinfo.max_freq = policy->max;
ret = freq_qos_update_request(policy->max_freq_req, policy->max);
if (ret < 0)
return ret;
return 0;
}
static struct cpufreq_driver cppc_cpufreq_driver = { static struct cpufreq_driver cppc_cpufreq_driver = {
.flags = CPUFREQ_CONST_LOOPS, .flags = CPUFREQ_CONST_LOOPS,
.verify = cppc_verify_policy, .verify = cppc_verify_policy,
...@@ -417,6 +451,7 @@ static struct cpufreq_driver cppc_cpufreq_driver = { ...@@ -417,6 +451,7 @@ static struct cpufreq_driver cppc_cpufreq_driver = {
.get = cppc_cpufreq_get_rate, .get = cppc_cpufreq_get_rate,
.init = cppc_cpufreq_cpu_init, .init = cppc_cpufreq_cpu_init,
.stop_cpu = cppc_cpufreq_stop_cpu, .stop_cpu = cppc_cpufreq_stop_cpu,
.set_boost = cppc_cpufreq_set_boost,
.name = "cppc_cpufreq", .name = "cppc_cpufreq",
}; };
......
...@@ -2532,34 +2532,29 @@ EXPORT_SYMBOL_GPL(cpufreq_update_limits); ...@@ -2532,34 +2532,29 @@ EXPORT_SYMBOL_GPL(cpufreq_update_limits);
/********************************************************************* /*********************************************************************
* BOOST * * BOOST *
*********************************************************************/ *********************************************************************/
static int cpufreq_boost_set_sw(int state) static int cpufreq_boost_set_sw(struct cpufreq_policy *policy, int state)
{ {
struct cpufreq_policy *policy; int ret;
for_each_active_policy(policy) {
int ret;
if (!policy->freq_table) if (!policy->freq_table)
return -ENXIO; return -ENXIO;
ret = cpufreq_frequency_table_cpuinfo(policy, ret = cpufreq_frequency_table_cpuinfo(policy, policy->freq_table);
policy->freq_table); if (ret) {
if (ret) { pr_err("%s: Policy frequency update failed\n", __func__);
pr_err("%s: Policy frequency update failed\n", return ret;
__func__);
return ret;
}
ret = freq_qos_update_request(policy->max_freq_req, policy->max);
if (ret < 0)
return ret;
} }
ret = freq_qos_update_request(policy->max_freq_req, policy->max);
if (ret < 0)
return ret;
return 0; return 0;
} }
int cpufreq_boost_trigger_state(int state) int cpufreq_boost_trigger_state(int state)
{ {
struct cpufreq_policy *policy;
unsigned long flags; unsigned long flags;
int ret = 0; int ret = 0;
...@@ -2570,15 +2565,25 @@ int cpufreq_boost_trigger_state(int state) ...@@ -2570,15 +2565,25 @@ int cpufreq_boost_trigger_state(int state)
cpufreq_driver->boost_enabled = state; cpufreq_driver->boost_enabled = state;
write_unlock_irqrestore(&cpufreq_driver_lock, flags); write_unlock_irqrestore(&cpufreq_driver_lock, flags);
ret = cpufreq_driver->set_boost(state); get_online_cpus();
if (ret) { for_each_active_policy(policy) {
write_lock_irqsave(&cpufreq_driver_lock, flags); ret = cpufreq_driver->set_boost(policy, state);
cpufreq_driver->boost_enabled = !state; if (ret)
write_unlock_irqrestore(&cpufreq_driver_lock, flags); goto err_reset_state;
pr_err("%s: Cannot %s BOOST\n",
__func__, state ? "enable" : "disable");
} }
put_online_cpus();
return 0;
err_reset_state:
put_online_cpus();
write_lock_irqsave(&cpufreq_driver_lock, flags);
cpufreq_driver->boost_enabled = !state;
write_unlock_irqrestore(&cpufreq_driver_lock, flags);
pr_err("%s: Cannot %s BOOST\n",
__func__, state ? "enable" : "disable");
return ret; return ret;
} }
......
...@@ -93,7 +93,8 @@ static int tegra186_cpufreq_set_target(struct cpufreq_policy *policy, ...@@ -93,7 +93,8 @@ static int tegra186_cpufreq_set_target(struct cpufreq_policy *policy,
static struct cpufreq_driver tegra186_cpufreq_driver = { static struct cpufreq_driver tegra186_cpufreq_driver = {
.name = "tegra186", .name = "tegra186",
.flags = CPUFREQ_STICKY | CPUFREQ_HAVE_GOVERNOR_PER_POLICY, .flags = CPUFREQ_STICKY | CPUFREQ_HAVE_GOVERNOR_PER_POLICY |
CPUFREQ_NEED_INITIAL_FREQ_CHECK,
.verify = cpufreq_generic_frequency_table_verify, .verify = cpufreq_generic_frequency_table_verify,
.target_index = tegra186_cpufreq_set_target, .target_index = tegra186_cpufreq_set_target,
.init = tegra186_cpufreq_init, .init = tegra186_cpufreq_init,
......
...@@ -367,7 +367,7 @@ struct cpufreq_driver { ...@@ -367,7 +367,7 @@ struct cpufreq_driver {
/* platform specific boost support code */ /* platform specific boost support code */
bool boost_enabled; bool boost_enabled;
int (*set_boost)(int state); int (*set_boost)(struct cpufreq_policy *policy, int state);
}; };
/* flags */ /* flags */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment