|
@@ -1049,30 +1049,29 @@ static int cpufreq_add_policy_cpu(struct cpufreq_policy *policy, unsigned int cp
|
|
if (cpumask_test_cpu(cpu, policy->cpus))
|
|
if (cpumask_test_cpu(cpu, policy->cpus))
|
|
return 0;
|
|
return 0;
|
|
|
|
|
|
|
|
+ down_write(&policy->rwsem);
|
|
if (has_target()) {
|
|
if (has_target()) {
|
|
ret = __cpufreq_governor(policy, CPUFREQ_GOV_STOP);
|
|
ret = __cpufreq_governor(policy, CPUFREQ_GOV_STOP);
|
|
if (ret) {
|
|
if (ret) {
|
|
pr_err("%s: Failed to stop governor\n", __func__);
|
|
pr_err("%s: Failed to stop governor\n", __func__);
|
|
- return ret;
|
|
|
|
|
|
+ goto unlock;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- down_write(&policy->rwsem);
|
|
|
|
cpumask_set_cpu(cpu, policy->cpus);
|
|
cpumask_set_cpu(cpu, policy->cpus);
|
|
- up_write(&policy->rwsem);
|
|
|
|
|
|
|
|
if (has_target()) {
|
|
if (has_target()) {
|
|
ret = __cpufreq_governor(policy, CPUFREQ_GOV_START);
|
|
ret = __cpufreq_governor(policy, CPUFREQ_GOV_START);
|
|
if (!ret)
|
|
if (!ret)
|
|
ret = __cpufreq_governor(policy, CPUFREQ_GOV_LIMITS);
|
|
ret = __cpufreq_governor(policy, CPUFREQ_GOV_LIMITS);
|
|
|
|
|
|
- if (ret) {
|
|
|
|
|
|
+ if (ret)
|
|
pr_err("%s: Failed to start governor\n", __func__);
|
|
pr_err("%s: Failed to start governor\n", __func__);
|
|
- return ret;
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- return 0;
|
|
|
|
|
|
+unlock:
|
|
|
|
+ up_write(&policy->rwsem);
|
|
|
|
+ return ret;
|
|
}
|
|
}
|
|
|
|
|
|
static struct cpufreq_policy *cpufreq_policy_alloc(unsigned int cpu)
|
|
static struct cpufreq_policy *cpufreq_policy_alloc(unsigned int cpu)
|
|
@@ -1375,13 +1374,13 @@ static void cpufreq_offline(unsigned int cpu)
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ down_write(&policy->rwsem);
|
|
if (has_target()) {
|
|
if (has_target()) {
|
|
ret = __cpufreq_governor(policy, CPUFREQ_GOV_STOP);
|
|
ret = __cpufreq_governor(policy, CPUFREQ_GOV_STOP);
|
|
if (ret)
|
|
if (ret)
|
|
pr_err("%s: Failed to stop governor\n", __func__);
|
|
pr_err("%s: Failed to stop governor\n", __func__);
|
|
}
|
|
}
|
|
|
|
|
|
- down_write(&policy->rwsem);
|
|
|
|
cpumask_clear_cpu(cpu, policy->cpus);
|
|
cpumask_clear_cpu(cpu, policy->cpus);
|
|
|
|
|
|
if (policy_is_inactive(policy)) {
|
|
if (policy_is_inactive(policy)) {
|
|
@@ -1394,7 +1393,6 @@ static void cpufreq_offline(unsigned int cpu)
|
|
/* Nominate new CPU */
|
|
/* Nominate new CPU */
|
|
policy->cpu = cpumask_any(policy->cpus);
|
|
policy->cpu = cpumask_any(policy->cpus);
|
|
}
|
|
}
|
|
- up_write(&policy->rwsem);
|
|
|
|
|
|
|
|
/* Start governor again for active policy */
|
|
/* Start governor again for active policy */
|
|
if (!policy_is_inactive(policy)) {
|
|
if (!policy_is_inactive(policy)) {
|
|
@@ -1407,7 +1405,7 @@ static void cpufreq_offline(unsigned int cpu)
|
|
pr_err("%s: Failed to start governor\n", __func__);
|
|
pr_err("%s: Failed to start governor\n", __func__);
|
|
}
|
|
}
|
|
|
|
|
|
- return;
|
|
|
|
|
|
+ goto unlock;
|
|
}
|
|
}
|
|
|
|
|
|
if (cpufreq_driver->stop_cpu)
|
|
if (cpufreq_driver->stop_cpu)
|
|
@@ -1429,6 +1427,9 @@ static void cpufreq_offline(unsigned int cpu)
|
|
cpufreq_driver->exit(policy);
|
|
cpufreq_driver->exit(policy);
|
|
policy->freq_table = NULL;
|
|
policy->freq_table = NULL;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+unlock:
|
|
|
|
+ up_write(&policy->rwsem);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -1625,6 +1626,7 @@ EXPORT_SYMBOL(cpufreq_generic_suspend);
|
|
void cpufreq_suspend(void)
|
|
void cpufreq_suspend(void)
|
|
{
|
|
{
|
|
struct cpufreq_policy *policy;
|
|
struct cpufreq_policy *policy;
|
|
|
|
+ int ret;
|
|
|
|
|
|
if (!cpufreq_driver)
|
|
if (!cpufreq_driver)
|
|
return;
|
|
return;
|
|
@@ -1635,7 +1637,11 @@ void cpufreq_suspend(void)
|
|
pr_debug("%s: Suspending Governors\n", __func__);
|
|
pr_debug("%s: Suspending Governors\n", __func__);
|
|
|
|
|
|
for_each_active_policy(policy) {
|
|
for_each_active_policy(policy) {
|
|
- if (__cpufreq_governor(policy, CPUFREQ_GOV_STOP))
|
|
|
|
|
|
+ down_write(&policy->rwsem);
|
|
|
|
+ ret = __cpufreq_governor(policy, CPUFREQ_GOV_STOP);
|
|
|
|
+ up_write(&policy->rwsem);
|
|
|
|
+
|
|
|
|
+ if (ret)
|
|
pr_err("%s: Failed to stop governor for policy: %p\n",
|
|
pr_err("%s: Failed to stop governor for policy: %p\n",
|
|
__func__, policy);
|
|
__func__, policy);
|
|
else if (cpufreq_driver->suspend
|
|
else if (cpufreq_driver->suspend
|
|
@@ -1657,6 +1663,7 @@ suspend:
|
|
void cpufreq_resume(void)
|
|
void cpufreq_resume(void)
|
|
{
|
|
{
|
|
struct cpufreq_policy *policy;
|
|
struct cpufreq_policy *policy;
|
|
|
|
+ int ret;
|
|
|
|
|
|
if (!cpufreq_driver)
|
|
if (!cpufreq_driver)
|
|
return;
|
|
return;
|
|
@@ -1669,13 +1676,20 @@ void cpufreq_resume(void)
|
|
pr_debug("%s: Resuming Governors\n", __func__);
|
|
pr_debug("%s: Resuming Governors\n", __func__);
|
|
|
|
|
|
for_each_active_policy(policy) {
|
|
for_each_active_policy(policy) {
|
|
- if (cpufreq_driver->resume && cpufreq_driver->resume(policy))
|
|
|
|
|
|
+ if (cpufreq_driver->resume && cpufreq_driver->resume(policy)) {
|
|
pr_err("%s: Failed to resume driver: %p\n", __func__,
|
|
pr_err("%s: Failed to resume driver: %p\n", __func__,
|
|
policy);
|
|
policy);
|
|
- else if (__cpufreq_governor(policy, CPUFREQ_GOV_START)
|
|
|
|
- || __cpufreq_governor(policy, CPUFREQ_GOV_LIMITS))
|
|
|
|
- pr_err("%s: Failed to start governor for policy: %p\n",
|
|
|
|
- __func__, policy);
|
|
|
|
|
|
+ } else {
|
|
|
|
+ down_write(&policy->rwsem);
|
|
|
|
+ ret = __cpufreq_governor(policy, CPUFREQ_GOV_START);
|
|
|
|
+ if (!ret)
|
|
|
|
+ __cpufreq_governor(policy, CPUFREQ_GOV_LIMITS);
|
|
|
|
+ up_write(&policy->rwsem);
|
|
|
|
+
|
|
|
|
+ if (ret)
|
|
|
|
+ pr_err("%s: Failed to start governor for policy: %p\n",
|
|
|
|
+ __func__, policy);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -2326,8 +2340,11 @@ static int cpufreq_boost_set_sw(int state)
|
|
__func__);
|
|
__func__);
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ down_write(&policy->rwsem);
|
|
policy->user_policy.max = policy->max;
|
|
policy->user_policy.max = policy->max;
|
|
__cpufreq_governor(policy, CPUFREQ_GOV_LIMITS);
|
|
__cpufreq_governor(policy, CPUFREQ_GOV_LIMITS);
|
|
|
|
+ up_write(&policy->rwsem);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|