From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Michael Olbrich <m.olbrich@pengutronix.de>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>
Cc: Felipe Balbi <balbi@kernel.org>,
Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"kernel@pengutronix.de" <kernel@pengutronix.de>
Subject: Re: [PATCH 2/2] usb: dwc3: gadget: restart the transfer if a isoc request is queued too late
Date: Wed, 13 Nov 2019 03:55:01 +0000 [thread overview]
Message-ID: <45ce4107-7c52-48d2-90d1-dfe835024063@synopsys.com> (raw)
In-Reply-To: <20191111152645.13792-3-m.olbrich@pengutronix.de>
Hi Michael,
Michael Olbrich wrote:
> Currently, most gadget drivers handle isoc transfers on a best effort
> bases: If the request queue runs empty, then there will simply be gaps in
> the isoc data stream.
>
> The UVC gadget depends on this behaviour. It simply provides new requests
> when video frames are available and assumes that they are sent as soon as
> possible.
>
> The dwc3 gadget currently works differently: It assumes that there is a
> contiguous stream of requests without any gaps. If a request is too late,
> then it is dropped by the hardware.
> For the UVC gadget this means that a live stream stops after the first
> frame because all following requests are late.
Can you explain little more how UVC gadget fails?
dwc3 controller expects a steady stream of data otherwise it will result
in missed_isoc status, and it should be fine as long as new requests are
queued. The controller doesn't just drop the request unless there's some
other failure.
> This patch changes the behaviour of the dwc3 gadget driver to match the
> expectations. If a request arrives too late, then the transfer will be
> restart to create the needed gap.
>
> A request is late if:
> 1. There are currently no requests queued in the hardware
> 2. The current frame number provided by DSTS does not match the frame
> number returned by the last transfer.
>
> If this happens transfers are stopped. The following XferNotReady provides
> the new correct frame number and restarts the transfer.
>
> Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
> ---
> drivers/usb/dwc3/gadget.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> index ac4673d91939..eb7f09929f28 100644
> --- a/drivers/usb/dwc3/gadget.c
> +++ b/drivers/usb/dwc3/gadget.c
> @@ -1473,6 +1473,14 @@ static int __dwc3_gadget_ep_queue(struct dwc3_ep *dep, struct dwc3_request *req)
> return __dwc3_gadget_start_isoc(dep);
> }
> }
> + if ((dep->flags & DWC3_EP_TRANSFER_STARTED) &&
> + list_empty(&dep->started_list) &&
> + ((dep->frame_number & 0x3fff) !=
> + __dwc3_gadget_get_frame(dwc))) {
> + dwc3_stop_active_transfer(dep, true, true);
> + dep->flags = DWC3_EP_ENABLED;
> + return 0;
> + }
> }
>
> return __dwc3_gadget_kick_transfer(dep, false);
BR,
Thinh
next prev parent reply other threads:[~2019-11-13 3:55 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-11 15:26 [PATCH 0/2] usb: dwc3: gadget: improve isoc handling Michael Olbrich
2019-11-11 15:26 ` [PATCH 1/2] usb: dwc3: gadget: make starting isoc transfers more robust Michael Olbrich
2019-11-12 20:41 ` kbuild test robot
2019-11-13 3:55 ` Thinh Nguyen
2019-11-13 8:02 ` Michael Olbrich
2019-11-13 19:40 ` Thinh Nguyen
2019-11-11 15:26 ` [PATCH 2/2] usb: dwc3: gadget: restart the transfer if a isoc request is queued too late Michael Olbrich
2019-11-13 3:55 ` Thinh Nguyen [this message]
2019-11-13 7:53 ` Michael Olbrich
2019-11-13 15:39 ` Alan Stern
2019-11-13 19:14 ` Thinh Nguyen
2019-11-14 12:14 ` Michael Olbrich
2019-11-14 20:11 ` Thinh Nguyen
2019-11-15 21:06 ` Alan Stern
2019-11-28 11:36 ` Michael Olbrich
2019-11-28 17:59 ` Alan Stern
2019-12-02 15:41 ` Michael Olbrich
2019-12-02 17:02 ` Alan Stern
2020-04-09 7:59 ` Michael Grzeschik
2020-04-10 1:09 ` Thinh Nguyen
2020-04-10 22:03 ` Michael Grzeschik
2020-04-11 0:59 ` Thinh Nguyen
2020-04-21 6:51 ` Michael Grzeschik
2020-04-21 23:41 ` Thinh Nguyen
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=45ce4107-7c52-48d2-90d1-dfe835024063@synopsys.com \
--to=thinh.nguyen@synopsys.com \
--cc=balbi@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=kernel@pengutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=m.olbrich@pengutronix.de \
/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;
as well as URLs for NNTP newsgroup(s).