public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xhci: Introduce max wait timeout in xhci_handshake()
@ 2020-12-15 13:22 Chen Yu
  2020-12-15 13:39 ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: Chen Yu @ 2020-12-15 13:22 UTC (permalink / raw)
  To: Mathias Nyman
  Cc: linux-usb, linux-kernel, Muchowski, MaciejX, Paczynski, Lukasz,
	Chen Yu

The time to finish a xhci_handshake() is platform specific
and sometimes during suspend resume test the followng
errors were encountered:
[53455.418330] ACPI: Waking up from system sleep state S4
[66838.490856] xhci_hcd 0000:00:14.0: xHCI dying, ignoring interrupt.
               Shouldn't IRQs be disabled?
After changing the poll time granularity from 1 usec to 20 usec in
xhci_handshake() this issue was not reproduced. While tuning on the
poll time granularity might be painful on different platforms, it is
applicable to introduce a module parameter to allow the xhci driver to wait
for at max 16 ms.

Reported-by: "Muchowski, MaciejX" <maciejx.muchowski@intel.com>
Signed-off-by: Chen Yu <yu.c.chen@intel.com>
---
 drivers/usb/host/xhci.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index d4a8d0efbbc4..b8be9f3cc987 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -38,6 +38,10 @@ static unsigned long long quirks;
 module_param(quirks, ullong, S_IRUGO);
 MODULE_PARM_DESC(quirks, "Bit flags for quirks to be enabled as default");
 
+static int wait_handshake;
+module_param(wait_handshake, int, 0644);
+MODULE_PARM_DESC(wait_handshake, "Force wait for completion of handshake");
+
 static bool td_on_ring(struct xhci_td *td, struct xhci_ring *ring)
 {
 	struct xhci_segment *seg = ring->first_seg;
@@ -74,7 +78,7 @@ int xhci_handshake(void __iomem *ptr, u32 mask, u32 done, int usec)
 	ret = readl_poll_timeout_atomic(ptr, result,
 					(result & mask) == done ||
 					result == U32_MAX,
-					1, usec);
+					1, wait_handshake ? XHCI_MAX_HALT_USEC : usec);
 	if (result == U32_MAX)		/* card removed */
 		return -ENODEV;
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-12-16  4:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-15 13:22 [PATCH] xhci: Introduce max wait timeout in xhci_handshake() Chen Yu
2020-12-15 13:39 ` Greg KH
2020-12-16  4:36   ` Chen Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox