From: Enric Balletbo i Serra <eballetb@redhat.com>
To: Daniel Lezcano <daniel.lezcano@kernel.org>,
Thomas Gleixner <tglx@kernel.org>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Alexandre Torgue <alexandre.torgue@foss.st.com>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Clark Williams <clrkwllms@kernel.org>,
Steven Rostedt <rostedt@goodmis.org>
Cc: linux-kernel@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org,
linux-rt-devel@lists.linux.dev,
Ghennadi Procopciuc <ghennadi.procopciuc@oss.nxp.com>,
NXP S32 Linux Team <s32@nxp.com>,
stable@vger.kernel.org,
Enric Balletbo i Serra <eballetb@redhat.com>
Subject: [PATCH v2 3/3] clocksource/drivers/nxp-stm: Increase min_delta to 20us for PREEMPT_RT
Date: Mon, 02 Nov 2026 22:16:22 +0100 [thread overview]
Message-ID: <20261102-nxp-stm-fixes-v2-3-8ca2706f30ef@redhat.com> (raw)
In-Reply-To: <20261102-nxp-stm-fixes-v2-0-8ca2706f30ef@redhat.com>
Under heavy bus contention on PREEMPT_RT kernels, a 2us min_delta is too
tight and causes ~32-second timer soft lockups.
Increase min_delta from 2us to 20us (~2,660 cycles at 133 MHz). This
provides sufficient margin under severe bus contention to ensure the
channel-enable write completes well before the counter reaches the match
value, resolving the 32-second soft lockup.
Fixes: cec32ac75827 ("clocksource/drivers/nxp-timer: Add the System Timer Module for the s32gx platforms")
Signed-off-by: Enric Balletbo i Serra <eballetb@redhat.com>
---
drivers/clocksource/timer-nxp-stm.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/drivers/clocksource/timer-nxp-stm.c b/drivers/clocksource/timer-nxp-stm.c
index ed7662a4e2bc..a1a0e23d3342 100644
--- a/drivers/clocksource/timer-nxp-stm.c
+++ b/drivers/clocksource/timer-nxp-stm.c
@@ -335,14 +335,18 @@ static int nxp_stm_clockevent_starting_cpu(unsigned int cpu)
/*
* The timings measurement show reading the counter register
* and writing to the comparator register takes as a maximum
- * value 1100 ns at 133MHz rate frequency. The timer must be
- * set above this value and to be secure we set the minimum
- * value equal to 2000ns, so 2us.
+ * value 1100 ns at 133MHz rate frequency. However, under heavy
+ * bus contention on PREEMPT_RT, 2us is too tight and can allow
+ * the counter to pass the match value before the channel-enable
+ * write takes effect, leading to 32s wraparounds.
*
- * minimum ticks = (rate / MICRO) * 2
+ * Increase to 20us to guarantee the comparator channel is fully
+ * enabled before the match value is reached.
+ *
+ * minimum ticks = (rate / MICRO) * 20
*/
clockevents_config_and_register(&stm_timer->ced, stm_timer->rate,
- (stm_timer->rate / MICRO) * 2, 0x7FFFFFFFU);
+ (stm_timer->rate / MICRO) * 20, 0x7FFFFFFFU);
return 0;
}
--
2.56.0
next prev parent reply other threads:[~2026-11-02 21:16 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-02 21:16 [PATCH v2 0/3] Fix NXP STM clockevent bugs causing lockups Enric Balletbo i Serra
2026-11-02 21:16 ` [PATCH v2 1/3] clocksource/drivers/nxp-stm: Fix max_delta overflow on 64-bit platforms Enric Balletbo i Serra
2026-11-02 21:16 ` [PATCH v2 2/3] clocksource/drivers/nxp-stm: Fix missed comparator match in set_next_event Enric Balletbo i Serra
2026-11-02 21:16 ` Enric Balletbo i Serra [this message]
2026-11-02 21:25 ` [PATCH v2 3/3] clocksource/drivers/nxp-stm: Increase min_delta to 20us for PREEMPT_RT sashiko-bot
2026-11-02 21:47 ` Enric Balletbo i Serra
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=20261102-nxp-stm-fixes-v2-3-8ca2706f30ef@redhat.com \
--to=eballetb@redhat.com \
--cc=alexandre.torgue@foss.st.com \
--cc=bigeasy@linutronix.de \
--cc=clrkwllms@kernel.org \
--cc=daniel.lezcano@kernel.org \
--cc=ghennadi.procopciuc@oss.nxp.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-devel@lists.linux.dev \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=rostedt@goodmis.org \
--cc=s32@nxp.com \
--cc=stable@vger.kernel.org \
--cc=tglx@kernel.org \
/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®