Linux USB
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Wesley Cheng" <wesley.cheng@oss.qualcomm.com>
Cc: linux-usb@vger.kernel.org, linux-sound@vger.kernel.org
Subject: Re: [PATCH v8 3/4] ALSA: usb-audio: qcom: tag sideband endpoints before ring allocation
Date: Tue, 01 Dec 2026 23:16:10 +0000	[thread overview]
Message-ID: <sashiko-outbox-244376@kernel.org> (raw)
In-Reply-To: <20261201-16k_offload_v1_b4-v8-3-aad08c457d7e@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] usb: xhci: xhci_sideband_add_endpoint() rejects existing
  ep->ring too early
--

commit b9ffa7500ce27332d8a4a070f26d4eaeefa92e40
Author: Wesley Cheng <wesley.cheng@oss.qualcomm.com>

ALSA: usb-audio: qcom: tag sideband endpoints before ring allocation

This commit moves the xhci_sideband_add_endpoint() calls in
enable_audio_stream() ahead of snd_usb_endpoint_prepare() so endpoint
transfer rings are allocated with ep->no_pool_alloc set, and rejects
adding sideband endpoints that already have a transfer ring allocated.

> diff --git a/drivers/usb/host/xhci-sideband.c b/drivers/usb/host/xhci-sideband.c
> index d28ff17411661..30c058a5988f2 100644
> --- a/drivers/usb/host/xhci-sideband.c
> +++ b/drivers/usb/host/xhci-sideband.c
> @@ -225,6 +225,8 @@ EXPORT_SYMBOL_GPL(xhci_sideband_notify_ep_ring_free);
>   * After an endpoint is added the sideband client can get the endpoint transfer
>   * ring buffer by calling xhci_sideband_endpoint_buffer()
>   *
> + * The endpoint must be added before its transfer ring is allocated.
> + *
>   * Return: 0 on success, negative error otherwise.
>   */
>  int
> @@ -255,7 +257,7 @@ xhci_sideband_add_endpoint(struct xhci_sideband *sb,
>  	 * and let this function add the endpoint and allocate the ring buffer
>  	 * with the smallest common DMA mask
>  	 */
> -	if (sb->eps[ep_index] || ep->sideband)
> +	if (sb->eps[ep_index] || ep->sideband || ep->ring || ep->new_ring)
>  		return -EBUSY;

[Severity: Medium]
Can checking ep->ring here cause enable_audio_stream() to fail with
-EBUSY when an old transfer ring is still present before
snd_usb_endpoint_prepare() replaces it?

For example, when QUIRK_FLAG_IFACE_SKIP_CLOSE is set, closing a stream
skips switching back to altsetting 0 and leaves ep->ring allocated until
the next snd_usb_endpoint_prepare() deselects and re-enables the
altsetting:

sound/usb/endpoint.c:snd_usb_endpoint_close() {
    ...
	if (!--ep->iface_ref->opened &&
		!(chip->quirk_flags & QUIRK_FLAG_IFACE_SKIP_CLOSE))
		endpoint_set_interface(chip, ep, false);
    ...
}

Because enable_audio_stream() now calls xhci_sideband_add_endpoint()
before snd_usb_endpoint_prepare(), starting a second offloaded stream on
such a device (or on a device whose altsetting 0 defines the endpoint)
sees the existing ep->ring and fails with -EBUSY, even though
snd_usb_endpoint_prepare() is about to free and reallocate that ring.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261201-16k_offload_v1_b4-v8-0-aad08c457d7e@oss.qualcomm.com?part=3

  reply	other threads:[~2026-12-01 23:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 22:56 [PATCH v8 0/4] Add larger page size support for USB audio offload path Wesley Cheng
2026-12-01 22:56 ` [PATCH v8 1/4] usb: xhci: sideband: fix ring sg table for sub-page TRB segments Wesley Cheng
2026-12-01 22:56 ` [PATCH v8 2/4] usb: xhci: Allocate sideband ring segments with dma_alloc_coherent() Wesley Cheng
2026-12-01 22:56 ` [PATCH v8 3/4] ALSA: usb-audio: qcom: tag sideband endpoints before ring allocation Wesley Cheng
2026-12-01 23:16   ` sashiko-bot [this message]
2026-12-01 22:56 ` [PATCH v8 4/4] ALSA: usb-audio: qcom: fix xfer ring IOMMU unmap on 16K+ page kernels Wesley Cheng
2026-12-01 23:16 ` [PATCH v8 0/4] Add larger page size support for USB audio offload path sashiko-bot

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=sashiko-outbox-244376@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox