Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 360187
b: refs/heads/master
c: 1e26662
h: refs/heads/master
i:
  360185: 389dbd1
  360183: b6f7148
v: v3
  • Loading branch information
Vineet Gupta committed Feb 15, 2013
1 parent 9e9bc63 commit 8440e25
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 37 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: d626f547dd0457ab36f6151673fcc78fc3c63eaa
refs/heads/master: 1e266629933bb3e40ac7db128f3b661f5bab56c1
38 changes: 2 additions & 36 deletions trunk/arch/arc/kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ static cycle_t arc_counter_read(struct clocksource *cs)
__asm__ __volatile(
" .extCoreRegister tsch, 58, r, cannot_shortcut \n"
" rtsc %0, 0 \n"
" mov %1, tsch \n" /* TSCH is extn core reg 58 */
" mov %1, 0 \n"
: "=r" (stamp.low), "=r" (stamp.high));

arch_local_irq_restore(flags);
Expand All @@ -88,7 +88,7 @@ static struct clocksource arc_counter = {
.name = "ARC RTSC",
.rating = 300,
.read = arc_counter_read,
.mask = CLOCKSOURCE_MASK(64),
.mask = CLOCKSOURCE_MASK(32),
.flags = CLOCK_SOURCE_IS_CONTINUOUS,
};

Expand Down Expand Up @@ -263,37 +263,3 @@ void __init time_init(void)
if (machine_desc->init_time)
machine_desc->init_time();
}

#ifdef CONFIG_ARC_HAS_RTSC
/*
* sched_clock math assist
* ns = cycles * (ns_per_sec / cpu_freq_hz)
* ns = cycles * (10^6 / cpu_freq_khz)
* ns = cycles * (10^6 * 2^SF / cpu_freq_khz) / 2^SF
* ns = cycles * cyc2ns_scale >> SF
*/
#define CYC2NS_SF 10 /* 2^10, carefully chosen */
#define CYC2NS_SCALE ((1000000 << CYC2NS_SF) / (arc_get_core_freq() / 1000))

static unsigned long long cycles2ns(unsigned long long cyc)
{
return (cyc * CYC2NS_SCALE ) >> CYC2NS_SF;
}

/*
* Scheduler clock - a monotonically increasing clock in nanosec units.
* It's return value must NOT wrap around.
*
* - Since 32bit TIMER1 will overflow almost immediately (53sec @ 80MHz), it
* can't be used directly.
* - Using getrawmonotonic (TIMER1 based, but with state for last + current
* snapshots), is no-good either because of seqlock deadlock possibilities
* - So only with native 64bit timer we do this, otherwise fallback to generic
* jiffies based version - which despite not being fine grained gaurantees
* the monotonically increasing semantics.
*/
unsigned long long sched_clock(void)
{
return cycles2ns(arc_counter_read(NULL));
}
#endif

0 comments on commit 8440e25

Please sign in to comment.