#define DBG(fmt...)
 #endif
 
+int *chip_id_lookup_table;
+
 #ifdef CONFIG_PPC64
 int __initdata iommu_is_off;
 int __initdata iommu_force_on;
 int cpu_to_chip_id(int cpu)
 {
        struct device_node *np;
+       int ret = -1, idx;
+
+       idx = cpu / threads_per_core;
+       if (chip_id_lookup_table && chip_id_lookup_table[idx] != -1)
+               return chip_id_lookup_table[idx];
 
        np = of_get_cpu_node(cpu, NULL);
-       if (!np)
-               return -1;
+       if (np) {
+               ret = of_get_ibm_chip_id(np);
+               of_node_put(np);
+
+               if (chip_id_lookup_table)
+                       chip_id_lookup_table[idx] = ret;
+       }
 
-       of_node_put(np);
-       return of_get_ibm_chip_id(np);
+       return ret;
 }
 EXPORT_SYMBOL(cpu_to_chip_id);
 
 
                                cpu_smallcore_mask(boot_cpuid));
        }
 
+       if (cpu_to_chip_id(boot_cpuid) != -1) {
+               int idx = num_possible_cpus() / threads_per_core;
+
+               /*
+                * All threads of a core will all belong to the same core,
+                * chip_id_lookup_table will have one entry per core.
+                * Assumption: if boot_cpuid doesn't have a chip-id, then no
+                * other CPUs, will also not have chip-id.
+                */
+               chip_id_lookup_table = kcalloc(idx, sizeof(int), GFP_KERNEL);
+               if (chip_id_lookup_table)
+                       memset(chip_id_lookup_table, -1, sizeof(int) * idx);
+       }
+
        if (smp_ops && smp_ops->probe)
                smp_ops->probe();
 }
 {
        struct cpumask *(*submask_fn)(int) = cpu_sibling_mask;
        int first_thread = cpu_first_thread_sibling(cpu);
-       int chip_id = cpu_to_chip_id(cpu);
        cpumask_var_t mask;
+       int chip_id = -1;
        bool ret;
        int i;
 
        if (has_coregroup_support())
                update_coregroup_mask(cpu, &mask);
 
-       if (chip_id == -1 || !ret) {
+       if (chip_id_lookup_table && ret)
+               chip_id = cpu_to_chip_id(cpu);
+
+       if (chip_id == -1) {
                cpumask_copy(per_cpu(cpu_core_map, cpu), cpu_cpu_mask(cpu));
                goto out;
        }