Skip to content

Commit 0d8d3ce

Browse files
committed
qed: make 'ethtool -d' 10 times faster
jira LE-2177 Rebuild_History Non-Buildable kernel-5.14.0-503.19.1.el9_5 commit-author Michal Schmidt <[email protected]> commit b8db67d As a side effect of commit 5401c3e ("qed: allow sleep in qed_mcp_trace_dump()"), 'ethtool -d' became much slower. Almost all the time is spent collecting the "mcp_trace". It is caused by sleeping too long in _qed_mcp_cmd_and_union. When called with sleeping not allowed, the function delays for 10 µs between firmware polls. But if sleeping is allowed, it sleeps for 10 ms instead. The sleeps in _qed_mcp_cmd_and_union are unnecessarily long. Replace msleep with usleep_range, which allows to achieve a similar polling interval like in the no-sleeping mode (10 - 20 µs). The only caller, qed_mcp_cmd_and_union, can stop doing the multiplication/division of the usecs/max_retries. The polling interval and the number of retries do not need to be parameters at all. On my test system, 'ethtool -d' now takes 4 seconds instead of 44. Signed-off-by: Michal Schmidt <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]> (cherry picked from commit b8db67d) Signed-off-by: Jonathan Maple <[email protected]>
1 parent 84f7809 commit 0d8d3ce

File tree

1 file changed

+15
-21
lines changed

1 file changed

+15
-21
lines changed

drivers/net/ethernet/qlogic/qed/qed_mcp.c

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -459,12 +459,11 @@ static void qed_mcp_print_cpu_info(struct qed_hwfn *p_hwfn,
459459
static int
460460
_qed_mcp_cmd_and_union(struct qed_hwfn *p_hwfn,
461461
struct qed_ptt *p_ptt,
462-
struct qed_mcp_mb_params *p_mb_params,
463-
u32 max_retries, u32 usecs)
462+
struct qed_mcp_mb_params *p_mb_params)
464463
{
465-
u32 cnt = 0, msecs = DIV_ROUND_UP(usecs, 1000);
466464
struct qed_mcp_cmd_elem *p_cmd_elem;
467465
u16 seq_num;
466+
u32 cnt = 0;
468467
int rc = 0;
469468

470469
/* Wait until the mailbox is non-occupied */
@@ -488,12 +487,13 @@ _qed_mcp_cmd_and_union(struct qed_hwfn *p_hwfn,
488487
spin_unlock_bh(&p_hwfn->mcp_info->cmd_lock);
489488

490489
if (QED_MB_FLAGS_IS_SET(p_mb_params, CAN_SLEEP))
491-
msleep(msecs);
490+
usleep_range(QED_MCP_RESP_ITER_US,
491+
QED_MCP_RESP_ITER_US * 2);
492492
else
493-
udelay(usecs);
494-
} while (++cnt < max_retries);
493+
udelay(QED_MCP_RESP_ITER_US);
494+
} while (++cnt < QED_DRV_MB_MAX_RETRIES);
495495

496-
if (cnt >= max_retries) {
496+
if (cnt >= QED_DRV_MB_MAX_RETRIES) {
497497
DP_NOTICE(p_hwfn,
498498
"The MFW mailbox is occupied by an uncompleted command. Failed to send command 0x%08x [param 0x%08x].\n",
499499
p_mb_params->cmd, p_mb_params->param);
@@ -520,9 +520,10 @@ _qed_mcp_cmd_and_union(struct qed_hwfn *p_hwfn,
520520
*/
521521

522522
if (QED_MB_FLAGS_IS_SET(p_mb_params, CAN_SLEEP))
523-
msleep(msecs);
523+
usleep_range(QED_MCP_RESP_ITER_US,
524+
QED_MCP_RESP_ITER_US * 2);
524525
else
525-
udelay(usecs);
526+
udelay(QED_MCP_RESP_ITER_US);
526527

527528
spin_lock_bh(&p_hwfn->mcp_info->cmd_lock);
528529

@@ -536,9 +537,9 @@ _qed_mcp_cmd_and_union(struct qed_hwfn *p_hwfn,
536537
goto err;
537538

538539
spin_unlock_bh(&p_hwfn->mcp_info->cmd_lock);
539-
} while (++cnt < max_retries);
540+
} while (++cnt < QED_DRV_MB_MAX_RETRIES);
540541

541-
if (cnt >= max_retries) {
542+
if (cnt >= QED_DRV_MB_MAX_RETRIES) {
542543
DP_NOTICE(p_hwfn,
543544
"The MFW failed to respond to command 0x%08x [param 0x%08x].\n",
544545
p_mb_params->cmd, p_mb_params->param);
@@ -564,7 +565,8 @@ _qed_mcp_cmd_and_union(struct qed_hwfn *p_hwfn,
564565
"MFW mailbox: response 0x%08x param 0x%08x [after %d.%03d ms]\n",
565566
p_mb_params->mcp_resp,
566567
p_mb_params->mcp_param,
567-
(cnt * usecs) / 1000, (cnt * usecs) % 1000);
568+
(cnt * QED_MCP_RESP_ITER_US) / 1000,
569+
(cnt * QED_MCP_RESP_ITER_US) % 1000);
568570

569571
/* Clear the sequence number from the MFW response */
570572
p_mb_params->mcp_resp &= FW_MSG_CODE_MASK;
@@ -581,8 +583,6 @@ static int qed_mcp_cmd_and_union(struct qed_hwfn *p_hwfn,
581583
struct qed_mcp_mb_params *p_mb_params)
582584
{
583585
size_t union_data_size = sizeof(union drv_union_data);
584-
u32 max_retries = QED_DRV_MB_MAX_RETRIES;
585-
u32 usecs = QED_MCP_RESP_ITER_US;
586586

587587
/* MCP not initialized */
588588
if (!qed_mcp_is_init(p_hwfn)) {
@@ -606,13 +606,7 @@ static int qed_mcp_cmd_and_union(struct qed_hwfn *p_hwfn,
606606
return -EINVAL;
607607
}
608608

609-
if (QED_MB_FLAGS_IS_SET(p_mb_params, CAN_SLEEP)) {
610-
max_retries = DIV_ROUND_UP(max_retries, 1000);
611-
usecs *= 1000;
612-
}
613-
614-
return _qed_mcp_cmd_and_union(p_hwfn, p_ptt, p_mb_params, max_retries,
615-
usecs);
609+
return _qed_mcp_cmd_and_union(p_hwfn, p_ptt, p_mb_params);
616610
}
617611

618612
static int _qed_mcp_cmd(struct qed_hwfn *p_hwfn,

0 commit comments

Comments
 (0)