[RFC Patch v1 40/55] ARC: SMP support
From: Vineet Gupta I would like to acknowledge people who have contributed to SMP port -Rajeshwar Ranga for orig 2.6.19 SMP port -Noam Camus for help with resurrecting 3.2 SMP port Signed-off-by: Vineet Gupta --- arch/arc/Kconfig | 39 - arch/arc/Makefile|3 + arch/arc/include/asm/entry.h | 49 + arch/arc/include/asm/mmu_context.h |4 + arch/arc/include/asm/mutex.h |9 + arch/arc/include/asm/pgtable.h |4 + arch/arc/include/asm/processor.h |8 + arch/arc/include/asm/smp.h | 108 +++ arch/arc/kernel/Makefile |1 + arch/arc/kernel/ctx_sw.c | 11 + arch/arc/kernel/entry.S |4 + arch/arc/kernel/head.S | 33 arch/arc/kernel/irq.c|5 + arch/arc/kernel/setup.c |4 + arch/arc/kernel/smp.c| 295 ++ arch/arc/mm/tlb.c|6 + arch/arc/mm/tlbex.S | 38 arch/arc/plat-arcfpga/Kconfig| 12 ++ arch/arc/plat-arcfpga/Makefile |1 + arch/arc/plat-arcfpga/include/plat/irq.h | 10 +- arch/arc/plat-arcfpga/include/plat/smp.h | 115 arch/arc/plat-arcfpga/irq.c | 10 + arch/arc/plat-arcfpga/smp.c | 192 +++ 23 files changed, 959 insertions(+), 2 deletions(-) create mode 100644 arch/arc/kernel/smp.c create mode 100644 arch/arc/plat-arcfpga/include/plat/smp.h create mode 100644 arch/arc/plat-arcfpga/smp.c diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index 15d740c..8d72ada 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig @@ -118,9 +118,44 @@ config CPU_BIG_ENDIAN help Build kernel for Big Endian Mode of ARC CPU +# If a plat can do IPI, same core(s) can do minimal SMP +config ARC_HAS_IPI + bool + +config SMP + bool "Symmetric Multi-Processing (Incomplete)" + default y + depends on ARC_HAS_IPI + select USE_GENERIC_SMP_HELPERS + help + This enables support for systems with more than one CPU. If you have + a system with only one CPU, like most personal computers, say N. If + you have a system with more than one CPU, say Y. + +if SMP + +config ARC_HAS_COH_CACHES + def_bool n + +config ARC_HAS_COH_LLSC + def_bool n + +config ARC_HAS_REENTRANT_IRQ_LV2 + def_bool n + +endif + +config NR_CPUS + int "Maximum number of CPUs (2-32)" + range 2 32 + depends on SMP + default "2" + menuconfig ARC_CACHE bool "Enable Cache Support" default y + # if SMP, cache enabled ONLY if ARC implementation has cache coherency + depends on !SMP || ARC_HAS_COH_CACHES if ARC_CACHE @@ -213,6 +248,8 @@ endchoice config ARC_COMPACT_IRQ_LEVELS bool "ARCompact IRQ Priorities: High(2)/Low(1)" default n + # if SMP, LV2 enabled ONLY if ARC implementation has LV2 re-entrancy + depends on !SMP || ARC_HAS_REENTRANT_IRQ_LV2 if ARC_COMPACT_IRQ_LEVELS @@ -320,7 +357,7 @@ menuconfig ARC_DBG config ARC_DBG_TLB_PARANOIA bool "Paranoia Checks in Low Level TLB Handlers" - depends on ARC_DBG + depends on ARC_DBG && !SMP default n config ARC_DBG_EVENT_TIMELINE diff --git a/arch/arc/Makefile b/arch/arc/Makefile index a533546..a86e284 100644 --- a/arch/arc/Makefile +++ b/arch/arc/Makefile @@ -127,3 +127,6 @@ archclean: # Thus forcing all exten calls in this file to be long calls export CFLAGS_decompress_inflate.o = -mmedium-calls export CFLAGS_initramfs.o = -mmedium-calls +ifdef CONFIG_SMP +export CFLAGS_core.o = -mmedium-calls +endif diff --git a/arch/arc/include/asm/entry.h b/arch/arc/include/asm/entry.h index 43dbf6f..a054e27 100644 --- a/arch/arc/include/asm/entry.h +++ b/arch/arc/include/asm/entry.h @@ -354,11 +354,19 @@ * to be saved again on kernel mode stack, as part of ptregs. *-*/ .macro EXCPN_PROLOG_FREEUP_REG reg +#ifdef CONFIG_SMP + sr \reg, [ARC_REG_SCRATCH_DATA0] +#else st \reg, [@ex_saved_reg1] +#endif .endm .macro EXCPN_PROLOG_RESTORE_REGreg +#ifdef CONFIG_SMP + lr \reg, [ARC_REG_SCRATCH_DATA0] +#else ld \reg, [@ex_saved_reg1] +#endif .endm /*-- @@ -468,7 +476,11 @@ /* restore original r9 , saved in int1_saved_reg * It will be saved on stack in macro: SAVE_CALLER_SAVED */ +#ifdef CONFIG_SMP + lr r9, [ARC_REG_SCRATCH_DATA0] +#else ld r9, [@int1_saved_reg] +#endif /* now we are ready to save the remaining context :) */ st -1, [sp, 8]/* orig_r8, -1 for interuppt level one */ @@ -599,6 +611,41 @@ bmsk \reg, \reg, 7 .endm
[RFC Patch v1 40/55] ARC: SMP support
From: Vineet Gupta vgu...@synopsys.com I would like to acknowledge people who have contributed to SMP port -Rajeshwar Ranga rajeshwar.ra...@gmail.com for orig 2.6.19 SMP port -Noam Camus na...@ezchip.com for help with resurrecting 3.2 SMP port Signed-off-by: Vineet Gupta vgu...@synopsys.com --- arch/arc/Kconfig | 39 - arch/arc/Makefile|3 + arch/arc/include/asm/entry.h | 49 + arch/arc/include/asm/mmu_context.h |4 + arch/arc/include/asm/mutex.h |9 + arch/arc/include/asm/pgtable.h |4 + arch/arc/include/asm/processor.h |8 + arch/arc/include/asm/smp.h | 108 +++ arch/arc/kernel/Makefile |1 + arch/arc/kernel/ctx_sw.c | 11 + arch/arc/kernel/entry.S |4 + arch/arc/kernel/head.S | 33 arch/arc/kernel/irq.c|5 + arch/arc/kernel/setup.c |4 + arch/arc/kernel/smp.c| 295 ++ arch/arc/mm/tlb.c|6 + arch/arc/mm/tlbex.S | 38 arch/arc/plat-arcfpga/Kconfig| 12 ++ arch/arc/plat-arcfpga/Makefile |1 + arch/arc/plat-arcfpga/include/plat/irq.h | 10 +- arch/arc/plat-arcfpga/include/plat/smp.h | 115 arch/arc/plat-arcfpga/irq.c | 10 + arch/arc/plat-arcfpga/smp.c | 192 +++ 23 files changed, 959 insertions(+), 2 deletions(-) create mode 100644 arch/arc/kernel/smp.c create mode 100644 arch/arc/plat-arcfpga/include/plat/smp.h create mode 100644 arch/arc/plat-arcfpga/smp.c diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index 15d740c..8d72ada 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig @@ -118,9 +118,44 @@ config CPU_BIG_ENDIAN help Build kernel for Big Endian Mode of ARC CPU +# If a plat can do IPI, same core(s) can do minimal SMP +config ARC_HAS_IPI + bool + +config SMP + bool Symmetric Multi-Processing (Incomplete) + default y + depends on ARC_HAS_IPI + select USE_GENERIC_SMP_HELPERS + help + This enables support for systems with more than one CPU. If you have + a system with only one CPU, like most personal computers, say N. If + you have a system with more than one CPU, say Y. + +if SMP + +config ARC_HAS_COH_CACHES + def_bool n + +config ARC_HAS_COH_LLSC + def_bool n + +config ARC_HAS_REENTRANT_IRQ_LV2 + def_bool n + +endif + +config NR_CPUS + int Maximum number of CPUs (2-32) + range 2 32 + depends on SMP + default 2 + menuconfig ARC_CACHE bool Enable Cache Support default y + # if SMP, cache enabled ONLY if ARC implementation has cache coherency + depends on !SMP || ARC_HAS_COH_CACHES if ARC_CACHE @@ -213,6 +248,8 @@ endchoice config ARC_COMPACT_IRQ_LEVELS bool ARCompact IRQ Priorities: High(2)/Low(1) default n + # if SMP, LV2 enabled ONLY if ARC implementation has LV2 re-entrancy + depends on !SMP || ARC_HAS_REENTRANT_IRQ_LV2 if ARC_COMPACT_IRQ_LEVELS @@ -320,7 +357,7 @@ menuconfig ARC_DBG config ARC_DBG_TLB_PARANOIA bool Paranoia Checks in Low Level TLB Handlers - depends on ARC_DBG + depends on ARC_DBG !SMP default n config ARC_DBG_EVENT_TIMELINE diff --git a/arch/arc/Makefile b/arch/arc/Makefile index a533546..a86e284 100644 --- a/arch/arc/Makefile +++ b/arch/arc/Makefile @@ -127,3 +127,6 @@ archclean: # Thus forcing all exten calls in this file to be long calls export CFLAGS_decompress_inflate.o = -mmedium-calls export CFLAGS_initramfs.o = -mmedium-calls +ifdef CONFIG_SMP +export CFLAGS_core.o = -mmedium-calls +endif diff --git a/arch/arc/include/asm/entry.h b/arch/arc/include/asm/entry.h index 43dbf6f..a054e27 100644 --- a/arch/arc/include/asm/entry.h +++ b/arch/arc/include/asm/entry.h @@ -354,11 +354,19 @@ * to be saved again on kernel mode stack, as part of ptregs. *-*/ .macro EXCPN_PROLOG_FREEUP_REG reg +#ifdef CONFIG_SMP + sr \reg, [ARC_REG_SCRATCH_DATA0] +#else st \reg, [@ex_saved_reg1] +#endif .endm .macro EXCPN_PROLOG_RESTORE_REGreg +#ifdef CONFIG_SMP + lr \reg, [ARC_REG_SCRATCH_DATA0] +#else ld \reg, [@ex_saved_reg1] +#endif .endm /*-- @@ -468,7 +476,11 @@ /* restore original r9 , saved in int1_saved_reg * It will be saved on stack in macro: SAVE_CALLER_SAVED */ +#ifdef CONFIG_SMP + lr r9, [ARC_REG_SCRATCH_DATA0] +#else ld r9, [@int1_saved_reg] +#endif /* now we are ready to save the remaining context :) */ st -1, [sp, 8]/* orig_r8, -1 for interuppt level one