From: Ghennadi Procopciuc <ghennadi.procopciuc@oss.nxp.com>
To: Juhee Kang <juhee.kang@redhat.com>,
Daniel Lezcano <daniel.lezcano@kernel.org>,
Thomas Gleixner <tglx@kernel.org>
Cc: linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
NXP S32 Linux Team <s32@nxp.com>,
Dustin Black <dblack@redhat.com>,
stable@vger.kernel.org
Subject: Re: [PATCH v2] clocksource/drivers/nxp-stm: Register sched_clock once
Date: Thu, 15 Oct 2026 14:40:12 +0300 [thread overview]
Message-ID: <a626dba9-6aa2-4cf9-883d-8c6f94770d6c@oss.nxp.com> (raw)
In-Reply-To: <20261015113738.435986-1-juhee.kang@redhat.com>
On 10/15/2026 2:37 PM, Juhee Kang wrote:
> [You don't often get email from juhee.kang@redhat.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> Each probe updates stm_sched_clock before calling sched_clock_register()
> again. The call then subtracts the counter value saved during the
> previous registration from the new STM's counter. If the new counter is
> smaller, the subtraction wraps and the timestamp jumps forward.
> (e.g. from 0.4 to 32.9 seconds below)
>
> [ 0.403653] sched_clock: 32 bits at 132MHz, resolution 7ns, wraps every 16243448316ns
> [ 0.404056] clocksource: timer@40120000: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 14456668980 ns
> [ 32.890509] sched_clock: 32 bits at 132MHz, resolution 7ns, wraps every 16243448316ns
> [ 32.890882] clocksource: timer@40124000: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 14456668980 ns
>
> To fix this, register sched_clock once at the end of the first
> successful probe. Clocksource and per-CPU clockevent registration
> remain unchanged.
>
> Fixes: cec32ac75827 ("clocksource/drivers/nxp-timer: Add the System Timer Module for the s32gx platforms")
> Reported-by: Dustin Black <dblack@redhat.com>
> Signed-off-by: Juhee Kang <juhee.kang@redhat.com>
> Reviewed-by: Ghennadi Procopciuc <ghennadi.procopciuc@oss.nxp.com>
> ---
> Changes in v2:
> - add the comment
> ---
> drivers/clocksource/timer-nxp-stm.c | 13 +++++++++----
> 1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/clocksource/timer-nxp-stm.c b/drivers/clocksource/timer-nxp-stm.c
> index 6fe098a4a33f..23b2d44e4b78 100644
> --- a/drivers/clocksource/timer-nxp-stm.c
> +++ b/drivers/clocksource/timer-nxp-stm.c
> @@ -211,10 +211,6 @@ static int nxp_stm_clocksource_init(struct device *dev, struct stm_timer *stm_ti
> if (ret)
> return ret;
>
> - stm_sched_clock = stm_timer;
> -
> - sched_clock_register(nxp_stm_read_sched_clock, 32, stm_timer->rate);
> -
> dev_dbg(dev, "Registered clocksource %s\n", name);
>
> return 0;
> @@ -473,6 +469,15 @@ static int nxp_stm_timer_probe(struct platform_device *pdev)
> return ret;
> }
>
> + /*
> + * STM counters run independently at the same rate. Use the first
> + * probed instance for sched_clock to avoid timestamp jumps.
> + */
> + if (!stm_sched_clock) {
> + stm_sched_clock = stm_timer;
> + sched_clock_register(nxp_stm_read_sched_clock, 32, stm_timer->rate);
> + }
> +
> return 0;
> }
>
> --
> 2.55.0
Thank you for addressing this issue!
Tested-by: Ghennadi Procopciuc <ghennadi.procopciuc@oss.nxp.com>
--
Regards,
Ghennadi
prev parent reply other threads:[~2026-10-15 11:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-15 11:37 Juhee Kang
2026-10-15 11:40 ` Ghennadi Procopciuc [this message]
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=a626dba9-6aa2-4cf9-883d-8c6f94770d6c@oss.nxp.com \
--to=ghennadi.procopciuc@oss.nxp.com \
--cc=daniel.lezcano@kernel.org \
--cc=dblack@redhat.com \
--cc=juhee.kang@redhat.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.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®