diff --git a/drivers/net/ethernet/intel/ice/ice_dpll.c b/drivers/net/ethernet/intel/ice/ice_dpll.c
index 5148e419f49a07..15b5f4a15af915 100644
--- a/drivers/net/ethernet/intel/ice/ice_dpll.c
+++ b/drivers/net/ethernet/intel/ice/ice_dpll.c
@@ -85,6 +85,8 @@ static const char * const pin_type_name[] = {
static const char * const ice_dpll_sw_pin_sma[] = { "SMA1", "SMA2" };
static const char * const ice_dpll_sw_pin_ufl[] = { "U.FL1", "U.FL2" };
static const char * const ice_dpll_ext_eref_pin = "EXT_EREF0";
+static const char * const ice_dpll_ext_synce_pin = "EXT_SYNCE";
+static const char * const ice_dpll_time_ref_pin = "TIME_REF";
static const char * const ice_dpll_fwnode_ext_synce = "clk_ref_synce";
static const char * const ice_dpll_fwnode_time_ref = "time_ref";
@@ -3792,8 +3794,6 @@ static void ice_dpll_pin_notify_work(struct work_struct *work)
struct ice_dpll_pin_work,
work);
struct ice_dpll_pin *pin, *parent = w->pin;
- bool is_tx_synce_parent = false;
- bool is_tspll_time_ref = false;
struct ice_pf *pf = parent->pf;
bool is_rclk_parent = false;
int ret;
@@ -3811,14 +3811,7 @@ static void ice_dpll_pin_notify_work(struct work_struct *work)
}
}
- is_tx_synce_parent =
- ice_dpll_fwnode_eq(parent->fwnode,
- pf->dplls.txclks[E825_EXT_SYNCE_PIN_IDX].fwnode);
-
- is_tspll_time_ref =
- ice_dpll_fwnode_eq(parent->fwnode, pf->dplls.tspll_in.fwnode);
-
- if (!is_rclk_parent && !is_tx_synce_parent && !is_tspll_time_ref)
+ if (!is_rclk_parent)
goto out;
switch (w->action) {@@ -3837,40 +3830,15 @@ static void ice_dpll_pin_notify_work(struct work_struct *work)
goto out;
}
- if (is_rclk_parent) {
- /* Register rclk pin via on-pin relationship */
- pin = &pf->dplls.rclk;
- ret = dpll_pin_on_pin_register(parent->pin, pin->pin,
- &ice_dpll_rclk_ops, pin);
- if (ret) {
- dev_err(ice_pf_to_dev(pf),
- "RCLK pin register failed: %pe\n",
- ERR_PTR(ret));
- goto drop_parent_ref;
- }
- } else if (is_tx_synce_parent) {
- /* Register TX-CLK SYNCE pin directly to TXC DPLL */
- pin = &pf->dplls.txclks[E825_EXT_SYNCE_PIN_IDX];
- ret = dpll_pin_register(pf->dplls.txc.dpll, pin->pin,
- &ice_dpll_txclk_ops, pin);
- if (ret) {
- dev_err(ice_pf_to_dev(pf),
- "TX SYNCE pin register failed: %pe\n",
- ERR_PTR(ret));
- goto drop_parent_ref;
- }
- } else if (is_tspll_time_ref) {
- /* Register TIME_REF pin directly to TSPLL DPLL */
- ret = dpll_pin_register(pf->dplls.tspll.dpll,
- parent->pin,
- &ice_dpll_tspll_in_ops,
- parent);
- if (ret) {
- dev_err(ice_pf_to_dev(pf),
- "TSPLL TIME_REF pin register failed: %pe\n",
- ERR_PTR(ret));
- goto drop_parent_ref;
- }
+ /* Register rclk pin via on-pin relationship */
+ pin = &pf->dplls.rclk;
+ ret = dpll_pin_on_pin_register(parent->pin, pin->pin,
+ &ice_dpll_rclk_ops, pin);
+ if (ret) {
+ dev_err(ice_pf_to_dev(pf),
+ "RCLK pin register failed: %pe\n",
+ ERR_PTR(ret));
+ goto drop_parent_ref;
}
break;
case DPLL_PIN_DELETED:@@ -3879,22 +3847,10 @@ static void ice_dpll_pin_notify_work(struct work_struct *work)
goto out;
}
- if (is_rclk_parent) {
- /* Unregister rclk pin */
- pin = &pf->dplls.rclk;
- dpll_pin_on_pin_unregister(parent->pin, pin->pin,
- &ice_dpll_rclk_ops, pin);
- } else if (is_tx_synce_parent) {
- /* Unregister TX-CLK SYNCE pin from TXC DPLL */
- pin = &pf->dplls.txclks[E825_EXT_SYNCE_PIN_IDX];
- dpll_pin_unregister(pf->dplls.txc.dpll, pin->pin,
- &ice_dpll_txclk_ops, pin);
- } else if (is_tspll_time_ref) {
- /* Unregister TIME_REF pin from TSPLL DPLL */
- dpll_pin_unregister(pf->dplls.tspll.dpll,
- parent->pin,
- &ice_dpll_tspll_in_ops, parent);
- }
+ /* Unregister rclk pin */
+ pin = &pf->dplls.rclk;
+ dpll_pin_on_pin_unregister(parent->pin, pin->pin,
+ &ice_dpll_rclk_ops, pin);
drop_parent_ref:
/* Drop fwnode pin reference */
dpll_pin_put(parent->pin, &parent->tracker);@@ -4067,43 +4023,36 @@ ice_dpll_deinit_fwnode_pins(struct ice_pf *pf, struct ice_dpll_pin *pins,
destroy_workqueue(pf->dplls.wq);
}
-static int ice_dpll_deinit_txclk_pins(struct ice_pf *pf, bool flush)
+static void ice_dpll_deinit_txclk_pins(struct ice_pf *pf)
{
- struct ice_dpll_pin *synce_pin = &pf->dplls.txclks[E825_EXT_SYNCE_PIN_IDX];
- struct ice_dpll *dt = &pf->dplls.txc;
+ struct ice_dplls *d = &pf->dplls;
+ int i;
- ice_dpll_stop_fwnode_pin_activity(synce_pin, flush);
- ice_dpll_unregister_pins(dt->dpll, pf->dplls.txclks,
- &ice_dpll_txclk_ops,
- ARRAY_SIZE(pf->dplls.txclks));
- ice_dpll_release_pins(&pf->dplls.txclks[E825_EXT_EREF_PIN_IDX], 1);
- /* ice_dpll_release_pins() puts the pin but does not clear the slot,
- * unlike ice_dpll_release_fwnode_pin() used for SYNCE below. NULL it
- * so a late ice_txclk_get_pin() returns NULL rather than a dangling
- * pointer.
+ ice_dpll_unregister_pins(d->txc.dpll, d->txclks, &ice_dpll_txclk_ops,
+ ARRAY_SIZE(d->txclks));
+ ice_dpll_release_pins(d->txclks, ARRAY_SIZE(d->txclks));
+ /* ice_dpll_release_pins() puts the pins but does not clear the slots.
+ * Clear them so a late ice_txclk_get_pin() returns NULL rather than a
+ * dangling pointer.
*/
- pf->dplls.txclks[E825_EXT_EREF_PIN_IDX].pin = NULL;
- ice_dpll_release_fwnode_pin(synce_pin);
- return 0;
+ for (i = 0; i < ARRAY_SIZE(d->txclks); i++)
+ d->txclks[i].pin = NULL;
}
/**
- * ice_dpll_deinit_tspll_pins - deinitialize TSPLL fwnode pin
+ * ice_dpll_deinit_tspll_pins - deinitialize TSPLL pin
* @pf: board private structure
*
- * Stop notifier activity and release the TIME_REF fwnode pin, unregistering
- * it from the TSPLL DPLL if it was registered.
+ * Unregister the TIME_REF pin from the TSPLL DPLL and release it.
*/
static void ice_dpll_deinit_tspll_pins(struct ice_pf *pf)
{
struct ice_dpll_pin *time_ref = &pf->dplls.tspll_in;
- struct ice_dpll *tp = &pf->dplls.tspll;
- ice_dpll_stop_fwnode_pin_activity(time_ref, true);
- if (!IS_ERR_OR_NULL(time_ref->pin))
- dpll_pin_unregister(tp->dpll, time_ref->pin,
- &ice_dpll_tspll_in_ops, time_ref);
- ice_dpll_release_fwnode_pin(time_ref);
+ ice_dpll_unregister_pins(pf->dplls.tspll.dpll, time_ref,
+ &ice_dpll_tspll_in_ops, 1);
+ ice_dpll_release_pins(time_ref, 1);
+ time_ref->pin = NULL;
}
/**@@ -4129,7 +4078,7 @@ static void ice_dpll_deinit_pins(struct ice_pf *pf, bool cgu)
if (ice_pf_src_tmr_owned(pf) &&
test_bit(ICE_FLAG_PTP_SUPPORTED, pf->flags))
ice_dpll_deinit_tspll_pins(pf);
- ice_dpll_deinit_txclk_pins(pf, true);
+ ice_dpll_deinit_txclk_pins(pf);
ice_dpll_deinit_fwnode_pins(pf, pf->dplls.inputs, 0);
}
if (cgu) {@@ -4173,6 +4122,34 @@ ice_dpll_pin_node_get(struct ice_pf *pf, const char *name)
return fwnode_find_reference(fwnode, "dpll-pins", index);
}
+/**
+ * ice_dpll_pin_link_add - link a pin with the pin wired to it
+ * @pf: board private structure
+ * @pin: pin of the driver
+ * @name: name of the firmware node of the pin at the other end
+ *
+ * Return:
+ * * 0 - success
+ * * negative - failure reason
+ */
+static int ice_dpll_pin_link_add(struct ice_pf *pf, struct dpll_pin *pin,
+ const char *name)
+{
+ struct fwnode_handle *fwnode;
+ int ret;
+
+ fwnode = ice_dpll_pin_node_get(pf, name);
+ if (IS_ERR(fwnode)) {
+ dev_err(ice_pf_to_dev(pf),
+ "Failed to find %s firmware node: %pe\n", name, fwnode);
+ return -ENODEV;
+ }
+ ret = dpll_pin_link_add(pin, fwnode);
+ fwnode_handle_put(fwnode);
+
+ return ret;
+}
+
static int
ice_dpll_init_fwnode_pin(struct ice_dpll_pin *pin, const char *name)
{@@ -4266,77 +4243,58 @@ ice_dpll_init_fwnode_pins(struct ice_pf *pf, struct ice_dpll_pin *pins,
return ret;
}
-static int ice_dpll_init_txclk_pins(struct ice_pf *pf, int start_idx)
+/**
+ * ice_dpll_init_txclk_pins - init and register TX reference clock pins
+ * @pf: board private structure
+ *
+ * Get the EXT_EREF0 and EXT_SYNCE pins, link EXT_SYNCE with the pin wired to
+ * it and register both pins with the TXC DPLL.
+ *
+ * Return:
+ * * 0 - success
+ * * negative - initialization failure reason
+ */
+static int ice_dpll_init_txclk_pins(struct ice_pf *pf)
{
- struct ice_dpll_pin *ref_pin = pf->dplls.txclks;
+ struct ice_dpll_pin *pins = pf->dplls.txclks;
struct ice_dpll *txc = &pf->dplls.txc;
u64 clock_id;
- int ret;
+ int ret, i;
- /* EXT_EREF0 is a non-fwnode pin; its clock_id must match the TX-CLK
- * DPLL device clock_id (see dpll_pin_register()).
+ /* The clock_id of the pins must match the TXC DPLL device clock_id
+ * (see dpll_pin_register()). Without a valid MAC address it is the
+ * clock_id of the other DPLLs of the NIC, so the pin indices are
+ * dynamic to keep the pins distinct.
*/
clock_id = ice_generate_dpll_clock_id(pf, txc, DPLL_TYPE_GENERIC);
-
- /* Configure EXT_EREF0 pin */
- ret = ice_dpll_get_pins(pf, ref_pin, start_idx, 1, clock_id);
+ ret = ice_dpll_get_pins(pf, pins, DPLL_PIN_IDX_UNSPEC,
+ ICE_DPLL_TXCLK_NUM_MAX, clock_id);
if (ret)
return ret;
- ret = dpll_pin_register(txc->dpll, ref_pin->pin, &ice_dpll_txclk_ops,
- ref_pin);
+ ret = ice_dpll_pin_link_add(pf, pins[E825_EXT_SYNCE_PIN_IDX].pin,
+ ice_dpll_fwnode_ext_synce);
if (ret)
- goto err_release_ext_eref;
-
- /*
- * Configure EXT_SYNCE pin (fwnode-backed).
- * The pin may not yet be available; in that case registration
- * will be deferred via the notifier path.
- */
- ref_pin++;
- ret = ice_dpll_init_fwnode_pin(ref_pin, ice_dpll_fwnode_ext_synce);
- if (ret)
- goto err_unregister_ext_eref;
-
- if (IS_ERR_OR_NULL(ref_pin->pin)) {
- dev_dbg(ice_pf_to_dev(pf),
- "Tx-clk SYNCE pin not registered yet\n");
- return 0;
- }
-
- ret = dpll_pin_register(txc->dpll, ref_pin->pin, &ice_dpll_txclk_ops,
- ref_pin);
+ goto release_pins;
+ ret = ice_dpll_register_pins(txc->dpll, pins, &ice_dpll_txclk_ops,
+ ICE_DPLL_TXCLK_NUM_MAX);
if (ret)
- goto err_deinit_synce;
+ goto release_pins;
return 0;
-err_deinit_synce:
- /*
- * Avoid deadlock against notifier workers blocked on dpll_init.
- * The outer init error path will complete dpll_init and flush the
- * shared workqueue before destroying it.
- */
- ice_dpll_stop_fwnode_pin_activity(ref_pin, false);
- ice_dpll_release_fwnode_pin(ref_pin);
-err_unregister_ext_eref:
- dpll_pin_unregister(txc->dpll,
- pf->dplls.txclks[E825_EXT_EREF_PIN_IDX].pin,
- &ice_dpll_txclk_ops,
- &pf->dplls.txclks[E825_EXT_EREF_PIN_IDX]);
-
-err_release_ext_eref:
- ice_dpll_release_pins(&pf->dplls.txclks[E825_EXT_EREF_PIN_IDX], 1);
-
+release_pins:
+ ice_dpll_release_pins(pins, ICE_DPLL_TXCLK_NUM_MAX);
+ for (i = 0; i < ICE_DPLL_TXCLK_NUM_MAX; i++)
+ pins[i].pin = NULL;
return ret;
}
/**
- * ice_dpll_init_tspll_pins - init and register TSPLL TIME_REF fwnode pin
+ * ice_dpll_init_tspll_pins - init and register TSPLL TIME_REF pin
* @pf: board private structure
*
- * Initialize the fwnode-based TIME_REF input pin for the TSPLL DPLL on E825.
- * If the pin is not yet available in the dpll subsystem, registration will
- * be deferred via the notifier path.
+ * Get the TIME_REF input pin of the TSPLL DPLL on E825, link it with the pin
+ * wired to it and register it with the TSPLL DPLL.
*
* Return:
* * 0 - success@@ -4346,26 +4304,36 @@ static int ice_dpll_init_tspll_pins(struct ice_pf *pf)
{
struct ice_dpll_pin *time_ref = &pf->dplls.tspll_in;
struct ice_dpll *tp = &pf->dplls.tspll;
+ u64 clock_id;
int ret;
time_ref->pf = pf;
- ret = ice_dpll_init_fwnode_pin(time_ref, ice_dpll_fwnode_time_ref);
+ time_ref->prop.type = DPLL_PIN_TYPE_EXT;
+ time_ref->prop.capabilities = DPLL_PIN_CAPABILITIES_STATE_CAN_CHANGE;
+ time_ref->prop.board_label = ice_dpll_time_ref_pin;
+
+ /* The clock_id of the pin must match the TSPLL DPLL device clock_id
+ * (see dpll_pin_register()), the pin index is dynamic as for the TX
+ * reference pins.
+ */
+ clock_id = ice_generate_dpll_clock_id(pf, tp, DPLL_TYPE_GENERIC);
+ ret = ice_dpll_get_pins(pf, time_ref, DPLL_PIN_IDX_UNSPEC, 1, clock_id);
if (ret)
return ret;
-
- if (IS_ERR_OR_NULL(time_ref->pin)) {
- dev_dbg(ice_pf_to_dev(pf),
- "TSPLL TIME_REF pin not registered yet\n");
- return 0;
- }
-
+ ret = ice_dpll_pin_link_add(pf, time_ref->pin,
+ ice_dpll_fwnode_time_ref);
+ if (ret)
+ goto release_pin;
ret = dpll_pin_register(tp->dpll, time_ref->pin,
&ice_dpll_tspll_in_ops, time_ref);
- if (ret) {
- ice_dpll_stop_fwnode_pin_activity(time_ref, false);
- ice_dpll_release_fwnode_pin(time_ref);
- }
+ if (ret)
+ goto release_pin;
+
+ return 0;
+release_pin:
+ ice_dpll_release_pins(time_ref, 1);
+ time_ref->pin = NULL;
return ret;
}
@@ -4394,7 +4362,7 @@ static int ice_dpll_init_pins_e825(struct ice_pf *pf)
if (ret)
goto unregister_pins;
- ret = ice_dpll_init_txclk_pins(pf, 0);
+ ret = ice_dpll_init_txclk_pins(pf);
if (ret) {
ice_dpll_deinit_rclk_pin(pf);
goto unregister_pins;@@ -4404,12 +4372,7 @@ static int ice_dpll_init_pins_e825(struct ice_pf *pf)
test_bit(ICE_FLAG_PTP_SUPPORTED, pf->flags)) {
ret = ice_dpll_init_tspll_pins(pf);
if (ret) {
- /* Avoid flushing pf->dplls.wq here: notifier work
- * items block on pf->dplls.dpll_init which is
- * completed by the unregister_pins path below.
- * destroy_workqueue() there drains queued items.
- */
- ice_dpll_deinit_txclk_pins(pf, false);
+ ice_dpll_deinit_txclk_pins(pf);
ice_dpll_deinit_rclk_pin(pf);
}
}@@ -4964,6 +4927,7 @@ static int ice_dpll_init_info_txclk_pins_e825c(struct ice_pf *pf)
tx_pin->prop.board_label = ice_dpll_ext_eref_pin;
tx_pin->tx_ref_src = ICE_REF_CLK_EREF0;
} else if (i == E825_EXT_SYNCE_PIN_IDX) {
+ tx_pin->prop.board_label = ice_dpll_ext_synce_pin;
tx_pin->tx_ref_src = ICE_REF_CLK_SYNCE;
}
}diff --git a/drivers/net/ethernet/intel/ice/ice_dpll.h b/drivers/net/ethernet/intel/ice/ice_dpll.h
index 3f9a993129acef..e0b48c8af3fbbb 100644
--- a/drivers/net/ethernet/intel/ice/ice_dpll.h
+++ b/drivers/net/ethernet/intel/ice/ice_dpll.h
@@ -138,7 +138,7 @@ struct ice_dpll {
* @outputs: output pins pointer
* @rclk: recovered pins pointer
* @txclks: TX clock reference pins pointer
- * @tspll_in: TSPLL TIME_REF fwnode input pin (E825 only)
+ * @tspll_in: TSPLL TIME_REF input pin (E825 only)
* @num_inputs: number of input pins available on dpll
* @num_outputs: number of output pins available on dpll
* @cgu_state_acq_err_num: number of errors returned during periodic work--
2.56.1