Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Tim Michals" <tcmichals@gmail.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org,
	linux-sunxi@lists.linux.dev
Subject: Re: [PATCH v2 3/7] mailbox: sun55i: add KUnit test suite for sun55i msgbox driver
Date: Sun, 27 Sep 2026 00:31:20 +0000	[thread overview]
Message-ID: <20260927003121.14C351F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260927002021.797069-4-tcmichals@gmail.com>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [Medium] test: MMIO endianness bug in mock registers causes test failures on BE
- [Low] build: missing SUN55I_MSGBOX dependency for KUnit test config
- [Low] test: mock bypass causes startup() flush test to silently succeed via failsafe
--

commit cd5e63e730e04c965eb8f6c0be2bc107e7e91214
Author: Tim Michals <tcmichals@gmail.com>

mailbox: sun55i: add KUnit test suite for sun55i msgbox driver

Adds a KUnit test suite for the Allwinner sun55i hardware Message Box
driver, validating channel routing, mock MMIO message sending, and
interrupt handling.

> diff --git a/drivers/mailbox/Kconfig b/drivers/mailbox/Kconfig
> index 9067f5161276a..af51794d260df 100644
> --- a/drivers/mailbox/Kconfig
> +++ b/drivers/mailbox/Kconfig
> @@ -342,6 +342,16 @@ config SUN55I_MSGBOX
>  	  provides 12 hardware FIFO channels for communication between the
>  	  Cortex-A55 host, CPUS, HiFi4 DSP, and XuanTie E907 RISC-V coprocessors.
>  
> +config SUN55I_MSGBOX_KUNIT_TEST
> +	tristate "KUnit tests for Allwinner sun55i msgbox" if !KUNIT_ALL_TESTS
> +	depends on KUNIT
> +	default KUNIT_ALL_TESTS

[Severity: Low]
Should this test configuration also depend on SUN55I_MSGBOX?

If the kernel is built with SUN55I_MSGBOX as a module and the test is
built-in, or if the driver is disabled completely, could this cause
undefined reference linker errors since the test links against symbols
exported by the driver?

> diff --git a/drivers/mailbox/sun55i_msgbox_test.c b/drivers/mailbox/sun55i_msgbox_test.c
> new file mode 100644
> --- /dev/null
> +++ b/drivers/mailbox/sun55i_msgbox_test.c
[ ... ]
> +static struct mock_msgbox_fixture *create_mock_fixture(struct kunit *test)
> +{
> +	struct mock_msgbox_fixture *fix;
> +	int i;
[ ... ]
> +	for (i = 0; i < SUN55I_MAX_PROCESSORS; i++)
> +		fix->mbox.regs[i] = (void __iomem *)fix->regs[i];

[Severity: Medium]
Will this cause the KUnit tests to fail unconditionally on big-endian
architectures?

The test fixture uses a host-endian u32 array for mock memory, but the
driver uses readl() and writel(). On a big-endian host, the device
accessors will perform a byte-swap, resulting in scrambled values when
reading from or writing to the mock registers.

[ ... ]
> +static void mock_rx_cb(struct mbox_client *cl, void *data)
> +{
[ ... ]
> +	/*
> +	 * Emulate hardware FIFO pop behavior: reading a word from the
> +	 * message FIFO decrements MSG_STATUS in real hardware.
> +	 */
> +	if (sink->status_reg && (*sink->status_reg & MSG_NUM_MASK) > 0)
> +		(*sink->status_reg)--;
> +}
[ ... ]
> +static void test_functional_startup_flushes_stale_fifo(struct kunit *test)
> +{
> +	struct mock_msgbox_fixture *fix = create_mock_fixture(test);
> +	u32 en_idx = SUNXI_MSGBOX_READ_IRQ_ENABLE(2) / 4;
> +	u32 stat_idx = SUNXI_MSGBOX_READ_IRQ_STATUS(2) / 4;
> +	u32 msg_stat_idx = SUNXI_MSGBOX_MSG_STATUS(2, 0) / 4;
> +	u32 fifo_idx = SUNXI_MSGBOX_MSG_FIFO(2, 0) / 4;
> +	int ret;
> +
> +	/* Simulate stale messages present in hardware FIFO before channel open */
> +	fix->regs[0][msg_stat_idx] = 4;
> +	fix->regs[0][fifo_idx] = 0xDEADBEEF;
> +
> +	ret = sun55i_msgbox_chan_ops.startup(&fix->chans[8]);
> +	KUNIT_EXPECT_EQ(test, ret, 0);

[Severity: Low]
Does test_functional_startup_flushes_stale_fifo() pass here solely due
to the driver's hardcoded failsafe boundary?

Since the readl() calls in the driver's startup() function do not trigger
the mock IRQ callback mock_rx_cb() (the only place where the mock MSG_STATUS
count is decremented), the status count never drops.

The test intends to simulate a 4-message flush, but it appears the driver
loop will spin until it hits the SUN55I_FIFO_MAX boundary cap instead.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260927002021.797069-1-tcmichals@gmail.com?part=3

  reply	other threads:[~2026-09-27  0:31 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260922034711.190253-1-tcmichals@gmail.com>
2026-09-22  3:47 ` [PATCH 1/7] dt-bindings: mailbox: add Allwinner sun55i msgbox schema Tim Michals
2026-09-22  3:54   ` sashiko-bot
2026-09-22  8:54   ` Krzysztof Kozlowski
2026-09-22  3:47 ` [PATCH 4/7] dt-bindings: remoteproc: add allwinner sun55i rproc binding Tim Michals
2026-09-22  3:56   ` sashiko-bot
2026-09-22  8:58   ` Krzysztof Kozlowski
2026-09-22 12:46   ` Rob Herring (Arm)
2026-09-22  3:47 ` [PATCH 7/7] arm64: dts: allwinner: add a523 msgbox and remoteproc nodes Tim Michals
2026-09-22  3:59   ` sashiko-bot
2026-09-27  0:20 ` [PATCH v2 0/7] remoteproc: sunxi: Add Allwinner XuanTie E907 RemoteProc and Message Box support Tim Michals
2026-09-27  0:20   ` [PATCH v2 1/7] dt-bindings: mailbox: add Allwinner sun55i msgbox schema Tim Michals
2026-09-27  0:30     ` sashiko-bot
2026-10-01  6:16     ` Krzysztof Kozlowski
2026-09-27  0:20   ` [PATCH v2 2/7] mailbox: sun55i: add Allwinner sun55i/sun60i 4-port Message Box driver Tim Michals
2026-09-27  0:33     ` sashiko-bot
2026-09-27  0:20   ` [PATCH v2 3/7] mailbox: sun55i: add KUnit test suite for sun55i msgbox driver Tim Michals
2026-09-27  0:31     ` sashiko-bot [this message]
2026-09-27  0:20   ` [PATCH v2 4/7] dt-bindings: remoteproc: add Allwinner sun55i-rproc schema Tim Michals
2026-09-27  0:27     ` sashiko-bot
2026-10-01  6:17     ` Krzysztof Kozlowski
2026-09-27  0:20   ` [PATCH v2 5/7] remoteproc: sunxi: add Allwinner XuanTie RISC-V remoteproc driver Tim Michals
2026-09-27  0:33     ` sashiko-bot
2026-09-27  0:20   ` [PATCH v2 6/7] remoteproc: sunxi: add KUnit test suite for sunxi " Tim Michals
2026-09-27  0:32     ` sashiko-bot
2026-09-27  0:20   ` [PATCH v2 7/7] arm64: dts: allwinner: add a523 msgbox and remoteproc nodes Tim Michals

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=20260927003121.14C351F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=tcmichals@gmail.com \
    /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