From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Wesley Cheng <quic_wcheng@quicinc.com>
Cc: Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
"quic_jackp@quicinc.com" <quic_jackp@quicinc.com>,
"quic_ugoswami@quicinc.com" <quic_ugoswami@quicinc.com>
Subject: Re: [PATCH] usb: dwc3: gadget: Stall and restart EP0 if host is unresponsive
Date: Wed, 5 Apr 2023 18:49:46 +0000 [thread overview]
Message-ID: <20230405184943.fajtjau2dcgylg25@synopsys.com> (raw)
In-Reply-To: <f1ff2346-0fd5-2e77-044c-9dc95cd5683f@quicinc.com>
On Tue, Apr 04, 2023, Wesley Cheng wrote:
> Hi Thinh,
>
> On 4/4/2023 3:16 PM, Thinh Nguyen wrote:
> > On Tue, Apr 04, 2023, Wesley Cheng wrote:
> > > Hi Thinh,
> > >
> > > On 4/3/2023 6:11 PM, Thinh Nguyen wrote:
> > > > On Fri, Mar 31, 2023, Wesley Cheng wrote:
> > > > > It was observed that there are hosts that may complete pending SETUP
> > > > > transactions before the stop active transfers and controller halt occurs,
> > > > > leading to lingering endxfer commands on DEPs on subsequent pullup/gadget
> > > > > start iterations.
> > > >
> > > > Can you clarify this a bit further? Even though the controller is
> > > > halted, you still observed activity?
> > > >
> > >
> > > Yes...I didn't understand how that was possible either, but traces clearly
> > > showed that the controller halt was successful even though there were no
> > > endxfers issued on some EPs. Although, I can't say for certain if those EPs
> > > were actively being used at that time.
> > >
> >
> > The controller should only be halted after the (non-ep0) endpoints are
> > disabled.
> >
> > "even though there were no endxferx issued on some EPs", which EPs are
> > you referring to? If there's no End Transfer issued while the endpoints
> > are active and started during disconnect, we need to fix that in the
> > driver.
> >
>
> Sorry let me clarify. When I said there were no endxfers issued, I meant
> that they were pending (DWC3_EP_DELAY_STOP is set for those EPs). However,
> since the host wasn't moving the EP0 state forward, we never moved back to
> the SETUP phase, which is where we flush any pending end transfers.
>
> void dwc3_ep0_out_start(struct dwc3 *dwc)
> {
> ...
> for (i = 2; i < DWC3_ENDPOINTS_NUM; i++) {
> struct dwc3_ep *dwc3_ep;
>
> dwc3_ep = dwc->eps[i];
> if (!dwc3_ep)
> continue;
>
> if (!(dwc3_ep->flags & DWC3_EP_DELAY_STOP))
> continue;
>
> dwc3_ep->flags &= ~DWC3_EP_DELAY_STOP;
> if (dwc->connected)
> dwc3_stop_active_transfer(dwc3_ep, true, true);
> else
> dwc3_remove_requests(dwc, dwc3_ep, -ESHUTDOWN);
> }
> }
>
> This is part of the reason for moving the wait_for_completion() call until
> AFTER the stop active transfers, since that is the point at which we could
> potentially set the DWC3_EP_DELAY_STOP. If there is a host not moving the
> EP0 state, then we can at least utilize the timeout path to force EP0 back
> to the setup phase.
>
Thanks for the clarification. If I understand correctly, the issue here
is the missing handling of the timeout of the wait for control transfer
completion. This can happen if we enter flow control and/or if the host
delays polling for data. If it times out, then we'll have problems as
you mention above.
In that case, we can halt the control endpoint causing it to respond
with a STALL to the next host polling of data, cancelling the control
transfer. This is what you did with dwc3_ep0_reset_state() on timeout
right?
I think this should work as the End Transfer commands should complete
before the controller is halted.
Thanks,
Thinh
next prev parent reply other threads:[~2023-04-05 18:50 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-31 23:20 Wesley Cheng
2023-04-04 1:11 ` Thinh Nguyen
2023-04-04 18:49 ` Wesley Cheng
2023-04-04 22:16 ` Thinh Nguyen
2023-04-04 22:23 ` Wesley Cheng
2023-04-05 18:49 ` Thinh Nguyen [this message]
2023-04-06 0:10 ` Wesley Cheng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230405184943.fajtjau2dcgylg25@synopsys.com \
--to=thinh.nguyen@synopsys.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=quic_jackp@quicinc.com \
--cc=quic_ugoswami@quicinc.com \
--cc=quic_wcheng@quicinc.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®