From: sashiko-bot@kernel.org
To: "Ben Levinsky" <ben.levinsky@amd.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v3 2/4] mailbox: Add AMD PL Mailbox soft IP controller
Date: Thu, 19 Nov 2026 22:18:33 +0000 [thread overview]
Message-ID: <sashiko-outbox-224127@kernel.org> (raw)
In-Reply-To: <20261119220405.2838553-3-ben.levinsky@amd.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] mailbox: skipped error read in amd_pl_mbox_irq_thread() when
ratelimited
- [Medium] mailbox: lost RX threshold IRQ race in amd_pl_mbox_startup()
--
commit d942eb10f8289caaed849b4d53047a9b3e47ae11
Author: Ben Levinsky <ben.levinsky@amd.com>
mailbox: Add AMD PL Mailbox soft IP controller
This commit adds a mailbox controller driver for the AMD Programmable
Logic Mailbox soft IP with polling-based TX completion and
interrupt-driven RX handling.
> diff --git a/drivers/mailbox/amd-pl-mailbox.c b/drivers/mailbox/amd-pl-mailbox.c
> new file mode 100644
> index 0000000000000..d1fe0f381dce5
> --- /dev/null
> +++ b/drivers/mailbox/amd-pl-mailbox.c
> @@ -0,0 +1,378 @@
[ ... ]
> +static int amd_pl_mbox_startup(struct mbox_chan *chan)
> +{
[ ... ]
> + writel(AMD_PL_MBOX_CTRL_RX_RESET, mb->regs + AMD_PL_MBOX_CTRL);
> + /* Interrupt when the RX FIFO changes from empty to nonempty. */
> + writel(0, mb->regs + AMD_PL_MBOX_RECV_THRESHOLD);
> + writel(AMD_PL_MBOX_IRQ_RX_THRESHOLD | AMD_PL_MBOX_IRQ_ERROR,
> + mb->regs + AMD_PL_MBOX_IRQ_STATUS);
> + irq_enable = readl(mb->regs + AMD_PL_MBOX_IRQ_ENABLE);
> + irq_enable |= AMD_PL_MBOX_IRQ_RX_THRESHOLD | AMD_PL_MBOX_IRQ_ERROR;
> + writel(irq_enable, mb->regs + AMD_PL_MBOX_IRQ_ENABLE);
> + enable_irq(mb->irq);
> +
> + return 0;
> +}
[Severity: Medium]
Can clearing AMD_PL_MBOX_IRQ_STATUS after resetting the RX FIFO lose an
incoming receive interrupt and stall the RX channel?
With AMD_PL_MBOX_RECV_THRESHOLD set to 0, AMD_PL_MBOX_IRQ_RX_THRESHOLD
only latches when the RX FIFO transitions from empty to nonempty. If the
remote peer writes a word after AMD_PL_MBOX_CTRL_RX_RESET empties the
FIFO and before AMD_PL_MBOX_IRQ_STATUS is cleared, that status write
clears the latched event while the word stays unread in the FIFO. Later
words then see a nonempty FIFO and never latch AMD_PL_MBOX_IRQ_RX_THRESHOLD
again.
Clearing AMD_PL_MBOX_IRQ_STATUS before resetting the RX FIFO (or draining
after enabling the interrupt) would avoid this race.
[ ... ]
> +static irqreturn_t amd_pl_mbox_irq_thread(int irq, void *data)
> +{
[ ... ]
> + /*
> + * Acknowledge before draining. The receive event latches when the RX
> + * FIFO goes from empty to nonempty, so a word that arrives after the
> + * drain has emptied the FIFO raises a new event.
> + */
> + writel(pending_intr, mb->regs + AMD_PL_MBOX_IRQ_STATUS);
> +
> + if (pending_intr & AMD_PL_MBOX_IRQ_ERROR)
> + dev_warn_ratelimited(mb->controller.dev,
> + "mailbox FIFO error: %#x\n",
> + readl(mb->regs + AMD_PL_MBOX_ERROR));
[Severity: Medium]
Does passing readl(mb->regs + AMD_PL_MBOX_ERROR) directly to
dev_warn_ratelimited() skip reading the error register when logging is
rate-limited or CONFIG_PRINTK is disabled?
dev_warn_ratelimited() only evaluates its variadic arguments when
__ratelimit() succeeds, so once the burst limit is exceeded the
clear-on-read AMD_PL_MBOX_ERROR register is not read and its sticky FIFO
error bits remain set. Reading AMD_PL_MBOX_ERROR into a local variable
before calling dev_warn_ratelimited() ensures the register is always
cleared.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261119220405.2838553-1-ben.levinsky@amd.com?part=2
next prev parent reply other threads:[~2026-11-19 22:18 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 22:04 [PATCH v3 0/4] Add AMD PL Mailbox and RPMsg support for the AMD BRAM remoteproc Ben Levinsky
2026-11-19 22:04 ` [PATCH v3 1/4] dt-bindings: mailbox: Add AMD PL Mailbox IP Ben Levinsky
2026-11-19 22:04 ` [PATCH v3 2/4] mailbox: Add AMD PL Mailbox soft IP controller Ben Levinsky
2026-11-19 22:18 ` sashiko-bot [this message]
2026-11-19 22:04 ` [PATCH v3 3/4] dt-bindings: remoteproc: Add RPMsg resources to AMD BRAM rproc Ben Levinsky
2026-11-19 22:04 ` [PATCH v3 4/4] remoteproc: amd_mbv_bram: Add RPMsg support Ben Levinsky
2026-11-19 22:19 ` sashiko-bot
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-224127@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=ben.levinsky@amd.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--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.