Merge branch 'origin'
[pandora-kernel.git] / arch / powerpc / kernel / lparcfg.c
index 5e954fa..e789fef 100644 (file)
 #include <asm/time.h>
 #include <asm/iseries/it_exp_vpd_panel.h>
 #include <asm/prom.h>
-#include <asm/systemcfg.h>
+#include <asm/vdso_datapage.h>
 
 #define MODULE_VERS "1.6"
 #define MODULE_NAME "lparcfg"
 
 /* #define LPARCFG_DEBUG */
 
-/* find a better place for this function... */
-void log_plpar_hcall_return(unsigned long rc, char *tag)
-{
-       if (rc == 0)            /* success, return */
-               return;
-/* check for null tag ? */
-       if (rc == H_Hardware)
-               printk(KERN_INFO
-                      "plpar-hcall (%s) failed with hardware fault\n", tag);
-       else if (rc == H_Function)
-               printk(KERN_INFO
-                      "plpar-hcall (%s) failed; function not allowed\n", tag);
-       else if (rc == H_Authority)
-               printk(KERN_INFO
-                      "plpar-hcall (%s) failed; not authorized to this function\n",
-                      tag);
-       else if (rc == H_Parameter)
-               printk(KERN_INFO "plpar-hcall (%s) failed; Bad parameter(s)\n",
-                      tag);
-       else
-               printk(KERN_INFO
-                      "plpar-hcall (%s) failed with unexpected rc(0x%lx)\n",
-                      tag, rc);
-
-}
-
 static struct proc_dir_entry *proc_ppc64_lparcfg;
 #define LPARCFG_BUFF_SIZE 4096
 
@@ -81,15 +55,13 @@ static unsigned long get_purr(void)
 {
        unsigned long sum_purr = 0;
        int cpu;
-       struct paca_struct *lpaca;
 
        for_each_cpu(cpu) {
-               lpaca = paca + cpu;
-               sum_purr += lpaca->lppaca.emulated_time_base;
+               sum_purr += lppaca[cpu].emulated_time_base;
 
 #ifdef PURR_DEBUG
                printk(KERN_INFO "get_purr for cpu (%d) has value (%ld) \n",
-                       cpu, lpaca->lppaca.emulated_time_base);
+                       cpu, lppaca[cpu].emulated_time_base);
 #endif
        }
        return sum_purr;
@@ -105,12 +77,11 @@ static int lparcfg_data(struct seq_file *m, void *v)
        unsigned long pool_id, lp_index;
        int shared, entitled_capacity, max_entitled_capacity;
        int processors, max_processors;
-       struct paca_struct *lpaca = get_paca();
        unsigned long purr = get_purr();
 
        seq_printf(m, "%s %s \n", MODULE_NAME, MODULE_VERS);
 
-       shared = (int)(lpaca->lppaca_ptr->shared_proc);
+       shared = (int)(get_lppaca()->shared_proc);
        seq_printf(m, "serial_number=%c%c%c%c%c%c%c\n",
                   e2a(xItExtVpdPanel.mfgID[2]),
                   e2a(xItExtVpdPanel.mfgID[3]),
@@ -172,6 +143,31 @@ static int lparcfg_data(struct seq_file *m, void *v)
 /*
  * Methods used to fetch LPAR data when running on a pSeries platform.
  */
+/* find a better place for this function... */
+static void log_plpar_hcall_return(unsigned long rc, char *tag)
+{
+       if (rc == 0)            /* success, return */
+               return;
+/* check for null tag ? */
+       if (rc == H_Hardware)
+               printk(KERN_INFO
+                      "plpar-hcall (%s) failed with hardware fault\n", tag);
+       else if (rc == H_Function)
+               printk(KERN_INFO
+                      "plpar-hcall (%s) failed; function not allowed\n", tag);
+       else if (rc == H_Authority)
+               printk(KERN_INFO
+                      "plpar-hcall (%s) failed; not authorized to this function\n",
+                      tag);
+       else if (rc == H_Parameter)
+               printk(KERN_INFO "plpar-hcall (%s) failed; Bad parameter(s)\n",
+                      tag);
+       else
+               printk(KERN_INFO
+                      "plpar-hcall (%s) failed with unexpected rc(0x%lx)\n",
+                      tag, rc);
+
+}
 
 /*
  * H_GET_PPP hcall returns info in 4 parms.
@@ -213,11 +209,10 @@ static void h_pic(unsigned long *pool_idle_time, unsigned long *num_procs)
        unsigned long dummy;
        rc = plpar_hcall(H_PIC, 0, 0, 0, 0, pool_idle_time, num_procs, &dummy);
 
-       log_plpar_hcall_return(rc, "H_PIC");
+       if (rc != H_Authority)
+               log_plpar_hcall_return(rc, "H_PIC");
 }
 
-static unsigned long get_purr(void);
-
 /* Track sum of all purrs across all processors. This is used to further */
 /* calculate usage values by different applications                       */
 
@@ -319,8 +314,6 @@ static void parse_system_parameter_string(struct seq_file *m)
        kfree(local_buffer);
 }
 
-static int lparcfg_count_active_processors(void);
-
 /* Return the number of processors in the system.
  * This function reads through the device tree and counts
  * the virtual processors, this does not include threads.
@@ -348,7 +341,7 @@ static int lparcfg_data(struct seq_file *m, void *v)
        const char *system_id = "";
        unsigned int *lp_index_ptr, lp_index = 0;
        struct device_node *rtas_node;
-       int *lrdrp;
+       int *lrdrp = NULL;
 
        rootdn = find_path_device("/");
        if (rootdn) {
@@ -369,10 +362,12 @@ static int lparcfg_data(struct seq_file *m, void *v)
        seq_printf(m, "partition_id=%d\n", (int)lp_index);
 
        rtas_node = find_path_device("/rtas");
-       lrdrp = (int *)get_property(rtas_node, "ibm,lrdr-capacity", NULL);
+       if (rtas_node)
+               lrdrp = (int *)get_property(rtas_node, "ibm,lrdr-capacity",
+                                           NULL);
 
        if (lrdrp == NULL) {
-               partition_potential_processors = _systemcfg->processorCount;
+               partition_potential_processors = vdso_data->processorCount;
        } else {
                partition_potential_processors = *(lrdrp + 4);
        }
@@ -406,7 +401,7 @@ static int lparcfg_data(struct seq_file *m, void *v)
                           (h_resource >> 0 * 8) & 0xffff);
 
                /* pool related entries are apropriate for shared configs */
-               if (paca[0].lppaca.shared_proc) {
+               if (lppaca[0].shared_proc) {
 
                        h_pic(&pool_idle_time, &pool_procs);
 
@@ -455,7 +450,7 @@ static int lparcfg_data(struct seq_file *m, void *v)
        seq_printf(m, "partition_potential_processors=%d\n",
                   partition_potential_processors);
 
-       seq_printf(m, "shared_processor_mode=%d\n", paca[0].lppaca.shared_proc);
+       seq_printf(m, "shared_processor_mode=%d\n", lppaca[0].shared_proc);
 
        return 0;
 }
@@ -548,7 +543,7 @@ static ssize_t lparcfg_write(struct file *file, const char __user * buf,
                retval = -EIO;
        }
 
-      out:
+out:
        kfree(kbuf);
        return retval;
 }
@@ -561,10 +556,10 @@ static int lparcfg_open(struct inode *inode, struct file *file)
 }
 
 struct file_operations lparcfg_fops = {
-      .owner   = THIS_MODULE,
-      .read    = seq_read,
-      .open    = lparcfg_open,
-      .release = single_release,
+       .owner          = THIS_MODULE,
+       .read           = seq_read,
+       .open           = lparcfg_open,
+       .release        = single_release,
 };
 
 int __init lparcfg_init(void)