Skip to content

Commit

Permalink
realtek: Use atomic poll for aux-mdio commands
Browse files Browse the repository at this point in the history
regmap_read_poll_timeout() relies on usleep_range() to time the polling
loop. With the current, rather large, scheduling interval, a short
usleep_range() may take a lot longer than expected, causing performance
issues.

Switch the driver over to using regmap_read_poll_timeout_atomic(), which
uses udelay() to time the polling loop.

For comparision, the 'ethtool -m <dev>' command is about 10 times faster
with the atomic variant.
Using 'perf -r10 ethtool -m lan25':
  - Driver using regmap_read_poll_timeout():
      2.0117 +- 0.0118 seconds time elapsed  ( +-  0.58% )
  - Driver using regmap_read_poll_timeout_atomic():
      0.1674 +- 0.0250 seconds time elapsed  ( +- 14.95% )

Signed-off-by: Sander Vanheule <[email protected]>
  • Loading branch information
svanheule committed Jan 16, 2025
1 parent 0a7c8ed commit 693c1ea
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Signed-off-by: Sander Vanheule <[email protected]>
+ if (err)
+ return err;
+
+ err = regmap_read_poll_timeout(ctrl->map, ctrl->cmd_reg, run, (run != cmd), 3, 100);
+ err = regmap_read_poll_timeout_atomic(ctrl->map, ctrl->cmd_reg, run, (run != cmd), 3, 100);
+
+ if ((run & ~mask_volatile) != (cmd & ~mask_volatile)) {
+ dev_err(ctrl->dev, "Command modified. Is offloading still active?");
Expand Down

0 comments on commit 693c1ea

Please sign in to comment.