]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blobdiff - kernel/time/tick-common.c
clockevents: Provide functions to set and get the state
[mirror_ubuntu-jammy-kernel.git] / kernel / time / tick-common.c
index 3ae6afa1eb98e71cc82272cd0a79a25101eff429..311e2e133517de641f9f5d7834e031cb061f80f1 100644 (file)
@@ -102,7 +102,17 @@ void tick_handle_periodic(struct clock_event_device *dev)
 
        tick_periodic(cpu);
 
-       if (dev->state != CLOCK_EVT_STATE_ONESHOT)
+#if defined(CONFIG_HIGH_RES_TIMERS) || defined(CONFIG_NO_HZ_COMMON)
+       /*
+        * The cpu might have transitioned to HIGHRES or NOHZ mode via
+        * update_process_times() -> run_local_timers() ->
+        * hrtimer_run_queues().
+        */
+       if (dev->event_handler != tick_handle_periodic)
+               return;
+#endif
+
+       if (!clockevent_state_oneshot(dev))
                return;
        for (;;) {
                /*
@@ -140,7 +150,7 @@ void tick_setup_periodic(struct clock_event_device *dev, int broadcast)
 
        if ((dev->features & CLOCK_EVT_FEAT_PERIODIC) &&
            !tick_broadcast_oneshot_active()) {
-               clockevents_set_state(dev, CLOCK_EVT_STATE_PERIODIC);
+               clockevents_switch_state(dev, CLOCK_EVT_STATE_PERIODIC);
        } else {
                unsigned long seq;
                ktime_t next;
@@ -150,7 +160,7 @@ void tick_setup_periodic(struct clock_event_device *dev, int broadcast)
                        next = tick_next_period;
                } while (read_seqretry(&jiffies_lock, seq));
 
-               clockevents_set_state(dev, CLOCK_EVT_STATE_ONESHOT);
+               clockevents_switch_state(dev, CLOCK_EVT_STATE_ONESHOT);
 
                for (;;) {
                        if (!clockevents_program_event(dev, next, false))