From: Daniel Lezcano <daniel.lezcano@oss.qualcomm.com>
To: Ryan Brue <ryanbrue.dev@gmail.com>,
Daniel Lezcano <daniel.lezcano@kernel.org>,
Thomas Gleixner <tglx@kernel.org>,
Matthias Brugger <matthias.bgg@gmail.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
Luca Leonardo Scorcia <l.scorcia@gmail.com>
Cc: Chen-Yu Tsai <wenst@chromium.org>,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org
Subject: Re: [PATCH RESEND] clocksource/drivers/timer-mediatek: Enable the GPT irq before registering
Date: Thu, 26 Nov 2026 01:02:08 +0100 [thread overview]
Message-ID: <1e12ac6a-eb73-4f54-8a79-8da13d6c1638@oss.qualcomm.com> (raw)
In-Reply-To: <20261125-timer-mediatek-gpt-irq-order-v1-1-7e24640e82d4@gmail.com>
On 11/26/26 00:22, Ryan Brue wrote:
> Since the driver probes as a platform device, the GPT clock event is
> registered late in boot, when PSCI CPU idle may already have put CPUs
> into a state that stops their local timer. Those CPUs wait in the
> oneshot broadcast mask on the hrtimer broadcast, and
> tick_install_broadcast_device() arms the new broadcast device to expire
> at once so that it wakes them.
>
> mtk_gpt_init() sets the timer's bit in GPT_IRQ_EN only after
> clockevents_config_and_register(). The forced event fires while the bit
> is clear, nothing is latched in the status register, and the waiting
> CPUs are never woken. On an MT8173 tablet with the CPU_SLEEP_0 idle
> state in use, this hung the boot in 20 of 40 boots, and in none of 16
> with this change.
>
> Enable the interrupt before registering the clock event. The IRQ line
> stays disabled until enable_irq(), so the handler still can't run before
> the clock event is set up.
Please have a look at:
https://sashiko.dev/#/patchset/20261125-timer-mediatek-gpt-irq-order-v1-1-7e24640e82d4%40gmail.com
> Fixes: 7a097aba7255 ("clocksource/drivers/timer-mediatek: Convert to OF probing")
> Reviewed-by: Luca Leonardo Scorcia <l.scorcia@gmail.com>
> Tested-by: Luca Leonardo Scorcia <l.scorcia@gmail.com> # on mt8167
> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> Tested-by: Chen-Yu Tsai <wenst@chromium.org> # on Hana (Telesu)
> Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
> Signed-off-by: Ryan Brue <ryanbrue.dev@gmail.com>
> ---
> Since v7.4-rc1 the MediaTek timer probes as a platform device, and on
> MT8173 with PSCI CPU idle the boot then hangs about half the time: the
> broadcast device is armed at once to wake CPUs that are already idle,
> and that event is lost because the GPT's interrupt is enabled only after
> registration. Traced on the board with prints in
> tick_install_broadcast_device() and mtk_gpt_init().
>
> This is a resend of the 11-03 patch with the review and test tags from
> its thread folded in. The code is unchanged, and it still applies to
> v7.4-rc4 and tip timers/urgent. As a 7.4-rc1 regression, it would be
> good to have it in 7.4.
>
> This patch was developed with the help of an LLM coding assistant.
> ---
> Changes in RESEND:
> - Collected Reviewed-by and Tested-by tags from v1; no code change.
> - Cc Daniel's oss.qualcomm.com address and Chen-Yu.
> - Link to v1: https://lore.kernel.org/r/20261103-timer-mediatek-gpt-irq-order-v1-1-6d1ddf977224@gmail.com
> ---
> drivers/clocksource/timer-mediatek.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/clocksource/timer-mediatek.c b/drivers/clocksource/timer-mediatek.c
> index 842d6ee4259e..1b2cbcc2795a 100644
> --- a/drivers/clocksource/timer-mediatek.c
> +++ b/drivers/clocksource/timer-mediatek.c
> @@ -339,10 +339,10 @@ static int mtk_gpt_init(struct platform_device *pdev)
>
> /* Configure clock event */
> mtk_gpt_setup(&to, TIMER_CLK_EVT, GPT_CTRL_OP_REPEAT);
> + mtk_gpt_enable_irq(&to, TIMER_CLK_EVT);
> clockevents_config_and_register(&to.clkevt, timer_of_rate(&to),
> TIMER_SYNC_TICKS, 0xffffffff);
>
> - mtk_gpt_enable_irq(&to, TIMER_CLK_EVT);
> enable_irq(timer_of_irq(&to));
>
> return 0;
>
> ---
> base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
> change-id: 20261103-timer-mediatek-gpt-irq-order-a878ed869f84
>
> Best regards,
prev parent reply other threads:[~2026-11-26 0:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 23:22 Ryan Brue
2026-11-26 0:02 ` Daniel Lezcano [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=1e12ac6a-eb73-4f54-8a79-8da13d6c1638@oss.qualcomm.com \
--to=daniel.lezcano@oss.qualcomm.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=daniel.lezcano@kernel.org \
--cc=l.scorcia@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=ryanbrue.dev@gmail.com \
--cc=tglx@kernel.org \
--cc=wenst@chromium.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®