Commit a618e86d authored by Andrew Lunn's avatar Andrew Lunn Committed by David S. Miller

net : phy: marvell: Speedup TDR data retrieval by only changing page once

Getting the TDR data requires a large number of MDIO bus
transactions. The number can however be reduced if the page is only
changed once. Add the needed locking to allow this, and make use of
unlocked read/write methods where needed.
Signed-off-by: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f2bc8ad3
...@@ -1751,15 +1751,12 @@ static int marvell_vct5_wait_complete(struct phy_device *phydev) ...@@ -1751,15 +1751,12 @@ static int marvell_vct5_wait_complete(struct phy_device *phydev)
int val; int val;
for (i = 0; i < 32; i++) { for (i = 0; i < 32; i++) {
val = phy_read_paged(phydev, MII_MARVELL_VCT5_PAGE, val = __phy_read(phydev, MII_VCT5_CTRL);
MII_VCT5_CTRL);
if (val < 0) if (val < 0)
return val; return val;
if (val & MII_VCT5_CTRL_COMPLETE) if (val & MII_VCT5_CTRL_COMPLETE)
return 0; return 0;
usleep_range(1000, 2000);
} }
phydev_err(phydev, "Timeout while waiting for cable test to finish\n"); phydev_err(phydev, "Timeout while waiting for cable test to finish\n");
...@@ -1773,7 +1770,7 @@ static int marvell_vct5_amplitude(struct phy_device *phydev, int pair) ...@@ -1773,7 +1770,7 @@ static int marvell_vct5_amplitude(struct phy_device *phydev, int pair)
int reg; int reg;
reg = MII_VCT5_TX_RX_MDI0_COUPLING + pair; reg = MII_VCT5_TX_RX_MDI0_COUPLING + pair;
val = phy_read_paged(phydev, MII_MARVELL_VCT5_PAGE, reg); val = __phy_read(phydev, reg);
if (val < 0) if (val < 0)
return 0; return 0;
...@@ -1805,8 +1802,7 @@ static int marvell_vct5_amplitude_distance(struct phy_device *phydev, ...@@ -1805,8 +1802,7 @@ static int marvell_vct5_amplitude_distance(struct phy_device *phydev,
int mV; int mV;
int i; int i;
err = phy_write_paged(phydev, MII_MARVELL_VCT5_PAGE, err = __phy_write(phydev, MII_VCT5_SAMPLE_POINT_DISTANCE,
MII_VCT5_SAMPLE_POINT_DISTANCE,
distance); distance);
if (err) if (err)
return err; return err;
...@@ -1816,8 +1812,7 @@ static int marvell_vct5_amplitude_distance(struct phy_device *phydev, ...@@ -1816,8 +1812,7 @@ static int marvell_vct5_amplitude_distance(struct phy_device *phydev,
MII_VCT5_CTRL_SAMPLES_DEFAULT | MII_VCT5_CTRL_SAMPLES_DEFAULT |
MII_VCT5_CTRL_SAMPLE_POINT | MII_VCT5_CTRL_SAMPLE_POINT |
MII_VCT5_CTRL_PEEK_HYST_DEFAULT; MII_VCT5_CTRL_PEEK_HYST_DEFAULT;
err = phy_write_paged(phydev, MII_MARVELL_VCT5_PAGE, err = __phy_write(phydev, MII_VCT5_CTRL, reg);
MII_VCT5_CTRL, reg);
if (err) if (err)
return err; return err;
...@@ -1840,6 +1835,7 @@ static int marvell_vct5_amplitude_graph(struct phy_device *phydev) ...@@ -1840,6 +1835,7 @@ static int marvell_vct5_amplitude_graph(struct phy_device *phydev)
{ {
struct marvell_priv *priv = phydev->priv; struct marvell_priv *priv = phydev->priv;
int distance; int distance;
int page;
int err; int err;
u16 reg; u16 reg;
...@@ -1853,16 +1849,27 @@ static int marvell_vct5_amplitude_graph(struct phy_device *phydev) ...@@ -1853,16 +1849,27 @@ static int marvell_vct5_amplitude_graph(struct phy_device *phydev)
if (err) if (err)
return err; return err;
/* Reading the TDR data is very MDIO heavy. We need to optimize
* access to keep the time to a minimum. So lock the bus once,
* and don't release it until complete. We can then avoid having
* to change the page for every access, greatly speeding things
* up.
*/
page = phy_select_page(phydev, MII_MARVELL_VCT5_PAGE);
if (page < 0)
return page;
for (distance = priv->first; for (distance = priv->first;
distance <= priv->last; distance <= priv->last;
distance += priv->step) { distance += priv->step) {
err = marvell_vct5_amplitude_distance(phydev, distance, err = marvell_vct5_amplitude_distance(phydev, distance,
priv->pair); priv->pair);
if (err) if (err)
return err; goto restore_page;
} }
return 0; restore_page:
return phy_restore_page(phydev, page, err);
} }
static int marvell_cable_test_start_common(struct phy_device *phydev) static int marvell_cable_test_start_common(struct phy_device *phydev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment