Skip to content

Commit

Permalink
Introduce sleeps during and timing debug messages for TDR cable test.
Browse files Browse the repository at this point in the history
This WiP patch should avoid Timeouts during TDR test execution and also
reduce busy-waiting on some mdio bus implementations (e.g. ath79).

Debug printks are added for discovery of optimal default timings
(initial wait and retry).
  • Loading branch information
tim-seoss committed Nov 27, 2024
1 parent 52b6c92 commit 54198a8
Showing 1 changed file with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
Index: linux-6.6.61/drivers/net/phy/marvell.c
===================================================================
--- linux-6.6.61.orig/drivers/net/phy/marvell.c
+++ linux-6.6.61/drivers/net/phy/marvell.c
@@ -38,6 +38,9 @@
#include <asm/irq.h>
#include <linux/uaccess.h>

+/* For timing debugging only TODO remove */
+#include <linux/time.h>
+
#define MII_MARVELL_PHY_PAGE 22
#define MII_MARVELL_COPPER_PAGE 0x00
#define MII_MARVELL_FIBER_PAGE 0x01
@@ -2042,14 +2045,24 @@ static int marvell_vct5_wait_complete(st
{
int i;
int val;
+ u64 entrystamp, exitstamp;
+ entrystamp = ktime_get_ns();
+
+ usleep_range(5000, 5000);
+ /* msleep(10); */

- for (i = 0; i < 32; i++) {
+ for (i = 0; i < 100; i++) {
val = __phy_read(phydev, MII_VCT5_CTRL);
if (val < 0)
return val;

- if (val & MII_VCT5_CTRL_COMPLETE)
+ if (val & MII_VCT5_CTRL_COMPLETE) {
+ exitstamp = ktime_get_ns();
+ phydev_warn(phydev, "Got VCT5 ctrl data after polling %d times\n", i);
+ phydev_warn(phydev, "Got VCT5 after %llu ns\n", exitstamp - entrystamp);
return 0;
+ }
+ usleep_range(500, 500);
}

phydev_err(phydev, "Timeout while waiting for cable test to finish\n");

0 comments on commit 54198a8

Please sign in to comment.