From nobody Thu Apr 16 22:32:43 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 9A7DD2D2385 for ; Wed, 25 Feb 2026 06:46:12 +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=1772001974; cv=none; b=T7m9IkxpC8vv3ZwD4TeIqtUN10BK8Jrlk5P+tn7+nadv+0D1u6Q+ko2axIoUNm6BC1smWiLdYCdD8eLkwoQz7b5QOL9BPJklNTGfw62gz3kn+ZRPmrODTORrPrhrpSmg8RGLkMYE9eoqrpoCyyXdJfLyK8vNqVsI7YIFjFlBBx0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772001974; c=relaxed/simple; bh=8jXjL4fbM6gkhPw4/nMZoR6XPa+UBbga/qTa9E4J9vU=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=IFIrgazAkjCfce3/lr0AjNVDM2yu3OkONghsDoDqpdy0HPZwez1tJ1Pd+cwqQjq3eol4oXTLf/+/ukzuge8NMk3CFf9EDM7RaSKgAWsC2AbwcQ6fymMeAUWk0+vKzRBQ1suLZ8JxUxjncSVKHWtd2Eh/Gg56MvSiQXjE18c/Pic= 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=a6jkZjQe; 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="a6jkZjQe" Received: by mail-pg1-f201.google.com with SMTP id 41be03b00d2f7-b630753cc38so35275270a12.1 for ; Tue, 24 Feb 2026 22:46:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1772001972; x=1772606772; 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=q5f300QESzf5Ez7BqOSUeVAJjkHUA2IYF3yXjjVhVPI=; b=a6jkZjQemq9m4bFcy5fAJzVX346fmVbME9bnVdg0RUCvQ/qin2ziP751f2YSBKvDmn fyq1P/Dh+wCcOLQs9cBaUpQgvPq2k8ClQxsBfdPCVZKNorbDjzEHz6CSDmn5OoaNiJ9j ZxdpyfsGON/4vuhH1yFZrRVtyuPmbXsa7FbRgKjQ8l+Ba87nKT+I3zvhg9QcphxNssjv No6QKj0AHUWiO4vKPnHVwrQdqoNmlbp/L3GyToPqy1QfrX1/0v6kAGmpRy0oOO5bpD1y 2t48v2mzl3CGVVulOc4RAw1IwnZSbimtNB7U/NKENuh58pzSwEs2o4UwjDO6FSYXlllv /aGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772001972; x=1772606772; 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=q5f300QESzf5Ez7BqOSUeVAJjkHUA2IYF3yXjjVhVPI=; b=r+meVZ3rerzov8nAl5y+fdNidYVmpWwS9x6dv5PiIt/CL95rdQXVktXqdIYNEVxwAz 2iwyAWnkCQS5CJe32A5es+1bsciy8PwIwJOm6H2tvYdYVtIomMRW85v4r2GkZu/r5hK9 sf/uBPnG2NGFSnsAJ3bbc6MpgWIZQW0nmmkf1CXoobxdMT8cpl2WFsg/yi22Hw2AhBnE 7rnz13yKKMhnFWPbus4oPYVkJvW8V3S7X78WDjf9Isy7zFg/GYzBQbilI5yDUHLaSL3Q pCGhMcb2oZ3droGbKNVTbwSpiqFJl1lI07yjEjnNmYLOXSM7EzDCC84nI2ceQk1AMjB9 cgUg== X-Forwarded-Encrypted: i=1; AJvYcCWAyB2BjLIk9iRgEjYZmkweqG0rYHcp4WOcr2Vz4+L23CCQIknliYDNEwE4HvbpB/eFGC5+MqqaaHsL6Is=@vger.kernel.org X-Gm-Message-State: AOJu0YxsJtTkJN2YEkqslLaGCbU73EZLRUj3t941dWkOkE5qEjy2rh4M OSV8sPsUBj1JI8efsi1ZCp2uJrEGTWKB07WUYlN/n+NwzHKoGijMtZ2UZgBxl1rs3AUKfzzo/Ks lEn8TUhM1P+GUulIOEA== X-Received: from pgav17.prod.google.com ([2002:a05:6a02:2dd1:b0:c70:95a6:8599]) (user=guanyulin job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:2d2b:b0:392:e583:b766 with SMTP id adf61e73a8af0-39545f8e05cmr13793496637.42.1772001971759; Tue, 24 Feb 2026 22:46:11 -0800 (PST) Date: Wed, 25 Feb 2026 06:45:50 +0000 In-Reply-To: <20260225064601.270301-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: <20260225064601.270301-1-guanyulin@google.com> X-Mailer: git-send-email 2.53.0.414.gf7e9f6c205-goog Message-ID: <20260225064601.270301-2-guanyulin@google.com> Subject: [PATCH v1 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, harshit.m.mogalapalli@oracle.com, wesley.cheng@oss.qualcomm.com, dan.carpenter@linaro.org 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" 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.414.gf7e9f6c205-goog From nobody Thu Apr 16 22:32:43 2026 Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.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 66CF92BDC03 for ; Wed, 25 Feb 2026 06:46:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772001980; cv=none; b=FPfBiLX+XWH3XyICNVhbEStT79y8mxFXXBKZA3omPlkuq6dtJsyrcvyy5+KK3QzJWzUuxAuxdTOAA+sWgVymosTjPRrH3oc7SXakECLNOWsXKIX9rECyhevWOfq3l5RP6stkOMLhRsCuupmwh68zWIUwirGwtb55Vwvl7l6YcYA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772001980; c=relaxed/simple; bh=KapOGnfYOh0PXxFD3beN+OUTsZGlUIANBotOvS5qfBU=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=r3WBJmMLWuPWCQbuZfAHtnhmWI1aOzj+uO2XPR7xR8epoOriCfL4L22jzaJYp2UTrDEGuIGfPK7VmRrFd/lPYu0O8J+RO+DqJOJg5w07U4QUm6IaQCd293/xLakJ3VY+4legbvHb2ohvsH9YDh+gL9F9C/s22LHtyl0wug8lrqg= 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=fOuKXTg7; arc=none smtp.client-ip=209.85.215.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="fOuKXTg7" Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-c6e18ade2c2so4191792a12.1 for ; Tue, 24 Feb 2026 22:46:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1772001975; x=1772606775; 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=QnjS8olMajKnP/sZl5vPFhjp48gpsJXv+tm2dwICITg=; b=fOuKXTg7xdPgbuvDQh9UA4vsU2GLSCulXctaJ3hj1RVw7GEuVJaA0ySUC4PYUee2Ri 9s3TndCsOySG+Leu9bNlX3vCHgj+roHQsdRR6mp9w2l9TKvBIX7CFQmvYH/og0mt3m9D yEl1HG1ncHxFdjbPpZDzq+QiLZKnXu4BKNvMDVEFRK4lySAcGylCnNEo503XHA0tLjXY NXN/rE9B/b3IzNmKiGxmsQ9+hxtOttbiZgO34R/YnJzibTMowrsG7q2LN+tr6oiSDHTi SZ8WDOG3sqC/PKSH/DflhYxC/QYIF2/sAgAe1cjtGMevef0QEfmUwbFPCl7TLWX+1f21 Ab4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772001975; x=1772606775; 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=QnjS8olMajKnP/sZl5vPFhjp48gpsJXv+tm2dwICITg=; b=NmsuXCFHyHvBJMZbkzGupZwwwE+NG3IKGG4SP08Tx63PSw30DQMB873cRNXuUAWYSc sqAdDPv6S6c8h6baXH7VK+GzVEQtLHnaghdsDWdcDOOlpqxB/xIJt2cfISi/Gb9Cxnc+ 1jVUklBc5ioLkWWXEXjMsgg0oarW7LRxCYPv631Bdmb6MTieqKvS41DirCZ1l7Q+AYmW AkI8GsOnr4jba2iV6oDlYhOI1ohXX2FxdZQqrAwoUsqeStC888Bz03Mzb4XKlBWcFEZz 11Yx3aUyF4D4piEGbRB25X1bXByZPx5gSOA93+uwsc6zyq7wiILIAuo1PAl8Z0Rm6eUr Mqtw== X-Forwarded-Encrypted: i=1; AJvYcCWY26EzZ24fdG1AOhbgAuk+1SzOU56d8XA3uyT+8vpksI8VoZRItv+buaNa1Lk8qsZcrBM6HHmT7M7zjxo=@vger.kernel.org X-Gm-Message-State: AOJu0YxYKn39G5DmCiq1i54YVcNxYykT7TqBeDVoWg92d88CC5S040Yc q6Sv0jyOjgFY9kEbkWiGp5m2dAHBXeUASPuXdwgN9CyCwpV6Ky62IhfOkIqnZ2LMF9ra2JrVn8A b7YqYO5w7qbkCU1EmEA== X-Received: from pgce1.prod.google.com ([2002:a05:6a02:1c1:b0:bd9:a349:94a5]) (user=guanyulin job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:9d91:b0:394:6208:6623 with SMTP id adf61e73a8af0-39545ed01cfmr12186049637.27.1772001974577; Tue, 24 Feb 2026 22:46:14 -0800 (PST) Date: Wed, 25 Feb 2026 06:45:51 +0000 In-Reply-To: <20260225064601.270301-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: <20260225064601.270301-1-guanyulin@google.com> X-Mailer: git-send-email 2.53.0.414.gf7e9f6c205-goog Message-ID: <20260225064601.270301-3-guanyulin@google.com> Subject: [PATCH v1 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, dan.carpenter@linaro.org 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.414.gf7e9f6c205-goog