Commit 14b92470 authored by Timur Tabi's avatar Timur Tabi Committed by Benjamin Herrenschmidt

powerpc/mpic: Add support for discontiguous cores

There is one place in the MPIC driver that assumes that the cores are numbered
from 0 to n-1.  However, this is not true if the CPUs are not numbered
sequentially.  This can happen on a eight-core SOC where cores two and three
are removed in the device tree.  So instead of blindly looping, we iterate
over the discovered CPUs and use the SMP ID as the index.

This means that we no longer ask the MPIC how many CPUs there are, so
we also delete mpic->num_cpus.

We also catch if the number of CPUs in the SOC exceeds the number that the
MPIC supports.  This should never happen, of course, but it's good to be
sure.
Signed-off-by: default avatarTimur Tabi <timur@freescale.com>
Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
parent 41151e77
...@@ -273,8 +273,6 @@ struct mpic ...@@ -273,8 +273,6 @@ struct mpic
unsigned int irq_count; unsigned int irq_count;
/* Number of sources */ /* Number of sources */
unsigned int num_sources; unsigned int num_sources;
/* Number of CPUs */
unsigned int num_cpus;
/* default senses array */ /* default senses array */
unsigned char *senses; unsigned char *senses;
unsigned int senses_count; unsigned int senses_count;
......
...@@ -1285,13 +1285,11 @@ struct mpic * __init mpic_alloc(struct device_node *node, ...@@ -1285,13 +1285,11 @@ struct mpic * __init mpic_alloc(struct device_node *node,
mpic_read(mpic->gregs, MPIC_INFO(GREG_GLOBAL_CONF_0)) mpic_read(mpic->gregs, MPIC_INFO(GREG_GLOBAL_CONF_0))
| MPIC_GREG_GCONF_MCK); | MPIC_GREG_GCONF_MCK);
/* Read feature register, calculate num CPUs and, for non-ISU /*
* MPICs, num sources as well. On ISU MPICs, sources are counted * Read feature register. For non-ISU MPICs, num sources as well. On
* as ISUs are added * ISU MPICs, sources are counted as ISUs are added
*/ */
greg_feature = mpic_read(mpic->gregs, MPIC_INFO(GREG_FEATURE_0)); greg_feature = mpic_read(mpic->gregs, MPIC_INFO(GREG_FEATURE_0));
mpic->num_cpus = ((greg_feature & MPIC_GREG_FEATURE_LAST_CPU_MASK)
>> MPIC_GREG_FEATURE_LAST_CPU_SHIFT) + 1;
if (isu_size == 0) { if (isu_size == 0) {
if (flags & MPIC_BROKEN_FRR_NIRQS) if (flags & MPIC_BROKEN_FRR_NIRQS)
mpic->num_sources = mpic->irq_count; mpic->num_sources = mpic->irq_count;
...@@ -1301,10 +1299,18 @@ struct mpic * __init mpic_alloc(struct device_node *node, ...@@ -1301,10 +1299,18 @@ struct mpic * __init mpic_alloc(struct device_node *node,
>> MPIC_GREG_FEATURE_LAST_SRC_SHIFT) + 1; >> MPIC_GREG_FEATURE_LAST_SRC_SHIFT) + 1;
} }
/*
* The MPIC driver will crash if there are more cores than we
* can initialize, so we may as well catch that problem here.
*/
BUG_ON(num_possible_cpus() > MPIC_MAX_CPUS);
/* Map the per-CPU registers */ /* Map the per-CPU registers */
for (i = 0; i < mpic->num_cpus; i++) { for_each_possible_cpu(i) {
mpic_map(mpic, node, paddr, &mpic->cpuregs[i], unsigned int cpu = get_hard_smp_processor_id(i);
MPIC_INFO(CPU_BASE) + i * MPIC_INFO(CPU_STRIDE),
mpic_map(mpic, node, paddr, &mpic->cpuregs[cpu],
MPIC_INFO(CPU_BASE) + cpu * MPIC_INFO(CPU_STRIDE),
0x1000); 0x1000);
} }
...@@ -1343,7 +1349,7 @@ struct mpic * __init mpic_alloc(struct device_node *node, ...@@ -1343,7 +1349,7 @@ struct mpic * __init mpic_alloc(struct device_node *node,
} }
printk(KERN_INFO "mpic: Setting up MPIC \"%s\" version %s at %llx," printk(KERN_INFO "mpic: Setting up MPIC \"%s\" version %s at %llx,"
" max %d CPUs\n", " max %d CPUs\n",
name, vers, (unsigned long long)paddr, mpic->num_cpus); name, vers, (unsigned long long)paddr, num_possible_cpus());
printk(KERN_INFO "mpic: ISU size: %d, shift: %d, mask: %x\n", printk(KERN_INFO "mpic: ISU size: %d, shift: %d, mask: %x\n",
mpic->isu_size, mpic->isu_shift, mpic->isu_mask); mpic->isu_size, mpic->isu_shift, mpic->isu_mask);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment