bnxt_en: use firmware provided max timeout for messages
authorEdwin Peer <edwin.peer@broadcom.com>
Sun, 9 Jan 2022 23:54:44 +0000 (18:54 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 27 Jan 2022 10:04:03 +0000 (11:04 +0100)
[ Upstream commit bce9a0b7900836df223ab638090df0cb8430d9e8 ]

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: 881d8353b05e ("bnxt_en: Add an upper bound for all firmware command timeouts.")
Signed-off-by: Edwin Peer <edwin.peer@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/broadcom/bnxt/bnxt.c
drivers/net/ethernet/broadcom/bnxt/bnxt.h
drivers/net/ethernet/broadcom/bnxt/bnxt_coredump.c
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
drivers/net/ethernet/broadcom/bnxt/bnxt_hwrm.c
drivers/net/ethernet/broadcom/bnxt/bnxt_hwrm.h

index 0fba01db336cc7d44e1e7e81753bc0f6dab9fb3d..a8855a200a3c51e905f0331c17d7ce43f036042f 100644 (file)
@@ -8004,6 +8004,12 @@ static int bnxt_hwrm_ver_get(struct bnxt *bp)
        bp->hwrm_cmd_timeout = le16_to_cpu(resp->def_req_timeout);
        if (!bp->hwrm_cmd_timeout)
                bp->hwrm_cmd_timeout = DFLT_HWRM_CMD_TIMEOUT;
+       bp->hwrm_cmd_max_timeout = le16_to_cpu(resp->max_req_timeout) * 1000;
+       if (!bp->hwrm_cmd_max_timeout)
+               bp->hwrm_cmd_max_timeout = HWRM_CMD_MAX_TIMEOUT;
+       else if (bp->hwrm_cmd_max_timeout > HWRM_CMD_MAX_TIMEOUT)
+               netdev_warn(bp->dev, "Device requests max timeout of %d seconds, may trigger hung task watchdog\n",
+                           bp->hwrm_cmd_max_timeout / 1000);
 
        if (resp->hwrm_intf_maj_8b >= 1) {
                bp->hwrm_max_req_len = le16_to_cpu(resp->max_req_win_len);
index 19fe6478e9b4bc40f7e391cb318efe04c8140d46..0a5137c1f6d4e022c809495ad25ea60d0fe0523f 100644 (file)
@@ -1901,7 +1901,8 @@ struct bnxt {
 
        u16                     hwrm_max_req_len;
        u16                     hwrm_max_ext_req_len;
-       int                     hwrm_cmd_timeout;
+       unsigned int            hwrm_cmd_timeout;
+       unsigned int            hwrm_cmd_max_timeout;
        struct mutex            hwrm_cmd_lock;  /* serialize hwrm messages */
        struct hwrm_ver_get_output      ver_resp;
 #define FW_VER_STR_LEN         32
index 3e23fce3771e6d2757f3c11c510ffae9026746fd..156f76bcea7eb22ce4d9a49fa7847010c9557b35 100644 (file)
@@ -32,7 +32,7 @@ static int bnxt_hwrm_dbg_dma_data(struct bnxt *bp, void *msg,
                return -ENOMEM;
        }
 
-       hwrm_req_timeout(bp, msg, HWRM_COREDUMP_TIMEOUT);
+       hwrm_req_timeout(bp, msg, bp->hwrm_cmd_max_timeout);
        cmn_resp = hwrm_req_hold(bp, msg);
        resp = cmn_resp;
 
@@ -125,7 +125,7 @@ static int bnxt_hwrm_dbg_coredump_initiate(struct bnxt *bp, u16 component_id,
        if (rc)
                return rc;
 
-       hwrm_req_timeout(bp, req, HWRM_COREDUMP_TIMEOUT);
+       hwrm_req_timeout(bp, req, bp->hwrm_cmd_max_timeout);
        req->component_id = cpu_to_le16(component_id);
        req->segment_id = cpu_to_le16(segment_id);
 
index c5974b16670a8403e9beb56c4ef1d0b006ddca85..2497925105215072da6890f2ac3eaa62fd1606b2 100644 (file)
@@ -31,9 +31,6 @@
 #include "bnxt_nvm_defs.h"     /* NVRAM content constant and structure defs */
 #include "bnxt_fw_hdr.h"       /* Firmware hdr constant and structure defs */
 #include "bnxt_coredump.h"
-#define FLASH_NVRAM_TIMEOUT    ((HWRM_CMD_TIMEOUT) * 100)
-#define FLASH_PACKAGE_TIMEOUT  ((HWRM_CMD_TIMEOUT) * 200)
-#define INSTALL_PACKAGE_TIMEOUT        ((HWRM_CMD_TIMEOUT) * 200)
 
 static u32 bnxt_get_msglevel(struct net_device *dev)
 {
@@ -2167,7 +2164,7 @@ static int bnxt_flash_nvram(struct net_device *dev, u16 dir_type,
                req->host_src_addr = cpu_to_le64(dma_handle);
        }
 
-       hwrm_req_timeout(bp, req, FLASH_NVRAM_TIMEOUT);
+       hwrm_req_timeout(bp, req, bp->hwrm_cmd_max_timeout);
        req->dir_type = cpu_to_le16(dir_type);
        req->dir_ordinal = cpu_to_le16(dir_ordinal);
        req->dir_ext = cpu_to_le16(dir_ext);
@@ -2508,8 +2505,8 @@ int bnxt_flash_package_from_fw_obj(struct net_device *dev, const struct firmware
                return rc;
        }
 
-       hwrm_req_timeout(bp, modify, FLASH_PACKAGE_TIMEOUT);
-       hwrm_req_timeout(bp, install, INSTALL_PACKAGE_TIMEOUT);
+       hwrm_req_timeout(bp, modify, bp->hwrm_cmd_max_timeout);
+       hwrm_req_timeout(bp, install, bp->hwrm_cmd_max_timeout);
 
        hwrm_req_hold(bp, modify);
        modify->host_src_addr = cpu_to_le64(dma_handle);
index bb7327b82d0b2511e363264eb7ab730fc67fa4f2..8171f4912fa01e75e977688669ffff93f3b4cfbc 100644 (file)
@@ -496,7 +496,7 @@ static int __hwrm_send(struct bnxt *bp, struct bnxt_hwrm_ctx *ctx)
        }
 
        /* Limit timeout to an upper limit */
-       timeout = min_t(uint, ctx->timeout, HWRM_CMD_MAX_TIMEOUT);
+       timeout = min(ctx->timeout, bp->hwrm_cmd_max_timeout ?: HWRM_CMD_MAX_TIMEOUT);
        /* convert timeout to usec */
        timeout *= 1000;
 
index 4d17f0d5363bbcdd06e4cc238e001ffd1998712b..9a9fc4e8041b6bd65a7e98e5d3722a90815e31a8 100644 (file)
@@ -58,11 +58,10 @@ void hwrm_update_token(struct bnxt *bp, u16 seq, enum bnxt_hwrm_wait_state s);
 
 #define BNXT_HWRM_MAX_REQ_LEN          (bp->hwrm_max_req_len)
 #define BNXT_HWRM_SHORT_REQ_LEN                sizeof(struct hwrm_short_input)
-#define HWRM_CMD_MAX_TIMEOUT           40000
+#define HWRM_CMD_MAX_TIMEOUT           40000U
 #define SHORT_HWRM_CMD_TIMEOUT         20
 #define HWRM_CMD_TIMEOUT               (bp->hwrm_cmd_timeout)
 #define HWRM_RESET_TIMEOUT             ((HWRM_CMD_TIMEOUT) * 4)
-#define HWRM_COREDUMP_TIMEOUT          ((HWRM_CMD_TIMEOUT) * 12)
 #define BNXT_HWRM_TARGET               0xffff
 #define BNXT_HWRM_NO_CMPL_RING         -1
 #define BNXT_HWRM_REQ_MAX_SIZE         128