Pull 5165 into release branch
authorLen Brown <len.brown@intel.com>
Mon, 5 Dec 2005 22:08:40 +0000 (17:08 -0500)
committerLen Brown <len.brown@intel.com>
Mon, 5 Dec 2005 22:08:40 +0000 (17:08 -0500)
1  2 
drivers/acpi/processor_idle.c

@@@ -169,11 -169,15 +169,11 @@@ acpi_processor_power_activate(struct ac
  
  static void acpi_safe_halt(void)
  {
 -      int polling = test_thread_flag(TIF_POLLING_NRFLAG);
 -      if (polling) {
 -              clear_thread_flag(TIF_POLLING_NRFLAG);
 -              smp_mb__after_clear_bit();
 -      }
 +      clear_thread_flag(TIF_POLLING_NRFLAG);
 +      smp_mb__after_clear_bit();
        if (!need_resched())
                safe_halt();
 -      if (polling)
 -              set_thread_flag(TIF_POLLING_NRFLAG);
 +      set_thread_flag(TIF_POLLING_NRFLAG);
  }
  
  static atomic_t c3_cpu_count;
@@@ -274,8 -278,6 +274,6 @@@ static void acpi_processor_idle(void
                }
        }
  
-       cx->usage++;
  #ifdef CONFIG_HOTPLUG_CPU
        /*
         * Check for P_LVL2_UP flag before entering C2 and above on
         * detection phase, to work cleanly with logical CPU hotplug.
         */
        if ((cx->type != ACPI_STATE_C1) && (num_online_cpus() > 1) && 
-           !pr->flags.has_cst && acpi_fadt.plvl2_up)
-               cx->type = ACPI_STATE_C1;
+           !pr->flags.has_cst && !acpi_fadt.plvl2_up)
+               cx = &pr->power.states[ACPI_STATE_C1];
  #endif
+       cx->usage++;
        /*
         * Sleep:
         * ------
         * Invoke the current Cx state to put the processor to sleep.
         */
 +      if (cx->type == ACPI_STATE_C2 || cx->type == ACPI_STATE_C3) {
 +              clear_thread_flag(TIF_POLLING_NRFLAG);
 +              smp_mb__after_clear_bit();
 +              if (need_resched()) {
 +                      set_thread_flag(TIF_POLLING_NRFLAG);
 +                      local_irq_enable();
 +                      return;
 +              }
 +      }
 +
        switch (cx->type) {
  
        case ACPI_STATE_C1:
                t2 = inl(acpi_fadt.xpm_tmr_blk.address);
                /* Re-enable interrupts */
                local_irq_enable();
 +              set_thread_flag(TIF_POLLING_NRFLAG);
                /* Compute time (ticks) that we were actually asleep */
                sleep_ticks =
                    ticks_elapsed(t1, t2) - cx->latency_ticks - C2_OVERHEAD;
  
                /* Re-enable interrupts */
                local_irq_enable();
 +              set_thread_flag(TIF_POLLING_NRFLAG);
                /* Compute time (ticks) that we were actually asleep */
                sleep_ticks =
                    ticks_elapsed(t1, t2) - cx->latency_ticks - C3_OVERHEAD;
  
        next_state = pr->power.state;
  
+ #ifdef CONFIG_HOTPLUG_CPU
+       /* Don't do promotion/demotion */
+       if ((cx->type == ACPI_STATE_C1) && (num_online_cpus() > 1) &&
+           !pr->flags.has_cst && !acpi_fadt.plvl2_up) {
+               next_state = cx;
+               goto end;
+       }
+ #endif
        /*
         * Promotion?
         * ----------
@@@ -557,7 -559,7 +567,7 @@@ static int acpi_processor_get_power_inf
         * Check for P_LVL2_UP flag before entering C2 and above on
         * an SMP system. 
         */
-       if ((num_online_cpus() > 1) && acpi_fadt.plvl2_up)
+       if ((num_online_cpus() > 1) && !acpi_fadt.plvl2_up)
                return_VALUE(-ENODEV);
  #endif