xtensa SMP queue
Subsystems (6)
Max Filippov
maintainercover xtensa SMP queue
Hi Chris,
this series adds SMP support for xtensa.
There's a number of trivial cleanups:
xtensa: remove NO_IRQ definitions
xtensa: fix build warning in 64-bit build environment
xtensa: fix build warning from gcc-4.7.2
xtensa: call check_s32c1i after trap_init
xtensa: move init_mmu declaration to mmu_context.h
a couple of fixes for spinlocks:
xtensa: fix arch spinlock function names
xtensa: fix __delay for small loop count
three fixes for the clocksources, with these we get high precision timers usable in SMP and IRQ time accounting:
xtensa: mark ccount as continuous clocksource
xtensa: update clockevent setup for SMP
xtensa: enable HAVE_IRQ_TIME_ACCOUNTING
fixes and rearrangement of IRQ handling code and a new driver for MX interrupt distributor:
xtensa: move built-in PIC to drivers/irqchip
xtensa: clean up do_interrupt/do_IRQ
xtensa: clear timer IRQ unconditionally in its handler
xtensa: add MX irqchip
and finally SMP and hotplug CPU support and a sample SMP-capable CPU variant:
xtensa: add SMP support
xtensa: implement CPU hotplug
xtensa: add Three Core HiFi-2 MX Variant.
Please review.
You can pull these changes from my git tree,
the following changes since commit 61e6cfa80de5760bbe406f4e815b7739205754d2:
Linux 3.12-rc5 (2013-10-13 15:41:28 -0700)
are available in the git repository at:
git://github.com/jcmvbkbc/linux-xtensa.git tags/xtensa-smp-20131017
for you to fetch changes up to 4862c5ae570b8a40275f413dfa2e3f184ecfa1d9:
xtensa: implement CPU hotplug (2013-10-17 01:50:17 +0400)
----------------------------------------------------------------
Clean up minor warnings.
Fix spinlock function names, provide missing definitions. Extract PIC into drivers/irqchip.
Clean up IRQ handling.
Add MX interrupt distributor.
Add SMP support.
Add hotplug CPU support.
Add SMP-capable core variant.
----------------------------------------------------------------
Baruch Siach (1):
xtensa: mark ccount as continuous clocksource
Max Filippov (15):
xtensa: remove NO_IRQ definitions
xtensa: fix build warning in 64-bit build environment
xtensa: fix build warning from gcc-4.7.2
xtensa: fix arch spinlock function names
xtensa: fix __delay for small loop count
xtensa: enable HAVE_IRQ_TIME_ACCOUNTING
xtensa: update clockevent setup for SMP
xtensa: call check_s32c1i after trap_init
xtensa: move init_mmu declaration to mmu_context.h
xtensa: move built-in PIC to drivers/irqchip
xtensa: clean up do_interrupt/do_IRQ
xtensa: clear timer IRQ unconditionally in its handler
xtensa: add MX irqchip
xtensa: add SMP support
xtensa: implement CPU hotplug
Piet Delaney (1):
xtensa: add Three Core HiFi-2 MX Variant.
arch/xtensa/Kconfig | 54 +- arch/xtensa/Makefile | 1 + arch/xtensa/include/asm/barrier.h | 4 +- arch/xtensa/include/asm/bitops.h | 8 +- arch/xtensa/include/asm/cacheflush.h | 40 +- arch/xtensa/include/asm/delay.h | 9 +- arch/xtensa/include/asm/irq.h | 9 + arch/xtensa/include/asm/mmu.h | 10 +- arch/xtensa/include/asm/mmu_context.h | 106 ++-- arch/xtensa/include/asm/mxregs.h | 46 ++ arch/xtensa/include/asm/processor.h | 20 + arch/xtensa/include/asm/ptrace.h | 8 + arch/xtensa/include/asm/smp.h | 38 +- arch/xtensa/include/asm/spinlock.h | 31 +- arch/xtensa/include/asm/spinlock_types.h | 20 + arch/xtensa/include/asm/timex.h | 14 +- arch/xtensa/include/asm/tlbflush.h | 42 +- arch/xtensa/include/asm/traps.h | 1 + arch/xtensa/include/asm/vectors.h | 4 + arch/xtensa/kernel/Makefile | 1 + arch/xtensa/kernel/head.S | 181 +++++-- arch/xtensa/kernel/irq.c | 207 ++++---- arch/xtensa/kernel/mxhead.S | 85 +++ arch/xtensa/kernel/setup.c | 92 ++-- arch/xtensa/kernel/smp.c | 591 +++++++++++++++++++++ arch/xtensa/kernel/time.c | 56 +- arch/xtensa/kernel/traps.c | 56 +- arch/xtensa/kernel/vmlinux.lds.S | 26 + arch/xtensa/mm/cache.c | 7 +- arch/xtensa/mm/fault.c | 2 +- arch/xtensa/mm/misc.S | 4 +- arch/xtensa/mm/mmu.c | 4 +- arch/xtensa/mm/tlb.c | 37 +- .../platforms/xtfpga/include/platform/hardware.h | 6 +- arch/xtensa/variants/s6000/include/variant/irq.h | 1 - .../test_mmuhifi_c3/include/variant/core.h | 384 +++++++++++++ .../test_mmuhifi_c3/include/variant/tie-asm.h | 183 +++++++ .../variants/test_mmuhifi_c3/include/variant/tie.h | 141 +++++ drivers/irqchip/Kconfig | 4 + drivers/irqchip/Makefile | 2 + drivers/irqchip/irq-xtensa-mx.c | 166 ++++++ drivers/irqchip/irq-xtensa-pic.c | 108 ++++ include/linux/irqchip/xtensa-mx.h | 17 + include/linux/irqchip/xtensa-pic.h | 18 + 44 files changed, 2455 insertions(+), 389 deletions(-) create mode 100644 arch/xtensa/include/asm/mxregs.h create mode 100644 arch/xtensa/include/asm/spinlock_types.h create mode 100644 arch/xtensa/kernel/mxhead.S create mode 100644 arch/xtensa/kernel/smp.c create mode 100644 arch/xtensa/variants/test_mmuhifi_c3/include/variant/core.h create mode 100644 arch/xtensa/variants/test_mmuhifi_c3/include/variant/tie-asm.h create mode 100644 arch/xtensa/variants/test_mmuhifi_c3/include/variant/tie.h create mode 100644 drivers/irqchip/irq-xtensa-mx.c create mode 100644 drivers/irqchip/irq-xtensa-pic.c create mode 100644 include/linux/irqchip/xtensa-mx.h create mode 100644 include/linux/irqchip/xtensa-pic.h
Signature · 1 line
1.8.1.4
Max Filippov
maintainerPATCH 1/17 xtensa: remove NO_IRQ definitions
These definitions (-1) were correct when used as a hardware IRQ number, but are incorrect as a mapped IRQ number.
--- arch/xtensa/platforms/xtfpga/include/platform/hardware.h | 4 ---- arch/xtensa/variants/s6000/include/variant/irq.h | 1 - 2 files changed, 5 deletions(-)
arch/xtensa/platforms/xtfpga/include/platform/hardware.h +0 -4
@@ -15,10 +15,6 @@#ifndef __XTENSA_XTAVNET_HARDWARE_H#define __XTENSA_XTAVNET_HARDWARE_H -/* By default NO_IRQ is defined to 0 in Linux, but we use the -interrupt 0 for UART... */ -#define NO_IRQ -1 -/* Memory configuration. */ #define PLATFORM_DEFAULT_MEM_START 0x00000000
arch/xtensa/variants/s6000/include/variant/irq.h +0 -1
@@ -1,7 +1,6 @@#ifndef _XTENSA_S6000_IRQ_H#define _XTENSA_S6000_IRQ_H -#define NO_IRQ (-1)#define VARIANT_NR_IRQS 8/* GPIO interrupts */ extern void variant_irq_enable (unsigned int irq);
Signature · 1 line
1.8.1.4
Max Filippov
maintainerPATCH 2/17 xtensa: fix build warning in 64-bit build environment
In reply to Max FilippovThis fixes the following build warnings:
arch/xtensa/mm/misc.S: Assembler messages:arch/xtensa/mm/misc.S:143: Warning: value 0xffffffff30000106 truncated to 0x30000106 arch/xtensa/mm/misc.S:197: Warning: value 0xffffffff30000106 truncated to 0x30000106
--- arch/xtensa/mm/misc.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/xtensa/mm/misc.S +2 -2
@@ -140,7 +140,7 @@ ENTRY(clear_user_page) /* Setup a temporary DTLB with the color of the VPN */ - movi a4, -PAGE_OFFSET + (PAGE_KERNEL | _PAGE_HW_WRITE) + movi a4, ((PAGE_KERNEL | _PAGE_HW_WRITE) - PAGE_OFFSET) & 0xffffffff movi a5, TLBTEMP_BASE_1 # virt add a6, a2, a4 # ppn add a2, a5, a3 # add 'color'
@@ -194,7 +194,7 @@ ENTRY(copy_user_page) or a9, a9, a8 slli a4, a4, PAGE_SHIFT s32i a9, a5, PAGE_FLAGS - movi a5, -PAGE_OFFSET + (PAGE_KERNEL | _PAGE_HW_WRITE) + movi a5, ((PAGE_KERNEL | _PAGE_HW_WRITE) - PAGE_OFFSET) & 0xffffffff beqz a6, 1f
Signature · 1 line
1.8.1.4
Max Filippov
maintainerPATCH 3/17 xtensa: fix build warning from gcc-4.7.2
In reply to Max FilippovThis fixes the following build warning:
arch/xtensa/include/asm/vectors.h:70:5: warning: "XCHAL_HAVE_VECBASE" is not defined [-Wundef]
--- arch/xtensa/include/asm/vectors.h | 4 ++++ 1 file changed, 4 insertions(+)
arch/xtensa/include/asm/vectors.h +4 -0
@@ -67,6 +67,10 @@ VECBASE_RESET_VADDR)#define RESET_VECTOR1_VADDR XC_VADDR(RESET_VECTOR1_VECOFS) +#ifndef XCHAL_HAVE_VECBASE +#define XCHAL_HAVE_VECBASE 0 +#endif +#if XCHAL_HAVE_VECBASE #define USER_VECTOR_VADDR XC_VADDR(XCHAL_USER_VECOFS)
Signature · 1 line
1.8.1.4
Max Filippov
maintainerPATCH 4/17 xtensa: fix arch spinlock function names
In reply to Max Filippov--- arch/xtensa/include/asm/spinlock.h | 31 +++++++++++++++++-------------- arch/xtensa/include/asm/spinlock_types.h | 20 ++++++++++++++++++++ 2 files changed, 37 insertions(+), 14 deletions(-) create mode 100644 arch/xtensa/include/asm/spinlock_types.h
arch/xtensa/include/asm/spinlock.h +17 -14
@@ -28,13 +28,13 @@* 1 somebody owns the spinlock */ -#define __raw_spin_is_locked (x) ((x)->slock != 0) -#define __raw_spin_unlock_wait (lock) \ - do { while (__raw_spin_is_locked(lock)) cpu_relax(); } while (0) +#define arch_spin_is_locked (x) ((x)->slock != 0) +#define arch_spin_unlock_wait (lock) \ + do { while (arch_spin_is_locked(lock)) cpu_relax(); } while (0) -#define __raw_spin_lock_flags (lock, flags) __raw_spin_lock(lock) +#define arch_spin_lock_flags (lock, flags) arch_spin_lock(lock) -static inline void __raw_spin_lock (raw_spinlock_t *lock) +static inline void arch_spin_lock (arch_spinlock_t *lock) {unsigned long tmp;
@@ -51,7 +51,7 @@ static inline void __raw_spin_lock(raw_spinlock_t *lock)/* Returns 1 if the lock is obtained, 0 otherwise. */ -static inline int __raw_spin_trylock (raw_spinlock_t *lock) +static inline int arch_spin_trylock (arch_spinlock_t *lock) {unsigned long tmp;
@@ -67,7 +67,7 @@ static inline int __raw_spin_trylock(raw_spinlock_t *lock)return tmp ==0 ?1 :0 ; } -static inline void __raw_spin_unlock (raw_spinlock_t *lock) +static inline void arch_spin_unlock (arch_spinlock_t *lock) {unsigned long tmp;
@@ -96,9 +96,9 @@ static inline void __raw_spin_unlock(raw_spinlock_t *lock)* 0x80000000 one writer owns the rwlock, no other writers, no readers */ -#define __raw_write_can_lock (x) ((x)->lock == 0) +#define arch_write_can_lock (x) ((x)->lock == 0) -static inline void __raw_write_lock (raw_rwlock_t *rw) +static inline void arch_write_lock (arch_rwlock_t *rw) {unsigned long tmp;
@@ -116,7 +116,7 @@ static inline void __raw_write_lock(raw_rwlock_t *rw)/* Returns 1 if the lock is obtained, 0 otherwise. */ -static inline int __raw_write_trylock (raw_rwlock_t *rw) +static inline int arch_write_trylock (arch_rwlock_t *rw) {unsigned long tmp;
@@ -133,7 +133,7 @@ static inline int __raw_write_trylock(raw_rwlock_t *rw)return tmp ==0 ?1 :0 ; } -static inline void __raw_write_unlock (raw_rwlock_t *rw) +static inline void arch_write_unlock (arch_rwlock_t *rw) {unsigned long tmp;
@@ -145,7 +145,7 @@ static inline void __raw_write_unlock(raw_rwlock_t *rw) : "memory"); } -static inline void __raw_read_lock (raw_rwlock_t *rw) +static inline void arch_read_lock (arch_rwlock_t *rw) {unsigned long tmp;unsigned long result;
@@ -164,7 +164,7 @@ static inline void __raw_read_lock(raw_rwlock_t *rw)/* Returns 1 if the lock is obtained, 0 otherwise. */ -static inline int __raw_read_trylock (raw_rwlock_t *rw) +static inline int arch_read_trylock (arch_rwlock_t *rw) {unsigned long result;unsigned long tmp;
@@ -184,7 +184,7 @@ static inline int __raw_read_trylock(raw_rwlock_t *rw)return result ==0 ; } -static inline void __raw_read_unlock (raw_rwlock_t *rw) +static inline void arch_read_unlock (arch_rwlock_t *rw) {unsigned long tmp1, tmp2;
@@ -199,4 +199,7 @@ static inline void __raw_read_unlock(raw_rwlock_t *rw) : "memory"); } +#define arch_read_lock_flags (lock, flags) arch_read_lock(lock) +#define arch_write_lock_flags (lock, flags) arch_write_lock(lock) +#endif /* _XTENSA_SPINLOCK_H */
arch/xtensa/include/asm/spinlock_types.h new file +20 -0
@@ -0,0 +1,20 @@ +#ifndef __ASM_SPINLOCK_TYPES_H +#define __ASM_SPINLOCK_TYPES_H + +#ifndef __LINUX_SPINLOCK_TYPES_H +# error "please don't include this file directly" +#endif + +typedef struct { +volatile unsigned int slock; +}arch_spinlock_t ; + +#define __ARCH_SPIN_LOCK_UNLOCKED { 0 } + +typedef struct { +volatile unsigned int lock; +}arch_rwlock_t ; + +#define __ARCH_RW_LOCK_UNLOCKED { 0 } + +#endif
Signature · 1 line
1.8.1.4
Max Filippov
maintainerPATCH 5/17 xtensa: fix __delay for small loop count
In reply to Max FilippovAvoid __delay counter underflow for loop counts < 2.
--- arch/xtensa/include/asm/delay.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
arch/xtensa/include/asm/delay.h +6 -3
@@ -19,9 +19,12 @@ extern unsigned long loops_per_jiffy;static inline void __delay (unsigned long loops) { -/* 2 cycles per loop. */ - __asm__ __volatile__ ("1: addi %0, %0, -2; bgeui %0, 2, 1b" - :"=r" (loops) :"0" (loops)); +if (__builtin_constant_p (loops) && loops <2 ) + __asm__ __volatile__ ("nop" ); +else if (loops >=2 ) +/* 2 cycles per loop. */ + __asm__ __volatile__ ("1: addi %0, %0, -2; bgeui %0, 2, 1b" + :"+r" (loops)); }/* For SMP/NUMA systems, change boot_cpu_data to something like
Signature · 1 line
1.8.1.4
Max Filippov
maintainerPATCH 6/17 xtensa: enable HAVE_IRQ_TIME_ACCOUNTING
In reply to Max Filippov--- arch/xtensa/Kconfig | 1 + 1 file changed, 1 insertion(+)
arch/xtensa/Kconfig +1 -0
@@ -19,6 +19,7 @@ config XTENSA select IRQ_DOMAIN select HAVE_OPROFILE select HAVE_FUNCTION_TRACER + select HAVE_IRQ_TIME_ACCOUNTING help Xtensa processors are 32-bit RISC machines designed by Tensilica primarily for embedded systems. These processors are both
Signature · 1 line
1.8.1.4
Max Filippov
maintainerPATCH 7/17 xtensa: mark ccount as continuous clocksource
In reply to Max FilippovFrom: Baruch Siach <[email protected]>
This allows ccount to be used as highres timer.
--- arch/xtensa/kernel/time.c | 1 + 1 file changed, 1 insertion(+)
arch/xtensa/kernel/time.c +1 -0
@@ -46,6 +46,7 @@ static struct clocksource ccount_clocksource = { .rating = 200, .read = ccount_read, .mask = CLOCKSOURCE_MASK(32), + .flags = CLOCK_SOURCE_IS_CONTINUOUS, }; static int ccount_timer_set_next_event(unsigned long delta,
Signature · 1 line
1.8.1.4
Max Filippov
maintainerPATCH 8/17 xtensa: update clockevent setup for SMP
In reply to Max FilippovProvide per-cpu ccount_timer objects and use them appropriately. Extract per-cpu clockevent setup function.
--- arch/xtensa/kernel/time.c | 54 +++++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 25 deletions(-)
arch/xtensa/kernel/time.c +29 -25
@@ -53,18 +53,12 @@ static int ccount_timer_set_next_event(unsigned long delta, struct clock_event_device *dev);static void ccount_timer_set_mode (enum clock_event_mode mode,struct clock_event_device *evt); -static struct ccount_timer_t { +struct ccount_timer {struct clock_event_device evt;int irq_enabled; -} ccount_timer = { - .evt = { - .name ="ccount_clockevent" , - .features =CLOCK_EVT_FEAT_ONESHOT , - .rating =300 , - .set_next_event = ccount_timer_set_next_event, - .set_mode = ccount_timer_set_mode, - }, +char name[24 ]; }; +static DEFINE_PER_CPU(struct ccount_timer, ccount_timer);static int ccount_timer_set_next_event (unsigned long delta,struct clock_event_device *dev)
@@ -85,8 +79,8 @@ static int ccount_timer_set_next_event(unsigned long delta,static void ccount_timer_set_mode (enum clock_event_mode mode,struct clock_event_device *evt) { -struct ccount_timer_t *timer = - container_of(evt, struct ccount_timer_t, evt); +struct ccount_timer *timer = + container_of(evt, struct ccount_timer, evt);/* * There is no way to disable the timer interrupt at the device level,
@@ -118,9 +112,28 @@ static struct irqaction timer_irqaction = { .handler = timer_interrupt, .flags = IRQF_TIMER, .name = "timer", - .dev_id = &ccount_timer, }; +void local_timer_setup (unsigned cpu) +{ +struct ccount_timer *timer = &per_cpu (ccount_timer, cpu); +struct clock_event_device *clockevent = &timer->evt; + + timer->irq_enabled =1 ; + clockevent->name = timer->name; +snprintf (timer->name,sizeof (timer->name),"ccount_clockevent_%u" , cpu); + clockevent->features =CLOCK_EVT_FEAT_ONESHOT ; + clockevent->rating =300 ; + clockevent->set_next_event = ccount_timer_set_next_event; + clockevent->set_mode = ccount_timer_set_mode; + clockevent->cpumask =cpumask_of (cpu); + clockevent->irq =irq_create_mapping (NULL ,LINUX_TIMER_INT ); +if (WARN (!clockevent->irq,"error: can't map timer irq" )) +return ; +clockevents_config_and_register (clockevent, ccount_freq, +0xf ,0xffffffff ); +} +void __init time_init (void ) {#ifdef CONFIG_XTENSA_CALIBRATE_CCOUNT
@@ -132,16 +145,8 @@ void __init time_init(void) ccount_freq =CONFIG_XTENSA_CPU_CLOCK *1000000UL ;#endif clocksource_register_hz (&ccount_clocksource, ccount_freq); - - ccount_timer.evt.cpumask =cpumask_of (0 ); - ccount_timer.evt.irq =irq_create_mapping (NULL ,LINUX_TIMER_INT ); -if (WARN (!ccount_timer.evt.irq,"error: can't map timer irq" )) -return ; -clockevents_config_and_register (&ccount_timer.evt, ccount_freq,0xf , -0xffffffff ); -setup_irq (ccount_timer.evt.irq, &timer_irqaction); - ccount_timer.irq_enabled =1 ; - +local_timer_setup (0 ); +setup_irq (this_cpu_ptr (&ccount_timer)->evt.irq, &timer_irqaction);setup_sched_clock (ccount_sched_clock_read,32 , ccount_freq); }
@@ -149,10 +154,9 @@ void __init time_init(void)* The timer interrupt is called HZ times per second. */ -irqreturn_t timer_interrupt (int irq,void *dev_id) +irqreturn_t timer_interrupt (int irq,void *dev_id) { -struct ccount_timer_t *timer = dev_id; -struct clock_event_device *evt = &timer->evt; +struct clock_event_device *evt = &this_cpu_ptr (&ccount_timer)->evt; evt->event_handler (evt);
Signature · 1 line
1.8.1.4
Max Filippov
maintainerPATCH 9/17 xtensa: call check_s32c1i after trap_init
In reply to Max FilippovOtherwise exceptions may occur prior to exception handling mechanism initialization, resulting in silently dead system.
--- arch/xtensa/kernel/setup.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-)
arch/xtensa/kernel/setup.c +7 -11
@@ -378,7 +378,8 @@ static inline int probed_compare_swap(int *v, int cmp, int set)/* Handle probed exception */ -void __init do_probed_exception (struct pt_regs *regs,unsigned long exccause) +static void __init do_probed_exception (struct pt_regs *regs, +unsigned long exccause) {if (regs->pc == rcw_probe_pc) {/* exception on s32c1i ? */ regs->pc +=3 ;/* skip the s32c1i instruction */
@@ -390,7 +391,7 @@ void __init do_probed_exception(struct pt_regs *regs, unsigned long exccause)/* Simple test of S32C1I (soc bringup assist) */ -void __init check_s32c1i (void ) +static int __init check_s32c1i (void ) {int n, cause1, cause2;void *handbus, *handdata, *handaddr;/* temporarily saved handlers */
@@ -445,24 +446,21 @@ void __init check_s32c1i(void)trap_set_handler (EXCCAUSE_LOAD_STORE_ERROR , handbus);trap_set_handler (EXCCAUSE_LOAD_STORE_DATA_ERROR , handdata);trap_set_handler (EXCCAUSE_LOAD_STORE_ADDR_ERROR , handaddr); +return 0 ; }#else /* XCHAL_HAVE_S32C1I */ /* This condition should not occur with a commercially deployed processor. Display reminder for early engr test or demo chips / FPGA bitstreams */ -void __init check_s32c1i (void ) +static int __init check_s32c1i (void ) {pr_warn ("Processor configuration lacks atomic compare-and-swap support!\n" ); +return 0 ; }#endif /* XCHAL_HAVE_S32C1I */ -#else /* CONFIG_S32C1I_SELFTEST */ - -void __init check_s32c1i (void ) -{ -} - +early_initcall (check_s32c1i);#endif /* CONFIG_S32C1I_SELFTEST */
@@ -471,8 +469,6 @@ void __init setup_arch(char **cmdline_p)strlcpy (boot_command_line, command_line,COMMAND_LINE_SIZE ); *cmdline_p = command_line; -check_s32c1i (); -/* Reserve some memory regions */ #ifdef CONFIG_BLK_DEV_INITRD
Signature · 1 line
1.8.1.4
Max Filippov
maintainerPATCH 10/17 xtensa: move init_mmu declaration to mmu_context.h
In reply to Max FilippovSecondary CPUs need this declaration to initialize their MMUs.
--- arch/xtensa/include/asm/mmu_context.h | 6 ++++++ arch/xtensa/kernel/setup.c | 7 +------ 2 files changed, 7 insertions(+), 6 deletions(-)
arch/xtensa/include/asm/mmu_context.h +6 -0
@@ -49,6 +49,12 @@ extern unsigned long asid_cache;#define ASID_MASK ((1 << XCHAL_MMU_ASID_BITS) - 1)#define ASID_INSERT (x) (0x03020001 | (((x) & ASID_MASK) << 8)) +#ifdef CONFIG_MMU +void init_mmu (void ); +#else +static inline void init_mmu (void ) { } +#endif +static inline void set_rasid_register (unsigned long val) { __asm__ __volatile__ (" wsr %0, rasid\n\t"
arch/xtensa/kernel/setup.c +1 -6
@@ -40,6 +40,7 @@#endif #include <asm/bootparam.h> +#include <asm/mmu_context.h> #include <asm/pgtable.h> #include <asm/processor.h> #include <asm/timex.h>
@@ -88,12 +89,6 @@ static char default_command_line[COMMAND_LINE_SIZE] __initdata = CONFIG_CMDLINE;sysmem_info_t __initdata sysmem; -#ifdef CONFIG_MMU -extern void init_mmu (void ); -#else -static inline void init_mmu (void ) { } -#endif -extern int mem_reserve (unsigned long ,unsigned long ,int );extern void bootmem_init (void );extern void zones_init (void );
Signature · 1 line
1.8.1.4
Max Filippov
maintainerPATCH 11/17 xtensa: move built-in PIC to drivers/irqchip
In reply to Max FilippovExtract xtensa built-in interrupt controller implementation from xtensa/kernel/irq.c and move it to other irqchips, providing way to instantiate it from the device tree.
--- arch/xtensa/include/asm/irq.h | 7 ++ arch/xtensa/kernel/irq.c | 137 ++++++++----------------------------- drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-xtensa-pic.c | 108 +++++++++++++++++++++++++++++ include/linux/irqchip/xtensa-pic.h | 18 +++++ 5 files changed, 164 insertions(+), 107 deletions(-) create mode 100644 drivers/irqchip/irq-xtensa-pic.c create mode 100644 include/linux/irqchip/xtensa-pic.h
arch/xtensa/include/asm/irq.h +7 -0
@@ -43,5 +43,12 @@ static __inline__ int irq_canonicalize(int irq) }struct irqaction ; +struct irq_domain ; + +int xtensa_irq_domain_xlate (const u32 *intspec,unsigned int intsize, +unsigned long int_irq,unsigned long ext_irq, +unsigned long *out_hwirq,unsigned int *out_type); +int xtensa_irq_map (struct irq_domain *d,unsigned int irq,irq_hw_number_t hw); +unsigned xtensa_map_ext_irq (unsigned ext_irq);#endif /* _XTENSA_IRQ_H */
arch/xtensa/kernel/irq.c +30 -107
196 lines not on this page · raw message
drivers/irqchip/Makefile +1 -0
@@ -22,3 +22,4 @@ obj-$(CONFIG_RENESAS_IRQC) += irq-renesas-irqc.o obj-$(CONFIG_VERSATILE_FPGA_IRQ) += irq-versatile-fpga.o obj-$(CONFIG_ARCH_VT8500) += irq-vt8500.o obj-$(CONFIG_TB10X_IRQC) += irq-tb10x.o +obj-$(CONFIG_XTENSA) += irq-xtensa-pic.o
drivers/irqchip/irq-xtensa-pic.c new file +108 -0
108 lines not on this page · raw message
include/linux/irqchip/xtensa-pic.h new file +18 -0
@@ -0,0 +1,18 @@ +/* +* Xtensa built-in interrupt controller +* +* Copyright (C) 2002 - 2013 Tensilica, Inc. +* Copyright (C) 1992, 1998 Linus Torvalds, Ingo Molnar +* +* This file is subject to the terms and conditions of the GNU General Public +* License. See the file "COPYING" in the main directory of this archive +* for more details. +*/ + +#ifndef __LINUX_IRQCHIP_XTENSA_PIC_H +#define __LINUX_IRQCHIP_XTENSA_PIC_H + +struct device_node ; +int xtensa_pic_init_legacy (struct device_node *interrupt_parent); + +#endif /* __LINUX_IRQCHIP_XTENSA_PIC_H */
Signature · 1 line
1.8.1.4
Max Filippov
maintainerPATCH 12/17 xtensa: clean up do_interrupt/do_IRQ
In reply to Max Filippov- set up irq registers and call irq_enter/irq_exit once for each kernel entry due to interrupt;
- don't attempt to clear current IRQ in the do_interrupt, IRQ handler will take care of it;
- find pending interrupt with highest priority before every ISR invocation.
--- arch/xtensa/kernel/irq.c | 6 ------ arch/xtensa/kernel/traps.c | 23 +++++++++-------------- 2 files changed, 9 insertions(+), 20 deletions(-)
arch/xtensa/kernel/irq.c +0 -6
@@ -30,7 +30,6 @@ atomic_t irq_err_count; asmlinkage void do_IRQ(int hwirq, struct pt_regs *regs) { -struct pt_regs *old_regs =set_irq_regs (regs);int irq =irq_find_mapping (NULL , hwirq);if (hwirq >=NR_IRQS ) {
@@ -38,8 +37,6 @@ asmlinkage void do_IRQ(int hwirq, struct pt_regs *regs) __func__, hwirq); } -irq_enter (); -#ifdef CONFIG_DEBUG_STACKOVERFLOW /* Debugging check for stack overflow: is there less than 1KB free? */ {
@@ -54,9 +51,6 @@ asmlinkage void do_IRQ(int hwirq, struct pt_regs *regs) }#endif generic_handle_irq (irq); - -irq_exit (); -set_irq_regs (old_regs); }int arch_show_interrupts (struct seq_file *p,int prec)
arch/xtensa/kernel/traps.c +9 -14
@@ -212,6 +212,9 @@ void do_interrupt(struct pt_regs *regs)XCHAL_INTLEVEL6_MASK , XCHAL_INTLEVEL7_MASK, }; +struct pt_regs *old_regs =set_irq_regs (regs); + +irq_enter ();for (;;) {unsigned intread =get_sr (interrupt);
@@ -227,21 +230,13 @@ void do_interrupt(struct pt_regs *regs) }if (level ==0 ) -return ; - -/* -* Clear the interrupt before processing, in case it's -* edge-triggered or software-generated -*/ -while (int_at_level) { -unsigned i =__ffs (int_at_level); -unsigned mask =1 << i; - - int_at_level ^= mask; -set_sr (mask, intclear); -do_IRQ (i, regs); - } +break ; + +do_IRQ (__ffs (int_at_level), regs); } + +irq_exit (); +set_irq_regs (old_regs); }/*
Signature · 1 line
1.8.1.4
Max Filippov
maintainerPATCH 13/17 xtensa: clear timer IRQ unconditionally in its handler
In reply to Max FilippovPIC irq_ack doesn't clear timer IRQ, because timer interrupt handler usually set up new timer by writing to ccompare register and thus clearing timer IRQ. However timer may not be set up in the IRQ handler, e.g. with tickless idle on SMP, or when CPU is going offline, leaving timer IRQ raised and making do_interrupt attempting to handle it forever.
To fix this always write current value of ccompare SR chosen to be linux timer back to that SR on entry to timer interrupt handler.
--- arch/xtensa/kernel/time.c | 1 + 1 file changed, 1 insertion(+)
arch/xtensa/kernel/time.c +1 -0
@@ -158,6 +158,7 @@ irqreturn_t timer_interrupt(int irq, void *dev_id) {struct clock_event_device *evt = &this_cpu_ptr (&ccount_timer)->evt; +set_linux_timer (get_linux_timer ()); evt->event_handler (evt);/* Allow platform to do something useful (Wdog). */
Signature · 1 line
1.8.1.4
Max Filippov
maintainerPATCH 14/17 xtensa: add MX irqchip
In reply to Max FilippovMX is an interrupt distributor used in some SMP-capable xtensa configurations.
--- arch/xtensa/include/asm/irq.h | 1 + arch/xtensa/include/asm/mxregs.h | 46 ++++++++++ arch/xtensa/include/asm/processor.h | 20 +++++ arch/xtensa/kernel/irq.c | 8 ++ drivers/irqchip/Kconfig | 4 + drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-xtensa-mx.c | 166 ++++++++++++++++++++++++++++++++++++ include/linux/irqchip/xtensa-mx.h | 17 ++++ 8 files changed, 263 insertions(+) create mode 100644 arch/xtensa/include/asm/mxregs.h create mode 100644 drivers/irqchip/irq-xtensa-mx.c create mode 100644 include/linux/irqchip/xtensa-mx.h
arch/xtensa/include/asm/irq.h +1 -0
@@ -50,5 +50,6 @@ int xtensa_irq_domain_xlate(const u32 *intspec, unsigned int intsize, unsigned long *out_hwirq, unsigned int *out_type);int xtensa_irq_map (struct irq_domain *d,unsigned int irq,irq_hw_number_t hw);unsigned xtensa_map_ext_irq (unsigned ext_irq); +unsigned xtensa_get_ext_irq_no (unsigned irq);#endif /* _XTENSA_IRQ_H */
arch/xtensa/include/asm/mxregs.h new file +46 -0
46 lines not on this page · raw message
arch/xtensa/include/asm/processor.h +20 -0
@@ -191,5 +191,25 @@ extern unsigned long get_wchan(struct task_struct *p);#define set_sr (x,sr) ({unsigned int v=(unsigned int)x; WSR(v,sr);})#define get_sr (sr) ({unsigned int v; RSR(v,sr); v; }) +#ifndef XCHAL_HAVE_EXTERN_REGS +#define XCHAL_HAVE_EXTERN_REGS 0 +#endif + +#if XCHAL_HAVE_EXTERN_REGS + +static inline void set_er (unsigned long value,unsigned long addr) +{ + asmvolatile ("wer %0, %1" : :"a" (value),"a" (addr) :"memory" ); +} + +static inline unsigned long get_er (unsigned long addr) +{ + registerunsigned long value; + asmvolatile ("rer %0, %1" :"=a" (value) :"a" (addr) :"memory" ); +return value; +} + +#endif /* XCHAL_HAVE_EXTERN_REGS */ +#endif /* __ASSEMBLY__ */ #endif /* _XTENSA_PROCESSOR_H */
arch/xtensa/kernel/irq.c +8 -0
@@ -123,6 +123,14 @@ unsigned xtensa_map_ext_irq(unsigned ext_irq)return XCHAL_NUM_INTERRUPTS ; } +unsigned xtensa_get_ext_irq_no (unsigned irq) +{ +unsigned mask = (XCHAL_INTTYPE_MASK_EXTERN_EDGE | +XCHAL_INTTYPE_MASK_EXTERN_LEVEL ) & + ((1u << irq) -1 ); +return hweight32 (mask); +} +void __init init_IRQ (void ) {#ifdef CONFIG_OF
drivers/irqchip/Kconfig +4 -0
@@ -61,3 +61,7 @@ config VERSATILE_FPGA_IRQ_NR int default 4 depends on VERSATILE_FPGA_IRQ + +config XTENSA_MX + bool + select IRQ_DOMAIN
drivers/irqchip/Makefile +1 -0
@@ -23,3 +23,4 @@ obj-$(CONFIG_VERSATILE_FPGA_IRQ) += irq-versatile-fpga.o obj-$(CONFIG_ARCH_VT8500) += irq-vt8500.o obj-$(CONFIG_TB10X_IRQC) += irq-tb10x.o obj-$(CONFIG_XTENSA) += irq-xtensa-pic.o +obj-$(CONFIG_XTENSA_MX) += irq-xtensa-mx.o
drivers/irqchip/irq-xtensa-mx.c new file +166 -0
166 lines not on this page · raw message
include/linux/irqchip/xtensa-mx.h new file +17 -0
@@ -0,0 +1,17 @@ +/* +* Xtensa MX interrupt distributor +* +* Copyright (C) 2002 - 2013 Tensilica, Inc. +* +* This file is subject to the terms and conditions of the GNU General Public +* License. See the file "COPYING" in the main directory of this archive +* for more details. +*/ + +#ifndef __LINUX_IRQCHIP_XTENSA_MX_H +#define __LINUX_IRQCHIP_XTENSA_MX_H + +struct device_node ; +int xtensa_mx_init_legacy (struct device_node *interrupt_parent); + +#endif /* __LINUX_IRQCHIP_XTENSA_MX_H */
Signature · 1 line
1.8.1.4
Max Filippov
maintainerPATCH 15/17 xtensa: add SMP support
In reply to Max FilippovThis is largely based on SMP code from the xtensa-2.6.29-smp tree by Piet Delaney, Marc Gauthier, Joe Taylor, Christian Zankel (and possibly other Tensilica folks).
--- arch/xtensa/Kconfig | 37 +- arch/xtensa/include/asm/barrier.h | 4 +- arch/xtensa/include/asm/bitops.h | 8 +- arch/xtensa/include/asm/cacheflush.h | 40 +- arch/xtensa/include/asm/mmu.h | 10 +- arch/xtensa/include/asm/mmu_context.h | 100 +++-- arch/xtensa/include/asm/ptrace.h | 8 + arch/xtensa/include/asm/smp.h | 29 +- arch/xtensa/include/asm/timex.h | 14 +- arch/xtensa/include/asm/tlbflush.h | 42 +- arch/xtensa/include/asm/traps.h | 1 + arch/xtensa/kernel/Makefile | 1 + arch/xtensa/kernel/head.S | 130 ++++-- arch/xtensa/kernel/irq.c | 15 +- arch/xtensa/kernel/mxhead.S | 85 ++++ arch/xtensa/kernel/setup.c | 66 ++- arch/xtensa/kernel/smp.c | 465 +++++++++++++++++++++ arch/xtensa/kernel/traps.c | 33 +- arch/xtensa/kernel/vmlinux.lds.S | 26 ++ arch/xtensa/mm/cache.c | 7 +- arch/xtensa/mm/fault.c | 2 +- arch/xtensa/mm/mmu.c | 4 +- arch/xtensa/mm/tlb.c | 37 +- .../platforms/xtfpga/include/platform/hardware.h | 2 +- 24 files changed, 967 insertions(+), 199 deletions(-) create mode 100644 arch/xtensa/kernel/mxhead.S create mode 100644 arch/xtensa/kernel/smp.c
arch/xtensa/Kconfig +36 -1
@@ -9,7 +9,6 @@ config XTENSA select GENERIC_CLOCKEVENTS select VIRT_TO_BUS select GENERIC_IRQ_SHOW - select GENERIC_CPU_DEVICES select GENERIC_SCHED_CLOCK select MODULES_USE_ELF_RELA select GENERIC_PCI_IOMAP
@@ -65,6 +64,9 @@ config MMU config VARIANT_IRQ_SWITCH def_bool n +config MAY_HAVE_SMP + def_bool n + menu "Processor type and features" choice
@@ -105,6 +107,39 @@ config XTENSA_UNALIGNED_USER source "kernel/Kconfig.preempt" +config HAVE_SMP + bool "System Supports SMP (MX)" + depends on MAY_HAVE_SMP + select XTENSA_MX + help + This option is use to indicate that the system-on-a-chip (SOC) + supports Multiprocessing. Multiprocessor support implemented above + the CPU core definition and currently needs to be selected manually. + + Multiprocessor support in implemented with external cache and + interrupt controlers. + + The MX interrupt distributer adds Interprocessor Interrupts + and causes the IRQ numbers to be increased by 4 for devices + like the open cores ethernet driver and the serial interface. + + You still have to select "Enable SMP" to enable SMP on this SOC. + +config SMP + bool "Enable Symmetric multi-processing support" + depends on HAVE_SMP + select USE_GENERIC_SMP_HELPERS + select GENERIC_SMP_IDLE_THREAD + help + Enabled SMP Software; allows more than one CPU/CORE + to be activated during startup. + +config NR_CPUS + depends on SMP + int "Maximum number of CPUs (2-32)" + range 2 32 + default "4" + config MATH_EMULATION bool "Math emulation" help
arch/xtensa/include/asm/barrier.h +3 -1
@@ -17,7 +17,9 @@#define wmb () mb()#ifdef CONFIG_SMP -#error smp_* not defined +#define smp_mb () mb() +#define smp_rmb () rmb() +#define smp_wmb () wmb()#else #define smp_mb () barrier()#define smp_rmb () barrier()
arch/xtensa/include/asm/bitops.h +2 -6
@@ -22,12 +22,8 @@#include <asm/processor.h> #include <asm/byteorder.h> -#ifdef CONFIG_SMP -# error SMP not supported on this architecture -#endif - -#define smp_mb__before_clear_bit () barrier() -#define smp_mb__after_clear_bit () barrier() +#define smp_mb__before_clear_bit () smp_mb() +#define smp_mb__after_clear_bit () smp_mb()#include <asm-generic/bitops/non-atomic.h>
arch/xtensa/include/asm/cacheflush.h +25 -15
@@ -1,18 +1,14 @@/* -* include/asm-xtensa/cacheflush.h -* * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive * for more details. * -* (C) 2001 - 2007 Tensilica Inc. +* (C) 2001 - 2013 Tensilica Inc. */ #ifndef _XTENSA_CACHEFLUSH_H#define _XTENSA_CACHEFLUSH_H -#ifdef __KERNEL__ -#include <linux/mm.h> #include <asm/processor.h> #include <asm/page.h>
@@ -51,7 +47,6 @@ extern void __invalidate_icache_page(unsigned long);extern void __invalidate_icache_range (unsigned long ,unsigned long );extern void __invalidate_dcache_range (unsigned long ,unsigned long ); -#if XCHAL_DCACHE_IS_WRITEBACK extern void __flush_invalidate_dcache_all (void );extern void __flush_dcache_page (unsigned long );
@@ -87,9 +82,22 @@ static inline void __invalidate_icache_page_alias(unsigned long virt,* (see also Documentation/cachetlb.txt) */ -#if (DCACHE_WAY_SIZE >PAGE_SIZE ) +#if (DCACHE_WAY_SIZE >PAGE_SIZE ) || defined(CONFIG_SMP ) + +#ifdef CONFIG_SMP +void flush_cache_all (void ); +void flush_cache_range (struct vm_area_struct *,ulong ,ulong ); +void flush_icache_range (unsigned long start,unsigned long end); +void flush_cache_page (struct vm_area_struct *, +unsigned long ,unsigned long ); +#else +#define flush_cache_all local_flush_cache_all +#define flush_cache_range local_flush_cache_range +#define flush_icache_range local_flush_icache_range +#define flush_cache_page local_flush_cache_page +#endif -#define flush_cache_all () \ +#define local_flush_cache_all () \ do { \ __flush_invalidate_dcache_all(); \ __invalidate_icache_all(); \
@@ -103,9 +111,11 @@ static inline void __invalidate_icache_page_alias(unsigned long virt,#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 1extern void flush_dcache_page (struct page *); -extern void flush_cache_range (struct vm_area_struct *,ulong ,ulong ); -extern void flush_cache_page (struct vm_area_struct *, -unsigned long ,unsigned long ); + +void local_flush_cache_range (struct vm_area_struct *vma, +unsigned long start,unsigned long end); +void local_flush_cache_page (struct vm_area_struct *vma, +unsigned long address,unsigned long pfn);#else
@@ -119,13 +129,14 @@ extern void flush_cache_page(struct vm_area_struct*,#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0#define flush_dcache_page (page) do { } while (0) -#define flush_cache_page (vma,addr,pfn) do { } while (0) -#define flush_cache_range (vma,start,end) do { } while (0) +#define flush_icache_range local_flush_icache_range +#define flush_cache_page (vma, addr, pfn) do { } while (0) +#define flush_cache_range (vma, start, end) do { } while (0)#endif /* Ensure consistency between data and instruction cache. */ -#define flush_icache_range (start,end) \ +#define local_flush_icache_range (start, end) \ do { \ __flush_dcache_range(start, (end) - (start)); \ __invalidate_icache_range(start,(end) - (start)); \
@@ -253,5 +264,4 @@ static inline void flush_invalidate_dcache_unaligned(u32 addr, u32 size) } } -#endif /* __KERNEL__ */ #endif /* _XTENSA_CACHEFLUSH_H */
arch/xtensa/include/asm/mmu.h +5 -5
@@ -1,11 +1,9 @@/* -* include/asm-xtensa/mmu.h -* * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive * for more details. * -* Copyright (C) 2001 - 2005 Tensilica Inc. +* Copyright (C) 2001 - 2013 Tensilica Inc. */ #ifndef _XTENSA_MMU_H
@@ -15,8 +13,10 @@#include <asm-generic/mmu.h> #else -/* Default "unsigned long" context */ -typedef unsigned long mm_context_t ; +typedef struct { +unsigned long asid[NR_CPUS ]; +unsigned int cpu; +}mm_context_t ;#endif /* CONFIG_MMU */ #endif /* _XTENSA_MMU_H */
arch/xtensa/include/asm/mmu_context.h +57 -43
156 lines not on this page · raw message
arch/xtensa/include/asm/ptrace.h +8 -0
@@ -59,9 +59,17 @@ struct pt_regs { (task_stack_page(tsk) + KERNEL_STACK_SIZE - (XCHAL_NUM_AREGS-16)*4) - 1)# define user_mode (regs) (((regs)->ps & 0x00000020)!=0)# define instruction_pointer (regs) ((regs)->pc) +# define return_pointer (regs) (MAKE_PC_FROM_RA((regs)->areg[0], \ + (regs)->areg[1]))# ifndef CONFIG_SMP # define profile_pc (regs) instruction_pointer(regs) +# else +# define profile_pc (regs) \ + ({ \ + in_lock_functions(instruction_pointer(regs)) ? \ + return_pointer(regs) : instruction_pointer(regs); \ + })# endif #define user_stack_pointer (regs) ((regs)->areg[1])
arch/xtensa/include/asm/smp.h +18 -11
@@ -1,27 +1,34 @@/* -* include/asm-xtensa/smp.h -* * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive * for more details. * -* Copyright (C) 2001 - 2005 Tensilica Inc. +* Copyright (C) 2001 - 2013 Tensilica Inc. */ #ifndef _XTENSA_SMP_H#define _XTENSA_SMP_H -extern struct xtensa_cpuinfo boot_cpu_data; +#ifdef CONFIG_SMP -#define cpu_data (&boot_cpu_data) -#define current_cpu_data boot_cpu_data +#define raw_smp_processor_id () (current_thread_info()->cpu) +#define cpu_logical_map (cpu) (cpu) -struct xtensa_cpuinfo { -unsigned long *pgd_cache; -unsigned long *pte_cache; -unsigned long pgtable_cache_sz; +struct start_info { +unsigned long stack; }; +extern struct start_info start_info; -#define cpu_logical_map (cpu) (cpu) +struct cpumask ; +void arch_send_call_function_ipi_mask (const struct cpumask *mask); +void arch_send_call_function_single_ipi (int cpu); + +void smp_init_cpus (void ); +void secondary_init_irq (void ); +void ipi_init (void ); +struct seq_file ; +void show_ipi_list (struct seq_file *p,int prec); + +#endif /* CONFIG_SMP */ #endif /* _XTENSA_SMP_H */
arch/xtensa/include/asm/timex.h +2 -12
@@ -1,18 +1,14 @@/* -* include/asm-xtensa/timex.h -* * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive * for more details. * -* Copyright (C) 2001 - 2008 Tensilica Inc. +* Copyright (C) 2001 - 2013 Tensilica Inc. */ #ifndef _XTENSA_TIMEX_H#define _XTENSA_TIMEX_H -#ifdef __KERNEL__ -#include <asm/processor.h> #include <linux/stringify.h>
@@ -39,14 +35,9 @@ extern unsigned long ccount_freq;typedef unsigned long long cycles_t ; -/* -* Only used for SMP. -*/ - -extern cycles_t cacheflush_time; -#define get_cycles () (0) +void local_timer_setup (unsigned cpu);/* * Register access.
@@ -81,5 +72,4 @@ static inline void set_linux_timer (unsigned long ccompare) WSR_CCOMPARE(LINUX_TIMER, ccompare); } -#endif /* __KERNEL__ */ #endif /* _XTENSA_TIMEX_H */
arch/xtensa/include/asm/tlbflush.h +31 -11
66 lines not on this page · raw message
arch/xtensa/include/asm/traps.h +1 -0
@@ -19,6 +19,7 @@*/ extern void *__init trap_set_handler (int cause,void *handler);extern void do_unhandled (struct pt_regs *regs,unsigned long exccause); +void secondary_trap_init (void );static inline void spill_registers (void ) {
arch/xtensa/kernel/Makefile +1 -0
@@ -12,6 +12,7 @@ obj-$(CONFIG_KGDB) += xtensa-stub.o obj-$(CONFIG_PCI) += pci.o obj-$(CONFIG_MODULES) += xtensa_ksyms.o module.o obj-$(CONFIG_FUNCTION_TRACER) += mcount.o +obj-$(CONFIG_SMP) += smp.o mxhead.o AFLAGS_head.o += -mtext-section-literals
arch/xtensa/kernel/head.S +87 -43
181 lines not on this page · raw message
arch/xtensa/kernel/irq.c +14 -1
@@ -4,7 +4,7 @@* Xtensa built-in interrupt controller and some generic functions copied * from i386. * -* Copyright (C) 2002 - 2006 Tensilica, Inc. +* Copyright (C) 2002 - 2013 Tensilica, Inc. * Copyright (C) 1992, 1998 Linus Torvalds, Ingo Molnar * *
@@ -19,10 +19,12 @@#include <linux/irq.h> #include <linux/kernel_stat.h> #include <linux/irqchip.h> +#include <linux/irqchip/xtensa-mx.h> #include <linux/irqchip/xtensa-pic.h> #include <linux/irqdomain.h> #include <linux/of.h> +#include <asm/mxregs.h> #include <asm/uaccess.h> #include <asm/platform.h>
@@ -55,6 +57,9 @@ asmlinkage void do_IRQ(int hwirq, struct pt_regs *regs)int arch_show_interrupts (struct seq_file *p,int prec) { +#ifdef CONFIG_SMP +show_ipi_list (p, prec); +#endif seq_printf (p,"%*s: " , prec,"ERR" );seq_printf (p,"%10u\n" ,atomic_read (&irq_err_count));return 0 ;
@@ -136,7 +141,15 @@ void __init init_IRQ(void)#ifdef CONFIG_OF irqchip_init ();#else +#ifdef CONFIG_HAVE_SMP +xtensa_mx_init_legacy (NULL ); +#else xtensa_pic_init_legacy (NULL );#endif +#endif + +#ifdef CONFIG_SMP +ipi_init (); +#endif variant_init_irq (); }
arch/xtensa/kernel/mxhead.S new file +85 -0
85 lines not on this page · raw message
arch/xtensa/kernel/setup.c +47 -19
109 lines not on this page · raw message
arch/xtensa/kernel/smp.c new file +465 -0
465 lines not on this page · raw message
arch/xtensa/kernel/traps.c +25 -8
@@ -157,7 +157,7 @@ COPROCESSOR(7),* 2. it is a temporary memory buffer for the exception handlers. */ -unsigned long exc_table[EXC_TABLE_SIZE /4 ]; +DEFINE_PER_CPU(unsigned long, exc_table[EXC_TABLE_SIZE/4]);void die (const char *,struct pt_regs *,long );
@@ -313,17 +313,31 @@ do_debug(struct pt_regs *regs) } +static void set_handler (int idx,void *handler) +{ +unsigned int cpu; + +for_each_possible_cpu (cpu) +per_cpu (exc_table, cpu)[idx] = (unsigned long )handler; +} +/* Set exception C handler - for temporary use when probing exceptions */ void *__init trap_set_handler (int cause,void *handler) { -unsigned long *entry = &exc_table[EXC_TABLE_DEFAULT /4 + cause]; -void *previous = (void *)*entry; - *entry = (unsigned long )handler; +void *previous = (void *)per_cpu (exc_table,0 )[ +EXC_TABLE_DEFAULT /4 + cause]; +set_handler (EXC_TABLE_DEFAULT /4 + cause, handler);return previous; } +static void __init trap_init_excsave (void ) +{ +unsigned long excsave1 = (unsigned long )this_cpu_ptr (exc_table); + __asm__ __volatile__("wsr %0, excsave1\n" : :"a" (excsave1)); +} +/* * Initialize dispatch tables. *
@@ -337,8 +351,6 @@ void * __init trap_set_handler(int cause, void *handler)* See vectors.S for more details. */ -#define set_handler (idx,handler) (exc_table[idx] = (unsigned long) (handler)) -void __init trap_init (void ) {int i;
@@ -368,10 +380,15 @@ void __init trap_init(void) }/* Initialize EXCSAVE_1 to hold the address of the exception table. */ +trap_init_excsave (); +} - i = (unsigned long )exc_table; - __asm__ __volatile__("wsr %0, excsave1\n" : :"a" (i)); +#ifdef CONFIG_SMP +void __init secondary_trap_init (void ) +{ +trap_init_excsave (); } +#endif /* * This function dumps the current valid window frame and other base registers.
arch/xtensa/kernel/vmlinux.lds.S +26 -0
@@ -165,6 +165,13 @@ SECTIONS .DoubleExceptionVector.text); RELOCATE_ENTRY(_DebugInterruptVector_text, .DebugInterruptVector.text); +#if defined(CONFIG_SMP) + RELOCATE_ENTRY(_SecondaryResetVector_literal, + .SecondaryResetVector.literal); + RELOCATE_ENTRY(_SecondaryResetVector_text, + .SecondaryResetVector.text); +#endif + __boot_reloc_table_end = ABSOLUTE(.) ;
@@ -272,6 +279,25 @@ SECTIONS .DoubleExceptionVector.literal) . = (LOADADDR( .DoubleExceptionVector.text ) + SIZEOF( .DoubleExceptionVector.text ) + 3) & ~ 3; + +#if defined(CONFIG_SMP) + + SECTION_VECTOR (_SecondaryResetVector_literal, + .SecondaryResetVector.literal, + RESET_VECTOR1_VADDR - 4, + SIZEOF(.DoubleExceptionVector.text), + .DoubleExceptionVector.text) + + SECTION_VECTOR (_SecondaryResetVector_text, + .SecondaryResetVector.text, + RESET_VECTOR1_VADDR, + 4, + .SecondaryResetVector.literal) + + . = LOADADDR(.SecondaryResetVector.text)+SIZEOF(.SecondaryResetVector.text); + +#endif + . = ALIGN(PAGE_SIZE); __init_end = .;
arch/xtensa/mm/cache.c +3 -4
@@ -118,7 +118,7 @@ void flush_dcache_page(struct page *page)* For now, flush the whole cache. FIXME?? */ -void flush_cache_range (struct vm_area_struct * vma, +void local_flush_cache_range (struct vm_area_struct *vma,unsigned long start,unsigned long end) {__flush_invalidate_dcache_all ();
@@ -132,7 +132,7 @@ void flush_cache_range(struct vm_area_struct* vma,* alias versions of the cache flush functions. */ -void flush_cache_page (struct vm_area_struct * vma,unsigned long address, +void local_flush_cache_page (struct vm_area_struct *vma,unsigned long address,unsigned long pfn) {/* Note that we have to use the 'alias' address to avoid multi-hit */
@@ -159,8 +159,7 @@ update_mmu_cache(struct vm_area_struct * vma, unsigned long addr, pte_t *ptep)/* Invalidate old entry in TLBs */ -invalidate_itlb_mapping (addr); -invalidate_dtlb_mapping (addr); +flush_tlb_page (vma, addr);#if (DCACHE_WAY_SIZE >PAGE_SIZE ) &&XCHAL_DCACHE_IS_WRITEBACK
arch/xtensa/mm/fault.c +1 -1
@@ -21,7 +21,7 @@#include <asm/uaccess.h> #include <asm/pgalloc.h> -unsigned long asid_cache =ASID_USER_FIRST ; +DEFINE_PER_CPU(unsigned long, asid_cache) = ASID_USER_FIRST;void bad_page_fault (struct pt_regs *,unsigned long ,int );#undef DEBUG_PAGE_FAULT
arch/xtensa/mm/mmu.c +2 -2
@@ -22,7 +22,7 @@ void __init paging_init(void)/* * Flush the mmu and reset associated register to default values. */ -void __init init_mmu (void ) +void init_mmu (void ) {#if !(XCHAL_HAVE_PTP_MMU &&XCHAL_HAVE_SPANNING_WAY )/*
@@ -37,7 +37,7 @@ void __init init_mmu(void)set_itlbcfg_register (0 );set_dtlbcfg_register (0 );#endif -flush_tlb_all (); +local_flush_tlb_all ();/* Set rasid register to a known value. */
arch/xtensa/mm/tlb.c +22 -15
@@ -48,7 +48,7 @@ static inline void __flush_dtlb_all (void) } -void flush_tlb_all (void ) +void local_flush_tlb_all (void ) {__flush_itlb_all ();__flush_dtlb_all ();
@@ -60,19 +60,23 @@ void flush_tlb_all (void)* a new context will be assigned to it. */ -void flush_tlb_mm (struct mm_struct *mm) +void local_flush_tlb_mm (struct mm_struct *mm) { +int cpu =smp_processor_id (); +if (mm == current->active_mm) {unsigned long flags;local_irq_save (flags); -__get_new_mmu_context (mm); -__load_mmu_context (mm); + mm->context.asid[cpu] =NO_CONTEXT ; +activate_context (mm, cpu);local_irq_restore (flags); + }else { + mm->context.asid[cpu] =NO_CONTEXT ; + mm->context.cpu =-1 ; } -else - mm->context =0 ; } +#define _ITLB_ENTRIES (ITLB_ARF_WAYS << XCHAL_ITLB_ARF_ENTRIES_LOG2)#define _DTLB_ENTRIES (DTLB_ARF_WAYS << XCHAL_DTLB_ARF_ENTRIES_LOG2)#if _ITLB_ENTRIES > _DTLB_ENTRIES
@@ -81,24 +85,26 @@ void flush_tlb_mm(struct mm_struct *mm)# define _TLB_ENTRIES _DTLB_ENTRIES#endif -void flush_tlb_range (struct vm_area_struct *vma, -unsigned long start,unsigned long end) +void local_flush_tlb_range (struct vm_area_struct *vma, +unsigned long start,unsigned long end) { +int cpu =smp_processor_id ();struct mm_struct *mm = vma->vm_mm;unsigned long flags; -if (mm->context ==NO_CONTEXT ) +if (mm->context.asid[cpu] ==NO_CONTEXT )return ;#if 0 printk ("[tlbrange<%02lx,%08lx,%08lx>]\n" , - (unsigned long )mm->context, start, end); + (unsigned long )mm->context.asid[cpu], start, end);#endif local_irq_save (flags);if (end-start + (PAGE_SIZE -1 ) <= _TLB_ENTRIES <<PAGE_SHIFT ) {int oldpid =get_rasid_register (); -set_rasid_register (ASID_INSERT (mm->context)); + +set_rasid_register (ASID_INSERT (mm->context.asid[cpu])); start &=PAGE_MASK ;if (vma->vm_flags &VM_EXEC )while (start < end) {
@@ -114,24 +120,25 @@ void flush_tlb_range (struct vm_area_struct *vma,set_rasid_register (oldpid); }else { -flush_tlb_mm (mm); +local_flush_tlb_mm (mm); }local_irq_restore (flags); } -void flush_tlb_page (struct vm_area_struct *vma,unsigned long page) +void local_flush_tlb_page (struct vm_area_struct *vma,unsigned long page) { +int cpu =smp_processor_id ();struct mm_struct * mm = vma->vm_mm;unsigned long flags;int oldpid; -if (mm->context ==NO_CONTEXT ) +if (mm->context.asid[cpu] ==NO_CONTEXT )return ;local_irq_save (flags); oldpid =get_rasid_register (); -set_rasid_register (ASID_INSERT (mm->context)); +set_rasid_register (ASID_INSERT (mm->context.asid[cpu]));if (vma->vm_flags &VM_EXEC )invalidate_itlb_mapping (page);
arch/xtensa/platforms/xtfpga/include/platform/hardware.h +1 -1
@@ -26,7 +26,7 @@/* Default assignment of LX60 devices to external interrupts. */ -#ifdef CONFIG_ARCH_HAS_SMP +#ifdef CONFIG_XTENSA_MX #define DUART16552_INTNUM XCHAL_EXTINT3_NUM#define OETH_IRQ XCHAL_EXTINT4_NUM#else
Signature · 1 line
1.8.1.4
Max Filippov
maintainerPATCH 16/17 xtensa: add Three Core HiFi-2 MX Variant.
In reply to Max FilippovFrom: Piet Delaney <[email protected]>
This variant is equipped with MX and is capable of running SMP linux.
--- arch/xtensa/Kconfig | 7 + arch/xtensa/Makefile | 1 + .../test_mmuhifi_c3/include/variant/core.h | 384 +++++++++++++++++++++ .../test_mmuhifi_c3/include/variant/tie-asm.h | 183 ++++++++++ .../variants/test_mmuhifi_c3/include/variant/tie.h | 141 ++++++++ 5 files changed, 716 insertions(+) create mode 100644 arch/xtensa/variants/test_mmuhifi_c3/include/variant/core.h create mode 100644 arch/xtensa/variants/test_mmuhifi_c3/include/variant/tie-asm.h create mode 100644 arch/xtensa/variants/test_mmuhifi_c3/include/variant/tie.h
arch/xtensa/Kconfig +7 -0
@@ -89,6 +89,13 @@ config XTENSA_VARIANT_DC233C help This variant refers to Tensilica's Diamond 233L Standard core Rev.C (LE). +config XTENSA_VARIANT_TEST_MMUHIFI_C3 + bool "test_mmuhifi_c3 - Experimental 3 Core SMP HiFi-2 with a V2 MMU; Extension of a Diamond DC_D_330HiFi" + select MMU + select MAY_HAVE_SMP + help + This variant refers to Tensilica's Diamond 330HiFi 3 core SMP cluster. + config XTENSA_VARIANT_S6000 bool "s6000 - Stretch software configurable processor" select VARIANT_IRQ_SWITCH
arch/xtensa/Makefile +1 -0
@@ -16,6 +16,7 @@ variant-$(CONFIG_XTENSA_VARIANT_FSF) := fsf variant-$(CONFIG_XTENSA_VARIANT_DC232B) := dc232b variant-$(CONFIG_XTENSA_VARIANT_DC233C) := dc233c +variant-$(CONFIG_XTENSA_VARIANT_TEST_MMUHIFI_C3) := test_mmuhifi_c3 variant-$(CONFIG_XTENSA_VARIANT_S6000) := s6000 variant-$(CONFIG_XTENSA_VARIANT_LINUX_CUSTOM) := custom
arch/xtensa/variants/test_mmuhifi_c3/include/variant/core.h new file +384 -0
384 lines not on this page · raw message
arch/xtensa/variants/test_mmuhifi_c3/include/variant/tie-asm.h new file +183 -0
183 lines not on this page · raw message
arch/xtensa/variants/test_mmuhifi_c3/include/variant/tie.h new file +141 -0
141 lines not on this page · raw message
Signature · 1 line
1.8.1.4
Max Filippov
maintainerPATCH 17/17 xtensa: implement CPU hotplug
In reply to Max Filippov--- arch/xtensa/Kconfig | 9 +++ arch/xtensa/include/asm/irq.h | 1 + arch/xtensa/include/asm/smp.h | 9 +++ arch/xtensa/kernel/head.S | 51 ++++++++++++++++- arch/xtensa/kernel/irq.c | 49 ++++++++++++++++ arch/xtensa/kernel/setup.c | 1 + arch/xtensa/kernel/smp.c | 128 +++++++++++++++++++++++++++++++++++++++++- arch/xtensa/kernel/traps.c | 4 +- 8 files changed, 248 insertions(+), 4 deletions(-)
arch/xtensa/Kconfig +9 -0
@@ -147,6 +147,15 @@ config NR_CPUS range 2 32 default "4" +config HOTPLUG_CPU + bool "Enable CPU hotplug support" + depends on SMP + help + Say Y here to allow turning CPUs off and on. CPUs can be + controlled through /sys/devices/system/cpu. + + Say N if you want to disable CPU hotplug. + config MATH_EMULATION bool "Math emulation" help
arch/xtensa/include/asm/irq.h +1 -0
@@ -45,6 +45,7 @@ static __inline__ int irq_canonicalize(int irq)struct irqaction ;struct irq_domain ; +void migrate_irqs (void );int xtensa_irq_domain_xlate (const u32 *intspec,unsigned int intsize,unsigned long int_irq,unsigned long ext_irq,unsigned long *out_hwirq,unsigned int *out_type);
arch/xtensa/include/asm/smp.h +9 -0
@@ -29,6 +29,15 @@ void ipi_init(void);struct seq_file ;void show_ipi_list (struct seq_file *p,int prec); +#ifdef CONFIG_HOTPLUG_CPU + +void __cpu_die (unsigned int cpu); +int __cpu_disable (void ); +void cpu_die (void ); +void cpu_restart (void ); + +#endif /* CONFIG_HOTPLUG_CPU */ +#endif /* CONFIG_SMP */ #endif /* _XTENSA_SMP_H */
arch/xtensa/kernel/head.S +50 -1
63 lines not on this page · raw message
arch/xtensa/kernel/irq.c +49 -0
52 lines not on this page · raw message
arch/xtensa/kernel/setup.c +1 -0
@@ -554,6 +554,7 @@ static int __init topology_init(void)for_each_possible_cpu (i) {struct cpu *cpu = &per_cpu (cpu_data, i); + cpu->hotpluggable = !!i;register_cpu (cpu, i); }
arch/xtensa/kernel/smp.c +127 -1
161 lines not on this page · raw message
arch/xtensa/kernel/traps.c +2 -2
@@ -332,7 +332,7 @@ void * __init trap_set_handler(int cause, void *handler) } -static void __init trap_init_excsave (void ) +static void trap_init_excsave (void ) {unsigned long excsave1 = (unsigned long )this_cpu_ptr (exc_table); __asm__ __volatile__("wsr %0, excsave1\n" : :"a" (excsave1));
@@ -384,7 +384,7 @@ void __init trap_init(void) }#ifdef CONFIG_SMP -void __init secondary_trap_init (void ) +void secondary_trap_init (void ) {trap_init_excsave (); }
Signature · 1 line
1.8.1.4
Chris Zankel
maintainerHi Max,
I have added the SMP patch-set to the for_next tree (for the time being). Let me know if you wanted it in for this release or if you think it's not ready for prime time. Note that I skipped the variant configuration as it is a lot of code and it is more of a 'test' configuration.
Thanks,
-Chris
Quoted 138 lines · Max Filippov
Hi Chris,
this series adds SMP support for xtensa.
There's a number of trivial cleanups:
xtensa: removeNO_IRQdefinitions
xtensa: fix build warning in 64-bit build environment
xtensa: fix build warning from gcc-4.7.2
xtensa: callcheck_s32c1iaftertrap_init
xtensa: moveinit_mmudeclaration tommu_context.ha couple of fixes for spinlocks:
xtensa: fix arch spinlock function names
xtensa: fix__delayfor small loop countthree fixes for the clocksources, with these we get high precision timers usable in SMP and IRQ time accounting:
xtensa: mark ccount as continuous clocksource
xtensa: update clockevent setup for SMP
xtensa: enableHAVE_IRQ_TIME_ACCOUNTINGfixes and rearrangement of IRQ handling code and a new driver for MX interrupt distributor:
xtensa: move built-in PIC todrivers/irqchip
xtensa: clean up do_interrupt/do_IRQ
xtensa: clear timer IRQ unconditionally in its handler
xtensa: add MX irqchipand finally SMP and hotplug CPU support and a sample SMP-capable CPU variant:
xtensa: add SMP support
xtensa: implement CPU hotplug
xtensa: add Three Core HiFi-2 MX Variant.Please review.
You can pull these changes from my git tree,
the following changes since commit61e6cfa80de5760bbe406f4e815b7739205754d2:Linux 3.12-rc5 (2013-10-13 15:41:28 -0700)are available in the git repository at:
git://github.com/jcmvbkbc/linux-xtensa.git tags/xtensa-smp-20131017for you to fetch changes up to
4862c5ae570b8a40275f413dfa2e3f184ecfa1d9:xtensa: implement CPU hotplug (2013-10-17 01:50:17 +0400)----------------------------------------------------------------
Clean up minor warnings.
Fix spinlock function names, provide missing definitions. Extract PIC intodrivers/irqchip.
Clean up IRQ handling.
Add MX interrupt distributor.
Add SMP support.
Add hotplug CPU support.
Add SMP-capable core variant.----------------------------------------------------------------
Baruch Siach (1):
xtensa: mark ccount as continuous clocksourceMax Filippov (15):
xtensa: removeNO_IRQdefinitions
xtensa: fix build warning in 64-bit build environment
xtensa: fix build warning from gcc-4.7.2
xtensa: fix arch spinlock function names
xtensa: fix__delayfor small loop count
xtensa: enableHAVE_IRQ_TIME_ACCOUNTING
xtensa: update clockevent setup for SMP
xtensa: callcheck_s32c1iaftertrap_init
xtensa: moveinit_mmudeclaration tommu_context.h
xtensa: move built-in PIC todrivers/irqchip
xtensa: clean up do_interrupt/do_IRQ
xtensa: clear timer IRQ unconditionally in its handler
xtensa: add MX irqchip
xtensa: add SMP support
xtensa: implement CPU hotplugPiet Delaney (1):
xtensa: add Three Core HiFi-2 MX Variant.arch/xtensa/Kconfig | 54 +- arch/xtensa/Makefile | 1 + arch/xtensa/include/asm/barrier.h | 4 +- arch/xtensa/include/asm/bitops.h | 8 +- arch/xtensa/include/asm/cacheflush.h | 40 +- arch/xtensa/include/asm/delay.h | 9 +- arch/xtensa/include/asm/irq.h | 9 + arch/xtensa/include/asm/mmu.h | 10 +- arch/xtensa/include/asm/mmu_context.h | 106 ++-- arch/xtensa/include/asm/mxregs.h | 46 ++ arch/xtensa/include/asm/processor.h | 20 + arch/xtensa/include/asm/ptrace.h | 8 + arch/xtensa/include/asm/smp.h | 38 +- arch/xtensa/include/asm/spinlock.h | 31 +- arch/xtensa/include/asm/spinlock_types.h | 20 + arch/xtensa/include/asm/timex.h | 14 +- arch/xtensa/include/asm/tlbflush.h | 42 +- arch/xtensa/include/asm/traps.h | 1 + arch/xtensa/include/asm/vectors.h | 4 + arch/xtensa/kernel/Makefile | 1 + arch/xtensa/kernel/head.S | 181 +++++-- arch/xtensa/kernel/irq.c | 207 ++++---- arch/xtensa/kernel/mxhead.S | 85 +++ arch/xtensa/kernel/setup.c | 92 ++-- arch/xtensa/kernel/smp.c | 591 +++++++++++++++++++++ arch/xtensa/kernel/time.c | 56 +- arch/xtensa/kernel/traps.c | 56 +- arch/xtensa/kernel/vmlinux.lds.S | 26 + arch/xtensa/mm/cache.c | 7 +- arch/xtensa/mm/fault.c | 2 +- arch/xtensa/mm/misc.S | 4 +- arch/xtensa/mm/mmu.c | 4 +- arch/xtensa/mm/tlb.c | 37 +- .../platforms/xtfpga/include/platform/hardware.h | 6 +- arch/xtensa/variants/s6000/include/variant/irq.h | 1 - .../test_mmuhifi_c3/include/variant/core.h | 384 +++++++++++++ .../test_mmuhifi_c3/include/variant/tie-asm.h | 183 +++++++ .../variants/test_mmuhifi_c3/include/variant/tie.h | 141 +++++ drivers/irqchip/Kconfig | 4 + drivers/irqchip/Makefile | 2 + drivers/irqchip/irq-xtensa-mx.c | 166 ++++++ drivers/irqchip/irq-xtensa-pic.c | 108 ++++ include/linux/irqchip/xtensa-mx.h | 17 + include/linux/irqchip/xtensa-pic.h | 18 + 44 files changed, 2455 insertions(+), 389 deletions(-)create mode 100644
arch/xtensa/include/asm/mxregs.h
create mode 100644arch/xtensa/include/asm/spinlock_types.h
create mode 100644arch/xtensa/kernel/mxhead.S
create mode 100644arch/xtensa/kernel/smp.c
create mode 100644arch/xtensa/variants/test_mmuhifi_c3/include/variant/core.hcreate mode 100644arch/xtensa/variants/test_mmuhifi_c3/include/variant/tie-asm.hcreate mode 100644arch/xtensa/variants/test_mmuhifi_c3/include/variant/tie.hcreate mode 100644drivers/irqchip/irq-xtensa-mx.c
create mode 100644drivers/irqchip/irq-xtensa-pic.c
create mode 100644include/linux/irqchip/xtensa-mx.h
create mode 100644include/linux/irqchip/xtensa-pic.h
Max Filippov
maintainerHi Chris,
Quoted 6 lines · Chris Zankel
Hi Max,
I have added the SMP patch-set to the
for_nexttree (for the time being). Let me know if you wanted it in for this release or if you think it's not ready for prime time. Note that I skipped the variant configuration as it is a lot of code and it is more of a 'test' configuration.
Cool (: I currently only have a small optimization fix for the MX interrupt controller, otherwise I think it's good. Should I send a follow-up patch or respin the whole series?
Quoted 147 lines · Max Filippov
Quoted 145 lines
Hi Chris,
this series adds SMP support for xtensa.
There's a number of trivial cleanups:
xtensa: removeNO_IRQdefinitions
xtensa: fix build warning in 64-bit build environment
xtensa: fix build warning from gcc-4.7.2
xtensa: callcheck_s32c1iaftertrap_init
xtensa: moveinit_mmudeclaration tommu_context.ha couple of fixes for spinlocks:
xtensa: fix arch spinlock function names
xtensa: fix__delayfor small loop countthree fixes for the clocksources, with these we get high precision timers usable in SMP and IRQ time accounting:
xtensa: mark ccount as continuous clocksource
xtensa: update clockevent setup for SMP
xtensa: enableHAVE_IRQ_TIME_ACCOUNTINGfixes and rearrangement of IRQ handling code and a new driver for MX interrupt distributor:
xtensa: move built-in PIC todrivers/irqchip
xtensa: clean up do_interrupt/do_IRQ
xtensa: clear timer IRQ unconditionally in its handler
xtensa: add MX irqchipand finally SMP and hotplug CPU support and a sample SMP-capable CPU variant:
xtensa: add SMP support
xtensa: implement CPU hotplug
xtensa: add Three Core HiFi-2 MX Variant.Please review.
You can pull these changes from my git tree,
the following changes since commit61e6cfa80de5760bbe406f4e815b7739205754d2:Linux 3.12-rc5 (2013-10-13 15:41:28 -0700)are available in the git repository at:
git://github.com/jcmvbkbc/linux-xtensa.git tags/xtensa-smp-20131017for you to fetch changes up to
4862c5ae570b8a40275f413dfa2e3f184ecfa1d9:xtensa: implement CPU hotplug (2013-10-17 01:50:17 +0400)----------------------------------------------------------------
Clean up minor warnings.
Fix spinlock function names, provide missing definitions. Extract PIC intodrivers/irqchip.
Clean up IRQ handling.
Add MX interrupt distributor.
Add SMP support.
Add hotplug CPU support.
Add SMP-capable core variant.----------------------------------------------------------------
Baruch Siach (1):
xtensa: mark ccount as continuous clocksourceMax Filippov (15):
xtensa: removeNO_IRQdefinitions
xtensa: fix build warning in 64-bit build environment
xtensa: fix build warning from gcc-4.7.2
xtensa: fix arch spinlock function names
xtensa: fix__delayfor small loop count
xtensa: enableHAVE_IRQ_TIME_ACCOUNTING
xtensa: update clockevent setup for SMP
xtensa: callcheck_s32c1iaftertrap_init
xtensa: moveinit_mmudeclaration tommu_context.h
xtensa: move built-in PIC todrivers/irqchip
xtensa: clean up do_interrupt/do_IRQ
xtensa: clear timer IRQ unconditionally in its handler
xtensa: add MX irqchip
xtensa: add SMP support
xtensa: implement CPU hotplugPiet Delaney (1):
xtensa: add Three Core HiFi-2 MX Variant.arch/xtensa/Kconfig | 54 +- arch/xtensa/Makefile | 1 + arch/xtensa/include/asm/barrier.h | 4 +- arch/xtensa/include/asm/bitops.h | 8 +- arch/xtensa/include/asm/cacheflush.h | 40 +- arch/xtensa/include/asm/delay.h | 9 +- arch/xtensa/include/asm/irq.h | 9 + arch/xtensa/include/asm/mmu.h | 10 +- arch/xtensa/include/asm/mmu_context.h | 106 ++-- arch/xtensa/include/asm/mxregs.h | 46 ++ arch/xtensa/include/asm/processor.h | 20 + arch/xtensa/include/asm/ptrace.h | 8 + arch/xtensa/include/asm/smp.h | 38 +- arch/xtensa/include/asm/spinlock.h | 31 +- arch/xtensa/include/asm/spinlock_types.h | 20 + arch/xtensa/include/asm/timex.h | 14 +- arch/xtensa/include/asm/tlbflush.h | 42 +- arch/xtensa/include/asm/traps.h | 1 + arch/xtensa/include/asm/vectors.h | 4 + arch/xtensa/kernel/Makefile | 1 + arch/xtensa/kernel/head.S | 181 +++++-- arch/xtensa/kernel/irq.c | 207 ++++---- arch/xtensa/kernel/mxhead.S | 85 +++ arch/xtensa/kernel/setup.c | 92 ++-- arch/xtensa/kernel/smp.c | 591 +++++++++++++++++++++ arch/xtensa/kernel/time.c | 56 +- arch/xtensa/kernel/traps.c | 56 +- arch/xtensa/kernel/vmlinux.lds.S | 26 + arch/xtensa/mm/cache.c | 7 +- arch/xtensa/mm/fault.c | 2 +- arch/xtensa/mm/misc.S | 4 +- arch/xtensa/mm/mmu.c | 4 +- arch/xtensa/mm/tlb.c | 37 +- .../platforms/xtfpga/include/platform/hardware.h | 6 +- arch/xtensa/variants/s6000/include/variant/irq.h | 1 - .../test_mmuhifi_c3/include/variant/core.h | 384 +++++++++++++ .../test_mmuhifi_c3/include/variant/tie-asm.h | 183 +++++++ .../variants/test_mmuhifi_c3/include/variant/tie.h | 141 +++++ drivers/irqchip/Kconfig | 4 + drivers/irqchip/Makefile | 2 + drivers/irqchip/irq-xtensa-mx.c | 166 ++++++ drivers/irqchip/irq-xtensa-pic.c | 108 ++++ include/linux/irqchip/xtensa-mx.h | 17 + include/linux/irqchip/xtensa-pic.h | 18 + 44 files changed, 2455 insertions(+), 389 deletions(-)create mode 100644
arch/xtensa/include/asm/mxregs.hcreate mode 100644arch/xtensa/include/asm/spinlock_types.hcreate mode 100644arch/xtensa/kernel/mxhead.Screate mode 100644arch/xtensa/kernel/smp.c
create mode 100644arch/xtensa/variants/test_mmuhifi_c3/include/variant/core.h
create mode 100644arch/xtensa/variants/test_mmuhifi_c3/include/variant/tie-asm.h
create mode 100644arch/xtensa/variants/test_mmuhifi_c3/include/variant/tie.h
create mode 100644drivers/irqchip/irq-xtensa-mx.ccreate mode 100644drivers/irqchip/irq-xtensa-pic.ccreate mode 100644include/linux/irqchip/xtensa-mx.hcreate mode 100644include/linux/irqchip/xtensa-pic.h
Signature · 2 lines
Thanks. -- Max
czankel
maintainerQuoted 5 lines · Max Filippov
Hi Chris,
Quoted 2 lines · Chris Zankel
Hi Max,
Quoted 7 lines
Quoted 4 lines
I have added the SMP patch-set to the
for_nexttree (for the time being). Let me know if you wanted it in for this release or if you think it's not ready for prime time. Note that I skipped the variant configuration as it is a lot of code and it is more of a 'test' configuration.Cool (: I currently only have a small optimization fix for the MX interrupt controller, otherwise I think it's good. Should I send a follow-up patch or respin the whole series?
Feel free to just send me the patch, patch to the patch, or whatever is easiest for you.
Thanks,
-Chris
Max Filippov
maintainerPATCH v2 14/17 xtensa: add MX irqchip
MX is an interrupt distributor used in some SMP-capable xtensa configurations.
---
Hi Chris,
this is the updated version of the MX irqchip patch, you will also find it in the SMP series tagged xtensa-smp-20131201 in my xtensa tree.
Changes v1 -> v2:
- don't disable preemption in the else clause of xtensa_mx_irq_[un]mask as these functions should be always called with preemption disabled.
arch/xtensa/include/asm/irq.h | 1 + arch/xtensa/include/asm/mxregs.h | 46 ++++++++++ arch/xtensa/include/asm/processor.h | 20 +++++ arch/xtensa/kernel/irq.c | 8 ++ drivers/irqchip/Kconfig | 4 + drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-xtensa-mx.c | 164 ++++++++++++++++++++++++++++++++++++ include/linux/irqchip/xtensa-mx.h | 17 ++++ 8 files changed, 261 insertions(+) create mode 100644 arch/xtensa/include/asm/mxregs.h create mode 100644 drivers/irqchip/irq-xtensa-mx.c create mode 100644 include/linux/irqchip/xtensa-mx.h
arch/xtensa/include/asm/irq.h +1 -0
@@ -50,5 +50,6 @@ int xtensa_irq_domain_xlate(const u32 *intspec, unsigned int intsize, unsigned long *out_hwirq, unsigned int *out_type);int xtensa_irq_map (struct irq_domain *d,unsigned int irq,irq_hw_number_t hw);unsigned xtensa_map_ext_irq (unsigned ext_irq); +unsigned xtensa_get_ext_irq_no (unsigned irq);#endif /* _XTENSA_IRQ_H */
arch/xtensa/include/asm/mxregs.h new file +46 -0
46 lines not on this page · raw message
arch/xtensa/include/asm/processor.h +20 -0
@@ -191,5 +191,25 @@ extern unsigned long get_wchan(struct task_struct *p);#define set_sr (x,sr) ({unsigned int v=(unsigned int)x; WSR(v,sr);})#define get_sr (sr) ({unsigned int v; RSR(v,sr); v; }) +#ifndef XCHAL_HAVE_EXTERN_REGS +#define XCHAL_HAVE_EXTERN_REGS 0 +#endif + +#if XCHAL_HAVE_EXTERN_REGS + +static inline void set_er (unsigned long value,unsigned long addr) +{ + asmvolatile ("wer %0, %1" : :"a" (value),"a" (addr) :"memory" ); +} + +static inline unsigned long get_er (unsigned long addr) +{ + registerunsigned long value; + asmvolatile ("rer %0, %1" :"=a" (value) :"a" (addr) :"memory" ); +return value; +} + +#endif /* XCHAL_HAVE_EXTERN_REGS */ +#endif /* __ASSEMBLY__ */ #endif /* _XTENSA_PROCESSOR_H */
arch/xtensa/kernel/irq.c +8 -0
@@ -123,6 +123,14 @@ unsigned xtensa_map_ext_irq(unsigned ext_irq)return XCHAL_NUM_INTERRUPTS ; } +unsigned xtensa_get_ext_irq_no (unsigned irq) +{ +unsigned mask = (XCHAL_INTTYPE_MASK_EXTERN_EDGE | +XCHAL_INTTYPE_MASK_EXTERN_LEVEL ) & + ((1u << irq) -1 ); +return hweight32 (mask); +} +void __init init_IRQ (void ) {#ifdef CONFIG_OF
drivers/irqchip/Kconfig +4 -0
@@ -61,3 +61,7 @@ config VERSATILE_FPGA_IRQ_NR int default 4 depends on VERSATILE_FPGA_IRQ + +config XTENSA_MX + bool + select IRQ_DOMAIN
drivers/irqchip/Makefile +1 -0
@@ -23,3 +23,4 @@ obj-$(CONFIG_VERSATILE_FPGA_IRQ) += irq-versatile-fpga.o obj-$(CONFIG_ARCH_VT8500) += irq-vt8500.o obj-$(CONFIG_TB10X_IRQC) += irq-tb10x.o obj-$(CONFIG_XTENSA) += irq-xtensa-pic.o +obj-$(CONFIG_XTENSA_MX) += irq-xtensa-mx.o
drivers/irqchip/irq-xtensa-mx.c new file +164 -0
164 lines not on this page · raw message
include/linux/irqchip/xtensa-mx.h new file +17 -0
@@ -0,0 +1,17 @@ +/* +* Xtensa MX interrupt distributor +* +* Copyright (C) 2002 - 2013 Tensilica, Inc. +* +* This file is subject to the terms and conditions of the GNU General Public +* License. See the file "COPYING" in the main directory of this archive +* for more details. +*/ + +#ifndef __LINUX_IRQCHIP_XTENSA_MX_H +#define __LINUX_IRQCHIP_XTENSA_MX_H + +struct device_node ; +int xtensa_mx_init_legacy (struct device_node *interrupt_parent); + +#endif /* __LINUX_IRQCHIP_XTENSA_MX_H */
Signature · 1 line
1.8.1.4
Re: [Linux-Xtensa] [PATCHv2 14/17] xtensa: add MX irqchip
Hi Max,
Quoted 5 lines · Max Filippov
MX is an interrupt distributor used in some SMP-capable xtensa configurations.
Signed-off-by Max Filippov <[email protected]>---
[...]
Quoted 1 line
+IRQCHIP_DECLARE(xtensa_mx_irq_chip, "xtensa,mx",
xtensa_mx_init);
This should probably better named "cdns,xtensa-mx", according to the ePAPR 1.1 recommendation.
baruch
Signature · 3 lines
http://baruch.siach.name/blog/ ~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- [email protected] - tel: +972.2.679.5364, http://www.tkos.co.il -Max Filippov
maintainerRe: [Linux-Xtensa] [PATCHv2 14/17] xtensa: add MX irqchip
Quoted 9 lines · Baruch Siach
Hi Max,
Quoted 5 lines · Max Filippov
MX is an interrupt distributor used in some SMP-capable xtensa configurations.
Signed-off-by Max Filippov <[email protected]>---
Quoted 6 lines
[...]
Quoted 1 line
+IRQCHIP_DECLARE(xtensa_mx_irq_chip, "xtensa,mx",
xtensa_mx_init);This should probably better named "cdns,xtensa-mx", according to the ePAPR 1.1 recommendation.
Right, I've sent an update for both MX and PIC xtensa irqchips.
Signature · 2 lines
Thanks. -- Max