bnxt_en: Add an upper bound for all firmware command timeouts.
authorVasundhara Volam <vasundhara-v.volam@broadcom.com>
Mon, 25 Jan 2021 07:08:12 +0000 (02:08 -0500)
committerJakub Kicinski <kuba@kernel.org>
Tue, 26 Jan 2021 03:20:03 +0000 (19:20 -0800)
The timeout period for firmware messages is passed to the driver
from the firmware in the response of the first command.  This
timeout period is multiplied by a factor for certain long
running commands such as NVRAM commands.  In some cases, the
timeout period can become really long and it can cause hung task
warnings if firmware has crashed or is not responding.  To avoid
such long delays, cap all firmware commands to a max timeout value
of 40 seconds.

Reviewed-by: Edwin Peer <edwin.peer@broadcom.com>
Signed-off-by: Vasundhara Volam <vasundhara-v.volam@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Acked-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/broadcom/bnxt/bnxt.c
drivers/net/ethernet/broadcom/bnxt/bnxt.h

index 2fb9873..c06c5f8 100644 (file)
@@ -4425,6 +4425,8 @@ static int bnxt_hwrm_do_send_msg(struct bnxt *bp, void *msg, u32 msg_len,
 
        if (!timeout)
                timeout = DFLT_HWRM_CMD_TIMEOUT;
+       /* Limit timeout to an upper limit */
+       timeout = min(timeout, HWRM_CMD_MAX_TIMEOUT);
        /* convert timeout to usec */
        timeout *= 1000;
 
index 867b1d3..cbb338b 100644 (file)
@@ -656,6 +656,7 @@ struct nqe_cn {
 #define BNXT_HWRM_MAX_REQ_LEN          (bp->hwrm_max_req_len)
 #define BNXT_HWRM_SHORT_REQ_LEN                sizeof(struct hwrm_short_input)
 #define DFLT_HWRM_CMD_TIMEOUT          500
+#define HWRM_CMD_MAX_TIMEOUT           40000
 #define SHORT_HWRM_CMD_TIMEOUT         20
 #define HWRM_CMD_TIMEOUT               (bp->hwrm_cmd_timeout)
 #define HWRM_RESET_TIMEOUT             ((HWRM_CMD_TIMEOUT) * 4)