OSDN Git Service

bnxt_en: Fix firmware message delay loop regression.
authorMichael Chan <michael.chan@broadcom.com>
Tue, 8 May 2018 07:18:38 +0000 (03:18 -0400)
committerDavid S. Miller <davem@davemloft.net>
Tue, 8 May 2018 14:14:21 +0000 (10:14 -0400)
A recent change to reduce delay granularity waiting for firmware
reponse has caused a regression.  With a tighter delay loop,
the driver may see the beginning part of the response faster.
The original 5 usec delay to wait for the rest of the message
is not long enough and some messages are detected as invalid.

Increase the maximum wait time from 5 usec to 20 usec.  Also, fix
the debug message that shows the total delay time for the response
when the message times out.  With the new logic, the delay time
is not fixed per iteration of the loop, so we define a macro to
show the total delay time.

Fixes: 9751e8e71487 ("bnxt_en: reduce timeout on initial HWRM calls")
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/broadcom/bnxt/bnxt.c
drivers/net/ethernet/broadcom/bnxt/bnxt.h

index efe5c72..168342a 100644 (file)
@@ -3530,6 +3530,8 @@ static int bnxt_hwrm_do_send_msg(struct bnxt *bp, void *msg, u32 msg_len,
                      HWRM_RESP_LEN_SFT;
                valid = bp->hwrm_cmd_resp_addr + len - 1;
        } else {
+               int j;
+
                /* Check if response len is updated */
                for (i = 0; i < tmo_count; i++) {
                        len = (le32_to_cpu(*resp_len) & HWRM_RESP_LEN_MASK) >>
@@ -3547,14 +3549,15 @@ static int bnxt_hwrm_do_send_msg(struct bnxt *bp, void *msg, u32 msg_len,
 
                if (i >= tmo_count) {
                        netdev_err(bp->dev, "Error (timeout: %d) msg {0x%x 0x%x} len:%d\n",
-                                  timeout, le16_to_cpu(req->req_type),
+                                  HWRM_TOTAL_TIMEOUT(i),
+                                  le16_to_cpu(req->req_type),
                                   le16_to_cpu(req->seq_id), len);
                        return -1;
                }
 
                /* Last byte of resp contains valid bit */
                valid = bp->hwrm_cmd_resp_addr + len - 1;
-               for (i = 0; i < 5; i++) {
+               for (j = 0; j < HWRM_VALID_BIT_DELAY_USEC; j++) {
                        /* make sure we read from updated DMA memory */
                        dma_rmb();
                        if (*valid)
@@ -3562,9 +3565,10 @@ static int bnxt_hwrm_do_send_msg(struct bnxt *bp, void *msg, u32 msg_len,
                        udelay(1);
                }
 
-               if (i >= 5) {
+               if (j >= HWRM_VALID_BIT_DELAY_USEC) {
                        netdev_err(bp->dev, "Error (timeout: %d) msg {0x%x 0x%x} len:%d v:%d\n",
-                                  timeout, le16_to_cpu(req->req_type),
+                                  HWRM_TOTAL_TIMEOUT(i),
+                                  le16_to_cpu(req->req_type),
                                   le16_to_cpu(req->seq_id), len, *valid);
                        return -1;
                }
index 8df1d8b..a9c210e 100644 (file)
@@ -539,6 +539,13 @@ struct rx_tpa_end_cmp_ext {
 #define HWRM_MIN_TIMEOUT               25
 #define HWRM_MAX_TIMEOUT               40
 
+#define HWRM_TOTAL_TIMEOUT(n)  (((n) <= HWRM_SHORT_TIMEOUT_COUNTER) ?  \
+       ((n) * HWRM_SHORT_MIN_TIMEOUT) :                                \
+       (HWRM_SHORT_TIMEOUT_COUNTER * HWRM_SHORT_MIN_TIMEOUT +          \
+        ((n) - HWRM_SHORT_TIMEOUT_COUNTER) * HWRM_MIN_TIMEOUT))
+
+#define HWRM_VALID_BIT_DELAY_USEC      20
+
 #define BNXT_RX_EVENT  1
 #define BNXT_AGG_EVENT 2
 #define BNXT_TX_EVENT  4