u-boot/arch/mips/include/asm
Chris Packham 73a4152b25 mips: Use unsigned int when reading c0 registers
In commit a18a477 (MIPS: use common code from lib/time.c) MIPS platforms
started using common the common timer functions which are based around
the fact that many platforms have a 32-bit free running counter register
that can be used see commit 8dfafdd (Introduce common timer functions).

Even MIPS64 has such a 32-bit register (some have an additional 64-bit free
running counter, but that's something for another time).

The problem is that in __read_32bit_c0_register() we read the value from
this register into an _signed_ int and as it's returned up the call
chain to timer_read_counter() it gets assigned to an unsigned long. On a
32-bit system there is no problem. On a 64-bit system odd things happen,
sign extension seems to kick in and all of a sudden if the counter
register happens to have the MSb (i.e. the sign bit) set the negative
int gets sign extended into a very large unsigned long value. This in
turn throws out things from get_ticks() up.

Update __read_32bit_c0_register() and __read_32bit_c0_ctrl_register() to
use "unsigned int res;" instead of "int res;". There seems to be little
reason to treat these register values as signed. They are either
counters (which by definition are unsigned) or are made up of various
bit fields to be interpreted as per the CPU datasheet.

Reported-by: Sachin Surendran <sachin.surendran@alliedtelesis.co.nz>
Signed-off-by: Chris Packham <judge.packham@gmail.com>
2015-08-21 15:22:41 +02:00
..
addrspace.h MIPS: add support for 64 bit addressing 2012-10-16 15:02:08 +02:00
asm.h MIPS: don't use camel-case style 2012-10-16 15:02:08 +02:00
au1x00.h Add GPL-2.0+ SPDX-License-Identifier to source files 2013-07-24 09:44:38 -04:00
bitops.h include: delete include/linux/config.h 2013-11-08 15:25:13 -05:00
byteorder.h Move architecture-specific includes to arch/$ARCH/include/asm 2010-04-13 09:13:12 +02:00
cache.h Add GPL-2.0+ SPDX-License-Identifier to source files 2013-07-24 09:44:38 -04:00
cachectl.h Move architecture-specific includes to arch/$ARCH/include/asm 2010-04-13 09:13:12 +02:00
cacheops.h MIPS: fix missing semicolon in cacheops.h 2015-07-02 11:29:33 +02:00
config.h MIPS: add support for pre-relocation malloc 2015-01-21 14:07:23 +01:00
errno.h MIPS: asm/errno.h: switch to asm-generic/errno.h 2013-06-08 23:10:10 +02:00
global_data.h Add GPL-2.0+ SPDX-License-Identifier to source files 2013-07-24 09:44:38 -04:00
io.h MIPS: change 'extern inline' to 'static inline' 2015-07-02 11:29:33 +02:00
isadep.h Move architecture-specific includes to arch/$ARCH/include/asm 2010-04-13 09:13:12 +02:00
jz4740.h MIPS: Ingenic XBurst Jz4740 processor support 2011-10-10 22:06:12 +09:00
malta.h malta: IDE support 2015-01-29 13:11:02 +01:00
mipsregs.h mips: Use unsigned int when reading c0 registers 2015-08-21 15:22:41 +02:00
posix_types.h MIPS: add support for 64 bit addressing 2012-10-16 15:02:08 +02:00
processor.h include: delete include/linux/config.h 2013-11-08 15:25:13 -05:00
ptrace.h Move architecture-specific includes to arch/$ARCH/include/asm 2010-04-13 09:13:12 +02:00
reboot.h Move architecture-specific includes to arch/$ARCH/include/asm 2010-04-13 09:13:12 +02:00
reg.h Move architecture-specific includes to arch/$ARCH/include/asm 2010-04-13 09:13:12 +02:00
regdef.h Move architecture-specific includes to arch/$ARCH/include/asm 2010-04-13 09:13:12 +02:00
sections.h Add GPL-2.0+ SPDX-License-Identifier to source files 2013-07-24 09:44:38 -04:00
sgidefs.h Move architecture-specific includes to arch/$ARCH/include/asm 2010-04-13 09:13:12 +02:00
string.h Move architecture-specific includes to arch/$ARCH/include/asm 2010-04-13 09:13:12 +02:00
system.h MIPS: change 'extern inline' to 'static inline' 2015-07-02 11:29:33 +02:00
types.h MIPS: fix types u64 and __u64 to unsigned long long 2014-03-04 23:18:00 +01:00
u-boot-mips.h MIPS: drop incaip board 2014-04-20 13:16:43 +02:00
u-boot.h bd_info: remove bi_barudrate member from struct bd_info 2014-05-12 15:19:45 -04:00
unaligned.h Replace <compiler.h> with <linux/compiler.h> 2014-12-08 09:35:46 -05:00