From: netdev-bot+sashiko@kernel.org
To: ahmadexp@gmail.com
Cc: netdev@vger.kernel.org, vadim.fedorenko@linux.dev,
andi.shyti@kernel.org, andrew+netdev@lunn.ch, corbet@lwn.net,
davem@davemloft.net, edumazet@kernel.org, horms@kernel.org,
jiri@resnulli.us, kuba@kernel.org, linux-doc@vger.kernel.org,
linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org,
pabeni@redhat.com, rdunlap@infradead.org,
richardcochran@gmail.com, skhan@linuxfoundation.org
Subject: Re: [PATCH net-next v3 2/3] i2c: xiic: add KUnit coverage for register access modes
Date: Wed, 18 Nov 2026 18:22:56 +0000 [thread overview]
Message-ID: <179502617695.3136.6995182814188526026@kernel.org> (raw)
In-Reply-To: <20261116-wiwi-v3-87afa10a8-2-ahmadexp@gmail.com>
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The new KUnit suite cannot catch a regression in the forced
32-bit read path of xiic_getreg8().
--
i2c: xiic: add KUnit coverage for register access modes
This adds a KUnit suite that is compiled into i2c-xiic.c and tests the
driver's private register accessors against RAM-backed registers. It
covers native and forced 32-bit accesses in both byte orders across 22
register offsets. It only builds on direct x86-64 MMIO.
> diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
> index 275aaa7f35833..0a7a2aeb78909 100644
> --- a/drivers/i2c/busses/Kconfig
> +++ b/drivers/i2c/busses/Kconfig
> @@ -1322,6 +1322,21 @@ config I2C_XILINX
[ ... ]
> +config I2C_XILINX_KUNIT_TEST
> + bool "KUnit tests for Xilinx I2C register accesses" if !KUNIT_ALL_TESTS
> + depends on I2C_XILINX && KUNIT=y
> + depends on X86_64 && !UML && !INDIRECT_IOMEM
> + default KUNIT_ALL_TESTS
> + help
> + Test the Xilinx I2C driver's register accessors with both byte orders
> + and with native-width or forced 32-bit accesses. The tests use
> + allocated RAM in place of registers. This relies on the direct
> + x86-64 MMIO accessor implementation; no controller is required.
[ ... ]
> diff --git a/drivers/i2c/busses/tests/i2c_xiic_kunit.c b/drivers/i2c/busses/tests/i2c_xiic_kunit.c
> new file mode 100644
> index 0000000000000..1b691de7e9250
> --- /dev/null
> +++ b/drivers/i2c/busses/tests/i2c_xiic_kunit.c
> @@ -0,0 +1,91 @@
[ ... ]
> + for (i = 0; i < ARRAY_SIZE(offsets); i++) {
> + reg = offsets[i];
> + memset(mem, 0xa5, 0x200);
> +
> + xiic_setreg8(i2c, reg, 0xc0);
> + expected = param->force_32bit_access ? 0xc0 : 0xa5a5a5c0;
> + KUNIT_EXPECT_EQ(test, (u32)xiic_getreg32(i2c, reg), expected);
> + KUNIT_EXPECT_EQ(test, xiic_getreg8(i2c, reg), (u8)0xc0);
[Severity: Low]
Would this check, or any of the other xiic_getreg8() checks in
xiic_register_access(), catch a regression in the forced 32-bit read path?
In xiic_getreg8(), the forced path is:
if (i2c->force_32bit_access)
return xiic_getreg32(i2c, reg);
Without it, the function does ioread8(base + reg) for LITTLE and
ioread8(base + reg + 3) for BIG.
In the word_little_endian and word_big_endian cases, every value is first
stored as a zero-extended 32-bit word. With RAM-backed registers, the byte
at reg + 0 (LE) or reg + 3 (BE) is always the low byte of that word. The
native 8-bit read and the truncated 32-bit read therefore return the same
value (0xc0, 0xff, 0x78, 0xef).
So it looks like the force_32bit_access branch could be removed from
xiic_getreg8() and all four parameterized cases would still pass.
The write side is covered, because the upper bytes (0xc0 vs 0xa5a5a5c0)
would catch a subword store. The read side is the one behind the machine
check from ioread8() in xiic_clear_rx_fifo(). That machine check is what
motivated "i2c: xiic: allow platforms to require 32-bit register
accesses".
The changelog says "These tests do not validate physical bus transaction
widths". The Kconfig help text above, however, says the accessors are
tested "with native-width or forced 32-bit accesses", and does not mention
that read width can't be observed.
Could that limit be documented in the Kconfig help or in a test comment?
Alternatively, the accessor could be instrumented so the read width can be
checked.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261116-wiwi-v3-87afa10a8-0-ahmadexp%40gmail.com
parent reply other threads:[~2026-11-18 18:22 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <20261116-wiwi-v3-87afa10a8-2-ahmadexp@gmail.com>]
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=179502617695.3136.6995182814188526026@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=ahmadexp@gmail.com \
--cc=andi.shyti@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rdunlap@infradead.org \
--cc=richardcochran@gmail.com \
--cc=skhan@linuxfoundation.org \
--cc=vadim.fedorenko@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox