Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Sebastian Andrzej Siewior" <bigeasy@linutronix.de>
Cc: Frank.Li@kernel.org, imx@lists.linux.dev
Subject: Re: [PATCH 4/5] mailbox: imx: Don't force-thread the primary handler
Date: Fri, 29 May 2026 18:13:28 +0000	[thread overview]
Message-ID: <20260529181329.274501F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260529-imx_mbox_rproc-v1-4-b8ffc36e11e5@linutronix.de>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Mailbox controller is registered before initialization completes, leading to a race condition and potential system crash on probe error paths.
--

commit 1073878552c10da376c68e938a69f8f471bd3ed5
Author: Sebastian Andrzej Siewior <bigeasy@linutronix.de>

mailbox: imx: Don't force-thread the primary handler

The primary interrupt handler no longer invokes callbacks; it only masks
the interrupt source and returns. This patch converts the control register
lock to a raw_spinlock_t to allow the primary handler to run in hardirq
context even on PREEMPT_RT, skipping one thread.

> diff --git a/drivers/mailbox/imx-mailbox.c b/drivers/mailbox/imx-mailbox.c
> --- a/drivers/mailbox/imx-mailbox.c
> +++ b/drivers/mailbox/imx-mailbox.c
[ ... ]
> @@ -964,7 +963,7 @@ static int imx_mu_probe(struct platform_device *pdev)
>  		goto disable_clk;
>  	}
>  
> -	spin_lock_init(&priv->xcr_lock);
> +	raw_spin_lock_init(&priv->xcr_lock);
>  
>  	priv->mbox.dev = dev;
>  	priv->mbox.ops = &imx_mu_ops;

[Severity: High]
This is a pre-existing issue, but could the ordering in imx_mu_probe() lead
to a race condition on probe error paths?

Looking at the initialization sequence, devm_mbox_controller_register() is
called shortly after this lock initialization, but before pm_runtime_enable()
and before the probe function is guaranteed to succeed. 

If a consumer requests a channel immediately after registration and calls
startup(), it gains access to the hardware. If probe() subsequently fails
(for example, if pm_runtime_resume_and_get() fails), the error path calls
clk_disable_unprepare() to manually turn off the hardware clock.

The driver core will then trigger devres cleanup, which unregisters the
mailbox controller and calls imx_mu_shutdown() for the active channel.

Since imx_mu_shutdown() attempts to write to hardware registers to mask
interrupts, and the clock has already been disabled by the probe error path,
will this register access result in a fatal bus error or system hang?

Should the devm_mbox_controller_register() call be moved to the very end of
probe() to ensure consumers cannot interact with the hardware during an early
teardown?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260529-imx_mbox_rproc-v1-0-b8ffc36e11e5@linutronix.de?part=4

  reply	other threads:[~2026-05-29 18:13 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-29 16:01 [PATCH 0/5] mailbox: imx: Use threaded handler to avoid kworker in imx's remoteproc Sebastian Andrzej Siewior
2026-05-29 16:01 ` [PATCH 1/5] mailbox: imx: Start splitting the IRQ handler in primary and threaded handler Sebastian Andrzej Siewior
2026-05-29 16:43   ` sashiko-bot
2026-06-01 15:28     ` Sebastian Andrzej Siewior
2026-05-29 16:01 ` [PATCH 2/5] mailbox: imx: Move the RX part of the mailbox into the " Sebastian Andrzej Siewior
2026-05-29 17:26   ` sashiko-bot
2026-06-01 16:07     ` Sebastian Andrzej Siewior
2026-05-29 16:01 ` [PATCH 3/5] mailbox: imx: Move the RXDB " Sebastian Andrzej Siewior
2026-05-29 17:34   ` sashiko-bot
2026-06-01 16:15     ` Sebastian Andrzej Siewior
2026-05-29 16:01 ` [PATCH 4/5] mailbox: imx: Don't force-thread the primary handler Sebastian Andrzej Siewior
2026-05-29 18:13   ` sashiko-bot [this message]
2026-06-02 10:03     ` Sebastian Andrzej Siewior
2026-05-29 16:01 ` [PATCH 5/5] remoteproc: imx_rproc: Invoke the callback directly Sebastian Andrzej Siewior
2026-05-29 19:08   ` sashiko-bot
2026-06-02 12:11     ` Sebastian Andrzej Siewior
2026-06-02 16:51 ` [PATCH 0/5] mailbox: imx: Use threaded handler to avoid kworker in imx's remoteproc Mathieu Poirier

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=20260529181329.274501F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=bigeasy@linutronix.de \
    --cc=imx@lists.linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    /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