Commit 2e906655 authored by venkatesh.pallipadi@intel.com's avatar venkatesh.pallipadi@intel.com Committed by Len Brown

ACPI: idle: Fix acpi_safe_halt usages and interrupt enabling/disabling

acpi_safe_halt() needs interrupts to be disabled for atomic
need_resched check and safe halt. Otherwise we may miss an
interrupt and go into halt.

acpi_safe_halt() also does not enable interrupts on all return paths.

So the callers should handle enable and disable interrupts around it.
Signed-off-by: default avatarVenkatesh Pallipadi <venkatesh.pallipadi@intel.com>
Signed-off-by: default avatarLen Brown <len.brown@intel.com>
parent 488b5ec8
...@@ -201,6 +201,10 @@ static inline u32 ticks_elapsed_in_us(u32 t1, u32 t2) ...@@ -201,6 +201,10 @@ static inline u32 ticks_elapsed_in_us(u32 t1, u32 t2)
return PM_TIMER_TICKS_TO_US((0xFFFFFFFF - t1) + t2); return PM_TIMER_TICKS_TO_US((0xFFFFFFFF - t1) + t2);
} }
/*
* Callers should disable interrupts before the call and enable
* interrupts after return.
*/
static void acpi_safe_halt(void) static void acpi_safe_halt(void)
{ {
current_thread_info()->status &= ~TS_POLLING; current_thread_info()->status &= ~TS_POLLING;
...@@ -413,6 +417,8 @@ static void acpi_processor_idle(void) ...@@ -413,6 +417,8 @@ static void acpi_processor_idle(void)
pm_idle_save(); pm_idle_save();
else else
acpi_safe_halt(); acpi_safe_halt();
local_irq_enable();
return; return;
} }
...@@ -521,6 +527,7 @@ static void acpi_processor_idle(void) ...@@ -521,6 +527,7 @@ static void acpi_processor_idle(void)
* skew otherwise. * skew otherwise.
*/ */
sleep_ticks = 0xFFFFFFFF; sleep_ticks = 0xFFFFFFFF;
local_irq_enable();
break; break;
case ACPI_STATE_C2: case ACPI_STATE_C2:
...@@ -1403,11 +1410,13 @@ static int acpi_idle_enter_c1(struct cpuidle_device *dev, ...@@ -1403,11 +1410,13 @@ static int acpi_idle_enter_c1(struct cpuidle_device *dev,
if (unlikely(!pr)) if (unlikely(!pr))
return 0; return 0;
local_irq_disable();
if (pr->flags.bm_check) if (pr->flags.bm_check)
acpi_idle_update_bm_rld(pr, cx); acpi_idle_update_bm_rld(pr, cx);
acpi_safe_halt(); acpi_safe_halt();
local_irq_enable();
cx->usage++; cx->usage++;
return 0; return 0;
...@@ -1517,7 +1526,9 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev, ...@@ -1517,7 +1526,9 @@ static int acpi_idle_enter_bm(struct cpuidle_device *dev,
if (dev->safe_state) { if (dev->safe_state) {
return dev->safe_state->enter(dev, dev->safe_state); return dev->safe_state->enter(dev, dev->safe_state);
} else { } else {
local_irq_disable();
acpi_safe_halt(); acpi_safe_halt();
local_irq_enable();
return 0; return 0;
} }
} }
......
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