[PATCH] sysctl: convert arch specific unaligned access regulators to generic ones
From: Vineet Gupta * parisc: /proc/sys/kernel/unaligned-trap => SYSCTL_ARCH_UNALIGN_ALLOW * ia64: /proc/sys/kernel/ignore-unaligned-usertrap => SYSCTL_ARCH_UNALIGN_NO_WARN This allows other architectures, specifically ARC to reuse these sysctl knobs. Signed-off-by: Vineet Gupta Cc: Tony Luck Cc: Fenghua Yu Cc: "James E.J. Bottomley" Cc: "Eric W. Biederman" Cc: Serge Hallyn Cc: "David S. Miller" Cc: "Paul E. McKenney" Cc: linux-i...@vger.kernel.org Cc: linux-par...@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- arch/ia64/Kconfig |1 + arch/parisc/Kconfig |1 + init/Kconfig| 16 kernel/sysctl.c | 16 +--- 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig index 3279646..5fb1064 100644 --- a/arch/ia64/Kconfig +++ b/arch/ia64/Kconfig @@ -40,6 +40,7 @@ config IA64 select ARCH_THREAD_INFO_ALLOCATOR select ARCH_CLOCKSOURCE_DATA select GENERIC_TIME_VSYSCALL_OLD + select SYSCTL_ARCH_UNALIGN_NO_WARN select HAVE_MOD_ARCH_SPECIFIC select MODULES_USE_ELF_RELA default y diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig index 11def45..7d9de54 100644 --- a/arch/parisc/Kconfig +++ b/arch/parisc/Kconfig @@ -20,6 +20,7 @@ config PARISC select ARCH_HAVE_NMI_SAFE_CMPXCHG select GENERIC_SMP_IDLE_THREAD select GENERIC_STRNCPY_FROM_USER + select SYSCTL_ARCH_UNALIGN_ALLOW select HAVE_MOD_ARCH_SPECIFIC select MODULES_USE_ELF_RELA diff --git a/init/Kconfig b/init/Kconfig index 6fdd6e3..de4b184 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1169,6 +1169,22 @@ config SYSCTL_EXCEPTION_TRACE help Enable support for /proc/sys/debug/exception-trace. +config SYSCTL_ARCH_UNALIGN_NO_WARN + bool + help + Enable support for /proc/sys/kernel/ignore-unaligned-usertrap + Allows arch to define/use @no_unaligned_warning to possbly warn about + unaligned access emulation going on under the hood. + see arch/ia64/kernel/unaligned.c for reference + +config SYSCTL_ARCH_UNALIGN_ALLOW + bool + help + Enable support for /proc/sys/kernel/unaligned-trap + Allows arches to define/use @unaligned_enabled to runtime toggle + the unaligned access emulation. + see arch/parisc/kernel/unaligned.c for reference + config KALLSYMS bool "Load all symbols for debugging/ksymoops" if EXPERT default y diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 26f65ea..9c618bf 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -157,14 +157,20 @@ extern int sysctl_tsb_ratio; #ifdef __hppa__ extern int pwrsw_enabled; -extern int unaligned_enabled; #endif #ifdef CONFIG_IA64 -extern int no_unaligned_warning; extern int unaligned_dump_stack; #endif +#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW +extern int unaligned_enabled; +#endif + +#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN +extern int no_unaligned_warning; +#endif + #ifdef CONFIG_PROC_SYSCTL static int proc_do_cad_pid(struct ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos); @@ -504,6 +510,8 @@ static struct ctl_table kern_table[] = { .mode = 0644, .proc_handler = proc_dointvec, }, +#endif +#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW { .procname = "unaligned-trap", .data = _enabled, @@ -870,7 +878,7 @@ static struct ctl_table kern_table[] = { .proc_handler = proc_doulongvec_minmax, }, #endif -#ifdef CONFIG_IA64 +#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN { .procname = "ignore-unaligned-usertrap", .data = _unaligned_warning, @@ -878,6 +886,8 @@ static struct ctl_table kern_table[] = { .mode = 0644, .proc_handler = proc_dointvec, }, +#endif +#ifdef CONFIG_IA64 { .procname = "unaligned-dump-stack", .data = _dump_stack, -- 1.7.4.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] sysctl: convert arch specific unaligned access regulators to generic ones
From: Vineet Gupta vgu...@synopsys.com * parisc: /proc/sys/kernel/unaligned-trap = SYSCTL_ARCH_UNALIGN_ALLOW * ia64: /proc/sys/kernel/ignore-unaligned-usertrap = SYSCTL_ARCH_UNALIGN_NO_WARN This allows other architectures, specifically ARC to reuse these sysctl knobs. Signed-off-by: Vineet Gupta vgu...@synopsys.com Cc: Tony Luck tony.l...@intel.com Cc: Fenghua Yu fenghua...@intel.com Cc: James E.J. Bottomley j...@parisc-linux.org Cc: Eric W. Biederman ebied...@xmission.com Cc: Serge Hallyn serge.hal...@canonical.com Cc: David S. Miller da...@davemloft.net Cc: Paul E. McKenney paul...@linux.vnet.ibm.com Cc: linux-i...@vger.kernel.org Cc: linux-par...@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- arch/ia64/Kconfig |1 + arch/parisc/Kconfig |1 + init/Kconfig| 16 kernel/sysctl.c | 16 +--- 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig index 3279646..5fb1064 100644 --- a/arch/ia64/Kconfig +++ b/arch/ia64/Kconfig @@ -40,6 +40,7 @@ config IA64 select ARCH_THREAD_INFO_ALLOCATOR select ARCH_CLOCKSOURCE_DATA select GENERIC_TIME_VSYSCALL_OLD + select SYSCTL_ARCH_UNALIGN_NO_WARN select HAVE_MOD_ARCH_SPECIFIC select MODULES_USE_ELF_RELA default y diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig index 11def45..7d9de54 100644 --- a/arch/parisc/Kconfig +++ b/arch/parisc/Kconfig @@ -20,6 +20,7 @@ config PARISC select ARCH_HAVE_NMI_SAFE_CMPXCHG select GENERIC_SMP_IDLE_THREAD select GENERIC_STRNCPY_FROM_USER + select SYSCTL_ARCH_UNALIGN_ALLOW select HAVE_MOD_ARCH_SPECIFIC select MODULES_USE_ELF_RELA diff --git a/init/Kconfig b/init/Kconfig index 6fdd6e3..de4b184 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1169,6 +1169,22 @@ config SYSCTL_EXCEPTION_TRACE help Enable support for /proc/sys/debug/exception-trace. +config SYSCTL_ARCH_UNALIGN_NO_WARN + bool + help + Enable support for /proc/sys/kernel/ignore-unaligned-usertrap + Allows arch to define/use @no_unaligned_warning to possbly warn about + unaligned access emulation going on under the hood. + see arch/ia64/kernel/unaligned.c for reference + +config SYSCTL_ARCH_UNALIGN_ALLOW + bool + help + Enable support for /proc/sys/kernel/unaligned-trap + Allows arches to define/use @unaligned_enabled to runtime toggle + the unaligned access emulation. + see arch/parisc/kernel/unaligned.c for reference + config KALLSYMS bool Load all symbols for debugging/ksymoops if EXPERT default y diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 26f65ea..9c618bf 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -157,14 +157,20 @@ extern int sysctl_tsb_ratio; #ifdef __hppa__ extern int pwrsw_enabled; -extern int unaligned_enabled; #endif #ifdef CONFIG_IA64 -extern int no_unaligned_warning; extern int unaligned_dump_stack; #endif +#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW +extern int unaligned_enabled; +#endif + +#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN +extern int no_unaligned_warning; +#endif + #ifdef CONFIG_PROC_SYSCTL static int proc_do_cad_pid(struct ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos); @@ -504,6 +510,8 @@ static struct ctl_table kern_table[] = { .mode = 0644, .proc_handler = proc_dointvec, }, +#endif +#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW { .procname = unaligned-trap, .data = unaligned_enabled, @@ -870,7 +878,7 @@ static struct ctl_table kern_table[] = { .proc_handler = proc_doulongvec_minmax, }, #endif -#ifdef CONFIG_IA64 +#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN { .procname = ignore-unaligned-usertrap, .data = no_unaligned_warning, @@ -878,6 +886,8 @@ static struct ctl_table kern_table[] = { .mode = 0644, .proc_handler = proc_dointvec, }, +#endif +#ifdef CONFIG_IA64 { .procname = unaligned-dump-stack, .data = unaligned_dump_stack, -- 1.7.4.1 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 2/2] ARC: provide optimal __get_user_fn()
From: Vineet Gupta Signed-off-by: Vineet Gupta --- arch/arc/include/asm/uaccess.h | 51 1 files changed, 51 insertions(+), 0 deletions(-) diff --git a/arch/arc/include/asm/uaccess.h b/arch/arc/include/asm/uaccess.h index 503c98d..d9cbae4 100644 --- a/arch/arc/include/asm/uaccess.h +++ b/arch/arc/include/asm/uaccess.h @@ -35,6 +35,57 @@ #define __access_ok(addr, sz) (unlikely(__kernel_ok) || \ likely(__user_ok((addr), (sz +/*** Single byte/s-word/word copies **/ + +#define __get_user_fn(sz, u, k)\ +({ \ + long __ret = 0; /* success by default */\ + switch (sz) { \ + case 1: __arc_get_user_one(*(k), u, "ldb", __ret); break; \ + case 2: __arc_get_user_one(*(k), u, "ldw", __ret); break; \ + case 4: __arc_get_user_one(*(k), u, "ld", __ret); break; \ + case 8: __arc_get_user_one_64(*(k), u, __ret); break; \ + } \ + __ret; \ +}) + +#define __arc_get_user_one(dst, src, op, ret) \ + __asm__ __volatile__( \ + "1: "op"%1,[%2]\n" \ + "2: ;nop\n" \ + " .section .fixup, \"ax\"\n" \ + " .align 4\n" \ + "3: mov %0, %3\n" \ + " j 2b\n" \ + " .previous\n"\ + " .section __ex_table, \"a\"\n" \ + " .align 4\n" \ + " .word 1b,3b\n" \ + " .previous\n"\ + \ + : "+r" (ret), "=r" (dst)\ + : "r" (src), "i" (-EFAULT)) + +#define __arc_get_user_one_64(dst, src, ret) \ + __asm__ __volatile__( \ + "1: ld %1,[%2]\n" \ + "4: ld %R1,[%2, 4]\n" \ + "2: ;nop\n" \ + " .section .fixup, \"ax\"\n" \ + " .align 4\n" \ + "3: mov %0, %3\n" \ + " j 2b\n" \ + " .previous\n"\ + " .section __ex_table, \"a\"\n" \ + " .align 4\n" \ + " .word 1b,3b\n" \ + " .word 4b,3b\n" \ + " .previous\n"\ + \ + : "+r" (ret), "=r" (dst)\ + : "r" (src), "i" (-EFAULT)) + + static inline unsigned long __arc_copy_from_user(void *to, const void __user *from, unsigned long n) { -- 1.7.4.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 1/2] asm-generic: uaccess: allow arch to over-ride __get_user_fn()
From: Vineet Gupta Signed-off-by: Vineet Gupta --- include/asm-generic/uaccess.h |5 + 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h index 5f6ee61..432d55f 100644 --- a/include/asm-generic/uaccess.h +++ b/include/asm-generic/uaccess.h @@ -225,12 +225,17 @@ extern int __put_user_bad(void) __attribute__((noreturn)); -EFAULT;\ }) +#ifndef __get_user_fn static inline int __get_user_fn(size_t size, const void __user *ptr, void *x) { size = __copy_from_user(x, ptr, size); return size ? -EFAULT : size; } +#define __get_user_fn(sz, u, k)__get_user_fn(sz, u, k) + +#endif + extern int __get_user_bad(void) __attribute__((noreturn)); #ifndef __copy_from_user_inatomic -- 1.7.4.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 0/2] RFC only - allow arches to over-ride unit sized user copies
From: Vineet Gupta Hi Arnd, The current asm-generic/uaccess unit copy interface __{get,put}_user( ) defaults to using __copy_{to,from}_user( ). For archs which don't support unaligned access, latter typically involves generated code for alignment checks. It is expected that arch will provide a fast path in __copy_{to,from}_user( ) for such unit sized copies - probably using __builtin_const_p( ) etc - however the alignment checks still can't be eliminated altogether using that. Even if they could, it woudl make the implementation messier IMHO. However given that 2 separate interfaces already exist form beginning (i.e. __get_user vs. __copy_from_user) will it make sense to allow arch to provide alternate implementation of former w/o having to mess with latter. I did a quick hack to that end and I can see that savings are more than just "noise". bloat-o-meter vmlinux_pre_uaccess vmlinux_uaccess_part1 | head add/remove: 0/1 grow/shrink: 10/62 up/down: 1502/-7256 (-5754) The patch which converts just __get_user follows. I've not done the full/clean version yet as this is just to gather feedback. Thx, -Vineet Vineet Gupta (2): asm-generic: uaccess: allow arch to over-ride __get_user_fn() ARC: provide optimal __get_user_fn() arch/arc/include/asm/uaccess.h | 51 include/asm-generic/uaccess.h |5 2 files changed, 56 insertions(+), 0 deletions(-) -- 1.7.4.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 0/2] RFC only - allow arches to over-ride unit sized user copies
From: Vineet Gupta vgu...@synopsys.com Hi Arnd, The current asm-generic/uaccess unit copy interface __{get,put}_user( ) defaults to using __copy_{to,from}_user( ). For archs which don't support unaligned access, latter typically involves generated code for alignment checks. It is expected that arch will provide a fast path in __copy_{to,from}_user( ) for such unit sized copies - probably using __builtin_const_p( ) etc - however the alignment checks still can't be eliminated altogether using that. Even if they could, it woudl make the implementation messier IMHO. However given that 2 separate interfaces already exist form beginning (i.e. __get_user vs. __copy_from_user) will it make sense to allow arch to provide alternate implementation of former w/o having to mess with latter. I did a quick hack to that end and I can see that savings are more than just noise. bloat-o-meter vmlinux_pre_uaccess vmlinux_uaccess_part1 | head add/remove: 0/1 grow/shrink: 10/62 up/down: 1502/-7256 (-5754) The patch which converts just __get_user follows. I've not done the full/clean version yet as this is just to gather feedback. Thx, -Vineet Vineet Gupta (2): asm-generic: uaccess: allow arch to over-ride __get_user_fn() ARC: provide optimal __get_user_fn() arch/arc/include/asm/uaccess.h | 51 include/asm-generic/uaccess.h |5 2 files changed, 56 insertions(+), 0 deletions(-) -- 1.7.4.1 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 2/2] ARC: provide optimal __get_user_fn()
From: Vineet Gupta vgu...@synopsys.com Signed-off-by: Vineet Gupta vgu...@synopsys.com --- arch/arc/include/asm/uaccess.h | 51 1 files changed, 51 insertions(+), 0 deletions(-) diff --git a/arch/arc/include/asm/uaccess.h b/arch/arc/include/asm/uaccess.h index 503c98d..d9cbae4 100644 --- a/arch/arc/include/asm/uaccess.h +++ b/arch/arc/include/asm/uaccess.h @@ -35,6 +35,57 @@ #define __access_ok(addr, sz) (unlikely(__kernel_ok) || \ likely(__user_ok((addr), (sz +/*** Single byte/s-word/word copies **/ + +#define __get_user_fn(sz, u, k)\ +({ \ + long __ret = 0; /* success by default */\ + switch (sz) { \ + case 1: __arc_get_user_one(*(k), u, ldb, __ret); break; \ + case 2: __arc_get_user_one(*(k), u, ldw, __ret); break; \ + case 4: __arc_get_user_one(*(k), u, ld, __ret); break; \ + case 8: __arc_get_user_one_64(*(k), u, __ret); break; \ + } \ + __ret; \ +}) + +#define __arc_get_user_one(dst, src, op, ret) \ + __asm__ __volatile__( \ + 1: op%1,[%2]\n \ + 2: ;nop\n \ + .section .fixup, \ax\\n \ + .align 4\n \ + 3: mov %0, %3\n \ + j 2b\n \ + .previous\n\ + .section __ex_table, \a\\n \ + .align 4\n \ + .word 1b,3b\n \ + .previous\n\ + \ + : +r (ret), =r (dst)\ + : r (src), i (-EFAULT)) + +#define __arc_get_user_one_64(dst, src, ret) \ + __asm__ __volatile__( \ + 1: ld %1,[%2]\n \ + 4: ld %R1,[%2, 4]\n \ + 2: ;nop\n \ + .section .fixup, \ax\\n \ + .align 4\n \ + 3: mov %0, %3\n \ + j 2b\n \ + .previous\n\ + .section __ex_table, \a\\n \ + .align 4\n \ + .word 1b,3b\n \ + .word 4b,3b\n \ + .previous\n\ + \ + : +r (ret), =r (dst)\ + : r (src), i (-EFAULT)) + + static inline unsigned long __arc_copy_from_user(void *to, const void __user *from, unsigned long n) { -- 1.7.4.1 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 1/2] asm-generic: uaccess: allow arch to over-ride __get_user_fn()
From: Vineet Gupta vgu...@synopsys.com Signed-off-by: Vineet Gupta vgu...@synopsys.com --- include/asm-generic/uaccess.h |5 + 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h index 5f6ee61..432d55f 100644 --- a/include/asm-generic/uaccess.h +++ b/include/asm-generic/uaccess.h @@ -225,12 +225,17 @@ extern int __put_user_bad(void) __attribute__((noreturn)); -EFAULT;\ }) +#ifndef __get_user_fn static inline int __get_user_fn(size_t size, const void __user *ptr, void *x) { size = __copy_from_user(x, ptr, size); return size ? -EFAULT : size; } +#define __get_user_fn(sz, u, k)__get_user_fn(sz, u, k) + +#endif + extern int __get_user_bad(void) __attribute__((noreturn)); #ifndef __copy_from_user_inatomic -- 1.7.4.1 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] Ensure that kernel_init_freebale() is not inlined into non __init code
From: Vineet Gupta Commit d6b2123802d "make sure that we always have a return path from kernel_execve()" reshuffled kernel_init()/init_post() to ensure that kernel_execve() has a caller to return to. Just for documentation, here's what that commit did. Orig THREAD __init kernel_init() smp_init() ... open("/dev/console") init_post() --> forced to be noinline return 0; init_post() free_initmem() --> reaps caller kernel_init() run_init_process("/init") kernel_execve New --- THREAD kernel_init() kernel_init_freeable() --> __init tagged smp_init() ... open("/dev/console") free_initmem() --> reaps kernel_init_freeable() run_init_process "init" kernel_execve However kernel_init_freebale() was NOT marked as noinline making ARC gcc 4.4 inline it in non __init freeable kernel_init(), wasting a bit of memory. bloat-o-meter vmlinux_orig vmlinux add/remove: 1/0 grow/shrink: 0/1 up/down: 374/-330 (44) function old new delta kernel_init_freeable - 374+374 kernel_init 636 306-330 Signed-off-by: Vineet Gupta --- init/main.c |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/init/main.c b/init/main.c index e33e09d..cd147a9 100644 --- a/init/main.c +++ b/init/main.c @@ -800,7 +800,7 @@ static int run_init_process(const char *init_filename) return kernel_execve(init_filename, argv_init, envp_init); } -static void __init kernel_init_freeable(void); +static noinline void __init kernel_init_freeable(void); static int __ref kernel_init(void *unused) { @@ -844,7 +844,7 @@ static int __ref kernel_init(void *unused) "See Linux Documentation/init.txt for guidance."); } -static void __init kernel_init_freeable(void) +static noinline void __init kernel_init_freeable(void) { /* * Wait until kthreadd is all set-up. -- 1.7.4.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] Ensure that kernel_init_freebale() is not inlined into non __init code
From: Vineet Gupta vgu...@synopsys.com Commit d6b2123802d make sure that we always have a return path from kernel_execve() reshuffled kernel_init()/init_post() to ensure that kernel_execve() has a caller to return to. Just for documentation, here's what that commit did. Orig THREAD __init kernel_init() smp_init() ... open(/dev/console) init_post() -- forced to be noinline return 0; init_post() free_initmem() -- reaps caller kernel_init() run_init_process(/init) kernel_execve New --- THREAD kernel_init() kernel_init_freeable() -- __init tagged smp_init() ... open(/dev/console) free_initmem() -- reaps kernel_init_freeable() run_init_process init kernel_execve However kernel_init_freebale() was NOT marked as noinline making ARC gcc 4.4 inline it in non __init freeable kernel_init(), wasting a bit of memory. bloat-o-meter vmlinux_orig vmlinux add/remove: 1/0 grow/shrink: 0/1 up/down: 374/-330 (44) function old new delta kernel_init_freeable - 374+374 kernel_init 636 306-330 Signed-off-by: Vineet Gupta vgu...@synopsys.com --- init/main.c |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/init/main.c b/init/main.c index e33e09d..cd147a9 100644 --- a/init/main.c +++ b/init/main.c @@ -800,7 +800,7 @@ static int run_init_process(const char *init_filename) return kernel_execve(init_filename, argv_init, envp_init); } -static void __init kernel_init_freeable(void); +static noinline void __init kernel_init_freeable(void); static int __ref kernel_init(void *unused) { @@ -844,7 +844,7 @@ static int __ref kernel_init(void *unused) See Linux Documentation/init.txt for guidance.); } -static void __init kernel_init_freeable(void) +static noinline void __init kernel_init_freeable(void) { /* * Wait until kthreadd is all set-up. -- 1.7.4.1 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[RFC Patch v1 38/55] ARC: Low level event capture/logging
From: Vineet Gupta Poorman's version of LTT Signed-off-by: Vineet Gupta --- arch/arc/Kconfig |7 + arch/arc/Makefile|3 + arch/arc/include/asm/event-log-asm.h | 185 + arch/arc/include/asm/event-log.h | 102 arch/arc/kernel/Makefile |1 + arch/arc/kernel/asm-offsets.c| 15 ++ arch/arc/kernel/entry.S | 31 arch/arc/kernel/event-log.c | 304 ++ arch/arc/kernel/signal.c |3 + arch/arc/mm/tlb.c|3 + arch/arc/mm/tlbex.S |7 + 11 files changed, 661 insertions(+), 0 deletions(-) create mode 100644 arch/arc/include/asm/event-log-asm.h create mode 100644 arch/arc/include/asm/event-log.h create mode 100644 arch/arc/kernel/event-log.c diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index e096545..15d740c 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig @@ -323,6 +323,13 @@ config ARC_DBG_TLB_PARANOIA depends on ARC_DBG default n +config ARC_DBG_EVENT_TIMELINE + bool "Low level event capture" + depends on ARC_DBG + default n + help + Capture low level events: IRQ/Trap/Exception + config ARC_DBG_TLB_MISS_COUNT bool "Profile TLB Misses" default n diff --git a/arch/arc/Makefile b/arch/arc/Makefile index 7ef6767..a533546 100644 --- a/arch/arc/Makefile +++ b/arch/arc/Makefile @@ -47,6 +47,9 @@ endif disable_small_data := y cflags-$(disable_small_data) += -mno-sdata -fcall-used-gp +# Low level event tracing with Metaware debugger assist needs symbol info +cflags-$(CONFIG_ARC_DBG_EVENT_TIMELINE) += -g + cflags-$(CONFIG_CPU_BIG_ENDIAN)+= -mbig-endian ldflags-$(CONFIG_CPU_BIG_ENDIAN) += -EB diff --git a/arch/arc/include/asm/event-log-asm.h b/arch/arc/include/asm/event-log-asm.h new file mode 100644 index 000..bc29e7d --- /dev/null +++ b/arch/arc/include/asm/event-log-asm.h @@ -0,0 +1,185 @@ +/* + * Low level Event Capture API callable from Assembly Code + * vineetg: Feb 2008 + * + * TBD: SMP Safe + * + * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef __ASM_ARC_EVENT_LOG_ASM_H +#define __ASM_ARC_EVENT_LOG_ASM_H + +#include + +#ifdef __ASSEMBLY__ + +#ifndef CONFIG_ARC_DBG_EVENT_TIMELINE + +.macro TAKE_SNAP_ASM reg_scratch, reg_ptr, type +.endm + +.macro TAKE_SNAP_C_FROM_ASM type +.endm + +#else + +#include + +/* + * Macro to invoke the ASM event logger routine from assmebly code + * This is generated in-place in caller. + * + * @reg_scratch and @reg_ptr: + * Registers provided by caller for coding the macro itself. + * At this point if call, say Low level ISR, the Reg-File might not have + * been saved, so only use reg safe. + * @type: + * The low level event, defined in event-log.h + */ +.macro TAKE_SNAP_ASM reg_scratch, reg_ptr, type + + /* +* Earlier we used to save only reg_scratch and clobber reg_ptr and rely +* on caller to understand this. Too much trouble. +* Now we save both +*/ + st \reg_scratch, [tmp_save_reg] + st \reg_ptr, [tmp_save_reg2] + + ld \reg_ptr, [timeline_ctr] + + /* HACK to detect if the circular log buffer is being overflowed */ + brne \reg_ptr, MAX_SNAPS, 1f + flag 1 + nop +1: +#ifdef CONFIG_ARC_HAS_HW_MPY + mpyu \reg_ptr, \reg_ptr, EVLOG_RECORD_SZ +#else +#error "even logger broken for !CONFIG_ARC_HAS_HW_MPY +#endif + + add \reg_ptr, timeline_log, \reg_ptr + + /* Common data ## */ + + /* TIMER1 count in timeline_log[timeline_ctr].time */ + lr \reg_scratch, [ARC_REG_TIMER1_CNT] + st \reg_scratch, [\reg_ptr, EVLOG_FIELD_TIME] + + /* current task ptr in timeline_log[timeline_ctr].task */ + ld \reg_scratch, [_current_task] + ld \reg_scratch, [\reg_scratch, TASK_TGID] + st \reg_scratch, [\reg_ptr, EVLOG_FIELD_TASK] + + /* Type of event (Intr/Excp/Trap etc) */ + mov \reg_scratch, \type + st \reg_scratch, [\reg_ptr, EVLOG_FIELD_EVENT_ID] + + /* save SP at time of exception */ + st sp, [\reg_ptr, EVLOG_FIELD_SP] + + st 0, [\reg_ptr, EVLOG_FIELD_EXTRA] + st 0, [\reg_ptr, EVLOG_FIELD_CAUSE] + st 0, [\reg_ptr, EVLOG_FIELD_EXTRA3] + + lr \reg_scratch, [status32] + st \reg_scratch, [\reg_ptr, EVLOG_FIELD_EXTRA2] + + /* Event specific data ## */ + mov \reg_scratch, \type + and.f 0, \reg_scratch, EVENT_CLASS_EXIT + bz 1f + + /* Stuff to do for all kernel exit events */ + ld \reg_scratch, [sp, PT_status32] + st \reg_scratch,
[RFC Patch v1 51/55] modpost: Ignore ARC specific non-alloc section
From: Vineet Gupta ARC relocatable object files contain one/more .gnu.linkonce.arcextmap.* sections (collated into .arcextmap in final link). These sections are used by debuggers to display the extension instructions and need-not be loaded by target (hence !SHF_ALLOC) This patch adds the section to modpost's ignore list to avoid the following ==>8 WARNING: vmlinux.o (.gnu.linkonce.arcextmap.inst.3.5.8): unexpected non-allocatable section. Did you forget to use "ax"/"aw" in a .S file? Note that for example contains section definitions for use in .S files. ==>8 Signed-off-by: Vineet Gupta --- scripts/mod/modpost.c |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 0d93856..fbbdb8e 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -830,6 +830,7 @@ static const char *section_white_list[] = ".toc*", ".xt.prop", /* xtensa */ ".xt.lit", /* xtensa */ + ".arcextmap*", /* arc */ NULL }; -- 1.7.4.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[RFC Patch v1 46/55] ARC: kgdb support
From: Mischa Jonker Signed-off-by: Mischa Jonker Signed-off-by: Vineet Gupta --- arch/arc/Kconfig|5 +- arch/arc/include/asm/kgdb.h | 61 + arch/arc/kernel/Makefile|2 + arch/arc/kernel/kgdb.c | 205 +++ arch/arc/kernel/traps.c |6 ++ 5 files changed, 277 insertions(+), 2 deletions(-) create mode 100644 arch/arc/include/asm/kgdb.h create mode 100644 arch/arc/kernel/kgdb.c diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index 81d78fc..b878d3e 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig @@ -20,6 +20,7 @@ config ARC select GENERIC_KERNEL_THREAD select GENERIC_PENDING_IRQ if SMP select GENERIC_SMP_IDLE_THREAD + select HAVE_ARCH_KGDB select HAVE_ARCH_TRACEHOOK select HAVE_GENERIC_HARDIRQS select HAVE_KPROBES @@ -383,12 +384,12 @@ config ARC_DW2_UNWIND config ARC_DBG_TLB_PARANOIA bool "Paranoia Checks in Low Level TLB Handlers" - depends on ARC_DBG && !SMP + depends on ARC_DBG default n config ARC_DBG_EVENT_TIMELINE bool "Low level event capture" - depends on ARC_DBG + depends on ARC_DBG && !SMP default n help Capture low level events: IRQ/Trap/Exception diff --git a/arch/arc/include/asm/kgdb.h b/arch/arc/include/asm/kgdb.h new file mode 100644 index 000..f3c4934 --- /dev/null +++ b/arch/arc/include/asm/kgdb.h @@ -0,0 +1,61 @@ +/* + * kgdb support for ARC + * + * Copyright (C) 2012 Synopsys, Inc. (www.synopsys.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef __ARC_KGDB_H__ +#define __ARC_KGDB_H__ + +#ifdef CONFIG_KGDB + +#include + +/* to ensure compatibility with Linux 2.6.35, we don't implement the get/set + * register API yet */ +#undef DBG_MAX_REG_NUM + +#define GDB_MAX_REGS 39 + +#define BREAK_INSTR_SIZE 2 +#define CACHE_FLUSH_IS_SAFE1 +#define NUMREGBYTES(GDB_MAX_REGS * 4) +#define BUFMAX 2048 + +static inline void arch_kgdb_breakpoint(void) +{ + __asm__ __volatile__ ("trap_s 0x4\n"); +} + +extern void kgdb_trap(struct pt_regs *regs, int param); + +enum arc700_linux_regnums { + _R0 = 0, + _R1, _R2, _R3, _R4, _R5, _R6, _R7, _R8, _R9, _R10, _R11, _R12, _R13, + _R14, _R15, _R16, _R17, _R18, _R19, _R20, _R21, _R22, _R23, _R24, + _R25, _R26, + _BTA= 27, + _LP_START = 28, + _LP_END = 29, + _LP_COUNT = 30, + _STATUS32 = 31, + _BLINK = 32, + _FP = 33, + __SP= 34, + _EFA= 35, + _RET= 36, + _ORIG_R8= 37, + _STOP_PC= 38 +}; + +#else +static inline void kgdb_trap(struct pt_regs *regs, int param) +{ +} +#endif + +#endif /* __ARC_KGDB_H__ */ diff --git a/arch/arc/kernel/Makefile b/arch/arc/kernel/Makefile index 52ef6ce..a2b7493 100644 --- a/arch/arc/kernel/Makefile +++ b/arch/arc/kernel/Makefile @@ -17,6 +17,8 @@ obj-$(CONFIG_SMP) += smp.o obj-$(CONFIG_ARC_DW2_UNWIND) += unwind.o obj-$(CONFIG_KPROBES) += kprobes.o obj-$(CONFIG_ARC_MISALIGN_ACCESS) += unaligned.o +obj-$(CONFIG_KGDB) += kgdb.o + obj-$(CONFIG_ARC_FPU_SAVE_RESTORE) += fpu.o CFLAGS_fpu.o += -mdpfp diff --git a/arch/arc/kernel/kgdb.c b/arch/arc/kernel/kgdb.c new file mode 100644 index 000..2888ba5 --- /dev/null +++ b/arch/arc/kernel/kgdb.c @@ -0,0 +1,205 @@ +/* + * kgdb support for ARC + * + * Copyright (C) 2012 Synopsys, Inc. (www.synopsys.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include +#include + +static void to_gdb_regs(unsigned long *gdb_regs, struct pt_regs *kernel_regs, + struct callee_regs *cregs) +{ + int regno; + + for (regno = 0; regno <= 26; regno++) + gdb_regs[_R0 + regno] = get_reg(regno, kernel_regs, cregs); + + for (regno = 27; regno < GDB_MAX_REGS; regno++) + gdb_regs[regno] = 0; + + gdb_regs[_FP] = kernel_regs->fp; + gdb_regs[__SP] = kernel_regs->sp; + gdb_regs[_BLINK]= kernel_regs->blink; + gdb_regs[_RET] = kernel_regs->ret; + gdb_regs[_STATUS32] = kernel_regs->status32; + gdb_regs[_LP_COUNT] = kernel_regs->lp_count; + gdb_regs[_LP_END] = kernel_regs->lp_end; + gdb_regs[_LP_START] = kernel_regs->lp_start; + gdb_regs[_BTA] = kernel_regs->bta; + gdb_regs[_STOP_PC] = kernel_regs->ret; +} + +static void
[RFC Patch v1 42/55] ARC: stacktracing APIs based on dw2 unwinder
From: Vineet Gupta Signed-off-by: Vineet Gupta --- arch/arc/kernel/stacktrace.c | 215 +- 1 files changed, 213 insertions(+), 2 deletions(-) diff --git a/arch/arc/kernel/stacktrace.c b/arch/arc/kernel/stacktrace.c index b9d1646..a63ff84 100644 --- a/arch/arc/kernel/stacktrace.c +++ b/arch/arc/kernel/stacktrace.c @@ -1,13 +1,206 @@ /* + * stacktrace.c : stacktracing APIs needed by rest of kernel + * (wrappers over ARC dwarf based unwinder) + * * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. + * + * vineetg: aug 2009 + * -Implemented CONFIG_STACKTRACE APIs, primarily save_stack_trace_tsk( ) + * for displaying task's kernel mode call stack in /proc//stack + * -Iterator based approach to have single copy of unwinding core and APIs + * needing unwinding, implement the logic in iterator regarding: + * = which frame onwards to start capture + * = which frame to stop capturing (wchan) + * = specifics of data structs where trace is saved(CONFIG_STACKTRACE etc) + * + * vineetg: March 2009 + * -Implemented correct versions of thread_saved_pc() and get_wchan() + * + * rajeshwarr: 2008 + * -Initial implementation */ #include #include +#include +#include +#include +#include +#include + +/*- + * Unwinder Iterator + *- + */ + +#ifdef CONFIG_ARC_DW2_UNWIND + +static void seed_unwind_frame_info(struct task_struct *tsk, + struct pt_regs *regs, + struct unwind_frame_info *frame_info) +{ + if (tsk == NULL && regs == NULL) { + unsigned long fp, sp, blink, ret; + frame_info->task = current; + + __asm__ __volatile__( + "mov %0,r27\n\t" + "mov %1,r28\n\t" + "mov %2,r31\n\t" + "mov %3,r63\n\t" + : "=r"(fp), "=r"(sp), "=r"(blink), "=r"(ret) + ); + + frame_info->regs.r27 = fp; + frame_info->regs.r28 = sp; + frame_info->regs.r31 = blink; + frame_info->regs.r63 = ret; + frame_info->call_frame = 0; + } else if (regs == NULL) { + + frame_info->task = tsk; + + frame_info->regs.r27 = KSTK_FP(tsk); + frame_info->regs.r28 = KSTK_ESP(tsk); + frame_info->regs.r31 = KSTK_BLINK(tsk); + frame_info->regs.r63 = (unsigned int)__switch_to; + + /* In the prologue of __switch_to, first FP is saved on stack +* and then SP is copied to FP. Dwarf assumes cfa as FP based +* but we didn't save FP. The value retrieved above is FP's +* state in previous frame. +* As a work around for this, we unwind from __switch_to start +* and adjust SP accordingly. The other limitation is that +* __switch_to macro is dwarf rules are not generated for inline +* assembly code +*/ + frame_info->regs.r27 = 0; + frame_info->regs.r28 += 64; + frame_info->call_frame = 0; + + } else { + frame_info->task = tsk; + + frame_info->regs.r27 = regs->fp; + frame_info->regs.r28 = regs->sp; + frame_info->regs.r31 = regs->blink; + frame_info->regs.r63 = regs->ret; + frame_info->call_frame = 0; + } +} + +#endif + +static noinline unsigned int +arc_unwind_core(struct task_struct *tsk, struct pt_regs *regs, + int (*consumer_fn) (unsigned int, void *), void *arg) +{ +#ifdef CONFIG_ARC_DW2_UNWIND + int ret = 0; + unsigned int address; + struct unwind_frame_info frame_info; + + seed_unwind_frame_info(tsk, regs, _info); + + while (1) { + address = UNW_PC(_info); + + if (address && __kernel_text_address(address)) { + if (consumer_fn(address, arg) == -1) + break; + } + + ret = arc_unwind(_info); + + if (ret == 0) { + frame_info.regs.r63 = frame_info.regs.r31; + continue; + } else { + break; + } + } + + return address; /* return the last address it saw */ +#else + /* On ARC, only Dward based unwinder works. fp based backtracing is +* not possible (-fno-omit-frame-pointer)
[RFC Patch v1 55/55] ARC: Add self to MAINTAINERS
From: Vineet Gupta Signed-off-by: Vineet Gupta --- MAINTAINERS |6 ++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 1fa9074..e933489 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -7073,6 +7073,12 @@ F: lib/swiotlb.c F: arch/*/kernel/pci-swiotlb.c F: include/linux/swiotlb.h +SYNOPSYS ARC ARCHITECTURE +M: Vineet Gupta +L: linux-snps-...@vger.kernel.org +S: Supported +F: arch/arc/ + SYSV FILESYSTEM M: Christoph Hellwig S: Maintained -- 1.7.4.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[RFC Patch v1 54/55] ARC: [plat-arcfpga] defconfig
From: Vineet Gupta Signed-off-by: Vineet Gupta --- arch/arc/configs/fpga_defconfig | 137 +-- 1 files changed, 130 insertions(+), 7 deletions(-) diff --git a/arch/arc/configs/fpga_defconfig b/arch/arc/configs/fpga_defconfig index cfdca3c..d43e738 100644 --- a/arch/arc/configs/fpga_defconfig +++ b/arch/arc/configs/fpga_defconfig @@ -17,6 +17,7 @@ CONFIG_STACKTRACE_SUPPORT=y CONFIG_HAVE_LATENCYTOP_SUPPORT=y # CONFIG_NO_DMA is not set CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" +CONFIG_HAVE_IRQ_WORK=y # # General setup @@ -31,6 +32,7 @@ CONFIG_DEFAULT_HOSTNAME="(none)" # CONFIG_SWAP is not set # CONFIG_SYSVIPC is not set # CONFIG_FHANDLE is not set +# CONFIG_AUDIT is not set CONFIG_HAVE_GENERIC_HARDIRQS=y # @@ -53,6 +55,7 @@ CONFIG_HIGH_RES_TIMERS=y # CONFIG_TICK_CPU_ACCOUNTING=y # CONFIG_BSD_PROCESS_ACCT is not set +# CONFIG_TASKSTATS is not set # # RCU Subsystem @@ -66,8 +69,7 @@ CONFIG_LOG_BUF_SHIFT=17 CONFIG_NAMESPACES=y # CONFIG_UTS_NS is not set # CONFIG_PID_NS is not set -CONFIG_UIDGID_CONVERTED=y -# CONFIG_UIDGID_STRICT_TYPE_CHECKS is not set +CONFIG_NET_NS=y # CONFIG_SCHED_AUTOGROUP is not set # CONFIG_SYSFS_DEPRECATED is not set # CONFIG_RELAY is not set @@ -97,13 +99,16 @@ CONFIG_BUG=y # CONFIG_SIGNALFD is not set # CONFIG_TIMERFD is not set # CONFIG_EVENTFD is not set -# CONFIG_SHMEM is not set +CONFIG_SHMEM=y # CONFIG_AIO is not set CONFIG_EMBEDDED=y +CONFIG_HAVE_PERF_EVENTS=y +CONFIG_PERF_USE_VMALLOC=y # # Kernel Performance Events And Counters # +# CONFIG_PERF_EVENTS is not set # CONFIG_VM_EVENT_COUNTERS is not set # CONFIG_SLUB_DEBUG is not set # CONFIG_COMPAT_BRK is not set @@ -111,6 +116,11 @@ CONFIG_EMBEDDED=y CONFIG_SLUB=y # CONFIG_SLOB is not set # CONFIG_PROFILING is not set +CONFIG_HAVE_OPROFILE=y +# CONFIG_KPROBES is not set +CONFIG_HAVE_KPROBES=y +CONFIG_HAVE_KRETPROBES=y +CONFIG_HAVE_ARCH_TRACEHOOK=y CONFIG_GENERIC_SMP_IDLE_THREAD=y CONFIG_ARCH_WANT_IPC_PARSE_VERSION=y CONFIG_GENERIC_KERNEL_THREAD=y @@ -121,7 +131,12 @@ CONFIG_MODULES_USE_ELF_RELA=y # # CONFIG_HAVE_GENERIC_DMA_COHERENT is not set CONFIG_BASE_SMALL=1 -# CONFIG_MODULES is not set +CONFIG_MODULES=y +# CONFIG_MODULE_FORCE_LOAD is not set +# CONFIG_MODULE_UNLOAD is not set +# CONFIG_MODVERSIONS is not set +# CONFIG_MODULE_SRCVERSION_ALL is not set +# CONFIG_MODULE_SIG is not set CONFIG_BLOCK=y # CONFIG_LBDAF is not set # CONFIG_BLK_DEV_BSG is not set @@ -165,6 +180,8 @@ CONFIG_ARC_CACHE_LINE_SHIFT=6 CONFIG_ARC_HAS_ICACHE=y CONFIG_ARC_HAS_DCACHE=y CONFIG_ARC_CACHE_PAGES=y +# CONFIG_ARC_HAS_ICCM is not set +# CONFIG_ARC_HAS_DCCM is not set CONFIG_ARC_HAS_HW_MPY=y # CONFIG_ARC_MMU_V1 is not set # CONFIG_ARC_MMU_V2 is not set @@ -172,6 +189,7 @@ CONFIG_ARC_MMU_V3=y CONFIG_ARC_PAGE_SIZE_8K=y # CONFIG_ARC_PAGE_SIZE_16K is not set # CONFIG_ARC_PAGE_SIZE_4K is not set +# CONFIG_ARC_COMPACT_IRQ_LEVELS is not set # CONFIG_ARC_FPU_SAVE_RESTORE is not set CONFIG_ARC_CPU_REL_4_10=y CONFIG_ARC_HAS_LLSC=y @@ -183,12 +201,17 @@ CONFIG_ARC_HAS_RTSC=y # CONFIG_ARC_BOARD_ANGEL4=y # CONFIG_ARC_BOARD_ML509 is not set +# CONFIG_ISS_SMP_EXTN is not set CONFIG_ARC_SERIAL_BAUD=115200 +# CONFIG_ARC_HAS_BVCI_LAT_UNIT is not set CONFIG_ARC_PLAT_CLK=8000 CONFIG_LINUX_LINK_BASE=0x8000 CONFIG_ARC_PLAT_SDRAM_SIZE=0x1000 +CONFIG_ARC_CURR_IN_REG=y +# CONFIG_ARC_MISALIGN_ACCESS is not set # CONFIG_ARC_STACK_NONEXEC is not set CONFIG_HZ=100 +# CONFIG_ARC_METAWARE_HLINK is not set # CONFIG_ARC_DBG is not set CONFIG_CMDLINE="print-fatal-signals=1" # CONFIG_CMDLINE_UBOOT is not set @@ -208,7 +231,71 @@ CONFIG_DEFAULT_MMAP_MIN_ADDR=4096 # CONFIG_CROSS_MEMORY_ATTACH is not set CONFIG_NEED_PER_CPU_KM=y # CONFIG_CLEANCACHE is not set -# CONFIG_NET is not set +CONFIG_NET=y + +# +# Networking options +# +CONFIG_PACKET=y +# CONFIG_PACKET_DIAG is not set +CONFIG_UNIX=y +# CONFIG_UNIX_DIAG is not set +# CONFIG_XFRM_USER is not set +# CONFIG_NET_KEY is not set +CONFIG_INET=y +# CONFIG_IP_MULTICAST is not set +# CONFIG_IP_ADVANCED_ROUTER is not set +# CONFIG_IP_PNP is not set +# CONFIG_NET_IPIP is not set +# CONFIG_NET_IPGRE_DEMUX is not set +# CONFIG_ARPD is not set +# CONFIG_SYN_COOKIES is not set +# CONFIG_INET_AH is not set +# CONFIG_INET_ESP is not set +# CONFIG_INET_IPCOMP is not set +# CONFIG_INET_XFRM_TUNNEL is not set +# CONFIG_INET_TUNNEL is not set +# CONFIG_INET_XFRM_MODE_TRANSPORT is not set +# CONFIG_INET_XFRM_MODE_TUNNEL is not set +# CONFIG_INET_XFRM_MODE_BEET is not set +# CONFIG_INET_LRO is not set +CONFIG_INET_DIAG=y +CONFIG_INET_TCP_DIAG=y +# CONFIG_INET_UDP_DIAG is not set +# CONFIG_TCP_CONG_ADVANCED is not set +CONFIG_TCP_CONG_CUBIC=y +CONFIG_DEFAULT_TCP_CONG="cubic" +# CONFIG_IPV6 is not set +# CONFIG_NETWORK_SECMARK is not set +# CONFIG_NETFILTER is not set +# CONFIG_ATM is not set +# CONFIG_L2TP is not set +# CONFIG_BRIDGE is not set +# CONFIG_VLAN_8021Q is not set +# CONFIG_DECNET is not set +#
[RFC Patch v1 53/55] ARC: Hostlink Pseudo-Driver for Metaware Debugger
From: Vineet Gupta This allows ARC Target to do I/O to host in absence of any peripherals whatsoever, assisted by Metaware Hostlink facility. Further we have a FUSE based filesystem which makes us mount/access host filesystem on target and do fops. Signed-off-by: Vineet Gupta --- arch/arc/Kconfig |9 +++ arch/arc/kernel/Makefile |1 + arch/arc/kernel/arc_hostlink.c | 114 3 files changed, 124 insertions(+), 0 deletions(-) create mode 100644 arch/arc/kernel/arc_hostlink.c diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index 79e8f2f..4653070 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig @@ -394,6 +394,15 @@ config HZ int "Timer Frequency" default 100 +config ARC_METAWARE_HLINK + bool "Support for Metaware debugger assisted Host access" + default n + help + This options allows a Linux userland apps to directly access + host file system (open/creat/read/write etc) with help from + Metaware Debugger. This can come in handy for Linux-host communication + when there is no real usable peripheral such as EMAC. + menuconfig ARC_DBG bool "ARC debugging" default y diff --git a/arch/arc/kernel/Makefile b/arch/arc/kernel/Makefile index a2b7493..ce14b45 100644 --- a/arch/arc/kernel/Makefile +++ b/arch/arc/kernel/Makefile @@ -18,6 +18,7 @@ obj-$(CONFIG_ARC_DW2_UNWIND) += unwind.o obj-$(CONFIG_KPROBES) += kprobes.o obj-$(CONFIG_ARC_MISALIGN_ACCESS) += unaligned.o obj-$(CONFIG_KGDB) += kgdb.o +obj-$(CONFIG_ARC_METAWARE_HLINK) += arc_hostlink.o obj-$(CONFIG_ARC_FPU_SAVE_RESTORE) += fpu.o CFLAGS_fpu.o += -mdpfp diff --git a/arch/arc/kernel/arc_hostlink.c b/arch/arc/kernel/arc_hostlink.c new file mode 100644 index 000..de3bc42 --- /dev/null +++ b/arch/arc/kernel/arc_hostlink.c @@ -0,0 +1,114 @@ +/* + * arc_hostlink.c: Pseudo-driver for Metaware provided "hostlink" facility + * + * Allows Linux userland access to host in absence of any peripherals. + * + * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include /* file_operations */ +#include /* class_create */ +#include /* cdev */ +#include /* VM_IO */ +#include +#include + +static unsigned char __HOSTLINK__[4 * PAGE_SIZE] __aligned(PAGE_SIZE); + +static int arc_hl_mmap(struct file *fp, struct vm_area_struct *vma); +static long arc_hl_ioctl(struct file *file, unsigned int cmd, + unsigned long arg); + +static const struct file_operations arc_hl_fops = { + .owner = THIS_MODULE, + .unlocked_ioctl = arc_hl_ioctl, + .mmap = arc_hl_mmap, +}; + +static int arc_hl_major; +static int arc_hl_minor; +static int arc_hl_nr_devs = 1; +static const char arc_hl_devnm[] = "hostlink"; +static struct cdev arc_hl_cdev; +static struct class *arc_hl_class; + +static int __init arc_hl_linux_glue(void) +{ + dev_t arc_hl_dev; + int i; + + if (arc_hl_major) { /* Preallocated MAJOR */ + + arc_hl_dev = MKDEV(arc_hl_major, arc_hl_minor); + register_chrdev_region(arc_hl_dev, arc_hl_nr_devs, + arc_hl_devnm); + } else {/* allocates Major to devices */ + alloc_chrdev_region(_hl_dev, 0, arc_hl_nr_devs, + arc_hl_devnm); + arc_hl_major = MAJOR(arc_hl_dev); + } + + /* Populate sysfs entries: creates /sys/class/ sub-node for device */ + + arc_hl_class = class_create(THIS_MODULE, arc_hl_devnm); + + /* connect file ops with cdev */ + + cdev_init(_hl_cdev, _hl_fops); + arc_hl_cdev.owner = THIS_MODULE; + + /* Connect major/minor number to cdev +* makes device available. +* device nodes created with 'mknod` are probably already active. +*/ + + cdev_add(_hl_cdev, arc_hl_dev, arc_hl_nr_devs); + + /* creates /sys/devices/virtual// node with +* link from/sys/class/, needed by mdev. +*/ + + for (i = 0; i < arc_hl_nr_devs; i++) + device_create(arc_hl_class, NULL, MKDEV(MAJOR(arc_hl_dev), i), + NULL, arc_hl_devnm); + + pr_info("Hostlink dev to mknod is %d:%d\n", + arc_hl_major, arc_hl_minor); + return 0; +} + +static int __init arc_hl_init(void) +{ + arc_hl_linux_glue(); + + pr_info("Hlink buffer mmap @ 0x%p\n", __HOSTLINK__); + + return 0; +} + +static int arc_hl_mmap(struct file *fp, struct vm_area_struct *vma) +{ + vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); + + if
[RFC Patch v1 52/55] ARC: Support for single cycle Close Coupled Mem (CCM)
From: Vineet Gupta * Includes mapping of CCMs in address space * Annotations to move arbitrary code/data into CCM * Moving some of the critical code/data into CCM * Runtime detection/reporting Signed-off-by: Vineet Gupta --- arch/arc/Kconfig | 27 arch/arc/include/asm/linkage.h | 33 + arch/arc/kernel/entry.S|4 +- arch/arc/kernel/setup.c| 53 +++- arch/arc/kernel/vmlinux.lds.S | 21 arch/arc/mm/tlbex.S|5 +-- 6 files changed, 137 insertions(+), 6 deletions(-) diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index 9882ce0c..79e8f2f 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig @@ -198,6 +198,33 @@ config ARC_CACHE_PAGES endif #ARC_CACHE +config ARC_HAS_ICCM + bool "Use ICCM" + help + Single Cycle RAMS to store Fast Path Code + default n + +config ARC_ICCM_SZ + int "ICCM Size in KB" + default "64" + depends on ARC_HAS_ICCM + +config ARC_HAS_DCCM + bool "Use DCCM" + help + Single Cycle RAMS to store Fast Path Data + default n + +config ARC_DCCM_SZ + int "DCCM Size in KB" + default "64" + depends on ARC_HAS_DCCM + +config ARC_DCCM_BASE + hex "DCCM map address" + default "0xA000" + depends on ARC_HAS_DCCM + config ARC_HAS_HW_MPY bool "Use Hardware Multiplier (Normal or Faster XMAC)" default y diff --git a/arch/arc/include/asm/linkage.h b/arch/arc/include/asm/linkage.h index a45d1bb..0283e9e 100644 --- a/arch/arc/include/asm/linkage.h +++ b/arch/arc/include/asm/linkage.h @@ -25,6 +25,39 @@ .size \ name, ASM_PREV_SYM_ADDR(\name) .endm +/* annotation for data we want in DCCM - if enabled in .config */ +.macro ARCFP_DATA nm +#ifdef CONFIG_ARC_HAS_DCCM + .section .data.arcfp +#else + .section .data +#endif + .global \nm +.endm + +/* annotation for data we want in DCCM - if enabled in .config */ +.macro ARCFP_CODE +#ifdef CONFIG_ARC_HAS_ICCM + .section .text.arcfp, "ax",@progbits +#else + .section .text, "ax",@progbits +#endif +.endm + +#else /* !__ASSEMBLY__ */ + +#ifdef CONFIG_ARC_HAS_ICCM +#define __arcfp_code __attribute__((__section__(".text.arcfp"))) +#else +#define __arcfp_code __attribute__((__section__(".text"))) +#endif + +#ifdef CONFIG_ARC_HAS_DCCM +#define __arcfp_data __attribute__((__section__(".data.arcfp"))) +#else +#define __arcfp_data __attribute__((__section__(".data"))) +#endif + #endif /* __ASSEMBLY__ */ #endif diff --git a/arch/arc/kernel/entry.S b/arch/arc/kernel/entry.S index 2ff15e0..873588e 100644 --- a/arch/arc/kernel/entry.S +++ b/arch/arc/kernel/entry.S @@ -155,7 +155,7 @@ VECTOR reserved; Reserved Exceptions ;# Scratch Mem for IRQ stack switching # - .section .data ; NOT .global +ARCFP_DATA int1_saved_reg .align 32 .type int1_saved_reg, @object .size int1_saved_reg, 4 @@ -165,7 +165,7 @@ int1_saved_reg: /* Each Interrupt level needs it's own scratch */ #ifdef CONFIG_ARC_COMPACT_IRQ_LEVELS - .section .data ; NOT .global +ARCFP_DATA int2_saved_reg .type int2_saved_reg, @object .size int2_saved_reg, 4 int2_saved_reg: diff --git a/arch/arc/kernel/setup.c b/arch/arc/kernel/setup.c index d470aa1..0deec55 100644 --- a/arch/arc/kernel/setup.c +++ b/arch/arc/kernel/setup.c @@ -61,6 +61,33 @@ void __init read_arc_build_cfg_regs(void) cpu->extn.ext_arith = read_aux_reg(ARC_REG_EXTARITH_BCR); cpu->extn.crc = read_aux_reg(ARC_REG_CRC_BCR); + /* Note that we read the CCM BCRs independent of kernel config +* This is to catch the cases where user doesn't know that +* CCMs are present in hardware build +*/ + { + struct bcr_iccm iccm; + struct bcr_dccm dccm; + struct bcr_dccm_base dccm_base; + unsigned int bcr_32bit_val; + + bcr_32bit_val = read_aux_reg(ARC_REG_ICCM_BCR); + if (bcr_32bit_val) { + iccm = *((struct bcr_iccm *)_32bit_val); + cpu->iccm.base_addr = iccm.base << 16; + cpu->iccm.sz = 0x2000 << (iccm.sz - 1); + } + + bcr_32bit_val = read_aux_reg(ARC_REG_DCCM_BCR); + if (bcr_32bit_val) { + dccm = *((struct bcr_dccm *)_32bit_val); + cpu->dccm.sz = 0x800 << (dccm.sz); + + READ_BCR(ARC_REG_DCCMBASE_BCR, dccm_base); + cpu->dccm.base_addr = dccm_base.addr << 8; + } + } + READ_BCR(ARC_REG_XY_MEM_BCR, cpu->extn_xymem); read_decode_mmu_bcr(); @@ -208,6 +235,30 @@ char *arc_extn_mumbojumbo(int cpu_id, char *buf, int len) return buf; } +void __init
[RFC Patch v1 50/55] ARC: perf support (software counters only)
From: Vineet Gupta Signed-off-by: Vineet Gupta --- arch/arc/Kconfig |3 +++ arch/arc/include/asm/perf_event.h | 19 +++ 2 files changed, 22 insertions(+), 0 deletions(-) create mode 100644 arch/arc/include/asm/perf_event.h diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index b878d3e..9882ce0c 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig @@ -23,12 +23,15 @@ config ARC select HAVE_ARCH_KGDB select HAVE_ARCH_TRACEHOOK select HAVE_GENERIC_HARDIRQS + select HAVE_IRQ_WORK select HAVE_KPROBES select HAVE_KRETPROBES select HAVE_MOD_ARCH_SPECIFIC if ARC_DW2_UNWIND select HAVE_OPROFILE + select HAVE_PERF_EVENTS select HOTPLUG if !INITRAMFS_SOURCE="" select MODULES_USE_ELF_RELA + select PERF_USE_VMALLOC config SCHED_OMIT_FRAME_POINTER def_bool y diff --git a/arch/arc/include/asm/perf_event.h b/arch/arc/include/asm/perf_event.h new file mode 100644 index 000..a10eb78 --- /dev/null +++ b/arch/arc/include/asm/perf_event.h @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2011-2012 Synopsys, Inc. (www.synopsys.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + */ + +#ifndef __ASM_PERF_EVENT_H +#define __ASM_PERF_EVENT_H + +#define PERF_EVENT_INDEX_OFFSET0 + +static inline void set_perf_event_pending(void) +{ +} + +#endif /* __ASM_PERF_EVENT_H */ -- 1.7.4.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[RFC Patch v1 49/55] perf, ARC: Enable building perf tools for ARC
From: Vineet Gupta Although with uClibc there's more we need to do Signed-off-by: Vineet Gupta --- tools/perf/perf.h |6 ++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/tools/perf/perf.h b/tools/perf/perf.h index c50985e..1006b17 100644 --- a/tools/perf/perf.h +++ b/tools/perf/perf.h @@ -107,6 +107,12 @@ void get_term_dimensions(struct winsize *ws); #define CPUINFO_PROC "cpu model" #endif +#ifdef __arc__ +#define rmb() asm volatile("" ::: "memory") +#define cpu_relax()rmb() +#define CPUINFO_PROC "Processor" +#endif + #include #include #include -- 1.7.4.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[RFC Patch v1 48/55] ARC: [plat-arfpga] BVCI Latency Unit setup
From: Vineet Gupta Signed-off-by: Vineet Gupta --- arch/arc/plat-arcfpga/Kconfig| 32 + arch/arc/plat-arcfpga/platform.c | 56 ++ 2 files changed, 88 insertions(+), 0 deletions(-) diff --git a/arch/arc/plat-arcfpga/Kconfig b/arch/arc/plat-arcfpga/Kconfig index 1b65644..6bc1149 100644 --- a/arch/arc/plat-arcfpga/Kconfig +++ b/arch/arc/plat-arcfpga/Kconfig @@ -55,4 +55,36 @@ config ARC_SERIAL_LV2 depends on ARC_COMPACT_IRQ_LEVELS select ARC_IRQ5_LV2 +menuconfig ARC_HAS_BVCI_LAT_UNIT + bool "BVCI Bus Latency Unit" + depends on ARC_BOARD_ML509 || ARC_BOARD_ANGEL4 + help + IP to add artifical latency to BVCI Bus Based FPGA builds. + The default latency (even worst case) for FPGA is non-realistic + (~10 SDRAM, ~5 SSRAM). + +config BVCI_LAT_UNITS + hex "Latency Unit(s) Bitmap" + default "0x0" + depends on ARC_HAS_BVCI_LAT_UNIT + help + There are multiple Latency Units corresponding to the many + interfaces of the system bus arbiter (both CPU side as well as + the peripheral side). + To add latency to ALL memory transaction, choose Unit 0, otherwise + for finer grainer - interface wise latency, specify a bitmap (1 bit + per unit) of all units. e.g. 1,2,12 will be 0x1003 + + Unit 0 - System Arb and Mem Controller + Unit 1 - I$ and System Bus + Unit 2 - D$ and System Bus + .. + Unit 12 - IDE Disk controller and System Bus + +config BVCI_LAT_CYCLES + int "Latency Value in cycles" + range 0 63 + default "30" + depends on ARC_HAS_BVCI_LAT_UNIT + endif diff --git a/arch/arc/plat-arcfpga/platform.c b/arch/arc/plat-arcfpga/platform.c index 3243091..d5d4a10 100644 --- a/arch/arc/plat-arcfpga/platform.c +++ b/arch/arc/plat-arcfpga/platform.c @@ -17,6 +17,60 @@ #include #include +/*---BVCI Latency Unit -*/ + +#ifdef CONFIG_ARC_HAS_BVCI_LAT_UNIT + +int lat_cycles = CONFIG_BVCI_LAT_CYCLES; + +/* BVCI Bus Profiler: Latency Unit */ +static void __init setup_bvci_lat_unit(void) +{ +#define MAX_BVCI_UNITS 12 + + /* TBD: rewrite this using I/O macros */ + volatile unsigned int *base = (unsigned int *)BVCI_LAT_UNIT_BASE; + volatile unsigned int *lat_unit = (unsigned int *)base + 21; + volatile unsigned int *lat_val = (unsigned int *)base + 22; + unsigned int unit; + const unsigned long units_req = CONFIG_BVCI_LAT_UNITS; + + /* +* There are multiple Latency Units corresponding to the many +* interfaces of the system bus arbiter (both CPU side as well as +* the peripheral side). +* +* Unit 0 - System Arb and Mem Controller - adds latency to all +* memory trasactions +* Unit 1 - I$ and System Bus +* Unit 2 - D$ and System Bus +* .. +* Unit 12 - IDE Disk controller and System Bus +* +* The programmers model requires writing to lat_unit reg first +* and then the latency value (cycles) to lat_value reg +*/ + + if (CONFIG_BVCI_LAT_UNITS == 0) { + *lat_unit = 0; + *lat_val = lat_cycles; + pr_info("BVCI Latency for all Memory Transactions %d cycles\n", + lat_cycles); + } else { + for_each_set_bit(unit, _req, MAX_BVCI_UNITS) { + *lat_unit = unit + 1; /* above returns 0 based */ + *lat_val = lat_cycles; + pr_info("BVCI Latency for Unit[%d] = %d cycles\n", + (unit + 1), lat_cycles); + } + } +} +#else +static void __init setup_bvci_lat_unit(void) +{ +} +#endif + /*--- Platform Devices -*/ #if defined(CONFIG_SERIAL_ARC) || defined(CONFIG_SERIAL_ARC_MODULE) @@ -111,6 +165,8 @@ void __init arc_platform_early_init(void) { pr_info("[plat-arcfpga]: registering early dev resources\n"); + setup_bvci_lat_unit(); + arc_fpga_serial_init(); } -- 1.7.4.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[RFC Patch v1 47/55] ARC: startup #2: Verbose Boot reporting / feature verification
From: Vineet Gupta Signed-off-by: Vineet Gupta --- arch/arc/Makefile |2 + arch/arc/include/asm/arcregs.h | 122 -- arch/arc/include/asm/defines.h | 56 ++ arch/arc/include/asm/setup.h | 14 +++ arch/arc/kernel/setup.c| 223 +++- arch/arc/mm/cache_arc700.c | 46 arch/arc/mm/tlb.c | 38 +++ 7 files changed, 490 insertions(+), 11 deletions(-) create mode 100644 arch/arc/include/asm/defines.h diff --git a/arch/arc/Makefile b/arch/arc/Makefile index a86e284..3de315e 100644 --- a/arch/arc/Makefile +++ b/arch/arc/Makefile @@ -20,6 +20,8 @@ export PLATFORM cflags-y += -Iarch/arc/plat-$(PLATFORM)/include cflags-y += -mA7 -fno-common -pipe -fno-builtin -D__linux__ +LINUXINCLUDE += -include ${src}/arch/arc/include/asm/defines.h + ifdef CONFIG_ARC_CURR_IN_REG # For a global register defintion, make sure it gets passed to every file # We had a customer reported bug where some code built in kernel was NOT using diff --git a/arch/arc/include/asm/arcregs.h b/arch/arc/include/asm/arcregs.h index 725b94c..bd126c9 100644 --- a/arch/arc/include/asm/arcregs.h +++ b/arch/arc/include/asm/arcregs.h @@ -12,8 +12,26 @@ #ifdef __KERNEL__ /* Build Configuration Registers */ +#define ARC_REG_DCCMBASE_BCR 0x61/* DCCM Base Addr */ +#define ARC_REG_CRC_BCR0x62 +#define ARC_REG_DVFB_BCR 0x64 +#define ARC_REG_EXTARITH_BCR 0x65 #define ARC_REG_VECBASE_BCR0x68 +#define ARC_REG_PERIBASE_BCR 0x69 +#define ARC_REG_FP_BCR 0x6B/* Single-Precision FPU */ +#define ARC_REG_DPFP_BCR 0x6C/* Dbl Precision FPU */ #define ARC_REG_MMU_BCR0x6f +#define ARC_REG_DCCM_BCR 0x74/* DCCM Present + SZ */ +#define ARC_REG_TIMERS_BCR 0x75 +#define ARC_REG_ICCM_BCR 0x78 +#define ARC_REG_XY_MEM_BCR 0x79 +#define ARC_REG_MAC_BCR0x7a +#define ARC_REG_MUL_BCR0x7b +#define ARC_REG_SWAP_BCR 0x7c +#define ARC_REG_NORM_BCR 0x7d +#define ARC_REG_MIXMAX_BCR 0x7e +#define ARC_REG_BARREL_BCR 0x7f +#define ARC_REG_D_UNCACH_BCR 0x6A /* status32 Bits Positions */ #define STATUS_H_BIT 0 /* CPU Halted */ @@ -87,16 +105,6 @@ #define TIMER_CTRL_IE (1 << 0) /* Interupt when Count reachs limit */ #define TIMER_CTRL_NH (1 << 1) /* Count only when CPU NOT halted */ -#if defined(CONFIG_ARC_MMU_V1) -#define CONFIG_ARC_MMU_VER 1 -#elif defined(CONFIG_ARC_MMU_V2) -#define CONFIG_ARC_MMU_VER 2 -#elif defined(CONFIG_ARC_MMU_V3) -#define CONFIG_ARC_MMU_VER 3 -#else -#error "Error: MMU ver" -#endif - /* MMU Management regs */ #define ARC_REG_TLBPD0 0x405 #define ARC_REG_TLBPD1 0x406 @@ -276,6 +284,13 @@ struct arc_fpu { *** * Build Configuration Registers, with encoded hardware config */ +struct bcr_identity { +#ifdef CONFIG_CPU_BIG_ENDIAN + unsigned int chip_id:16, cpu_id:8, family:8; +#else + unsigned int family:8, cpu_id:8, chip_id:16; +#endif +}; struct bcr_mmu_1_2 { #ifdef CONFIG_CPU_BIG_ENDIAN @@ -295,6 +310,38 @@ struct bcr_mmu_3 { #endif }; +#define EXTN_SWAP_VALID 0x1 +#define EXTN_NORM_VALID 0x2 +#define EXTN_MINMAX_VALID 0x2 +#define EXTN_BARREL_VALID 0x2 + +struct bcr_extn { +#ifdef CONFIG_CPU_BIG_ENDIAN + unsigned int pad:20, crc:1, ext_arith:2, mul:2, barrel:2, minmax:2, +norm:2, swap:1; +#else + unsigned int swap:1, norm:2, minmax:2, barrel:2, mul:2, ext_arith:2, +crc:1, pad:20; +#endif +}; + +/* DSP Options Ref Manual */ +struct bcr_extn_mac_mul { +#ifdef CONFIG_CPU_BIG_ENDIAN + unsigned int pad:16, type:8, ver:8; +#else + unsigned int ver:8, type:8, pad:16; +#endif +}; + +struct bcr_extn_xymem { +#ifdef CONFIG_CPU_BIG_ENDIAN + unsigned int ram_org:2, num_banks:4, bank_sz:4, ver:8; +#else + unsigned int ver:8, bank_sz:4, num_banks:4, ram_org:2; +#endif +}; + struct bcr_cache { #ifdef CONFIG_CPU_BIG_ENDIAN unsigned int pad:12, line_len:4, sz:4, config:4, ver:8; @@ -303,6 +350,48 @@ struct bcr_cache { #endif }; +struct bcr_perip { +#ifdef CONFIG_CPU_BIG_ENDIAN + unsigned int start:8, pad2:8, sz:8, pad:8; +#else + unsigned int pad:8, sz:8, pad2:8, start:8; +#endif +}; +struct bcr_iccm { +#ifdef CONFIG_CPU_BIG_ENDIAN + unsigned int base:16, pad:5, sz:3, ver:8; +#else + unsigned int ver:8, sz:3, pad:5, base:16; +#endif +}; + +/* DCCM Base Address Register: ARC_REG_DCCMBASE_BCR */ +struct bcr_dccm_base { +#ifdef CONFIG_CPU_BIG_ENDIAN + unsigned int addr:24, ver:8; +#else + unsigned int ver:8, addr:24; +#endif +}; + +/* DCCM RAM Configuration Register: ARC_REG_DCCM_BCR */ +struct bcr_dccm { +#ifdef CONFIG_CPU_BIG_ENDIAN + unsigned int res:21, sz:3, ver:8; +#else + unsigned int ver:8,
[RFC Patch v1 45/55] ARC: unaligned access emulation
From: Vineet Gupta Signed-off-by: Vineet Gupta --- arch/arc/Kconfig |9 ++ arch/arc/include/asm/Kbuild |1 - arch/arc/include/asm/ptrace.h|3 + arch/arc/include/asm/unaligned.h | 29 + arch/arc/kernel/Makefile |3 +- arch/arc/kernel/disasm.c |2 +- arch/arc/kernel/entry.S | 13 ++ arch/arc/kernel/traps.c | 26 + arch/arc/kernel/unaligned.c | 225 ++ 9 files changed, 308 insertions(+), 3 deletions(-) create mode 100644 arch/arc/include/asm/unaligned.h create mode 100644 arch/arc/kernel/unaligned.c diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index 3ef21be..81d78fc 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig @@ -343,6 +343,15 @@ config ARC_CURR_IN_REG This reserved Register R25 to point to Current Task in kernel mode. This saves memory access for each such access + +config ARC_MISALIGN_ACCESS + bool "Emulate unaligned memory access (userspace only)" + default N + help + This enables misaligned 16 & 32 bit memory access from user space. + Use ONLY-IF-ABS-NECESSARY as it will be very slow and also can hide + potential bugs in code + config ARC_STACK_NONEXEC bool "Make stack non-executable" default n diff --git a/arch/arc/include/asm/Kbuild b/arch/arc/include/asm/Kbuild index a246390..06ca702 100644 --- a/arch/arc/include/asm/Kbuild +++ b/arch/arc/include/asm/Kbuild @@ -51,7 +51,6 @@ generic-y += termios.h generic-y += topology.h generic-y += types.h generic-y += ucontext.h -generic-y += unaligned.h generic-y += user.h generic-y += vga.h generic-y += xor.h diff --git a/arch/arc/include/asm/ptrace.h b/arch/arc/include/asm/ptrace.h index bb621e8..2843dd4 100644 --- a/arch/arc/include/asm/ptrace.h +++ b/arch/arc/include/asm/ptrace.h @@ -117,6 +117,9 @@ struct user_regs_struct { /* return 1 if user mode or 0 if kernel mode */ #define user_mode(regs) (regs->status32 & STATUS_U_MASK) +/* return 1 if PC in delay slot */ +#define delay_mode(regs) ((regs->status32 & STATUS_DE_MASK) == STATUS_DE_MASK) + /* return 1 if in syscall, 0 if Intr or Exception */ #define in_syscall(regs) (((regs->orig_r8) >= 0 && \ (regs->orig_r8 <= NR_syscalls)) ? 1 : 0) diff --git a/arch/arc/include/asm/unaligned.h b/arch/arc/include/asm/unaligned.h new file mode 100644 index 000..5dbe63f --- /dev/null +++ b/arch/arc/include/asm/unaligned.h @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef _ASM_ARC_UNALIGNED_H +#define _ASM_ARC_UNALIGNED_H + +/* ARC700 can't handle unaligned Data accesses. */ + +#include +#include + +#ifdef CONFIG_ARC_MISALIGN_ACCESS +int misaligned_fixup(unsigned long address, struct pt_regs *regs, +unsigned long cause, struct callee_regs *cregs); +#else +static inline int +misaligned_fixup(unsigned long address, struct pt_regs *regs, +unsigned long cause, struct callee_regs *cregs) +{ + return 0; +} +#endif + +#endif /* _ASM_ARC_UNALIGNED_H */ diff --git a/arch/arc/kernel/Makefile b/arch/arc/kernel/Makefile index 442d024..52ef6ce 100644 --- a/arch/arc/kernel/Makefile +++ b/arch/arc/kernel/Makefile @@ -9,13 +9,14 @@ CFLAGS_ptrace.o+= -DUTS_MACHINE='"$(UTS_MACHINE)"' obj-y := arcksyms.o setup.o irq.o time.o reset.o ptrace.o entry.o process.o \ - signal.o traps.o sys.o troubleshoot.o stacktrace.o disasm.c + signal.o traps.o sys.o troubleshoot.o stacktrace.o disasm.o obj-$(CONFIG_MODULES) += arcksyms.o module.o obj-$(CONFIG_ARC_DBG_EVENT_TIMELINE) += event-log.o obj-$(CONFIG_SMP) += smp.o obj-$(CONFIG_ARC_DW2_UNWIND) += unwind.o obj-$(CONFIG_KPROBES) += kprobes.o +obj-$(CONFIG_ARC_MISALIGN_ACCESS) += unaligned.o obj-$(CONFIG_ARC_FPU_SAVE_RESTORE) += fpu.o CFLAGS_fpu.o += -mdpfp diff --git a/arch/arc/kernel/disasm.c b/arch/arc/kernel/disasm.c index 51bad8f..2f39028 100644 --- a/arch/arc/kernel/disasm.c +++ b/arch/arc/kernel/disasm.c @@ -15,7 +15,7 @@ #include #include -#if defined(CONFIG_KGDB) || defined(CONFIG_MISALIGN_ACCESS) || \ +#if defined(CONFIG_KGDB) || defined(CONFIG_ARC_MISALIGN_ACCESS) || \ defined(CONFIG_KPROBES) /* disasm_instr: Analyses instruction at addr, stores diff --git a/arch/arc/kernel/entry.S b/arch/arc/kernel/entry.S index 13d6feb..2ff15e0 100644 --- a/arch/arc/kernel/entry.S +++ b/arch/arc/kernel/entry.S @@ -12,6 +12,9 @@ * needed before task_pt_regs was invented. This saves a branch per call * and more importantly allows clean invocation of post-syscall ptrace hook * + * vineetg:
[RFC Patch v1 44/55] ARC: kprobes support
From: Vineet Gupta Origin port done by Rajeshwar Ranga Signed-off-by: Vineet Gupta --- arch/arc/Kconfig |2 + arch/arc/include/asm/kprobes.h | 62 + arch/arc/kernel/Makefile |1 + arch/arc/kernel/disasm.c |5 +- arch/arc/kernel/kprobes.c | 525 arch/arc/kernel/traps.c| 13 + 6 files changed, 605 insertions(+), 3 deletions(-) create mode 100644 arch/arc/include/asm/kprobes.h create mode 100644 arch/arc/kernel/kprobes.c diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index 26609d6..3ef21be 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig @@ -22,6 +22,8 @@ config ARC select GENERIC_SMP_IDLE_THREAD select HAVE_ARCH_TRACEHOOK select HAVE_GENERIC_HARDIRQS + select HAVE_KPROBES + select HAVE_KRETPROBES select HAVE_MOD_ARCH_SPECIFIC if ARC_DW2_UNWIND select HAVE_OPROFILE select HOTPLUG if !INITRAMFS_SOURCE="" diff --git a/arch/arc/include/asm/kprobes.h b/arch/arc/include/asm/kprobes.h new file mode 100644 index 000..4d9c211 --- /dev/null +++ b/arch/arc/include/asm/kprobes.h @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef _ARC_KPROBES_H +#define _ARC_KPROBES_H + +#ifdef CONFIG_KPROBES + +typedef u16 kprobe_opcode_t; + +#define UNIMP_S_INSTRUCTION 0x79e0 +#define TRAP_S_2_INSTRUCTION 0x785e + +#define MAX_INSN_SIZE 8 +#define MAX_STACK_SIZE 64 + +struct arch_specific_insn { + int is_short; + kprobe_opcode_t *t1_addr, *t2_addr; + kprobe_opcode_t t1_opcode, t2_opcode; +}; + +#define flush_insn_slot(p) do { } while (0) + +#define kretprobe_blacklist_size0 + +struct kprobe; + +void arch_remove_kprobe(struct kprobe *p); + +int kprobe_exceptions_notify(struct notifier_block *self, +unsigned long val, void *data); + +struct prev_kprobe { + struct kprobe *kp; + unsigned long status; +}; + +struct kprobe_ctlblk { + unsigned int kprobe_status; + struct pt_regs jprobe_saved_regs; + char jprobes_stack[MAX_STACK_SIZE]; + struct prev_kprobe prev_kprobe; +}; + +int kprobe_fault_handler(struct pt_regs *regs, unsigned long cause); +void kretprobe_trampoline(void); +void trap_is_kprobe(unsigned long cause, unsigned long address, + struct pt_regs *regs); +#else +static void trap_is_kprobe(unsigned long cause, unsigned long address, + struct pt_regs *regs) +{ +} +#endif + +#endif diff --git a/arch/arc/kernel/Makefile b/arch/arc/kernel/Makefile index 1fc0461..442d024 100644 --- a/arch/arc/kernel/Makefile +++ b/arch/arc/kernel/Makefile @@ -15,6 +15,7 @@ obj-$(CONFIG_MODULES) += arcksyms.o module.o obj-$(CONFIG_ARC_DBG_EVENT_TIMELINE) += event-log.o obj-$(CONFIG_SMP) += smp.o obj-$(CONFIG_ARC_DW2_UNWIND) += unwind.o +obj-$(CONFIG_KPROBES) += kprobes.o obj-$(CONFIG_ARC_FPU_SAVE_RESTORE) += fpu.o CFLAGS_fpu.o += -mdpfp diff --git a/arch/arc/kernel/disasm.c b/arch/arc/kernel/disasm.c index 254d11a..51bad8f 100644 --- a/arch/arc/kernel/disasm.c +++ b/arch/arc/kernel/disasm.c @@ -497,9 +497,8 @@ void __kprobes set_reg(int reg, long val, struct pt_regs *regs, * @pc +2/4/6 (ARCompact ISA allows free intermixing of 16/32 bit insns). * * If @pc is a branch - * -@tgt_if_br is set to branch target. - * -If branch has delay slot, @next_pc updated with actual next PC. - * + * -@tgt_if_br is set to branch target. + * -If branch has delay slot, @next_pc updated with actual next PC. */ int __kprobes disasm_next_pc(unsigned long pc, struct pt_regs *regs, struct callee_regs *cregs, diff --git a/arch/arc/kernel/kprobes.c b/arch/arc/kernel/kprobes.c new file mode 100644 index 000..47e42f2 --- /dev/null +++ b/arch/arc/kernel/kprobes.c @@ -0,0 +1,525 @@ +/* + * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define MIN_STACK_SIZE(addr) min((unsigned long)MAX_STACK_SIZE, \ + (unsigned long)current_thread_info() + THREAD_SIZE - (addr)) + +DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL; +DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk); + +int __kprobes arch_prepare_kprobe(struct kprobe *p) +{ + /* Attempt to probe at unaligned address */ + if ((unsigned long)p->addr &
[RFC Patch v1 43/55] ARC: disassembly (needed by kprobes/kgdb/unaligned-access-emul)
From: Vineet Gupta Orig written by Rajeshwar Ranga Consolidation/cleanups by Mischa Jonker Signed-off-by: Vineet Gupta --- arch/arc/include/asm/disasm.h | 116 + arch/arc/kernel/Makefile |2 +- arch/arc/kernel/disasm.c | 539 + 3 files changed, 656 insertions(+), 1 deletions(-) create mode 100644 arch/arc/include/asm/disasm.h create mode 100644 arch/arc/kernel/disasm.c diff --git a/arch/arc/include/asm/disasm.h b/arch/arc/include/asm/disasm.h new file mode 100644 index 000..f1cce3d --- /dev/null +++ b/arch/arc/include/asm/disasm.h @@ -0,0 +1,116 @@ +/* + * several functions that help interpret ARC instructions + * used for unaligned accesses, kprobes and kgdb + * + * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef __ARC_DISASM_H__ +#define __ARC_DISASM_H__ + +enum { + op_Bcc = 0, op_BLcc = 1, op_LD = 2, op_ST = 3, op_MAJOR_4 = 4, + op_MAJOR_5 = 5, op_LD_ADD = 12, op_ADD_SUB_SHIFT = 13, + op_ADD_MOV_CMP = 14, op_S = 15, op_LD_S = 16, op_LDB_S = 17, + op_LDW_S = 18, op_LDWX_S = 19, op_ST_S = 20, op_STB_S = 21, + op_STW_S = 22, op_Su5 = 23, op_SP = 24, op_GP = 25, + op_Pcl = 26, op_MOV_S = 27, op_ADD_CMP = 28, op_BR_S = 29, + op_B_S = 30, op_BL_S = 31 +}; + +enum flow { + noflow, + direct_jump, + direct_call, + indirect_jump, + indirect_call, + invalid_instr +}; + +#define IS_BIT(word, n)((word) & (1<> (s)) & (~((-2) << ((e) - (s) + +#define MAJOR_OPCODE(word) (BITS((word), 27, 31)) +#define MINOR_OPCODE(word) (BITS((word), 16, 21)) +#define FIELD_A(word) (BITS((word), 0, 5)) +#define FIELD_B(word) ((BITS((word), 12, 14)<<3) | \ + (BITS((word), 24, 26))) +#define FIELD_C(word) (BITS((word), 6, 11)) +#define FIELD_u6(word) FIELDC(word) +#define FIELD_s12(word)sign_extend(((BITS((word), 0, 5) << 6) | \ + BITS((word), 6, 11)), 12) + +/* note that for BL/BRcc these two macro's need another AND statement to mask + * out bit 1 (make the result a multiple of 4) */ +#define FIELD_s9(word) sign_extend(((BITS(word, 15, 15) << 8) | \ + BITS(word, 16, 23)), 9) +#define FIELD_s21(word)sign_extend(((BITS(word, 6, 15) << 11) | \ + (BITS(word, 17, 26) << 1)), 12) +#define FIELD_s25(word)sign_extend(((BITS(word, 0, 3) << 21) | \ + (BITS(word, 6, 15) << 11) | \ + (BITS(word, 17, 26) << 1)), 12) + +/* note: these operate on 16 bits! */ +#define FIELD_S_A(word)((BITS((word), 2, 2)<<3) | BITS((word), 0, 2)) +#define FIELD_S_B(word)((BITS((word), 10, 10)<<3) | \ + BITS((word), 8, 10)) +#define FIELD_S_C(word)((BITS((word), 7, 7)<<3) | BITS((word), 5, 7)) +#define FIELD_S_H(word)((BITS((word), 0, 2)<<3) | BITS((word), 5, 8)) +#define FIELD_S_u5(word) (BITS((word), 0, 4)) +#define FIELD_S_u6(word) (BITS((word), 0, 4) << 1) +#define FIELD_S_u7(word) (BITS((word), 0, 4) << 2) +#define FIELD_S_u10(word) (BITS((word), 0, 7) << 2) +#define FIELD_S_s7(word) sign_extend(BITS((word), 0, 5) << 1, 9) +#define FIELD_S_s8(word) sign_extend(BITS((word), 0, 7) << 1, 9) +#define FIELD_S_s9(word) sign_extend(BITS((word), 0, 8), 9) +#define FIELD_S_s10(word) sign_extend(BITS((word), 0, 8) << 1, 10) +#define FIELD_S_s11(word) sign_extend(BITS((word), 0, 8) << 2, 11) +#define FIELD_S_s13(word) sign_extend(BITS((word), 0, 10) << 2, 13) + +#define STATUS32_L 0x0100 +#define REG_LIMM 62 + +struct disasm_state { + /* generic info */ + unsigned long words[2]; + int instr_len; + int major_opcode; + /* info for branch/jump */ + int is_branch; + int target; + int delay_slot; + enum flow flow; + /* info for load/store */ + int src1, src2, src3, dest, wb_reg; + int zz, aa, x, pref, di; + int fault, write; +}; + +static inline int sign_extend(int value, int bits) +{ + if (IS_BIT(value, (bits - 1))) + value |= (0x << bits); + + return value; +} + +static inline int is_short_instr(unsigned long addr) +{ + uint16_t word = *((uint16_t *)addr); + int opcode = (word >> 11) & 0x1F; + return (opcode >= 0x0B); +} + +void disasm_instr(unsigned long addr, struct disasm_state *state, + int userspace, struct pt_regs *regs, struct
[RFC Patch v1 41/55] ARC: dwarf2 stack unwinder
From: Vineet Gupta -Originally controbuted by Rajeshwar Range -Derived off of generic unwinder in 2.6.19 and adapted to ARC Signed-off-by: Vineet Gupta --- arch/arc/Kconfig | 15 + arch/arc/include/asm/module.h |7 + arch/arc/include/asm/unwind.h | 163 + arch/arc/kernel/Makefile |6 + arch/arc/kernel/entry.S |9 + arch/arc/kernel/module.c | 42 ++ arch/arc/kernel/setup.c |3 + arch/arc/kernel/unwind.c | 1329 + arch/arc/kernel/vmlinux.lds.S | 23 +- 9 files changed, 1596 insertions(+), 1 deletions(-) create mode 100644 arch/arc/include/asm/unwind.h create mode 100644 arch/arc/kernel/unwind.c diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index 8d72ada..26609d6 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig @@ -22,6 +22,7 @@ config ARC select GENERIC_SMP_IDLE_THREAD select HAVE_ARCH_TRACEHOOK select HAVE_GENERIC_HARDIRQS + select HAVE_MOD_ARCH_SPECIFIC if ARC_DW2_UNWIND select HAVE_OPROFILE select HOTPLUG if !INITRAMFS_SOURCE="" select MODULES_USE_ELF_RELA @@ -355,6 +356,20 @@ menuconfig ARC_DBG bool "ARC debugging" default y +config ARC_DW2_UNWIND + bool "Enable DWARF specific kernel stack unwind" + depends on ARC_DBG + default y + select KALLSYMS + help + Compiles the kernel with DWARF unwind information and can be used + to get stack backtraces. + + If you say Y here the resulting kernel image will be slightly larger + but not slower, and it will give very useful debugging information. + If you don't debug the kernel, you can say N, but we may not be able + to solve problems without frame unwind information + config ARC_DBG_TLB_PARANOIA bool "Paranoia Checks in Low Level TLB Handlers" depends on ARC_DBG && !SMP diff --git a/arch/arc/include/asm/module.h b/arch/arc/include/asm/module.h index 234b435..518222b 100644 --- a/arch/arc/include/asm/module.h +++ b/arch/arc/include/asm/module.h @@ -14,6 +14,13 @@ #include +#ifdef CONFIG_ARC_DW2_UNWIND +struct mod_arch_specific { + void *unw_info; + int unw_sec_idx; +}; +#endif + #define MODULE_PROC_FAMILY "ARC700" #define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY diff --git a/arch/arc/include/asm/unwind.h b/arch/arc/include/asm/unwind.h new file mode 100644 index 000..7ca628b --- /dev/null +++ b/arch/arc/include/asm/unwind.h @@ -0,0 +1,163 @@ +/* + * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef _ASM_ARC_UNWIND_H +#define _ASM_ARC_UNWIND_H + +#ifdef CONFIG_ARC_DW2_UNWIND + +#include + +struct arc700_regs { + unsigned long r0; + unsigned long r1; + unsigned long r2; + unsigned long r3; + unsigned long r4; + unsigned long r5; + unsigned long r6; + unsigned long r7; + unsigned long r8; + unsigned long r9; + unsigned long r10; + unsigned long r11; + unsigned long r12; + unsigned long r13; + unsigned long r14; + unsigned long r15; + unsigned long r16; + unsigned long r17; + unsigned long r18; + unsigned long r19; + unsigned long r20; + unsigned long r21; + unsigned long r22; + unsigned long r23; + unsigned long r24; + unsigned long r25; + unsigned long r26; + unsigned long r27; /* fp */ + unsigned long r28; /* sp */ + unsigned long r29; + unsigned long r30; + unsigned long r31; /* blink */ + unsigned long r63; /* pc */ +}; + +struct unwind_frame_info { + struct arc700_regs regs; + struct task_struct *task; + unsigned call_frame:1; +}; + +#define UNW_PC(frame) ((frame)->regs.r63) +#define UNW_SP(frame) ((frame)->regs.r28) +#define UNW_BLINK(frame) ((frame)->regs.r31) + +/* Rajesh FIXME */ +#ifdef CONFIG_FRAME_POINTER +#define UNW_FP(frame) ((frame)->regs.r27) +#define FRAME_RETADDR_OFFSET 4 +#define FRAME_LINK_OFFSET 0 +#define STACK_BOTTOM_UNW(tsk) STACK_LIMIT((tsk)->thread.ksp) +#define STACK_TOP_UNW(tsk) ((tsk)->thread.ksp) +#else +#define UNW_FP(frame) ((void)(frame), 0) +#endif + +#define STACK_LIMIT(ptr) (((ptr) - 1) & ~(THREAD_SIZE - 1)) + +#define UNW_REGISTER_INFO \ + PTREGS_INFO(r0), \ + PTREGS_INFO(r1), \ + PTREGS_INFO(r2), \ + PTREGS_INFO(r3), \ + PTREGS_INFO(r4), \ + PTREGS_INFO(r5), \ + PTREGS_INFO(r6), \ + PTREGS_INFO(r7), \ + PTREGS_INFO(r8), \ + PTREGS_INFO(r9), \ + PTREGS_INFO(r10), \ + PTREGS_INFO(r11), \ + PTREGS_INFO(r12), \ +
[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 39/55] ARC: kernel diagnostics: show_regs() etc
From: Vineet Gupta Signed-off-by: Vineet Gupta --- arch/arc/kernel/troubleshoot.c | 304 arch/arc/mm/tlbex.S| 20 +++ 2 files changed, 324 insertions(+), 0 deletions(-) diff --git a/arch/arc/kernel/troubleshoot.c b/arch/arc/kernel/troubleshoot.c index 80bfe2a..8a816f2 100644 --- a/arch/arc/kernel/troubleshoot.c +++ b/arch/arc/kernel/troubleshoot.c @@ -6,12 +6,316 @@ */ #include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Common routine to print scratch regs (r0-r12) or callee regs (r13-r25) + * -Prints 3 regs per line and a CR. + * -To continue, callee regs right after scratch, special handling of CR + */ +static noinline void print_reg_file(long *reg_rev, int start_num) +{ + unsigned int i; + char buf[512]; + int n = 0, len = sizeof(buf); + + /* weird loop because pt_regs regs rev r12..r0, r25..r13 */ + for (i = start_num; i < start_num + 13; i++) { + n += scnprintf(buf + n, len - n, "r%02u: 0x%08lx\t", + i, (unsigned long)*reg_rev); + + if (((i + 1) % 3) == 0) + n += scnprintf(buf + n, len - n, "\n"); + + reg_rev--; + } + + if (start_num != 0) + n += scnprintf(buf + n, len - n, "\n\n"); + + pr_info("%s", buf); +} + +static void show_callee_regs(struct callee_regs *cregs) +{ + print_reg_file(&(cregs->r13), 13); +} + +void print_task_path_n_nm(struct task_struct *task, char *buf) +{ + struct path path; + char *nm = NULL; + struct mm_struct *mm; + struct file *exe_file; + char comm_buf[TASK_COMM_LEN]; + + mm = get_task_mm(task); + if (!mm) + goto done; + + exe_file = get_mm_exe_file(mm); + mmput(mm); + + if (exe_file) { + path = exe_file->f_path; + path_get(_file->f_path); + fput(exe_file); + nm = d_path(, buf, 255); + path_put(); + } + +done: + pr_info("task = %s '%s', TGID %u PID = %u\n", nm, + get_task_comm(comm_buf, task), task->tgid, task->pid); +} +EXPORT_SYMBOL(print_task_path_n_nm); + +static void show_faulting_vma(unsigned long address, char *buf) +{ + struct vm_area_struct *vma; + struct inode *inode; + unsigned long ino = 0; + dev_t dev = 0; + char *nm = buf; + + vma = find_vma(current->active_mm, address); + + /* check against the find_vma( ) behaviour which returns the next VMA +* if the container VMA is not found +*/ + if (vma && (vma->vm_start <= address)) { + struct file *file = vma->vm_file; + if (file) { + struct path *path = >f_path; + nm = d_path(path, buf, PAGE_SIZE - 1); + inode = vma->vm_file->f_path.dentry->d_inode; + dev = inode->i_sb->s_dev; + ino = inode->i_ino; + } + pr_info("@off 0x%lx in [%s]\n" + "VMA: 0x%08lx to 0x%08lx\n\n", + address - vma->vm_start, nm, vma->vm_start, vma->vm_end); + } else + pr_info("@No matching VMA found\n"); +} + +static void show_ecr_verbose(struct pt_regs *regs) +{ + unsigned int vec, cause_code, cause_reg; + unsigned long address; + + cause_reg = current->thread.cause_code; + pr_info("\n[ECR]: 0x%08x => ", cause_reg); + + /* For Data fault, this is data address not instruction addr */ + address = current->thread.fault_address; + + vec = cause_reg >> 16; + cause_code = (cause_reg >> 8) & 0xFF; + + /* For DTLB Miss or ProtV, display the memory involved too */ + if (vec == ECR_V_DTLB_MISS) { + pr_cont("Invalid (%s) @ 0x%08lx by insn @ 0x%08lx\n", + (cause_code == 0x01) ? "Read From" : + ((cause_code == 0x02) ? "Write to" : "EX"), + address, regs->ret); + } else if (vec == ECR_V_ITLB_MISS) { + pr_cont("Insn could not be fetched\n"); + } else if (vec == ECR_V_MACH_CHK) { + pr_cont("%s\n", (cause_code == 0x0) ? + "Double Fault" : "Other Fatal Err"); + + } else if (vec == ECR_V_PROTV) { + if (cause_code == ECR_C_PROTV_INST_FETCH) + pr_cont("Execute from Non-exec Page\n"); + else if (cause_code == ECR_C_PROTV_LOAD) + pr_cont("Read from Non-readable Page\n"); + else if (cause_code == ECR_C_PROTV_STORE) + pr_cont("Write to Non-writable Page\n"); + else if (cause_code == ECR_C_PROTV_XCHG) + pr_cont("Data exchange protection violation\n"); +
[RFC Patch v1 37/55] ARC: dynamic loadable module support
From: Vineet Gupta Signed-off-by: Vineet Gupta --- arch/arc/include/asm/module.h |4 ++ arch/arc/kernel/Makefile |1 + arch/arc/kernel/module.c | 117 + 3 files changed, 122 insertions(+), 0 deletions(-) create mode 100644 arch/arc/kernel/module.c diff --git a/arch/arc/include/asm/module.h b/arch/arc/include/asm/module.h index 165d768..234b435 100644 --- a/arch/arc/include/asm/module.h +++ b/arch/arc/include/asm/module.h @@ -14,4 +14,8 @@ #include +#define MODULE_PROC_FAMILY "ARC700" + +#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY + #endif /* _ASM_ARC_MODULE_H */ diff --git a/arch/arc/kernel/Makefile b/arch/arc/kernel/Makefile index 4ddef9a..9151bbe 100644 --- a/arch/arc/kernel/Makefile +++ b/arch/arc/kernel/Makefile @@ -11,6 +11,7 @@ CFLAGS_ptrace.o += -DUTS_MACHINE='"$(UTS_MACHINE)"' obj-y := arcksyms.o setup.o irq.o time.o reset.o ptrace.o entry.o process.o \ signal.o traps.o sys.o troubleshoot.o stacktrace.o +obj-$(CONFIG_MODULES) += arcksyms.o module.o obj-$(CONFIG_ARC_FPU_SAVE_RESTORE) += fpu.o CFLAGS_fpu.o += -mdpfp diff --git a/arch/arc/kernel/module.c b/arch/arc/kernel/module.c new file mode 100644 index 000..cc13df4 --- /dev/null +++ b/arch/arc/kernel/module.c @@ -0,0 +1,117 @@ +/* + * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +static inline void arc_write_me(unsigned short *addr, unsigned long value) +{ + *addr = (value & 0x) >> 16; + *(addr + 1) = (value & 0x); +} + +void *module_alloc(unsigned long size) +{ + if (size == 0) + return NULL; + + return vmalloc(size); + +} + +void module_free(struct module *module, void *region) +{ + vfree(region); +} + +int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs, + char *secstr, struct module *mod) +{ +return 0; +} + +void module_arch_cleanup(struct module *mod) +{ +} + +int apply_relocate_add(Elf32_Shdr *sechdrs, + const char *strtab, + unsigned int symindex, /* sec index for sym tbl */ + unsigned int relsec, /* sec index for relo sec */ + struct module *module) +{ + int i, n; + Elf32_Rela *rel_entry = (void *)sechdrs[relsec].sh_addr; + Elf32_Sym *sym_entry, *sym_sec; + Elf32_Addr relocation; + Elf32_Addr location; + Elf32_Addr sec_to_patch; + int relo_type; + + sec_to_patch = sechdrs[sechdrs[relsec].sh_info].sh_addr; + sym_sec = (Elf32_Sym *) sechdrs[symindex].sh_addr; + n = sechdrs[relsec].sh_size / sizeof(*rel_entry); + + pr_debug("\n== Module Sym reloc ===\n"); + pr_debug("Section to fixup %x\n", sec_to_patch); + pr_debug("=\n"); + pr_debug("rela->r_off | rela->addend | sym->st_value | ADDR | VALUE\n"); + pr_debug("=\n"); + + /* Loop thru entries in relocation section */ + for (i = 0; i < n; i++) { + + /* This is where to make the change */ + location = sec_to_patch + rel_entry[i].r_offset; + + /* This is the symbol it is referring to. Note that all + undefined symbols have been resolved. */ + sym_entry = sym_sec + ELF32_R_SYM(rel_entry[i].r_info); + + relocation = sym_entry->st_value + rel_entry[i].r_addend; + + pr_debug("\t%x\t\t%x\t\t%x %x %x [%s]\n", + rel_entry[i].r_offset, rel_entry[i].r_addend, + sym_entry->st_value, location, relocation, + strtab + sym_entry->st_name); + + /* This assumes modules are built with -mlong-calls +* so any branches/jumps are absolute 32 bit jmps +* global data access again is abs 32 bit. +* Both of these are handled by same relocation type +*/ + relo_type = ELF32_R_TYPE(rel_entry[i].r_info); + + if (likely(R_ARC_32_ME == relo_type)) + arc_write_me((unsigned short *)location, relocation); + else if (R_ARC_32 == relo_type) + *((Elf32_Addr *) location) = relocation; + else + goto relo_err; + + } + return 0; + +relo_err: + pr_err("%s: unknown relocation: %u\n", + module->name, ELF32_R_TYPE(rel_entry[i].r_info)); + return -ENOEXEC; + +} +
[RFC Patch v1 36/55] ARC: ARCompact 2 levels IRQ (high/low priority) Handling
From: Vineet Gupta There is a bit of hack/kludge right now where we disable preemption if a L2 (High prio) IRQ is taken while L1 (Low prio) is active. Need to revisit this Signed-off-by: Vineet Gupta --- arch/arc/Kconfig| 17 ++ arch/arc/include/asm/entry.h| 95 +++ arch/arc/include/asm/irqflags.h |6 ++- arch/arc/kernel/entry.S | 117 +++ arch/arc/kernel/irq.c | 104 ++ arch/arc/plat-arcfpga/Kconfig | 13 6 files changed, 351 insertions(+), 1 deletions(-) diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index 4557c8d..e096545 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig @@ -210,6 +210,23 @@ config ARC_PAGE_SIZE_4K endchoice +config ARC_COMPACT_IRQ_LEVELS + bool "ARCompact IRQ Priorities: High(2)/Low(1)" + default n + +if ARC_COMPACT_IRQ_LEVELS + +config ARC_IRQ3_LV2 + bool + +config ARC_IRQ5_LV2 + bool + +config ARC_IRQ6_LV2 + bool + +endif + config ARC_FPU_SAVE_RESTORE bool "Enable FPU state persistence across context switch" default n diff --git a/arch/arc/include/asm/entry.h b/arch/arc/include/asm/entry.h index 6113e1a..43dbf6f 100644 --- a/arch/arc/include/asm/entry.h +++ b/arch/arc/include/asm/entry.h @@ -5,6 +5,12 @@ * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * + * Vineetg: March 2009 (Supporting 2 levels of Interrupts) + * Stack switching code can no longer reliably rely on the fact that + * if we are NOT in user mode, stack is switched to kernel mode. + * e.g. L2 IRQ interrupted a L1 ISR which had not yet completed + * it's prologue including stack switching from user mode + * * Vineetg: Aug 28th 2008: Bug #94984 * -Zero Overhead Loop Context shd be cleared when entering IRQ/EXcp/Trap * Normally CPU does this automatically, however when doing FAKE rtie, @@ -233,6 +239,33 @@ * assume SP is kernel mode SP. _NO_ need to do any stack switching */ +#ifdef CONFIG_ARC_COMPACT_IRQ_LEVELS + /* However +* If Level 2 Interrupts enabled, we may end up with a corner case: +* 1. User Task executing +* 2. L1 IRQ taken, ISR starts (CPU auto-switched to KERNEL mode) +* 3. But before it could switch SP from USER to KERNEL stack +* a L2 IRQ "Interrupts" L1 +* Thay way although L2 IRQ happened in Kernel mode, stack is still +* not switched. +* To handle this, we may need to switch stack even if in kernel mode +* provided SP has values in range of USER mode stack ( < 0x7000_ ) +*/ + brlo sp, VMALLOC_START, 88f + + /* TODO: vineetg: +* We need to be a bit more cautious here. What if a kernel bug in +* L1 ISR, caused SP to go whaco (some small value which looks like +* USER stk) and then we take L2 ISR. +* Above brlo alone would treat it as a valid L1-L2 sceanrio +* instead of shouting alound +* The only feasible way is to make sure this L2 happened in +* L1 prelogue ONLY i.e. ilink2 is less than a pre-set marker in +* L1 ISR before it switches stack +*/ + +#endif + /* Save Pre Intr/Exception KERNEL MODE SP on kernel stack * safe-keeping not really needed, but it keeps the epilogue code * (SP restore) simpler/uniform. @@ -463,6 +496,42 @@ sub sp, sp, 4 .endm +.macro SAVE_ALL_INT2 + + /* TODO-vineetg: SMP we can't use global nor can we use + * SCRATCH0 as we do for int1 because while int1 is using + * it, int2 can come + */ + /* retsore original r9 , saved in sys_saved_r9 */ + ld r9, [@int2_saved_reg] + + /* now we are ready to save the remaining context :) */ + st -2, [sp, 8]/* orig_r8, -2 for interrupt level 2 */ + st 0, [sp, 4]/* orig_r0 , N/A for IRQ */ + SAVE_CALLER_SAVED + st.ar26, [sp, -4] /* gp */ + st.afp, [sp, -4] + st.ablink, [sp, -4] + st.ailink2, [sp, -4] + lr r9, [status32_l2] + st.ar9, [sp, -4] + st.alp_count, [sp, -4] + lr r9, [lp_end] + st.ar9, [sp, -4] + lr r9, [lp_start] + st.ar9, [sp, -4] + lr r9, [bta_l2] + st.ar9, [sp, -4] + +#ifdef PT_REGS_CANARY + mov r9, 0xdeadbee2 + str9, [sp, -4] +#endif + + /* move up by 1 word to "create" pt_regs->"stack_place_holder" */ + sub sp, sp, 4 +.endm + /*-- * Restore all registers used by interrupt handlers. * @@ -497,6 +566,32 @@ /* orig_r0 and orig_r8 skipped automatically */ .endm +.macro RESTORE_ALL_INT2 + add sp, sp, 4 /* hop over unused "pt_regs->stack_place_holder" */ + + ld.ab
[RFC Patch v1 35/55] ARC: oprofile support
From: Vineet Gupta Signed-off-by: Vineet Gupta --- arch/arc/Kconfig |1 + arch/arc/Makefile |2 ++ arch/arc/oprofile/Makefile |9 + arch/arc/oprofile/common.c | 22 ++ 4 files changed, 34 insertions(+), 0 deletions(-) create mode 100644 arch/arc/oprofile/Makefile create mode 100644 arch/arc/oprofile/common.c diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index 198c7d0..4557c8d 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig @@ -22,6 +22,7 @@ config ARC select GENERIC_SMP_IDLE_THREAD select HAVE_ARCH_TRACEHOOK select HAVE_GENERIC_HARDIRQS + select HAVE_OPROFILE select HOTPLUG if !INITRAMFS_SOURCE="" select MODULES_USE_ELF_RELA diff --git a/arch/arc/Makefile b/arch/arc/Makefile index eeb64dd..7ef6767 100644 --- a/arch/arc/Makefile +++ b/arch/arc/Makefile @@ -97,6 +97,8 @@ ifneq ($(platform-y),) core-y += arch/arc/plat-$(PLATFORM)/ endif +drivers-$(CONFIG_OPROFILE) += arch/arc/oprofile/ + libs-y += arch/arc/lib/ $(LIBGCC) #default target for make without any arguements. diff --git a/arch/arc/oprofile/Makefile b/arch/arc/oprofile/Makefile new file mode 100644 index 000..ce417a6 --- /dev/null +++ b/arch/arc/oprofile/Makefile @@ -0,0 +1,9 @@ +obj-$(CONFIG_OPROFILE) += oprofile.o + +DRIVER_OBJS = $(addprefix ../../../drivers/oprofile/, \ + oprof.o cpu_buffer.o buffer_sync.o \ + event_buffer.o oprofile_files.o \ + oprofilefs.o oprofile_stats.o \ + timer_int.o ) + +oprofile-y := $(DRIVER_OBJS) common.o diff --git a/arch/arc/oprofile/common.c b/arch/arc/oprofile/common.c new file mode 100644 index 000..917ae16 --- /dev/null +++ b/arch/arc/oprofile/common.c @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * Based on orig code from @author John Levon + */ + +#include +#include + +int __init oprofile_arch_init(struct oprofile_operations *ops) +{ + return oprofile_perf_init(ops); +} + +void oprofile_arch_exit(void) +{ + oprofile_perf_exit(); +} -- 1.7.4.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[RFC Patch v1 34/55] ARC: futex
From: Vineet Gupta Signed-off-by: Vineet Gupta --- arch/arc/include/asm/futex.h | 151 ++ 1 files changed, 151 insertions(+), 0 deletions(-) create mode 100644 arch/arc/include/asm/futex.h diff --git a/arch/arc/include/asm/futex.h b/arch/arc/include/asm/futex.h new file mode 100644 index 000..4dc64dd --- /dev/null +++ b/arch/arc/include/asm/futex.h @@ -0,0 +1,151 @@ +/* + * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * Vineetg: August 2010: From Android kernel work + */ + +#ifndef _ASM_FUTEX_H +#define _ASM_FUTEX_H + +#include +#include +#include +#include + +#define __futex_atomic_op(insn, ret, oldval, uaddr, oparg)\ + \ + __asm__ __volatile__( \ + "1: ld %1, [%2]\n" \ + insn"\n"\ + "2: st %0, [%2]\n" \ + " mov %0, 0 \n" \ + "3: \n" \ + " .section .fixup,\"ax\" \n" \ + " .align 4 \n" \ + "4: mov %0, %4 \n" \ + " b 3b \n" \ + " .previous \n" \ + " .section __ex_table,\"a\" \n" \ + " .align 4 \n" \ + " .word 1b, 4b \n" \ + " .word 2b, 4b \n" \ + " .previous \n" \ + \ + : "=" (ret), "=" (oldval) \ + : "r" (uaddr), "r" (oparg), "ir" (-EFAULT) \ + : "cc", "memory") + +static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr) +{ + int op = (encoded_op >> 28) & 7; + int cmp = (encoded_op >> 24) & 15; + int oparg = (encoded_op << 8) >> 20; + int cmparg = (encoded_op << 20) >> 20; + int oldval = 0, ret; + + if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) + oparg = 1 << oparg; + + if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int))) + return -EFAULT; + + pagefault_disable();/* implies preempt_disable() */ + + switch (op) { + case FUTEX_OP_SET: + __futex_atomic_op("mov %0, %3", ret, oldval, uaddr, oparg); + break; + case FUTEX_OP_ADD: + __futex_atomic_op("add %0, %1, %3", ret, oldval, uaddr, oparg); + break; + case FUTEX_OP_OR: + __futex_atomic_op("or %0, %1, %3", ret, oldval, uaddr, oparg); + break; + case FUTEX_OP_ANDN: + __futex_atomic_op("bic %0, %1, %3", ret, oldval, uaddr, oparg); + break; + case FUTEX_OP_XOR: + __futex_atomic_op("xor %0, %1, %3", ret, oldval, uaddr, oparg); + break; + default: + ret = -ENOSYS; + } + + pagefault_enable(); /* subsumes preempt_enable() */ + + if (!ret) { + switch (cmp) { + case FUTEX_OP_CMP_EQ: + ret = (oldval == cmparg); + break; + case FUTEX_OP_CMP_NE: + ret = (oldval != cmparg); + break; + case FUTEX_OP_CMP_LT: + ret = (oldval < cmparg); + break; + case FUTEX_OP_CMP_GE: + ret = (oldval >= cmparg); + break; + case FUTEX_OP_CMP_LE: + ret = (oldval <= cmparg); + break; + case FUTEX_OP_CMP_GT: + ret = (oldval > cmparg); + break; + default: + ret = -ENOSYS; + } + } + return ret; +} + +/* Compare-xchg with preemption disabled. + * Notes: + * -Best-Effort: Exchg happens only if compare succeeds. + * If compare fails, returns; leaving retry/looping to upper layers + * -successful cmp-xchg: return orig value in @addr (same as cmp val) + * -Compare fails: return orig value in @addr + * -user access r/w fails: return -EFAULT + */ +static inline int +futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr, u32 oldval, + u32 newval) +{ + u32 val; + + if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int))) + return -EFAULT; + + pagefault_disable();/* implies
[RFC Patch v1 33/55] ARC: ptrace support
From: Vineet Gupta Signed-off-by: Vineet Gupta --- arch/arc/Kconfig |1 + arch/arc/include/asm/ptrace.h | 18 - arch/arc/kernel/Makefile |3 + arch/arc/kernel/entry.S | 69 + arch/arc/kernel/ptrace.c | 164 - 5 files changed, 251 insertions(+), 4 deletions(-) diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index 71e55c0..198c7d0 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig @@ -20,6 +20,7 @@ config ARC select GENERIC_KERNEL_THREAD select GENERIC_PENDING_IRQ if SMP select GENERIC_SMP_IDLE_THREAD + select HAVE_ARCH_TRACEHOOK select HAVE_GENERIC_HARDIRQS select HOTPLUG if !INITRAMFS_SOURCE="" select MODULES_USE_ELF_RELA diff --git a/arch/arc/include/asm/ptrace.h b/arch/arc/include/asm/ptrace.h index bc2229f..bb621e8 100644 --- a/arch/arc/include/asm/ptrace.h +++ b/arch/arc/include/asm/ptrace.h @@ -42,6 +42,8 @@ #define PT_orig_r0 96 #define PT_orig_r8 100 +#ifdef __KERNEL__ + #ifndef __ASSEMBLY__ /* THE pt_regs: Defines how regs are saved during entry into kernel */ @@ -115,7 +117,6 @@ struct user_regs_struct { /* return 1 if user mode or 0 if kernel mode */ #define user_mode(regs) (regs->status32 & STATUS_U_MASK) - /* return 1 if in syscall, 0 if Intr or Exception */ #define in_syscall(regs) (((regs->orig_r8) >= 0 && \ (regs->orig_r8 <= NR_syscalls)) ? 1 : 0) @@ -128,6 +129,19 @@ struct user_regs_struct { (struct pt_regs *)(pg_start + THREAD_SIZE - 4) - 1; \ }) -#endif /* __ASSEMBLY__ */ +#define in_brkpt_trap(regs) (((regs->orig_r8) == (NR_syscalls + 2)) ? 1 : 0) + +#define user_stack_pointer(regs)\ +({ unsigned int sp; \ + if (user_mode(regs))\ + sp = (regs)->sp;\ + else\ + sp = -1;\ + sp; \ +}) + +#endif /* !__ASSEMBLY__ */ + +#endif /* __KERNEL__ */ #endif /* __ASM_PTRACE_H */ diff --git a/arch/arc/kernel/Makefile b/arch/arc/kernel/Makefile index 47f6b33..4ddef9a 100644 --- a/arch/arc/kernel/Makefile +++ b/arch/arc/kernel/Makefile @@ -5,6 +5,9 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +# Pass UTS_MACHINE for user_regset definition +CFLAGS_ptrace.o+= -DUTS_MACHINE='"$(UTS_MACHINE)"' + obj-y := arcksyms.o setup.o irq.o time.o reset.o ptrace.o entry.o process.o \ signal.o traps.o sys.o troubleshoot.o stacktrace.o diff --git a/arch/arc/kernel/entry.S b/arch/arc/kernel/entry.S index 35406da..93cde5e 100644 --- a/arch/arc/kernel/entry.S +++ b/arch/arc/kernel/entry.S @@ -10,6 +10,14 @@ * TBD: * -remove the low level wrappers for execve/fork/vfork * needed before task_pt_regs was invented. This saves a branch per call + * and more importantly allows clean invocation of post-syscall ptrace hook + * + * vineetg: Feb 2011 (ptrace low level code fixes) + * -traced syscall return code (r0) was not saved into pt_regs for restoring + * into user reg-file when traded task rets to user space. + * -syscalls needing arch-wrappers (mainly for passing sp as pt_regs) + * were not invoking post-syscall trace hook (jumping directly into + * ret_from_system_call) * * vineetg: Nov 2010: * -Vector table jumps (@8 bytes) converted into branches (@4 bytes) @@ -351,6 +359,50 @@ ARC_ENTRY EV_Extension b ret_from_exception ARC_EXIT EV_Extension +;# System Call Tracing # + +tracesys: + ; save EFA in case tracer wants the PC of traced task + ; using ERET won't work since next-PC has already committed + lr r12, [efa] + GET_CURR_TASK_FIELD_PTR TASK_THREAD, r11 + st r12, [r11, THREAD_FAULT_ADDR] + + ; PRE Sys Call Ptrace hook + mov r0, sp ; pt_regs needed + bl @syscall_trace_entry + + ; Tracing code now returns the syscall num (orig or modif) + mov r8, r0 + + ; Do the Sys Call as we normally would. + ; Validate the Sys Call number + cmp r8, NR_syscalls + mov.hi r0, -ENOSYS + bhi tracesys_exit + + ; Restore the sys-call args. Mere invocation of the hook abv could have + ; clobbered them (since they are in scratch regs). The tracer could also + ; have deliberately changed the syscall args: r0-r7 + ld r0, [sp, PT_r0] + ld r1, [sp, PT_r1] + ld r2, [sp, PT_r2] + ld r3, [sp, PT_r3] + ld r4, [sp, PT_r4] + ld r5, [sp, PT_r5] + ld r6, [sp, PT_r6] + ld r7, [sp, PT_r7] + ld.as r9, [sys_call_table, r8] + jl [r9]; Entry into Sys Call Handler + +tracesys_exit: + st r0, [sp, PT_r0] ; sys call return value in pt_regs + + ;POST Sys Call Ptrace Hook + bl @syscall_trace_exit +
[RFC Patch v1 32/55] ARC: [optim] Cache "current" in Register r25
From: Vineet Gupta Signed-off-by: Vineet Gupta --- arch/arc/Kconfig |7 ++ arch/arc/Makefile|9 +++ arch/arc/include/asm/Kbuild |1 - arch/arc/include/asm/current.h | 32 +++ arch/arc/include/asm/entry.h | 45 ++ arch/arc/include/asm/processor.h |3 ++ arch/arc/kernel/asm-offsets.c|3 ++ arch/arc/kernel/ctx_sw.c |7 ++ arch/arc/kernel/entry.S | 14 +++ 9 files changed, 120 insertions(+), 1 deletions(-) create mode 100644 arch/arc/include/asm/current.h diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index f3aacfc..71e55c0 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig @@ -277,6 +277,13 @@ config ARC_PLAT_SDRAM_SIZE endmenu # "Platform Board Configuration" +config ARC_CURR_IN_REG + bool "Dedicate Register r25 for current_task pointer" + default y + help + This reserved Register R25 to point to Current Task in + kernel mode. This saves memory access for each such access + config ARC_STACK_NONEXEC bool "Make stack non-executable" default n diff --git a/arch/arc/Makefile b/arch/arc/Makefile index 4d52a3b..eeb64dd 100644 --- a/arch/arc/Makefile +++ b/arch/arc/Makefile @@ -20,6 +20,15 @@ export PLATFORM cflags-y += -Iarch/arc/plat-$(PLATFORM)/include cflags-y += -mA7 -fno-common -pipe -fno-builtin -D__linux__ +ifdef CONFIG_ARC_CURR_IN_REG +# For a global register defintion, make sure it gets passed to every file +# We had a customer reported bug where some code built in kernel was NOT using +# any kernel headers, and missing the r25 global register +# Can't do unconditionally (like above) because of recursive include issues +# due to +LINUXINCLUDE += -include ${src}/arch/arc/include/asm/current.h +endif + atleast_gcc44 := $(call cc-ifversion, -gt, 0402, y) cflags-$(atleast_gcc44)+= -fsection-anchors diff --git a/arch/arc/include/asm/Kbuild b/arch/arc/include/asm/Kbuild index 148dfcf..a246390 100644 --- a/arch/arc/include/asm/Kbuild +++ b/arch/arc/include/asm/Kbuild @@ -11,7 +11,6 @@ generic-y += bugs.h generic-y += bitsperlong.h generic-y += clkdev.h generic-y += cputime.h -generic-y += current.h generic-y += device.h generic-y += div64.h generic-y += emergency-restart.h diff --git a/arch/arc/include/asm/current.h b/arch/arc/include/asm/current.h new file mode 100644 index 000..87b9185 --- /dev/null +++ b/arch/arc/include/asm/current.h @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * Vineetg: May 16th, 2008 + * - Current macro is now implemented as "global register" r25 + */ + +#ifndef _ASM_ARC_CURRENT_H +#define _ASM_ARC_CURRENT_H + +#ifdef __KERNEL__ + +#ifndef __ASSEMBLY__ + +#ifdef CONFIG_ARC_CURR_IN_REG + +register struct task_struct *curr_arc asm("r25"); +#define current (curr_arc) + +#else +#include +#endif /* ! CONFIG_ARC_CURR_IN_REG */ + +#endif /* ! __ASSEMBLY__ */ + +#endif /* __KERNEL__ */ + +#endif /* _ASM_ARC_CURRENT_H */ diff --git a/arch/arc/include/asm/entry.h b/arch/arc/include/asm/entry.h index 3e0a9f4..6113e1a 100644 --- a/arch/arc/include/asm/entry.h +++ b/arch/arc/include/asm/entry.h @@ -13,6 +13,8 @@ * was being "CLEARED" rather then "SET". Actually "SET" clears ZOL context * * Vineetg: May 5th 2008 + * -Modified CALLEE_REG save/restore macros to handle the fact that + * r25 contains the kernel current task ptr * - Defined Stack Switching Macro to be reused in all intr/excp hdlrs * - Shaved off 11 instructions from RESTORE_ALL_INT1 by using the * address Write back load ld.ab instead of seperate ld/add instn @@ -28,6 +30,7 @@ #include #include #include +#include /* For VMALLOC_START */ #include/* For THREAD_SIZE */ /* Note on the LD/ST addr modes with addr reg wback @@ -106,7 +109,14 @@ st.ar22, [sp, -4] st.ar23, [sp, -4] st.ar24, [sp, -4] + +#ifdef CONFIG_ARC_CURR_IN_REG + ; Retrieve orig r25 and save it on stack + ld r12, [r25, TASK_THREAD + THREAD_USER_R25] + st.ar12, [sp, -4] +#else st.ar25, [sp, -4] +#endif /* move up by 1 word to "create" callee_regs->"stack_place_holder" */ sub sp, sp, 4 @@ -131,8 +141,12 @@ st.ar22, [sp, -4] st.ar23, [sp, -4] st.ar24, [sp, -4] +#ifdef CONFIG_ARC_CURR_IN_REG + sub sp, sp, 8 +#else st.ar25, [sp, -4] sub sp, sp, 4 +#endif .endm /*-- @@ -148,8 +162,14 @@ *-*/ .macro
[RFC Patch v1 00/55] Addons to Synopsys ARC Linux kernel Port
From: Vineet Gupta Hi, This is a follow-up on ARC Linux port, whose #1 was posted last week. This is part #2 of the port containing optional features. Kindly review and provide comments ! The v2 series incorporating the review comments will combine both #1 and #2. Thx, -Vineet Mischa Jonker (1): ARC: kgdb support Vineet Gupta (23): ARC: [optim] Cache "current" in Register r25 ARC: ptrace support ARC: futex ARC: oprofile support ARC: ARCompact 2 levels IRQ (high/low priority) Handling ARC: dynamic loadable module support ARC: Low level event capture/logging ARC: kernel diagnostics: show_regs() etc ARC: SMP support ARC: dwarf2 stack unwinder ARC: stacktracing APIs based on dw2 unwinder ARC: disassembly (needed by kprobes/kgdb/unaligned-access-emul) ARC: kprobes support ARC: unaligned access emulation ARC: startup #2: Verbose Boot reporting / feature verification ARC: [plat-arfpga] BVCI Latency Unit setup perf, ARC: Enable building perf tools for ARC ARC: perf support (software counters only) modpost: Ignore ARC specific non-alloc section ARC: Support for single cycle Close Coupled Mem (CCM) ARC: Hostlink Pseudo-Driver for Metaware Debugger ARC: [plat-arcfpga] defconfig ARC: Add self to MAINTAINERS MAINTAINERS |6 + arch/arc/Kconfig | 136 +++ arch/arc/Makefile| 19 + arch/arc/configs/fpga_defconfig | 137 +++- arch/arc/include/asm/Kbuild |2 - arch/arc/include/asm/arcregs.h | 122 +++- arch/arc/include/asm/current.h | 32 + arch/arc/include/asm/defines.h | 56 ++ arch/arc/include/asm/disasm.h| 116 +++ arch/arc/include/asm/entry.h | 189 + arch/arc/include/asm/event-log-asm.h | 185 + arch/arc/include/asm/event-log.h | 102 +++ arch/arc/include/asm/futex.h | 151 arch/arc/include/asm/irqflags.h |6 +- arch/arc/include/asm/kgdb.h | 61 ++ arch/arc/include/asm/kprobes.h | 62 ++ arch/arc/include/asm/linkage.h | 33 + arch/arc/include/asm/mmu_context.h |4 + arch/arc/include/asm/module.h| 11 + arch/arc/include/asm/mutex.h |9 + arch/arc/include/asm/perf_event.h| 19 + arch/arc/include/asm/pgtable.h |4 + arch/arc/include/asm/processor.h | 11 + arch/arc/include/asm/ptrace.h| 19 +- arch/arc/include/asm/setup.h | 14 + arch/arc/include/asm/smp.h | 108 +++ arch/arc/include/asm/unaligned.h | 29 + arch/arc/include/asm/unwind.h| 163 arch/arc/kernel/Makefile | 19 +- arch/arc/kernel/arc_hostlink.c | 114 +++ arch/arc/kernel/asm-offsets.c| 18 + arch/arc/kernel/ctx_sw.c | 18 + arch/arc/kernel/disasm.c | 538 arch/arc/kernel/entry.S | 259 ++- arch/arc/kernel/event-log.c | 304 +++ arch/arc/kernel/head.S | 33 + arch/arc/kernel/irq.c| 109 +++ arch/arc/kernel/kgdb.c | 205 + arch/arc/kernel/kprobes.c| 525 arch/arc/kernel/module.c | 159 arch/arc/kernel/ptrace.c | 164 - arch/arc/kernel/setup.c | 281 +++- arch/arc/kernel/signal.c |3 + arch/arc/kernel/smp.c| 295 +++ arch/arc/kernel/stacktrace.c | 215 +- arch/arc/kernel/traps.c | 45 + arch/arc/kernel/troubleshoot.c | 304 +++ arch/arc/kernel/unaligned.c | 225 + arch/arc/kernel/unwind.c | 1329 ++ arch/arc/kernel/vmlinux.lds.S| 44 +- arch/arc/mm/cache_arc700.c | 46 + arch/arc/mm/tlb.c| 47 ++ arch/arc/mm/tlbex.S | 70 ++- arch/arc/oprofile/Makefile |9 + arch/arc/oprofile/common.c | 22 + arch/arc/plat-arcfpga/Kconfig| 57 ++ 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/platform.c | 56 ++ arch/arc/plat-arcfpga/smp.c | 192 + scripts/mod/modpost.c|1 + tools/perf/perf.h|6 + 64 files changed, 7621 insertions(+), 33 deletions(-) create mode 100644 arch/arc/include/asm/current.h create mode 100644 arch/arc/include/asm/defines.h create mode 100644 arch/arc/include/asm/disasm.h create mode 100644 arch/arc/include/asm/event-log-asm.h create mode 100644
[RFC Patch v1 00/55] Addons to Synopsys ARC Linux kernel Port
From: Vineet Gupta vgu...@synopsys.com Hi, This is a follow-up on ARC Linux port, whose #1 was posted last week. This is part #2 of the port containing optional features. Kindly review and provide comments ! The v2 series incorporating the review comments will combine both #1 and #2. Thx, -Vineet Mischa Jonker (1): ARC: kgdb support Vineet Gupta (23): ARC: [optim] Cache current in Register r25 ARC: ptrace support ARC: futex ARC: oprofile support ARC: ARCompact 2 levels IRQ (high/low priority) Handling ARC: dynamic loadable module support ARC: Low level event capture/logging ARC: kernel diagnostics: show_regs() etc ARC: SMP support ARC: dwarf2 stack unwinder ARC: stacktracing APIs based on dw2 unwinder ARC: disassembly (needed by kprobes/kgdb/unaligned-access-emul) ARC: kprobes support ARC: unaligned access emulation ARC: startup #2: Verbose Boot reporting / feature verification ARC: [plat-arfpga] BVCI Latency Unit setup perf, ARC: Enable building perf tools for ARC ARC: perf support (software counters only) modpost: Ignore ARC specific non-alloc section ARC: Support for single cycle Close Coupled Mem (CCM) ARC: Hostlink Pseudo-Driver for Metaware Debugger ARC: [plat-arcfpga] defconfig ARC: Add self to MAINTAINERS MAINTAINERS |6 + arch/arc/Kconfig | 136 +++ arch/arc/Makefile| 19 + arch/arc/configs/fpga_defconfig | 137 +++- arch/arc/include/asm/Kbuild |2 - arch/arc/include/asm/arcregs.h | 122 +++- arch/arc/include/asm/current.h | 32 + arch/arc/include/asm/defines.h | 56 ++ arch/arc/include/asm/disasm.h| 116 +++ arch/arc/include/asm/entry.h | 189 + arch/arc/include/asm/event-log-asm.h | 185 + arch/arc/include/asm/event-log.h | 102 +++ arch/arc/include/asm/futex.h | 151 arch/arc/include/asm/irqflags.h |6 +- arch/arc/include/asm/kgdb.h | 61 ++ arch/arc/include/asm/kprobes.h | 62 ++ arch/arc/include/asm/linkage.h | 33 + arch/arc/include/asm/mmu_context.h |4 + arch/arc/include/asm/module.h| 11 + arch/arc/include/asm/mutex.h |9 + arch/arc/include/asm/perf_event.h| 19 + arch/arc/include/asm/pgtable.h |4 + arch/arc/include/asm/processor.h | 11 + arch/arc/include/asm/ptrace.h| 19 +- arch/arc/include/asm/setup.h | 14 + arch/arc/include/asm/smp.h | 108 +++ arch/arc/include/asm/unaligned.h | 29 + arch/arc/include/asm/unwind.h| 163 arch/arc/kernel/Makefile | 19 +- arch/arc/kernel/arc_hostlink.c | 114 +++ arch/arc/kernel/asm-offsets.c| 18 + arch/arc/kernel/ctx_sw.c | 18 + arch/arc/kernel/disasm.c | 538 arch/arc/kernel/entry.S | 259 ++- arch/arc/kernel/event-log.c | 304 +++ arch/arc/kernel/head.S | 33 + arch/arc/kernel/irq.c| 109 +++ arch/arc/kernel/kgdb.c | 205 + arch/arc/kernel/kprobes.c| 525 arch/arc/kernel/module.c | 159 arch/arc/kernel/ptrace.c | 164 - arch/arc/kernel/setup.c | 281 +++- arch/arc/kernel/signal.c |3 + arch/arc/kernel/smp.c| 295 +++ arch/arc/kernel/stacktrace.c | 215 +- arch/arc/kernel/traps.c | 45 + arch/arc/kernel/troubleshoot.c | 304 +++ arch/arc/kernel/unaligned.c | 225 + arch/arc/kernel/unwind.c | 1329 ++ arch/arc/kernel/vmlinux.lds.S| 44 +- arch/arc/mm/cache_arc700.c | 46 + arch/arc/mm/tlb.c| 47 ++ arch/arc/mm/tlbex.S | 70 ++- arch/arc/oprofile/Makefile |9 + arch/arc/oprofile/common.c | 22 + arch/arc/plat-arcfpga/Kconfig| 57 ++ 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/platform.c | 56 ++ arch/arc/plat-arcfpga/smp.c | 192 + scripts/mod/modpost.c|1 + tools/perf/perf.h|6 + 64 files changed, 7621 insertions(+), 33 deletions(-) create mode 100644 arch/arc/include/asm/current.h create mode 100644 arch/arc/include/asm/defines.h create mode 100644 arch/arc/include/asm/disasm.h create mode 100644 arch/arc/include/asm/event-log-asm.h create mode 100644
[RFC Patch v1 32/55] ARC: [optim] Cache current in Register r25
From: Vineet Gupta vgu...@synopsys.com Signed-off-by: Vineet Gupta vgu...@synopsys.com --- arch/arc/Kconfig |7 ++ arch/arc/Makefile|9 +++ arch/arc/include/asm/Kbuild |1 - arch/arc/include/asm/current.h | 32 +++ arch/arc/include/asm/entry.h | 45 ++ arch/arc/include/asm/processor.h |3 ++ arch/arc/kernel/asm-offsets.c|3 ++ arch/arc/kernel/ctx_sw.c |7 ++ arch/arc/kernel/entry.S | 14 +++ 9 files changed, 120 insertions(+), 1 deletions(-) create mode 100644 arch/arc/include/asm/current.h diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index f3aacfc..71e55c0 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig @@ -277,6 +277,13 @@ config ARC_PLAT_SDRAM_SIZE endmenu # Platform Board Configuration +config ARC_CURR_IN_REG + bool Dedicate Register r25 for current_task pointer + default y + help + This reserved Register R25 to point to Current Task in + kernel mode. This saves memory access for each such access + config ARC_STACK_NONEXEC bool Make stack non-executable default n diff --git a/arch/arc/Makefile b/arch/arc/Makefile index 4d52a3b..eeb64dd 100644 --- a/arch/arc/Makefile +++ b/arch/arc/Makefile @@ -20,6 +20,15 @@ export PLATFORM cflags-y += -Iarch/arc/plat-$(PLATFORM)/include cflags-y += -mA7 -fno-common -pipe -fno-builtin -D__linux__ +ifdef CONFIG_ARC_CURR_IN_REG +# For a global register defintion, make sure it gets passed to every file +# We had a customer reported bug where some code built in kernel was NOT using +# any kernel headers, and missing the r25 global register +# Can't do unconditionally (like above) because of recursive include issues +# due to linux/thread_info.h +LINUXINCLUDE += -include ${src}/arch/arc/include/asm/current.h +endif + atleast_gcc44 := $(call cc-ifversion, -gt, 0402, y) cflags-$(atleast_gcc44)+= -fsection-anchors diff --git a/arch/arc/include/asm/Kbuild b/arch/arc/include/asm/Kbuild index 148dfcf..a246390 100644 --- a/arch/arc/include/asm/Kbuild +++ b/arch/arc/include/asm/Kbuild @@ -11,7 +11,6 @@ generic-y += bugs.h generic-y += bitsperlong.h generic-y += clkdev.h generic-y += cputime.h -generic-y += current.h generic-y += device.h generic-y += div64.h generic-y += emergency-restart.h diff --git a/arch/arc/include/asm/current.h b/arch/arc/include/asm/current.h new file mode 100644 index 000..87b9185 --- /dev/null +++ b/arch/arc/include/asm/current.h @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * Vineetg: May 16th, 2008 + * - Current macro is now implemented as global register r25 + */ + +#ifndef _ASM_ARC_CURRENT_H +#define _ASM_ARC_CURRENT_H + +#ifdef __KERNEL__ + +#ifndef __ASSEMBLY__ + +#ifdef CONFIG_ARC_CURR_IN_REG + +register struct task_struct *curr_arc asm(r25); +#define current (curr_arc) + +#else +#include asm-generic/current.h +#endif /* ! CONFIG_ARC_CURR_IN_REG */ + +#endif /* ! __ASSEMBLY__ */ + +#endif /* __KERNEL__ */ + +#endif /* _ASM_ARC_CURRENT_H */ diff --git a/arch/arc/include/asm/entry.h b/arch/arc/include/asm/entry.h index 3e0a9f4..6113e1a 100644 --- a/arch/arc/include/asm/entry.h +++ b/arch/arc/include/asm/entry.h @@ -13,6 +13,8 @@ * was being CLEARED rather then SET. Actually SET clears ZOL context * * Vineetg: May 5th 2008 + * -Modified CALLEE_REG save/restore macros to handle the fact that + * r25 contains the kernel current task ptr * - Defined Stack Switching Macro to be reused in all intr/excp hdlrs * - Shaved off 11 instructions from RESTORE_ALL_INT1 by using the * address Write back load ld.ab instead of seperate ld/add instn @@ -28,6 +30,7 @@ #include asm/asm-offsets.h #include asm/arcregs.h #include asm/ptrace.h +#include asm/processor.h /* For VMALLOC_START */ #include asm/thread_info.h /* For THREAD_SIZE */ /* Note on the LD/ST addr modes with addr reg wback @@ -106,7 +109,14 @@ st.ar22, [sp, -4] st.ar23, [sp, -4] st.ar24, [sp, -4] + +#ifdef CONFIG_ARC_CURR_IN_REG + ; Retrieve orig r25 and save it on stack + ld r12, [r25, TASK_THREAD + THREAD_USER_R25] + st.ar12, [sp, -4] +#else st.ar25, [sp, -4] +#endif /* move up by 1 word to create callee_regs-stack_place_holder */ sub sp, sp, 4 @@ -131,8 +141,12 @@ st.ar22, [sp, -4] st.ar23, [sp, -4] st.ar24, [sp, -4] +#ifdef CONFIG_ARC_CURR_IN_REG + sub sp, sp, 8 +#else st.ar25, [sp, -4] sub sp, sp, 4 +#endif .endm
[RFC Patch v1 33/55] ARC: ptrace support
From: Vineet Gupta vgu...@synopsys.com Signed-off-by: Vineet Gupta vgu...@synopsys.com --- arch/arc/Kconfig |1 + arch/arc/include/asm/ptrace.h | 18 - arch/arc/kernel/Makefile |3 + arch/arc/kernel/entry.S | 69 + arch/arc/kernel/ptrace.c | 164 - 5 files changed, 251 insertions(+), 4 deletions(-) diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index 71e55c0..198c7d0 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig @@ -20,6 +20,7 @@ config ARC select GENERIC_KERNEL_THREAD select GENERIC_PENDING_IRQ if SMP select GENERIC_SMP_IDLE_THREAD + select HAVE_ARCH_TRACEHOOK select HAVE_GENERIC_HARDIRQS select HOTPLUG if !INITRAMFS_SOURCE= select MODULES_USE_ELF_RELA diff --git a/arch/arc/include/asm/ptrace.h b/arch/arc/include/asm/ptrace.h index bc2229f..bb621e8 100644 --- a/arch/arc/include/asm/ptrace.h +++ b/arch/arc/include/asm/ptrace.h @@ -42,6 +42,8 @@ #define PT_orig_r0 96 #define PT_orig_r8 100 +#ifdef __KERNEL__ + #ifndef __ASSEMBLY__ /* THE pt_regs: Defines how regs are saved during entry into kernel */ @@ -115,7 +117,6 @@ struct user_regs_struct { /* return 1 if user mode or 0 if kernel mode */ #define user_mode(regs) (regs-status32 STATUS_U_MASK) - /* return 1 if in syscall, 0 if Intr or Exception */ #define in_syscall(regs) (((regs-orig_r8) = 0 \ (regs-orig_r8 = NR_syscalls)) ? 1 : 0) @@ -128,6 +129,19 @@ struct user_regs_struct { (struct pt_regs *)(pg_start + THREAD_SIZE - 4) - 1; \ }) -#endif /* __ASSEMBLY__ */ +#define in_brkpt_trap(regs) (((regs-orig_r8) == (NR_syscalls + 2)) ? 1 : 0) + +#define user_stack_pointer(regs)\ +({ unsigned int sp; \ + if (user_mode(regs))\ + sp = (regs)-sp;\ + else\ + sp = -1;\ + sp; \ +}) + +#endif /* !__ASSEMBLY__ */ + +#endif /* __KERNEL__ */ #endif /* __ASM_PTRACE_H */ diff --git a/arch/arc/kernel/Makefile b/arch/arc/kernel/Makefile index 47f6b33..4ddef9a 100644 --- a/arch/arc/kernel/Makefile +++ b/arch/arc/kernel/Makefile @@ -5,6 +5,9 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. +# Pass UTS_MACHINE for user_regset definition +CFLAGS_ptrace.o+= -DUTS_MACHINE='$(UTS_MACHINE)' + obj-y := arcksyms.o setup.o irq.o time.o reset.o ptrace.o entry.o process.o \ signal.o traps.o sys.o troubleshoot.o stacktrace.o diff --git a/arch/arc/kernel/entry.S b/arch/arc/kernel/entry.S index 35406da..93cde5e 100644 --- a/arch/arc/kernel/entry.S +++ b/arch/arc/kernel/entry.S @@ -10,6 +10,14 @@ * TBD: * -remove the low level wrappers for execve/fork/vfork * needed before task_pt_regs was invented. This saves a branch per call + * and more importantly allows clean invocation of post-syscall ptrace hook + * + * vineetg: Feb 2011 (ptrace low level code fixes) + * -traced syscall return code (r0) was not saved into pt_regs for restoring + * into user reg-file when traded task rets to user space. + * -syscalls needing arch-wrappers (mainly for passing sp as pt_regs) + * were not invoking post-syscall trace hook (jumping directly into + * ret_from_system_call) * * vineetg: Nov 2010: * -Vector table jumps (@8 bytes) converted into branches (@4 bytes) @@ -351,6 +359,50 @@ ARC_ENTRY EV_Extension b ret_from_exception ARC_EXIT EV_Extension +;# System Call Tracing # + +tracesys: + ; save EFA in case tracer wants the PC of traced task + ; using ERET won't work since next-PC has already committed + lr r12, [efa] + GET_CURR_TASK_FIELD_PTR TASK_THREAD, r11 + st r12, [r11, THREAD_FAULT_ADDR] + + ; PRE Sys Call Ptrace hook + mov r0, sp ; pt_regs needed + bl @syscall_trace_entry + + ; Tracing code now returns the syscall num (orig or modif) + mov r8, r0 + + ; Do the Sys Call as we normally would. + ; Validate the Sys Call number + cmp r8, NR_syscalls + mov.hi r0, -ENOSYS + bhi tracesys_exit + + ; Restore the sys-call args. Mere invocation of the hook abv could have + ; clobbered them (since they are in scratch regs). The tracer could also + ; have deliberately changed the syscall args: r0-r7 + ld r0, [sp, PT_r0] + ld r1, [sp, PT_r1] + ld r2, [sp, PT_r2] + ld r3, [sp, PT_r3] + ld r4, [sp, PT_r4] + ld r5, [sp, PT_r5] + ld r6, [sp, PT_r6] + ld r7, [sp, PT_r7] + ld.as r9, [sys_call_table, r8] + jl [r9]; Entry into Sys Call Handler + +tracesys_exit: + st r0, [sp, PT_r0] ; sys call return value in pt_regs + + ;POST Sys Call Ptrace Hook + bl
[RFC Patch v1 34/55] ARC: futex
From: Vineet Gupta vgu...@synopsys.com Signed-off-by: Vineet Gupta vgu...@synopsys.com --- arch/arc/include/asm/futex.h | 151 ++ 1 files changed, 151 insertions(+), 0 deletions(-) create mode 100644 arch/arc/include/asm/futex.h diff --git a/arch/arc/include/asm/futex.h b/arch/arc/include/asm/futex.h new file mode 100644 index 000..4dc64dd --- /dev/null +++ b/arch/arc/include/asm/futex.h @@ -0,0 +1,151 @@ +/* + * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * Vineetg: August 2010: From Android kernel work + */ + +#ifndef _ASM_FUTEX_H +#define _ASM_FUTEX_H + +#include linux/futex.h +#include linux/preempt.h +#include linux/uaccess.h +#include asm/errno.h + +#define __futex_atomic_op(insn, ret, oldval, uaddr, oparg)\ + \ + __asm__ __volatile__( \ + 1: ld %1, [%2]\n \ + insn\n\ + 2: st %0, [%2]\n \ + mov %0, 0 \n \ + 3: \n \ + .section .fixup,\ax\ \n \ + .align 4 \n \ + 4: mov %0, %4 \n \ + b 3b \n \ + .previous \n \ + .section __ex_table,\a\ \n \ + .align 4 \n \ + .word 1b, 4b \n \ + .word 2b, 4b \n \ + .previous \n \ + \ + : =r (ret), =r (oldval) \ + : r (uaddr), r (oparg), ir (-EFAULT) \ + : cc, memory) + +static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr) +{ + int op = (encoded_op 28) 7; + int cmp = (encoded_op 24) 15; + int oparg = (encoded_op 8) 20; + int cmparg = (encoded_op 20) 20; + int oldval = 0, ret; + + if (encoded_op (FUTEX_OP_OPARG_SHIFT 28)) + oparg = 1 oparg; + + if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int))) + return -EFAULT; + + pagefault_disable();/* implies preempt_disable() */ + + switch (op) { + case FUTEX_OP_SET: + __futex_atomic_op(mov %0, %3, ret, oldval, uaddr, oparg); + break; + case FUTEX_OP_ADD: + __futex_atomic_op(add %0, %1, %3, ret, oldval, uaddr, oparg); + break; + case FUTEX_OP_OR: + __futex_atomic_op(or %0, %1, %3, ret, oldval, uaddr, oparg); + break; + case FUTEX_OP_ANDN: + __futex_atomic_op(bic %0, %1, %3, ret, oldval, uaddr, oparg); + break; + case FUTEX_OP_XOR: + __futex_atomic_op(xor %0, %1, %3, ret, oldval, uaddr, oparg); + break; + default: + ret = -ENOSYS; + } + + pagefault_enable(); /* subsumes preempt_enable() */ + + if (!ret) { + switch (cmp) { + case FUTEX_OP_CMP_EQ: + ret = (oldval == cmparg); + break; + case FUTEX_OP_CMP_NE: + ret = (oldval != cmparg); + break; + case FUTEX_OP_CMP_LT: + ret = (oldval cmparg); + break; + case FUTEX_OP_CMP_GE: + ret = (oldval = cmparg); + break; + case FUTEX_OP_CMP_LE: + ret = (oldval = cmparg); + break; + case FUTEX_OP_CMP_GT: + ret = (oldval cmparg); + break; + default: + ret = -ENOSYS; + } + } + return ret; +} + +/* Compare-xchg with preemption disabled. + * Notes: + * -Best-Effort: Exchg happens only if compare succeeds. + * If compare fails, returns; leaving retry/looping to upper layers + * -successful cmp-xchg: return orig value in @addr (same as cmp val) + * -Compare fails: return orig value in @addr + * -user access r/w fails: return -EFAULT + */ +static inline int +futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr, u32 oldval, + u32 newval) +{ + u32 val; + + if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int))) + return -EFAULT; + + pagefault_disable();/* implies
[RFC Patch v1 35/55] ARC: oprofile support
From: Vineet Gupta vgu...@synopsys.com Signed-off-by: Vineet Gupta vgu...@synopsys.com --- arch/arc/Kconfig |1 + arch/arc/Makefile |2 ++ arch/arc/oprofile/Makefile |9 + arch/arc/oprofile/common.c | 22 ++ 4 files changed, 34 insertions(+), 0 deletions(-) create mode 100644 arch/arc/oprofile/Makefile create mode 100644 arch/arc/oprofile/common.c diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index 198c7d0..4557c8d 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig @@ -22,6 +22,7 @@ config ARC select GENERIC_SMP_IDLE_THREAD select HAVE_ARCH_TRACEHOOK select HAVE_GENERIC_HARDIRQS + select HAVE_OPROFILE select HOTPLUG if !INITRAMFS_SOURCE= select MODULES_USE_ELF_RELA diff --git a/arch/arc/Makefile b/arch/arc/Makefile index eeb64dd..7ef6767 100644 --- a/arch/arc/Makefile +++ b/arch/arc/Makefile @@ -97,6 +97,8 @@ ifneq ($(platform-y),) core-y += arch/arc/plat-$(PLATFORM)/ endif +drivers-$(CONFIG_OPROFILE) += arch/arc/oprofile/ + libs-y += arch/arc/lib/ $(LIBGCC) #default target for make without any arguements. diff --git a/arch/arc/oprofile/Makefile b/arch/arc/oprofile/Makefile new file mode 100644 index 000..ce417a6 --- /dev/null +++ b/arch/arc/oprofile/Makefile @@ -0,0 +1,9 @@ +obj-$(CONFIG_OPROFILE) += oprofile.o + +DRIVER_OBJS = $(addprefix ../../../drivers/oprofile/, \ + oprof.o cpu_buffer.o buffer_sync.o \ + event_buffer.o oprofile_files.o \ + oprofilefs.o oprofile_stats.o \ + timer_int.o ) + +oprofile-y := $(DRIVER_OBJS) common.o diff --git a/arch/arc/oprofile/common.c b/arch/arc/oprofile/common.c new file mode 100644 index 000..917ae16 --- /dev/null +++ b/arch/arc/oprofile/common.c @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * Based on orig code from @author John Levon le...@movementarian.org + */ + +#include linux/oprofile.h +#include linux/perf_event.h + +int __init oprofile_arch_init(struct oprofile_operations *ops) +{ + return oprofile_perf_init(ops); +} + +void oprofile_arch_exit(void) +{ + oprofile_perf_exit(); +} -- 1.7.4.1 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[RFC Patch v1 36/55] ARC: ARCompact 2 levels IRQ (high/low priority) Handling
From: Vineet Gupta vgu...@synopsys.com There is a bit of hack/kludge right now where we disable preemption if a L2 (High prio) IRQ is taken while L1 (Low prio) is active. Need to revisit this Signed-off-by: Vineet Gupta vgu...@synopsys.com --- arch/arc/Kconfig| 17 ++ arch/arc/include/asm/entry.h| 95 +++ arch/arc/include/asm/irqflags.h |6 ++- arch/arc/kernel/entry.S | 117 +++ arch/arc/kernel/irq.c | 104 ++ arch/arc/plat-arcfpga/Kconfig | 13 6 files changed, 351 insertions(+), 1 deletions(-) diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index 4557c8d..e096545 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig @@ -210,6 +210,23 @@ config ARC_PAGE_SIZE_4K endchoice +config ARC_COMPACT_IRQ_LEVELS + bool ARCompact IRQ Priorities: High(2)/Low(1) + default n + +if ARC_COMPACT_IRQ_LEVELS + +config ARC_IRQ3_LV2 + bool + +config ARC_IRQ5_LV2 + bool + +config ARC_IRQ6_LV2 + bool + +endif + config ARC_FPU_SAVE_RESTORE bool Enable FPU state persistence across context switch default n diff --git a/arch/arc/include/asm/entry.h b/arch/arc/include/asm/entry.h index 6113e1a..43dbf6f 100644 --- a/arch/arc/include/asm/entry.h +++ b/arch/arc/include/asm/entry.h @@ -5,6 +5,12 @@ * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * + * Vineetg: March 2009 (Supporting 2 levels of Interrupts) + * Stack switching code can no longer reliably rely on the fact that + * if we are NOT in user mode, stack is switched to kernel mode. + * e.g. L2 IRQ interrupted a L1 ISR which had not yet completed + * it's prologue including stack switching from user mode + * * Vineetg: Aug 28th 2008: Bug #94984 * -Zero Overhead Loop Context shd be cleared when entering IRQ/EXcp/Trap * Normally CPU does this automatically, however when doing FAKE rtie, @@ -233,6 +239,33 @@ * assume SP is kernel mode SP. _NO_ need to do any stack switching */ +#ifdef CONFIG_ARC_COMPACT_IRQ_LEVELS + /* However +* If Level 2 Interrupts enabled, we may end up with a corner case: +* 1. User Task executing +* 2. L1 IRQ taken, ISR starts (CPU auto-switched to KERNEL mode) +* 3. But before it could switch SP from USER to KERNEL stack +* a L2 IRQ Interrupts L1 +* Thay way although L2 IRQ happened in Kernel mode, stack is still +* not switched. +* To handle this, we may need to switch stack even if in kernel mode +* provided SP has values in range of USER mode stack ( 0x7000_ ) +*/ + brlo sp, VMALLOC_START, 88f + + /* TODO: vineetg: +* We need to be a bit more cautious here. What if a kernel bug in +* L1 ISR, caused SP to go whaco (some small value which looks like +* USER stk) and then we take L2 ISR. +* Above brlo alone would treat it as a valid L1-L2 sceanrio +* instead of shouting alound +* The only feasible way is to make sure this L2 happened in +* L1 prelogue ONLY i.e. ilink2 is less than a pre-set marker in +* L1 ISR before it switches stack +*/ + +#endif + /* Save Pre Intr/Exception KERNEL MODE SP on kernel stack * safe-keeping not really needed, but it keeps the epilogue code * (SP restore) simpler/uniform. @@ -463,6 +496,42 @@ sub sp, sp, 4 .endm +.macro SAVE_ALL_INT2 + + /* TODO-vineetg: SMP we can't use global nor can we use + * SCRATCH0 as we do for int1 because while int1 is using + * it, int2 can come + */ + /* retsore original r9 , saved in sys_saved_r9 */ + ld r9, [@int2_saved_reg] + + /* now we are ready to save the remaining context :) */ + st -2, [sp, 8]/* orig_r8, -2 for interrupt level 2 */ + st 0, [sp, 4]/* orig_r0 , N/A for IRQ */ + SAVE_CALLER_SAVED + st.ar26, [sp, -4] /* gp */ + st.afp, [sp, -4] + st.ablink, [sp, -4] + st.ailink2, [sp, -4] + lr r9, [status32_l2] + st.ar9, [sp, -4] + st.alp_count, [sp, -4] + lr r9, [lp_end] + st.ar9, [sp, -4] + lr r9, [lp_start] + st.ar9, [sp, -4] + lr r9, [bta_l2] + st.ar9, [sp, -4] + +#ifdef PT_REGS_CANARY + mov r9, 0xdeadbee2 + str9, [sp, -4] +#endif + + /* move up by 1 word to create pt_regs-stack_place_holder */ + sub sp, sp, 4 +.endm + /*-- * Restore all registers used by interrupt handlers. * @@ -497,6 +566,32 @@ /* orig_r0 and orig_r8 skipped automatically */ .endm +.macro RESTORE_ALL_INT2 + add sp, sp, 4 /* hop over unused
[RFC Patch v1 37/55] ARC: dynamic loadable module support
From: Vineet Gupta vgu...@synopsys.com Signed-off-by: Vineet Gupta vgu...@synopsys.com --- arch/arc/include/asm/module.h |4 ++ arch/arc/kernel/Makefile |1 + arch/arc/kernel/module.c | 117 + 3 files changed, 122 insertions(+), 0 deletions(-) create mode 100644 arch/arc/kernel/module.c diff --git a/arch/arc/include/asm/module.h b/arch/arc/include/asm/module.h index 165d768..234b435 100644 --- a/arch/arc/include/asm/module.h +++ b/arch/arc/include/asm/module.h @@ -14,4 +14,8 @@ #include asm-generic/module.h +#define MODULE_PROC_FAMILY ARC700 + +#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY + #endif /* _ASM_ARC_MODULE_H */ diff --git a/arch/arc/kernel/Makefile b/arch/arc/kernel/Makefile index 4ddef9a..9151bbe 100644 --- a/arch/arc/kernel/Makefile +++ b/arch/arc/kernel/Makefile @@ -11,6 +11,7 @@ CFLAGS_ptrace.o += -DUTS_MACHINE='$(UTS_MACHINE)' obj-y := arcksyms.o setup.o irq.o time.o reset.o ptrace.o entry.o process.o \ signal.o traps.o sys.o troubleshoot.o stacktrace.o +obj-$(CONFIG_MODULES) += arcksyms.o module.o obj-$(CONFIG_ARC_FPU_SAVE_RESTORE) += fpu.o CFLAGS_fpu.o += -mdpfp diff --git a/arch/arc/kernel/module.c b/arch/arc/kernel/module.c new file mode 100644 index 000..cc13df4 --- /dev/null +++ b/arch/arc/kernel/module.c @@ -0,0 +1,117 @@ +/* + * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include linux/module.h +#include linux/moduleloader.h +#include linux/kernel.h +#include linux/elf.h +#include linux/vmalloc.h +#include linux/slab.h +#include linux/fs.h +#include linux/string.h + +static inline void arc_write_me(unsigned short *addr, unsigned long value) +{ + *addr = (value 0x) 16; + *(addr + 1) = (value 0x); +} + +void *module_alloc(unsigned long size) +{ + if (size == 0) + return NULL; + + return vmalloc(size); + +} + +void module_free(struct module *module, void *region) +{ + vfree(region); +} + +int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs, + char *secstr, struct module *mod) +{ +return 0; +} + +void module_arch_cleanup(struct module *mod) +{ +} + +int apply_relocate_add(Elf32_Shdr *sechdrs, + const char *strtab, + unsigned int symindex, /* sec index for sym tbl */ + unsigned int relsec, /* sec index for relo sec */ + struct module *module) +{ + int i, n; + Elf32_Rela *rel_entry = (void *)sechdrs[relsec].sh_addr; + Elf32_Sym *sym_entry, *sym_sec; + Elf32_Addr relocation; + Elf32_Addr location; + Elf32_Addr sec_to_patch; + int relo_type; + + sec_to_patch = sechdrs[sechdrs[relsec].sh_info].sh_addr; + sym_sec = (Elf32_Sym *) sechdrs[symindex].sh_addr; + n = sechdrs[relsec].sh_size / sizeof(*rel_entry); + + pr_debug(\n== Module Sym reloc ===\n); + pr_debug(Section to fixup %x\n, sec_to_patch); + pr_debug(=\n); + pr_debug(rela-r_off | rela-addend | sym-st_value | ADDR | VALUE\n); + pr_debug(=\n); + + /* Loop thru entries in relocation section */ + for (i = 0; i n; i++) { + + /* This is where to make the change */ + location = sec_to_patch + rel_entry[i].r_offset; + + /* This is the symbol it is referring to. Note that all + undefined symbols have been resolved. */ + sym_entry = sym_sec + ELF32_R_SYM(rel_entry[i].r_info); + + relocation = sym_entry-st_value + rel_entry[i].r_addend; + + pr_debug(\t%x\t\t%x\t\t%x %x %x [%s]\n, + rel_entry[i].r_offset, rel_entry[i].r_addend, + sym_entry-st_value, location, relocation, + strtab + sym_entry-st_name); + + /* This assumes modules are built with -mlong-calls +* so any branches/jumps are absolute 32 bit jmps +* global data access again is abs 32 bit. +* Both of these are handled by same relocation type +*/ + relo_type = ELF32_R_TYPE(rel_entry[i].r_info); + + if (likely(R_ARC_32_ME == relo_type)) + arc_write_me((unsigned short *)location, relocation); + else if (R_ARC_32 == relo_type) + *((Elf32_Addr *) location) = relocation; + else + goto relo_err; + + } + return 0; + +relo_err: +
[RFC Patch v1 39/55] ARC: kernel diagnostics: show_regs() etc
From: Vineet Gupta vgu...@synopsys.com Signed-off-by: Vineet Gupta vgu...@synopsys.com --- arch/arc/kernel/troubleshoot.c | 304 arch/arc/mm/tlbex.S| 20 +++ 2 files changed, 324 insertions(+), 0 deletions(-) diff --git a/arch/arc/kernel/troubleshoot.c b/arch/arc/kernel/troubleshoot.c index 80bfe2a..8a816f2 100644 --- a/arch/arc/kernel/troubleshoot.c +++ b/arch/arc/kernel/troubleshoot.c @@ -6,12 +6,316 @@ */ #include linux/ptrace.h +#include linux/module.h +#include linux/mm.h +#include linux/fs.h +#include linux/kdev_t.h +#include linux/fs_struct.h +#include linux/proc_fs.h +#include linux/file.h +#include asm/arcregs.h +#include asm/event-log.h + +/* + * Common routine to print scratch regs (r0-r12) or callee regs (r13-r25) + * -Prints 3 regs per line and a CR. + * -To continue, callee regs right after scratch, special handling of CR + */ +static noinline void print_reg_file(long *reg_rev, int start_num) +{ + unsigned int i; + char buf[512]; + int n = 0, len = sizeof(buf); + + /* weird loop because pt_regs regs rev r12..r0, r25..r13 */ + for (i = start_num; i start_num + 13; i++) { + n += scnprintf(buf + n, len - n, r%02u: 0x%08lx\t, + i, (unsigned long)*reg_rev); + + if (((i + 1) % 3) == 0) + n += scnprintf(buf + n, len - n, \n); + + reg_rev--; + } + + if (start_num != 0) + n += scnprintf(buf + n, len - n, \n\n); + + pr_info(%s, buf); +} + +static void show_callee_regs(struct callee_regs *cregs) +{ + print_reg_file((cregs-r13), 13); +} + +void print_task_path_n_nm(struct task_struct *task, char *buf) +{ + struct path path; + char *nm = NULL; + struct mm_struct *mm; + struct file *exe_file; + char comm_buf[TASK_COMM_LEN]; + + mm = get_task_mm(task); + if (!mm) + goto done; + + exe_file = get_mm_exe_file(mm); + mmput(mm); + + if (exe_file) { + path = exe_file-f_path; + path_get(exe_file-f_path); + fput(exe_file); + nm = d_path(path, buf, 255); + path_put(path); + } + +done: + pr_info(task = %s '%s', TGID %u PID = %u\n, nm, + get_task_comm(comm_buf, task), task-tgid, task-pid); +} +EXPORT_SYMBOL(print_task_path_n_nm); + +static void show_faulting_vma(unsigned long address, char *buf) +{ + struct vm_area_struct *vma; + struct inode *inode; + unsigned long ino = 0; + dev_t dev = 0; + char *nm = buf; + + vma = find_vma(current-active_mm, address); + + /* check against the find_vma( ) behaviour which returns the next VMA +* if the container VMA is not found +*/ + if (vma (vma-vm_start = address)) { + struct file *file = vma-vm_file; + if (file) { + struct path *path = file-f_path; + nm = d_path(path, buf, PAGE_SIZE - 1); + inode = vma-vm_file-f_path.dentry-d_inode; + dev = inode-i_sb-s_dev; + ino = inode-i_ino; + } + pr_info(@off 0x%lx in [%s]\n + VMA: 0x%08lx to 0x%08lx\n\n, + address - vma-vm_start, nm, vma-vm_start, vma-vm_end); + } else + pr_info(@No matching VMA found\n); +} + +static void show_ecr_verbose(struct pt_regs *regs) +{ + unsigned int vec, cause_code, cause_reg; + unsigned long address; + + cause_reg = current-thread.cause_code; + pr_info(\n[ECR]: 0x%08x = , cause_reg); + + /* For Data fault, this is data address not instruction addr */ + address = current-thread.fault_address; + + vec = cause_reg 16; + cause_code = (cause_reg 8) 0xFF; + + /* For DTLB Miss or ProtV, display the memory involved too */ + if (vec == ECR_V_DTLB_MISS) { + pr_cont(Invalid (%s) @ 0x%08lx by insn @ 0x%08lx\n, + (cause_code == 0x01) ? Read From : + ((cause_code == 0x02) ? Write to : EX), + address, regs-ret); + } else if (vec == ECR_V_ITLB_MISS) { + pr_cont(Insn could not be fetched\n); + } else if (vec == ECR_V_MACH_CHK) { + pr_cont(%s\n, (cause_code == 0x0) ? + Double Fault : Other Fatal Err); + + } else if (vec == ECR_V_PROTV) { + if (cause_code == ECR_C_PROTV_INST_FETCH) + pr_cont(Execute from Non-exec Page\n); + else if (cause_code == ECR_C_PROTV_LOAD) + pr_cont(Read from Non-readable Page\n); + else if (cause_code == ECR_C_PROTV_STORE) + pr_cont(Write to Non-writable Page\n); +
[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
[RFC Patch v1 41/55] ARC: dwarf2 stack unwinder
From: Vineet Gupta vgu...@synopsys.com -Originally controbuted by Rajeshwar Range rajeshwar.ranga -Derived off of generic unwinder in 2.6.19 and adapted to ARC Signed-off-by: Vineet Gupta vgu...@synopsys.com --- arch/arc/Kconfig | 15 + arch/arc/include/asm/module.h |7 + arch/arc/include/asm/unwind.h | 163 + arch/arc/kernel/Makefile |6 + arch/arc/kernel/entry.S |9 + arch/arc/kernel/module.c | 42 ++ arch/arc/kernel/setup.c |3 + arch/arc/kernel/unwind.c | 1329 + arch/arc/kernel/vmlinux.lds.S | 23 +- 9 files changed, 1596 insertions(+), 1 deletions(-) create mode 100644 arch/arc/include/asm/unwind.h create mode 100644 arch/arc/kernel/unwind.c diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index 8d72ada..26609d6 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig @@ -22,6 +22,7 @@ config ARC select GENERIC_SMP_IDLE_THREAD select HAVE_ARCH_TRACEHOOK select HAVE_GENERIC_HARDIRQS + select HAVE_MOD_ARCH_SPECIFIC if ARC_DW2_UNWIND select HAVE_OPROFILE select HOTPLUG if !INITRAMFS_SOURCE= select MODULES_USE_ELF_RELA @@ -355,6 +356,20 @@ menuconfig ARC_DBG bool ARC debugging default y +config ARC_DW2_UNWIND + bool Enable DWARF specific kernel stack unwind + depends on ARC_DBG + default y + select KALLSYMS + help + Compiles the kernel with DWARF unwind information and can be used + to get stack backtraces. + + If you say Y here the resulting kernel image will be slightly larger + but not slower, and it will give very useful debugging information. + If you don't debug the kernel, you can say N, but we may not be able + to solve problems without frame unwind information + config ARC_DBG_TLB_PARANOIA bool Paranoia Checks in Low Level TLB Handlers depends on ARC_DBG !SMP diff --git a/arch/arc/include/asm/module.h b/arch/arc/include/asm/module.h index 234b435..518222b 100644 --- a/arch/arc/include/asm/module.h +++ b/arch/arc/include/asm/module.h @@ -14,6 +14,13 @@ #include asm-generic/module.h +#ifdef CONFIG_ARC_DW2_UNWIND +struct mod_arch_specific { + void *unw_info; + int unw_sec_idx; +}; +#endif + #define MODULE_PROC_FAMILY ARC700 #define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY diff --git a/arch/arc/include/asm/unwind.h b/arch/arc/include/asm/unwind.h new file mode 100644 index 000..7ca628b --- /dev/null +++ b/arch/arc/include/asm/unwind.h @@ -0,0 +1,163 @@ +/* + * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef _ASM_ARC_UNWIND_H +#define _ASM_ARC_UNWIND_H + +#ifdef CONFIG_ARC_DW2_UNWIND + +#include linux/sched.h + +struct arc700_regs { + unsigned long r0; + unsigned long r1; + unsigned long r2; + unsigned long r3; + unsigned long r4; + unsigned long r5; + unsigned long r6; + unsigned long r7; + unsigned long r8; + unsigned long r9; + unsigned long r10; + unsigned long r11; + unsigned long r12; + unsigned long r13; + unsigned long r14; + unsigned long r15; + unsigned long r16; + unsigned long r17; + unsigned long r18; + unsigned long r19; + unsigned long r20; + unsigned long r21; + unsigned long r22; + unsigned long r23; + unsigned long r24; + unsigned long r25; + unsigned long r26; + unsigned long r27; /* fp */ + unsigned long r28; /* sp */ + unsigned long r29; + unsigned long r30; + unsigned long r31; /* blink */ + unsigned long r63; /* pc */ +}; + +struct unwind_frame_info { + struct arc700_regs regs; + struct task_struct *task; + unsigned call_frame:1; +}; + +#define UNW_PC(frame) ((frame)-regs.r63) +#define UNW_SP(frame) ((frame)-regs.r28) +#define UNW_BLINK(frame) ((frame)-regs.r31) + +/* Rajesh FIXME */ +#ifdef CONFIG_FRAME_POINTER +#define UNW_FP(frame) ((frame)-regs.r27) +#define FRAME_RETADDR_OFFSET 4 +#define FRAME_LINK_OFFSET 0 +#define STACK_BOTTOM_UNW(tsk) STACK_LIMIT((tsk)-thread.ksp) +#define STACK_TOP_UNW(tsk) ((tsk)-thread.ksp) +#else +#define UNW_FP(frame) ((void)(frame), 0) +#endif + +#define STACK_LIMIT(ptr) (((ptr) - 1) ~(THREAD_SIZE - 1)) + +#define UNW_REGISTER_INFO \ + PTREGS_INFO(r0), \ + PTREGS_INFO(r1), \ + PTREGS_INFO(r2), \ + PTREGS_INFO(r3), \ + PTREGS_INFO(r4), \ + PTREGS_INFO(r5), \ + PTREGS_INFO(r6), \ + PTREGS_INFO(r7), \ + PTREGS_INFO(r8), \ + PTREGS_INFO(r9), \ + PTREGS_INFO(r10), \
[RFC Patch v1 43/55] ARC: disassembly (needed by kprobes/kgdb/unaligned-access-emul)
From: Vineet Gupta vgu...@synopsys.com Orig written by Rajeshwar Ranga rajeshwar.ra...@gmail.com Consolidation/cleanups by Mischa Jonker mjon...@synopsys.com Signed-off-by: Vineet Gupta vgu...@synopsys.com --- arch/arc/include/asm/disasm.h | 116 + arch/arc/kernel/Makefile |2 +- arch/arc/kernel/disasm.c | 539 + 3 files changed, 656 insertions(+), 1 deletions(-) create mode 100644 arch/arc/include/asm/disasm.h create mode 100644 arch/arc/kernel/disasm.c diff --git a/arch/arc/include/asm/disasm.h b/arch/arc/include/asm/disasm.h new file mode 100644 index 000..f1cce3d --- /dev/null +++ b/arch/arc/include/asm/disasm.h @@ -0,0 +1,116 @@ +/* + * several functions that help interpret ARC instructions + * used for unaligned accesses, kprobes and kgdb + * + * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef __ARC_DISASM_H__ +#define __ARC_DISASM_H__ + +enum { + op_Bcc = 0, op_BLcc = 1, op_LD = 2, op_ST = 3, op_MAJOR_4 = 4, + op_MAJOR_5 = 5, op_LD_ADD = 12, op_ADD_SUB_SHIFT = 13, + op_ADD_MOV_CMP = 14, op_S = 15, op_LD_S = 16, op_LDB_S = 17, + op_LDW_S = 18, op_LDWX_S = 19, op_ST_S = 20, op_STB_S = 21, + op_STW_S = 22, op_Su5 = 23, op_SP = 24, op_GP = 25, + op_Pcl = 26, op_MOV_S = 27, op_ADD_CMP = 28, op_BR_S = 29, + op_B_S = 30, op_BL_S = 31 +}; + +enum flow { + noflow, + direct_jump, + direct_call, + indirect_jump, + indirect_call, + invalid_instr +}; + +#define IS_BIT(word, n)((word) (1n)) +#define BITS(word, s, e) (((word) (s)) (~((-2) ((e) - (s) + +#define MAJOR_OPCODE(word) (BITS((word), 27, 31)) +#define MINOR_OPCODE(word) (BITS((word), 16, 21)) +#define FIELD_A(word) (BITS((word), 0, 5)) +#define FIELD_B(word) ((BITS((word), 12, 14)3) | \ + (BITS((word), 24, 26))) +#define FIELD_C(word) (BITS((word), 6, 11)) +#define FIELD_u6(word) FIELDC(word) +#define FIELD_s12(word)sign_extend(((BITS((word), 0, 5) 6) | \ + BITS((word), 6, 11)), 12) + +/* note that for BL/BRcc these two macro's need another AND statement to mask + * out bit 1 (make the result a multiple of 4) */ +#define FIELD_s9(word) sign_extend(((BITS(word, 15, 15) 8) | \ + BITS(word, 16, 23)), 9) +#define FIELD_s21(word)sign_extend(((BITS(word, 6, 15) 11) | \ + (BITS(word, 17, 26) 1)), 12) +#define FIELD_s25(word)sign_extend(((BITS(word, 0, 3) 21) | \ + (BITS(word, 6, 15) 11) | \ + (BITS(word, 17, 26) 1)), 12) + +/* note: these operate on 16 bits! */ +#define FIELD_S_A(word)((BITS((word), 2, 2)3) | BITS((word), 0, 2)) +#define FIELD_S_B(word)((BITS((word), 10, 10)3) | \ + BITS((word), 8, 10)) +#define FIELD_S_C(word)((BITS((word), 7, 7)3) | BITS((word), 5, 7)) +#define FIELD_S_H(word)((BITS((word), 0, 2)3) | BITS((word), 5, 8)) +#define FIELD_S_u5(word) (BITS((word), 0, 4)) +#define FIELD_S_u6(word) (BITS((word), 0, 4) 1) +#define FIELD_S_u7(word) (BITS((word), 0, 4) 2) +#define FIELD_S_u10(word) (BITS((word), 0, 7) 2) +#define FIELD_S_s7(word) sign_extend(BITS((word), 0, 5) 1, 9) +#define FIELD_S_s8(word) sign_extend(BITS((word), 0, 7) 1, 9) +#define FIELD_S_s9(word) sign_extend(BITS((word), 0, 8), 9) +#define FIELD_S_s10(word) sign_extend(BITS((word), 0, 8) 1, 10) +#define FIELD_S_s11(word) sign_extend(BITS((word), 0, 8) 2, 11) +#define FIELD_S_s13(word) sign_extend(BITS((word), 0, 10) 2, 13) + +#define STATUS32_L 0x0100 +#define REG_LIMM 62 + +struct disasm_state { + /* generic info */ + unsigned long words[2]; + int instr_len; + int major_opcode; + /* info for branch/jump */ + int is_branch; + int target; + int delay_slot; + enum flow flow; + /* info for load/store */ + int src1, src2, src3, dest, wb_reg; + int zz, aa, x, pref, di; + int fault, write; +}; + +static inline int sign_extend(int value, int bits) +{ + if (IS_BIT(value, (bits - 1))) + value |= (0x bits); + + return value; +} + +static inline int is_short_instr(unsigned long addr) +{ + uint16_t word = *((uint16_t *)addr); + int opcode = (word 11) 0x1F; + return (opcode = 0x0B); +} + +void disasm_instr(unsigned long addr, struct
[RFC Patch v1 44/55] ARC: kprobes support
From: Vineet Gupta vgu...@synopsys.com Origin port done by Rajeshwar Ranga rajeshwar.ra...@gmail.com Signed-off-by: Vineet Gupta vgu...@synopsys.com --- arch/arc/Kconfig |2 + arch/arc/include/asm/kprobes.h | 62 + arch/arc/kernel/Makefile |1 + arch/arc/kernel/disasm.c |5 +- arch/arc/kernel/kprobes.c | 525 arch/arc/kernel/traps.c| 13 + 6 files changed, 605 insertions(+), 3 deletions(-) create mode 100644 arch/arc/include/asm/kprobes.h create mode 100644 arch/arc/kernel/kprobes.c diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index 26609d6..3ef21be 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig @@ -22,6 +22,8 @@ config ARC select GENERIC_SMP_IDLE_THREAD select HAVE_ARCH_TRACEHOOK select HAVE_GENERIC_HARDIRQS + select HAVE_KPROBES + select HAVE_KRETPROBES select HAVE_MOD_ARCH_SPECIFIC if ARC_DW2_UNWIND select HAVE_OPROFILE select HOTPLUG if !INITRAMFS_SOURCE= diff --git a/arch/arc/include/asm/kprobes.h b/arch/arc/include/asm/kprobes.h new file mode 100644 index 000..4d9c211 --- /dev/null +++ b/arch/arc/include/asm/kprobes.h @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef _ARC_KPROBES_H +#define _ARC_KPROBES_H + +#ifdef CONFIG_KPROBES + +typedef u16 kprobe_opcode_t; + +#define UNIMP_S_INSTRUCTION 0x79e0 +#define TRAP_S_2_INSTRUCTION 0x785e + +#define MAX_INSN_SIZE 8 +#define MAX_STACK_SIZE 64 + +struct arch_specific_insn { + int is_short; + kprobe_opcode_t *t1_addr, *t2_addr; + kprobe_opcode_t t1_opcode, t2_opcode; +}; + +#define flush_insn_slot(p) do { } while (0) + +#define kretprobe_blacklist_size0 + +struct kprobe; + +void arch_remove_kprobe(struct kprobe *p); + +int kprobe_exceptions_notify(struct notifier_block *self, +unsigned long val, void *data); + +struct prev_kprobe { + struct kprobe *kp; + unsigned long status; +}; + +struct kprobe_ctlblk { + unsigned int kprobe_status; + struct pt_regs jprobe_saved_regs; + char jprobes_stack[MAX_STACK_SIZE]; + struct prev_kprobe prev_kprobe; +}; + +int kprobe_fault_handler(struct pt_regs *regs, unsigned long cause); +void kretprobe_trampoline(void); +void trap_is_kprobe(unsigned long cause, unsigned long address, + struct pt_regs *regs); +#else +static void trap_is_kprobe(unsigned long cause, unsigned long address, + struct pt_regs *regs) +{ +} +#endif + +#endif diff --git a/arch/arc/kernel/Makefile b/arch/arc/kernel/Makefile index 1fc0461..442d024 100644 --- a/arch/arc/kernel/Makefile +++ b/arch/arc/kernel/Makefile @@ -15,6 +15,7 @@ obj-$(CONFIG_MODULES) += arcksyms.o module.o obj-$(CONFIG_ARC_DBG_EVENT_TIMELINE) += event-log.o obj-$(CONFIG_SMP) += smp.o obj-$(CONFIG_ARC_DW2_UNWIND) += unwind.o +obj-$(CONFIG_KPROBES) += kprobes.o obj-$(CONFIG_ARC_FPU_SAVE_RESTORE) += fpu.o CFLAGS_fpu.o += -mdpfp diff --git a/arch/arc/kernel/disasm.c b/arch/arc/kernel/disasm.c index 254d11a..51bad8f 100644 --- a/arch/arc/kernel/disasm.c +++ b/arch/arc/kernel/disasm.c @@ -497,9 +497,8 @@ void __kprobes set_reg(int reg, long val, struct pt_regs *regs, * @pc +2/4/6 (ARCompact ISA allows free intermixing of 16/32 bit insns). * * If @pc is a branch - * -@tgt_if_br is set to branch target. - * -If branch has delay slot, @next_pc updated with actual next PC. - * + * -@tgt_if_br is set to branch target. + * -If branch has delay slot, @next_pc updated with actual next PC. */ int __kprobes disasm_next_pc(unsigned long pc, struct pt_regs *regs, struct callee_regs *cregs, diff --git a/arch/arc/kernel/kprobes.c b/arch/arc/kernel/kprobes.c new file mode 100644 index 000..47e42f2 --- /dev/null +++ b/arch/arc/kernel/kprobes.c @@ -0,0 +1,525 @@ +/* + * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include linux/types.h +#include linux/kprobes.h +#include linux/slab.h +#include linux/module.h +#include linux/kprobes.h +#include linux/kdebug.h +#include linux/sched.h +#include linux/uaccess.h +#include asm/cacheflush.h +#include asm/current.h +#include asm/disasm.h + +#define MIN_STACK_SIZE(addr) min((unsigned long)MAX_STACK_SIZE, \ + (unsigned long)current_thread_info() + THREAD_SIZE - (addr)) + +DEFINE_PER_CPU(struct kprobe *,
[RFC Patch v1 45/55] ARC: unaligned access emulation
From: Vineet Gupta vgu...@synopsys.com Signed-off-by: Vineet Gupta vgu...@synopsys.com --- arch/arc/Kconfig |9 ++ arch/arc/include/asm/Kbuild |1 - arch/arc/include/asm/ptrace.h|3 + arch/arc/include/asm/unaligned.h | 29 + arch/arc/kernel/Makefile |3 +- arch/arc/kernel/disasm.c |2 +- arch/arc/kernel/entry.S | 13 ++ arch/arc/kernel/traps.c | 26 + arch/arc/kernel/unaligned.c | 225 ++ 9 files changed, 308 insertions(+), 3 deletions(-) create mode 100644 arch/arc/include/asm/unaligned.h create mode 100644 arch/arc/kernel/unaligned.c diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index 3ef21be..81d78fc 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig @@ -343,6 +343,15 @@ config ARC_CURR_IN_REG This reserved Register R25 to point to Current Task in kernel mode. This saves memory access for each such access + +config ARC_MISALIGN_ACCESS + bool Emulate unaligned memory access (userspace only) + default N + help + This enables misaligned 16 32 bit memory access from user space. + Use ONLY-IF-ABS-NECESSARY as it will be very slow and also can hide + potential bugs in code + config ARC_STACK_NONEXEC bool Make stack non-executable default n diff --git a/arch/arc/include/asm/Kbuild b/arch/arc/include/asm/Kbuild index a246390..06ca702 100644 --- a/arch/arc/include/asm/Kbuild +++ b/arch/arc/include/asm/Kbuild @@ -51,7 +51,6 @@ generic-y += termios.h generic-y += topology.h generic-y += types.h generic-y += ucontext.h -generic-y += unaligned.h generic-y += user.h generic-y += vga.h generic-y += xor.h diff --git a/arch/arc/include/asm/ptrace.h b/arch/arc/include/asm/ptrace.h index bb621e8..2843dd4 100644 --- a/arch/arc/include/asm/ptrace.h +++ b/arch/arc/include/asm/ptrace.h @@ -117,6 +117,9 @@ struct user_regs_struct { /* return 1 if user mode or 0 if kernel mode */ #define user_mode(regs) (regs-status32 STATUS_U_MASK) +/* return 1 if PC in delay slot */ +#define delay_mode(regs) ((regs-status32 STATUS_DE_MASK) == STATUS_DE_MASK) + /* return 1 if in syscall, 0 if Intr or Exception */ #define in_syscall(regs) (((regs-orig_r8) = 0 \ (regs-orig_r8 = NR_syscalls)) ? 1 : 0) diff --git a/arch/arc/include/asm/unaligned.h b/arch/arc/include/asm/unaligned.h new file mode 100644 index 000..5dbe63f --- /dev/null +++ b/arch/arc/include/asm/unaligned.h @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef _ASM_ARC_UNALIGNED_H +#define _ASM_ARC_UNALIGNED_H + +/* ARC700 can't handle unaligned Data accesses. */ + +#include asm-generic/unaligned.h +#include asm/ptrace.h + +#ifdef CONFIG_ARC_MISALIGN_ACCESS +int misaligned_fixup(unsigned long address, struct pt_regs *regs, +unsigned long cause, struct callee_regs *cregs); +#else +static inline int +misaligned_fixup(unsigned long address, struct pt_regs *regs, +unsigned long cause, struct callee_regs *cregs) +{ + return 0; +} +#endif + +#endif /* _ASM_ARC_UNALIGNED_H */ diff --git a/arch/arc/kernel/Makefile b/arch/arc/kernel/Makefile index 442d024..52ef6ce 100644 --- a/arch/arc/kernel/Makefile +++ b/arch/arc/kernel/Makefile @@ -9,13 +9,14 @@ CFLAGS_ptrace.o+= -DUTS_MACHINE='$(UTS_MACHINE)' obj-y := arcksyms.o setup.o irq.o time.o reset.o ptrace.o entry.o process.o \ - signal.o traps.o sys.o troubleshoot.o stacktrace.o disasm.c + signal.o traps.o sys.o troubleshoot.o stacktrace.o disasm.o obj-$(CONFIG_MODULES) += arcksyms.o module.o obj-$(CONFIG_ARC_DBG_EVENT_TIMELINE) += event-log.o obj-$(CONFIG_SMP) += smp.o obj-$(CONFIG_ARC_DW2_UNWIND) += unwind.o obj-$(CONFIG_KPROBES) += kprobes.o +obj-$(CONFIG_ARC_MISALIGN_ACCESS) += unaligned.o obj-$(CONFIG_ARC_FPU_SAVE_RESTORE) += fpu.o CFLAGS_fpu.o += -mdpfp diff --git a/arch/arc/kernel/disasm.c b/arch/arc/kernel/disasm.c index 51bad8f..2f39028 100644 --- a/arch/arc/kernel/disasm.c +++ b/arch/arc/kernel/disasm.c @@ -15,7 +15,7 @@ #include asm/disasm.h #include asm/uaccess.h -#if defined(CONFIG_KGDB) || defined(CONFIG_MISALIGN_ACCESS) || \ +#if defined(CONFIG_KGDB) || defined(CONFIG_ARC_MISALIGN_ACCESS) || \ defined(CONFIG_KPROBES) /* disasm_instr: Analyses instruction at addr, stores diff --git a/arch/arc/kernel/entry.S b/arch/arc/kernel/entry.S index 13d6feb..2ff15e0 100644 --- a/arch/arc/kernel/entry.S +++ b/arch/arc/kernel/entry.S @@ -12,6 +12,9 @@ * needed before task_pt_regs was invented. This saves a branch per call * and more
[RFC Patch v1 47/55] ARC: startup #2: Verbose Boot reporting / feature verification
From: Vineet Gupta vgu...@synopsys.com Signed-off-by: Vineet Gupta vgu...@synopsys.com --- arch/arc/Makefile |2 + arch/arc/include/asm/arcregs.h | 122 -- arch/arc/include/asm/defines.h | 56 ++ arch/arc/include/asm/setup.h | 14 +++ arch/arc/kernel/setup.c| 223 +++- arch/arc/mm/cache_arc700.c | 46 arch/arc/mm/tlb.c | 38 +++ 7 files changed, 490 insertions(+), 11 deletions(-) create mode 100644 arch/arc/include/asm/defines.h diff --git a/arch/arc/Makefile b/arch/arc/Makefile index a86e284..3de315e 100644 --- a/arch/arc/Makefile +++ b/arch/arc/Makefile @@ -20,6 +20,8 @@ export PLATFORM cflags-y += -Iarch/arc/plat-$(PLATFORM)/include cflags-y += -mA7 -fno-common -pipe -fno-builtin -D__linux__ +LINUXINCLUDE += -include ${src}/arch/arc/include/asm/defines.h + ifdef CONFIG_ARC_CURR_IN_REG # For a global register defintion, make sure it gets passed to every file # We had a customer reported bug where some code built in kernel was NOT using diff --git a/arch/arc/include/asm/arcregs.h b/arch/arc/include/asm/arcregs.h index 725b94c..bd126c9 100644 --- a/arch/arc/include/asm/arcregs.h +++ b/arch/arc/include/asm/arcregs.h @@ -12,8 +12,26 @@ #ifdef __KERNEL__ /* Build Configuration Registers */ +#define ARC_REG_DCCMBASE_BCR 0x61/* DCCM Base Addr */ +#define ARC_REG_CRC_BCR0x62 +#define ARC_REG_DVFB_BCR 0x64 +#define ARC_REG_EXTARITH_BCR 0x65 #define ARC_REG_VECBASE_BCR0x68 +#define ARC_REG_PERIBASE_BCR 0x69 +#define ARC_REG_FP_BCR 0x6B/* Single-Precision FPU */ +#define ARC_REG_DPFP_BCR 0x6C/* Dbl Precision FPU */ #define ARC_REG_MMU_BCR0x6f +#define ARC_REG_DCCM_BCR 0x74/* DCCM Present + SZ */ +#define ARC_REG_TIMERS_BCR 0x75 +#define ARC_REG_ICCM_BCR 0x78 +#define ARC_REG_XY_MEM_BCR 0x79 +#define ARC_REG_MAC_BCR0x7a +#define ARC_REG_MUL_BCR0x7b +#define ARC_REG_SWAP_BCR 0x7c +#define ARC_REG_NORM_BCR 0x7d +#define ARC_REG_MIXMAX_BCR 0x7e +#define ARC_REG_BARREL_BCR 0x7f +#define ARC_REG_D_UNCACH_BCR 0x6A /* status32 Bits Positions */ #define STATUS_H_BIT 0 /* CPU Halted */ @@ -87,16 +105,6 @@ #define TIMER_CTRL_IE (1 0) /* Interupt when Count reachs limit */ #define TIMER_CTRL_NH (1 1) /* Count only when CPU NOT halted */ -#if defined(CONFIG_ARC_MMU_V1) -#define CONFIG_ARC_MMU_VER 1 -#elif defined(CONFIG_ARC_MMU_V2) -#define CONFIG_ARC_MMU_VER 2 -#elif defined(CONFIG_ARC_MMU_V3) -#define CONFIG_ARC_MMU_VER 3 -#else -#error Error: MMU ver -#endif - /* MMU Management regs */ #define ARC_REG_TLBPD0 0x405 #define ARC_REG_TLBPD1 0x406 @@ -276,6 +284,13 @@ struct arc_fpu { *** * Build Configuration Registers, with encoded hardware config */ +struct bcr_identity { +#ifdef CONFIG_CPU_BIG_ENDIAN + unsigned int chip_id:16, cpu_id:8, family:8; +#else + unsigned int family:8, cpu_id:8, chip_id:16; +#endif +}; struct bcr_mmu_1_2 { #ifdef CONFIG_CPU_BIG_ENDIAN @@ -295,6 +310,38 @@ struct bcr_mmu_3 { #endif }; +#define EXTN_SWAP_VALID 0x1 +#define EXTN_NORM_VALID 0x2 +#define EXTN_MINMAX_VALID 0x2 +#define EXTN_BARREL_VALID 0x2 + +struct bcr_extn { +#ifdef CONFIG_CPU_BIG_ENDIAN + unsigned int pad:20, crc:1, ext_arith:2, mul:2, barrel:2, minmax:2, +norm:2, swap:1; +#else + unsigned int swap:1, norm:2, minmax:2, barrel:2, mul:2, ext_arith:2, +crc:1, pad:20; +#endif +}; + +/* DSP Options Ref Manual */ +struct bcr_extn_mac_mul { +#ifdef CONFIG_CPU_BIG_ENDIAN + unsigned int pad:16, type:8, ver:8; +#else + unsigned int ver:8, type:8, pad:16; +#endif +}; + +struct bcr_extn_xymem { +#ifdef CONFIG_CPU_BIG_ENDIAN + unsigned int ram_org:2, num_banks:4, bank_sz:4, ver:8; +#else + unsigned int ver:8, bank_sz:4, num_banks:4, ram_org:2; +#endif +}; + struct bcr_cache { #ifdef CONFIG_CPU_BIG_ENDIAN unsigned int pad:12, line_len:4, sz:4, config:4, ver:8; @@ -303,6 +350,48 @@ struct bcr_cache { #endif }; +struct bcr_perip { +#ifdef CONFIG_CPU_BIG_ENDIAN + unsigned int start:8, pad2:8, sz:8, pad:8; +#else + unsigned int pad:8, sz:8, pad2:8, start:8; +#endif +}; +struct bcr_iccm { +#ifdef CONFIG_CPU_BIG_ENDIAN + unsigned int base:16, pad:5, sz:3, ver:8; +#else + unsigned int ver:8, sz:3, pad:5, base:16; +#endif +}; + +/* DCCM Base Address Register: ARC_REG_DCCMBASE_BCR */ +struct bcr_dccm_base { +#ifdef CONFIG_CPU_BIG_ENDIAN + unsigned int addr:24, ver:8; +#else + unsigned int ver:8, addr:24; +#endif +}; + +/* DCCM RAM Configuration Register: ARC_REG_DCCM_BCR */ +struct bcr_dccm { +#ifdef CONFIG_CPU_BIG_ENDIAN + unsigned int res:21, sz:3, ver:8;
[RFC Patch v1 48/55] ARC: [plat-arfpga] BVCI Latency Unit setup
From: Vineet Gupta vgu...@synopsys.com Signed-off-by: Vineet Gupta vgu...@synopsys.com --- arch/arc/plat-arcfpga/Kconfig| 32 + arch/arc/plat-arcfpga/platform.c | 56 ++ 2 files changed, 88 insertions(+), 0 deletions(-) diff --git a/arch/arc/plat-arcfpga/Kconfig b/arch/arc/plat-arcfpga/Kconfig index 1b65644..6bc1149 100644 --- a/arch/arc/plat-arcfpga/Kconfig +++ b/arch/arc/plat-arcfpga/Kconfig @@ -55,4 +55,36 @@ config ARC_SERIAL_LV2 depends on ARC_COMPACT_IRQ_LEVELS select ARC_IRQ5_LV2 +menuconfig ARC_HAS_BVCI_LAT_UNIT + bool BVCI Bus Latency Unit + depends on ARC_BOARD_ML509 || ARC_BOARD_ANGEL4 + help + IP to add artifical latency to BVCI Bus Based FPGA builds. + The default latency (even worst case) for FPGA is non-realistic + (~10 SDRAM, ~5 SSRAM). + +config BVCI_LAT_UNITS + hex Latency Unit(s) Bitmap + default 0x0 + depends on ARC_HAS_BVCI_LAT_UNIT + help + There are multiple Latency Units corresponding to the many + interfaces of the system bus arbiter (both CPU side as well as + the peripheral side). + To add latency to ALL memory transaction, choose Unit 0, otherwise + for finer grainer - interface wise latency, specify a bitmap (1 bit + per unit) of all units. e.g. 1,2,12 will be 0x1003 + + Unit 0 - System Arb and Mem Controller + Unit 1 - I$ and System Bus + Unit 2 - D$ and System Bus + .. + Unit 12 - IDE Disk controller and System Bus + +config BVCI_LAT_CYCLES + int Latency Value in cycles + range 0 63 + default 30 + depends on ARC_HAS_BVCI_LAT_UNIT + endif diff --git a/arch/arc/plat-arcfpga/platform.c b/arch/arc/plat-arcfpga/platform.c index 3243091..d5d4a10 100644 --- a/arch/arc/plat-arcfpga/platform.c +++ b/arch/arc/plat-arcfpga/platform.c @@ -17,6 +17,60 @@ #include asm/irq.h #include plat/memmap.h +/*---BVCI Latency Unit -*/ + +#ifdef CONFIG_ARC_HAS_BVCI_LAT_UNIT + +int lat_cycles = CONFIG_BVCI_LAT_CYCLES; + +/* BVCI Bus Profiler: Latency Unit */ +static void __init setup_bvci_lat_unit(void) +{ +#define MAX_BVCI_UNITS 12 + + /* TBD: rewrite this using I/O macros */ + volatile unsigned int *base = (unsigned int *)BVCI_LAT_UNIT_BASE; + volatile unsigned int *lat_unit = (unsigned int *)base + 21; + volatile unsigned int *lat_val = (unsigned int *)base + 22; + unsigned int unit; + const unsigned long units_req = CONFIG_BVCI_LAT_UNITS; + + /* +* There are multiple Latency Units corresponding to the many +* interfaces of the system bus arbiter (both CPU side as well as +* the peripheral side). +* +* Unit 0 - System Arb and Mem Controller - adds latency to all +* memory trasactions +* Unit 1 - I$ and System Bus +* Unit 2 - D$ and System Bus +* .. +* Unit 12 - IDE Disk controller and System Bus +* +* The programmers model requires writing to lat_unit reg first +* and then the latency value (cycles) to lat_value reg +*/ + + if (CONFIG_BVCI_LAT_UNITS == 0) { + *lat_unit = 0; + *lat_val = lat_cycles; + pr_info(BVCI Latency for all Memory Transactions %d cycles\n, + lat_cycles); + } else { + for_each_set_bit(unit, units_req, MAX_BVCI_UNITS) { + *lat_unit = unit + 1; /* above returns 0 based */ + *lat_val = lat_cycles; + pr_info(BVCI Latency for Unit[%d] = %d cycles\n, + (unit + 1), lat_cycles); + } + } +} +#else +static void __init setup_bvci_lat_unit(void) +{ +} +#endif + /*--- Platform Devices -*/ #if defined(CONFIG_SERIAL_ARC) || defined(CONFIG_SERIAL_ARC_MODULE) @@ -111,6 +165,8 @@ void __init arc_platform_early_init(void) { pr_info([plat-arcfpga]: registering early dev resources\n); + setup_bvci_lat_unit(); + arc_fpga_serial_init(); } -- 1.7.4.1 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[RFC Patch v1 49/55] perf, ARC: Enable building perf tools for ARC
From: Vineet Gupta vgu...@synopsys.com Although with uClibc there's more we need to do Signed-off-by: Vineet Gupta vgu...@synopsys.com --- tools/perf/perf.h |6 ++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/tools/perf/perf.h b/tools/perf/perf.h index c50985e..1006b17 100644 --- a/tools/perf/perf.h +++ b/tools/perf/perf.h @@ -107,6 +107,12 @@ void get_term_dimensions(struct winsize *ws); #define CPUINFO_PROC cpu model #endif +#ifdef __arc__ +#define rmb() asm volatile( ::: memory) +#define cpu_relax()rmb() +#define CPUINFO_PROC Processor +#endif + #include time.h #include unistd.h #include sys/types.h -- 1.7.4.1 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[RFC Patch v1 50/55] ARC: perf support (software counters only)
From: Vineet Gupta vgu...@synopsys.com Signed-off-by: Vineet Gupta vgu...@synopsys.com --- arch/arc/Kconfig |3 +++ arch/arc/include/asm/perf_event.h | 19 +++ 2 files changed, 22 insertions(+), 0 deletions(-) create mode 100644 arch/arc/include/asm/perf_event.h diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index b878d3e..9882ce0c 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig @@ -23,12 +23,15 @@ config ARC select HAVE_ARCH_KGDB select HAVE_ARCH_TRACEHOOK select HAVE_GENERIC_HARDIRQS + select HAVE_IRQ_WORK select HAVE_KPROBES select HAVE_KRETPROBES select HAVE_MOD_ARCH_SPECIFIC if ARC_DW2_UNWIND select HAVE_OPROFILE + select HAVE_PERF_EVENTS select HOTPLUG if !INITRAMFS_SOURCE= select MODULES_USE_ELF_RELA + select PERF_USE_VMALLOC config SCHED_OMIT_FRAME_POINTER def_bool y diff --git a/arch/arc/include/asm/perf_event.h b/arch/arc/include/asm/perf_event.h new file mode 100644 index 000..a10eb78 --- /dev/null +++ b/arch/arc/include/asm/perf_event.h @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2011-2012 Synopsys, Inc. (www.synopsys.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + */ + +#ifndef __ASM_PERF_EVENT_H +#define __ASM_PERF_EVENT_H + +#define PERF_EVENT_INDEX_OFFSET0 + +static inline void set_perf_event_pending(void) +{ +} + +#endif /* __ASM_PERF_EVENT_H */ -- 1.7.4.1 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[RFC Patch v1 52/55] ARC: Support for single cycle Close Coupled Mem (CCM)
From: Vineet Gupta vgu...@synopsys.com * Includes mapping of CCMs in address space * Annotations to move arbitrary code/data into CCM * Moving some of the critical code/data into CCM * Runtime detection/reporting Signed-off-by: Vineet Gupta vgu...@synopsys.com --- arch/arc/Kconfig | 27 arch/arc/include/asm/linkage.h | 33 + arch/arc/kernel/entry.S|4 +- arch/arc/kernel/setup.c| 53 +++- arch/arc/kernel/vmlinux.lds.S | 21 arch/arc/mm/tlbex.S|5 +-- 6 files changed, 137 insertions(+), 6 deletions(-) diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index 9882ce0c..79e8f2f 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig @@ -198,6 +198,33 @@ config ARC_CACHE_PAGES endif #ARC_CACHE +config ARC_HAS_ICCM + bool Use ICCM + help + Single Cycle RAMS to store Fast Path Code + default n + +config ARC_ICCM_SZ + int ICCM Size in KB + default 64 + depends on ARC_HAS_ICCM + +config ARC_HAS_DCCM + bool Use DCCM + help + Single Cycle RAMS to store Fast Path Data + default n + +config ARC_DCCM_SZ + int DCCM Size in KB + default 64 + depends on ARC_HAS_DCCM + +config ARC_DCCM_BASE + hex DCCM map address + default 0xA000 + depends on ARC_HAS_DCCM + config ARC_HAS_HW_MPY bool Use Hardware Multiplier (Normal or Faster XMAC) default y diff --git a/arch/arc/include/asm/linkage.h b/arch/arc/include/asm/linkage.h index a45d1bb..0283e9e 100644 --- a/arch/arc/include/asm/linkage.h +++ b/arch/arc/include/asm/linkage.h @@ -25,6 +25,39 @@ .size \ name, ASM_PREV_SYM_ADDR(\name) .endm +/* annotation for data we want in DCCM - if enabled in .config */ +.macro ARCFP_DATA nm +#ifdef CONFIG_ARC_HAS_DCCM + .section .data.arcfp +#else + .section .data +#endif + .global \nm +.endm + +/* annotation for data we want in DCCM - if enabled in .config */ +.macro ARCFP_CODE +#ifdef CONFIG_ARC_HAS_ICCM + .section .text.arcfp, ax,@progbits +#else + .section .text, ax,@progbits +#endif +.endm + +#else /* !__ASSEMBLY__ */ + +#ifdef CONFIG_ARC_HAS_ICCM +#define __arcfp_code __attribute__((__section__(.text.arcfp))) +#else +#define __arcfp_code __attribute__((__section__(.text))) +#endif + +#ifdef CONFIG_ARC_HAS_DCCM +#define __arcfp_data __attribute__((__section__(.data.arcfp))) +#else +#define __arcfp_data __attribute__((__section__(.data))) +#endif + #endif /* __ASSEMBLY__ */ #endif diff --git a/arch/arc/kernel/entry.S b/arch/arc/kernel/entry.S index 2ff15e0..873588e 100644 --- a/arch/arc/kernel/entry.S +++ b/arch/arc/kernel/entry.S @@ -155,7 +155,7 @@ VECTOR reserved; Reserved Exceptions ;# Scratch Mem for IRQ stack switching # - .section .data ; NOT .global +ARCFP_DATA int1_saved_reg .align 32 .type int1_saved_reg, @object .size int1_saved_reg, 4 @@ -165,7 +165,7 @@ int1_saved_reg: /* Each Interrupt level needs it's own scratch */ #ifdef CONFIG_ARC_COMPACT_IRQ_LEVELS - .section .data ; NOT .global +ARCFP_DATA int2_saved_reg .type int2_saved_reg, @object .size int2_saved_reg, 4 int2_saved_reg: diff --git a/arch/arc/kernel/setup.c b/arch/arc/kernel/setup.c index d470aa1..0deec55 100644 --- a/arch/arc/kernel/setup.c +++ b/arch/arc/kernel/setup.c @@ -61,6 +61,33 @@ void __init read_arc_build_cfg_regs(void) cpu-extn.ext_arith = read_aux_reg(ARC_REG_EXTARITH_BCR); cpu-extn.crc = read_aux_reg(ARC_REG_CRC_BCR); + /* Note that we read the CCM BCRs independent of kernel config +* This is to catch the cases where user doesn't know that +* CCMs are present in hardware build +*/ + { + struct bcr_iccm iccm; + struct bcr_dccm dccm; + struct bcr_dccm_base dccm_base; + unsigned int bcr_32bit_val; + + bcr_32bit_val = read_aux_reg(ARC_REG_ICCM_BCR); + if (bcr_32bit_val) { + iccm = *((struct bcr_iccm *)bcr_32bit_val); + cpu-iccm.base_addr = iccm.base 16; + cpu-iccm.sz = 0x2000 (iccm.sz - 1); + } + + bcr_32bit_val = read_aux_reg(ARC_REG_DCCM_BCR); + if (bcr_32bit_val) { + dccm = *((struct bcr_dccm *)bcr_32bit_val); + cpu-dccm.sz = 0x800 (dccm.sz); + + READ_BCR(ARC_REG_DCCMBASE_BCR, dccm_base); + cpu-dccm.base_addr = dccm_base.addr 8; + } + } + READ_BCR(ARC_REG_XY_MEM_BCR, cpu-extn_xymem); read_decode_mmu_bcr(); @@ -208,6 +235,30 @@ char *arc_extn_mumbojumbo(int cpu_id, char *buf, int len) return buf; } +void __init
[RFC Patch v1 53/55] ARC: Hostlink Pseudo-Driver for Metaware Debugger
From: Vineet Gupta vgu...@synopsys.com This allows ARC Target to do I/O to host in absence of any peripherals whatsoever, assisted by Metaware Hostlink facility. Further we have a FUSE based filesystem which makes us mount/access host filesystem on target and do fops. Signed-off-by: Vineet Gupta vgu...@synopsys.com --- arch/arc/Kconfig |9 +++ arch/arc/kernel/Makefile |1 + arch/arc/kernel/arc_hostlink.c | 114 3 files changed, 124 insertions(+), 0 deletions(-) create mode 100644 arch/arc/kernel/arc_hostlink.c diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index 79e8f2f..4653070 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig @@ -394,6 +394,15 @@ config HZ int Timer Frequency default 100 +config ARC_METAWARE_HLINK + bool Support for Metaware debugger assisted Host access + default n + help + This options allows a Linux userland apps to directly access + host file system (open/creat/read/write etc) with help from + Metaware Debugger. This can come in handy for Linux-host communication + when there is no real usable peripheral such as EMAC. + menuconfig ARC_DBG bool ARC debugging default y diff --git a/arch/arc/kernel/Makefile b/arch/arc/kernel/Makefile index a2b7493..ce14b45 100644 --- a/arch/arc/kernel/Makefile +++ b/arch/arc/kernel/Makefile @@ -18,6 +18,7 @@ obj-$(CONFIG_ARC_DW2_UNWIND) += unwind.o obj-$(CONFIG_KPROBES) += kprobes.o obj-$(CONFIG_ARC_MISALIGN_ACCESS) += unaligned.o obj-$(CONFIG_KGDB) += kgdb.o +obj-$(CONFIG_ARC_METAWARE_HLINK) += arc_hostlink.o obj-$(CONFIG_ARC_FPU_SAVE_RESTORE) += fpu.o CFLAGS_fpu.o += -mdpfp diff --git a/arch/arc/kernel/arc_hostlink.c b/arch/arc/kernel/arc_hostlink.c new file mode 100644 index 000..de3bc42 --- /dev/null +++ b/arch/arc/kernel/arc_hostlink.c @@ -0,0 +1,114 @@ +/* + * arc_hostlink.c: Pseudo-driver for Metaware provided hostlink facility + * + * Allows Linux userland access to host in absence of any peripherals. + * + * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include linux/fs.h /* file_operations */ +#include linux/device.h /* class_create */ +#include linux/cdev.h/* cdev */ +#include linux/mm.h /* VM_IO */ +#include linux/module.h +#include linux/uaccess.h + +static unsigned char __HOSTLINK__[4 * PAGE_SIZE] __aligned(PAGE_SIZE); + +static int arc_hl_mmap(struct file *fp, struct vm_area_struct *vma); +static long arc_hl_ioctl(struct file *file, unsigned int cmd, + unsigned long arg); + +static const struct file_operations arc_hl_fops = { + .owner = THIS_MODULE, + .unlocked_ioctl = arc_hl_ioctl, + .mmap = arc_hl_mmap, +}; + +static int arc_hl_major; +static int arc_hl_minor; +static int arc_hl_nr_devs = 1; +static const char arc_hl_devnm[] = hostlink; +static struct cdev arc_hl_cdev; +static struct class *arc_hl_class; + +static int __init arc_hl_linux_glue(void) +{ + dev_t arc_hl_dev; + int i; + + if (arc_hl_major) { /* Preallocated MAJOR */ + + arc_hl_dev = MKDEV(arc_hl_major, arc_hl_minor); + register_chrdev_region(arc_hl_dev, arc_hl_nr_devs, + arc_hl_devnm); + } else {/* allocates Major to devices */ + alloc_chrdev_region(arc_hl_dev, 0, arc_hl_nr_devs, + arc_hl_devnm); + arc_hl_major = MAJOR(arc_hl_dev); + } + + /* Populate sysfs entries: creates /sys/class/ sub-node for device */ + + arc_hl_class = class_create(THIS_MODULE, arc_hl_devnm); + + /* connect file ops with cdev */ + + cdev_init(arc_hl_cdev, arc_hl_fops); + arc_hl_cdev.owner = THIS_MODULE; + + /* Connect major/minor number to cdev +* makes device available. +* device nodes created with 'mknod` are probably already active. +*/ + + cdev_add(arc_hl_cdev, arc_hl_dev, arc_hl_nr_devs); + + /* creates /sys/devices/virtual/dev_name/names[i] node with +* link from/sys/class/dev_name, needed by mdev. +*/ + + for (i = 0; i arc_hl_nr_devs; i++) + device_create(arc_hl_class, NULL, MKDEV(MAJOR(arc_hl_dev), i), + NULL, arc_hl_devnm); + + pr_info(Hostlink dev to mknod is %d:%d\n, + arc_hl_major, arc_hl_minor); + return 0; +} + +static int __init arc_hl_init(void) +{ + arc_hl_linux_glue(); + + pr_info(Hlink buffer mmap @ 0x%p\n, __HOSTLINK__); + + return 0; +} + +static int
[RFC Patch v1 54/55] ARC: [plat-arcfpga] defconfig
From: Vineet Gupta vgu...@synopsys.com Signed-off-by: Vineet Gupta vgu...@synopsys.com --- arch/arc/configs/fpga_defconfig | 137 +-- 1 files changed, 130 insertions(+), 7 deletions(-) diff --git a/arch/arc/configs/fpga_defconfig b/arch/arc/configs/fpga_defconfig index cfdca3c..d43e738 100644 --- a/arch/arc/configs/fpga_defconfig +++ b/arch/arc/configs/fpga_defconfig @@ -17,6 +17,7 @@ CONFIG_STACKTRACE_SUPPORT=y CONFIG_HAVE_LATENCYTOP_SUPPORT=y # CONFIG_NO_DMA is not set CONFIG_DEFCONFIG_LIST=/lib/modules/$UNAME_RELEASE/.config +CONFIG_HAVE_IRQ_WORK=y # # General setup @@ -31,6 +32,7 @@ CONFIG_DEFAULT_HOSTNAME=(none) # CONFIG_SWAP is not set # CONFIG_SYSVIPC is not set # CONFIG_FHANDLE is not set +# CONFIG_AUDIT is not set CONFIG_HAVE_GENERIC_HARDIRQS=y # @@ -53,6 +55,7 @@ CONFIG_HIGH_RES_TIMERS=y # CONFIG_TICK_CPU_ACCOUNTING=y # CONFIG_BSD_PROCESS_ACCT is not set +# CONFIG_TASKSTATS is not set # # RCU Subsystem @@ -66,8 +69,7 @@ CONFIG_LOG_BUF_SHIFT=17 CONFIG_NAMESPACES=y # CONFIG_UTS_NS is not set # CONFIG_PID_NS is not set -CONFIG_UIDGID_CONVERTED=y -# CONFIG_UIDGID_STRICT_TYPE_CHECKS is not set +CONFIG_NET_NS=y # CONFIG_SCHED_AUTOGROUP is not set # CONFIG_SYSFS_DEPRECATED is not set # CONFIG_RELAY is not set @@ -97,13 +99,16 @@ CONFIG_BUG=y # CONFIG_SIGNALFD is not set # CONFIG_TIMERFD is not set # CONFIG_EVENTFD is not set -# CONFIG_SHMEM is not set +CONFIG_SHMEM=y # CONFIG_AIO is not set CONFIG_EMBEDDED=y +CONFIG_HAVE_PERF_EVENTS=y +CONFIG_PERF_USE_VMALLOC=y # # Kernel Performance Events And Counters # +# CONFIG_PERF_EVENTS is not set # CONFIG_VM_EVENT_COUNTERS is not set # CONFIG_SLUB_DEBUG is not set # CONFIG_COMPAT_BRK is not set @@ -111,6 +116,11 @@ CONFIG_EMBEDDED=y CONFIG_SLUB=y # CONFIG_SLOB is not set # CONFIG_PROFILING is not set +CONFIG_HAVE_OPROFILE=y +# CONFIG_KPROBES is not set +CONFIG_HAVE_KPROBES=y +CONFIG_HAVE_KRETPROBES=y +CONFIG_HAVE_ARCH_TRACEHOOK=y CONFIG_GENERIC_SMP_IDLE_THREAD=y CONFIG_ARCH_WANT_IPC_PARSE_VERSION=y CONFIG_GENERIC_KERNEL_THREAD=y @@ -121,7 +131,12 @@ CONFIG_MODULES_USE_ELF_RELA=y # # CONFIG_HAVE_GENERIC_DMA_COHERENT is not set CONFIG_BASE_SMALL=1 -# CONFIG_MODULES is not set +CONFIG_MODULES=y +# CONFIG_MODULE_FORCE_LOAD is not set +# CONFIG_MODULE_UNLOAD is not set +# CONFIG_MODVERSIONS is not set +# CONFIG_MODULE_SRCVERSION_ALL is not set +# CONFIG_MODULE_SIG is not set CONFIG_BLOCK=y # CONFIG_LBDAF is not set # CONFIG_BLK_DEV_BSG is not set @@ -165,6 +180,8 @@ CONFIG_ARC_CACHE_LINE_SHIFT=6 CONFIG_ARC_HAS_ICACHE=y CONFIG_ARC_HAS_DCACHE=y CONFIG_ARC_CACHE_PAGES=y +# CONFIG_ARC_HAS_ICCM is not set +# CONFIG_ARC_HAS_DCCM is not set CONFIG_ARC_HAS_HW_MPY=y # CONFIG_ARC_MMU_V1 is not set # CONFIG_ARC_MMU_V2 is not set @@ -172,6 +189,7 @@ CONFIG_ARC_MMU_V3=y CONFIG_ARC_PAGE_SIZE_8K=y # CONFIG_ARC_PAGE_SIZE_16K is not set # CONFIG_ARC_PAGE_SIZE_4K is not set +# CONFIG_ARC_COMPACT_IRQ_LEVELS is not set # CONFIG_ARC_FPU_SAVE_RESTORE is not set CONFIG_ARC_CPU_REL_4_10=y CONFIG_ARC_HAS_LLSC=y @@ -183,12 +201,17 @@ CONFIG_ARC_HAS_RTSC=y # CONFIG_ARC_BOARD_ANGEL4=y # CONFIG_ARC_BOARD_ML509 is not set +# CONFIG_ISS_SMP_EXTN is not set CONFIG_ARC_SERIAL_BAUD=115200 +# CONFIG_ARC_HAS_BVCI_LAT_UNIT is not set CONFIG_ARC_PLAT_CLK=8000 CONFIG_LINUX_LINK_BASE=0x8000 CONFIG_ARC_PLAT_SDRAM_SIZE=0x1000 +CONFIG_ARC_CURR_IN_REG=y +# CONFIG_ARC_MISALIGN_ACCESS is not set # CONFIG_ARC_STACK_NONEXEC is not set CONFIG_HZ=100 +# CONFIG_ARC_METAWARE_HLINK is not set # CONFIG_ARC_DBG is not set CONFIG_CMDLINE=print-fatal-signals=1 # CONFIG_CMDLINE_UBOOT is not set @@ -208,7 +231,71 @@ CONFIG_DEFAULT_MMAP_MIN_ADDR=4096 # CONFIG_CROSS_MEMORY_ATTACH is not set CONFIG_NEED_PER_CPU_KM=y # CONFIG_CLEANCACHE is not set -# CONFIG_NET is not set +CONFIG_NET=y + +# +# Networking options +# +CONFIG_PACKET=y +# CONFIG_PACKET_DIAG is not set +CONFIG_UNIX=y +# CONFIG_UNIX_DIAG is not set +# CONFIG_XFRM_USER is not set +# CONFIG_NET_KEY is not set +CONFIG_INET=y +# CONFIG_IP_MULTICAST is not set +# CONFIG_IP_ADVANCED_ROUTER is not set +# CONFIG_IP_PNP is not set +# CONFIG_NET_IPIP is not set +# CONFIG_NET_IPGRE_DEMUX is not set +# CONFIG_ARPD is not set +# CONFIG_SYN_COOKIES is not set +# CONFIG_INET_AH is not set +# CONFIG_INET_ESP is not set +# CONFIG_INET_IPCOMP is not set +# CONFIG_INET_XFRM_TUNNEL is not set +# CONFIG_INET_TUNNEL is not set +# CONFIG_INET_XFRM_MODE_TRANSPORT is not set +# CONFIG_INET_XFRM_MODE_TUNNEL is not set +# CONFIG_INET_XFRM_MODE_BEET is not set +# CONFIG_INET_LRO is not set +CONFIG_INET_DIAG=y +CONFIG_INET_TCP_DIAG=y +# CONFIG_INET_UDP_DIAG is not set +# CONFIG_TCP_CONG_ADVANCED is not set +CONFIG_TCP_CONG_CUBIC=y +CONFIG_DEFAULT_TCP_CONG=cubic +# CONFIG_IPV6 is not set +# CONFIG_NETWORK_SECMARK is not set +# CONFIG_NETFILTER is not set +# CONFIG_ATM is not set +# CONFIG_L2TP is not set +# CONFIG_BRIDGE is not set +# CONFIG_VLAN_8021Q is not set +#
[RFC Patch v1 55/55] ARC: Add self to MAINTAINERS
From: Vineet Gupta vgu...@synopsys.com Signed-off-by: Vineet Gupta vgu...@synopsys.com --- MAINTAINERS |6 ++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index 1fa9074..e933489 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -7073,6 +7073,12 @@ F: lib/swiotlb.c F: arch/*/kernel/pci-swiotlb.c F: include/linux/swiotlb.h +SYNOPSYS ARC ARCHITECTURE +M: Vineet Gupta vgu...@synopsys.com +L: linux-snps-...@vger.kernel.org +S: Supported +F: arch/arc/ + SYSV FILESYSTEM M: Christoph Hellwig h...@infradead.org S: Maintained -- 1.7.4.1 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[RFC Patch v1 42/55] ARC: stacktracing APIs based on dw2 unwinder
From: Vineet Gupta vgu...@synopsys.com Signed-off-by: Vineet Gupta vgu...@synopsys.com --- arch/arc/kernel/stacktrace.c | 215 +- 1 files changed, 213 insertions(+), 2 deletions(-) diff --git a/arch/arc/kernel/stacktrace.c b/arch/arc/kernel/stacktrace.c index b9d1646..a63ff84 100644 --- a/arch/arc/kernel/stacktrace.c +++ b/arch/arc/kernel/stacktrace.c @@ -1,13 +1,206 @@ /* + * stacktrace.c : stacktracing APIs needed by rest of kernel + * (wrappers over ARC dwarf based unwinder) + * * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. + * + * vineetg: aug 2009 + * -Implemented CONFIG_STACKTRACE APIs, primarily save_stack_trace_tsk( ) + * for displaying task's kernel mode call stack in /proc/pid/stack + * -Iterator based approach to have single copy of unwinding core and APIs + * needing unwinding, implement the logic in iterator regarding: + * = which frame onwards to start capture + * = which frame to stop capturing (wchan) + * = specifics of data structs where trace is saved(CONFIG_STACKTRACE etc) + * + * vineetg: March 2009 + * -Implemented correct versions of thread_saved_pc() and get_wchan() + * + * rajeshwarr: 2008 + * -Initial implementation */ #include linux/ptrace.h #include linux/export.h +#include linux/stacktrace.h +#include linux/kallsyms.h +#include asm/arcregs.h +#include asm/unwind.h +#include asm/switch_to.h + +/*- + * Unwinder Iterator + *- + */ + +#ifdef CONFIG_ARC_DW2_UNWIND + +static void seed_unwind_frame_info(struct task_struct *tsk, + struct pt_regs *regs, + struct unwind_frame_info *frame_info) +{ + if (tsk == NULL regs == NULL) { + unsigned long fp, sp, blink, ret; + frame_info-task = current; + + __asm__ __volatile__( + mov %0,r27\n\t + mov %1,r28\n\t + mov %2,r31\n\t + mov %3,r63\n\t + : =r(fp), =r(sp), =r(blink), =r(ret) + ); + + frame_info-regs.r27 = fp; + frame_info-regs.r28 = sp; + frame_info-regs.r31 = blink; + frame_info-regs.r63 = ret; + frame_info-call_frame = 0; + } else if (regs == NULL) { + + frame_info-task = tsk; + + frame_info-regs.r27 = KSTK_FP(tsk); + frame_info-regs.r28 = KSTK_ESP(tsk); + frame_info-regs.r31 = KSTK_BLINK(tsk); + frame_info-regs.r63 = (unsigned int)__switch_to; + + /* In the prologue of __switch_to, first FP is saved on stack +* and then SP is copied to FP. Dwarf assumes cfa as FP based +* but we didn't save FP. The value retrieved above is FP's +* state in previous frame. +* As a work around for this, we unwind from __switch_to start +* and adjust SP accordingly. The other limitation is that +* __switch_to macro is dwarf rules are not generated for inline +* assembly code +*/ + frame_info-regs.r27 = 0; + frame_info-regs.r28 += 64; + frame_info-call_frame = 0; + + } else { + frame_info-task = tsk; + + frame_info-regs.r27 = regs-fp; + frame_info-regs.r28 = regs-sp; + frame_info-regs.r31 = regs-blink; + frame_info-regs.r63 = regs-ret; + frame_info-call_frame = 0; + } +} + +#endif + +static noinline unsigned int +arc_unwind_core(struct task_struct *tsk, struct pt_regs *regs, + int (*consumer_fn) (unsigned int, void *), void *arg) +{ +#ifdef CONFIG_ARC_DW2_UNWIND + int ret = 0; + unsigned int address; + struct unwind_frame_info frame_info; + + seed_unwind_frame_info(tsk, regs, frame_info); + + while (1) { + address = UNW_PC(frame_info); + + if (address __kernel_text_address(address)) { + if (consumer_fn(address, arg) == -1) + break; + } + + ret = arc_unwind(frame_info); + + if (ret == 0) { + frame_info.regs.r63 = frame_info.regs.r31; + continue; + } else { + break; + } + } + + return address; /* return the last address it saw */ +#else + /* On ARC,
[RFC Patch v1 46/55] ARC: kgdb support
From: Mischa Jonker mjon...@synopsys.com Signed-off-by: Mischa Jonker mjon...@synopsys.com Signed-off-by: Vineet Gupta vgu...@synopsys.com --- arch/arc/Kconfig|5 +- arch/arc/include/asm/kgdb.h | 61 + arch/arc/kernel/Makefile|2 + arch/arc/kernel/kgdb.c | 205 +++ arch/arc/kernel/traps.c |6 ++ 5 files changed, 277 insertions(+), 2 deletions(-) create mode 100644 arch/arc/include/asm/kgdb.h create mode 100644 arch/arc/kernel/kgdb.c diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index 81d78fc..b878d3e 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig @@ -20,6 +20,7 @@ config ARC select GENERIC_KERNEL_THREAD select GENERIC_PENDING_IRQ if SMP select GENERIC_SMP_IDLE_THREAD + select HAVE_ARCH_KGDB select HAVE_ARCH_TRACEHOOK select HAVE_GENERIC_HARDIRQS select HAVE_KPROBES @@ -383,12 +384,12 @@ config ARC_DW2_UNWIND config ARC_DBG_TLB_PARANOIA bool Paranoia Checks in Low Level TLB Handlers - depends on ARC_DBG !SMP + depends on ARC_DBG default n config ARC_DBG_EVENT_TIMELINE bool Low level event capture - depends on ARC_DBG + depends on ARC_DBG !SMP default n help Capture low level events: IRQ/Trap/Exception diff --git a/arch/arc/include/asm/kgdb.h b/arch/arc/include/asm/kgdb.h new file mode 100644 index 000..f3c4934 --- /dev/null +++ b/arch/arc/include/asm/kgdb.h @@ -0,0 +1,61 @@ +/* + * kgdb support for ARC + * + * Copyright (C) 2012 Synopsys, Inc. (www.synopsys.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef __ARC_KGDB_H__ +#define __ARC_KGDB_H__ + +#ifdef CONFIG_KGDB + +#include asm/user.h + +/* to ensure compatibility with Linux 2.6.35, we don't implement the get/set + * register API yet */ +#undef DBG_MAX_REG_NUM + +#define GDB_MAX_REGS 39 + +#define BREAK_INSTR_SIZE 2 +#define CACHE_FLUSH_IS_SAFE1 +#define NUMREGBYTES(GDB_MAX_REGS * 4) +#define BUFMAX 2048 + +static inline void arch_kgdb_breakpoint(void) +{ + __asm__ __volatile__ (trap_s 0x4\n); +} + +extern void kgdb_trap(struct pt_regs *regs, int param); + +enum arc700_linux_regnums { + _R0 = 0, + _R1, _R2, _R3, _R4, _R5, _R6, _R7, _R8, _R9, _R10, _R11, _R12, _R13, + _R14, _R15, _R16, _R17, _R18, _R19, _R20, _R21, _R22, _R23, _R24, + _R25, _R26, + _BTA= 27, + _LP_START = 28, + _LP_END = 29, + _LP_COUNT = 30, + _STATUS32 = 31, + _BLINK = 32, + _FP = 33, + __SP= 34, + _EFA= 35, + _RET= 36, + _ORIG_R8= 37, + _STOP_PC= 38 +}; + +#else +static inline void kgdb_trap(struct pt_regs *regs, int param) +{ +} +#endif + +#endif /* __ARC_KGDB_H__ */ diff --git a/arch/arc/kernel/Makefile b/arch/arc/kernel/Makefile index 52ef6ce..a2b7493 100644 --- a/arch/arc/kernel/Makefile +++ b/arch/arc/kernel/Makefile @@ -17,6 +17,8 @@ obj-$(CONFIG_SMP) += smp.o obj-$(CONFIG_ARC_DW2_UNWIND) += unwind.o obj-$(CONFIG_KPROBES) += kprobes.o obj-$(CONFIG_ARC_MISALIGN_ACCESS) += unaligned.o +obj-$(CONFIG_KGDB) += kgdb.o + obj-$(CONFIG_ARC_FPU_SAVE_RESTORE) += fpu.o CFLAGS_fpu.o += -mdpfp diff --git a/arch/arc/kernel/kgdb.c b/arch/arc/kernel/kgdb.c new file mode 100644 index 000..2888ba5 --- /dev/null +++ b/arch/arc/kernel/kgdb.c @@ -0,0 +1,205 @@ +/* + * kgdb support for ARC + * + * Copyright (C) 2012 Synopsys, Inc. (www.synopsys.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include linux/kgdb.h +#include asm/disasm.h +#include asm/cacheflush.h + +static void to_gdb_regs(unsigned long *gdb_regs, struct pt_regs *kernel_regs, + struct callee_regs *cregs) +{ + int regno; + + for (regno = 0; regno = 26; regno++) + gdb_regs[_R0 + regno] = get_reg(regno, kernel_regs, cregs); + + for (regno = 27; regno GDB_MAX_REGS; regno++) + gdb_regs[regno] = 0; + + gdb_regs[_FP] = kernel_regs-fp; + gdb_regs[__SP] = kernel_regs-sp; + gdb_regs[_BLINK]= kernel_regs-blink; + gdb_regs[_RET] = kernel_regs-ret; + gdb_regs[_STATUS32] = kernel_regs-status32; + gdb_regs[_LP_COUNT] = kernel_regs-lp_count; + gdb_regs[_LP_END] = kernel_regs-lp_end; + gdb_regs[_LP_START] = kernel_regs-lp_start; + gdb_regs[_BTA] =
[RFC Patch v1 51/55] modpost: Ignore ARC specific non-alloc section
From: Vineet Gupta vgu...@synopsys.com ARC relocatable object files contain one/more .gnu.linkonce.arcextmap.* sections (collated into .arcextmap in final link). These sections are used by debuggers to display the extension instructions and need-not be loaded by target (hence !SHF_ALLOC) This patch adds the section to modpost's ignore list to avoid the following ==8 WARNING: vmlinux.o (.gnu.linkonce.arcextmap.inst.3.5.8): unexpected non-allocatable section. Did you forget to use ax/aw in a .S file? Note that for example linux/init.h contains section definitions for use in .S files. ==8 Signed-off-by: Vineet Gupta vgu...@synopsys.com --- scripts/mod/modpost.c |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 0d93856..fbbdb8e 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -830,6 +830,7 @@ static const char *section_white_list[] = .toc*, .xt.prop, /* xtensa */ .xt.lit, /* xtensa */ + .arcextmap*, /* arc */ NULL }; -- 1.7.4.1 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[RFC Patch v1 38/55] ARC: Low level event capture/logging
From: Vineet Gupta vgu...@synopsys.com Poorman's version of LTT Signed-off-by: Vineet Gupta vgu...@synopsys.com --- arch/arc/Kconfig |7 + arch/arc/Makefile|3 + arch/arc/include/asm/event-log-asm.h | 185 + arch/arc/include/asm/event-log.h | 102 arch/arc/kernel/Makefile |1 + arch/arc/kernel/asm-offsets.c| 15 ++ arch/arc/kernel/entry.S | 31 arch/arc/kernel/event-log.c | 304 ++ arch/arc/kernel/signal.c |3 + arch/arc/mm/tlb.c|3 + arch/arc/mm/tlbex.S |7 + 11 files changed, 661 insertions(+), 0 deletions(-) create mode 100644 arch/arc/include/asm/event-log-asm.h create mode 100644 arch/arc/include/asm/event-log.h create mode 100644 arch/arc/kernel/event-log.c diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index e096545..15d740c 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig @@ -323,6 +323,13 @@ config ARC_DBG_TLB_PARANOIA depends on ARC_DBG default n +config ARC_DBG_EVENT_TIMELINE + bool Low level event capture + depends on ARC_DBG + default n + help + Capture low level events: IRQ/Trap/Exception + config ARC_DBG_TLB_MISS_COUNT bool Profile TLB Misses default n diff --git a/arch/arc/Makefile b/arch/arc/Makefile index 7ef6767..a533546 100644 --- a/arch/arc/Makefile +++ b/arch/arc/Makefile @@ -47,6 +47,9 @@ endif disable_small_data := y cflags-$(disable_small_data) += -mno-sdata -fcall-used-gp +# Low level event tracing with Metaware debugger assist needs symbol info +cflags-$(CONFIG_ARC_DBG_EVENT_TIMELINE) += -g + cflags-$(CONFIG_CPU_BIG_ENDIAN)+= -mbig-endian ldflags-$(CONFIG_CPU_BIG_ENDIAN) += -EB diff --git a/arch/arc/include/asm/event-log-asm.h b/arch/arc/include/asm/event-log-asm.h new file mode 100644 index 000..bc29e7d --- /dev/null +++ b/arch/arc/include/asm/event-log-asm.h @@ -0,0 +1,185 @@ +/* + * Low level Event Capture API callable from Assembly Code + * vineetg: Feb 2008 + * + * TBD: SMP Safe + * + * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef __ASM_ARC_EVENT_LOG_ASM_H +#define __ASM_ARC_EVENT_LOG_ASM_H + +#include asm/event-log.h + +#ifdef __ASSEMBLY__ + +#ifndef CONFIG_ARC_DBG_EVENT_TIMELINE + +.macro TAKE_SNAP_ASM reg_scratch, reg_ptr, type +.endm + +.macro TAKE_SNAP_C_FROM_ASM type +.endm + +#else + +#include asm/asm-offsets.h + +/* + * Macro to invoke the ASM event logger routine from assmebly code + * This is generated in-place in caller. + * + * @reg_scratch and @reg_ptr: + * Registers provided by caller for coding the macro itself. + * At this point if call, say Low level ISR, the Reg-File might not have + * been saved, so only use reg safe. + * @type: + * The low level event, defined in event-log.h + */ +.macro TAKE_SNAP_ASM reg_scratch, reg_ptr, type + + /* +* Earlier we used to save only reg_scratch and clobber reg_ptr and rely +* on caller to understand this. Too much trouble. +* Now we save both +*/ + st \reg_scratch, [tmp_save_reg] + st \reg_ptr, [tmp_save_reg2] + + ld \reg_ptr, [timeline_ctr] + + /* HACK to detect if the circular log buffer is being overflowed */ + brne \reg_ptr, MAX_SNAPS, 1f + flag 1 + nop +1: +#ifdef CONFIG_ARC_HAS_HW_MPY + mpyu \reg_ptr, \reg_ptr, EVLOG_RECORD_SZ +#else +#error even logger broken for !CONFIG_ARC_HAS_HW_MPY +#endif + + add \reg_ptr, timeline_log, \reg_ptr + + /* Common data ## */ + + /* TIMER1 count in timeline_log[timeline_ctr].time */ + lr \reg_scratch, [ARC_REG_TIMER1_CNT] + st \reg_scratch, [\reg_ptr, EVLOG_FIELD_TIME] + + /* current task ptr in timeline_log[timeline_ctr].task */ + ld \reg_scratch, [_current_task] + ld \reg_scratch, [\reg_scratch, TASK_TGID] + st \reg_scratch, [\reg_ptr, EVLOG_FIELD_TASK] + + /* Type of event (Intr/Excp/Trap etc) */ + mov \reg_scratch, \type + st \reg_scratch, [\reg_ptr, EVLOG_FIELD_EVENT_ID] + + /* save SP at time of exception */ + st sp, [\reg_ptr, EVLOG_FIELD_SP] + + st 0, [\reg_ptr, EVLOG_FIELD_EXTRA] + st 0, [\reg_ptr, EVLOG_FIELD_CAUSE] + st 0, [\reg_ptr, EVLOG_FIELD_EXTRA3] + + lr \reg_scratch, [status32] + st \reg_scratch, [\reg_ptr, EVLOG_FIELD_EXTRA2] + + /* Event specific data ## */ + mov \reg_scratch, \type + and.f 0, \reg_scratch, EVENT_CLASS_EXIT + bz 1f + + /* Stuff to do for all kernel exit events */ +
[PATCH v7] serial/arc-uart: Add new driver
From: Vineet Gupta Driver for non-standard on-chip UART, instantiated in the ARC (Synopsys) FPGA Boards such as ARCAngel4/ML50x Signed-off-by: Vineet Gupta --- drivers/tty/serial/Kconfig | 23 ++ drivers/tty/serial/Makefile |1 + drivers/tty/serial/arc_uart.c| 746 ++ include/uapi/linux/serial_core.h |2 + 4 files changed, 772 insertions(+), 0 deletions(-) create mode 100644 drivers/tty/serial/arc_uart.c diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig index 2a53be5..b176801 100644 --- a/drivers/tty/serial/Kconfig +++ b/drivers/tty/serial/Kconfig @@ -1423,4 +1423,27 @@ config SERIAL_EFM32_UART_CONSOLE depends on SERIAL_EFM32_UART=y select SERIAL_CORE_CONSOLE +config SERIAL_ARC + tristate "ARC UART driver support" + select SERIAL_CORE + help + Driver for on-chip UART for ARC(Synopsys) for the legacy + FPGA Boards (ML50x/ARCAngel4) + +config SERIAL_ARC_CONSOLE + bool "Console on ARC UART" + depends on SERIAL_ARC=y + select SERIAL_CORE_CONSOLE + help + Enable system Console on ARC UART + +config SERIAL_ARC_NR_PORTS + int "Number of ARC UART ports" + depends on SERIAL_ARC + range 1 3 + default "1" + help + Set this to the number of serial ports you want the driver + to support. + endmenu diff --git a/drivers/tty/serial/Makefile b/drivers/tty/serial/Makefile index 4f694da..df1b998 100644 --- a/drivers/tty/serial/Makefile +++ b/drivers/tty/serial/Makefile @@ -82,3 +82,4 @@ obj-$(CONFIG_SERIAL_XILINX_PS_UART) += xilinx_uartps.o obj-$(CONFIG_SERIAL_SIRFSOC) += sirfsoc_uart.o obj-$(CONFIG_SERIAL_AR933X) += ar933x_uart.o obj-$(CONFIG_SERIAL_EFM32_UART) += efm32-uart.o +obj-$(CONFIG_SERIAL_ARC) += arc_uart.o diff --git a/drivers/tty/serial/arc_uart.c b/drivers/tty/serial/arc_uart.c new file mode 100644 index 000..e9c61d1 --- /dev/null +++ b/drivers/tty/serial/arc_uart.c @@ -0,0 +1,746 @@ +/* + * ARC On-Chip(fpga) UART Driver + * + * Copyright (C) 2010-2012 Synopsys, Inc. (www.synopsys.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * vineetg: July 10th 2012 + * -Decoupled the driver from arch/arc + *+Using platform_get_resource() for irq/membase (thx to bfin_uart.c) + *+Using early_platform_xxx() for early console (thx to mach-shmobile/xxx) + * + * Vineetg: Aug 21st 2010 + * -Is uart_tx_stopped() not done in tty write path as it has already been + * taken care of, in serial core + * + * Vineetg: Aug 18th 2010 + * -New Serial Core based ARC UART driver + * -Derived largely from blackfin driver albiet with some major tweaks + * + * TODO: + * -check if sysreq works + */ + +#if defined(CONFIG_SERIAL_ARC_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) +#define SUPPORT_SYSRQ +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * ARC UART Hardware Specs + / +#define ARC_UART_TX_FIFO_SIZE 1 + +/* + * UART Register set (this is not a Standards Compliant IP) + * Also each reg is Word aligned, but only 8 bits wide + */ +#define R_ID0 0 +#define R_ID1 4 +#define R_ID2 8 +#define R_ID3 12 +#define R_DATA 16 +#define R_STS 20 +#define R_BAUDL24 +#define R_BAUDH28 + +/* Bits for UART Status Reg (R/W) */ +#define RXIENB 0x04 /* Receive Interrupt Enable */ +#define TXIENB 0x40 /* Transmit Interrupt Enable */ + +#define RXEMPTY 0x20 /* Receive FIFO Empty: No char receivede */ +#define TXEMPTY 0x80 /* Transmit FIFO Empty, thus char can be written into */ + +#define RXFULL 0x08 /* Receive FIFO full */ +#define RXFULL1 0x10 /* Receive FIFO has space for 1 char (tot space=4) */ + +#define RXFERR 0x01 /* Frame Error: Stop Bit not detected */ +#define RXOERR 0x02 /* OverFlow Err: Char recv but RXFULL still set */ + +/* Uart bit fiddling helpers: lowest level */ +#define RBASE(uart, reg) (uart->port.membase + reg) +#define UART_REG_SET(u, r, v) writeb((v), RBASE(u, r)) +#define UART_REG_GET(u, r)readb(RBASE(u, r)) + +#define UART_REG_OR(u, r, v) UART_REG_SET(u, r, UART_REG_GET(u, r) | (v)) +#define UART_REG_CLR(u, r, v) UART_REG_SET(u, r, UART_REG_GET(u, r) & ~(v)) + +/* Uart bit fiddling helpers: API level */ +#define UART_SET_DATA(uart, val) UART_REG_SET(uart, R_DATA, val) +#define UART_GET_DATA(uart)UART_REG_GET(uart, R_DATA) + +#define UART_SET_BAUDH(uart, val) UART_REG_SET(uart, R_BAUDH, val) +#define UART_SET_BAUDL(uart, val) UART_REG_SET(uart, R_BAUDL, val) + +#define UART_CLR_STATUS(uart, val) UART_REG_CLR(uart, R_STS, val) +#define UART_GET_STATUS(uart) UART_REG_GET(uart, R_STS) + +#define UART_ALL_IRQ_DISABLE(uart) UART_REG_CLR(uart,
[PATCH v7] serial/arc-uart: Add new driver
From: Vineet Gupta Hi, Here's the updated revision with all of Felipe' review comments. -Rebased off tty-next tip. -Build tested for x86, both as builtin and as module -Same driver (as module) verified on ARCAngel4 Board. Please consider applying. Thanks, Vineet v7: * Reinstated (request|release)_port() as they are called w/o NULL check by core * verify_port() now does some basic checking * Use container_of() for converting embedded uart_port to arc_uart_port * dev_* instead of pr_* v6: * syntactical changes per comments by Felipe * Empty (request|release)_port removed v5: * Driver now builds as module; default !y * Fixed some build wreckage due to SERIAL_ARC && !SERIAL_ARC_CONSOLE * Fixed a sparse warning due to forced cast, hence reg offsets now in bytes v4: * UAPI disintegration fallout for serial_core.h * rebased off of tty-next v3: * Removed empty arc_serial_set_ldisc() * More set_termios fixes - CSIZE forced to CS8 (for 8N1) * global @running_on_iss replaced with platform data, saved in device specific port structure. v2: * ttyARC used as device name * Dynamic assignment of major/minor numbers. * Ref counting tty in rx routine to prevent it from disappearing in case of a hangup * set_termios fixes: - hardware flow control/parity are marked as unsupported - baud written back to termios * cosmetics such as commenting the need for @running_on_iss, empty lines etc Vineet Gupta (1): serial/arc-uart: Add new driver drivers/tty/serial/Kconfig | 23 ++ drivers/tty/serial/Makefile |1 + drivers/tty/serial/arc_uart.c| 754 ++ include/uapi/linux/serial_core.h |2 + 4 files changed, 780 insertions(+), 0 deletions(-) create mode 100644 drivers/tty/serial/arc_uart.c -- 1.7.4.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v7] serial/arc-uart: Add new driver
From: Vineet Gupta vgu...@synopsys.com Hi, Here's the updated revision with all of Felipe' review comments. -Rebased off tty-next tip. -Build tested for x86, both as builtin and as module -Same driver (as module) verified on ARCAngel4 Board. Please consider applying. Thanks, Vineet v7: * Reinstated (request|release)_port() as they are called w/o NULL check by core * verify_port() now does some basic checking * Use container_of() for converting embedded uart_port to arc_uart_port * dev_* instead of pr_* v6: * syntactical changes per comments by Felipe * Empty (request|release)_port removed v5: * Driver now builds as module; default !y * Fixed some build wreckage due to SERIAL_ARC !SERIAL_ARC_CONSOLE * Fixed a sparse warning due to forced cast, hence reg offsets now in bytes v4: * UAPI disintegration fallout for serial_core.h * rebased off of tty-next v3: * Removed empty arc_serial_set_ldisc() * More set_termios fixes - CSIZE forced to CS8 (for 8N1) * global @running_on_iss replaced with platform data, saved in device specific port structure. v2: * ttyARC used as device name * Dynamic assignment of major/minor numbers. * Ref counting tty in rx routine to prevent it from disappearing in case of a hangup * set_termios fixes: - hardware flow control/parity are marked as unsupported - baud written back to termios * cosmetics such as commenting the need for @running_on_iss, empty lines etc Vineet Gupta (1): serial/arc-uart: Add new driver drivers/tty/serial/Kconfig | 23 ++ drivers/tty/serial/Makefile |1 + drivers/tty/serial/arc_uart.c| 754 ++ include/uapi/linux/serial_core.h |2 + 4 files changed, 780 insertions(+), 0 deletions(-) create mode 100644 drivers/tty/serial/arc_uart.c -- 1.7.4.1 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v7] serial/arc-uart: Add new driver
From: Vineet Gupta vgu...@synopsys.com Driver for non-standard on-chip UART, instantiated in the ARC (Synopsys) FPGA Boards such as ARCAngel4/ML50x Signed-off-by: Vineet Gupta vgu...@synopsys.com --- drivers/tty/serial/Kconfig | 23 ++ drivers/tty/serial/Makefile |1 + drivers/tty/serial/arc_uart.c| 746 ++ include/uapi/linux/serial_core.h |2 + 4 files changed, 772 insertions(+), 0 deletions(-) create mode 100644 drivers/tty/serial/arc_uart.c diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig index 2a53be5..b176801 100644 --- a/drivers/tty/serial/Kconfig +++ b/drivers/tty/serial/Kconfig @@ -1423,4 +1423,27 @@ config SERIAL_EFM32_UART_CONSOLE depends on SERIAL_EFM32_UART=y select SERIAL_CORE_CONSOLE +config SERIAL_ARC + tristate ARC UART driver support + select SERIAL_CORE + help + Driver for on-chip UART for ARC(Synopsys) for the legacy + FPGA Boards (ML50x/ARCAngel4) + +config SERIAL_ARC_CONSOLE + bool Console on ARC UART + depends on SERIAL_ARC=y + select SERIAL_CORE_CONSOLE + help + Enable system Console on ARC UART + +config SERIAL_ARC_NR_PORTS + int Number of ARC UART ports + depends on SERIAL_ARC + range 1 3 + default 1 + help + Set this to the number of serial ports you want the driver + to support. + endmenu diff --git a/drivers/tty/serial/Makefile b/drivers/tty/serial/Makefile index 4f694da..df1b998 100644 --- a/drivers/tty/serial/Makefile +++ b/drivers/tty/serial/Makefile @@ -82,3 +82,4 @@ obj-$(CONFIG_SERIAL_XILINX_PS_UART) += xilinx_uartps.o obj-$(CONFIG_SERIAL_SIRFSOC) += sirfsoc_uart.o obj-$(CONFIG_SERIAL_AR933X) += ar933x_uart.o obj-$(CONFIG_SERIAL_EFM32_UART) += efm32-uart.o +obj-$(CONFIG_SERIAL_ARC) += arc_uart.o diff --git a/drivers/tty/serial/arc_uart.c b/drivers/tty/serial/arc_uart.c new file mode 100644 index 000..e9c61d1 --- /dev/null +++ b/drivers/tty/serial/arc_uart.c @@ -0,0 +1,746 @@ +/* + * ARC On-Chip(fpga) UART Driver + * + * Copyright (C) 2010-2012 Synopsys, Inc. (www.synopsys.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * vineetg: July 10th 2012 + * -Decoupled the driver from arch/arc + *+Using platform_get_resource() for irq/membase (thx to bfin_uart.c) + *+Using early_platform_xxx() for early console (thx to mach-shmobile/xxx) + * + * Vineetg: Aug 21st 2010 + * -Is uart_tx_stopped() not done in tty write path as it has already been + * taken care of, in serial core + * + * Vineetg: Aug 18th 2010 + * -New Serial Core based ARC UART driver + * -Derived largely from blackfin driver albiet with some major tweaks + * + * TODO: + * -check if sysreq works + */ + +#if defined(CONFIG_SERIAL_ARC_CONSOLE) defined(CONFIG_MAGIC_SYSRQ) +#define SUPPORT_SYSRQ +#endif + +#include linux/module.h +#include linux/serial.h +#include linux/console.h +#include linux/sysrq.h +#include linux/platform_device.h +#include linux/tty.h +#include linux/tty_flip.h +#include linux/serial_core.h +#include linux/io.h + +/* + * ARC UART Hardware Specs + / +#define ARC_UART_TX_FIFO_SIZE 1 + +/* + * UART Register set (this is not a Standards Compliant IP) + * Also each reg is Word aligned, but only 8 bits wide + */ +#define R_ID0 0 +#define R_ID1 4 +#define R_ID2 8 +#define R_ID3 12 +#define R_DATA 16 +#define R_STS 20 +#define R_BAUDL24 +#define R_BAUDH28 + +/* Bits for UART Status Reg (R/W) */ +#define RXIENB 0x04 /* Receive Interrupt Enable */ +#define TXIENB 0x40 /* Transmit Interrupt Enable */ + +#define RXEMPTY 0x20 /* Receive FIFO Empty: No char receivede */ +#define TXEMPTY 0x80 /* Transmit FIFO Empty, thus char can be written into */ + +#define RXFULL 0x08 /* Receive FIFO full */ +#define RXFULL1 0x10 /* Receive FIFO has space for 1 char (tot space=4) */ + +#define RXFERR 0x01 /* Frame Error: Stop Bit not detected */ +#define RXOERR 0x02 /* OverFlow Err: Char recv but RXFULL still set */ + +/* Uart bit fiddling helpers: lowest level */ +#define RBASE(uart, reg) (uart-port.membase + reg) +#define UART_REG_SET(u, r, v) writeb((v), RBASE(u, r)) +#define UART_REG_GET(u, r)readb(RBASE(u, r)) + +#define UART_REG_OR(u, r, v) UART_REG_SET(u, r, UART_REG_GET(u, r) | (v)) +#define UART_REG_CLR(u, r, v) UART_REG_SET(u, r, UART_REG_GET(u, r) ~(v)) + +/* Uart bit fiddling helpers: API level */ +#define UART_SET_DATA(uart, val) UART_REG_SET(uart, R_DATA, val) +#define UART_GET_DATA(uart)UART_REG_GET(uart, R_DATA) + +#define UART_SET_BAUDH(uart, val) UART_REG_SET(uart, R_BAUDH, val) +#define UART_SET_BAUDL(uart, val) UART_REG_SET(uart, R_BAUDL, val) + +#define
[PATCH v6] serial/arc-uart: Add new driver
From: Vineet Gupta Driver for non-standard on-chip UART, instantiated in the ARC (Synopsys) FPGA Boards such as ARCAngel4/ML50x Signed-off-by: Vineet Gupta --- drivers/tty/serial/Kconfig | 23 ++ drivers/tty/serial/Makefile |1 + drivers/tty/serial/arc_uart.c| 734 ++ include/uapi/linux/serial_core.h |2 + 4 files changed, 760 insertions(+), 0 deletions(-) create mode 100644 drivers/tty/serial/arc_uart.c diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig index 2a53be5..b176801 100644 --- a/drivers/tty/serial/Kconfig +++ b/drivers/tty/serial/Kconfig @@ -1423,4 +1423,27 @@ config SERIAL_EFM32_UART_CONSOLE depends on SERIAL_EFM32_UART=y select SERIAL_CORE_CONSOLE +config SERIAL_ARC + tristate "ARC UART driver support" + select SERIAL_CORE + help + Driver for on-chip UART for ARC(Synopsys) for the legacy + FPGA Boards (ML50x/ARCAngel4) + +config SERIAL_ARC_CONSOLE + bool "Console on ARC UART" + depends on SERIAL_ARC=y + select SERIAL_CORE_CONSOLE + help + Enable system Console on ARC UART + +config SERIAL_ARC_NR_PORTS + int "Number of ARC UART ports" + depends on SERIAL_ARC + range 1 3 + default "1" + help + Set this to the number of serial ports you want the driver + to support. + endmenu diff --git a/drivers/tty/serial/Makefile b/drivers/tty/serial/Makefile index 4f694da..df1b998 100644 --- a/drivers/tty/serial/Makefile +++ b/drivers/tty/serial/Makefile @@ -82,3 +82,4 @@ obj-$(CONFIG_SERIAL_XILINX_PS_UART) += xilinx_uartps.o obj-$(CONFIG_SERIAL_SIRFSOC) += sirfsoc_uart.o obj-$(CONFIG_SERIAL_AR933X) += ar933x_uart.o obj-$(CONFIG_SERIAL_EFM32_UART) += efm32-uart.o +obj-$(CONFIG_SERIAL_ARC) += arc_uart.o diff --git a/drivers/tty/serial/arc_uart.c b/drivers/tty/serial/arc_uart.c new file mode 100644 index 000..ea311f8 --- /dev/null +++ b/drivers/tty/serial/arc_uart.c @@ -0,0 +1,734 @@ +/* + * ARC On-Chip(fpga) UART Driver + * + * Copyright (C) 2010-2012 Synopsys, Inc. (www.synopsys.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * vineetg: July 10th 2012 + * -Decoupled the driver from arch/arc + *+Using platform_get_resource() for irq/membase (thx to bfin_uart.c) + *+Using early_platform_xxx() for early console (thx to mach-shmobile/xxx) + * + * Vineetg: Aug 21st 2010 + * -Is uart_tx_stopped() not done in tty write path as it has already been + * taken care of, in serial core + * + * Vineetg: Aug 18th 2010 + * -New Serial Core based ARC UART driver + * -Derived largely from blackfin driver albiet with some major tweaks + * + * TODO: + * -check if sysreq works + */ + +#if defined(CONFIG_SERIAL_ARC_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) +#define SUPPORT_SYSRQ +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * ARC UART Hardware Specs + / +#define ARC_UART_TX_FIFO_SIZE 1 + +/* + * UART Register set (this is not a Standards Compliant IP) + * Also each reg is Word aligned, but only 8 bits wide + */ +#define R_ID0 0 +#define R_ID1 4 +#define R_ID2 8 +#define R_ID3 12 +#define R_DATA 16 +#define R_STS 20 +#define R_BAUDL24 +#define R_BAUDH28 + +/* Bits for UART Status Reg (R/W) */ +#define RXIENB 0x04 /* Receive Interrupt Enable */ +#define TXIENB 0x40 /* Transmit Interrupt Enable */ + +#define RXEMPTY 0x20 /* Receive FIFO Empty: No char receivede */ +#define TXEMPTY 0x80 /* Transmit FIFO Empty, thus char can be written into */ + +#define RXFULL 0x08 /* Receive FIFO full */ +#define RXFULL1 0x10 /* Receive FIFO has space for 1 char (tot space=4) */ + +#define RXFERR 0x01 /* Frame Error: Stop Bit not detected */ +#define RXOERR 0x02 /* OverFlow Err: Char recv but RXFULL still set */ + +/* Uart bit fiddling helpers: lowest level */ +#define RBASE(uart, reg) (uart->port.membase + reg) +#define UART_REG_SET(u, r, v) writeb((v), RBASE(u, r)) +#define UART_REG_GET(u, r)readb(RBASE(u, r)) + +#define UART_REG_OR(u, r, v) UART_REG_SET(u, r, UART_REG_GET(u, r) | (v)) +#define UART_REG_CLR(u, r, v) UART_REG_SET(u, r, UART_REG_GET(u, r) & ~(v)) + +/* Uart bit fiddling helpers: API level */ +#define UART_SET_DATA(uart, val) UART_REG_SET(uart, R_DATA, val) +#define UART_GET_DATA(uart)UART_REG_GET(uart, R_DATA) + +#define UART_SET_BAUDH(uart, val) UART_REG_SET(uart, R_BAUDH, val) +#define UART_SET_BAUDL(uart, val) UART_REG_SET(uart, R_BAUDL, val) + +#define UART_CLR_STATUS(uart, val) UART_REG_CLR(uart, R_STS, val) +#define UART_GET_STATUS(uart) UART_REG_GET(uart, R_STS) + +#define UART_ALL_IRQ_DISABLE(uart) UART_REG_CLR(uart,
[PATCH v6] serial/arc-uart: Add new driver
From: Vineet Gupta Hi, Here's the updated revision with fixes per Greg and Felipe' review comments. -Rebased off tty-next tip. -Build tested for x86, both as builtin and as module -Same driver (as module) verified on ARCAngel4 Board. Please consider applying. Thanks, Vineet v6: * syntactical changes per comments by Felipe * Empty (request|release)_port removed v5: * Driver now builds as module; default !y * Fixed some build wreckage due to SERIAL_ARC && !SERIAL_ARC_CONSOLE * Fixed a sparse warning due to forced cast, hence reg offsets now in bytes v4: * UAPI disintegration fallout for serial_core.h * rebased off of tty-next v3: * Removed empty arc_serial_set_ldisc() * More set_termios fixes - CSIZE forced to CS8 (for 8N1) * global @running_on_iss replaced with platform data, saved in device specific port structure. v2: * ttyARC used as device name * Dynamic assignment of major/minor numbers. * Ref counting tty in rx routine to prevent it from disappearing in case of a hangup * set_termios fixes: - hardware flow control/parity are marked as unsupported - baud written back to termios * cosmetics such as commenting the need for @running_on_iss, empty lines etc Vineet Gupta (1): serial/arc-uart: Add new driver drivers/tty/serial/Kconfig | 23 ++ drivers/tty/serial/Makefile |1 + drivers/tty/serial/arc_uart.c| 754 ++ include/uapi/linux/serial_core.h |2 + 4 files changed, 780 insertions(+), 0 deletions(-) create mode 100644 drivers/tty/serial/arc_uart.c -- 1.7.4.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v5] serial/arc-uart: Add new driver
From: Vineet Gupta Hi Greg, Here's the updated revision with fixes per your review comments. -Rebased off tty-next tip. -Build tested for x86, both as builtin and as module -Same driver (as module) verified on ARCAngel4 Board. Please consider applying. Thanks, Vineet v5: * Driver now builds as module; default !y * Fixed some build wreckage due to SERIAL_ARC && !SERIAL_ARC_CONSOLE * Fixed a sparse warning due to forced cast, hence reg offsets now in bytes v4: * UAPI disintegration fallout for serial_core.h * rebased off of tty-next v3: * Removed empty arc_serial_set_ldisc() * More set_termios fixes - CSIZE forced to CS8 (for 8N1) * global @running_on_iss replaced with platform data, saved in device specific port structure. v2: * ttyARC used as device name * Dynamic assignment of major/minor numbers. * Ref counting tty in rx routine to prevent it from disappearing in case of a hangup * set_termios fixes: - hardware flow control/parity are marked as unsupported - baud written back to termios * cosmetics such as commenting the need for @running_on_iss, empty lines etc Vineet Gupta (1): serial/arc-uart: Add new driver drivers/tty/serial/Kconfig | 23 ++ drivers/tty/serial/Makefile |1 + drivers/tty/serial/arc_uart.c| 754 ++ include/uapi/linux/serial_core.h |2 + 4 files changed, 780 insertions(+), 0 deletions(-) create mode 100644 drivers/tty/serial/arc_uart.c -- 1.7.4.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v5] serial/arc-uart: Add new driver
From: Vineet Gupta Driver for non-standard on-chip UART, instantiated in the ARC (Synopsys) FPGA Boards such as ARCAngel4/ML50x Signed-off-by: Vineet Gupta --- drivers/tty/serial/Kconfig | 23 ++ drivers/tty/serial/Makefile |1 + drivers/tty/serial/arc_uart.c| 754 ++ include/uapi/linux/serial_core.h |2 + 4 files changed, 780 insertions(+), 0 deletions(-) create mode 100644 drivers/tty/serial/arc_uart.c diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig index 2a53be5..b176801 100644 --- a/drivers/tty/serial/Kconfig +++ b/drivers/tty/serial/Kconfig @@ -1423,4 +1423,27 @@ config SERIAL_EFM32_UART_CONSOLE depends on SERIAL_EFM32_UART=y select SERIAL_CORE_CONSOLE +config SERIAL_ARC + tristate "ARC UART driver support" + select SERIAL_CORE + help + Driver for on-chip UART for ARC(Synopsys) for the legacy + FPGA Boards (ML50x/ARCAngel4) + +config SERIAL_ARC_CONSOLE + bool "Console on ARC UART" + depends on SERIAL_ARC=y + select SERIAL_CORE_CONSOLE + help + Enable system Console on ARC UART + +config SERIAL_ARC_NR_PORTS + int "Number of ARC UART ports" + depends on SERIAL_ARC + range 1 3 + default "1" + help + Set this to the number of serial ports you want the driver + to support. + endmenu diff --git a/drivers/tty/serial/Makefile b/drivers/tty/serial/Makefile index 4f694da..df1b998 100644 --- a/drivers/tty/serial/Makefile +++ b/drivers/tty/serial/Makefile @@ -82,3 +82,4 @@ obj-$(CONFIG_SERIAL_XILINX_PS_UART) += xilinx_uartps.o obj-$(CONFIG_SERIAL_SIRFSOC) += sirfsoc_uart.o obj-$(CONFIG_SERIAL_AR933X) += ar933x_uart.o obj-$(CONFIG_SERIAL_EFM32_UART) += efm32-uart.o +obj-$(CONFIG_SERIAL_ARC) += arc_uart.o diff --git a/drivers/tty/serial/arc_uart.c b/drivers/tty/serial/arc_uart.c new file mode 100644 index 000..c12efae --- /dev/null +++ b/drivers/tty/serial/arc_uart.c @@ -0,0 +1,754 @@ +/* + * ARC On-Chip(fpga) UART Driver + * + * Copyright (C) 2010-2012 Synopsys, Inc. (www.synopsys.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * vineetg: July 10th 2012 + * -Decoupled the driver from arch/arc + *+Using platform_get_resource() for irq/membase (thx to bfin_uart.c) + *+Using early_platform_xxx() for early console (thx to mach-shmobile/xxx) + * + * Vineetg: Aug 21st 2010 + * -Is uart_tx_stopped() not done in tty write path as it has already been + * taken care of, in serial core + * + * Vineetg: Aug 18th 2010 + * -New Serial Core based ARC UART driver + * -Derived largely from blackfin driver albiet with some major tweaks + * + * TODO: + * -check if sysreq works + */ + +#if defined(CONFIG_SERIAL_ARC_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) +#define SUPPORT_SYSRQ +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * ARC UART Hardware Specs + / +#define ARC_UART_TX_FIFO_SIZE 1 + +/* + * UART Register set (this is not a Standards Compliant IP) + * Also each reg is Word aligned, but only 8 bits wide + */ +#define R_ID0 0 +#define R_ID1 4 +#define R_ID2 8 +#define R_ID3 12 +#define R_DATA 16 +#define R_STS 20 +#define R_BAUDL24 +#define R_BAUDH28 + +/* Bits for UART Status Reg (R/W) */ +#define RXIENB 0x04 /* Receive Interrupt Enable */ +#define TXIENB 0x40 /* Transmit Interrupt Enable */ + +#define RXEMPTY 0x20 /* Receive FIFO Empty: No char receivede */ +#define TXEMPTY 0x80 /* Transmit FIFO Empty, thus char can be written into */ + +#define RXFULL 0x08 /* Receive FIFO full */ +#define RXFULL1 0x10 /* Receive FIFO has space for 1 char (tot space=4) */ + +#define RXFERR 0x01 /* Frame Error: Stop Bit not detected */ +#define RXOERR 0x02 /* OverFlow Err: Char recv but RXFULL still set */ + +/* Uart bit fiddling helpers: lowest level */ +#define RBASE(uart, reg) (uart->port.membase + reg) +#define UART_REG_SET(u, r, v) writeb((v), RBASE(u, r)) +#define UART_REG_GET(u, r)readb(RBASE(u, r)) + +#define UART_REG_OR(u, r, v) UART_REG_SET(u, r, UART_REG_GET(u, r) | (v)) +#define UART_REG_CLR(u, r, v) UART_REG_SET(u, r, UART_REG_GET(u, r) & ~(v)) + +/* Uart bit fiddling helpers: API level */ +#define UART_SET_DATA(uart, val) UART_REG_SET(uart, R_DATA, val) +#define UART_GET_DATA(uart)UART_REG_GET(uart, R_DATA) + +#define UART_SET_BAUDH(uart, val) UART_REG_SET(uart, R_BAUDH, val) +#define UART_SET_BAUDL(uart, val) UART_REG_SET(uart, R_BAUDL, val) + +#define UART_CLR_STATUS(uart, val) UART_REG_CLR(uart, R_STS, val) +#define UART_GET_STATUS(uart) UART_REG_GET(uart, R_STS) + +#define UART_ALL_IRQ_DISABLE(uart) UART_REG_CLR(uart,
[PATCH v5] serial/arc-uart: Add new driver
From: Vineet Gupta vgu...@synopsys.com Driver for non-standard on-chip UART, instantiated in the ARC (Synopsys) FPGA Boards such as ARCAngel4/ML50x Signed-off-by: Vineet Gupta vgu...@synopsys.com --- drivers/tty/serial/Kconfig | 23 ++ drivers/tty/serial/Makefile |1 + drivers/tty/serial/arc_uart.c| 754 ++ include/uapi/linux/serial_core.h |2 + 4 files changed, 780 insertions(+), 0 deletions(-) create mode 100644 drivers/tty/serial/arc_uart.c diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig index 2a53be5..b176801 100644 --- a/drivers/tty/serial/Kconfig +++ b/drivers/tty/serial/Kconfig @@ -1423,4 +1423,27 @@ config SERIAL_EFM32_UART_CONSOLE depends on SERIAL_EFM32_UART=y select SERIAL_CORE_CONSOLE +config SERIAL_ARC + tristate ARC UART driver support + select SERIAL_CORE + help + Driver for on-chip UART for ARC(Synopsys) for the legacy + FPGA Boards (ML50x/ARCAngel4) + +config SERIAL_ARC_CONSOLE + bool Console on ARC UART + depends on SERIAL_ARC=y + select SERIAL_CORE_CONSOLE + help + Enable system Console on ARC UART + +config SERIAL_ARC_NR_PORTS + int Number of ARC UART ports + depends on SERIAL_ARC + range 1 3 + default 1 + help + Set this to the number of serial ports you want the driver + to support. + endmenu diff --git a/drivers/tty/serial/Makefile b/drivers/tty/serial/Makefile index 4f694da..df1b998 100644 --- a/drivers/tty/serial/Makefile +++ b/drivers/tty/serial/Makefile @@ -82,3 +82,4 @@ obj-$(CONFIG_SERIAL_XILINX_PS_UART) += xilinx_uartps.o obj-$(CONFIG_SERIAL_SIRFSOC) += sirfsoc_uart.o obj-$(CONFIG_SERIAL_AR933X) += ar933x_uart.o obj-$(CONFIG_SERIAL_EFM32_UART) += efm32-uart.o +obj-$(CONFIG_SERIAL_ARC) += arc_uart.o diff --git a/drivers/tty/serial/arc_uart.c b/drivers/tty/serial/arc_uart.c new file mode 100644 index 000..c12efae --- /dev/null +++ b/drivers/tty/serial/arc_uart.c @@ -0,0 +1,754 @@ +/* + * ARC On-Chip(fpga) UART Driver + * + * Copyright (C) 2010-2012 Synopsys, Inc. (www.synopsys.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * vineetg: July 10th 2012 + * -Decoupled the driver from arch/arc + *+Using platform_get_resource() for irq/membase (thx to bfin_uart.c) + *+Using early_platform_xxx() for early console (thx to mach-shmobile/xxx) + * + * Vineetg: Aug 21st 2010 + * -Is uart_tx_stopped() not done in tty write path as it has already been + * taken care of, in serial core + * + * Vineetg: Aug 18th 2010 + * -New Serial Core based ARC UART driver + * -Derived largely from blackfin driver albiet with some major tweaks + * + * TODO: + * -check if sysreq works + */ + +#if defined(CONFIG_SERIAL_ARC_CONSOLE) defined(CONFIG_MAGIC_SYSRQ) +#define SUPPORT_SYSRQ +#endif + +#include linux/module.h +#include linux/serial.h +#include linux/console.h +#include linux/sysrq.h +#include linux/platform_device.h +#include linux/tty.h +#include linux/tty_flip.h +#include linux/serial_core.h +#include linux/io.h + +/* + * ARC UART Hardware Specs + / +#define ARC_UART_TX_FIFO_SIZE 1 + +/* + * UART Register set (this is not a Standards Compliant IP) + * Also each reg is Word aligned, but only 8 bits wide + */ +#define R_ID0 0 +#define R_ID1 4 +#define R_ID2 8 +#define R_ID3 12 +#define R_DATA 16 +#define R_STS 20 +#define R_BAUDL24 +#define R_BAUDH28 + +/* Bits for UART Status Reg (R/W) */ +#define RXIENB 0x04 /* Receive Interrupt Enable */ +#define TXIENB 0x40 /* Transmit Interrupt Enable */ + +#define RXEMPTY 0x20 /* Receive FIFO Empty: No char receivede */ +#define TXEMPTY 0x80 /* Transmit FIFO Empty, thus char can be written into */ + +#define RXFULL 0x08 /* Receive FIFO full */ +#define RXFULL1 0x10 /* Receive FIFO has space for 1 char (tot space=4) */ + +#define RXFERR 0x01 /* Frame Error: Stop Bit not detected */ +#define RXOERR 0x02 /* OverFlow Err: Char recv but RXFULL still set */ + +/* Uart bit fiddling helpers: lowest level */ +#define RBASE(uart, reg) (uart-port.membase + reg) +#define UART_REG_SET(u, r, v) writeb((v), RBASE(u, r)) +#define UART_REG_GET(u, r)readb(RBASE(u, r)) + +#define UART_REG_OR(u, r, v) UART_REG_SET(u, r, UART_REG_GET(u, r) | (v)) +#define UART_REG_CLR(u, r, v) UART_REG_SET(u, r, UART_REG_GET(u, r) ~(v)) + +/* Uart bit fiddling helpers: API level */ +#define UART_SET_DATA(uart, val) UART_REG_SET(uart, R_DATA, val) +#define UART_GET_DATA(uart)UART_REG_GET(uart, R_DATA) + +#define UART_SET_BAUDH(uart, val) UART_REG_SET(uart, R_BAUDH, val) +#define UART_SET_BAUDL(uart, val) UART_REG_SET(uart, R_BAUDL, val) + +#define
[PATCH v5] serial/arc-uart: Add new driver
From: Vineet Gupta vgu...@synopsys.com Hi Greg, Here's the updated revision with fixes per your review comments. -Rebased off tty-next tip. -Build tested for x86, both as builtin and as module -Same driver (as module) verified on ARCAngel4 Board. Please consider applying. Thanks, Vineet v5: * Driver now builds as module; default !y * Fixed some build wreckage due to SERIAL_ARC !SERIAL_ARC_CONSOLE * Fixed a sparse warning due to forced cast, hence reg offsets now in bytes v4: * UAPI disintegration fallout for serial_core.h * rebased off of tty-next v3: * Removed empty arc_serial_set_ldisc() * More set_termios fixes - CSIZE forced to CS8 (for 8N1) * global @running_on_iss replaced with platform data, saved in device specific port structure. v2: * ttyARC used as device name * Dynamic assignment of major/minor numbers. * Ref counting tty in rx routine to prevent it from disappearing in case of a hangup * set_termios fixes: - hardware flow control/parity are marked as unsupported - baud written back to termios * cosmetics such as commenting the need for @running_on_iss, empty lines etc Vineet Gupta (1): serial/arc-uart: Add new driver drivers/tty/serial/Kconfig | 23 ++ drivers/tty/serial/Makefile |1 + drivers/tty/serial/arc_uart.c| 754 ++ include/uapi/linux/serial_core.h |2 + 4 files changed, 780 insertions(+), 0 deletions(-) create mode 100644 drivers/tty/serial/arc_uart.c -- 1.7.4.1 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v6] serial/arc-uart: Add new driver
From: Vineet Gupta vgu...@synopsys.com Hi, Here's the updated revision with fixes per Greg and Felipe' review comments. -Rebased off tty-next tip. -Build tested for x86, both as builtin and as module -Same driver (as module) verified on ARCAngel4 Board. Please consider applying. Thanks, Vineet v6: * syntactical changes per comments by Felipe * Empty (request|release)_port removed v5: * Driver now builds as module; default !y * Fixed some build wreckage due to SERIAL_ARC !SERIAL_ARC_CONSOLE * Fixed a sparse warning due to forced cast, hence reg offsets now in bytes v4: * UAPI disintegration fallout for serial_core.h * rebased off of tty-next v3: * Removed empty arc_serial_set_ldisc() * More set_termios fixes - CSIZE forced to CS8 (for 8N1) * global @running_on_iss replaced with platform data, saved in device specific port structure. v2: * ttyARC used as device name * Dynamic assignment of major/minor numbers. * Ref counting tty in rx routine to prevent it from disappearing in case of a hangup * set_termios fixes: - hardware flow control/parity are marked as unsupported - baud written back to termios * cosmetics such as commenting the need for @running_on_iss, empty lines etc Vineet Gupta (1): serial/arc-uart: Add new driver drivers/tty/serial/Kconfig | 23 ++ drivers/tty/serial/Makefile |1 + drivers/tty/serial/arc_uart.c| 754 ++ include/uapi/linux/serial_core.h |2 + 4 files changed, 780 insertions(+), 0 deletions(-) create mode 100644 drivers/tty/serial/arc_uart.c -- 1.7.4.1 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v6] serial/arc-uart: Add new driver
From: Vineet Gupta vgu...@synopsys.com Driver for non-standard on-chip UART, instantiated in the ARC (Synopsys) FPGA Boards such as ARCAngel4/ML50x Signed-off-by: Vineet Gupta vgu...@synopsys.com --- drivers/tty/serial/Kconfig | 23 ++ drivers/tty/serial/Makefile |1 + drivers/tty/serial/arc_uart.c| 734 ++ include/uapi/linux/serial_core.h |2 + 4 files changed, 760 insertions(+), 0 deletions(-) create mode 100644 drivers/tty/serial/arc_uart.c diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig index 2a53be5..b176801 100644 --- a/drivers/tty/serial/Kconfig +++ b/drivers/tty/serial/Kconfig @@ -1423,4 +1423,27 @@ config SERIAL_EFM32_UART_CONSOLE depends on SERIAL_EFM32_UART=y select SERIAL_CORE_CONSOLE +config SERIAL_ARC + tristate ARC UART driver support + select SERIAL_CORE + help + Driver for on-chip UART for ARC(Synopsys) for the legacy + FPGA Boards (ML50x/ARCAngel4) + +config SERIAL_ARC_CONSOLE + bool Console on ARC UART + depends on SERIAL_ARC=y + select SERIAL_CORE_CONSOLE + help + Enable system Console on ARC UART + +config SERIAL_ARC_NR_PORTS + int Number of ARC UART ports + depends on SERIAL_ARC + range 1 3 + default 1 + help + Set this to the number of serial ports you want the driver + to support. + endmenu diff --git a/drivers/tty/serial/Makefile b/drivers/tty/serial/Makefile index 4f694da..df1b998 100644 --- a/drivers/tty/serial/Makefile +++ b/drivers/tty/serial/Makefile @@ -82,3 +82,4 @@ obj-$(CONFIG_SERIAL_XILINX_PS_UART) += xilinx_uartps.o obj-$(CONFIG_SERIAL_SIRFSOC) += sirfsoc_uart.o obj-$(CONFIG_SERIAL_AR933X) += ar933x_uart.o obj-$(CONFIG_SERIAL_EFM32_UART) += efm32-uart.o +obj-$(CONFIG_SERIAL_ARC) += arc_uart.o diff --git a/drivers/tty/serial/arc_uart.c b/drivers/tty/serial/arc_uart.c new file mode 100644 index 000..ea311f8 --- /dev/null +++ b/drivers/tty/serial/arc_uart.c @@ -0,0 +1,734 @@ +/* + * ARC On-Chip(fpga) UART Driver + * + * Copyright (C) 2010-2012 Synopsys, Inc. (www.synopsys.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * vineetg: July 10th 2012 + * -Decoupled the driver from arch/arc + *+Using platform_get_resource() for irq/membase (thx to bfin_uart.c) + *+Using early_platform_xxx() for early console (thx to mach-shmobile/xxx) + * + * Vineetg: Aug 21st 2010 + * -Is uart_tx_stopped() not done in tty write path as it has already been + * taken care of, in serial core + * + * Vineetg: Aug 18th 2010 + * -New Serial Core based ARC UART driver + * -Derived largely from blackfin driver albiet with some major tweaks + * + * TODO: + * -check if sysreq works + */ + +#if defined(CONFIG_SERIAL_ARC_CONSOLE) defined(CONFIG_MAGIC_SYSRQ) +#define SUPPORT_SYSRQ +#endif + +#include linux/module.h +#include linux/serial.h +#include linux/console.h +#include linux/sysrq.h +#include linux/platform_device.h +#include linux/tty.h +#include linux/tty_flip.h +#include linux/serial_core.h +#include linux/io.h + +/* + * ARC UART Hardware Specs + / +#define ARC_UART_TX_FIFO_SIZE 1 + +/* + * UART Register set (this is not a Standards Compliant IP) + * Also each reg is Word aligned, but only 8 bits wide + */ +#define R_ID0 0 +#define R_ID1 4 +#define R_ID2 8 +#define R_ID3 12 +#define R_DATA 16 +#define R_STS 20 +#define R_BAUDL24 +#define R_BAUDH28 + +/* Bits for UART Status Reg (R/W) */ +#define RXIENB 0x04 /* Receive Interrupt Enable */ +#define TXIENB 0x40 /* Transmit Interrupt Enable */ + +#define RXEMPTY 0x20 /* Receive FIFO Empty: No char receivede */ +#define TXEMPTY 0x80 /* Transmit FIFO Empty, thus char can be written into */ + +#define RXFULL 0x08 /* Receive FIFO full */ +#define RXFULL1 0x10 /* Receive FIFO has space for 1 char (tot space=4) */ + +#define RXFERR 0x01 /* Frame Error: Stop Bit not detected */ +#define RXOERR 0x02 /* OverFlow Err: Char recv but RXFULL still set */ + +/* Uart bit fiddling helpers: lowest level */ +#define RBASE(uart, reg) (uart-port.membase + reg) +#define UART_REG_SET(u, r, v) writeb((v), RBASE(u, r)) +#define UART_REG_GET(u, r)readb(RBASE(u, r)) + +#define UART_REG_OR(u, r, v) UART_REG_SET(u, r, UART_REG_GET(u, r) | (v)) +#define UART_REG_CLR(u, r, v) UART_REG_SET(u, r, UART_REG_GET(u, r) ~(v)) + +/* Uart bit fiddling helpers: API level */ +#define UART_SET_DATA(uart, val) UART_REG_SET(uart, R_DATA, val) +#define UART_GET_DATA(uart)UART_REG_GET(uart, R_DATA) + +#define UART_SET_BAUDH(uart, val) UART_REG_SET(uart, R_BAUDH, val) +#define UART_SET_BAUDL(uart, val) UART_REG_SET(uart, R_BAUDL, val) + +#define
[PATCH v4] serial/arc-uart: Add New Driver
From: Vineet Gupta Hi Greg, Rebased off of tty-next and verfied that it builds fine. Please consider applying. Thanks, Vineet v4: * UAPI disintegration fallout for serial_core.h * rebased off of tty-next v3: * Removed empty arc_serial_set_ldisc() * More set_termios fixes - CSIZE forced to CS8 (for 8N1) * global @running_on_iss replaced with platform data, saved in device specific port structure. v2: * ttyARC used as device name * Dynamic assignment of major/minor numbers. * Ref counting tty in rx routine to prevent it from disappearing in case of a hangup * set_termios fixes: - hardware flow control/parity are marked as unsupported - baud written back to termios * cosmetics such as commenting the need for @running_on_iss, empty lines etc Vineet Gupta (1): serial/arc-uart: Add new driver drivers/tty/serial/Kconfig | 25 ++ drivers/tty/serial/Makefile |1 + drivers/tty/serial/arc_uart.c| 747 ++ include/uapi/linux/serial_core.h |2 + 4 files changed, 775 insertions(+), 0 deletions(-) create mode 100644 drivers/tty/serial/arc_uart.c -- 1.7.4.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] serial/arc-uart: Add new driver
From: Vineet Gupta Driver for non-standard on-chip UART, instantiated in the ARC (Synopsys) FPGA Boards such as ARCAngel4/ML50x Signed-off-by: Vineet Gupta --- drivers/tty/serial/Kconfig | 25 ++ drivers/tty/serial/Makefile |1 + drivers/tty/serial/arc_uart.c| 747 ++ include/uapi/linux/serial_core.h |2 + 4 files changed, 775 insertions(+), 0 deletions(-) create mode 100644 drivers/tty/serial/arc_uart.c diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig index 2a53be5..efee7fe 100644 --- a/drivers/tty/serial/Kconfig +++ b/drivers/tty/serial/Kconfig @@ -1423,4 +1423,29 @@ config SERIAL_EFM32_UART_CONSOLE depends on SERIAL_EFM32_UART=y select SERIAL_CORE_CONSOLE +config SERIAL_ARC + bool "ARC UART driver support" + select SERIAL_CORE + default y + help + Driver for on-chip UART for ARC(Synopsys) for the legacy + FPGA Boards (ML50x/ARCAngel4) + +config SERIAL_ARC_CONSOLE + bool + select SERIAL_CORE_CONSOLE + depends on SERIAL_ARC=y + default y + help + Enable system Console on ARC UART + +config SERIAL_ARC_NR_PORTS + int 'Number of ports' + range 1 3 + default 1 + depends on SERIAL_ARC + help + Set this to the number of serial ports you want the driver + to support. + endmenu diff --git a/drivers/tty/serial/Makefile b/drivers/tty/serial/Makefile index 4f694da..df1b998 100644 --- a/drivers/tty/serial/Makefile +++ b/drivers/tty/serial/Makefile @@ -82,3 +82,4 @@ obj-$(CONFIG_SERIAL_XILINX_PS_UART) += xilinx_uartps.o obj-$(CONFIG_SERIAL_SIRFSOC) += sirfsoc_uart.o obj-$(CONFIG_SERIAL_AR933X) += ar933x_uart.o obj-$(CONFIG_SERIAL_EFM32_UART) += efm32-uart.o +obj-$(CONFIG_SERIAL_ARC) += arc_uart.o diff --git a/drivers/tty/serial/arc_uart.c b/drivers/tty/serial/arc_uart.c new file mode 100644 index 000..9215bf4 --- /dev/null +++ b/drivers/tty/serial/arc_uart.c @@ -0,0 +1,747 @@ +/* + * ARC On-Chip(fpga) UART Driver + * + * Copyright (C) 2010-2012 Synopsys, Inc. (www.synopsys.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * vineetg: July 10th 2012 + * -Decoupled the driver from arch/arc + *+Using platform_get_resource() for irq/membase (thx to bfin_uart.c) + *+Using early_platform_xxx() for early console (thx to mach-shmobile/xxx) + * + * Vineetg: Aug 21st 2010 + * -Is uart_tx_stopped() not done in tty write path as it has already been + * taken care of, in serial core + * + * Vineetg: Aug 18th 2010 + * -New Serial Core based ARC UART driver + * -Derived largely from blackfin driver albiet with some major tweaks + * + * TODO: + * -check if sysreq works + */ + +#if defined(CONFIG_SERIAL_ARC_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) +#define SUPPORT_SYSRQ +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * ARC UART Hardware Specs + / +#define ARC_UART_TX_FIFO_SIZE 1 + +/* + * UART Register set (this is not a Standards Compliant IP) + * Also each reg is Word aligned, but only 8 bits wide + */ +#define R_ID0 0 +#define R_ID1 1 +#define R_ID2 2 +#define R_ID3 3 +#define R_DATA 4 +#define R_STS 5 +#define R_BAUDL6 +#define R_BAUDH7 + +/* Bits for UART Status Reg (R/W) */ +#define RXIENB 0x04 /* Receive Interrupt Enable */ +#define TXIENB 0x40 /* Transmit Interrupt Enable */ + +#define RXEMPTY 0x20 /* Receive FIFO Empty: No char receivede */ +#define TXEMPTY 0x80 /* Transmit FIFO Empty, thus char can be written into */ + +#define RXFULL 0x08 /* Receive FIFO full */ +#define RXFULL1 0x10 /* Receive FIFO has space for 1 char (tot space=4) */ + +#define RXFERR 0x01 /* Frame Error: Stop Bit not detected */ +#define RXOERR 0x02 /* OverFlow Err: Char recv but RXFULL still set */ + +/* Uart bit fiddling helpers: lowest level */ +#define RBASE(uart, reg) ((unsigned int *)uart->port.membase + reg) +#define UART_REG_SET(u, r, v) writeb((v), RBASE(u, r)) +#define UART_REG_GET(u, r)readb(RBASE(u, r)) + +#define UART_REG_OR(u, r, v) UART_REG_SET(u, r, UART_REG_GET(u, r) | (v)) +#define UART_REG_CLR(u, r, v) UART_REG_SET(u, r, UART_REG_GET(u, r) & ~(v)) + +/* Uart bit fiddling helpers: API level */ +#define UART_SET_DATA(uart, val) UART_REG_SET(uart, R_DATA, val) +#define UART_GET_DATA(uart)UART_REG_GET(uart, R_DATA) + +#define UART_SET_BAUDH(uart, val) UART_REG_SET(uart, R_BAUDH, val) +#define UART_SET_BAUDL(uart, val) UART_REG_SET(uart, R_BAUDL, val) + +#define UART_CLR_STATUS(uart, val) UART_REG_CLR(uart, R_STS, val) +#define UART_GET_STATUS(uart) UART_REG_GET(uart, R_STS) + +#define UART_ALL_IRQ_DISABLE(uart)
[PATCH] serial/arc-uart: Add new driver
From: Vineet Gupta vgu...@synopsys.com Driver for non-standard on-chip UART, instantiated in the ARC (Synopsys) FPGA Boards such as ARCAngel4/ML50x Signed-off-by: Vineet Gupta vgu...@synopsys.com --- drivers/tty/serial/Kconfig | 25 ++ drivers/tty/serial/Makefile |1 + drivers/tty/serial/arc_uart.c| 747 ++ include/uapi/linux/serial_core.h |2 + 4 files changed, 775 insertions(+), 0 deletions(-) create mode 100644 drivers/tty/serial/arc_uart.c diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig index 2a53be5..efee7fe 100644 --- a/drivers/tty/serial/Kconfig +++ b/drivers/tty/serial/Kconfig @@ -1423,4 +1423,29 @@ config SERIAL_EFM32_UART_CONSOLE depends on SERIAL_EFM32_UART=y select SERIAL_CORE_CONSOLE +config SERIAL_ARC + bool ARC UART driver support + select SERIAL_CORE + default y + help + Driver for on-chip UART for ARC(Synopsys) for the legacy + FPGA Boards (ML50x/ARCAngel4) + +config SERIAL_ARC_CONSOLE + bool + select SERIAL_CORE_CONSOLE + depends on SERIAL_ARC=y + default y + help + Enable system Console on ARC UART + +config SERIAL_ARC_NR_PORTS + int 'Number of ports' + range 1 3 + default 1 + depends on SERIAL_ARC + help + Set this to the number of serial ports you want the driver + to support. + endmenu diff --git a/drivers/tty/serial/Makefile b/drivers/tty/serial/Makefile index 4f694da..df1b998 100644 --- a/drivers/tty/serial/Makefile +++ b/drivers/tty/serial/Makefile @@ -82,3 +82,4 @@ obj-$(CONFIG_SERIAL_XILINX_PS_UART) += xilinx_uartps.o obj-$(CONFIG_SERIAL_SIRFSOC) += sirfsoc_uart.o obj-$(CONFIG_SERIAL_AR933X) += ar933x_uart.o obj-$(CONFIG_SERIAL_EFM32_UART) += efm32-uart.o +obj-$(CONFIG_SERIAL_ARC) += arc_uart.o diff --git a/drivers/tty/serial/arc_uart.c b/drivers/tty/serial/arc_uart.c new file mode 100644 index 000..9215bf4 --- /dev/null +++ b/drivers/tty/serial/arc_uart.c @@ -0,0 +1,747 @@ +/* + * ARC On-Chip(fpga) UART Driver + * + * Copyright (C) 2010-2012 Synopsys, Inc. (www.synopsys.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * vineetg: July 10th 2012 + * -Decoupled the driver from arch/arc + *+Using platform_get_resource() for irq/membase (thx to bfin_uart.c) + *+Using early_platform_xxx() for early console (thx to mach-shmobile/xxx) + * + * Vineetg: Aug 21st 2010 + * -Is uart_tx_stopped() not done in tty write path as it has already been + * taken care of, in serial core + * + * Vineetg: Aug 18th 2010 + * -New Serial Core based ARC UART driver + * -Derived largely from blackfin driver albiet with some major tweaks + * + * TODO: + * -check if sysreq works + */ + +#if defined(CONFIG_SERIAL_ARC_CONSOLE) defined(CONFIG_MAGIC_SYSRQ) +#define SUPPORT_SYSRQ +#endif + +#include linux/module.h +#include linux/serial.h +#include linux/console.h +#include linux/sysrq.h +#include linux/platform_device.h +#include linux/tty.h +#include linux/tty_flip.h +#include linux/serial_core.h +#include linux/io.h + +/* + * ARC UART Hardware Specs + / +#define ARC_UART_TX_FIFO_SIZE 1 + +/* + * UART Register set (this is not a Standards Compliant IP) + * Also each reg is Word aligned, but only 8 bits wide + */ +#define R_ID0 0 +#define R_ID1 1 +#define R_ID2 2 +#define R_ID3 3 +#define R_DATA 4 +#define R_STS 5 +#define R_BAUDL6 +#define R_BAUDH7 + +/* Bits for UART Status Reg (R/W) */ +#define RXIENB 0x04 /* Receive Interrupt Enable */ +#define TXIENB 0x40 /* Transmit Interrupt Enable */ + +#define RXEMPTY 0x20 /* Receive FIFO Empty: No char receivede */ +#define TXEMPTY 0x80 /* Transmit FIFO Empty, thus char can be written into */ + +#define RXFULL 0x08 /* Receive FIFO full */ +#define RXFULL1 0x10 /* Receive FIFO has space for 1 char (tot space=4) */ + +#define RXFERR 0x01 /* Frame Error: Stop Bit not detected */ +#define RXOERR 0x02 /* OverFlow Err: Char recv but RXFULL still set */ + +/* Uart bit fiddling helpers: lowest level */ +#define RBASE(uart, reg) ((unsigned int *)uart-port.membase + reg) +#define UART_REG_SET(u, r, v) writeb((v), RBASE(u, r)) +#define UART_REG_GET(u, r)readb(RBASE(u, r)) + +#define UART_REG_OR(u, r, v) UART_REG_SET(u, r, UART_REG_GET(u, r) | (v)) +#define UART_REG_CLR(u, r, v) UART_REG_SET(u, r, UART_REG_GET(u, r) ~(v)) + +/* Uart bit fiddling helpers: API level */ +#define UART_SET_DATA(uart, val) UART_REG_SET(uart, R_DATA, val) +#define UART_GET_DATA(uart)UART_REG_GET(uart, R_DATA) + +#define UART_SET_BAUDH(uart, val) UART_REG_SET(uart, R_BAUDH, val) +#define UART_SET_BAUDL(uart, val) UART_REG_SET(uart, R_BAUDL, val) + +#define
[PATCH v4] serial/arc-uart: Add New Driver
From: Vineet Gupta vgu...@synopsys.com Hi Greg, Rebased off of tty-next and verfied that it builds fine. Please consider applying. Thanks, Vineet v4: * UAPI disintegration fallout for serial_core.h * rebased off of tty-next v3: * Removed empty arc_serial_set_ldisc() * More set_termios fixes - CSIZE forced to CS8 (for 8N1) * global @running_on_iss replaced with platform data, saved in device specific port structure. v2: * ttyARC used as device name * Dynamic assignment of major/minor numbers. * Ref counting tty in rx routine to prevent it from disappearing in case of a hangup * set_termios fixes: - hardware flow control/parity are marked as unsupported - baud written back to termios * cosmetics such as commenting the need for @running_on_iss, empty lines etc Vineet Gupta (1): serial/arc-uart: Add new driver drivers/tty/serial/Kconfig | 25 ++ drivers/tty/serial/Makefile |1 + drivers/tty/serial/arc_uart.c| 747 ++ include/uapi/linux/serial_core.h |2 + 4 files changed, 775 insertions(+), 0 deletions(-) create mode 100644 drivers/tty/serial/arc_uart.c -- 1.7.4.1 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[RESEND PATCH v3] serial/arc-uart: Add new driver
From: Vineet Gupta Driver for non-standard on-chip UART, instantiated in the ARC (Synopsys) FPGA Boards such as ARCAngel4/ML50x Signed-off-by: Vineet Gupta --- drivers/tty/serial/Kconfig| 25 ++ drivers/tty/serial/Makefile |1 + drivers/tty/serial/arc_uart.c | 747 + include/linux/serial_core.h |3 + 4 files changed, 776 insertions(+), 0 deletions(-) create mode 100644 drivers/tty/serial/arc_uart.c diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig index 233fbaa..0a87741 100644 --- a/drivers/tty/serial/Kconfig +++ b/drivers/tty/serial/Kconfig @@ -1423,4 +1423,29 @@ config SERIAL_EFM32_UART_CONSOLE depends on SERIAL_EFM32_UART=y select SERIAL_CORE_CONSOLE +config SERIAL_ARC + bool "ARC UART driver support" + select SERIAL_CORE + default y + help + Driver for on-chip UART for ARC(Synopsys) for the legacy + FPGA Boards (ML50x/ARCAngel4) + +config SERIAL_ARC_CONSOLE + bool + select SERIAL_CORE_CONSOLE + depends on SERIAL_ARC=y + default y + help + Enable system Console on ARC UART + +config SERIAL_ARC_NR_PORTS + int 'Number of ports' + range 1 3 + default 1 + depends on SERIAL_ARC + help + Set this to the number of serial ports you want the driver + to support. + endmenu diff --git a/drivers/tty/serial/Makefile b/drivers/tty/serial/Makefile index 4f694da..df1b998 100644 --- a/drivers/tty/serial/Makefile +++ b/drivers/tty/serial/Makefile @@ -82,3 +82,4 @@ obj-$(CONFIG_SERIAL_XILINX_PS_UART) += xilinx_uartps.o obj-$(CONFIG_SERIAL_SIRFSOC) += sirfsoc_uart.o obj-$(CONFIG_SERIAL_AR933X) += ar933x_uart.o obj-$(CONFIG_SERIAL_EFM32_UART) += efm32-uart.o +obj-$(CONFIG_SERIAL_ARC) += arc_uart.o diff --git a/drivers/tty/serial/arc_uart.c b/drivers/tty/serial/arc_uart.c new file mode 100644 index 000..9215bf4 --- /dev/null +++ b/drivers/tty/serial/arc_uart.c @@ -0,0 +1,747 @@ +/* + * ARC On-Chip(fpga) UART Driver + * + * Copyright (C) 2010-2012 Synopsys, Inc. (www.synopsys.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * vineetg: July 10th 2012 + * -Decoupled the driver from arch/arc + *+Using platform_get_resource() for irq/membase (thx to bfin_uart.c) + *+Using early_platform_xxx() for early console (thx to mach-shmobile/xxx) + * + * Vineetg: Aug 21st 2010 + * -Is uart_tx_stopped() not done in tty write path as it has already been + * taken care of, in serial core + * + * Vineetg: Aug 18th 2010 + * -New Serial Core based ARC UART driver + * -Derived largely from blackfin driver albiet with some major tweaks + * + * TODO: + * -check if sysreq works + */ + +#if defined(CONFIG_SERIAL_ARC_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) +#define SUPPORT_SYSRQ +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * ARC UART Hardware Specs + / +#define ARC_UART_TX_FIFO_SIZE 1 + +/* + * UART Register set (this is not a Standards Compliant IP) + * Also each reg is Word aligned, but only 8 bits wide + */ +#define R_ID0 0 +#define R_ID1 1 +#define R_ID2 2 +#define R_ID3 3 +#define R_DATA 4 +#define R_STS 5 +#define R_BAUDL6 +#define R_BAUDH7 + +/* Bits for UART Status Reg (R/W) */ +#define RXIENB 0x04 /* Receive Interrupt Enable */ +#define TXIENB 0x40 /* Transmit Interrupt Enable */ + +#define RXEMPTY 0x20 /* Receive FIFO Empty: No char receivede */ +#define TXEMPTY 0x80 /* Transmit FIFO Empty, thus char can be written into */ + +#define RXFULL 0x08 /* Receive FIFO full */ +#define RXFULL1 0x10 /* Receive FIFO has space for 1 char (tot space=4) */ + +#define RXFERR 0x01 /* Frame Error: Stop Bit not detected */ +#define RXOERR 0x02 /* OverFlow Err: Char recv but RXFULL still set */ + +/* Uart bit fiddling helpers: lowest level */ +#define RBASE(uart, reg) ((unsigned int *)uart->port.membase + reg) +#define UART_REG_SET(u, r, v) writeb((v), RBASE(u, r)) +#define UART_REG_GET(u, r)readb(RBASE(u, r)) + +#define UART_REG_OR(u, r, v) UART_REG_SET(u, r, UART_REG_GET(u, r) | (v)) +#define UART_REG_CLR(u, r, v) UART_REG_SET(u, r, UART_REG_GET(u, r) & ~(v)) + +/* Uart bit fiddling helpers: API level */ +#define UART_SET_DATA(uart, val) UART_REG_SET(uart, R_DATA, val) +#define UART_GET_DATA(uart)UART_REG_GET(uart, R_DATA) + +#define UART_SET_BAUDH(uart, val) UART_REG_SET(uart, R_BAUDH, val) +#define UART_SET_BAUDL(uart, val) UART_REG_SET(uart, R_BAUDL, val) + +#define UART_CLR_STATUS(uart, val) UART_REG_CLR(uart, R_STS, val) +#define UART_GET_STATUS(uart) UART_REG_GET(uart, R_STS) + +#define UART_ALL_IRQ_DISABLE(uart) UART_REG_CLR(uart,
[RESEND PATCH v3] serial/arc-uart: Add new driver
From: Vineet Gupta Hi, Please find following ARC UART driver with all the review comments incorporated. It's rebased off of current tip (commit 12250d843e) Please consider merging. Thx, -Vineet v3: * Removed empty arc_serial_set_ldisc() * More set_termios fixes - CSIZE forced to CS8 (for 8N1) * global @running_on_iss replaced with platform data, saved in device specific port structure. v2: * ttyARC used as device name * Dynamic assignment of major/minor numbers. * Ref counting tty in rx routine to prevent it from disappearing in case of a hangup * set_termios fixes: - hardware flow control/parity are marked as unsupported - baud written back to termios * cosmetics such as commenting the need for @running_on_iss, empty lines etc Vineet Gupta (1): serial/arc-uart: Add new driver drivers/tty/serial/Kconfig| 25 ++ drivers/tty/serial/Makefile |1 + drivers/tty/serial/arc_uart.c | 747 + include/linux/serial_core.h |3 + 4 files changed, 776 insertions(+), 0 deletions(-) create mode 100644 drivers/tty/serial/arc_uart.c -- 1.7.4.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[RESEND PATCH v3] serial/arc-uart: Add new driver
From: Vineet Gupta vgu...@synopsys.com Hi, Please find following ARC UART driver with all the review comments incorporated. It's rebased off of current tip (commit 12250d843e) Please consider merging. Thx, -Vineet v3: * Removed empty arc_serial_set_ldisc() * More set_termios fixes - CSIZE forced to CS8 (for 8N1) * global @running_on_iss replaced with platform data, saved in device specific port structure. v2: * ttyARC used as device name * Dynamic assignment of major/minor numbers. * Ref counting tty in rx routine to prevent it from disappearing in case of a hangup * set_termios fixes: - hardware flow control/parity are marked as unsupported - baud written back to termios * cosmetics such as commenting the need for @running_on_iss, empty lines etc Vineet Gupta (1): serial/arc-uart: Add new driver drivers/tty/serial/Kconfig| 25 ++ drivers/tty/serial/Makefile |1 + drivers/tty/serial/arc_uart.c | 747 + include/linux/serial_core.h |3 + 4 files changed, 776 insertions(+), 0 deletions(-) create mode 100644 drivers/tty/serial/arc_uart.c -- 1.7.4.1 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[RESEND PATCH v3] serial/arc-uart: Add new driver
From: Vineet Gupta vgu...@synopsys.com Driver for non-standard on-chip UART, instantiated in the ARC (Synopsys) FPGA Boards such as ARCAngel4/ML50x Signed-off-by: Vineet Gupta vgu...@synopsys.com --- drivers/tty/serial/Kconfig| 25 ++ drivers/tty/serial/Makefile |1 + drivers/tty/serial/arc_uart.c | 747 + include/linux/serial_core.h |3 + 4 files changed, 776 insertions(+), 0 deletions(-) create mode 100644 drivers/tty/serial/arc_uart.c diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig index 233fbaa..0a87741 100644 --- a/drivers/tty/serial/Kconfig +++ b/drivers/tty/serial/Kconfig @@ -1423,4 +1423,29 @@ config SERIAL_EFM32_UART_CONSOLE depends on SERIAL_EFM32_UART=y select SERIAL_CORE_CONSOLE +config SERIAL_ARC + bool ARC UART driver support + select SERIAL_CORE + default y + help + Driver for on-chip UART for ARC(Synopsys) for the legacy + FPGA Boards (ML50x/ARCAngel4) + +config SERIAL_ARC_CONSOLE + bool + select SERIAL_CORE_CONSOLE + depends on SERIAL_ARC=y + default y + help + Enable system Console on ARC UART + +config SERIAL_ARC_NR_PORTS + int 'Number of ports' + range 1 3 + default 1 + depends on SERIAL_ARC + help + Set this to the number of serial ports you want the driver + to support. + endmenu diff --git a/drivers/tty/serial/Makefile b/drivers/tty/serial/Makefile index 4f694da..df1b998 100644 --- a/drivers/tty/serial/Makefile +++ b/drivers/tty/serial/Makefile @@ -82,3 +82,4 @@ obj-$(CONFIG_SERIAL_XILINX_PS_UART) += xilinx_uartps.o obj-$(CONFIG_SERIAL_SIRFSOC) += sirfsoc_uart.o obj-$(CONFIG_SERIAL_AR933X) += ar933x_uart.o obj-$(CONFIG_SERIAL_EFM32_UART) += efm32-uart.o +obj-$(CONFIG_SERIAL_ARC) += arc_uart.o diff --git a/drivers/tty/serial/arc_uart.c b/drivers/tty/serial/arc_uart.c new file mode 100644 index 000..9215bf4 --- /dev/null +++ b/drivers/tty/serial/arc_uart.c @@ -0,0 +1,747 @@ +/* + * ARC On-Chip(fpga) UART Driver + * + * Copyright (C) 2010-2012 Synopsys, Inc. (www.synopsys.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * vineetg: July 10th 2012 + * -Decoupled the driver from arch/arc + *+Using platform_get_resource() for irq/membase (thx to bfin_uart.c) + *+Using early_platform_xxx() for early console (thx to mach-shmobile/xxx) + * + * Vineetg: Aug 21st 2010 + * -Is uart_tx_stopped() not done in tty write path as it has already been + * taken care of, in serial core + * + * Vineetg: Aug 18th 2010 + * -New Serial Core based ARC UART driver + * -Derived largely from blackfin driver albiet with some major tweaks + * + * TODO: + * -check if sysreq works + */ + +#if defined(CONFIG_SERIAL_ARC_CONSOLE) defined(CONFIG_MAGIC_SYSRQ) +#define SUPPORT_SYSRQ +#endif + +#include linux/module.h +#include linux/serial.h +#include linux/console.h +#include linux/sysrq.h +#include linux/platform_device.h +#include linux/tty.h +#include linux/tty_flip.h +#include linux/serial_core.h +#include linux/io.h + +/* + * ARC UART Hardware Specs + / +#define ARC_UART_TX_FIFO_SIZE 1 + +/* + * UART Register set (this is not a Standards Compliant IP) + * Also each reg is Word aligned, but only 8 bits wide + */ +#define R_ID0 0 +#define R_ID1 1 +#define R_ID2 2 +#define R_ID3 3 +#define R_DATA 4 +#define R_STS 5 +#define R_BAUDL6 +#define R_BAUDH7 + +/* Bits for UART Status Reg (R/W) */ +#define RXIENB 0x04 /* Receive Interrupt Enable */ +#define TXIENB 0x40 /* Transmit Interrupt Enable */ + +#define RXEMPTY 0x20 /* Receive FIFO Empty: No char receivede */ +#define TXEMPTY 0x80 /* Transmit FIFO Empty, thus char can be written into */ + +#define RXFULL 0x08 /* Receive FIFO full */ +#define RXFULL1 0x10 /* Receive FIFO has space for 1 char (tot space=4) */ + +#define RXFERR 0x01 /* Frame Error: Stop Bit not detected */ +#define RXOERR 0x02 /* OverFlow Err: Char recv but RXFULL still set */ + +/* Uart bit fiddling helpers: lowest level */ +#define RBASE(uart, reg) ((unsigned int *)uart-port.membase + reg) +#define UART_REG_SET(u, r, v) writeb((v), RBASE(u, r)) +#define UART_REG_GET(u, r)readb(RBASE(u, r)) + +#define UART_REG_OR(u, r, v) UART_REG_SET(u, r, UART_REG_GET(u, r) | (v)) +#define UART_REG_CLR(u, r, v) UART_REG_SET(u, r, UART_REG_GET(u, r) ~(v)) + +/* Uart bit fiddling helpers: API level */ +#define UART_SET_DATA(uart, val) UART_REG_SET(uart, R_DATA, val) +#define UART_GET_DATA(uart)UART_REG_GET(uart, R_DATA) + +#define UART_SET_BAUDH(uart, val) UART_REG_SET(uart, R_BAUDH, val) +#define UART_SET_BAUDL(uart, val) UART_REG_SET(uart, R_BAUDL, val) + +#define
[PATCH v3] serial/arc-uart: Add new driver
From: Vineet Gupta Driver for non-standard on-chip UART, instantiated in the ARC (Synopsys) FPGA Boards such as ARCAngel4/ML50x v3: * Removed empty arc_serial_set_ldisc() * More set_termios fixes - CSIZE forced to CS8 (for 8N1) * global @running_on_iss replaced with platform data, saved in device specific port structure. v2: * ttyARC used as device name * Dynamic assignment of major/minor numbers. * Ref counting tty in rx routine to prevent it from disappearing in case of a hangup * set_termios fixes: - hardware flow control/parity are marked as unsupported - baud written back to termios * cosmetics such as commenting the need for @running_on_iss, empty lines etc Signed-off-by: Vineet Gupta --- drivers/tty/serial/Kconfig| 25 ++ drivers/tty/serial/Makefile |1 + drivers/tty/serial/arc_uart.c | 747 + include/linux/serial_core.h |3 + 4 files changed, 776 insertions(+), 0 deletions(-) create mode 100644 drivers/tty/serial/arc_uart.c diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig index 4720b4b..af4bd69 100644 --- a/drivers/tty/serial/Kconfig +++ b/drivers/tty/serial/Kconfig @@ -1360,4 +1360,29 @@ config SERIAL_EFM32_UART_CONSOLE depends on SERIAL_EFM32_UART=y select SERIAL_CORE_CONSOLE +config SERIAL_ARC + bool "ARC UART driver support" + select SERIAL_CORE + default y + help + Driver for on-chip UART for ARC(Synopsys) for the legacy + FPGA Boards (ML50x/ARCAngel4) + +config SERIAL_ARC_CONSOLE + bool + select SERIAL_CORE_CONSOLE + depends on SERIAL_ARC=y + default y + help + Enable system Console on ARC UART + +config SERIAL_ARC_NR_PORTS + int 'Number of ports' + range 1 3 + default 1 + depends on SERIAL_ARC + help + Set this to the number of serial ports you want the driver + to support. + endmenu diff --git a/drivers/tty/serial/Makefile b/drivers/tty/serial/Makefile index 7257c5d..2b70b5f 100644 --- a/drivers/tty/serial/Makefile +++ b/drivers/tty/serial/Makefile @@ -79,3 +79,4 @@ obj-$(CONFIG_SERIAL_XILINX_PS_UART) += xilinx_uartps.o obj-$(CONFIG_SERIAL_SIRFSOC) += sirfsoc_uart.o obj-$(CONFIG_SERIAL_AR933X) += ar933x_uart.o obj-$(CONFIG_SERIAL_EFM32_UART) += efm32-uart.o +obj-$(CONFIG_SERIAL_ARC) += arc_uart.o diff --git a/drivers/tty/serial/arc_uart.c b/drivers/tty/serial/arc_uart.c new file mode 100644 index 000..9215bf4 --- /dev/null +++ b/drivers/tty/serial/arc_uart.c @@ -0,0 +1,747 @@ +/* + * ARC On-Chip(fpga) UART Driver + * + * Copyright (C) 2010-2012 Synopsys, Inc. (www.synopsys.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * vineetg: July 10th 2012 + * -Decoupled the driver from arch/arc + *+Using platform_get_resource() for irq/membase (thx to bfin_uart.c) + *+Using early_platform_xxx() for early console (thx to mach-shmobile/xxx) + * + * Vineetg: Aug 21st 2010 + * -Is uart_tx_stopped() not done in tty write path as it has already been + * taken care of, in serial core + * + * Vineetg: Aug 18th 2010 + * -New Serial Core based ARC UART driver + * -Derived largely from blackfin driver albiet with some major tweaks + * + * TODO: + * -check if sysreq works + */ + +#if defined(CONFIG_SERIAL_ARC_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) +#define SUPPORT_SYSRQ +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * ARC UART Hardware Specs + / +#define ARC_UART_TX_FIFO_SIZE 1 + +/* + * UART Register set (this is not a Standards Compliant IP) + * Also each reg is Word aligned, but only 8 bits wide + */ +#define R_ID0 0 +#define R_ID1 1 +#define R_ID2 2 +#define R_ID3 3 +#define R_DATA 4 +#define R_STS 5 +#define R_BAUDL6 +#define R_BAUDH7 + +/* Bits for UART Status Reg (R/W) */ +#define RXIENB 0x04 /* Receive Interrupt Enable */ +#define TXIENB 0x40 /* Transmit Interrupt Enable */ + +#define RXEMPTY 0x20 /* Receive FIFO Empty: No char receivede */ +#define TXEMPTY 0x80 /* Transmit FIFO Empty, thus char can be written into */ + +#define RXFULL 0x08 /* Receive FIFO full */ +#define RXFULL1 0x10 /* Receive FIFO has space for 1 char (tot space=4) */ + +#define RXFERR 0x01 /* Frame Error: Stop Bit not detected */ +#define RXOERR 0x02 /* OverFlow Err: Char recv but RXFULL still set */ + +/* Uart bit fiddling helpers: lowest level */ +#define RBASE(uart, reg) ((unsigned int *)uart->port.membase + reg) +#define UART_REG_SET(u, r, v) writeb((v), RBASE(u, r)) +#define UART_REG_GET(u, r)readb(RBASE(u, r)) + +#define UART_REG_OR(u, r, v) UART_REG_SET(u, r, UART_REG_GET(u, r) | (v)) +#define UART_REG_CLR(u, r,
[PATCH v3] serial/arc-uart: Add new driver
From: Vineet Gupta vgu...@synopsys.com Driver for non-standard on-chip UART, instantiated in the ARC (Synopsys) FPGA Boards such as ARCAngel4/ML50x v3: * Removed empty arc_serial_set_ldisc() * More set_termios fixes - CSIZE forced to CS8 (for 8N1) * global @running_on_iss replaced with platform data, saved in device specific port structure. v2: * ttyARC used as device name * Dynamic assignment of major/minor numbers. * Ref counting tty in rx routine to prevent it from disappearing in case of a hangup * set_termios fixes: - hardware flow control/parity are marked as unsupported - baud written back to termios * cosmetics such as commenting the need for @running_on_iss, empty lines etc Signed-off-by: Vineet Gupta vgu...@synopsys.com --- drivers/tty/serial/Kconfig| 25 ++ drivers/tty/serial/Makefile |1 + drivers/tty/serial/arc_uart.c | 747 + include/linux/serial_core.h |3 + 4 files changed, 776 insertions(+), 0 deletions(-) create mode 100644 drivers/tty/serial/arc_uart.c diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig index 4720b4b..af4bd69 100644 --- a/drivers/tty/serial/Kconfig +++ b/drivers/tty/serial/Kconfig @@ -1360,4 +1360,29 @@ config SERIAL_EFM32_UART_CONSOLE depends on SERIAL_EFM32_UART=y select SERIAL_CORE_CONSOLE +config SERIAL_ARC + bool ARC UART driver support + select SERIAL_CORE + default y + help + Driver for on-chip UART for ARC(Synopsys) for the legacy + FPGA Boards (ML50x/ARCAngel4) + +config SERIAL_ARC_CONSOLE + bool + select SERIAL_CORE_CONSOLE + depends on SERIAL_ARC=y + default y + help + Enable system Console on ARC UART + +config SERIAL_ARC_NR_PORTS + int 'Number of ports' + range 1 3 + default 1 + depends on SERIAL_ARC + help + Set this to the number of serial ports you want the driver + to support. + endmenu diff --git a/drivers/tty/serial/Makefile b/drivers/tty/serial/Makefile index 7257c5d..2b70b5f 100644 --- a/drivers/tty/serial/Makefile +++ b/drivers/tty/serial/Makefile @@ -79,3 +79,4 @@ obj-$(CONFIG_SERIAL_XILINX_PS_UART) += xilinx_uartps.o obj-$(CONFIG_SERIAL_SIRFSOC) += sirfsoc_uart.o obj-$(CONFIG_SERIAL_AR933X) += ar933x_uart.o obj-$(CONFIG_SERIAL_EFM32_UART) += efm32-uart.o +obj-$(CONFIG_SERIAL_ARC) += arc_uart.o diff --git a/drivers/tty/serial/arc_uart.c b/drivers/tty/serial/arc_uart.c new file mode 100644 index 000..9215bf4 --- /dev/null +++ b/drivers/tty/serial/arc_uart.c @@ -0,0 +1,747 @@ +/* + * ARC On-Chip(fpga) UART Driver + * + * Copyright (C) 2010-2012 Synopsys, Inc. (www.synopsys.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * vineetg: July 10th 2012 + * -Decoupled the driver from arch/arc + *+Using platform_get_resource() for irq/membase (thx to bfin_uart.c) + *+Using early_platform_xxx() for early console (thx to mach-shmobile/xxx) + * + * Vineetg: Aug 21st 2010 + * -Is uart_tx_stopped() not done in tty write path as it has already been + * taken care of, in serial core + * + * Vineetg: Aug 18th 2010 + * -New Serial Core based ARC UART driver + * -Derived largely from blackfin driver albiet with some major tweaks + * + * TODO: + * -check if sysreq works + */ + +#if defined(CONFIG_SERIAL_ARC_CONSOLE) defined(CONFIG_MAGIC_SYSRQ) +#define SUPPORT_SYSRQ +#endif + +#include linux/module.h +#include linux/serial.h +#include linux/console.h +#include linux/sysrq.h +#include linux/platform_device.h +#include linux/tty.h +#include linux/tty_flip.h +#include linux/serial_core.h +#include linux/io.h + +/* + * ARC UART Hardware Specs + / +#define ARC_UART_TX_FIFO_SIZE 1 + +/* + * UART Register set (this is not a Standards Compliant IP) + * Also each reg is Word aligned, but only 8 bits wide + */ +#define R_ID0 0 +#define R_ID1 1 +#define R_ID2 2 +#define R_ID3 3 +#define R_DATA 4 +#define R_STS 5 +#define R_BAUDL6 +#define R_BAUDH7 + +/* Bits for UART Status Reg (R/W) */ +#define RXIENB 0x04 /* Receive Interrupt Enable */ +#define TXIENB 0x40 /* Transmit Interrupt Enable */ + +#define RXEMPTY 0x20 /* Receive FIFO Empty: No char receivede */ +#define TXEMPTY 0x80 /* Transmit FIFO Empty, thus char can be written into */ + +#define RXFULL 0x08 /* Receive FIFO full */ +#define RXFULL1 0x10 /* Receive FIFO has space for 1 char (tot space=4) */ + +#define RXFERR 0x01 /* Frame Error: Stop Bit not detected */ +#define RXOERR 0x02 /* OverFlow Err: Char recv but RXFULL still set */ + +/* Uart bit fiddling helpers: lowest level */ +#define RBASE(uart, reg) ((unsigned int *)uart-port.membase + reg) +#define UART_REG_SET(u, r, v) writeb((v),
[PATCH v2] serial/arc-uart: Add new driver
From: Vineet Gupta Driver for non-standard on-chip UART, instantiated in the ARC (Synopsys) FPGA Boards such as ARCAngel4/ML50x v2: * ttyARC used as device name * Dynamic assignment of major/minor numbers. * Ref counting tty in rx routine to prevent it from disappearing in case of a hangup * set_termios fixes: - hardware flow control/parity are marked as unsupported - baud written back to termios * cosmetics such as commenting the need for @running_on_iss, empty lines etc Signed-off-by: Vineet Gupta --- drivers/tty/serial/Kconfig| 25 ++ drivers/tty/serial/Makefile |1 + drivers/tty/serial/arc_uart.c | 746 + include/linux/serial_core.h |3 + 4 files changed, 775 insertions(+), 0 deletions(-) create mode 100644 drivers/tty/serial/arc_uart.c diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig index 4720b4b..af4bd69 100644 --- a/drivers/tty/serial/Kconfig +++ b/drivers/tty/serial/Kconfig @@ -1360,4 +1360,29 @@ config SERIAL_EFM32_UART_CONSOLE depends on SERIAL_EFM32_UART=y select SERIAL_CORE_CONSOLE +config SERIAL_ARC + bool "ARC UART driver support" + select SERIAL_CORE + default y + help + Driver for on-chip UART for ARC(Synopsys) for the legacy + FPGA Boards (ML50x/ARCAngel4) + +config SERIAL_ARC_CONSOLE + bool + select SERIAL_CORE_CONSOLE + depends on SERIAL_ARC=y + default y + help + Enable system Console on ARC UART + +config SERIAL_ARC_NR_PORTS + int 'Number of ports' + range 1 3 + default 1 + depends on SERIAL_ARC + help + Set this to the number of serial ports you want the driver + to support. + endmenu diff --git a/drivers/tty/serial/Makefile b/drivers/tty/serial/Makefile index 7257c5d..2b70b5f 100644 --- a/drivers/tty/serial/Makefile +++ b/drivers/tty/serial/Makefile @@ -79,3 +79,4 @@ obj-$(CONFIG_SERIAL_XILINX_PS_UART) += xilinx_uartps.o obj-$(CONFIG_SERIAL_SIRFSOC) += sirfsoc_uart.o obj-$(CONFIG_SERIAL_AR933X) += ar933x_uart.o obj-$(CONFIG_SERIAL_EFM32_UART) += efm32-uart.o +obj-$(CONFIG_SERIAL_ARC) += arc_uart.o diff --git a/drivers/tty/serial/arc_uart.c b/drivers/tty/serial/arc_uart.c new file mode 100644 index 000..b65bfe4 --- /dev/null +++ b/drivers/tty/serial/arc_uart.c @@ -0,0 +1,746 @@ +/* + * ARC On-Chip(fpga) UART Driver + * + * Copyright (C) 2010-2012 Synopsys, Inc. (www.synopsys.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * vineetg: July 10th 2012 + * -Decoupled the driver from arch/arc + *+Using platform_get_resource() for irq/membase (thx to bfin_uart.c) + *+Using early_platform_xxx() for early console (thx to mach-shmobile/xxx) + * + * Vineetg: Aug 21st 2010 + * -Is uart_tx_stopped() not done in tty write path as it has already been + * taken care of, in serial core + * + * Vineetg: Aug 18th 2010 + * -New Serial Core based ARC UART driver + * -Derived largely from blackfin driver albiet with some major tweaks + * + * TODO: + * -check if sysreq works + */ + +#if defined(CONFIG_SERIAL_ARC_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) +#define SUPPORT_SYSRQ +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * ARC UART Hardware Specs + / +#define ARC_UART_TX_FIFO_SIZE 1 + +/* + * UART Register set (this is not a Standards Compliant IP) + * Also each reg is Word aligned, but only 8 bits wide + */ +#define R_ID0 0 +#define R_ID1 1 +#define R_ID2 2 +#define R_ID3 3 +#define R_DATA 4 +#define R_STS 5 +#define R_BAUDL6 +#define R_BAUDH7 + +/* Bits for UART Status Reg (R/W) */ +#define RXIENB 0x04 /* Receive Interrupt Enable */ +#define TXIENB 0x40 /* Transmit Interrupt Enable */ + +#define RXEMPTY 0x20 /* Receive FIFO Empty: No char receivede */ +#define TXEMPTY 0x80 /* Transmit FIFO Empty, thus char can be written into */ + +#define RXFULL 0x08 /* Receive FIFO full */ +#define RXFULL1 0x10 /* Receive FIFO has space for 1 char (tot space=4) */ + +#define RXFERR 0x01 /* Frame Error: Stop Bit not detected */ +#define RXOERR 0x02 /* OverFlow Err: Char recv but RXFULL still set */ + +/* Uart bit fiddling helpers: lowest level */ +#define RBASE(uart, reg) ((unsigned int *)uart->port.membase + reg) +#define UART_REG_SET(u, r, v) writeb((v), RBASE(u, r)) +#define UART_REG_GET(u, r)readb(RBASE(u, r)) + +#define UART_REG_OR(u, r, v) UART_REG_SET(u, r, UART_REG_GET(u, r) | (v)) +#define UART_REG_CLR(u, r, v) UART_REG_SET(u, r, UART_REG_GET(u, r) & ~(v)) + +/* Uart bit fiddling helpers: API level */ +#define UART_SET_DATA(uart, val) UART_REG_SET(uart, R_DATA, val) +#define UART_GET_DATA(uart)
[PATCH v2] serial/arc-uart: Add new driver
From: Vineet Gupta vgu...@synopsys.com Driver for non-standard on-chip UART, instantiated in the ARC (Synopsys) FPGA Boards such as ARCAngel4/ML50x v2: * ttyARC used as device name * Dynamic assignment of major/minor numbers. * Ref counting tty in rx routine to prevent it from disappearing in case of a hangup * set_termios fixes: - hardware flow control/parity are marked as unsupported - baud written back to termios * cosmetics such as commenting the need for @running_on_iss, empty lines etc Signed-off-by: Vineet Gupta vgu...@synopsys.com --- drivers/tty/serial/Kconfig| 25 ++ drivers/tty/serial/Makefile |1 + drivers/tty/serial/arc_uart.c | 746 + include/linux/serial_core.h |3 + 4 files changed, 775 insertions(+), 0 deletions(-) create mode 100644 drivers/tty/serial/arc_uart.c diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig index 4720b4b..af4bd69 100644 --- a/drivers/tty/serial/Kconfig +++ b/drivers/tty/serial/Kconfig @@ -1360,4 +1360,29 @@ config SERIAL_EFM32_UART_CONSOLE depends on SERIAL_EFM32_UART=y select SERIAL_CORE_CONSOLE +config SERIAL_ARC + bool ARC UART driver support + select SERIAL_CORE + default y + help + Driver for on-chip UART for ARC(Synopsys) for the legacy + FPGA Boards (ML50x/ARCAngel4) + +config SERIAL_ARC_CONSOLE + bool + select SERIAL_CORE_CONSOLE + depends on SERIAL_ARC=y + default y + help + Enable system Console on ARC UART + +config SERIAL_ARC_NR_PORTS + int 'Number of ports' + range 1 3 + default 1 + depends on SERIAL_ARC + help + Set this to the number of serial ports you want the driver + to support. + endmenu diff --git a/drivers/tty/serial/Makefile b/drivers/tty/serial/Makefile index 7257c5d..2b70b5f 100644 --- a/drivers/tty/serial/Makefile +++ b/drivers/tty/serial/Makefile @@ -79,3 +79,4 @@ obj-$(CONFIG_SERIAL_XILINX_PS_UART) += xilinx_uartps.o obj-$(CONFIG_SERIAL_SIRFSOC) += sirfsoc_uart.o obj-$(CONFIG_SERIAL_AR933X) += ar933x_uart.o obj-$(CONFIG_SERIAL_EFM32_UART) += efm32-uart.o +obj-$(CONFIG_SERIAL_ARC) += arc_uart.o diff --git a/drivers/tty/serial/arc_uart.c b/drivers/tty/serial/arc_uart.c new file mode 100644 index 000..b65bfe4 --- /dev/null +++ b/drivers/tty/serial/arc_uart.c @@ -0,0 +1,746 @@ +/* + * ARC On-Chip(fpga) UART Driver + * + * Copyright (C) 2010-2012 Synopsys, Inc. (www.synopsys.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * vineetg: July 10th 2012 + * -Decoupled the driver from arch/arc + *+Using platform_get_resource() for irq/membase (thx to bfin_uart.c) + *+Using early_platform_xxx() for early console (thx to mach-shmobile/xxx) + * + * Vineetg: Aug 21st 2010 + * -Is uart_tx_stopped() not done in tty write path as it has already been + * taken care of, in serial core + * + * Vineetg: Aug 18th 2010 + * -New Serial Core based ARC UART driver + * -Derived largely from blackfin driver albiet with some major tweaks + * + * TODO: + * -check if sysreq works + */ + +#if defined(CONFIG_SERIAL_ARC_CONSOLE) defined(CONFIG_MAGIC_SYSRQ) +#define SUPPORT_SYSRQ +#endif + +#include linux/module.h +#include linux/serial.h +#include linux/console.h +#include linux/sysrq.h +#include linux/platform_device.h +#include linux/tty.h +#include linux/tty_flip.h +#include linux/serial_core.h +#include linux/io.h + +/* + * ARC UART Hardware Specs + / +#define ARC_UART_TX_FIFO_SIZE 1 + +/* + * UART Register set (this is not a Standards Compliant IP) + * Also each reg is Word aligned, but only 8 bits wide + */ +#define R_ID0 0 +#define R_ID1 1 +#define R_ID2 2 +#define R_ID3 3 +#define R_DATA 4 +#define R_STS 5 +#define R_BAUDL6 +#define R_BAUDH7 + +/* Bits for UART Status Reg (R/W) */ +#define RXIENB 0x04 /* Receive Interrupt Enable */ +#define TXIENB 0x40 /* Transmit Interrupt Enable */ + +#define RXEMPTY 0x20 /* Receive FIFO Empty: No char receivede */ +#define TXEMPTY 0x80 /* Transmit FIFO Empty, thus char can be written into */ + +#define RXFULL 0x08 /* Receive FIFO full */ +#define RXFULL1 0x10 /* Receive FIFO has space for 1 char (tot space=4) */ + +#define RXFERR 0x01 /* Frame Error: Stop Bit not detected */ +#define RXOERR 0x02 /* OverFlow Err: Char recv but RXFULL still set */ + +/* Uart bit fiddling helpers: lowest level */ +#define RBASE(uart, reg) ((unsigned int *)uart-port.membase + reg) +#define UART_REG_SET(u, r, v) writeb((v), RBASE(u, r)) +#define UART_REG_GET(u, r)readb(RBASE(u, r)) + +#define UART_REG_OR(u, r, v) UART_REG_SET(u, r, UART_REG_GET(u, r) | (v)) +#define UART_REG_CLR(u, r, v) UART_REG_SET(u, r,
[PATCH] serial/arc-uart: Add new driver
From: Vineet Gupta Driver for non-standard on-chip UART, instantiated in the ARC (Synopsys) FPGA Boards such as ARCAngel4/ML50x This is based off of current Linus tree, build tested for x86. Signed-off-by: Vineet Gupta --- drivers/tty/serial/Kconfig| 25 ++ drivers/tty/serial/Makefile |1 + drivers/tty/serial/arc_uart.c | 742 + include/linux/serial_core.h |3 + 4 files changed, 771 insertions(+), 0 deletions(-) create mode 100644 drivers/tty/serial/arc_uart.c diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig index 4720b4b..af4bd69 100644 --- a/drivers/tty/serial/Kconfig +++ b/drivers/tty/serial/Kconfig @@ -1360,4 +1360,29 @@ config SERIAL_EFM32_UART_CONSOLE depends on SERIAL_EFM32_UART=y select SERIAL_CORE_CONSOLE +config SERIAL_ARC + bool "ARC UART driver support" + select SERIAL_CORE + default y + help + Driver for on-chip UART for ARC(Synopsys) for the legacy + FPGA Boards (ML50x/ARCAngel4) + +config SERIAL_ARC_CONSOLE + bool + select SERIAL_CORE_CONSOLE + depends on SERIAL_ARC=y + default y + help + Enable system Console on ARC UART + +config SERIAL_ARC_NR_PORTS + int 'Number of ports' + range 1 3 + default 1 + depends on SERIAL_ARC + help + Set this to the number of serial ports you want the driver + to support. + endmenu diff --git a/drivers/tty/serial/Makefile b/drivers/tty/serial/Makefile index 7257c5d..2b70b5f 100644 --- a/drivers/tty/serial/Makefile +++ b/drivers/tty/serial/Makefile @@ -79,3 +79,4 @@ obj-$(CONFIG_SERIAL_XILINX_PS_UART) += xilinx_uartps.o obj-$(CONFIG_SERIAL_SIRFSOC) += sirfsoc_uart.o obj-$(CONFIG_SERIAL_AR933X) += ar933x_uart.o obj-$(CONFIG_SERIAL_EFM32_UART) += efm32-uart.o +obj-$(CONFIG_SERIAL_ARC) += arc_uart.o diff --git a/drivers/tty/serial/arc_uart.c b/drivers/tty/serial/arc_uart.c new file mode 100644 index 000..4f2e57b --- /dev/null +++ b/drivers/tty/serial/arc_uart.c @@ -0,0 +1,742 @@ +/* + * ARC On-Chip(fpga) UART Driver + * + * Copyright (C) 2010-2012 Synopsys, Inc. (www.synopsys.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * vineetg: July 10th 2012 + * -Decoupled the driver from arch/arc + *+Using platform_get_resource() for irq/membase (thx to bfin_uart.c) + *+Using early_platform_xxx() for early console (thx to mach-shmobile/xxx) + * + * Vineetg: Aug 21st 2010 + * -Is uart_tx_stopped() not done in tty write path as it has already been + * taken care of, in serial core + * + * Vineetg: Aug 18th 2010 + * -New Serial Core based ARC UART driver + * -Derived largely from blackfin driver albiet with some major tweaks + * + * TODO: + * -check if sysreq works + */ + +#if defined(CONFIG_SERIAL_ARC_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) +#define SUPPORT_SYSRQ +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * ARC UART Hardware Specs + / +#define ARC_UART_TX_FIFO_SIZE 1 + +/* + * UART Register set (this is not a Standards Compliant IP) + * Also each reg is Word aligned, but only 8 bits wide + */ +#define R_ID0 0 +#define R_ID1 1 +#define R_ID2 2 +#define R_ID3 3 +#define R_DATA 4 +#define R_STS 5 +#define R_BAUDL6 +#define R_BAUDH7 + +/* Bits for UART Status Reg (R/W) */ +#define RXIENB 0x04 /* Receive Interrupt Enable */ +#define TXIENB 0x40 /* Transmit Interrupt Enable */ + +#define RXEMPTY 0x20 /* Receive FIFO Empty: No char receivede */ +#define TXEMPTY 0x80 /* Transmit FIFO Empty, thus char can be written into */ + +#define RXFULL 0x08 /* Receive FIFO full */ +#define RXFULL1 0x10 /* Receive FIFO has space for 1 char (tot space=4) */ + +#define RXFERR 0x01 /* Frame Error: Stop Bit not detected */ +#define RXOERR 0x02 /* OverFlow Err: Char recv but RXFULL still set */ + +/* Uart bit fiddling helpers: lowest level */ +#define RBASE(uart, reg) ((unsigned int *)uart->port.membase + reg) +#define UART_REG_SET(u, r, v) writeb((v), RBASE(u, r)) +#define UART_REG_GET(u, r)readb(RBASE(u, r)) + +#define UART_REG_OR(u, r, v) UART_REG_SET(u, r, UART_REG_GET(u, r) | (v)) +#define UART_REG_CLR(u, r, v) UART_REG_SET(u, r, UART_REG_GET(u, r) & ~(v)) + +/* Uart bit fiddling helpers: API level */ +#define UART_SET_DATA(uart, val) UART_REG_SET(uart, R_DATA, val) +#define UART_GET_DATA(uart)UART_REG_GET(uart, R_DATA) + +#define UART_SET_BAUDH(uart, val) UART_REG_SET(uart, R_BAUDH, val) +#define UART_SET_BAUDL(uart, val) UART_REG_SET(uart, R_BAUDL, val) + +#define UART_CLR_STATUS(uart, val) UART_REG_CLR(uart, R_STS, val) +#define UART_GET_STATUS(uart) UART_REG_GET(uart,
[PATCH] serial/arc-uart: Add new driver
From: Vineet Gupta vgu...@synopsys.com Driver for non-standard on-chip UART, instantiated in the ARC (Synopsys) FPGA Boards such as ARCAngel4/ML50x This is based off of current Linus tree, build tested for x86. Signed-off-by: Vineet Gupta vgu...@synopsys.com --- drivers/tty/serial/Kconfig| 25 ++ drivers/tty/serial/Makefile |1 + drivers/tty/serial/arc_uart.c | 742 + include/linux/serial_core.h |3 + 4 files changed, 771 insertions(+), 0 deletions(-) create mode 100644 drivers/tty/serial/arc_uart.c diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig index 4720b4b..af4bd69 100644 --- a/drivers/tty/serial/Kconfig +++ b/drivers/tty/serial/Kconfig @@ -1360,4 +1360,29 @@ config SERIAL_EFM32_UART_CONSOLE depends on SERIAL_EFM32_UART=y select SERIAL_CORE_CONSOLE +config SERIAL_ARC + bool ARC UART driver support + select SERIAL_CORE + default y + help + Driver for on-chip UART for ARC(Synopsys) for the legacy + FPGA Boards (ML50x/ARCAngel4) + +config SERIAL_ARC_CONSOLE + bool + select SERIAL_CORE_CONSOLE + depends on SERIAL_ARC=y + default y + help + Enable system Console on ARC UART + +config SERIAL_ARC_NR_PORTS + int 'Number of ports' + range 1 3 + default 1 + depends on SERIAL_ARC + help + Set this to the number of serial ports you want the driver + to support. + endmenu diff --git a/drivers/tty/serial/Makefile b/drivers/tty/serial/Makefile index 7257c5d..2b70b5f 100644 --- a/drivers/tty/serial/Makefile +++ b/drivers/tty/serial/Makefile @@ -79,3 +79,4 @@ obj-$(CONFIG_SERIAL_XILINX_PS_UART) += xilinx_uartps.o obj-$(CONFIG_SERIAL_SIRFSOC) += sirfsoc_uart.o obj-$(CONFIG_SERIAL_AR933X) += ar933x_uart.o obj-$(CONFIG_SERIAL_EFM32_UART) += efm32-uart.o +obj-$(CONFIG_SERIAL_ARC) += arc_uart.o diff --git a/drivers/tty/serial/arc_uart.c b/drivers/tty/serial/arc_uart.c new file mode 100644 index 000..4f2e57b --- /dev/null +++ b/drivers/tty/serial/arc_uart.c @@ -0,0 +1,742 @@ +/* + * ARC On-Chip(fpga) UART Driver + * + * Copyright (C) 2010-2012 Synopsys, Inc. (www.synopsys.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * vineetg: July 10th 2012 + * -Decoupled the driver from arch/arc + *+Using platform_get_resource() for irq/membase (thx to bfin_uart.c) + *+Using early_platform_xxx() for early console (thx to mach-shmobile/xxx) + * + * Vineetg: Aug 21st 2010 + * -Is uart_tx_stopped() not done in tty write path as it has already been + * taken care of, in serial core + * + * Vineetg: Aug 18th 2010 + * -New Serial Core based ARC UART driver + * -Derived largely from blackfin driver albiet with some major tweaks + * + * TODO: + * -check if sysreq works + */ + +#if defined(CONFIG_SERIAL_ARC_CONSOLE) defined(CONFIG_MAGIC_SYSRQ) +#define SUPPORT_SYSRQ +#endif + +#include linux/module.h +#include linux/serial.h +#include linux/console.h +#include linux/sysrq.h +#include linux/platform_device.h +#include linux/tty.h +#include linux/tty_flip.h +#include linux/serial_core.h +#include linux/io.h + +/* + * ARC UART Hardware Specs + / +#define ARC_UART_TX_FIFO_SIZE 1 + +/* + * UART Register set (this is not a Standards Compliant IP) + * Also each reg is Word aligned, but only 8 bits wide + */ +#define R_ID0 0 +#define R_ID1 1 +#define R_ID2 2 +#define R_ID3 3 +#define R_DATA 4 +#define R_STS 5 +#define R_BAUDL6 +#define R_BAUDH7 + +/* Bits for UART Status Reg (R/W) */ +#define RXIENB 0x04 /* Receive Interrupt Enable */ +#define TXIENB 0x40 /* Transmit Interrupt Enable */ + +#define RXEMPTY 0x20 /* Receive FIFO Empty: No char receivede */ +#define TXEMPTY 0x80 /* Transmit FIFO Empty, thus char can be written into */ + +#define RXFULL 0x08 /* Receive FIFO full */ +#define RXFULL1 0x10 /* Receive FIFO has space for 1 char (tot space=4) */ + +#define RXFERR 0x01 /* Frame Error: Stop Bit not detected */ +#define RXOERR 0x02 /* OverFlow Err: Char recv but RXFULL still set */ + +/* Uart bit fiddling helpers: lowest level */ +#define RBASE(uart, reg) ((unsigned int *)uart-port.membase + reg) +#define UART_REG_SET(u, r, v) writeb((v), RBASE(u, r)) +#define UART_REG_GET(u, r)readb(RBASE(u, r)) + +#define UART_REG_OR(u, r, v) UART_REG_SET(u, r, UART_REG_GET(u, r) | (v)) +#define UART_REG_CLR(u, r, v) UART_REG_SET(u, r, UART_REG_GET(u, r) ~(v)) + +/* Uart bit fiddling helpers: API level */ +#define UART_SET_DATA(uart, val) UART_REG_SET(uart, R_DATA, val) +#define UART_GET_DATA(uart)UART_REG_GET(uart, R_DATA) + +#define UART_SET_BAUDH(uart, val) UART_REG_SET(uart, R_BAUDH, val) +#define