Skip to contentSkip to conversation

sparc,leon: Sparc-Leon SMP support

PATCH In review [email protected] 2 participants 5 messages Aug 31, 2009 – Sep 1, 2009 SPARC + UltraSPARC (sparc/sparc64)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sparc,leon: Sparc-Leon SMP support

From: Konrad Eisele <[email protected]>

Support SMP for a Sparc-Leon multiprocessor system. Add Leon specific SMP code to arch/sparc/kernel/leon_smp.c.

---
 arch/sparc/include/asm/leon.h      |   28 +++
 arch/sparc/include/asm/leon_amba.h |    3 +
 arch/sparc/include/asm/smp_32.h    |    9 +
 arch/sparc/kernel/Makefile         |    2 +-
 arch/sparc/kernel/entry.S          |   33 +++
 arch/sparc/kernel/head_32.S        |   22 ++
 arch/sparc/kernel/ioport.c         |    5 +
 arch/sparc/kernel/leon_kernel.c    |   94 +++++++
 arch/sparc/kernel/leon_smp.c       |  468 ++++++++++++++++++++++++++++++++++++
 arch/sparc/kernel/smp_32.c         |   10 +
 arch/sparc/kernel/trampoline_32.S  |   69 ++++++-
 arch/sparc/mm/srmmu.c              |    5 +-
 12 files changed, 745 insertions(+), 3 deletions(-)
 create mode 100644 arch/sparc/kernel/leon_smp.c
arch/sparc/include/asm/leon.h +28 -0
index 28a42b7..559448c 100644
@@ -340,6 +340,30 @@ extern int leon_flush_needed(void);
 extern void leon_switch_mm(void);
 extern int srmmu_swprobe_trace;
 
+#ifdef CONFIG_SMP
+extern int leon_smp_nrcpus(void);
+extern void leon_clear_profile_irq(int cpu);
+extern void leon_smp_done(void);
+extern void leon_boot_cpus(void);
+extern int leon_boot_one_cpu(int i);
+void leon_init_smp(void);
+extern void cpu_probe(void);
+extern void cpu_idle(void);
+extern void init_IRQ(void);
+extern void cpu_panic(void);
+extern int __leon_processor_id(void);
+void leon_enable_irq_cpu(unsigned int irq_nr, unsigned int cpu);
+
+extern unsigned int real_irq_entry[], smpleon_ticker[];
+extern unsigned int patchme_maybe_smp_msg[];
+extern unsigned long trapbase_cpu1[];
+extern unsigned long trapbase_cpu2[];
+extern unsigned long trapbase_cpu3[];
+extern unsigned int t_nmi[], linux_trap_ipi15_leon[];
+extern unsigned int linux_trap_ipi15_sun4m[];
+
+#endif /* CONFIG_SMP */
+
 #endif /* __KERNEL__ */
 
 #endif /* __ASSEMBLY__ */
@@ -356,6 +380,10 @@ extern int srmmu_swprobe_trace;
 #define leon_switch_mm() do {} while (0)
 #define leon_init_IRQ() do {} while (0)
 #define init_leon() do {} while (0)
+#define leon_smp_done() do {} while (0)
+#define leon_boot_cpus() do {} while (0)
+#define leon_boot_one_cpu(i) 1
+#define leon_init_smp() do {} while (0)
 
 #endif /* !defined(CONFIG_SPARC_LEON) */
 
arch/sparc/include/asm/leon_amba.h +3 -0
index 618e888..57d2eae 100644
@@ -188,6 +188,9 @@ extern int leon_debug_irqout;
 extern unsigned long leon3_gptimer_irq;
 extern unsigned int sparc_leon_eirq;
 
+int amba_get_free_apbslv_devices(int vendor, int device, struct amba_apb_device *dev, int nr);
+
+
 #endif /* __ASSEMBLY__ */
 
 #define LEON3_IO_AREA 0xfff00000
arch/sparc/include/asm/smp_32.h +9 -0
index 58101dc..841905c 100644
@@ -106,6 +106,15 @@ static inline int hard_smp4d_processor_id(void)
 	return cpuid;
 }
 
+extern inline int hard_smpleon_processor_id(void)
+{
+	int cpuid;
+	__asm__ __volatile__("rd     %%asr17,%0\n\t"
+			     "srl    %0,28,%0" :
+			     "=&r" (cpuid) : );
+	return cpuid;
+}
+
 #ifndef MODULE
 static inline int hard_smp_processor_id(void)
 {
arch/sparc/kernel/Makefile +1 -1
index b004175..7056244 100644
@@ -68,7 +68,7 @@ obj-$(CONFIG_SPARC32)     += dma.o
 obj-$(CONFIG_SPARC32_PCI) += pcic.o
 
 obj-$(CONFIG_SMP)         += trampoline_$(BITS).o smp_$(BITS).o
-obj-$(CONFIG_SPARC32_SMP) += sun4m_smp.o sun4d_smp.o
+obj-$(CONFIG_SPARC32_SMP) += sun4m_smp.o sun4d_smp.o leon_smp.o
 obj-$(CONFIG_SPARC64_SMP) += hvtramp.o
 
 obj-y                     += auxio_$(BITS).o
arch/sparc/kernel/entry.S +33 -0
index f41ecc5..ec9c7bc 100644
@@ -400,6 +400,39 @@ linux_trap_ipi15_sun4d:
 	/* FIXME */
 1:	b,a	1b
 
+#ifdef CONFIG_SPARC_LEON
+
+	.globl	smpleon_ticker
+	/* SMP per-cpu ticker interrupts are handled specially. */
+smpleon_ticker:
+        SAVE_ALL
+	or	%l0, PSR_PIL, %g2
+	wr	%g2, 0x0, %psr
+	WRITE_PAUSE
+	wr	%g2, PSR_ET, %psr
+	WRITE_PAUSE
+	call	leon_percpu_timer_interrupt
+	 add	%sp, STACKFRAME_SZ, %o0
+	wr	%l0, PSR_ET, %psr
+	WRITE_PAUSE
+	RESTORE_ALL
+
+	.align	4
+	.globl	linux_trap_ipi15_leon
+linux_trap_ipi15_leon:
+	SAVE_ALL
+	or	%l0, PSR_PIL, %l4
+	wr	%l4, 0x0, %psr
+	WRITE_PAUSE
+	wr	%l4, PSR_ET, %psr
+	WRITE_PAUSE
+	call	leon_cross_call_irq
+	 nop
+	b	ret_trap_lockless_ipi
+	 clr	%l6
+
+#endif /* CONFIG_SPARC_LEON */
+
 #endif /* CONFIG_SMP */
 
 	/* This routine handles illegal instructions and privileged
arch/sparc/kernel/head_32.S +22 -0
index 439d82a..21bb259 100644
@@ -811,9 +811,31 @@ found_version:
 got_prop:
 #ifdef CONFIG_SPARC_LEON
 	        /* no cpu-type check is needed, it is a SPARC-LEON */
+#ifdef CONFIG_SMP
+		ba leon_smp_init
+		 nop
+
+		.global leon_smp_init
+leon_smp_init:
+		sethi	%hi(boot_cpu_id), %g1    ! master always 0
+		stb	%g0, [%g1 + %lo(boot_cpu_id)]
+		sethi	%hi(boot_cpu_id4), %g1   ! master always 0
+		stb	%g0, [%g1 + %lo(boot_cpu_id4)]
+
+		rd     %asr17,%g1
+		srl    %g1,28,%g1
+
+		cmp %g0,%g1
+		 beq sun4c_continue_boot         !continue with master
+		nop
+
+		ba leon_smp_cpu_startup
+		 nop
+#else
 		ba sun4c_continue_boot
 		 nop
 #endif
+#endif
 		set	cputypval, %o2
 		ldub	[%o2 + 0x4], %l1
 
arch/sparc/kernel/ioport.c +5 -0
index 87ea0d0..ec87fb8 100644
@@ -47,10 +47,15 @@
 #include <asm/dma.h>
 #include <asm/iommu.h>
 #include <asm/io-unit.h>
+#include <asm/leon.h>
 
 #include "dma.h"
 
+#ifdef CONFIG_SPARC_LEON
+#define mmu_inval_dma_area(p, l) leon_flush_dcache_all()
+#else
 #define mmu_inval_dma_area(p, l)	/* Anton pulled it out for 2.4.0-xx */
+#endif
 
 static struct resource *_sparc_find_resource(struct resource *r,
 					     unsigned long);
arch/sparc/kernel/leon_kernel.c +94 -0

132 lines not on this page · raw message

arch/sparc/kernel/leon_smp.c new file +466 -0

466 lines not on this page · raw message

arch/sparc/kernel/smp_32.c +10 -0
index 132d81f..91c10fb 100644
@@ -32,6 +32,7 @@
 #include <asm/cacheflush.h>
 #include <asm/tlbflush.h>
 #include <asm/cpudata.h>
+#include <asm/leon.h>
 
 #include "irq.h"
 
@@ -96,6 +97,9 @@ void __init smp_cpus_done(unsigned int max_cpus)
 	case sun4d:
 		smp4d_smp_done();
 		break;
+	case sparc_leon:
+		leon_smp_done();
+		break;
 	case sun4e:
 		printk("SUN4E\n");
 		BUG();
@@ -306,6 +310,9 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
 	case sun4d:
 		smp4d_boot_cpus();
 		break;
+	case sparc_leon:
+		leon_boot_cpus();
+		break;
 	case sun4e:
 		printk("SUN4E\n");
 		BUG();
@@ -376,6 +383,9 @@ int __cpuinit __cpu_up(unsigned int cpu)
 	case sun4d:
 		ret = smp4d_boot_one_cpu(cpu);
 		break;
+	case sparc_leon:
+		ret = leon_boot_one_cpu(cpu);
+		break;
 	case sun4e:
 		printk("SUN4E\n");
 		BUG();
arch/sparc/kernel/trampoline_32.S +68 -1

84 lines not on this page · raw message

arch/sparc/mm/srmmu.c +4 -1
index 509b1ff..d55c255 100644
@@ -2301,7 +2301,8 @@ void __init ld_mmu_srmmu(void)
 	BTFIXUPSET_CALL(flush_cache_mm, smp_flush_cache_mm, BTFIXUPCALL_NORM);
 	BTFIXUPSET_CALL(flush_cache_range, smp_flush_cache_range, BTFIXUPCALL_NORM);
 	BTFIXUPSET_CALL(flush_cache_page, smp_flush_cache_page, BTFIXUPCALL_NORM);
-	if (sparc_cpu_model != sun4d) {
+	if (sparc_cpu_model != sun4d &&
+	    sparc_cpu_model != sparc_leon) {
 		BTFIXUPSET_CALL(flush_tlb_all, smp_flush_tlb_all, BTFIXUPCALL_NORM);
 		BTFIXUPSET_CALL(flush_tlb_mm, smp_flush_tlb_mm, BTFIXUPCALL_NORM);
 		BTFIXUPSET_CALL(flush_tlb_range, smp_flush_tlb_range, BTFIXUPCALL_NORM);
@@ -2330,6 +2331,8 @@ void __init ld_mmu_srmmu(void)
 #ifdef CONFIG_SMP
 	if (sparc_cpu_model = sun4d)
 		sun4d_init_smp();
+	else if (sparc_cpu_model = sparc_leon)
+		leon_init_smp();
 	else
 		sun4m_init_smp();
 #endif
Signature · 1 line
1.6.3.2
#1 lore raw

Konrad,

A couple of things that stood out from a quick read over the code.

Quoted 27 lines · On Mon, Aug 31, 2009 at 23:47, <[email protected]> wrote:

From: Konrad Eisele <[email protected]>

Support SMP for a Sparc-Leon multiprocessor system. Add Leon specific SMP code to arch/sparc/kernel/leon_smp.c.

---
 arch/sparc/include/asm/leon.h      |   28 +++ arch/sparc/include/asm/leon_amba.h |    3 + arch/sparc/include/asm/smp_32.h    |    9 + arch/sparc/kernel/Makefile         |    2 +- arch/sparc/kernel/entry.S          |   33 +++ arch/sparc/kernel/head_32.S        |   22 ++ arch/sparc/kernel/ioport.c         |    5 + arch/sparc/kernel/leon_kernel.c    |   94 +++++++ arch/sparc/kernel/leon_smp.c       |  468 ++++++++++++++++++++++++++++++++++++ arch/sparc/kernel/smp_32.c         |   10 + arch/sparc/kernel/trampoline_32.S  |   69 ++++++- arch/sparc/mm/srmmu.c              |    5 +-

 12 files changed, 745 insertions(+), 3 deletions(-)

 create mode 100644 arch/sparc/kernel/leon_smp.c

arch/sparc/include/asm/leon_amba.h +0 -0
index 618e888..57d2eae 100644

arch/sparc/include/asm/leon_amba.h extern int leon_debug_irqout; · line 196

Quoted 9 lines
arch/sparc/include/asm/leon_amba.h +3 -0
@@ -188,6 +188,9 @@ extern int leon_debug_irqout;
  extern unsigned long leon3_gptimer_irq;
  extern unsigned int sparc_leon_eirq;
 
+int amba_get_free_apbslv_devices(int vendor, int device, struct amba_apb_device *dev, int nr);
+
+
  #endif /* __ASSEMBLY__ */
 
  #define LEON3_IO_AREA 0xfff00000

Should this be in a different patch? it doesn't seem to be related to the SMP changes.

Quoted 12 lines
arch/sparc/kernel/leon_kernel.c +1 -0
index 54d8a5b..ab449b4 100644
@@ -12,15 +12,20 @@
  #include <linux/of_platform.h>
  #include <linux/interrupt.h>
  #include <linux/of_device.h>
+
  #include <asm/oplib.h>
  #include <asm/timer.h>
  #include <asm/prom.h>

arch/sparc/kernel/leon_kernel.c line 28

Quoted 10 lines
arch/sparc/kernel/leon_kernel.c +4 -0
  #include <asm/leon.h>
  #include <asm/leon_amba.h>
+#include <asm/traps.h>
+#include <asm/cacheflush.h>
 
  #include "prom.h"
  #include "irq.h"
 
+#define CONFIG_LEONSMP_USETIMER2
+

Should this be a KConfig symbol?

Quoted 8 lines

 struct leon3_irqctrl_regs_map *leon3_irqctrl_regs; /* interrupt controller base address, initialized by amba_init() */ struct leon3_gptimer_regs_map *leon3_gptimer_regs; /* timer controller base address, initialized by amba_init() */ struct amba_apb_device leon_percpu_timer_dev[16];

arch/sparc/mm/srmmu.c +0 -0
index 509b1ff..d55c255 100644

arch/sparc/mm/srmmu.c void __init ld_mmu_srmmu(void) · line 2308

Quoted 9 lines
arch/sparc/mm/srmmu.c +2 -1
@@ -2301,7 +2301,8 @@ void __init ld_mmu_srmmu(void)
        BTFIXUPSET_CALL(flush_cache_mm, smp_flush_cache_mm, BTFIXUPCALL_NORM);
        BTFIXUPSET_CALL(flush_cache_range, smp_flush_cache_range, BTFIXUPCALL_NORM);
        BTFIXUPSET_CALL(flush_cache_page, smp_flush_cache_page, BTFIXUPCALL_NORM);
-       if (sparc_cpu_model != sun4d) {
+       if (sparc_cpu_model != sun4d &&
+           sparc_cpu_model != sparc_leon) {
                BTFIXUPSET_CALL(flush_tlb_all, smp_flush_tlb_all, BTFIXUPCALL_NORM);
                BTFIXUPSET_CALL(flush_tlb_mm, smp_flush_tlb_mm, BTFIXUPCALL_NORM);
                BTFIXUPSET_CALL(flush_tlb_range, smp_flush_tlb_range, BTFIXUPCALL_NORM);

Again, doesn't seem SMP related.

Other than those small issues, on a first read-through, this seems like a good patch.

Good work!

Thanks,

Signature · 4 lines
Julian Calaby

Email: [email protected]
.Plan: http://sites.google.com/site/juliancalaby/
#2 lore raw
In reply to [email protected]
Quoted 30 lines · Konrad Eisele
Quoted 20 lines · Julian Calaby
Quoted 20 lines

 struct leon3_irqctrl_regs_map *leon3_irqctrl_regs; /* interrupt controller base address, initialized by amba_init() */ struct leon3_gptimer_regs_map *leon3_gptimer_regs; /* timer controller base address, initialized by amba_init() */
 struct amba_apb_device leon_percpu_timer_dev[16];

arch/sparc/mm/srmmu.c +2 -1
index 509b1ff..d55c255 100644
@@ -2301,7 +2301,8 @@ void __init ld_mmu_srmmu(void)
       BTFIXUPSET_CALL(flush_cache_mm, smp_flush_cache_mm,
 BTFIXUPCALL_NORM);
       BTFIXUPSET_CALL(flush_cache_range, smp_flush_cache_range,
 BTFIXUPCALL_NORM);
       BTFIXUPSET_CALL(flush_cache_page, smp_flush_cache_page,
 BTFIXUPCALL_NORM);
-       if (sparc_cpu_model != sun4d) {
+       if (sparc_cpu_model != sun4d &&
+           sparc_cpu_model != sparc_leon) {
Quoted 8 lines
Quoted 6 lines

              BTFIXUPSET_CALL(flush_tlb_all, smp_flush_tlb_all, BTFIXUPCALL_NORM);
              BTFIXUPSET_CALL(flush_tlb_mm, smp_flush_tlb_mm, BTFIXUPCALL_NORM);
              BTFIXUPSET_CALL(flush_tlb_range, smp_flush_tlb_range, BTFIXUPCALL_NORM);

Again, doesn't seem SMP related.

Quoted 8 lines

This is in srmmu.c inside a CONFIG_SMP section:
#ifdef CONFIG_SMP
       /* El switcheroo... */
 ...

Quoted 2 lines
Quoted 2 lines

+       if (sparc_cpu_model != sun4d &&
+           sparc_cpu_model != sparc_leon) {

 ...
#endif

That's what I get from reading over the patch at work without access to the actual codebase.

Thanks!

Signature · 4 lines
Julian Calaby

Email: [email protected]
.Plan: http://sites.google.com/site/juliancalaby/
#3 lore raw
In reply to [email protected]
Quoted 35 lines · Julian Calaby

Konrad,

A couple of things that stood out from a quick read over the code.

Quoted 30 lines · On Mon, Aug 31, 2009 at 23:47, <[email protected]> wrote:

From: Konrad Eisele <[email protected]>

Support SMP for a Sparc-Leon multiprocessor system. Add Leon specific SMP code to arch/sparc/kernel/leon_smp.c.

---
 arch/sparc/include/asm/leon.h      |   28 +++
 arch/sparc/include/asm/leon_amba.h |    3 +
 arch/sparc/include/asm/smp_32.h    |    9 +
 arch/sparc/kernel/Makefile         |    2 +-
 arch/sparc/kernel/entry.S          |   33 +++
 arch/sparc/kernel/head_32.S        |   22 ++
 arch/sparc/kernel/ioport.c         |    5 +
 arch/sparc/kernel/leon_kernel.c    |   94 +++++++
 arch/sparc/kernel/leon_smp.c       |  468 ++++++++++++++++++++++++++++++++++++
 arch/sparc/kernel/smp_32.c         |   10 +
 arch/sparc/kernel/trampoline_32.S  |   69 ++++++-
 arch/sparc/mm/srmmu.c              |    5 +-
 12 files changed, 745 insertions(+), 3 deletions(-)
 create mode 100644 arch/sparc/kernel/leon_smp.c
arch/sparc/include/asm/leon_amba.h +0 -0
index 618e888..57d2eae 100644
@@ -188,6 +188,9 @@ extern int leon_debug_irqout;
 extern unsigned long leon3_gptimer_irq;
 extern unsigned int sparc_leon_eirq;
 
Quoted 3 lines

arch/sparc/include/asm/leon_amba.h extern int leon_debug_irqout; · line 193

Quoted 3 lines
arch/sparc/include/asm/leon_amba.h +3 -0
+int amba_get_free_apbslv_devices(int vendor, int device, struct amba_apb_device *dev, int nr);
+
+

I'll remove it. It is not used by the patch. It was related to a cleanup the I did in conjunction with the CONFIG_LEONSMP_USETIMER2 define below.

Quoted 24 lines

arch/sparc/include/asm/leon_amba.h extern int leon_debug_irqout; · line 196

Quoted 3 lines
arch/sparc/include/asm/leon_amba.h +0 -0
 #endif /* __ASSEMBLY__ */
 
 #define LEON3_IO_AREA 0xfff00000

Should this be in a different patch? it doesn't seem to be related to the SMP changes.

Quoted 17 lines
arch/sparc/kernel/leon_kernel.c +3 -0
index 54d8a5b..ab449b4 100644
@@ -12,15 +12,20 @@
 #include <linux/of_platform.h>
 #include <linux/interrupt.h>
 #include <linux/of_device.h>
+
 #include <asm/oplib.h>
 #include <asm/timer.h>
 #include <asm/prom.h>
 #include <asm/leon.h>
 #include <asm/leon_amba.h>
+#include <asm/traps.h>
+#include <asm/cacheflush.h>
 
Quoted 7 lines

arch/sparc/kernel/leon_kernel.c line 28

Quoted 5 lines
arch/sparc/kernel/leon_kernel.c +2 -0
 #include "prom.h"
 #include "irq.h"
 
+#define CONFIG_LEONSMP_USETIMER2
+

Should this be a KConfig symbol?

Yes, but I tool it out of Kconfig to make the patch smaller. I'll remove this and the dependent part.

Quoted 12 lines
Quoted 12 lines
arch/sparc/kernel/leon_kernel.c +0 -0
 struct leon3_irqctrl_regs_map *leon3_irqctrl_regs; /* interrupt controller base address, initialized by amba_init() */
 struct leon3_gptimer_regs_map *leon3_gptimer_regs; /* timer controller base address, initialized by amba_init() */
 struct amba_apb_device leon_percpu_timer_dev[16];
arch/sparc/mm/srmmu.c +0 -0
index 509b1ff..d55c255 100644
@@ -2301,7 +2301,8 @@ void __init ld_mmu_srmmu(void)
       BTFIXUPSET_CALL(flush_cache_mm, smp_flush_cache_mm, BTFIXUPCALL_NORM);
       BTFIXUPSET_CALL(flush_cache_range, smp_flush_cache_range, BTFIXUPCALL_NORM);
       BTFIXUPSET_CALL(flush_cache_page, smp_flush_cache_page, BTFIXUPCALL_NORM);
Quoted 8 lines

arch/sparc/mm/srmmu.c void __init ld_mmu_srmmu(void) · line 2308

Quoted 6 lines
arch/sparc/mm/srmmu.c +2 -1
-       if (sparc_cpu_model != sun4d) {
+       if (sparc_cpu_model != sun4d &&
+           sparc_cpu_model != sparc_leon) {
               BTFIXUPSET_CALL(flush_tlb_all, smp_flush_tlb_all, BTFIXUPCALL_NORM);
               BTFIXUPSET_CALL(flush_tlb_mm, smp_flush_tlb_mm, BTFIXUPCALL_NORM);
               BTFIXUPSET_CALL(flush_tlb_range, smp_flush_tlb_range, BTFIXUPCALL_NORM);

Again, doesn't seem SMP related.

This is in srmmu.c inside a CONFIG_SMP section:

#ifdef CONFIG_SMP
	/* El switcheroo... */

...

Quoted 2 lines

arch/sparc/mm/srmmu.c void __init ld_mmu_srmmu(void) · line 2305

Quoted 2 lines
arch/sparc/mm/srmmu.c +2 -0
+       if (sparc_cpu_model != sun4d &&
+           sparc_cpu_model != sparc_leon) {

...
#endif

Quoted 8 lines

Other than those small issues, on a first read-through, this seems like a good patch.

Good work!

Thanks,

#4 lore raw

PATCH 1/1 sparc,leon: Sparc-Leon SMP support

In reply to [email protected]

From: Konrad Eisele <[email protected]>

Support SMP for a Sparc-Leon multiprocessor system. Add Leon specific SMP code to arch/sparc/kernel/leon_smp.c.

---
 arch/sparc/include/asm/leon.h     |   28 +++
 arch/sparc/include/asm/smp_32.h   |    9 +
 arch/sparc/kernel/Makefile        |    2 +-
 arch/sparc/kernel/entry.S         |   33 +++
 arch/sparc/kernel/head_32.S       |   22 ++
 arch/sparc/kernel/ioport.c        |    5 +
 arch/sparc/kernel/leon_kernel.c   |   84 +++++++
 arch/sparc/kernel/leon_smp.c      |  468 +++++++++++++++++++++++++++++++++++++
 arch/sparc/kernel/smp_32.c        |   10 +
 arch/sparc/kernel/trampoline_32.S |   69 ++++++-
 arch/sparc/mm/srmmu.c             |    5 +-
 11 files changed, 732 insertions(+), 3 deletions(-)
 create mode 100644 arch/sparc/kernel/leon_smp.c
arch/sparc/include/asm/leon.h +28 -0
index 28a42b7..559448c 100644
@@ -340,6 +340,30 @@ extern int leon_flush_needed(void);
 extern void leon_switch_mm(void);
 extern int srmmu_swprobe_trace;
 
+#ifdef CONFIG_SMP
+extern int leon_smp_nrcpus(void);
+extern void leon_clear_profile_irq(int cpu);
+extern void leon_smp_done(void);
+extern void leon_boot_cpus(void);
+extern int leon_boot_one_cpu(int i);
+void leon_init_smp(void);
+extern void cpu_probe(void);
+extern void cpu_idle(void);
+extern void init_IRQ(void);
+extern void cpu_panic(void);
+extern int __leon_processor_id(void);
+void leon_enable_irq_cpu(unsigned int irq_nr, unsigned int cpu);
+
+extern unsigned int real_irq_entry[], smpleon_ticker[];
+extern unsigned int patchme_maybe_smp_msg[];
+extern unsigned long trapbase_cpu1[];
+extern unsigned long trapbase_cpu2[];
+extern unsigned long trapbase_cpu3[];
+extern unsigned int t_nmi[], linux_trap_ipi15_leon[];
+extern unsigned int linux_trap_ipi15_sun4m[];
+
+#endif /* CONFIG_SMP */
+
 #endif /* __KERNEL__ */
 
 #endif /* __ASSEMBLY__ */
@@ -356,6 +380,10 @@ extern int srmmu_swprobe_trace;
 #define leon_switch_mm() do {} while (0)
 #define leon_init_IRQ() do {} while (0)
 #define init_leon() do {} while (0)
+#define leon_smp_done() do {} while (0)
+#define leon_boot_cpus() do {} while (0)
+#define leon_boot_one_cpu(i) 1
+#define leon_init_smp() do {} while (0)
 
 #endif /* !defined(CONFIG_SPARC_LEON) */
 
arch/sparc/include/asm/smp_32.h +9 -0
index 58101dc..841905c 100644
@@ -106,6 +106,15 @@ static inline int hard_smp4d_processor_id(void)
 	return cpuid;
 }
 
+extern inline int hard_smpleon_processor_id(void)
+{
+	int cpuid;
+	__asm__ __volatile__("rd     %%asr17,%0\n\t"
+			     "srl    %0,28,%0" :
+			     "=&r" (cpuid) : );
+	return cpuid;
+}
+
 #ifndef MODULE
 static inline int hard_smp_processor_id(void)
 {
arch/sparc/kernel/Makefile +1 -1
index b004175..7056244 100644
@@ -68,7 +68,7 @@ obj-$(CONFIG_SPARC32)     += dma.o
 obj-$(CONFIG_SPARC32_PCI) += pcic.o
 
 obj-$(CONFIG_SMP)         += trampoline_$(BITS).o smp_$(BITS).o
-obj-$(CONFIG_SPARC32_SMP) += sun4m_smp.o sun4d_smp.o
+obj-$(CONFIG_SPARC32_SMP) += sun4m_smp.o sun4d_smp.o leon_smp.o
 obj-$(CONFIG_SPARC64_SMP) += hvtramp.o
 
 obj-y                     += auxio_$(BITS).o
arch/sparc/kernel/entry.S +33 -0
index f41ecc5..ec9c7bc 100644
@@ -400,6 +400,39 @@ linux_trap_ipi15_sun4d:
 	/* FIXME */
 1:	b,a	1b
 
+#ifdef CONFIG_SPARC_LEON
+
+	.globl	smpleon_ticker
+	/* SMP per-cpu ticker interrupts are handled specially. */
+smpleon_ticker:
+        SAVE_ALL
+	or	%l0, PSR_PIL, %g2
+	wr	%g2, 0x0, %psr
+	WRITE_PAUSE
+	wr	%g2, PSR_ET, %psr
+	WRITE_PAUSE
+	call	leon_percpu_timer_interrupt
+	 add	%sp, STACKFRAME_SZ, %o0
+	wr	%l0, PSR_ET, %psr
+	WRITE_PAUSE
+	RESTORE_ALL
+
+	.align	4
+	.globl	linux_trap_ipi15_leon
+linux_trap_ipi15_leon:
+	SAVE_ALL
+	or	%l0, PSR_PIL, %l4
+	wr	%l4, 0x0, %psr
+	WRITE_PAUSE
+	wr	%l4, PSR_ET, %psr
+	WRITE_PAUSE
+	call	leon_cross_call_irq
+	 nop
+	b	ret_trap_lockless_ipi
+	 clr	%l6
+
+#endif /* CONFIG_SPARC_LEON */
+
 #endif /* CONFIG_SMP */
 
 	/* This routine handles illegal instructions and privileged
arch/sparc/kernel/head_32.S +22 -0
index 439d82a..21bb259 100644
@@ -811,9 +811,31 @@ found_version:
 got_prop:
 #ifdef CONFIG_SPARC_LEON
 	        /* no cpu-type check is needed, it is a SPARC-LEON */
+#ifdef CONFIG_SMP
+		ba leon_smp_init
+		 nop
+
+		.global leon_smp_init
+leon_smp_init:
+		sethi	%hi(boot_cpu_id), %g1    ! master always 0
+		stb	%g0, [%g1 + %lo(boot_cpu_id)]
+		sethi	%hi(boot_cpu_id4), %g1   ! master always 0
+		stb	%g0, [%g1 + %lo(boot_cpu_id4)]
+
+		rd     %asr17,%g1
+		srl    %g1,28,%g1
+
+		cmp %g0,%g1
+		 beq sun4c_continue_boot         !continue with master
+		nop
+
+		ba leon_smp_cpu_startup
+		 nop
+#else
 		ba sun4c_continue_boot
 		 nop
 #endif
+#endif
 		set	cputypval, %o2
 		ldub	[%o2 + 0x4], %l1
 
arch/sparc/kernel/ioport.c +5 -0
index 87ea0d0..ec87fb8 100644
@@ -47,10 +47,15 @@
 #include <asm/dma.h>
 #include <asm/iommu.h>
 #include <asm/io-unit.h>
+#include <asm/leon.h>
 
 #include "dma.h"
 
+#ifdef CONFIG_SPARC_LEON
+#define mmu_inval_dma_area(p, l) leon_flush_dcache_all()
+#else
 #define mmu_inval_dma_area(p, l)	/* Anton pulled it out for 2.4.0-xx */
+#endif
 
 static struct resource *_sparc_find_resource(struct resource *r,
 					     unsigned long);
arch/sparc/kernel/leon_kernel.c +84 -0

118 lines not on this page · raw message

arch/sparc/kernel/leon_smp.c new file +466 -0

466 lines not on this page · raw message

arch/sparc/kernel/smp_32.c +10 -0
index 132d81f..91c10fb 100644
@@ -32,6 +32,7 @@
 #include <asm/cacheflush.h>
 #include <asm/tlbflush.h>
 #include <asm/cpudata.h>
+#include <asm/leon.h>
 
 #include "irq.h"
 
@@ -96,6 +97,9 @@ void __init smp_cpus_done(unsigned int max_cpus)
 	case sun4d:
 		smp4d_smp_done();
 		break;
+	case sparc_leon:
+		leon_smp_done();
+		break;
 	case sun4e:
 		printk("SUN4E\n");
 		BUG();
@@ -306,6 +310,9 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
 	case sun4d:
 		smp4d_boot_cpus();
 		break;
+	case sparc_leon:
+		leon_boot_cpus();
+		break;
 	case sun4e:
 		printk("SUN4E\n");
 		BUG();
@@ -376,6 +383,9 @@ int __cpuinit __cpu_up(unsigned int cpu)
 	case sun4d:
 		ret = smp4d_boot_one_cpu(cpu);
 		break;
+	case sparc_leon:
+		ret = leon_boot_one_cpu(cpu);
+		break;
 	case sun4e:
 		printk("SUN4E\n");
 		BUG();
arch/sparc/kernel/trampoline_32.S +68 -1

84 lines not on this page · raw message

arch/sparc/mm/srmmu.c +4 -1
index 509b1ff..d55c255 100644
@@ -2301,7 +2301,8 @@ void __init ld_mmu_srmmu(void)
 	BTFIXUPSET_CALL(flush_cache_mm, smp_flush_cache_mm, BTFIXUPCALL_NORM);
 	BTFIXUPSET_CALL(flush_cache_range, smp_flush_cache_range, BTFIXUPCALL_NORM);
 	BTFIXUPSET_CALL(flush_cache_page, smp_flush_cache_page, BTFIXUPCALL_NORM);
-	if (sparc_cpu_model != sun4d) {
+	if (sparc_cpu_model != sun4d &&
+	    sparc_cpu_model != sparc_leon) {
 		BTFIXUPSET_CALL(flush_tlb_all, smp_flush_tlb_all, BTFIXUPCALL_NORM);
 		BTFIXUPSET_CALL(flush_tlb_mm, smp_flush_tlb_mm, BTFIXUPCALL_NORM);
 		BTFIXUPSET_CALL(flush_tlb_range, smp_flush_tlb_range, BTFIXUPCALL_NORM);
@@ -2330,6 +2331,8 @@ void __init ld_mmu_srmmu(void)
 #ifdef CONFIG_SMP
 	if (sparc_cpu_model = sun4d)
 		sun4d_init_smp();
+	else if (sparc_cpu_model = sparc_leon)
+		leon_init_smp();
 	else
 		sun4m_init_smp();
 #endif
Signature · 1 line
1.6.3.2