usb: xhci: move device slot enabling register write
authorNiklas Neronin <niklas.neronin@linux.intel.com>
Thu, 15 May 2025 13:56:01 +0000 (16:56 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 21 May 2025 10:35:31 +0000 (12:35 +0200)
Refactor the setting of the Number of Device Slots Enabled field into a
separate function, relocating it to xhci_init().

The xHCI driver consistently sets the number of enabled device slots to the
maximum value. The new function is named to reflect this behavior.

Remove the "// " prefix from trace messages, as it is unnecessary and
distracting.

Signed-off-by: Niklas Neronin <niklas.neronin@linux.intel.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Link: https://lore.kernel.org/r/20250515135621.335595-5-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 a7955e02905cb5c1c0d3b0299fbdf8159701e690..e03109a24a503c9913ae730838311c65e8b5f841 100644 (file)
@@ -2419,23 +2419,10 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
        struct xhci_interrupter *ir;
        struct device   *dev = xhci_to_hcd(xhci)->self.sysdev;
        dma_addr_t      dma;
-       unsigned int    val, val2;
+       unsigned int    val;
        u64             val_64;
        u32             temp;
 
-       /*
-        * Program the Number of Device Slots Enabled field in the CONFIG
-        * register with the max value of slots the HC can handle.
-        */
-       val = HCS_MAX_SLOTS(readl(&xhci->cap_regs->hcs_params1));
-       xhci_dbg_trace(xhci, trace_xhci_dbg_init,
-                       "// xHC can handle at most %d device slots.", val);
-       val2 = readl(&xhci->op_regs->config_reg);
-       val |= (val2 & ~HCS_SLOTS_MASK);
-       xhci_dbg_trace(xhci, trace_xhci_dbg_init,
-                       "// Setting Max device slots reg = 0x%x.", val);
-       writel(val, &xhci->op_regs->config_reg);
-
        /*
         * xHCI section 5.4.6 - Device Context array must be
         * "physically contiguous and 64-byte (cache line) aligned".
index b073e9d916651ea8e6903311b6804cafdb420a5b..ec0a2fa7d0034165603c24f5466dc91d1e8f4a56 100644 (file)
@@ -477,6 +477,24 @@ static void xhci_hcd_page_size(struct xhci_hcd *xhci)
                       xhci->page_size >> 10);
 }
 
+static void xhci_enable_max_dev_slots(struct xhci_hcd *xhci)
+{
+       u32 config_reg;
+       u32 max_slots;
+
+       max_slots = HCS_MAX_SLOTS(xhci->hcs_params1);
+       xhci_dbg_trace(xhci, trace_xhci_dbg_init, "xHC can handle at most %d device slots",
+                      max_slots);
+
+       config_reg = readl(&xhci->op_regs->config_reg);
+       config_reg &= ~HCS_SLOTS_MASK;
+       config_reg |= max_slots;
+
+       xhci_dbg_trace(xhci, trace_xhci_dbg_init, "Setting Max device slots reg = 0x%x",
+                      config_reg);
+       writel(config_reg, &xhci->op_regs->config_reg);
+}
+
 /*
  * Initialize memory for HCD and xHC (one-time init).
  *
@@ -502,6 +520,9 @@ static int xhci_init(struct usb_hcd *hcd)
        if (retval)
                return retval;
 
+       /* Set the Number of Device Slots Enabled to the maximum supported value */
+       xhci_enable_max_dev_slots(xhci);
+
        /* Initializing Compliance Mode Recovery Data If Needed */
        if (xhci_compliance_mode_recovery_timer_quirk_check()) {
                xhci->quirks |= XHCI_COMP_MODE_QUIRK;