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

Commit e7898836 authored by Sriharsha Allenki's avatar Sriharsha Allenki
Browse files

usb: dwc3: gadget: Issue soft reset as part of composition switch



As part of composition switch, the device initiates
disconnect from the host by clearing the run/stop
bit of DCTL and initiates a connect by setting the run/stop bit.
But during this entire scenario the core is not reset
and there is a possibility of core caching the SETUP packets
from the previous session and giving this to the driver once the
run/stop bit is set leading to unintnented SETUP packets further
leading to stall on endpoint 0. This caused the endpoint 0 to
go into a bad state leading to enumeration failures.

Also, the databook clearly mentions that the soft reset has
to be issued before setting the run/stop bit to initialize a
conenct after a disconnect.
So, issue soft reset as part of composition switch to fix this
issue.

Change-Id: Id93bef710e7cdb67a6820cb4c9defecc5ad2a34e
Signed-off-by: default avatarSriharsha Allenki <sallenki@codeaurora.org>
parent ef302ddf
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -2102,6 +2102,12 @@ static int dwc3_device_core_soft_reset(struct dwc3 *dwc)
	/* phy sync delay as per data book */
	msleep(50);

	/*
	 * Soft reset clears the block on the doorbell,
	 * set it back to prevent unwanted writes to the doorbell.
	 */
	dwc3_notify_event(dwc, DWC3_CONTROLLER_NOTIFY_CLEAR_DB, 0);

	return 0;
}

@@ -2265,6 +2271,9 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on)
	/* prevent pending bh to run later */
	flush_work(&dwc->bh_work);

	if (is_on)
		dwc3_device_core_soft_reset(dwc);

	spin_lock_irqsave(&dwc->lock, flags);
	if (dwc->ep0state != EP0_SETUP_PHASE)
		dbg_event(0xFF, "EP0 is not in SETUP phase\n", 0);