Commit 54472edf authored by Sekhar Nori's avatar Sekhar Nori Committed by David S. Miller

drivers: net: davinci_mdio: prevent spurious timeout

A well timed kernel preemption in the time_after() loop
in wait_for_idle() can result in a spurious timeout
error to be returned.

Fix it by using readl_poll_timeout() which takes care of
this issue.
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarSekhar Nori <nsekhar@ti.com>
Reviewed-by: default avatarGrygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent bfe1e616
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/iopoll.h>
#include <linux/pm_runtime.h> #include <linux/pm_runtime.h>
#include <linux/davinci_emac.h> #include <linux/davinci_emac.h>
#include <linux/of.h> #include <linux/of.h>
...@@ -227,14 +228,14 @@ static inline int wait_for_user_access(struct davinci_mdio_data *data) ...@@ -227,14 +228,14 @@ static inline int wait_for_user_access(struct davinci_mdio_data *data)
static inline int wait_for_idle(struct davinci_mdio_data *data) static inline int wait_for_idle(struct davinci_mdio_data *data)
{ {
struct davinci_mdio_regs __iomem *regs = data->regs; struct davinci_mdio_regs __iomem *regs = data->regs;
unsigned long timeout = jiffies + msecs_to_jiffies(MDIO_TIMEOUT); u32 val, ret;
while (time_after(timeout, jiffies)) { ret = readl_poll_timeout(&regs->control, val, val & CONTROL_IDLE,
if (__raw_readl(&regs->control) & CONTROL_IDLE) 0, MDIO_TIMEOUT * 1000);
return 0; if (ret)
} dev_err(data->dev, "timed out waiting for idle\n");
dev_err(data->dev, "timed out waiting for idle\n");
return -ETIMEDOUT; return ret;
} }
static int davinci_mdio_read(struct mii_bus *bus, int phy_id, int phy_reg) static int davinci_mdio_read(struct mii_bus *bus, int phy_id, int phy_reg)
......
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