Merge branch 'topic/asoc' into for-linus
[pandora-kernel.git] / drivers / acpi / processor_idle.c
index f7ca8c5..10a2d91 100644 (file)
@@ -148,6 +148,9 @@ static void acpi_timer_check_state(int state, struct acpi_processor *pr,
        if (cpu_has(&cpu_data(pr->id), X86_FEATURE_ARAT))
                return;
 
+       if (boot_cpu_has(X86_FEATURE_AMDC1E))
+               type = ACPI_STATE_C1;
+
        /*
         * Check, if one of the previous states already marked the lapic
         * unstable
@@ -202,21 +205,44 @@ static void acpi_state_timer_broadcast(struct acpi_processor *pr,
  * Suspend / resume control
  */
 static int acpi_idle_suspend;
+static u32 saved_bm_rld;
+
+static void acpi_idle_bm_rld_save(void)
+{
+       acpi_read_bit_register(ACPI_BITREG_BUS_MASTER_RLD, &saved_bm_rld);
+}
+static void acpi_idle_bm_rld_restore(void)
+{
+       u32 resumed_bm_rld;
+
+       acpi_read_bit_register(ACPI_BITREG_BUS_MASTER_RLD, &resumed_bm_rld);
+
+       if (resumed_bm_rld != saved_bm_rld)
+               acpi_write_bit_register(ACPI_BITREG_BUS_MASTER_RLD, saved_bm_rld);
+}
 
 int acpi_processor_suspend(struct acpi_device * device, pm_message_t state)
 {
+       if (acpi_idle_suspend == 1)
+               return 0;
+
+       acpi_idle_bm_rld_save();
        acpi_idle_suspend = 1;
        return 0;
 }
 
 int acpi_processor_resume(struct acpi_device * device)
 {
+       if (acpi_idle_suspend == 0)
+               return 0;
+
+       acpi_idle_bm_rld_restore();
        acpi_idle_suspend = 0;
        return 0;
 }
 
 #if defined (CONFIG_GENERIC_TIME) && defined (CONFIG_X86)
-static int tsc_halts_in_c(int state)
+static void tsc_check_state(int state)
 {
        switch (boot_cpu_data.x86_vendor) {
        case X86_VENDOR_AMD:
@@ -226,13 +252,17 @@ static int tsc_halts_in_c(int state)
                 * C/P/S0/S1 states when this bit is set.
                 */
                if (boot_cpu_has(X86_FEATURE_NONSTOP_TSC))
-                       return 0;
+                       return;
 
                /*FALL THROUGH*/
        default:
-               return state > ACPI_STATE_C1;
+               /* TSC could halt in idle, so notify users */
+               if (state > ACPI_STATE_C1)
+                       mark_tsc_unstable("TSC halts in idle");
        }
 }
+#else
+static void tsc_check_state(int state) { return; }
 #endif
 
 static int acpi_processor_get_power_info_fadt(struct acpi_processor *pr)
@@ -578,17 +608,13 @@ static int acpi_processor_power_verify(struct acpi_processor *pr)
 
        pr->power.timer_broadcast_on_state = INT_MAX;
 
-       for (i = 1; i < ACPI_PROCESSOR_MAX_POWER; i++) {
+       for (i = 1; i < ACPI_PROCESSOR_MAX_POWER && i <= max_cstate; i++) {
                struct acpi_processor_cx *cx = &pr->power.states[i];
 
-#if defined (CONFIG_GENERIC_TIME) && defined (CONFIG_X86)
-               /* TSC could halt in idle, so notify users */
-               if (tsc_halts_in_c(cx->type))
-                       mark_tsc_unstable("TSC halts in idle");;
-#endif
                switch (cx->type) {
                case ACPI_STATE_C1:
                        cx->valid = 1;
+                       acpi_timer_check_state(i, pr, cx);
                        break;
 
                case ACPI_STATE_C2:
@@ -603,6 +629,8 @@ static int acpi_processor_power_verify(struct acpi_processor *pr)
                                acpi_timer_check_state(i, pr, cx);
                        break;
                }
+               if (cx->valid)
+                       tsc_check_state(cx->type);
 
                if (cx->valid)
                        working++;
@@ -806,11 +834,12 @@ static int acpi_idle_enter_c1(struct cpuidle_device *dev,
 
        /* Do not access any ACPI IO ports in suspend path */
        if (acpi_idle_suspend) {
-               acpi_safe_halt();
                local_irq_enable();
+               cpu_relax();
                return 0;
        }
 
+       acpi_state_timer_broadcast(pr, cx, 1);
        kt1 = ktime_get_real();
        acpi_idle_do_entry(cx);
        kt2 = ktime_get_real();
@@ -818,6 +847,7 @@ static int acpi_idle_enter_c1(struct cpuidle_device *dev,
 
        local_irq_enable();
        cx->usage++;
+       acpi_state_timer_broadcast(pr, cx, 0);
 
        return idle_time;
 }