Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 179160
b: refs/heads/master
c: 0e8a1d8
h: refs/heads/master
v: v3
  • Loading branch information
David Daney authored and Ralf Baechle committed Jan 12, 2010
1 parent d67ac5e commit 2817b1a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9b54dc5869c3989077e456c57e51810f0a1bdbcb
refs/heads/master: 0e8a1d8262f41d6e8c1d736a408882bbb7a5c0a6
31 changes: 28 additions & 3 deletions trunk/arch/mips/cavium-octeon/csrc-octeon.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,34 @@ static struct clocksource clocksource_mips = {

unsigned long long notrace sched_clock(void)
{
return clocksource_cyc2ns(read_c0_cvmcount(),
clocksource_mips.mult,
clocksource_mips.shift);
/* 64-bit arithmatic can overflow, so use 128-bit. */
#if (__GNUC__ < 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ <= 3))
u64 t1, t2, t3;
unsigned long long rv;
u64 mult = clocksource_mips.mult;
u64 shift = clocksource_mips.shift;
u64 cnt = read_c0_cvmcount();

asm (
"dmultu\t%[cnt],%[mult]\n\t"
"nor\t%[t1],$0,%[shift]\n\t"
"mfhi\t%[t2]\n\t"
"mflo\t%[t3]\n\t"
"dsll\t%[t2],%[t2],1\n\t"
"dsrlv\t%[rv],%[t3],%[shift]\n\t"
"dsllv\t%[t1],%[t2],%[t1]\n\t"
"or\t%[rv],%[t1],%[rv]\n\t"
: [rv] "=&r" (rv), [t1] "=&r" (t1), [t2] "=&r" (t2), [t3] "=&r" (t3)
: [cnt] "r" (cnt), [mult] "r" (mult), [shift] "r" (shift)
: "hi", "lo");
return rv;
#else
/* GCC > 4.3 do it the easy way. */
unsigned int __attribute__((mode(TI))) t;
t = read_c0_cvmcount();
t = t * clocksource_mips.mult;
return (unsigned long long)(t >> clocksource_mips.shift);
#endif
}

void __init plat_time_init(void)
Expand Down

0 comments on commit 2817b1a

Please sign in to comment.