Skip to contentSkip to conversation

ptp: ocp: add TAP CPLD support for ADVA TimeCard X1

PATCH Superseded Sagi Maimon 2 participants 8 messages Sep 14 – Sep 16

Subsystems (6)

v14 of 15 Superseded Latest is v15 →

lore
Share & tools
lore
#0 lore raw

v14 cover ptp: ocp: add TAP CPLD support for ADVA TimeCard X1

The ADVA TimeCard X1 (PCI device 0x0410) carries a Lattice MachXO3 CPLD on the TMC I2C bus. This series adds access to it and an update path through devlink flash.

The card has two I2C controllers. Linux registers only the one at 0x00150000, normally routed to the config EEPROMs; the one at 0x00120000 belongs to the on-card MicroBlaze and is routed to the TMC or M.2 bus as its firmware selects. A request/grant handshake re-routes the host controller onto the TMC bus, where the PCA9548 and the CPLD behind its channel 0 live. Everything here is built on that handshake.

Patches 1 and 2 are pre-existing probe-error-path bugs that were buried in the feature commit in v13; they are split out with Fixes: tags, as requested. Patch 1 is also a prerequisite: patch 3 adds a mutex that ptp_ocp_detach() destroys, so devlink has to be unregistered first. Patch 3 adds the bus arbitration and the read-only interfaces, patch 4 the flashing.

v13: https://lore.kernel.org/netdev/[email protected]/T/#u

Changes since v13:

- The CPLD is no longer flashed through the firmware-upload subsystem. It is a devlink flash component instead:

devlink dev flash pci/0000:02:00.0 file cpld.bin component fw.cpld

->info_get() reports fw.cpld as a running version with DEVLINK_INFO_VERSION_TYPE_COMPONENT, carrying the USERCODE of the image in the part, which is also what makes the core accept the component name. No component still means the card flash. This removed fw_upload_ops, the adva-cpld.N node, the FW_LOADER/FW_UPLOAD selects and the cancellation state machine - and with it a race where a cancel arriving after one upload finished could abort the next. Patch 4. (Jakub Kicinski)
- cpld_status now contains the names of the flags that are set, space separated, and an empty line when none is, instead of "done=<0|1> busy=<0|1> failed=<0|1>". Patch 3. (Jakub Kicinski)
- The commit was split; the two pre-existing fixes it contained are patches 1 and 2 with Fixes: tags. (Jakub Kicinski)
- The flash path now validates the state after REFRESH - DONE set, not busy, and no sysCONFIG error - and fails the devlink command rather than reporting success for an image that did not come back. Patch 4.
- adva_x1_mblaze_release() waits for the firmware to drop the grant instead of writing RELEASE and returning, and warns if it does not. Patch 3.
- The i2c bus notifier only caches the adapter number for the card's own controller, not for an i2c-mux child registered on it. The adapter is also resolved once from probe, because the notifier fires from inside platform_device_register() - before bp->i2c_ctrl is assigned - whenever the i2c controller driver is already loaded. Patch 3.
- ptp_ocp_devlink_info_get() checks bp->has_cpld explicitly rather than relying on cpld_id being zero on boards without one. Patch 3.
- ptp_ocp_sync_work() no longer latches the one-shot ID read on -EBUSY, so a read that collided with a CPLD operation is retried. Patch 3.
- Documentation/networking/devlink/ptp_ocp.rst documents the flash components and states the accepted image format: a raw bitstream, a whole number of 16-byte pages; .jed and other containers are rejected. Patch 4.

Tested on an ADVA TimeCard X1: a full erase/program/refresh cycle of a 6526-page image through "devlink dev flash ... component fw.cpld", the CPLD reporting done afterwards and still done across a reboot, and both rejection paths (a .jed image, and an unknown component name).

Sagi Maimon (4):
ptp: ocp: unregister devlink before detach on probe error
ptp: ocp: fix dpll cleanup on probe error
ptp: ocp: add TAP CPLD access for ADVA TimeCard X1
ptp: ocp: add TAP CPLD flashing via devlink

 Documentation/ABI/testing/sysfs-timecard     |  28 +
 Documentation/networking/devlink/index.rst   |   1 +
 Documentation/networking/devlink/ptp_ocp.rst |  70 ++
 MAINTAINERS                                  |   1 +
 drivers/ptp/ptp_ocp.c                        | 774 ++++++++++++++++++-
 5 files changed, 868 insertions(+), 6 deletions(-)
 create mode 100644 Documentation/networking/devlink/ptp_ocp.rst

base-commit: 879e280b8486d4612ad1aa050d6fada2dd80cf1c

Signature · 1 line
2.47.0
#1 lore raw

PATCH v14 1/4 ptp: ocp: unregister devlink before detach on probe error

devlink_register() runs before the dpll setup in ptp_ocp_probe(), but the failure paths after it went straight to ptp_ocp_detach() and then devlink_free(), which opens with ASSERT_DEVLINK_NOT_REGISTERED(devlink). Any dpll failure during probe therefore freed a devlink instance that was still registered.

Route those paths through a new out_devlink label that unregisters first, matching the order ptp_ocp_remove() already uses.

Fixes 09eeb3aecc6c ("ptp_ocp: implement DPLL ops")
---
 drivers/ptp/ptp_ocp.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/ptp/ptp_ocp.c +4 -2
index 3d26ec1f7b9e..401b04f12d2b 100644
@@ -5119,12 +5119,12 @@ ptp_ocp_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	if (IS_ERR(bp->dpll)) {
 		err = PTR_ERR(bp->dpll);
 		dev_err(&pdev->dev, "dpll_device_alloc failed\n");
-		goto out;
+		goto out_devlink;
 	}
 
 	err = dpll_device_register(bp->dpll, DPLL_TYPE_PPS, &dpll_ops, bp);
 	if (err)
-		goto out;
+		goto out_devlink;
 
 	for (i = 0; i < OCP_SMA_NUM; i++) {
 		bp->sma[i].dpll_pin = dpll_pin_get(clkid, i, THIS_MODULE,
@@ -5151,6 +5151,8 @@ ptp_ocp_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 		dpll_pin_put(bp->sma[i].dpll_pin, &bp->sma[i].tracker);
 	}
 	dpll_device_put(bp->dpll, &bp->tracker);
+out_devlink:
+	devlink_unregister(devlink);
 out:
 	ptp_ocp_detach(bp);
 out_disable:
Signature · 1 line
2.47.0
#2 lore raw

PATCH v14 2/4 ptp: ocp: fix dpll cleanup on probe error

In reply to Sagi Maimon

Two problems on the dpll error paths in ptp_ocp_probe().

dpll_device_register() takes a second reference and stores bp as the registration private data, and only dpll_device_unregister() drops it. out_dpll dropped bp->tracker but never unregistered, so a dpll_pin_get() or dpll_pin_register() failure left the device registered and visible to userspace with a priv pointer into the storage devlink_free() releases a few lines later, as well as leaking the registration object.

A failing dpll_device_register() jumped to the same label as the failing dpll_device_get(), so the reference taken by dpll_device_get() was never dropped either. Give that case its own label.

Fixes 09eeb3aecc6c ("ptp_ocp: implement DPLL ops")
---
 drivers/ptp/ptp_ocp.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/ptp/ptp_ocp.c +7 -1
index 401b04f12d2b..f4299878c27c 100644
@@ -5124,7 +5124,7 @@ ptp_ocp_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 
 	err = dpll_device_register(bp->dpll, DPLL_TYPE_PPS, &dpll_ops, bp);
 	if (err)
-		goto out_devlink;
+		goto out_dpll_put;
 
 	for (i = 0; i < OCP_SMA_NUM; i++) {
 		bp->sma[i].dpll_pin = dpll_pin_get(clkid, i, THIS_MODULE,
@@ -5150,6 +5150,12 @@ ptp_ocp_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 		dpll_pin_unregister(bp->dpll, bp->sma[i].dpll_pin, &dpll_pins_ops, &bp->sma[i]);
 		dpll_pin_put(bp->sma[i].dpll_pin, &bp->sma[i].tracker);
 	}
+	/* dpll_device_register() takes a second reference and stores bp; only
+	 * dpll_device_unregister() drops it.  Without this the device stays
+	 * visible with a priv pointer into storage devlink_free() will release.
+	 */
+	dpll_device_unregister(bp->dpll, &dpll_ops, bp);
+out_dpll_put:
 	dpll_device_put(bp->dpll, &bp->tracker);
 out_devlink:
 	devlink_unregister(devlink);
Signature · 1 line
2.47.0
#3 lore raw

PATCH v14 3/4 ptp: ocp: add TAP CPLD access for ADVA TimeCard X1

In reply to Sagi Maimon

The ADVA TimeCard X1 carries a Lattice MachXO3 CPLD on its TMC I2C bus. Reaching it means taking that bus from the on-card MicroBlaze first.

The card has two I2C controllers. Linux registers only the one at 0x00150000, normally routed to the config EEPROMs; the one at 0x00120000 belongs to the MicroBlaze and is routed to the TMC or M.2 bus as its firmware selects. A request/grant handshake re-routes the host controller onto the TMC bus, where the PCA9548 and the CPLD behind its channel 0 live. An operation takes the i2c core adapter lock for the whole grant window and uses __i2c_transfer() internally; without that, a concurrent transfer from ptp_ocp_read_eeprom(), from the nvmem attributes or from the at24 sysfs files would be issued onto the TMC bus instead of to the EEPROM. The hand-back waits for the firmware to drop the grant before the adapter lock is released, for the same reason.

On top of the arbitration this adds two read-only interfaces: a root-only cpld_status attribute reporting the flags in the CPLD status register, and the Lattice device ID as the fixed devlink version cpld.id. Reading the ID claims the bus, so it must not sit on DEVLINK_CMD_INFO_GET, which carries no GENL_ADMIN_PERM; the driver reads it once from its own worker, as soon as the i2c adapter has registered, and info_get() reports the cached value.

---
 Documentation/ABI/testing/sysfs-timecard     |  24 +
 Documentation/networking/devlink/index.rst   |   1 +
 Documentation/networking/devlink/ptp_ocp.rst |  35 ++
 MAINTAINERS                                  |   1 +
 drivers/ptp/ptp_ocp.c                        | 447 ++++++++++++++++++-
 5 files changed, 504 insertions(+), 4 deletions(-)
 create mode 100644 Documentation/networking/devlink/ptp_ocp.rst
Documentation/ABI/testing/sysfs-timecard +24 -0
index 3ae41b7634ac..c440d8930384 100644
@@ -11,6 +11,30 @@ Contact:	Jonathan Lemon <[email protected]>
 Description:	This directory contains the attributes of the Nth timecard
 		registered.
 
+What:		/sys/class/timecard/ocpN/cpld_status
+Date:		July 2026
+Contact:	Sagi Maimon <[email protected]>
+Description:	(RO, root only) The flags set in the status register of the
+		TAP CPLD, space separated, or an empty line when none is
+		set.  Only present on ADVA x1 TAP boards (PCI ID
+		0xad5a:0x0410).
+
+		==========  ================================================
+		done        the configuration flash was programmed
+			    successfully and is active
+		busy        an internal operation is in progress
+		failed      the last ISC operation failed
+		==========  ================================================
+
+		For example "busy" while programming, or "busy failed" if a
+		failure is latched while another operation runs.
+
+		A read arbitrates for the shared I2C bus and reprograms the
+		on-card mux, so it is restricted to root.  The Lattice device
+		ID of the CPLD is read once by the driver, shortly after
+		probe, and reported from that cached value as the fixed
+		"cpld.id" version by devlink dev info.
+
 What:		/sys/class/timecard/ocpN/available_clock_sources
 Date:		September 2021
 Contact:	Jonathan Lemon <[email protected]>
Documentation/networking/devlink/index.rst +1 -0
index d4a83fdcff7f..1af780c811ee 100644
@@ -99,6 +99,7 @@ parameters, info versions, and other features it supports.
    nfp
    octeontx2
    prestera
+   ptp_ocp
    qed
    sfc
    stmmac
Documentation/networking/devlink/ptp_ocp.rst new file +35 -0
new file mode 100644
index 000000000000..3f997cd9f3a3
@@ -0,0 +1,35 @@
+.. SPDX-License-Identifier: GPL-2.0
+
+========================
+ptp_ocp devlink support
+========================
+
+This document describes the devlink features implemented by the ``ptp_ocp``
+device driver.
+
+Info versions
+=============
+
+The ``ptp_ocp`` driver reports the following versions
+
+.. list-table:: devlink info versions implemented
+   :widths: 5 5 90
+
+   * - Name
+     - Type
+     - Description
+   * - ``fw``
+     - running
+     - Version of the firmware running on the card.  Reported as ``loader``
+       instead when the card is running the firmware loader.
+   * - ``board.id``
+     - fixed
+     - Board identifier, read from the on-card EEPROM.
+   * - ``cpld.id``
+     - fixed
+     - Lattice device ID (IDCODE) of the TAP CPLD, formatted as ``0x%08x``.
+       Only present on ADVA TimeCard X1 boards, which are the only ones
+       carrying that CPLD.  Reading it claims the shared I2C bus and
+       reprograms the on-card mux, so the driver does that once from its
+       own worker and reports the cached value here; the version is
+       omitted until that read has succeeded.
MAINTAINERS +1 -0
index 0e04d92d1b09..113f31434617 100644
@@ -20479,6 +20479,7 @@ OPENCOMPUTE PTP CLOCK DRIVER
 M:	Vadim Fedorenko <[email protected]>
 L:	[email protected]
 S:	Maintained
+F:	Documentation/networking/devlink/ptp_ocp.rst
 F:	drivers/ptp/ptp_ocp.c
 
 OPENCORES I2C BUS DRIVER
drivers/ptp/ptp_ocp.c +443 -4

555 lines not on this page · raw message

Signature · 1 line
2.47.0
#4 lore raw

Re: [PATCH net-next v14 3/4] ptp: ocp: add TAP CPLD access for ADVA TimeCard X1

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:

Critical: 0 · High: 0 · Medium: 2 · Low: 1

- [Medium] adva_x1_mblaze_release() (drivers/ptp/ptp_ocp.c:4375-4393) documents and the changelog promises that the hand-back "waits for the…
- [Medium] The firmware hand-back failure is swallowed.
- [Low] Forward-referencing leftovers in this intermediate patch:
#include <linux/iopoll.h> is added at drivers/ptp/ptp_ocp.c:23 with no…

--

ptp: ocp: add TAP CPLD access for ADVA TimeCard X1

This adds a request/grant handshake that re-routes the registered i2c controller of the ADVA TimeCard X1 from the config EEPROMs onto the TMC bus, so the Lattice CPLD behind the PCA9548 can be reached. On top of it the patch exposes a root-only cpld_status sysfs attribute and reports the cached Lattice device ID as the fixed devlink version cpld.id.

Quoted 5 lines
Documentation/ABI/testing/sysfs-timecard +0 -0
index 3ae41b7634ac..c440d8930384 100644

Documentation/ABI/testing/sysfs-timecard Contact: Jonathan Lemon <[email protected]> · line 19

Quoted 9 lines
Documentation/ABI/testing/sysfs-timecard +9 -0
@@ -11,6 +11,30 @@ Contact:	Jonathan Lemon <[email protected]>
+		==========  ================================================
+		done        the configuration flash was programmed
+			    successfully and is active
+		busy        an internal operation is in progress
+		failed      the last ISC operation failed
+		==========  ================================================
+
+		For example "busy" while programming, or "busy failed" if a
+		failure is latched while another operation runs.

[Severity: Low]
This isn't a bug, but the flag descriptions here are phrased in terms of programming the part ("the configuration flash was programmed successfully", "busy while programming"), while this commit only defines CPLD_CMD_READ_ID and CPLD_CMD_READ_STATUS and cannot program anything.

The same forward reference shows up in the code, see the two comments below. The follow-up patch in this series, "ptp: ocp: add TAP CPLD flashing via devlink", is what adds the page-programming commands, the read_poll_timeout() users and the fw.cpld component, so everything is live at the end of the series. Would it read better to move the upload-referencing wording and the iopoll.h include into that patch?

[ ... ]

drivers/ptp/ptp_ocp.c line 23

Quoted 9 lines
drivers/ptp/ptp_ocp.c +1 -0
index f4299878c27c..98cb26077181 100644
@@ -20,10 +20,14 @@
 #include <linux/spi/altera.h>
 #include <net/devlink.h>
 #include <linux/i2c.h>
+#include <linux/iopoll.h>

[Severity: Low]
Is there a user for this include at this commit? Grepping the file for poll_timeout matches only this line; the first *_poll_timeout() caller (adva_x1_cpld_wait_idle()) arrives with the flashing patch.

Quoted 7 lines
drivers/ptp/ptp_ocp.c +3 -0
 #include <linux/mtd/mtd.h>
 #include <linux/nvmem-consumer.h>
 #include <linux/crc16.h>
 #include <linux/dpll.h>
+#include <linux/unaligned.h>
+#include <linux/delay.h>
+#include <linux/firmware.h>

[ ... ]

Quoted 16 lines
drivers/ptp/ptp_ocp.c +12 -0
@@ -4226,6 +4266,367 @@ static const struct ocp_attr_group art_timecard_groups[] = {
 	{ },
 };
 
+#define ADVA_MUX_ADDR     0x74
+#define ADVA_CPLD_ADDR    0x40
+#define ADVA_MUX_CHANNEL  0
+
+/* Longest command or reply; bounds each half of the per-claim scratch. */
+#define ADVA_CPLD_XFER_MAX 32
+
+#define MBLAZE_REQUEST    0x0000aaaaU
+#define MBLAZE_GRANTED    0x5555aaaaU
+#define MBLAZE_RELEASE    0x55550000U
+#define MBLAZE_RETRIES    200
+#define MBLAZE_RETRY_US   10000

[ ... ]

Quoted 5 lines

+/*
+ * Issue one I2C transaction on the TMC bus: @cmd if not negative, then
+ * @wlen bytes of @wdata (NULL sends zeros), then @rlen bytes read back.
+ * The message is built in the scratch buffer from adva_x1_bus_claim(), so
+ * an upload costs one allocation rather than one per page. I2C_M_DMA_SAFE

[Severity: Low]
This isn't a bug, but the "upload costs one allocation rather than one per page" rationale refers to an image upload path that does not exist until the next patch.

Quoted 3 lines

+ * is not set: the two halves are not separately aligned, so let the core
+ * bounce. Caller holds the claim, hence __i2c_transfer().
+ */

[ ... ]

Quoted 11 lines
drivers/ptp/ptp_ocp.c +11 -0
+/* Hand the segment back, and wait for the firmware to drop the grant before
+ * the caller unlocks the adapter: a transfer queued behind us would
+ * otherwise be clocked out while the controller is still on the TMC bus,
+ * which is what holding the adapter lock across the grant exists to stop.
+ */
+static void adva_x1_mblaze_release(struct ptp_ocp *bp)
+{
+	int i;
+
+	if (!bp->pps_select)
+		return;

drivers/ptp/ptp_ocp.c static const struct ocp_attr_group art_timecard_groups[] = { · line 4390

Quoted 10 lines
drivers/ptp/ptp_ocp.c +10 -0
+
+	iowrite32(MBLAZE_RELEASE, &bp->pps_select->i2c_bus_ctrl);
+	/* Flush the posted write, as the acquire path does. */
+	ioread32(&bp->pps_select->i2c_bus_ctrl);
+
+	for (i = 0; i < MBLAZE_RETRIES; i++) {
+		if (ioread32(&bp->pps_select->i2c_bus_ctrl) != MBLAZE_GRANTED)
+			return;
+		usleep_range(MBLAZE_RETRY_US, MBLAZE_RETRY_US + 1000);
+	}

[Severity: Medium]
Can this loop ever iterate?

The constants describe a register with a host-written half and a firmware-written half:

	#define MBLAZE_REQUEST    0x0000aaaaU		/* host half */
	#define MBLAZE_GRANTED    0x5555aaaaU		/* grant | request */
	#define MBLAZE_RELEASE    0x55550000U		/* grant, request cleared */

adva_x1_mblaze_release() writes MBLAZE_RELEASE first, which clears the host request half. After that write the register can read back 0x55550000 (grant still asserted) or 0x00000000, but not 0x5555aaaa, so the first ioread32() in the loop compares unequal to MBLAZE_GRANTED and returns.

If that is right, then the usleep_range() body, the MBLAZE_RETRIES/MBLAZE_RETRY_US budget and the "TMC bus still granted after release" warning below are all unreachable, and the hand-back the changelog describes:

"The hand-back waits for the firmware to drop the grant before the adapter lock is released, for the same reason."

does not happen. adva_x1_bus_release() then calls i2c_unlock_bus() immediately, so a transfer already queued behind the CPLD operation from ptp_ocp_read_eeprom(), the nvmem attributes or the at24 sysfs files can be clocked out while the host controller is still routed to the TMC bus.

Should the wait test the firmware-owned grant field on its own, for instance polling for the register to read 0 or masking off the request half before the comparison?

The same helper is the timeout cleanup in adva_x1_mblaze_acquire(), so a grant asserted just after the host gave up waiting is not observed either.

Both paths are reachable without user action: adva_x1_cpld_read_id() runs from ptp_ocp_sync_work() after probe, and cpld_status_show() is a root read of /sys/class/timecard/ocpN/cpld_status.

drivers/ptp/ptp_ocp.c static const struct ocp_attr_group art_timecard_groups[] = { · line 4393

Quoted 3 lines
drivers/ptp/ptp_ocp.c +3 -0
+
+	dev_warn(&bp->pdev->dev, "TMC bus still granted after release\n");
+}

[Severity: Medium]
If the wait can expire (that is, if the equality test above does work on real hardware), is losing the failure here intentional?

adva_x1_mblaze_release() returns void, so after the warning the caller cannot tell that the firmware never dropped the grant. Nothing records the condition, so the next claim re-runs the handshake as if the controller were back on the EEPROMs.

Note this and the question above are two sides of the same code: either the poll cannot iterate, or it can and its expiry is ignored.

[ ... ]

Quoted 7 lines
drivers/ptp/ptp_ocp.c +7 -0
+/* Route the host controller back to the EEPROMs and release the adapter.
+ * Safe after a failed claim: it also clears a request that was never granted.
+ */
+static void adva_x1_bus_release(struct ptp_ocp *bp)
+{
+	struct i2c_adapter *adap = bp->cpld_adap;
+

drivers/ptp/ptp_ocp.c static const struct ocp_attr_group art_timecard_groups[] = { · line 4441

Quoted 10 lines
drivers/ptp/ptp_ocp.c +10 -0
+	if (!adap)
+		return;
+
+	adva_x1_mblaze_release(bp);
+	bp->cpld_adap = NULL;
+	kfree(bp->cpld_buf);
+	bp->cpld_buf = NULL;
+	i2c_unlock_bus(adap, I2C_LOCK_ROOT_ADAPTER);
+	i2c_put_adapter(adap);
+}

[Severity: Medium]
Should i2c_unlock_bus()/i2c_put_adapter() run unconditionally when the hand-back may have failed?

Once the adapter is unlocked, ptp_ocp_read_eeprom(), the nvmem attributes and the at24 sysfs files address 0x50/0x58 again. With the controller still on the TMC segment those transfers either NAK, so has_eeprom_data stays false, or some TMC device answers and ptp_ocp_read_eeprom() latches a bogus serial/board_id; an at24 write would be clocked into an unrelated TMC device.

cpld_status_show() also returns the status word it read as a success in that case, and adva_x1_cpld_read_id() still publishes bp->cpld_id, so nothing surfaces the mis-routing to userspace.

[ ... ]

Quoted 7 lines
drivers/ptp/ptp_ocp.c +7 -0
+/*
+ * Claim the TMC bus.  The adapter lock is held across the handshake to keep
+ * the EEPROM, nvmem and at24 paths off the controller while it is routed
+ * away from the EEPROMs; an EEPROM read blocks until the claim is dropped.
+ */
+static int adva_x1_bus_claim(struct ptp_ocp *bp)
+{

[ ... ]

drivers/ptp/ptp_ocp.c static const struct ocp_attr_group art_timecard_groups[] = { · line 4498

Quoted 4 lines
drivers/ptp/ptp_ocp.c +4 -0
+	/* One scratch buffer per claim rather than per transfer: an upload
+	 * holds the claim for the whole image.
+	 */
+	bp->cpld_buf = kzalloc(2 * ADVA_CPLD_XFER_MAX, GFP_KERNEL);

[Severity: Low]
This isn't a bug, but same as above: the comment explains the allocation by an upload that holds the claim for a whole image, which only becomes true with the flashing patch.

Quoted 4 lines
drivers/ptp/ptp_ocp.c +4 -0
+	if (!bp->cpld_buf) {
+		i2c_put_adapter(adap);
+		return -ENOMEM;
+	}

drivers/ptp/ptp_ocp.c static const struct ocp_attr_group art_timecard_groups[] = { · line 4512

Quoted 10 lines
drivers/ptp/ptp_ocp.c +10 -0
+
+	i2c_lock_bus(adap, I2C_LOCK_ROOT_ADAPTER);
+	bp->cpld_adap = adap;
+
+	ret = adva_x1_mblaze_acquire(bp);
+	if (ret)
+		adva_x1_bus_release(bp);
+
+	return ret;
+}

[ ... ]

All three observations were checked against the last patch of the series (5c1c35566015); the release wait is unchanged there.

Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260914071555.11684-1-maimon.sagi%40gmail.com
#5 lore raw

PATCH v14 4/4 ptp: ocp: add TAP CPLD flashing via devlink

In reply to Sagi Maimon

The Lattice MachXO3 CPLD on the ADVA TimeCard X1 is programmed over I2C using in-system programming (ISP). Build on the TMC bus arbitration added previously and expose the update path as a devlink flash component, next to the card flash the driver already writes through devlink.

The component is named fw.cpld and reported as a running version, so ->info_get() both publishes the USERCODE of the image currently in the part and lets the core accept the name:

devlink dev flash pci/0000:02:00.0 file adva-cpld.bin component fw.cpld

Flashing acquires the bus, erases the configuration flash, programs the image page by page and activates it with the MachXO3 REFRESH command, reporting progress with the standard devlink notifications. The CPLD is required to come back with DONE set, not busy and no error code before the update is called successful, as drivers/fpga/machxo2-spi.c does.

The whole sequence runs under cpld_lock and the i2c adapter lock, so an EEPROM read blocks for as long as programming takes; the alternative is reading the TMC bus instead. Flashing is privileged:
DEVLINK_CMD_FLASH_UPDATE carries GENL_ADMIN_PERM.

---
 Documentation/ABI/testing/sysfs-timecard     |   4 +
 Documentation/networking/devlink/ptp_ocp.rst |  37 ++-
 drivers/ptp/ptp_ocp.c                        | 327 ++++++++++++++++++-
 3 files changed, 361 insertions(+), 7 deletions(-)
Documentation/ABI/testing/sysfs-timecard +4 -0
index c440d8930384..6ddca452bc63 100644
@@ -35,6 +35,10 @@ Description:	(RO, root only) The flags set in the status register of the
 		probe, and reported from that cached value as the fixed
 		"cpld.id" version by devlink dev info.
 
+		New CPLD firmware is programmed with devlink dev flash,
+		selecting the "fw.cpld" component; see
+		Documentation/networking/devlink/ptp_ocp.rst.
+
 What:		/sys/class/timecard/ocpN/available_clock_sources
 Date:		September 2021
 Contact:	Jonathan Lemon <[email protected]>
Documentation/networking/devlink/ptp_ocp.rst +36 -1
index 3f997cd9f3a3..37e9f1ebd1a8 100644
@@ -5,7 +5,7 @@ ptp_ocp devlink support
 ========================
 
 This document describes the devlink features implemented by the ``ptp_ocp``
-device driver.
+device driver: the info versions it reports and its flash update support.
 
 Info versions
 =============
@@ -33,3 +33,38 @@ The ``ptp_ocp`` driver reports the following versions
        reprograms the on-card mux, so the driver does that once from its
        own worker and reports the cached value here; the version is
        omitted until that read has succeeded.
+   * - ``fw.cpld``
+     - running
+     - USERCODE of the image programmed into the TAP CPLD, formatted as
+       ``0x%08x``.  Read together with ``cpld.id`` and reported the same
+       way.  This is the component name to pass to ``devlink dev flash``
+       to update the CPLD.
+
+Flash update
+============
+
+The driver implements ``devlink dev flash`` for two separate targets,
+selected with the component name.
+
+.. list-table:: Flash components
+   :widths: 20 80
+
+   * - Component
+     - Description
+   * - (none)
+     - The card's own flash, written through the SPI controller the driver
+       exposes.  The card runs the new image after its next reset.
+   * - ``fw.cpld``
+     - The configuration flash of the TAP CPLD on ADVA TimeCard X1 boards,
+       programmed over I2C with the MachXO3 in-system programming commands
+       and activated with a REFRESH, so the new image runs immediately.
+       The image is the raw configuration bitstream, a whole number of
+       16-byte pages; container formats such as ``.jed`` are rejected.
+
+Programming the CPLD claims the shared I2C bus for the whole cycle, so
+reads of the card's EEPROM block until it completes.  Progress is reported
+with the standard devlink status notifications.
+
+Example::
+
+    $ devlink dev flash pci/0000:02:00.0 file adva-cpld.bin component fw.cpld
drivers/ptp/ptp_ocp.c +321 -6

404 lines not on this page · raw message

Signature · 1 line
2.47.0
#6 lore raw

Re: [PATCH net-next v14 4/4] ptp: ocp: add TAP CPLD flashing via devlink

Thank you for your contribution! Sashiko AI review found 10 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 10 potential issue(s) to consider:

Critical: 0 · High: 0 · Medium: 7 · Low: 3

- [Medium] The fw.cpld flash component is only reachable while the cached CPLD identity is valid.
- [Medium] Documentation/networking/devlink/ptp_ocp.rst states for fw.cpld that "The image is the raw configuration bitstream, a whole…
- [Medium] bp->cpld_id / bp->cpld_usercode are invalidated only on the fully successful path of adva_x1_cpld_flash()…
- [Medium] In adva_x1_cpld_read_id() the newly added USERCODE transaction failing throws away the device ID that was already read…
- [Medium] adva_x1_cpld_exit_config() (drivers/ptp/ptp_ocp.c:4688-4703) discards the return value of `adva_x1_cpld_wait_idle(bp,…
- [Medium] adva_x1_cpld_flash() invalidates the cached CPLD identity (`WRITE_ONCE(bp->cpld_id, 0); WRITE_ONCE(bp->cpld_id_tried, false);…
- [Medium] The ISP sequence in adva_x1_cpld_flash() programs the configuration flash (EN_CFG_TP 0x74, ERASE 0x0E with operand 0x04 =…
- [Low] Inconsistent devlink error/status reporting between the two components of the same ->flash_update() implementation.
- [Low] The comment on adva_x1_cpld_wait_idle() (drivers/ptp/ptp_ocp.c:4665) says it waits "for BUSY to clear,…
- [Low] adva_x1_cpld_read_id() publishes cpld_usercode and then cpld_id with plain WRITE_ONCE() and documents the dependency…

--

ptp: ocp: add TAP CPLD flashing via devlink

This adds a devlink flash component named fw.cpld that programs the Lattice MachXO3 CPLD on ADVA TimeCard X1 boards over I2C using the in-system programming commands, then activates the image with REFRESH. The same patch starts reporting the image USERCODE as a running version from ->info_get(), which is also what makes the component name acceptable to the devlink core. A few questions below about the component gating, the cached identity and the configuration-mode exit path.

Quoted 4 lines
Documentation/networking/devlink/ptp_ocp.rst +0 -0
index 3f997cd9f3a3..37e9f1ebd1a8 100644

[ ... ]

Documentation/networking/devlink/ptp_ocp.rst The ``ptp_ocp`` driver reports the following versions · line 38

Quoted 7 lines
Documentation/networking/devlink/ptp_ocp.rst +6 -0
@@ -33,3 +33,38 @@ The ``ptp_ocp`` driver reports the following versions
+   * - ``fw.cpld``
+     - The configuration flash of the TAP CPLD on ADVA TimeCard X1 boards,
+       programmed over I2C with the MachXO3 in-system programming commands
+       and activated with a REFRESH, so the new image runs immediately.
+       The image is the raw configuration bitstream, a whole number of
+       16-byte pages; container formats such as ``.jed`` are rejected.

[Severity: Medium]
Where are container formats such as .jed rejected? The only validation in adva_x1_cpld_flash() is a length check:

	if (!fw->size || fw->size % CPLD_PAGE_SIZE) {
		NL_SET_ERR_MSG_MOD(extack,
				   "image must be a whole number of 16-byte pages");
		return -EINVAL;
	}

There is no format or container detection anywhere in the function, so a .jed or .bit file whose byte length happens to be a multiple of 16 passes, the configuration sector is erased by CPLD_CMD_ERASE and the container bytes are programmed as configuration frames. Should the documentation be narrowed to describe only the length check, or should the code inspect the image format?

Quoted 4 lines
drivers/ptp/ptp_ocp.c +0 -0
index 98cb26077181..58b90b2b282f 100644

[ ... ]

Quoted 18 lines
drivers/ptp/ptp_ocp.c +11 -0
@@ -2158,6 +2169,17 @@ ptp_ocp_devlink_flash_update(struct devlink *devlink,
 	const char *msg;
 	int err;
 
+	if (params->component) {
+		if (!bp->has_cpld ||
+		    strcmp(params->component, ADVA_CPLD_COMPONENT)) {
+			NL_SET_ERR_MSG_MOD(extack,
+					   "unsupported flash component");
+			return -EOPNOTSUPP;
+		}
+
+		return adva_x1_cpld_flash(bp, devlink, params->fw, extack);
+	}
+
 	dev = ptp_ocp_find_flash(bp);
 	if (!dev) {
 		dev_err(&bp->pdev->dev, "Can't find Flash SPI adapter\n");

[ ... ]

Quoted 5 lines
drivers/ptp/ptp_ocp.c +1 -0
@@ -2202,6 +2226,16 @@ ptp_ocp_devlink_info_get(struct devlink *devlink, struct devlink_info_req *req,
 		err = devlink_info_version_fixed_put(req, "cpld.id", buf);
 		if (err)
 			return err;
+

drivers/ptp/ptp_ocp.c ptp_ocp_devlink_info_get(struct devlink *devlink, struct devlink_info_req *req, · line 2239

Quoted 10 lines
drivers/ptp/ptp_ocp.c +9 -0
+		/* The flashable component: naming it here is what lets
+		 * "devlink dev flash ... component fw.cpld" through, as the
+		 * core matches the name against the versions reported here.
+		 */
+		sprintf(buf, "0x%08x", READ_ONCE(bp->cpld_usercode));
+		err = devlink_info_version_running_put_ext(req, "fw.cpld", buf,
+							   ver_type);
+		if (err)
+			return err;
 	}

[Severity: Medium]
Is the fw.cpld component reachable when the cached CPLD identity is not valid? The version is only emitted inside:

	id = READ_ONCE(bp->cpld_id);
	if (bp->has_cpld && id) {

and the core requires the name to have been reported:

net/devlink/dev.c:devlink_flash_component_get() {
	...
	if (!lookup_ctx.lookup_name_found) {
		NL_SET_ERR_MSG_ATTR(extack, nla_component,
				    "selected component is not supported by this device");
		return -EINVAL;
	}
	...
}

The handler above accepts the component on the weaker condition bp->has_cpld alone, so the two sides disagree and the -EOPNOTSUPP branch cannot be reached for a name the core already rejected.

Two states the driver creates itself leave cpld_id at 0:

- adva_x1_cpld_flash() ends its success path with WRITE_ONCE(bp->cpld_id, 0), so a flash issued before ptp_ocp_sync_work() manages the next read gets -EINVAL from the core.

- ptp_ocp_sync_work() abandons the one-shot read after CPLD_ID_MAX_ATTEMPTS non-EBUSY failures:

if (err != -EBUSY &&
(!err || ++bp->cpld_id_attempts >= CPLD_ID_MAX_ATTEMPTS))
WRITE_ONCE(bp->cpld_id_tried, true);

after which fw.cpld is never advertised again for the life of the binding, and the documented flash command is unavailable even though adva_x1_cpld_flash() would run.

Should the component be advertised independently of the cached identity, so that recovering from a bad image does not depend on a successful ID read?

[ ... ]

Quoted 17 lines
drivers/ptp/ptp_ocp.c +16 -0
@@ -4522,6 +4568,48 @@ static int adva_x1_mux_select(struct ptp_ocp *bp, int ch)
+static const u8 *adva_x1_cpld_args(u8 cmd, u8 *nargs)
+{
+	static const u8 en_cfg_tp[] = { 0x08, 0x00 };
+	/* cfg sector only */
+	static const u8 erase_cfg[] = { 0x04, 0x00, 0x00 };
+
+	switch (cmd) {
+	case CPLD_CMD_EN_CFG_TP:
+		*nargs = sizeof(en_cfg_tp);
+		return en_cfg_tp;
+	case CPLD_CMD_ERASE:
+		*nargs = sizeof(erase_cfg);
+		return erase_cfg;
+	case CPLD_CMD_RESET_ADDR:
+	case CPLD_CMD_SET_DONE:
+		*nargs = 3;

drivers/ptp/ptp_ocp.c static int adva_x1_mux_select(struct ptp_ocp *bp, int ch) · line 4593

Quoted 10 lines
drivers/ptp/ptp_ocp.c +10 -0
+		return NULL;
+	case CPLD_CMD_DIS_CFG:
+	case CPLD_CMD_REFRESH:
+		*nargs = 2;
+		return NULL;
+	default:
+		*nargs = 0;
+		return NULL;
+	}
+}

[Severity: Medium]
Where does the sequence program the USERCODE? This switch enumerates every ISC opcode the driver can emit and there is no ISC_PROGRAM_USERCODE (0xC2) entry, and adva_x1_cpld_flash() never writes a usercode either.

The USERCODE field lives in the configuration flash that CPLD_CMD_ERASE with operand { 0x04, 0x00, 0x00 } wipes, and it has its own read opcode (CPLD_CMD_READ_USERCODE, 0xC0). If the page writes issued with CPLD_CMD_WRITE_PAGE do not carry it, then the value read back by adva_x1_cpld_read_id() after a successful flash is the erased value rather than the USERCODE of the image just programmed.

That is the value the patch publishes as the fw.cpld running version, and the commit message describes it as "the USERCODE of the image currently in the part". Can you confirm whether the incremental program frames restore the usercode field on this part?

Quoted 1 line
drivers/ptp/ptp_ocp.c +0 -0
@@ -4547,14 +4635,82 @@ static int adva_x1_cpld_read_status(struct ptp_ocp *bp, u32 *status)

[ ... ]

drivers/ptp/ptp_ocp.c static int adva_x1_cpld_read_status(struct ptp_ocp *bp, u32 *status) · line 4669

Quoted 5 lines
drivers/ptp/ptp_ocp.c +5 -0
+/* Wait for BUSY to clear, ignoring a pending cancel.  An ISC command issued
+ * while the part is still erasing or programming may not latch, so an abort
+ * has to wait the operation out before it can leave configuration mode.
+ */
+static int adva_x1_cpld_wait_idle(struct ptp_ocp *bp, unsigned int max_ms)

[Severity: Low]
This isn't a bug, but what is the "pending cancel" the comment refers to? There is no cancel, abort or signal check anywhere in the CPLD code; a grep for cancel, signal_pending and fatal_signal in this file finds only this comment, an unrelated flash status string and cancel_delayed_work_sync() in ptp_ocp_remove().

adva_x1_cpld_wait_ready() is equally uninterruptible; the only actual difference is that it also treats CPLD_STATUS_FAILED as an error, which the comment does not mention. Could the comment state that difference instead?

Quoted 10 lines
drivers/ptp/ptp_ocp.c +10 -0
+/* Leave transparent configuration mode.  cpld_in_config_mode stays set when
+ * DIS_CFG does not get through, so a later cleanup() tries again rather than
+ * recording an exit that never happened.
+ */
+static void adva_x1_cpld_exit_config(struct ptp_ocp *bp)
+{
+	int err;
+
+	if (!bp->cpld_in_config_mode)
+		return;

drivers/ptp/ptp_ocp.c static int adva_x1_cpld_read_status(struct ptp_ocp *bp, u32 *status) · line 4703

Quoted 10 lines
drivers/ptp/ptp_ocp.c +10 -0
+
+	adva_x1_cpld_wait_idle(bp, CPLD_ERASE_MS);
+
+	err = adva_x1_cpld_write(bp, CPLD_CMD_DIS_CFG);
+	if (err)
+		dev_warn(&bp->pdev->dev,
+			 "CPLD left in configuration mode: %d\n", err);
+	else
+		bp->cpld_in_config_mode = false;
+}

[Severity: Medium]
Which "later cleanup()" retries the exit? bp->cpld_in_config_mode is read only by this function, and its only caller is adva_x1_cpld_flash(). ptp_ocp_remove()/ptp_ocp_detach(), cpld_status_show() and adva_x1_cpld_read_id() never look at it, so when DIS_CFG returns an error the flag stays set and nothing ever sends it again - the part can stay latched in transparent configuration mode across module unload.

The discarded return value looks related: if adva_x1_cpld_wait_idle(bp, CPLD_ERASE_MS) timed out with the part still BUSY, then by this function's own reasoning the DIS_CFG opcode probably did not latch, yet an ACKed write still clears cpld_in_config_mode. Should the wait_idle() result gate the flag update, and should the teardown path attempt the release?

Quoted 2 lines

/*
- * Read the Lattice device ID into bp->cpld_id. Done once, off the

[ ... ]

Quoted 10 lines

static int adva_x1_cpld_read_id(struct ptp_ocp *bp) {

drivers/ptp/ptp_ocp.c +1 -0
+	u32 id, usercode;
 	u8 data[4];
 	int ret;
@@ -4568,8 +4724,19 @@ static int adva_x1_cpld_read_id(struct ptp_ocp *bp)
 	if (ret)
 		goto release;
 	ret = adva_x1_cpld_cmd_read(bp, CPLD_CMD_READ_ID, data, 4);

drivers/ptp/ptp_ocp.c static int adva_x1_cpld_read_id(struct ptp_ocp *bp) · line 4734

Quoted 10 lines
drivers/ptp/ptp_ocp.c +8 -2
-	if (!ret)
-		WRITE_ONCE(bp->cpld_id, get_unaligned_be32(data));
+	if (ret)
+		goto deselect;
+	id = get_unaligned_be32(data);
+
+	ret = adva_x1_cpld_cmd_read(bp, CPLD_CMD_READ_USERCODE, data, 4);
+	if (ret)
+		goto deselect;
+	usercode = get_unaligned_be32(data);

[Severity: Medium]
Does a failing USERCODE read throw away the device ID that was just read successfully? Before this patch a successful READ_ID alone set bp->cpld_id; now the goto skips both stores, so an I2C NAK or a part that does not answer the 0xC0 opcode leaves cpld_id at 0.

Since the read is a bounded one-shot, ptp_ocp_sync_work() latches cpld_id_tried after CPLD_ID_MAX_ATTEMPTS failures and never retries, so a persistent USERCODE failure permanently removes the pre-existing cpld.id version as well - and with it the fw.cpld entry that gates flashing, as both come out of the same if (bp->has_cpld && id) block.

Would publishing the ID before attempting the USERCODE read keep the older behaviour intact?

drivers/ptp/ptp_ocp.c static int adva_x1_cpld_read_id(struct ptp_ocp *bp) · line 4739

Quoted 5 lines
drivers/ptp/ptp_ocp.c +5 -0
+
+	/* cpld_id is the validity flag for both, so publish it last. */
+	WRITE_ONCE(bp->cpld_usercode, usercode);
+	WRITE_ONCE(bp->cpld_id, id);
+deselect:

[Severity: Low]
Do these accessors give the ordering the comment relies on? WRITE_ONCE() and READ_ONCE() only prevent compiler tearing, they add no store-store or load-load ordering, and the reader's control dependency on id does not order the following load:

	id = READ_ONCE(bp->cpld_id);
	if (bp->has_cpld && id) {
		...
		sprintf(buf, "0x%08x", READ_ONCE(bp->cpld_usercode));

On a weakly ordered machine can ptp_ocp_devlink_info_get() observe a valid cpld_id together with a stale or zero cpld_usercode and report fw.cpld as 0x00000000? smp_store_release()/smp_load_acquire() would express the publish pattern the comment describes.

Quoted 1 line
drivers/ptp/ptp_ocp.c +0 -0
@@ -4627,6 +4794,154 @@ cpld_status_show(struct device *dev, struct device_attribute *attr,

[ ... ]

drivers/ptp/ptp_ocp.c cpld_status_show(struct device *dev, struct device_attribute *attr, · line 4884

Quoted 13 lines
drivers/ptp/ptp_ocp.c +13 -0
+	err = adva_x1_cpld_write(bp, CPLD_CMD_SET_DONE);
+	if (!err)
+		err = adva_x1_cpld_wait_ready(bp, 1000);
+	if (err)
+		goto exit_config;
+
+	err = adva_x1_cpld_read_status(bp, &st);
+	if (err)
+		goto exit_config;
+	if (!(st & CPLD_STATUS_DONE)) {
+		err = -EIO;
+		goto exit_config;
+	}

[Severity: Low]
Why does this DONE check report differently from the identical one after REFRESH? Here userspace gets a bare -EIO with extack untouched and nothing in the log, while the post-refresh check sets both:

	dev_err(&bp->pdev->dev,
		"CPLD refresh left status 0x%08x\n", st);
	NL_SET_ERR_MSG_MOD(extack, "CPLD did not come back configured");

Related: the CPLD path emits "Erasing"/"Programming"/"Activating" but never a terminal notification, whereas the SPI path in ptp_ocp_devlink_flash_update() finishes with:

	msg = err ? "Flash error" : "Flash complete";
	devlink_flash_update_status_notify(devlink, msg, NULL, 0, 0);

Should the CPLD component report a terminal status too, given the new documentation says progress "is reported with the standard devlink status notifications"?

[ ... ]

drivers/ptp/ptp_ocp.c cpld_status_show(struct device *dev, struct device_attribute *attr, · line 4940

Quoted 13 lines
drivers/ptp/ptp_ocp.c +13 -0
+	/* The image on the part changed, so the cached USERCODE has too. */
+	WRITE_ONCE(bp->cpld_id, 0);
+	WRITE_ONCE(bp->cpld_id_tried, false);
+	bp->cpld_id_attempts = 0;
+
+exit_config:
+	adva_x1_cpld_exit_config(bp);
+deselect:
+	adva_x1_mux_select(bp, -1);
+release:
+	adva_x1_bus_release(bp);
+unlock:
+	mutex_unlock(&bp->cpld_lock);

[Severity: Medium]
Should the cache also be invalidated on the failure paths? This block is reached only when every post-refresh check passed. Every failure taken after CPLD_CMD_ERASE completed - a page write error, SET_DONE failure, DONE not set, the REFRESH write failing, the mux reselect timing out, or the post-refresh status check - jumps to exit_config or deselect and skips it.

The boot-time read has already latched cpld_id_tried, and ptp_ocp_sync_work() gates the re-read on that flag:

	if (bp->has_cpld && !READ_ONCE(bp->cpld_id_tried) &&
	    READ_ONCE(bp->cpld_i2c_adap_nr) >= 0) {

so ptp_ocp_devlink_info_get() keeps publishing cpld.id and the fw.cpld running version of an image that has been erased or only partially rewritten, for the life of the binding. Would invalidating immediately after the erase is issued be more accurate than after final verification?

[Severity: Medium]
Can ptp_ocp_sync_work() clobber this invalidation? These three fields are written here under cpld_lock, but the worker writes the same fields with no lock held - adva_x1_cpld_read_id() takes and drops cpld_lock internally, so the bookkeeping that follows it runs unprotected:

ptp_ocp_sync_work()

	err = adva_x1_cpld_read_id(bp);	/* takes and releases cpld_lock */
	if (err != -EBUSY &&
	    (!err || ++bp->cpld_id_attempts >= CPLD_ID_MAX_ATTEMPTS))
		WRITE_ONCE(bp->cpld_id_tried, true);

Interleaving:

worker adva_x1_cpld_read_id() succeeds, cpld_lock released,
preempted before WRITE_ONCE(cpld_id_tried, true)

flash mutex_lock(&bp->cpld_lock), programs for tens of seconds,

		WRITE_ONCE(bp->cpld_id, 0)
		WRITE_ONCE(bp->cpld_id_tried, false)
		bp->cpld_id_attempts = 0
		mutex_unlock(&bp->cpld_lock)

worker WRITE_ONCE(bp->cpld_id_tried, true)

That leaves cpld_id == 0 with tried latched, so the worker never re-reads, info_get() permanently omits cpld.id and fw.cpld, and further devlink dev flash ... component fw.cpld requests are rejected by devlink_flash_component_get() until the driver is rebound. The plain bp->cpld_id_attempts = 0 store here also races with the worker's ++bp->cpld_id_attempts. Would moving the tried/attempts bookkeeping inside adva_x1_cpld_read_id(), under cpld_lock, close this?

Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260914071555.11684-1-maimon.sagi%40gmail.com