1/2] net: axienet: use readx_poll_timeout() in mdio wait function
authorKurt Kanzenbach <kurt@linutronix.de>
Sun, 19 May 2019 17:59:36 +0000 (19:59 +0200)
committerDavid S. Miller <davem@davemloft.net>
Tue, 21 May 2019 00:00:46 +0000 (20:00 -0400)
On loaded systems with a preemptible kernel the mdio_wait() function may
report an error while everything is working fine:

axienet_mdio_wait_until_ready():
  axienet_ior() -> chip not ready
  --> interrupt here (other work for some time / chip become ready)
  if (time_before_eq(end, jiffies))
    --> false positive error report

Replace the current code with readx_poll_timeout() which take care
of the situation.

Signed-off-by: Kurt Kanzenbach <kurt@linutronix.de>
Signed-off-by: Benedikt Spranger <b.spranger@linutronix.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/xilinx/xilinx_axienet.h
drivers/net/ethernet/xilinx/xilinx_axienet_mdio.c

index c337400485dad83ee0fd13a1a32c5dd89ac7b64f..011adae32b89e0f4aa94347352a11b974d8101b6 100644 (file)
@@ -484,6 +484,11 @@ static inline u32 axienet_ior(struct axienet_local *lp, off_t offset)
        return in_be32(lp->regs + offset);
 }
 
+static inline u32 axinet_ior_read_mcr(struct axienet_local *lp)
+{
+       return axienet_ior(lp, XAE_MDIO_MCR_OFFSET);
+}
+
 /**
  * axienet_iow - Memory mapped Axi Ethernet register write
  * @lp:         Pointer to axienet local structure
index 757a3b37ae8a8af8077001d548b65fe862d03c2d..704babdbc8a222a68510476ce9625dd305820a01 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/of_address.h>
 #include <linux/of_mdio.h>
 #include <linux/jiffies.h>
+#include <linux/iopoll.h>
 
 #include "xilinx_axienet.h"
 
 /* Wait till MDIO interface is ready to accept a new transaction.*/
 int axienet_mdio_wait_until_ready(struct axienet_local *lp)
 {
-       unsigned long end = jiffies + 2;
-       while (!(axienet_ior(lp, XAE_MDIO_MCR_OFFSET) &
-                XAE_MDIO_MCR_READY_MASK)) {
-               if (time_before_eq(end, jiffies)) {
-                       WARN_ON(1);
-                       return -ETIMEDOUT;
-               }
-               udelay(1);
-       }
-       return 0;
+       u32 val;
+
+       return readx_poll_timeout(axinet_ior_read_mcr, lp,
+                                 val, val & XAE_MDIO_MCR_READY_MASK,
+                                 1, 20000);
 }
 
 /**