UPSTREAM: usb: dwc3: Do not service EP0 and conndone events if soft disconnected
There are some operations that need to be ignored if there is a soft
disconnect in progress. This is to avoid having a pending EP0 transfer in
progress while attempting to stop active transfers and halting the
controller.
There were several instances seen where a soft disconnect was able to occur
during early link negotiation, i.e. bus reset/conndone, which leads to the
conndone handler re-configuring EPs while attempting to halt the
controller, as DEP flags are cleared as part of the soft disconnect path.
ep0out: cmd 'Start New Configuration'
ep0out: cmd 'Set Endpoint Transfer Resource'
ep0in: cmd 'Set Endpoint Transfer Resource'
ep1out: cmd 'Set Endpoint Transfer Resource'
...
event (00030601): Suspend [U3]
event (00000101): Reset [U0]
ep0out: req ffffff87e5c9e100 length 0/0 zsI ==> 0
event (00000201): Connection Done [U0]
ep0out: cmd 'Start New Configuration'
ep0out: cmd 'Set Endpoint Transfer Resource'
In addition, if a soft disconnect occurs, EP0 events are still allowed to
process, however, it will stall/restart during the SETUP phase. The
host is still able to query for the DATA phase, leading to a
xfernotready(DATA) event. Since none of the SETUP transfer parameters are
populated, the xfernotready is treated as a "wrong direction" error,
leading to a duplicate stall/restart routine.
Add the proper softconnect/connected checks in sequences that are
potentially involved during soft disconnect processing.
Reviewed-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Signed-off-by: Wesley Cheng <quic_wcheng@quicinc.com>
Link: https://lore.kernel.org/r/20220817182359.13550-2-quic_wcheng@quicinc.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 359d5a85a7)
Bug: 263189538
Change-Id: Ia933ce7a70febbab8bb122d650691bd937d9ec37
Signed-off-by: Krishna Kurapati <quic_kriskura@quicinc.com>
This commit is contained in:
committed by
Treehugger Robot
parent
dd8418a59a
commit
5dc06419d8
@@ -197,7 +197,7 @@ int dwc3_gadget_ep0_queue(struct usb_ep *ep, struct usb_request *request,
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
spin_lock_irqsave(&dwc->lock, flags);
|
spin_lock_irqsave(&dwc->lock, flags);
|
||||||
if (!dep->endpoint.desc || !dwc->pullups_connected) {
|
if (!dep->endpoint.desc || !dwc->pullups_connected || !dwc->connected) {
|
||||||
dev_err(dwc->dev, "%s: can't queue to disabled endpoint\n",
|
dev_err(dwc->dev, "%s: can't queue to disabled endpoint\n",
|
||||||
dep->name);
|
dep->name);
|
||||||
ret = -ESHUTDOWN;
|
ret = -ESHUTDOWN;
|
||||||
@@ -814,8 +814,9 @@ static void dwc3_ep0_inspect_setup(struct dwc3 *dwc,
|
|||||||
struct usb_ctrlrequest *ctrl = (void *) dwc->ep0_trb;
|
struct usb_ctrlrequest *ctrl = (void *) dwc->ep0_trb;
|
||||||
int ret = -EINVAL;
|
int ret = -EINVAL;
|
||||||
u32 len;
|
u32 len;
|
||||||
|
struct dwc3_vendor *vdwc = container_of(dwc, struct dwc3_vendor, dwc);
|
||||||
|
|
||||||
if (!dwc->gadget_driver || !dwc->connected)
|
if (!dwc->gadget_driver || !vdwc->softconnect || !dwc->connected)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
trace_dwc3_ctrl_req(ctrl);
|
trace_dwc3_ctrl_req(ctrl);
|
||||||
@@ -1115,8 +1116,12 @@ void dwc3_ep0_end_control_data(struct dwc3 *dwc, struct dwc3_ep *dep)
|
|||||||
static void dwc3_ep0_xfernotready(struct dwc3 *dwc,
|
static void dwc3_ep0_xfernotready(struct dwc3 *dwc,
|
||||||
const struct dwc3_event_depevt *event)
|
const struct dwc3_event_depevt *event)
|
||||||
{
|
{
|
||||||
|
struct dwc3_vendor *vdwc = container_of(dwc, struct dwc3_vendor, dwc);
|
||||||
|
|
||||||
switch (event->status) {
|
switch (event->status) {
|
||||||
case DEPEVT_STATUS_CONTROL_DATA:
|
case DEPEVT_STATUS_CONTROL_DATA:
|
||||||
|
if (!vdwc->softconnect || !dwc->connected)
|
||||||
|
return;
|
||||||
/*
|
/*
|
||||||
* We already have a DATA transfer in the controller's cache,
|
* We already have a DATA transfer in the controller's cache,
|
||||||
* if we receive a XferNotReady(DATA) we will ignore it, unless
|
* if we receive a XferNotReady(DATA) we will ignore it, unless
|
||||||
|
|||||||
@@ -3877,6 +3877,10 @@ static void dwc3_gadget_conndone_interrupt(struct dwc3 *dwc)
|
|||||||
u32 reg;
|
u32 reg;
|
||||||
u8 lanes = 1;
|
u8 lanes = 1;
|
||||||
u8 speed;
|
u8 speed;
|
||||||
|
struct dwc3_vendor *vdwc = container_of(dwc, struct dwc3_vendor, dwc);
|
||||||
|
|
||||||
|
if (!vdwc->softconnect)
|
||||||
|
return;
|
||||||
|
|
||||||
reg = dwc3_readl(dwc->regs, DWC3_DSTS);
|
reg = dwc3_readl(dwc->regs, DWC3_DSTS);
|
||||||
speed = reg & DWC3_DSTS_CONNECTSPD;
|
speed = reg & DWC3_DSTS_CONNECTSPD;
|
||||||
|
|||||||
Reference in New Issue
Block a user