Skip to content

Commit

Permalink
clocksource: jz4780-tcu: Provide sched_clock() implementation
Browse files Browse the repository at this point in the history
Use sched_clock_register() to register an implementation of sched_clock()
using the OST, the same as the clocksource. Without this sched_clock() is
implemented using jiffies. This implementation provides much higher
resolution, which benefits several things such as CPU time accounting,
the ftrace local clock and printk timing information.

Signed-off-by: Alex Smith <alex.smith@imgtec.com>
  • Loading branch information
Alex Smith authored and aejsmith committed Jul 20, 2015
1 parent 6b892c2 commit c47eed2
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions drivers/clocksource/jz4780-tcu.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include <linux/clocksource.h>
#include <linux/err.h>
#include <linux/sched_clock.h>

#include "jz47xx-tcu.h"

Expand Down Expand Up @@ -51,6 +52,11 @@ static cycle_t jz4780_tcu_clocksource_read(struct clocksource *cs)
return jz47xx_tcu_read_channel_count(jz4780_tcu_clocksource.channel);
}

static u64 notrace jz4780_tcu_sched_read(void)
{
return jz47xx_tcu_read_channel_count(jz4780_tcu_clocksource.channel);
}

static void __init jz4780_tcu_init(struct device_node *np)
{
struct jz47xx_tcu *tcu;
Expand All @@ -72,6 +78,7 @@ static void __init jz4780_tcu_init(struct device_node *np)

err = clocksource_register_hz(&jz4780_tcu_clocksource.cs, rate);
BUG_ON(err);
sched_clock_register(jz4780_tcu_sched_read, 64, rate);

/* For local clock events */
err = jz47xx_tcu_setup_cevt(tcu, 5);
Expand Down

0 comments on commit c47eed2

Please sign in to comment.