Merge remote-tracking branch 'stable/linux-5.15.y' into rpi-5.15.y
[platform/kernel/linux-rpi.git] / drivers / usb / host / xhci-mem.c
index 28dcc35..ddd321d 100644 (file)
@@ -913,15 +913,19 @@ void xhci_free_virt_device(struct xhci_hcd *xhci, int slot_id)
                if (dev->eps[i].stream_info)
                        xhci_free_stream_info(xhci,
                                        dev->eps[i].stream_info);
-               /* Endpoints on the TT/root port lists should have been removed
-                * when usb_disable_device() was called for the device.
-                * We can't drop them anyway, because the udev might have gone
-                * away by this point, and we can't tell what speed it was.
+               /*
+                * Endpoints are normally deleted from the bandwidth list when
+                * endpoints are dropped, before device is freed.
+                * If host is dying or being removed then endpoints aren't
+                * dropped cleanly, so delete the endpoint from list here.
+                * Only applicable for hosts with software bandwidth checking.
                 */
-               if (!list_empty(&dev->eps[i].bw_endpoint_list))
-                       xhci_warn(xhci, "Slot %u endpoint %u "
-                                       "not removed from BW list!\n",
-                                       slot_id, i);
+
+               if (!list_empty(&dev->eps[i].bw_endpoint_list)) {
+                       list_del_init(&dev->eps[i].bw_endpoint_list);
+                       xhci_dbg(xhci, "Slot %u endpoint %u not removed from BW list!\n",
+                                slot_id, i);
+               }
        }
        /* If this is a hub, free the TT(s) from the TT list */
        xhci_free_tt_info(xhci, dev, slot_id);