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

Commit 83176dae authored by Danny Segal's avatar Danny Segal
Browse files

usb: dwc: Fix function wakeup during suspend on SW path



When the SW wants to start USB traffic during USB bus suspend state, it
needs to issue remote-wakeup signaling to the USB host before sending the
function wakeup notification. This patch changes the function wakeup
sending notification function to check whenter the USB bus is suspended
and issue remote-wakeup if needed.

CRs-Fixed: 678203
Change-Id: I1b09e7763c821a0a0e62095b4dc1c8621a2316b3
Signed-off-by: default avatarDanny Segal <dsegal@codeaurora.org>
parent 02a2c6ee
Loading
Loading
Loading
Loading
+22 −12
Original line number Diff line number Diff line
@@ -1414,28 +1414,33 @@ static inline enum dwc3_link_state dwc3_get_link_state(struct dwc3 *dwc)
	return DWC3_DSTS_USBLNKST(reg);
}

static int dwc3_gadget_ep_queue(struct usb_ep *ep, struct usb_request *request,
	gfp_t gfp_flags)
static bool dwc3_gadget_is_suspended(struct dwc3 *dwc)
{
	struct dwc3_request		*req = to_dwc3_request(request);
	struct dwc3_ep			*dep = to_dwc3_ep(ep);
	struct dwc3			*dwc = dep->dwc;

	unsigned long			flags;
	enum dwc3_link_state		link_state;
	int				ret;
	bool wakeup = false;

	if (atomic_read(&dwc->in_lpm)) {
		wakeup = true;
		return true;
	} else {
		link_state = dwc3_get_link_state(dwc);
		if (link_state == DWC3_LINK_STATE_RX_DET ||
			link_state == DWC3_LINK_STATE_U3)
			wakeup = true;
			return true;
	}

	return false;
}

	if (wakeup) {
static int dwc3_gadget_ep_queue(struct usb_ep *ep, struct usb_request *request,
	gfp_t gfp_flags)
{
	struct dwc3_request		*req = to_dwc3_request(request);
	struct dwc3_ep			*dep = to_dwc3_ep(ep);
	struct dwc3			*dwc = dep->dwc;

	unsigned long			flags;
	int				ret;

	if (dwc3_gadget_is_suspended(dwc)) {
		dwc3_gadget_wakeup(&dwc->gadget);
		return -EAGAIN;
	}
@@ -1735,6 +1740,11 @@ static int dwc_gadget_func_wakeup(struct usb_gadget *g, int interface_id)
	if (!g || (g->speed != USB_SPEED_SUPER))
		return -ENOTSUPP;

	if (dwc3_gadget_is_suspended(dwc)) {
		dwc3_gadget_wakeup(&dwc->gadget);
		return -EAGAIN;
	}

	ret = dwc3_send_gadget_generic_command(dwc,
		DWC3_DGCMD_XMIT_FUNCTION, interface_id);