Skip to content

Commit b435092

Browse files
committed
tick: Fix oneshot broadcast setup really
Sven Joachim reported, that suspend/resume on rc3 trips over a NULL pointer dereference. Linus spotted the clockevent handler being NULL. commit fa4da36(clockevents: tTack broadcast device mode change in tick_broadcast_switch_to_oneshot()) tried to fix a problem with the broadcast device setup, which was introduced in commit 77b0d60( clockevents: Leave the broadcast device in shutdown mode when not needed). The initial commit avoided to set up the broadcast device when no broadcast request bits were set, but that left the broadcast device disfunctional. In consequence deep idle states which need the broadcast device were not woken up. commit fa4da36 tried to fix that by initializing the state of the broadcast facility, but that missed the fact, that nothing initializes the event handler and some other state of the underlying clock event device. The fix is to revert both commits and make only the mode setting of the clock event device conditional on the state of active broadcast users. That initializes everything except the low level device mode, but this happens when the broadcast functionality is invoked by deep idle. Reported-and-tested-by: Sven Joachim <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: Rafael J. Wysocki <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Suresh Siddha <[email protected]> Link: http://lkml.kernel.org/r/alpine.LFD.2.02.1204181205540.2542@ionos
1 parent 592fe89 commit b435092

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

kernel/time/tick-broadcast.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,6 @@ void tick_broadcast_setup_oneshot(struct clock_event_device *bc)
531531
int was_periodic = bc->mode == CLOCK_EVT_MODE_PERIODIC;
532532

533533
bc->event_handler = tick_handle_oneshot_broadcast;
534-
clockevents_set_mode(bc, CLOCK_EVT_MODE_ONESHOT);
535534

536535
/* Take the do_timer update */
537536
tick_do_timer_cpu = cpu;
@@ -549,6 +548,7 @@ void tick_broadcast_setup_oneshot(struct clock_event_device *bc)
549548
to_cpumask(tmpmask));
550549

551550
if (was_periodic && !cpumask_empty(to_cpumask(tmpmask))) {
551+
clockevents_set_mode(bc, CLOCK_EVT_MODE_ONESHOT);
552552
tick_broadcast_init_next_event(to_cpumask(tmpmask),
553553
tick_next_period);
554554
tick_broadcast_set_event(tick_next_period, 1);
@@ -577,15 +577,10 @@ void tick_broadcast_switch_to_oneshot(void)
577577
raw_spin_lock_irqsave(&tick_broadcast_lock, flags);
578578

579579
tick_broadcast_device.mode = TICKDEV_MODE_ONESHOT;
580-
581-
if (cpumask_empty(tick_get_broadcast_mask()))
582-
goto end;
583-
584580
bc = tick_broadcast_device.evtdev;
585581
if (bc)
586582
tick_broadcast_setup_oneshot(bc);
587583

588-
end:
589584
raw_spin_unlock_irqrestore(&tick_broadcast_lock, flags);
590585
}
591586

0 commit comments

Comments
 (0)