Commit 239c0a91 authored by Andrey Smirnov's avatar Andrey Smirnov Committed by Greg Kroah-Hartman

xhci: Convert xhci_handshake() to use readl_poll_timeout_atomic()

commit f7fac17c upstream.

Xhci_handshake() implements the algorithm already captured by
readl_poll_timeout_atomic(). Convert the former to use the latter to
avoid repetition.

Turned out this patch also fixes a bug on the AMD Stoneyridge platform
where usleep(1) sometimes takes over 10ms.
This means a 5 second timeout can easily take over 15 seconds which will
trigger the watchdog and reboot the system.

[Add info about patch fixing a bug to commit message -Mathias]
Signed-off-by: default avatarAndrey Smirnov <andrew.smirnov@gmail.com>
Tested-by: default avatarRaul E Rangel <rrangel@chromium.org>
Reviewed-by: default avatarRaul E Rangel <rrangel@chromium.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: default avatarMathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 1f44ae1f
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
*/ */
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/iopoll.h>
#include <linux/irq.h> #include <linux/irq.h>
#include <linux/log2.h> #include <linux/log2.h>
#include <linux/module.h> #include <linux/module.h>
...@@ -52,7 +53,6 @@ static bool td_on_ring(struct xhci_td *td, struct xhci_ring *ring) ...@@ -52,7 +53,6 @@ static bool td_on_ring(struct xhci_td *td, struct xhci_ring *ring)
return false; return false;
} }
/* TODO: copied from ehci-hcd.c - can this be refactored? */
/* /*
* xhci_handshake - spin reading hc until handshake completes or fails * xhci_handshake - spin reading hc until handshake completes or fails
* @ptr: address of hc register to be read * @ptr: address of hc register to be read
...@@ -69,18 +69,16 @@ static bool td_on_ring(struct xhci_td *td, struct xhci_ring *ring) ...@@ -69,18 +69,16 @@ static bool td_on_ring(struct xhci_td *td, struct xhci_ring *ring)
int xhci_handshake(void __iomem *ptr, u32 mask, u32 done, int usec) int xhci_handshake(void __iomem *ptr, u32 mask, u32 done, int usec)
{ {
u32 result; u32 result;
int ret;
do { ret = readl_poll_timeout_atomic(ptr, result,
result = readl(ptr); (result & mask) == done ||
if (result == ~(u32)0) /* card removed */ result == U32_MAX,
return -ENODEV; 1, usec);
result &= mask; if (result == U32_MAX) /* card removed */
if (result == done) return -ENODEV;
return 0;
udelay(1); return ret;
usec--;
} while (usec > 0);
return -ETIMEDOUT;
} }
/* /*
......
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