All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Paul Cercueil" <paul.cercueil@bootlin.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v2 2/2] mailbox: marvell-mhu: add Marvell MHU driver
Date: Fri, 20 Nov 2026 11:52:06 +0000	[thread overview]
Message-ID: <sashiko-outbox-225100@kernel.org> (raw)
In-Reply-To: <20261120113952.168265-3-paul.cercueil@bootlin.com>

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [High] mailbox: marvell-mhu: missing IRQF_NO_AUTOEN in
  mrvl_mhu_setup_irq()
- [Medium] mailbox: marvell-mhu: inverted TX done check in
  mrvl_mhu_last_tx_done()
- [Low] mailbox: marvell-mhu: invalid min_vecs in mrvl_mhu_setup_irq()
--

commit 2ee602a4969cc96c3afca49d7d2c3b05ee5ffda2
Author: George Cherian <gcherian@marvell.com>

mailbox: marvell-mhu: add Marvell MHU driver

This commit adds a mailbox controller driver for the Message Handling Unit
on Marvell OcteonTX and OcteonTX2 platforms.

> diff --git a/drivers/mailbox/marvell_mhu.c b/drivers/mailbox/marvell_mhu.c
> new file mode 100644
> index 0000000000000..9b618b3fe2768
> --- /dev/null
> +++ b/drivers/mailbox/marvell_mhu.c
> @@ -0,0 +1,239 @@
[ ... ]
> +#define SCP_INDEX	0x0
> +#define DEV_AP0		0x2
> +#define SCP_TO_AP_INTERRUPT	2
> +#define INT_VECS_MIN	0
> +#define INT_VECS_MAX	3
[ ... ]
> +static bool mrvl_mhu_last_tx_done(struct mbox_chan *chan)
> +{
> +	struct mrvl_mhu *mhu = chan->con_priv;
> +	u64 status;
> +
> +	status = ioread64(mhu->base + AP0_TO_SCP_MBOX_LINT);
> +
> +	return status != 0;
> +}

[Severity: Medium]
Is the status check in mrvl_mhu_last_tx_done() inverted?

Writing the doorbell in mrvl_mhu_send_data() asserts the interrupt bit in
AP0_TO_SCP_MBOX_LINT, and the register remains non-zero until the SCP
services and clears the interrupt.  Returning status != 0 reports TX done
while the interrupt is still pending (or times out if the SCP clears it
before the poll runs), instead of waiting for status == 0.

> +
> +static int mrvl_mhu_startup(struct mbox_chan *chan)
> +{
> +	struct mrvl_mhu *mhu = chan->con_priv;
> +
> +	/* Enable interrupts only if there is client for data */
> +	writeq_relaxed(1ul, mhu->base + SCP_TO_AP0_MBOX_RINT_ENA_W1S);
> +
> +	enable_irq(mhu->irq);
> +
> +	return 0;
> +}
> +
> +static void mrvl_mhu_shutdown(struct mbox_chan *chan)
> +{
> +	struct mrvl_mhu *mhu = chan->con_priv;
> +
> +	/* Could be using SCP_TO_AP0_MBOX_RINT_DIS_W1S if we knew where it was */
> +	disable_irq(mhu->irq);
> +}
[ ... ]
> +static int mrvl_mhu_setup_irq(struct mrvl_mhu *mhu, struct pci_dev *pdev)
> +{
> +	struct device *dev = &pdev->dev;
> +	int ret, nvec;
> +
> +	nvec = pci_alloc_irq_vectors(pdev, INT_VECS_MIN, INT_VECS_MAX, PCI_IRQ_MSIX);
> +	if (nvec < 0)
> +		return nvec;
> +
> +	ret = devm_add_action_or_reset(dev, mrvl_mhu_free_irq_vector, pdev);
> +	if (ret)
> +		return ret;
> +
> +	mhu->irq = pci_irq_vector(pdev, SCP_TO_AP_INTERRUPT);

[Severity: Low]
Should INT_VECS_MIN be 3 (or SCP_TO_AP_INTERRUPT + 1) instead of 0?
pci_alloc_irq_vectors() requires min_vecs >= 1, and requesting vector
index 2 requires at least 3 MSI-X vectors to be allocated.

> +	if (mhu->irq < 0)
> +		return mhu->irq;
> +
> +	return devm_request_irq(dev, mhu->irq,
> +				mrvl_mhu_rx_interrupt, 0, "mvl-mhu", mhu);
> +}

[Severity: High]
Should devm_request_irq() pass IRQF_NO_AUTOEN?

With irqflags set to 0, mhu->irq is enabled immediately during probe while
mhu->chan.cl is still NULL.  When a client binds to the channel,
mrvl_mhu_startup() calls enable_irq(mhu->irq) on the already-enabled IRQ
and triggers an "Unbalanced enable for IRQ" warning in __enable_irq().  In
addition, if an SCP interrupt fires before a client attaches,
mrvl_mhu_rx_interrupt() calls mbox_chan_received_data(&mhu->chan, ...) and
dereferences a NULL chan->cl.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261120113952.168265-1-paul.cercueil@bootlin.com?part=2

      reply	other threads:[~2026-11-20 11:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20 11:39 [PATCH v2 0/2] mailbox: Add Marvell MHU driver Paul Cercueil
2026-11-20 11:39 ` [PATCH v2 1/2] dt-bindings: mailbox: add Marvell MHU Paul Cercueil
2026-11-20 11:39 ` [PATCH v2 2/2] mailbox: marvell-mhu: add Marvell MHU driver Paul Cercueil
2026-11-20 11:52   ` sashiko-bot [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=sashiko-outbox-225100@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=paul.cercueil@bootlin.com \
    --cc=robh@kernel.org \
    --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 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.