From: Christian Riesch Date: Mon, 16 Apr 2012 04:35:25 +0000 (+0000) Subject: davinci_mdio: Fix MDIO timeout check X-Git-Tag: v3.0.30~54 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=590999cbb260ae3a2907d4070bdd535c28e86868;p=karo-tx-linux.git davinci_mdio: Fix MDIO timeout check commit 5b76d0600b2b08eef77f8e9226938b7b6bde3099 upstream. Under heavy load (flood ping) it is possible for the MDIO timeout to expire before the loop checks the GO bit again. This patch adds an additional check whether the operation was done before actually returning -ETIMEDOUT. To reproduce this bug, flood ping the device, e.g., ping -f -l 1000 After some time, a "timed out waiting for user access" warning may appear. And even worse, link may go down since the PHY reported a timeout. Signed-off-by: Christian Riesch Cc: Cyril Chemparathy Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/net/davinci_mdio.c b/drivers/net/davinci_mdio.c index 7615040df756..f470ab64b093 100644 --- a/drivers/net/davinci_mdio.c +++ b/drivers/net/davinci_mdio.c @@ -181,6 +181,11 @@ static inline int wait_for_user_access(struct davinci_mdio_data *data) __davinci_mdio_reset(data); return -EAGAIN; } + + reg = __raw_readl(®s->user[0].access); + if ((reg & USERACCESS_GO) == 0) + return 0; + dev_err(data->dev, "timed out waiting for user access\n"); return -ETIMEDOUT; }