Skip to content

Commit

Permalink
Merge branch 'qed-ethtool-d-faster-less-latency'
Browse files Browse the repository at this point in the history
Michal Schmidt says:

====================
qed: 'ethtool -d' faster, less latency

Here is a patch to make 'ethtool -d' on a qede network device a lot
faster and 3 patches to make it cause less latency for other tasks on
non-preemptible kernels.
====================

Link: https://patch.msgid.link/20240930201307.330692-1-mschmidt@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Jakub Kicinski committed Oct 4, 2024
2 parents 4cd0bd1 + 2efeaf1 commit 6443cf1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 29 deletions.
1 change: 1 addition & 0 deletions drivers/net/ethernet/qlogic/qed/qed_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -2873,6 +2873,7 @@ static u32 qed_grc_dump_ctx_data(struct qed_hwfn *p_hwfn,
false,
SPLIT_TYPE_NONE, 0);
}
cond_resched();
}

return offset;
Expand Down
1 change: 1 addition & 0 deletions drivers/net/ethernet/qlogic/qed/qed_hw.c
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,7 @@ static int qed_dmae_operation_wait(struct qed_hwfn *p_hwfn)
barrier();
while (*p_hwfn->dmae_info.p_completion_word != DMAE_COMPLETION_VAL) {
udelay(DMAE_MIN_WAIT_TIME);
cond_resched();
if (++wait_cnt > wait_cnt_limit) {
DP_NOTICE(p_hwfn->cdev,
"Timed-out waiting for operation to complete. Completion word is 0x%08x expected 0x%08x.\n",
Expand Down
45 changes: 16 additions & 29 deletions drivers/net/ethernet/qlogic/qed/qed_mcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -459,12 +459,11 @@ static void qed_mcp_print_cpu_info(struct qed_hwfn *p_hwfn,
static int
_qed_mcp_cmd_and_union(struct qed_hwfn *p_hwfn,
struct qed_ptt *p_ptt,
struct qed_mcp_mb_params *p_mb_params,
u32 max_retries, u32 usecs)
struct qed_mcp_mb_params *p_mb_params)
{
u32 cnt = 0, msecs = DIV_ROUND_UP(usecs, 1000);
struct qed_mcp_cmd_elem *p_cmd_elem;
u16 seq_num;
u32 cnt = 0;
int rc = 0;

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

if (QED_MB_FLAGS_IS_SET(p_mb_params, CAN_SLEEP))
msleep(msecs);
usleep_range(QED_MCP_RESP_ITER_US,
QED_MCP_RESP_ITER_US * 2);
else
udelay(usecs);
} while (++cnt < max_retries);
udelay(QED_MCP_RESP_ITER_US);
} while (++cnt < QED_DRV_MB_MAX_RETRIES);

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

if (QED_MB_FLAGS_IS_SET(p_mb_params, CAN_SLEEP))
msleep(msecs);
usleep_range(QED_MCP_RESP_ITER_US,
QED_MCP_RESP_ITER_US * 2);
else
udelay(usecs);
udelay(QED_MCP_RESP_ITER_US);

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

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

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

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

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

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

if (QED_MB_FLAGS_IS_SET(p_mb_params, CAN_SLEEP)) {
max_retries = DIV_ROUND_UP(max_retries, 1000);
usecs *= 1000;
}

return _qed_mcp_cmd_and_union(p_hwfn, p_ptt, p_mb_params, max_retries,
usecs);
return _qed_mcp_cmd_and_union(p_hwfn, p_ptt, p_mb_params);
}

static int _qed_mcp_cmd(struct qed_hwfn *p_hwfn,
Expand Down Expand Up @@ -3085,20 +3079,13 @@ int qed_mcp_nvm_read(struct qed_dev *cdev, u32 addr, u8 *p_buf, u32 len)
DRV_MB_PARAM_NVM_LEN_OFFSET),
&resp, &resp_param,
&read_len,
(u32 *)(p_buf + offset), false);
(u32 *)(p_buf + offset), true);

if (rc || (resp != FW_MSG_CODE_NVM_OK)) {
DP_NOTICE(cdev, "MCP command rc = %d\n", rc);
break;
}

/* This can be a lengthy process, and it's possible scheduler
* isn't preemptible. Sleep a bit to prevent CPU hogging.
*/
if (bytes_left % 0x1000 <
(bytes_left - read_len) % 0x1000)
usleep_range(1000, 2000);

offset += read_len;
bytes_left -= read_len;
}
Expand Down

0 comments on commit 6443cf1

Please sign in to comment.