From: Mathias Nyman <mathias.nyman@linux.intel.com>
To: "Michał Pecio" <michal.pecio@gmail.com>
Cc: linux-usb@vger.kernel.org
Subject: Re: [RFT PATCH] xhci: process isoc TD properly when there was an error mid TD.
Date: Wed, 17 Jan 2024 12:46:00 +0200 [thread overview]
Message-ID: <f6542354-d6d1-be22-82ed-5dfa57aa8337@linux.intel.com> (raw)
In-Reply-To: <20240116232045.76da750b@foxbook>
On 17.1.2024 0.20, Michał Pecio wrote:
> I applied your patch on v6.7 and it appears to be working. It removes
> the disconnection spam and also handles intermittent transmission errors
> on UVC without obvious glitches or errors messages, except one xhci_dbg
> added to confirm that I'm really hitting this edge case.
>
> Anything else that might be worth testing?
>
>
> I have a question, though. What happens if there is no next TD because
> a mid TD error has occured on the last packet queued by the client? Is
> there any mechanism to retire that stuck TD on a NEC host which submits
> one mid TD error event and then goes silent?
In disconnect cases usb core should flush the remaining URBs once
roothub code notices the disconnect.
But yes, if the last TD in a URB is a multi TRB isoc TD, and it has an error
MID TD then its stuck until timeout.
>
> Would it be possible to retire the TD right after the first failed TRB?
> (I imagine difficulties in determining when exactly the host has moved
> its internal pointer past the remaining TRBs so they can be reused).
Probably not as a normal error handling routine.
We have the same "Transfer event TRB DMA ptr not part of current TD" issue
for hosts that do issue an event for the last TRB.
If the TD is given back immediately we also have a memory issue as the
DMA address pointed to by that last TRB might be accessed by the controller
_after_ driver gave back the TD, and possibly freed/unmapped it.
But for that special case where there are no more TDs queued it might
make sense
>
>
>> - if (!ep->skip ||
>> - !usb_endpoint_xfer_isoc(&td->urb->ep->desc)) {
>> + if (ep->skip && usb_endpoint_xfer_isoc(&td->urb->ep->desc)) {
> I like this. I would suggest another cleanup: the if(!ep_seg && stuf)
> right above your change could be pulled inside if(!ep_seg).
Noticed the same, but for stable kernel reasons it's probably better to limit
this patch to mostly fixing this bug.
>
>
>> + * if there was an error event mid TD then host may not
>> + * give an event for the last TRB on an isoc TD.
>> + * This event can be for the next TD, See xHCI 4.9.1.
> This seems to suggest that 4.9.1 encourages such behavior, but the
> opposite is the case as far as I understand.
I'll rephrase this.
>
>
>> + if (td->error_mid_td) {
>> + struct xhci_td *td_next = list_next_entry(td, td_list);
> This if needs && !list_is_last(&td->td_list, &ep_ring->td_list).
Thanks, nice catch, good point.
>
> Otherwise a serious bug in the host (maybe in the driver too) tricks
> us into grabbing a pointer to ep_ring instead, filling the subsequent
> "TRB not part of current TD" message with mystifying garbage numbers.
>
>
>> + if (ep_seg) {
>> + /* give back previous TD, start handling new */
> Suggested:
>> + xhci_dbg(xhci, "Missing completion event after mid TD error\n");
Makes sense.
Thanks
Mathias
next prev parent reply other threads:[~2024-01-17 10:44 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-12 22:52 "Transfer event TRB DMA ptr not part of current TD" spam after USB disconnection Michał Pecio
2024-01-13 20:47 ` Michał Pecio
2024-01-14 14:06 ` Michał Pecio
2024-01-15 13:58 ` Mathias Nyman
2024-01-15 16:27 ` Michał Pecio
2024-01-16 15:36 ` [RFT PATCH] xhci: process isoc TD properly when there was an error mid TD Mathias Nyman
2024-01-16 22:20 ` Michał Pecio
2024-01-17 10:46 ` Mathias Nyman [this message]
2024-01-17 17:49 ` Michał Pecio
2024-01-18 11:00 ` Isochronous error handling bug on VIA VL805 Michał Pecio
2024-01-18 11:10 ` Michał Pecio
2024-01-18 13:54 ` Mathias Nyman
2024-01-18 13:56 ` [RFT PATCH v2] xhci: process isoc TD properly when there was an error mid TD Mathias Nyman
2024-01-18 22:16 ` Michał Pecio
2024-01-19 10:49 ` Mathias Nyman
2024-01-19 10:58 ` [RTF PATCH v3] " Mathias Nyman
2024-01-19 21:54 ` Michał Pecio
2024-01-22 9:03 ` Michał Pecio
2024-01-22 13:37 ` Mathias Nyman
2024-01-22 17:10 ` Michał Pecio
2024-01-22 11:47 ` Mathias Nyman
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=f6542354-d6d1-be22-82ed-5dfa57aa8337@linux.intel.com \
--to=mathias.nyman@linux.intel.com \
--cc=linux-usb@vger.kernel.org \
--cc=michal.pecio@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.