Commit dc4dc270 authored by Mikulas Patocka's avatar Mikulas Patocka Committed by Ben Hutchings

cpufreq: speedstep-smi: enable interrupts when waiting

commit d4d4eda2 upstream.

On Dell Latitude C600 laptop with Pentium 3 850MHz processor, the
speedstep-smi driver sometimes loads and sometimes doesn't load with
"change to state X failed" message.

The hardware sometimes refuses to change frequency and in this case, we
need to retry later. I found out that we need to enable interrupts while
waiting. When we enable interrupts, the hardware blockage that prevents
frequency transition resolves and the transition is possible. With
disabled interrupts, the blockage doesn't resolve (no matter how long do
we wait). The exact reasons for this hardware behavior are unknown.

This patch enables interrupts in the function speedstep_set_state that can
be called with disabled interrupts. However, this function is called with
disabled interrupts only from speedstep_get_freqs, so it shouldn't cause
any problem.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com
Acked-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent 59195960
...@@ -399,6 +399,7 @@ unsigned int speedstep_get_freqs(enum speedstep_processor processor, ...@@ -399,6 +399,7 @@ unsigned int speedstep_get_freqs(enum speedstep_processor processor,
pr_debug("previous speed is %u\n", prev_speed); pr_debug("previous speed is %u\n", prev_speed);
preempt_disable();
local_irq_save(flags); local_irq_save(flags);
/* switch to low state */ /* switch to low state */
...@@ -463,6 +464,8 @@ unsigned int speedstep_get_freqs(enum speedstep_processor processor, ...@@ -463,6 +464,8 @@ unsigned int speedstep_get_freqs(enum speedstep_processor processor,
out: out:
local_irq_restore(flags); local_irq_restore(flags);
preempt_enable();
return ret; return ret;
} }
EXPORT_SYMBOL_GPL(speedstep_get_freqs); EXPORT_SYMBOL_GPL(speedstep_get_freqs);
......
...@@ -187,6 +187,7 @@ static void speedstep_set_state(unsigned int state) ...@@ -187,6 +187,7 @@ static void speedstep_set_state(unsigned int state)
return; return;
/* Disable IRQs */ /* Disable IRQs */
preempt_disable();
local_irq_save(flags); local_irq_save(flags);
command = (smi_sig & 0xffffff00) | (smi_cmd & 0xff); command = (smi_sig & 0xffffff00) | (smi_cmd & 0xff);
...@@ -197,9 +198,19 @@ static void speedstep_set_state(unsigned int state) ...@@ -197,9 +198,19 @@ static void speedstep_set_state(unsigned int state)
do { do {
if (retry) { if (retry) {
/*
* We need to enable interrupts, otherwise the blockage
* won't resolve.
*
* We disable preemption so that other processes don't
* run. If other processes were running, they could
* submit more DMA requests, making the blockage worse.
*/
pr_debug("retry %u, previous result %u, waiting...\n", pr_debug("retry %u, previous result %u, waiting...\n",
retry, result); retry, result);
local_irq_enable();
mdelay(retry * 50); mdelay(retry * 50);
local_irq_disable();
} }
retry++; retry++;
__asm__ __volatile__( __asm__ __volatile__(
...@@ -216,6 +227,7 @@ static void speedstep_set_state(unsigned int state) ...@@ -216,6 +227,7 @@ static void speedstep_set_state(unsigned int state)
/* enable IRQs */ /* enable IRQs */
local_irq_restore(flags); local_irq_restore(flags);
preempt_enable();
if (new_state == state) if (new_state == state)
pr_debug("change to %u MHz succeeded after %u tries " pr_debug("change to %u MHz succeeded after %u tries "
......
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