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>,
	Willem de Bruijn <willemb@google.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 v2 2/3] dpll: zl3073x: track whether the cached device state is valid
Date: Sat,  5 Dec 2026 09:38:59 +0100	[thread overview]
Message-ID: <20261205083900.595822-3-ivecera@redhat.com> (raw)
In-Reply-To: <20261205083900.595822-1-ivecera@redhat.com>

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 it does not reset the device, and a new fetch would lose
the cached frequency offset of a channel in NCO mode, which cannot be
reliably read back from the device.

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.

Replace the 'full' parameter with a 'state_valid' flag. Clear it in
zl3073x_dev_hw_reset() and when entering the flash mode, and set it in
zl3073x_dev_start() once the device state is fetched and the phase
offset measurement block is set up. Fetch the state and set up the
block only when the flag is clear.

Reviewed-by: Min Li <min.li@microchip.com>
Tested-by: Min Li <min.li@microchip.com>
Signed-off-by: Ivan Vecera <ivecera@redhat.com>
---
Changes in v2:
- Track whether the cached state is valid instead of always fetching
  it, so a DRIVER_REINIT reload keeps the NCO frequency offset (Sashiko)
- Subject changed from "always fetch device state on start"
---
 drivers/dpll/zl3073x/core.c    | 20 +++++++++++++-------
 drivers/dpll/zl3073x/core.h    |  4 +++-
 drivers/dpll/zl3073x/devlink.c |  6 +++---
 drivers/dpll/zl3073x/flash.c   |  5 +++++
 4 files changed, 24 insertions(+), 11 deletions(-)

diff --git a/drivers/dpll/zl3073x/core.c b/drivers/dpll/zl3073x/core.c
index e833c62d064842..bb32dc1863b429 100644
--- a/drivers/dpll/zl3073x/core.c
+++ b/drivers/dpll/zl3073x/core.c
@@ -524,6 +524,11 @@ int zl3073x_dev_hw_reset(struct zl3073x_dev *zldev)
 	u8 reset_status;
 	int rc;
 
+	/* The reset reloads the configuration from flash, the cached state
+	 * becomes stale.
+	 */
+	zldev->state_valid = false;
+
 	/* Read reset status register */
 	rc = zl3073x_read_u8(zldev, ZL_REG_RESET_STATUS, &reset_status);
 	if (rc)
@@ -863,16 +868,15 @@ 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.
+ * their pins, and starting monitoring. If the cached device state is not
+ * valid, e.g. at probe or after a device reset, the function first fetches
+ * the device state and initializes the phase offset measurement block.
  *
  * 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;
@@ -898,7 +902,7 @@ int zl3073x_dev_start(struct zl3073x_dev *zldev, bool full)
 		return 0;
 	}
 
-	if (full) {
+	if (!zldev->state_valid) {
 		/* Fetch device state */
 		rc = zl3073x_dev_state_fetch(zldev);
 		if (rc)
@@ -911,6 +915,8 @@ int zl3073x_dev_start(struct zl3073x_dev *zldev, bool full)
 				"Failed to setup phase measurement\n");
 			return rc;
 		}
+
+		zldev->state_valid = true;
 	}
 
 	/* Register all DPLLs */
@@ -1015,7 +1021,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..40df48668bd399 100644
--- a/drivers/dpll/zl3073x/core.h
+++ b/drivers/dpll/zl3073x/core.h
@@ -65,6 +65,7 @@ struct zl3073x_chip_info {
  * @out: array of outs' invariants
  * @synth: array of synths' invariants
  * @chan: array of DPLL channels' state
+ * @state_valid: cached device state is valid, cleared by a device reset
  * @dplls: list of DPLLs
  * @kworker: thread for periodic work
  * @work: periodic work
@@ -86,6 +87,7 @@ struct zl3073x_dev {
 	struct zl3073x_out	out[ZL3073X_NUM_OUTS];
 	struct zl3073x_synth	synth[ZL3073X_NUM_SYNTHS];
 	struct zl3073x_chan	chan[ZL3073X_MAX_CHANNELS];
+	bool			state_valid;
 
 	/* DPLL channels */
 	struct list_head	dplls;
@@ -106,7 +108,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",
diff --git a/drivers/dpll/zl3073x/flash.c b/drivers/dpll/zl3073x/flash.c
index 306e7c857b2313..a350f7031a8a74 100644
--- a/drivers/dpll/zl3073x/flash.c
+++ b/drivers/dpll/zl3073x/flash.c
@@ -551,6 +551,11 @@ int zl3073x_flash_mode_enter(struct zl3073x_dev *zldev, const void *util_ptr,
 	zl3073x_devlink_flash_notify(zldev, "Prepare flash mode", "utility",
 				     0, 0);
 
+	/* The device stops normal firmware processing, the cached state
+	 * becomes stale.
+	 */
+	zldev->state_valid = false;
+
 	/* Execure pre-load sequence */
 	rc = zl3073x_write_hwreg_seq(zldev, pre_seq, ARRAY_SIZE(pre_seq));
 	if (rc) {
-- 
2.56.1


  parent reply	other threads:[~2026-12-05  8:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-05  8:38 [PATCH net-next v2 0/3] dpll: zl3073x: add device reset via devlink reload Ivan Vecera
2026-12-05  8:38 ` [PATCH net-next v2 1/3] dpll: zl3073x: factor device CPU reset into a helper Ivan Vecera
2026-12-05  8:38 ` Ivan Vecera [this message]
2026-12-05  8:39 ` [PATCH net-next v2 3/3] dpll: zl3073x: add device reset via devlink reload Ivan Vecera

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=20261205083900.595822-3-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 \
    --cc=willemb@google.com \
    /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