]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
usb: xhci: move initialization for lifetime objects
authorNiklas Neronin <niklas.neronin@linux.intel.com>
Thu, 2 Apr 2026 13:13:26 +0000 (16:13 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 2 Apr 2026 13:55:37 +0000 (15:55 +0200)
Initialize objects that exist for the lifetime of the driver only once,
rather than repeatedly. These objects do not require re-initialization
after events such as 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-10-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 ca4463eebc4952575a1c10ec080e3179961ffbf3..2cd6111c97073ff4b243312b091664a3838e0787 100644 (file)
@@ -2009,7 +2009,6 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
        xhci->port_caps = NULL;
        xhci->interrupters = NULL;
 
-       xhci->page_size = 0;
        xhci->usb2_rhub.bus_state.bus_suspended = 0;
        xhci->usb3_rhub.bus_state.bus_suspended = 0;
 }
index dd495dc740c371b7f369488cd7bbb67d50c99a25..674bd40e4e2df4d152b00972715f86a5bae2b02e 100644 (file)
@@ -549,13 +549,6 @@ static int xhci_init(struct usb_hcd *hcd)
        int retval;
 
        xhci_dbg_trace(xhci, trace_xhci_dbg_init, "Starting %s", __func__);
-       spin_lock_init(&xhci->lock);
-
-       INIT_LIST_HEAD(&xhci->cmd_list);
-       INIT_DELAYED_WORK(&xhci->cmd_timer, xhci_handle_command_timeout);
-       init_completion(&xhci->cmd_ring_stop_completion);
-       xhci_hcd_page_size(xhci);
-       memset(xhci->devs, 0, MAX_HC_SLOTS * sizeof(*xhci->devs));
 
        retval = xhci_mem_init(xhci, GFP_KERNEL);
        if (retval)
@@ -5532,6 +5525,14 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks)
                dma_set_coherent_mask(dev, DMA_BIT_MASK(32));
        }
 
+       spin_lock_init(&xhci->lock);
+       INIT_LIST_HEAD(&xhci->cmd_list);
+       INIT_DELAYED_WORK(&xhci->cmd_timer, xhci_handle_command_timeout);
+       init_completion(&xhci->cmd_ring_stop_completion);
+       xhci_hcd_page_size(xhci);
+
+       memset(xhci->devs, 0, MAX_HC_SLOTS * sizeof(*xhci->devs));
+
        xhci_dbg(xhci, "Calling HCD init\n");
        /* Initialize HCD and host controller data structures. */
        retval = xhci_init(hcd);