Skip to content

Commit 98d4884

Browse files
jchandra-brcmralfbaechle
authored andcommitted
MIPS: Netlogic: Add cpu to node mapping for XLP9XX
XLP9XX has 20 cores per node, opposed to 8 on earlier XLP8XX. Update code that calculates node id from cpu id to handle this. Signed-off-by: Jayachandran C <jchandra@broadcom.com> Signed-off-by: John Crispin <blogic@openwrt.org> Patchwork: http://patchwork.linux-mips.org/patch/6283/
1 parent e7aa6c6 commit 98d4884

8 files changed

Lines changed: 33 additions & 14 deletions

File tree

‎arch/mips/include/asm/mach-netlogic/multi-node.h‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,16 @@
4747
#endif
4848
#endif
4949

50-
#define NLM_CORES_PER_NODE 8
5150
#define NLM_THREADS_PER_CORE 4
52-
#define NLM_CPUS_PER_NODE (NLM_CORES_PER_NODE * NLM_THREADS_PER_CORE)
51+
#ifdef CONFIG_CPU_XLR
52+
#define nlm_cores_per_node() 8
53+
#else
54+
extern unsigned int xlp_cores_per_node;
55+
#define nlm_cores_per_node() xlp_cores_per_node
56+
#endif
57+
58+
#define nlm_threads_per_node() (nlm_cores_per_node() * NLM_THREADS_PER_CORE)
59+
#define nlm_cpuid_to_node(c) ((c) / nlm_threads_per_node())
5360

5461
struct nlm_soc_info {
5562
unsigned long coremask; /* cores enabled on the soc */

‎arch/mips/include/asm/netlogic/mips-extns.h‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,12 @@ static inline int hard_smp_processor_id(void)
146146

147147
static inline int nlm_nodeid(void)
148148
{
149-
return (__read_32bit_c0_register($15, 1) >> 5) & 0x3;
149+
uint32_t prid = read_c0_prid();
150+
151+
if ((prid & 0xff00) == PRID_IMP_NETLOGIC_XLP9XX)
152+
return (__read_32bit_c0_register($15, 1) >> 7) & 0x7;
153+
else
154+
return (__read_32bit_c0_register($15, 1) >> 5) & 0x3;
150155
}
151156

152157
static inline unsigned int nlm_core_id(void)

‎arch/mips/netlogic/common/irq.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ static void nlm_init_node_irqs(int node)
223223
continue;
224224

225225
nlm_pic_init_irt(nodep->picbase, irt, i,
226-
node * NLM_CPUS_PER_NODE, 0);
226+
node * nlm_threads_per_node(), 0);
227227
nlm_setup_pic_irq(node, i, i, irt);
228228
}
229229
}
@@ -232,8 +232,8 @@ void nlm_smp_irq_init(int hwcpuid)
232232
{
233233
int node, cpu;
234234

235-
node = hwcpuid / NLM_CPUS_PER_NODE;
236-
cpu = hwcpuid % NLM_CPUS_PER_NODE;
235+
node = nlm_cpuid_to_node(hwcpuid);
236+
cpu = hwcpuid % nlm_threads_per_node();
237237

238238
if (cpu == 0 && node != 0)
239239
nlm_init_node_irqs(node);

‎arch/mips/netlogic/common/smp.c‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ void nlm_send_ipi_single(int logical_cpu, unsigned int action)
6363
uint64_t picbase;
6464

6565
cpu = cpu_logical_map(logical_cpu);
66-
node = cpu / NLM_CPUS_PER_NODE;
66+
node = nlm_cpuid_to_node(cpu);
6767
picbase = nlm_get_node(node)->picbase;
6868

6969
if (action & SMP_CALL_FUNCTION)
@@ -152,7 +152,7 @@ void nlm_boot_secondary(int logical_cpu, struct task_struct *idle)
152152
int cpu, node;
153153

154154
cpu = cpu_logical_map(logical_cpu);
155-
node = cpu / NLM_CPUS_PER_NODE;
155+
node = nlm_cpuid_to_node(logical_cpu);
156156
nlm_next_sp = (unsigned long)__KSTK_TOS(idle);
157157
nlm_next_gp = (unsigned long)task_thread_info(idle);
158158

@@ -164,7 +164,7 @@ void nlm_boot_secondary(int logical_cpu, struct task_struct *idle)
164164
void __init nlm_smp_setup(void)
165165
{
166166
unsigned int boot_cpu;
167-
int num_cpus, i, ncore;
167+
int num_cpus, i, ncore, node;
168168
volatile u32 *cpu_ready = nlm_get_boot_data(BOOT_CPU_READY);
169169
char buf[64];
170170

@@ -187,6 +187,8 @@ void __init nlm_smp_setup(void)
187187
__cpu_number_map[i] = num_cpus;
188188
__cpu_logical_map[num_cpus] = i;
189189
set_cpu_possible(num_cpus, true);
190+
node = nlm_cpuid_to_node(i);
191+
cpumask_set_cpu(num_cpus, &nlm_get_node(node)->cpumask);
190192
++num_cpus;
191193
}
192194
}

‎arch/mips/netlogic/xlp/setup.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ uint64_t nlm_io_base;
5151
struct nlm_soc_info nlm_nodes[NLM_NR_NODES];
5252
cpumask_t nlm_cpumask = CPU_MASK_CPU0;
5353
unsigned int nlm_threads_per_core;
54+
unsigned int xlp_cores_per_node;
5455

5556
static void nlm_linux_exit(void)
5657
{
@@ -154,6 +155,10 @@ void __init prom_init(void)
154155
void *reset_vec;
155156

156157
nlm_io_base = CKSEG1ADDR(XLP_DEFAULT_IO_BASE);
158+
if (cpu_is_xlp9xx())
159+
xlp_cores_per_node = 32;
160+
else
161+
xlp_cores_per_node = 8;
157162
nlm_init_boot_cpu();
158163
xlp_mmu_init();
159164
nlm_node_init(0);

‎arch/mips/netlogic/xlp/wakeup.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ static void xlp_enable_secondary_cores(const cpumask_t *wakeup_mask)
165165
nodep->coremask = 1;
166166

167167
pr_info("Node %d - SYS/FUSE coremask %x\n", n, syscoremask);
168-
for (core = 0; core < NLM_CORES_PER_NODE; core++) {
168+
for (core = 0; core < nlm_cores_per_node(); core++) {
169169
/* we will be on node 0 core 0 */
170170
if (n == 0 && core == 0)
171171
continue;
@@ -175,7 +175,7 @@ static void xlp_enable_secondary_cores(const cpumask_t *wakeup_mask)
175175
continue;
176176

177177
/* see if at least the first hw thread is enabled */
178-
cpu = (n * NLM_CORES_PER_NODE + core)
178+
cpu = (n * nlm_cores_per_node() + core)
179179
* NLM_THREADS_PER_CORE;
180180
if (!cpumask_test_cpu(cpu, wakeup_mask))
181181
continue;

‎arch/mips/netlogic/xlr/wakeup.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ int xlr_wakeup_secondary_cpus(void)
7070

7171
/* Fill up the coremask early */
7272
nodep->coremask = 1;
73-
for (i = 1; i < NLM_CORES_PER_NODE; i++) {
73+
for (i = 1; i < nlm_cores_per_node(); i++) {
7474
for (j = 1000000; j > 0; j--) {
7575
if (cpu_ready[i * NLM_THREADS_PER_CORE])
7676
break;

‎arch/mips/pci/msi-xlp.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ static int xlp_setup_msi(uint64_t lnkbase, int node, int link,
280280
irt = PIC_IRT_PCIE_LINK_INDEX(link);
281281
nlm_setup_pic_irq(node, lirq, lirq, irt);
282282
nlm_pic_init_irt(nlm_get_node(node)->picbase, irt, lirq,
283-
node * NLM_CPUS_PER_NODE, 1 /*en */);
283+
node * nlm_threads_per_node(), 1 /*en */);
284284
}
285285

286286
/* allocate a MSI vec, and tell the bridge about it */
@@ -443,7 +443,7 @@ void __init xlp_init_node_msi_irqs(int node, int link)
443443
msixvec = link * XLP_MSIXVEC_PER_LINK + i;
444444
irt = PIC_IRT_PCIE_MSIX_INDEX(msixvec);
445445
nlm_pic_init_irt(nodep->picbase, irt, PIC_PCIE_MSIX_IRQ(link),
446-
node * NLM_CPUS_PER_NODE, 1 /* enable */);
446+
node * nlm_threads_per_node(), 1 /* enable */);
447447

448448
/* Initialize MSI-X extended irq space for the link */
449449
irq = nlm_irq_to_xirq(node, nlm_link_msixirq(link, i));

0 commit comments

Comments
 (0)