This one fell through the automation at first because it initializes the
semaphore to locked, but that's easily remedied
Signed-off-by: Arjan van de Ven <arjan@infradead.org>
Signed-off-by: Dave Jones <davej@redhat.com>
drivers/cpufreq/cpufreq.c | 37 +++++++++++++++++++------------------
include/linux/cpufreq.h | 3 ++-
2 files changed, 21 insertions(+), 19 deletions(-)
policy->cpu = cpu;
policy->cpus = cpumask_of_cpu(cpu);
policy->cpu = cpu;
policy->cpus = cpumask_of_cpu(cpu);
- init_MUTEX_LOCKED(&policy->lock);
+ mutex_init(&policy->lock);
+ mutex_lock(&policy->lock);
init_completion(&policy->kobj_unregister);
INIT_WORK(&policy->update, handle_update, (void *)(long)cpu);
init_completion(&policy->kobj_unregister);
INIT_WORK(&policy->update, handle_update, (void *)(long)cpu);
spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
policy->governor = NULL; /* to assure that the starting sequence is
* run in cpufreq_set_policy */
spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
policy->governor = NULL; /* to assure that the starting sequence is
* run in cpufreq_set_policy */
+ mutex_unlock(&policy->lock);
spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
#endif
spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
#endif
+ mutex_lock(&data->lock);
if (cpufreq_driver->target)
__cpufreq_governor(data, CPUFREQ_GOV_STOP);
if (cpufreq_driver->target)
__cpufreq_governor(data, CPUFREQ_GOV_STOP);
+ mutex_unlock(&data->lock);
kobject_unregister(&data->kobj);
kobject_unregister(&data->kobj);
unsigned int ret = 0;
if (policy) {
unsigned int ret = 0;
if (policy) {
+ mutex_lock(&policy->lock);
+ mutex_unlock(&policy->lock);
cpufreq_cpu_put(policy);
}
cpufreq_cpu_put(policy);
}
if (!cpufreq_driver->get)
goto out;
if (!cpufreq_driver->get)
goto out;
+ mutex_lock(&policy->lock);
ret = cpufreq_driver->get(cpu);
ret = cpufreq_driver->get(cpu);
+ mutex_unlock(&policy->lock);
out:
cpufreq_cpu_put(policy);
out:
cpufreq_cpu_put(policy);
if (!policy)
return -EINVAL;
if (!policy)
return -EINVAL;
+ mutex_lock(&policy->lock);
ret = __cpufreq_driver_target(policy, target_freq, relation);
ret = __cpufreq_driver_target(policy, target_freq, relation);
+ mutex_unlock(&policy->lock);
if (!policy)
return -EINVAL;
if (!policy)
return -EINVAL;
+ mutex_lock(&policy->lock);
ret = __cpufreq_governor(policy, event);
ret = __cpufreq_governor(policy, event);
+ mutex_unlock(&policy->lock);
if (!cpu_policy)
return -EINVAL;
if (!cpu_policy)
return -EINVAL;
- down(&cpu_policy->lock);
+ mutex_lock(&cpu_policy->lock);
memcpy(policy, cpu_policy, sizeof(struct cpufreq_policy));
memcpy(policy, cpu_policy, sizeof(struct cpufreq_policy));
+ mutex_unlock(&cpu_policy->lock);
cpufreq_cpu_put(cpu_policy);
cpufreq_cpu_put(cpu_policy);
return -EINVAL;
/* lock this CPU */
return -EINVAL;
/* lock this CPU */
+ mutex_lock(&data->lock);
ret = __cpufreq_set_policy(data, policy);
data->user_policy.min = data->min;
ret = __cpufreq_set_policy(data, policy);
data->user_policy.min = data->min;
data->user_policy.policy = data->policy;
data->user_policy.governor = data->governor;
data->user_policy.policy = data->policy;
data->user_policy.governor = data->governor;
+ mutex_unlock(&data->lock);
cpufreq_cpu_put(data);
return ret;
cpufreq_cpu_put(data);
return ret;
if (!data)
return -ENODEV;
if (!data)
return -ENODEV;
+ mutex_lock(&data->lock);
dprintk("updating policy for CPU %u\n", cpu);
memcpy(&policy,
dprintk("updating policy for CPU %u\n", cpu);
memcpy(&policy,
ret = __cpufreq_set_policy(data, &policy);
ret = __cpufreq_set_policy(data, &policy);
+ mutex_unlock(&data->lock);
cpufreq_cpu_put(data);
return ret;
cpufreq_cpu_put(data);
return ret;
#ifndef _LINUX_CPUFREQ_H
#define _LINUX_CPUFREQ_H
#ifndef _LINUX_CPUFREQ_H
#define _LINUX_CPUFREQ_H
+#include <linux/mutex.h>
#include <linux/config.h>
#include <linux/notifier.h>
#include <linux/threads.h>
#include <linux/config.h>
#include <linux/notifier.h>
#include <linux/threads.h>
unsigned int policy; /* see above */
struct cpufreq_governor *governor; /* see below */
unsigned int policy; /* see above */
struct cpufreq_governor *governor; /* see below */
- struct semaphore lock; /* CPU ->setpolicy or ->target may
+ struct mutex lock; /* CPU ->setpolicy or ->target may
only be called once a time */
struct work_struct update; /* if update_policy() needs to be
only be called once a time */
struct work_struct update; /* if update_policy() needs to be