From: Wesley Cheng <wesley.cheng@oss.qualcomm.com>
To: Mathias Nyman <mathias.nyman@intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-sound@vger.kernel.org,
Wesley Cheng <wesley.cheng@oss.qualcomm.com>
Subject: [PATCH 0/2] Add larger page size support for USB audio offload path
Date: Mon, 24 Aug 2026 19:06:54 -0700 [thread overview]
Message-ID: <20260824-16k_offload_v1_b4-v1-0-49a6be60ca30@oss.qualcomm.com> (raw)
On some environments, 16kB pages can be enabled from the Linux subsystem,
which manages the IOMMU mappings for the audio DSP within the system. In
the current design, the following assumptions break when 16k pages are
utilized:
1. xHCI ring size is equal to PAGE_SIZE
2. Ring addresses start at the beginning of a page
When the USB offload driver maps the rings (w/ the audio DSP SID), it is
set with a 16k granular, which is a problem, as several xHCI rings could
exist on the same page. This is because the rings are currently allocated
from the segment_pool. Hence, potentially mapping non USB audio related
rings into the region accessible by the audio DSP.
To mitigate this, this series introduces the alignment_req parameter.
Before the USB audio offload path is enabled, the USB audio data
streams/endpoint are not active. Only when the class driver issues a
usb_set_interface() call (done from snd_usb_endpoint_prepare()), will the
xHCI allocate the transfer ring resources. By setting the alignment_req
beforehand, when allocating the ring segment, it can fulfill the audio DSP
alignment requirements by allocating DMA-able memory on the fly (based on
what is being requested) versus fetching it from the segment pool.
Likewise, keep track of if memory was dynamically allocated to handle the
free path properly. The function call flow will now look like the
following:
handle_uaudio_stream_req()
│
▼
enable_audio_stream(subs, ..., pcm_card_num)
│
├─ xhci_sideband_add_endpoint(sb, data_ep, PAGE_SIZE)
│ │ alignment_req == PAGE_SIZE
│ ▼
│ sb->alignment_req = alignment_req
│
├─ snd_usb_endpoint_prepare(chip, data_endpoint)
│ → xhci_check_bandwidth() → xhci_endpoint_init())
│ ▼
xhci_endpoint_init(..., ep_index, ...)
│ if (sideband && sideband->alignment_req)
│ new_ring = xhci_ring_alloc(xhci, 2, ring_type, max_packet,
│ sideband->alignment_req, mem_flags)
│ ▼
xhci_ring_alloc(..., alignment_req, ...)
│ ring->alignment_req = alignment_req
│ ▼
xhci_alloc_segments_for_ring(xhci, ring, flags)
│ xhci_segment_alloc(xhci, ..., ring->alignment_req, flags)
│ ▼
xhci_segment_alloc(..., alignment_req, flags)
if (alignment_req > TRB_SEGMENT_SIZE)
seg->trbs = dma_alloc_coherent(dev, alignment_req, &dma, flags)
else
seg->trbs = dma_pool_zalloc(xhci->segment_pool, ...)
Similar logic is added for the secondary interrupter path as well. The USB
offload class driver calls xhci_sideband_create_interrupter(), which will
be responsible for allocating the secondary event ring. The same
alignment_req parameter is passed, and during xHCI event ring creation, the
same set of APIs are utilized, so the runtime memory allocation is already
handled.
This was confirmed to work on the SM8350 MTP platform, with the
CONFIG_ARM64_16K_PAGES config enabled, alongside tinyaudio binaries:
tinymix -D 0 set 513 1 (Enables USB_RX multimedia#1 path)
tinyplay -D 0 -d 0.... (Routes PCM data to ASoC platform sound card)
Signed-off-by: Wesley Cheng <wesley.cheng@oss.qualcomm.com>
---
Wesley Cheng (2):
xhci: sideband: support page-aligned ring segment allocation
ALSA: usb-audio: qcom: request page-aligned xHCI ring buffers
drivers/usb/host/xhci-mem.c | 70 ++++++++++++++++++++--------
drivers/usb/host/xhci-sideband.c | 9 ++--
drivers/usb/host/xhci.h | 11 ++++-
include/linux/usb/xhci-sideband.h | 7 ++-
sound/usb/qcom/qc_audio_offload.c | 96 +++++++++++++++++++++++++++++++++------
5 files changed, 152 insertions(+), 41 deletions(-)
---
base-commit: e1e6e541c5c9cf548e9fdc35fc26808c82074440
change-id: 20260824-16k_offload_v1_b4-3d1460405774
Best regards,
--
Wesley Cheng <wesley.cheng@oss.qualcomm.com>
next reply other threads:[~2026-08-25 2:07 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-25 2:06 Wesley Cheng [this message]
2026-08-25 2:06 ` [PATCH 1/2] xhci: sideband: support page-aligned ring segment allocation Wesley Cheng
2026-08-25 2:06 ` [PATCH 2/2] ALSA: usb-audio: qcom: request page-aligned xHCI ring buffers Wesley Cheng
2026-08-25 7:43 ` [PATCH 0/2] Add larger page size support for USB audio offload path Michal Pecio
2026-08-25 19:08 ` Wesley Cheng
2026-08-26 7:50 ` Wesley Cheng
2026-08-26 10:25 ` Michal Pecio
2026-08-26 11:44 ` Mathias Nyman
2026-08-26 19:58 ` Wesley Cheng
2026-09-04 14:46 ` Michal Pecio
2026-08-25 11:09 ` Takashi Iwai
2026-08-25 19:09 ` 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=20260824-16k_offload_v1_b4-v1-0-49a6be60ca30@oss.qualcomm.com \
--to=wesley.cheng@oss.qualcomm.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=perex@perex.cz \
--cc=tiwai@suse.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