Re: [PATCH RFC 1/2] USB: core: add helper to queue device re-enumeration
Alan Stern <[email protected]>
| Newsgroups | org.infradead.lists.linux-mediatek,org.infradead.lists.linux-arm-kernel,org.kernel.vger.linux-bluetooth,org.kernel.vger.linux-kernel,org.kernel.vger.linux-usb |
|---|---|
| Message-ID | <[email protected]> |
On Tue, Aug 18, 2026 at 04:55:20AM +0200, George Maraveyas via B4 Relay wrote: > From: George Maraveyas <[email protected]> > > USB drivers can use usb_queue_reset_device() when they need USB core to > reset an already enumerated device asynchronously. > > There is currently no driver-facing helper corresponding to > usb_queue_reset_device() which allows an interface driver to ask USB core > to remove the current usb_device and enumerate the physical device on the > port again. > > The difference between the two is that a device reset continues using the > existing usb_device and its current enumeration state while > re-enumeration removes the existing usb_device and returns the port to > the hub code, which then discovers the device again through the normal > USB enumeration path. A device reset continues to use the existing usb_device only when a new partial enumeration yields the same descriptors as before. If the descriptors have changed significantly then it goes through a logical disconnect and re-enumeration, just like the function you want to add. For this reason it's not clear why you can't just use usb_queue_reset_device() here. From the device's point of view, the two approaches do pretty much the same thing. Alan Stern > Add usb_queue_reenumerate_device() to provide this facility. > > The helper queues a logical disconnect on the parent hub port. > hub_port_logical_disconnect() disables the port, records a logical > connect-change event and queues the hub work. The hub work later > disconnects the existing usb_device and, if the physical device remains > connected, attempts to enumerate it again through the normal hub path. > > Any retries or port recovery required during the subsequent enumeration > remain the responsibility of the existing hub code. > > usb_remove_device() cannot provide the same behaviour because it also > marks the port in removed_bits. The hub connection path does not > enumerate a device on a port while that bit remains set. > > The helper takes the device lock required by usb_hub_to_struct_hub() and > holds a runtime-PM reference on the parent hub interface while the > logical disconnect is queued. > > The helper does not decide when re-enumeration is needed. That decision > remains with the calling driver. > > The following MT7925 Bluetooth patch is the first user of the helper. It > requests re-enumeration after the controller has already enumerated > successfully but later fails during Bluetooth setup and cannot be > recovered by its existing reset path. > > Signed-off-by: George Maraveyas <[email protected]>