linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jindong Yue <jindong.yue@nxp.com>
To: fweisbec@gmail.com, tglx@linutronix.de, mingo@kernel.org
Cc: linux-kernel@vger.kernel.org, jindong.yue@nxp.com
Subject: [PATCH v3] tick/broadcast: Allow later registered device enter oneshot mode
Date: Wed, 31 Mar 2021 16:33:18 +0800	[thread overview]
Message-ID: <20210331083318.21794-1-jindong.yue@nxp.com> (raw)

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


             reply	other threads:[~2021-03-31  8:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-31  8:33 Jindong Yue [this message]
2021-04-16 19:07 ` [tip: timers/core] tick/broadcast: Allow late registered device to enter oneshot mode tip-bot2 for Jindong Yue

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210331083318.21794-1-jindong.yue@nxp.com \
    --to=jindong.yue@nxp.com \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).