All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peng Fan <peng.fan@oss.nxp.com>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: linux-kernel@vger.kernel.org, imx@lists.linux.dev,
	linux-arm-kernel@lists.infradead.org,
	linux-remoteproc@vger.kernel.org, linux-rt-devel@lists.linux.dev,
	Bjorn Andersson <andersson@kernel.org>,
	Clark Williams <clrkwllms@kernel.org>,
	Fabio Estevam <festevam@gmail.com>, Frank Li <Frank.Li@nxp.com>,
	Jassi Brar <jassisinghbrar@gmail.com>,
	Mathieu Poirier <mathieu.poirier@linaro.org>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Steven Rostedt <rostedt@goodmis.org>
Subject: Re: [PATCH v2 5/9] mailbox: imx: Start splitting the IRQ handler in primary and threaded handler
Date: Mon, 8 Jun 2026 13:32:49 +0800	[thread overview]
Message-ID: <aiZUAdrwhFn63a2a@shlinux89> (raw)
In-Reply-To: <20260603-imx_mbox_rproc-v2-5-a0059dc3b69a@linutronix.de>

On Wed, Jun 03, 2026 at 03:05:08PM +0200, Sebastian Andrzej Siewior wrote:
>Split the mailbox irq handling into a primary handler (imx_mu_isr()) and
>a threaded handler (imx_mu_isr_th()). The primary handler masks the
>interrupt event so the threaded handler can run without raising the
>interrupt again. The threaded handler can invoke the actuall callback in
>preemtible context.
>
>As a first step, prepare the logic and move TX handling part.
>
>Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
>---
> drivers/mailbox/imx-mailbox.c | 33 ++++++++++++++++++++++++++++++---
> 1 file changed, 30 insertions(+), 3 deletions(-)
>
>diff --git a/drivers/mailbox/imx-mailbox.c b/drivers/mailbox/imx-mailbox.c
>index d1de07cc0ed62..006aa76b74b62 100644
>--- a/drivers/mailbox/imx-mailbox.c
>+++ b/drivers/mailbox/imx-mailbox.c
>@@ -81,6 +81,7 @@ struct imx_mu_con_priv {
> 	struct mbox_chan	*chan;
> 	struct work_struct 	txdb_work;
> 	bool			shutdown;
>+	bool			pending;
> };
> 
> struct imx_mu_priv {
>@@ -539,11 +540,35 @@ static void imx_mu_txdb_work(struct work_struct *t)
> 	mbox_chan_txdone(cp->chan, 0);
> }
> 
>+static irqreturn_t imx_mu_isr_th(int irq, void *p)
>+{
>+	struct mbox_chan *chan = p;
>+	struct imx_mu_priv *priv = to_imx_mu_priv(chan->mbox);
>+	struct imx_mu_con_priv *cp = chan->con_priv;
>+
>+	if (!cp->pending)
>+		return IRQ_NONE;

Is there a chance that cp->pending could be false here?

Regards
Peng

>+
>+	switch (cp->type) {
>+	case IMX_MU_TYPE_TX:
>+		cp->pending = false;
>+		mbox_chan_txdone(chan, 0);
>+		break;
>+
>+	default:
>+		dev_warn_ratelimited(priv->dev, "Unhandled channel type %d\n",
>+				     cp->type);
>+		return IRQ_NONE;
>+	}
>+	return IRQ_HANDLED;
>+}
>+
> static irqreturn_t imx_mu_isr(int irq, void *p)
> {
> 	struct mbox_chan *chan = p;
> 	struct imx_mu_priv *priv = to_imx_mu_priv(chan->mbox);
> 	struct imx_mu_con_priv *cp = chan->con_priv;
>+	irqreturn_t ret = IRQ_HANDLED;
> 	u32 val, ctrl;
> 
> 	switch (cp->type) {
>@@ -579,7 +604,8 @@ static irqreturn_t imx_mu_isr(int irq, void *p)
> 	if ((val == IMX_MU_xSR_TEn(priv->dcfg->type, cp->idx)) &&
> 	    (cp->type == IMX_MU_TYPE_TX)) {
> 		imx_mu_xcr_rmw(priv, IMX_MU_TCR, 0, IMX_MU_xCR_TIEn(priv->dcfg->type, cp->idx));
>-		mbox_chan_txdone(chan, 0);
>+		cp->pending = true;
>+		ret = IRQ_WAKE_THREAD;
> 	} else if ((val == IMX_MU_xSR_RFn(priv->dcfg->type, cp->idx)) &&
> 		   (cp->type == IMX_MU_TYPE_RX)) {
> 		priv->dcfg->rx(priv, cp);
>@@ -594,7 +620,7 @@ static irqreturn_t imx_mu_isr(int irq, void *p)
> 	if (priv->suspend)
> 		pm_system_wakeup();
> 
>-	return IRQ_HANDLED;
>+	return ret;
> }
> 
> static int imx_mu_send_data(struct mbox_chan *chan, void *data)
>@@ -629,7 +655,8 @@ static int imx_mu_startup(struct mbox_chan *chan)
> 	if (!(priv->dcfg->type & IMX_MU_V2_IRQ))
> 		irq_flag |= IRQF_SHARED;
> 
>-	ret = request_irq(priv->irq[cp->type], imx_mu_isr, irq_flag, cp->irq_desc, chan);
>+	ret = request_threaded_irq(priv->irq[cp->type], imx_mu_isr, imx_mu_isr_th,
>+				   irq_flag, cp->irq_desc, chan);
> 	if (ret) {
> 		dev_err(priv->dev, "Unable to acquire IRQ %d\n", priv->irq[cp->type]);
> 		return ret;
>
>-- 
>2.53.0
>

  parent reply	other threads:[~2026-06-08  5:29 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-03 13:05 [PATCH v2 0/9] mailbox: imx: Use threaded handler to avoid kworker in imx's remoteproc Sebastian Andrzej Siewior
2026-06-03 13:05 ` [PATCH v2 1/9] mailbox: imx: Add a channel shutdown field Sebastian Andrzej Siewior
2026-06-03 13:20   ` sashiko-bot
2026-06-03 14:59     ` Sebastian Andrzej Siewior
2026-06-08  5:01   ` Peng Fan
2026-06-03 13:05 ` [PATCH v2 2/9] mailbox: imx: Use devm_pm_runtime_enable() Sebastian Andrzej Siewior
2026-06-03 13:27   ` sashiko-bot
2026-06-03 15:00     ` Sebastian Andrzej Siewior
2026-06-08  5:06   ` Peng Fan
2026-06-03 13:05 ` [PATCH v2 3/9] mailbox: imx: use devm_of_platform_populate() Sebastian Andrzej Siewior
2026-06-03 13:37   ` sashiko-bot
2026-06-03 15:01     ` Sebastian Andrzej Siewior
2026-06-08  5:05   ` Peng Fan
2026-06-03 13:05 ` [PATCH v2 4/9] mailbox: imx: Use channel index instead of zero in imx_mu_specific_rx() Sebastian Andrzej Siewior
2026-06-08  5:11   ` Peng Fan
2026-06-08  9:39     ` Sebastian Andrzej Siewior
2026-06-03 13:05 ` [PATCH v2 5/9] mailbox: imx: Start splitting the IRQ handler in primary and threaded handler Sebastian Andrzej Siewior
2026-06-03 13:58   ` sashiko-bot
2026-06-03 15:07     ` Sebastian Andrzej Siewior
2026-06-08  5:14   ` Peng Fan
2026-06-08  5:32   ` Peng Fan [this message]
2026-06-08  9:37     ` Sebastian Andrzej Siewior
2026-06-03 13:05 ` [PATCH v2 6/9] mailbox: imx: Move the RX part of the mailbox into the " Sebastian Andrzej Siewior
2026-06-03 13:18   ` Daniel Baluta
2026-06-03 13:20     ` Sebastian Andrzej Siewior
2026-06-03 13:45       ` Daniel Baluta
2026-06-03 15:26         ` Sebastian Andrzej Siewior
2026-06-08  5:48   ` Peng Fan
2026-06-03 13:05 ` [PATCH v2 7/9] mailbox: imx: Move the RXDB " Sebastian Andrzej Siewior
2026-06-03 14:19   ` sashiko-bot
2026-06-08  5:48   ` Peng Fan
2026-06-03 13:05 ` [PATCH v2 8/9] mailbox: imx: Don't force-thread the primary handler Sebastian Andrzej Siewior
2026-06-03 14:31   ` sashiko-bot
2026-06-03 15:20     ` Sebastian Andrzej Siewior
2026-06-08  5:50   ` Peng Fan
2026-06-03 13:05 ` [PATCH v2 9/9] remoteproc: imx_rproc: Invoke the callback directly Sebastian Andrzej Siewior
2026-06-03 14:45   ` sashiko-bot
2026-06-03 15:21     ` Sebastian Andrzej Siewior
2026-06-08  5:52   ` Peng Fan

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=aiZUAdrwhFn63a2a@shlinux89 \
    --to=peng.fan@oss.nxp.com \
    --cc=Frank.Li@nxp.com \
    --cc=andersson@kernel.org \
    --cc=bigeasy@linutronix.de \
    --cc=clrkwllms@kernel.org \
    --cc=festevam@gmail.com \
    --cc=imx@lists.linux.dev \
    --cc=jassisinghbrar@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-remoteproc@vger.kernel.org \
    --cc=linux-rt-devel@lists.linux.dev \
    --cc=mathieu.poirier@linaro.org \
    --cc=rostedt@goodmis.org \
    --cc=s.hauer@pengutronix.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.