All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Pecio <michal.pecio@gmail.com>
To: Wesley Cheng <wesley.cheng@oss.qualcomm.com>
Cc: Mathias Nyman <mathias.nyman@linux.intel.com>,
	Mathias Nyman <mathias.nyman@intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-sound@vger.kernel.org
Subject: Re: [PATCH v4 3/5] usb: xhci: sideband: allocate sideband ring segments from a dedicated pool
Date: Wed, 14 Oct 2026 11:17:01 +0200	[thread overview]
Message-ID: <20261014111701.4a63e9ca.michal.pecio@gmail.com> (raw)
In-Reply-To: <5cd85c1b-4bb7-4f30-930d-6c6451f09395@oss.qualcomm.com>

On Tue, 13 Oct 2026 15:53:39 -0700, Wesley Cheng wrote:
> I guess my intention was to see if we could leverage the existing
> memory operations within xHCI as much as we could.

This means xhci-hcd needs to be aware of all the client requirements. 
Today we are adding DMA pool to allocate segments on separate pages.
But people may want more - say a client wants different segment size,
it needs to adjust the DMA pool, but also to add another patch because
xhci-hcd would try to create Link TRB at 4KB offset. Or maybe a client
needs more segments. Client allocation gives this flexibility.

To me this is the main appeal - both sides can evolve independently,
without needing to update each other when something changes.

Maybe the sg_table stuff could be replaced with something simpler.
Clients still needs to tell xhci-hcd where the segments are so they
can be mapped, but it could be a few xhci_sideband_[un]map_segment()
calls instead of constructing a table. In principle, a client could
even grow the ring dynamically, without any patches to xhci-hcd.

> The only concern I would have with having the client own all the
> memory operations/allocations is that we would need to carefully
> maintain the transitional phases between offloaded and non-offloaded
> scenarios to be handled properly.  At least in the audio offload
> case, we're only offloading data to the DSP when audio is active,
> which can be for a short duration, and we have proper checks and
> locking already within the xHCI mem/core layers.

Not sure if ring ownership changes anything here?
What sort of existing checks and locking do you want to rely on?

> Since I did take a look at the other issue that probably reminded you
> of this, without getting on to a tangent subject, it really broke
> down to two scenarios:
> 1.  reset_resume during bus resume
> 2.  usb_device_reset for recovery
> 
> In both situations there are requirements that when those
> happen/trigger, technically, the bus should be completely idle.  For
> #1, since we're coming from a bus suspend transition, there should be
> no pending URBs in flight, so if reset_resume happened, xfer rings
> aren't being utilized.  For #2, there were some changes that weren't
> properly handling the pre and post reset callbacks, leading to
> problems in that situation.  I think that series showed us that there
> are corner cases where referencing vdev could potentially be
> unreliable.  I'm going to assume this has no relationship to the
> client driver owning memory, please correct me if I'm wrong. :)

Right, ring UAF and driver data UAF are separate issues and changing
ring ownership won't magically fix driver bugs. It seems impossible to
avoid xhci-sideband keeping references to vdevs, because endpoints must
be stopped on sideband removal. So these references need to be found
and invalidated in all cases when devices are freed "prematurely".

But does this need to go outside xhci-hcd (including xhci-sideband)?
Are those callbacks into the client necessary? It seems they wouldn't
be necessary if ring memory is client-owned.

Regards,
Michal

  reply	other threads:[~2026-10-14  9:17 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-10  1:50 [PATCH v4 0/5] Add larger page size support for USB audio offload path Wesley Cheng
2026-09-10  1:50 ` [PATCH v4 1/5] usb: xhci: sideband: fix ring sg table for sub-page TRB segments Wesley Cheng
2026-09-10  1:50 ` [PATCH v4 2/5] usb: xhci: Allow to specify a different segment pool for allocations Wesley Cheng
2026-09-10  1:50 ` [PATCH v4 3/5] usb: xhci: sideband: allocate sideband ring segments from a dedicated pool Wesley Cheng
2026-10-05 11:03   ` Mathias Nyman
2026-10-13  1:01     ` Wesley Cheng
2026-10-13  9:11       ` Michal Pecio
2026-10-13 22:53         ` Wesley Cheng
2026-10-14  9:17           ` Michal Pecio [this message]
2026-10-14 14:26         ` Mathias Nyman
2026-09-10  1:51 ` [PATCH v4 4/5] ALSA: usb-audio: qcom: tag sideband endpoints before ring allocation Wesley Cheng
2026-09-10  1:51 ` [PATCH v4 5/5] ALSA: usb-audio: qcom: fix xfer ring IOMMU unmap on 16K+ page kernels Wesley Cheng
2026-09-30 22:23 ` [PATCH v4 0/5] Add larger page size support for USB audio offload path Wesley Cheng
2026-10-01 22:33   ` Mathias Nyman
2026-10-02  1:42     ` Wesley Cheng

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=20261014111701.4a63e9ca.michal.pecio@gmail.com \
    --to=michal.pecio@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@intel.com \
    --cc=mathias.nyman@linux.intel.com \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.com \
    --cc=wesley.cheng@oss.qualcomm.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.