Skip to content

Commit 880f8f9

Browse files
edumazetdavem330
authored andcommitted
bnx2x: allow bnx2x_bsc_read() to schedule
bnx2x_warpcore_read_sfp_module_eeprom() can call bnx2x_bsc_read() three times before giving up. This causes latency blips of at least 31 ms (58 ms being reported by our teams) Convert the long lasting loops of udelay() to usleep_range() ones, and breaks the loops on precise time tracking. Signed-off-by: Eric Dumazet <[email protected]> Cc: Ariel Elior <[email protected]> Cc: Sudarsana Kalluru <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 6a1015b commit 880f8f9

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3085,6 +3085,7 @@ static int bnx2x_bsc_read(struct link_params *params,
30853085
u8 xfer_cnt,
30863086
u32 *data_array)
30873087
{
3088+
u64 t0, delta;
30883089
u32 val, i;
30893090
int rc = 0;
30903091

@@ -3114,17 +3115,18 @@ static int bnx2x_bsc_read(struct link_params *params,
31143115
REG_WR(bp, MCP_REG_MCPR_IMC_COMMAND, val);
31153116

31163117
/* Poll for completion */
3117-
i = 0;
3118+
t0 = ktime_get_ns();
31183119
val = REG_RD(bp, MCP_REG_MCPR_IMC_COMMAND);
31193120
while (((val >> MCPR_IMC_COMMAND_IMC_STATUS_BITSHIFT) & 0x3) != 1) {
3120-
udelay(10);
3121-
val = REG_RD(bp, MCP_REG_MCPR_IMC_COMMAND);
3122-
if (i++ > 1000) {
3123-
DP(NETIF_MSG_LINK, "wr 0 byte timed out after %d try\n",
3124-
i);
3121+
delta = ktime_get_ns() - t0;
3122+
if (delta > 10 * NSEC_PER_MSEC) {
3123+
DP(NETIF_MSG_LINK, "wr 0 byte timed out after %Lu ns\n",
3124+
delta);
31253125
rc = -EFAULT;
31263126
break;
31273127
}
3128+
usleep_range(10, 20);
3129+
val = REG_RD(bp, MCP_REG_MCPR_IMC_COMMAND);
31283130
}
31293131
if (rc == -EFAULT)
31303132
return rc;
@@ -3138,16 +3140,18 @@ static int bnx2x_bsc_read(struct link_params *params,
31383140
REG_WR(bp, MCP_REG_MCPR_IMC_COMMAND, val);
31393141

31403142
/* Poll for completion */
3141-
i = 0;
3143+
t0 = ktime_get_ns();
31423144
val = REG_RD(bp, MCP_REG_MCPR_IMC_COMMAND);
31433145
while (((val >> MCPR_IMC_COMMAND_IMC_STATUS_BITSHIFT) & 0x3) != 1) {
3144-
udelay(10);
3145-
val = REG_RD(bp, MCP_REG_MCPR_IMC_COMMAND);
3146-
if (i++ > 1000) {
3147-
DP(NETIF_MSG_LINK, "rd op timed out after %d try\n", i);
3146+
delta = ktime_get_ns() - t0;
3147+
if (delta > 10 * NSEC_PER_MSEC) {
3148+
DP(NETIF_MSG_LINK, "rd op timed out after %Lu ns\n",
3149+
delta);
31483150
rc = -EFAULT;
31493151
break;
31503152
}
3153+
usleep_range(10, 20);
3154+
val = REG_RD(bp, MCP_REG_MCPR_IMC_COMMAND);
31513155
}
31523156
if (rc == -EFAULT)
31533157
return rc;

0 commit comments

Comments
 (0)