qed: make 'ethtool -d' 10 times faster
authorMichal Schmidt <mschmidt@redhat.com>
Mon, 30 Sep 2024 20:13:04 +0000 (22:13 +0200)
committerJakub Kicinski <kuba@kernel.org>
Fri, 4 Oct 2024 16:25:14 +0000 (09:25 -0700)
commitb8db67d4df0022e3595263b542953c251f4ccf06
tree83348ac4af067d53c04400a59ba571dbd3b8cb64
parent4cd0bd19ce933cf7b087f0c321c564da0e58f1b2
qed: make 'ethtool -d' 10 times faster

As a side effect of commit 5401c3e09928 ("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 <mschmidt@redhat.com>
Link: https://patch.msgid.link/20240930201307.330692-2-mschmidt@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/qlogic/qed/qed_mcp.c