All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] tick/broadcast: Allow later registered device enter oneshot mode
@ 2021-03-31  8:33 Jindong Yue
  2021-04-16 19:07 ` [tip: timers/core] tick/broadcast: Allow late registered device to " tip-bot2 for Jindong Yue
  0 siblings, 1 reply; 2+ messages in thread
From: Jindong Yue @ 2021-03-31  8:33 UTC (permalink / raw)
  To: fweisbec, tglx, mingo; +Cc: linux-kernel, jindong.yue

Broadcast device is switched to oneshot mode in
tick_switch_to_oneshot() -> tick_broadcast_switch_to_oneshot().

If build broadcast clock event device driver as module, and
install it after system enters oneshot mode, then it will
stay in periodic mode forever.

This patch allows such broadcast device switch to oneshot
mode when register.

Signed-off-by: Jindong Yue <jindong.yue@nxp.com>
---

v3 changes: 
- Remove useless declaration: tick_handle_oneshot_broadcast()
- Refine some comments

v2 changes:
- Remove below condition check before switch new installed
  broadcast device to oneshot mode:
  dev->event_handler != tick_handle_oneshot_broadcast
- Put tick_clock_notify() after check system not runs in
  oneshot mode

---
 kernel/time/tick-broadcast.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c
index 36d7464c8962..f4bc384d8f1b 100644
--- a/kernel/time/tick-broadcast.c
+++ b/kernel/time/tick-broadcast.c
@@ -107,6 +107,19 @@ void tick_install_broadcast_device(struct clock_event_device *dev)
 	tick_broadcast_device.evtdev = dev;
 	if (!cpumask_empty(tick_broadcast_mask))
 		tick_broadcast_start_periodic(dev);
+
+	if (!(dev->features & CLOCK_EVT_FEAT_ONESHOT))
+		return;
+
+	/*
+	 * If the system already runs in oneshot mode, switch the newly
+	 * registered broadcast device to oneshot mode explicitly.
+	 */
+	if (tick_broadcast_oneshot_active()) {
+		tick_broadcast_switch_to_oneshot();
+		return;
+	}
+
 	/*
 	 * Inform all cpus about this. We might be in a situation
 	 * where we did not switch to oneshot mode because the per cpu
@@ -115,8 +128,7 @@ void tick_install_broadcast_device(struct clock_event_device *dev)
 	 * notification the systems stays stuck in periodic mode
 	 * forever.
 	 */
-	if (dev->features & CLOCK_EVT_FEAT_ONESHOT)
-		tick_clock_notify();
+	tick_clock_notify();
 }
 
 /*
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [tip: timers/core] tick/broadcast: Allow late registered device to enter oneshot mode
  2021-03-31  8:33 [PATCH v3] tick/broadcast: Allow later registered device enter oneshot mode Jindong Yue
@ 2021-04-16 19:07 ` tip-bot2 for Jindong Yue
  0 siblings, 0 replies; 2+ messages in thread
From: tip-bot2 for Jindong Yue @ 2021-04-16 19:07 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: Jindong Yue, Thomas Gleixner, x86, linux-kernel

The following commit has been merged into the timers/core branch of tip:

Commit-ID:     9c336c9935cff267470bb3aaa85c66fac194b650
Gitweb:        https://git.kernel.org/tip/9c336c9935cff267470bb3aaa85c66fac194b650
Author:        Jindong Yue <jindong.yue@nxp.com>
AuthorDate:    Wed, 31 Mar 2021 16:33:18 +08:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Fri, 16 Apr 2021 21:03:50 +02:00

tick/broadcast: Allow late registered device to enter oneshot mode

The broadcast device is switched to oneshot mode when the system switches
to oneshot mode. If a broadcast clock event device is registered after the
system switched to oneshot mode, it will stay in periodic mode forever.

Ensure that a late registered device which is selected as broadcast device
is initialized in oneshot mode when the system already uses oneshot mode.

[ tglx: Massage changelog ]

Signed-off-by: Jindong Yue <jindong.yue@nxp.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20210331083318.21794-1-jindong.yue@nxp.com

---
 kernel/time/tick-broadcast.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c
index 6ec7855..a440552 100644
--- a/kernel/time/tick-broadcast.c
+++ b/kernel/time/tick-broadcast.c
@@ -107,6 +107,19 @@ void tick_install_broadcast_device(struct clock_event_device *dev)
 	tick_broadcast_device.evtdev = dev;
 	if (!cpumask_empty(tick_broadcast_mask))
 		tick_broadcast_start_periodic(dev);
+
+	if (!(dev->features & CLOCK_EVT_FEAT_ONESHOT))
+		return;
+
+	/*
+	 * If the system already runs in oneshot mode, switch the newly
+	 * registered broadcast device to oneshot mode explicitly.
+	 */
+	if (tick_broadcast_oneshot_active()) {
+		tick_broadcast_switch_to_oneshot();
+		return;
+	}
+
 	/*
 	 * Inform all cpus about this. We might be in a situation
 	 * where we did not switch to oneshot mode because the per cpu
@@ -115,8 +128,7 @@ void tick_install_broadcast_device(struct clock_event_device *dev)
 	 * notification the systems stays stuck in periodic mode
 	 * forever.
 	 */
-	if (dev->features & CLOCK_EVT_FEAT_ONESHOT)
-		tick_clock_notify();
+	tick_clock_notify();
 }
 
 /*

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-04-16 19:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-31  8:33 [PATCH v3] tick/broadcast: Allow later registered device enter oneshot mode Jindong Yue
2021-04-16 19:07 ` [tip: timers/core] tick/broadcast: Allow late registered device to " tip-bot2 for Jindong Yue

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.