Synopsys ARC Linux kernel Port (Part #2)
Subsystems (11)
v3 cover Synopsys ARC Linux kernel Port (Part #2)
This is the second set of patches untouched since v2.
-Vineet
PATCH v3 3/71 ARC: irqflags - Interrupt enabling/disabling at in-core intc
ARC700 has an in-core intc which provides 2 priorities (a.k.a.) "levels" of interrupts (per IRQ) hencforth referred to as L1/L2 interrupts.
CPU flags register STATUS32 has Interrupt Enable bits per level (E1/E2) to globally enable (or disable) all IRQs at a level. Hence the implementation of arch_local_irq_{save,restore,enable,disable}( )
The STATUS32 reg can be r/w only using the AUX Interface of ARC, hence the use of LR/SR instructions. Further, E1/E2 bits in there can only be updated using the FLAG insn.
The intc supports 32 interrupts - and per IRQ enabling is controlled by a bit in the AUX_IENABLE register, hence the implmentation of arch_{,un}mask_irq( ) routines.
--- arch/arc/include/asm/arcregs.h | 114 ++++++++++++++++++++++++++++++ arch/arc/include/asm/irqflags.h | 149 +++++++++++++++++++++++++++++++++++++++ arch/arc/kernel/irq.c | 32 ++++++++ 3 files changed, 295 insertions(+), 0 deletions(-) create mode 100644 arch/arc/include/asm/arcregs.h create mode 100644 arch/arc/include/asm/irqflags.h create mode 100644 arch/arc/kernel/irq.c
arch/arc/include/asm/arcregs.h new file +114 -0
@@ -0,0 +1,114 @@ +/* +* 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_ARCREGS_H +#define _ASM_ARC_ARCREGS_H + +#ifdef __KERNEL__ + +/* status32 Bits Positions */ +#define STATUS_H_BIT 0/* CPU Halted */ +#define STATUS_E1_BIT 1/* Int 1 enable */ +#define STATUS_E2_BIT 2/* Int 2 enable */ +#define STATUS_A1_BIT 3/* Int 1 active */ +#define STATUS_A2_BIT 4/* Int 2 active */ +#define STATUS_AE_BIT 5/* Exception active */ +#define STATUS_DE_BIT 6/* PC is in delay slot */ +#define STATUS_U_BIT 7/* User/Kernel mode */ +#define STATUS_L_BIT 12/* Loop inhibit */ + +/* These masks correspond to the status word(STATUS_32) bits */ +#define STATUS_H_MASK (1<<STATUS_H_BIT) +#define STATUS_E1_MASK (1<<STATUS_E1_BIT) +#define STATUS_E2_MASK (1<<STATUS_E2_BIT) +#define STATUS_A1_MASK (1<<STATUS_A1_BIT) +#define STATUS_A2_MASK (1<<STATUS_A2_BIT) +#define STATUS_AE_MASK (1<<STATUS_AE_BIT) +#define STATUS_DE_MASK (1<<STATUS_DE_BIT) +#define STATUS_U_MASK (1<<STATUS_U_BIT) +#define STATUS_L_MASK (1<<STATUS_L_BIT) + +/* Auxiliary registers */ +#define AUX_IDENTITY 4 +#define AUX_INTR_VEC_BASE 0x25 +#define AUX_IRQ_LEV 0x200/* IRQ Priority: L1 or L2 */ +#define AUX_IRQ_HINT 0x201/* For generating Soft Interrupts */ +#define AUX_IRQ_LV12 0x43/* interrupt level register */ + +#define AUX_IENABLE 0x40c +#define AUX_ITRIGGER 0x40d +#define AUX_IPULSE 0x415 + +#ifndef __ASSEMBLY__ + +/* +****************************************************************** +* Inline ASM macros to read/write AUX Regs +* Essentially invocation of lr/sr insns from "C" +*/ + +#if 1 + +#define read_aux_reg (reg) __builtin_arc_lr(reg) + +/* gcc builtin sr needs reg param to be long immediate */ +#define write_aux_reg (reg_immed, val) \ + __builtin_arc_sr((unsigned int)val, reg_immed) + +#else + +#define read_aux_reg (reg) \ +({ \ + unsigned int __ret; \ + __asm__ __volatile__( \ + " lr %0, [%1]" \ + : "=r"(__ret) \ + : "i"(reg)); \ + __ret; \ +}) + +/* +* Aux Reg address is specified as long immediate by caller +* e.g. +* write_aux_reg(0x69, some_val); +* This generates tightest code. +*/ +#define write_aux_reg (reg_imm, val) \ +({ \ + __asm__ __volatile__( \ + " sr %0, [%1] \n" \ + : \ + : "ir"(val), "i"(reg_imm)); \ +}) + +/* +* Aux Reg address is specified in a variable +* * e.g. +* reg_num = 0x69 +* write_aux_reg2(reg_num, some_val); +* This has to generate glue code to load the reg num from +* memory to a reg hence not recommended. +*/ +#define write_aux_reg2 (reg_in_var, val) \ +({ \ + unsigned int tmp; \ + \ + __asm__ __volatile__( \ + " ld %0, [%2] \n\t" \ + " sr %1, [%0] \n\t" \ + : "=&r"(tmp) \ + : "r"(val), "memory"(®_in_var)); \ +}) + +#endif + +#endif /* __ASEMBLY__ */ + +#endif /* __KERNEL__ */ + +#endif /* _ASM_ARC_ARCREGS_H */
arch/arc/include/asm/irqflags.h new file +149 -0
149 lines not on this page · raw message
arch/arc/kernel/irq.c new file +32 -0
@@ -0,0 +1,32 @@ +/* +* Copyright (C) 2011-12 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/interrupt.h> +#include <linux/module.h> +#include <asm/irqflags.h> +#include <asm/arcregs.h> + +void arch_local_irq_enable (void ) +{ +unsigned long flags; + +/* +* ARC IDE Drivers tries to re-enable interrupts from hard-isr +* context which is simply wrong +*/ +if (in_irq ()) { +WARN_ONCE (1 ,"IRQ enabled from hard-isr" ); +return ; + } + + flags =arch_local_save_flags (); + flags |= (STATUS_E1_MASK |STATUS_E2_MASK ); +arch_local_irq_restore (flags); +} +EXPORT_SYMBOL (arch_local_irq_enable);
Signature · 1 line
1.7.4.1
PATCH v3 4/71 ARC: Atomic/bitops/cmpxchg/barriers
In reply to Vineet GuptaThis covers the UP / SMP (with no hardware assist for atomic r-m-w) as well as ARC700 LLOCK/SCOND insns based.
--- arch/arc/include/asm/atomic.h | 232 ++++++++++++++++++ arch/arc/include/asm/barrier.h | 42 ++++ arch/arc/include/asm/bitops.h | 516 ++++++++++++++++++++++++++++++++++++++++ arch/arc/include/asm/cmpxchg.h | 143 +++++++++++ arch/arc/include/asm/smp.h | 34 +++ 5 files changed, 967 insertions(+), 0 deletions(-) create mode 100644 arch/arc/include/asm/atomic.h create mode 100644 arch/arc/include/asm/barrier.h create mode 100644 arch/arc/include/asm/bitops.h create mode 100644 arch/arc/include/asm/cmpxchg.h create mode 100644 arch/arc/include/asm/smp.h
arch/arc/include/asm/atomic.h new file +232 -0
@@ -0,0 +1,232 @@ +/* +* 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_ATOMIC_H +#define _ASM_ARC_ATOMIC_H + +#ifdef __KERNEL__ + +#ifndef __ASSEMBLY__ + +#include <linux/types.h> +#include <linux/compiler.h> +#include <asm/cmpxchg.h> +#include <asm/barrier.h> +#include <asm/smp.h> + +#define atomic_read (v) ((v)->counter) + +#ifdef CONFIG_ARC_HAS_LLSC + +#define atomic_set (v, i) (((v)->counter) = (i)) + +static inline void atomic_add (int i,atomic_t *v) +{ +unsigned int temp; + + __asm__ __volatile__( +"1: llock %0, [%1] \n" +" add %0, %0, %2 \n" +" scond %0, [%1] \n" +" bnz 1b \n" + :"=&r" (temp)/* Early clobber, to prevent reg reuse */ + :"r" (&v->counter),"ir" (i) + :"cc" ); +} + +static inline void atomic_sub (int i,atomic_t *v) +{ +unsigned int temp; + + __asm__ __volatile__( +"1: llock %0, [%1] \n" +" sub %0, %0, %2 \n" +" scond %0, [%1] \n" +" bnz 1b \n" + :"=&r" (temp) + :"r" (&v->counter),"ir" (i) + :"cc" ); +} + +/* add and also return the new value */ +static inline int atomic_add_return (int i,atomic_t *v) +{ +unsigned int temp; + + __asm__ __volatile__( +"1: llock %0, [%1] \n" +" add %0, %0, %2 \n" +" scond %0, [%1] \n" +" bnz 1b \n" + :"=&r" (temp) + :"r" (&v->counter),"ir" (i) + :"cc" ); + +return temp; +} + +static inline int atomic_sub_return (int i,atomic_t *v) +{ +unsigned int temp; + + __asm__ __volatile__( +"1: llock %0, [%1] \n" +" sub %0, %0, %2 \n" +" scond %0, [%1] \n" +" bnz 1b \n" + :"=&r" (temp) + :"r" (&v->counter),"ir" (i) + :"cc" ); + +return temp; +} + +static inline void atomic_clear_mask (unsigned long mask,unsigned long *addr) +{ +unsigned int temp; + + __asm__ __volatile__( +"1: llock %0, [%1] \n" +" bic %0, %0, %2 \n" +" scond %0, [%1] \n" +" bnz 1b \n" + :"=&r" (temp) + :"r" (addr),"ir" (mask) + :"cc" ); +} + +#else /* !CONFIG_ARC_HAS_LLSC */ + +#ifndef CONFIG_SMP + +/* violating atomic_xxx API locking protocol in UP for optimization sake */ +#define atomic_set (v, i) (((v)->counter) = (i)) + +#else + +static inline void atomic_set (atomic_t *v,int i) +{ +/* +* Independent of hardware support, all of the atomic_xxx() APIs need +* to follow the same locking rules to make sure that a "hardware" +* atomic insn (e.g. LD) doesn't clobber an "emulated" atomic insn +* sequence +* +* Thus atomic_set() despite being 1 insn (and seemingly atomic) +* requires the locking. +*/ +unsigned long flags; + +atomic_ops_lock (flags); + v->counter = i; +atomic_ops_unlock (flags); +} +#endif + +/* +* Non hardware assisted Atomic-R-M-W +* Locking would change to irq-disabling only (UP) and spinlocks (SMP) +*/ + +static inline void atomic_add (int i,atomic_t *v) +{ +unsigned long flags; + +atomic_ops_lock (flags); + v->counter += i; +atomic_ops_unlock (flags); +} + +static inline void atomic_sub (int i,atomic_t *v) +{ +unsigned long flags; + +atomic_ops_lock (flags); + v->counter -= i; +atomic_ops_unlock (flags); +} + +static inline int atomic_add_return (int i,atomic_t *v) +{ +unsigned long flags; +unsigned long temp; + +atomic_ops_lock (flags); + temp = v->counter; + temp += i; + v->counter = temp; +atomic_ops_unlock (flags); + +return temp; +} + +static inline int atomic_sub_return (int i,atomic_t *v) +{ +unsigned long flags; +unsigned long temp; + +atomic_ops_lock (flags); + temp = v->counter; + temp -= i; + v->counter = temp; +atomic_ops_unlock (flags); + +return temp; +} + +static inline void atomic_clear_mask (unsigned long mask,unsigned long *addr) +{ +unsigned long flags; + +atomic_ops_lock (flags); + *addr &= ~mask; +atomic_ops_unlock (flags); +} + +#endif /* !CONFIG_ARC_HAS_LLSC */ + +/** +* __atomic_add_unless - add unless the number is a given value +* @v: pointer of type atomic_t +* @a: the amount to add to v... +* @u: ...unless v is equal to u. +* +* Atomically adds @a to @v, so long as it was not @u. +* Returns the old value of @v +*/ +#define __atomic_add_unless (v, a, u) \ +({ \ + int c, old; \ + c = atomic_read(v); \ + while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c)\ + c = old; \ + c; \ +}) + +#define atomic_inc_not_zero (v) atomic_add_unless((v), 1, 0) + +#define atomic_inc (v) atomic_add(1, v) +#define atomic_dec (v) atomic_sub(1, v) + +#define atomic_inc_and_test (v) (atomic_add_return(1, v) == 0) +#define atomic_dec_and_test (v) (atomic_sub_return(1, v) == 0) +#define atomic_inc_return (v) atomic_add_return(1, (v)) +#define atomic_dec_return (v) atomic_sub_return(1, (v)) +#define atomic_sub_and_test (i, v) (atomic_sub_return(i, v) == 0) + +#define atomic_add_negative (i, v) (atomic_add_return(i, v) < 0) + +#define ATOMIC_INIT (i) { (i) } + +#include <asm-generic/atomic64.h> + +#endif + +#endif + +#endif
arch/arc/include/asm/barrier.h new file +42 -0
42 lines not on this page · raw message
arch/arc/include/asm/bitops.h new file +516 -0
516 lines not on this page · raw message
arch/arc/include/asm/cmpxchg.h new file +143 -0
143 lines not on this page · raw message
arch/arc/include/asm/smp.h new file +34 -0
@@ -0,0 +1,34 @@ +/* +* 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_SMP_H +#define __ASM_ARC_SMP_H + +/* +* ARC700 doesn't support atomic Read-Modify-Write ops. +* Originally Interrupts had to be disabled around code to gaurantee atomicity. +* The LLOCK/SCOND insns allow writing interrupt-hassle-free based atomic ops +* based on retry-if-irq-in-atomic (with hardware assist). +* However despite these, we provide the IRQ disabling variant +* +* (1) These insn were introduced only in 4.10 release. So for older released +* support needed. +*/ +#ifndef CONFIG_ARC_HAS_LLSC + +#include <linux/irqflags.h> + +#define atomic_ops_lock (flags) local_irq_save(flags) +#define atomic_ops_unlock (flags) local_irq_restore(flags) + +#define bitops_lock (flags) local_irq_save(flags) +#define bitops_unlock (flags) local_irq_restore(flags) + +#endif /* !CONFIG_ARC_HAS_LLSC */ + +#endif
Signature · 1 line
1.7.4.1
PATCH v3 5/71 asm-generic headers: uaccess.h to conditionally define segment_eq()
In reply to Vineet GuptaThis is because mm_segment_t is exported by arch code, while seqment_eq assumes it will have .seg element.
--- include/asm-generic/uaccess.h | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
include/asm-generic/uaccess.h +2 -1
@@ -7,7 +7,6 @@* address space, e.g. all NOMMU machines. */ #include <linux/sched.h> -#include <linux/mm.h> #include <linux/string.h> #include <asm/segment.h>
@@ -32,7 +31,9 @@ static inline void set_fs(mm_segment_t fs) }#endif +#ifndef segment_eq#define segment_eq (a, b) ((a).seg == (b).seg) +#endif #define VERIFY_READ 0#define VERIFY_WRITE 1
Signature · 1 line
1.7.4.1
PATCH v3 7/71 asm-generic: uaccess: Allow arches to over-ride __{get,put}_user_fn()
In reply to Vineet GuptaAs of now these default to calling the arch provided __copy_{to,from}_user() routines which being general purpose (w.r.t buffer alignment and lengths) would lead to alignment checks in generated code (for arches which don't support unaligned load/stores).
Given that in this case we already know that data involved is "unit" sized and aligned, using the vanilla copy backend is a bit wasteful.
This change thus allows arches to over-ride the aforementioned routines.
--- include/asm-generic/uaccess.h | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-)
include/asm-generic/uaccess.h +11 -0
@@ -169,12 +169,18 @@ static inline __must_check long __copy_to_user(void __user *to, -EFAULT ; \ }) +#ifndef __put_user_fn +static inline int __put_user_fn (size_t size,void __user *ptr,void *x) { size =__copy_to_user (ptr, x, size);return size ? -EFAULT : size; } +#define __put_user_fn (sz, u, k) __put_user_fn(sz, u, k) + +#endif +extern int __put_user_bad (void ) __attribute__((noreturn));#define __get_user (x, ptr) \
@@ -225,12 +231,17 @@ extern int __put_user_bad(void) __attribute__((noreturn)); -EFAULT ; \ }) +#ifndef __get_user_fnstatic 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
Signature · 1 line
1.7.4.1
PATCH v3 8/71 ARC: [optim] uaccess __{get,put}_user() optimised
In reply to Vineet GuptaOverride asm-generic implementations. We basically gain on 2 fronts
* checks for alignment no longer needed as we are only doing "unit" sized copies.
(Careful observer could argue that While the kernel buffers are aligned,
the user buffer in theory might not be - however in that case the user space is already broken when it tries to deref a hword/word straddling word boundary - so we are not making it any worse).
* __copy_{to,from}_user( ) returns bytes that couldn't be copied, whereas get_user() returns 0 for success or -EFAULT (not size). Thus the code to do leftover bytes calculation can be avoided as well.
The savings were significant: ~17k of code.
bloat-o-meter vmlinux_uaccess_pre vmlinux_uaccess_post add/remove: 0/4 grow/shrink: 8/118 up/down: 1262/-18758 (-17496)
^^^^^^^^^
--- arch/arc/include/asm/uaccess.h | 105 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 105 insertions(+), 0 deletions(-)
arch/arc/include/asm/uaccess.h +105 -0
@@ -57,6 +57,111 @@#define __access_ok (addr, sz) (unlikely(__kernel_ok) || \ likely(__user_ok((addr), (sz)))) +/*********** Single byte/hword/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; \ +}) + +/* +* Returns 0 on success, -EFAULT if not. +* @ret already contains 0 - given that errors will be less likely +* (hence +r asm constraint below). +* In case of error, fixup code will make it -EFAULT +*/ +#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), "ir" (-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), "ir" (-EFAULT)) + +#define __put_user_fn(sz, u, k) \ +({ \ + long __ret = 0; /* success by default */ \ + switch (sz) { \ + case 1: __arc_put_user_one(*(k), u, "stb", __ret); break; \ + case 2: __arc_put_user_one(*(k), u, "stw", __ret); break; \ + case 4: __arc_put_user_one(*(k), u, "st", __ret); break; \ + case 8: __arc_put_user_one_64(*(k), u, __ret); break; \ + } \ + __ret; \ +}) + +#define __arc_put_user_one (src, dst, 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" (src), "r" (dst), "ir" (-EFAULT)) + +#define __arc_put_user_one_64 (src, dst, ret) \ + __asm__ __volatile__( \ + "1: st %1,[%2]\n" \ + "4: st %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" (src), "r" (dst), "ir" (-EFAULT)) + +static inline unsigned long __arc_copy_from_user (void *to,const void __user *from,unsigned long n) {
Signature · 1 line
1.7.4.1
PATCH v3 9/71 asm-generic headers: Allow yet more arch overrides in checksum.h
In reply to Vineet Guptaarches can have more efficient implementation of these routines
--- include/asm-generic/checksum.h | 4 ++++ lib/checksum.c | 2 ++ 2 files changed, 6 insertions(+), 0 deletions(-)
include/asm-generic/checksum.h +4 -0
@@ -38,12 +38,15 @@ extern __wsum csum_partial_copy_from_user(const void __user *src, void *dst, csum_partial_copy((src), (dst), (len), (sum))#endif +#ifndef ip_fast_csum/* * This is a version of ip_compute_csum() optimized for IP headers, * which always checksum on 4 octet boundaries. */ extern __sum16 ip_fast_csum (const void *iph,unsigned int ihl); +#endif +#ifndef csum_fold/* * Fold a partial checksum */
@@ -54,6 +57,7 @@ static inline __sum16 csum_fold(__wsum csum) sum = (sum &0xffff ) + (sum >>16 ); return (__force __sum16)~sum; } +#endif #ifndef csum_tcpudp_nofold/*
lib/checksum.c +2 -0
@@ -102,6 +102,7 @@ out: }#endif +#ifndef ip_fast_csum/* * This is a version of ip_compute_csum() optimized for IP headers, * which always checksum on 4 octet boundaries.
@@ -111,6 +112,7 @@ __sum16 ip_fast_csum(const void *iph, unsigned int ihl) return (__force __sum16)~do_csum(iph, ihl*4); }EXPORT_SYMBOL (ip_fast_csum); +#endif /* * computes the checksum of a memory block at buff, length len,
Signature · 1 line
1.7.4.1
PATCH v3 10/71 ARC: Checksum/byteorder/swab routines
In reply to Vineet GuptaTBD: do_csum still needs to be written in asm
--- arch/arc/include/asm/byteorder.h | 18 +++++++ arch/arc/include/asm/checksum.h | 101 ++++++++++++++++++++++++++++++++++++++ arch/arc/include/asm/swab.h | 98 ++++++++++++++++++++++++++++++++++++ 3 files changed, 217 insertions(+), 0 deletions(-) create mode 100644 arch/arc/include/asm/byteorder.h create mode 100644 arch/arc/include/asm/checksum.h create mode 100644 arch/arc/include/asm/swab.h
arch/arc/include/asm/byteorder.h new file +18 -0
@@ -0,0 +1,18 @@ +/* +* 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_BYTEORDER_H +#define __ASM_ARC_BYTEORDER_H + +#ifdef CONFIG_CPU_BIG_ENDIAN +#include <linux/byteorder/big_endian.h> +#else +#include <linux/byteorder/little_endian.h> +#endif + +#endif /* ASM_ARC_BYTEORDER_H */
arch/arc/include/asm/checksum.h new file +101 -0
101 lines not on this page · raw message
arch/arc/include/asm/swab.h new file +98 -0
98 lines not on this page · raw message
Signature · 1 line
1.7.4.1
PATCH v3 12/71 ARC: Spinlock/rwlock/mutex primitives
In reply to Vineet Gupta--- arch/arc/include/asm/mutex.h | 9 ++ arch/arc/include/asm/spinlock.h | 144 +++++++++++++++++++++++++++++++++ arch/arc/include/asm/spinlock_types.h | 35 ++++++++ 3 files changed, 188 insertions(+), 0 deletions(-) create mode 100644 arch/arc/include/asm/mutex.h create mode 100644 arch/arc/include/asm/spinlock.h create mode 100644 arch/arc/include/asm/spinlock_types.h
arch/arc/include/asm/mutex.h new file +9 -0
@@ -0,0 +1,9 @@ +/* +* 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 <asm-generic/mutex-xchg.h>
arch/arc/include/asm/spinlock.h new file +144 -0
144 lines not on this page · raw message
arch/arc/include/asm/spinlock_types.h new file +35 -0
@@ -0,0 +1,35 @@ +/* +* 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_SPINLOCK_TYPES_H +#define __ASM_SPINLOCK_TYPES_H + +typedef struct { +volatile unsigned int slock; +}arch_spinlock_t ; + +#define __ARCH_SPIN_LOCK_UNLOCKED__ 0 +#define __ARCH_SPIN_LOCK_LOCKED__ 1 + +#define __ARCH_SPIN_LOCK_UNLOCKED { __ARCH_SPIN_LOCK_UNLOCKED__ } +#define __ARCH_SPIN_LOCK_LOCKED { __ARCH_SPIN_LOCK_LOCKED__ } + +/* +* Unlocked: 0x01_00_00_00 +* Read lock(s): 0x00_FF_00_00 to say 0x01 +* Write lock: 0x0, but only possible if prior value "unlocked" 0x0100_0000 +*/ +typedef struct { +volatile unsigned int counter; +arch_spinlock_t lock_mutex; +}arch_rwlock_t ; + +#define __ARCH_RW_LOCK_UNLOCKED__ 0x01000000 +#define __ARCH_RW_LOCK_UNLOCKED { .counter = __ARCH_RW_LOCK_UNLOCKED__ } + +#endif
Signature · 1 line
1.7.4.1
PATCH v3 13/71 ARC: String library
In reply to Vineet GuptaHand optimised asm code for ARC700 pipeline.
Originally written/optimized by Joern Rennecke
--- arch/arc/include/asm/string.h | 40 +++++++++++++ arch/arc/lib/memcmp.S | 124 +++++++++++++++++++++++++++++++++++++++++ arch/arc/lib/memcpy-700.S | 66 ++++++++++++++++++++++ arch/arc/lib/memset.S | 59 +++++++++++++++++++ arch/arc/lib/strchr-700.S | 123 ++++++++++++++++++++++++++++++++++++++++ arch/arc/lib/strcmp.S | 96 +++++++++++++++++++++++++++++++ arch/arc/lib/strcpy-700.S | 70 +++++++++++++++++++++++ arch/arc/lib/strlen.S | 83 +++++++++++++++++++++++++++ 8 files changed, 661 insertions(+), 0 deletions(-) create mode 100644 arch/arc/include/asm/string.h create mode 100644 arch/arc/lib/memcmp.S create mode 100644 arch/arc/lib/memcpy-700.S create mode 100644 arch/arc/lib/memset.S create mode 100644 arch/arc/lib/strchr-700.S create mode 100644 arch/arc/lib/strcmp.S create mode 100644 arch/arc/lib/strcpy-700.S create mode 100644 arch/arc/lib/strlen.S
arch/arc/include/asm/string.h new file +40 -0
@@ -0,0 +1,40 @@ +/* +* 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 2011 +* -We had half-optimised memset/memcpy, got better versions of those +* -Added memcmp, strchr, strcpy, strcmp, strlen +* +* Amit Bhor: Codito Technologies 2004 +*/ + +#ifndef _ASM_ARC_STRING_H +#define _ASM_ARC_STRING_H + +#include <linux/types.h> + +#ifdef __KERNEL__ + +#define __HAVE_ARCH_MEMSET +#define __HAVE_ARCH_MEMCPY +#define __HAVE_ARCH_MEMCMP +#define __HAVE_ARCH_STRCHR +#define __HAVE_ARCH_STRCPY +#define __HAVE_ARCH_STRCMP +#define __HAVE_ARCH_STRLEN + +extern void *memset (void *ptr,int ,__kernel_size_t ); +extern void *memcpy (void *,const void *,__kernel_size_t ); +extern void memzero (void *ptr,__kernel_size_t n); +extern int memcmp (const void *,const void *,__kernel_size_t ); +extern char *strchr (const char *s,int c); +extern char *strcpy (char *dest,const char *src); +extern int strcmp (const char *cs,const char *ct); +extern __kernel_size_t strlen (const char *); + +#endif /* __KERNEL__ */ +#endif /* _ASM_ARC_STRING_H */
arch/arc/lib/memcmp.S new file +124 -0
124 lines not on this page · raw message
arch/arc/lib/memcpy-700.S new file +66 -0
66 lines not on this page · raw message
arch/arc/lib/memset.S new file +59 -0
59 lines not on this page · raw message
arch/arc/lib/strchr-700.S new file +123 -0
123 lines not on this page · raw message
arch/arc/lib/strcmp.S new file +96 -0
96 lines not on this page · raw message
arch/arc/lib/strcpy-700.S new file +70 -0
70 lines not on this page · raw message
arch/arc/lib/strlen.S new file +83 -0
83 lines not on this page · raw message
Signature · 1 line
1.7.4.1
PATCH v3 14/71 ARC: Low level IRQ/Trap/Exception Handling
In reply to Vineet Gupta--- arch/arc/include/asm/entry.h | 495 ++++++++++++++++++++++++++++++++++++ arch/arc/kernel/entry.S | 571 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 1066 insertions(+), 0 deletions(-) create mode 100644 arch/arc/include/asm/entry.h create mode 100644 arch/arc/kernel/entry.S
arch/arc/include/asm/entry.h new file +495 -0
@@ -0,0 +1,495 @@ +/* +* 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 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, +* we also need to explicitly do this. The problem in macros +* FAKE_RET_FROM_EXCPN and FAKE_RET_FROM_EXCPN_LOCK_IRQ was that this bit +* was being "CLEARED" rather then "SET". Actually "SET" clears ZOL context +* +* Vineetg: May 5th 2008 +* - 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 +* +* Amit Bhor, Sameer Dhavale: Codito Technologies 2004 +*/ + +#ifndef __ASM_ARC_ENTRY_H +#define __ASM_ARC_ENTRY_H + +#ifdef __ASSEMBLY__ +#include <asm/unistd.h> /* For NR_syscalls defination */ +#include <asm/asm-offsets.h> +#include <asm/arcregs.h> +#include <asm/ptrace.h> +#include <asm/thread_info.h> /* For THREAD_SIZE */ + +/* Note on the LD/ST addr modes with addr reg wback + * + * LD.a same as LD.aw + * + * LD.a reg1, [reg2, x] => Pre Incr + * Eff Addr for load = [reg2 + x] + * + * LD.ab reg1, [reg2, x] => Post Incr + * Eff Addr for load = [reg2] + */ + +/*-------------------------------------------------------------- + * Save caller saved registers (scratch registers) ( r0 - r12 ) + * Registers are pushed / popped in the order defined in struct ptregs + * in asm/ptrace.h + *-------------------------------------------------------------*/ +.macro SAVE_CALLER_SAVED + st.a r0, [sp, -4] + st.a r1, [sp, -4] + st.a r2, [sp, -4] + st.a r3, [sp, -4] + st.a r4, [sp, -4] + st.a r5, [sp, -4] + st.a r6, [sp, -4] + st.a r7, [sp, -4] + st.a r8, [sp, -4] + st.a r9, [sp, -4] + st.a r10, [sp, -4] + st.a r11, [sp, -4] + st.a r12, [sp, -4] +.endm + +/*-------------------------------------------------------------- + * Restore caller saved registers (scratch registers) + *-------------------------------------------------------------*/ +.macro RESTORE_CALLER_SAVED + ld.ab r12, [sp, 4] + ld.ab r11, [sp, 4] + ld.ab r10, [sp, 4] + ld.ab r9, [sp, 4] + ld.ab r8, [sp, 4] + ld.ab r7, [sp, 4] + ld.ab r6, [sp, 4] + ld.ab r5, [sp, 4] + ld.ab r4, [sp, 4] + ld.ab r3, [sp, 4] + ld.ab r2, [sp, 4] + ld.ab r1, [sp, 4] + ld.ab r0, [sp, 4] +.endm + + +/*-------------------------------------------------------------- + * Save callee saved registers (non scratch registers) ( r13 - r25 ) + * on kernel stack. + * User mode callee regs need to be saved in case of + * -fork and friends for replicating from parent to child + * -before going into do_signal( ) for ptrace/core-dump + * Special case handling is required for r25 in case it is used by kernel + * for caching task ptr. Low level exception/ISR save user mode r25 + * into task->thread.user_r25. So it needs to be retrieved from there and + * saved into kernel stack with rest of callee reg-file + *-------------------------------------------------------------*/ +.macro SAVE_CALLEE_SAVED_USER + st.a r13, [sp, -4] + st.a r14, [sp, -4] + st.a r15, [sp, -4] + st.a r16, [sp, -4] + st.a r17, [sp, -4] + st.a r18, [sp, -4] + st.a r19, [sp, -4] + st.a r20, [sp, -4] + st.a r21, [sp, -4] + st.a r22, [sp, -4] + st.a r23, [sp, -4] + st.a r24, [sp, -4] + st.a r25, [sp, -4] + + /* move up by 1 word to "create" callee_regs->"stack_place_holder" */ + sub sp, sp, 4 +.endm + +/*-------------------------------------------------------------- + * Save callee saved registers (non scratch registers) ( r13 - r25 ) + * kernel mode callee regs needed to be saved in case of context switch + * If r25 is used for caching task pointer then that need not be saved + * as it can be re-created from current task global + *-------------------------------------------------------------*/ +.macro SAVE_CALLEE_SAVED_KERNEL + st.a r13, [sp, -4] + st.a r14, [sp, -4] + st.a r15, [sp, -4] + st.a r16, [sp, -4] + st.a r17, [sp, -4] + st.a r18, [sp, -4] + st.a r19, [sp, -4] + st.a r20, [sp, -4] + st.a r21, [sp, -4] + st.a r22, [sp, -4] + st.a r23, [sp, -4] + st.a r24, [sp, -4] + st.a r25, [sp, -4] + sub sp, sp, 4 +.endm + +/*-------------------------------------------------------------- + * RESTORE_CALLEE_SAVED_KERNEL: + * Loads callee (non scratch) Reg File by popping from Kernel mode stack. + * This is reverse of SAVE_CALLEE_SAVED, + * + * NOTE: + * Ideally this shd only be called in switch_to for loading + * switched-IN task's CALLEE Reg File. + * For all other cases RESTORE_CALLEE_SAVED_FAST must be used + * which simply pops the stack w/o touching regs. + *-------------------------------------------------------------*/ +.macro RESTORE_CALLEE_SAVED_KERNEL + + add sp, sp, 4 /* skip "callee_regs->stack_place_holder" */ + ld.ab r25, [sp, 4] + ld.ab r24, [sp, 4] + ld.ab r23, [sp, 4] + ld.ab r22, [sp, 4] + ld.ab r21, [sp, 4] + ld.ab r20, [sp, 4] + ld.ab r19, [sp, 4] + ld.ab r18, [sp, 4] + ld.ab r17, [sp, 4] + ld.ab r16, [sp, 4] + ld.ab r15, [sp, 4] + ld.ab r14, [sp, 4] + ld.ab r13, [sp, 4] + +.endm + +/*-------------------------------------------------------------- + * Super FAST Restore callee saved regs by simply re-adjusting SP + *-------------------------------------------------------------*/ +.macro DISCARD_CALLEE_SAVED_USER + add sp, sp, 14 * 4 +.endm + +/*-------------------------------------------------------------- + * Restore User mode r25 saved in task_struct->thread.user_r25 + *-------------------------------------------------------------*/ +.macro RESTORE_USER_R25 + ld r25, [r25, TASK_THREAD + THREAD_USER_R25] +.endm + +/*------------------------------------------------------------- + * given a tsk struct, get to the base of it's kernel mode stack + * tsk->thread_info is really a PAGE, whose bottom hoists stack + * which grows upwards towards thread_info + *------------------------------------------------------------*/ + +.macro GET_TSK_STACK_BASE tsk, out + + /* Get task->thread_info (this is essentially start of a PAGE) */ + ld \out, [\tsk, TASK_THREAD_INFO] + + /* Go to end of page where stack begins (grows upwards) */ + add2 \out, \out, (THREAD_SIZE - 4)/4 /* one word GUTTER */ + +.endm + +/*-------------------------------------------------------------- + * Switch to Kernel Mode stack if SP points to User Mode stack + * + * Entry : r9 contains pre-IRQ/exception/trap status32 + * Exit : SP is set to kernel mode stack pointer + * Clobbers: r9 + *-------------------------------------------------------------*/ + +.macro SWITCH_TO_KERNEL_STK + + /* User Mode when this happened ? Yes: Proceed to switch stack */ + bbit1 r9, STATUS_U_BIT, 88f + + /* OK we were already in kernel mode when this event happened, thus can + * assume SP is kernel mode SP. _NO_ need to do any stack switching + */ + + /* 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. + */ + b.d 77f + + st.a sp, [sp, -12] ; Make room for orig_r0 and orig_r8 + +88: /*------Intr/Ecxp happened in user mode, "switch" stack ------ */ + + GET_CURR_TASK_ON_CPU r9 + + /* With current tsk in r9, get it's kernel mode stack base */ + GET_TSK_STACK_BASE r9, r9 + +#ifdef PT_REGS_CANARY + st 0xabcdabcd, [r9, 0] +#endif + + /* Save Pre Intr/Exception User SP on kernel stack */ + st.a sp, [r9, -12] ; Make room for orig_r0 and orig_r8 + + /* CAUTION: + * SP should be set at the very end when we are done with everything + * In case of 2 levels of interrupt we depend on value of SP to assume + * that everything else is done (loading r25 etc) + */ + + /* set SP to point to kernel mode stack */ + mov sp, r9 + +77: /* ----- Stack Switched to kernel Mode, Now save REG FILE ----- */ + +.endm + +/*------------------------------------------------------------ + * "FAKE" a rtie to return from CPU Exception context + * This is to re-enable Exceptions within exception + * Look at EV_ProtV to see how this is actually used + *-------------------------------------------------------------*/ + +.macro FAKE_RET_FROM_EXCPN reg + + ld \reg, [sp, PT_status32] + bic \reg, \reg, (STATUS_U_MASK|STATUS_DE_MASK) + bset \reg, \reg, STATUS_L_BIT + sr \reg, [erstatus] + mov \reg, 55f + sr \reg, [eret] + + rtie +55: +.endm + +/* + * @reg [OUT] &thread_info of "current" + */ +.macro GET_CURR_THR_INFO_FROM_SP reg + and \reg, sp, ~(THREAD_SIZE - 1) +.endm + +/* + * @reg [OUT] thread_info->flags of "current" + */ +.macro GET_CURR_THR_INFO_FLAGS reg + GET_CURR_THR_INFO_FROM_SP \reg + ld \reg, [\reg, THREAD_INFO_FLAGS] +.endm + +/*-------------------------------------------------------------- + * For early Exception Prologue, a core reg is temporarily needed to + * code the rest of prolog (stack switching). This is done by stashing + * it to memory (non-SMP case) or SCRATCH0 Aux Reg (SMP). + * + * Before saving the full regfile - this reg is restored back, only + * to be saved again on kernel mode stack, as part of ptregs. + *-------------------------------------------------------------*/ +.macro EXCPN_PROLOG_FREEUP_REG reg + st \reg, [@ex_saved_reg1] +.endm + +.macro EXCPN_PROLOG_RESTORE_REG reg + ld \reg, [@ex_saved_reg1] +.endm + +/*-------------------------------------------------------------- + * Save all registers used by Exceptions (TLB Miss, Prot-V, Mem err etc) + * Requires SP to be already switched to kernel mode Stack + * sp points to the next free element on the stack at exit of this macro. + * Registers are pushed / popped in the order defined in struct ptregs + * in asm/ptrace.h + * Note that syscalls are implemented via TRAP which is also a exception + * from CPU's point of view + *-------------------------------------------------------------*/ +.macro SAVE_ALL_EXCEPTION marker + + /* Restore r9 used to code the early prologue */ + EXCPN_PROLOG_RESTORE_REG r9 + + /* Save the complete regfile now */ + + /* orig_r8 marker: + * syscalls -> 1 to NR_SYSCALLS + * Exceptions -> NR_SYSCALLS + 1 + * Break-point-> NR_SYSCALLS + 2 + */ + st \marker, [sp, 8] + st r0, [sp, 4] /* orig_r0, needed only for sys calls */ + SAVE_CALLER_SAVED + st.a r26, [sp, -4] /* gp */ + st.a fp, [sp, -4] + st.a blink, [sp, -4] + lr r9, [eret] + st.a r9, [sp, -4] + lr r9, [erstatus] + st.a r9, [sp, -4] + st.a lp_count, [sp, -4] + lr r9, [lp_end] + st.a r9, [sp, -4] + lr r9, [lp_start] + st.a r9, [sp, -4] + lr r9, [erbta] + st.a r9, [sp, -4] + +#ifdef PT_REGS_CANARY + mov r9, 0xdeadbeef + st r9, [sp, -4] +#endif + + /* move up by 1 word to "create" pt_regs->"stack_place_holder" */ + sub sp, sp, 4 +.endm + +/*-------------------------------------------------------------- + * Save scratch regs for exceptions + *-------------------------------------------------------------*/ +.macro SAVE_ALL_SYS + SAVE_ALL_EXCEPTION (NR_syscalls + 1) +.endm + +/*-------------------------------------------------------------- + * Save scratch regs for sys calls + *-------------------------------------------------------------*/ +.macro SAVE_ALL_TRAP + SAVE_ALL_EXCEPTION r8 +.endm + +/*-------------------------------------------------------------- + * Restore all registers used by system call or Exceptions + * SP should always be pointing to the next free stack element + * when entering this macro. + * + * NOTE: + * + * It is recommended that lp_count/ilink1/ilink2 not be used as a dest reg + * for memory load operations. If used in that way interrupts are deffered + * by hardware and that is not good. + *-------------------------------------------------------------*/ +.macro RESTORE_ALL_SYS + + add sp, sp, 4 /* hop over unused "pt_regs->stack_place_holder" */ + + ld.ab r9, [sp, 4] + sr r9, [erbta] + ld.ab r9, [sp, 4] + sr r9, [lp_start] + ld.ab r9, [sp, 4] + sr r9, [lp_end] + ld.ab r9, [sp, 4] + mov lp_count, r9 + ld.ab r9, [sp, 4] + sr r9, [erstatus] + ld.ab r9, [sp, 4] + sr r9, [eret] + ld.ab blink, [sp, 4] + ld.ab fp, [sp, 4] + ld.ab r26, [sp, 4] /* gp */ + RESTORE_CALLER_SAVED + + ld sp, [sp] /* restore original sp */ + /* orig_r0 and orig_r8 skipped automatically */ +.endm + + +/*-------------------------------------------------------------- + * Save all registers used by interrupt handlers. + *-------------------------------------------------------------*/ +.macro SAVE_ALL_INT1 + + /* restore original r9 , saved in int1_saved_reg + * It will be saved on stack in macro: SAVE_CALLER_SAVED + */ + ld r9, [@int1_saved_reg] + + /* now we are ready to save the remaining context :) */ + st -1, [sp, 8] /* orig_r8, -1 for interuppt level one */ + st 0, [sp, 4] /* orig_r0 , N/A for IRQ */ + SAVE_CALLER_SAVED + st.a r26, [sp, -4] /* gp */ + st.a fp, [sp, -4] + st.a blink, [sp, -4] + st.a ilink1, [sp, -4] + lr r9, [status32_l1] + st.a r9, [sp, -4] + st.a lp_count, [sp, -4] + lr r9, [lp_end] + st.a r9, [sp, -4] + lr r9, [lp_start] + st.a r9, [sp, -4] + lr r9, [bta_l1] + st.a r9, [sp, -4] + +#ifdef PT_REGS_CANARY + mov r9, 0xdeadbee1 + st r9, [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. + * + * NOTE: + * + * It is recommended that lp_count/ilink1/ilink2 not be used as a dest reg + * for memory load operations. If used in that way interrupts are deffered + * by hardware and that is not good. + *-------------------------------------------------------------*/ + +.macro RESTORE_ALL_INT1 + add sp, sp, 4 /* hop over unused "pt_regs->stack_place_holder" */ + + ld.ab r9, [sp, 4] /* Actual reg file */ + sr r9, [bta_l1] + ld.ab r9, [sp, 4] + sr r9, [lp_start] + ld.ab r9, [sp, 4] + sr r9, [lp_end] + ld.ab r9, [sp, 4] + mov lp_count, r9 + ld.ab r9, [sp, 4] + sr r9, [status32_l1] + ld.ab r9, [sp, 4] + mov ilink1, r9 + ld.ab blink, [sp, 4] + ld.ab fp, [sp, 4] + ld.ab r26, [sp, 4] /* gp */ + RESTORE_CALLER_SAVED + + ld sp, [sp] /* restore original sp */ + /* orig_r0 and orig_r8 skipped automatically */ +.endm + +/* Get CPU-ID of this core */ +.macro GET_CPU_ID reg + lr \reg, [identity] + lsr \reg, \reg, 8 + bmsk \reg, \reg, 7 +.endm + +.macro GET_CURR_TASK_ON_CPU reg + ld \reg, [@_current_task] +.endm + +.macro SET_CURR_TASK_ON_CPU tsk, tmp + st \tsk, [@_current_task] +.endm + +/* ------------------------------------------------------------------ + * Get the ptr to some field of Current Task at @off in task struct + */ + +.macro GET_CURR_TASK_FIELD_PTR off, reg + GET_CURR_TASK_ON_CPU \reg + add \reg, \reg, \off +.endm + +#endif /* __ASSEMBLY__ */ + +#endif /* __ASM_ARC_ENTRY_H */
arch/arc/kernel/entry.S new file +571 -0
571 lines not on this page · raw message
Signature · 1 line
1.7.4.1
Re: [PATCH v3 14/71] ARC: Low level IRQ/Trap/Exception Handling
Hi Al,
Quoted 1,078 lines · Vineet Gupta
Signed-off-by Vineet Gupta <[email protected]>Cc Al Viro <[email protected]>--- arch/arc/include/asm/entry.h | 495 ++++++++++++++++++++++++++++++++++++ arch/arc/kernel/entry.S | 571 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 1066 insertions(+), 0 deletions(-) create mode 100644 arch/arc/include/asm/entry.h create mode 100644 arch/arc/kernel/entry.Sarch/arc/include/asm/entry.h new file +495
-0@@ -0,0 +1,495 @@ +/* +* 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 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, +* we also need to explicitly do this. The problem in macros +* FAKE_RET_FROM_EXCPN and FAKE_RET_FROM_EXCPN_LOCK_IRQ was that this bit +* was being "CLEARED" rather then "SET". Actually "SET" clears ZOL context +* +* Vineetg: May 5th 2008 +* - 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 +* +* Amit Bhor, Sameer Dhavale: Codito Technologies 2004 +*/ + +#ifndef __ASM_ARC_ENTRY_H +#define __ASM_ARC_ENTRY_H + +#ifdef __ASSEMBLY__ +#include <asm/unistd.h> /* For NR_syscalls defination */ +#include <asm/asm-offsets.h> +#include <asm/arcregs.h> +#include <asm/ptrace.h> +#include <asm/thread_info.h> /* For THREAD_SIZE */ + +/* Note on the LD/ST addr modes with addr reg wback + * + * LD.a same as LD.aw + * + * LD.a reg1, [reg2, x] => Pre Incr + * Eff Addr for load = [reg2 + x] + * + * LD.ab reg1, [reg2, x] => Post Incr + * Eff Addr for load = [reg2] + */ + +/*-------------------------------------------------------------- + * Save caller saved registers (scratch registers) ( r0 - r12 ) + * Registers are pushed / popped in the order defined in struct ptregs + * in asm/ptrace.h + *-------------------------------------------------------------*/ +.macro SAVE_CALLER_SAVED + st.a r0, [sp, -4] + st.a r1, [sp, -4] + st.a r2, [sp, -4] + st.a r3, [sp, -4] + st.a r4, [sp, -4] + st.a r5, [sp, -4] + st.a r6, [sp, -4] + st.a r7, [sp, -4] + st.a r8, [sp, -4] + st.a r9, [sp, -4] + st.a r10, [sp, -4] + st.a r11, [sp, -4] + st.a r12, [sp, -4] +.endm + +/*-------------------------------------------------------------- + * Restore caller saved registers (scratch registers) + *-------------------------------------------------------------*/ +.macro RESTORE_CALLER_SAVED + ld.ab r12, [sp, 4] + ld.ab r11, [sp, 4] + ld.ab r10, [sp, 4] + ld.ab r9, [sp, 4] + ld.ab r8, [sp, 4] + ld.ab r7, [sp, 4] + ld.ab r6, [sp, 4] + ld.ab r5, [sp, 4] + ld.ab r4, [sp, 4] + ld.ab r3, [sp, 4] + ld.ab r2, [sp, 4] + ld.ab r1, [sp, 4] + ld.ab r0, [sp, 4] +.endm + + +/*-------------------------------------------------------------- + * Save callee saved registers (non scratch registers) ( r13 - r25 ) + * on kernel stack. + * User mode callee regs need to be saved in case of + * -fork and friends for replicating from parent to child + * -before going into do_signal( ) for ptrace/core-dump + * Special case handling is required for r25 in case it is used by kernel + * for caching task ptr. Low level exception/ISR save user mode r25 + * into task->thread.user_r25. So it needs to be retrieved from there and + * saved into kernel stack with rest of callee reg-file + *-------------------------------------------------------------*/ +.macro SAVE_CALLEE_SAVED_USER + st.a r13, [sp, -4] + st.a r14, [sp, -4] + st.a r15, [sp, -4] + st.a r16, [sp, -4] + st.a r17, [sp, -4] + st.a r18, [sp, -4] + st.a r19, [sp, -4] + st.a r20, [sp, -4] + st.a r21, [sp, -4] + st.a r22, [sp, -4] + st.a r23, [sp, -4] + st.a r24, [sp, -4] + st.a r25, [sp, -4] + + /* move up by 1 word to "create" callee_regs->"stack_place_holder" */ + sub sp, sp, 4 +.endm + +/*-------------------------------------------------------------- + * Save callee saved registers (non scratch registers) ( r13 - r25 ) + * kernel mode callee regs needed to be saved in case of context switch + * If r25 is used for caching task pointer then that need not be saved + * as it can be re-created from current task global + *-------------------------------------------------------------*/ +.macro SAVE_CALLEE_SAVED_KERNEL + st.a r13, [sp, -4] + st.a r14, [sp, -4] + st.a r15, [sp, -4] + st.a r16, [sp, -4] + st.a r17, [sp, -4] + st.a r18, [sp, -4] + st.a r19, [sp, -4] + st.a r20, [sp, -4] + st.a r21, [sp, -4] + st.a r22, [sp, -4] + st.a r23, [sp, -4] + st.a r24, [sp, -4] + st.a r25, [sp, -4] + sub sp, sp, 4 +.endm + +/*-------------------------------------------------------------- + * RESTORE_CALLEE_SAVED_KERNEL: + * Loads callee (non scratch) Reg File by popping from Kernel mode stack. + * This is reverse of SAVE_CALLEE_SAVED, + * + * NOTE: + * Ideally this shd only be called in switch_to for loading + * switched-IN task's CALLEE Reg File. + * For all other cases RESTORE_CALLEE_SAVED_FAST must be used + * which simply pops the stack w/o touching regs. + *-------------------------------------------------------------*/ +.macro RESTORE_CALLEE_SAVED_KERNEL + + add sp, sp, 4 /* skip "callee_regs->stack_place_holder" */ + ld.ab r25, [sp, 4] + ld.ab r24, [sp, 4] + ld.ab r23, [sp, 4] + ld.ab r22, [sp, 4] + ld.ab r21, [sp, 4] + ld.ab r20, [sp, 4] + ld.ab r19, [sp, 4] + ld.ab r18, [sp, 4] + ld.ab r17, [sp, 4] + ld.ab r16, [sp, 4] + ld.ab r15, [sp, 4] + ld.ab r14, [sp, 4] + ld.ab r13, [sp, 4] + +.endm + +/*-------------------------------------------------------------- + * Super FAST Restore callee saved regs by simply re-adjusting SP + *-------------------------------------------------------------*/ +.macro DISCARD_CALLEE_SAVED_USER + add sp, sp, 14 * 4 +.endm + +/*-------------------------------------------------------------- + * Restore User mode r25 saved in task_struct->thread.user_r25 + *-------------------------------------------------------------*/ +.macro RESTORE_USER_R25 + ld r25, [r25, TASK_THREAD + THREAD_USER_R25] +.endm + +/*------------------------------------------------------------- + * given a tsk struct, get to the base of it's kernel mode stack + * tsk->thread_info is really a PAGE, whose bottom hoists stack + * which grows upwards towards thread_info + *------------------------------------------------------------*/ + +.macro GET_TSK_STACK_BASE tsk, out + + /* Get task->thread_info (this is essentially start of a PAGE) */ + ld \out, [\tsk, TASK_THREAD_INFO] + + /* Go to end of page where stack begins (grows upwards) */ + add2 \out, \out, (THREAD_SIZE - 4)/4 /* one word GUTTER */ + +.endm + +/*-------------------------------------------------------------- + * Switch to Kernel Mode stack if SP points to User Mode stack + * + * Entry : r9 contains pre-IRQ/exception/trap status32 + * Exit : SP is set to kernel mode stack pointer + * Clobbers: r9 + *-------------------------------------------------------------*/ + +.macro SWITCH_TO_KERNEL_STK + + /* User Mode when this happened ? Yes: Proceed to switch stack */ + bbit1 r9, STATUS_U_BIT, 88f + + /* OK we were already in kernel mode when this event happened, thus can + * assume SP is kernel mode SP. _NO_ need to do any stack switching + */ + + /* 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. + */ + b.d 77f + + st.a sp, [sp, -12] ; Make room for orig_r0 and orig_r8 + +88: /*------Intr/Ecxp happened in user mode, "switch" stack ------ */ + + GET_CURR_TASK_ON_CPU r9 + + /* With current tsk in r9, get it's kernel mode stack base */ + GET_TSK_STACK_BASE r9, r9 + +#ifdef PT_REGS_CANARY + st 0xabcdabcd, [r9, 0] +#endif + + /* Save Pre Intr/Exception User SP on kernel stack */ + st.a sp, [r9, -12] ; Make room for orig_r0 and orig_r8 + + /* CAUTION: + * SP should be set at the very end when we are done with everything + * In case of 2 levels of interrupt we depend on value of SP to assume + * that everything else is done (loading r25 etc) + */ + + /* set SP to point to kernel mode stack */ + mov sp, r9 + +77: /* ----- Stack Switched to kernel Mode, Now save REG FILE ----- */ + +.endm + +/*------------------------------------------------------------ + * "FAKE" a rtie to return from CPU Exception context + * This is to re-enable Exceptions within exception + * Look at EV_ProtV to see how this is actually used + *-------------------------------------------------------------*/ + +.macro FAKE_RET_FROM_EXCPN reg + + ld \reg, [sp, PT_status32] + bic \reg, \reg, (STATUS_U_MASK|STATUS_DE_MASK) + bset \reg, \reg, STATUS_L_BIT + sr \reg, [erstatus] + mov \reg, 55f + sr \reg, [eret] + + rtie +55: +.endm + +/* + * @reg [OUT] &thread_info of "current" + */ +.macro GET_CURR_THR_INFO_FROM_SP reg + and \reg, sp, ~(THREAD_SIZE - 1) +.endm + +/* + * @reg [OUT] thread_info->flags of "current" + */ +.macro GET_CURR_THR_INFO_FLAGS reg + GET_CURR_THR_INFO_FROM_SP \reg + ld \reg, [\reg, THREAD_INFO_FLAGS] +.endm + +/*-------------------------------------------------------------- + * For early Exception Prologue, a core reg is temporarily needed to + * code the rest of prolog (stack switching). This is done by stashing + * it to memory (non-SMP case) or SCRATCH0 Aux Reg (SMP). + * + * Before saving the full regfile - this reg is restored back, only + * to be saved again on kernel mode stack, as part of ptregs. + *-------------------------------------------------------------*/ +.macro EXCPN_PROLOG_FREEUP_REG reg + st \reg, [@ex_saved_reg1] +.endm + +.macro EXCPN_PROLOG_RESTORE_REG reg + ld \reg, [@ex_saved_reg1] +.endm + +/*-------------------------------------------------------------- + * Save all registers used by Exceptions (TLB Miss, Prot-V, Mem err etc) + * Requires SP to be already switched to kernel mode Stack + * sp points to the next free element on the stack at exit of this macro. + * Registers are pushed / popped in the order defined in struct ptregs + * in asm/ptrace.h + * Note that syscalls are implemented via TRAP which is also a exception + * from CPU's point of view + *-------------------------------------------------------------*/ +.macro SAVE_ALL_EXCEPTION marker + + /* Restore r9 used to code the early prologue */ + EXCPN_PROLOG_RESTORE_REG r9 + + /* Save the complete regfile now */ + + /* orig_r8 marker: + * syscalls -> 1 to NR_SYSCALLS + * Exceptions -> NR_SYSCALLS + 1 + * Break-point-> NR_SYSCALLS + 2 + */ + st \marker, [sp, 8] + st r0, [sp, 4] /* orig_r0, needed only for sys calls */ + SAVE_CALLER_SAVED + st.a r26, [sp, -4] /* gp */ + st.a fp, [sp, -4] + st.a blink, [sp, -4] + lr r9, [eret] + st.a r9, [sp, -4] + lr r9, [erstatus] + st.a r9, [sp, -4] + st.a lp_count, [sp, -4] + lr r9, [lp_end] + st.a r9, [sp, -4] + lr r9, [lp_start] + st.a r9, [sp, -4] + lr r9, [erbta] + st.a r9, [sp, -4] + +#ifdef PT_REGS_CANARY + mov r9, 0xdeadbeef + st r9, [sp, -4] +#endif + + /* move up by 1 word to "create" pt_regs->"stack_place_holder" */ + sub sp, sp, 4 +.endm + +/*-------------------------------------------------------------- + * Save scratch regs for exceptions + *-------------------------------------------------------------*/ +.macro SAVE_ALL_SYS + SAVE_ALL_EXCEPTION (NR_syscalls + 1) +.endm + +/*-------------------------------------------------------------- + * Save scratch regs for sys calls + *-------------------------------------------------------------*/ +.macro SAVE_ALL_TRAP + SAVE_ALL_EXCEPTION r8 +.endm + +/*-------------------------------------------------------------- + * Restore all registers used by system call or Exceptions + * SP should always be pointing to the next free stack element + * when entering this macro. + * + * NOTE: + * + * It is recommended that lp_count/ilink1/ilink2 not be used as a dest reg + * for memory load operations. If used in that way interrupts are deffered + * by hardware and that is not good. + *-------------------------------------------------------------*/ +.macro RESTORE_ALL_SYS + + add sp, sp, 4 /* hop over unused "pt_regs->stack_place_holder" */ + + ld.ab r9, [sp, 4] + sr r9, [erbta] + ld.ab r9, [sp, 4] + sr r9, [lp_start] + ld.ab r9, [sp, 4] + sr r9, [lp_end] + ld.ab r9, [sp, 4] + mov lp_count, r9 + ld.ab r9, [sp, 4] + sr r9, [erstatus] + ld.ab r9, [sp, 4] + sr r9, [eret] + ld.ab blink, [sp, 4] + ld.ab fp, [sp, 4] + ld.ab r26, [sp, 4] /* gp */ + RESTORE_CALLER_SAVED + + ld sp, [sp] /* restore original sp */ + /* orig_r0 and orig_r8 skipped automatically */ +.endm + + +/*-------------------------------------------------------------- + * Save all registers used by interrupt handlers. + *-------------------------------------------------------------*/ +.macro SAVE_ALL_INT1 + + /* restore original r9 , saved in int1_saved_reg + * It will be saved on stack in macro: SAVE_CALLER_SAVED + */ + ld r9, [@int1_saved_reg] + + /* now we are ready to save the remaining context :) */ + st -1, [sp, 8] /* orig_r8, -1 for interuppt level one */ + st 0, [sp, 4] /* orig_r0 , N/A for IRQ */ + SAVE_CALLER_SAVED + st.a r26, [sp, -4] /* gp */ + st.a fp, [sp, -4] + st.a blink, [sp, -4] + st.a ilink1, [sp, -4] + lr r9, [status32_l1] + st.a r9, [sp, -4] + st.a lp_count, [sp, -4] + lr r9, [lp_end] + st.a r9, [sp, -4] + lr r9, [lp_start] + st.a r9, [sp, -4] + lr r9, [bta_l1] + st.a r9, [sp, -4] + +#ifdef PT_REGS_CANARY + mov r9, 0xdeadbee1 + st r9, [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. + * + * NOTE: + * + * It is recommended that lp_count/ilink1/ilink2 not be used as a dest reg + * for memory load operations. If used in that way interrupts are deffered + * by hardware and that is not good. + *-------------------------------------------------------------*/ + +.macro RESTORE_ALL_INT1 + add sp, sp, 4 /* hop over unused "pt_regs->stack_place_holder" */ + + ld.ab r9, [sp, 4] /* Actual reg file */ + sr r9, [bta_l1] + ld.ab r9, [sp, 4] + sr r9, [lp_start] + ld.ab r9, [sp, 4] + sr r9, [lp_end] + ld.ab r9, [sp, 4] + mov lp_count, r9 + ld.ab r9, [sp, 4] + sr r9, [status32_l1] + ld.ab r9, [sp, 4] + mov ilink1, r9 + ld.ab blink, [sp, 4] + ld.ab fp, [sp, 4] + ld.ab r26, [sp, 4] /* gp */ + RESTORE_CALLER_SAVED + + ld sp, [sp] /* restore original sp */ + /* orig_r0 and orig_r8 skipped automatically */ +.endm + +/* Get CPU-ID of this core */ +.macro GET_CPU_ID reg + lr \reg, [identity] + lsr \reg, \reg, 8 + bmsk \reg, \reg, 7 +.endm + +.macro GET_CURR_TASK_ON_CPU reg + ld \reg, [@_current_task] +.endm + +.macro SET_CURR_TASK_ON_CPU tsk, tmp + st \tsk, [@_current_task] +.endm + +/* ------------------------------------------------------------------ + * Get the ptr to some field of Current Task at @off in task struct + */ + +.macro GET_CURR_TASK_FIELD_PTR off, reg + GET_CURR_TASK_ON_CPU \reg + add \reg, \reg, \off +.endm + +#endif /* __ASSEMBLY__ */ + +#endif /* __ASM_ARC_ENTRY_H */arch/arc/kernel/entry.S new file +561
-0@@ -0,0 +1,571 @@ +/* + * Low Level Interrupts/Traps/Exceptions(non-TLB) Handling for ARC + * + * 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: Nov 2010: + * -Vector table jumps (@8 bytes) converted into branches (@4 bytes) + * -To maintain the slot size of 8 bytes/vector, added nop, which is + * not executed at runtime. + * + * vineetg: Nov 2009 (Everything needed for TIF_RESTORE_SIGMASK) + * -do_signal()invoked upon TIF_RESTORE_SIGMASK as well + * -Wrappers for sys_{,rt_}sigsuspend() nolonger needed as they don't + * need ptregs anymore + * + * Vineetg: Oct 2009 + * -In a rare scenario, Process gets a Priv-V exception and gets scheduled + * out. Since we don't do FAKE RTIE for Priv-V, CPU excpetion state remains + * active (AE bit enabled). This causes a double fault for a subseq valid + * exception. Thus FAKE RTIE needed in low level Priv-Violation handler. + * Instr Error could also cause similar scenario, so same there as well. + * + * 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, + * we need to explicitly do this. The problem in macros + * FAKE_RET_FROM_EXCPN and FAKE_RET_FROM_EXCPN_LOCK_IRQ was that this bit + * was being "CLEARED" rather then "SET". Since it is Loop INHIBIT Bit, + * setting it and not clearing it clears ZOL context + * + * Vineetg: Dec 22, 2007 + * Minor Surgery of Low Level ISR to make it SMP safe + * - MMU_SCRATCH0 Reg used for freeing up r9 in Level 1 ISR + * - _current_task is made an array of NR_CPUS + * - Access of _current_task wrapped inside a macro so that if hardware + * team agrees for a dedicated reg, no other code is touched + * + * Amit Bhor, Rahul Trivedi, Kanika Nema, Sameer Dhavale : Codito Tech 2004 + */ + +/*------------------------------------------------------------------ + * Function ABI + *------------------------------------------------------------------ + * + * Arguments r0 - r7 + * Caller Saved Registers r0 - r12 + * Callee Saved Registers r13- r25 + * Global Pointer (gp) r26 + * Frame Pointer (fp) r27 + * Stack Pointer (sp) r28 + * Interrupt link register (ilink1) r29 + * Interrupt link register (ilink2) r30 + * Branch link register (blink) r31 + *------------------------------------------------------------------ + */ + + .cpu A7 + +;############################ Vector Table ################################# + +.macro VECTOR lbl +#if 1 /* Just in case, build breaks */ + j \lbl +#else + b \lbl + nop +#endif +.endm + + .section .vector, "ax",@progbits + .align 4 + +/* Each entry in the vector table must occupy 2 words. Since it is a jump + * across sections (.vector to .text) we are gauranteed that 'j somewhere' + * will use the 'j limm' form of the intrsuction as long as somewhere is in + * a section other than .vector. + */ + +; ********* Critical System Events ********************** +VECTOR res_service ; 0x0, Restart Vector (0x0) +VECTOR mem_service ; 0x8, Mem exception (0x1) +VECTOR instr_service ; 0x10, Instrn Error (0x2) + +; ******************** Device ISRs ********************** +VECTOR handle_interrupt_level1 + +VECTOR handle_interrupt_level1 + +VECTOR handle_interrupt_level1 + +VECTOR handle_interrupt_level1 + +.rept 25 +VECTOR handle_interrupt_level1 ; Other devices +.endr + +/* FOR ARC600: timer = 0x3, uart = 0x8, emac = 0x10 */ + +; ******************** Exceptions ********************** +VECTOR EV_MachineCheck ; 0x100, Fatal Machine check (0x20) +VECTOR EV_TLBMissI ; 0x108, Intruction TLB miss (0x21) +VECTOR EV_TLBMissD ; 0x110, Data TLB miss (0x22) +VECTOR EV_TLBProtV ; 0x118, Protection Violation (0x23) + ; or Misaligned Access +VECTOR EV_PrivilegeV ; 0x120, Privilege Violation (0x24) +VECTOR EV_Trap ; 0x128, Trap exception (0x25) +VECTOR EV_Extension ; 0x130, Extn Intruction Excp (0x26) + +.rept 24 +VECTOR reserved ; Reserved Exceptions +.endr + +#include <linux/linkage.h> /* ARC_{EXTRY,EXIT} */ +#include <asm/entry.h> /* SAVE_ALL_{INT1,INT2,TRAP...} */ +#include <asm/errno.h> +#include <asm/arcregs.h> +#include <asm/irqflags.h> + +;##################### Scratch Mem for IRQ stack switching ############# + + .section .data ; NOT .global + .align 32 + .type int1_saved_reg, @object + .size int1_saved_reg, 4 +int1_saved_reg: + .zero 4 + +; --------------------------------------------- + .section .text, "ax",@progbits + +res_service: ; processor restart + flag 0x1 ; not implemented + nop + nop + +reserved: ; processor restart + rtie ; jump to processor initializations + +;##################### Interrupt Handling ############################## + +; --------------------------------------------- +; Level 1 ISR +; --------------------------------------------- +ARC_ENTRY handle_interrupt_level1 + + /* free up r9 as scratchpad */ + st r9, [@int1_saved_reg] + + ;Which mode (user/kernel) was the system in when intr occured + lr r9, [status32_l1] + + SWITCH_TO_KERNEL_STK + SAVE_ALL_INT1 + + lr r0, [icause1] + and r0, r0, 0x1f + + bl.d @arch_do_IRQ + mov r1, sp + + mov r8,0x1 + sr r8, [AUX_IRQ_LV12] ; clear bit in Sticky Status Reg + + b ret_from_exception +ARC_EXIT handle_interrupt_level1 + +;################### Non TLB Exception Handling ############################# + +; --------------------------------------------- +; Instruction Error Exception Handler +; --------------------------------------------- + +ARC_ENTRY instr_service + + EXCPN_PROLOG_FREEUP_REG r9 + + lr r9, [erstatus] + + SWITCH_TO_KERNEL_STK + SAVE_ALL_SYS + + lr r0, [ecr] + lr r1, [efa] + + mov r2, sp + + FAKE_RET_FROM_EXCPN r9 + + bl do_insterror_or_kprobe + b ret_from_exception +ARC_EXIT instr_service + +; --------------------------------------------- +; Memory Error Exception Handler +; --------------------------------------------- + +ARC_ENTRY mem_service + + EXCPN_PROLOG_FREEUP_REG r9 + + lr r9, [erstatus] + + SWITCH_TO_KERNEL_STK + SAVE_ALL_SYS + + lr r0, [ecr] + lr r1, [efa] + mov r2, sp + bl do_memory_error + b ret_from_exception +ARC_EXIT mem_service + +; --------------------------------------------- +; Machine Check Exception Handler +; --------------------------------------------- + +ARC_ENTRY EV_MachineCheck + + EXCPN_PROLOG_FREEUP_REG r9 + lr r9, [erstatus] + + SWITCH_TO_KERNEL_STK + SAVE_ALL_SYS + + lr r0, [ecr] + lr r1, [efa] + mov r2, sp + + brne r0, 0x200100, 1f + bl do_tlb_overlap_fault + b ret_from_exception + +1: + ; DEAD END: can't do much, display Regs and HALT + SAVE_CALLEE_SAVED_USER + + GET_CURR_TASK_FIELD_PTR TASK_THREAD, r10 + st sp, [r10, THREAD_CALLEE_REG] + + j do_machine_check_fault + +ARC_EXIT EV_MachineCheck + +; --------------------------------------------- +; Protection Violation Exception Handler +; --------------------------------------------- + +ARC_ENTRY EV_TLBProtV + + EXCPN_PROLOG_FREEUP_REG r9 + + ;Which mode (user/kernel) was the system in when Exception occured + lr r9, [erstatus] + + SWITCH_TO_KERNEL_STK + SAVE_ALL_SYS + + ;---------(3) Save some more regs----------------- + ; vineetg: Mar 6th: Random Seg Fault issue #1 + ; ecr and efa were not saved in case an Intr sneaks in + ; after fake rtie + ; + lr r3, [ecr] + lr r4, [efa] + + ; --------(4) Return from CPU Exception Mode --------- + ; Fake a rtie, but rtie to next label + ; That way, subsequently, do_page_fault ( ) executes in pure kernel + ; mode with further Exceptions enabled + + FAKE_RET_FROM_EXCPN r9 + + ;------ (5) Type of Protection Violation? ---------- + ; + ; ProtV Hardware Exception is triggered for Access Faults of 2 types + ; -Access Violaton (WRITE to READ ONLY Page) - for linux COW + ; -Unaligned Access (READ/WRITE on odd boundary) + ; + cmp r3, 0x230400 ; Misaligned data access ? + beq 4f + + ;========= (6a) Access Violation Processing ======== + cmp r3, 0x230100 + mov r1, 0x0 ; if LD exception ? write = 0 + mov.ne r1, 0x1 ; else write = 1 + + mov r2, r4 ; faulting address + mov r0, sp ; pt_regs + bl do_page_fault + b ret_from_exception + + ;========== (6b) Non aligned access ============ +4: + mov r0, r3 ; cause code + mov r1, r4 ; faulting address + mov r2, sp ; pt_regs + + bl do_misaligned_access + b ret_from_exception + +ARC_EXIT EV_TLBProtV + +; --------------------------------------------- +; Privilege Violation Exception Handler +; --------------------------------------------- +ARC_ENTRY EV_PrivilegeV + + EXCPN_PROLOG_FREEUP_REG r9 + + lr r9, [erstatus] + + SWITCH_TO_KERNEL_STK + SAVE_ALL_SYS + + lr r0, [ecr] + lr r1, [efa] + mov r2, sp + + FAKE_RET_FROM_EXCPN r9 + + bl do_privilege_fault + b ret_from_exception +ARC_EXIT EV_PrivilegeV + +; --------------------------------------------- +; Extension Instruction Exception Handler +; --------------------------------------------- +ARC_ENTRY EV_Extension + + EXCPN_PROLOG_FREEUP_REG r9 + lr r9, [erstatus] + + SWITCH_TO_KERNEL_STK + SAVE_ALL_SYS + + lr r0, [ecr] + lr r1, [efa] + mov r2, sp + bl do_extension_fault + b ret_from_exception +ARC_EXIT EV_Extension + +;################### Break Point TRAP ########################## + + ; ======= (5b) Trap is due to Break-Point ========= + +trap_with_param: + + ;make sure orig_r8 is a positive value + st NR_syscalls + 2, [sp, PT_orig_r8] + + mov r0, r12 + lr r1, [efa] + mov r2, sp + + ; Now that we have read EFA, its safe to do "fake" rtie + ; and get out of CPU exception mode + FAKE_RET_FROM_EXCPN r11 + + ; Save callee regs in case gdb wants to have a look + ; SP will grow up by size of CALLEE Reg-File + ; NOTE: clobbers r12 + SAVE_CALLEE_SAVED_USER + + ; save location of saved Callee Regs @ thread_struct->pc + GET_CURR_TASK_FIELD_PTR TASK_THREAD, r10 + st sp, [r10, THREAD_CALLEE_REG] + + ; Call the trap handler + bl do_non_swi_trap + + ; unwind stack to discard Callee saved Regs + DISCARD_CALLEE_SAVED_USER + + b ret_from_exception + +;##################### Trap Handling ############################## +; +; EV_Trap caused by TRAP_S and TRAP0 instructions. +;------------------------------------------------------------------ +; (1) System Calls +; :parameters in r0-r7. +; :r8 has the system call number +; (2) Break Points +;------------------------------------------------------------------ + +ARC_ENTRY EV_Trap + + ; Need at least 1 reg to code the early exception prolog + EXCPN_PROLOG_FREEUP_REG r9 + + ;Which mode (user/kernel) was the system in when intr occured + lr r9, [erstatus] + + SWITCH_TO_KERNEL_STK + SAVE_ALL_TRAP + + ;------- (4) What caused the Trap -------------- + lr r12, [ecr] + and.f 0, r12, ECR_PARAM_MASK + bnz trap_with_param + + ; ======= (5a) Trap is due to System Call ======== + + ; Before doing anything, return from CPU Exception Mode + FAKE_RET_FROM_EXCPN r11 + + ;============ This is normal System Call case ========== + ; Sys-call num shd not exceed the total system calls avail + cmp r8, NR_syscalls + mov.hi r0, -ENOSYS + bhi ret_from_system_call + + ; Offset into the syscall_table and call handler + ld.as r9,[sys_call_table, r8] + jl [r9] ; Entry into Sys Call Handler + + ; fall through to ret_from_system_call +ARC_EXIT EV_Trap + +ARC_ENTRY ret_from_system_call + + st r0, [sp, PT_r0] ; sys call return value in pt_regs + + ; fall through yet again to ret_from_exception + +;############# Return from Intr/Excp/Trap (Linux Specifics) ############## +; +; If ret to user mode do we need to handle signals, schedule() et al. + +ARC_ENTRY ret_from_exception + + ; Pre-{IRQ,Trap,Exception} K/U mode from pt_regs->status32 + ld r8, [sp, PT_status32] ; returning to User/Kernel Mode + +#ifdef CONFIG_PREEMPT + bbit0 r8, STATUS_U_BIT, resume_kernel_mode +#else + bbit0 r8, STATUS_U_BIT, restore_regs +#endif + + ; Before returning to User mode check-for-and-complete any pending work + ; such as rescheduling/signal-delivery etc. +resume_user_mode_begin: + + ; Disable IRQs to ensures that chk for pending work itself is atomic + ; (and we don't end up missing a NEED_RESCHED/SIGPENDING due to an + ; interim IRQ). + IRQ_DISABLE r10 + + ; Fast Path return to user mode if no pending work + GET_CURR_THR_INFO_FLAGS r9 + and.f 0, r9, _TIF_WORK_MASK + bz restore_regs + + ; --- (Slow Path #1) task preemption --- + bbit0 r9, TIF_NEED_RESCHED, .Lchk_pend_signals + mov blink, resume_user_mode_begin ; tail-call to U mode ret chks + b @schedule ; BTST+Bnz causes relo error in link + +.Lchk_pend_signals: + IRQ_ENABLE r10 + + ; --- (Slow Path #2) pending signal --- + mov r0, sp ; pt_regs for arg to do_signal()/do_notify_resume() + + bbit0 r9, TIF_SIGPENDING, .Lchk_notify_resume + + ; save CALLEE Regs. + ; (i) If this signal causes coredump - full regfile needed + ; (ii) If signal is SIGTRAP/SIGSTOP, task is being traced thus + ; tracer might call PEEKUSR(CALLEE reg) + ; + ; NOTE: SP will grow up by size of CALLEE Reg-File + SAVE_CALLEE_SAVED_USER ; clobbers r12 + + ; save location of saved Callee Regs @ thread_struct->callee + GET_CURR_TASK_FIELD_PTR TASK_THREAD, r10 + st sp, [r10, THREAD_CALLEE_REG] + + bl @do_signal + + ; unwind SP for cheap discard of Callee saved Regs + DISCARD_CALLEE_SAVED_USER + + b resume_user_mode_begin ; loop back to start of U mode ret + + ; --- (Slow Path #3) notify_resume --- +.Lchk_notify_resume: + btst r9, TIF_NOTIFY_RESUME + blnz @do_notify_resume + b resume_user_mode_begin ; unconditionally back to U mode ret chks + ; for single exit point from this block + +#ifdef CONFIG_PREEMPT + +resume_kernel_mode: + + ; Can't preempt if preemption disabled + GET_CURR_THR_INFO_FROM_SP r10 + ld r8, [r10, THREAD_INFO_PREEMPT_COUNT] + brne r8, 0, restore_regs + + ; check if this task's NEED_RESCHED flag set + ld r9, [r10, THREAD_INFO_FLAGS] + bbit0 r9, TIF_NEED_RESCHED, restore_regs + + IRQ_DISABLE r9 + + ; Invoke PREEMPTION + bl preempt_schedule_irq + + ; preempt_schedule_irq() always returns with IRQ disabled +#endif + + ; fall through + +;############# Return from Intr/Excp/Trap (ARC Specifics) ############## +; +; Restore the saved sys context (common exit-path for EXCPN/IRQ/Trap) +; IRQ shd definitely not happen between now and rtie + +restore_regs : + + ; Disable Interrupts while restoring reg-file back + ; XXX can this be optimised out + IRQ_DISABLE_SAVE r9, r10 ;@r10 has prisitine (pre-disable) copy + + ; Restore REG File. In case multiple Events outstanding, + ; use the same priorty as rtie: EXCPN, L2 IRQ, L1 IRQ, None + ; Note that we use realtime STATUS32 (not pt_regs->status32) to + ; decide that. + + ; if Returning from Exception + bbit0 r10, STATUS_AE_BIT, not_exception + RESTORE_ALL_SYS + rtie + + ; Not Exception so maybe Interrupts (Level 1 or 2) + +not_exception: + + bbit0 r10, STATUS_A1_BIT, not_level1_interrupt + + ;return from level 1 + + RESTORE_ALL_INT1 +debug_marker_l1: + rtie + +not_level1_interrupt: + + ;this case is for syscalls or Exceptions (with fake rtie) + + RESTORE_ALL_SYS +debug_marker_syscall: + rtie
arch/arc/kernel/entry.S line 571
Quoted 10 lines
arch/arc/kernel/entry.S new file +10
-0+ +ARC_EXIT ret_from_exception + +ARC_ENTRY ret_from_fork + ; when the forked child comes here from the __switch_to function + ; r0 has the last task pointer. + ; put last task in scheduler queue + bl @schedule_tail + b @ret_from_exception +ARC_EXIT ret_from_fork
If the reworked resume user mode handling looks OK, can you please ACK it.
Thx,
-Vineet
PATCH v3 15/71 ARC: Interrupt Handling
In reply to Vineet GuptaThis contains:
-bootup arch IRQ init: init_IRQ(), arc_init_IRQ()
-generic IRQ subsystem glue: arch_do_IRQ()
-basic IRQ chip setup for in-core intc
--- arch/arc/include/asm/arcregs.h | 3 + arch/arc/include/asm/hw_irq.h | 7 +++ arch/arc/include/asm/irq.h | 22 ++++++++ arch/arc/kernel/irq.c | 107 +++++++++++++++++++++++++++++++++++++++- arch/arc/plat-arcfpga/irq.c | 15 ++++++ 5 files changed, 152 insertions(+), 2 deletions(-) create mode 100644 arch/arc/include/asm/hw_irq.h create mode 100644 arch/arc/include/asm/irq.h create mode 100644 arch/arc/plat-arcfpga/irq.c
arch/arc/include/asm/arcregs.h +3 -0
@@ -11,6 +11,9 @@#ifdef __KERNEL__ +/* Build Configuration Registers */ +#define ARC_REG_VECBASE_BCR 0x68 +/* status32 Bits Positions */ #define STATUS_H_BIT 0/* CPU Halted */ #define STATUS_E1_BIT 1/* Int 1 enable */
arch/arc/include/asm/hw_irq.h new file +7 -0
@@ -0,0 +1,7 @@ +/* +* 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. +*/
arch/arc/include/asm/irq.h new file +22 -0
@@ -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. +*/ + +#ifndef __ASM_ARC_IRQ_H +#define __ASM_ARC_IRQ_H + +/* Platform Independent IRQs */ +#define TIMER0_IRQ 3 +#define TIMER1_IRQ 4 + +#include <asm-generic/irq.h> + +extern void __init arc_init_IRQ (void ); +extern void __init plat_init_IRQ (void ); +extern int __init get_hw_config_num_irq (void ); + +#endif
arch/arc/kernel/irq.c +105 -2
113 lines not on this page · raw message
arch/arc/plat-arcfpga/irq.c new file +15 -0
@@ -0,0 +1,15 @@ +/* +* ARC FPGA Platform IRQ hookups +* +* 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/interrupt.h> + +void __init plat_init_IRQ (void ) +{ +}
Signature · 1 line
1.7.4.1
PATCH v3 16/71 ARC: Non-MMU Exception Handling
In reply to Vineet Gupta--- arch/arc/include/asm/hw_irq.h | 7 -- arch/arc/kernel/traps.c | 125 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 125 insertions(+), 7 deletions(-) delete mode 100644 arch/arc/include/asm/hw_irq.h create mode 100644 arch/arc/kernel/traps.c
arch/arc/include/asm/hw_irq.h deleted +0 -7
@@ -1,7 +0,0 @@ -/* -* 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. -*/
arch/arc/kernel/traps.c new file +125 -0
125 lines not on this page · raw message
Signature · 1 line
1.7.4.1
PATCH v3 24/71 ARC: Page Table Management
In reply to Vineet Gupta--- arch/arc/include/asm/page.h | 92 +++++++++ arch/arc/include/asm/pgalloc.h | 134 +++++++++++++ arch/arc/include/asm/pgtable.h | 401 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 627 insertions(+), 0 deletions(-) create mode 100644 arch/arc/include/asm/pgalloc.h create mode 100644 arch/arc/include/asm/pgtable.h
arch/arc/include/asm/page.h +92 -0
@@ -35,6 +35,98 @@#define PAGE_MASK (~(PAGE_SIZE-1)) +#ifdef __KERNEL__ + +#ifndef __ASSEMBLY__ + +#define get_user_page (vaddr) __get_free_page(GFP_KERNEL) +#define free_user_page (page, addr) free_page(addr) + +/* TBD: for now don't worry about VIPT D$ aliasing */ +#define clear_page (paddr) memset((paddr), 0, PAGE_SIZE) +#define copy_page (to, from) memcpy((to), (from), PAGE_SIZE) + +#define clear_user_page (addr, vaddr, pg) clear_page(addr) +#define copy_user_page (vto, vfrom, vaddr, pg) copy_page(vto, vfrom) + +#undef STRICT_MM_TYPECHECKS + +#ifdef STRICT_MM_TYPECHECKS +/* +* These are used to make use of C type-checking.. +*/ +typedef struct { +unsigned long pte; +}pte_t ; +typedef struct { +unsigned long pgd; +}pgd_t ; +typedef struct { +unsigned long pgprot; +}pgprot_t ; +typedef unsigned long pgtable_t ; + +#define pte_val (x) ((x).pte) +#define pgd_val (x) ((x).pgd) +#define pgprot_val (x) ((x).pgprot) + +#define __pte (x) ((pte_t) { (x) }) +#define __pgd (x) ((pgd_t) { (x) }) +#define __pgprot (x) ((pgprot_t) { (x) }) + +#else /* !STRICT_MM_TYPECHECKS */ + +typedef unsigned long pte_t ; +typedef unsigned long pgd_t ; +typedef unsigned long pgprot_t ; +typedef unsigned long pgtable_t ; + +#define pte_val (x) (x) +#define pgd_val (x) (x) +#define pgprot_val (x) (x) +#define __pte (x) (x) +#define __pgprot (x) (x) + +#endif + +#define ARCH_PFN_OFFSET (CONFIG_LINUX_LINK_BASE >> PAGE_SHIFT) + +#define pfn_valid (pfn) (((pfn) - ARCH_PFN_OFFSET) < max_mapnr) + +/* +* __pa, __va, virt_to_page (ALERT: deprecated, don't use them) +* +* These macros have historically been misnamed +* virt here means link-address/program-address as embedded in object code. +* So if kernel img is linked at 0x8000_0000 onwards, 0x8010_0000 will be +* 128th page, and virt_to_page( ) will return the struct page corresp to it. +* mem_map[ ] is an array of struct page for each page frame in the system +* +* Independent of where linux is linked at, link-addr = physical address +* So the old macro __pa = vaddr + PAGE_OFFSET - CONFIG_LINUX_LINK_BASE +* would have been wrong in case kernel is not at 0x8zs +*/ +#define __pa (vaddr) ((unsigned long)vaddr) +#define __va (paddr) ((void *)((unsigned long)(paddr))) + +#define virt_to_page (kaddr) \ + (mem_map + ((__pa(kaddr) - CONFIG_LINUX_LINK_BASE) >> PAGE_SHIFT)) + +#define virt_addr_valid (kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT) + +/* Default Permissions for page, used in mmap.c */ +#ifdef CONFIG_ARC_STACK_NONEXEC +#define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE) +#else +#define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \ + VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) +#endif + +#define WANT_PAGE_VIRTUAL 1 + +#include <asm-generic/memory_model.h> /* page_to_pfn, pfn_to_page */ +#include <asm-generic/getorder.h> +#endif /* !__ASSEMBLY__ */ #endif /* __KERNEL__ */
arch/arc/include/asm/pgalloc.h new file +134 -0
134 lines not on this page · raw message
arch/arc/include/asm/pgtable.h new file +401 -0
401 lines not on this page · raw message
Signature · 1 line
1.7.4.1
PATCH v3 25/71 ARC: MMU Context Management
In reply to Vineet GuptaARC700 MMU provides for tagging TLB entries with a 8-bit ASID to avoid having to flush the TLB every task switch.
It also allows for a quick way to invalidate all the TLB entries for task useful for:
* COW sementics during fork()
* task exit()ing
--- arch/arc/include/asm/arcregs.h | 7 ++ arch/arc/include/asm/mmu.h | 23 ++++ arch/arc/include/asm/mmu_context.h | 209 ++++++++++++++++++++++++++++++++++++ arch/arc/mm/tlb.c | 23 ++++ 4 files changed, 262 insertions(+), 0 deletions(-) create mode 100644 arch/arc/include/asm/mmu.h create mode 100644 arch/arc/include/asm/mmu_context.h create mode 100644 arch/arc/mm/tlb.c
arch/arc/include/asm/arcregs.h +7 -0
@@ -85,6 +85,13 @@#define DC_CTRL_INV_MODE_FLUSH 0x40#define DC_CTRL_FLUSH_STATUS 0x100 +/* MMU Management regs */ +#define ARC_REG_PID 0x409 +#define ARC_REG_SCRATCH_DATA0 0x418 + +/* Bits in MMU PID register */ +#define MMU_ENABLE (1 << 31)/* Enable MMU for process */ +/* * Floating Pt Registers * Status regs are read-only (build-time) so need not be saved/restored
arch/arc/include/asm/mmu.h new file +23 -0
@@ -0,0 +1,23 @@ +/* +* 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_MMU_H +#define _ASM_ARC_MMU_H + +#ifndef __ASSEMBLY__ + +typedef struct { +unsigned long asid;/* Pvt Addr-Space ID for mm */ +#ifdef CONFIG_ARC_TLB_DBG +struct task_struct *tsk; +#endif +}mm_context_t ; + +#endif + +#endif
arch/arc/include/asm/mmu_context.h new file +209 -0
209 lines not on this page · raw message
arch/arc/mm/tlb.c new file +23 -0
@@ -0,0 +1,23 @@ +/* +* TLB Management (flush/create/diagnostics) for ARC700 +* +* 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 <asm/arcregs.h> +#include <asm/mmu_context.h> +#include <asm/tlb.h> + +/* A copy of the ASID from the PID reg is kept in asid_cache */ +int asid_cache =FIRST_ASID ; + +/* ASID to mm struct mapping. We have one extra entry corresponding to +* NO_ASID to save us a compare when clearing the mm entry for old asid +* see get_new_mmu_context (asm-arc/mmu_context.h) +*/ +struct mm_struct *asid_mm_map[NUM_ASID +1 ];
Signature · 1 line
1.7.4.1
PATCH v3 26/71 ARC: MMU Exception Handling
In reply to Vineet Gupta* MMU I-TLB / D-TLB Miss Exceptions
- Fast Path TLB Refill Handler
- slowpath TLB creation via do_page_fault() -> update_mmu_cache()
* Duplicate PD Exception Handler
--- arch/arc/include/asm/arcregs.h | 91 ++++++++++ arch/arc/include/asm/tlb-mmu1.h | 104 ++++++++++++ arch/arc/include/asm/tlb.h | 41 +++++ arch/arc/mm/tlb.c | 267 +++++++++++++++++++++++++++++ arch/arc/mm/tlbex.S | 351 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 854 insertions(+), 0 deletions(-) create mode 100644 arch/arc/include/asm/tlb-mmu1.h create mode 100644 arch/arc/include/asm/tlb.h create mode 100644 arch/arc/mm/tlbex.S
arch/arc/include/asm/arcregs.h +91 -0
@@ -13,6 +13,7 @@/* Build Configuration Registers */ #define ARC_REG_VECBASE_BCR 0x68 +#define ARC_REG_MMU_BCR 0x6f/* status32 Bits Positions */ #define STATUS_H_BIT 0/* CPU Halted */
@@ -36,6 +37,35 @@#define STATUS_U_MASK (1<<STATUS_U_BIT)#define STATUS_L_MASK (1<<STATUS_L_BIT) +/* +* ECR: Exception Cause Reg bits-n-pieces +* [23:16] = Exception Vector +* [15: 8] = Exception Cause Code +* [ 7: 0] = Exception Parameters (for certain types only) +*/ +#define ECR_VEC_MASK 0xff0000 +#define ECR_CODE_MASK 0x00ff00 +#define ECR_PARAM_MASK 0x0000ff + +/* Exception Cause Vector Values */ +#define ECR_V_INSN_ERR 0x02 +#define ECR_V_MACH_CHK 0x20 +#define ECR_V_ITLB_MISS 0x21 +#define ECR_V_DTLB_MISS 0x22 +#define ECR_V_PROTV 0x23 + +/* Protection Violation Exception Cause Code Values */ +#define ECR_C_PROTV_INST_FETCH 0x00 +#define ECR_C_PROTV_LOAD 0x01 +#define ECR_C_PROTV_STORE 0x02 +#define ECR_C_PROTV_XCHG 0x03 +#define ECR_C_PROTV_MISALIG_DATA 0x04 + +/* DTLB Miss Exception Cause Code Values */ +#define ECR_C_BIT_DTLB_LD_MISS 8 +#define ECR_C_BIT_DTLB_ST_MISS 9 + +/* Auxiliary registers */ #define AUX_IDENTITY 4#define AUX_INTR_VEC_BASE 0x25
@@ -58,6 +88,44 @@#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 +#define ARC_REG_TLBINDEX 0x407 +#define ARC_REG_TLBCOMMAND 0x408 +#define ARC_REG_PID 0x409 +#define ARC_REG_SCRATCH_DATA0 0x418 + +/* Bits in MMU PID register */ +#define MMU_ENABLE (1 << 31)/* Enable MMU for process */ + +/* Error code if probe fails */ +#define TLB_LKUP_ERR 0x80000000 + +/* TLB Commands */ +#define TLBWrite 0x1 +#define TLBRead 0x2 +#define TLBGetIndex 0x3 +#define TLBProbe 0x4 + +#if (CONFIG_ARC_MMU_VER >=2 ) +#define TLBWriteNI 0x5/* write JTLB without inv uTLBs */ +#define TLBIVUTLB 0x6/* explicitly inv uTLBs */ +#else +#undef TLBWriteNI/* These cmds don't exist on older MMU */ +#undef TLBIVUTLB +#endif +/* Instruction cache related Auxiliary registers */ #define ARC_REG_IC_BCR 0x77/* Build Config reg */ #define ARC_REG_IC_IVIC 0x10
@@ -205,6 +273,24 @@ struct arc_fpu {* Build Configuration Registers, with encoded hardware config */ +struct bcr_mmu_1_2 { +#ifdef CONFIG_CPU_BIG_ENDIAN +unsigned int ver:8 , ways:4 , sets:4 , u_itlb:8 , u_dtlb:8 ; +#else +unsigned int u_dtlb:8 , u_itlb:8 , sets:4 , ways:4 , ver:8 ; +#endif +}; + +struct bcr_mmu_3 { +#ifdef CONFIG_CPU_BIG_ENDIAN +unsigned int ver:8 , ways:4 , sets:4 , osm:1 , reserv:3 , pg_sz:4 , + u_itlb:4 , u_dtlb:4 ; +#else +unsigned int u_dtlb:4 , u_itlb:4 , pg_sz:4 , reserv:3 , osm:1 , sets:4 , + ways:4 , ver:8 ; +#endif +}; +struct bcr_cache {#ifdef CONFIG_CPU_BIG_ENDIAN unsigned int pad:12 , line_len:4 , sz:4 , config:4 , ver:8 ;
@@ -218,12 +304,17 @@ struct bcr_cache {* Generic structures to hold build configuration used at runtime */ +struct cpuinfo_arc_mmu { +unsigned int ver, pg_sz, sets, ways, u_dtlb, u_itlb, num_tlb; +}; +struct cpuinfo_arc_cache {unsigned int has_aliasing, sz, line_len, assoc, ver; };struct cpuinfo_arc {struct cpuinfo_arc_cache icache, dcache; +struct cpuinfo_arc_mmu mmu; };extern struct cpuinfo_arc cpuinfo_arc700[];
arch/arc/include/asm/tlb-mmu1.h new file +104 -0
104 lines not on this page · raw message
arch/arc/include/asm/tlb.h new file +41 -0
41 lines not on this page · raw message
arch/arc/mm/tlb.c +267 -0
270 lines not on this page · raw message
arch/arc/mm/tlbex.S new file +351 -0
351 lines not on this page · raw message
Signature · 1 line
1.7.4.1
PATCH v3 27/71 ARC: TLB flush Handling
In reply to Vineet Gupta--- arch/arc/include/asm/tlb.h | 17 ++ arch/arc/include/asm/tlbflush.h | 28 ++++ arch/arc/mm/tlb.c | 311 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 356 insertions(+), 0 deletions(-) create mode 100644 arch/arc/include/asm/tlbflush.h
arch/arc/include/asm/tlb.h +17 -0
@@ -21,6 +21,23 @@#ifndef __ASSEMBLY__ +#define tlb_flush (tlb) local_flush_tlb_mm((tlb)->mm) + +/* +* This pair is called at time of munmap/exit to flush cache and TLB entries +* for mappings being torn down. +* 1) cache-flush part -implemented via tlb_start_vma( ) can be NOP (for now) +* as we don't support aliasing configs in our VIPT D$. +* 2) tlb-flush part - implemted via tlb_end_vma( ) can be NOP as well- +* albiet for difft reasons - its better handled by moving to new ASID +* +* Note, read http://lkml.org/lkml/2004/1/15/6 +*/ +#define tlb_start_vma (tlb, vma) +#define tlb_end_vma (tlb, vma) + +#define __tlb_remove_tlb_entry (tlb, ptep, address) +#include <linux/pagemap.h> #include <asm-generic/tlb.h>
arch/arc/include/asm/tlbflush.h new file +28 -0
@@ -0,0 +1,28 @@ +/* +* 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_TLBFLUSH__ +#define __ASM_ARC_TLBFLUSH__ + +#include <linux/mm.h> + +void local_flush_tlb_all (void ); +void local_flush_tlb_mm (struct mm_struct *mm); +void local_flush_tlb_page (struct vm_area_struct *vma,unsigned long page); +void local_flush_tlb_kernel_range (unsigned long start,unsigned long end); +void local_flush_tlb_range (struct vm_area_struct *vma, +unsigned long start,unsigned long end); + +/* XXX: Revisit for SMP */ +#define flush_tlb_range (vma, s, e) local_flush_tlb_range(vma, s, e) +#define flush_tlb_page (vma, page) local_flush_tlb_page(vma, page) +#define flush_tlb_kernel_range (s, e) local_flush_tlb_kernel_range(s, e) +#define flush_tlb_all () local_flush_tlb_all() +#define flush_tlb_mm (mm) local_flush_tlb_mm(mm) + +#endif
arch/arc/mm/tlb.c +311 -0
330 lines not on this page · raw message
Signature · 1 line
1.7.4.1
PATCH v3 28/71 ARC: Page Fault handling
In reply to Vineet GuptaThis includes recent changes to make handler "retry" and/or "killable"
The killable (early exit) logic is loosely based on how SH implements it
return if SIGKILL + either of VM_FAULT_OOM or VM_FAULT_RETRY
which is different from Hexagon implementation which would NOT early exit for
SIGKILL + VM_FAULT_OOM + !VM_FAULT_RETRY
--- arch/arc/mm/fault.c | 228 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 228 insertions(+), 0 deletions(-) create mode 100644 arch/arc/mm/fault.c
arch/arc/mm/fault.c new file +228 -0
@@ -0,0 +1,228 @@ +/* Page Fault Handling for ARC (TLB Miss / ProtV) +* +* 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/signal.h> +#include <linux/interrupt.h> +#include <linux/sched.h> +#include <linux/errno.h> +#include <linux/ptrace.h> +#include <linux/version.h> +#include <linux/uaccess.h> +#include <linux/kdebug.h> +#include <asm/pgalloc.h> + +static int handle_vmalloc_fault (struct mm_struct *mm,unsigned long address) +{ +/* +* Synchronize this task's top level page-table +* with the 'reference' page table. +*/ +pgd_t *pgd, *pgd_k; +pud_t *pud, *pud_k; +pmd_t *pmd, *pmd_k; + + pgd =pgd_offset_fast (mm, address); + pgd_k =pgd_offset_k (address); + +if (!pgd_present (*pgd_k)) + goto bad_area; + + pud =pud_offset (pgd, address); + pud_k =pud_offset (pgd_k, address); +if (!pud_present (*pud_k)) + goto bad_area; + + pmd =pmd_offset (pud, address); + pmd_k =pmd_offset (pud_k, address); +if (!pmd_present (*pmd_k)) + goto bad_area; + +set_pmd (pmd, *pmd_k); + +/* XXX: create the TLB entry here */ +return 0 ; + +bad_area: +return 1 ; +} + +void do_page_fault (struct pt_regs *regs,int write,unsigned long address, +unsigned long cause_code) +{ +struct vm_area_struct *vma =NULL ; +struct task_struct *tsk = current; +struct mm_struct *mm = tsk->mm; +siginfo_t info; +int fault, ret; +unsigned int flags =FAULT_FLAG_ALLOW_RETRY |FAULT_FLAG_KILLABLE | + (write ?FAULT_FLAG_WRITE :0 ); + +/* +* We fault-in kernel-space virtual memory on-demand. The +* 'reference' page table is init_mm.pgd. +* +* NOTE! We MUST NOT take any locks for this case. We may +* be in an interrupt or a critical region, and should +* only copy the information from the master page table, +* nothing more. +*/ +if (address >=VMALLOC_START && address <=VMALLOC_END ) { + ret =handle_vmalloc_fault (mm, address); +if (unlikely (ret)) + goto bad_area_nosemaphore; +else +return ; + } + + info.si_code =SEGV_MAPERR ; + +/* +* If we're in an interrupt or have no user +* context, we must not take the fault.. +*/ +if (in_atomic () || !mm) + goto no_context; + +retry: +down_read (&mm->mmap_sem); + vma =find_vma (mm, address); +if (!vma) + goto bad_area; +if (vma->vm_start <= address) + goto good_area; +if (!(vma->vm_flags &VM_GROWSDOWN )) + goto bad_area; +if (expand_stack (vma, address)) + goto bad_area; + +/* +* Ok, we have a good vm_area for this memory access, so +* we can handle it.. +*/ +good_area: + info.si_code =SEGV_ACCERR ; + +/* Handle protection violation, execute on heap or stack */ + +if (cause_code == ((ECR_V_PROTV <<16 ) |ECR_C_PROTV_INST_FETCH )) + goto bad_area; + +if (write) { +if (!(vma->vm_flags &VM_WRITE )) + goto bad_area; + }else { +if (!(vma->vm_flags & (VM_READ |VM_EXEC ))) + goto bad_area; + } + +survive: +/* +* If for any reason at all we couldn't handle the fault, +* make sure we exit gracefully rather than endlessly redo +* the fault. +*/ + fault =handle_mm_fault (mm, vma, address, flags); + +/* If Pagefault was interrupted by SIGKILL, exit page fault "early" */ +if (unlikely (fatal_signal_pending (current))) { +if ((fault &VM_FAULT_ERROR ) && !(fault &VM_FAULT_RETRY )) +up_read (&mm->mmap_sem); +if (user_mode (regs)) +return ; + } + +if (likely (!(fault &VM_FAULT_ERROR ))) { +if (flags &FAULT_FLAG_ALLOW_RETRY ) { +/* To avoid updating stats twice for retry case */ +if (fault &VM_FAULT_MAJOR ) + tsk->maj_flt++; +else + tsk->min_flt++; + +if (fault &VM_FAULT_RETRY ) { + flags &= ~FAULT_FLAG_ALLOW_RETRY ; + flags |=FAULT_FLAG_TRIED ; + goto retry; + } + } + +/* Fault Handled Gracefully */ +up_read (&mm->mmap_sem); +return ; + } + +/* TBD: switch to pagefault_out_of_memory() */ +if (fault &VM_FAULT_OOM ) + goto out_of_memory; +else if (fault &VM_FAULT_SIGBUS ) + goto do_sigbus; + +/* no man's land */ +BUG (); + +/* +* Something tried to access memory that isn't in our memory map.. +* Fix it, but check if it's kernel or user first.. +*/ +bad_area: +up_read (&mm->mmap_sem); + +bad_area_nosemaphore: +/* User mode accesses just cause a SIGSEGV */ +if (user_mode (regs)) { + tsk->thread.fault_address = address; + tsk->thread.cause_code = cause_code; + info.si_signo =SIGSEGV ; + info.si_errno =0 ; +/* info.si_code has been set above */ + info.si_addr = (void __user *)address; +force_sig_info (SIGSEGV , &info, tsk); +return ; + } + +no_context: +/* Are we prepared to handle this kernel fault? +* +* (The kernel has valid exception-points in the source +* when it acesses user-memory. When it fails in one +* of those points, we find it in a table and do a jump +* to some fixup code that loads an appropriate error +* code) +*/ +if (fixup_exception (regs)) +return ; + +die ("Oops" , regs, address, cause_code); + +out_of_memory: +if (is_global_init (tsk)) { +yield (); + goto survive; + } +up_read (&mm->mmap_sem); + +if (user_mode (regs)) +do_group_exit (SIGKILL );/* This will never return */ + + goto no_context; + +do_sigbus: +up_read (&mm->mmap_sem); + +if (!user_mode (regs)) + goto no_context; + + tsk->thread.fault_address = address; + tsk->thread.cause_code = cause_code; + info.si_signo =SIGBUS ; + info.si_errno =0 ; + info.si_code =BUS_ADRERR ; + info.si_addr = (void __user *)address; +force_sig_info (SIGBUS , &info, tsk); +}
Signature · 1 line
1.7.4.1
PATCH v3 31/71 ARC: [plat-arcfpga] Static platform device for CONFIG_SERIAL_ARC
In reply to Vineet GuptaN.B. This is old style of hardcoding platform device specific info in code and it's instantiation thererof using platform_add_devices(). Subsequent patches replace this with DeviceTree based runtime probe.
This patch has been retained just as an example of "don't-do-this" for newer kernel ports.
--- arch/arc/include/asm/irq.h | 1 + arch/arc/plat-arcfpga/include/plat/irq.h | 27 +++++++ arch/arc/plat-arcfpga/include/plat/memmap.h | 31 ++++++++ arch/arc/plat-arcfpga/platform.c | 108 +++++++++++++++++++++++++++ 4 files changed, 167 insertions(+), 0 deletions(-) create mode 100644 arch/arc/plat-arcfpga/include/plat/irq.h create mode 100644 arch/arc/plat-arcfpga/include/plat/memmap.h
arch/arc/include/asm/irq.h +1 -0
@@ -13,6 +13,7 @@#define TIMER0_IRQ 3#define TIMER1_IRQ 4 +#include <plat/irq.h> /* Board Specific IRQ assignments */ #include <asm-generic/irq.h> extern void __init arc_init_IRQ (void );
arch/arc/plat-arcfpga/include/plat/irq.h new file +27 -0
@@ -0,0 +1,27 @@ +/* +* 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: Feb 2009 +* -For AA4 board, IRQ assignments to peripherals +*/ + +#ifndef __PLAT_IRQ_H +#define __PLAT_IRQ_H + +#define NR_IRQS 16 + +#define UART0_IRQ 5 +#define UART1_IRQ 10 +#define UART2_IRQ 11 + +#define VMAC_IRQ 6 + +#define IDE_IRQ 13 +#define PCI_IRQ 14 +#define PS2_IRQ 15 + +#endif
arch/arc/plat-arcfpga/include/plat/memmap.h new file +31 -0
@@ -0,0 +1,31 @@ +/* +* 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: Feb 2009 +* -For AA4 board, System Memory Map for Peripherals etc +*/ + +#ifndef __PLAT_MEMMAP_H +#define __PLAT_MEMMAP_H + +#define UART0_BASE 0xC0FC1000 +#define UART1_BASE 0xC0FC1100 + +#define VMAC_REG_BASEADDR 0xC0FC2000 + +#define IDE_CONTROLLER_BASE 0xC0FC9000 + +#define AHB_PCI_HOST_BRG_BASE 0xC0FD0000 + +#define PGU_BASEADDR 0xC0FC8000 +#define VLCK_ADDR 0xC0FCF028 + +#define BVCI_LAT_UNIT_BASE 0xC0FED000 + +#define PS2_BASE_ADDR 0xC0FCC000 + +#endif
arch/arc/plat-arcfpga/platform.c +108 -0
127 lines not on this page · raw message
Signature · 1 line
1.7.4.1
PATCH v3 35/71 ARC: Last bits (stubs) to get to a running kernel with UART
In reply to Vineet GuptaThis was part of port buildup strategy from Arnd to have a minimal kernel at first and then add optional features (stacktracing, ptrace, smp, kprobes, oprofile....)
--- arch/arc/kernel/ptrace.c | 26 ++++++++++++++++++++++++ arch/arc/kernel/stacktrace.c | 43 ++++++++++++++++++++++++++++++++++++++++ arch/arc/kernel/troubleshoot.c | 17 +++++++++++++++ 3 files changed, 86 insertions(+), 0 deletions(-) create mode 100644 arch/arc/kernel/ptrace.c create mode 100644 arch/arc/kernel/stacktrace.c create mode 100644 arch/arc/kernel/troubleshoot.c
arch/arc/kernel/ptrace.c new file +26 -0
@@ -0,0 +1,26 @@ +/* +* 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/ptrace.h> + +void ptrace_disable (struct task_struct *child) +{ +} + +long arch_ptrace (struct task_struct *child,long request, +unsigned long addr,unsigned long data) +{ +int ret = -EIO ; +return ret; +} + + +const struct user_regset_view *task_user_regset_view (struct task_struct *task) +{ +return (const struct user_regset_view *)NULL ; +}
arch/arc/kernel/stacktrace.c new file +43 -0
43 lines not on this page · raw message
arch/arc/kernel/troubleshoot.c new file +17 -0
@@ -0,0 +1,17 @@ +/* +* 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 +*/ + +#include <linux/ptrace.h> + +void show_regs (struct pt_regs *regs) +{ +} + +void show_kernel_fault_diag (const char *str,struct pt_regs *regs, +unsigned long address,unsigned long cause_reg) +{ +}
Signature · 1 line
1.7.4.1
PATCH v3 36/71 ARC: [plat-arcfpga] defconfig
In reply to Vineet GuptaWith this we get to a running kernel on ISS
---------------------------------->8----------------------------------- Linux version 3.8.0-rc3+ (vineetg@vineetg-Latitude) (gcc version 4.4.7 (ARCompact elf32 toolchain (built 20121213)) ) #3 Thu Jan 17 14:22:05 IST 2013
Board "arc-angel4" from snps (Manufacturer)
Memory size set via devicetree 256M
[plat-arcfpga]: registering early dev resources
bootconsole [early_ARCuart0] enabled
pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
pcpu-alloc: [0] 0
Built 1 zonelists in Zone order, mobility grouping on. Total pages:
32624
Kernel command line: console=ttyARC0,115200n8
PID hash table entries: 1024 (order: -1, 4096 bytes)
Dentry cache hash table entries: 32768 (order: 4, 131072 bytes) Inode-cache hash table entries: 16384 (order: 3, 65536 bytes) Memory Available: 248M / 256M (1312K code, 463K data, 4184K init, 1400K reserv)
SLUB: Genslabs=12, HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1 NR_IRQS:16
Console: colour dummy device 80x25
Calibrating delay loop... 39.73 BogoMIPS (lpj=198656)pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 1024
devtmpfs: initialized
[plat-arcfpga]: registering device resources
bio: create slab <bio-0> at 0
Switching to clocksource ARC RTSC
io scheduler noop registered (default)
arc-uart: ttyARC0 at MMIO 0xc0fc1000 (irq = 5) is a arc-uart console [ttyARC0] enabled, bootconsole disabled
console [ttyARC0] enabled, bootconsole disabled
mousedev: PS/2 mouse device common for all mice
Warning: unable to open an initial console.
Freeing unused kernel memory: 4184k [80002000] to [80418000] Mounting proc
Mounting sysfs
Mounting devpts
Setting hostname to ARCLinux
Starting System logger (syslogd)
Bringing up loopback device
ifconfig: socket: Function not implemented
route: socket: Function not implemented
Disk not detected !
Mounting tmpfs
mount: mounting tmpfs on /dev/shm failed: Invalid argument /etc/init.d/rcS: line 76: can't create /proc/sys/kernel/msgmni:
nonexistent directory
Please press Enter to activate this console.
***********************************************************************
Welcome to ARCLinux
***********************************************************************
[ARCLinux]$
---------------------------------->8-----------------------------------
--- arch/arc/configs/fpga_defconfig | 46 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 46 insertions(+), 0 deletions(-) create mode 100644 arch/arc/configs/fpga_defconfig
arch/arc/configs/fpga_defconfig new file +46 -0
@@ -0,0 +1,46 @@ +CONFIG_CROSS_COMPILE="arc-elf32-" +# CONFIG_LOCALVERSION_AUTO is not set +CONFIG_DEFAULT_HOSTNAME="ARCLinux" +# CONFIG_SWAP is not set +CONFIG_HIGH_RES_TIMERS=y +CONFIG_IKCONFIG=y +CONFIG_IKCONFIG_PROC=y +CONFIG_NAMESPACES=y +# CONFIG_UTS_NS is not set +# CONFIG_PID_NS is not set +CONFIG_BLK_DEV_INITRD=y +CONFIG_INITRAMFS_SOURCE="../arc_initramfs" +CONFIG_EXPERT=y +# CONFIG_FUTEX is not set +# CONFIG_COMPAT_BRK is not set +# CONFIG_LBDAF is not set +# CONFIG_BLK_DEV_BSG is not set +# CONFIG_IOSCHED_DEADLINE is not set +# CONFIG_IOSCHED_CFQ is not set +CONFIG_ARC_BUILTIN_DTB_NAME="angel4" +# CONFIG_COMPACTION is not set +# CONFIG_CROSS_MEMORY_ATTACH is not set +# CONFIG_STANDALONE is not set +# CONFIG_PREVENT_FIRMWARE_BUILD is not set +# CONFIG_FIRMWARE_IN_KERNEL is not set +# CONFIG_BLK_DEV is not set +# CONFIG_INPUT_MOUSEDEV_PSAUX is not set +# CONFIG_INPUT_KEYBOARD is not set +# CONFIG_INPUT_MOUSE is not set +# CONFIG_SERIO is not set +# CONFIG_LEGACY_PTYS is not set +# CONFIG_DEVKMEM is not set +CONFIG_SERIAL_ARC=y +CONFIG_SERIAL_ARC_CONSOLE=y +# CONFIG_HW_RANDOM is not set +# CONFIG_HWMON is not set +# CONFIG_VGA_CONSOLE is not set +# CONFIG_HID is not set +# CONFIG_USB_SUPPORT is not set +# CONFIG_IOMMU_SUPPORT is not set +# CONFIG_DNOTIFY is not set +# CONFIG_INOTIFY_USER is not set +# CONFIG_MISC_FILESYSTEMS is not set +# CONFIG_ENABLE_WARN_DEPRECATED is not set +# CONFIG_ENABLE_MUST_CHECK is not set +CONFIG_XZ_DEC=y
Signature · 1 line
1.7.4.1
PATCH v3 37/71 ARC: [optim] Cache "current" in Register r25
In reply to 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
arch/arc/Kconfig +7 -0
@@ -264,6 +264,13 @@ config LINUX_LINK_BASE 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
arch/arc/Makefile +9 -0
@@ -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
arch/arc/include/asm/Kbuild +0 -1
@@ -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
arch/arc/include/asm/current.h new file +32 -0
@@ -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 + +registerstruct 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 */
arch/arc/include/asm/entry.h +45 -0
109 lines not on this page · raw message
arch/arc/include/asm/processor.h +3 -0
@@ -29,6 +29,9 @@ struct thread_struct {unsigned long callee_reg;/* pointer to callee regs */ unsigned long fault_address;/* dbls as brkpt holder as well */ unsigned long cause_code;/* Exception Cause Code (ECR) */ +#ifdef CONFIG_ARC_CURR_IN_REG +unsigned long user_r25; +#endif #ifdef CONFIG_ARC_FPU_SAVE_RESTORE struct arc_fpu fpu;#endif
arch/arc/kernel/asm-offsets.c +3 -0
@@ -23,6 +23,9 @@ int main(void)DEFINE (THREAD_KSP , offsetof(struct thread_struct , ksp));DEFINE (THREAD_CALLEE_REG , offsetof(struct thread_struct , callee_reg)); +#ifdef CONFIG_ARC_CURR_IN_REG +DEFINE (THREAD_USER_R25 , offsetof(struct thread_struct , user_r25)); +#endif DEFINE (THREAD_FAULT_ADDR , offsetof(struct thread_struct , fault_address));
arch/arc/kernel/ctx_sw.c +7 -0
@@ -24,6 +24,9 @@ __switch_to(struct task_struct *prev_task, struct task_struct *next_task)unsigned int prev = (unsigned int )prev_task;unsigned int next = (unsigned int )next_task;int num_words_to_skip =1 ; +#ifdef CONFIG_ARC_CURR_IN_REG + num_words_to_skip++; +#endif __asm__ __volatile__(/* FP/BLINK save generated by gcc (standard function prologue */
@@ -39,7 +42,9 @@ __switch_to(struct task_struct *prev_task, struct task_struct *next_task) "st.a r22, [sp, -4] \n\t" "st.a r23, [sp, -4] \n\t" "st.a r24, [sp, -4] \n\t" +#ifndef CONFIG_ARC_CURR_IN_REG "st.a r25, [sp, -4] \n\t" +#endif"sub sp, sp, %4 \n\t" /* create gutter at top */ /* set ksp of outgoing task in tsk->thread.ksp */
@@ -62,7 +67,9 @@ __switch_to(struct task_struct *prev_task, struct task_struct *next_task) "add sp, sp, %4 \n\t" /* skip gutter at top */ +#ifndef CONFIG_ARC_CURR_IN_REG "ld.ab r25, [sp, 4] \n\t" +#endif"ld.ab r24, [sp, 4] \n\t" "ld.ab r23, [sp, 4] \n\t" "ld.ab r22, [sp, 4] \n\t"
arch/arc/kernel/entry.S +14 -0
@@ -32,6 +32,9 @@ * was being "CLEARED" rather then "SET". Since it is Loop INHIBIT Bit, * setting it and not clearing it clears ZOL context * + * Vineetg: May 16th, 2008 + * - r25 now contains the Current Task when in kernel + * * Vineetg: Dec 22, 2007 * Minor Surgery of Low Level ISR to make it SMP safe * - MMU_SCRATCH0 Reg used for freeing up r9 in Level 1 ISR
@@ -535,6 +538,17 @@ restore_regs : ; XXX can this be optimised out IRQ_DISABLE_SAVE r9, r10 ;@r10 has prisitine (pre-disable) copy +#ifdef CONFIG_ARC_CURR_IN_REG + ; Restore User R25 + ; Earlier this used to be only for returning to user mode + ; However with 2 levels of IRQ this can also happen even if + ; in kernel mode + ld r9, [sp, PT_sp] + brhs r9, VMALLOC_START, 8f + RESTORE_USER_R25 +8: +#endif + ; Restore REG File. In case multiple Events outstanding, ; use the same priorty as rtie: EXCPN, L2 IRQ, L1 IRQ, None ; Note that we use realtime STATUS32 (not pt_regs->status32) to
Signature · 1 line
1.7.4.1
PATCH v3 38/71 ARC: ptrace support
In reply to Vineet Gupta--- arch/arc/Kconfig | 1 + arch/arc/kernel/Makefile | 3 + arch/arc/kernel/entry.S | 68 +++++++++++++++++++++++ arch/arc/kernel/ptrace.c | 136 +++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 206 insertions(+), 2 deletions(-)
arch/arc/Kconfig +1 -0
@@ -22,6 +22,7 @@ config ARC select GENERIC_PENDING_IRQ if SMP select GENERIC_SIGALTSTACK select GENERIC_SMP_IDLE_THREAD + select HAVE_ARCH_TRACEHOOK select HAVE_GENERIC_HARDIRQS select HAVE_MEMBLOCK select IRQ_DOMAIN
arch/arc/kernel/Makefile +3 -0
@@ -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 obj-y += signal.o traps.o sys.o troubleshoot.o stacktrace.o clk.o
arch/arc/kernel/entry.S +68 -0
103 lines not on this page · raw message
arch/arc/kernel/ptrace.c +134 -2
151 lines not on this page · raw message
Signature · 1 line
1.7.4.1
PATCH v3 39/71 ARC: Futex support
In reply to 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
arch/arc/include/asm/futex.h new file +151 -0
@@ -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 preempt_disable() */ + +/* TBD : can use llock/scond */ + __asm__ __volatile__( +"1: ld %0, [%3] \n" +" brne %0, %1, 3f \n" +"2: st %2, [%3] \n" +"3: \n" +" .section .fixup,\"ax\" \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" (val) + :"r" (oldval),"r" (newval),"r" (uaddr),"ir" (-EFAULT ) + :"cc" ,"memory" ); + +pagefault_enable ();/* subsumes preempt_enable() */ + + *uval = val; +return val; +} + +#endif
Signature · 1 line
1.7.4.1
PATCH v3 40/71 ARC: OProfile support
In reply to 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
arch/arc/Kconfig +1 -0
@@ -25,6 +25,7 @@ config ARC select HAVE_ARCH_TRACEHOOK select HAVE_GENERIC_HARDIRQS select HAVE_MEMBLOCK + select HAVE_OPROFILE select IRQ_DOMAIN select MODULES_USE_ELF_RELA select NO_BOOTMEM
arch/arc/Makefile +2 -0
@@ -100,6 +100,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.
arch/arc/oprofile/Makefile new file +9 -0
@@ -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
arch/arc/oprofile/common.c new file +22 -0
@@ -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 <[email protected]> +*/ + +#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 (); +}
Signature · 1 line
1.7.4.1
Re: [PATCH v3 40/71] ARC: OProfile support
Hi Vineet,
Quoted 64 lines · Vineet Gupta
Signed-off-by Vineet Gupta <[email protected]>Cc Robert Richter <[email protected]>--- 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.carch/arc/Kconfig +1
-0@@ -25,6 +25,7 @@ config ARC select HAVE_ARCH_TRACEHOOK select HAVE_GENERIC_HARDIRQS select HAVE_MEMBLOCK + select HAVE_OPROFILE select IRQ_DOMAIN select MODULES_USE_ELF_RELA select NO_BOOTMEMarch/arc/Makefile +2
-0@@ -100,6 +100,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.arch/arc/oprofile/Makefile new file +9
-0@@ -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.oarch/arc/oprofile/common.c new file +6
-0@@ -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.
arch/arc/oprofile/common.c line 16
Quoted 10 lines
arch/arc/oprofile/common.c new file +10
-0+* +* Based on orig code from @author John Levon <[email protected]> +*/ + +#include <linux/oprofile.h> +#include <linux/perf_event.h> + +int __init oprofile_arch_init (struct oprofile_operations *ops) +{ +return oprofile_perf_init (ops);
You don't appear to define CONFIG_HW_PERF_EVENTS, so include/linux/oprofile.h will presumably define oprofile_perf_init as just a pr_info(...); return -ENODEV;
Similarly drivers/oprofile/oprofile_perf.o doesn't seem to be being built.
I'm probably missing something somewhere?
Cheers
James
Quoted 7 lines
arch/arc/oprofile/common.c new file +6
-0+} + +void oprofile_arch_exit (void ) +{ +oprofile_perf_exit (); +}
Re: [PATCH v3 40/71] ARC: OProfile support
Quoted 9 lines · James Hogan
Hi Vineet,
You don't appear to define
CONFIG_HW_PERF_EVENTS, soinclude/linux/oprofile.hwill presumably defineoprofile_perf_initas just apr_info(...); return-ENODEV;Similarly
drivers/oprofile/oprofile_perf.odoesn't seem to be being built.I'm probably missing something somewhere?
Not much :-)
oprofile_arch_init() failure causes oprofile to fall back to timer based PC only sampling - for coarse grained profiling. I'll soon be starting on integratign the hardware counter support to both oprofile/perf.
FWIW, I just re-verified that latest upstream OProfile works fine with 3.8 kernel.
[ARCLinux]$ uname -a
Linux ARCLinux 3.8.0-rc4+ #2 Wed Jan 30 11:13:21 IST 2013 arc GNU/Linux [ARCLinux]$ ./opcontrol -v
opcontrol: oprofile 0.9.9git compiled on Jan 30 2013 11:40:15 [ARCLinux]$ ./opcontrol --dump
[ARCLinux]$ ./opreport -l /mnt/arc/next-linux/vmlinux
Using /var/lib/oprofile/samples/ for samples directory.
CPU: CPU with timer interrupt
Profiling through timer interrupt
samples % symbol name 856 69.3679 cpu_idle 61 4.9433 arch_local_irq_enable
....
Thx for taking a look and if you are content - a Reviewed-by please (and for DeviceTree patch as well if that looks sane now). I'll start doing the same for metag patches after this one bug I'm debugging right now.
-Vineet
James Hogan
Reviewed-byRe: [PATCH v3 40/71] ARC: OProfile support
Quoted 9 lines · Vineet Gupta
Quoted 8 lines · James Hogan
Hi Vineet,
You don't appear to define
CONFIG_HW_PERF_EVENTS, soinclude/linux/oprofile.hwill presumably defineoprofile_perf_initas just apr_info(...); return-ENODEV;Similarly
drivers/oprofile/oprofile_perf.odoesn't seem to be being built.
Quoted 7 lines
Quoted 1 line
I'm probably missing something somewhere?
Not much :-)
oprofile_arch_init()failure causes oprofile to fall back to timer based PC only sampling - for coarse grained profiling. I'll soon be starting on integratign the hardware counter support to both oprofile/perf.
Okay cool. It's just slightly misleading for anybody copying the code that it calls oprofile_perf_init which is known never to do anything :-). Maybe it's worth adding a comment in there to clarify. If it's only temporary I'm fine with it.
Cheers
James
Re: [PATCH v3 40/71] ARC: OProfile support
Quoted 11 lines · James Hogan
Quoted 10 lines · Vineet Gupta
Quoted 9 lines · James Hogan
Hi Vineet,
You don't appear to define
CONFIG_HW_PERF_EVENTS, soinclude/linux/oprofile.hwill presumably defineoprofile_perf_initas just apr_info(...); return-ENODEV;Similarly
drivers/oprofile/oprofile_perf.odoesn't seem to be being built.I'm probably missing something somewhere?
Quoted 8 lines
Quoted 5 lines
Not much :-)
oprofile_arch_init()failure causes oprofile to fall back to timer based PC only sampling - for coarse grained profiling. I'll soon be starting on integratign the hardware counter support to both oprofile/perf.Okay cool. It's just slightly misleading for anybody copying the code that it calls
oprofile_perf_initwhich is known never to do anything :-). Maybe it's worth adding a comment in there to clarify.
I think banner comment in oprofile.h for oprofile_arch_init() needs to document that "in case it fails, oprofile switches to timer mode PC sampling". But nevertheless it's good idea to add that clarification in my code anyways.
Quoted 2 lines
Reviewed-by James Hogan <[email protected]>
Thx,
-Vineet
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_jan
PATCH v3 41/71 ARC: Support for high priority interrupts in the in-core intc
In reply to Vineet GuptaThere 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
--- arch/arc/Kconfig | 19 ++++++ 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 ++++++++++++++++++++++++++++++++++- 5 files changed, 339 insertions(+), 2 deletions(-)
arch/arc/Kconfig +19 -0
@@ -208,6 +208,25 @@ config ARC_PAGE_SIZE_4K endchoice +config ARC_COMPACT_IRQ_LEVELS + bool "ARCompact IRQ Priorities: High(2)/Low(1)" + default n + # Timer HAS to be high priority, for any other high priority config + select ARC_IRQ3_LV2 + +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
arch/arc/include/asm/entry.h +95 -0
119 lines not on this page · raw message
arch/arc/include/asm/irqflags.h +5 -1
@@ -95,7 +95,11 @@ static inline long arch_local_save_flags(void)*/ static inline int arch_irqs_disabled_flags (unsigned long flags) { -return !(flags & (STATUS_E1_MASK )); +return !(flags & (STATUS_E1_MASK +#ifdef CONFIG_ARC_COMPACT_IRQ_LEVELS + |STATUS_E2_MASK +#endif + )); }static inline int arch_irqs_disabled (void )
arch/arc/kernel/entry.S +117 -0
154 lines not on this page · raw message
arch/arc/kernel/irq.c +103 -1
128 lines not on this page · raw message
Signature · 1 line
1.7.4.1
PATCH v3 43/71 ARC: Diagnostics: show_regs() etc
In reply to Vineet Gupta--- arch/arc/kernel/troubleshoot.c | 305 ++++++++++++++++++++++++++++++++++++++++ arch/arc/mm/tlbex.S | 20 +++ 2 files changed, 325 insertions(+), 0 deletions(-)
arch/arc/kernel/troubleshoot.c +305 -0
@@ -6,12 +6,317 @@*/ #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> + +/* +* 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 *tsk,char *buf) +{ +struct path path; +char *path_nm =NULL ; +struct mm_struct *mm; +struct file *exe_file; + + mm =get_task_mm (tsk); +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); + path_nm =d_path (&path, buf,255 ); +path_put (&path); + } + +done: +pr_info ("%s, TGID %u\n" , path_nm, tsk->tgid); +} +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" ); +else if (cause_code ==ECR_C_PROTV_XCHG ) +pr_cont ("Data exchange protection violation\n" ); +else if (cause_code ==ECR_C_PROTV_MISALIG_DATA ) +pr_cont ("Misaligned r/w from 0x%08lx\n" , address); + }else if (vec ==ECR_V_INSN_ERR ) { +pr_cont ("Illegal Insn\n" ); + }else { +pr_cont ("Check Programmer's Manual\n" ); + } +} + +/************************************************************************ +* API called by rest of kernel +***********************************************************************/ void show_regs (struct pt_regs *regs) { +struct task_struct *tsk = current; +struct callee_regs *cregs; +char *buf; + + buf = (char *)__get_free_page (GFP_TEMPORARY ); +if (!buf) +return ; + +print_task_path_n_nm (tsk, buf); + +if (current->thread.cause_code) +show_ecr_verbose (regs); + +pr_info ("[EFA]: 0x%08lx\n" , current->thread.fault_address); +pr_info ("[ERET]: 0x%08lx (PC of Faulting Instr)\n" , regs->ret); + +show_faulting_vma (regs->ret, buf);/* faulting code, not data */ + +/* can't use print_vma_addr() yet as it doesn't check for +* non-inclusive vma +*/ + +/* print special regs */ +pr_info ("status32: 0x%08lx\n" , regs->status32); +pr_info (" SP: 0x%08lx\tFP: 0x%08lx\n" , regs->sp, regs->fp); +pr_info ("BTA: 0x%08lx\tBLINK: 0x%08lx\n" , + regs->bta, regs->blink); +pr_info ("LPS: 0x%08lx\tLPE: 0x%08lx\tLPC: 0x%08lx\n" , + regs->lp_start, regs->lp_end, regs->lp_count); + +/* print regs->r0 thru regs->r12 +* Sequential printing was generating horrible code +*/ +print_reg_file (&(regs->r0),0 ); + +/* If Callee regs were saved, display them too */ + cregs = (struct callee_regs *)current->thread.callee_reg; +if (cregs) +show_callee_regs (cregs); + +free_page ((unsigned long )buf); }void show_kernel_fault_diag (const char *str,struct pt_regs *regs,unsigned long address,unsigned long cause_reg) { + current->thread.fault_address = address; + current->thread.cause_code = cause_reg; + +/* Caller and Callee regs */ +show_regs (regs); + +/* Show stack trace if this Fatality happened in kernel mode */ +if (!user_mode (regs)) +show_stacktrace (current, regs); } + +#ifdef CONFIG_DEBUG_FS + +#include <linux/module.h> +#include <linux/fs.h> +#include <linux/mount.h> +#include <linux/pagemap.h> +#include <linux/init.h> +#include <linux/namei.h> +#include <linux/debugfs.h> + +static struct dentry *test_dentry; +static struct dentry *test_dir; +static struct dentry *test_u32_dentry; + +static u32 clr_on_read =1 ; + +#ifdef CONFIG_ARC_DBG_TLB_MISS_COUNT +u32 numitlb, numdtlb, num_pte_not_present; + +static int fill_display_data (char *kbuf) +{ +size_t num =0 ; + num +=sprintf (kbuf + num,"I-TLB Miss %x\n" , numitlb); + num +=sprintf (kbuf + num,"D-TLB Miss %x\n" , numdtlb); + num +=sprintf (kbuf + num,"PTE not present %x\n" , num_pte_not_present); + +if (clr_on_read) + numitlb = numdtlb = num_pte_not_present =0 ; + +return num; +} + +static int tlb_stats_open (struct inode *inode,struct file *file) +{ + file->private_data = (void *)__get_free_page (GFP_KERNEL ); +return 0 ; +} + +/* called on user read(): display the couters */ +static ssize_t tlb_stats_output (struct file *file,/* file descriptor */ +char __user *user_buf,/* user buffer */ +size_t len,/* length of buffer */ +loff_t *offset)/* offset in the file */ +{ +size_t num; +char *kbuf = (char *)file->private_data; + +/* All of the data can he shoved in one iteration */ +if (*offset !=0 ) +return 0 ; + + num =fill_display_data (kbuf); + +/* simple_read_from_buffer() is helper for copy to user space +It copies up to @2 (num) bytes from kernel buffer @4 (kbuf) at offset +@3 (offset) into the user space address starting at @1 (user_buf). +@5 (len) is max size of user buffer +*/ +return simple_read_from_buffer (user_buf, num, offset, kbuf, len); +} + +/* called on user write : clears the counters */ +static ssize_t tlb_stats_clear (struct file *file,const char __user *user_buf, +size_t length,loff_t *offset) +{ + numitlb = numdtlb = num_pte_not_present =0 ; +return length; +} + +static int tlb_stats_close (struct inode *inode,struct file *file) +{ +free_page ((unsigned long )(file->private_data)); +return 0 ; +} + +static const struct file_operations tlb_stats_file_ops = { + .read = tlb_stats_output, + .write = tlb_stats_clear, + .open = tlb_stats_open, + .release = tlb_stats_close +}; +#endif + +static int __init arc_debugfs_init (void ) +{ + test_dir =debugfs_create_dir ("arc" ,NULL ); + +#ifdef CONFIG_ARC_DBG_TLB_MISS_COUNT + test_dentry =debugfs_create_file ("tlb_stats" ,0444 , test_dir,NULL , + &tlb_stats_file_ops); +#endif + + test_u32_dentry = +debugfs_create_u32 ("clr_on_read" ,0444 , test_dir, &clr_on_read); + +return 0 ; +} + +module_init (arc_debugfs_init); + +static void __exit arc_debugfs_exit(void) +{ +debugfs_remove (test_u32_dentry); +debugfs_remove (test_dentry); +debugfs_remove (test_dir); +} +module_exit (arc_debugfs_exit); + +#endif
arch/arc/mm/tlbex.S +20 -0
@@ -133,6 +133,14 @@ ex_saved_reg1: lsr r0, r2, (PAGE_SHIFT - 2) and r0, r0, ( (PTRS_PER_PTE - 1) << 2) ld.aw r0, [r1, r0] ; get PTE and PTE ptr for fault addr +#ifdef CONFIG_ARC_DBG_TLB_MISS_COUNT + and.f 0, r0, _PAGE_PRESENT + bz 1f + ld r2, [num_pte_not_present] + add r2, r2, 1 + st r2, [num_pte_not_present] +1: +#endif .endm
@@ -219,6 +227,12 @@ ARC_ENTRY EV_TLBMissI TLBMISS_FREEUP_REGS +#ifdef CONFIG_ARC_DBG_TLB_MISS_COUNT + ld r0, [@numitlb] + add r0, r0, 1 + st r0, [@numitlb] +#endif + ;---------------------------------------------------------------- ; Get the PTE corresponding to V-addr accessed LOAD_FAULT_PTE
@@ -252,6 +266,12 @@ ARC_ENTRY EV_TLBMissD TLBMISS_FREEUP_REGS +#ifdef CONFIG_ARC_DBG_TLB_MISS_COUNT + ld r0, [@numdtlb] + add r0, r0, 1 + st r0, [@numdtlb] +#endif + ;---------------------------------------------------------------- ; Get the PTE corresponding to V-addr accessed ; If PTE exists, it will setup, r0 = PTE, r1 = Ptr to PTE
Signature · 1 line
1.7.4.1
PATCH v3 46/71 ARC: stacktracing APIs based on dw2 unwinder
In reply to Vineet Gupta--- arch/arc/Kconfig | 4 + arch/arc/kernel/stacktrace.c | 215 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 217 insertions(+), 2 deletions(-)
arch/arc/Kconfig +4 -0
@@ -60,6 +60,10 @@ config GENERIC_HWEIGHT config BINFMT_ELF def_bool y +config STACKTRACE_SUPPORT + def_bool y + select STACKTRACE + config HAVE_LATENCYTOP_SUPPORT def_bool y
arch/arc/kernel/stacktrace.c +213 -2
238 lines not on this page · raw message
Signature · 1 line
1.7.4.1
PATCH v3 47/71 ARC: disassembly (needed by kprobes/kgdb/unaligned-access-emul)
In reply to Vineet GuptaIn-kernel disassembler
Due Credits
* Orig written by Rajeshwar Ranga <[email protected]>
* Consolidation/cleanups by Mischa Jonker <[email protected]>
--- 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
arch/arc/include/asm/disasm.h new file +116 -0
@@ -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<<n)) +#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 0x00000100 +#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 |= (0xffffffff << 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 callee_regs *cregs); +int disasm_next_pc (unsigned long pc,struct pt_regs *regs,struct callee_regs + *cregs,unsigned long *fall_thru,unsigned long *target); +long get_reg (int reg,struct pt_regs *regs,struct callee_regs *cregs); +void set_reg (int reg,long val,struct pt_regs *regs, +struct callee_regs *cregs); + +#endif /* __ARC_DISASM_H__ */
arch/arc/kernel/Makefile +1 -1
@@ -9,7 +9,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 -obj-y += signal.o traps.o sys.o troubleshoot.o stacktrace.o clk.o +obj-y += signal.o traps.o sys.o troubleshoot.o stacktrace.o disasm.o clk.o obj-$(CONFIG_OF) += devtree.o obj-$(CONFIG_MODULES) += arcksyms.o module.o
arch/arc/kernel/disasm.c new file +539 -0
539 lines not on this page · raw message
Signature · 1 line
1.7.4.1
PATCH v3 49/71 sysctl: Enable PARISC "unaligned-trap" to be used cross-arch
In reply to Vineet GuptaPARISC defines /proc/sys/kernel/unaligned-trap to runtime toggle unaligned access emulation.
The exact mechanics of enablig/disabling are still arch specific, we can make the sysctl usable by other arches.
--- arch/parisc/Kconfig | 1 + init/Kconfig | 8 ++++++++ kernel/sysctl.c | 5 +++++ 3 files changed, 14 insertions(+), 0 deletions(-)
arch/parisc/Kconfig +1 -0
@@ -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 select CLONE_BACKWARDS
init/Kconfig +8 -0
@@ -1232,6 +1232,14 @@ config SYSCTL_EXCEPTION_TRACE help Enable support for /proc/sys/debug/exception-trace. +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
kernel/sysctl.c +5 -0
@@ -157,6 +157,9 @@ extern int sysctl_tsb_ratio;#ifdef __hppa__extern int pwrsw_enabled; +#endif + +#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW extern int unaligned_enabled;#endif
@@ -545,6 +548,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,
Signature · 1 line
1.7.4.1
PATCH v3 50/71 ARC: Unaligned access emulation
In reply to Vineet GuptaARC700 doesn't natively support unaligned access, but can be emulated -Unaligned Access Exception
-Disassembly at the Fault address to find the exact insn (long/short)
Also per Arnd's comment, we runtime control it using 2 sysctl knobs:
* SYSCTL_ARCH_UNALIGN_ALLOW: Runtime enable/disble
* SYSCTL_ARCH_UNALIGN_NO_WARN: Warn on each emulation attempt
Originally contributed by Tim Yao <[email protected]>
--- arch/arc/Kconfig | 11 ++ arch/arc/include/asm/Kbuild | 1 - arch/arc/include/asm/ptrace.h | 3 + arch/arc/include/asm/unaligned.h | 29 +++++ arch/arc/kernel/Makefile | 1 + arch/arc/kernel/disasm.c | 2 +- arch/arc/kernel/entry.S | 13 ++ arch/arc/kernel/traps.c | 26 ++++ arch/arc/kernel/unaligned.c | 245 ++++++++++++++++++++++++++++++++++++++ 9 files changed, 329 insertions(+), 2 deletions(-) create mode 100644 arch/arc/include/asm/unaligned.h create mode 100644 arch/arc/kernel/unaligned.c
arch/arc/Kconfig +11 -0
@@ -336,6 +336,17 @@ 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 + select SYSCTL_ARCH_UNALIGN_NO_WARN + select SYSCTL_ARCH_UNALIGN_ALLOW + 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
arch/arc/include/asm/Kbuild +0 -1
@@ -52,7 +52,6 @@ generic-y += topology.h generic-y += trace_clock.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
arch/arc/include/asm/ptrace.h +3 -0
@@ -132,6 +132,9 @@ struct user_regs_struct { sp; \ }) +/* return 1 if PC in delay slot */ +#define delay_mode (regs) ((regs->status32 & STATUS_DE_MASK) == STATUS_DE_MASK) +#define in_syscall (regs) (regs->event & orig_r8_IS_SCALL)#define in_brkpt_trap (regs) (regs->event & orig_r8_IS_BRKPT)
arch/arc/include/asm/unaligned.h new file +29 -0
@@ -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 */
arch/arc/kernel/Makefile +1 -0
@@ -16,6 +16,7 @@ obj-$(CONFIG_MODULES) += arcksyms.o module.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
arch/arc/kernel/disasm.c +1 -1
@@ -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
arch/arc/kernel/entry.S +13 -0
@@ -7,6 +7,9 @@ * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * + * vineetg: May 2011 + * -Userspace unaligned access emulation + * * 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.
@@ -387,7 +390,17 @@ ARC_ENTRY EV_TLBProtV mov r1, r4 ; faulting address mov r2, sp ; pt_regs +#ifdef CONFIG_ARC_MISALIGN_ACCESS + SAVE_CALLEE_SAVED_USER + mov r3, sp ; callee_regs +#endif + bl do_misaligned_access + +#ifdef CONFIG_ARC_MISALIGN_ACCESS + DISCARD_CALLEE_SAVED_USER +#endif + b ret_from_exception ARC_EXIT EV_TLBProtV
arch/arc/kernel/traps.c +26 -0
@@ -7,6 +7,9 @@* it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * +* vineetg: May 2011 +* -user-space unaligned access emulation +* * Rahul Trivedi: Codito Technologies 2004 */
@@ -16,6 +19,7 @@#include <asm/ptrace.h> #include <asm/setup.h> #include <asm/kprobes.h> +#include <asm/unaligned.h> void __init trap_init (void ) {
@@ -79,7 +83,29 @@ DO_ERROR_INFO(SIGILL, "Illegal Insn (or Seq)", insterror_is_error, ILL_ILLOPC) DO_ERROR_INFO(SIGBUS, "Invalid Mem Access", do_memory_error, BUS_ADRERR) DO_ERROR_INFO(SIGTRAP, "Breakpoint Set", trap_is_brkpt, TRAP_BRKPT) +#ifdef CONFIG_ARC_MISALIGN_ACCESS +/* +* Entry Point for Misaligned Data access Exception, for emulating in software +*/ +int do_misaligned_access (unsigned long cause,unsigned long address, +struct pt_regs *regs,struct callee_regs *cregs) +{ +if (misaligned_fixup (address, regs, cause, cregs) !=0 ) { +siginfo_t info; + + info.si_signo =SIGBUS ; + info.si_errno =0 ; + info.si_code =BUS_ADRALN ; + info.si_addr = (void __user *)address; +return handle_exception (cause,"Misaligned Access" , regs, + &info); + } +return 0 ; +} + +#else DO_ERROR_INFO(SIGSEGV, "Misaligned Access", do_misaligned_access, SEGV_ACCERR) +#endif /* * Entry point for miscll errors such as Nested Exceptions
arch/arc/kernel/unaligned.c new file +245 -0
245 lines not on this page · raw message
Signature · 1 line
1.7.4.1
PATCH v3 51/71 ARC: kgdb support
In reply to Vineet GuptaFrom: Mischa Jonker <[email protected]>
--- arch/arc/Kconfig | 3 +- arch/arc/include/asm/kgdb.h | 61 +++++++++++++ arch/arc/kernel/Makefile | 1 + arch/arc/kernel/kgdb.c | 205 +++++++++++++++++++++++++++++++++++++++++++ arch/arc/kernel/traps.c | 6 ++ 5 files changed, 275 insertions(+), 1 deletions(-) create mode 100644 arch/arc/include/asm/kgdb.h create mode 100644 arch/arc/kernel/kgdb.c
arch/arc/Kconfig +2 -1
@@ -22,6 +22,7 @@ config ARC select GENERIC_PENDING_IRQ if SMP select GENERIC_SIGALTSTACK select GENERIC_SMP_IDLE_THREAD + select HAVE_ARCH_KGDB select HAVE_ARCH_TRACEHOOK select HAVE_GENERIC_HARDIRQS select HAVE_KPROBES
@@ -378,7 +379,7 @@ 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_TLB_MISS_COUNT
arch/arc/include/asm/kgdb.h new file +61 -0
61 lines not on this page · raw message
arch/arc/kernel/Makefile +1 -0
@@ -17,6 +17,7 @@ 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
arch/arc/kernel/kgdb.c new file +205 -0
205 lines not on this page · raw message
arch/arc/kernel/traps.c +6 -0
@@ -20,6 +20,7 @@#include <asm/setup.h> #include <asm/kprobes.h> #include <asm/unaligned.h> +#include <asm/kgdb.h> void __init trap_init (void ) {
@@ -141,6 +142,11 @@ void do_non_swi_trap(unsigned long cause, unsigned long address,trap_is_kprobe (param, address, regs);break ; +case 3 : +case 4 : +kgdb_trap (regs, param); +break ; +default :break ; }
Signature · 1 line
1.7.4.1
PATCH v3 52/71 ARC: Boot #2: Verbose Boot reporting / feature verification
In reply to 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
arch/arc/Makefile +2 -0
@@ -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
arch/arc/include/asm/arcregs.h +112 -10
163 lines not on this page · raw message
arch/arc/include/asm/defines.h new file +56 -0
56 lines not on this page · raw message
arch/arc/include/asm/setup.h +14 -0
@@ -13,6 +13,20 @@#define COMMAND_LINE_SIZE 256 +/* +* Data structure to map a ID to string +* Used a lot for bootup reporting of hardware diversity +*/ +struct id_to_str { +int id; +const char *str; +}; + +struct cpuinfo_data { +struct id_to_str info; +int up_range; +}; +extern int root_mountflags, end_mem;extern int running_on_hw;
arch/arc/kernel/setup.c +222 -1
260 lines not on this page · raw message
arch/arc/mm/cache_arc700.c +46 -0
68 lines not on this page · raw message
arch/arc/mm/tlb.c +38 -0
@@ -463,8 +463,46 @@ void __init read_decode_mmu_bcr(void) mmu->num_tlb = mmu->sets * mmu->ways; } +char *arc_mmu_mumbojumbo (int cpu_id,char *buf,int len) +{ +int n =0 ; +struct cpuinfo_arc_mmu *p_mmu = &cpuinfo_arc700[smp_processor_id ()].mmu; + + n +=scnprintf (buf + n, len - n,"ARC700 MMU [v%x]\t: %dk PAGE, " , + p_mmu->ver,TO_KB (p_mmu->pg_sz)); + + n +=scnprintf (buf + n, len - n, +"J-TLB %d (%dx%d), uDTLB %d, uITLB %d, %s\n" , + p_mmu->num_tlb, p_mmu->sets, p_mmu->ways, + p_mmu->u_dtlb, p_mmu->u_itlb, + __CONFIG_ARC_MMU_SASID_VAL ?"SASID" :"" ); + +return buf; +} +void __init arc_mmu_init (void ) { +char str[256 ]; +struct cpuinfo_arc_mmu *mmu = &cpuinfo_arc700[smp_processor_id ()].mmu; + +printk (arc_mmu_mumbojumbo (0 , str,sizeof (str))); + +/* For efficiency sake, kernel is compile time built for a MMU ver +* This must match the hardware it is running on. +* Linux built for MMU V2, if run on MMU V1 will break down because V1 +* hardware doesn't understand cmds such as WriteNI, or IVUTLB +* On the other hand, Linux built for V1 if run on MMU V2 will do +* un-needed workarounds to prevent memcpy thrashing. +* Similarly MMU V3 has new features which won't work on older MMU +*/ +if (mmu->ver !=CONFIG_ARC_MMU_VER ) { +panic ("MMU ver %d doesn't match kernel built for %d...\n" , + mmu->ver,CONFIG_ARC_MMU_VER ); + } + +if (mmu->pg_sz !=PAGE_SIZE ) +panic ("MMU pg size != PAGE_SIZE (%luk)\n" ,TO_KB (PAGE_SIZE )); +/* * ASID mgmt data structures are compile time init * asid_cache = FIRST_ASID and asid_mm_map[] all zeroes
Signature · 1 line
1.7.4.1
PATCH v3 53/71 ARC: [plat-arfpga] BVCI Latency Unit setup
In reply to Vineet Gupta--- arch/arc/plat-arcfpga/Kconfig | 32 +++++++++++++++++++++ arch/arc/plat-arcfpga/platform.c | 56 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 0 deletions(-)
arch/arc/plat-arcfpga/Kconfig +32 -0
@@ -44,4 +44,36 @@ config ARC_SERIAL_BAUD help Baud rate for the ARC UART +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
arch/arc/plat-arcfpga/platform.c +56 -0
74 lines not on this page · raw message
Signature · 1 line
1.7.4.1
PATCH v3 54/71 perf, ARC: Enable building perf tools for ARC
In reply to Vineet GuptaAlthough with uClibc there's more we need to do
--- tools/perf/perf.h | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
tools/perf/perf.h +6 -0
@@ -98,6 +98,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>
Signature · 1 line
1.7.4.1
PATCH v3 55/71 ARC: perf support (software counters only)
In reply to Vineet Gupta--- arch/arc/Kconfig | 3 +++ arch/arc/include/asm/perf_event.h | 13 +++++++++++++ 2 files changed, 16 insertions(+), 0 deletions(-) create mode 100644 arch/arc/include/asm/perf_event.h
arch/arc/Kconfig +3 -0
@@ -25,16 +25,19 @@ 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_MEMBLOCK select HAVE_MOD_ARCH_SPECIFIC if ARC_DW2_UNWIND select HAVE_OPROFILE + select HAVE_PERF_EVENTS select IRQ_DOMAIN select MODULES_USE_ELF_RELA select NO_BOOTMEM select OF select OF_EARLY_FLATTREE + select PERF_USE_VMALLOC config SCHED_OMIT_FRAME_POINTER def_bool y
arch/arc/include/asm/perf_event.h new file +13 -0
@@ -0,0 +1,13 @@ +/* +* 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 + +#endif /* __ASM_PERF_EVENT_H */
Signature · 1 line
1.7.4.1
PATCH v3 56/71 ARC: Support for single cycle Close Coupled Mem (CCM)
In reply to 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
--- 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(-)
arch/arc/Kconfig +27 -0
@@ -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 "0xA0000000" + depends on ARC_HAS_DCCM + config ARC_HAS_HW_MPY bool "Use Hardware Multiplier (Normal or Faster XMAC)" default y
arch/arc/include/asm/linkage.h +33 -0
@@ -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
arch/arc/kernel/entry.S +2 -2
@@ -149,7 +149,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
@@ -159,7 +159,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:
arch/arc/kernel/setup.c +52 -1
71 lines not on this page · raw message
arch/arc/kernel/vmlinux.lds.S +21 -0
@@ -23,6 +23,12 @@ jiffies = jiffies_64; SECTIONS { + /* + * ICCM starts at 0x8000_0000. So if kernel is relocated to some other + * address, make sure peripheral at 0x8z doesn't clash with ICCM + * Essentially vector is also in ICCM. + */ + . = CONFIG_LINUX_LINK_BASE; _int_vec_base_lds = .;
@@ -31,6 +37,13 @@ SECTIONS . = ALIGN(PAGE_SIZE); } +#ifdef CONFIG_ARC_HAS_ICCM + .text.arcfp : { + *(.text.arcfp) + . = ALIGN(CONFIG_ARC_ICCM_SZ * 1024); + } +#endif + /* * The reason for having a seperate subsection .init.ramfs is to * prevent objump from including it in kernel dumps
@@ -134,4 +147,12 @@ SECTIONS .debug_loc 0 : { *(.debug_loc) } .debug_macinfo 0 : { *(.debug_macinfo) } +#ifdef CONFIG_ARC_HAS_DCCM + . = CONFIG_ARC_DCCM_BASE; + __arc_dccm_base = .; + .data.arcfp : { + *(.data.arcfp) + } + . = ALIGN(CONFIG_ARC_DCCM_SZ * 1024); +#endif }
arch/arc/mm/tlbex.S +2 -3
@@ -53,8 +53,7 @@ ; For details refer to comments before TLBMISS_FREEUP_REGS below ;-------------------------------------------------------------------------- - .section .data - .global ex_saved_reg1 +ARCFP_DATA ex_saved_reg1 .align 1 << L1_CACHE_SHIFT ; IMP: Must be Cache Line aligned .type ex_saved_reg1, @object #ifdef CONFIG_SMP
@@ -255,7 +254,7 @@ ex_saved_reg1: #endif .endm -.section .text, "ax",@progbits ;Fast Path Code, candidate for ICCM +ARCFP_CODE ;Fast Path Code, candidate for ICCM ;----------------------------------------------------------------------------- ; I-TLB Miss Exception Handler
Signature · 1 line
1.7.4.1
PATCH v3 60/71 ARC: [Review] Multi-platform image #1: Kconfig enablement
In reply to Vineet GuptaThis mini patchseries addresses the lack of multi-platform-image support in ARC port.
Older build system only supported one platform(soc) to build at a time and further only one board of that platform could be built. There was no technical reason for that - we just didn't have the need.
So the first step towards multi-platform (and multi-board) builds it to allow build system to do that.
So as applicable, <choice .. endchoice> => <menu .. endmenu>
--- arch/arc/Kconfig | 6 ++---- arch/arc/plat-arcfpga/Kconfig | 5 ++--- 2 files changed, 4 insertions(+), 7 deletions(-)
arch/arc/Kconfig +2 -4
@@ -82,9 +82,7 @@ source "kernel/Kconfig.freezer" menu "ARC Architecture Configuration" -choice - prompt "ARC Platform" - default ARC_PLAT_FPGA_LEGACY +menu "ARC Platform/SoC" config ARC_PLAT_FPGA_LEGACY bool "\"Legacy\" ARC FPGA dev platform"
@@ -96,7 +94,7 @@ config ARC_PLAT_FPGA_LEGACY - MetaWare ISS #New platform adds here -endchoice +endmenu menu "ARC CPU Configuration"
arch/arc/plat-arcfpga/Kconfig +2 -3
@@ -8,8 +8,7 @@ if ARC_PLAT_FPGA_LEGACY -choice - prompt "FPGA Board" +menu "FPGA Board" config ARC_BOARD_ANGEL4 bool "ARC Angel4"
@@ -35,7 +34,7 @@ config ISS_SMP_EXTN -XTL (To enable CPU start/stop/set-PC for another CPU) It doesn't provide coherent Caches and/or Atomic Ops (LLOCK/SCOND) -endchoice +endmenu config ARC_SERIAL_BAUD int "UART Baud rate"
Signature · 1 line
1.7.4.1
PATCH v3 61/71 ARC: Fold boards sub-menu into platform/SoC menu
In reply to Vineet GuptaThis is more natural and is now doable since the choice constructs are gone.
--- arch/arc/Kconfig | 21 +++------------------ arch/arc/plat-arcfpga/Kconfig | 14 ++++++++++---- 2 files changed, 13 insertions(+), 22 deletions(-)
arch/arc/Kconfig +3 -18
@@ -82,18 +82,11 @@ source "kernel/Kconfig.freezer" menu "ARC Architecture Configuration" -menu "ARC Platform/SoC" - -config ARC_PLAT_FPGA_LEGACY - bool "\"Legacy\" ARC FPGA dev platform" - help - Support for ARC development platforms, provided by Synopsys. - These are based on FPGA or ISS. e.g. - - ARCAngel4 - - ML509 - - MetaWare ISS +menu "ARC Platform/SoC/Board" +source "arch/arc/plat-arcfpga/Kconfig" #New platform adds here + endmenu menu "ARC CPU Configuration"
@@ -338,12 +331,6 @@ config ARC_HAS_RTSC endmenu # "ARC CPU Configuration" -menu "Platform Board Configuration" - -source "arch/arc/plat-arcfpga/Kconfig" - -#New platform adds here - config LINUX_LINK_BASE hex "Linux Link Address" default "0x80000000"
@@ -357,8 +344,6 @@ config LINUX_LINK_BASE Linux needs to be scooted a bit. If you don't know what the above means, leave this setting alone. -endmenu # "Platform Board Configuration" - config ARC_CURR_IN_REG bool "Dedicate Register r25 for current_task pointer" default y
arch/arc/plat-arcfpga/Kconfig +10 -4
@@ -6,13 +6,21 @@ # published by the Free Software Foundation. # -if ARC_PLAT_FPGA_LEGACY +menuconfig ARC_PLAT_FPGA_LEGACY + bool "\"Legacy\" ARC FPGA dev Boards" + help + Support for ARC development boards, provided by Synopsys. + These are based on FPGA or ISS. e.g. + - ARCAngel4 + - ML509 + - MetaWare ISS -menu "FPGA Board" +if ARC_PLAT_FPGA_LEGACY config ARC_BOARD_ANGEL4 bool "ARC Angel4" select ISS_SMP_EXTN if SMP + default y help ARC Angel4 FPGA Ref Platform (Xilinx Virtex Based)
@@ -34,8 +42,6 @@ config ISS_SMP_EXTN -XTL (To enable CPU start/stop/set-PC for another CPU) It doesn't provide coherent Caches and/or Atomic Ops (LLOCK/SCOND) -endmenu - config ARC_SERIAL_BAUD int "UART Baud rate" default "115200"
Signature · 1 line
1.7.4.1
PATCH v3 63/71 ARC: [Review] Multi-platform image #3: switch to board callback
In reply to Vineet Gupta-platform API is retired and instead callbacks are used
--- arch/arc/include/asm/irq.h | 1 - arch/arc/include/asm/smp.h | 5 --- arch/arc/kernel/irq.c | 2 - arch/arc/kernel/setup.c | 5 --- arch/arc/kernel/smp.c | 1 - arch/arc/plat-arcfpga/include/plat/irq.h | 2 + arch/arc/plat-arcfpga/include/plat/smp.h | 2 + arch/arc/plat-arcfpga/irq.c | 2 +- arch/arc/plat-arcfpga/platform.c | 50 +++++++++++++++++++++++++----- arch/arc/plat-arcfpga/smp.c | 4 +-- 10 files changed, 48 insertions(+), 26 deletions(-)
arch/arc/include/asm/irq.h +0 -1
@@ -17,7 +17,6 @@#include <asm-generic/irq.h> extern void __init arc_init_IRQ (void ); -extern void __init plat_init_IRQ (void );extern int __init get_hw_config_num_irq (void );void __cpuinit arc_local_timer_setup (unsigned int cpu);
arch/arc/include/asm/smp.h +0 -5
@@ -46,10 +46,6 @@ extern int smp_ipi_irq_setup(int cpu, int irq);* arc_platform_smp_cpuinfo: * returns a string containing info for /proc/cpuinfo * -* arc_platform_smp_init_cpu: -* Called from start_kernel_secondary to do any CPU local setup -* such as starting a timer, setting up IPI etc -* * arc_platform_smp_wait_to_boot: * Called from early bootup code for non-Master CPUs to "park" them *
@@ -64,7 +60,6 @@ extern int smp_ipi_irq_setup(int cpu, int irq);* Takes @cpu which got IPI at @irq to do any IPI clearing */ extern const char *arc_platform_smp_cpuinfo (void ); -extern void arc_platform_smp_init_cpu (void );extern void arc_platform_smp_wait_to_boot (int cpu);extern void arc_platform_smp_wakeup_cpu (int cpu,unsigned long pc);extern void arc_platform_ipi_send (const struct cpumask *callmap);
arch/arc/kernel/irq.c +0 -2
@@ -124,7 +124,6 @@ void __init init_onchip_IRQ(void)void __init init_IRQ (void ) {init_onchip_IRQ (); -plat_init_IRQ ();/* Any external intc can be setup here */ if (machine_desc->init_irq)
@@ -132,7 +131,6 @@ void __init init_IRQ(void)#ifdef CONFIG_SMP /* Master CPU can initialize it's side of IPI */ -arc_platform_smp_init_cpu ();if (machine_desc->init_smp) machine_desc->init_smp (smp_processor_id ());#endif
arch/arc/kernel/setup.c +0 -5
@@ -319,10 +319,6 @@ void __init setup_processor(void)arc_chk_fpu (); } -void __init __attribute__((weak))arc_platform_early_init (void ) -{ -} -void __init setup_arch (char **cmdline_p) {#ifdef CONFIG_CMDLINE_UBOOT
@@ -347,7 +343,6 @@ void __init setup_arch(char **cmdline_p)parse_early_param ();/* Platform/board specific: e.g. early console registration */ -arc_platform_early_init ();if (machine_desc->init_early) machine_desc->init_early ();
arch/arc/kernel/smp.c +0 -1
@@ -127,7 +127,6 @@ void __cpuinit start_kernel_secondary(void)pr_info ("## CPU%u LIVE ##: Executing Code...\n" , cpu); -arc_platform_smp_init_cpu ();if (machine_desc->init_smp) machine_desc->init_smp (smp_processor_id ());
arch/arc/plat-arcfpga/include/plat/irq.h +2 -0
@@ -32,4 +32,6 @@#define IDU_INTERRUPT_0 16#endif +extern void __init plat_fpga_init_IRQ (void ); +#endif
arch/arc/plat-arcfpga/include/plat/smp.h +2 -0
@@ -110,6 +110,8 @@ struct idu_irq_status {extern void idu_irq_set_tgtcpu (uint8_t irq,uint32_t mask);extern void idu_irq_set_mode (uint8_t irq,uint8_t dest_mode,uint8_t trig_mode); +extern void iss_model_init_smp (unsigned int cpu); +#endif /* CONFIG_SMP */ #endif
arch/arc/plat-arcfpga/irq.c +1 -1
@@ -11,7 +11,7 @@#include <linux/interrupt.h> #include <asm/irq.h> -void __init plat_init_IRQ (void ) +void __init plat_fpga_init_IRQ (void ) {/* * SMP Hack because UART IRQ hardwired to cpu0 (boot-cpu) but if the
arch/arc/plat-arcfpga/platform.c +42 -8
73 lines not on this page · raw message
arch/arc/plat-arcfpga/smp.c +1 -3
@@ -63,10 +63,8 @@ void arc_platform_smp_wakeup_cpu(int cpu, unsigned long pc)* -Master : init_IRQ() * -Other(s) : start_kernel_secondary() */ -void arc_platform_smp_init_cpu (void ) +void iss_model_init_smp (unsigned int cpu) { -int cpu =smp_processor_id (); -/* Check if CPU is configured for more than 16 interrupts */ if (NR_IRQS <=16 ||get_hw_config_num_irq () <=16 )panic ("[arcfpga] IRQ system can't support IDU IPI\n" );
Signature · 1 line
1.7.4.1
PATCH v3 64/71 ARC: [Review] Multi-platform image #4: Isolate platform headers
In reply to Vineet Gupta-Top level ARC makefile removes -I for platform headers -asm/irq.h no longer includes plat/irq.h
-platform makefile adds -I for it's specfic platform headers -platform code to directly include it's plat/irq.h
-Linker script needed plat/memmap.h for CCM info, already in .config
--- arch/arc/Makefile | 16 +--------------- arch/arc/include/asm/irq.h | 1 - arch/arc/kernel/vmlinux.lds.S | 1 - arch/arc/plat-arcfpga/Makefile | 2 ++ arch/arc/plat-arcfpga/irq.c | 2 +- arch/arc/plat-arcfpga/platform.c | 2 +- arch/arc/plat-arcfpga/smp.c | 3 ++- 7 files changed, 7 insertions(+), 20 deletions(-)
arch/arc/Makefile +1 -15
@@ -10,14 +10,6 @@ UTS_MACHINE := arc KBUILD_DEFCONFIG := fpga_defconfig -# For ARC FPGA Platforms -platform-$(CONFIG_ARC_PLAT_FPGA_LEGACY) := arcfpga -#New platform adds here - -PLATFORM := $(platform-y) -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
@@ -86,9 +78,6 @@ KBUILD_CFLAGS += $(cflags-y) KBUILD_AFLAGS += $(KBUILD_CFLAGS) LDFLAGS += $(ldflags-y) -# Needed for Linker script preprocessing -KBUILD_CPPFLAGS += -Iarch/arc/plat-$(PLATFORM)/include - head-y := arch/arc/kernel/head.o # See arch/arc/Kbuild for content of core part of the kernel
@@ -97,10 +86,7 @@ core-y += arch/arc/ # w/o this dtb won't embed into kernel binary core-y += arch/arc/boot/dts/ -# w/o this ifneq, make ARCH=arc clean was crapping out -ifneq ($(platform-y),) -core-y += arch/arc/plat-$(PLATFORM)/ -endif +core-$(CONFIG_ARC_PLAT_FPGA_LEGACY) += arch/arc/plat-arcfpga/ drivers-$(CONFIG_OPROFILE) += arch/arc/oprofile/
arch/arc/include/asm/irq.h +0 -1
@@ -13,7 +13,6 @@#define TIMER0_IRQ 3#define TIMER1_IRQ 4 -#include <plat/irq.h> /* Board Specific IRQ assignments */ #include <asm-generic/irq.h> extern void __init arc_init_IRQ (void );
arch/arc/kernel/vmlinux.lds.S +0 -1
@@ -10,7 +10,6 @@ #include <asm/cache.h> #include <asm/page.h> #include <asm/thread_info.h> -#include <plat/memmap.h> OUTPUT_ARCH(arc) ENTRY(_stext)
arch/arc/plat-arcfpga/Makefile +2 -0
@@ -6,5 +6,7 @@ # published by the Free Software Foundation. # +KBUILD_CFLAGS += -Iarch/arc/plat-arcfpga/include + obj-y := platform.o irq.o obj-$(CONFIG_SMP) += smp.o
arch/arc/plat-arcfpga/irq.c +1 -1
@@ -9,7 +9,7 @@*/ #include <linux/interrupt.h> -#include <asm/irq.h> +#include <plat/irq.h> void __init plat_fpga_init_IRQ (void ) {
arch/arc/plat-arcfpga/platform.c +1 -1
@@ -16,11 +16,11 @@#include <linux/console.h> #include <linux/of_platform.h> #include <asm/setup.h> -#include <asm/irq.h> #include <asm/clk.h> #include <asm/mach_desc.h> #include <plat/memmap.h> #include <plat/smp.h> +#include <plat/irq.h> /*-----------------------BVCI Latency Unit -----------------------------*/
arch/arc/plat-arcfpga/smp.c +2 -1
@@ -12,7 +12,8 @@*/ #include <linux/smp.h> -#include <asm/irq.h> +#include <linux/irq.h> +#include <plat/irq.h> #include <plat/smp.h> static char smp_cpuinfo_buf[128 ];
Signature · 1 line
1.7.4.1
PATCH v3 65/71 ARC: [Review] Multi-platform image #5: NR_IRQS defined by ARC core
In reply to Vineet GuptaFor now this will suffice for all platforms, later exotic ones needs to get this from DeviceTree
--- arch/arc/include/asm/irq.h | 2 ++ arch/arc/plat-arcfpga/include/plat/irq.h | 6 ------ 2 files changed, 2 insertions(+), 6 deletions(-)
arch/arc/include/asm/irq.h +2 -0
@@ -9,6 +9,8 @@#ifndef __ASM_ARC_IRQ_H#define __ASM_ARC_IRQ_H +#define NR_IRQS 32 +/* Platform Independent IRQs */ #define TIMER0_IRQ 3#define TIMER1_IRQ 4
arch/arc/plat-arcfpga/include/plat/irq.h +0 -6
@@ -12,12 +12,6 @@#ifndef __PLAT_IRQ_H#define __PLAT_IRQ_H -#ifdef CONFIG_SMP -#define NR_IRQS 32 -#else -#define NR_IRQS 16 -#endif -#define UART0_IRQ 5#define UART1_IRQ 10#define UART2_IRQ 11
Signature · 1 line
1.7.4.1
PATCH v3 66/71 ARC: [Review] Multi-platform image #6: cpu-to-dma-addr optional
In reply to Vineet GuptaAll the current platforms can work with 0x8000_0000 based dma_addr_t since the Bus Bridges typically ignore the top bit (the only excpetion was Angel4 PCI-AHM bridge which we no longer care for). That way we don't need plat-specific cpu-addr to bus-addr conversion.
Hooks still provided - just in case a platform has an obscure device which say needs 0 based bus address.
That way <asm/dma_mapping.h> no longer needs to unconditinally include <plat/dma_addr.h>
Also verfied that on Angel4 board, other peripherals (IDE-disk / EMAC) work fine with 0x8000_0000 based dma addresses.
--- arch/arc/Kconfig | 4 ++ arch/arc/include/asm/dma-mapping.h | 16 +++++++++ arch/arc/plat-arcfpga/include/plat/dma_addr.h | 45 ------------------------- 3 files changed, 20 insertions(+), 45 deletions(-) delete mode 100644 arch/arc/plat-arcfpga/include/plat/dma_addr.h
arch/arc/Kconfig +4 -0
@@ -119,6 +119,10 @@ config CPU_BIG_ENDIAN help Build kernel for Big Endian Mode of ARC CPU +# If a platform can't work with 0x8000_0000 based dma_addr_t +config ARC_PLAT_NEEDS_CPU_TO_DMA + bool + config SMP bool "Symmetric Multi-Processing (Incomplete)" default n
arch/arc/include/asm/dma-mapping.h +16 -0
@@ -13,7 +13,23 @@#include <asm-generic/dma-coherent.h> #include <asm/cacheflush.h> + +#ifndef CONFIG_ARC_PLAT_NEEDS_CPU_TO_DMA +/* +* dma_map_* API take cpu addresses, which is kernel logical address in the +* untranslated address space (0x8000_0000) based. The dma address (bus addr) +* ideally needs to be 0x0000_0000 based hence these glue routines. +* However given that intermediate bus bridges can ignore the high bit, we can +* do with these routines being no-ops. +* If a platform/device comes up which sriclty requires 0 based bus addr +* (e.g. AHB-PCI bridge on Angel4 board), then it can provide it's own versions +*/ +#define plat_dma_addr_to_kernel (dev, addr) ((unsigned long)(addr)) +#define plat_kernel_addr_to_dma (dev, ptr) ((dma_addr_t)(ptr)) + +#else #include <plat/dma_addr.h> +#endif void *dma_alloc_noncoherent (struct device *dev,size_t size,dma_addr_t *dma_handle,gfp_t gfp);
arch/arc/plat-arcfpga/include/plat/dma_addr.h deleted +0 -45
45 lines not on this page · raw message
Signature · 1 line
1.7.4.1
PATCH v3 67/71 ARC: [Review] Multi-platform image #7: SMP common code to use callbacks
In reply to Vineet GuptaThis again is for switch from singleton platform SMP API to multi-platform paradigm
Platform code is not yet setup to populate the callbacks, that happens in next commit
--- arch/arc/include/asm/smp.h | 36 +++++++++++++++--------------------- arch/arc/kernel/smp.c | 16 +++++++++++++--- 2 files changed, 28 insertions(+), 24 deletions(-)
arch/arc/include/asm/smp.h +15 -21
@@ -31,6 +31,7 @@ extern void arch_send_call_function_ipi_mask(const struct cpumask *mask);*/ extern void __init smp_init_cpus (void );extern void __init first_lines_of_secondary (void ); +extern const char *arc_platform_smp_cpuinfo (void );/* * API expected BY platform smp code (FROM arch smp code)
@@ -41,29 +42,22 @@ extern void __init first_lines_of_secondary(void);extern int smp_ipi_irq_setup (int cpu,int irq);/* -* APIs expected FROM platform smp code -* -* arc_platform_smp_cpuinfo: -* returns a string containing info for /proc/cpuinfo -* -* arc_platform_smp_wait_to_boot: -* Called from early bootup code for non-Master CPUs to "park" them +* struct plat_smp_ops - SMP callbacks provided by platform to ARC SMP * -* arc_platform_smp_wakeup_cpu: -* Called from __cpu_up (Master CPU) to kick start another one -* -* arc_platform_ipi_send: -* Takes @cpumask to which IPI(s) would be sent. -* The actual msg-id/buffer is manager in arch-common code -* -* arc_platform_ipi_clear: -* Takes @cpu which got IPI at @irq to do any IPI clearing +* @info: SoC SMP specific info for /proc/cpuinfo etc +* @cpu_kick: For Master to kickstart a cpu (optionally at a PC) +* @ipi_send: To send IPI to a @cpumask +* @ips_clear: To clear IPI received by @cpu at @irq */ -extern const char *arc_platform_smp_cpuinfo (void ); -extern void arc_platform_smp_wait_to_boot (int cpu); -extern void arc_platform_smp_wakeup_cpu (int cpu,unsigned long pc); -extern void arc_platform_ipi_send (const struct cpumask *callmap); -extern void arc_platform_ipi_clear (int cpu,int irq); +struct plat_smp_ops { +const char *info; +void (*cpu_kick)(int cpu,unsigned long pc); +void (*ipi_send)(void *callmap); +void (*ipi_clear)(int cpu,int irq); +}; + +/* TBD: stop exporting it for direct population by platform */ +extern struct plat_smp_ops plat_smp_ops;#endif /* CONFIG_SMP */
arch/arc/kernel/smp.c +13 -3
@@ -37,6 +37,8 @@arch_spinlock_t smp_atomic_ops_lock = __ARCH_SPIN_LOCK_UNLOCKED;arch_spinlock_t smp_bitops_lock = __ARCH_SPIN_LOCK_UNLOCKED; +struct plat_smp_ops plat_smp_ops; +/* XXX: per cpu ? Only needed once in early seconday boot */ struct task_struct *secondary_idle_tsk;
@@ -105,6 +107,11 @@ void __attribute__((weak)) arc_platform_smp_wait_to_boot(int cpu) " b 1b \n"); } +const char *arc_platform_smp_cpuinfo (void ) +{ +return plat_smp_ops.info; +} +/* * The very first "C" code executed by secondary * Called from asm stub in head.S
@@ -156,7 +163,8 @@ int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *idle)pr_info ("Idle Task [%d] %p" , cpu, idle);pr_info ("Trying to bring up CPU%u ...\n" , cpu); -arc_platform_smp_wakeup_cpu (cpu, +if (plat_smp_ops.cpu_kick) + plat_smp_ops.cpu_kick (cpu, (unsigned long )first_lines_of_secondary);/* wait for 1 sec after kicking the secondary */
@@ -225,7 +233,8 @@ static void ipi_send_msg(const struct cpumask *callmap, enum ipi_msg_type msg) }/* Call the platform specific cross-CPU call function */ -arc_platform_ipi_send (callmap); +if (plat_smp_ops.ipi_send) + plat_smp_ops.ipi_send ((void *)callmap);local_irq_restore (flags); }
@@ -299,7 +308,8 @@ irqreturn_t do_IPI(int irq, void *dev_id)struct ipi_data *ipi = &per_cpu (ipi_data, cpu);unsigned long ops; -arc_platform_ipi_clear (cpu, irq); +if (plat_smp_ops.ipi_clear) + plat_smp_ops.ipi_clear (cpu, irq);/* * XXX: is this loop really needed
Signature · 1 line
1.7.4.1
PATCH v3 68/71 ARC: [Review] Multi-platform image #8: platform registers SMP callbacks
In reply to Vineet GuptaPlatforms export their SMP callbacks by populating arc_smp_ops. The population itself needs to be done pretty early, from init_early callback.
--- arch/arc/plat-arcfpga/include/plat/smp.h | 1 + arch/arc/plat-arcfpga/platform.c | 4 +++ arch/arc/plat-arcfpga/smp.c | 41 ++++++++++++++++------------- 3 files changed, 28 insertions(+), 18 deletions(-)
arch/arc/plat-arcfpga/include/plat/smp.h +1 -0
@@ -111,6 +111,7 @@ extern void idu_irq_set_tgtcpu(uint8_t irq, uint32_t mask);extern void idu_irq_set_mode (uint8_t irq,uint8_t dest_mode,uint8_t trig_mode);extern void iss_model_init_smp (unsigned int cpu); +extern void iss_model_init_early_smp (void );#endif /* CONFIG_SMP */
arch/arc/plat-arcfpga/platform.c +4 -0
@@ -162,6 +162,10 @@ static void __init plat_fpga_early_init(void)setup_bvci_lat_unit ();arc_fpga_serial_init (); + +#ifdef CONFIG_SMP +iss_model_init_early_smp (); +#endif }static struct of_dev_auxdata plat_auxdata_lookup[]__initdata = {
arch/arc/plat-arcfpga/smp.c +23 -18
67 lines not on this page · raw message
Signature · 1 line
1.7.4.1
PATCH v3 71/71 ARC: Add self to MAINTAINERS
In reply to Vineet Gupta--- MAINTAINERS | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
MAINTAINERS +6 -0
@@ -7418,6 +7418,12 @@ F: lib/swiotlb.c F: arch/*/kernel/pci-swiotlb.c F: include/linux/swiotlb.h +SYNOPSYS ARC ARCHITECTURE +M: Vineet Gupta <[email protected]> +L: [email protected] +S: Supported +F: arch/arc/ + SYSV FILESYSTEM M: Christoph Hellwig <[email protected]> S: Maintained
Signature · 1 line
1.7.4.1