include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[safe/jmp/linux-2.6] / arch / powerpc / kernel / rtas.c
index d9a9974..7436784 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/completion.h>
 #include <linux/cpumask.h>
 #include <linux/lmb.h>
+#include <linux/slab.h>
 
 #include <asm/prom.h>
 #include <asm/rtas.h>
 #include <asm/syscalls.h>
 #include <asm/smp.h>
 #include <asm/atomic.h>
+#include <asm/time.h>
+#include <asm/mmu.h>
 
 struct rtas_t rtas = {
-       .lock = __RAW_SPIN_LOCK_UNLOCKED
+       .lock = __ARCH_SPIN_LOCK_UNLOCKED
 };
 EXPORT_SYMBOL(rtas);
 
@@ -78,13 +81,13 @@ static unsigned long lock_rtas(void)
 
        local_irq_save(flags);
        preempt_disable();
-       __raw_spin_lock_flags(&rtas.lock, flags);
+       arch_spin_lock_flags(&rtas.lock, flags);
        return flags;
 }
 
 static void unlock_rtas(unsigned long flags)
 {
-       __raw_spin_unlock(&rtas.lock);
+       arch_spin_unlock(&rtas.lock);
        local_irq_restore(flags);
        preempt_enable();
 }
@@ -712,6 +715,7 @@ static void rtas_percpu_suspend_me(void *info)
 {
        long rc = H_SUCCESS;
        unsigned long msr_save;
+       u16 slb_size = mmu_slb_size;
        int cpu;
        struct rtas_suspend_me_data *data =
                (struct rtas_suspend_me_data *)info;
@@ -734,13 +738,16 @@ static void rtas_percpu_suspend_me(void *info)
                /* All other cpus are in H_JOIN, this cpu does
                 * the suspend.
                 */
+               slb_set_size(SLB_MIN_SIZE);
                printk(KERN_DEBUG "calling ibm,suspend-me on cpu %i\n",
                       smp_processor_id());
                data->error = rtas_call(data->token, 0, 1, NULL);
 
-               if (data->error)
+               if (data->error) {
                        printk(KERN_DEBUG "ibm,suspend-me returned %d\n",
                               data->error);
+                       slb_set_size(slb_size);
+               }
        } else {
                printk(KERN_ERR "H_JOIN on cpu %i failed with rc = %ld\n",
                       smp_processor_id(), rc);
@@ -971,3 +978,33 @@ int __init early_init_dt_scan_rtas(unsigned long node,
        /* break now */
        return 1;
 }
+
+static arch_spinlock_t timebase_lock;
+static u64 timebase = 0;
+
+void __cpuinit rtas_give_timebase(void)
+{
+       unsigned long flags;
+
+       local_irq_save(flags);
+       hard_irq_disable();
+       arch_spin_lock(&timebase_lock);
+       rtas_call(rtas_token("freeze-time-base"), 0, 1, NULL);
+       timebase = get_tb();
+       arch_spin_unlock(&timebase_lock);
+
+       while (timebase)
+               barrier();
+       rtas_call(rtas_token("thaw-time-base"), 0, 1, NULL);
+       local_irq_restore(flags);
+}
+
+void __cpuinit rtas_take_timebase(void)
+{
+       while (!timebase)
+               barrier();
+       arch_spin_lock(&timebase_lock);
+       set_tb(timebase >> 32, timebase & 0xffffffff);
+       timebase = 0;
+       arch_spin_unlock(&timebase_lock);
+}