Skip to content

Commit 712da5f

Browse files
matnymangregkh
authored andcommitted
xhci: Don't create stream debugfs files with spinlock held.
Creating debugfs files while loding the spin_lock_irqsave(xhci->lock) creates a lock dependecy that could possibly deadlock. Lockdep warns: ===================================================== WARNING: HARDIRQ-safe -> HARDIRQ-unsafe lock order detected 5.10.0-rc1pdx86+ #8 Not tainted ----------------------------------------------------- systemd-udevd/386 [HC0[0]:SC0[0]:HE0:SE1] is trying to acquire: ffffffffb1a94038 (pin_fs_lock){+.+.}-{2:2}, at: simple_pin_fs+0x22/0xa0 and this task is already holding: ffff9e7b87fbc430 (&xhci->lock){-.-.}-{2:2}, at: xhci_alloc_streams+0x5f9/0x810 which would create a new lock dependency: (&xhci->lock){-.-.}-{2:2} -> (pin_fs_lock){+.+.}-{2:2} Create the files a bit later after lock is released. Fixes: 673d746 ("usb: xhci: add debugfs support for ep with stream") CC: Li Jun <[email protected]> Reported-by: Hans de Goede <[email protected]> Reported-by: Mike Galbraith <[email protected]> Tested-by: Hans de Goede <[email protected]> Signed-off-by: Mathias Nyman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 2a63281 commit 712da5f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/usb/host/xhci.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3533,11 +3533,14 @@ static int xhci_alloc_streams(struct usb_hcd *hcd, struct usb_device *udev,
35333533
xhci_dbg(xhci, "Slot %u ep ctx %u now has streams.\n",
35343534
udev->slot_id, ep_index);
35353535
vdev->eps[ep_index].ep_state |= EP_HAS_STREAMS;
3536-
xhci_debugfs_create_stream_files(xhci, vdev, ep_index);
35373536
}
35383537
xhci_free_command(xhci, config_cmd);
35393538
spin_unlock_irqrestore(&xhci->lock, flags);
35403539

3540+
for (i = 0; i < num_eps; i++) {
3541+
ep_index = xhci_get_endpoint_index(&eps[i]->desc);
3542+
xhci_debugfs_create_stream_files(xhci, vdev, ep_index);
3543+
}
35413544
/* Subtract 1 for stream 0, which drivers can't use */
35423545
return num_streams - 1;
35433546

0 commit comments

Comments
 (0)