Skip to content

Commit bce9a0b

Browse files
Edwin Peerkuba-moo
authored andcommitted
bnxt_en: use firmware provided max timeout for messages
Some older devices cannot accommodate the 40 seconds timeout cap for long running commands (such as NVRAM commands) due to hardware limitations. Allow these devices to request more time for these long running commands, but print a warning, since the longer timeout may cause the hung task watchdog to trigger. In the case of a firmware update operation, this is preferable to failing outright. v2: Use bp->hwrm_cmd_max_timeout directly without the constants. Fixes: 881d835 ("bnxt_en: Add an upper bound for all firmware command timeouts.") Signed-off-by: Edwin Peer <[email protected]> Signed-off-by: Michael Chan <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 662c9b2 commit bce9a0b

File tree

6 files changed

+15
-12
lines changed

6 files changed

+15
-12
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8034,6 +8034,12 @@ static int bnxt_hwrm_ver_get(struct bnxt *bp)
80348034
bp->hwrm_cmd_timeout = le16_to_cpu(resp->def_req_timeout);
80358035
if (!bp->hwrm_cmd_timeout)
80368036
bp->hwrm_cmd_timeout = DFLT_HWRM_CMD_TIMEOUT;
8037+
bp->hwrm_cmd_max_timeout = le16_to_cpu(resp->max_req_timeout) * 1000;
8038+
if (!bp->hwrm_cmd_max_timeout)
8039+
bp->hwrm_cmd_max_timeout = HWRM_CMD_MAX_TIMEOUT;
8040+
else if (bp->hwrm_cmd_max_timeout > HWRM_CMD_MAX_TIMEOUT)
8041+
netdev_warn(bp->dev, "Device requests max timeout of %d seconds, may trigger hung task watchdog\n",
8042+
bp->hwrm_cmd_max_timeout / 1000);
80378043

80388044
if (resp->hwrm_intf_maj_8b >= 1) {
80398045
bp->hwrm_max_req_len = le16_to_cpu(resp->max_req_win_len);

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1987,7 +1987,8 @@ struct bnxt {
19871987

19881988
u16 hwrm_max_req_len;
19891989
u16 hwrm_max_ext_req_len;
1990-
int hwrm_cmd_timeout;
1990+
unsigned int hwrm_cmd_timeout;
1991+
unsigned int hwrm_cmd_max_timeout;
19911992
struct mutex hwrm_cmd_lock; /* serialize hwrm messages */
19921993
struct hwrm_ver_get_output ver_resp;
19931994
#define FW_VER_STR_LEN 32

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ static int bnxt_hwrm_dbg_dma_data(struct bnxt *bp, void *msg,
3232
return -ENOMEM;
3333
}
3434

35-
hwrm_req_timeout(bp, msg, HWRM_COREDUMP_TIMEOUT);
35+
hwrm_req_timeout(bp, msg, bp->hwrm_cmd_max_timeout);
3636
cmn_resp = hwrm_req_hold(bp, msg);
3737
resp = cmn_resp;
3838

@@ -125,7 +125,7 @@ static int bnxt_hwrm_dbg_coredump_initiate(struct bnxt *bp, u16 component_id,
125125
if (rc)
126126
return rc;
127127

128-
hwrm_req_timeout(bp, req, HWRM_COREDUMP_TIMEOUT);
128+
hwrm_req_timeout(bp, req, bp->hwrm_cmd_max_timeout);
129129
req->component_id = cpu_to_le16(component_id);
130130
req->segment_id = cpu_to_le16(segment_id);
131131

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@
3131
#include "bnxt_nvm_defs.h" /* NVRAM content constant and structure defs */
3232
#include "bnxt_fw_hdr.h" /* Firmware hdr constant and structure defs */
3333
#include "bnxt_coredump.h"
34-
#define FLASH_NVRAM_TIMEOUT ((HWRM_CMD_TIMEOUT) * 100)
35-
#define FLASH_PACKAGE_TIMEOUT ((HWRM_CMD_TIMEOUT) * 200)
36-
#define INSTALL_PACKAGE_TIMEOUT ((HWRM_CMD_TIMEOUT) * 200)
3734

3835
static u32 bnxt_get_msglevel(struct net_device *dev)
3936
{
@@ -2194,7 +2191,7 @@ static int bnxt_flash_nvram(struct net_device *dev, u16 dir_type,
21942191
req->host_src_addr = cpu_to_le64(dma_handle);
21952192
}
21962193

2197-
hwrm_req_timeout(bp, req, FLASH_NVRAM_TIMEOUT);
2194+
hwrm_req_timeout(bp, req, bp->hwrm_cmd_max_timeout);
21982195
req->dir_type = cpu_to_le16(dir_type);
21992196
req->dir_ordinal = cpu_to_le16(dir_ordinal);
22002197
req->dir_ext = cpu_to_le16(dir_ext);
@@ -2540,8 +2537,8 @@ int bnxt_flash_package_from_fw_obj(struct net_device *dev, const struct firmware
25402537
return rc;
25412538
}
25422539

2543-
hwrm_req_timeout(bp, modify, FLASH_PACKAGE_TIMEOUT);
2544-
hwrm_req_timeout(bp, install, INSTALL_PACKAGE_TIMEOUT);
2540+
hwrm_req_timeout(bp, modify, bp->hwrm_cmd_max_timeout);
2541+
hwrm_req_timeout(bp, install, bp->hwrm_cmd_max_timeout);
25452542

25462543
hwrm_req_hold(bp, modify);
25472544
modify->host_src_addr = cpu_to_le64(dma_handle);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ static int __hwrm_send(struct bnxt *bp, struct bnxt_hwrm_ctx *ctx)
529529
}
530530

531531
/* Limit timeout to an upper limit */
532-
timeout = min_t(uint, ctx->timeout, HWRM_CMD_MAX_TIMEOUT);
532+
timeout = min(ctx->timeout, bp->hwrm_cmd_max_timeout ?: HWRM_CMD_MAX_TIMEOUT);
533533
/* convert timeout to usec */
534534
timeout *= 1000;
535535

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,10 @@ void hwrm_update_token(struct bnxt *bp, u16 seq, enum bnxt_hwrm_wait_state s);
5858

5959
#define BNXT_HWRM_MAX_REQ_LEN (bp->hwrm_max_req_len)
6060
#define BNXT_HWRM_SHORT_REQ_LEN sizeof(struct hwrm_short_input)
61-
#define HWRM_CMD_MAX_TIMEOUT 40000
61+
#define HWRM_CMD_MAX_TIMEOUT 40000U
6262
#define SHORT_HWRM_CMD_TIMEOUT 20
6363
#define HWRM_CMD_TIMEOUT (bp->hwrm_cmd_timeout)
6464
#define HWRM_RESET_TIMEOUT ((HWRM_CMD_TIMEOUT) * 4)
65-
#define HWRM_COREDUMP_TIMEOUT ((HWRM_CMD_TIMEOUT) * 12)
6665
#define BNXT_HWRM_TARGET 0xffff
6766
#define BNXT_HWRM_NO_CMPL_RING -1
6867
#define BNXT_HWRM_REQ_MAX_SIZE 128

0 commit comments

Comments
 (0)