Re: [PATCH v2 2/2] ALSA: usb: qcom: manage offload device usage
From: Guan-Yu Lin
Date: Wed Mar 18 2026 - 19:30:11 EST
On Wed, Mar 18, 2026 at 12:59 AM Greg KH <gregkh@xxxxxxxxxxxxxxxxxxx> wrote:
>
> On Tue, Mar 17, 2026 at 04:45:00PM -0400, Guan-Yu Lin wrote:
> >
> > Hi Greg,
> >
> > Thank you for the feedback. I understand the concern regarding locking
> > complexity and the reviewer burden. The usb_offload_get/put functions
> > track sideband activity that runtime PM cannot reflect. This is
> > necessary to prevent the USB stack from suspending the device while a
> > sideband stream is active. Ensuring atomicity requires orchestrating
> > three asynchronous subsystems: System PM, Runtime PM, and USB Core.
> >
> > To address the concerns effectively in the next iteration, I would
> > appreciate clarification on your primary concern:
> > 1. Preference for fine-grained locking:
> > Using USB device lock ensures atomicity across these subsystems, which
> > is inherently a device-wide requirement. A fine-grained approach risks
> > races during concurrent software events, such as a reset occurring
> > during a runtime suspend transition.
> > 2. Preference for improved transparency:
> > If the coarse lock is acceptable but the implementation is too opaque,
> > I will refactor the next version to be more explicit. I plan to
> > include device_lock_assert() calls, __must_hold() macros, and add a
> > "Locking Hierarchy" comment block documenting the vendor-mutex and
> > USB-core lock interactions.
>
> At the very least, this is going to have to be required so that we can
> catch any future changes and ensure that changes do not create locking
> inversions and the like. I guess we are stuck with this for now, due to
> this being "outside" of the normal runtime PM, which still feels wrong
> to me as runtime PM _should_ be able to handle this (if not, why is this
> case somehow unique from all other hardware types?)
>
The runtime pm doesn't apply here because when a sideband instance
accesses the controller, the main system could suspend. The runtime pm
only reflects whether the "main system" is using the controller,
whereas a sideband instance might still be using the controller when
the main system has suspended. Runtime pm couldn't reflect the
sideband's status. If runtime pm reflects sidebands activity on the
controller, it will mark the controller as active, which prevents the
entire "main system" from suspending. Does that sound right to you, or
is there anything I can clarify?
> > To clarify the "broken hardware" point: this isn't a hardware bug.
>
> It was described as triggering when a shock happened to the system to
> cause the system to reset in places, which is a hardware issue :)
>
> > These races are triggered by standard software events, such as a reset
> > occurring while a sideband stream is active. Please let me know which
> > direction you think is more appropriate for the kernel, and I will
> > refactor the next version accordingly.
>
> And how exactly can a "reset while active" happen as just a normal
> software driven event?
>
> thanks,
>
> greg k-h
I'm not sure what the OPPO team has encountered. In our experiments,
we saw the following call stack:
[ 721.889147][ T228] qc_usb_audio_offload_disconnect
[ 721.889284][ T228] usb_audio_disconnect+0x7c/0x268
[ 721.889302][ T228] usb_unbind_interface+0xc4/0x2f8
[ 721.889313][ T228] device_release_driver_internal+0x1c4/0x2bc
[ 721.889333][ T228] device_release_driver+0x18/0x28
[ 721.889347][ T228] usb_forced_unbind_intf+0x60/0x80
[ 721.889358][ T228] usb_reset_device+0xbc/0x23c
[ 721.889375][ T228] __usb_queue_reset_device+0x3c/0x64
[ 721.889386][ T228] process_scheduled_works+0x1b8/0x8ec
[ 721.889405][ T228] worker_thread+0x1b0/0x470
[ 721.889418][ T228] kthread+0x11c/0x158
[ 721.889429][ T228] ret_from_fork+0x10/0x20
In addition, if a process interacts with the kernel using
`usbdev_do_ioctl` and then `usbdev_do_ioctl ` calls
`usb_driver_release_interface`, we could also encounter a deadlock
issue.
Regards,
Guan-Yu