Skip to content

Commit ac61251

Browse files
kaleshap86gregkh
authored andcommitted
bnxt_en: Fix wrong return value check in bnxt_close_nic()
[ Upstream commit bd6781c ] The wait_event_interruptible_timeout() function returns 0 if the timeout elapsed, -ERESTARTSYS if it was interrupted by a signal, and the remaining jiffies otherwise if the condition evaluated to true before the timeout elapsed. Driver should have checked for zero return value instead of a positive value. MChan: Print a warning for -ERESTARTSYS. The close operation will proceed anyway when wait_event_interruptible_timeout() returns for any reason. Since we do the close no matter what, we should not return this error code to the caller. Change bnxt_close_nic() to a void function and remove all error handling from some of the callers. Fixes: c0c050c ("bnxt_en: New Broadcom ethernet driver.") Reviewed-by: Andy Gospodarek <andrew.gospodarek@broadcom.com> Reviewed-by: Vikas Gupta <vikas.gupta@broadcom.com> Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com> Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com> Signed-off-by: Michael Chan <michael.chan@broadcom.com> Link: https://lore.kernel.org/r/20231208001658.14230-4-michael.chan@broadcom.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 8217f93 commit ac61251

5 files changed

Lines changed: 16 additions & 34 deletions

File tree

drivers/net/ethernet/broadcom/bnxt/bnxt.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10719,10 +10719,8 @@ static void __bnxt_close_nic(struct bnxt *bp, bool irq_re_init,
1071910719
bnxt_free_mem(bp, irq_re_init);
1072010720
}
1072110721

10722-
int bnxt_close_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)
10722+
void bnxt_close_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)
1072310723
{
10724-
int rc = 0;
10725-
1072610724
if (test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) {
1072710725
/* If we get here, it means firmware reset is in progress
1072810726
* while we are trying to close. We can safely proceed with
@@ -10737,15 +10735,18 @@ int bnxt_close_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)
1073710735

1073810736
#ifdef CONFIG_BNXT_SRIOV
1073910737
if (bp->sriov_cfg) {
10738+
int rc;
10739+
1074010740
rc = wait_event_interruptible_timeout(bp->sriov_cfg_wait,
1074110741
!bp->sriov_cfg,
1074210742
BNXT_SRIOV_CFG_WAIT_TMO);
10743-
if (rc)
10744-
netdev_warn(bp->dev, "timeout waiting for SRIOV config operation to complete!\n");
10743+
if (!rc)
10744+
netdev_warn(bp->dev, "timeout waiting for SRIOV config operation to complete, proceeding to close!\n");
10745+
else if (rc < 0)
10746+
netdev_warn(bp->dev, "SRIOV config operation interrupted, proceeding to close!\n");
1074510747
}
1074610748
#endif
1074710749
__bnxt_close_nic(bp, irq_re_init, link_re_init);
10748-
return rc;
1074910750
}
1075010751

1075110752
static int bnxt_close(struct net_device *dev)

drivers/net/ethernet/broadcom/bnxt/bnxt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2343,7 +2343,7 @@ int bnxt_open_nic(struct bnxt *, bool, bool);
23432343
int bnxt_half_open_nic(struct bnxt *bp);
23442344
void bnxt_half_close_nic(struct bnxt *bp);
23452345
void bnxt_reenable_sriov(struct bnxt *bp);
2346-
int bnxt_close_nic(struct bnxt *, bool, bool);
2346+
void bnxt_close_nic(struct bnxt *, bool, bool);
23472347
void bnxt_get_ring_err_stats(struct bnxt *bp,
23482348
struct bnxt_total_ring_err_stats *stats);
23492349
int bnxt_dbg_hwrm_rd_reg(struct bnxt *bp, u32 reg_off, u16 num_words,

drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -478,15 +478,8 @@ static int bnxt_dl_reload_down(struct devlink *dl, bool netns_change,
478478
return -ENODEV;
479479
}
480480
bnxt_ulp_stop(bp);
481-
if (netif_running(bp->dev)) {
482-
rc = bnxt_close_nic(bp, true, true);
483-
if (rc) {
484-
NL_SET_ERR_MSG_MOD(extack, "Failed to close");
485-
dev_close(bp->dev);
486-
rtnl_unlock();
487-
break;
488-
}
489-
}
481+
if (netif_running(bp->dev))
482+
bnxt_close_nic(bp, true, true);
490483
bnxt_vf_reps_free(bp);
491484
rc = bnxt_hwrm_func_drv_unrgtr(bp);
492485
if (rc) {

drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,8 @@ static int bnxt_set_coalesce(struct net_device *dev,
164164
reset_coalesce:
165165
if (test_bit(BNXT_STATE_OPEN, &bp->state)) {
166166
if (update_stats) {
167-
rc = bnxt_close_nic(bp, true, false);
168-
if (!rc)
169-
rc = bnxt_open_nic(bp, true, false);
167+
bnxt_close_nic(bp, true, false);
168+
rc = bnxt_open_nic(bp, true, false);
170169
} else {
171170
rc = bnxt_hwrm_set_coal(bp);
172171
}
@@ -956,12 +955,7 @@ static int bnxt_set_channels(struct net_device *dev,
956955
* before PF unload
957956
*/
958957
}
959-
rc = bnxt_close_nic(bp, true, false);
960-
if (rc) {
961-
netdev_err(bp->dev, "Set channel failure rc :%x\n",
962-
rc);
963-
return rc;
964-
}
958+
bnxt_close_nic(bp, true, false);
965959
}
966960

967961
if (sh) {
@@ -3634,12 +3628,7 @@ static void bnxt_self_test(struct net_device *dev, struct ethtool_test *etest,
36343628
bnxt_run_fw_tests(bp, test_mask, &test_results);
36353629
} else {
36363630
bnxt_ulp_stop(bp);
3637-
rc = bnxt_close_nic(bp, true, false);
3638-
if (rc) {
3639-
etest->flags |= ETH_TEST_FL_FAILED;
3640-
bnxt_ulp_start(bp, rc);
3641-
return;
3642-
}
3631+
bnxt_close_nic(bp, true, false);
36433632
bnxt_run_fw_tests(bp, test_mask, &test_results);
36443633

36453634
buf[BNXT_MACLPBK_TEST_IDX] = 1;

drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -506,9 +506,8 @@ static int bnxt_hwrm_ptp_cfg(struct bnxt *bp)
506506

507507
if (netif_running(bp->dev)) {
508508
if (ptp->rx_filter == HWTSTAMP_FILTER_ALL) {
509-
rc = bnxt_close_nic(bp, false, false);
510-
if (!rc)
511-
rc = bnxt_open_nic(bp, false, false);
509+
bnxt_close_nic(bp, false, false);
510+
rc = bnxt_open_nic(bp, false, false);
512511
} else {
513512
bnxt_ptp_cfg_tstamp_filters(bp);
514513
}

0 commit comments

Comments
 (0)