ARM Sunxi Platform Development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Tim Michals" <tcmichals@gmail.com>
Cc: linux-sunxi@lists.linux.dev
Subject: Re: [PATCH 3/7] mailbox: sun55i: add KUnit tests for routing and registers
Date: Tue, 22 Sep 2026 03:54:08 +0000	[thread overview]
Message-ID: <20260922035409.5B7661F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260922034711.190253-4-tcmichals@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] mailbox: sun55i: KUnit test is tautological and does not test driver code
- [Medium] mailbox: sun55i: missing functional tests claimed in documentation
--

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

mailbox: sun55i: add KUnit tests for routing and registers

This commit introduces a KUnit test suite for the sun55i-msgbox driver. It
adds pure-logic tests meant to verify channel routing, register offsets, IRQ
bit positions, and driver constants without requiring real hardware.

>     Add KUnit test suite for the sun55i-msgbox driver, verifying:
>       - Channel routing table entries for CPUX (ARM), CPUS, DSP, and RV
>       - Local and remote port register offset macros
>       - Direction flags (rx/tx) and FIFO configurations
>       - Read IRQ enable/pending bit positions per channel
>       - Driver constants (NUM_CHANS, FIFO_MAX, MSG_NUM_MASK)

[ ... ]

> diff --git a/drivers/mailbox/sun55i_msgbox_test.c b/drivers/mailbox/sun55i_msgbox_test.c
> new file mode 100644
> index 0000000000000..984870b49db16
> --- /dev/null
> +++ b/drivers/mailbox/sun55i_msgbox_test.c
> @@ -0,0 +1,296 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * KUnit tests for Allwinner sun55i 4-port Message Box driver (sun55i-msgbox.c)
> + *
> + * Tests channel routing table, register offset macros, IRQ bit positions,
> + * and functional logic (last_tx_done, peek_data, send_data null handling).
> + * Pure-logic tests that run without real hardware.
> + *
> + * Copyright (C) 2026 Tim Michals <tcmichals@gmail.com>
> + */

[Severity: Medium]
Are the functional tests missing from this patch? The commit message claims
to test direction flags (rx/tx) and FIFO configurations, and this file header
claims to test functional logic like last_tx_done, peek_data, and send_data
null handling.

[ ... ]

> +/*
> + * Mirror of constants and macros from sun55i-msgbox.c.
> + * Must be kept in sync with the driver. Divergence is a bug.
> + */
> +#define SUN55I_MAX_PROCESSORS		4
> +#define SUN55I_CHANS_PER_PROC		4
> +#define SUN55I_NUM_CHANS		((SUN55I_MAX_PROCESSORS - 1) * SUN55I_CHANS_PER_PROC)
> +#define SUN55I_FIFO_MAX			8
> +
> +#define SUNXI_MSGBOX_OFFSET(n)			(0x100 * (n))
> +#define SUNXI_MSGBOX_READ_IRQ_ENABLE(n)		(0x020 + SUNXI_MSGBOX_OFFSET(n))

[Severity: Medium]
Does this test setup actually verify the driver code? By manually duplicating
the driver's macros and constants instead of including the driver code
or headers, the tests appear to be tautological.

If a regression is introduced in the actual driver logic in sun55i-msgbox.c,
these local duplicate macros will remain unchanged and the test suite will
continue to silently pass.

Could the test include the actual driver source and test its definitions
directly, rather than asserting against copies of the macros?

[ ... ]

> +/* Mirror of sun55i_chan_to_route() from sun55i-msgbox.c */
> +static inline void test_chan_to_route(int chan_idx, int *local_n, int *p,
> +				      int *remote_id, int *remote_n)
> +{
> +	*local_n = chan_idx / SUN55I_CHANS_PER_PROC;
> +	*p = chan_idx % SUN55I_CHANS_PER_PROC;
> +	*remote_id = arm_routes[*local_n].remote_id;
> +	*remote_n = arm_routes[*local_n].remote_n;
> +}

[Severity: Medium]
Similar to the regression above, is this function testing the actual routing
logic? This creates a duplicate of the driver's routing function. Testing
this function only verifies the duplicate implementation, leaving the real
sun55i_chan_to_route() untested.

[ ... ]

> +static void test_msg_fifo_offsets_all_channels(struct kunit *test)
> +{
> +	int n, p;
> +
> +	for (n = 0; n < 3; n++) {
> +		for (p = 0; p < SUN55I_CHANS_PER_PROC; p++) {
> +			u32 expected = 0x070 + 0x100 * n + 0x4 * p;
> +			u32 actual = SUNXI_MSGBOX_MSG_FIFO(n, p);
> +
> +			KUNIT_EXPECT_EQ_MSG(test, actual, expected,
> +					    "MSG_FIFO(%d,%d): expected 0x%03x got 0x%03x",
> +					    n, p, expected, actual);
> +		}
> +	}
> +}

[Severity: Medium]
Because SUNXI_MSGBOX_MSG_FIFO is defined locally in this file, does this loop
only evaluate the local duplicate macro against its own mathematical expansion?

[ ... ]

> +static struct kunit_case sun55i_msgbox_register_cases[] = {
> +	KUNIT_CASE(test_msgbox_offset_values),
> +	KUNIT_CASE(test_read_irq_enable_offsets),
> +	KUNIT_CASE(test_read_irq_status_offsets),
> +	KUNIT_CASE(test_msg_fifo_offsets_all_channels),
> +	KUNIT_CASE(test_msg_status_offsets_all_channels),
> +	KUNIT_CASE(test_fifo_status_offsets_all_channels),
> +	KUNIT_CASE(test_rd_irq_en_bit_positions),
> +	KUNIT_CASE(test_rd_irq_pend_bit_positions),
> +	KUNIT_CASE(test_num_chans_constant),
> +	KUNIT_CASE(test_msg_num_mask),
> +	{}
> +};

[Severity: Medium]
Looking at the registered test cases, the claimed tests for direction flags
and functional logic mentioned in the commit message and file header are not
present. Could the commit message and documentation be updated to match the
code, or were these tests accidentally omitted?

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

  reply	other threads:[~2026-09-22  3:54 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-22  3:47 [PATCH 0/7] remoteproc/mailbox: add Allwinner A523/A527/T527 E907 RISC-V support Tim Michals
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 2/7] mailbox: sun55i: add Allwinner sun55i/sun60i 4-port Message Box driver Tim Michals
2026-09-22  4:00   ` sashiko-bot
2026-09-22  3:47 ` [PATCH 3/7] mailbox: sun55i: add KUnit tests for routing and registers Tim Michals
2026-09-22  3:54   ` sashiko-bot [this message]
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 5/7] remoteproc: sunxi: add allwinner riscv remoteproc driver Tim Michals
2026-09-22  3:59   ` sashiko-bot
2026-09-22  3:47 ` [PATCH 6/7] remoteproc: sunxi: add KUnit tests for da_to_va address translation Tim Michals
2026-09-22  3:54   ` sashiko-bot
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-22  6:34 ` [PATCH 0/7] remoteproc/mailbox: add Allwinner A523/A527/T527 E907 RISC-V support Chen-Yu Tsai
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
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=20260922035409.5B7661F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-sunxi@lists.linux.dev \
    --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