* [PATCH net-next v2 0/3] ptp: ocp: support the WiWi production Time Card
@ 2026-11-12 16:33 Ahmad Byagowi
2026-11-12 16:33 ` [PATCH net-next v2 1/3] i2c: xiic: allow platforms to require 32-bit register accesses Ahmad Byagowi
2026-11-12 16:33 ` [PATCH net-next v2 2/3] i2c: xiic: add KUnit coverage for register access modes Ahmad Byagowi
0 siblings, 2 replies; 3+ messages in thread
From: Ahmad Byagowi @ 2026-11-12 16:33 UTC (permalink / raw)
To: netdev, vadim.fedorenko, andi.shyti
Cc: linux-i2c, Jiri Pirko, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman, Jonathan Corbet,
Shuah Khan, Randy Dunlap, Michal Simek, Richard Cochran,
Andrew Lunn, linux-doc, linux-kernel, linux-arm-kernel
The WiWi Time Card (2163:1008, subsystem 10ee:0007) uses a
Celestica-compatible register map behind LitePCIe. Its bridge does not
support the subword MMIO used by the XIIC driver. Add an opt-in word
access mode, exercise both modes with KUnit, and enable ptp_ocp on the
revision 02 interface. Other cards retain their existing access modes.
The series does not enable WiWi flash updates or change LED policy.
Patch 3 uses the platform-data field from patch 1. Could the I2C
maintainers review patches 1 and 2 for an Ack to take the series
through net-next?
Changes since v1:
- 1/3: Drop five explicit inline annotations in the C file and
shorten the platform-data comment. No access semantics change.
- 2/3: Wrap the offsets and expectations flagged by checkpatch.
The four test modes, register offsets and expected values are unchanged.
- 3/3: Follow NetTimeLogic's PCI revision convention. Replace the exact
image ID and per-core version checks with a revision 02 gate. Reject
unknown revisions before FPGA MMIO and retain the BAR/MSI-X checks.
Report the full build ID in devlink; select capabilities by interface
revision. Update the documentation and wrap overlength lines.
The revision 02 driver was tested on a physical card running build
0x0000800f under Secure Boot. It bound with 64 MSI-X vectors; the PHC
advanced 3.000441080 s over three one-second sleeps. SPI NOR and both
EEPROM clients bound. The PHC was UNSYNCED at probe; this test does not
establish PPS lock or valid UTC. Only that firmware build was tested on
hardware. Subsequent edits to the tested drivers remove inline hints or
change formatting and comments.
On the rebased v2, the XIIC and ptp_ocp objects built on x86-64 with
W=1 under allmodconfig and allyesconfig. Four XIIC KUnit cases passed
in an isolated x86-64 QEMU boot. Fixtures exercised all 256 PCI
revisions, bad PCI layouts and multiple image IDs. These are not
additional hardware tests. No full allmodconfig or allyesconfig build
is claimed for v2.
Codex assisted with the changes, tests and changelogs using the board
layout, machine-check evidence, vendor revision rule and v1 CI reports.
v1: https://lore.kernel.org/netdev/20261111041904.48916-1-ahmadexp@gmail.com/
Ahmad Byagowi (3):
i2c: xiic: allow platforms to require 32-bit register accesses
i2c: xiic: add KUnit coverage for register access modes
ptp: ocp: support the WiWi revision 02 Time Card
Documentation/networking/devlink/ptp_ocp.rst | 36 +++-
MAINTAINERS | 1 +
drivers/i2c/busses/Kconfig | 14 ++
drivers/i2c/busses/i2c-xiic.c | 60 +++++--
drivers/i2c/busses/tests/i2c_xiic_kunit.c | 91 +++++++++++
drivers/ptp/ptp_ocp.c | 163 ++++++++++++++++++-
include/linux/platform_data/i2c-xiic.h | 3 +
7 files changed, 341 insertions(+), 27 deletions(-)
create mode 100644 drivers/i2c/busses/tests/i2c_xiic_kunit.c
base-commit: 368fbf5d82da9ebce309449c74fc0b128f7d0219
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH net-next v2 1/3] i2c: xiic: allow platforms to require 32-bit register accesses
2026-11-12 16:33 [PATCH net-next v2 0/3] ptp: ocp: support the WiWi production Time Card Ahmad Byagowi
@ 2026-11-12 16:33 ` Ahmad Byagowi
2026-11-12 16:33 ` [PATCH net-next v2 2/3] i2c: xiic: add KUnit coverage for register access modes Ahmad Byagowi
1 sibling, 0 replies; 3+ messages in thread
From: Ahmad Byagowi @ 2026-11-12 16:33 UTC (permalink / raw)
To: netdev, vadim.fedorenko, andi.shyti
Cc: linux-i2c, Michal Simek, linux-arm-kernel, linux-kernel
The LitePCIe bridge in the WiWi Time Card production image cannot safely
service subword MMIO accesses. Bringing up its AXI IIC controller with the
existing byte accessors caused a fatal machine check. Two crash dumps
placed the faulting access in ioread8(), called by xiic_clear_rx_fifo()
during xiic_reinit(). The affected register was the IIC status register.
Add a platform-data flag to use aligned 32-bit accesses for registers
carrying byte or halfword values. Keep the detected register endianness
and use a single transaction, not read-modify-write, for FIFO accesses.
Platforms that do not request this mode retain their existing accessors.
With these accessors on a WiWi card, the controller probed and at24
registered the board and MAC EEPROMs. Repeated EEPROM reads and I2C
interrupt delivery were tested separately on an earlier Ubuntu port.
Tool-origin disclosure, as required by generated-content.rst: Codex was
used to analyze the supplied crash evidence, implement the accessors,
prepare tests and draft this changelog. The request was to support the
WiWi card while retaining the existing behavior on other platforms.
Signed-off-by: Ahmad Byagowi <ahmadexp@gmail.com>
---
drivers/i2c/busses/i2c-xiic.c | 56 +++++++++++++++++---------
include/linux/platform_data/i2c-xiic.h | 3 ++
2 files changed, 41 insertions(+), 18 deletions(-)
diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c
index ba560462d..8425a540f 100644
--- a/drivers/i2c/busses/i2c-xiic.c
+++ b/drivers/i2c/busses/i2c-xiic.c
@@ -66,6 +66,7 @@ enum i2c_scl_freq {
* @rx_msg: Current RX message
* @rx_pos: Position within current RX message
* @endianness: big/little-endian byte order
+ * @force_32bit_access: Bridge requires aligned 32-bit register accesses
* @clk: Pointer to AXI4-lite input clock
* @irq: Interrupt number
* @state: See STATE_
@@ -95,6 +96,7 @@ struct xiic_i2c {
struct i2c_msg *rx_msg;
int rx_pos;
enum xiic_endian endianness;
+ bool force_32bit_access;
struct clk *clk;
int irq;
enum xilinx_i2c_state state;
@@ -282,52 +284,68 @@ static int xiic_i2c_runtime_resume(struct device *dev)
* Only the least significant byte [doublet] of the register are ever
* accessed. This requires an offset of 3 [2] from the base address for
* big-endian systems.
+ * Some bridges only support aligned 32-bit accesses. For these, access the
+ * entire register in its detected byte order, without a read-modify-write:
+ * reading or writing a FIFO register must perform exactly one transaction.
*/
-static inline void xiic_setreg8(struct xiic_i2c *i2c, int reg, u8 value)
+static void xiic_setreg32(struct xiic_i2c *i2c, int reg, int value)
{
if (i2c->endianness == LITTLE)
- iowrite8(value, i2c->base + reg);
+ iowrite32(value, i2c->base + reg);
else
- iowrite8(value, i2c->base + reg + 3);
+ iowrite32be(value, i2c->base + reg);
}
-static inline u8 xiic_getreg8(struct xiic_i2c *i2c, int reg)
+static int xiic_getreg32(struct xiic_i2c *i2c, int reg)
{
- u8 ret;
+ u32 ret;
if (i2c->endianness == LITTLE)
- ret = ioread8(i2c->base + reg);
+ ret = ioread32(i2c->base + reg);
else
- ret = ioread8(i2c->base + reg + 3);
+ ret = ioread32be(i2c->base + reg);
return ret;
}
-static inline void xiic_setreg16(struct xiic_i2c *i2c, int reg, u16 value)
+static void xiic_setreg8(struct xiic_i2c *i2c, int reg, u8 value)
{
+ if (i2c->force_32bit_access) {
+ xiic_setreg32(i2c, reg, value);
+ return;
+ }
+
if (i2c->endianness == LITTLE)
- iowrite16(value, i2c->base + reg);
+ iowrite8(value, i2c->base + reg);
else
- iowrite16be(value, i2c->base + reg + 2);
+ iowrite8(value, i2c->base + reg + 3);
}
-static inline void xiic_setreg32(struct xiic_i2c *i2c, int reg, int value)
+static u8 xiic_getreg8(struct xiic_i2c *i2c, int reg)
{
+ u8 ret;
+
+ if (i2c->force_32bit_access)
+ return xiic_getreg32(i2c, reg);
+
if (i2c->endianness == LITTLE)
- iowrite32(value, i2c->base + reg);
+ ret = ioread8(i2c->base + reg);
else
- iowrite32be(value, i2c->base + reg);
+ ret = ioread8(i2c->base + reg + 3);
+ return ret;
}
-static inline int xiic_getreg32(struct xiic_i2c *i2c, int reg)
+static void xiic_setreg16(struct xiic_i2c *i2c, int reg, u16 value)
{
- u32 ret;
+ if (i2c->force_32bit_access) {
+ xiic_setreg32(i2c, reg, value);
+ return;
+ }
if (i2c->endianness == LITTLE)
- ret = ioread32(i2c->base + reg);
+ iowrite16(value, i2c->base + reg);
else
- ret = ioread32be(i2c->base + reg);
- return ret;
+ iowrite16be(value, i2c->base + reg + 2);
}
static inline void xiic_irq_dis(struct xiic_i2c *i2c, u32 mask)
@@ -1480,6 +1498,8 @@ static int xiic_i2c_probe(struct platform_device *pdev)
return irq;
pdata = dev_get_platdata(dev);
+ if (pdata)
+ i2c->force_32bit_access = pdata->force_32bit_access;
/* hook up driver to tree */
platform_set_drvdata(pdev, i2c);
diff --git a/include/linux/platform_data/i2c-xiic.h b/include/linux/platform_data/i2c-xiic.h
index 2e3683c23..afad9a49c 100644
--- a/include/linux/platform_data/i2c-xiic.h
+++ b/include/linux/platform_data/i2c-xiic.h
@@ -16,6 +16,8 @@
* @num_devices: Number of devices that shall be added when the driver
* is probed.
* @devices: The actuall devices to add.
+ * @force_32bit_access: Use aligned 32-bit accesses even for byte and
+ * halfword payloads on bridges without subword I/O.
*
* This purpose of this platform data struct is to be able to provide a number
* of devices that should be added to the I2C bus. The reason is that sometimes
@@ -26,6 +28,7 @@
struct xiic_i2c_platform_data {
u8 num_devices;
struct i2c_board_info const *devices;
+ bool force_32bit_access;
};
#endif /* _LINUX_I2C_XIIC_H */
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH net-next v2 2/3] i2c: xiic: add KUnit coverage for register access modes
2026-11-12 16:33 [PATCH net-next v2 0/3] ptp: ocp: support the WiWi production Time Card Ahmad Byagowi
2026-11-12 16:33 ` [PATCH net-next v2 1/3] i2c: xiic: allow platforms to require 32-bit register accesses Ahmad Byagowi
@ 2026-11-12 16:33 ` Ahmad Byagowi
1 sibling, 0 replies; 3+ messages in thread
From: Ahmad Byagowi @ 2026-11-12 16:33 UTC (permalink / raw)
To: netdev, vadim.fedorenko, andi.shyti
Cc: linux-i2c, Michal Simek, linux-kernel, linux-arm-kernel
Exercise the driver's private register accessors with memory-backed
registers instead of physical hardware. Cover native byte/halfword and
forced 32-bit accesses in both register byte orders, across 22 register
offsets. Check payload truncation, high-bit values and neighboring
sentinels. These tests do not validate physical bus transaction widths
or hardware interrupt behavior.
Include the tests in the driver translation unit so no accessors need
to become exported interfaces. Require built-in KUnit to avoid a
built-in driver depending on a modular test framework. The tests follow
the driver into either its built-in image or module.
The four parameterized cases passed in an isolated x86-64 QEMU boot
with networking disabled and no physical-device passthrough.
Tool-origin disclosure, as required by generated-content.rst: Codex was
used to implement this test suite, run the KUnit build/boot and draft
this changelog, in response to a request for upstream-quality testing.
Signed-off-by: Ahmad Byagowi <ahmadexp@gmail.com>
---
MAINTAINERS | 1 +
drivers/i2c/busses/Kconfig | 14 ++++
drivers/i2c/busses/i2c-xiic.c | 4 +
drivers/i2c/busses/tests/i2c_xiic_kunit.c | 91 +++++++++++++++++++++++
4 files changed, 110 insertions(+)
create mode 100644 drivers/i2c/busses/tests/i2c_xiic_kunit.c
diff --git a/MAINTAINERS b/MAINTAINERS
index 893b0670a..64fa74c40 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4018,6 +4018,7 @@ F: drivers/cpuidle/cpuidle-zynq.c
F: drivers/edac/synopsys_edac.c
F: drivers/i2c/busses/i2c-cadence.c
F: drivers/i2c/busses/i2c-xiic.c
+F: drivers/i2c/busses/tests/i2c_xiic_kunit.c
F: drivers/mmc/host/sdhci-of-arasan.c
N: zynq
N: xilinx
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 275aaa7f3..014281fa2 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -1322,6 +1322,20 @@ config I2C_XILINX
This driver can also be built as a module. If so, the module
will be called xilinx_i2c.
+config I2C_XILINX_KUNIT_TEST
+ bool "KUnit tests for Xilinx I2C register accesses" if !KUNIT_ALL_TESTS
+ depends on I2C_XILINX && KUNIT=y
+ 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. KUnit is a kernel
+ unit testing framework. These tests use memory-backed registers and
+ do not require an I2C controller.
+
+ The tests are compiled into the driver to exercise its private
+ accessors, and follow the driver's built-in or module configuration.
+ If unsure, say N.
+
config I2C_XLP9XX
tristate "Cavium ThunderX2 I2C support"
depends on ARCH_THUNDER2 || COMPILE_TEST
diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c
index 8425a540f..6c0f04aaa 100644
--- a/drivers/i2c/busses/i2c-xiic.c
+++ b/drivers/i2c/busses/i2c-xiic.c
@@ -1650,3 +1650,7 @@ MODULE_ALIAS("platform:" DRIVER_NAME);
MODULE_AUTHOR("info@mocean-labs.com");
MODULE_DESCRIPTION("Xilinx I2C bus driver");
MODULE_LICENSE("GPL v2");
+
+#if IS_ENABLED(CONFIG_I2C_XILINX_KUNIT_TEST)
+#include "tests/i2c_xiic_kunit.c"
+#endif
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 000000000..b4c818d8b
--- /dev/null
+++ b/drivers/i2c/busses/tests/i2c_xiic_kunit.c
@@ -0,0 +1,91 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/* Included by i2c-xiic.c to exercise the driver's private accessors. */
+#include <kunit/test.h>
+
+struct xiic_access_param {
+ const char *name;
+ enum xiic_endian endianness;
+ bool force_32bit_access;
+};
+
+static const struct xiic_access_param xiic_access_params[] = {
+ { "native_little_endian", LITTLE, false },
+ { "native_big_endian", BIG, false },
+ { "word_little_endian", LITTLE, true },
+ { "word_big_endian", BIG, true },
+};
+
+KUNIT_ARRAY_PARAM_DESC(xiic_access, xiic_access_params, name);
+
+static void xiic_register_access(struct kunit *test)
+{
+ static const int offsets[] = {
+ XIIC_DGIER_OFFSET, XIIC_IISR_OFFSET, XIIC_IIER_OFFSET,
+ XIIC_RESETR_OFFSET, XIIC_CR_REG_OFFSET, XIIC_SR_REG_OFFSET,
+ XIIC_DTR_REG_OFFSET, XIIC_DRR_REG_OFFSET, XIIC_ADR_REG_OFFSET,
+ XIIC_TFO_REG_OFFSET, XIIC_RFO_REG_OFFSET, XIIC_TBA_REG_OFFSET,
+ XIIC_RFD_REG_OFFSET, XIIC_GPO_REG_OFFSET,
+ XIIC_TSUSTA_REG_OFFSET, XIIC_TSUSTO_REG_OFFSET,
+ XIIC_THDSTA_REG_OFFSET,
+ XIIC_TSUDAT_REG_OFFSET, XIIC_TBUF_REG_OFFSET,
+ XIIC_THIGH_REG_OFFSET, XIIC_TLOW_REG_OFFSET,
+ XIIC_THDDAT_REG_OFFSET,
+ };
+ const struct xiic_access_param *param = test->param_value;
+ struct xiic_i2c *i2c;
+ u32 expected;
+ u8 *mem;
+ size_t i;
+ int reg;
+
+ i2c = kunit_kzalloc(test, sizeof(*i2c), GFP_KERNEL);
+ KUNIT_ASSERT_NOT_NULL(test, i2c);
+ mem = kunit_kmalloc(test, 0x200, GFP_KERNEL);
+ KUNIT_ASSERT_NOT_NULL(test, mem);
+ /* Aligned RAM stands in for MMIO. No hardware is accessed. */
+ i2c->base = (void __force __iomem *)(mem + sizeof(u32));
+ i2c->endianness = param->endianness;
+ i2c->force_32bit_access = param->force_32bit_access;
+
+ 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);
+
+ xiic_setreg16(i2c, reg, 0x03ff);
+ expected = param->force_32bit_access ? 0x03ff : 0xa5a503ff;
+ KUNIT_EXPECT_EQ(test, (u32)xiic_getreg32(i2c, reg), expected);
+ KUNIT_EXPECT_EQ(test, xiic_getreg8(i2c, reg), (u8)0xff);
+
+ xiic_setreg32(i2c, reg, 0x12345678);
+ KUNIT_EXPECT_EQ(test, (u32)xiic_getreg32(i2c, reg),
+ 0x12345678U);
+ KUNIT_EXPECT_EQ(test, xiic_getreg8(i2c, reg), (u8)0x78);
+ KUNIT_EXPECT_EQ(test, mem[reg + sizeof(u32)],
+ (u8)(param->endianness == BIG ? 0x12 : 0x78));
+ KUNIT_EXPECT_EQ(test, mem[reg + sizeof(u32) + 3],
+ (u8)(param->endianness == BIG ? 0x78 : 0x12));
+ xiic_setreg32(i2c, reg, 0x89abcdefU);
+ KUNIT_EXPECT_EQ(test, (u32)xiic_getreg32(i2c, reg),
+ 0x89abcdefU);
+ KUNIT_EXPECT_EQ(test, xiic_getreg8(i2c, reg), (u8)0xef);
+ KUNIT_EXPECT_EQ(test, mem[reg + sizeof(u32) - 1], (u8)0xa5);
+ KUNIT_EXPECT_EQ(test, mem[reg + 2 * sizeof(u32)], (u8)0xa5);
+ }
+}
+
+static struct kunit_case xiic_access_test_cases[] = {
+ KUNIT_CASE_PARAM(xiic_register_access, xiic_access_gen_params),
+ {}
+};
+
+static struct kunit_suite xiic_access_test_suite = {
+ .name = "i2c_xiic",
+ .test_cases = xiic_access_test_cases,
+};
+
+kunit_test_suite(xiic_access_test_suite);
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-12 16:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-12 16:33 [PATCH net-next v2 0/3] ptp: ocp: support the WiWi production Time Card Ahmad Byagowi
2026-11-12 16:33 ` [PATCH net-next v2 1/3] i2c: xiic: allow platforms to require 32-bit register accesses Ahmad Byagowi
2026-11-12 16:33 ` [PATCH net-next v2 2/3] i2c: xiic: add KUnit coverage for register access modes Ahmad Byagowi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox