From nobody Thu Apr 9 12:49:58 2026 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) (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 076CE285CBC for ; Mon, 9 Mar 2026 02:22:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773022935; cv=none; b=kVSk9iGlFx7QKHBlc4CuPcTGBhI5p+ZUrcn9Xns0E03C+s3tUeit/GeDXS3Np8iUWeO4R1dStisM755RnToWHWZ46rx7ujF+TBwqV4v7K8Di+6tnJXRNnmJlAHYFntkfLDDIs8cWzyfMBx38lu+VUsSt9KDJpX+HptgyJHiq8BY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773022935; c=relaxed/simple; bh=hHjfugAI2wmLuqiTQpdrD0FeyO2Rh0gO6Ktv4HlhCi4=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=mwBNUlJCUyysQ/zCSA/qd2fTbLknlBQn7/2PKaEwmfbQ6+AD2HnWAYBlq4xyeSGMGSGMlbeeHm7FoMycrEFQ2pqy0DDNNwI20RJke4M+tKl+d2pNdBDpwGDI5HhhoGiPIkOPe02Xl+Aq6VMAUOJ/PgL/xa8tCcmUu9IltHcuows= 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=hHMefplH; arc=none smtp.client-ip=209.85.214.202 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="hHMefplH" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-2ae415b68b1so92041865ad.2 for ; Sun, 08 Mar 2026 19:22:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1773022933; x=1773627733; 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=u2u3Zs+Rjt0MiMQEbIUbjMYBi44MTXuAO7nU4+IJIFM=; b=hHMefplHFeTxxl46LMUCdLufAYfDP8Q/0iKpUYNVrXiTNO1jx7aredzvQbnljBqcmB JG4W+39VJEYy+lCRVfb8FsPQP/h3YnISWUsgiIJrMtl3dKUgyzeo3dV03rZx8zbR6KM6 MxB/XKlbTf1C1qAdm9N7hMvisYZ/nekvtuerRJdRn6yEHE9968fWvf2e+RnX13h5A2EX RBYAnXQkkTeXK9jKBWAnSFL8roHeppX3RIzTNoTzLTMWpb99eyGTbgg/8XVyDq1Y09zb QGXdH8vLX12KKPolz/+TbAr0SqBzrY3uinu8RjFAqWwVh3x8jYmtA56t4qd6Rntr1hXM jXyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773022933; x=1773627733; 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=u2u3Zs+Rjt0MiMQEbIUbjMYBi44MTXuAO7nU4+IJIFM=; b=QdtkIVo3SAYfCA/uyil6q8XIiJjC0vzwEf7UMWDzEcjbhhgc0/uuC0/GVMLLe8D8pT 9I9NO7t158iRYXPvL9S2do5n9Hi45deqMnEZ0CEvGavkmy+81FFPCHW15cEg1Cp+c1CW Yb98w13I1PYObSSjFi/DlWpR8etpUDkkSTwJTq/tI4P8XuO6as+sdsE1tvGqIf+sy/Pg UcVr9oRgzJcBu0a4gZBCJUIjqCaIPlBabXhjCb2nMJHlu81NIwjtHfZe6K/dRg4oyx19 4vNszxUshBYoMAsQ27fhiQFX6epPjk+oMZQzXfuLR/pgHZxYI3CecvoL81VGHejPGDt4 kjFA== X-Forwarded-Encrypted: i=1; AJvYcCWvpW8QC33IEk/cc69RdfgqoqUUfsuWfNbkwbGczZUcLjLSSILBcslyh8dbsRuj6lBS5w5FFAfBuL0tfe8=@vger.kernel.org X-Gm-Message-State: AOJu0Ywa/f/ipyCQFy0TrNEw324qyrjznUvB5hdyXgsxCO5M89fXl4RP 1Gv9qk8Z+MGPwhEGh4V76kk3lrC/AXG5emnaZ1nVZVtDRGzd7+1SofPk+h8hYgdYPrM5MmvC/fQ 515QOYpm8/hTAeORNAQ== X-Received: from pgbs189.prod.google.com ([2002:a63:5ec6:0:b0:c73:987f:4708]) (user=guanyulin job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:3e0d:b0:398:6bb5:54c4 with SMTP id adf61e73a8af0-3986bb55a1dmr6064755637.5.1773022933281; Sun, 08 Mar 2026 19:22:13 -0700 (PDT) Date: Mon, 9 Mar 2026 02:22:04 +0000 In-Reply-To: <20260309022205.28136-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: <20260309022205.28136-1-guanyulin@google.com> X-Mailer: git-send-email 2.53.0.473.g4a7958ca14-goog Message-ID: <20260309022205.28136-2-guanyulin@google.com> Subject: [PATCH v2 1/2] usb: offload: move device locking to callers in offload.c 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, christophe.jaillet@wanadoo.fr, xiaopei01@kylinos.cn, 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, Hailong Liu Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Update usb_offload_get() and usb_offload_put() to require that the caller holds the USB device lock. Remove the internal call to usb_lock_device() and add device_lock_assert() to ensure synchronization is handled by the caller. These functions continue to manage the device's power state via autoresume/autosuspend and update the offload_usage counter. Additionally, decouple the xHCI sideband interrupter lifecycle from the offload usage counter by removing the calls to usb_offload_get() and usb_offload_put() from the interrupter creation and removal paths. This allows interrupters to be managed independently of the device's offload activity status. Cc: stable@vger.kernel.org Fixes: ef82a4803aab ("xhci: sideband: add api to trace sideband usage") Signed-off-by: Guan-Yu Lin Tested-by: Hailong Liu --- drivers/usb/core/offload.c | 34 +++++++++++--------------------- drivers/usb/host/xhci-sideband.c | 14 +------------ 2 files changed, 13 insertions(+), 35 deletions(-) diff --git a/drivers/usb/core/offload.c b/drivers/usb/core/offload.c index 7c699f1b8d2b..e13a4c21d61b 100644 --- a/drivers/usb/core/offload.c +++ b/drivers/usb/core/offload.c @@ -20,6 +20,7 @@ * enabled on this usb_device; that is, another entity is actively handlin= g USB * transfers. This information allows the USB driver to adjust its power * management policy based on offload activity. + * The caller must hold @udev's device lock. * * Return: 0 on success. A negative error code otherwise. */ @@ -27,31 +28,25 @@ int usb_offload_get(struct usb_device *udev) { int ret; =20 - usb_lock_device(udev); - if (udev->state =3D=3D USB_STATE_NOTATTACHED) { - usb_unlock_device(udev); + device_lock_assert(&udev->dev); + + if (udev->state =3D=3D USB_STATE_NOTATTACHED) return -ENODEV; - } =20 if (udev->state =3D=3D USB_STATE_SUSPENDED || - udev->offload_at_suspend) { - usb_unlock_device(udev); + udev->offload_at_suspend) return -EBUSY; - } =20 /* * offload_usage could only be modified when the device is active, since * it will alter the suspend flow of the device. */ ret =3D usb_autoresume_device(udev); - if (ret < 0) { - usb_unlock_device(udev); + if (ret < 0) return ret; - } =20 udev->offload_usage++; usb_autosuspend_device(udev); - usb_unlock_device(udev); =20 return ret; } @@ -64,6 +59,7 @@ EXPORT_SYMBOL_GPL(usb_offload_get); * The inverse operation of usb_offload_get, which drops the offload_usage= of * a USB device. This information allows the USB driver to adjust its power * management policy based on offload activity. + * The caller must hold @udev's device lock. * * Return: 0 on success. A negative error code otherwise. */ @@ -71,33 +67,27 @@ int usb_offload_put(struct usb_device *udev) { int ret; =20 - usb_lock_device(udev); - if (udev->state =3D=3D USB_STATE_NOTATTACHED) { - usb_unlock_device(udev); + device_lock_assert(&udev->dev); + + if (udev->state =3D=3D USB_STATE_NOTATTACHED) return -ENODEV; - } =20 if (udev->state =3D=3D USB_STATE_SUSPENDED || - udev->offload_at_suspend) { - usb_unlock_device(udev); + udev->offload_at_suspend) return -EBUSY; - } =20 /* * offload_usage could only be modified when the device is active, since * it will alter the suspend flow of the device. */ ret =3D usb_autoresume_device(udev); - if (ret < 0) { - usb_unlock_device(udev); + if (ret < 0) return ret; - } =20 /* Drop the count when it wasn't 0, ignore the operation otherwise. */ if (udev->offload_usage) udev->offload_usage--; usb_autosuspend_device(udev); - usb_unlock_device(udev); =20 return ret; } diff --git a/drivers/usb/host/xhci-sideband.c b/drivers/usb/host/xhci-sideb= and.c index 2bd77255032b..6fc0ad658d66 100644 --- a/drivers/usb/host/xhci-sideband.c +++ b/drivers/usb/host/xhci-sideband.c @@ -93,8 +93,6 @@ __xhci_sideband_remove_endpoint(struct xhci_sideband *sb,= struct xhci_virt_ep *e static void __xhci_sideband_remove_interrupter(struct xhci_sideband *sb) { - struct usb_device *udev; - lockdep_assert_held(&sb->mutex); =20 if (!sb->ir) @@ -102,10 +100,6 @@ __xhci_sideband_remove_interrupter(struct xhci_sideban= d *sb) =20 xhci_remove_secondary_interrupter(xhci_to_hcd(sb->xhci), sb->ir); sb->ir =3D NULL; - udev =3D sb->vdev->udev; - - if (udev->state !=3D USB_STATE_NOTATTACHED) - usb_offload_put(udev); } =20 /* sideband api functions */ @@ -328,9 +322,6 @@ int xhci_sideband_create_interrupter(struct xhci_sideband *sb, int num_seg, bool ip_autoclear, u32 imod_interval, int intr_num) { - int ret =3D 0; - struct usb_device *udev; - if (!sb || !sb->xhci) return -ENODEV; =20 @@ -348,12 +339,9 @@ xhci_sideband_create_interrupter(struct xhci_sideband = *sb, int num_seg, if (!sb->ir) return -ENOMEM; =20 - udev =3D sb->vdev->udev; - ret =3D usb_offload_get(udev); - sb->ir->ip_autoclear =3D ip_autoclear; =20 - return ret; + return 0; } EXPORT_SYMBOL_GPL(xhci_sideband_create_interrupter); =20 --=20 2.53.0.473.g4a7958ca14-goog From nobody Thu Apr 9 12:49:58 2026 Received: from mail-pg1-f201.google.com (mail-pg1-f201.google.com [209.85.215.201]) (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 32228292B2E for ; Mon, 9 Mar 2026 02:22:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773022938; cv=none; b=XJEcSFoRmLf2N5J3UNCr1OyZZliD8YKGOPQcyq5adrq0fTXApF0g+t0AM7htnB02JFcR8t7BXnPlpj7axf/ccqgVq9Rc7PwU5JPU8u2wX9YC9bbFEY3fzdF2RcHvf0qJWIrqHYyaSnwW17v+jG0sf/MuK1vLDus2QLCFS/ufg9I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773022938; c=relaxed/simple; bh=sfhKlOxhZjp27RRqyMOv5tQbb25tvaGuKH9jjcuerK8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=oQSImUW9kL9CnNKt1HizL0oH0y67Bmdzp9RggnD0KI84vdZMF/438HI7Rvt2ABbE+UEu0U9pYEISOGBfINADkSP3d29aJkwos5PB9sZ6XTb77tItobZOrwkqZeOdwzYVl6DT+qkgL5AZHN7ys8bcDDFVSupeqyh69ijKbsPhZ5k= 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=qXS0xK/H; arc=none smtp.client-ip=209.85.215.201 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="qXS0xK/H" Received: by mail-pg1-f201.google.com with SMTP id 41be03b00d2f7-b6ce1b57b9cso8561987a12.1 for ; Sun, 08 Mar 2026 19:22:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1773022936; x=1773627736; 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=gplv2Tex9lazNCSIePgQz/7GHAFcH+CmqLMfgw0rRa0=; b=qXS0xK/H+4hXaFLUlZ8x87PPHpUbo46YLYLBWMcdL9kyLAofzbPujHJCCKYCmfDIKI BAaWPJKtf0PDXEyvBUJH3E98gWq9K6EfaAmpcYtIPoWKoQhKlNurghHkYy/OV2bqExfV Eb1lGEnpPVGw1Y0vZ7+dIz611n+QcCpX/phanCnjfZbr22m7H9EUpzJHDj5Q6gH7kL88 A90UAYwwWr2fp4/MjdBikNAwFpE/NM8XRJeElQ8G+7xJJyXyZ0KIXrNNAtAcOBwia6an vbOgLueVCmlSlNPm6E/SG7w/kjC/vBZNaJsjdqaz6fZ+1h5zHDx+ebWoCwIHouO8igbE OjIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773022936; x=1773627736; 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=gplv2Tex9lazNCSIePgQz/7GHAFcH+CmqLMfgw0rRa0=; b=TiFvFJtnt6ah3oJGDOYlgaKAJNhBFeYUa3GvXwfDgDT1YuOhSoOoTxPdmmO0MKYPZL QJAXtDpnYwmvr75w9OJNE2nY2fQmLLt38usJPjHJQKJUvRc9z0ohOw4Y7Q750YKkrUCW oblTuDfxF+ezSmTYVCS9hlDuitI0Q3KZuFMKguMsXLP2AxBjelVQEmYWjC5vF2sKMN6h HKIdL9GAkH7ZwH6mMdLXG1rZvAnNr+KzfC6rVf7sYlYevOZwZCTzDQ6KG7balOnQW28O B7WZuuZEpAjEyV3WicmYLQ4j/Kk57s1VKRzTOGCShTsz1Zb3YR4nOH5GcrzAl5MNp9dc FPJg== X-Forwarded-Encrypted: i=1; AJvYcCXY4ScJzAQYicpto+wulVRbj+e4qwCs32Bsm2Mdifp9kSF83oNR+e+OH02mpKsFbOiR9zvBC5dSVJY6xDs=@vger.kernel.org X-Gm-Message-State: AOJu0YxZZrqz3oggazVenMIGUMQKHe3+bTpg2bzgphNtWGdgzMMyyRB6 bPgV9fnJO6811wQHpO1JN6W+uNDaQp3DZL8KMTCYsGaddaSIHEuVhn9lgWVklh4l935X+35OtFv hRI3qGkdcbkeV4VBXBg== X-Received: from pliy14.prod.google.com ([2002:a17:903:3d0e:b0:2ae:42de:7ed4]) (user=guanyulin job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:f64e:b0:2ae:3ab7:1545 with SMTP id d9443c01a7336-2ae82505e81mr96587345ad.43.1773022936417; Sun, 08 Mar 2026 19:22:16 -0700 (PDT) Date: Mon, 9 Mar 2026 02:22:05 +0000 In-Reply-To: <20260309022205.28136-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: <20260309022205.28136-1-guanyulin@google.com> X-Mailer: git-send-email 2.53.0.473.g4a7958ca14-goog Message-ID: <20260309022205.28136-3-guanyulin@google.com> Subject: [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, christophe.jaillet@wanadoo.fr, xiaopei01@kylinos.cn, 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 | 102 ++++++++++++++++++------------ 1 file changed, 60 insertions(+), 42 deletions(-) diff --git a/sound/usb/qcom/qc_audio_offload.c b/sound/usb/qcom/qc_audio_of= fload.c index cfb30a195364..1da243662327 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,50 +1612,53 @@ static void handle_uaudio_stream_req(struct qmi_han= dle *handle, =20 uadev[pcm_card_num].ctrl_intf =3D chip->ctrl_intf; =20 - if (req_msg->enable) { - ret =3D enable_audio_stream(subs, - map_pcm_format(req_msg->audio_format), - req_msg->number_of_ch, req_msg->bit_rate, - datainterval); - - if (!ret) - ret =3D prepare_qmi_response(subs, req_msg, &resp, - info_idx); - if (ret < 0) { - guard(mutex)(&chip->mutex); - subs->opened =3D 0; - } - } else { - info =3D &uadev[pcm_card_num].info[info_idx]; - if (info->data_ep_pipe) { - ep =3D usb_pipe_endpoint(uadev[pcm_card_num].udev, - info->data_ep_pipe); - if (ep) { - xhci_sideband_stop_endpoint(uadev[pcm_card_num].sb, - ep); - xhci_sideband_remove_endpoint(uadev[pcm_card_num].sb, - ep); + udev =3D subs->dev; + scoped_guard(device, &udev->dev) { + if (req_msg->enable) { + ret =3D enable_audio_stream(subs, + map_pcm_format(req_msg->audio_format), + req_msg->number_of_ch, req_msg->bit_rate, + datainterval); + + if (!ret) + ret =3D prepare_qmi_response(subs, req_msg, &resp, + info_idx); + if (ret < 0) { + guard(mutex)(&chip->mutex); + subs->opened =3D 0; + } + } else { + info =3D &uadev[pcm_card_num].info[info_idx]; + if (info->data_ep_pipe) { + ep =3D usb_pipe_endpoint(uadev[pcm_card_num].udev, + info->data_ep_pipe); + if (ep) { + xhci_sideband_stop_endpoint(uadev[pcm_card_num].sb, + ep); + xhci_sideband_remove_endpoint(uadev[pcm_card_num].sb, + ep); + } + + info->data_ep_pipe =3D 0; } =20 - info->data_ep_pipe =3D 0; - } - - if (info->sync_ep_pipe) { - ep =3D usb_pipe_endpoint(uadev[pcm_card_num].udev, - info->sync_ep_pipe); - if (ep) { - xhci_sideband_stop_endpoint(uadev[pcm_card_num].sb, - ep); - xhci_sideband_remove_endpoint(uadev[pcm_card_num].sb, - ep); + if (info->sync_ep_pipe) { + ep =3D usb_pipe_endpoint(uadev[pcm_card_num].udev, + info->sync_ep_pipe); + if (ep) { + xhci_sideband_stop_endpoint(uadev[pcm_card_num].sb, + ep); + xhci_sideband_remove_endpoint(uadev[pcm_card_num].sb, + ep); + } + + info->sync_ep_pipe =3D 0; } =20 - info->sync_ep_pipe =3D 0; + disable_audio_stream(subs); + guard(mutex)(&chip->mutex); + subs->opened =3D 0; } - - disable_audio_stream(subs); - guard(mutex)(&chip->mutex); - subs->opened =3D 0; } =20 response: --=20 2.53.0.473.g4a7958ca14-goog