ACPI: un-export ACPI_ERROR() -- use printk(KERN_ERR...)
[pandora-kernel.git] / drivers / acpi / processor_idle.c
index eb730a8..786851d 100644 (file)
@@ -54,10 +54,10 @@ ACPI_MODULE_NAME("acpi_processor")
 #define US_TO_PM_TIMER_TICKS(t)                ((t * (PM_TIMER_FREQUENCY/1000)) / 1000)
 #define C2_OVERHEAD                    4       /* 1us (3.579 ticks per us) */
 #define C3_OVERHEAD                    4       /* 1us (3.579 ticks per us) */
-static void (*pm_idle_save) (void);
+static void (*pm_idle_save) (void) __read_mostly;
 module_param(max_cstate, uint, 0644);
 
-static unsigned int nocst = 0;
+static unsigned int nocst __read_mostly;
 module_param(nocst, uint, 0000);
 
 /*
@@ -67,7 +67,7 @@ module_param(nocst, uint, 0000);
  * 100 HZ: 0x0000000F: 4 jiffies = 40ms
  * reduce history for more aggressive entry into C3
  */
-static unsigned int bm_history =
+static unsigned int bm_history __read_mostly =
     (HZ >= 800 ? 0xFFFFFFFF : ((1U << (HZ / 25)) - 1));
 module_param(bm_history, uint, 0644);
 /* --------------------------------------------------------------------------
@@ -206,11 +206,11 @@ acpi_processor_power_activate(struct acpi_processor *pr,
 
 static void acpi_safe_halt(void)
 {
-       clear_thread_flag(TIF_POLLING_NRFLAG);
+       current_thread_info()->status &= ~TS_POLLING;
        smp_mb__after_clear_bit();
        if (!need_resched())
                safe_halt();
-       set_thread_flag(TIF_POLLING_NRFLAG);
+       current_thread_info()->status |= TS_POLLING;
 }
 
 static atomic_t c3_cpu_count;
@@ -330,10 +330,10 @@ static void acpi_processor_idle(void)
         * 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);
+               current_thread_info()->status &= ~TS_POLLING;
                smp_mb__after_clear_bit();
                if (need_resched()) {
-                       set_thread_flag(TIF_POLLING_NRFLAG);
+                       current_thread_info()->status |= TS_POLLING;
                        local_irq_enable();
                        return;
                }
@@ -369,9 +369,14 @@ static void acpi_processor_idle(void)
                t2 = inl(acpi_fadt.xpm_tmr_blk.address);
                /* Get end time (ticks) */
                t2 = inl(acpi_fadt.xpm_tmr_blk.address);
+
+#ifdef CONFIG_GENERIC_TIME
+               /* TSC halts in C2, so notify users */
+               mark_tsc_unstable();
+#endif
                /* Re-enable interrupts */
                local_irq_enable();
-               set_thread_flag(TIF_POLLING_NRFLAG);
+               current_thread_info()->status |= TS_POLLING;
                /* Compute time (ticks) that we were actually asleep */
                sleep_ticks =
                    ticks_elapsed(t1, t2) - cx->latency_ticks - C2_OVERHEAD;
@@ -409,9 +414,13 @@ static void acpi_processor_idle(void)
                                          ACPI_MTX_DO_NOT_LOCK);
                }
 
+#ifdef CONFIG_GENERIC_TIME
+               /* TSC halts in C3, so notify users */
+               mark_tsc_unstable();
+#endif
                /* Re-enable interrupts */
                local_irq_enable();
-               set_thread_flag(TIF_POLLING_NRFLAG);
+               current_thread_info()->status |= TS_POLLING;
                /* Compute time (ticks) that we were actually asleep */
                sleep_ticks =
                    ticks_elapsed(t1, t2) - cx->latency_ticks - C3_OVERHEAD;
@@ -665,8 +674,7 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
 
        /* There must be at least 2 elements */
        if (!cst || (cst->type != ACPI_TYPE_PACKAGE) || cst->package.count < 2) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "not enough elements in _CST\n"));
+               printk(KERN_ERR PREFIX "not enough elements in _CST\n");
                status = -EFAULT;
                goto end;
        }
@@ -675,8 +683,7 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
 
        /* Validate number of power states. */
        if (count < 1 || count != cst->package.count - 1) {
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "count given by _CST is not valid\n"));
+               printk(KERN_ERR PREFIX "count given by _CST is not valid\n");
                status = -EFAULT;
                goto end;
        }
@@ -878,12 +885,9 @@ static int acpi_processor_power_verify(struct acpi_processor *pr)
        unsigned int working = 0;
 
 #ifdef ARCH_APICTIMER_STOPS_ON_C3
-       struct cpuinfo_x86 *c = cpu_data + pr->id;
+       int timer_broadcast = 0;
        cpumask_t mask = cpumask_of_cpu(pr->id);
-
-       if (c->x86_vendor == X86_VENDOR_INTEL) {
-               on_each_cpu(switch_ipi_to_APIC_timer, &mask, 1, 1);
-       }
+       on_each_cpu(switch_ipi_to_APIC_timer, &mask, 1, 1);
 #endif
 
        for (i = 1; i < ACPI_PROCESSOR_MAX_POWER; i++) {
@@ -896,15 +900,20 @@ static int acpi_processor_power_verify(struct acpi_processor *pr)
 
                case ACPI_STATE_C2:
                        acpi_processor_power_verify_c2(cx);
+#ifdef ARCH_APICTIMER_STOPS_ON_C3
+                       /* Some AMD systems fake C3 as C2, but still
+                          have timer troubles */
+                       if (cx->valid && 
+                               boot_cpu_data.x86_vendor == X86_VENDOR_AMD)
+                               timer_broadcast++;
+#endif
                        break;
 
                case ACPI_STATE_C3:
                        acpi_processor_power_verify_c3(pr, cx);
 #ifdef ARCH_APICTIMER_STOPS_ON_C3
-                       if (cx->valid && c->x86_vendor == X86_VENDOR_INTEL) {
-                               on_each_cpu(switch_APIC_timer_to_ipi,
-                                               &mask, 1, 1);
-                       }
+                       if (cx->valid)
+                               timer_broadcast++;
 #endif
                        break;
                }
@@ -913,6 +922,11 @@ static int acpi_processor_power_verify(struct acpi_processor *pr)
                        working++;
        }
 
+#ifdef ARCH_APICTIMER_STOPS_ON_C3
+       if (timer_broadcast)
+               on_each_cpu(switch_APIC_timer_to_ipi, &mask, 1, 1);
+#endif
+
        return (working);
 }
 
@@ -1074,7 +1088,7 @@ int acpi_processor_power_init(struct acpi_processor *pr,
                              struct acpi_device *device)
 {
        acpi_status status = 0;
-       static int first_run = 0;
+       static int first_run;
        struct proc_dir_entry *entry = NULL;
        unsigned int i;
 
@@ -1096,8 +1110,8 @@ int acpi_processor_power_init(struct acpi_processor *pr,
                status =
                    acpi_os_write_port(acpi_fadt.smi_cmd, acpi_fadt.cst_cnt, 8);
                if (ACPI_FAILURE(status)) {
-                       ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                         "Notifying BIOS of _CST ability failed\n"));
+                       ACPI_EXCEPTION((AE_INFO, status,
+                                       "Notifying BIOS of _CST ability failed"));
                }
        }
 
@@ -1126,9 +1140,7 @@ int acpi_processor_power_init(struct acpi_processor *pr,
        entry = create_proc_entry(ACPI_PROCESSOR_FILE_POWER,
                                  S_IRUGO, acpi_device_dir(device));
        if (!entry)
-               ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
-                                 "Unable to create '%s' fs entry\n",
-                                 ACPI_PROCESSOR_FILE_POWER));
+               return -EIO;
        else {
                entry->proc_fops = &acpi_processor_power_fops;
                entry->data = acpi_driver_data(device);