netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: stmmac: Use msleep rather then udelay for reset delay
@ 2015-09-06 15:50 Sjoerd Simons
  2015-09-09  5:40 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Sjoerd Simons @ 2015-09-06 15:50 UTC (permalink / raw)
  To: Giuseppe Cavallaro; +Cc: netdev, linux-kernel

The reset delays used for stmmac are in the order of 10ms to 1 second,
which is far too long for udelay usage, so switch to using msleep.

Practically this fixes the PHY not being reliably detected in some cases
as udelay wouldn't actually delay for long enough to let the phy
reliably be reset.

Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
---

 drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
index b735fa2..17fa588 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
@@ -161,11 +161,16 @@ int stmmac_mdio_reset(struct mii_bus *bus)
 
 		if (!gpio_request(reset_gpio, "mdio-reset")) {
 			gpio_direction_output(reset_gpio, active_low ? 1 : 0);
-			udelay(data->delays[0]);
+			if (data->delays[0])
+				msleep((data->delays[0] + 999) / 1000);
+
 			gpio_set_value(reset_gpio, active_low ? 0 : 1);
-			udelay(data->delays[1]);
+			if (data->delays[1])
+				msleep((data->delays[1] + 999) / 1000);
+
 			gpio_set_value(reset_gpio, active_low ? 1 : 0);
-			udelay(data->delays[2]);
+			if (data->delays[2])
+				msleep((data->delays[2] + 999) / 1000);
 		}
 	}
 #endif
-- 
2.5.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] net: stmmac: Use msleep rather then udelay for reset delay
  2015-09-06 15:50 [PATCH] net: stmmac: Use msleep rather then udelay for reset delay Sjoerd Simons
@ 2015-09-09  5:40 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2015-09-09  5:40 UTC (permalink / raw)
  To: sjoerd.simons; +Cc: peppe.cavallaro, netdev, linux-kernel

From: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
Date: Sun,  6 Sep 2015 17:50:59 +0200

> @@ -161,11 +161,16 @@ int stmmac_mdio_reset(struct mii_bus *bus)
>  
>  		if (!gpio_request(reset_gpio, "mdio-reset")) {
>  			gpio_direction_output(reset_gpio, active_low ? 1 : 0);
> -			udelay(data->delays[0]);
> +			if (data->delays[0])
> +				msleep((data->delays[0] + 999) / 1000);

Please use something like DIV_ROUND_UP(..., USEC_PER_MSEC) or similar.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-09-09  5:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-06 15:50 [PATCH] net: stmmac: Use msleep rather then udelay for reset delay Sjoerd Simons
2015-09-09  5:40 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).