Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5e359bf2 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge branch 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull timer updates from Thomas Gleixner:
 "Rather large, but nothing exiting:

   - new range check for settimeofday() to prevent that boot time
     becomes negative.
   - fix for file time rounding
   - a few simplifications of the hrtimer code
   - fix for the proc/timerlist code so the output of clock realtime
     timers is accurate
   - more y2038 work
   - tree wide conversion of clockevent drivers to the new callbacks"

* 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (88 commits)
  hrtimer: Handle failure of tick_init_highres() gracefully
  hrtimer: Unconfuse switch_hrtimer_base() a bit
  hrtimer: Simplify get_target_base() by returning current base
  hrtimer: Drop return code of hrtimer_switch_to_hres()
  time: Introduce timespec64_to_jiffies()/jiffies_to_timespec64()
  time: Introduce current_kernel_time64()
  time: Introduce struct itimerspec64
  time: Add the common weak version of update_persistent_clock()
  time: Always make sure wall_to_monotonic isn't positive
  time: Fix nanosecond file time rounding in timespec_trunc()
  timer_list: Add the base offset so remaining nsecs are accurate for non monotonic timers
  cris/time: Migrate to new 'set-state' interface
  kernel: broadcast-hrtimer: Migrate to new 'set-state' interface
  xtensa/time: Migrate to new 'set-state' interface
  unicore/time: Migrate to new 'set-state' interface
  um/time: Migrate to new 'set-state' interface
  sparc/time: Migrate to new 'set-state' interface
  sh/localtimer: Migrate to new 'set-state' interface
  score/time: Migrate to new 'set-state' interface
  s390/time: Migrate to new 'set-state' interface
  ...
parents 8d01b66b 85e1cd6e
Loading
Loading
Loading
Loading
+6 −12
Original line number Diff line number Diff line
@@ -93,7 +93,7 @@ rtc_timer_interrupt(int irq, void *dev)
	struct clock_event_device *ce = &per_cpu(cpu_ce, cpu);

	/* Don't run the hook for UNUSED or SHUTDOWN.  */
	if (likely(ce->mode == CLOCK_EVT_MODE_PERIODIC))
	if (likely(clockevent_state_periodic(ce)))
		ce->event_handler(ce);

	if (test_irq_work_pending()) {
@@ -104,13 +104,6 @@ rtc_timer_interrupt(int irq, void *dev)
	return IRQ_HANDLED;
}

static void
rtc_ce_set_mode(enum clock_event_mode mode, struct clock_event_device *ce)
{
	/* The mode member of CE is updated in generic code.
	   Since we only support periodic events, nothing to do.  */
}

static int
rtc_ce_set_next_event(unsigned long evt, struct clock_event_device *ce)
{
@@ -129,7 +122,6 @@ init_rtc_clockevent(void)
		.features = CLOCK_EVT_FEAT_PERIODIC,
		.rating = 100,
		.cpumask = cpumask_of(cpu),
		.set_mode = rtc_ce_set_mode,
		.set_next_event = rtc_ce_set_next_event,
	};

@@ -161,12 +153,12 @@ static struct clocksource qemu_cs = {
 * The QEMU alarm as a clock_event_device primitive.
 */

static void
qemu_ce_set_mode(enum clock_event_mode mode, struct clock_event_device *ce)
static int qemu_ce_shutdown(struct clock_event_device *ce)
{
	/* The mode member of CE is updated for us in generic code.
	   Just make sure that the event is disabled.  */
	qemu_set_alarm_abs(0);
	return 0;
}

static int
@@ -197,7 +189,9 @@ init_qemu_clockevent(void)
		.features = CLOCK_EVT_FEAT_ONESHOT,
		.rating = 400,
		.cpumask = cpumask_of(cpu),
		.set_mode = qemu_ce_set_mode,
		.set_state_shutdown = qemu_ce_shutdown,
		.set_state_oneshot = qemu_ce_shutdown,
		.tick_resume = qemu_ce_shutdown,
		.set_next_event = qemu_ce_set_next_event,
	};

+70 −66
Original line number Diff line number Diff line
@@ -136,44 +136,44 @@ static int bfin_gptmr0_set_next_event(unsigned long cycles,
	return 0;
}

static void bfin_gptmr0_set_mode(enum clock_event_mode mode,
				struct clock_event_device *evt)
static int bfin_gptmr0_set_periodic(struct clock_event_device *evt)
{
	switch (mode) {
	case CLOCK_EVT_MODE_PERIODIC: {
#ifndef CONFIG_BF60x
		set_gptimer_config(TIMER0_id, \
			TIMER_OUT_DIS | TIMER_IRQ_ENA | \
	set_gptimer_config(TIMER0_id,
			   TIMER_OUT_DIS | TIMER_IRQ_ENA |
			   TIMER_PERIOD_CNT | TIMER_MODE_PWM);
#else
		set_gptimer_config(TIMER0_id,  TIMER_OUT_DIS
			| TIMER_MODE_PWM_CONT | TIMER_PULSE_HI | TIMER_IRQ_PER);
	set_gptimer_config(TIMER0_id,
			   TIMER_OUT_DIS | TIMER_MODE_PWM_CONT |
			   TIMER_PULSE_HI | TIMER_IRQ_PER);
#endif

	set_gptimer_period(TIMER0_id, get_sclk() / HZ);
	set_gptimer_pwidth(TIMER0_id, get_sclk() / HZ - 1);
	enable_gptimers(TIMER0bit);
		break;
	return 0;
}
	case CLOCK_EVT_MODE_ONESHOT:

static int bfin_gptmr0_set_oneshot(struct clock_event_device *evt)
{
	disable_gptimers(TIMER0bit);
#ifndef CONFIG_BF60x
		set_gptimer_config(TIMER0_id, \
	set_gptimer_config(TIMER0_id,
			   TIMER_OUT_DIS | TIMER_IRQ_ENA | TIMER_MODE_PWM);
#else
		set_gptimer_config(TIMER0_id, TIMER_OUT_DIS | TIMER_MODE_PWM
			| TIMER_PULSE_HI | TIMER_IRQ_WID_DLY);
	set_gptimer_config(TIMER0_id,
			   TIMER_OUT_DIS | TIMER_MODE_PWM | TIMER_PULSE_HI |
			   TIMER_IRQ_WID_DLY);
#endif

	set_gptimer_period(TIMER0_id, 0);
		break;
	case CLOCK_EVT_MODE_UNUSED:
	case CLOCK_EVT_MODE_SHUTDOWN:
		disable_gptimers(TIMER0bit);
		break;
	case CLOCK_EVT_MODE_RESUME:
		break;
	return 0;
}

static int bfin_gptmr0_shutdown(struct clock_event_device *evt)
{
	disable_gptimers(TIMER0bit);
	return 0;
}

static void bfin_gptmr0_ack(void)
@@ -215,9 +215,12 @@ static struct clock_event_device clockevent_gptmr0 = {
	.rating			= 300,
	.irq			= IRQ_TIMER0,
	.shift			= 32,
	.features 	= CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
	.features		= CLOCK_EVT_FEAT_PERIODIC |
				  CLOCK_EVT_FEAT_ONESHOT,
	.set_next_event		= bfin_gptmr0_set_next_event,
	.set_mode	= bfin_gptmr0_set_mode,
	.set_state_shutdown	= bfin_gptmr0_shutdown,
	.set_state_periodic	= bfin_gptmr0_set_periodic,
	.set_state_oneshot	= bfin_gptmr0_set_oneshot,
};

static void __init bfin_gptmr0_clockevent_init(struct clock_event_device *evt)
@@ -250,12 +253,10 @@ static int bfin_coretmr_set_next_event(unsigned long cycles,
	return 0;
}

static void bfin_coretmr_set_mode(enum clock_event_mode mode,
				struct clock_event_device *evt)
static int bfin_coretmr_set_periodic(struct clock_event_device *evt)
{
	switch (mode) {
	case CLOCK_EVT_MODE_PERIODIC: {
	unsigned long tcount = ((get_cclk() / (HZ * TIME_SCALE)) - 1);

	bfin_write_TCNTL(TMPWR);
	CSYNC();
	bfin_write_TSCALE(TIME_SCALE - 1);
@@ -263,23 +264,24 @@ static void bfin_coretmr_set_mode(enum clock_event_mode mode,
	bfin_write_TCOUNT(tcount);
	CSYNC();
	bfin_write_TCNTL(TMPWR | TMREN | TAUTORLD);
		break;
	return 0;
}
	case CLOCK_EVT_MODE_ONESHOT:

static int bfin_coretmr_set_oneshot(struct clock_event_device *evt)
{
	bfin_write_TCNTL(TMPWR);
	CSYNC();
	bfin_write_TSCALE(TIME_SCALE - 1);
	bfin_write_TPERIOD(0);
	bfin_write_TCOUNT(0);
		break;
	case CLOCK_EVT_MODE_UNUSED:
	case CLOCK_EVT_MODE_SHUTDOWN:
	return 0;
}

static int bfin_coretmr_shutdown(struct clock_event_device *evt)
{
	bfin_write_TCNTL(0);
	CSYNC();
		break;
	case CLOCK_EVT_MODE_RESUME:
		break;
	}
	return 0;
}

void bfin_coretmr_init(void)
@@ -335,7 +337,9 @@ void bfin_coretmr_clockevent_init(void)
	evt->shift = 32;
	evt->features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT;
	evt->set_next_event = bfin_coretmr_set_next_event;
	evt->set_mode = bfin_coretmr_set_mode;
	evt->set_state_shutdown = bfin_coretmr_shutdown;
	evt->set_state_periodic = bfin_coretmr_set_periodic;
	evt->set_state_oneshot = bfin_coretmr_set_oneshot;

	clock_tick = get_cclk() / TIME_SCALE;
	evt->mult = div_sc(clock_tick, NSEC_PER_SEC, evt->shift);
+27 −25
Original line number Diff line number Diff line
@@ -126,34 +126,36 @@ static int next_event(unsigned long delta,
	return 0;
}

static void set_clock_mode(enum clock_event_mode mode,
			   struct clock_event_device *evt)
static int set_periodic(struct clock_event_device *evt)
{
	switch (mode) {
	case CLOCK_EVT_MODE_PERIODIC:
	timer64_enable();
	timer64_mode = TIMER64_MODE_PERIODIC;
	timer64_config(TIMER64_RATE / HZ);
		break;
	case CLOCK_EVT_MODE_ONESHOT:
	return 0;
}

static int set_oneshot(struct clock_event_device *evt)
{
	timer64_enable();
	timer64_mode = TIMER64_MODE_ONE_SHOT;
		break;
	case CLOCK_EVT_MODE_UNUSED:
	case CLOCK_EVT_MODE_SHUTDOWN:
	return 0;
}

static int shutdown(struct clock_event_device *evt)
{
	timer64_mode = TIMER64_MODE_DISABLED;
	timer64_disable();
		break;
	case CLOCK_EVT_MODE_RESUME:
		break;
	}
	return 0;
}

static struct clock_event_device t64_clockevent_device = {
	.name			= "TIMER64_EVT32_TIMER",
	.features	= CLOCK_EVT_FEAT_ONESHOT | CLOCK_EVT_FEAT_PERIODIC,
	.features		= CLOCK_EVT_FEAT_ONESHOT |
				  CLOCK_EVT_FEAT_PERIODIC,
	.rating			= 200,
	.set_mode	= set_clock_mode,
	.set_state_shutdown	= shutdown,
	.set_state_periodic	= set_periodic,
	.set_state_oneshot	= set_oneshot,
	.set_next_event		= next_event,
};

+5 −3
Original line number Diff line number Diff line
@@ -172,8 +172,7 @@ void handle_watchdog_bite(struct pt_regs *regs)
extern void cris_profile_sample(struct pt_regs *regs);
static void __iomem *timer_base;

static void crisv32_clkevt_mode(enum clock_event_mode mode,
				struct clock_event_device *dev)
static int crisv32_clkevt_switch_state(struct clock_event_device *dev)
{
	reg_timer_rw_tmr0_ctrl ctrl = {
		.op = regk_timer_hold,
@@ -181,6 +180,7 @@ static void crisv32_clkevt_mode(enum clock_event_mode mode,
	};

	REG_WR(timer, timer_base, rw_tmr0_ctrl, ctrl);
	return 0;
}

static int crisv32_clkevt_next_event(unsigned long evt,
@@ -231,7 +231,9 @@ static struct clock_event_device crisv32_clockevent = {
	.name = "crisv32-timer",
	.rating = 300,
	.features = CLOCK_EVT_FEAT_ONESHOT,
	.set_mode = crisv32_clkevt_mode,
	.set_state_oneshot = crisv32_clkevt_switch_state,
	.set_state_shutdown = crisv32_clkevt_switch_state,
	.tick_resume = crisv32_clkevt_switch_state,
	.set_next_event = crisv32_clkevt_next_event,
};

+19 −27
Original line number Diff line number Diff line
@@ -122,37 +122,29 @@ static int xilinx_timer_set_next_event(unsigned long delta,
	return 0;
}

static void xilinx_timer_set_mode(enum clock_event_mode mode,
				struct clock_event_device *evt)
static int xilinx_timer_shutdown(struct clock_event_device *evt)
{
	switch (mode) {
	case CLOCK_EVT_MODE_PERIODIC:
		pr_info("%s: periodic\n", __func__);
		xilinx_timer0_start_periodic(freq_div_hz);
		break;
	case CLOCK_EVT_MODE_ONESHOT:
		pr_info("%s: oneshot\n", __func__);
		break;
	case CLOCK_EVT_MODE_UNUSED:
		pr_info("%s: unused\n", __func__);
		break;
	case CLOCK_EVT_MODE_SHUTDOWN:
		pr_info("%s: shutdown\n", __func__);
	pr_info("%s\n", __func__);
	xilinx_timer0_stop();
		break;
	case CLOCK_EVT_MODE_RESUME:
		pr_info("%s: resume\n", __func__);
		break;
	return 0;
}

static int xilinx_timer_set_periodic(struct clock_event_device *evt)
{
	pr_info("%s\n", __func__);
	xilinx_timer0_start_periodic(freq_div_hz);
	return 0;
}

static struct clock_event_device clockevent_xilinx_timer = {
	.name			= "xilinx_clockevent",
	.features       = CLOCK_EVT_FEAT_ONESHOT | CLOCK_EVT_FEAT_PERIODIC,
	.features		= CLOCK_EVT_FEAT_ONESHOT |
				  CLOCK_EVT_FEAT_PERIODIC,
	.shift			= 8,
	.rating			= 300,
	.set_next_event		= xilinx_timer_set_next_event,
	.set_mode	= xilinx_timer_set_mode,
	.set_state_shutdown	= xilinx_timer_shutdown,
	.set_state_periodic	= xilinx_timer_set_periodic,
};

static inline void timer_ack(void)
Loading