Linux Documentation
 help / color / mirror / Atom feed
* [PATCH net-next 0/3] dpll: zl3073x: add device reset via devlink reload
@ 2026-12-03 18:06 Ivan Vecera
  2026-12-03 18:06 ` [PATCH net-next 1/3] dpll: zl3073x: factor device CPU reset into a helper Ivan Vecera
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ivan Vecera @ 2026-12-03 18:06 UTC (permalink / raw)
  To: netdev
  Cc: Jiri Pirko, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Simon Horman, Jonathan Corbet, Shuah Khan,
	Randy Dunlap, Min Li, Vadim Fedorenko, Arkadiusz Kubalewski,
	linux-doc

The ZL3073x chips can reboot the firmware and reload the whole
configuration from flash. This series exposes this full device reset
through the devlink 'fw_activate' reload action. As the reset affects
the whole chip, devlink is used rather than the per-DPLL netlink
interface.

Patch 1 factors the HW register sequence used by
zl3073x_flash_mode_leave() to reset the device CPU into a reusable
helper. Patch 2 makes the driver fetch the device state on every start,
as a reset changes it. Patch 3 adds the 'fw_activate' reload action and
documents the supported reload actions.

Ivan Vecera (3):
  dpll: zl3073x: factor device CPU reset into a helper
  dpll: zl3073x: always fetch device state on start
  dpll: zl3073x: add device reset via devlink reload

 Documentation/networking/devlink/zl3073x.rst | 25 ++++++
 drivers/dpll/zl3073x/core.c                  | 91 +++++++++++++++-----
 drivers/dpll/zl3073x/core.h                  |  8 +-
 drivers/dpll/zl3073x/devlink.c               | 81 ++++++++++++-----
 drivers/dpll/zl3073x/flash.c                 | 79 ++++-------------
 5 files changed, 172 insertions(+), 112 deletions(-)


base-commit: fe4597b13a535ebf999053d2ed9993ec534be192
-- 
2.56.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH net-next 1/3] dpll: zl3073x: factor device CPU reset into a helper
  2026-12-03 18:06 [PATCH net-next 0/3] dpll: zl3073x: add device reset via devlink reload Ivan Vecera
@ 2026-12-03 18:06 ` Ivan Vecera
  2026-12-03 18:06 ` [PATCH net-next 2/3] dpll: zl3073x: always fetch device state on start Ivan Vecera
  2026-12-03 18:06 ` [PATCH net-next 3/3] dpll: zl3073x: add device reset via devlink reload Ivan Vecera
  2 siblings, 0 replies; 4+ messages in thread
From: Ivan Vecera @ 2026-12-03 18:06 UTC (permalink / raw)
  To: netdev
  Cc: Jiri Pirko, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Simon Horman, Jonathan Corbet, Shuah Khan,
	Randy Dunlap, Min Li, Vadim Fedorenko, Arkadiusz Kubalewski,
	linux-doc

zl3073x_flash_mode_leave() resets the device CPU back to normal
firmware processing via an open-coded HW register write sequence in
flash.c. The same core reset is needed for a full device reset that
reboots the firmware and reloads the configuration from flash,
introduced later in this series. Factor it into a reusable helper,
zl3073x_dev_hw_reset(), in core.c.

Drop the 'wait' field from struct zl3073x_hwreg_seq_item and the
HWREG_SEQ_ITEM() macro. zl3073x_write_hwreg_seq() tested seq->wait
instead of seq[i].wait, so only the first item of a sequence was
considered and, as that is zero in all the sequences, the 1000 ms
waits requested by the flash mode enter sequences never took place.
The flash update has worked without them, so drop them instead of
fixing the test. zl3073x_flash_mode_leave() waits after the core reset
with msleep() on its own, and that wait moves into the helper.

Reviewed-by: Min Li <min.li@microchip.com>
Tested-by: Min Li <min.li@microchip.com>
Signed-off-by: Ivan Vecera <ivecera@redhat.com>
---
 drivers/dpll/zl3073x/core.c  | 58 ++++++++++++++++++++++++--
 drivers/dpll/zl3073x/core.h  |  6 +--
 drivers/dpll/zl3073x/flash.c | 79 ++++++++----------------------------
 3 files changed, 74 insertions(+), 69 deletions(-)

diff --git a/drivers/dpll/zl3073x/core.c b/drivers/dpll/zl3073x/core.c
index 230df08e27cd19..27a55d810d5b05 100644
--- a/drivers/dpll/zl3073x/core.c
+++ b/drivers/dpll/zl3073x/core.c
@@ -497,14 +497,66 @@ int zl3073x_write_hwreg_seq(struct zl3073x_dev *zldev,
 						  seq[i].value, seq[i].mask);
 		if (rc)
 			return rc;
-
-		if (seq->wait)
-			msleep(seq->wait);
 	}
 
 	return rc;
 }
 
+/**
+ * zl3073x_dev_hw_reset - Reset the device CPU and reload firmware and config
+ * @zldev: zl3073x device pointer
+ *
+ * Triggers a core reset that reboots the firmware and reloads the whole
+ * configuration from flash. The device is inaccessible on the control bus
+ * while the reset is in progress.
+ *
+ * Context: Process context. The caller must stop normal operation with
+ * zl3073x_dev_stop() first.
+ *
+ * Return: 0 on success, <0 on error
+ */
+int zl3073x_dev_hw_reset(struct zl3073x_dev *zldev)
+{
+	static const struct zl3073x_hwreg_seq_item hw_seq[] = {
+		HWREG_SEQ_ITEM(0x80000404, 1, BIT(0)),
+		HWREG_SEQ_ITEM(0x80000410, 1, BIT(0)),
+	};
+	u8 reset_status;
+	int rc;
+
+	/* Read reset status register */
+	rc = zl3073x_read_u8(zldev, ZL_REG_RESET_STATUS, &reset_status);
+	if (rc)
+		return rc;
+
+	/* Arm the reset detection flag */
+	reset_status |= ZL_REG_RESET_STATUS_RESET;
+	rc = zl3073x_write_u8(zldev, ZL_REG_RESET_STATUS, reset_status);
+	if (rc)
+		return rc;
+
+	/* Trigger the core reset. The last write typically errors out as
+	 * the device CPU resets mid-transaction, so its return value is
+	 * not checked.
+	 */
+	zl3073x_write_hwreg_seq(zldev, hw_seq, ARRAY_SIZE(hw_seq));
+
+	msleep(500);
+
+	/* Read again the reset status register */
+	rc = zl3073x_read_u8(zldev, ZL_REG_RESET_STATUS, &reset_status);
+	if (rc)
+		return rc;
+
+	/* Check the reset flag was cleared by the firmware */
+	if (reset_status & ZL_REG_RESET_STATUS_RESET) {
+		dev_err(zldev->dev, "Device reset not confirmed\n");
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
 static int
 zl3073x_dev_state_fetch(struct zl3073x_dev *zldev)
 {
diff --git a/drivers/dpll/zl3073x/core.h b/drivers/dpll/zl3073x/core.h
index 67c10e2595118c..4d979543500c4e 100644
--- a/drivers/dpll/zl3073x/core.h
+++ b/drivers/dpll/zl3073x/core.h
@@ -125,21 +125,18 @@ int zl3073x_dev_phase_avg_factor_set(struct zl3073x_dev *zldev, u8 factor);
  * @addr: HW register to be written
  * @value: value to be written to HW register
  * @mask: bitmask indicating bits to be updated
- * @wait: number of ms to wait after register write
  */
 struct zl3073x_hwreg_seq_item {
 	u32	addr;
 	u32	value;
 	u32	mask;
-	u32	wait;
 };
 
-#define HWREG_SEQ_ITEM(_addr, _value, _mask, _wait)	\
+#define HWREG_SEQ_ITEM(_addr, _value, _mask)		\
 {							\
 	.addr	= _addr,				\
 	.value	= FIELD_PREP_CONST(_mask, _value),	\
 	.mask	= _mask,				\
-	.wait	= _wait,				\
 }
 
 int zl3073x_mb_op(struct zl3073x_dev *zldev, unsigned int op_reg, u8 op_val,
@@ -161,6 +158,7 @@ int zl3073x_update_hwreg(struct zl3073x_dev *zldev, u32 addr, u32 value,
 int zl3073x_write_hwreg_seq(struct zl3073x_dev *zldev,
 			    const struct zl3073x_hwreg_seq_item *seq,
 			    size_t num_items);
+int zl3073x_dev_hw_reset(struct zl3073x_dev *zldev);
 
 /*****************
  * Misc operations
diff --git a/drivers/dpll/zl3073x/flash.c b/drivers/dpll/zl3073x/flash.c
index f85535c8ad2469..306e7c857b2313 100644
--- a/drivers/dpll/zl3073x/flash.c
+++ b/drivers/dpll/zl3073x/flash.c
@@ -529,22 +529,22 @@ int zl3073x_flash_mode_enter(struct zl3073x_dev *zldev, const void *util_ptr,
 {
 	/* Sequence to be written prior utility download */
 	static const struct zl3073x_hwreg_seq_item pre_seq[] = {
-		HWREG_SEQ_ITEM(0x80000400, 1, BIT(0), 0),
-		HWREG_SEQ_ITEM(0x80206340, 1, BIT(4), 0),
-		HWREG_SEQ_ITEM(0x10000000, 1, BIT(2), 0),
-		HWREG_SEQ_ITEM(0x10000024, 0x00000001, U32_MAX, 0),
-		HWREG_SEQ_ITEM(0x10000020, 0x00000001, U32_MAX, 0),
-		HWREG_SEQ_ITEM(0x10000000, 1, BIT(10), 1000),
+		HWREG_SEQ_ITEM(0x80000400, 1, BIT(0)),
+		HWREG_SEQ_ITEM(0x80206340, 1, BIT(4)),
+		HWREG_SEQ_ITEM(0x10000000, 1, BIT(2)),
+		HWREG_SEQ_ITEM(0x10000024, 0x00000001, U32_MAX),
+		HWREG_SEQ_ITEM(0x10000020, 0x00000001, U32_MAX),
+		HWREG_SEQ_ITEM(0x10000000, 1, BIT(10)),
 	};
 	/* Sequence to be written after utility download */
 	static const struct zl3073x_hwreg_seq_item post_seq[] = {
-		HWREG_SEQ_ITEM(0x10400004, 0x000000C0, U32_MAX, 0),
-		HWREG_SEQ_ITEM(0x10400008, 0x00000000, U32_MAX, 0),
-		HWREG_SEQ_ITEM(0x10400010, 0x20000000, U32_MAX, 0),
-		HWREG_SEQ_ITEM(0x10400014, 0x20000004, U32_MAX, 0),
-		HWREG_SEQ_ITEM(0x10000000, 1, GENMASK(10, 9), 0),
-		HWREG_SEQ_ITEM(0x10000020, 0x00000000, U32_MAX, 0),
-		HWREG_SEQ_ITEM(0x10000000, 0, BIT(0), 1000),
+		HWREG_SEQ_ITEM(0x10400004, 0x000000C0, U32_MAX),
+		HWREG_SEQ_ITEM(0x10400008, 0x00000000, U32_MAX),
+		HWREG_SEQ_ITEM(0x10400010, 0x20000000, U32_MAX),
+		HWREG_SEQ_ITEM(0x10400014, 0x20000004, U32_MAX),
+		HWREG_SEQ_ITEM(0x10000000, 1, GENMASK(10, 9)),
+		HWREG_SEQ_ITEM(0x10000020, 0x00000000, U32_MAX),
+		HWREG_SEQ_ITEM(0x10000000, 0, BIT(0)),
 	};
 	int rc;
 
@@ -604,62 +604,17 @@ int zl3073x_flash_mode_enter(struct zl3073x_dev *zldev, const void *util_ptr,
  * @extack: netlink extack pointer to report errors
  *
  * The function instructs the device to leave the flash mode and
- * to return back to normal operation.
- *
- * The procedure:
- * 1) Set reset flag
- * 2) Reset the device CPU by specific HW register sequence
- * 3) Wait for the device to be ready
- * 4) Check the reset flag was cleared
+ * to return back to normal operation by resetting the device CPU
+ * with zl3073x_dev_hw_reset().
  *
  * Return: 0 on success, <0 on error
  */
 int zl3073x_flash_mode_leave(struct zl3073x_dev *zldev,
 			     struct netlink_ext_ack *extack)
 {
-	/* Sequence to be written after flash */
-	static const struct zl3073x_hwreg_seq_item fw_reset_seq[] = {
-		HWREG_SEQ_ITEM(0x80000404, 1, BIT(0), 0),
-		HWREG_SEQ_ITEM(0x80000410, 1, BIT(0), 0),
-	};
-	u8 reset_status;
-	int rc;
-
 	zl3073x_devlink_flash_notify(zldev, "Leaving flash mode", "utility",
 				     0, 0);
 
-	/* Read reset status register */
-	rc = zl3073x_read_u8(zldev, ZL_REG_RESET_STATUS, &reset_status);
-	if (rc)
-		return rc;
-
-	/* Set reset bit */
-	reset_status |= ZL_REG_RESET_STATUS_RESET;
-
-	/* Update reset status register */
-	rc = zl3073x_write_u8(zldev, ZL_REG_RESET_STATUS, reset_status);
-	if (rc)
-		return rc;
-
-	/* We do not check the return value here as the sequence resets
-	 * the device CPU and the last write always return an error.
-	 */
-	zl3073x_write_hwreg_seq(zldev, fw_reset_seq, ARRAY_SIZE(fw_reset_seq));
-
-	/* Wait for the device to be ready */
-	msleep(500);
-
-	/* Read again the reset status register */
-	rc = zl3073x_read_u8(zldev, ZL_REG_RESET_STATUS, &reset_status);
-	if (rc)
-		return rc;
-
-	/* Check the reset bit was cleared */
-	if (reset_status & ZL_REG_RESET_STATUS_RESET) {
-		dev_err(zldev->dev,
-			"Reset not confirmed after switch to normal mode\n");
-		return -EINVAL;
-	}
-
-	return 0;
+	/* Reset the device CPU to resume normal firmware processing */
+	return zl3073x_dev_hw_reset(zldev);
 }
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH net-next 2/3] dpll: zl3073x: always fetch device state on start
  2026-12-03 18:06 [PATCH net-next 0/3] dpll: zl3073x: add device reset via devlink reload Ivan Vecera
  2026-12-03 18:06 ` [PATCH net-next 1/3] dpll: zl3073x: factor device CPU reset into a helper Ivan Vecera
@ 2026-12-03 18:06 ` Ivan Vecera
  2026-12-03 18:06 ` [PATCH net-next 3/3] dpll: zl3073x: add device reset via devlink reload Ivan Vecera
  2 siblings, 0 replies; 4+ messages in thread
From: Ivan Vecera @ 2026-12-03 18:06 UTC (permalink / raw)
  To: netdev
  Cc: Jiri Pirko, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Simon Horman, Jonathan Corbet, Shuah Khan,
	Randy Dunlap, Min Li, Vadim Fedorenko, Arkadiusz Kubalewski,
	linux-doc

zl3073x_dev_start() fetches the device state and sets up the phase
offset measurement block only when asked for a full start. Probe and
the devlink flash update ask for it, the devlink DRIVER_REINIT reload
does not, as a 'clock_id' change does not change the device state.

The devlink FW_ACTIVATE reload, added later in this series, resets the
device, which reloads the whole configuration from flash. If the
restart after the reset fails, a following DRIVER_REINIT reload would
register the DPLLs with cached state that predates the reset, and would
not set up the phase offset measurement block again. The device CPU
reset at the end of a flash update already allows the same.

Always fetch the device state and set up the phase offset measurement
block on start, and drop the 'full' parameter. A DRIVER_REINIT reload
is rare, so fetching the state again there costs little.

Reviewed-by: Min Li <min.li@microchip.com>
Tested-by: Min Li <min.li@microchip.com>
Signed-off-by: Ivan Vecera <ivecera@redhat.com>
---
 drivers/dpll/zl3073x/core.c    | 33 ++++++++++++++-------------------
 drivers/dpll/zl3073x/core.h    |  2 +-
 drivers/dpll/zl3073x/devlink.c |  6 +++---
 3 files changed, 18 insertions(+), 23 deletions(-)

diff --git a/drivers/dpll/zl3073x/core.c b/drivers/dpll/zl3073x/core.c
index 27a55d810d5b05..5495d2c67848ac 100644
--- a/drivers/dpll/zl3073x/core.c
+++ b/drivers/dpll/zl3073x/core.c
@@ -860,16 +860,14 @@ zl3073x_dev_phase_meas_setup(struct zl3073x_dev *zldev)
 /**
  * zl3073x_dev_start - Start normal operation
  * @zldev: zl3073x device pointer
- * @full: perform full initialization
  *
- * The function starts normal operation, which means registering all DPLLs and
- * their pins, and starting monitoring. If full initialization is requested,
- * the function additionally initializes the phase offset measurement block and
- * fetches hardware-invariant parameters.
+ * The function starts normal operation, which means fetching the device
+ * state, initializing the phase offset measurement block, registering all
+ * DPLLs and their pins, and starting monitoring.
  *
  * Return: 0 on success, <0 on error
  */
-int zl3073x_dev_start(struct zl3073x_dev *zldev, bool full)
+int zl3073x_dev_start(struct zl3073x_dev *zldev)
 {
 	struct zl3073x_dpll *zldpll;
 	u8 info;
@@ -895,19 +893,16 @@ int zl3073x_dev_start(struct zl3073x_dev *zldev, bool full)
 		return 0;
 	}
 
-	if (full) {
-		/* Fetch device state */
-		rc = zl3073x_dev_state_fetch(zldev);
-		if (rc)
-			return rc;
+	/* Fetch device state */
+	rc = zl3073x_dev_state_fetch(zldev);
+	if (rc)
+		return rc;
 
-		/* Setup phase offset measurement block */
-		rc = zl3073x_dev_phase_meas_setup(zldev);
-		if (rc) {
-			dev_err(zldev->dev,
-				"Failed to setup phase measurement\n");
-			return rc;
-		}
+	/* Setup phase offset measurement block */
+	rc = zl3073x_dev_phase_meas_setup(zldev);
+	if (rc) {
+		dev_err(zldev->dev, "Failed to setup phase measurement\n");
+		return rc;
 	}
 
 	/* Register all DPLLs */
@@ -1012,7 +1007,7 @@ zl3073x_devm_dpll_init(struct zl3073x_dev *zldev)
 	zldev->kworker = kworker;
 
 	/* Start normal operation */
-	rc = zl3073x_dev_start(zldev, true);
+	rc = zl3073x_dev_start(zldev);
 	if (rc) {
 		dev_err_probe(zldev->dev, rc, "Failed to start device\n");
 		goto error;
diff --git a/drivers/dpll/zl3073x/core.h b/drivers/dpll/zl3073x/core.h
index 4d979543500c4e..728782e33332ba 100644
--- a/drivers/dpll/zl3073x/core.h
+++ b/drivers/dpll/zl3073x/core.h
@@ -106,7 +106,7 @@ extern const struct regmap_config zl3073x_regmap_config;
 struct zl3073x_dev *zl3073x_devm_alloc(struct device *dev);
 int zl3073x_dev_probe(struct zl3073x_dev *zldev);
 
-int zl3073x_dev_start(struct zl3073x_dev *zldev, bool full);
+int zl3073x_dev_start(struct zl3073x_dev *zldev);
 void zl3073x_dev_stop(struct zl3073x_dev *zldev);
 
 static inline u8 zl3073x_dev_phase_avg_factor_get(struct zl3073x_dev *zldev)
diff --git a/drivers/dpll/zl3073x/devlink.c b/drivers/dpll/zl3073x/devlink.c
index 218b08fd8a3065..10143ec81a1167 100644
--- a/drivers/dpll/zl3073x/devlink.c
+++ b/drivers/dpll/zl3073x/devlink.c
@@ -125,7 +125,7 @@ zl3073x_devlink_reload_up(struct devlink *devlink,
 	}
 
 	/* Restart normal operation */
-	rc = zl3073x_dev_start(zldev, false);
+	rc = zl3073x_dev_start(zldev);
 	if (rc)
 		dev_warn(zldev->dev, "Failed to re-start normal operation\n");
 
@@ -180,7 +180,7 @@ zl3073x_devlink_flash_prepare(struct zl3073x_dev *zldev,
 					     NULL, 0, 0);
 
 		/* Resume normal operation */
-		zl3073x_dev_start(zldev, true);
+		zl3073x_dev_start(zldev);
 
 		return rc;
 	}
@@ -208,7 +208,7 @@ zl3073x_devlink_flash_finish(struct zl3073x_dev *zldev,
 	zl3073x_flash_mode_leave(zldev, extack);
 
 	/* Resume normal operation */
-	rc = zl3073x_dev_start(zldev, true);
+	rc = zl3073x_dev_start(zldev);
 	if (rc)
 		zl3073x_devlink_flash_notify(zldev,
 					     "Failed to start normal operation",
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH net-next 3/3] dpll: zl3073x: add device reset via devlink reload
  2026-12-03 18:06 [PATCH net-next 0/3] dpll: zl3073x: add device reset via devlink reload Ivan Vecera
  2026-12-03 18:06 ` [PATCH net-next 1/3] dpll: zl3073x: factor device CPU reset into a helper Ivan Vecera
  2026-12-03 18:06 ` [PATCH net-next 2/3] dpll: zl3073x: always fetch device state on start Ivan Vecera
@ 2026-12-03 18:06 ` Ivan Vecera
  2 siblings, 0 replies; 4+ messages in thread
From: Ivan Vecera @ 2026-12-03 18:06 UTC (permalink / raw)
  To: netdev
  Cc: Jiri Pirko, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Simon Horman, Jonathan Corbet, Shuah Khan,
	Randy Dunlap, Min Li, Vadim Fedorenko, Arkadiusz Kubalewski,
	linux-doc

The ZL3073x chips can perform a full device reset that reboots the
firmware and reloads the whole configuration from flash. Expose it
through the devlink 'fw_activate' reload action using the previously
added zl3073x_dev_hw_reset() helper.

reload_down() stops normal operation for both DRIVER_REINIT and
FW_ACTIVATE. reload_up() additionally resets the device for
FW_ACTIVATE before restarting normal operation. Normal operation is
always restarted on a best-effort basis even if the reset fails, so
the dpll device is not left unregistered, but the reset failure is
still propagated as the overall reload_up() error so devlink reports
a failed reload and does not claim FW_ACTIVATE was performed in
actions_performed.

The 'clock_id' devlink param update is only meaningful for
DRIVER_REINIT, since the devlink core only loads a new driverinit
param value ahead of that action; factor it into a helper and call it
only from that case.

reload_up() now also propagates the error from the restart step
instead of always returning success, so devlink correctly reports a
failed reload. A missing or corrupted configuration in flash is not
treated as a failure. As during probe, only the devlink interface is
kept so that a correct configuration can be flashed.

Document the supported reload actions in the driver's devlink
documentation. Also state there, as recommended by Microchip, that the
output clocks may glitch during a flash update or a device reset.

Reviewed-by: Min Li <min.li@microchip.com>
Tested-by: Min Li <min.li@microchip.com>
Signed-off-by: Ivan Vecera <ivecera@redhat.com>
---
 Documentation/networking/devlink/zl3073x.rst | 25 +++++++
 drivers/dpll/zl3073x/devlink.c               | 77 ++++++++++++++------
 2 files changed, 81 insertions(+), 21 deletions(-)

diff --git a/Documentation/networking/devlink/zl3073x.rst b/Documentation/networking/devlink/zl3073x.rst
index fc5a8dc272a774..a653b9e1fa9d61 100644
--- a/Documentation/networking/devlink/zl3073x.rst
+++ b/Documentation/networking/devlink/zl3073x.rst
@@ -62,4 +62,29 @@ During the flash procedure, the standard firmware interface is not available,
 so the driver unregisters all DPLLs and associated pins, and re-registers them
 once the flash procedure is complete.
 
+The output clocks may glitch during the flash procedure unless they are stopped
+and disabled before the flash utility is loaded and the power-up configuration
+stored in flash has them disabled. The driver does not stop or disable the
+output clocks itself.
+
 The driver does not support any overwrite mask flags.
+
+Reload
+======
+
+The ``zl3073x`` driver supports the following ``devlink-reload`` actions:
+
+``driver_reinit``
+  Unregisters all DPLLs and associated pins and registers them again. A new
+  value of the ``clock_id`` parameter is applied by this action.
+
+``fw_activate``
+  Resets the device, which reboots the firmware and reloads the whole
+  configuration from flash, and registers all DPLLs and associated pins again.
+  A new value of the ``clock_id`` parameter is not applied by this action.
+  The output clocks may glitch during the reset unless they are stopped and
+  disabled before the reset and the power-up configuration stored in flash has
+  them disabled.
+
+If the configuration stored in flash is wrong or missing, the DPLLs stay
+unregistered and only the devlink interface remains available.
diff --git a/drivers/dpll/zl3073x/devlink.c b/drivers/dpll/zl3073x/devlink.c
index 10143ec81a1167..0ff93889acd503 100644
--- a/drivers/dpll/zl3073x/devlink.c
+++ b/drivers/dpll/zl3073x/devlink.c
@@ -89,29 +89,26 @@ zl3073x_devlink_reload_down(struct devlink *devlink, bool netns_change,
 {
 	struct zl3073x_dev *zldev = devlink_priv(devlink);
 
-	if (action != DEVLINK_RELOAD_ACTION_DRIVER_REINIT)
-		return -EOPNOTSUPP;
+	switch (action) {
+	case DEVLINK_RELOAD_ACTION_DRIVER_REINIT:
+	case DEVLINK_RELOAD_ACTION_FW_ACTIVATE:
+		/* Stop normal operation */
+		zl3073x_dev_stop(zldev);
 
-	/* Stop normal operation */
-	zl3073x_dev_stop(zldev);
+		return 0;
 
-	return 0;
+	default:
+		return -EOPNOTSUPP;
+	}
 }
 
 static int
-zl3073x_devlink_reload_up(struct devlink *devlink,
-			  enum devlink_reload_action action,
-			  enum devlink_reload_limit limit,
-			  u32 *actions_performed,
-			  struct netlink_ext_ack *extack)
+zl3073x_devlink_clock_id_update(struct zl3073x_dev *zldev)
 {
-	struct zl3073x_dev *zldev = devlink_priv(devlink);
+	struct devlink *devlink = priv_to_devlink(zldev);
 	union devlink_param_value val;
 	int rc;
 
-	if (action != DEVLINK_RELOAD_ACTION_DRIVER_REINIT)
-		return -EOPNOTSUPP;
-
 	rc = devl_param_driverinit_value_get(devlink,
 					     DEVLINK_PARAM_GENERIC_ID_CLOCK_ID,
 					     &val);
@@ -124,14 +121,51 @@ zl3073x_devlink_reload_up(struct devlink *devlink,
 		zldev->clock_id = val.vu64;
 	}
 
-	/* Restart normal operation */
-	rc = zl3073x_dev_start(zldev);
-	if (rc)
-		dev_warn(zldev->dev, "Failed to re-start normal operation\n");
+	return rc;
+}
 
-	*actions_performed = BIT(DEVLINK_RELOAD_ACTION_DRIVER_REINIT);
+static int
+zl3073x_devlink_reload_up(struct devlink *devlink,
+			  enum devlink_reload_action action,
+			  enum devlink_reload_limit limit,
+			  u32 *actions_performed,
+			  struct netlink_ext_ack *extack)
+{
+	struct zl3073x_dev *zldev = devlink_priv(devlink);
+	int rc, restart_rc;
+
+	*actions_performed = 0;
+	switch (action) {
+	case DEVLINK_RELOAD_ACTION_DRIVER_REINIT:
+		rc = zl3073x_devlink_clock_id_update(zldev);
+		if (rc)
+			NL_SET_ERR_MSG_MOD(extack, "Failed to update clock_id");
+		break;
+	case DEVLINK_RELOAD_ACTION_FW_ACTIVATE:
+		/* Reset the device CPU to reboot the firmware and reload the
+		 * configuration from flash. On failure, normal operation is
+		 * still restarted below on a best-effort basis.
+		 */
+		rc = zl3073x_dev_hw_reset(zldev);
+		if (rc) {
+			NL_SET_ERR_MSG_MOD(extack, "Hardware reset failed");
+			break;
+		}
+		*actions_performed |= BIT(DEVLINK_RELOAD_ACTION_FW_ACTIVATE);
+		break;
+	default:
+		return -EOPNOTSUPP;
+	}
 
-	return 0;
+	/* Restart normal operation */
+	restart_rc = zl3073x_dev_start(zldev);
+	if (restart_rc)
+		NL_SET_ERR_MSG_WEAK_MOD(extack,
+					"Failed to re-start normal operation");
+	else
+		*actions_performed |= BIT(DEVLINK_RELOAD_ACTION_DRIVER_REINIT);
+
+	return rc ? : restart_rc;
 }
 
 void zl3073x_devlink_flash_notify(struct zl3073x_dev *zldev, const char *msg,
@@ -270,7 +304,8 @@ zl3073x_devlink_flash_update(struct devlink *devlink,
 
 static const struct devlink_ops zl3073x_devlink_ops = {
 	.info_get = zl3073x_devlink_info_get,
-	.reload_actions = BIT(DEVLINK_RELOAD_ACTION_DRIVER_REINIT),
+	.reload_actions = BIT(DEVLINK_RELOAD_ACTION_DRIVER_REINIT) |
+			  BIT(DEVLINK_RELOAD_ACTION_FW_ACTIVATE),
 	.reload_down = zl3073x_devlink_reload_down,
 	.reload_up = zl3073x_devlink_reload_up,
 	.flash_update = zl3073x_devlink_flash_update,
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-12-03 18:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03 18:06 [PATCH net-next 0/3] dpll: zl3073x: add device reset via devlink reload Ivan Vecera
2026-12-03 18:06 ` [PATCH net-next 1/3] dpll: zl3073x: factor device CPU reset into a helper Ivan Vecera
2026-12-03 18:06 ` [PATCH net-next 2/3] dpll: zl3073x: always fetch device state on start Ivan Vecera
2026-12-03 18:06 ` [PATCH net-next 3/3] dpll: zl3073x: add device reset via devlink reload Ivan Vecera

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox