igc: Fix double reset adapter triggered from a single taprio cmd
Subsystems (4)
PATCH 1/1 igc: Fix double reset adapter triggered from a single taprio cmd
Following the implementation of "igc: Add TransmissionOverrun counter" patch, when a taprio command is triggered by user, igc processes two
commands: TAPRIO_CMD_REPLACE followed by TAPRIO_CMD_STATS. However, both commands unconditionally pass through igc_tsn_offload_apply() which evaluates and triggers reset adapter. The double reset causes issues in the calculation of adapter->qbv_count in igc.
TAPRIO_CMD_REPLACE command is expected to reset the adapter since it activates qbv. It's unexpected for TAPRIO_CMD_STATS to do the same because it doesn't configure any driver-specific TSN settings. So, the evaluation in igc_tsn_offload_apply() isn't needed for TAPRIO_CMD_STATS.
To address this, commands parsing are relocated to igc_tsn_enable_qbv_scheduling(). Commands that don't require an adapter reset will exit after processing, thus avoiding igc_tsn_offload_apply().
--- drivers/net/ethernet/intel/igc/igc_main.c | 33 ++++++++++++----------- 1 file changed, 17 insertions(+), 16 deletions(-)
drivers/net/ethernet/intel/igc/igc_main.c +17 -16
@@ -6310,21 +6310,6 @@ static int igc_save_qbv_schedule(struct igc_adapter *adapter,size_t n;int i; -switch (qopt->cmd) { -case TAPRIO_CMD_REPLACE : -break ; -case TAPRIO_CMD_DESTROY : -return igc_tsn_clear_schedule (adapter); -case TAPRIO_CMD_STATS : -igc_taprio_stats (adapter->netdev, &qopt->stats); -return 0 ; -case TAPRIO_CMD_QUEUE_STATS : -igc_taprio_queue_stats (adapter->netdev, &qopt->queue_stats); -return 0 ; -default : -return -EOPNOTSUPP ; - } -if (qopt->base_time <0 )return -ERANGE ;
@@ -6433,7 +6418,23 @@ static int igc_tsn_enable_qbv_scheduling(struct igc_adapter *adapter,if (hw->mac.type != igc_i225)return -EOPNOTSUPP ; - err =igc_save_qbv_schedule (adapter, qopt); +switch (qopt->cmd) { +case TAPRIO_CMD_REPLACE : + err =igc_save_qbv_schedule (adapter, qopt); +break ; +case TAPRIO_CMD_DESTROY : + err =igc_tsn_clear_schedule (adapter); +break ; +case TAPRIO_CMD_STATS : +igc_taprio_stats (adapter->netdev, &qopt->stats); +return 0 ; +case TAPRIO_CMD_QUEUE_STATS : +igc_taprio_queue_stats (adapter->netdev, &qopt->queue_stats); +return 0 ; +default : +return -EOPNOTSUPP ; + } +if (err)return err;
--
2.25.1
kernel test robot
build botFYI: kernel test robot notices the stable kernel rule is not satisfied.
Hi,
Thanks for your patch.
FYI: kernel test robot notices the stable kernel rule is not satisfied.
The check is based on https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html#option-1
Rule: add the tag "Cc: [email protected]" in the sign-off area to have the patch automatically included in the stable tree.
Subject: [PATCH net 1/1] igc: Fix double reset adapter triggered from a single taprio cmd
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Added Vladimir and Husaini in CC.
Quoted 76 lines · Faizal Rahim
Following the implementation of "igc: Add TransmissionOverrun counter" patch, when a taprio command is triggered by user, igc processes two
commands:TAPRIO_CMD_REPLACEfollowed byTAPRIO_CMD_STATS. However, both commands unconditionally pass throughigc_tsn_offload_apply()which evaluates and triggers reset adapter. The double reset causes issues in the calculation ofadapter->qbv_countin igc.
TAPRIO_CMD_REPLACEcommand is expected to reset the adapter since it activates qbv. It's unexpected forTAPRIO_CMD_STATSto do the same because it doesn't configure any driver-specific TSN settings. So, the evaluation inigc_tsn_offload_apply()isn't needed forTAPRIO_CMD_STATS.To address this, commands parsing are relocated to
igc_tsn_enable_qbv_scheduling(). Commands that don't require an adapter reset will exit after processing, thus avoidingigc_tsn_offload_apply().Fixes d3750076d464 ("igc: Add TransmissionOverrun counter")Signed-off-by Faizal Rahim <[email protected]>--- drivers/net/ethernet/intel/igc/igc_main.c | 33 ++++++++++++----------- 1 file changed, 17 insertions(+), 16 deletions(-)drivers/net/ethernet/intel/igc/igc_main.c +17
-17@@ -6310,21 +6310,6 @@ static int igc_save_qbv_schedule(struct igc_adapter *adapter,size_t n;int i; -switch (qopt->cmd) { -case TAPRIO_CMD_REPLACE : -break ; -case TAPRIO_CMD_DESTROY : -return igc_tsn_clear_schedule (adapter); -case TAPRIO_CMD_STATS : -igc_taprio_stats (adapter->netdev, &qopt->stats); -return 0 ; -case TAPRIO_CMD_QUEUE_STATS : -igc_taprio_queue_stats (adapter->netdev, &qopt->queue_stats); -return 0 ; -default : -return -EOPNOTSUPP ; - } -if (qopt->base_time <0 )return -ERANGE ;@@ -6433,7 +6418,23 @@ static int igc_tsn_enable_qbv_scheduling(struct igc_adapter *adapter,if (hw->mac.type != igc_i225)return -EOPNOTSUPP ; - err =igc_save_qbv_schedule (adapter, qopt); +switch (qopt->cmd) { +case TAPRIO_CMD_REPLACE : + err =igc_save_qbv_schedule (adapter, qopt); +break ; +case TAPRIO_CMD_DESTROY : + err =igc_tsn_clear_schedule (adapter); +break ; +case TAPRIO_CMD_STATS : +igc_taprio_stats (adapter->netdev, &qopt->stats); +return 0 ; +case TAPRIO_CMD_QUEUE_STATS : +igc_taprio_queue_stats (adapter->netdev, &qopt->queue_stats); +return 0 ; +default : +return -EOPNOTSUPP ; + } +if (err)return err; --2.25.1
Vladimir Oltean
Reviewed-byQuoted 22 lines · Faizal
Added Vladimir and Husaini in CC.
Quoted 19 lines · Faizal Rahim
Following the implementation of "igc: Add TransmissionOverrun counter" patch, when a taprio command is triggered by user, igc processes two
commands:TAPRIO_CMD_REPLACEfollowed byTAPRIO_CMD_STATS. However, both commands unconditionally pass throughigc_tsn_offload_apply()which evaluates and triggers reset adapter. The double reset causes issues in the calculation ofadapter->qbv_countin igc.
TAPRIO_CMD_REPLACEcommand is expected to reset the adapter since it activates qbv. It's unexpected forTAPRIO_CMD_STATSto do the same because it doesn't configure any driver-specific TSN settings. So, the evaluation inigc_tsn_offload_apply()isn't needed forTAPRIO_CMD_STATS.To address this, commands parsing are relocated to
igc_tsn_enable_qbv_scheduling(). Commands that don't require an adapter reset will exit after processing, thus avoidingigc_tsn_offload_apply().Fixes d3750076d464 ("igc: Add TransmissionOverrun counter")Signed-off-by Faizal Rahim <[email protected]>---
Thank you for the patch. The code organization is much more logical this way.
Quoted 60 lines · Faizal Rahim
Following the implementation of "igc: Add TransmissionOverrun counter" patch, when a taprio command is triggered by user, igc processes two
commands:TAPRIO_CMD_REPLACEfollowed byTAPRIO_CMD_STATS. However, both commands unconditionally pass throughigc_tsn_offload_apply()which evaluates and triggers reset adapter. The double reset causes issues in the calculation ofadapter->qbv_countin igc.
TAPRIO_CMD_REPLACEcommand is expected to reset the adapter since it activates qbv. It's unexpected forTAPRIO_CMD_STATSto do the same because it doesn't configure any driver-specific TSN settings. So, the evaluation inigc_tsn_offload_apply()isn't needed forTAPRIO_CMD_STATS.To address this, commands parsing are relocated to
igc_tsn_enable_qbv_scheduling(). Commands that don't require an adapter reset will exit after processing, thus avoidingigc_tsn_offload_apply().Fixes d3750076d464 ("igc: Add TransmissionOverrun counter")Signed-off-by Faizal Rahim <[email protected]>--- drivers/net/ethernet/intel/igc/igc_main.c | 33 ++++++++++++----------- 1 file changed, 17 insertions(+), 16 deletions(-)drivers/net/ethernet/intel/igc/igc_main.c +7
-16@@ -6310,21 +6310,6 @@ static int igc_save_qbv_schedule(struct igc_adapter *adapter,size_t n;int i; -switch (qopt->cmd) { -case TAPRIO_CMD_REPLACE : -break ; -case TAPRIO_CMD_DESTROY : -return igc_tsn_clear_schedule (adapter); -case TAPRIO_CMD_STATS : -igc_taprio_stats (adapter->netdev, &qopt->stats); -return 0 ; -case TAPRIO_CMD_QUEUE_STATS : -igc_taprio_queue_stats (adapter->netdev, &qopt->queue_stats); -return 0 ; -default : -return -EOPNOTSUPP ; - } -if (qopt->base_time <0 )return -ERANGE ;@@ -6433,7 +6418,23 @@ static int igc_tsn_enable_qbv_scheduling(struct igc_adapter *adapter,if (hw->mac.type != igc_i225)return -EOPNOTSUPP ; - err =igc_save_qbv_schedule (adapter, qopt); +switch (qopt->cmd) { +case TAPRIO_CMD_REPLACE : + err =igc_save_qbv_schedule (adapter, qopt); +break ; +case TAPRIO_CMD_DESTROY : + err =igc_tsn_clear_schedule (adapter); +break ;
drivers/net/ethernet/intel/igc/igc_main.c static int igc_tsn_enable_qbv_scheduling(struct igc_adapter *adapter, · line 6437
Quoted 10 lines
drivers/net/ethernet/intel/igc/igc_main.c +10
-0+case TAPRIO_CMD_STATS : +igc_taprio_stats (adapter->netdev, &qopt->stats); +return 0 ; +case TAPRIO_CMD_QUEUE_STATS : +igc_taprio_queue_stats (adapter->netdev, &qopt->queue_stats); +return 0 ; +default : +return -EOPNOTSUPP ; + } +
Yeah, moving the command parsing to be done earlier sounds like the right fix:
Quoted 6 lines
drivers/net/ethernet/intel/igc/igc_main.c +0
-1if (err)return err; --2.25.1
Signature · 1 line
Vinicius
Quoted 16 lines · Faizal Rahim
Following the implementation of "igc: Add TransmissionOverrun counter" patch, when a taprio command is triggered by user, igc processes two
commands:TAPRIO_CMD_REPLACEfollowed byTAPRIO_CMD_STATS. However, both commands unconditionally pass throughigc_tsn_offload_apply()which evaluates and triggers reset adapter. The double reset causes issues in the calculation ofadapter->qbv_countin igc.
TAPRIO_CMD_REPLACEcommand is expected to reset the adapter since it activates qbv. It's unexpected forTAPRIO_CMD_STATSto do the same because it doesn't configure any driver-specific TSN settings. So, the evaluation inigc_tsn_offload_apply()isn't needed forTAPRIO_CMD_STATS.To address this, commands parsing are relocated to
igc_tsn_enable_qbv_scheduling(). Commands that don't require an adapter reset will exit after processing, thus avoidingigc_tsn_offload_apply().
Quoted 8 lines
Fixes d3750076d464 ("igc: Add TransmissionOverrun counter")Signed-off-by Faizal Rahim <[email protected]>Reviewed-by Vladimir Oltean <[email protected]>--- drivers/net/ethernet/intel/igc/igc_main.c | 33 ++++++++++++----------- 1 file changed, 17 insertions(+), 16 deletions(-)