]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
usb: xhci: move reserving command ring trb
authorNiklas Neronin <niklas.neronin@linux.intel.com>
Thu, 2 Apr 2026 13:13:24 +0000 (16:13 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 2 Apr 2026 13:55:37 +0000 (15:55 +0200)
Move the command ring TRB reservation from xhci_mem_init() to xhci_init().

Function xhci_mem_init() is intended for memory allocation,
while xhci_init() is for initialization.

This split allows xhci_init() to be reused when resuming from S4
suspend-to-disk.

Signed-off-by: Niklas Neronin <niklas.neronin@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Link: https://patch.msgid.link/20260402131342.2628648-8-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/host/xhci-mem.c
drivers/usb/host/xhci.c

index d4a9dbed8f16edfffddde4f3ed7dd3de4ace1ed3..45638ab13635192ce2c0dac43a0a65aa11e52b55 100644 (file)
@@ -2485,13 +2485,6 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
        xhci_dbg_trace(xhci, trace_xhci_dbg_init, "First segment DMA is 0x%pad",
                       &xhci->cmd_ring->first_seg->dma);
 
-       /*
-        * Reserve one command ring TRB for disabling LPM.
-        * Since the USB core grabs the shared usb_bus bandwidth mutex before
-        * disabling LPM, we only need to reserve one TRB for all devices.
-        */
-       xhci->cmd_ring_reserved_trbs++;
-
        /* Allocate and set up primary interrupter 0 with an event ring. */
        xhci_dbg_trace(xhci, trace_xhci_dbg_init, "Allocating primary event ring");
        xhci->interrupters = kcalloc_node(xhci->max_interrupters, sizeof(*xhci->interrupters),
index fdd3a19b7c9c1b595a1e4f573ed123571e316251..b9fa941425c588a0f6d089e67116aab8b9b6dc13 100644 (file)
@@ -564,6 +564,12 @@ static int xhci_init(struct usb_hcd *hcd)
        /* Set the Number of Device Slots Enabled to the maximum supported value */
        xhci_enable_max_dev_slots(xhci);
 
+       /*
+        * Reserve one command ring TRB for disabling LPM.
+        * Since the USB core grabs the shared usb_bus bandwidth mutex before
+        * disabling LPM, we only need to reserve one TRB for all devices.
+        */
+       xhci->cmd_ring_reserved_trbs = 1;
        /* Set the address in the Command Ring Control register */
        xhci_set_cmd_ring_deq(xhci);