On 9/25/26 11:11 AM, Stefan Eichenberger wrote:
From: Stefan Eichenberger <[email protected]>On Verdin iMX95, with a USB hub permanently attached to the DWC3 host port the hub itself enumerates fine but a USB stick plugged into it fails intermittently: Verdin iMX95 # usb start starting USB... USB XHCI 1.10 Device not responding to set address. USB device not accepting new address (error=80000000) Bus usb@4c100000: 2 USB Device(s) found scanning usb for storage devices... 0 Storage Device(s) found Verdin iMX95 # usb reset resetting USB... USB XHCI 1.10 WARN endpoint is halted WARN endpoint is halted unable to get device descriptor (error=-22) Commit c6583354b7c1 ("usb: dwc3: Look up reference clock DT phandle in both controller DT nodes") added a fallback that searches the DWC3 child node's "clock-names" for "ref"/"ref_clk" when it isn't found on the parent glue node, but always resolves the found index against glue->clks, a clk_bulk populated only from the parent glue node's own clock-names list. This is wrong since the child node's clock-names list is not guaranteed to be in the same order as the parent's, and indeed on Verdin iMX95 the child node has a different order than the parent node. Fix it by looking the reference clock up by name with clk_get_by_name(), trying the dwc3 device and then its parent glue device, so the clock is always resolved through the device that owns the node its name was found in. Also enable the clock before use and fail the probe if that does not work, and disable it again on the probe error paths and in dwc3_generic_remove() to keep the enable balanced. Because of moving to clk_get_by_name() for receiving the reference clock, also ensure that the parent driver is a DWC3 glue driver before looking up the reference clock, since the parent could be a bus or root device with unrelated clocks. Fixes: c6583354b7c1 ("usb: dwc3: Look up reference clock DT phandle in both controller DT nodes") Signed-off-by: Stefan Eichenberger <[email protected]> Tested-by: Tom Hsieh <[email protected]> --- Changes in v3: - Ensure that dev->parent->driver is not NULL (Marek) - Return with an error if clk_enable fails. (Marek) - Balance the clk_enable() with a clk_disable() on the probe error paths. Changes in v2: - Check if the parent driver is a DWC3 glue driver before looking up the reference clock. I use driver->name as this should work with all implementations used today and I hope this is more generic. (Marek) - Add Tested-by from Tom --- drivers/usb/dwc3/dwc3-generic.c | 69 +++++++++++++++++++++++----------
Reviewed-by: Marek Vasut <[email protected]>
