From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Michael Grzeschik <mgr@pengutronix.de>
Cc: Dan Vacura <w36195@motorola.com>,
Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
Daniel Scally <dan.scally@ideasonboard.com>,
Jeff Vanhoof <qjv001@motorola.com>,
"stable@vger.kernel.org" <stable@vger.kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jonathan Corbet <corbet@lwn.net>,
Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
Felipe Balbi <balbi@kernel.org>,
Paul Elder <paul.elder@ideasonboard.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>
Subject: Re: [PATCH v3 2/6] usb: dwc3: gadget: cancel requests instead of release after missed isoc
Date: Thu, 22 Feb 2024 01:20:04 +0000 [thread overview]
Message-ID: <20240222011955.7sida4udjlvrlue7@synopsys.com> (raw)
In-Reply-To: <ZdaPLGTbsBo4F4pK@pengutronix.de>
On Thu, Feb 22, 2024, Michael Grzeschik wrote:
> Sorry for digging up this grave! :)
>
> I once more came accross the whole situation we are still encountering
> since one year or so again and found the some reasons why:
>
> #1 there are so many latencies, so that the system is not fast enough to
> enqueue requests back into an running HW-Transfer. At least on our
> system setup.
>
> and
>
> #2 there are so many missed transfers leading to broken frames
> when adding request with no_interrupt set.
>
> For #1: There sometimes are situations in the system where the threaded
> interrupt handler for the dwc3 is not called fast enough, although the
> HW-irq was called early and enqueued the irq event and woke the irq
> thread early. In our case this often happens, when there are other tasks
> involved on the same CPU and the scheduler is not able to pipeline the
> irq thread in the necessary time. In our case the main issue is an
> HW-irq handler of the ethernet controller (cadence macb) that runs
> berserk on CPU0 and therefor is taking a lot of CPU time. Per default on
> our system all irq handlers are running on the same CPU. As per
> definition all interrupt threads will be started on the same CPU as the
> irq was called, this forces a lot of pressure on one Core. So changing
> the smp_affinity of the dwc3 irq to the second CPU only, already solves
> a lot of the underruns.
That's great!
>
> For #2: I found an issue in the handling of the completion of requests in
> the started list. When the interrupt handler is *explicitly* calling
> stop_active_transfer if the overall event of the request was an missed
> event. This event value only represents the value of the request that
> was actually triggering the interrupt.
>
> It also calls ep_cleanup_completed_requests and is iterating over the
> started requests and will call giveback/complete functions of the
> requests with the proper request status.
>
> So this will also catch missed requests in the queue. However, since
> there might be, lets say 5 good requests and one missed request, what
> will happen is, that each complete call for the first good requests will
> enqueue new requests into the started list and will also call the
> updatecmd on that transfer that was already missed until the loop will
> reach the one request with the MISSED status bit set.
>
> So in my opinion the patch from Jeff makes sense when adding the
> following change aswell. With those both changes the underruns and
> broken frames finally disappear. I am still unsure about the complete
> solution about that, since with this the mentioned 5 good requests
> will be cancelled aswell. So this is still a WIP status here.
>
When the dwc3 driver issues stop_active_transfer(), that means that the
started_list is empty and there is an underrun. It treats the incoming
requests as staled. However, for UVC, they are still "good".
I think you can just check if the started_list is empty before queuing
new requests. If it is, perform stop_active_transfer() to reschedule the
incoming requests. None of the newly queue requests will be released
yet since they are in the pending_list.
For UVC, perhaps you can introduce a new flag to usb_request called
"ignore_queue_latency" or something equivalent. The dwc3 is already
partially doing this for UVC. With this new flag, we can rework dwc3 to
clearly separate the expected behavior from the function driver.
BR,
Thinh
next prev parent reply other threads:[~2024-02-22 1:20 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-17 20:54 [PATCH v3 0/6] uvc gadget performance issues Dan Vacura
2022-10-17 20:54 ` [PATCH] usb: gadget: uvc: fix dropped frame after missed isoc Dan Vacura
2022-10-18 1:50 ` Bagas Sanjaya
2022-10-18 2:15 ` Dan Vacura
2022-10-18 5:13 ` Greg Kroah-Hartman
2022-10-17 20:54 ` [PATCH v3 2/6] usb: dwc3: gadget: cancel requests instead of release " Dan Vacura
2022-10-17 21:30 ` Thinh Nguyen
2022-10-18 2:10 ` Dan Vacura
2022-10-18 18:45 ` Thinh Nguyen
2022-10-18 19:13 ` Michael Grzeschik
2022-10-18 22:45 ` Thinh Nguyen
2022-10-19 6:46 ` Michael Grzeschik
2024-02-22 0:02 ` Michael Grzeschik
2024-02-22 1:20 ` Thinh Nguyen [this message]
2024-02-27 21:01 ` Michael Grzeschik
2024-03-07 1:57 ` Thinh Nguyen
2024-03-07 16:15 ` Michael Grzeschik
2024-03-08 2:47 ` Thinh Nguyen
2022-10-17 20:54 ` [PATCH v3 3/6] usb: gadget: uvc: fix sg handling in error case Dan Vacura
2022-10-17 20:54 ` [PATCH v3 4/6] usb: gadget: uvc: fix sg handling during video encode Dan Vacura
2022-10-17 20:54 ` [PATCH v3 5/6] usb: gadget: uvc: make interrupt skip logic configurable Dan Vacura
2022-10-17 20:54 ` [PATCH v3 6/6] usb: gadget: uvc: add configfs option for sg support Dan Vacura
2022-10-18 13:27 ` Dan Scally
2022-10-18 14:04 ` Michael Grzeschik
2022-10-18 14:09 ` Dan Scally
2022-10-18 14:10 ` Dan Scally
2022-10-18 15:00 ` Dan Vacura
2022-10-18 14:32 ` Alan Stern
2022-10-18 15:14 ` Dan Vacura
2022-10-18 15:23 ` Alan Stern
2022-10-18 15:28 ` Michael Grzeschik
-- strict thread matches above, loose matches on Subject: below --
2022-10-18 20:49 [PATCH v3 2/6] usb: dwc3: gadget: cancel requests instead of release after missed isoc Jeffrey Vanhoof
2022-10-18 22:35 ` Thinh Nguyen
2022-10-19 1:41 ` Jeff Vanhoof
2022-10-19 2:02 ` Thinh Nguyen
2022-10-19 7:40 ` Jeff Vanhoof
2022-10-19 19:08 ` Thinh Nguyen
2022-10-19 21:34 ` Jeff Vanhoof
2022-10-19 23:06 ` Thinh Nguyen
2022-10-20 16:47 ` Jeff Vanhoof
2022-10-20 20:53 ` Jeff Vanhoof
2022-10-20 22:47 ` Thinh Nguyen
2022-10-21 0:55 ` Thinh Nguyen
2022-10-21 9:39 ` Jeff Vanhoof
2022-10-21 16:43 ` Thinh Nguyen
2022-10-21 18:28 ` Jeff Vanhoof
2022-10-21 19:09 ` Thinh Nguyen
2022-10-21 19:27 ` Jeff Vanhoof
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=20240222011955.7sida4udjlvrlue7@synopsys.com \
--to=thinh.nguyen@synopsys.com \
--cc=balbi@kernel.org \
--cc=corbet@lwn.net \
--cc=dan.scally@ideasonboard.com \
--cc=gregkh@linuxfoundation.org \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mgr@pengutronix.de \
--cc=paul.elder@ideasonboard.com \
--cc=qjv001@motorola.com \
--cc=stable@vger.kernel.org \
--cc=w36195@motorola.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;
as well as URLs for NNTP newsgroup(s).