Re: [PATCH] ALSA: usb-audio: qcom: move offload usage counting to stream request handler

From: Guan-Yu Lin

Date: Mon Apr 20 2026 - 05:53:33 EST


On Fri, Apr 17, 2026 at 4:49 PM Takashi Iwai <tiwai@xxxxxxx> wrote:
>
> On Fri, 17 Apr 2026 07:43:30 +0200,
> Guan-Yu Lin wrote:
> >
> > Centralize usb_offload_get()/usb_offload_put() calls from various helper
> > functions to handle_uaudio_stream_req(), which ensures the usage count
> > is tied directly to the QMI stream enable/dsiable requests from audio
> > DSP. Such design provides a clear synchronization point for the
> > offloading lifecycle and correctly balances the count for both playback
> > and capture paths while avoiding redundant increments during auxiliary
> > operations.
> >
> > Suggested-by: Wesley Cheng <wesley.cheng@xxxxxxxxxxxxxxxx>
> > Signed-off-by: Guan-Yu Lin <guanyulin@xxxxxxxxxx>
> > ---
> > sound/usb/qcom/qc_audio_offload.c | 20 ++++++++++----------
> > 1 file changed, 10 insertions(+), 10 deletions(-)
> >
> > diff --git a/sound/usb/qcom/qc_audio_offload.c b/sound/usb/qcom/qc_audio_offload.c
> > index 2ac813d57f4f..cddab55d4691 100644
> > @@ -1605,6 +1597,12 @@ static void handle_uaudio_stream_req(struct qmi_handle *handle,
> > uadev[pcm_card_num].ctrl_intf = chip->ctrl_intf;
> >
> > if (req_msg->enable) {
> > + ret = usb_offload_get(subs->dev);
> > + if (ret < 0) {
> > + guard(mutex)(&chip->mutex);
> > + subs->opened = 0;
> > + goto response;
> > + }
> > ret = enable_audio_stream(subs,
> > map_pcm_format(req_msg->audio_format),
> > req_msg->number_of_ch, req_msg->bit_rate,
>
> I think the usb_offload_put() is missing at the error handling of the
> call above?
>
>
> thanks,
>
> Takashi

Yes, I think we should add error handling in this case. Let me update
it in the next version. Thanks.

Regards,
Guan-Yu