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 <[email protected]> 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/[email protected]?part=14
