mirror of https://lore.kernel.org/lkml/
 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] tick/broadcast: Allow later probed device enter oneshot mode
Date: Mon, 29 Mar 2021 13:25:55 +0800	[thread overview]
Message-ID: <20210329052555.24487-1-jindong.yue@nxp.com> (raw)

Broadcast device is switched to oneshot mode in
hrtimer_switch_to_hres() -> tick_broadcast_switch_to_oneshot().
After high resolution timers are enabled, new installed
broadcast device has no chance to switch mode.

This issue happens in below situation:
In order to make broadcast clock source driver build as module,
use module_platform_driver() to replace TIMER_OF_DECLARE().
This will make clock source driver probed later than
high resolution timers enabled.

Signed-off-by: Jindong Yue <jindong.yue@nxp.com>
---
 kernel/time/tick-broadcast.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c
index e51778c312f1..f38a7544cb5b 100644
--- a/kernel/time/tick-broadcast.c
+++ b/kernel/time/tick-broadcast.c
@@ -47,6 +47,7 @@ static inline void tick_resume_broadcast_oneshot(struct clock_event_device *bc)
 static inline void tick_broadcast_oneshot_offline(unsigned int cpu) { }
 # endif
 #endif
+static void tick_handle_oneshot_broadcast(struct clock_event_device *dev);
 
 /*
  * Debugging: see timer_list.c
@@ -115,8 +116,20 @@ 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)
+	if (dev->features & CLOCK_EVT_FEAT_ONESHOT) {
 		tick_clock_notify();
+
+		/*
+		 * If new broadcast device is installed after high resolution
+		 * timers enabled, it can not switch to oneshot mode anymore.
+		 * Here give it a chance.
+		 */
+		if (tick_broadcast_oneshot_active() &&
+		    dev->event_handler != tick_handle_oneshot_broadcast) {
+			tick_broadcast_switch_to_oneshot();
+		}
+	}
+
 }
 
 /*
-- 
2.17.1


             reply	other threads:[~2021-03-29  5:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-29  5:25 Jindong Yue [this message]
2021-03-29 21:17 ` Thomas Gleixner
2021-03-30 12:27   ` [EXT] " J.d. 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=20210329052555.24487-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

all inboxes | Powered by JetHome®