本文整理汇总了C++中cpufreq_get_policy函数的典型用法代码示例。如果您正苦于以下问题:C++ cpufreq_get_policy函数的具体用法?C++ cpufreq_get_policy怎么用?C++ cpufreq_get_policy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cpufreq_get_policy函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: single_freq_init
int single_freq_init (actuator_t *act)
{
int err;
struct cpufreq_policy *policy;
struct cpufreq_available_frequencies *freq_list;
freq_scaler_data_t *data;
unsigned long freq_min, freq_max;
act->data = data = malloc(sizeof(freq_scaler_data_t));
fail_if(!data, "cannot allocate freq data block");
err = cpufreq_get_hardware_limits(act->core, &freq_min, &freq_max);
fail_if(err, "cannot get cpufreq hardware limits");
act->min = freq_min;
act->max = freq_max;
policy = cpufreq_get_policy(act->core);
fail_if(!policy, "cannot get cpufreq policy");
if (strcmp(policy->governor, "userspace") != 0) {
err = cpufreq_modify_policy_governor(act->core, "userspace");
policy = cpufreq_get_policy(act->core);
fail_if (strcmp(policy->governor, "userspace") != 0, "cannot set cpufreq policy to userspace");
}
freq_list = cpufreq_get_available_frequencies(act->core);
data->freq_count = create_freq_array(freq_list, &data->freq_array);
fail_if(data->freq_count < 1, "cannot get frequency list");
act->value = act->set_value = cpufreq_get_freq_kernel(act->core);
data->cur_index = get_freq_index(data, act->value);
return 0;
fail:
return -1;
}
示例2: boost_mig_sync_thread
static int boost_mig_sync_thread(void *data)
{
int dest_cpu = (int) data;
int src_cpu, ret;
struct cpu_sync *s = &per_cpu(sync_info, dest_cpu);
struct cpufreq_policy dest_policy;
struct cpufreq_policy src_policy;
unsigned long flags;
while (1) {
wait_event(s->sync_wq, s->pending || kthread_should_stop());
if (kthread_should_stop())
break;
spin_lock_irqsave(&s->lock, flags);
s->pending = false;
src_cpu = s->src_cpu;
spin_unlock_irqrestore(&s->lock, flags);
ret = cpufreq_get_policy(&src_policy, src_cpu);
if (ret)
continue;
ret = cpufreq_get_policy(&dest_policy, dest_cpu);
if (ret)
continue;
if (dest_policy.cur >= src_policy.cur) {
pr_debug("No sync. CPU%[email protected]%dKHz >= CPU%[email protected]%dKHz\n",
dest_cpu, dest_policy.cur,
src_cpu, src_policy.cur);
continue;
}
if (sync_threshold && (dest_policy.cur >= sync_threshold))
continue;
cancel_delayed_work_sync(&s->boost_rem);
if (sync_threshold)
s->boost_min = min(sync_threshold, src_policy.cur);
else
s->boost_min = src_policy.cur;
/* Force policy re-evaluation to trigger adjust notifier. */
get_online_cpus();
if (cpu_online(dest_cpu)) {
cpufreq_update_policy(dest_cpu);
queue_delayed_work_on(dest_cpu, cpu_boost_wq,
&s->boost_rem, msecs_to_jiffies(boost_ms));
} else {
s->boost_min = 0;
}
put_online_cpus();
}
return 0;
}
示例3: run_boost_migration
static void run_boost_migration(unsigned int cpu)
{
int dest_cpu = cpu;
int src_cpu, ret;
struct cpu_sync *s = &per_cpu(sync_info, dest_cpu);
struct cpufreq_policy dest_policy;
struct cpufreq_policy src_policy;
unsigned long flags;
spin_lock_irqsave(&s->lock, flags);
s->pending = false;
src_cpu = s->src_cpu;
spin_unlock_irqrestore(&s->lock, flags);
ret = cpufreq_get_policy(&src_policy, src_cpu);
if (ret)
return;
ret = cpufreq_get_policy(&dest_policy, dest_cpu);
if (ret)
return;
if (src_policy.min == src_policy.cpuinfo.min_freq) {
pr_debug("No sync. Source CPU%[email protected]%dKHz at min freq\n",
src_cpu, src_policy.cur);
return;
}
cancel_delayed_work_sync(&s->boost_rem);
if (sync_threshold)
s->boost_min = min(sync_threshold, src_policy.cur);
else
s->boost_min = src_policy.cur;
/* Force policy re-evaluation to trigger adjust notifier. */
get_online_cpus();
if (cpu_online(src_cpu))
/*
* Send an unchanged policy update to the source
* CPU. Even though the policy isn't changed from
* its existing boosted or non-boosted state
* notifying the source CPU will let the governor
* know a boost happened on another CPU and that it
* should re-evaluate the frequency at the next timer
* event without interference from a min sample time.
*/
cpufreq_update_policy(src_cpu);
if (cpu_online(dest_cpu)) {
cpufreq_update_policy(dest_cpu);
queue_delayed_work_on(dest_cpu, cpu_boost_wq,
&s->boost_rem, msecs_to_jiffies(boost_ms));
} else {
s->boost_min = 0;
}
put_online_cpus();
}
示例4: run_boost_migration
static void run_boost_migration(unsigned int cpu)
{
int dest_cpu = cpu;
int src_cpu, ret;
struct cpu_sync *s = &per_cpu(sync_info, dest_cpu);
struct cpufreq_policy dest_policy;
struct cpufreq_policy src_policy;
unsigned long flags;
unsigned int req_freq;
spin_lock_irqsave(&s->lock, flags);
s->pending = false;
src_cpu = s->src_cpu;
spin_unlock_irqrestore(&s->lock, flags);
ret = cpufreq_get_policy(&src_policy, src_cpu);
if (ret)
return;
ret = cpufreq_get_policy(&dest_policy, dest_cpu);
if (ret)
return;
req_freq = max((dest_policy.max * s->task_load) / 100,
src_policy.cur);
if (req_freq <= dest_policy.cpuinfo.min_freq) {
pr_debug("No sync. Sync Freq:%u\n", req_freq);
return;
}
if (sync_threshold)
req_freq = min(sync_threshold, req_freq);
cancel_delayed_work_sync(&s->boost_rem);
s->boost_min = req_freq;
/* Force policy re-evaluation to trigger adjust notifier. */
get_online_cpus();
if (cpu_online(dest_cpu)) {
cpufreq_update_policy(dest_cpu);
queue_delayed_work_on(dest_cpu, cpu_boost_wq,
&s->boost_rem, msecs_to_jiffies(boost_ms));
} else {
s->boost_min = 0;
}
put_online_cpus();
}
示例5: syf_pwm_ioctl
static int
syf_pwm_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, void *arg)
{
int i;
unsigned int freq;
cpu_ctrl_t *cc = (cpu_ctrl_t *) arg;
pmu_results_t *r = &(cc->pmu);
unsigned int amt_cpu = cc->amt_cpu;
unsigned int amt_counter = cc->amt_counter;
for (i = 0; i < amt_cpu; ++i) {
struct syf_info_t *_sinfo = &per_cpu(_syf_info, i);
switch (cmd) {
case SYFPWM_TESTING:
printk("TESTING.\n");
break;
case SYFPWM_PMU_START:
pmu_start(amt_counter, cc->evt_t);
break;
case SYFPWM_PMU_STOP:
pmu_stop(amt_counter);
memcpy(r, &pmu, sizeof(pmu_results_t));
break;
case SYFPWM_GET_FEQU:
mutex_lock(&_syf_mutex);
cpufreq_get_policy(&_sinfo->cur_policy, i);
freq = cpufreq_get(_sinfo->cur_policy.cpu);
mutex_unlock(&_syf_mutex);
break;
case SYFPWM_SET_FEQU:
mutex_lock(&_syf_mutex);
cpufreq_get_policy(&_sinfo->cur_policy, i);
freq = __cpufreq_driver_target(&_sinfo->cur_policy,
(unsigned int) cc->cpu_freq,
CPUFREQ_RELATION_H);
mutex_unlock(&_syf_mutex);
break;
}
}
return 0;
}
示例6: do_input_boost
static void do_input_boost(struct work_struct *work)
{
unsigned int i, ret, freq;
struct cpu_sync *i_sync_info;
struct cpufreq_policy policy;
for_each_online_cpu(i) {
i_sync_info = &per_cpu(sync_info, i);
ret = cpufreq_get_policy(&policy, i);
if (ret)
continue;
// ensure, touch boost freq does never exceed max scaling freq
if (input_boost_freq > policy.max)
freq = policy.max;
else
freq = input_boost_freq;
if (policy.cur >= freq)
continue;
cancel_delayed_work_sync(&i_sync_info->input_boost_rem);
i_sync_info->input_boost_min = freq;
cpufreq_update_policy(i);
queue_delayed_work_on(i_sync_info->cpu, cpu_boost_wq,
&i_sync_info->input_boost_rem,
msecs_to_jiffies(input_boost_ms));
}
}
示例7: screen_off_limit
static void screen_off_limit(bool on)
{
unsigned int i, ret;
struct cpufreq_policy policy;
struct ip_cpu_info *l_ip_info;
/* not active, so exit */
if (screen_off_max == UINT_MAX)
return;
for_each_online_cpu(i) {
l_ip_info = &per_cpu(ip_info, i);
ret = cpufreq_get_policy(&policy, i);
if (ret)
continue;
if (on) {
/* save current instance */
l_ip_info->curr_max = policy.max;
policy.max = screen_off_max;
} else {
/* restore */
policy.max = l_ip_info->curr_max;
}
cpufreq_update_policy(i);
}
}
示例8: do_input_boost
static void do_input_boost(struct work_struct *work)
{
unsigned int i, ret;
struct cpu_sync *i_sync_info;
struct cpufreq_policy policy;
get_online_cpus();
for_each_online_cpu(i) {
i_sync_info = &per_cpu(sync_info, i);
ret = cpufreq_get_policy(&policy, i);
if (ret)
continue;
if (policy.cur >= input_boost_freq)
continue;
cancel_delayed_work_sync(&i_sync_info->input_boost_rem);
i_sync_info->input_boost_min = input_boost_freq;
cpufreq_update_policy(i);
queue_delayed_work_on(i_sync_info->cpu, cpu_boost_wq,
&i_sync_info->input_boost_rem,
msecs_to_jiffies(input_boost_ms));
}
put_online_cpus();
}
示例9: get_curr_load
static unsigned int get_curr_load(unsigned int cpu)
{
int ret;
unsigned int idle_time, wall_time;
unsigned int cur_load;
u64 cur_wall_time, cur_idle_time;
struct cpu_load_data *pcpu = &per_cpu(cpuload, cpu);
struct cpufreq_policy policy;
ret = cpufreq_get_policy(&policy, cpu);
if (ret)
return -EINVAL;
cur_idle_time = get_cpu_idle_time(cpu, &cur_wall_time, 0);
wall_time = (unsigned int) (cur_wall_time - pcpu->prev_cpu_wall);
pcpu->prev_cpu_wall = cur_wall_time;
idle_time = (unsigned int) (cur_idle_time - pcpu->prev_cpu_idle);
pcpu->prev_cpu_idle = cur_idle_time;
if (unlikely(!wall_time || wall_time < idle_time))
return 0;
cur_load = 100 * (wall_time - idle_time) / wall_time;
return cur_load;
}
示例10: do_new_policy
static int do_new_policy(unsigned int cpu, struct cpufreq_policy *new_pol)
{
struct cpufreq_policy *cur_pol = cpufreq_get_policy(cpu);
int ret;
if (!cur_pol) {
printf(_("wrong, unknown or unhandled CPU?\n"));
return -EINVAL;
}
if (!new_pol->min)
new_pol->min = cur_pol->min;
if (!new_pol->max)
new_pol->max = cur_pol->max;
if (!new_pol->governor)
new_pol->governor = cur_pol->governor;
ret = cpufreq_set_policy(cpu, new_pol);
cpufreq_put_policy(cur_pol);
return ret;
}
示例11: cpu_has_cpufreq
static int cpu_has_cpufreq(unsigned int cpu)
{
struct cpufreq_policy policy;
if (!acpi_thermal_cpufreq_is_init || cpufreq_get_policy(&policy, cpu))
return 0;
return 1;
}
示例12: set_cpufreq
static int set_cpufreq(int cpu, int min_freq, int max_freq)
{
int ret;
struct cpufreq_policy policy;
pr_debug("set cpu freq: min %d, max %d\n", min_freq, max_freq);
ret = cpufreq_get_policy(&policy, cpu);
if (ret < 0) {
pr_err("usecase-gov: failed to read policy\n");
return ret;
}
if (policy.min > max_freq) {
ret = cpufreq_update_freq(cpu, min_freq, policy.max);
if (ret)
pr_err("usecase-gov: update min cpufreq failed (1)\n");
}
if (policy.max < min_freq) {
ret = cpufreq_update_freq(cpu, policy.min, max_freq);
if (ret)
pr_err("usecase-gov: update max cpufreq failed (2)\n");
}
ret = cpufreq_update_freq(cpu, min_freq, max_freq);
if (ret)
pr_err("usecase-gov: update min-max cpufreq failed\n");
return ret;
}
示例13: update_cpu_max_freq
static int update_cpu_max_freq(int cpu, int throttled_bin, unsigned temp)
{
int ret;
int max_frequency = max_freq(throttled_bin);
ret = msm_cpufreq_set_freq_limits(cpu, MSM_CPUFREQ_NO_LIMIT, max_frequency);
if (ret)
return ret;
ret = cpufreq_update_policy(cpu);
if (ret)
return ret;
if (max_frequency != MSM_CPUFREQ_NO_LIMIT) {
struct cpufreq_policy policy;
if ((ret = cpufreq_get_policy(&policy, cpu)) == 0)
ret = cpufreq_driver_target(&policy, max_frequency, CPUFREQ_RELATION_L);
}
if (max_frequency != MSM_CPUFREQ_NO_LIMIT)
pr_info("msm_thermal: limiting cpu%d max frequency to %d at %u degC\n",
cpu, max_frequency, temp);
else
pr_info("msm_thermal: Max frequency reset for cpu%d at %u degC\n", cpu, temp);
return ret;
}
示例14: cd_set_cur_state
static int cd_set_cur_state(struct thermal_cooling_device *cdev,
unsigned long state)
{
struct thermal_freq *therm = cdev->devdata;
struct cpufreq_policy policy;
int trip, i;
if (!state && therm->state) {
if (cpufreq_get_policy(&policy, 0))
return -EINVAL;
maximum_freq = policy.cpuinfo.max_freq;
therm->current_trip = -1;
therm->state = 0;
therm->tdev->polling_delay = therm->idle_polling_delay;
cpufreq_update_policy(0);
return 0;
}
trip = -1;
therm->state = state;
for (i = 0; i < therm->trip_count; i++) {
if (therm->current_temp < therm->trip_table[i].temp)
break;
trip = i;
}
if (i == therm->current_trip)
return 0;
if (cpufreq_get_policy(&policy, 0))
return -EINVAL;
if (i < 0) {
therm->tdev->polling_delay = therm->idle_polling_delay;
maximum_freq = policy.cpuinfo.max_freq;
} else {
therm->tdev->polling_delay =
therm->trip_table[i].polling_interval;
maximum_freq = therm->trip_table[i].freq;
}
cpufreq_update_policy(0);
therm->current_trip = i;
return 0;
}
示例15: cpufreq_save_default_governor
void cpufreq_save_default_governor(void)
{
int ret;
struct cpufreq_policy current_policy;
ret = cpufreq_get_policy(¤t_policy, 0);
if (ret < 0)
pr_err("%s: cpufreq_get_policy got error", __func__);
memcpy(cpufreq_gov_default, current_policy.governor->name, 32);
}