Commit 880f8f99 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

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: default avatarEric Dumazet <edumazet@google.com>
Cc: Ariel Elior <aelior@marvell.com>
Cc: Sudarsana Kalluru <skalluru@marvell.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 6a1015b0
...@@ -3085,6 +3085,7 @@ static int bnx2x_bsc_read(struct link_params *params, ...@@ -3085,6 +3085,7 @@ static int bnx2x_bsc_read(struct link_params *params,
u8 xfer_cnt, u8 xfer_cnt,
u32 *data_array) u32 *data_array)
{ {
u64 t0, delta;
u32 val, i; u32 val, i;
int rc = 0; int rc = 0;
...@@ -3114,17 +3115,18 @@ static int bnx2x_bsc_read(struct link_params *params, ...@@ -3114,17 +3115,18 @@ static int bnx2x_bsc_read(struct link_params *params,
REG_WR(bp, MCP_REG_MCPR_IMC_COMMAND, val); REG_WR(bp, MCP_REG_MCPR_IMC_COMMAND, val);
/* Poll for completion */ /* Poll for completion */
i = 0; t0 = ktime_get_ns();
val = REG_RD(bp, MCP_REG_MCPR_IMC_COMMAND); val = REG_RD(bp, MCP_REG_MCPR_IMC_COMMAND);
while (((val >> MCPR_IMC_COMMAND_IMC_STATUS_BITSHIFT) & 0x3) != 1) { while (((val >> MCPR_IMC_COMMAND_IMC_STATUS_BITSHIFT) & 0x3) != 1) {
udelay(10); delta = ktime_get_ns() - t0;
val = REG_RD(bp, MCP_REG_MCPR_IMC_COMMAND); if (delta > 10 * NSEC_PER_MSEC) {
if (i++ > 1000) { DP(NETIF_MSG_LINK, "wr 0 byte timed out after %Lu ns\n",
DP(NETIF_MSG_LINK, "wr 0 byte timed out after %d try\n", delta);
i);
rc = -EFAULT; rc = -EFAULT;
break; break;
} }
usleep_range(10, 20);
val = REG_RD(bp, MCP_REG_MCPR_IMC_COMMAND);
} }
if (rc == -EFAULT) if (rc == -EFAULT)
return rc; return rc;
...@@ -3138,16 +3140,18 @@ static int bnx2x_bsc_read(struct link_params *params, ...@@ -3138,16 +3140,18 @@ static int bnx2x_bsc_read(struct link_params *params,
REG_WR(bp, MCP_REG_MCPR_IMC_COMMAND, val); REG_WR(bp, MCP_REG_MCPR_IMC_COMMAND, val);
/* Poll for completion */ /* Poll for completion */
i = 0; t0 = ktime_get_ns();
val = REG_RD(bp, MCP_REG_MCPR_IMC_COMMAND); val = REG_RD(bp, MCP_REG_MCPR_IMC_COMMAND);
while (((val >> MCPR_IMC_COMMAND_IMC_STATUS_BITSHIFT) & 0x3) != 1) { while (((val >> MCPR_IMC_COMMAND_IMC_STATUS_BITSHIFT) & 0x3) != 1) {
udelay(10); delta = ktime_get_ns() - t0;
val = REG_RD(bp, MCP_REG_MCPR_IMC_COMMAND); if (delta > 10 * NSEC_PER_MSEC) {
if (i++ > 1000) { DP(NETIF_MSG_LINK, "rd op timed out after %Lu ns\n",
DP(NETIF_MSG_LINK, "rd op timed out after %d try\n", i); delta);
rc = -EFAULT; rc = -EFAULT;
break; break;
} }
usleep_range(10, 20);
val = REG_RD(bp, MCP_REG_MCPR_IMC_COMMAND);
} }
if (rc == -EFAULT) if (rc == -EFAULT)
return rc; return rc;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment