From: Petr Oros <poros@redhat.com>
To: Ivan Vecera <ivecera@redhat.com>, netdev@vger.kernel.org
Cc: Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>,
Jakub Kicinski <kuba@kernel.org>, Jiri Pirko <jiri@resnulli.us>,
Min Li <min.li@microchip.com>, Paolo Abeni <pabeni@redhat.com>,
Richard Cochran <richardcochran@gmail.com>,
Vadim Fedorenko <vadim.fedorenko@linux.dev>,
linux-kernel@vger.kernel.org, Jonathan Corbet <corbet@lwn.net>,
Shuah Khan <skhan@linuxfoundation.org>,
linux-doc@vger.kernel.org
Subject: Re: [PATCH net-next v3 1/2] dpll: zl3073x: update all DPLL channels on ref_sync_set
Date: Tue, 11 Aug 2026 10:59:55 +0200 [thread overview]
Message-ID: <3cde09fa-3b68-4fdb-9797-f6e23b7166c4@redhat.com> (raw)
In-Reply-To: <20260807095926.386923-2-ivecera@redhat.com>
On 8/7/26 11:59, Ivan Vecera wrote:
> zl3073x_dpll_input_pin_ref_sync_set() excludes the sync source from
> automatic reference selection by setting its priority to NONE, but
> currently only does this on the single DPLL channel whose pin_priv
> was passed to the callback.
>
> Since input pins are registered with every DPLL channel, the datasheet
> recommends covering all channels to prevent the sync source from
> remaining a selectable candidate on the other channels. This is
> a preparation for the following patch which changes the DPLL core to
> invoke pin-level set callbacks only through the pin owner's reference
> instead of iterating over all registered DPLL devices.
>
> Replace the single-channel priority write with a list_for_each_entry()
> loop over all DPLL channels. Each channel's lock is acquired
> individually for its read-modify-write sequence. The guard(mutex) is
> replaced with explicit mutex_lock/mutex_unlock to allow releasing the
> owner's lock before iterating, avoiding nested locking of the same
> mutex class. A change notification is sent for the sync pin if any
> channel's priority was actually modified.
>
> Signed-off-by: Ivan Vecera <ivecera@redhat.com>
> ---
> drivers/dpll/zl3073x/dpll.c | 58 ++++++++++++++++++++++++++++++-------
> 1 file changed, 48 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/dpll/zl3073x/dpll.c b/drivers/dpll/zl3073x/dpll.c
> index 0488ae6ac486c8..83bd3027dbaa1e 100644
> --- a/drivers/dpll/zl3073x/dpll.c
> +++ b/drivers/dpll/zl3073x/dpll.c
> @@ -263,9 +263,10 @@ zl3073x_dpll_input_pin_ref_sync_set(const struct dpll_pin *dpll_pin,
> u8 mode, ref_id, sync_ref_id;
> struct zl3073x_chan chan;
> struct zl3073x_ref ref;
> + bool sync_ntf = false;
> int rc;
>
> - guard(mutex)(&zldpll->lock);
> + mutex_lock(&zldpll->lock);
>
> ref_id = zl3073x_input_pin_ref_get(pin->id);
> sync_ref_id = zl3073x_input_pin_ref_get(sync_pin->id);
> @@ -285,17 +286,20 @@ zl3073x_dpll_input_pin_ref_sync_set(const struct dpll_pin *dpll_pin,
> if (sync_freq > 8000) {
> NL_SET_ERR_MSG(extack,
> "sync frequency must be 8 kHz or less");
> - return -EINVAL;
> + rc = -EINVAL;
> + goto unlock;
> }
> if (ref_freq < 1000) {
> NL_SET_ERR_MSG(extack,
> "clock frequency must be 1 kHz or more");
> - return -EINVAL;
> + rc = -EINVAL;
> + goto unlock;
> }
> if (ref_freq <= sync_freq) {
> NL_SET_ERR_MSG(extack,
> "clock frequency must be higher than sync frequency");
> - return -EINVAL;
> + rc = -EINVAL;
> + goto unlock;
> }
>
> zl3073x_ref_sync_pair_set(&ref, sync_ref_id);
> @@ -308,20 +312,54 @@ zl3073x_dpll_input_pin_ref_sync_set(const struct dpll_pin *dpll_pin,
>
> rc = zl3073x_ref_state_set(zldev, ref_id, &ref);
> if (rc)
> - return rc;
> + goto unlock;
>
> - /* Exclude sync source from automatic reference selection by setting
> - * its priority to NONE. On disconnect the priority is left as NONE
> - * and the user must explicitly make the pin selectable again.
> + /* All code paths accessing per-channel reference priorities are
> + * serialized by the subsystem dpll_lock, so it is safe to release
> + * our lock here before iterating over the other channels.
> */
> - if (state == DPLL_PIN_STATE_CONNECTED) {
> + mutex_unlock(&zldpll->lock);
> +
> + if (state != DPLL_PIN_STATE_CONNECTED)
> + return 0;
> +
> + /* The datasheet recommends excluding the sync source from automatic
> + * reference selection by setting its priority to NONE on all DPLL
> + * channels. This is advisory - the ref sync pair is already
> + * configured, so a failure here is not fatal. On disconnect the
> + * priority is left as NONE and the user must explicitly make the
> + * pin selectable again.
> + */
> + list_for_each_entry(zldpll, &zldev->dplls, list) {
> + u8 prio;
> +
> + mutex_lock(&zldpll->lock);
> +
> chan = *zl3073x_chan_state_get(zldev, zldpll->id);
> + prio = zl3073x_chan_ref_prio_get(&chan, sync_ref_id);
> + if (prio == ZL_DPLL_REF_PRIO_NONE) {
> + mutex_unlock(&zldpll->lock);
> + continue; /* Ref is already non-selectable */
> + }
> +
> zl3073x_chan_ref_prio_set(&chan, sync_ref_id,
> ZL_DPLL_REF_PRIO_NONE);
> - return zl3073x_chan_state_set(zldev, zldpll->id, &chan);
> + if (zl3073x_chan_state_set(zldev, zldpll->id, &chan))
> + dev_warn(zldev->dev,
> + "Failed to set ref prio on DPLL%u\n",
> + zldpll->id);
> + else
> + sync_ntf = true;
> +
> + mutex_unlock(&zldpll->lock);
> }
> + if (sync_ntf)
> + __dpll_pin_change_ntf(sync_pin->dpll_pin);
>
> return 0;
> +unlock:
> + mutex_unlock(&zldpll->lock);
> + return rc;
> }
>
> static int
Reviewed-by: Petr Oros <poros@redhat.com>
next prev parent reply other threads:[~2026-08-11 9:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-07 9:59 [PATCH net-next v3 0/2] dpll: use pin owner's dpll ref for pin-level set callbacks Ivan Vecera
2026-08-07 9:59 ` [PATCH net-next v3 1/2] dpll: zl3073x: update all DPLL channels on ref_sync_set Ivan Vecera
2026-08-09 18:12 ` Ivan Vecera
2026-08-11 8:59 ` Petr Oros [this message]
2026-08-07 9:59 ` [PATCH net-next v3 2/2] dpll: use pin owner's dpll ref for pin-level attribute setting Ivan Vecera
2026-08-08 9:58 ` Jiri Pirko
2026-08-11 9:40 ` [PATCH net-next v3 0/2] dpll: use pin owner's dpll ref for pin-level set callbacks patchwork-bot+netdevbpf
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=3cde09fa-3b68-4fdb-9797-f6e23b7166c4@redhat.com \
--to=poros@redhat.com \
--cc=arkadiusz.kubalewski@intel.com \
--cc=corbet@lwn.net \
--cc=ivecera@redhat.com \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=min.li@microchip.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.com \
--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