From 6b3087c64a92a36ae20d33479b4df6d7afc910d4 Mon Sep 17 00:00:00 2001 From: Graf Yang Date: Wed, 7 Jan 2009 23:14:39 +0800 Subject: Blackfin arch: SMP supporting patchset: Blackfin header files and machine common code Blackfin dual core BF561 processor can support SMP like features. https://docs.blackfin.uclinux.org/doku.php?id=linux-kernel:smp-like In this patch, we provide SMP extend to Blackfin header files and machine common code Signed-off-by: Graf Yang Signed-off-by: Bryan Wu --- arch/blackfin/include/asm/processor.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'arch/blackfin/include/asm/processor.h') diff --git a/arch/blackfin/include/asm/processor.h b/arch/blackfin/include/asm/processor.h index e3e9b41fa8d..30703c75030 100644 --- a/arch/blackfin/include/asm/processor.h +++ b/arch/blackfin/include/asm/processor.h @@ -106,7 +106,8 @@ unsigned long get_wchan(struct task_struct *p); eip; }) #define KSTK_ESP(tsk) ((tsk) == current ? rdusp() : (tsk)->thread.usp) -#define cpu_relax() barrier() +#define cpu_relax() smp_mb() + /* Get the Silicon Revision of the chip */ static inline uint32_t __pure bfin_revid(void) @@ -137,7 +138,11 @@ static inline uint32_t __pure bfin_revid(void) static inline uint16_t __pure bfin_cpuid(void) { return (bfin_read_CHIPID() & CHIPID_FAMILY) >> 12; +} +static inline uint32_t __pure bfin_dspid(void) +{ + return bfin_read_DSPID(); } static inline uint32_t __pure bfin_compiled_revid(void) -- cgit v1.2.3-70-g09d2 From 2e8ca591479e7127c7a6406cfb54962afbd5a68e Mon Sep 17 00:00:00 2001 From: Bryan Wu Date: Tue, 18 Nov 2008 17:48:22 +0800 Subject: Blackfin arch: Use GPIO_BANKSIZE macro to replace const number 16 for GPIO_BANK_NUM macro caculating Signed-off-by: Bryan Wu --- arch/blackfin/include/asm/gpio.h | 4 ++-- arch/blackfin/include/asm/processor.h | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'arch/blackfin/include/asm/processor.h') diff --git a/arch/blackfin/include/asm/gpio.h b/arch/blackfin/include/asm/gpio.h index f8fe33b8bca..ec2ab465709 100644 --- a/arch/blackfin/include/asm/gpio.h +++ b/arch/blackfin/include/asm/gpio.h @@ -87,9 +87,9 @@ #define gpio_bank(x) ((x) >> 4) #define gpio_bit(x) (1<<((x) & 0xF)) #define gpio_sub_n(x) ((x) & 0xF) -#define GPIO_BANK_NUM DIV_ROUND_UP(MAX_BLACKFIN_GPIOS, 16) -#define GPIO_BANKSIZE 16 +#define GPIO_BANKSIZE 16 +#define GPIO_BANK_NUM DIV_ROUND_UP(MAX_BLACKFIN_GPIOS, GPIO_BANKSIZE) #define GPIO_0 0 #define GPIO_1 1 diff --git a/arch/blackfin/include/asm/processor.h b/arch/blackfin/include/asm/processor.h index 30703c75030..2cb0b8711fa 100644 --- a/arch/blackfin/include/asm/processor.h +++ b/arch/blackfin/include/asm/processor.h @@ -159,6 +159,8 @@ static inline uint32_t __pure bfin_compiled_revid(void) return 4; #elif defined(CONFIG_BF_REV_0_5) return 5; +#elif defined(CONFIG_BF_REV_0_6) + return 6; #elif defined(CONFIG_BF_REV_ANY) return 0xffff; #else -- cgit v1.2.3-70-g09d2 From a45d575f53c9ed2926840377e59aa19e2024ee87 Mon Sep 17 00:00:00 2001 From: Robin Getz Date: Wed, 7 Jan 2009 23:14:38 +0800 Subject: Blackfin arch: Add basic irq stack checking for Blackfin Signed-off-by: Robin Getz Signed-off-by: Bryan Wu --- arch/blackfin/Kconfig.debug | 16 ++++++++++++++++ arch/blackfin/include/asm/processor.h | 8 ++++++++ arch/blackfin/include/asm/thread_info.h | 1 + arch/blackfin/kernel/irqchip.c | 16 +++++++++++++++- 4 files changed, 40 insertions(+), 1 deletion(-) (limited to 'arch/blackfin/include/asm/processor.h') diff --git a/arch/blackfin/Kconfig.debug b/arch/blackfin/Kconfig.debug index 3ad25983ec9..bfd712ab125 100644 --- a/arch/blackfin/Kconfig.debug +++ b/arch/blackfin/Kconfig.debug @@ -2,6 +2,22 @@ menu "Kernel hacking" source "lib/Kconfig.debug" +config DEBUG_STACKOVERFLOW + bool "Check for stack overflows" + depends on DEBUG_KERNEL + help + This option will cause messages to be printed if free stack space + drops below a certain limit. + +config DEBUG_STACK_USAGE + bool "Enable stack utilization instrumentation" + depends on DEBUG_KERNEL + help + Enables the display of the minimum amount of free stack which each + task has ever had available in the sysrq-T output. + + This option will slow down process creation somewhat. + config HAVE_ARCH_KGDB def_bool y diff --git a/arch/blackfin/include/asm/processor.h b/arch/blackfin/include/asm/processor.h index 2cb0b8711fa..83d57a85b14 100644 --- a/arch/blackfin/include/asm/processor.h +++ b/arch/blackfin/include/asm/processor.h @@ -24,6 +24,14 @@ static inline void wrusp(unsigned long usp) __asm__ __volatile__("usp = %0;\n\t"::"da"(usp)); } +static inline unsigned long __get_SP(void) +{ + unsigned long sp; + + __asm__ __volatile__("%0 = sp;\n\t" : "=da"(sp)); + return sp; +} + /* * User space process size: 1st byte beyond user address space. * Fairly meaningless on nommu. Parts of user programs can be scattered diff --git a/arch/blackfin/include/asm/thread_info.h b/arch/blackfin/include/asm/thread_info.h index 642769329d1..1d380def241 100644 --- a/arch/blackfin/include/asm/thread_info.h +++ b/arch/blackfin/include/asm/thread_info.h @@ -44,6 +44,7 @@ */ #define THREAD_SIZE_ORDER 1 #define THREAD_SIZE 8192 /* 2 pages */ +#define STACK_WARN (THREAD_SIZE/8) #ifndef __ASSEMBLY__ diff --git a/arch/blackfin/kernel/irqchip.c b/arch/blackfin/kernel/irqchip.c index 5ad07525ea3..1624e112968 100644 --- a/arch/blackfin/kernel/irqchip.c +++ b/arch/blackfin/kernel/irqchip.c @@ -120,7 +120,21 @@ asmlinkage void asm_do_IRQ(unsigned int irq, struct pt_regs *regs) desc = &bad_irq_desc; irq_enter(); - +#ifdef CONFIG_DEBUG_STACKOVERFLOW + /* Debugging check for stack overflow: is there less than STACK_WARN free? */ + { + long sp; + + sp = __get_SP() & (THREAD_SIZE-1); + + if (unlikely(sp < (sizeof(struct thread_info) + STACK_WARN))) { + dump_stack(); + printk(KERN_EMERG "%s: possible stack overflow while handling irq %i " + " only %ld bytes free\n", + __func__, irq, sp - sizeof(struct thread_info)); + } + } +#endif generic_handle_irq(irq); /* If we're the only interrupt running (ignoring IRQ15 which is for -- cgit v1.2.3-70-g09d2 From cc92b870a779500f444419f27bf73c6c7660ff9c Mon Sep 17 00:00:00 2001 From: Sonic Zhang Date: Wed, 7 Jan 2009 23:14:38 +0800 Subject: Blackfin arch: disable pthread stack check for SMP at runtime Signed-off-by: Sonic Zhang Signed-off-by: Bryan Wu --- arch/blackfin/include/asm/l1layout.h | 2 ++ arch/blackfin/include/asm/processor.h | 11 +++++++++++ arch/blackfin/include/asm/system.h | 7 +++++++ arch/blackfin/include/asm/thread_info.h | 2 ++ 4 files changed, 22 insertions(+) (limited to 'arch/blackfin/include/asm/processor.h') diff --git a/arch/blackfin/include/asm/l1layout.h b/arch/blackfin/include/asm/l1layout.h index 06bb37f6c78..79dbefaa5be 100644 --- a/arch/blackfin/include/asm/l1layout.h +++ b/arch/blackfin/include/asm/l1layout.h @@ -8,6 +8,7 @@ #include +#ifndef CONFIG_SMP #ifndef __ASSEMBLY__ /* Data that is "mapped" into the process VM at the start of the L1 scratch @@ -28,5 +29,6 @@ struct l1_scratch_task_info get_l1_scratch_start()) #endif +#endif #endif diff --git a/arch/blackfin/include/asm/processor.h b/arch/blackfin/include/asm/processor.h index 83d57a85b14..0eece23b41c 100644 --- a/arch/blackfin/include/asm/processor.h +++ b/arch/blackfin/include/asm/processor.h @@ -65,6 +65,7 @@ struct thread_struct { * pass the data segment into user programs if it exists, * it can't hurt anything as far as I can tell */ +#ifndef CONFIG_SMP #define start_thread(_regs, _pc, _usp) \ do { \ set_fs(USER_DS); \ @@ -78,6 +79,16 @@ do { \ sizeof(*L1_SCRATCH_TASK_INFO)); \ wrusp(_usp); \ } while(0) +#else +#define start_thread(_regs, _pc, _usp) \ +do { \ + set_fs(USER_DS); \ + (_regs)->pc = (_pc); \ + if (current->mm) \ + (_regs)->p5 = current->mm->start_data; \ + wrusp(_usp); \ +} while (0) +#endif /* Forward declaration, a strange C thing */ struct task_struct; diff --git a/arch/blackfin/include/asm/system.h b/arch/blackfin/include/asm/system.h index aa7d87b62b2..812e6e6e2ce 100644 --- a/arch/blackfin/include/asm/system.h +++ b/arch/blackfin/include/asm/system.h @@ -197,6 +197,7 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, asmlinkage struct task_struct *resume(struct task_struct *prev, struct task_struct *next); +#ifndef CONFIG_SMP #define switch_to(prev,next,last) \ do { \ memcpy (&task_thread_info(prev)->l1_task_info, L1_SCRATCH_TASK_INFO, \ @@ -205,5 +206,11 @@ do { \ sizeof *L1_SCRATCH_TASK_INFO); \ (last) = resume (prev, next); \ } while (0) +#else +#define switch_to(prev, next, last) \ +do { \ + (last) = resume(prev, next); \ +} while (0) +#endif #endif /* _BLACKFIN_SYSTEM_H */ diff --git a/arch/blackfin/include/asm/thread_info.h b/arch/blackfin/include/asm/thread_info.h index 7eaf2e2606d..e721ce55956 100644 --- a/arch/blackfin/include/asm/thread_info.h +++ b/arch/blackfin/include/asm/thread_info.h @@ -63,7 +63,9 @@ struct thread_info { int preempt_count; /* 0 => preemptable, <0 => BUG */ mm_segment_t addr_limit; /* address limit */ struct restart_block restart_block; +#ifndef CONFIG_SMP struct l1_scratch_task_info l1_task_info; +#endif }; /* -- cgit v1.2.3-70-g09d2