Skip to content

Commit 6510459

Browse files
kubalewskianguy11
authored andcommitted
ice: fix max values for dpll pin phase adjust
Mask admin command returned max phase adjust value for both input and output pins. Only 31 bits are relevant, last released data sheet wrongly points that 32 bits are valid - see [1] 3.2.6.4.1 Get CCU Capabilities Command for reference. Fix of the datasheet itself is in progress. Fix the min/max assignment logic, previously the value was wrongly considered as negative value due to most significant bit being set. Example of previous broken behavior: $ ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/dpll.yaml \ --do pin-get --json '{"id":1}'| grep phase-adjust 'phase-adjust': 0, 'phase-adjust-max': 16723, 'phase-adjust-min': -16723, Correct behavior with the fix: $ ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/dpll.yaml \ --do pin-get --json '{"id":1}'| grep phase-adjust 'phase-adjust': 0, 'phase-adjust-max': 2147466925, 'phase-adjust-min': -2147466925, [1] https://cdrdv2.intel.com/v1/dl/getContent/613875?explicitVersion=true Fixes: 90e1c90 ("ice: dpll: implement phase related callbacks") Reviewed-by: Przemek Kitszel <[email protected]> Signed-off-by: Arkadiusz Kubalewski <[email protected]> Tested-by: Pucha Himasekhar Reddy <[email protected]> (A Contingent worker at Intel) Signed-off-by: Tony Nguyen <[email protected]>
1 parent fd48f07 commit 6510459

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

drivers/net/ethernet/intel/ice/ice_adminq_cmd.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2264,6 +2264,8 @@ struct ice_aqc_get_pkg_info_resp {
22642264
struct ice_aqc_get_pkg_info pkg_info[];
22652265
};
22662266

2267+
#define ICE_AQC_GET_CGU_MAX_PHASE_ADJ GENMASK(30, 0)
2268+
22672269
/* Get CGU abilities command response data structure (indirect 0x0C61) */
22682270
struct ice_aqc_get_cgu_abilities {
22692271
u8 num_inputs;

drivers/net/ethernet/intel/ice/ice_dpll.c

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2064,6 +2064,18 @@ static int ice_dpll_init_worker(struct ice_pf *pf)
20642064
return 0;
20652065
}
20662066

2067+
/**
2068+
* ice_dpll_phase_range_set - initialize phase adjust range helper
2069+
* @range: pointer to phase adjust range struct to be initialized
2070+
* @phase_adj: a value to be used as min(-)/max(+) boundary
2071+
*/
2072+
static void ice_dpll_phase_range_set(struct dpll_pin_phase_adjust_range *range,
2073+
u32 phase_adj)
2074+
{
2075+
range->min = -phase_adj;
2076+
range->max = phase_adj;
2077+
}
2078+
20672079
/**
20682080
* ice_dpll_init_info_pins_generic - initializes generic pins info
20692081
* @pf: board private structure
@@ -2105,8 +2117,8 @@ static int ice_dpll_init_info_pins_generic(struct ice_pf *pf, bool input)
21052117
for (i = 0; i < pin_num; i++) {
21062118
pins[i].idx = i;
21072119
pins[i].prop.board_label = labels[i];
2108-
pins[i].prop.phase_range.min = phase_adj_max;
2109-
pins[i].prop.phase_range.max = -phase_adj_max;
2120+
ice_dpll_phase_range_set(&pins[i].prop.phase_range,
2121+
phase_adj_max);
21102122
pins[i].prop.capabilities = cap;
21112123
pins[i].pf = pf;
21122124
ret = ice_dpll_pin_state_update(pf, &pins[i], pin_type, NULL);
@@ -2152,18 +2164,21 @@ ice_dpll_init_info_direct_pins(struct ice_pf *pf,
21522164
struct ice_hw *hw = &pf->hw;
21532165
struct ice_dpll_pin *pins;
21542166
unsigned long caps;
2167+
u32 phase_adj_max;
21552168
u8 freq_supp_num;
21562169
bool input;
21572170

21582171
switch (pin_type) {
21592172
case ICE_DPLL_PIN_TYPE_INPUT:
21602173
pins = pf->dplls.inputs;
21612174
num_pins = pf->dplls.num_inputs;
2175+
phase_adj_max = pf->dplls.input_phase_adj_max;
21622176
input = true;
21632177
break;
21642178
case ICE_DPLL_PIN_TYPE_OUTPUT:
21652179
pins = pf->dplls.outputs;
21662180
num_pins = pf->dplls.num_outputs;
2181+
phase_adj_max = pf->dplls.output_phase_adj_max;
21672182
input = false;
21682183
break;
21692184
default:
@@ -2188,19 +2203,13 @@ ice_dpll_init_info_direct_pins(struct ice_pf *pf,
21882203
return ret;
21892204
caps |= (DPLL_PIN_CAPABILITIES_PRIORITY_CAN_CHANGE |
21902205
DPLL_PIN_CAPABILITIES_STATE_CAN_CHANGE);
2191-
pins[i].prop.phase_range.min =
2192-
pf->dplls.input_phase_adj_max;
2193-
pins[i].prop.phase_range.max =
2194-
-pf->dplls.input_phase_adj_max;
21952206
} else {
2196-
pins[i].prop.phase_range.min =
2197-
pf->dplls.output_phase_adj_max;
2198-
pins[i].prop.phase_range.max =
2199-
-pf->dplls.output_phase_adj_max;
22002207
ret = ice_cgu_get_output_pin_state_caps(hw, i, &caps);
22012208
if (ret)
22022209
return ret;
22032210
}
2211+
ice_dpll_phase_range_set(&pins[i].prop.phase_range,
2212+
phase_adj_max);
22042213
pins[i].prop.capabilities = caps;
22052214
ret = ice_dpll_pin_state_update(pf, &pins[i], pin_type, NULL);
22062215
if (ret)
@@ -2308,8 +2317,10 @@ static int ice_dpll_init_info(struct ice_pf *pf, bool cgu)
23082317
dp->dpll_idx = abilities.pps_dpll_idx;
23092318
d->num_inputs = abilities.num_inputs;
23102319
d->num_outputs = abilities.num_outputs;
2311-
d->input_phase_adj_max = le32_to_cpu(abilities.max_in_phase_adj);
2312-
d->output_phase_adj_max = le32_to_cpu(abilities.max_out_phase_adj);
2320+
d->input_phase_adj_max = le32_to_cpu(abilities.max_in_phase_adj) &
2321+
ICE_AQC_GET_CGU_MAX_PHASE_ADJ;
2322+
d->output_phase_adj_max = le32_to_cpu(abilities.max_out_phase_adj) &
2323+
ICE_AQC_GET_CGU_MAX_PHASE_ADJ;
23132324

23142325
alloc_size = sizeof(*d->inputs) * d->num_inputs;
23152326
d->inputs = kzalloc(alloc_size, GFP_KERNEL);

0 commit comments

Comments
 (0)