Skip to content

Commit d4d4eda

Browse files
Mikulas Patockarafaeljw
authored andcommitted
cpufreq: speedstep-smi: enable interrupts when waiting
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 Cc: All applicable <stable@vger.kernel.org> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent c488ea4 commit d4d4eda

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

‎drivers/cpufreq/speedstep-lib.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ unsigned int speedstep_get_freqs(enum speedstep_processor processor,
400400

401401
pr_debug("previous speed is %u\n", prev_speed);
402402

403+
preempt_disable();
403404
local_irq_save(flags);
404405

405406
/* switch to low state */
@@ -464,6 +465,8 @@ unsigned int speedstep_get_freqs(enum speedstep_processor processor,
464465

465466
out:
466467
local_irq_restore(flags);
468+
preempt_enable();
469+
467470
return ret;
468471
}
469472
EXPORT_SYMBOL_GPL(speedstep_get_freqs);

‎drivers/cpufreq/speedstep-smi.c‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ static void speedstep_set_state(unsigned int state)
156156
return;
157157

158158
/* Disable IRQs */
159+
preempt_disable();
159160
local_irq_save(flags);
160161

161162
command = (smi_sig & 0xffffff00) | (smi_cmd & 0xff);
@@ -166,9 +167,19 @@ static void speedstep_set_state(unsigned int state)
166167

167168
do {
168169
if (retry) {
170+
/*
171+
* We need to enable interrupts, otherwise the blockage
172+
* won't resolve.
173+
*
174+
* We disable preemption so that other processes don't
175+
* run. If other processes were running, they could
176+
* submit more DMA requests, making the blockage worse.
177+
*/
169178
pr_debug("retry %u, previous result %u, waiting...\n",
170179
retry, result);
180+
local_irq_enable();
171181
mdelay(retry * 50);
182+
local_irq_disable();
172183
}
173184
retry++;
174185
__asm__ __volatile__(
@@ -185,6 +196,7 @@ static void speedstep_set_state(unsigned int state)
185196

186197
/* enable IRQs */
187198
local_irq_restore(flags);
199+
preempt_enable();
188200

189201
if (new_state == state)
190202
pr_debug("change to %u MHz succeeded after %u tries "

0 commit comments

Comments
 (0)