Update the Intel ICE driver to utilize the DPLL reference count tracking
infrastructure.

Add .dpll_tracker fields to the internal struct ice_dpll and struct
ice_dpll_pin structures.

Pass pointers to these trackers to the dpll_device_get/put() and
dpll_pin_get/put() functions, replacing the temporary NULL values.

This enables developers to trace reference ownership for the ICE driver's
DPLL resources via the ref_tracker debugfs interface when
CONFIG_DPLL_REFCNT_TRACKER is enabled.

Signed-off-by: Ivan Vecera <[email protected]>
---
 drivers/net/ethernet/intel/ice/ice_dpll.c | 16 +++++++++-------
 drivers/net/ethernet/intel/ice/ice_dpll.h |  4 ++++
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_dpll.c 
b/drivers/net/ethernet/intel/ice/ice_dpll.c
index 39cf26987b35c..ff1b597051e8f 100644
--- a/drivers/net/ethernet/intel/ice/ice_dpll.c
+++ b/drivers/net/ethernet/intel/ice/ice_dpll.c
@@ -2814,7 +2814,7 @@ static void ice_dpll_release_pins(struct ice_dpll_pin 
*pins, int count)
        int i;
 
        for (i = 0; i < count; i++)
-               dpll_pin_put(pins[i].pin, NULL);
+               dpll_pin_put(pins[i].pin, &pins[i].tracker);
 }
 
 /**
@@ -2840,7 +2840,8 @@ ice_dpll_get_pins(struct ice_pf *pf, struct ice_dpll_pin 
*pins,
 
        for (i = 0; i < count; i++) {
                pins[i].pin = dpll_pin_get(clock_id, i + start_idx, THIS_MODULE,
-                                          &pins[i].prop, NULL, NULL);
+                                          &pins[i].prop, NULL,
+                                          &pins[i].tracker);
                if (IS_ERR(pins[i].pin)) {
                        ret = PTR_ERR(pins[i].pin);
                        goto release_pins;
@@ -2851,7 +2852,7 @@ ice_dpll_get_pins(struct ice_pf *pf, struct ice_dpll_pin 
*pins,
 
 release_pins:
        while (--i >= 0)
-               dpll_pin_put(pins[i].pin, NULL);
+               dpll_pin_put(pins[i].pin, &pins[i].tracker);
        return ret;
 }
 
@@ -3037,7 +3038,7 @@ static void ice_dpll_deinit_rclk_pin(struct ice_pf *pf)
        if (WARN_ON_ONCE(!vsi || !vsi->netdev))
                return;
        dpll_netdev_pin_clear(vsi->netdev);
-       dpll_pin_put(rclk->pin, NULL);
+       dpll_pin_put(rclk->pin, &rclk->tracker);
 }
 
 /**
@@ -3247,7 +3248,7 @@ ice_dpll_deinit_dpll(struct ice_pf *pf, struct ice_dpll 
*d, bool cgu)
 {
        if (cgu)
                dpll_device_unregister(d->dpll, d->ops, d);
-       dpll_device_put(d->dpll, NULL);
+       dpll_device_put(d->dpll, &d->tracker);
 }
 
 /**
@@ -3271,7 +3272,8 @@ ice_dpll_init_dpll(struct ice_pf *pf, struct ice_dpll *d, 
bool cgu,
        u64 clock_id = pf->dplls.clock_id;
        int ret;
 
-       d->dpll = dpll_device_get(clock_id, d->dpll_idx, THIS_MODULE, NULL);
+       d->dpll = dpll_device_get(clock_id, d->dpll_idx, THIS_MODULE,
+                                 &d->tracker);
        if (IS_ERR(d->dpll)) {
                ret = PTR_ERR(d->dpll);
                dev_err(ice_pf_to_dev(pf),
@@ -3287,7 +3289,7 @@ ice_dpll_init_dpll(struct ice_pf *pf, struct ice_dpll *d, 
bool cgu,
                ice_dpll_update_state(pf, d, true);
                ret = dpll_device_register(d->dpll, type, ops, d);
                if (ret) {
-                       dpll_device_put(d->dpll, NULL);
+                       dpll_device_put(d->dpll, &d->tracker);
                        return ret;
                }
                d->ops = ops;
diff --git a/drivers/net/ethernet/intel/ice/ice_dpll.h 
b/drivers/net/ethernet/intel/ice/ice_dpll.h
index c0da03384ce91..63fac6510df6e 100644
--- a/drivers/net/ethernet/intel/ice/ice_dpll.h
+++ b/drivers/net/ethernet/intel/ice/ice_dpll.h
@@ -23,6 +23,7 @@ enum ice_dpll_pin_sw {
 /** ice_dpll_pin - store info about pins
  * @pin: dpll pin structure
  * @pf: pointer to pf, which has registered the dpll_pin
+ * @tracker: reference count tracker
  * @idx: ice pin private idx
  * @num_parents: hols number of parent pins
  * @parent_idx: hold indexes of parent pins
@@ -37,6 +38,7 @@ enum ice_dpll_pin_sw {
 struct ice_dpll_pin {
        struct dpll_pin *pin;
        struct ice_pf *pf;
+       dpll_tracker tracker;
        u8 idx;
        u8 num_parents;
        u8 parent_idx[ICE_DPLL_RCLK_NUM_MAX];
@@ -58,6 +60,7 @@ struct ice_dpll_pin {
 /** ice_dpll - store info required for DPLL control
  * @dpll: pointer to dpll dev
  * @pf: pointer to pf, which has registered the dpll_device
+ * @tracker: reference count tracker
  * @dpll_idx: index of dpll on the NIC
  * @input_idx: currently selected input index
  * @prev_input_idx: previously selected input index
@@ -76,6 +79,7 @@ struct ice_dpll_pin {
 struct ice_dpll {
        struct dpll_device *dpll;
        struct ice_pf *pf;
+       dpll_tracker tracker;
        u8 dpll_idx;
        u8 input_idx;
        u8 prev_input_idx;
-- 
2.51.2

Reply via email to