From nobody Thu Apr 2 22:05:40 2026 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BA05134F46A for ; Fri, 13 Feb 2026 10:09:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770977368; cv=none; b=fUkmdrfzzh6wqWdfJO7+6b16B/+NqCzr2T7MiA9/SBTeH+VShRIUsdR9EzrqjyANSQ405AG12siHUb1GdpX+rfu+dRN1Alszu7qhR5M9gKtm1+NV6detTF7QZv5eIIv+cc+uvKyn2MYWyZj4QugTQTdLqp9U2Kwqo52GCUjUHms= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770977368; c=relaxed/simple; bh=nEMCIOnsanEJMnLYmB5e41nP6UMT7vo619hj5X6ToIQ=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Lm+JU7D1E21wxhX2eYxIN0ecAmOknksDlURURK4BGymPRyqK0gDRuB+tH9Fse5kCwWYd+qvyRYZYCylX5nrylWUN3zgYpj6UF4bZ1U8j+GuLMUEv3zLBERMyVbAr1tI+jCKLj9l87ZgaIL0U4F7XHkQhXin6/cqKqMfQIPHjn0g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--guanyulin.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=qrRATXF/; arc=none smtp.client-ip=209.85.216.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--guanyulin.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="qrRATXF/" Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-354c44bf176so872112a91.0 for ; Fri, 13 Feb 2026 02:09:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1770977365; x=1771582165; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=6H578zF40bIvw0kW2/BZM5eR8EPStj53jblRqAXiqY4=; b=qrRATXF/DSXdU5UJqW3LPIGgJIjEkRjTN89lmtG8kzDeaVlcTM9S9JQfUKnaSqYbJ/ wBDPU7ZBCc365c0JAoPccaWcOJgCXDHTSnZebvwPuChdTSAAWxILFscDniFsqXPawIpn ed46QkXBKjKjt/W51iU52UB1FevqK+yT5JflHmH3s+DfsXSHxy5+WKfaQ8aXA9K249pq jw+Z5BFrU3IcHwG5EZMVPIexP4NS3xc3Y/l+qCt6KzPMTmi6RXQzqhWjPyIwPZCDB0UT 9LOSE5PKkOiw28RdCcMLYlRVIB8xZRdxODfseQnfGyzNnX3eNatbCkKgX8Dr7s5Mk3jB l9sA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770977365; x=1771582165; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=6H578zF40bIvw0kW2/BZM5eR8EPStj53jblRqAXiqY4=; b=daepmR9m8s6mw+16PN4Jzv6zdfjpE4xQjCeNmZ9Zcy731a0k0KeD2/JWPSiWEGvng2 KOQq53qwT4QVTuh+rwTCAAQMX4bzBQ4bmIlneHdGwcWtTOFTBryzbZveUDVinzku84uU aX3lYxS2z6a2sVBtzif38ptC9RsSy0AfggjqeUnFFpHTXePuMq1BW++vrb4JZB+q3kpJ IPndC7G9L8mNv77S0AXBMBSl1fyP+o1QoYh5zJWa4Eh8iWSBfanEBdFmh3RQpXO7UWMx 8Di/vdVY/uwzmjOL/Po4vK5RTx6OmTqze15fwNOvf6a0AESiVqg2KVQAD4F/cQx/r8Y4 CFzQ== X-Forwarded-Encrypted: i=1; AJvYcCXInAkLZzvgbpVR2BsKEnOdGJn9uKXXuhW1WqswF+zu1iO9ignms8KU6yGlD7yQ0umznJV8EA+9C0o6TII=@vger.kernel.org X-Gm-Message-State: AOJu0YwHkwYHlh77XPC1eYe0R2dcieLPYydpS+GXL3LpiAjs92X+ziYV E0XhzjvN5T4IbfP7ZOmLr3L6ytnm+i1vR0DdFUNn5SaA11u+uepjMCHBO1nBk8dIT8C9ZVJvx3t nJdATISH2gM+7DY+dxg== X-Received: from pjbbx10.prod.google.com ([2002:a17:90a:f48a:b0:356:28cb:9650]) (user=guanyulin job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:5550:b0:354:a065:ec3e with SMTP id 98e67ed59e1d1-356aad900fbmr1526714a91.26.1770977364914; Fri, 13 Feb 2026 02:09:24 -0800 (PST) Date: Fri, 13 Feb 2026 10:07:36 +0000 In-Reply-To: <20260213100736.2914690-1-guanyulin@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260213100736.2914690-1-guanyulin@google.com> X-Mailer: git-send-email 2.53.0.273.g2a3d683680-goog Message-ID: <20260213100736.2914690-3-guanyulin@google.com> Subject: [RFC PATCH v2 2/2] ALSA: usb: qcom: manage offload device usage From: Guan-Yu Lin To: gregkh@linuxfoundation.org, mathias.nyman@intel.com, perex@perex.cz, tiwai@suse.com, quic_wcheng@quicinc.com, broonie@kernel.org, arnd@arndb.de, harshit.m.mogalapalli@oracle.com, wesley.cheng@oss.qualcomm.com Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-sound@vger.kernel.org, Guan-Yu Lin , stable@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The Qualcomm USB audio offload driver currently does not report its offload activity to the USB core. This prevents the USB core from properly tracking active offload sessions, which could allow the device to auto-suspend while audio offloading is in progress. Integrate usb_offload_get() and usb_offload_put() calls into the offload stream setup and teardown paths. Specifically, call usb_offload_get() when initializing the event ring and usb_offload_put() when freeing it. Since the updated usb_offload_get() and usb_offload_put() APIs require the caller to hold the USB device lock, add the necessary device locking in handle_uaudio_stream_req() and qmi_stop_session() to satisfy this requirement. Cc: stable@vger.kernel.org Fixes: ef82a4803aab ("xhci: sideband: add api to trace sideband usage") Signed-off-by: Guan-Yu Lin --- sound/usb/qcom/qc_audio_offload.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/sound/usb/qcom/qc_audio_offload.c b/sound/usb/qcom/qc_audio_of= fload.c index cfb30a195364..6bcb6033e688 100644 --- a/sound/usb/qcom/qc_audio_offload.c +++ b/sound/usb/qcom/qc_audio_offload.c @@ -699,6 +699,7 @@ static void uaudio_event_ring_cleanup_free(struct uaudi= o_dev *dev) uaudio_iommu_unmap(MEM_EVENT_RING, IOVA_BASE, PAGE_SIZE, PAGE_SIZE); xhci_sideband_remove_interrupter(uadev[dev->chip->card->number].sb); + usb_offload_put(dev->udev); } } =20 @@ -750,6 +751,7 @@ static void qmi_stop_session(void) struct snd_usb_substream *subs; struct usb_host_endpoint *ep; struct snd_usb_audio *chip; + struct usb_device *udev; struct intf_info *info; int pcm_card_num; int if_idx; @@ -791,8 +793,13 @@ static void qmi_stop_session(void) disable_audio_stream(subs); } atomic_set(&uadev[idx].in_use, 0); - guard(mutex)(&chip->mutex); - uaudio_dev_cleanup(&uadev[idx]); + + udev =3D uadev[idx].udev; + if (udev) { + guard(device)(&udev->dev); + guard(mutex)(&chip->mutex); + uaudio_dev_cleanup(&uadev[idx]); + } } } =20 @@ -1183,11 +1190,15 @@ static int uaudio_event_ring_setup(struct snd_usb_s= ubstream *subs, er_pa =3D 0; =20 /* event ring */ + ret =3D usb_offload_get(subs->dev); + if (ret < 0) + goto exit; + ret =3D xhci_sideband_create_interrupter(uadev[card_num].sb, 1, false, 0, uaudio_qdev->data->intr_num); if (ret < 0) { dev_err(&subs->dev->dev, "failed to fetch interrupter\n"); - goto exit; + goto put_offload; } =20 sgt =3D xhci_sideband_get_event_buffer(uadev[card_num].sb); @@ -1219,6 +1230,8 @@ static int uaudio_event_ring_setup(struct snd_usb_sub= stream *subs, mem_info->dma =3D 0; remove_interrupter: xhci_sideband_remove_interrupter(uadev[card_num].sb); +put_offload: + usb_offload_put(subs->dev); exit: return ret; } @@ -1483,6 +1496,7 @@ static int prepare_qmi_response(struct snd_usb_substr= eam *subs, uaudio_iommu_unmap(MEM_EVENT_RING, IOVA_BASE, PAGE_SIZE, PAGE_SIZE); free_sec_ring: xhci_sideband_remove_interrupter(uadev[card_num].sb); + usb_offload_put(subs->dev); drop_sync_ep: if (subs->sync_endpoint) { uaudio_iommu_unmap(MEM_XFER_RING, @@ -1528,6 +1542,7 @@ static void handle_uaudio_stream_req(struct qmi_handl= e *handle, u8 pcm_card_num; u8 pcm_dev_num; u8 direction; + struct usb_device *udev =3D NULL; int ret =3D 0; =20 if (!svc->client_connected) { @@ -1597,6 +1612,8 @@ static void handle_uaudio_stream_req(struct qmi_handl= e *handle, =20 uadev[pcm_card_num].ctrl_intf =3D chip->ctrl_intf; =20 + udev =3D subs->dev; + guard(device)(&udev->dev); if (req_msg->enable) { ret =3D enable_audio_stream(subs, map_pcm_format(req_msg->audio_format), --=20 2.53.0.273.g2a3d683680-goog