Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 93f5ce49 authored by Hemant Kumar's avatar Hemant Kumar
Browse files

usb: XHCI: Implement xhci_handshake_check_state() API



This API is called to handle command timeout which may
happen upon XHCI stack removal. Since handshake is performed
by polling long duration for status, this can cause watchdog
timeout if status does not change for entire duration of
polling. Hence add new API which also checks for xhci state
and exit the handshake if xhci is removed.

Change-Id: I9a90b2dd83d76f80e3f6fd4546b949c88850edd3
Signed-off-by: default avatarHemant Kumar <hemantk@codeaurora.org>
parent b639b04b
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -78,6 +78,25 @@ int xhci_handshake(void __iomem *ptr, u32 mask, u32 done, int usec)
	return -ETIMEDOUT;
}

int xhci_handshake_check_state(struct xhci_hcd *xhci,
		void __iomem *ptr, u32 mask, u32 done, int usec)
{
	u32	result;

	do {
		result = readl_relaxed(ptr);
		if (result == ~(u32)0 ||
		xhci->xhc_state == XHCI_STATE_REMOVING)	/* card removed */
			return -ENODEV;
		result &= mask;
		if (result == done)
			return 0;
		udelay(1);
		usec--;
	} while (usec > 0);
	return -ETIMEDOUT;
}

/*
 * Disable interrupts and begin the xHCI halting process.
 */
+2 −0
Original line number Diff line number Diff line
@@ -1864,6 +1864,8 @@ int xhci_sec_event_ring_cleanup(struct usb_hcd *hcd, unsigned int intr_num);
/* xHCI host controller glue */
typedef void (*xhci_get_quirks_t)(struct device *, struct xhci_hcd *);
int xhci_handshake(void __iomem *ptr, u32 mask, u32 done, int usec);
int xhci_handshake_check_state(struct xhci_hcd *xhci,
		void __iomem *ptr, u32 mask, u32 done, int usec);
void xhci_quiesce(struct xhci_hcd *xhci);
int xhci_halt(struct xhci_hcd *xhci);
int xhci_reset(struct xhci_hcd *xhci);