From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Jack Pham <jackp@codeaurora.org>
Cc: Felipe Balbi <balbi@kernel.org>,
Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
Wesley Cheng <wcheng@codeaurora.org>,
linux-usb@vger.kernel.org, linux-arm-msm@vger.kernel.org
Subject: Re: [PATCH v2] usb: dwc3: gadget: Skip resizing EP's TX FIFO if already resized
Date: Thu, 21 Oct 2021 12:52:08 +0200 [thread overview]
Message-ID: <YXFGWPMmmdyaSOPg@kroah.com> (raw)
In-Reply-To: <20211019004123.15987-1-jackp@codeaurora.org>
On Mon, Oct 18, 2021 at 05:41:23PM -0700, Jack Pham wrote:
> Some functions may dynamically enable and disable their endpoints
> regularly throughout their operation, particularly when Set Interface
> is employed to switch between Alternate Settings. For instance the
> UAC2 function has its respective endpoints for playback & capture
> associated with AltSetting 1, in which case those endpoints would not
> get enabled until the host activates the AltSetting. And they
> conversely become disabled when the interfaces' AltSetting 0 is
> chosen.
>
> With the DWC3 FIFO resizing algorithm recently added, every
> usb_ep_enable() call results in a call to resize that EP's TXFIFO,
> but if the same endpoint is enabled again and again, this incorrectly
> leads to FIFO RAM allocation exhaustion as the mechanism did not
> account for the possibility that endpoints can be re-enabled many
> times.
>
> Example log splat:
>
> dwc3 a600000.dwc3: Fifosize(3717) > RAM size(3462) ep3in depth:217973127
> configfs-gadget gadget: u_audio_start_capture:521 Error!
> dwc3 a600000.dwc3: request 000000000be13e18 was not queued to ep3in
>
> Add another bit DWC3_EP_TXFIFO_RESIZED to dep->flags to keep track of
> whether an EP had already been resized in the current configuration.
> If so, bail out of dwc3_gadget_resize_tx_fifos() to avoid the
> calculation error resulting from accumulating the EP's FIFO depth
> repeatedly. This flag is retained across multiple ep_disable() and
> ep_enable() calls and is cleared when GTXFIFOSIZn is reset in
> dwc3_gadget_clear_tx_fifos() upon receiving the next Set Config.
>
> Fixes: 9f607a309fbe9 ("usb: dwc3: Resize TX FIFOs to meet EP bursting requirements")
> Signed-off-by: Jack Pham <jackp@codeaurora.org>
> ---
> v2: Added explicit flag to dep->flags and check that instead of directly
> reading the GTXFIFOSIZn register.
>
> drivers/usb/dwc3/core.h | 1 +
> drivers/usb/dwc3/gadget.c | 8 +++++++-
> 2 files changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h
> index 5612bfdf37da..f033063f6948 100644
> --- a/drivers/usb/dwc3/core.h
> +++ b/drivers/usb/dwc3/core.h
> @@ -723,6 +723,7 @@ struct dwc3_ep {
> #define DWC3_EP_FORCE_RESTART_STREAM BIT(9)
> #define DWC3_EP_FIRST_STREAM_PRIMED BIT(10)
> #define DWC3_EP_PENDING_CLEAR_STALL BIT(11)
> +#define DWC3_EP_TXFIFO_RESIZED BIT(12)
Any specific reason this isn't lined up properly?
thanks,
greg k-h
next prev parent reply other threads:[~2021-10-21 10:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-19 0:41 [PATCH v2] usb: dwc3: gadget: Skip resizing EP's TX FIFO if already resized Jack Pham
2021-10-19 2:50 ` Thinh Nguyen
2021-10-21 10:52 ` Greg Kroah-Hartman [this message]
2021-10-21 17:43 ` Jack Pham
2021-10-22 9:13 ` Greg Kroah-Hartman
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=YXFGWPMmmdyaSOPg@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=Thinh.Nguyen@synopsys.com \
--cc=balbi@kernel.org \
--cc=jackp@codeaurora.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=wcheng@codeaurora.org \
/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