Intel-Wired-Lan Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ivan Vecera" <ivecera@redhat.com>
Cc: intel-wired-lan@lists.osuosl.org
Subject: Re: [PATCH RFC net-next 14/19] ice: dpll: route the E825 recovered clock through the mux devices
Date: Fri, 27 Nov 2026 20:35:11 +0000	[thread overview]
Message-ID: <sashiko-outbox-238256@kernel.org> (raw)
In-Reply-To: <20261126203231.934632-15-ivecera@redhat.com>

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] ice: dpll: stale cached p->state check in
  ice_dpll_rclk_state_on_dpll_set()
- [Medium] ice: dpll: unvalidated pin state in
  ice_dpll_rclk_state_on_dpll_set()
- [Low] ice: dpll: mux notification on error exit in
  ice_dpll_rclk_state_on_dpll_set()
--

commit a3dbcf00efb856319244590da2964b162e852fdf
Author: Ivan Vecera <ivecera@redhat.com>

ice: dpll: route the E825 recovered clock through the mux devices

This commit registers each E825 PF's recovered clock pin directly as an
input of the two recovered clock mux DPLL devices instead of as a child of
firmware-described parent pins, and removes the DPLL notifier and fwnode
lookup paths.

> diff --git a/drivers/net/ethernet/intel/ice/ice_dpll.c b/drivers/net/ethernet/intel/ice/ice_dpll.c
> index a608c5ea4d5cc..42579cc3fb9e0 100644
> --- a/drivers/net/ethernet/intel/ice/ice_dpll.c
> +++ b/drivers/net/ethernet/intel/ice/ice_dpll.c
[ ... ]
> @@ -2856,6 +2840,108 @@ static int ice_dpll_rclk_mux_mode_get(const struct dpll_device *dpll,
>  	return 0;
>  }
>  
> +/**
> + * ice_dpll_rclk_state_on_dpll_set - set a state of rclk pin on a mux
> + * @pin: pointer to a pin
> + * @pin_priv: private data pointer passed on pin registration
> + * @dpll: registered dpll pointer
> + * @dpll_priv: private data pointer passed on dpll registration
> + * @state: state to be set on pin
> + * @extack: error reporting
> + *
> + * Dpll subsystem callback. Route the recovered clock of the port to the
> + * output of a recovered clock mux, or stop routing it.
> + *
> + * Context: Acquires pf->dplls.lock
> + * Return:
> + * * 0 - success
> + * * negative - failure
> + */
> +static int
> +ice_dpll_rclk_state_on_dpll_set(const struct dpll_pin *pin, void *pin_priv,
> +				const struct dpll_device *dpll,
> +				void *dpll_priv, enum dpll_pin_state state,
> +				struct netlink_ext_ack *extack)
> +{
> +	bool enable = state == DPLL_PIN_STATE_CONNECTED;
> +	struct ice_dpll_rclk_mux *mux = dpll_priv;
> +	struct ice_dpll_pin *p = pin_priv;
> +	struct ice_pf *pf = p->pf;
> +	struct dpll_pin *prev;
> +	int ret = -EINVAL;

[Severity: Medium]
Should ice_dpll_rclk_state_on_dpll_set() reject states other than
DPLL_PIN_STATE_CONNECTED and DPLL_PIN_STATE_DISCONNECTED, like
ice_dpll_txclk_state_on_dpll_set() and ice_dpll_tspll_state_on_dpll_set()
do?

The recovered clock mux operates in DPLL_MODE_MANUAL, but dpll_pin_state_set()
allows userspace to pass DPLL_PIN_STATE_SELECTABLE.  Here,
DPLL_PIN_STATE_SELECTABLE evaluates enable as false and disconnects a
connected port instead of returning -EINVAL.

> +
> +	if (ice_dpll_is_reset(pf, extack))
> +		return -EBUSY;
> +
> +	/* Read again with the write of the mux, under cgu_synce_lock */
> +	prev = READ_ONCE(mux->src);
> +	mutex_lock(&pf->dplls.lock);
> +	if ((enable && p->state[mux->idx] == DPLL_PIN_STATE_CONNECTED) ||
> +	    (!enable && p->state[mux->idx] == DPLL_PIN_STATE_DISCONNECTED)) {
> +		NL_SET_ERR_MSG_FMT(extack,
> +				   "pin:%u state:%u on dpll:%u already set",
> +				   p->idx, state, mux->idx);
> +		goto unlock;
> +	}
> +
> +	ret = ice_dpll_synce_update_e825c(&pf->hw, enable,
> +					  pf->ptp.port.port_num, mux->idx,
> +					  &prev);

[Severity: Medium]
Can p->state[mux->idx] be stale here when another PF takes over the shared
mux?

On E825, p->state[mux->idx] is only refreshed inside
ice_dpll_rclk_state_on_dpll_get().  When PF1 connects itself to a mux that
was routing PF0, PF0's cached p->state[mux->idx] is updated only as a side
effect of __dpll_pin_change_ntf(prev) -> dpll_pin_event_send() ->
dpll_cmd_pin_get_one() calling ice_dpll_rclk_state_on_dpll_get() on PF0.
If PF0 is undergoing a reset at that moment, ice_dpll_rclk_state_on_dpll_get()
returns -EBUSY before calling ice_dpll_pin_state_update(), leaving PF0's
p->state[mux->idx] at DPLL_PIN_STATE_CONNECTED.

A subsequent request on PF0 to connect will then be rejected as "already
set", while a request to disconnect PF0 will pass this check and call
ice_dpll_synce_update_e825c(&pf->hw, false, ...), which disables the shared
hardware mux in ice_tspll_cfg_bypass_mux_e825c() and cuts off PF1's
recovered clock.

> +	if (ret)
> +		NL_SET_ERR_MSG_FMT(extack,
> +				   "err:%d %s failed to set pin state:%u for pin:%u on dpll:%u",
> +				   ret,
> +				   libie_aq_str(pf->hw.adminq.sq_last_status),
> +				   state, p->idx, mux->idx);
> +unlock:
> +	mutex_unlock(&pf->dplls.lock);
> +	/* The core notifies this pin on success */
> +	__ice_dpll_rclk_mux_ntf(mux, prev, ret ? NULL : p->pin);
> +
> +	return ret;
> +}

[Severity: Low]
Does the "already set" goto unlock path need to skip
__ice_dpll_rclk_mux_ntf()?

Before this patch, ice_dpll_rclk_state_on_pin_set() left mux as NULL until
after the "already set" check, so jumping to unlock skipped the notification.
Now prev is sampled from mux->src without adapter->cgu_synce_lock before the
check, and __ice_dpll_rclk_mux_ntf() runs unconditionally on the early error
exit.  If another PF updates mux->src concurrently in
ice_dpll_rclk_src_init() or ice_dpll_rclk_src_fini(), the failed no-op call
sees mux->src != prev and emits spurious change notifications.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261126203231.934632-1-ivecera@redhat.com?part=14

  reply	other threads:[~2026-11-27 20:35 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26 20:32 [PATCH RFC net-next 00/19] dpll: single-owner pins, board wiring as pin links Ivan Vecera
2026-11-26 20:32 ` [PATCH RFC net-next 01/19] dpll: add " Ivan Vecera
2026-11-26 20:32 ` [PATCH RFC net-next 02/19] dpll: report " Ivan Vecera
2026-11-26 20:32 ` [PATCH RFC net-next 03/19] dpll: notify linked pins when a pin is registered or unregistered Ivan Vecera
2026-11-26 20:32 ` [PATCH RFC net-next 04/19] dpll: add KUnit tests for pin links Ivan Vecera
2026-11-26 20:32 ` [PATCH RFC net-next 05/19] ice: dpll: use own pins for the TX and time references Ivan Vecera
2026-11-26 20:32 ` [PATCH RFC net-next 06/19] ice: dpll: drop the filter of notifications from own registrations Ivan Vecera
2026-11-26 20:32 ` [PATCH RFC net-next 07/19] dpll: register pins only with a DPLL of their owner Ivan Vecera
2026-11-26 20:32 ` [PATCH RFC net-next 08/19] dpll: drop the state change exception for pins with a firmware node Ivan Vecera
2026-11-26 20:32 ` [PATCH RFC net-next 09/19] dpll: drop the source clock id from pin notifications Ivan Vecera
2026-11-26 20:32 ` [PATCH RFC net-next 10/19] dpll: drop device events from the in-kernel notifier Ivan Vecera
2026-11-26 20:32 ` [PATCH RFC net-next 11/19] dpll: drop the cached module name of a pin Ivan Vecera
2026-11-26 20:32 ` [PATCH RFC net-next 12/19] ice: dpll: track the E825 recovered clock routing in the adapter Ivan Vecera
2026-11-26 20:32 ` [PATCH RFC net-next 13/19] ice: dpll: register the E825 recovered clock muxes as DPLL devices Ivan Vecera
2026-11-26 20:32 ` [PATCH RFC net-next 14/19] ice: dpll: route the E825 recovered clock through the mux devices Ivan Vecera
2026-11-27 20:35   ` sashiko-bot [this message]
2026-11-26 20:32 ` [PATCH RFC net-next 15/19] dpll: register pins only with a parent pin of their owner Ivan Vecera
2026-11-26 20:32 ` [PATCH RFC net-next 16/19] dpll: drop the in-kernel notifier chain Ivan Vecera
2026-11-26 20:32 ` [PATCH RFC net-next 17/19] dpll: require a registered DPLL for pin registration Ivan Vecera
2026-11-26 20:32 ` [PATCH RFC net-next 18/19] dpll: drop the owner reference selection of pins Ivan Vecera
2026-11-26 20:32 ` [PATCH RFC net-next 19/19] dpll: add KUnit tests for the pin owner checks 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=sashiko-outbox-238256@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=ivecera@redhat.com \
    --cc=sashiko-reviews@lists.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