Skip to content
Snippets Groups Projects
Commit ab5a0dcb authored by Stefan Roese's avatar Stefan Roese Committed by Ben Warren
Browse files

net: Use 0.5 sec timeout in miiphy_reset() instead of counting loop


This patch fixes a problem I've notived on a buggy PPC4xx system. This
system has problems with the PHY MDIO communication and seemed to be
stuck/crashed in miiphy_reset(). But degugging revealed, that the CPU
didn't crash, but "only" hung in this counting loop for about 2 minutes.

This patch now uses a real timeout of 0.5 seconds (as mentioned in the
comment in miiphy_reset).

Signed-off-by: default avatarStefan Roese <sr@denx.de>
Signed-off-by: default avatarBen Warren <biggerbadderben@gmail.com>
parent 4294b248
No related branches found
No related tags found
No related merge requests found
...@@ -293,7 +293,7 @@ int miiphy_info (char *devname, unsigned char addr, unsigned int *oui, ...@@ -293,7 +293,7 @@ int miiphy_info (char *devname, unsigned char addr, unsigned int *oui,
int miiphy_reset (char *devname, unsigned char addr) int miiphy_reset (char *devname, unsigned char addr)
{ {
unsigned short reg; unsigned short reg;
int loop_cnt; int timeout = 500;
if (miiphy_read (devname, addr, PHY_BMCR, &reg) != 0) { if (miiphy_read (devname, addr, PHY_BMCR, &reg) != 0) {
debug ("PHY status read failed\n"); debug ("PHY status read failed\n");
...@@ -311,13 +311,13 @@ int miiphy_reset (char *devname, unsigned char addr) ...@@ -311,13 +311,13 @@ int miiphy_reset (char *devname, unsigned char addr)
* auto-clearing). This should happen within 0.5 seconds per the * auto-clearing). This should happen within 0.5 seconds per the
* IEEE spec. * IEEE spec.
*/ */
loop_cnt = 0;
reg = 0x8000; reg = 0x8000;
while (((reg & 0x8000) != 0) && (loop_cnt++ < 1000000)) { while (((reg & 0x8000) != 0) && timeout--) {
if (miiphy_read (devname, addr, PHY_BMCR, &reg) != 0) { if (miiphy_read(devname, addr, PHY_BMCR, &reg) != 0) {
debug ("PHY status read failed\n"); debug("PHY status read failed\n");
return (-1); return -1;
} }
udelay(1000);
} }
if ((reg & 0x8000) == 0) { if ((reg & 0x8000) == 0) {
return (0); return (0);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment