cpufreq: speedstep-smi: enable interrupts when waiting
authorMikulas Patocka <mpatocka@redhat.com>
Mon, 9 Feb 2015 18:38:17 +0000 (13:38 -0500)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 12 Feb 2015 01:02:52 +0000 (02:02 +0100)
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>
drivers/cpufreq/speedstep-lib.c
drivers/cpufreq/speedstep-smi.c

index 7047821a7f8a5fd966521ba5a8d48bf7664d2d54..4ab7a215667249326d4b1b81b2144b56767b0dcd 100644 (file)
@@ -400,6 +400,7 @@ unsigned int speedstep_get_freqs(enum speedstep_processor processor,
 
        pr_debug("previous speed is %u\n", prev_speed);
 
+       preempt_disable();
        local_irq_save(flags);
 
        /* switch to low state */
@@ -464,6 +465,8 @@ unsigned int speedstep_get_freqs(enum speedstep_processor processor,
 
 out:
        local_irq_restore(flags);
+       preempt_enable();
+
        return ret;
 }
 EXPORT_SYMBOL_GPL(speedstep_get_freqs);
index 5fc96d5d656bafc251293d753be52326257a6c0b..819229e824fb69dde06d44d8726d95b5697d29da 100644 (file)
@@ -156,6 +156,7 @@ static void speedstep_set_state(unsigned int state)
                return;
 
        /* Disable IRQs */
+       preempt_disable();
        local_irq_save(flags);
 
        command = (smi_sig & 0xffffff00) | (smi_cmd & 0xff);
@@ -166,9 +167,19 @@ static void speedstep_set_state(unsigned int state)
 
        do {
                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",
                                        retry, result);
+                       local_irq_enable();
                        mdelay(retry * 50);
+                       local_irq_disable();
                }
                retry++;
                __asm__ __volatile__(
@@ -185,6 +196,7 @@ static void speedstep_set_state(unsigned int state)
 
        /* enable IRQs */
        local_irq_restore(flags);
+       preempt_enable();
 
        if (new_state == state)
                pr_debug("change to %u MHz succeeded after %u tries "