From: Wesley Cheng <quic_wcheng@quicinc.com>
To: <balbi@kernel.org>, <gregkh@linuxfoundation.org>,
<Thinh.Nguyen@synopsys.com>
Cc: <linux-kernel@vger.kernel.org>, <linux-usb@vger.kernel.org>,
<quic_jackp@quicinc.com>, Wesley Cheng <quic_wcheng@quicinc.com>
Subject: [PATCH v4 4/9] usb: dwc3: gadget: Continue handling EP0 xfercomplete events
Date: Wed, 17 Aug 2022 11:23:54 -0700 [thread overview]
Message-ID: <20220817182359.13550-5-quic_wcheng@quicinc.com> (raw)
In-Reply-To: <20220817182359.13550-1-quic_wcheng@quicinc.com>
During soft disconnect, EP0 events are expected to be handled in order to
allow the controller to successfully move into the halted state. Since
__dwc3_gadget_stop() is executed before polling, EP0 has been disabled, and
events are being blocked. Allow xfercomplete events to be handled, so that
cached SETUP packets can be read out from the internal controller memory.
Without doing so, it will lead to endxfer timeouts, which results to
controller halt failures.
Reviewed-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Signed-off-by: Wesley Cheng <quic_wcheng@quicinc.com>
---
drivers/usb/dwc3/gadget.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 3b83e3c4b932..aff288b7baeb 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -2721,6 +2721,7 @@ static int __dwc3_gadget_start(struct dwc3 *dwc)
dwc3_gadget_ep0_desc.wMaxPacketSize = cpu_to_le16(512);
dep = dwc->eps[0];
+ dep->flags = 0;
ret = __dwc3_gadget_ep_enable(dep, DWC3_DEPCFG_ACTION_INIT);
if (ret) {
dev_err(dwc->dev, "failed to enable %s\n", dep->name);
@@ -2728,6 +2729,7 @@ static int __dwc3_gadget_start(struct dwc3 *dwc)
}
dep = dwc->eps[1];
+ dep->flags = 0;
ret = __dwc3_gadget_ep_enable(dep, DWC3_DEPCFG_ACTION_INIT);
if (ret) {
dev_err(dwc->dev, "failed to enable %s\n", dep->name);
@@ -3599,11 +3601,12 @@ static void dwc3_endpoint_interrupt(struct dwc3 *dwc,
dep = dwc->eps[epnum];
if (!(dep->flags & DWC3_EP_ENABLED)) {
- if (!(dep->flags & DWC3_EP_TRANSFER_STARTED))
+ if ((epnum > 1) && !(dep->flags & DWC3_EP_TRANSFER_STARTED))
return;
/* Handle only EPCMDCMPLT when EP disabled */
- if (event->endpoint_event != DWC3_DEPEVT_EPCMDCMPLT)
+ if ((event->endpoint_event != DWC3_DEPEVT_EPCMDCMPLT) &&
+ !(epnum <= 1 && event->endpoint_event == DWC3_DEPEVT_XFERCOMPLETE))
return;
}
next prev parent reply other threads:[~2022-08-18 4:22 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-17 18:23 [PATCH v4 0/9] Fix controller halt and endxfer timeout issues Wesley Cheng
2022-08-17 18:23 ` [PATCH v4 1/9] usb: dwc3: Do not service EP0 and conndone events if soft disconnected Wesley Cheng
2022-08-17 18:23 ` [PATCH v4 2/9] usb: dwc3: gadget: Force sending delayed status during soft disconnect Wesley Cheng
2022-08-17 18:23 ` [PATCH v4 3/9] usb: dwc3: gadget: Synchronize IRQ between soft connect/disconnect Wesley Cheng
2022-08-17 18:23 ` Wesley Cheng [this message]
2022-08-17 18:23 ` [PATCH v4 5/9] usb: dwc3: Avoid unmapping USB requests if endxfer is not complete Wesley Cheng
2022-08-30 14:08 ` Greg KH
2022-08-30 18:13 ` Wesley Cheng
2022-08-17 18:23 ` [PATCH v4 6/9] usb: dwc3: Remove DWC3 locking during gadget suspend/resume Wesley Cheng
2022-08-23 1:14 ` Thinh Nguyen
2022-08-17 18:23 ` [PATCH v4 7/9] usb: dwc3: Increase DWC3 controller halt timeout Wesley Cheng
2022-08-23 1:04 ` Thinh Nguyen
2022-08-17 18:23 ` [PATCH v4 8/9] usb: dwc3: gadget: Skip waiting for CMDACT cleared during endxfer Wesley Cheng
2022-08-17 18:23 ` [PATCH v4 9/9] usb: dwc3: gadget: Submit endxfer command if delayed during disconnect 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=20220817182359.13550-5-quic_wcheng@quicinc.com \
--to=quic_wcheng@quicinc.com \
--cc=Thinh.Nguyen@synopsys.com \
--cc=balbi@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=quic_jackp@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