Hexagon: Add support for Qualcomm Hexagon architecture
Subsystems (10)
v3 cover Hexagon: Add support for Qualcomm Hexagon architecture
This is the third version of the patchset to the Linux kernel to support the Qualcomm Hexagon architecture. These patches have been organized like the last time, in a somewhat logically grouped fashion.
A summary of changes from the last patchset:
* removed __delay
* cleaned up checksum header to pull generic one
* implemented vDSO so signal trampolines are no longer on stack
* fixed cpu_idle()
* removed init_IRQ() wrapper
* cleaned up (most of) the wrongness in time.c
* cleaned up smp.c to use more generic IPI handlers
* filled in ins/outs routines in IO and other misc cleanup
* removed redundant vunmap from ioremap
* removed more highmem cruft
* moved rwsem to asm-generic
* bonus ifdefs added to generic checksum.h
Also, I have been compiling with sparse and it seems to pass.
These patches are available on Code Aurora:
https://www.codeaurora.org/patches/quic/hlk/hexagon-linux-20110908.tar.gz
Thanks again for everyone's feedback!
-Richard Kuo
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
PATCH v3 1/36 Hexagon: Add generic headers
Reworked to use the Kbuild generic headers mechanism.
--- arch/hexagon/include/asm/Kbuild | 60 +++++++++++++++++++++++++ arch/hexagon/include/asm/bitsperlong.h | 26 ++++++++++ arch/hexagon/include/asm/mutex.h | 8 +++ arch/hexagon/include/asm/setup.h | 29 ++++++++++++ arch/hexagon/include/asm/user.h | 79 +++++++++++++++++++++++++++++++++ 5 files changed, 202 insertions(+)
arch/hexagon/include/asm/Kbuild new file +60 -0
@@ -0,0 +1,60 @@ +include include/asm-generic/Kbuild.asm + +header-y += registers.h +header-y += ucontext.h + +generic-y += auxvec.h +generic-y += bug.h +generic-y += bugs.h +generic-y += cpumask.h +generic-y += cputime.h +generic-y += current.h +generic-y += device.h +generic-y += div64.h +generic-y += emergency-restart.h +generic-y += errno.h +generic-y += fb.h +generic-y += fcntl.h +generic-y += ftrace.h +generic-y += hardirq.h +generic-y += hw_irq.h +generic-y += ioctl.h +generic-y += ioctls.h +generic-y += iomap.h +generic-y += ipcbuf.h +generic-y += ipc.h +generic-y += irq_regs.h +generic-y += kdebug.h +generic-y += kmap_types.h +generic-y += local64.h +generic-y += local.h +generic-y += local.h +generic-y += mman.h +generic-y += msgbuf.h +generic-y += pci.h +generic-y += percpu.h +generic-y += poll.h +generic-y += posix_types.h +generic-y += resource.h +generic-y += rwsem.h +generic-y += scatterlist.h +generic-y += sections.h +generic-y += segment.h +generic-y += sembuf.h +generic-y += shmbuf.h +generic-y += shmparam.h +generic-y += siginfo.h +generic-y += socket.h +generic-y += sockios.h +generic-y += statfs.h +generic-y += stat.h +generic-y += termbits.h +generic-y += termios.h +generic-y += topology.h +generic-y += types.h +generic-y += ucontext.h +generic-y += unaligned.h +generic-y += xor.h + + +
arch/hexagon/include/asm/bitsperlong.h new file +26 -0
@@ -0,0 +1,26 @@ +/* +* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#ifndef __ASM_HEXAGON_BITSPERLONG_H +#define __ASM_HEXAGON_BITSPERLONG_H + +#define __BITS_PER_LONG 32 + +#include <asm-generic/bitsperlong.h> + +#endif
arch/hexagon/include/asm/mutex.h new file +8 -0
@@ -0,0 +1,8 @@ +/* +* Pull in the generic implementation for the mutex fastpath. +* +* TODO: implement optimized primitives instead, or leave the generic +* implementation in place, or pick the atomic_xchg() based generic +* implementation. (see asm-generic/mutex-xchg.h for details) +*/ +#include <asm-generic/mutex-xchg.h>
arch/hexagon/include/asm/setup.h new file +29 -0
@@ -0,0 +1,29 @@ +/* +* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#ifndef _ASM_SETUP_H +#define _ASM_SETUP_H + +#include <linux/init.h> +#include <asm-generic/setup.h> + +extern char external_cmdline_buffer; + +void __init setup_arch_memory (void ); + +#endif
arch/hexagon/include/asm/user.h new file +79 -0
79 lines not on this page · raw message
--
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
PATCH v3 2/36 Hexagon: Core arch-specific header files
In reply to Richard Kuo--- arch/hexagon/include/asm/byteorder.h | 28 ++++ arch/hexagon/include/asm/elf.h | 228 ++++++++++++++++++++++++++++++++++ arch/hexagon/include/asm/fpu.h | 4 arch/hexagon/include/asm/futex.h | 137 ++++++++++++++++++++ arch/hexagon/include/asm/linkage.h | 25 +++ arch/hexagon/include/asm/module.h | 26 +++ arch/hexagon/include/asm/param.h | 26 +++ arch/hexagon/include/asm/perf_event.h | 24 +++ arch/hexagon/include/asm/string.h | 32 ++++ arch/hexagon/include/asm/suspend.h | 27 ++++ arch/hexagon/include/asm/swab.h | 24 +++ arch/hexagon/include/asm/timex.h | 37 +++++ 12 files changed, 618 insertions(+)
arch/hexagon/include/asm/byteorder.h new file +28 -0
@@ -0,0 +1,28 @@ +/* +* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#ifndef _ASM_BYTEORDER_H +#define _ASM_BYTEORDER_H + +#if defined(__GNUC__) && !defined(__STRICT_ANSI__) || defined(__KERNEL__) +# define __BYTEORDER_HAS_U64__ +#endif + +#include <linux/byteorder/little_endian.h> + +#endif /* _ASM_BYTEORDER_H */
arch/hexagon/include/asm/elf.h new file +228 -0
228 lines not on this page · raw message
arch/hexagon/include/asm/fpu.h new file +4 -0
@@ -0,0 +1,4 @@ +/* +* If the FPU is used inside the kernel, +* kernel_fpu_end() will be defined here. +*/
arch/hexagon/include/asm/futex.h new file +137 -0
137 lines not on this page · raw message
arch/hexagon/include/asm/linkage.h new file +25 -0
@@ -0,0 +1,25 @@ +/* +* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#ifndef __ASM_LINKAGE_H +#define __ASM_LINKAGE_H + +#define __ALIGN .align 4 +#define __ALIGN_STR ".align 4" + +#endif
arch/hexagon/include/asm/module.h new file +26 -0
@@ -0,0 +1,26 @@ +/* +* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#ifndef _ASM_MODULE_H +#define _ASM_MODULE_H + +#include <asm-generic/module.h> + +#define MODULE_ARCH_VERMAGIC __stringify(PROCESSOR_MODEL_NAME) " " + +#endif
arch/hexagon/include/asm/param.h new file +26 -0
@@ -0,0 +1,26 @@ +/* +* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#ifndef _ASM_PARAM_H +#define _ASM_PARAM_H + +#define EXEC_PAGESIZE 16384 + +#include <asm-generic/param.h> + +#endif
arch/hexagon/include/asm/string.h new file +32 -0
@@ -0,0 +1,32 @@ +/* +* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#ifndef _ASM_STRING_H_ +#define _ASM_STRING_H_ + +#ifdef __KERNEL__ +#define __HAVE_ARCH_MEMCPY +extern void *memcpy(void *__to, __const__ void *__from, size_t __n); + +/* ToDo: use dczeroa, accelerate the compiler-constant zero case */ +#define __HAVE_ARCH_MEMSET +extern void *memset (void *__to,int c,size_t __n); +#endif + + +#endif /* _ASM_STRING_H_ */
arch/hexagon/include/asm/suspend.h new file +27 -0
@@ -0,0 +1,27 @@ +/* +* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#ifndef _ASM_SUSPEND_H +#define _ASM_SUSPEND_H + +static inline int arch_prepare_suspend (void ) +{ +return 0 ; +} + +#endif
arch/hexagon/include/asm/swab.h new file +24 -0
@@ -0,0 +1,24 @@ +/* +* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#ifndef _ASM_SWAB_H +#define _ASM_SWAB_H + +#define __SWAB_64_THRU_32__ + +#endif
arch/hexagon/include/asm/timex.h new file +37 -0
@@ -0,0 +1,37 @@ +/* +* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#ifndef _ASM_TIMEX_H +#define _ASM_TIMEX_H + +#include <asm-generic/timex.h> +#include <asm/timer-regs.h> + +/* Using TCX0 as our clock. CLOCK_TICK_RATE scheduled to be removed. */ +#define CLOCK_TICK_RATE TCX0_CLK_RATE + +#define ARCH_HAS_READ_CURRENT_TIMER + +static inline int read_current_timer (unsigned long *timer_val) +{ + *timer_val = (unsigned long )__vmgettime (); +return 0 ; +} + +#endif +
arch/hexagon/include/asm/perf_event.h new file +24 -0
@@ -0,0 +1,24 @@ +/* +* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#ifndef _ASM_PERF_EVENT_H +#define _ASM_PERF_EVENT_H + +#define PERF_EVENT_INDEX_OFFSET 0 + +#endif /* _ASM_PERF_EVENT_H */
--
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
PATCH v3 3/36 Hexagon: Add bitops support
In reply to Richard KuoMerged sub-files into bitops.h; fixed return types and volatiles.
--- arch/hexagon/include/asm/bitops.h | 301 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 301 insertions(+)
arch/hexagon/include/asm/bitops.h new file +301 -0
@@ -0,0 +1,301 @@ +/* +* Bit operations for the Hexagon architecture +* +* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +* +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#ifndef _ASM_BITOPS_H +#define _ASM_BITOPS_H + +#include <linux/compiler.h> +#include <asm/byteorder.h> +#include <asm/system.h> +#include <asm/atomic.h> + +#ifdef __KERNEL__ + +#define smp_mb__before_clear_bit () barrier() +#define smp_mb__after_clear_bit () barrier() + +/* +* The offset calculations for these are based on BITS_PER_LONG == 32 +* (i.e. I get to shift by #5-2 (32 bits per long, 4 bytes per access), +* mask by 0x0000001F) +* +* Typically, R10 is clobbered for address, R11 bit nr, and R12 is temp +*/ + +/** +* test_and_clear_bit - clear a bit and return its old value +* @nr: bit number to clear +* @addr: pointer to memory +*/ +static inline int test_and_clear_bit (int nr,volatile void *addr) +{ +int oldval; + + __asm__ __volatile__ ( +" {R10 = %1; R11 = asr(%2,#5); }\n" +" {R10 += asl(R11,#2); R11 = and(%2,#0x1f)}\n" +"1: R12 = memw_locked(R10);\n" +" { P0 = tstbit(R12,R11); R12 = clrbit(R12,R11); }\n" +" memw_locked(R10,P1) = R12;\n" +" {if !P1 jump 1b; %0 = mux(P0,#1,#0);}\n" + :"=&r" (oldval) + :"r" (addr),"r" (nr) + :"r10" ,"r11" ,"r12" ,"p0" ,"p1" ,"memory" + ); + +return oldval; +} + +/** +* test_and_set_bit - set a bit and return its old value +* @nr: bit number to set +* @addr: pointer to memory +*/ +static inline int test_and_set_bit (int nr,volatile void *addr) +{ +int oldval; + + __asm__ __volatile__ ( +" {R10 = %1; R11 = asr(%2,#5); }\n" +" {R10 += asl(R11,#2); R11 = and(%2,#0x1f)}\n" +"1: R12 = memw_locked(R10);\n" +" { P0 = tstbit(R12,R11); R12 = setbit(R12,R11); }\n" +" memw_locked(R10,P1) = R12;\n" +" {if !P1 jump 1b; %0 = mux(P0,#1,#0);}\n" + :"=&r" (oldval) + :"r" (addr),"r" (nr) + :"r10" ,"r11" ,"r12" ,"p0" ,"p1" ,"memory" + ); + + +return oldval; + +} + +/** +* test_and_change_bit - toggle a bit and return its old value +* @nr: bit number to set +* @addr: pointer to memory +*/ +static inline int test_and_change_bit (int nr,volatile void *addr) +{ +int oldval; + + __asm__ __volatile__ ( +" {R10 = %1; R11 = asr(%2,#5); }\n" +" {R10 += asl(R11,#2); R11 = and(%2,#0x1f)}\n" +"1: R12 = memw_locked(R10);\n" +" { P0 = tstbit(R12,R11); R12 = togglebit(R12,R11); }\n" +" memw_locked(R10,P1) = R12;\n" +" {if !P1 jump 1b; %0 = mux(P0,#1,#0);}\n" + :"=&r" (oldval) + :"r" (addr),"r" (nr) + :"r10" ,"r11" ,"r12" ,"p0" ,"p1" ,"memory" + ); + +return oldval; + +} + +/* +* Atomic, but doesn't care about the return value. +* Rewrite later to save a cycle or two. +*/ + +static inline void clear_bit (int nr,volatile void *addr) +{ +test_and_clear_bit (nr, addr); +} + +static inline void set_bit (int nr,volatile void *addr) +{ +test_and_set_bit (nr, addr); +} + +static inline void change_bit (int nr,volatile void *addr) +{ +test_and_change_bit (nr, addr); +} + + +/* +* These are allowed to be non-atomic. In fact the generic flavors are +* in non-atomic.h. Would it be better to use intrinsics for this? +* +* OK, writes in our architecture do not invalidate LL/SC, so this has to +* be atomic, particularly for things like slab_lock and slab_unlock. +* +*/ +static inline void __clear_bit (int nr,volatile unsigned long *addr) +{ +test_and_clear_bit (nr, addr); +} + +static inline void __set_bit (int nr,volatile unsigned long *addr) +{ +test_and_set_bit (nr, addr); +} + +static inline void __change_bit (int nr,volatile unsigned long *addr) +{ +test_and_change_bit (nr, addr); +} + +/* Apparently, at least some of these are allowed to be non-atomic */ +static inline int __test_and_clear_bit (int nr,volatile unsigned long *addr) +{ +return test_and_clear_bit (nr, addr); +} + +static inline int __test_and_set_bit (int nr,volatile unsigned long *addr) +{ +return test_and_set_bit (nr, addr); +} + +static inline int __test_and_change_bit (int nr,volatile unsigned long *addr) +{ +return test_and_change_bit (nr, addr); +} + +static inline int __test_bit (int nr,const volatile unsigned long *addr) +{ +int retval; + + asmvolatile ( +"{P0 = tstbit(%1,%2); if (P0.new) %0 = #1; if (!P0.new) %0 = #0;}\n" + :"=&r" (retval) + :"r" (addr[BIT_WORD (nr)]),"r" (nr %BITS_PER_LONG ) + :"p0" + ); + +return retval; +} + +#define test_bit (nr, addr) __test_bit(nr, addr) + +/* +* ffz - find first zero in word. +* @word: The word to search +* +* Undefined if no zero exists, so code should check against ~0UL first. +*/ +static inline long ffz (int x) +{ +int r; + + asm("%0 = ct1(%1);\n" + :"=&r" (r) + :"r" (x)); +return r; +} + +/* +* fls - find last (most-significant) bit set +* @x: the word to search +* +* This is defined the same way as ffs. +* Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32. +*/ +static inline long fls (int x) +{ +int r; + + asm("{ %0 = cl0(%1);}\n" +"%0 = sub(#32,%0);\n" + :"=&r" (r) + :"r" (x) + :"p0" ); + +return r; +} + +/* +* ffs - find first bit set +* @x: the word to search +* +* This is defined the same way as +* the libc and compiler builtin ffs routines, therefore +* differs in spirit from the above ffz (man ffs). +*/ +static inline long ffs (int x) +{ +int r; + + asm("{ P0 = cmp.eq(%1,#0); %0 = ct0(%1);}\n" +"{ if P0 %0 = #0; if !P0 %0 = add(%0,#1);}\n" + :"=&r" (r) + :"r" (x) + :"p0" ); + +return r; +} + +/* +* __ffs - find first bit in word. +* @word: The word to search +* +* Undefined if no bit exists, so code should check against 0 first. +* +* bits_per_long assumed to be 32 +* numbering starts at 0 I think (instead of 1 like ffs) +*/ +static inline unsigned long __ffs (unsigned long word) +{ +int num; + + asm("%0 = ct0(%1);\n" + :"=&r" (num) + :"r" (word)); + +return num; +} + +/* +* __fls - find last (most-significant) set bit in a long word +* @word: the word to search +* +* Undefined if no set bit exists, so code should check against 0 first. +* bits_per_long assumed to be 32 +*/ +static inline unsigned long __fls (unsigned long word) +{ +int num; + + asm("%0 = cl0(%1);\n" +"%0 = sub(#31,%0);\n" + :"=&r" (num) + :"r" (word)); + +return num; +} + +#include <asm-generic/bitops/lock.h> +#include <asm-generic/bitops/find.h> + +#include <asm-generic/bitops/fls64.h> +#include <asm-generic/bitops/sched.h> +#include <asm-generic/bitops/hweight.h> + +#include <asm-generic/bitops/le.h> +#include <asm-generic/bitops/ext2-atomic.h> + +#endif /* __KERNEL__ */ +#endif
--
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
PATCH v3 4/36 Hexagon: Add atomic ops support
In reply to Richard KuoOur architecture uses load locked/store conditional type semantics for atomic ops.
Added inline assembly version of atomic_add_unless.
--- arch/hexagon/include/asm/atomic.h | 164 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 164 insertions(+)
arch/hexagon/include/asm/atomic.h new file +164 -0
@@ -0,0 +1,164 @@ +/* +* Atomic operations for the Hexagon architecture +* +* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +* +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#ifndef _ASM_ATOMIC_H +#define _ASM_ATOMIC_H + +#include <linux/types.h> + +#define ATOMIC_INIT (i) { (i) } +#define atomic_set (v, i) ((v)->counter = (i)) + +/** +* atomic_read - reads a word, atomically +* @v: pointer to atomic value +* +* Assumes all word reads on our architecture are atomic. +*/ +#define atomic_read (v) ((v)->counter) + +/** +* atomic_xchg - atomic +* @v: pointer to memory to change +* @new: new value (technically passed in a register -- see xchg) +*/ +#define atomic_xchg (v, new) (xchg(&((v)->counter), (new))) + + +/** +* atomic_cmpxchg - atomic compare-and-exchange values +* @v: pointer to value to change +* @old: desired old value to match +* @new: new value to put in +* +* Parameters are then pointer, value-in-register, value-in-register, +* and the output is the old value. +* +* Apparently this is complicated for archs that don't support +* the memw_locked like we do (or it's broken or whatever). +* +* Kind of the lynchpin of the rest of the generically defined routines. +* Remember V2 had that bug with dotnew predicate set by memw_locked. +* +* "old" is "expected" old val, __oldval is actual old value +*/ +static inline int atomic_cmpxchg (atomic_t *v,int old,int new) +{ +int __oldval; + + asmvolatile ( +"1: %0 = memw_locked(%1);\n" +" { P0 = cmp.eq(%0,%2);\n" +" if (!P0.new) jump:nt 2f; }\n" +" memw_locked(%1,P0) = %3;\n" +" if (!P0) jump 1b;\n" +"2:\n" + :"=&r" (__oldval) + :"r" (&v->counter),"r" (old),"r" (new) + :"memory" ,"p0" + ); + +return __oldval; +} + +static inline int atomic_add_return (int i,atomic_t *v) +{ +int output; + + __asm__ __volatile__ ( +"1: %0 = memw_locked(%1);\n" +" %0 = add(%0,%2);\n" +" memw_locked(%1,P3)=%0;\n" +" if !P3 jump 1b;\n" + :"=&r" (output) + :"r" (&v->counter),"r" (i) + :"memory" ,"p3" + ); +return output; + +} + +#define atomic_add (i, v) atomic_add_return(i, (v)) + +static inline int atomic_sub_return (int i,atomic_t *v) +{ +int output; + __asm__ __volatile__ ( +"1: %0 = memw_locked(%1);\n" +" %0 = sub(%0,%2);\n" +" memw_locked(%1,P3)=%0\n" +" if !P3 jump 1b;\n" + :"=&r" (output) + :"r" (&v->counter),"r" (i) + :"memory" ,"p3" + ); +return output; +} + +#define atomic_sub (i, v) atomic_sub_return(i, (v)) + +/** +* atomic_add_unless - add unless the number is a given value +* @v: pointer to value +* @a: amount to add +* @u: unless value is equal to u +* +* Returns 1 if the add happened, 0 if it didn't. +*/ +static inline int __atomic_add_unless (atomic_t *v,int a,int u) +{ +int output; + asmvolatile ( +"1: R15 = memw_locked(%1);" +" {" +" p3 = cmp.eq(R15, %3);" +" if (p3.new) jump:nt 2f;" +" R15 = add(R15,%2);" +" %0 = #0;" +" }" +" memw_locked(%1,p3) = r15;" +" {" +" if !p3 jump 1b;" +" %0 = #1;" +" }" +"2:" + :"=&r" (output) + :"r" (v),"r" (a),"r" (u) + :"memory" ,"p3" ,"r15" + ); +return output; +} + +#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_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_inc_return (v) (atomic_add_return(1, v)) +#define atomic_dec_return (v) (atomic_sub_return(1, v)) + +#endif
--
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
PATCH v3 5/36 Hexagon: Add syscalls
In reply to Richard KuoRemoved sys_mmap* and replaced with sys_mmap_pgoff()
--- arch/hexagon/include/asm/syscall.h | 40 ++++++++++++++++ arch/hexagon/include/asm/unistd.h | 36 ++++++++++++++ arch/hexagon/kernel/syscall.c | 90 +++++++++++++++++++++++++++++++++++++ arch/hexagon/kernel/syscalltab.c | 32 +++++++++++++ 4 files changed, 198 insertions(+)
arch/hexagon/include/asm/syscall.h new file +40 -0
@@ -0,0 +1,40 @@ +/* +* Syscall support for the Hexagon architecture +* +* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#ifndef _ASM_HEXAGON_SYSCALL_H +#define _ASM_HEXAGON_SYSCALL_H + +typedef long (*syscall_fn )(unsigned long ,unsigned long , +unsigned long ,unsigned long , +unsigned long ,unsigned long ); + +asmlinkage int sys_execve(char __user *ufilename, char __user * __user *argv, +char __user *__user *envp); +asmlinkage int sys_clone(unsigned long clone_flags, unsigned long newsp, +unsigned long parent_tidp,unsigned long child_tidp); + +#define sys_execve sys_execve +#define sys_clone sys_clone + +#include <asm-generic/syscalls.h> + +extern void *sys_call_table[]; + +#endif
arch/hexagon/include/asm/unistd.h new file +36 -0
@@ -0,0 +1,36 @@ +/* +* Syscall support for Hexagon +* +* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#if !defined(_ASM_HEXAGON_UNISTD_H) || defined(__SYSCALL) +#define _ASM_HEXAGON_UNISTD_H + +/* +* The kernel pulls this unistd.h in three different ways: +* 1. the "normal" way which gets all the __NR defines +* 2. with __SYSCALL defined to produce function declarations +* 3. with __SYSCALL defined to produce syscall table initialization +* See also: syscalltab.c +*/ + +#define sys_mmap2 sys_mmap_pgoff + +#include <asm-generic/unistd.h> + +#endif
arch/hexagon/kernel/syscall.c new file +90 -0
90 lines not on this page · raw message
arch/hexagon/kernel/syscalltab.c new file +32 -0
@@ -0,0 +1,32 @@ +/* +* System call table for Hexagon +* +* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#include <linux/syscalls.h> +#include <linux/signal.h> +#include <linux/unistd.h> + +#include <asm/syscall.h> + +#undef __SYSCALL +#define __SYSCALL (nr, call) [nr] = (call), + +void *sys_call_table[__NR_syscalls] = { +#include <asm/unistd.h> +};
--
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Re: [patch v3 05/36] Hexagon: Add syscalls
Quoted 4 lines · On Thursday 08 September 2011 20:08:52 Richard Kuo wrote:
Removed sys_mmap* and replaced with
sys_mmap_pgoff()Signed-off-by Richard Kuo <[email protected]>
PATCH v3 6/36 Hexagon: Add processor and system headers
In reply to Richard KuoAdds Hexagon information for processor/system type stuff like context switching, register access, and irqflags.
Changed cpu_relax() to call __vmyield().
--- arch/hexagon/include/asm/asm-offsets.h | 1 arch/hexagon/include/asm/irqflags.h | 62 ++++++++ arch/hexagon/include/asm/processor.h | 123 +++++++++++++++++ arch/hexagon/include/asm/registers.h | 236 +++++++++++++++++++++++++++++++++ arch/hexagon/include/asm/system.h | 126 +++++++++++++++++ 5 files changed, 548 insertions(+)
arch/hexagon/include/asm/irqflags.h new file +62 -0
@@ -0,0 +1,62 @@ +/* +* IRQ support for the Hexagon architecture +* +* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#ifndef _ASM_IRQFLAGS_H +#define _ASM_IRQFLAGS_H + +#include <asm/hexagon_vm.h> +#include <linux/types.h> + +static inline unsigned long arch_local_save_flags (void ) +{ +return __vmgetie (); +} + +static inline unsigned long arch_local_irq_save (void ) +{ +return __vmsetie (VM_INT_DISABLE ); +} + +static inline bool arch_irqs_disabled_flags (unsigned long flags) +{ +return !flags; +} + +static inline bool arch_irqs_disabled (void ) +{ +return !__vmgetie (); +} + +static inline void arch_local_irq_enable (void ) +{ +__vmsetie (VM_INT_ENABLE ); +} + +static inline void arch_local_irq_disable (void ) +{ +__vmsetie (VM_INT_DISABLE ); +} + +static inline void arch_local_irq_restore (unsigned long flags) +{ +__vmsetie (flags); +} + +#endif
arch/hexagon/include/asm/processor.h new file +123 -0
123 lines not on this page · raw message
arch/hexagon/include/asm/registers.h new file +236 -0
236 lines not on this page · raw message
arch/hexagon/include/asm/system.h new file +126 -0
126 lines not on this page · raw message
arch/hexagon/include/asm/asm-offsets.h new file +1 -0
@@ -0,0 +1 @@ +#include <generated/asm-offsets.h>
--
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
PATCH v3 7/36 Hexagon: Add threadinfo
In reply to Richard KuoRemoved some cruft and changed to allow kernel stack to be smaller than a page size.
I left the thread_info alignment alone for the time being; may revisit that in the future.
--- arch/hexagon/include/asm/thread_info.h | 154 +++++++++++++++++++++++++++++++++ 1 file changed, 154 insertions(+)
arch/hexagon/include/asm/thread_info.h new file +154 -0
@@ -0,0 +1,154 @@ +/* +* Thread support for the Hexagon architecture +* +* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#ifndef _ASM_THREAD_INFO_H +#define _ASM_THREAD_INFO_H + +#ifdef __KERNEL__ + +#ifndef __ASSEMBLY__ +#include <asm/processor.h> +#include <asm/registers.h> +#include <asm/page.h> +#endif + +#define THREAD_SHIFT 12 +#define THREAD_SIZE (1<<THREAD_SHIFT) + +#if THREAD_SHIFT >=PAGE_SHIFT +#define THREAD_SIZE_ORDER (THREAD_SHIFT - PAGE_SHIFT) +#else /* don't use standard allocator */ +#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR +extern struct thread_info *alloc_thread_info_node (struct task_struct *tsk,int node); +extern void free_thread_info (struct thread_info *ti); +#endif + + +#ifndef __ASSEMBLY__ + +typedef struct { +unsigned long seg; +}mm_segment_t ; + +/* +* This is union'd with the "bottom" of the kernel stack. +* It keeps track of thread info which is handy for routines +* to access quickly. +*/ + +struct thread_info { +struct task_struct *task;/* main task structure */ +struct exec_domain *exec_domain;/* execution domain */ +unsigned long flags;/* low level flags */ +__u32 cpu;/* current cpu */ +int preempt_count;/* 0=>preemptible,<0=>BUG */ +mm_segment_t addr_limit;/* segmentation sux */ +/* +* used for syscalls somehow; +* seems to have a function pointer and four arguments +*/ +struct restart_block restart_block; +/* Points to the current pt_regs frame */ +struct pt_regs *regs; +/* +* saved kernel sp at switch_to time; +* not sure if this is used (it's not in the VM model it seems; +* see thread_struct) +*/ +unsigned long sp; +}; + +#else /* !__ASSEMBLY__ */ + +#include <asm/asm-offsets.h> + +#endif /* __ASSEMBLY__ */ + +/* looks like "linux/hardirq.h" uses this. */ + +#define PREEMPT_ACTIVE 0x10000000 + +#ifndef __ASSEMBLY__ + +#define INIT_THREAD_INFO (tsk) \ +{ \ + .task = &tsk, \ + .exec_domain = &default_exec_domain, \ + .flags = 0, \ + .cpu = 0, \ + .preempt_count = 1, \ + .addr_limit = KERNEL_DS, \ + .restart_block = { \ + .fn = do_no_restart_syscall, \ + }, \ + .sp = 0, \ + .regs = NULL, \ +} + +#define init_thread_info (init_thread_union.thread_info) +#define init_stack (init_thread_union.stack) + +/* Tacky preprocessor trickery */ +#define qqstr (s) qstr(s) +#define qstr (s) #s +#define QUOTED_THREADINFO_REG qqstr(THREADINFO_REG) + +register struct thread_info *__current_thread_info asm(QUOTED_THREADINFO_REG); +#define current_thread_info () __current_thread_info + +#endif /* __ASSEMBLY__ */ + +/* +* thread information flags +* - these are process state flags that various assembly files +* may need to access +* - pending work-to-be-done flags are in LSW +* - other flags in MSW +*/ + +#define TIF_SYSCALL_TRACE 0/* syscall trace active */ +#define TIF_NOTIFY_RESUME 1/* resumption notification requested */ +#define TIF_SIGPENDING 2/* signal pending */ +#define TIF_NEED_RESCHED 3/* rescheduling necessary */ +#define TIF_SINGLESTEP 4/* restore ss @ return to usr mode */ +#define TIF_IRET 5/* return with iret */ +#define TIF_RESTORE_SIGMASK 6/* restore sig mask in do_signal() */ +/* true if poll_idle() is polling TIF_NEED_RESCHED */ +#define TIF_POLLING_NRFLAG 16 +#define TIF_MEMDIE 17/* OOM killer killed process */ + +#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) +#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME) +#define _TIF_SIGPENDING (1 << TIF_SIGPENDING) +#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED) +#define _TIF_SINGLESTEP (1 << TIF_SINGLESTEP) +#define _TIF_IRET (1 << TIF_IRET) +#define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK) +#define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG) + +/* work to do on interrupt/exception return - All but TIF_SYSCALL_TRACE */ +#define _TIF_WORK_MASK (0x0000FFFF & ~_TIF_SYSCALL_TRACE) + +/* work to do on any return to u-space */ +#define _TIF_ALLWORK_MASK 0x0000FFFF + +#endif /* __KERNEL__ */ + +#endif
--
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
PATCH v3 8/36 Hexagon: Add delay functions
In reply to Richard KuoAdded read_current_timer elsewhere.
udelay is based off of __vmgettime() which returns processor ticks.
Removed __delay and CONFIG_GENERIC_CALIBRATE_DELAY.
--- arch/hexagon/include/asm/delay.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
arch/hexagon/include/asm/delay.h new file +28 -0
@@ -0,0 +1,28 @@ +/* +* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#ifndef _ASM_DELAY_H +#define _ASM_DELAY_H + +#include <asm/param.h> + +extern void __udelay (unsigned long usecs); + +#define udelay (usecs) __udelay((usecs)) + +#endif /* _ASM_DELAY_H */
--
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Re: [patch v3 08/36] Hexagon: Add delay functions
Quoted 7 lines · On Thursday 08 September 2011 20:08:55 Richard Kuo wrote:
Added
read_current_timerelsewhere.udelay is based off of
__vmgettime()which returns processor ticks.Removed
__delayandCONFIG_GENERIC_CALIBRATE_DELAY.Signed-off-by Richard Kuo <[email protected]>
PATCH v3 9/36 Hexagon: Add checksum functions
In reply to Richard KuoRemoved most non-assembly functions and use the generic ones instead.
Made a few more minor changes to use the generic header file.
--- arch/hexagon/include/asm/checksum.h | 50 ++++++++ arch/hexagon/include/asm/intrinsics.h | 26 ++++ arch/hexagon/lib/checksum.c | 203 ++++++++++++++++++++++++++++++++++ 3 files changed, 279 insertions(+)
arch/hexagon/include/asm/checksum.h new file +50 -0
@@ -0,0 +1,50 @@ +/* +* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#ifndef _ASM_CHECKSUM_H +#define _ASM_CHECKSUM_H + +#define do_csum do_csum +unsigned int do_csum (const void *voidptr,int len); + +/* +* the same as csum_partial, but copies from src while it +* checksums +* +* here even more important to align src and dst on a 32-bit (or even +* better 64-bit) boundary +*/ +#define csum_partial_copy_nocheck csum_partial_copy_nocheck +__wsum csum_partial_copy_nocheck (const void *src,void *dst, +int len,__wsum sum); + +/* +* computes the checksum of the TCP/UDP pseudo-header +* returns a 16-bit checksum, already complemented +*/ +#define csum_tcpudp_nofold csum_tcpudp_nofold +__wsum csum_tcpudp_nofold (unsigned long saddr,unsigned long daddr, +unsigned short len,unsigned short proto,__wsum sum); + +#define csum_tcpudp_magic csum_tcpudp_magic +__sum16 csum_tcpudp_magic (unsigned long saddr,unsigned long daddr, +unsigned short len,unsigned short proto,__wsum sum); + +#include <asm-generic/checksum.h> + +#endif
arch/hexagon/include/asm/intrinsics.h new file +26 -0
@@ -0,0 +1,26 @@ +/* +* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#ifndef _ASM_HEXAGON_INTRINSICS_H +#define _ASM_HEXAGON_INTRINSICS_H + +#define HEXAGON_P_vrmpyhacc_PP __builtin_HEXAGON_M2_vrmac_s0 +#define HEXAGON_P_vrmpyh_PP __builtin_HEXAGON_M2_vrmpy_s0 +#define HEXAGON_R_cl0_R __builtin_HEXAGON_S2_cl0 + +#endif
arch/hexagon/lib/checksum.c new file +203 -0
203 lines not on this page · raw message
--
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
PATCH v3 10/36 Hexagon: Add memcpy and memset accelerated functions
In reply to Richard Kuo--- arch/hexagon/lib/memcpy.S | 543 ++++++++++++++++++++++++++++++++++++++++++++++ arch/hexagon/lib/memset.S | 316 ++++++++++++++++++++++++++ 2 files changed, 859 insertions(+)
arch/hexagon/lib/memcpy.S new file +543 -0
@@ -0,0 +1,543 @@ +/* + * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 and + * only version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +/* + * Description + * + * library function for memcpy where length bytes are copied from + * ptr_in to ptr_out. ptr_out is returned unchanged. + * Allows any combination of alignment on input and output pointers + * and length from 0 to 2^32-1 + * + * Restrictions + * The arrays should not overlap, the program will produce undefined output + * if they do. + * For blocks less than 16 bytes a byte by byte copy is performed. For + * 8byte alignments, and length multiples, a dword copy is performed up to + * 96bytes + * History + * + * DJH 5/15/09 Initial version 1.0 + * DJH 6/ 1/09 Version 1.1 modified ABI to inlcude R16-R19 + * DJH 7/12/09 Version 1.2 optimized codesize down to 760 was 840 + * DJH 10/14/09 Version 1.3 added special loop for aligned case, was + * overreading bloated codesize back up to 892 + * DJH 4/20/10 Version 1.4 fixed Ldword_loop_epilog loop to prevent loads + * occuring if only 1 left outstanding, fixes bug + * # 3888, corrected for all alignments. Peeled off + * 1 32byte chunk from kernel loop and extended 8byte + * loop at end to solve all combinations and prevent + * over read. Fixed Ldword_loop_prolog to prevent + * overread for blocks less than 48bytes. Reduced + * codesize to 752 bytes + * DJH 4/21/10 version 1.5 1.4 fix broke code for input block ends not + * aligned to dword boundaries,underwriting by 1 + * byte, added detection for this and fixed. A + * little bloat. + * DJH 4/23/10 version 1.6 corrected stack error, R20 was not being restored + * always, fixed the error of R20 being modified + * before it was being saved + * Natural c model + * =============== + * void * memcpy(char * ptr_out, char * ptr_in, int length) { + * int i; + * if(length) for(i=0; i < length; i++) { ptr_out[i] = ptr_in[i]; } + * return(ptr_out); + * } + * + * Optimized memcpy function + * ========================= + * void * memcpy(char * ptr_out, char * ptr_in, int len) { + * int i, prolog, kernel, epilog, mask; + * u8 offset; + * s64 data0, dataF8, data70; + * + * s64 * ptr8_in; + * s64 * ptr8_out; + * s32 * ptr4; + * s16 * ptr2; + * + * offset = ((int) ptr_in) & 7; + * ptr8_in = (s64 *) &ptr_in[-offset]; //read in the aligned pointers + * + * data70 = *ptr8_in++; + * dataF8 = *ptr8_in++; + * + * data0 = HEXAGON_P_valignb_PPp(dataF8, data70, offset); + * + * prolog = 32 - ((int) ptr_out); + * mask = 0x7fffffff >> HEXAGON_R_cl0_R(len); + * prolog = prolog & mask; + * kernel = len - prolog; + * epilog = kernel & 0x1F; + * kernel = kernel>>5; + * + * if (prolog & 1) { ptr_out[0] = (u8) data0; data0 >>= 8; ptr_out += 1;} + * ptr2 = (s16 *) &ptr_out[0]; + * if (prolog & 2) { ptr2[0] = (u16) data0; data0 >>= 16; ptr_out += 2;} + * ptr4 = (s32 *) &ptr_out[0]; + * if (prolog & 4) { ptr4[0] = (u32) data0; data0 >>= 32; ptr_out += 4;} + * + * offset = offset + (prolog & 7); + * if (offset >= 8) { + * data70 = dataF8; + * dataF8 = *ptr8_in++; + * } + * offset = offset & 0x7; + * + * prolog = prolog >> 3; + * if (prolog) for (i=0; i < prolog; i++) { + * data0 = HEXAGON_P_valignb_PPp(dataF8, data70, offset); + * ptr8_out = (s64 *) &ptr_out[0]; *ptr8_out = data0; ptr_out += 8; + * data70 = dataF8; + * dataF8 = *ptr8_in++; + * } + * if(kernel) { kernel -= 1; epilog += 32; } + * if(kernel) for(i=0; i < kernel; i++) { + * data0 = HEXAGON_P_valignb_PPp(dataF8, data70, offset); + * ptr8_out = (s64 *) &ptr_out[0]; *ptr8_out = data0; ptr_out += 8; + * data70 = *ptr8_in++; + * + * data0 = HEXAGON_P_valignb_PPp(data70, dataF8, offset); + * ptr8_out = (s64 *) &ptr_out[0]; *ptr8_out = data0; ptr_out += 8; + * dataF8 = *ptr8_in++; + * + * data0 = HEXAGON_P_valignb_PPp(dataF8, data70, offset); + * ptr8_out = (s64 *) &ptr_out[0]; *ptr8_out = data0; ptr_out += 8; + * data70 = *ptr8_in++; + * + * data0 = HEXAGON_P_valignb_PPp(data70, dataF8, offset); + * ptr8_out = (s64 *) &ptr_out[0]; *ptr8_out = data0; ptr_out += 8; + * dataF8 = *ptr8_in++; + * } + * epilogdws = epilog >> 3; + * if (epilogdws) for (i=0; i < epilogdws; i++) { + * data0 = HEXAGON_P_valignb_PPp(dataF8, data70, offset); + * ptr8_out = (s64 *) &ptr_out[0]; *ptr8_out = data0; ptr_out += 8; + * data70 = dataF8; + * dataF8 = *ptr8_in++; + * } + * data0 = HEXAGON_P_valignb_PPp(dataF8, data70, offset); + * + * ptr4 = (s32 *) &ptr_out[0]; + * if (epilog & 4) { ptr4[0] = (u32) data0; data0 >>= 32; ptr_out += 4;} + * ptr2 = (s16 *) &ptr_out[0]; + * if (epilog & 2) { ptr2[0] = (u16) data0; data0 >>= 16; ptr_out += 2;} + * if (epilog & 1) { *ptr_out++ = (u8) data0; } + * + * return(ptr_out - length); + * } + * + * Codesize : 784 bytes + */ + + +#define ptr_out R0 /* destination pounter */ +#define ptr_in R1 /* source pointer */ +#define len R2 /* length of copy in bytes */ + +#define data70 R13:12 /* lo 8 bytes of non-aligned transfer */ +#define dataF8 R11:10 /* hi 8 bytes of non-aligned transfer */ +#define ldata0 R7:6 /* even 8 bytes chunks */ +#define ldata1 R25:24 /* odd 8 bytes chunks */ +#define data1 R7 /* lower 8 bytes of ldata1 */ +#define data0 R6 /* lower 8 bytes of ldata0 */ + +#define ifbyte p0 /* if transfer has bytes in epilog/prolog */ +#define ifhword p0 /* if transfer has shorts in epilog/prolog */ +#define ifword p0 /* if transfer has words in epilog/prolog */ +#define noprolog p0 /* no prolog, xfer starts at 32byte */ +#define nokernel p1 /* no 32byte multiple block in the transfer */ +#define noepilog p0 /* no epilog, xfer ends on 32byte boundary */ +#define align p2 /* alignment of input rel to 8byte boundary */ +#define kernel1 p0 /* kernel count == 1 */ + +#define dalign R25 /* rel alignment of input to output data */ +#define star3 R16 /* number bytes in prolog - dwords */ +#define rest R8 /* length - prolog bytes */ +#define back R7 /* nr bytes > dword boundary in src block */ +#define epilog R3 /* bytes in epilog */ +#define inc R15:14 /* inc kernel by -1 and defetch ptr by 32 */ +#define kernel R4 /* number of 32byte chunks in kernel */ +#define ptr_in_p_128 R5 /* pointer for prefetch of input data */ +#define mask R8 /* mask used to determine prolog size */ +#define shift R8 /* used to work a shifter to extract bytes */ +#define shift2 R5 /* in epilog to workshifter to extract bytes */ +#define prolog R15 /* bytes in prolog */ +#define epilogdws R15 /* number dwords in epilog */ +#define shiftb R14 /* used to extract bytes */ +#define offset R9 /* same as align in reg */ +#define ptr_out_p_32 R17 /* pointer to output dczero */ +#define align888 R14 /* if simple dword loop can be used */ +#define len8 R9 /* number of dwords in length */ +#define over R20 /* nr of bytes > last inp buf dword boundary */ + +#define ptr_in_p_128kernel R5:4 /* packed fetch pointer & kernel cnt */ + + .section .text + .p2align 4 + .global memcpy + .type memcpy, @function +memcpy: +{ + p2 = cmp.eq(len, #0); /* =0 */ + align888 = or(ptr_in, ptr_out); /* %8 < 97 */ + p0 = cmp.gtu(len, #23); /* %1, <24 */ + p1 = cmp.eq(ptr_in, ptr_out); /* attempt to overwrite self */ +} +{ + p1 = or(p2, p1); + p3 = cmp.gtu(len, #95); /* %8 < 97 */ + align888 = or(align888, len); /* %8 < 97 */ + len8 = lsr(len, #3); /* %8 < 97 */ +} +{ + dcfetch(ptr_in); /* zero/ptrin=ptrout causes fetch */ + p2 = bitsclr(align888, #7); /* %8 < 97 */ + if(p1) jumpr r31; /* =0 */ +} +{ + p2 = and(p2,!p3); /* %8 < 97 */ + if (p2.new) len = add(len, #-8); /* %8 < 97 */ + if (p2.new) jump:NT .Ldwordaligned; /* %8 < 97 */ +} +{ + if(!p0) jump .Lbytes23orless; /* %1, <24 */ + mask.l = #LO(0x7fffffff); + /* all bytes before line multiples of data */ + prolog = sub(#0, ptr_out); +} +{ + /* save r31 on stack, decrement sp by 16 */ + allocframe(#24); + mask.h = #HI(0x7fffffff); + ptr_in_p_128 = add(ptr_in, #32); + back = cl0(len); +} +{ + memd(sp+#0) = R17:16; /* save r16,r17 on stack6 */ + r31.l = #LO(.Lmemcpy_return); /* set up final return pointer */ + prolog &= lsr(mask, back); + offset = and(ptr_in, #7); +} +{ + memd(sp+#8) = R25:24; /* save r25,r24 on stack */ + dalign = sub(ptr_out, ptr_in); + r31.h = #HI(.Lmemcpy_return); /* set up final return pointer */ +} +{ + /* see if there if input buffer end if aligned */ + over = add(len, ptr_in); + back = add(len, offset); + memd(sp+#16) = R21:20; /* save r20,r21 on stack */ +} +{ + noprolog = bitsclr(prolog, #7); + prolog = and(prolog, #31); + dcfetch(ptr_in_p_128); + ptr_in_p_128 = add(ptr_in_p_128, #32); +} +{ + kernel = sub(len, prolog); + shift = asl(prolog, #3); + star3 = and(prolog, #7); + ptr_in = and(ptr_in, #-8); +} +{ + prolog = lsr(prolog, #3); + epilog = and(kernel, #31); + ptr_out_p_32 = add(ptr_out, prolog); + over = and(over, #7); +} +{ + p3 = cmp.gtu(back, #8); + kernel = lsr(kernel, #5); + dcfetch(ptr_in_p_128); + ptr_in_p_128 = add(ptr_in_p_128, #32); +} +{ + p1 = cmp.eq(prolog, #0); + if(!p1.new) prolog = add(prolog, #1); + dcfetch(ptr_in_p_128); /* reserve the line 64bytes on */ + ptr_in_p_128 = add(ptr_in_p_128, #32); +} +{ + nokernel = cmp.eq(kernel,#0); + dcfetch(ptr_in_p_128); /* reserve the line 64bytes on */ + ptr_in_p_128 = add(ptr_in_p_128, #32); + shiftb = and(shift, #8); +} +{ + dcfetch(ptr_in_p_128); /* reserve the line 64bytes on */ + ptr_in_p_128 = add(ptr_in_p_128, #32); + if(nokernel) jump .Lskip64; + p2 = cmp.eq(kernel, #1); /* skip ovr if kernel == 0 */ +} +{ + dczeroa(ptr_out_p_32); + /* don't advance pointer */ + if(!p2) ptr_out_p_32 = add(ptr_out_p_32, #32); +} +{ + dalign = and(dalign, #31); + dczeroa(ptr_out_p_32); +} +.Lskip64: +{ + data70 = memd(ptr_in++#16); + if(p3) dataF8 = memd(ptr_in+#8); + if(noprolog) jump .Lnoprolog32; + align = offset; +} +/* upto initial 7 bytes */ +{ + ldata0 = valignb(dataF8, data70, align); + ifbyte = tstbit(shift,#3); + offset = add(offset, star3); +} +{ + if(ifbyte) memb(ptr_out++#1) = data0; + ldata0 = lsr(ldata0, shiftb); + shiftb = and(shift, #16); + ifhword = tstbit(shift,#4); +} +{ + if(ifhword) memh(ptr_out++#2) = data0; + ldata0 = lsr(ldata0, shiftb); + ifword = tstbit(shift,#5); + p2 = cmp.gtu(offset, #7); +} +{ + if(ifword) memw(ptr_out++#4) = data0; + if(p2) data70 = dataF8; + if(p2) dataF8 = memd(ptr_in++#8); /* another 8 bytes */ + align = offset; +} +.Lnoprolog32: +{ + p3 = sp1loop0(.Ldword_loop_prolog, prolog) + rest = sub(len, star3); /* whats left after the loop */ + p0 = cmp.gt(over, #0); +} + if(p0) rest = add(rest, #16); +.Ldword_loop_prolog: +{ + if(p3) memd(ptr_out++#8) = ldata0; + ldata0 = valignb(dataF8, data70, align); + p0 = cmp.gt(rest, #16); +} +{ + data70 = dataF8; + if(p0) dataF8 = memd(ptr_in++#8); + rest = add(rest, #-8); +}:endloop0 +.Lkernel: +{ + /* kernel is at least 32bytes */ + p3 = cmp.gtu(kernel, #0); + /* last itn. remove edge effects */ + if(p3.new) kernel = add(kernel, #-1); + /* dealt with in last dword loop */ + if(p3.new) epilog = add(epilog, #32); +} +{ + nokernel = cmp.eq(kernel, #0); /* after adjustment, recheck */ + if(nokernel.new) jump:NT .Lepilog; /* likely not taken */ + inc = combine(#32, #-1); + p3 = cmp.gtu(dalign, #24); +} +{ + if(p3) jump .Lodd_alignment; +} +{ + loop0(.Loword_loop_25to31, kernel); + kernel1 = cmp.gtu(kernel, #1); + rest = kernel; +} + .falign +.Loword_loop_25to31: +{ + dcfetch(ptr_in_p_128); /* prefetch 4 lines ahead */ + if(kernel1) ptr_out_p_32 = add(ptr_out_p_32, #32); +} +{ + dczeroa(ptr_out_p_32); /* reserve the next 32bytes in cache */ + p3 = cmp.eq(kernel, rest); +} +{ + /* kernel -= 1 */ + ptr_in_p_128kernel = vaddw(ptr_in_p_128kernel, inc); + /* kill write on first iteration */ + if(!p3) memd(ptr_out++#8) = ldata1; + ldata1 = valignb(dataF8, data70, align); + data70 = memd(ptr_in++#8); +} +{ + memd(ptr_out++#8) = ldata0; + ldata0 = valignb(data70, dataF8, align); + dataF8 = memd(ptr_in++#8); +} +{ + memd(ptr_out++#8) = ldata1; + ldata1 = valignb(dataF8, data70, align); + data70 = memd(ptr_in++#8); +} +{ + memd(ptr_out++#8) = ldata0; + ldata0 = valignb(data70, dataF8, align); + dataF8 = memd(ptr_in++#8); + kernel1 = cmp.gtu(kernel, #1); +}:endloop0 +{ + memd(ptr_out++#8) = ldata1; + jump .Lepilog; +} +.Lodd_alignment: +{ + loop0(.Loword_loop_00to24, kernel); + kernel1 = cmp.gtu(kernel, #1); + rest = add(kernel, #-1); +} + .falign +.Loword_loop_00to24: +{ + dcfetch(ptr_in_p_128); /* prefetch 4 lines ahead */ + ptr_in_p_128kernel = vaddw(ptr_in_p_128kernel, inc); + if(kernel1) ptr_out_p_32 = add(ptr_out_p_32, #32); +} +{ + dczeroa(ptr_out_p_32); /* reserve the next 32bytes in cache */ +} +{ + memd(ptr_out++#8) = ldata0; + ldata0 = valignb(dataF8, data70, align); + data70 = memd(ptr_in++#8); +} +{ + memd(ptr_out++#8) = ldata0; + ldata0 = valignb(data70, dataF8, align); + dataF8 = memd(ptr_in++#8); +} +{ + memd(ptr_out++#8) = ldata0; + ldata0 = valignb(dataF8, data70, align); + data70 = memd(ptr_in++#8); +} +{ + memd(ptr_out++#8) = ldata0; + ldata0 = valignb(data70, dataF8, align); + dataF8 = memd(ptr_in++#8); + kernel1 = cmp.gtu(kernel, #1); +}:endloop0 +.Lepilog: +{ + noepilog = cmp.eq(epilog,#0); + epilogdws = lsr(epilog, #3); + kernel = and(epilog, #7); +} +{ + if(noepilog) jumpr r31; + if(noepilog) ptr_out = sub(ptr_out, len); + p3 = cmp.eq(epilogdws, #0); + shift2 = asl(epilog, #3); +} +{ + shiftb = and(shift2, #32); + ifword = tstbit(epilog,#2); + if(p3) jump .Lepilog60; + if(!p3) epilog = add(epilog, #-16); +} +{ + loop0(.Ldword_loop_epilog, epilogdws); + /* stop criteria is lsbs unless = 0 then its 8 */ + p3 = cmp.eq(kernel, #0); + if(p3.new) kernel= #8; + p1 = cmp.gt(over, #0); +} + /* if not aligned to end of buffer execute 1 more iteration */ + if(p1) kernel= #0; +.Ldword_loop_epilog: +{ + memd(ptr_out++#8) = ldata0; + ldata0 = valignb(dataF8, data70, align); + p3 = cmp.gt(epilog, kernel); +} +{ + data70 = dataF8; + if(p3) dataF8 = memd(ptr_in++#8); + epilog = add(epilog, #-8); +}:endloop0 +/* copy last 7 bytes */ +.Lepilog60: +{ + if(ifword) memw(ptr_out++#4) = data0; + ldata0 = lsr(ldata0, shiftb); + ifhword = tstbit(epilog,#1); + shiftb = and(shift2, #16); +} +{ + if(ifhword) memh(ptr_out++#2) = data0; + ldata0 = lsr(ldata0, shiftb); + ifbyte = tstbit(epilog,#0); + if(ifbyte.new) len = add(len, #-1); +} +{ + if(ifbyte) memb(ptr_out) = data0; + ptr_out = sub(ptr_out, len); /* return dest pointer */ + jumpr r31; +} +/* do byte copy for small n */ +.Lbytes23orless: +{ + p3 = sp1loop0(.Lbyte_copy, len); + len = add(len, #-1); +} +.Lbyte_copy: +{ + data0 = memb(ptr_in++#1); + if(p3) memb(ptr_out++#1) = data0; +}:endloop0 +{ + memb(ptr_out) = data0; + ptr_out = sub(ptr_out, len); + jumpr r31; +} +/* do dword copies for aligned in, out and length */ +.Ldwordaligned: +{ + p3 = sp1loop0(.Ldword_copy, len8); +} +.Ldword_copy: +{ + if(p3) memd(ptr_out++#8) = ldata0; + ldata0 = memd(ptr_in++#8); +}:endloop0 +{ + memd(ptr_out) = ldata0; + ptr_out = sub(ptr_out, len); + jumpr r31; /* return to function caller */ +} +.Lmemcpy_return: + r21:20 = memd(sp+#16); /* restore r20+r21 */ +{ + r25:24 = memd(sp+#8); /* restore r24+r25 */ + r17:16 = memd(sp+#0); /* restore r16+r17 */ +} + deallocframe; /* restore r31 and incrment stack by 16 */ + jumpr r31
arch/hexagon/lib/memset.S new file +316 -0
316 lines not on this page · raw message
--
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
PATCH v3 11/36 Hexagon: Add hypervisor interface
In reply to Richard KuoThe port of Linux for Hexagon runs on top of a hypervisor layer, which presents an interface for memory management, events, hardware control, etc.
--- arch/hexagon/include/asm/hexagon_vm.h | 281 ++++++++++++++++++++ arch/hexagon/include/asm/vm_mmu.h | 111 ++++++++ arch/hexagon/kernel/vm_entry.S | 269 ++++++++++++++++++++ arch/hexagon/kernel/vm_events.c | 101 +++++++ arch/hexagon/kernel/vm_init_segtable.S | 442 +++++++++++++++++++++++++++++++++ arch/hexagon/kernel/vm_ops.S | 102 +++++++ arch/hexagon/kernel/vm_switch.S | 95 +++++++ arch/hexagon/kernel/vm_vectors.S | 50 +++ 8 files changed, 1451 insertions(+)
arch/hexagon/include/asm/hexagon_vm.h new file +281 -0
@@ -0,0 +1,281 @@ +/* +* Declarations for to Hexagon Virtal Machine. +* +* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#ifndef ASM_HEXAGON_VM_H +#define ASM_HEXAGON_VM_H + +/* +* In principle, a Linux kernel for the VM could +* selectively define the virtual instructions +* as inline assembler macros, but for a first pass, +* we'll use subroutines for both the VM and the native +* kernels. It's costing a subroutine call/return, +* but it makes for a single set of entry points +* for tracing/debugging. +*/ + +/* +* Lets make this stuff visible only if configured, +* so we can unconditionally include the file. +*/ + +#ifndef __ASSEMBLY__ + +enum VM_CACHE_OPS { + ickill, + dckill, + l2kill, + dccleaninva, + icinva, + idsync, + fetch_cfg +}; + +enum VM_INT_OPS { + nop, + globen, + globdis, + locen, + locdis, + affinity, + get, + peek, + status, + post, + clear +}; + +extern void _K_VM_event_vector (void ); + +void __vmrte (void ); +long __vmsetvec (void *); +long __vmsetie (long ); +long __vmgetie (void ); +long __vmintop (enum VM_INT_OPS ,long ,long ,long ,long ); +long __vmclrmap (void *,unsigned long ); +long __vmnewmap (void *); +long __vmcache (enum VM_CACHE_OPS op,unsigned long addr,unsigned long len); +unsigned long long __vmgettime (void ); +long __vmsettime (unsigned long long ); +long __vmstart (void *,void *); +void __vmstop (void ); +long __vmwait (void ); +void __vmyield (void ); +long __vmvpid (void ); + +static inline long __vmcache_ickill (void ) +{ +return __vmcache (ickill,0 ,0 ); +} + +static inline long __vmcache_dckill (void ) +{ +return __vmcache (dckill,0 ,0 ); +} + +static inline long __vmcache_l2kill (void ) +{ +return __vmcache (l2kill,0 ,0 ); +} + +static inline long __vmcache_dccleaninva (unsigned long addr,unsigned long len) +{ +return __vmcache (dccleaninva, addr, len); +} + +static inline long __vmcache_icinva (unsigned long addr,unsigned long len) +{ +return __vmcache (icinva, addr, len); +} + +static inline long __vmcache_idsync (unsigned long addr, +unsigned long len) +{ +return __vmcache (idsync, addr, len); +} + +static inline long __vmcache_fetch_cfg (unsigned long val) +{ +return __vmcache (fetch_cfg, val,0 ); +} + +/* interrupt operations */ + +static inline long __vmintop_nop (void ) +{ +return __vmintop (nop,0 ,0 ,0 ,0 ); +} + +static inline long __vmintop_globen (long i) +{ +return __vmintop (globen, i,0 ,0 ,0 ); +} + +static inline long __vmintop_globdis (long i) +{ +return __vmintop (globdis, i,0 ,0 ,0 ); +} + +static inline long __vmintop_locen (long i) +{ +return __vmintop (locen, i,0 ,0 ,0 ); +} + +static inline long __vmintop_locdis (long i) +{ +return __vmintop (locdis, i,0 ,0 ,0 ); +} + +static inline long __vmintop_affinity (long i,long cpu) +{ +return __vmintop (locdis, i, cpu,0 ,0 ); +} + +static inline long __vmintop_get (void ) +{ +return __vmintop (get,0 ,0 ,0 ,0 ); +} + +static inline long __vmintop_peek (void ) +{ +return __vmintop (peek,0 ,0 ,0 ,0 ); +} + +static inline long __vmintop_status (long i) +{ +return __vmintop (status, i,0 ,0 ,0 ); +} + +static inline long __vmintop_post (long i) +{ +return __vmintop (post, i,0 ,0 ,0 ); +} + +static inline long __vmintop_clear (long i) +{ +return __vmintop (clear, i,0 ,0 ,0 ); +} + +#else /* Only assembly code should reference these */ + +#define HVM_TRAP1_VMRTE 1 +#define HVM_TRAP1_VMSETVEC 2 +#define HVM_TRAP1_VMSETIE 3 +#define HVM_TRAP1_VMGETIE 4 +#define HVM_TRAP1_VMINTOP 5 +#define HVM_TRAP1_VMCLRMAP 10 +#define HVM_TRAP1_VMNEWMAP 11 +#define HVM_TRAP1_FORMERLY_VMWIRE 12 +#define HVM_TRAP1_VMCACHE 13 +#define HVM_TRAP1_VMGETTIME 14 +#define HVM_TRAP1_VMSETTIME 15 +#define HVM_TRAP1_VMWAIT 16 +#define HVM_TRAP1_VMYIELD 17 +#define HVM_TRAP1_VMSTART 18 +#define HVM_TRAP1_VMSTOP 19 +#define HVM_TRAP1_VMVPID 20 +#define HVM_TRAP1_VMSETREGS 21 +#define HVM_TRAP1_VMGETREGS 22 + +#endif /* __ASSEMBLY__ */ + +/* +* Constants for virtual instruction parameters and return values +*/ + +/* vmsetie arguments */ + +#define VM_INT_DISABLE 0 +#define VM_INT_ENABLE 1 + +/* vmsetimask arguments */ + +#define VM_INT_UNMASK 0 +#define VM_INT_MASK 1 + +#define VM_NEWMAP_TYPE_LINEAR 0 +#define VM_NEWMAP_TYPE_PGTABLES 1 + + +/* +* Event Record definitions useful to both C and Assembler +*/ + +/* VMEST Layout */ + +#define HVM_VMEST_UM_SFT 31 +#define HVM_VMEST_UM_MSK 1 +#define HVM_VMEST_IE_SFT 30 +#define HVM_VMEST_IE_MSK 1 +#define HVM_VMEST_EVENTNUM_SFT 16 +#define HVM_VMEST_EVENTNUM_MSK 0xff +#define HVM_VMEST_CAUSE_SFT 0 +#define HVM_VMEST_CAUSE_MSK 0xffff + +/* +* The initial program gets to find a system environment descriptor +* on its stack when it begins exection. The first word is a version +* code to indicate what is there. Zero means nothing more. +*/ + +#define HEXAGON_VM_SED_NULL 0 + +/* +* Event numbers for vector binding +*/ + +#define HVM_EV_RESET 0 +#define HVM_EV_MACHCHECK 1 +#define HVM_EV_GENEX 2 +#define HVM_EV_TRAP 8 +#define HVM_EV_INTR 15 +/* These shoud be nuked as soon as we know the VM is up to spec v0.1.1 */ +#define HVM_EV_INTR_0 16 +#define HVM_MAX_INTR 240 + +/* +* Cause values for General Exception +*/ + +#define HVM_GE_C_BUS 0x01 +#define HVM_GE_C_XPROT 0x11 +#define HVM_GE_C_XUSER 0x14 +#define HVM_GE_C_INVI 0x15 +#define HVM_GE_C_PRIVI 0x1B +#define HVM_GE_C_XMAL 0x1C +#define HVM_GE_C_RMAL 0x20 +#define HVM_GE_C_WMAL 0x21 +#define HVM_GE_C_RPROT 0x22 +#define HVM_GE_C_WPROT 0x23 +#define HVM_GE_C_RUSER 0x24 +#define HVM_GE_C_WUSER 0x25 +#define HVM_GE_C_CACHE 0x28 + +/* +* Cause codes for Machine Check +*/ + +#define HVM_MCHK_C_DOWN 0x00 +#define HVM_MCHK_C_BADSP 0x01 +#define HVM_MCHK_C_BADEX 0x02 +#define HVM_MCHK_C_BADPT 0x03 +#define HVM_MCHK_C_REGWR 0x29 + +#endif
arch/hexagon/include/asm/vm_mmu.h new file +111 -0
111 lines not on this page · raw message
arch/hexagon/kernel/vm_entry.S new file +269 -0
269 lines not on this page · raw message
arch/hexagon/kernel/vm_events.c new file +101 -0
101 lines not on this page · raw message
arch/hexagon/kernel/vm_init_segtable.S new file +442 -0
442 lines not on this page · raw message
arch/hexagon/kernel/vm_ops.S new file +102 -0
102 lines not on this page · raw message
arch/hexagon/kernel/vm_switch.S new file +95 -0
95 lines not on this page · raw message
arch/hexagon/kernel/vm_vectors.S new file +50 -0
50 lines not on this page · raw message
--
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
PATCH v3 12/36 Hexagon: Export ksyms defined in assembly files.
In reply to Richard Kuo--- arch/hexagon/kernel/hexagon_ksyms.c | 42 ++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+)
arch/hexagon/kernel/hexagon_ksyms.c new file +42 -0
@@ -0,0 +1,42 @@ +/* +* Export of symbols defined in assembly files and/or libgcc. +* +* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#include <asm/hexagon_vm.h> +#include <asm/uaccess.h> + +EXPORT_SYMBOL (__copy_from_user_hexagon); +EXPORT_SYMBOL (__copy_to_user_hexagon); +EXPORT_SYMBOL (__vmgetie); +EXPORT_SYMBOL (__vmsetie); +EXPORT_SYMBOL (memcpy); +EXPORT_SYMBOL (memset); + +#define DECLARE_EXPORT (name) \ + extern void name(void); EXPORT_SYMBOL(name) + +/* Symbols found in libgcc that assorted kernel modules need */ +DECLARE_EXPORT (__hexagon_memcpy_likely_aligned_min32bytes_mult8bytes); + +DECLARE_EXPORT (__hexagon_divsi3); +DECLARE_EXPORT (__hexagon_modsi3); +DECLARE_EXPORT (__hexagon_udivsi3); +DECLARE_EXPORT (__hexagon_umodsi3); + +
--
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
PATCH v3 13/36 Hexagon: Support dynamic module loading.
In reply to Richard KuoModules should be compiled as ordinary .o's; shared objects are not supported.
Deleted module functions that already have generic equivalents.
--- arch/hexagon/kernel/module.c | 162 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 162 insertions(+)
arch/hexagon/kernel/module.c new file +162 -0
@@ -0,0 +1,162 @@ +/* +* Kernel module loader for Hexagon +* +* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#include <asm/module.h> +#include <linux/elf.h> +#include <linux/module.h> +#include <linux/moduleloader.h> +#include <linux/vmalloc.h> + +#if 0 +#define DEBUGP printk +#else +#define DEBUGP (fmt , ...) +#endif + +/* +* module_frob_arch_sections - tweak got/plt sections. +* @hdr - pointer to elf header +* @sechdrs - pointer to elf load section headers +* @secstrings - symbol names +* @mod - pointer to module +*/ +int module_frob_arch_sections (Elf_Ehdr *hdr,Elf_Shdr *sechdrs, +char *secstrings, +struct module *mod) +{ +unsigned int i; +int found =0 ; + +/* Look for .plt and/or .got.plt and/or .init.plt sections */ +for (i =0 ; i < hdr->e_shnum; i++) { +DEBUGP ("Section %d is %s\n" , i, + secstrings + sechdrs[i].sh_name); +if (strcmp (secstrings + sechdrs[i].sh_name,".plt" ) ==0 ) + found = i+1 ; +if (strcmp (secstrings + sechdrs[i].sh_name,".got.plt" ) ==0 ) + found = i+1 ; +if (strcmp (secstrings + sechdrs[i].sh_name,".rela.plt" ) ==0 ) + found = i+1 ; + } + +/* At this time, we don't support modules comiled with -shared */ +if (found) { +printk (KERN_WARNING +"Module '%s' contains unexpected .plt/.got sections.\n" , + mod->name); +/* return -ENOEXEC; */ + } + +return 0 ; +} + +/* +* apply_relocate_add - perform rela relocations. +* @sechdrs - pointer to section headers +* @strtab - some sort of start address? +* @symindex - symbol index offset or something? +* @relsec - address to relocate to? +* @module - pointer to module +* +* Perform rela relocations. +*/ +int apply_relocate_add (Elf_Shdr *sechdrs,const char *strtab, +unsigned int symindex,unsigned int relsec, +struct module *module) +{ +unsigned int i; +Elf32_Sym *sym; +uint32_t *location; +uint32_t value; +unsigned int nrelocs = sechdrs[relsec].sh_size /sizeof (Elf32_Rela); +Elf32_Rela *rela = (void *)sechdrs[relsec].sh_addr; +Elf32_Word sym_info = sechdrs[relsec].sh_info; +Elf32_Sym *sym_base = (Elf32_Sym *) sechdrs[symindex].sh_addr; +void *loc_base = (void *) sechdrs[sym_info].sh_addr; + +DEBUGP ("Applying relocations in section %u to section %u base=%p\n" , + relsec, sym_info, loc_base); + +for (i =0 ; i < nrelocs; i++) { + +/* Symbol to relocate */ + sym = sym_base +ELF32_R_SYM (rela[i].r_info); + +/* Where to make the change */ + location = loc_base + rela[i].r_offset; + +/* `Everything is relative'. */ + value = sym->st_value + rela[i].r_addend; + +DEBUGP ("%d: value=%08x loc=%p reloc=%d symbol=%s\n" , + i, value, location,ELF32_R_TYPE (rela[i].r_info), + sym->st_name ? + &strtab[sym->st_name] :"(anonymous)" ); + +switch (ELF32_R_TYPE (rela[i].r_info)) { +case R_HEXAGON_B22_PCREL : { +int dist = (int )(value - (uint32_t )location); +if ((dist <-0x00800000 ) || + (dist >=0x00800000 )) { +printk (KERN_ERR +"%s: %s: %08x=%08x-%08x %s\n" , + module->name, +"R_HEXAGON_B22_PCREL reloc out of range" , + dist, value, (uint32_t )location, + sym->st_name ? + &strtab[sym->st_name] :"(anonymous)" ); +return -ENOEXEC ; + } +DEBUGP ("B22_PCREL contents: %08X.\n" , *location); + *location &= ~0x01ff3fff ; + *location |=0x00003fff & dist; + *location |=0x01ff0000 & (dist<<2 ); +DEBUGP ("Contents after reloc: %08x\n" , *location); +break ; + } +case R_HEXAGON_HI16 : + value = (value>>16 ) &0xffff ; +/* fallthrough */ +case R_HEXAGON_LO16 : + *location &= ~0x00c03fff ; + *location |= value &0x3fff ; + *location |= (value &0xc000 ) <<8 ; +break ; +case R_HEXAGON_32 : + *location = value; +break ; +case R_HEXAGON_32_PCREL : + *location = value - (uint32_t )location; +break ; +case R_HEXAGON_PLT_B22_PCREL : +case R_HEXAGON_GOTOFF_LO16 : +case R_HEXAGON_GOTOFF_HI16 : +printk (KERN_ERR "%s: GOT/PLT relocations unsupported\n" , + module->name); +return -ENOEXEC ; +default : +printk (KERN_ERR "%s: unknown relocation: %u\n" , + module->name, +ELF32_R_TYPE (rela[i].r_info)); +return -ENOEXEC ; + } + } +return 0 ; +}
--
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
PATCH v3 14/36 Hexagon: Add signal functions
In reply to Richard KuoAdded vDSO support; signal trampoline is no longer on the stack so it no longer needs to be executable.
--- arch/hexagon/include/asm/sigcontext.h | 32 +++ arch/hexagon/include/asm/signal.h | 26 ++ arch/hexagon/include/asm/vdso.h | 31 +++ arch/hexagon/kernel/signal.c | 320 ++++++++++++++++++++++++++++++++++ arch/hexagon/kernel/trampoline.S | 35 +++ arch/hexagon/kernel/vdso.c | 101 ++++++++++ 6 files changed, 545 insertions(+)
arch/hexagon/include/asm/sigcontext.h new file +32 -0
@@ -0,0 +1,32 @@ +/* +* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#ifndef _ASM_SIGCONTEXT_H +#define _ASM_SIGCONTEXT_H + +#include <asm/registers.h> + +/* +* Signal context structure - contains all info to do with the state +* before the signal handler was invoked. +*/ +struct sigcontext { +struct pt_regs sc_regs; +}; + +#endif
arch/hexagon/include/asm/signal.h new file +26 -0
@@ -0,0 +1,26 @@ +/* +* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#ifndef _ASM_SIGNAL_H +#define _ASM_SIGNAL_H + +extern unsigned long __rt_sigtramp_template[2 ]; + +#include <asm-generic/signal.h> + +#endif
arch/hexagon/kernel/signal.c new file +320 -0
320 lines not on this page · raw message
arch/hexagon/kernel/trampoline.S new file +35 -0
@@ -0,0 +1,35 @@ +/* + * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 and + * only version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +/* + * Trampoline sequences to be copied onto user stack. + * This consumes a little more space than hand-assembling + * immediate constants for use in C, but is more portable + * to future tweaks to the Hexagon instruction set. + */ + +#include <asm/unistd.h> + +/* Sig trampolines - call sys_sigreturn or sys_rt_sigreturn as appropriate */ + +/* plain sigreturn is gone. */ + + .globl __rt_sigtramp_template +__rt_sigtramp_template: + r6 = #__NR_rt_sigreturn; + trap0(#1);
arch/hexagon/include/asm/vdso.h new file +31 -0
@@ -0,0 +1,31 @@ +/* +* vDSO implementation for Hexagon +* +* Copyright (c) 2011, Code Aurora Forum. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#ifndef __ASM_VDSO_H +#define __ASM_VDSO_H + +#include <linux/types.h> + +struct hexagon_vdso { +u32 rt_signal_trampoline[2 ]; +}; + +#endif /* __ASM_VDSO_H */ +
arch/hexagon/kernel/vdso.c new file +101 -0
101 lines not on this page · raw message
--
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Arnd Bergmann
maintainerRe: [patch v3 14/36] Hexagon: Add signal functions
arch/hexagon/include/asm/sigcontext.h line 30
Quoted 7 lines · On Thursday 08 September 2011 20:09:01 Richard Kuo wrote:
arch/hexagon/include/asm/sigcontext.h new file +7
-0+/* +* Signal context structure - contains all info to do with the state +* before the signal handler was invoked. +*/ +struct sigcontext { +struct pt_regs sc_regs; +};
I've recently discussed this with Martin Schwidefsky for an unrelated reason, but I think now that you should define the sigcontext independent of pt_regs. The pt_regs should really be internal
arch/hexagon/kernel/signal.c line 45
Quoted 11 lines
arch/hexagon/kernel/signal.c new file +11
-0+struct sigframe { +unsigned long pad[2 ];/* Used to be signal tramp */ +struct sigcontext sc; +sigset_t mask; +}; + +struct rt_sigframe { +unsigned long pad[2 ];/* Used to be signal tramp */ +struct siginfo info; +struct ucontext uc; +};
I hadn't noticed this earlier, but I think you can remove the struct sigframe definition. There should be absolutely no need to have both sigframe and rt_sigframe.
Arnd
Re: [patch v3 14/36] Hexagon: Add signal functions
In reply to Richard Kuoarch/hexagon/kernel/signal.c line 45
Quoted 13 lines · Richard Kuo
arch/hexagon/kernel/signal.c new file +13
-0+#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) + +struct sigframe { +unsigned long pad[2 ];/* Used to be signal tramp */ +struct sigcontext sc; +sigset_t mask; +}; + +struct rt_sigframe { +unsigned long pad[2 ];/* Used to be signal tramp */ +struct siginfo info; +struct ucontext uc; +};
Why did you make two types of signal frames ? It's an unnecessary complication... Dunno if you can still fix that (if you can still control your ABI that is), but you should look how ppc64 uses the same frame for RT and non-RT, avoids duplication of bugs :-)
Cheers,
Ben.
PATCH v3 15/36 Hexagon: Add init_task and process functions
In reply to Richard KuoFixed potential race-to-sleep condition in cpu_idle() and calling schedule with irq's disabled. I still have to have that extra enable/disbale in the while() loop else the interrupt never gets serviced, and thus need_resched() will always be false.
If called with interrupts disabled, our __vmwait() actually just returns without servicing it.
--- arch/hexagon/kernel/init_task.c | 54 +++++++ arch/hexagon/kernel/process.c | 279 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 333 insertions(+)
arch/hexagon/kernel/init_task.c new file +54 -0
@@ -0,0 +1,54 @@ +/* +* Init task definition +* +* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#include <linux/mm.h> +#include <linux/module.h> +#include <linux/sched.h> +#include <linux/init_task.h> +#include <linux/fs.h> +#include <linux/mqueue.h> +#include <asm/thread_info.h> +#include <asm/uaccess.h> +#include <asm/pgtable.h> + +static struct signal_struct init_signals =INIT_SIGNALS (init_signals); +static struct sighand_struct init_sighand =INIT_SIGHAND (init_sighand); + +/* +* Initial thread structure. +* +* We need to make sure that this is 8192-byte aligned due to the +* way process stacks are handled. This is done by making sure +* the linker maps this in the .text segment right after head.S, +* and making head.S ensure the proper alignment. +*/ +union thread_union init_thread_union + __attribute__((__section__(".data.init_task"), + __aligned__(THREAD_SIZE))) = { + INIT_THREAD_INFO(init_task) + }; + +/* +* Initial task structure. +* +* All other task structs will be allocated on slabs in fork.c +*/ +struct task_struct init_task =INIT_TASK (init_task); +EXPORT_SYMBOL (init_task);
arch/hexagon/kernel/process.c new file +279 -0
279 lines not on this page · raw message
--
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
PATCH v3 16/36 Hexagon: Add startup code
In reply to Richard Kuo--- arch/hexagon/kernel/head.S | 162 ++++++++++++++++++++++++++++++++++++++++++++ arch/hexagon/kernel/reset.c | 38 ++++++++++ arch/hexagon/kernel/setup.c | 145 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 345 insertions(+)
arch/hexagon/kernel/head.S new file +162 -0
@@ -0,0 +1,162 @@ +/* + * Early kernel startup code for Hexagon + * + * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 and + * only version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +#include <linux/linkage.h> +#include <linux/init.h> +#include <asm/asm-offsets.h> +#include <asm/mem-layout.h> +#include <asm/vm_mmu.h> +#include <asm/page.h> + + __INIT +ENTRY(stext) + /* + * VMM will already have set up true vector page, MMU, etc. + * To set up initial kernel identity map, we have to pass + * the VMM a pointer to some canonical page tables. In + * this implementation, we're assuming that we've got + * them precompiled. Generate value in R24, as we'll need + * it again shortly. + */ + r24.L = #LO(swapper_pg_dir) + r24.H = #HI(swapper_pg_dir) + + /* + * Symbol is kernel segment address, but we need + * the logical/physical address. + */ + r24 = asl(r24, #2) + r24 = lsr(r24, #2) + + r0 = r24 + + /* + * Initialize a 16MB PTE to make the virtual and physical + * addresses where the kernel was loaded be identical. + */ +#define PTE_BITS ( __HVM_PTE_R | __HVM_PTE_W | __HVM_PTE_X \ + | __HEXAGON_C_WB_L2 << 6 \ + | __HVM_PDE_S_4MB) + + r1 = pc + r2.H = #0xffc0 + r2.L = #0x0000 + r1 = and(r1,r2) /* round PC to 4MB boundary */ + r2 = lsr(r1, #22) /* 4MB page number */ + r2 = asl(r2, #2) /* times sizeof(PTE) (4bytes) */ + r0 = add(r0,r2) /* r0 = address of correct PTE */ + r2 = #PTE_BITS + r1 = add(r1,r2) /* r1 = 4MB PTE for the first entry */ + r2.h = #0x0040 + r2.l = #0x0000 /* 4MB */ + memw(r0 ++ #4) = r1 + r1 = add(r1, r2) + memw(r0 ++ #4) = r1 + + r0 = r24 + + /* + * The subroutine wrapper around the virtual instruction touches + * no memory, so we should be able to use it even here. + */ + call __vmnewmap; + + /* Jump into virtual address range. */ + + r31.h = #hi(__head_s_vaddr_target) + r31.l = #lo(__head_s_vaddr_target) + jumpr r31 + + /* Insert trippy space effects. */ + +__head_s_vaddr_target: + /* + * Tear down VA=PA translation now that we are running + * in the desgnated kernel segments. + */ + r0 = #__HVM_PDE_S_INVALID + r1 = r24 + loop0(1f,#0x100) +1: + { + memw(R1 ++ #4) = R0 + }:endloop0 + + r0 = r24 + call __vmnewmap + + /* Go ahead and install the trap0 return so angel calls work */ + r0.h = #hi(_K_provisional_vec) + r0.l = #lo(_K_provisional_vec) + call __vmsetvec + + /* + * OK, at this point we should start to be much more careful, + * we're going to enter C code and start touching memory + * in all sorts of places. + * This means: + * SGP needs to be OK + * Need to lock shared resources + * A bunch of other things that will cause + * all kinds of painful bugs + */ + + /* + * Stack pointer should be pointed at the init task's + * thread stack, which should have been declared in arch/init_task.c. + * So uhhhhh... + * It's accessible via the init_thread_union, which is a union + * of a thread_info struct and a stack; of course, the top + * of the stack is not for you. The end of the stack + * is simply init_thread_union + THREAD_SIZE. + */ + + {r29.H = #HI(init_thread_union); r0.H = #HI(_THREAD_SIZE); } + {r29.L = #LO(init_thread_union); r0.L = #LO(_THREAD_SIZE); } + + /* initialize the register used to point to current_thread_info */ + /* Fixme: THREADINFO_REG can't be R2 because of that memset thing. */ + {r29 = add(r29,r0); THREADINFO_REG = r29; } + + /* Hack: zero bss; */ + { r0.L = #LO(__bss_start); r1 = #0; r2.l = #LO(__bss_stop); } + { r0.H = #HI(__bss_start); r2.h = #HI(__bss_stop); } + + r2 = sub(r2,r0); + call memset; + + /* Time to make the doughnuts. */ + call start_kernel + + /* + * Should not reach here. + */ +1: + jump 1b + +.p2align PAGE_SHIFT +ENTRY(external_cmdline_buffer) + .fill _PAGE_SIZE,1,0 + +.data +.p2align PAGE_SHIFT +ENTRY(empty_zero_page) + .fill _PAGE_SIZE,1,0
arch/hexagon/kernel/reset.c new file +38 -0
@@ -0,0 +1,38 @@ +/* +* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#include <linux/smp.h> +#include <asm/hexagon_vm.h> + +void machine_power_off (void ) +{ +smp_send_stop (); +__vmstop (); +} + +void machine_halt (void ) +{ +} + +void machine_restart (char *cmd) +{ +} + +void pm_power_off (void ) +{ +}
arch/hexagon/kernel/setup.c new file +145 -0
145 lines not on this page · raw message
--
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
PATCH v3 17/36 Hexagon: Add interrupts
In reply to Richard KuoRemoved init_IRQ wrapper and fixed up some comments.
--- arch/hexagon/include/asm/irq.h | 36 ++++++++++++++++ arch/hexagon/kernel/irq.c | 67 ++++++++++++++++++++++++++++++ arch/hexagon/kernel/irq_cpu.c | 90 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 193 insertions(+)
arch/hexagon/include/asm/irq.h new file +36 -0
@@ -0,0 +1,36 @@ +/* +* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#ifndef _ASM_IRQ_H_ +#define _ASM_IRQ_H_ + +/* Number of first-level interrupts associated with the CPU core. */ +#define HEXAGON_CPUINTS 32 + +/* +* Must define NR_IRQS before including <asm-generic/irq.h> +* 64 == the two SIRC's, 176 == the two gpio's +* +* IRQ configuration is still in flux; defining this to a comfortably +* large number. +*/ +#define NR_IRQS 512 + +#include <asm-generic/irq.h> + +#endif
arch/hexagon/kernel/irq.c new file +67 -0
67 lines not on this page · raw message
arch/hexagon/kernel/irq_cpu.c new file +90 -0
90 lines not on this page · raw message
--
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Re: [patch v3 17/36] Hexagon: Add interrupts
Quoted 3 lines · Richard Kuo
Removed
init_IRQwrapper and fixed up some comments.+int
show_interrupts(struct seq_file *p, void *v)
Please use the generic version of show_interrupts.
Otherwise please add:
Re: [patch v3 17/36] Hexagon: Add interrupts
In reply to Richard KuoQuoted 4 lines · Richard Kuo
Removed
init_IRQwrapper and fixed up some comments.Signed-off-by Richard Kuo <[email protected]>Acked-by Arnd Bergmann <[email protected]>
This should have a
since I think I wrote about 100% of some of these files...
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
PATCH v3 18/36 Hexagon: Add time and timer functions
In reply to Richard KuoCleaned up iomem and register declarations, unnecessary SMP ifdefs, cpu_relax() in udelay.
Platform stuff is in development; platform defines will be cleaned up.
--- arch/hexagon/include/asm/time.h | 29 +++ arch/hexagon/include/asm/timer-regs.h | 39 ++++ arch/hexagon/kernel/time.c | 275 ++++++++++++++++++++++++++++++++++ 3 files changed, 343 insertions(+)
arch/hexagon/include/asm/time.h new file +29 -0
@@ -0,0 +1,29 @@ +/* +* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#ifndef ASM_TIME_H +#define ASM_TIME_H + +extern cycles_t pcycle_freq_mhz; +extern cycles_t thread_freq_mhz; +extern cycles_t sleep_clk_freq; + +void setup_percpu_clockdev (void ); +void ipi_timer (void ); + +#endif
arch/hexagon/include/asm/timer-regs.h new file +39 -0
@@ -0,0 +1,39 @@ +/* +* Timer support for Hexagon +* +* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#ifndef _ASM_TIMER_REGS_H +#define _ASM_TIMER_REGS_H + +/* This stuff should go into a platform specific file */ +#define TCX0_CLK_RATE 19200 +#define TIMER_ENABLE 0 +#define TIMER_CLR_ON_MATCH 1 + +/* +* 8x50 HDD Specs 5-8. Simulator co-sim not fixed until +* release 1.1, and then it's "adjustable" and probably not defaulted. +*/ +#define RTOS_TIMER_INT 3 +#ifdef CONFIG_HEXAGON_COMET +#define RTOS_TIMER_REGS_ADDR 0xAB000000UL +#endif +#define SLEEP_CLK_RATE 32000 + +#endif
arch/hexagon/kernel/time.c new file +275 -0
275 lines not on this page · raw message
--
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Re: [patch v3 18/36] Hexagon: Add time and timer functions
arch/hexagon/include/asm/timer-regs.h line 37
Quoted 9 lines
+ * 8x50 HDD Specs 5-8. Simulator co-sim not fixed until
+ * release 1.1, and then it's "adjustable" and probably not defaulted.
+ */arch/hexagon/include/asm/timer-regs.h new file +5
-0+#define RTOS_TIMER_INT 3 +#ifdef CONFIG_HEXAGON_COMET +#define RTOS_TIMER_REGS_ADDR 0xAB000000UL +#endif +#define SLEEP_CLK_RATE 32000
I think it would be better to pull RTOS_TIMER_REGS_ADDR from the device tree, but this is probably good enough for 3.2.
Re: [patch v3 18/36] Hexagon: Add time and timer functions
In reply to Richard Kuoarch/hexagon/kernel/time.c line 90
Quoted 9 lines · Richard Kuo
arch/hexagon/kernel/time.c new file +9
-0+static cycle_t timer_get_cycles (struct clocksource *cs) +{ +return (cycle_t )__vmgettime (); +} + +static struct clocksource hexagon_clocksource = { + .name ="pcycles" , + .rating =250 , + .shift =16 ,
clocksource_register_khz() calcs mult and shift.
arch/hexagon/kernel/time.c line 134
Quoted 11 lines
arch/hexagon/kernel/time.c new file +10
-0+ .read = timer_get_cycles, + .mask = CLOCKSOURCE_MASK(64), + .flags = CLOCK_SOURCE_IS_CONTINUOUS, +}; + +static struct clock_event_device hexagon_clockevent_dev = { + .name ="clockevent" , + .features =CLOCK_EVT_FEAT_ONESHOT , + .rating =400 , + .shift =32 ,
You recalc this shift as well
Quoted 4 lines
arch/hexagon/kernel/time.c new file +4
-0+ .irq = RTOS_TIMER_INT, + .set_next_event = set_next_event, + .set_mode = set_mode, +#ifdef CONFIG_SMP
arch/hexagon/kernel/time.c line 167
Quoted 10 lines
arch/hexagon/kernel/time.c new file +9
-0+ .broadcast = broadcast, +#endif +}; + +/* Called from smp.c for each CPU's timer ipi call */ +void ipi_timer (void ) +{ +int cpu =smp_processor_id (); +struct clock_event_device *ce_dev = &hexagon_clockevent_dev;
This initialization is pointless
Quoted 9 lines
arch/hexagon/kernel/time.c new file +9
-0+ ce_dev = &per_cpu (clock_events, cpu); + ce_dev->event_handler(ce_dev); +} +#endif /* CONFIG_SMP */ + +static irqreturn_t timer_interrupt (int irq,void *devid) +{ +struct clock_event_device *ce_dev = &hexagon_clockevent_dev; +
arch/hexagon/kernel/time.c line 187
Quoted 10 lines
arch/hexagon/kernel/time.c new file +10
-0+ rtos_timer->enable =0 ; + ce_dev->event_handler (ce_dev); + +return IRQ_HANDLED ; +} + +/* This should also be pulled from devtree */ +static struct irqaction rtos_timer_intdesc = { + .handler = timer_interrupt, + .flags =IRQF_DISABLED |IRQF_TIMER |IRQF_TRIGGER_RISING ,
IRQF_DISABLED is about to be gone and IRQF_TIMER has it already.
Quoted 4 lines
arch/hexagon/kernel/time.c new file +4
-0+ .name = "rtos_timer" +}; + +void clocksource_debug (struct clocksource *cs)
arch/hexagon/kernel/time.c line 201
Quoted 10 lines
arch/hexagon/kernel/time.c new file +10
-0+{ +printk (KERN_DEBUG "cs->mult=0x%08x\n" , cs->mult); +printk (KERN_DEBUG "cs->shift=%d\n" , cs->shift); +} + +void clockevent_debug (struct clock_event_device *ce) +{ +printk (KERN_DEBUG "ce->mult=0x%08x\n" , ce->mult); +printk (KERN_DEBUG "ce->shift=%d\n" , ce->shift); +}
Important debug leftovers ?
Thanks,
tglx
PATCH v3 19/36 Hexagon: Add ptrace support
In reply to Richard KuoWill look at the more generic ptrace support in the future.
--- arch/hexagon/include/asm/ptrace.h | 46 +++++ arch/hexagon/kernel/ptrace.c | 333 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 379 insertions(+)
arch/hexagon/include/asm/ptrace.h new file +46 -0
@@ -0,0 +1,46 @@ +/* +* Ptrace definitions for the Hexagon architecture +* +* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#ifndef _ASM_PTRACE_H +#define _ASM_PTRACE_H + +#include <asm/registers.h> + +/* arch_ptrace and ptrace_disable use task_struct in arg lists */ +struct task_struct ; + +/* +* ptrace commands not part of Linux base set (but common to essentially +* all supported architectures). +*/ + +#define PTRACE_GETREGS 12 +#define PTRACE_SETREGS 13 + +#define N_PTRACE_REGS 44 + +#define profile_pc (regs) instruction_pointer(regs) +#define instruction_pointer (regs) pt_elr(regs) + +/* kprobe-based event tracer support */ +extern int regs_query_register_offset (const char *name); +extern const char *regs_query_register_name (unsigned int offset); + +#endif
arch/hexagon/kernel/ptrace.c new file +333 -0
333 lines not on this page · raw message
--
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Arnd Bergmann
maintainerRe: [patch v3 19/36] Hexagon: Add ptrace support
Quoted 4 lines · On Thursday 08 September 2011 20:09:06 Richard Kuo wrote:
Will look at the more generic ptrace support in the future.
Signed-off-by Richard Kuo <[email protected]>Signed-off-by Linas Vepstas <[email protected]>
Note that this absolutely has to be completed before the code is merged upstream, because it is relevant to the ABI.
Arnd
Re: [patch v3 19/36] Hexagon: Add ptrace support
In reply to Richard KuoQuoted 18 lines · Richard Kuo
arch/hexagon/kernel/ptrace.c new file +17
-0+long arch_ptrace (struct task_struct *child,long request, + unsigned long addr, unsigned long data) +{ + void __user *udata = (void __user *) data; + + switch (request) { + case PTRACE_POKETEXT: /* write the word at location addr. */ + case PTRACE_POKEDATA: + return generic_ptrace_pokedata(child, addr, data); + case PTRACE_POKEUSR: /* write register specified by addr. */ + return ptrace_pokeusr(child, addr, data); + case PTRACE_GETREGS: + return copy_regset_to_user(child, &hexagon_user_view, + REGSET_GPR, 0, + sizeof(struct user_regs_struct), + udata); + case PTRACE_SETREGS:
arch/hexagon/kernel/ptrace.c line 333
Quoted 10 lines
arch/hexagon/kernel/ptrace.c new file +10
-0+ return copy_regset_from_user(child, &hexagon_user_view, + REGSET_GPR, 0, + sizeof(struct user_regs_struct), + udata); + default: + return ptrace_request(child, request, addr, data); + } + + return 0; +}
I think that... other than for compatibility with legacy userspace code, you shouldn't need any of these cases other than the 'default'.
PTRACE_GETREGS is replaced by PTRACE_GETREGSET and this is handled in generic code. POKETEXT, POKEDATA are handled in the generic code. POKEUSR can also be done via the SETREGSET mechanism.
That said, I don't think gdbserver has been updated to use GETREGSET/SETREGSET. This is a bit like the uClibc/glibc issue, though... somebody just needs to do the work to make userspace work with the new, "clean" kernel interface.
Given all that, you shouldn't need to export pt_regs to userspace either. You already have a user_regs_struct which is userspace's view of the process registers. For OpenRISC we made pt_regs a kernel private structure, giving us the freedom to change the stack layout of the registers in the future while providing a stable view for userspace. I would suggest doing the same here.
If you do decide to make pt_regs private, you'll need to change your struct sigcontext to use user_regs_struct, as well.
/Jonas
--
To unsubscribe from this list: send the line "unsubscribe linux-hexagon" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [patch v3 19/36] Hexagon: Add ptrace support
Quoted 3 lines · Jonas Bonn
That said, I don't think gdbserver has been updated to use GETREGSET/SETREGSET. This is a bit like the uClibc/glibc issue,
Some dumb questions then: I notice that a few arches declare struct user_regs_struct in glibc, most of the others in the kernel. If I were to make pt_regs completely kernel-private, then I really do need to have struct user_regs_struct declared the kernel headers, right?
Putting a printk into case PTRACE_POKEUSR seemed to show that gdb was using this (and was somehow mis-numbering the registers ... sigh.) Are you saying that the default should handle this?
--linas
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Re: [patch v3 19/36] Hexagon: Add ptrace support
Quoted 10 lines · Linas Vepstas (Code Aurora)
Quoted 3 lines · Jonas Bonn
That said, I don't think gdbserver has been updated to use GETREGSET/SETREGSET. This is a bit like the uClibc/glibc issue,
Some dumb questions then: I notice that a few arches declare struct
user_regs_structin glibc, most of the others in the kernel. If I were to makept_regscompletely kernel-private, then I really do need to have structuser_regs_structdeclared the kernel headers, right?
Yes, on OpenRISC we declare it in ptrace.h (seearch/openrisc/include/asm/ptrace.h).
Quoted 4 lines
Putting a printk into case
PTRACE_POKEUSRseemed to show that gdb was using this (and was somehow mis-numbering the registers ... sigh.) Are you saying that the default should handle this?
I'm really not an expert on GDB, but I believe it can use either the PEEK/POKE functions to access regs, or it can use GET/SETREGS; it's an architecture-dependent configuration. I think the second variant can be easily modified to become GET/SETREGSET instead, and the PEEK/POKE variant wouldn't be needed at all.
/Jonas
--
To unsubscribe from this list: send the line "unsubscribe linux-hexagon" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Arnd Bergmann
maintainerRe: [patch v3 19/36] Hexagon: Add ptrace support
Quoted 9 lines · On Saturday 10 September 2011 08:42:26 Jonas Bonn wrote:
Quoted 3 lines
Putting a printk into case
PTRACE_POKEUSRseemed to show that gdb was using this (and was somehow mis-numbering the registers ... sigh.) Are you saying that the default should handle this?I'm really not an expert on GDB, but I believe it can use either the PEEK/POKE functions to access regs, or it can use GET/SETREGS; it's an architecture-dependent configuration. I think the second variant can be easily modified to become GET/SETREGSET instead, and the PEEK/POKE variant wouldn't be needed at all.
Yes, I think that is the way to go for new architectures, although practically no architecture in the upstream kernel does it this way.
The PEEKUSR/POKEUSR stuff is a relic from ancient Unix time where you would directly access a kernel data structure with it, we should get over it.
Arnd
Re: [patch v3 19/36] Hexagon: Add ptrace support
In reply to Jonas BonnQuoted 5 lines · Jonas Bonn
I'm really not an expert on GDB, but I believe it can use either the PEEK/POKE functions to access regs, or it can use GET/SETREGS; it's an architecture-dependent configuration. I think the second variant can be easily modified to become GET/SETREGSET instead, and the PEEK/POKE variant wouldn't be needed at all.
Yes, the x86/x86-64 ports or gdb and gdbserver are already using GET/SETREGSET even.
Signature · 1 line
Pedro Alves
Re: [patch v3 19/36] Hexagon: Add ptrace support
Quoted 10 lines · Pedro Alves
Quoted 5 lines · Jonas Bonn
I'm really not an expert on GDB, but I believe it can use either the PEEK/POKE functions to access regs, or it can use GET/SETREGS; it's an architecture-dependent configuration. I think the second variant can be easily modified to become GET/SETREGSET instead, and the PEEK/POKE variant wouldn't be needed at all.
Yes, the x86/x86-64 ports or gdb and gdbserver are already using GET/SETREGSET even.
Reading the code, it seemed to only fetch "extended state" in this way, and not all of the registers. Am I mistaken?
--linas
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Re: [patch v3 19/36] Hexagon: Add ptrace support
Quoted 9 lines · Linas Vepstas (Code Aurora)
Quoted 8 lines · Pedro Alves
Quoted 5 lines · Jonas Bonn
I'm really not an expert on GDB, but I believe it can use either the PEEK/POKE functions to access regs, or it can use GET/SETREGS; it's an architecture-dependent configuration. I think the second variant can be easily modified to become GET/SETREGSET instead, and the PEEK/POKE variant wouldn't be needed at all.
Quoted 5 lines
Quoted 2 lines
Yes, the x86/x86-64 ports or gdb and gdbserver are already using GET/SETREGSET even.
Reading the code, it seemed to only fetch "extended state" in this way, and not all of the registers. Am I mistaken?
True. gdb/gdbserver need to keep working with older x86 kernels, so we avoid having two ways of doing things with the other registers. No reason to support legacy interfaces with new ports though.
I wish there was an equivalent of PTRACE_GETREGSET for siginfo...
Signature · 1 line
Pedro Alves
Re: [patch v3 19/36] Hexagon: Add ptrace support
Quoted 3 lines · Pedro Alves
Quoted 3 lines · Pedro Alves
Quoted 2 lines
Yes, the x86/x86-64 ports or gdb and gdbserver are already using GET/SETREGSET even.
Thanks; after a bit of initial confusion, I've gotten gdb to work with this, so I'm happy.
Quoted 1 line
I wish there was an equivalent of
PTRACE_GETREGSETfor siginfo...
How? Why?
-- Linas
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Re: [patch v3 19/36] Hexagon: Add ptrace support
Quoted 11 lines · Linas Vepstas (Code Aurora)
Quoted 3 lines · Pedro Alves
Quoted 3 lines · Pedro Alves
Quoted 2 lines
Yes, the x86/x86-64 ports or gdb and gdbserver are already using GET/SETREGSET even.
Thanks; after a bit of initial confusion, I've gotten gdb to work with this, so I'm happy.
Quoted 1 line
I wish there was an equivalent of
PTRACE_GETREGSETfor siginfo...How? Why?
One of the the cool features of PTRACE_GETREGSET is that it returns the regset in the natural layout of the tracee. So when debugging a 32-bit process on a 64-bit kernel, PTRACE_GETREGSET returns the regset in 32-bit layout. Recent enough GDBs can print the siginfo of a caught signal (before its delivered with (PTRACE_CONT, sig). Try "(gdb) p $_siginfo" on x86. Trouble is 32-bit processes on 64-bit kernels or other biarch setups. PTRACE_GETSIGINFO returns the siginfo in 64-bit layout, so GDB gets to try to immitate what the kernel's 32-bit compat layer does. Both for reading and writting siginfo. See compat_siginfo_from_siginfo and siginfo_from_compat_siginfo at [1].
The kernel already knows to convert siginfo to the native layout of the process -- needed to pass to the user space signal handler at least. But AFAIK, there's no way for the debugger to get at it before the signal is actually delivered.
Signature · 1 line
Pedro Alves
PATCH v3 20/36 Hexagon: Provide basic debugging and system trap support.
In reply to Richard Kuo--- arch/hexagon/include/asm/traps.h | 29 +++ arch/hexagon/kernel/traps.c | 356 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 385 insertions(+)
arch/hexagon/kernel/traps.c new file +356 -0
@@ -0,0 +1,356 @@ +/* +* Kernel traps/events for Hexagon processor +* +* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#include <linux/init.h> +#include <linux/sched.h> +#include <linux/module.h> +#include <linux/kallsyms.h> +#include <linux/kdebug.h> +#include <linux/syscalls.h> +#include <linux/signal.h> +#include <linux/tracehook.h> +#include <asm/traps.h> +#include <asm/vm_fault.h> +#include <asm/syscall.h> +#include <asm/registers.h> +#include <asm/unistd.h> +#ifdef CONFIG_KGDB +# include <linux/kgdb.h> +#endif + +#define TRAP_SYSCALL 1 +#define TRAP_DEBUG 0xdb + +void __init trap_init (void ) +{ +} + +#ifdef CONFIG_GENERIC_BUG +/* Maybe should resemble arch/sh/kernel/traps.c ?? */ +int is_valid_bugaddr (unsigned long addr) +{ +return 1 ; +} +#endif /* CONFIG_GENERIC_BUG */ + +void show_stack (struct task_struct *task,unsigned long *fp) +{ +int kstack_depth_to_print =20 ; +unsigned long offset, size; +const char *name =NULL ; +unsigned long *newfp; +unsigned long ip; +char tmpstr[128 ]; +char *modname; +int i; + +if (task ==NULL ) + task = current; + +if (fp ==NULL ) { +if (task == current) { + asm("%0 = r30" :"=r" (fp)); + }else { + fp = (unsigned long *) + ((struct hexagon_switch_stack *) + task->thread.switch_sp)->fp; + } + } + +printk (KERN_INFO "CPU#%d, %s/%d, Call Trace:\n" , +raw_smp_processor_id (), current->comm, +task_pid_nr (current)); +for (i =0 ; i < kstack_depth_to_print; i++) { +if (0 /* Check irq stack at some point */ ) +printk (KERN_INFO " <EOI> " ); +else if (((long ) fp & (THREAD_SIZE -1 )) ==0 ) +break ; + + newfp = (unsigned long *) *fp; + + ip = *(unsigned long *)((char *)fp +sizeof (unsigned long )); + name =kallsyms_lookup (ip, &size, &offset, &modname, tmpstr); + +printk (KERN_INFO "[%p] 0x%lx: %s + 0x%lx" , fp, ip, name, + offset); +if (modname) +printk (KERN_CONT " [%s] " , modname); +if (i ==0 ) +printk (KERN_CONT " (unreliable)" ); +printk (KERN_CONT "\n" ); + +/* If newfp isn't larger, we're tracing garbage */ +if (newfp > fp) + fp = newfp; +else +break ; + } +} + +void dump_state (struct pt_regs *regs) +{ +show_regs (regs); +show_stack (current, ®s->r30); +} + +void dump_stack (void ) +{ +show_stack (current,NULL ); +} +EXPORT_SYMBOL (dump_stack); + +int die (const char *str,struct pt_regs *regs,long err) +{ +static struct { +spinlock_t lock; +int counter; + } die = { + .lock =__SPIN_LOCK_UNLOCKED (die.lock), + .counter =0 + }; + +spin_lock_irq (&die.lock); +bust_spinlocks (1 ); +printk (KERN_INFO "%s[#%d]:\n" , str, ++die.counter); + +if (notify_die (DIE_OOPS , str, regs, err,pt_cause (regs),SIGSEGV ) == +NOTIFY_STOP ) +return 1 ; + +print_modules (); +dump_state (regs); + +do_exit (err); +return 0 ; +} + +int die_if_kernel (char *str,struct pt_regs *regs,long err) +{ +if (!user_mode (regs)) +return die (str, regs, err); +else +return 0 ; +} + +/* +* It's not clear that misaligned fetches are ever recoverable. +*/ +static void misaligned_instruction (struct pt_regs *regs) +{ +die_if_kernel ("Misaligned Instruction" , regs,0 ); +force_sig (SIGBUS , current); +} + +/* +* Misaligned loads and stores, on the other hand, can be +* emulated, and probably should be, some day. But for now +* they will be considered fatal. +*/ +static void misaligned_data_load (struct pt_regs *regs) +{ +die_if_kernel ("Misaligned Data Load" , regs,0 ); +force_sig (SIGBUS , current); +} + +static void misaligned_data_store (struct pt_regs *regs) +{ +die_if_kernel ("Misaligned Data Store" , regs,0 ); +force_sig (SIGBUS , current); +} + +static void illegal_instruction (struct pt_regs *regs) +{ +die_if_kernel ("Illegal Instruction" , regs,0 ); +force_sig (SIGILL , current); +} + +/* +* Precise bus errors may be recoverable with a a retry, +* but for now, treat them as irrecoverable. +*/ +static void precise_bus_error (struct pt_regs *regs) +{ +die_if_kernel ("Precise Bus Error" , regs,0 ); +force_sig (SIGBUS , current); +} + +/* +* If anything is to be done here other than panic, +* it will probably be complex and migrate to another +* source module. For now, just die. +*/ +static void cache_error (struct pt_regs *regs) +{ +die ("Cache Error" , regs,0 ); +} + +/* +* General exception handler +*/ +void do_genex (struct pt_regs *regs) +{ + +/* +* Decode Cause and Dispatch +*/ +switch (pt_cause (regs)) { +case HVM_GE_C_XPROT : +case HVM_GE_C_XUSER : +execute_protection_fault (regs); +break ; +case HVM_GE_C_RPROT : +case HVM_GE_C_RUSER : +read_protection_fault (regs); +break ; +case HVM_GE_C_WPROT : +case HVM_GE_C_WUSER : +write_protection_fault (regs); +break ; +case HVM_GE_C_XMAL : +misaligned_instruction (regs); +break ; +case HVM_GE_C_RMAL : +misaligned_data_load (regs); +break ; +case HVM_GE_C_WMAL : +misaligned_data_store (regs); +break ; +case HVM_GE_C_INVI : +case HVM_GE_C_PRIVI : +illegal_instruction (regs); +break ; +case HVM_GE_C_BUS : +precise_bus_error (regs); +break ; +case HVM_GE_C_CACHE : +cache_error (regs); +break ; +default : +/* Halt and catch fire */ +panic ("Unrecognized exception 0x%lx\n" ,pt_cause (regs)); +break ; + } +} + +/* Indirect system call dispatch */ +long sys_syscall (void ) +{ +printk (KERN_ERR "sys_syscall invoked!\n" ); +return -ENOSYS ; +} + +void do_trap0 (struct pt_regs *regs) +{ +unsigned long syscallret =0 ; +syscall_fn syscall; + +switch (pt_cause (regs)) { +case TRAP_SYSCALL : +/* System call is trap0 #1 */ + +/* allow strace to catch syscall args */ +if (unlikely (test_thread_flag (TIF_SYSCALL_TRACE ) && +tracehook_report_syscall_entry (regs))) +return ;/* return -ENOSYS somewhere? */ + +/* Interrupts should be re-enabled for syscall processing */ +__vmsetie (VM_INT_ENABLE ); + +/* +* System call number is in r6, arguments in r0..r5. +* Fortunately, no Linux syscall has more than 6 arguments, +* and Hexagon ABI passes first 6 arguments in registers. +* 64-bit arguments are passed in odd/even register pairs. +* Fortunately, we have no system calls that take more +* than three arguments with more than one 64-bit value. +* Should that change, we'd need to redesign to copy +* between user and kernel stacks. +*/ + regs->syscall_nr = regs->r06; + +/* +* GPR R0 carries the first parameter, and is also used +* to report the return value. We need a backup of +* the user's value in case we need to do a late restart +* of the system call. +*/ + regs->restart_r0 = regs->r00; + +if ((unsigned long ) regs->syscall_nr >= __NR_syscalls) { + regs->r00 =-1 ; + }else { + syscall = (syscall_fn) + (sys_call_table[regs->syscall_nr]); + syscallret =syscall (regs->r00, regs->r01, + regs->r02, regs->r03, + regs->r04, regs->r05); + } + +/* +* If it was a sigreturn system call, don't overwrite +* r0 value in stack frame with return value. +* +* __NR_sigreturn doesn't seem to exist in new unistd.h +*/ + +if (regs->syscall_nr != __NR_rt_sigreturn) + regs->r00 = syscallret; + +/* allow strace to get the syscall return state */ +if (unlikely (test_thread_flag (TIF_SYSCALL_TRACE ))) +tracehook_report_syscall_exit (regs,0 ); + +break ; +case TRAP_DEBUG : +/* Trap0 0xdb is debug breakpoint */ +if (user_mode (regs)) { +struct siginfo info; + + info.si_signo =SIGTRAP ; + info.si_errno =0 ; +/* +* Some architecures add some per-thread state +* to distinguish between breakpoint traps and +* trace traps. We may want to do that, and +* set the si_code value appropriately, or we +* may want to use a different trap0 flavor. +*/ + info.si_code =TRAP_BRKPT ; + info.si_addr = (void __user *)pt_elr (regs); +send_sig_info (SIGTRAP , &info, current); + }else { +#ifdef CONFIG_KGDB +kgdb_handle_exception (pt_cause (regs),SIGTRAP , +TRAP_BRKPT , regs); +#endif + } +break ; + } +/* Ignore other trap0 codes for now, especially 0 (Angel calls) */ +} + +/* +* Machine check exception handler +*/ +void do_machcheck (struct pt_regs *regs) +{ +/* Halt and catch fire */ +__vmstop (); +}
arch/hexagon/include/asm/traps.h new file +29 -0
@@ -0,0 +1,29 @@ +/* +* Trap support for Hexagon +* +* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#ifndef _ASM_HEXAGON_TRAPS_H +#define _ASM_HEXAGON_TRAPS_H + +#include <asm/registers.h> + +extern int die (const char *str,struct pt_regs *regs,long err); +extern int die_if_kernel (char *str,struct pt_regs *regs,long err); + +#endif /* _ASM_HEXAGON_TRAPS_H */
--
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
PATCH v3 21/36 Hexagon: Add SMP support
In reply to Richard KuoChanged smp.c to use generic IPI handler functions.
--- arch/hexagon/include/asm/smp.h | 44 ++++++ arch/hexagon/kernel/smp.c | 282 +++++++++++++++++++++++++++++++++++++++++ arch/hexagon/kernel/topology.c | 52 +++++++ 3 files changed, 378 insertions(+)
arch/hexagon/include/asm/smp.h new file +44 -0
@@ -0,0 +1,44 @@ +/* +* SMP definitions for the Hexagon architecture +* +* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#ifndef __ASM_SMP_H +#define __ASM_SMP_H + +#include <linux/cpumask.h> + +#define raw_smp_processor_id () (current_thread_info()->cpu) + +enum ipi_message_type { +IPI_NOP =0 , +IPI_RESCHEDULE =1 , +IPI_CALL_FUNC , +IPI_CALL_FUNC_SINGLE , +IPI_CPU_STOP , +IPI_TIMER , +}; + +extern void send_ipi (const struct cpumask *cpumask,enum ipi_message_type msg); +extern void smp_start_cpus (void ); +extern void arch_send_call_function_single_ipi (int cpu); +extern void arch_send_call_function_ipi_mask (const struct cpumask *mask); + +extern void smp_vm_unmask_irq (void *info); + +#endif
arch/hexagon/kernel/smp.c new file +282 -0
282 lines not on this page · raw message
arch/hexagon/kernel/topology.c new file +52 -0
52 lines not on this page · raw message
--
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Re: [patch v3 21/36] Hexagon: Add SMP support
Quoted 4 lines · On Thursday 08 September 2011 20:09:08 Richard Kuo wrote:
Changed
smp.cto use generic IPI handler functions.Signed-off-by Richard Kuo <[email protected]>Signed-off-by Linas Vepstas <[email protected]>
Re: [patch v3 21/36] Hexagon: Add SMP support
In reply to Richard KuoQuoted 5 lines · Richard Kuo
arch/hexagon/kernel/smp.c new file +5
-0+/* Set the memory struct */ +atomic_inc (&init_mm.mm_count); + current->active_mm = &init_mm; + + cpu =smp_processor_id ();
arch/hexagon/kernel/smp.c line 191
Quoted 10 lines
arch/hexagon/kernel/smp.c new file +10
-0+ +setup_irq (BASE_IPI_IRQ + cpu, &ipi_intdesc); + +/* Register the clock_event dummy */ +setup_percpu_clockdev (); + +printk (KERN_INFO "%s cpu %d\n" , __func__,current_thread_info ()->cpu); + +local_irq_enable (); +set_cpu_online (cpu, true);
This wants to be:
set_cpu_online(cpu, true);
while (!cpumask_test_cpu(cpu, cpu_active_mask))
cpu_relax();
local_irq_enable();See x86/kernel/smpboot.c and
http://lists.arm.linux.org.uk/lurker/message/20110908.215756.a2ffbe5f.en.html
Thanks,
tglx
Re: [patch v3 21/36] Hexagon: Add SMP support
In reply to Richard Kuoarch/hexagon/kernel/smp.c line 115
Quoted 10 lines · Richard Kuo
arch/hexagon/kernel/smp.c new file +10
-0+irqreturn_t handle_ipi (int irq,void *desc) +{ +int cpu =smp_processor_id (); +struct ipi_data *ipi = &per_cpu (ipi_data, cpu); +unsigned long ops; + +while ((ops =xchg (&ipi->bits,0 )) !=0 ) +__handle_ipi (&ops, ipi, cpu); +return IRQ_HANDLED ; +}
So on the consumer side you are using xchg() ...
Quoted 14 lines
arch/hexagon/kernel/smp.c new file +14
-0+void send_ipi (const struct cpumask *cpumask,enum ipi_message_type msg) +{ +unsigned long flags; +unsigned long cpu; +unsigned long retval; + +local_irq_save (flags); + +for_each_cpu (cpu, cpumask) { +struct ipi_data *ipi = &per_cpu (ipi_data, cpu); + +spin_lock (&ipi->lock); + ipi->bits |=1 << msg;/* one bit per message */ +spin_unlock (&ipi->lock);
arch/hexagon/kernel/smp.c line 140
Quoted 10 lines
arch/hexagon/kernel/smp.c new file +10
-0+ + retval =__vmintop_post (BASE_IPI_IRQ +cpu); +if (retval !=0 ) { +printk (KERN_ERR "interrupt %ld not configured?\n" , +BASE_IPI_IRQ +cpu); + } + } + +local_irq_restore (flags); +}
And on the producer side, a spinlock for one or... that looks like wheel re-inventing to me :-)
In fact your bit iteration loop also re-invents find_*_bit interfaces.
Any reason why you don't simply use bitops or atomics here ?
Also what is your memory model ? ordered or weakly ordered ? Do you need some kind of memory barrier between setting ipi->bits and __vmintop_post() ?
Cheers,
Ben.
Re: [patch v3 21/36] Hexagon: Add SMP support
Quoted 6 lines · Benjamin Herrenschmidt
And on the producer side, a spinlock for one or... that looks like wheel re-inventing to me :-)
In fact your bit iteration loop also re-invents find_*_bit interfaces.
Any reason why you don't simply use bitops or atomics here ?
No particular reason; just the way it turned out when I was getting things working. I'll get them cleaned up.
Quoted 3 lines
Also what is your memory model ? ordered or weakly ordered ? Do you need some kind of memory barrier between setting
ipi->bitsand__vmintop_post()?
Our model is ordered, so there's no need for a barrier there yet.
Thanks,
Richard Kuo
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
PATCH v3 22/36 Hexagon: Add locking types and functions
In reply to Richard KuoMoved rwsem to asm-generic. Will submit a subsequent patch for PPC use it from the new location.
--- arch/hexagon/include/asm/spinlock.h | 186 ++++++++++++++++++++++++++++++ arch/hexagon/include/asm/spinlock_types.h | 42 ++++++ include/asm-generic/rwsem.h | 132 +++++++++++++++++++++ 3 files changed, 360 insertions(+)
arch/hexagon/include/asm/spinlock.h new file +186 -0
@@ -0,0 +1,186 @@ +/* +* Spinlock support for the Hexagon architecture +* +* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +* +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#ifndef _ASM_SPINLOCK_H +#define _ASM_SPINLOCK_H + +#include <asm/irqflags.h> + +/* +* This file is pulled in for SMP builds. +* Really need to check all the barrier stuff for "true" SMP +*/ + +/* +* Read locks: +* - load the lock value +* - increment it +* - if the lock value is still negative, go back and try again. +* - unsuccessful store is unsuccessful. Go back and try again. Loser. +* - successful store new lock value if positive -> lock acquired +*/ +static inline void arch_read_lock (arch_rwlock_t *lock) +{ + __asm__ __volatile__( +"1: R6 = memw_locked(%0);\n" +" { P3 = cmp.ge(R6,#0); R6 = add(R6,#1);}\n" +" { if !P3 jump 1b; }\n" +" memw_locked(%0,P3) = R6;\n" +" { if !P3 jump 1b; }\n" + : + :"r" (&lock->lock) + :"memory" ,"r6" ,"p3" + ); + +} + +static inline void arch_read_unlock (arch_rwlock_t *lock) +{ + __asm__ __volatile__( +"1: R6 = memw_locked(%0);\n" +" R6 = add(R6,#-1);\n" +" memw_locked(%0,P3) = R6\n" +" if !P3 jump 1b;\n" + : + :"r" (&lock->lock) + :"memory" ,"r6" ,"p3" + ); + +} + +/* I think this returns 0 on fail, 1 on success. */ +static inline int arch_read_trylock (arch_rwlock_t *lock) +{ +int temp; + __asm__ __volatile__( +" R6 = memw_locked(%1);\n" +" { %0 = #0; P3 = cmp.ge(R6,#0); R6 = add(R6,#1);}\n" +" { if !P3 jump 1f; }\n" +" memw_locked(%1,P3) = R6;\n" +" { %0 = P3 }\n" +"1:\n" + :"=&r" (temp) + :"r" (&lock->lock) + :"memory" ,"r6" ,"p3" + ); +return temp; +} + +static inline int arch_read_can_lock (arch_rwlock_t *rwlock) +{ +return rwlock->lock ==0 ; +} + +static inline int arch_write_can_lock (arch_rwlock_t *rwlock) +{ +return rwlock->lock ==0 ; +} + +/* Stuffs a -1 in the lock value? */ +static inline void arch_write_lock (arch_rwlock_t *lock) +{ + __asm__ __volatile__( +"1: R6 = memw_locked(%0)\n" +" { P3 = cmp.eq(R6,#0); R6 = #-1;}\n" +" { if !P3 jump 1b; }\n" +" memw_locked(%0,P3) = R6;\n" +" { if !P3 jump 1b; }\n" + : + :"r" (&lock->lock) + :"memory" ,"r6" ,"p3" + ); +} + + +static inline int arch_write_trylock (arch_rwlock_t *lock) +{ +int temp; + __asm__ __volatile__( +" R6 = memw_locked(%1)\n" +" { %0 = #0; P3 = cmp.eq(R6,#0); R6 = #-1;}\n" +" { if !P3 jump 1f; }\n" +" memw_locked(%1,P3) = R6;\n" +" %0 = P3;\n" +"1:\n" + :"=&r" (temp) + :"r" (&lock->lock) + :"memory" ,"r6" ,"p3" + ); +return temp; + +} + +static inline void arch_write_unlock (arch_rwlock_t *lock) +{ +smp_mb (); + lock->lock =0 ; +} + +static inline void arch_spin_lock (arch_spinlock_t *lock) +{ + __asm__ __volatile__( +"1: R6 = memw_locked(%0);\n" +" P3 = cmp.eq(R6,#0);\n" +" { if !P3 jump 1b; R6 = #1; }\n" +" memw_locked(%0,P3) = R6;\n" +" { if !P3 jump 1b; }\n" + : + :"r" (&lock->lock) + :"memory" ,"r6" ,"p3" + ); + +} + +static inline void arch_spin_unlock (arch_spinlock_t *lock) +{ +smp_mb (); + lock->lock =0 ; +} + +static inline unsigned int arch_spin_trylock (arch_spinlock_t *lock) +{ +int temp; + __asm__ __volatile__( +" R6 = memw_locked(%1);\n" +" P3 = cmp.eq(R6,#0);\n" +" { if !P3 jump 1f; R6 = #1; %0 = #0; }\n" +" memw_locked(%1,P3) = R6;\n" +" %0 = P3;\n" +"1:\n" + :"=&r" (temp) + :"r" (&lock->lock) + :"memory" ,"r6" ,"p3" + ); +return temp; +} + +/* +* SMP spinlocks are intended to allow only a single CPU at the lock +*/ +#define arch_spin_lock_flags (lock, flags) arch_spin_lock(lock) +#define arch_spin_unlock_wait (lock) \ + do {while (arch_spin_is_locked(lock)) cpu_relax(); } while (0) +#define arch_spin_is_locked (x) ((x)->lock != 0) + +#define arch_read_lock_flags (lock, flags) arch_read_lock(lock) +#define arch_write_lock_flags (lock, flags) arch_write_lock(lock) + +#endif
arch/hexagon/include/asm/spinlock_types.h new file +42 -0
42 lines not on this page · raw message
include/asm-generic/rwsem.h new file +132 -0
132 lines not on this page · raw message
--
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Re: [patch v3 22/36] Hexagon: Add locking types and functions
Quoted 2 lines · On Thursday 08 September 2011 20:09:09 Richard Kuo wrote:
Moved rwsem to asm-generic. Will submit a subsequent patch for PPC use it from the new location.
Excellent, thanks!
Quoted 1 line
Signed-off-by Richard Kuo <[email protected]>
PATCH v3 23/36 Hexagon: Add user access functions
In reply to Richard Kuo--- arch/hexagon/include/asm/uaccess.h | 116 +++++++++++++++++++++ arch/hexagon/mm/copy_from_user.S | 114 +++++++++++++++++++++ arch/hexagon/mm/copy_to_user.S | 92 +++++++++++++++++ arch/hexagon/mm/copy_user_template.S | 185 +++++++++++++++++++++++++++++++++++ arch/hexagon/mm/strnlen_user.S | 140 ++++++++++++++++++++++++++ arch/hexagon/mm/uaccess.c | 59 +++++++++++ 6 files changed, 706 insertions(+)
arch/hexagon/include/asm/uaccess.h new file +116 -0
@@ -0,0 +1,116 @@ +/* +* User memory access support for Hexagon +* +* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#ifndef _ASM_UACCESS_H +#define _ASM_UACCESS_H +/* +* User space memory access functions +*/ +#include <linux/sched.h> +#include <linux/mm.h> +#include <asm/segment.h> +#include <asm/sections.h> + +/* +* access_ok: - Checks if a user space pointer is valid +* @type: Type of access: %VERIFY_READ or %VERIFY_WRITE. Note that +* %VERIFY_WRITE is a superset of %VERIFY_READ - if it is safe +* to write to a block, it is always safe to read from it. +* @addr: User space pointer to start of block to check +* @size: Size of block to check +* +* Context: User context only. This function may sleep. +* +* Checks if a pointer to a block of memory in user space is valid. +* +* Returns true (nonzero) if the memory block *may* be valid, false (zero) +* if it is definitely invalid. +* +* User address space in Hexagon, like x86, goes to 0xbfffffff, so the +* simple MSB-based tests used by MIPS won't work. Some further +* optimization is probably possible here, but for now, keep it +* reasonably simple and not *too* slow. After all, we've got the +* MMU for backup. +*/ +#define VERIFY_READ 0 +#define VERIFY_WRITE 1 + +#define __access_ok (addr, size) \ + ((get_fs().seg == KERNEL_DS.seg) || \ + (((unsigned long)addr < get_fs().seg) && \ + (unsigned long)size < (get_fs().seg - (unsigned long)addr))) + +/* +* When a kernel-mode page fault is taken, the faulting instruction +* address is checked against a table of exception_table_entries. +* Each entry is a tuple of the address of an instruction that may +* be authorized to fault, and the address at which execution should +* be resumed instead of the faulting instruction, so as to effect +* a workaround. +*/ + +/* Assembly somewhat optimized copy routines */ +unsigned long __copy_from_user_hexagon (void *to,const void __user *from, +unsigned long n); +unsigned long __copy_to_user_hexagon (void __user *to,const void *from, +unsigned long n); + +#define __copy_from_user (to, from, n) __copy_from_user_hexagon(to, from, n) +#define __copy_to_user (to, from, n) __copy_to_user_hexagon(to, from, n) + +/* +* XXX todo: some additonal performance gain is possible by +* implementing __copy_to/from_user_inatomic, which is much +* like __copy_to/from_user, but performs slightly less checking. +*/ + +__kernel_size_t __clear_user_hexagon (void __user *dest,unsigned long count); +#define __clear_user (a, s) __clear_user_hexagon((a), (s)) + +#define __strncpy_from_user (dst, src, n) hexagon_strncpy_from_user(dst, src, n) + +/* get around the ifndef in asm-generic/uaccess.h */ +#define __strnlen_user __strnlen_user + +extern long __strnlen_user (const char __user *src,long n); + +static inline long hexagon_strncpy_from_user (char *dst,const char __user *src, +long n); + +#include <asm-generic/uaccess.h> + +/* Todo: an actual accelerated version of this. */ +static inline long hexagon_strncpy_from_user (char *dst,const char __user *src, +long n) +{ +long res =__strnlen_user (src, n); + +/* return from strnlen can't be zero -- that would be rubbish. */ + +if (res > n) { +copy_from_user (dst, src, n); +return n; + }else { +copy_from_user (dst, src, res); +return res-1 ; + } +} + +#endif
arch/hexagon/mm/copy_from_user.S new file +114 -0
114 lines not on this page · raw message
arch/hexagon/mm/copy_to_user.S new file +92 -0
92 lines not on this page · raw message
arch/hexagon/mm/copy_user_template.S new file +185 -0
185 lines not on this page · raw message
arch/hexagon/mm/uaccess.c new file +59 -0
59 lines not on this page · raw message
arch/hexagon/mm/strnlen_user.S new file +140 -0
140 lines not on this page · raw message
--
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
PATCH v3 24/36 Hexagon: Provide basic implementation and/or stubs for I/O routines.
In reply to Richard KuoFilled in the ins/outs; leaving them in for now.
Change _IO_BASE and IO_SPACE_LIMIT for safety.
I have compiled this with sparse and it builds; I've also picked over various files related to the HAS_IOPORT_MAP from arm-soc.git and tried them out, and they work, so I guess we'll just wait until they're merged.
--- arch/hexagon/include/asm/io.h | 323 ++++++++++++++++++++++++++++++++++++++++++ arch/hexagon/lib/io.c | 91 +++++++++++ 2 files changed, 414 insertions(+)
arch/hexagon/include/asm/io.h new file +323 -0
@@ -0,0 +1,323 @@ +/* +* IO definitions for the Hexagon architecture +* +* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#ifndef _ASM_IO_H +#define _ASM_IO_H + +#ifdef __KERNEL__ + +#include <linux/types.h> +#include <linux/delay.h> +#include <linux/vmalloc.h> +#include <asm/string.h> +#include <asm/mem-layout.h> +#include <asm/iomap.h> +#include <asm/page.h> +#include <asm/cacheflush.h> +#include <asm/tlbflush.h> + +/* +* We don't have PCI yet. +* _IO_BASE is pointing at what should be unused virtual space. +*/ +#define IO_SPACE_LIMIT 0xffff +#define _IO_BASE ((void __iomem *)0xfe000000) + +extern int remap_area_pages (unsigned long start,unsigned long phys_addr, +unsigned long end,unsigned long flags); + +extern void __iounmap (const volatile void __iomem *addr); + +/* Defined in lib/io.c, needed for smc91x driver. */ +extern void __raw_readsw (const void __iomem *addr,void *data,int wordlen); +extern void __raw_writesw (void __iomem *addr,const void *data,int wordlen); + +extern void __raw_readsl (const void __iomem *addr,void *data,int wordlen); +extern void __raw_writesl (void __iomem *addr,const void *data,int wordlen); + +#define readsw (p, d, l) __raw_readsw(p, d, l) +#define writesw (p, d, l) __raw_writesw(p, d, l) + +#define readsl (p, d, l) __raw_readsl(p, d, l) +#define writesl (p, d, l) __raw_writesl(p, d, l) + +/* +* virt_to_phys - map virtual address to physical +* @address: address to map +*/ +static inline unsigned long virt_to_phys (volatile void *address) +{ +return __pa (address); +} + +/* +* phys_to_virt - map physical address to virtual +* @address: address to map +*/ +static inline void *phys_to_virt (unsigned long address) +{ +return __va (address); +} + +/* +* convert a physical pointer to a virtual kernel pointer for +* /dev/mem access. +*/ +#define xlate_dev_kmem_ptr (p) __va(p) +#define xlate_dev_mem_ptr (p) __va(p) + +/* +* IO port access primitives. Hexagon doesn't have special IO access +* instructions; all I/O is memory mapped. +* +* in/out are used for "ports", but we don't have "port instructions", +* so these are really just memory mapped too. +*/ + +/* +* readb - read byte from memory mapped device +* @addr: pointer to memory +* +* Operates on "I/O bus memory space" +*/ +static inline u8 readb (const volatile void __iomem *addr) +{ +u8 val; + asmvolatile ( +"%0 = memb(%1);" + :"=&r" (val) + :"r" (addr) + ); +return val; +} + +static inline u16 readw (const volatile void __iomem *addr) +{ +u16 val; + asmvolatile ( +"%0 = memh(%1);" + :"=&r" (val) + :"r" (addr) + ); +return val; +} + +static inline u32 readl (const volatile void __iomem *addr) +{ +u32 val; + asmvolatile ( +"%0 = memw(%1);" + :"=&r" (val) + :"r" (addr) + ); +return val; +} + +/* +* writeb - write a byte to a memory location +* @data: data to write to +* @addr: pointer to memory +* +*/ +static inline void writeb (u8 data,volatile void __iomem *addr) +{ + asmvolatile ( +"memb(%0) = %1;" + : + :"r" (addr),"r" (data) + ); +} + +static inline void writew (u16 data,volatile void __iomem *addr) +{ + asmvolatile ( +"memh(%0) = %1;" + : + :"r" (addr),"r" (data) + ); + +} + +static inline void writel (u32 data,volatile void __iomem *addr) +{ + asmvolatile ( +"memw(%0) = %1;" + : + :"r" (addr),"r" (data) + ); +} + +#define __raw_writeb writeb +#define __raw_writew writew +#define __raw_writel writel + +#define __raw_readb readb +#define __raw_readw readw +#define __raw_readl readl + +/* +* Need an mtype somewhere in here, for cache type deals? +* This is probably too long for an inline. +*/ +void __iomem *ioremap_nocache (unsigned long phys_addr,unsigned long size); + +static inline void __iomem *ioremap (unsigned long phys_addr,unsigned long size) +{ +return ioremap_nocache (phys_addr, size); +} + +static inline void iounmap (volatile void __iomem *addr) +{ +__iounmap (addr); +} + +#define __raw_writel writel + +static inline void memcpy_fromio (void *dst,const volatile void __iomem *src, +int count) +{ +memcpy (dst, (void *) src, count); +} + +static inline void memcpy_toio (volatile void __iomem *dst,const void *src, +int count) +{ +memcpy ((void *) dst, src, count); +} + +#define PCI_IO_ADDR (volatile void __iomem *) + +/* +* inb - read byte from I/O port or something +* @port: address in I/O space +* +* Operates on "I/O bus I/O space" +*/ +static inline u8 inb (unsigned long port) +{ +return readb (_IO_BASE + (port &IO_SPACE_LIMIT )); +} + +static inline u16 inw (unsigned long port) +{ +return readw (_IO_BASE + (port &IO_SPACE_LIMIT )); +} + +static inline u32 inl (unsigned long port) +{ +return readl (_IO_BASE + (port &IO_SPACE_LIMIT )); +} + +/* +* outb - write a byte to a memory location +* @data: data to write to +* @addr: address in I/O space +*/ +static inline void outb (u8 data,unsigned long port) +{ +writeb (data, _IO_BASE + (port &IO_SPACE_LIMIT )); +} + +static inline void outw (u16 data,unsigned long port) +{ +writew (data, _IO_BASE + (port &IO_SPACE_LIMIT )); +} + +static inline void outl (u32 data,unsigned long port) +{ +writel (data, _IO_BASE + (port &IO_SPACE_LIMIT )); +} + +#define outb_p outb +#define outw_p outw +#define outl_p outl + +#define inb_p inb +#define inw_p inw +#define inl_p inl + +static inline void insb (unsigned long port,void *buffer,int count) +{ +if (count) { +u8 *buf = buffer; +do { +u8 x =inb (port); + *buf++ = x; + }while (--count); + } +} + +static inline void insw (unsigned long port,void *buffer,int count) +{ +if (count) { +u16 *buf = buffer; +do { +u16 x =inw (port); + *buf++ = x; + }while (--count); + } +} + +static inline void insl (unsigned long port,void *buffer,int count) +{ +if (count) { +u32 *buf = buffer; +do { +u32 x =inw (port); + *buf++ = x; + }while (--count); + } +} + +static inline void outsb (unsigned long port,const void *buffer,int count) +{ +if (count) { +const u8 *buf = buffer; +do { +outb (*buf++, port); + }while (--count); + } +} + +static inline void outsw (unsigned long port,const void *buffer,int count) +{ +if (count) { +const u16 *buf = buffer; +do { +outw (*buf++, port); + }while (--count); + } +} + +static inline void outsl (unsigned long port,const void *buffer,int count) +{ +if (count) { +const u32 *buf = buffer; +do { +outl (*buf++, port); + }while (--count); + } +} + +#define flush_write_buffers () do { } while (0) + +#endif /* __KERNEL__ */ + +#endif
arch/hexagon/lib/io.c new file +91 -0
91 lines not on this page · raw message
--
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Re: [patch v3 24/36] Hexagon: Provide basic implementation and/or stubs for I/O routines.
Quoted 4 lines · On Thursday 08 September 2011 20:09:11 Richard Kuo wrote:
Filled in the ins/outs; leaving them in for now.
Change
_IO_BASEandIO_SPACE_LIMITfor safety.
Quoted 8 lines
I have compiled this with sparse and it builds; I've also picked over various files related to the
HAS_IOPORT_MAPfrom arm-soc.git and tried them out, and they work, so I guess we'll just wait until they're merged.Signed-off-by Richard Kuo <[email protected]>Signed-off-by Linas Vepstas <[email protected]>
Re: [patch v3 24/36] Hexagon: Provide basic implementation and/or stubs for I/O routines.
In reply to Richard Kuoarch/hexagon/include/asm/io.h line 145
Quoted 5 lines · Richard Kuo
arch/hexagon/include/asm/io.h new file +5
-0+ asmvolatile ( +"memb(%0) = %1;" + : + :"r" (addr),"r" (data) + );
I'm kind-of vague on this, but I think that this also needs a : "memory" at the end (to indicate that the asm snippet clobbers memory), as otherwise the compiler may be tempted to reorder these around other memory accesses. That is, the "volatile" keyword is not enough (well, I'm not sure...), but I think "volatile" only prevents the compiler from optimizing these away completely, but is not enough to prevent unwanted re-ordering.
--linas
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Arnd Bergmann
maintainerRe: [patch v3 24/36] Hexagon: Provide basic implementation and/or stubs for I/O routines.
Quoted 7 lines · On Friday 09 September 2011 14:14:13 Linas Vepstas wrote:
arch/hexagon/include/asm/io.h line 145
Quoted 5 lines · Richard Kuo
arch/hexagon/include/asm/io.h new file +5
-0+ asmvolatile ( +"memb(%0) = %1;" + : + :"r" (addr),"r" (data) + );
Quoted 8 lines
I'm kind-of vague on this, but I think that this also needs a : "memory" at the end (to indicate that the asm snippet clobbers memory), as otherwise the compiler may be tempted to reorder these around other memory accesses. That is, the "volatile" keyword is not enough (well, I'm not sure...), but I think "volatile" only prevents the compiler from optimizing these away completely, but is not enough to prevent unwanted re-ordering.
Yes, absolutely correct. Specifically, this is required for the case where you first store values into regular memory and then use the writel() to trigger a DMA operation. Without the memory clobber, the dma may read from memory before the CPU has accessed it in case the store gets scheduled after the writel by the compiler.
Arnd
RE: [patch v3 24/36] Hexagon: Provide basic implementation and/or stubs for I/O routines.
Using "memory" is a pretty big hammer. Wouldn't it be better to use a memory operand?
asm volatile(
"memb(%0) = %1;"
: "m" (*(u8*)addr)
: "r" (data)
);This may be a dumb question, but why do we need inline asm? Why can't we write this with plain C code?
/*
* writeb - write a byte to a memory location
* @data: data to write to
* @addr: pointer to memory
*
*/
static inline void writeb(u8 data, volatile void __iomem *addr) {
volatile u8 *ptr = (volatile u8*)addr; *ptr = data; }
Taylor
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Arnd Bergmann
Sent: Friday, September 09, 2011 4:13 PM
To: Linas Vepstas (Code Aurora)
Cc: Richard Kuo; [email protected]; [email protected]; [email protected]
Subject: Re: [patch v3 24/36] Hexagon: Provide basic implementation and/or stubs for I/O routines.
Quoted 7 lines · On Friday 09 September 2011 14:14:13 Linas Vepstas wrote:
arch/hexagon/include/asm/io.h line 145
Quoted 5 lines · Richard Kuo
arch/hexagon/include/asm/io.h new file +5
-0+ asmvolatile ( +"memb(%0) = %1;" + : + :"r" (addr),"r" (data) + );
Quoted 8 lines
I'm kind-of vague on this, but I think that this also needs a : "memory" at the end (to indicate that the asm snippet clobbers memory), as otherwise the compiler may be tempted to reorder these around other memory accesses. That is, the "volatile" keyword is not enough (well, I'm not sure...), but I think "volatile" only prevents the compiler from optimizing these away completely, but is not enough to prevent unwanted re-ordering.
Yes, absolutely correct. Specifically, this is required for the case where you first store values into regular memory and then use the writel() to trigger a DMA operation. Without the memory clobber, the dma may read from memory before the CPU has accessed it in case the store gets scheduled after the writel by the compiler.
Arnd
RE: [patch v3 24/36] Hexagon: Provide basic implementation and/or stubs for I/O routines.
Quoted 7 lines · Taylor Simpson
Using "memory" is a pretty big hammer. Wouldn't it be better to use a memory operand?
asm volatile( "memb(%0) = %1;" : "m" (*(u8*)addr) : "r" (data) );
No you probably really want a full "memory" clobber, because typically your IO ops should also act as barriers. The compiler has no way to know for example that you want to order previous stores to memory (some DMA descriptor you are populating) vs. an MMIO access that will trigger the DMA from that location.
Linux defines the readX/writeX accessors as being fully ordered in that case.
In fact, I'm not familiar with Hexagon, but if it's a weakly ordered memory model you may also need some kind of memory barrier in those accessors.
Cheers,
Ben.
Quoted 62 lines
This may be a dumb question, but why do we need inline asm? Why can't we write this with plain C code?
/*
* writeb - write a byte to a memory location
* @data: data to write to
* @addr: pointer to memory
*
*/
static inline voidwriteb(u8 data, volatile void __iomem *addr){volatile u8 *ptr = (volatile u8*)addr; *ptr = data; }Taylor
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Arnd Bergmann
Sent: Friday, September 09, 2011 4:13 PM
To: Linas Vepstas (Code Aurora)
Cc: Richard Kuo; [email protected]; [email protected]; [email protected]
Subject: Re: [patch v3 24/36] Hexagon: Provide basic implementation and/or stubs for I/O routines.Quoted 7 lines · On Friday 09 September 2011 14:14:13 Linas Vepstas wrote:
arch/hexagon/include/asm/io.h line 145
Quoted 5 lines · Richard Kuo
arch/hexagon/include/asm/io.h new file +5
-0+ asmvolatile ( +"memb(%0) = %1;" + : + :"r" (addr),"r" (data) + );Quoted 8 lines
I'm kind-of vague on this, but I think that this also needs a : "memory" at the end (to indicate that the asm snippet clobbers memory), as otherwise the compiler may be tempted to reorder these around other memory accesses. That is, the "volatile" keyword is not enough (well, I'm not sure...), but I think "volatile" only prevents the compiler from optimizing these away completely, but is not enough to prevent unwanted re-ordering.
Yes, absolutely correct. Specifically, this is required for the case where you first store values into regular memory and then use the
writel()to trigger a DMA operation. Without the memory clobber, the dma may read from memory before the CPU has accessed it in case the store gets scheduled after the writel by the compiler.Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-hexagon" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
PATCH v3 25/36 Hexagon: Implement basic cache-flush support
In reply to Richard KuoWe have separate I/D caches. Data caches are physically indexed.
--- arch/hexagon/include/asm/cache.h | 34 +++++++++ arch/hexagon/include/asm/cacheflush.h | 99 ++++++++++++++++++++++++++ arch/hexagon/mm/cache.c | 128 ++++++++++++++++++++++++++++++++++ 3 files changed, 261 insertions(+)
arch/hexagon/include/asm/cacheflush.h new file +99 -0
@@ -0,0 +1,99 @@ +/* +* Cache flush operations for the Hexagon architecture +* +* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#ifndef _ASM_CACHEFLUSH_H +#define _ASM_CACHEFLUSH_H + +#include <linux/cache.h> +#include <linux/mm.h> +#include <asm/string.h> +#include <asm-generic/cacheflush.h> + +/* Cache flushing: +* +* - flush_cache_all() flushes entire cache +* - flush_cache_mm(mm) flushes the specified mm context's cache lines +* - flush_cache_page(mm, vmaddr, pfn) flushes a single page +* - flush_cache_range(vma, start, end) flushes a range of pages +* - flush_icache_range(start, end) flush a range of instructions +* - flush_dcache_page(pg) flushes(wback&invalidates) a page for dcache +* - flush_icache_page(vma, pg) flushes(invalidates) a page for icache +* +* Need to doublecheck which one is really needed for ptrace stuff to work. +*/ +#define LINESIZE 32 +#define LINEBITS 5 + +/* +* Flush Dcache range through current map. +*/ +extern void flush_dcache_range (unsigned long start,unsigned long end); + +/* +* Flush Icache range through current map. +*/ +#undef flush_icache_range +extern void flush_icache_range (unsigned long start,unsigned long end); + +/* +* Memory-management related flushes are there to ensure in non-physically +* indexed cache schemes that stale lines belonging to a given ASID aren't +* in the cache to confuse things. The prototype Hexagon Virtual Machine +* only uses a single ASID for all user-mode maps, which should +* mean that they aren't necessary. A brute-force, flush-everything +* implementation, with the name xxxxx_hexagon() is present in +* arch/hexagon/mm/cache.c, but let's not wire it up until we know +* it is needed. +*/ +extern void flush_cache_all_hexagon (void ); + +/* +* This may or may not ever have to be non-null, depending on the +* virtual machine MMU. For a native kernel, it's definitiely a no-op +* +* This is also the place where deferred cache coherency stuff seems +* to happen, classically... but instead we do it like ia64 and +* clean the cache when the PTE is set. +* +*/ +static inline void update_mmu_cache (struct vm_area_struct *vma, +unsigned long address,pte_t *ptep) +{ +/* generic_ptrace_pokedata doesn't wind up here, does it? */ +} + +#undef copy_to_user_page +static inline void copy_to_user_page (struct vm_area_struct *vma, +struct page *page, +unsigned long vaddr, +void *dst,void *src,int len) +{ +memcpy (dst, src, len); +if (vma->vm_flags &VM_EXEC ) { +flush_icache_range ((unsigned long ) dst, + (unsigned long ) dst + len); + } +} + + +extern void hexagon_inv_dcache_range (unsigned long start,unsigned long end); +extern void hexagon_clean_dcache_range (unsigned long start,unsigned long end); + +#endif
arch/hexagon/include/asm/cache.h new file +34 -0
@@ -0,0 +1,34 @@ +/* +* Cache definitions for the Hexagon architecture +* +* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#ifndef __ASM_CACHE_H +#define __ASM_CACHE_H + +/* Bytes per L1 cache line */ +#define L1_CACHE_SHIFT (5) +#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT) + +#define __cacheline_aligned __aligned(L1_CACHE_BYTES) +#define ____cacheline_aligned __aligned(L1_CACHE_BYTES) + +/* See http://kerneltrap.org/node/15100 */ +#define __read_mostly + +#endif
arch/hexagon/mm/cache.c new file +128 -0
128 lines not on this page · raw message
--
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
PATCH v3 26/36 Hexagon: Implement basic TLB management routines for Hexagon.
In reply to Richard KuoMostly all stubs, as the TLB is managed by the hypervisor.
--- arch/hexagon/include/asm/tlb.h | 39 +++++++++++++++ arch/hexagon/include/asm/tlbflush.h | 58 ++++++++++++++++++++++ arch/hexagon/mm/vm_tlb.c | 93 ++++++++++++++++++++++++++++++++++++ 3 files changed, 190 insertions(+)
arch/hexagon/include/asm/tlbflush.h new file +58 -0
@@ -0,0 +1,58 @@ +/* +* TLB flush support for Hexagon +* +* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#ifndef _ASM_TLBFLUSH_H +#define _ASM_TLBFLUSH_H + +#include <linux/mm.h> +#include <asm/processor.h> + +/* +* TLB flushing -- in "SMP", these routines get defined to be the +* ones from smp.c, else they are some local flavors. +*/ + +/* +* These functions are commonly macros, but in the interests of +* VM vs. native implementation and code size, we simply declare +* the function prototypes here. +*/ +extern void tlb_flush_all (void ); +extern void flush_tlb_mm (struct mm_struct *mm); +extern void flush_tlb_page (struct vm_area_struct *vma,unsigned long addr); +extern void flush_tlb_range (struct vm_area_struct *vma, +unsigned long start,unsigned long end); +extern void flush_tlb_kernel_range (unsigned long start,unsigned long end); +extern void flush_tlb_one (unsigned long ); + +/* +* "This is called in munmap when we have freed up some page-table pages. +* We don't need to do anything here..." +* +* The VM kernel doesn't walk page tables, and they are passed to the VMM +* by logical address. There doesn't seem to be any possibility that they +* could be referenced by the VM kernel based on a stale mapping, since +* they would only be located by consulting the mm structure, and they +* will have been purged from that structure by the munmap. Seems like +* a noop on HVM as well. +*/ +#define flush_tlb_pgtables (mm, start, end) + +#endif
arch/hexagon/include/asm/tlb.h new file +39 -0
@@ -0,0 +1,39 @@ +/* +* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#ifndef _ASM_TLB_H +#define _ASM_TLB_H + +#include <linux/pagemap.h> +#include <asm/tlbflush.h> + +/* +* We don't need any special per-pte or per-vma handling... +*/ +#define tlb_start_vma (tlb, vma) do { } while (0) +#define tlb_end_vma (tlb, vma) do { } while (0) +#define __tlb_remove_tlb_entry (tlb, ptep, address) do { } while (0) + +/* +* .. because we flush the whole mm when it fills up +*/ +#define tlb_flush (tlb) flush_tlb_mm((tlb)->mm) + +#include <asm-generic/tlb.h> + +#endif
arch/hexagon/mm/vm_tlb.c new file +93 -0
93 lines not on this page · raw message
--
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
PATCH v3 27/36 Hexagon: Provide DMA implementation
In reply to Richard KuoBasic DMA implementation for our architecture.
Added sync_single_for_* routines; hexagon_map_page() still seems to be a convenient place to flush/invalidate.
--- arch/hexagon/include/asm/dma-mapping.h | 101 +++++++++++++++ arch/hexagon/include/asm/dma.h | 29 ++++ arch/hexagon/kernel/dma.c | 220 +++++++++++++++++++++++++++++++++ 3 files changed, 350 insertions(+)
arch/hexagon/include/asm/dma.h new file +29 -0
@@ -0,0 +1,29 @@ +/* +* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#ifndef _ASM_DMA_H +#define _ASM_DMA_H + +#include <asm/io.h> + +#define MAX_DMA_CHANNELS 1 +#define MAX_DMA_ADDRESS (PAGE_OFFSET) + +extern size_t hexagon_coherent_pool_size; + +#endif
arch/hexagon/include/asm/dma-mapping.h new file +101 -0
101 lines not on this page · raw message
arch/hexagon/kernel/dma.c new file +220 -0
220 lines not on this page · raw message
--
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
PATCH v3 28/36 Hexagon: Add ioremap support
In reply to Richard KuoRemoved redundant flush_cache_vmap.
--- arch/hexagon/mm/ioremap.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+)
arch/hexagon/mm/ioremap.c new file +56 -0
@@ -0,0 +1,56 @@ +/* +* I/O remap functions for Hexagon +* +* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#include <linux/io.h> +#include <linux/vmalloc.h> + +void __iomem *ioremap_nocache (unsigned long phys_addr,unsigned long size) +{ +unsigned long last_addr, addr; +unsigned long offset = phys_addr & ~PAGE_MASK ; +struct vm_struct *area; + +pgprot_t prot =__pgprot (_PAGE_PRESENT|_PAGE_READ|_PAGE_WRITE + |(__HEXAGON_C_DEV <<6 )); + + last_addr = phys_addr + size -1 ; + +/* Wrapping not allowed */ +if (!size || (last_addr < phys_addr)) +return NULL ; + +/* Rounds up to next page size, including whole-page offset */ + size =PAGE_ALIGN (offset + size); + + area =get_vm_area (size,VM_IOREMAP ); + addr = (unsigned long )area->addr; + +if (ioremap_page_range (addr, addr+size, phys_addr, prot)) { +vunmap ((void *)addr); +return NULL ; + } + +return (void __iomem *) (offset + addr); +} + +void __iounmap (const volatile void __iomem *addr) +{ +vunmap ((void *) ((unsigned long ) addr &PAGE_MASK )); +}
--
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Re: [patch v3 28/36] Hexagon: Add ioremap support
Quoted 3 lines · On Thursday 08 September 2011 20:09:15 Richard Kuo wrote:
Removed redundant
flush_cache_vmap.Signed-off-by Richard Kuo <[email protected]>
PATCH v3 29/36 Hexagon: Add page table header files & etc.
In reply to Richard KuoRemoved highmem more highmem stuff.
--- arch/hexagon/include/asm/fixmap.h | 73 ++++ arch/hexagon/include/asm/mmu.h | 37 ++ arch/hexagon/include/asm/mmu_context.h | 100 ++++++ arch/hexagon/include/asm/page.h | 157 ++++++++++ arch/hexagon/include/asm/pgalloc.h | 146 +++++++++ arch/hexagon/include/asm/pgtable.h | 518 +++++++++++++++++++++++++++++++++ arch/hexagon/mm/pgalloc.c | 25 + 7 files changed, 1056 insertions(+)
arch/hexagon/include/asm/fixmap.h new file +73 -0
@@ -0,0 +1,73 @@ +/* +* Fixmap support for Hexagon - enough to support highmem features +* +* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#ifndef _ASM_FIXMAP_H +#define _ASM_FIXMAP_H + +/* +* A lot of the fixmap info is already in mem-layout.h +*/ +#include <asm/mem-layout.h> + +/* +* Full fixmap support involves set_fixmap() functions, but +* these may not be needed if all we're after is an area for +* highmem kernel mappings. +*/ +#define __fix_to_virt (x) (FIXADDR_TOP - ((x) << PAGE_SHIFT)) +#define __virt_to_fix (x) ((FIXADDR_TOP - ((x)&PAGE_MASK)) >> PAGE_SHIFT) + +extern void __this_fixmap_does_not_exist (void ); + +/** +* fix_to_virt -- "index to address" translation. +* +* If anyone tries to use the idx directly without translation, +* we catch the bug with a NULL-deference kernel oops. Illegal +* ranges of incoming indices are caught too. +*/ +static inline unsigned long fix_to_virt (const unsigned int idx) +{ +/* +* This branch gets completely eliminated after inlining, +* except when someone tries to use fixaddr indices in an +* illegal way. (such as mixing up address types or using +* out-of-range indices). +* +* If it doesn't get removed, the linker will complain +* loudly with a reasonably clear error message.. +*/ +if (idx >= __end_of_fixed_addresses) +__this_fixmap_does_not_exist (); + +return __fix_to_virt (idx); +} + +static inline unsigned long virt_to_fix (const unsigned long vaddr) +{ +BUG_ON (vaddr >=FIXADDR_TOP || vaddr <FIXADDR_START ); +return __virt_to_fix (vaddr); +} + +#define kmap_get_fixmap_pte (vaddr) \ + pte_offset_kernel(pmd_offset(pud_offset(pgd_offset_k(vaddr), \ + (vaddr)), (vaddr)), (vaddr)) + +#endif
arch/hexagon/include/asm/mmu_context.h new file +100 -0
100 lines not on this page · raw message
arch/hexagon/include/asm/mmu.h new file +37 -0
@@ -0,0 +1,37 @@ +/* +* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#ifndef _ASM_MMU_H +#define _ASM_MMU_H + +#include <asm/vdso.h> + +/* +* Architecture-specific state for a mm_struct. +* For the Hexagon Virtual Machine, it can be a copy +* of the pointer to the page table base. +*/ +struct mm_context { +unsigned long long generation; +unsigned long ptbase; +struct hexagon_vdso *vdso; +}; + +typedef struct mm_context mm_context_t ; + +#endif
arch/hexagon/include/asm/page.h new file +157 -0
157 lines not on this page · raw message
arch/hexagon/include/asm/pgalloc.h new file +146 -0
146 lines not on this page · raw message
arch/hexagon/include/asm/pgtable.h new file +518 -0
518 lines not on this page · raw message
arch/hexagon/mm/pgalloc.c new file +25 -0
@@ -0,0 +1,25 @@ +/* +* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#include <linux/init.h> + +void __init pgtable_cache_init (void ) +{ +} + +
--
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Re: [patch v3 29/36] Hexagon: Add page table header files & etc.
Quoted 5 lines · On Thursday 08 September 2011 20:09:16 Richard Kuo wrote:
Removed highmem more highmem stuff.
Signed-off-by Richard Kuo <[email protected]>Signed-off-by Linas Vepstas <[email protected]>
PATCH v3 30/36 Hexagon: Add page-fault support.
In reply to Richard Kuo--- arch/hexagon/include/asm/mem-layout.h | 112 +++++++++++++ arch/hexagon/include/asm/vm_fault.h | 26 +++ arch/hexagon/mm/init.c | 276 ++++++++++++++++++++++++++++++++++ arch/hexagon/mm/vm_fault.c | 188 +++++++++++++++++++++++ 4 files changed, 602 insertions(+)
arch/hexagon/include/asm/mem-layout.h new file +112 -0
@@ -0,0 +1,112 @@ +/* +* Memory layout definitions for the Hexagon architecture +* +* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#ifndef _ASM_HEXAGON_MEM_LAYOUT_H +#define _ASM_HEXAGON_MEM_LAYOUT_H + +#include <linux/const.h> + +/* +* Have to do this for ginormous numbers, else they get printed as +* negative numbers, which the linker no likey when you try to +* assign it to the location counter. +*/ + +#define PAGE_OFFSET _AC(0xc0000000, UL) + +/* +* LOAD_ADDRESS is the physical/linear address of where in memory +* the kernel gets loaded. The 12 least significant bits must be zero (0) +* due to limitations on setting the EVB +* +*/ + +#ifndef LOAD_ADDRESS +#define LOAD_ADDRESS 0x00000000 +#endif + +#define TASK_SIZE (PAGE_OFFSET) + +/* not sure how these are used yet */ +#define STACK_TOP TASK_SIZE +#define STACK_TOP_MAX TASK_SIZE + +#ifndef __ASSEMBLY__ +enum fixed_addresses { +FIX_KMAP_BEGIN , +FIX_KMAP_END ,/* check for per-cpuism */ + __end_of_fixed_addresses +}; + +#define MIN_KERNEL_SEG 0x300/* From 0xc0000000 */ +extern int max_kernel_seg; + +/* +* Start of vmalloc virtual address space for kernel; +* supposed to be based on the amount of physical memory available +*/ + +#define VMALLOC_START (PAGE_OFFSET + VMALLOC_OFFSET + \ + (unsigned long)high_memory) + +/* Gap between physical ram and vmalloc space for guard purposes. */ +#define VMALLOC_OFFSET PAGE_SIZE + +/* +* Create the space between VMALLOC_START and FIXADDR_TOP backwards +* from the ... "top". +* +* Permanent IO mappings will live at 0xfexx_xxxx +* Hypervisor occupies the last 16MB page at 0xffxxxxxx +*/ + +#define FIXADDR_TOP 0xfe000000 +#define FIXADDR_SIZE (__end_of_fixed_addresses << PAGE_SHIFT) +#define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE) + +/* +* "permanent kernel mappings", defined as long-lasting mappings of +* high-memory page frames into the kernel address space. +*/ + +#define LAST_PKMAP PTRS_PER_PTE +#define LAST_PKMAP_MASK (LAST_PKMAP - 1) +#define PKMAP_NR (virt) ((virt - PKMAP_BASE) >> PAGE_SHIFT) +#define PKMAP_ADDR (nr) (PKMAP_BASE + ((nr) << PAGE_SHIFT)) + +/* +* To the "left" of the fixed map space is the kmap space +* +* "Permanent Kernel Mappings"; fancy (or less fancy) PTE table +* that looks like it's actually walked. +* Need to check the alignment/shift usage; some archs use +* PMD_MASK on this value +*/ +#define PKMAP_BASE (FIXADDR_START-PAGE_SIZE*LAST_PKMAP) + +/* +* 2 pages of guard gap between where vmalloc area ends +* and pkmap_base begins. +*/ +#define VMALLOC_END (PKMAP_BASE-PAGE_SIZE*2) +#endif /* !__ASSEMBLY__ */ + + +#endif /* _ASM_HEXAGON_MEM_LAYOUT_H */
arch/hexagon/mm/init.c new file +276 -0
276 lines not on this page · raw message
arch/hexagon/mm/vm_fault.c new file +188 -0
188 lines not on this page · raw message
arch/hexagon/include/asm/vm_fault.h new file +26 -0
@@ -0,0 +1,26 @@ +/* +* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#ifndef _ASM_HEXAGON_VM_FAULT_H +#define _ASM_HEXAGON_VM_FAULT_H + +extern void execute_protection_fault (struct pt_regs *); +extern void write_protection_fault (struct pt_regs *); +extern void read_protection_fault (struct pt_regs *); + +#endif
--
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Re: [patch v3 30/36] Hexagon: Add page-fault support.
Quoted 11 lines · Richard Kuo
arch/hexagon/mm/vm_fault.c new file +11
-0+/* +* Canonical page fault handler +*/ +void do_page_fault (unsigned long address,long cause,struct pt_regs *regs) +{ +struct vm_area_struct *vma; +struct mm_struct *mm = current->mm; +siginfo_t info; +int si_code; +int fault; +const struct exception_table_entry *fixup;
arch/hexagon/mm/vm_fault.c line 65
Quoted 10 lines
arch/hexagon/mm/vm_fault.c new file +10
-0+ + si_code =SEGV_MAPERR ; +local_irq_enable (); + +/* +* If we're in an interrupt or have no user context, +* then must not take the fault. +*/ +if (unlikely (in_interrupt () || !mm)) + goto no_context;
Are you sure about enabling interrupts before going to "no_context" ?
If somebody does a user access "in atomic" with interrupt disabled (with the expectation that a fault would be caught by search_exception_tables and returned as -EFAULT), such code probably doesn't expect interrupts to be re-enabled implicitely.
Cheers,
Ben.
Re: [patch v3 30/36] Hexagon: Add page-fault support.
Quoted 6 lines · Benjamin Herrenschmidt
Are you sure about enabling interrupts before going to "
no_context" ?If somebody does a user access "in atomic" with interrupt disabled (with the expectation that a fault would be caught by
search_exception_tablesand returned as-EFAULT), such code probably doesn't expect interrupts to be re-enabled implicitely.
I hadn't considered that... I'll review this and make sure this isn't what we intended (it probably isn't) and get it fixed.
Thanks,
Richard Kuo
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
PATCH v3 31/36 Hexagon: kgdb support files
In reply to Richard Kuo--- arch/hexagon/include/asm/kgdb.h | 39 ++++++ arch/hexagon/kernel/kgdb.c | 241 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 280 insertions(+)
arch/hexagon/include/asm/kgdb.h new file +39 -0
@@ -0,0 +1,39 @@ +/* +* arch/hexagon/include/asm/kgdb.h - Hexagon KGDB Support +* +* Copyright (c) 2011, Code Aurora Forum. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#ifndef __HEXAGON_KGDB_H__ +#define __HEXAGON_KGDB_H__ + +#define BREAK_INSTR_SIZE 4 +#define CACHE_FLUSH_IS_SAFE 1 +#define BUFMAX ((NUMREGBYTES * 2) + 512) + +static inline void arch_kgdb_breakpoint (void ) +{ + asm("trap0(#0xDB)" ); +} + +/* Registers: +* 32 gpr + sa0/1 + lc0/1 + m0/1 + gp + ugp + pred + pc = 42 total. +*/ +#define NUMREGBYTES (42*4) +#define DBG_MAX_REG_NUM 42 + +#endif /* __HEXAGON_KGDB_H__ */
arch/hexagon/kernel/kgdb.c new file +241 -0
241 lines not on this page · raw message
--
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
PATCH v3 32/36 Hexagon: Comet platform support
In reply to Richard KuoUsed the shortened version of the config; other platform stuff moved out until it's ready.
--- arch/hexagon/configs/comet_defconfig | 85 +++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+)
arch/hexagon/configs/comet_defconfig new file +85 -0
@@ -0,0 +1,85 @@ +CONFIG_SMP=y +CONFIG_DEFAULT_MMAP_MIN_ADDR=0 +CONFIG_HZ_100=y +CONFIG_EXPERIMENTAL=y +CONFIG_CROSS_COMPILE="hexagon-" +CONFIG_LOCALVERSION="-smp" +# CONFIG_LOCALVERSION_AUTO is not set +CONFIG_SYSVIPC=y +CONFIG_POSIX_MQUEUE=y +CONFIG_BSD_PROCESS_ACCT=y +CONFIG_BSD_PROCESS_ACCT_V3=y +CONFIG_TASKSTATS=y +CONFIG_TASK_DELAY_ACCT=y +CONFIG_IKCONFIG=y +CONFIG_IKCONFIG_PROC=y +CONFIG_LOG_BUF_SHIFT=18 +CONFIG_BLK_DEV_INITRD=y +CONFIG_EMBEDDED=y +# CONFIG_VM_EVENT_COUNTERS is not set +# CONFIG_BLK_DEV_BSG is not set +CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" +# CONFIG_STANDALONE is not set +CONFIG_CONNECTOR=y +CONFIG_BLK_DEV_LOOP=y +CONFIG_BLK_DEV_NBD=y +CONFIG_NETDEVICES=y +CONFIG_MII=y +CONFIG_PHYLIB=y +CONFIG_NET_ETHERNET=y +# CONFIG_NETDEV_1000 is not set +# CONFIG_NETDEV_10000 is not set +# CONFIG_INPUT_MOUSEDEV is not set +# CONFIG_INPUT_KEYBOARD is not set +# CONFIG_INPUT_MOUSE is not set +# CONFIG_SERIO is not set +# CONFIG_CONSOLE_TRANSLATIONS is not set +CONFIG_LEGACY_PTY_COUNT=64 +# CONFIG_DEVKMEM is not set +# CONFIG_HW_RANDOM is not set +CONFIG_SPI=y +CONFIG_SPI_DEBUG=y +CONFIG_SPI_BITBANG=y +# CONFIG_HWMON is not set +# CONFIG_VGA_CONSOLE is not set +# CONFIG_HID_SUPPORT is not set +# CONFIG_USB_SUPPORT is not set +CONFIG_EXT2_FS=y +CONFIG_EXT2_FS_XATTR=y +CONFIG_EXT2_FS_POSIX_ACL=y +CONFIG_EXT2_FS_SECURITY=y +CONFIG_EXT3_FS=y +# CONFIG_EXT3_DEFAULTS_TO_ORDERED is not set +CONFIG_EXT3_FS_POSIX_ACL=y +CONFIG_EXT3_FS_SECURITY=y +CONFIG_QUOTA=y +CONFIG_PROC_KCORE=y +CONFIG_TMPFS=y +CONFIG_TMPFS_POSIX_ACL=y +# CONFIG_MISC_FILESYSTEMS is not set +CONFIG_NFS_FS=y +CONFIG_NFS_V3=y +CONFIG_NFS_V3_ACL=y +# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set +CONFIG_NET=y +CONFIG_PACKET=y +CONFIG_UNIX=y +CONFIG_INET=y +# CONFIG_INET_XFRM_MODE_TRANSPORT is not set +# CONFIG_INET_XFRM_MODE_TUNNEL is not set +# CONFIG_INET_XFRM_MODE_BEET is not set +# CONFIG_INET_LRO is not set +# CONFIG_INET_DIAG is not set +# CONFIG_IPV6 is not set +CONFIG_CRYPTO_MD5=y +# CONFIG_CRYPTO_ANSI_CPRNG is not set +# CONFIG_CRYPTO_HW is not set +CONFIG_CRC_CCITT=y +CONFIG_CRC16=y +CONFIG_CRC_T10DIF=y +CONFIG_LIBCRC32C=y +CONFIG_FRAME_WARN=0 +CONFIG_MAGIC_SYSRQ=y +CONFIG_DEBUG_FS=y +# CONFIG_SCHED_DEBUG is not set +CONFIG_DEBUG_INFO=y
--
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
PATCH v3 33/36 Hexagon: Add configuration and makefiles for the Hexagon architecture.
In reply to Richard KuoRemoved CONFIG_ARCH_HAS_KMAP
--- arch/hexagon/Kconfig | 218 ++++++++++++++++++++++++++++++++++++++ arch/hexagon/Makefile | 59 ++++++++++ arch/hexagon/kernel/Makefile | 19 +++ arch/hexagon/kernel/asm-offsets.c | 104 ++++++++++++++++++ arch/hexagon/kernel/vmlinux.lds.S | 93 ++++++++++++++++ arch/hexagon/lib/Makefile | 4 arch/hexagon/mm/Makefile | 7 + 7 files changed, 504 insertions(+)
arch/hexagon/Kconfig new file +218 -0
@@ -0,0 +1,218 @@ +# Hexagon configuration +comment "Linux Kernel Configuration for Hexagon" + +config HEXAGON + def_bool y + select HAVE_OPROFILE + select USE_GENERIC_SMP_HELPERS if SMP + # Other pending projects/to-do items. + # select HAVE_REGS_AND_STACK_ACCESS_API + # select HAVE_HW_BREAKPOINT if PERF_EVENTS + # select ARCH_HAS_CPU_IDLE_WAIT + # select ARCH_WANT_OPTIONAL_GPIOLIB + # select ARCH_REQUIRE_GPIOLIB + # select HAVE_CLK + # select IRQ_PER_CPU + select HAVE_IRQ_WORK + # select GENERIC_PENDING_IRQ if SMP + select GENERIC_ATOMIC64 + select HAVE_PERF_EVENTS + select HAVE_GENERIC_HARDIRQS + select GENERIC_HARDIRQS_NO__DO_IRQ + select GENERIC_HARDIRQS_NO_DEPRECATED + # GENERIC_ALLOCATOR is used by dma_alloc_coherent() + select GENERIC_ALLOCATOR + select HAVE_ARCH_KGDB + select NO_IOPORT + # mostly generic routines, with some accelerated ones + ---help--- + Qualcomm Hexagon is a processor architecture designed for high + performance and low power across a wide variety of applications. + +config HEXAGON_ARCH_V1 + bool + +config HEXAGON_ARCH_V2 + bool + +config HEXAGON_ARCH_V3 + bool + +config HEXAGON_ARCH_V4 + bool + +config FRAME_POINTER + def_bool y + +config LOCKDEP_SUPPORT + def_bool y + +config PCI + def_bool n + +config EARLY_PRINTK + def_bool y + +config KTIME_SCALAR + def_bool y + +config MMU + def_bool y + +config TRACE_IRQFLAGS_SUPPORT + def_bool y + +config GENERIC_CSUM + def_bool y + +# +# Use the generic interrupt handling code in kernel/irq/: +# +config GENERIC_IRQ_PROBE + def_bool y + +config GENERIC_IOMAP + def_bool y + +#config ZONE_DMA +# bool +# default y + +config HAS_DMA + bool + select HAVE_DMA_ATTRS + default y + +config NEED_SG_DMA_LENGTH + def_bool y + +config RWSEM_GENERIC_SPINLOCK + def_bool n + +config RWSEM_XCHGADD_ALGORITHM + def_bool y + +config GENERIC_FIND_NEXT_BIT + def_bool y + +config GENERIC_HWEIGHT + def_bool y + +config GENERIC_TIME + def_bool y + +config GENERIC_CLOCKEVENTS + def_bool y + +config GENERIC_CLOCKEVENTS_BROADCAST + def_bool y + +config STACKTRACE_SUPPORT + def_bool y + select STACKTRACE + +config GENERIC_BUG + def_bool y + depends on BUG + +config BUG + def_bool y + +menu "Machine selection" + +choice + prompt "System type" + default HEXAGON_ARCH_V2 + +config HEXAGON_COMET + bool "Comet Board" + select HEXAGON_ARCH_V2 + ---help--- + Support for the Comet platform. + +endchoice + +config HEXAGON_VM + def_bool y + +config CMDLINE + string "Default kernel command string" + default "" + help + On some platforms, there is currently no way for the boot loader + to pass arguments to the kernel. For these, you should supply some + command-line options at build time by entering them here. At a + minimum, you should specify the memory size and the root device + (e.g., mem=64M root=/dev/nfs). + +config HEXAGON_ANGEL_TRAPS + bool "Use Angel Traps" + default n + ---help--- + Enable angel debug traps (for printk's). + +config SMP + bool "Multi-Processing support" + ---help--- + Enables SMP support in the kernel. If unsure, say "Y" + +config NR_CPUS + int "Maximum number of CPUs" if SMP + range 2 6 if SMP + default "1" if !SMP + default "6" if SMP + ---help--- + This allows you to specify the maximum number of CPUs which this + kernel will support. The maximum supported value is 6 and the + minimum value which makes sense is 2. + + This is purely to save memory - each supported CPU adds + approximately eight kilobytes to the kernel image. + +choice + prompt "Kernel page size" + default PAGE_SIZE_4KB + ---help--- + Changes the default page size; use with caution. + +config PAGE_SIZE_4KB + bool "4KB" + +config PAGE_SIZE_16KB + bool "16KB" + +config PAGE_SIZE_64KB + bool "64KB" + +config PAGE_SIZE_256KB + bool "256KB" + +endchoice + +source "mm/Kconfig" + +source "kernel/Kconfig.hz" +source "kernel/time/Kconfig" + +config GENERIC_GPIO + bool "Generic GPIO support" + default n + +endmenu + +source "init/Kconfig" +source "drivers/Kconfig" +source "fs/Kconfig" + +menu "Executable File Formats" +source "fs/Kconfig.binfmt" +endmenu + +source "net/Kconfig" +source "security/Kconfig" +source "crypto/Kconfig" +source "lib/Kconfig" + +menu "Kernel hacking" +source "lib/Kconfig.debug" +endmenu
arch/hexagon/kernel/asm-offsets.c new file +104 -0
104 lines not on this page · raw message
arch/hexagon/kernel/vmlinux.lds.S new file +93 -0
93 lines not on this page · raw message
arch/hexagon/lib/Makefile new file +4 -0
@@ -0,0 +1,4 @@ +# +# Makefile for hexagon-specific library files. +# +obj-y = checksum.o io.o memcpy.o memset.o
arch/hexagon/Makefile new file +59 -0
59 lines not on this page · raw message
arch/hexagon/mm/Makefile new file +7 -0
@@ -0,0 +1,7 @@ +# +# Makefile for Hexagon memory management subsystem +# + +obj-y := init.o pgalloc.o ioremap.o uaccess.o vm_fault.o cache.o +obj-y += copy_to_user.o copy_from_user.o strnlen_user.o vm_tlb.o +
arch/hexagon/kernel/Makefile new file +19 -0
@@ -0,0 +1,19 @@ +extra-y := head.o vmlinux.lds init_task.o + +obj-$(CONFIG_SMP) += smp.o topology.o + +obj-y += irq.o setup.o irq_cpu.o traps.o syscalltab.o signal.o time.o +obj-y += process.o syscall.o trampoline.o reset.o ptrace.o +obj-y += vdso.o + +obj-$(CONFIG_KGDB) += kgdb.o +obj-$(CONFIG_MODULES) += module.o hexagon_ksyms.o + +# Modules required to work with the Hexagon Virtual Machine +obj-y += vm_entry.o vm_events.o vm_switch.o vm_ops.o vm_init_segtable.o +obj-y += vm_vectors.o + +obj-$(CONFIG_HAS_DMA) += dma.o + +obj-$(CONFIG_STACKTRACE) += stacktrace.o +
--
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
PATCH v3 34/36 Hexagon: Add basic stacktrace functionality for Hexagon architecture.
In reply to Richard Kuo--- arch/hexagon/kernel/stacktrace.c | 66 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+)
arch/hexagon/kernel/stacktrace.c new file +66 -0
@@ -0,0 +1,66 @@ +/* +* Stacktrace support for Hexagon +* +* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +* 02110-1301, USA. +*/ + +#include <linux/sched.h> +#include <linux/stacktrace.h> +#include <linux/thread_info.h> +#include <linux/module.h> + +registerunsigned long current_frame_pointer asm("r30" ); + +struct stackframe { +unsigned long fp; +unsigned long rets; +}; + +/* +* Save stack-backtrace addresses into a stack_trace buffer. +*/ +void save_stack_trace (struct stack_trace *trace) +{ +unsigned long low, high; +unsigned long fp; +struct stackframe *frame; +int skip = trace->skip; + + low = (unsigned long )task_stack_page (current); + high = low +THREAD_SIZE ; + fp = current_frame_pointer; + +while (fp >= low && fp <= (high -sizeof (*frame))) { + frame = (struct stackframe *)fp; + +if (skip) { + skip--; + }else { + trace->entries[trace->nr_entries++] = frame->rets; +if (trace->nr_entries >= trace->max_entries) +break ; + } + +/* +* The next frame must be at a higher address than the +* current frame. +*/ + low = fp +sizeof (*frame); + fp = frame->fp; + } +} +EXPORT_SYMBOL_GPL (save_stack_trace);
--
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
PATCH v3 35/36 Hexagon: Add self to MAINTAINERS
In reply to Richard Kuo--- MAINTAINERS | 6 ++++++ 1 file changed, 6 insertions(+)
MAINTAINERS +6 -0
@@ -5279,6 +5279,12 @@ F: include/linux/qnx4_fs.h F: include/linux/qnxtypes.h +QUALCOMM HEXAGON ARCHITECTURE +M: Richard Kuo <[email protected]> +L: [email protected] +S: Supported +F: arch/hexagon/ + RADOS BLOCK DEVICE (RBD) F: include/linux/qnxtypes.h M: Yehuda Sadeh <[email protected]>
--
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Re: [patch v3 35/36] Hexagon: Add self to MAINTAINERS
Quoted 1 line · On Thursday 08 September 2011 20:09:22 Richard Kuo wrote:
Signed-off-by Richard Kuo <[email protected]>
PATCH v3 36/36 Add extra arch overrides to asm-generic/checksum.h
In reply to Richard KuoThere are plausible reasons for architectures to provide their own versions of csum_partial_copy_nocheck and csum_tcpudp_magic. By protecting these, the architecture can still re-use the asm-generic checksum.h, instead of copying it.
--- include/asm-generic/checksum.h | 4 ++++ 1 file changed, 4 insertions(+)
include/asm-generic/checksum.h +4 -0
@@ -33,8 +33,10 @@extern __wsum csum_partial_copy_from_user (const void __user *src,void *dst,int len,__wsum sum,int *csum_err); +#ifndef csum_partial_copy_nocheck#define csum_partial_copy_nocheck (src, dst, len, sum) \ csum_partial_copy((src), (dst), (len), (sum)) +#endif /* * This is a version of ip_compute_csum() optimized for IP headers,
@@ -63,12 +65,14 @@ unsigned short proto, __wsum sum);#endif +#ifndef csum_tcpudp_magicstatic inline __sum16 csum_tcpudp_magic (__be32 saddr,__be32 daddr,unsigned short len,unsigned short proto,__wsum sum) {return csum_fold (csum_tcpudp_nofold (saddr, daddr, len, proto, sum)); } +#endif /* * this routine is used for miscellaneous IP-like checksums, mainly
--
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Arnd Bergmann
maintainerQuoted 18 lines · On Thursday 08 September 2011 20:08:47 Richard Kuo wrote:
This is the third version of the patchset to the Linux kernel to support the Qualcomm Hexagon architecture. These patches have been organized like the last time, in a somewhat logically grouped fashion.
A summary of changes from the last patchset:
* removed__delay
* cleaned up checksum header to pull generic one
* implemented vDSO so signal trampolines are no longer on stack
* fixedcpu_idle()
* removedinit_IRQ()wrapper
* cleaned up (most of) the wrongness intime.c
* cleaned upsmp.cto use more generic IPI handlers
* filled in ins/outs routines in IO and other misc cleanup
* removed redundant vunmap from ioremap
* removed more highmem cruft
* moved rwsem to asm-generic
* bonus ifdefs added to genericchecksum.h
Quoted 7 lines
Also, I have been compiling with sparse and it seems to pass.
These patches are available on Code Aurora:
https://www.codeaurora.org/patches/quic/hlk/hexagon-linux-20110908.tar.gz
Thanks again for everyone's feedback!
Ok, very good.
I haven't checked if it's already in linux-next, since you said you first wanted to fix a few things. If it's not, please have Stephen add it now.
I wrote a small piece on the two new architectures for 3.2 in
http://lwn.net/Articles/457635/ , I hope I got the facts right.
The ptrace interface is the only part that I'd ask you to definitely fix before the merge window, because of the impact to the user space
ABI: We try to be strict about not breaking user-visible interfaces for any code that has been in an official kernel release. It's of course less important for a newly merged architecture when there are no existing users, but I think it's best to always enforce this rule.
It would of course be very nice if you could get the board support based on device tree probing ready as well by the same time, but I don't see that as a show-stopper for inclusion.
One small comment about the way that you send patches: The changelog part if each patch you send lists the changes that you have done since the first submission. This is indeed helpful for the purpose of the review, but it's not actually how you are supposed to use this. The body of the email should instead start with a 'changeset comment' that describes the changes made by the patch, followed by the 'Signed-off-by:' lines, and then after the '---' line you should write the text that does not become part of the permanent git history: the diffstat and any additional comments you have for reviewers including what has changed since last time.
Arnd