Skip to content

Commit cc559c1

Browse files
Michael Chandavem330
authored andcommitted
bnxt_en: Fix firmware message delay loop regression.
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: 9751e8e ("bnxt_en: reduce timeout on initial HWRM calls") Signed-off-by: Michael Chan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 724e47a commit cc559c1

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3530,6 +3530,8 @@ static int bnxt_hwrm_do_send_msg(struct bnxt *bp, void *msg, u32 msg_len,
35303530
HWRM_RESP_LEN_SFT;
35313531
valid = bp->hwrm_cmd_resp_addr + len - 1;
35323532
} else {
3533+
int j;
3534+
35333535
/* Check if response len is updated */
35343536
for (i = 0; i < tmo_count; i++) {
35353537
len = (le32_to_cpu(*resp_len) & HWRM_RESP_LEN_MASK) >>
@@ -3547,24 +3549,26 @@ static int bnxt_hwrm_do_send_msg(struct bnxt *bp, void *msg, u32 msg_len,
35473549

35483550
if (i >= tmo_count) {
35493551
netdev_err(bp->dev, "Error (timeout: %d) msg {0x%x 0x%x} len:%d\n",
3550-
timeout, le16_to_cpu(req->req_type),
3552+
HWRM_TOTAL_TIMEOUT(i),
3553+
le16_to_cpu(req->req_type),
35513554
le16_to_cpu(req->seq_id), len);
35523555
return -1;
35533556
}
35543557

35553558
/* Last byte of resp contains valid bit */
35563559
valid = bp->hwrm_cmd_resp_addr + len - 1;
3557-
for (i = 0; i < 5; i++) {
3560+
for (j = 0; j < HWRM_VALID_BIT_DELAY_USEC; j++) {
35583561
/* make sure we read from updated DMA memory */
35593562
dma_rmb();
35603563
if (*valid)
35613564
break;
35623565
udelay(1);
35633566
}
35643567

3565-
if (i >= 5) {
3568+
if (j >= HWRM_VALID_BIT_DELAY_USEC) {
35663569
netdev_err(bp->dev, "Error (timeout: %d) msg {0x%x 0x%x} len:%d v:%d\n",
3567-
timeout, le16_to_cpu(req->req_type),
3570+
HWRM_TOTAL_TIMEOUT(i),
3571+
le16_to_cpu(req->req_type),
35683572
le16_to_cpu(req->seq_id), len, *valid);
35693573
return -1;
35703574
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,13 @@ struct rx_tpa_end_cmp_ext {
539539
#define HWRM_MIN_TIMEOUT 25
540540
#define HWRM_MAX_TIMEOUT 40
541541

542+
#define HWRM_TOTAL_TIMEOUT(n) (((n) <= HWRM_SHORT_TIMEOUT_COUNTER) ? \
543+
((n) * HWRM_SHORT_MIN_TIMEOUT) : \
544+
(HWRM_SHORT_TIMEOUT_COUNTER * HWRM_SHORT_MIN_TIMEOUT + \
545+
((n) - HWRM_SHORT_TIMEOUT_COUNTER) * HWRM_MIN_TIMEOUT))
546+
547+
#define HWRM_VALID_BIT_DELAY_USEC 20
548+
542549
#define BNXT_RX_EVENT 1
543550
#define BNXT_AGG_EVENT 2
544551
#define BNXT_TX_EVENT 4

0 commit comments

Comments
 (0)