Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 344144
b: refs/heads/master
c: 77ae798
h: refs/heads/master
v: v3
  • Loading branch information
Jayachandran C authored and John Crispin committed Nov 9, 2012
1 parent 4d9feeb commit d70a0b7
Show file tree
Hide file tree
Showing 13 changed files with 177 additions and 87 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2a37b1ae443f20470a789b12a45cbc249c9e50a6
refs/heads/master: 77ae798f5b736dfdc692b86b393d9699052ac77a
42 changes: 37 additions & 5 deletions trunk/arch/mips/include/asm/netlogic/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@

#ifndef __ASSEMBLY__
#include <linux/cpumask.h>
#include <linux/spinlock.h>
#include <asm/irq.h>

struct irq_desc;
extern struct plat_smp_ops nlm_smp_ops;
extern char nlm_reset_entry[], nlm_reset_entry_end[];
void nlm_smp_function_ipi_handler(unsigned int irq, struct irq_desc *desc);
void nlm_smp_resched_ipi_handler(unsigned int irq, struct irq_desc *desc);
void nlm_smp_irq_init(void);
Expand All @@ -70,10 +70,42 @@ nlm_set_nmi_handler(void *handler)
* Misc.
*/
unsigned int nlm_get_cpu_frequency(void);
void nlm_node_init(int node);
extern struct plat_smp_ops nlm_smp_ops;
extern char nlm_reset_entry[], nlm_reset_entry_end[];

extern unsigned long nlm_common_ebase;
extern int nlm_threads_per_core;
extern uint32_t nlm_coremask;
extern unsigned int nlm_threads_per_core;
extern cpumask_t nlm_cpumask;

struct nlm_soc_info {
unsigned long coremask; /* cores enabled on the soc */
unsigned long ebase;
uint64_t irqmask;
uint64_t sysbase; /* only for XLP */
uint64_t picbase;
spinlock_t piclock;
};

#define NLM_CORES_PER_NODE 8
#define NLM_THREADS_PER_CORE 4
#define NLM_CPUS_PER_NODE (NLM_CORES_PER_NODE * NLM_THREADS_PER_CORE)
#define nlm_get_node(i) (&nlm_nodes[i])
#define NLM_NR_NODES 1
#define nlm_current_node() (&nlm_nodes[0])

struct irq_data;
uint64_t nlm_pci_irqmask(int node);
void nlm_set_pic_extra_ack(int node, int irq, void (*xack)(struct irq_data *));

/*
* The NR_IRQs is divided between nodes, each of them has a separate irq space
*/
static inline int nlm_irq_to_xirq(int node, int irq)
{
return node * NR_IRQS / NLM_NR_NODES + irq;
}

extern struct nlm_soc_info nlm_nodes[NLM_NR_NODES];
extern int nlm_cpu_ready[];
#endif
#endif /* _NETLOGIC_COMMON_H_ */
5 changes: 5 additions & 0 deletions trunk/arch/mips/include/asm/netlogic/mips-extns.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,9 @@ static inline int hard_smp_processor_id(void)
return __read_32bit_c0_register($15, 1) & 0x3ff;
}

static inline int nlm_nodeid(void)
{
return (__read_32bit_c0_register($15, 1) >> 5) & 0x3;
}

#endif /*_ASM_NLM_MIPS_EXTS_H */
1 change: 0 additions & 1 deletion trunk/arch/mips/include/asm/netlogic/xlp-hal/pic.h
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,6 @@ nlm_pic_init_irt(uint64_t base, int irt, int irq, int hwt)
nlm_pic_write_irt_direct(base, irt, 0, 0, 0, irq, hwt);
}

extern uint64_t nlm_pic_base;
int nlm_irq_to_irt(int irq);
int nlm_irt_to_irq(int irt);

Expand Down
1 change: 0 additions & 1 deletion trunk/arch/mips/include/asm/netlogic/xlp-hal/sys.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,5 @@
#define nlm_get_sys_pcibase(node) nlm_pcicfg_base(XLP_IO_SYS_OFFSET(node))
#define nlm_get_sys_regbase(node) (nlm_get_sys_pcibase(node) + XLP_IO_PCI_HDRSZ)

extern uint64_t nlm_sys_base;
#endif
#endif
2 changes: 0 additions & 2 deletions trunk/arch/mips/include/asm/netlogic/xlr/pic.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,5 @@ nlm_pic_init_irt(uint64_t base, int irt, int irq, int hwt)
nlm_write_reg(base, PIC_IRT_1(irt),
(1 << 30) | (1 << 6) | irq);
}

extern uint64_t nlm_pic_base;
#endif
#endif /* _ASM_NLM_XLR_PIC_H */
55 changes: 36 additions & 19 deletions trunk/arch/mips/netlogic/common/irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,33 +70,34 @@
*/

/* Globals */
static uint64_t nlm_irq_mask;
static DEFINE_SPINLOCK(nlm_pic_lock);

static void xlp_pic_enable(struct irq_data *d)
{
unsigned long flags;
struct nlm_soc_info *nodep;
int irt;

nodep = nlm_current_node();
irt = nlm_irq_to_irt(d->irq);
if (irt == -1)
return;
spin_lock_irqsave(&nlm_pic_lock, flags);
nlm_pic_enable_irt(nlm_pic_base, irt);
spin_unlock_irqrestore(&nlm_pic_lock, flags);
spin_lock_irqsave(&nodep->piclock, flags);
nlm_pic_enable_irt(nodep->picbase, irt);
spin_unlock_irqrestore(&nodep->piclock, flags);
}

static void xlp_pic_disable(struct irq_data *d)
{
struct nlm_soc_info *nodep;
unsigned long flags;
int irt;

nodep = nlm_current_node();
irt = nlm_irq_to_irt(d->irq);
if (irt == -1)
return;
spin_lock_irqsave(&nlm_pic_lock, flags);
nlm_pic_disable_irt(nlm_pic_base, irt);
spin_unlock_irqrestore(&nlm_pic_lock, flags);
spin_lock_irqsave(&nodep->piclock, flags);
nlm_pic_disable_irt(nodep->picbase, irt);
spin_unlock_irqrestore(&nodep->piclock, flags);
}

static void xlp_pic_mask_ack(struct irq_data *d)
Expand All @@ -109,8 +110,10 @@ static void xlp_pic_mask_ack(struct irq_data *d)
static void xlp_pic_unmask(struct irq_data *d)
{
void *hd = irq_data_get_irq_handler_data(d);
struct nlm_soc_info *nodep;
int irt;

nodep = nlm_current_node();
irt = nlm_irq_to_irt(d->irq);
if (irt == -1)
return;
Expand All @@ -120,7 +123,7 @@ static void xlp_pic_unmask(struct irq_data *d)
extra_ack(d);
}
/* Ack is a single write, no need to lock */
nlm_pic_ack(nlm_pic_base, irt);
nlm_pic_ack(nodep->picbase, irt);
}

static struct irq_chip xlp_pic = {
Expand Down Expand Up @@ -177,7 +180,11 @@ struct irq_chip nlm_cpu_intr = {
void __init init_nlm_common_irqs(void)
{
int i, irq, irt;
uint64_t irqmask;
struct nlm_soc_info *nodep;

nodep = nlm_current_node();
irqmask = (1ULL << IRQ_TIMER);
for (i = 0; i < PIC_IRT_FIRST_IRQ; i++)
irq_set_chip_and_handler(i, &nlm_cpu_intr, handle_percpu_irq);

Expand All @@ -189,49 +196,59 @@ void __init init_nlm_common_irqs(void)
nlm_smp_function_ipi_handler);
irq_set_chip_and_handler(IRQ_IPI_SMP_RESCHEDULE, &nlm_cpu_intr,
nlm_smp_resched_ipi_handler);
nlm_irq_mask |=
irqmask |=
((1ULL << IRQ_IPI_SMP_FUNCTION) | (1ULL << IRQ_IPI_SMP_RESCHEDULE));
#endif

for (irq = PIC_IRT_FIRST_IRQ; irq <= PIC_IRT_LAST_IRQ; irq++) {
irt = nlm_irq_to_irt(irq);
if (irt == -1)
continue;
nlm_irq_mask |= (1ULL << irq);
nlm_pic_init_irt(nlm_pic_base, irt, irq, 0);
irqmask |= (1ULL << irq);
nlm_pic_init_irt(nodep->picbase, irt, irq, 0);
}

nlm_irq_mask |= (1ULL << IRQ_TIMER);
nodep->irqmask = irqmask;
}

void __init arch_init_irq(void)
{
/* Initialize the irq descriptors */
init_nlm_common_irqs();

write_c0_eimr(nlm_irq_mask);
write_c0_eimr(nlm_current_node()->irqmask);
}

void __cpuinit nlm_smp_irq_init(void)
{
/* set interrupt mask for non-zero cpus */
write_c0_eimr(nlm_irq_mask);
write_c0_eimr(nlm_current_node()->irqmask);
}

asmlinkage void plat_irq_dispatch(void)
{
uint64_t eirr;
int i;
int i, node;

node = nlm_nodeid();
eirr = read_c0_eirr() & read_c0_eimr();
if (eirr & (1 << IRQ_TIMER)) {
do_IRQ(IRQ_TIMER);
return;
}

#ifdef CONFIG_SMP
if (eirr & IRQ_IPI_SMP_FUNCTION) {
do_IRQ(IRQ_IPI_SMP_FUNCTION);
return;
}
if (eirr & IRQ_IPI_SMP_RESCHEDULE) {
do_IRQ(IRQ_IPI_SMP_RESCHEDULE);
return;
}
#endif
i = __ilog2_u64(eirr);
if (i == -1)
return;

do_IRQ(i);
do_IRQ(nlm_irq_to_xirq(node, i));
}
47 changes: 29 additions & 18 deletions trunk/arch/mips/netlogic/common/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,17 @@

void nlm_send_ipi_single(int logical_cpu, unsigned int action)
{
int cpu = cpu_logical_map(logical_cpu);
int cpu, node;
uint64_t picbase;

cpu = cpu_logical_map(logical_cpu);
node = cpu / NLM_CPUS_PER_NODE;
picbase = nlm_get_node(node)->picbase;

if (action & SMP_CALL_FUNCTION)
nlm_pic_send_ipi(nlm_pic_base, cpu, IRQ_IPI_SMP_FUNCTION, 0);
nlm_pic_send_ipi(picbase, cpu, IRQ_IPI_SMP_FUNCTION, 0);
if (action & SMP_RESCHEDULE_YOURSELF)
nlm_pic_send_ipi(nlm_pic_base, cpu, IRQ_IPI_SMP_RESCHEDULE, 0);
nlm_pic_send_ipi(picbase, cpu, IRQ_IPI_SMP_RESCHEDULE, 0);
}

void nlm_send_ipi_mask(const struct cpumask *mask, unsigned int action)
Expand Down Expand Up @@ -96,19 +101,20 @@ void nlm_smp_resched_ipi_handler(unsigned int irq, struct irq_desc *desc)
void nlm_early_init_secondary(int cpu)
{
change_c0_config(CONF_CM_CMASK, 0x3);
write_c0_ebase((uint32_t)nlm_common_ebase);
#ifdef CONFIG_CPU_XLP
if (cpu % 4 == 0)
/* mmu init, once per core */
if (cpu % NLM_THREADS_PER_CORE == 0)
xlp_mmu_init();
#endif
write_c0_ebase(nlm_current_node()->ebase);
}

/*
* Code to run on secondary just after probing the CPU
*/
static void __cpuinit nlm_init_secondary(void)
{
current_cpu_data.core = hard_smp_processor_id() / 4;
current_cpu_data.core = hard_smp_processor_id() / NLM_THREADS_PER_CORE;
nlm_smp_irq_init();
}

Expand Down Expand Up @@ -142,22 +148,22 @@ cpumask_t phys_cpu_present_map;

void nlm_boot_secondary(int logical_cpu, struct task_struct *idle)
{
unsigned long gp = (unsigned long)task_thread_info(idle);
unsigned long sp = (unsigned long)__KSTK_TOS(idle);
int cpu = cpu_logical_map(logical_cpu);
int cpu, node;

nlm_next_sp = sp;
nlm_next_gp = gp;
cpu = cpu_logical_map(logical_cpu);
node = cpu / NLM_CPUS_PER_NODE;
nlm_next_sp = (unsigned long)__KSTK_TOS(idle);
nlm_next_gp = (unsigned long)task_thread_info(idle);

/* barrier */
/* barrier for sp/gp store above */
__sync();
nlm_pic_send_ipi(nlm_pic_base, cpu, 1, 1);
nlm_pic_send_ipi(nlm_get_node(node)->picbase, cpu, 1, 1); /* NMI */
}

void __init nlm_smp_setup(void)
{
unsigned int boot_cpu;
int num_cpus, i;
int num_cpus, i, ncore;

boot_cpu = hard_smp_processor_id();
cpumask_clear(&phys_cpu_present_map);
Expand All @@ -182,11 +188,16 @@ void __init nlm_smp_setup(void)
}
}

/* check with the cores we have worken up */
for (ncore = 0, i = 0; i < NLM_NR_NODES; i++)
ncore += hweight32(nlm_get_node(i)->coremask);

pr_info("Phys CPU present map: %lx, possible map %lx\n",
(unsigned long)cpumask_bits(&phys_cpu_present_map)[0],
(unsigned long)cpumask_bits(cpu_possible_mask)[0]);

pr_info("Detected %i Slave CPU(s)\n", num_cpus);
pr_info("Detected (%dc%dt) %d Slave CPU(s)\n", ncore,
nlm_threads_per_core, num_cpus);
nlm_set_nmi_handler(nlm_boot_secondary_cpus);
}

Expand All @@ -196,7 +207,7 @@ static int nlm_parse_cpumask(cpumask_t *wakeup_mask)
int threadmode, i, j;

core0_thr_mask = 0;
for (i = 0; i < 4; i++)
for (i = 0; i < NLM_THREADS_PER_CORE; i++)
if (cpumask_test_cpu(i, wakeup_mask))
core0_thr_mask |= (1 << i);
switch (core0_thr_mask) {
Expand All @@ -217,9 +228,9 @@ static int nlm_parse_cpumask(cpumask_t *wakeup_mask)
}

/* Verify other cores CPU masks */
for (i = 0; i < NR_CPUS; i += 4) {
for (i = 0; i < NR_CPUS; i += NLM_THREADS_PER_CORE) {
core_thr_mask = 0;
for (j = 0; j < 4; j++)
for (j = 0; j < NLM_THREADS_PER_CORE; j++)
if (cpumask_test_cpu(i + j, wakeup_mask))
core_thr_mask |= (1 << j);
if (core_thr_mask != 0 && core_thr_mask != core0_thr_mask)
Expand Down
Loading

0 comments on commit d70a0b7

Please sign in to comment.