summaryrefslogtreecommitdiff
path: root/arch/sparc/lib
AgeCommit message (Collapse)Author
2012-01-11sparc32: Correct the return value of memcpy.David S. Miller
[ Upstream commit a52312b88c8103e965979a79a07f6b34af82ca4b ] Properly return the original destination buffer pointer. Signed-off-by: David S. Miller <davem@davemloft.net> Tested-by: Kjetil Oftedal <oftedal@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> Change-Id: I382ae5b35768be56473c8e92d68e2f3c74bf1422 Reviewed-on: http://git-master/r/74210 Reviewed-by: Varun Wadekar <vwadekar@nvidia.com> Tested-by: Varun Wadekar <vwadekar@nvidia.com>
2012-01-11sparc32: Remove uses of %g7 in memcpy implementation.David S. Miller
[ Upstream commit 21f74d361dfd6a7d0e47574e315f780d8172084a ] This is setting things up so that we can correct the return value, so that it properly returns the original destination buffer pointer. Signed-off-by: David S. Miller <davem@davemloft.net> Tested-by: Kjetil Oftedal <oftedal@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> Change-Id: I1515c20b1bcb29e9d32fedaa7fc2af3bfea265cb Reviewed-on: http://git-master/r/74209 Reviewed-by: Varun Wadekar <vwadekar@nvidia.com> Tested-by: Varun Wadekar <vwadekar@nvidia.com>
2012-01-11sparc32: Remove non-kernel code from memcpy implementation.David S. Miller
[ Upstream commit 045b7de9ca0cf09f1adc3efa467f668b89238390 ] Signed-off-by: David S. Miller <davem@davemloft.net> Tested-by: Kjetil Oftedal <oftedal@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> Change-Id: I469c7a79eaa35d3b5dcc1e6c1468174aa96dd87f Reviewed-on: http://git-master/r/74208 Reviewed-by: Varun Wadekar <vwadekar@nvidia.com> Tested-by: Varun Wadekar <vwadekar@nvidia.com>
2011-08-04sparc: Fix __atomic_add_unless() return value.Josip Rodin
Signed-off-by: David S. Miller <davem@davemloft.net>
2011-08-02sparc: Use popc when possible for ffs/__ffs/ffz.David S. Miller
Signed-off-by: David S. Miller <davem@davemloft.net>
2011-08-02sparc: Use popc if possible for hweight routines.David S. Miller
Just like powerpc, we code patch at boot time. Signed-off-by: David S. Miller <davem@davemloft.net>
2011-08-02sparc: Minor tweaks to Niagara page copy/clear.David S. Miller
Don't use floating point on Niagara2, use the traditional plain Niagara code instead. Unroll Niagara loops to 128 bytes for copy, and 256 bytes for clear. Signed-off-by: David S. Miller <davem@davemloft.net>
2011-07-27sparc: rename atomic_add_unlessStephen Rothwell
Should have been done in commit 1af08a1407f4 ("This is in preparation for more generic atomic"). Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au> Cc: Arun Sharma <asharma@fb.com> Cc: David Miller <davem@davemloft.net> Cc: "Hans-Christian Egtvedt" <hans-christian.egtvedt@atmel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-07-26atomic: use <linux/atomic.h>Arun Sharma
This allows us to move duplicated code in <asm/atomic.h> (atomic_inc_not_zero() for now) to <linux/atomic.h> Signed-off-by: Arun Sharma <asharma@fb.com> Reviewed-by: Eric Dumazet <eric.dumazet@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: David Miller <davem@davemloft.net> Cc: Eric Dumazet <eric.dumazet@gmail.com> Acked-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-05-20Merge branch 'master' of ↵David S. Miller
master.kernel.org:/pub/scm/linux/kernel/git/davem/sparc-2.6
2011-05-11sparc32: Fixed unaligned memory copying in function ↵Tkhai Kirill
__csum_partial_copy_sparc_generic When we are in the label cc_dword_align, registers %o0 and %o1 have the same last 2 bits, but it's not guaranteed one of them is zero. So we can get unaligned memory access in label ccte. Example of parameters which lead to this: %o0=0x7ff183e9, %o1=0x8e709e7d, %g1=3 With the parameters I had a memory corruption, when the additional 5 bytes were rewritten. This patch corrects the error. One comment to the patch. We don't care about the third bit in %o1, because cc_end_cruft stores word or less. Signed-off-by: Tkhai Kirill <tkhai@yandex.ru> Signed-off-by: David S. Miller <davem@davemloft.net>
2011-04-21sparc32: removed unused code, implemented by generic codeDaniel Hellstrom
Signed-off-by: Daniel Hellstrom <daniel@gaisler.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2011-03-15Merge branch 'core-locking-for-linus' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip * 'core-locking-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: rtmutex: tester: Remove the remaining BKL leftovers lockdep/timers: Explain in detail the locking problems del_timer_sync() may cause rtmutex: Simplify PI algorithm and make highest prio task get lock rwsem: Remove redundant asmregparm annotation rwsem: Move duplicate function prototypes to linux/rwsem.h rwsem: Unify the duplicate rwsem_is_locked() inlines rwsem: Move duplicate init macros and functions to linux/rwsem.h rwsem: Move duplicate struct rwsem declaration to linux/rwsem.h x86: Cleanup rwsem_count_t typedef rwsem: Cleanup includes locking: Remove deprecated lock initializers cred: Replace deprecated spinlock initialization kthread: Replace deprecated spinlock initialization xtensa: Replace deprecated spinlock initialization um: Replace deprecated spinlock initialization sparc: Replace deprecated spinlock initialization mips: Replace deprecated spinlock initialization cris: Replace deprecated spinlock initialization alpha: Replace deprecated spinlock initialization rtmutex-tester: Remove BKL tests
2011-02-08sparc: use bitmap_set()Akinobu Mita
Use bitmap_set() instead of calling __set_bit() each bit. Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Cc: "David S. Miller" <davem@davemloft.net> Cc: sparclinux@vger.kernel.org Signed-off-by: David S. Miller <davem@davemloft.net>
2011-01-27sparc: Replace deprecated spinlock initializationThomas Gleixner
SPIN_LOCK_UNLOCK is deprecated. Use the lockdep capable variant instead. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: David S. Miller <davem@davemloft.net>
2010-08-18sparc64: Make lock backoff really a NOP on UP builds.David S. Miller
As noticed by Mikulas Patocka, the backoff macros don't completely nop out for UP builds, we still get a branch always and a delay slot nop. Fix this by making the branch to the backoff spin loop selective, then we can nop out the spin loop completely. Signed-off-by: David S. Miller <davem@davemloft.net>
2010-08-18sparc64: simple microoptimizations for atomic functionsMikulas Patocka
Simple microoptimizations for sparc64 atomic functions: Save one instruction by using a delay slot. Use %g1 instead of %g7, because %g1 is written earlier. Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2010-08-17sparc64: Make rwsems 64-bit.David S. Miller
Basically tip-off the powerpc code, use a 64-bit type and atomic64_t interfaces for the implementation. This gets us off of the by-hand asm code I wrote, which frankly I think probably ruins I-cache hit rates. The idea was the keep the call chains less deep, but anything taking the rw-semaphores probably is also calling other stuff and therefore already has allocated a stack-frame. So no real stack frame savings ever. Ben H. has posted patches to make powerpc use 64-bit too and with some abstractions we can probably use a shared header file somewhere. With suggestions from Sam Ravnborg. Signed-off-by: David S. Miller <davem@davemloft.net>
2010-04-13sparc64: Allocate sufficient stack space in ftrace stubs.David S. Miller
128 bytes is sufficient for the register window save area, but the calling conventions allow the callee to save up to 6 incoming argument registers into the stack frame after the register window save area. This means a minimal stack frame is 176 bytes (128 + (6 * 8)). This fixes random crashes when using the function tracer. Reported-by: Frederic Weisbecker <fweisbec@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2010-04-12sparc64: Add function graph tracer support.David S. Miller
Signed-off-by: David S. Miller <davem@davemloft.net>
2010-04-12sparc64: Give a stack frame to the ftrace call sites.David S. Miller
It's the only way we'll be able to implement the function graph tracer properly. A positive is that we no longer have to worry about the linker over-optimizing the tail call, since we don't use a tail call any more. Signed-off-by: David S. Miller <davem@davemloft.net>
2010-04-12sparc64: Kill CONFIG_STACK_DEBUG code.David S. Miller
The generic stack tracer does this job just as well. Signed-off-by: David S. Miller <davem@davemloft.net>
2010-04-12sparc64: Add HAVE_FUNCTION_TRACE_MCOUNT_TEST and tidy up.David S. Miller
Check function_trace_stop at ftrace_caller Toss mcount_call and dummy call of ftrace_stub, unnecessary. Document problems we'll have if the final kernel image link ever turns on relaxation. Properly size 'ftrace_call' so it looks right when inspecting instructions under gdb et al. Signed-off-by: David S. Miller <davem@davemloft.net>
2009-12-10sparc: Stop trying to be so fancy and use __builtin_{memcpy,memset}()David S. Miller
This mirrors commit ff60fab71bb3b4fdbf8caf57ff3739ffd0887396 (x86: Use __builtin_memset and __builtin_memcpy for memset/memcpy) Signed-off-by: David S. Miller <davem@davemloft.net>
2009-12-10sparc: Use __builtin_object_size() to validate the buffer size for ↵David S. Miller
copy_from_user() This mirrors x86 commit 9f0cf4adb6aa0bfccf675c938124e68f7f06349d (x86: Use __builtin_object_size() to validate the buffer size for copy_from_user()) Signed-off-by: David S. Miller <davem@davemloft.net>
2009-12-09sparc64: Fix stack debugging IRQ stack regression.David S. Miller
Commit 4f70f7a91bffdcc39f088748dc678953eb9a3fbd (sparc64: Implement IRQ stacks.) has two bugs. First, the softirq range check forgets to subtract STACK_BIAS before comparing with %sp. Next, on failure the wrong label is jumped to, resulting in a bogus stack being loaded. Reported-by: Igor Kovalenko <igor.v.kovalenko@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2009-05-29sparc64: Fix section attribute warnings.David S. Miller
CSUM copy to/from user assembler was missing allocatable and executable attributes for .fixup Signed-off-by: David S. Miller <davem@davemloft.net>
2009-02-08sparc64: Fix probe_kernel_{read,write}().David S. Miller
This is based upon a report from Chris Torek and his initial patch. From Chris's report: -------------------- This came up in testing kgdb, using the built-in tests -- turn on CONFIG_KGDB_TESTS, then echo V1 > /sys/module/kgdbts/parameters/kgdbts -- but it would affect using kgdb if you were debugging and looking at bad pointers. -------------------- When we get a copy_{from,to}_user() request and the %asi is set to something other than ASI_AIUS (which is userspace) then we branch off to a routine called memcpy_user_stub(). It just does a straight memcpy since we are copying from kernel to kernel in this case. The logic was that since source and destination are both kernel pointers we don't need to have exception checks. But for what probe_kernel_{read,write}() is trying to do, we have to have the checks, otherwise things like kgdb bad kernel pointer accesses don't do the right thing. Signed-off-by: David S. Miller <davem@davemloft.net>
2009-02-08sparc64: Kill .fixup section bloat.David S. Miller
This is an implementation of a suggestion made by Chris Torek: -------------------- Something else I noticed in passing: the EX and EX_LD/EX_ST macros scattered throughout the various .S files make a fair bit of .fixup code, all of which does the same thing. At the cost of one symbol in copy_in_user.S, you could just have one common two-instruction retl-and-mov-1 fixup that they all share. -------------------- The following is with a defconfig build: text data bss dec hex filename 3972767 344024 584449 4901240 4ac978 vmlinux.orig 3968887 344024 584449 4897360 4aba50 vmlinux Signed-off-by: David S. Miller <davem@davemloft.net>
2009-01-17sparc64: fix modpost failureSam Ravnborg
Previously PeeCeeI.o was a library but it was always pulled in due to insw and friends being exported (at least for a modular kernel). But this resulted in modpost failures if there where no in-kernel users because then insw & friends were not linked in. Fix this by including PeeCeeI.o in the kernel unconditionally. The only drawback for this solution is that a nonmodular kernel will always include insw & friends no matter if they are in use or not. Reported-by: Meelis Roos <mroos@linux.ee> Signed-off-by: Sam Ravnborg <sam@ravnborg.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2009-01-08sparc64: move EXPORT_SYMBOL to the symbols definitionSam Ravnborg
Move all applicable EXPORT_SYMBOL()s to the file where the respective symbol is defined. Removed all the includes that are no longer needed in sparc_ksyms_64.c Comment all remaining EXPORT_SYMBOL()s in sparc_ksyms_64.c Signed-off-by: Sam Ravnborg <sam@ravnborg.org> Additions by Julian Calaby: * Moved EXPORT_SYMBOL()s for prom functions to their rightful places. * Made some minor cleanups to the includes and comments of sparc_ksyms_64.c * Updated and tidied commit message. * Rebased patch over sparc-2.6.git HEAD. * Ensured that all modified files have the correct includes. Signed-off-by: Julian Calaby <julian.calaby@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2009-01-08sparc: Create a new file lib/ksyms.c and add export of all symbols defined ↵Sam Ravnborg
in assembler in lib/ to this file. Remove the duplicate entries from kernel/sparc_ksyms_*.c The rationale behind this is that the EXPORT_SYMBOL() should be close to their definition and we cannot add designate a symbol to be exported in assembler so at least put it in a file in the same directory. Signed-off-by: Sam Ravnborg <sam@ravnborg.org> Additions by Julian Calaby: * Rebased over sparc-2.6.git HEAD Signed-off-by: Julian Calaby <julian.calaby@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2008-12-09sparc: Commonize memcmp assembler.David S. Miller
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-12-09sparc: Unify strlen assembler.David S. Miller
Use the new asm/asm.h header to help commonize the strlen assembler between 32-bit and 64-bit While we're here, use proper linux/linkage.h macros instead of by-hand stuff. Signed-off-by: David S. Miller <davem@davemloft.net>
2008-12-08sparc: Kill memcmp_32.S code which has been ifdef'd out for centuries.David S. Miller
Signed-off-by: David S. Miller <davem@davemloft.net>
2008-12-04sparc,sparc64: unify lib/Sam Ravnborg
o Renamed files in sparc64 to <name>_64.S when identical to sparc32 files. o iomap.c were equal for sparc32 and sparc64 o adjusted sparc/Makefile now we have only one lib/ Signed-off-by: Sam Ravnborg <sam@ravnborg.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2008-12-04sparc: prepare lib/ for unificationSam Ravnborg
Identical named files renamed to <name>_32.S Refactored Makefile to prepare for unification. Linking order was altered slightly - but this is a lib.a file so it should not matter. Signed-off-by: Sam Ravnborg <sam@ravnborg.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2008-05-20sparc: remove CVS keywordsAdrian Bunk
This patch removes the CVS keywords that weren't updated for a long time from comments. Signed-off-by: Adrian Bunk <bunk@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2008-04-29iomap: fix 64 bits resources on 32 bitsBenjamin Herrenschmidt
Almost all implementations of pci_iomap() in the kernel, including the generic lib/iomap.c one, copies the content of a struct resource into unsigned long's which will break on 32 bits platforms with 64 bits resources. This fixes all definitions of pci_iomap() to use resource_size_t. I also "fixed" the 64bits arch for consistency. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: <linux-arch@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-01-31[SPARC/SPARC64]: Fix usage of .section .sched.text in assembler code.Sam Ravnborg
ld will generate an unique named section when assembler do not use "ax" but gcc does. Add the missing annotation. Signed-off-by: Sam Ravnborg <sam@ravnborg.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2007-08-26[SPARC32]: Add __cmpdi2() libcall implementation ala. MIPS.David S. Miller
Device mapper generates calls to this with recent versions of gcc. Signed-off-by: David S. Miller <davem@davemloft.net>
2007-07-24[SPARC32]: Fix bug in sparc optimized memset.Alexander Shmelev
Sparc optimized memset (arch/sparc/lib/memset.S) does not fill last byte of the memory area, if area size is less than 8 bytes and start address is not word (4-bytes) aligned. Here is code chunk where bug located: /* %o0 - memory address, %o1 - size, %g3 - value */ 8: add %o0, 1, %o0 subcc %o1, 1, %o1 bne,a 8b stb %g3, [%o0 - 1] This code should write byte every loop iteration, but last time delay instruction stb is not executed because branch instruction sets "annul" bit. Patch replaces bne,a by bne instruction. Error can be reproduced by simple kernel module: -------------------- #include <linux/module.h> #include <linux/config.h> #include <linux/kernel.h> #include <linux/errno.h> #include <string.h> static void do_memset(void **p, int size) { memset(p, 0x00, size); } static int __init memset_test_init(void) { char fooc[8]; int *fooi; memset(fooc, 0xba, sizeof(fooc)); do_memset((void**)(fooc + 3), 1); fooi = (int*) fooc; printk("%08X %08X\n", fooi[0], fooi[1]); return -1; } static void __exit memset_test_cleanup(void) { return; } module_init(memset_test_init); module_exit(memset_test_cleanup); MODULE_LICENSE("GPL"); EXPORT_NO_SYMBOLS; -------------------- Signed-off-by: Alexander Shmelev <ashmelev@task.sun.mcst.ru> Signed-off-by: David S. Miller <davem@davemloft.net>
2007-05-31[SPARC32]: Build fix.Andrew Morton
Fix 6197fe4d720ea3e2ee94cdc7ef32d6c0151199de arch/sparc/lib/atomic32.c: In function '__cmpxchg_u32': arch/sparc/lib/atomic32.c:127: error: 'addr' undeclared (first use in this function) arch/sparc/lib/atomic32.c:127: error: (Each undeclared identifier is reported only once arch/sparc/lib/atomic32.c:127: error: for each function it appears in.) I assume this is what was intended.. Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Acked-by: William Irwin <wli@holomorphy.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2007-05-29[SPARC]: Emulate cmpxchg like pariscKyle McMartin
Signed-off-by: Kyle McMartin <kyle@parisc-linux.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2007-05-08header cleaning: don't include smp_lock.h when not usedRandy Dunlap
Remove includes of <linux/smp_lock.h> where it is not used/needed. Suggested by Al Viro. Builds cleanly on x86_64, i386, alpha, ia64, powerpc, sparc, sparc64, and arm (all 59 defconfigs). Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-03-26[SPARC32]: Fix SMP build regressionRobert Reif
commit b19cbe2a1695c09c74f83646c4b82b51123b3690 [BRIDGE]: Fix fdb RCU race breaks sparc SMP build because atomic_add_unless is not exported. This patch exports atomic_add_unless and atomic_cmpxchg. Signed-off-by: Robert Reif <reif@earthlink.net> Signed-off-by: David S. Miller <davem@davemloft.net>
2006-12-17[SPARC]: Make bitops use same spinlocks as atomics.David S. Miller
Recent workqueue changes basically make this a formal requirement. Also, move atomic32.o from lib-y to obj-y since it exports symbols to modules. Signed-off-by: David S. Miller <davem@davemloft.net>
2006-10-08[PATCH] sparc32 rwlock fixAl Viro
read_trylock() is broken on sparc32 (doesn't build and didn't work right, actually). Proposed fix: - make "writer holds lock" distinguishable from "reader tries to grab lock" - have __raw_read_trylock() try to acquire the mutex (in LSB of lock), terminating spin if we see that there's writer holding it. Then do the rest as we do in read_lock(). Thanks to Ingo for discussion... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-09-29[SPARC]: Don't zero out tail during copy_from_user_inatomic().David S. Miller
Actually, since we use the same code for all the copying types in and out of userspace, we check at runtime whether preemption is disabled. Signed-off-by: David S. Miller <davem@davemloft.net>
2006-06-30Remove obsolete #include <linux/config.h>Jörn Engel
Signed-off-by: Jörn Engel <joern@wohnheim.fh-wedel.de> Signed-off-by: Adrian Bunk <bunk@stusta.de>