From: Michal Pecio <michal.pecio@gmail.com>
To: Mathias Nyman <mathias.nyman@linux.intel.com>
Cc: Arthur Gautier <baloo@superbaloo.net>,
linux-usb@vger.kernel.org,
Mathias Nyman <mathias.nyman@intel.com>
Subject: Re: [PATCH v2] xhci: fix lost bounce buffers on TDs spanning several ring segments
Date: Tue, 18 Aug 2026 10:47:08 +0200 [thread overview]
Message-ID: <20260818104708.42d40a2f.michal.pecio@gmail.com> (raw)
In-Reply-To: <f1671140-f1e3-4afe-a806-c3f82587eab6@linux.intel.com>
On Tue, 18 Aug 2026 10:29:41 +0300, Mathias Nyman wrote:
> On 8/18/26 01:48, Michal Pecio wrote:
> > You have removed protection from infinite looping. I think nowadays
> > the driver has more loops without such protection and everytihng is
> > fine, but I'm not sure how it was in the past, and this patch goes
> > to stable.
> >
> > Maybe let's see what Mathias thinks about it.
>
> Thanks for adding me back to the loop (cc)
>
> The infinite loop risk could be prevented by using
> xhci_for_each_ring_seg():
>
> xhci_for_each_ring_seg(td->start_seg, seg) {
> if (seg->bounce_len)
> xhci_unmap_one_bounce_buffer(xhci, ring, td, seg);
> if (seg == td->bounce_seg)
> break;
> }
That's tricky to backport; the macro doesn't exist in linux-6.6.y or
earlier and the commit which added it includes many other changes.
And it only prevents infinite loop if start_seg is reachable from
itself (so not if start_seg->next->next == start_seg->next). Similarly,
v2 is good enough as long as bounce_seg is reachable from start_seg.
It surely was reachable at the time of enqueue, so only a botched ring
expansion *later* could break this.
I actually think that chances of such bugs existing and being unnoticed
for years are practically zero, so maybe just don't worry about it.
I only mentioned it because:
- v1 included a safety counter checked against ring->num_segs
- it's something that people used to worry about a lot in the past
for some reason; maybe just to aid debugging during development
Regards,
Michal
prev parent reply other threads:[~2026-08-18 8:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-12 0:25 [PATCH v2] xhci: fix lost bounce buffers on TDs spanning several ring segments Arthur Gautier
2026-08-17 22:48 ` Michal Pecio
2026-08-18 7:29 ` Mathias Nyman
2026-08-18 8:47 ` Michal Pecio [this message]
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=20260818104708.42d40a2f.michal.pecio@gmail.com \
--to=michal.pecio@gmail.com \
--cc=baloo@superbaloo.net \
--cc=linux-usb@vger.kernel.org \
--cc=mathias.nyman@intel.com \
--cc=mathias.nyman@linux.intel.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.