Linux Documentation
 help / color / mirror / Atom feed
From: Ivan Vecera <ivecera@redhat.com>
To: netdev@vger.kernel.org
Cc: Jiri Pirko <jiri@resnulli.us>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>, Jonathan Corbet <corbet@lwn.net>,
	Shuah Khan <skhan@linuxfoundation.org>,
	Randy Dunlap <rdunlap@infradead.org>,
	Min Li <min.li@microchip.com>,
	Vadim Fedorenko <vadim.fedorenko@linux.dev>,
	Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>,
	linux-doc@vger.kernel.org
Subject: [PATCH net-next 3/3] dpll: zl3073x: add device reset via devlink reload
Date: Thu,  3 Dec 2026 19:06:27 +0100	[thread overview]
Message-ID: <20261203180627.215256-4-ivecera@redhat.com> (raw)
In-Reply-To: <20261203180627.215256-1-ivecera@redhat.com>

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


      parent reply	other threads:[~2026-12-03 18:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]

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=20261203180627.215256-4-ivecera@redhat.com \
    --to=ivecera@redhat.com \
    --cc=arkadiusz.kubalewski@intel.com \
    --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=min.li@microchip.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rdunlap@infradead.org \
    --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