From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796459965; b=RUbaXNLWxSqM45FMy2l2N8QFXWmSuc7dAqeS/FaSIBlYnoEMvNIK/M7oSngyUQI2wgAb VM0GlOuzQWia2JfrfqyQoOtWowWwcnbpPSwbGlunx2XqLg+PrutYmJWjESo4JBx+NdMdC cInmgTAdMFhFlYbpiuVWGuSIZX2gVgC1uS8ssp87WeMCT8ZqR1AnpavW9cV+/v2tZRCEk wP/aq6fuGU38AWY6ArnTMKZDXl22QczpB8xQ6CZ0LiLwISSW/kCut3XkvpeAnawjJchi/ naPc46jxIkqZ9gZnBi/7gotlLXekG8P/blk2akcofW5ul/IT6ZyYkJRsOFvqZAJrveQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796459965; h=DMARC-Filter:DKIM-Signature:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:Received:From:To:Cc:Subject:Date: Message-ID:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Scanned-By; bh=NbIGh/atC3am1zg6OXBuEEVlfqYwXQBGK+uRr1rTGrw=; b=E/79SWC6szPIoL1HBMTOAAZcEg+uuVRh1P4L89u5katgw8PUMHJ6uT4WfMAESq1ukVJ/ 0fTMqt6/XHs6wnLfFPRafPOvoHM6lpKam0n/YBiweZknVz2jPVO4CtWR24J6tqprtVT5U 1eqWCi6X34GmEgTZm3vsVO88hb5HGTtQLlfwNjOx1rrvH0S+5BMvoFQTOTJ75fCc/COSs 1zfF1Dg2iNOeJdNxMTkFJ+V3Nl3WaDkFQopjzO1aFgi/7RAvYjoMCvWU06GLiNZZKx454 sgXKVsuB90HXW21ywCLtmnKkHIESNnLu4Tpc5hUZbh1h1eJ8pPrkNeIrQtROryWJdCg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=UnPiwTq2; arc=none smtp.remote-ip=170.10.129.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 13DB6606A322 for ; Sat, 5 Dec 2026 08:39:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 13DB6606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=UnPiwTq2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796459965; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NbIGh/atC3am1zg6OXBuEEVlfqYwXQBGK+uRr1rTGrw=; b=UnPiwTq2064kE4/jRxmJmAi/0zKLeMZTVceoquQjdrQQ2pxDqNrFVx5qBxSTo3xwXaIvWd Lo7ZpAX+0e52ujj9UNA6otHRdToP+7H34oZJmyiM+SN3jRYrwoONH9L+0hUMidb7vErwAP vcTL/NvbPSyTtBCMZvCgX0af6kRhWEc= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS with 8BITMIME (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-695-Egb2230fP9CrFs2KBjeTTw-1; Sat, 5 Dec 2026 08:39:18 +0000 X-MC-Unique: Egb2230fP9CrFs2KBjeTTw-1 X-Mimecast-MFC-AGG-ID: Egb2230fP9CrFs2KBjeTTw_1796459956 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E581619670E5; Sat, 5 Dec 2026 08:39:15 +0000 (UTC) Received: from ivecera-thinkpadp16vgen1.tpbc.csb (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id BD5251955E9E; Sat, 5 Dec 2026 08:39:11 +0000 (UTC) From: Ivan Vecera To: netdev@vger.kernel.org Cc: Jiri Pirko , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , Simon Horman , Jonathan Corbet , Shuah Khan , Randy Dunlap , Min Li , Vadim Fedorenko , Arkadiusz Kubalewski , 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 Message-ID: <20261205083900.595822-3-ivecera@redhat.com> In-Reply-To: <20261205083900.595822-1-ivecera@redhat.com> References: <20261205083900.595822-1-ivecera@redhat.com> X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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 Tested-by: Min Li Signed-off-by: Ivan Vecera --- 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