Skip to content

Commit

Permalink
Merge branch 'pm-cpufreq'
Browse files Browse the repository at this point in the history
* pm-cpufreq:
  cpufreq: ppc-corenet-cpufreq: Fix __udivdi3 modpost error
  cpufreq: powernow-k7: Fix double invocation of cpufreq_freq_transition_begin/end
  cpufreq: powernow-k6: Fix double invocation of cpufreq_freq_transition_begin/end
  cpufreq: powernow-k6: Fix incorrect comparison with max_multipler
  cpufreq: longhaul: Fix double invocation of cpufreq_freq_transition_begin/end
  • Loading branch information
Rafael J. Wysocki committed May 2, 2014
2 parents d1db0ee + 6712d29 commit d705116
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 27 deletions.
36 changes: 24 additions & 12 deletions drivers/cpufreq/longhaul.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ static void do_powersaver(int cx_address, unsigned int mults_index,
* Sets a new clock ratio.
*/

static void longhaul_setstate(struct cpufreq_policy *policy,
static int longhaul_setstate(struct cpufreq_policy *policy,
unsigned int table_index)
{
unsigned int mults_index;
Expand All @@ -258,19 +258,19 @@ static void longhaul_setstate(struct cpufreq_policy *policy,
/* Safety precautions */
mult = mults[mults_index & 0x1f];
if (mult == -1)
return;
return -EINVAL;

speed = calc_speed(mult);
if ((speed > highest_speed) || (speed < lowest_speed))
return;
return -EINVAL;

/* Voltage transition before frequency transition? */
if (can_scale_voltage && longhaul_index < table_index)
dir = 1;

freqs.old = calc_speed(longhaul_get_cpu_mult());
freqs.new = speed;

cpufreq_freq_transition_begin(policy, &freqs);

pr_debug("Setting to FSB:%dMHz Mult:%d.%dx (%s)\n",
fsb, mult/10, mult%10, print_speed(speed/1000));
retry_loop:
Expand Down Expand Up @@ -385,12 +385,14 @@ static void longhaul_setstate(struct cpufreq_policy *policy,
goto retry_loop;
}
}
/* Report true CPU frequency */
cpufreq_freq_transition_end(policy, &freqs, 0);

if (!bm_timeout)
if (!bm_timeout) {
printk(KERN_INFO PFX "Warning: Timeout while waiting for "
"idle PCI bus.\n");
return -EBUSY;
}

return 0;
}

/*
Expand Down Expand Up @@ -631,9 +633,10 @@ static int longhaul_target(struct cpufreq_policy *policy,
unsigned int i;
unsigned int dir = 0;
u8 vid, current_vid;
int retval = 0;

if (!can_scale_voltage)
longhaul_setstate(policy, table_index);
retval = longhaul_setstate(policy, table_index);
else {
/* On test system voltage transitions exceeding single
* step up or down were turning motherboard off. Both
Expand All @@ -648,7 +651,7 @@ static int longhaul_target(struct cpufreq_policy *policy,
while (i != table_index) {
vid = (longhaul_table[i].driver_data >> 8) & 0x1f;
if (vid != current_vid) {
longhaul_setstate(policy, i);
retval = longhaul_setstate(policy, i);
current_vid = vid;
msleep(200);
}
Expand All @@ -657,10 +660,11 @@ static int longhaul_target(struct cpufreq_policy *policy,
else
i--;
}
longhaul_setstate(policy, table_index);
retval = longhaul_setstate(policy, table_index);
}

longhaul_index = table_index;
return 0;
return retval;
}


Expand Down Expand Up @@ -968,7 +972,15 @@ static void __exit longhaul_exit(void)

for (i = 0; i < numscales; i++) {
if (mults[i] == maxmult) {
struct cpufreq_freqs freqs;

freqs.old = policy->cur;
freqs.new = longhaul_table[i].frequency;
freqs.flags = 0;

cpufreq_freq_transition_begin(policy, &freqs);
longhaul_setstate(policy, i);
cpufreq_freq_transition_end(policy, &freqs, 0);
break;
}
}
Expand Down
23 changes: 13 additions & 10 deletions drivers/cpufreq/powernow-k6.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,22 +138,14 @@ static void powernow_k6_set_cpu_multiplier(unsigned int best_i)
static int powernow_k6_target(struct cpufreq_policy *policy,
unsigned int best_i)
{
struct cpufreq_freqs freqs;

if (clock_ratio[best_i].driver_data > max_multiplier) {
printk(KERN_ERR PFX "invalid target frequency\n");
return -EINVAL;
}

freqs.old = busfreq * powernow_k6_get_cpu_multiplier();
freqs.new = busfreq * clock_ratio[best_i].driver_data;

cpufreq_freq_transition_begin(policy, &freqs);

powernow_k6_set_cpu_multiplier(best_i);

cpufreq_freq_transition_end(policy, &freqs, 0);

return 0;
}

Expand Down Expand Up @@ -227,9 +219,20 @@ static int powernow_k6_cpu_init(struct cpufreq_policy *policy)
static int powernow_k6_cpu_exit(struct cpufreq_policy *policy)
{
unsigned int i;
for (i = 0; i < 8; i++) {
if (i == max_multiplier)

for (i = 0; (clock_ratio[i].frequency != CPUFREQ_TABLE_END); i++) {
if (clock_ratio[i].driver_data == max_multiplier) {
struct cpufreq_freqs freqs;

freqs.old = policy->cur;
freqs.new = clock_ratio[i].frequency;
freqs.flags = 0;

cpufreq_freq_transition_begin(policy, &freqs);
powernow_k6_target(policy, i);
cpufreq_freq_transition_end(policy, &freqs, 0);
break;
}
}
return 0;
}
Expand Down
4 changes: 0 additions & 4 deletions drivers/cpufreq/powernow-k7.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,6 @@ static int powernow_target(struct cpufreq_policy *policy, unsigned int index)

freqs.new = powernow_table[index].frequency;

cpufreq_freq_transition_begin(policy, &freqs);

/* Now do the magic poking into the MSRs. */

if (have_a0 == 1) /* A0 errata 5 */
Expand All @@ -290,8 +288,6 @@ static int powernow_target(struct cpufreq_policy *policy, unsigned int index)
if (have_a0 == 1)
local_irq_enable();

cpufreq_freq_transition_end(policy, &freqs, 0);

return 0;
}

Expand Down
5 changes: 4 additions & 1 deletion drivers/cpufreq/ppc-corenet-cpufreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ static int corenet_cpufreq_cpu_init(struct cpufreq_policy *policy)
struct cpufreq_frequency_table *table;
struct cpu_data *data;
unsigned int cpu = policy->cpu;
u64 transition_latency_hz;

np = of_get_cpu_node(cpu, NULL);
if (!np)
Expand Down Expand Up @@ -205,8 +206,10 @@ static int corenet_cpufreq_cpu_init(struct cpufreq_policy *policy)
for_each_cpu(i, per_cpu(cpu_mask, cpu))
per_cpu(cpu_data, i) = data;

transition_latency_hz = 12ULL * NSEC_PER_SEC;
policy->cpuinfo.transition_latency =
(12ULL * NSEC_PER_SEC) / fsl_get_sys_freq();
do_div(transition_latency_hz, fsl_get_sys_freq());

of_node_put(np);

return 0;
Expand Down

0 comments on commit d705116

Please sign in to comment.