usb: xhci: move enabling of USB 3 device notifications
authorNiklas Neronin <niklas.neronin@linux.intel.com>
Thu, 15 May 2025 13:56:06 +0000 (16:56 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 21 May 2025 10:35:32 +0000 (12:35 +0200)
Relocated the enabling of USB 3.0 device notifications from xhci_mem_init()
to xhci_init(). Introduced xhci_set_dev_notifications() function to handle
the notification settings.

Simplify 'DEV_NOTE_FWAKE' masks by directly using the 'ENABLE_DEV_NOTE'
value (1 << 1) instead of using the 'ENABLE_DEV_NOTE' macro.
Macro 'ENABLE_DEV_NOTE' is removed.

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-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
drivers/usb/host/xhci.h

index 2f4dbb67b1bf037c3a9bdad9f100d3ca9aa960f6..718354bd7fb26ea7db7b27e10b28ad77c3dbe843 100644 (file)
@@ -2419,7 +2419,6 @@ 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;
-       u32             temp;
 
        /*
         * xHCI section 5.4.6 - Device Context array must be
@@ -2515,15 +2514,6 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
        if (xhci_setup_port_arrays(xhci, flags))
                goto fail;
 
-       /* Enable USB 3.0 device notifications for function remote wake, which
-        * is necessary for allowing USB 3.0 devices to do remote wakeup from
-        * U3 (device suspend).
-        */
-       temp = readl(&xhci->op_regs->dev_notification);
-       temp &= ~DEV_NOTE_MASK;
-       temp |= DEV_NOTE_FWAKE;
-       writel(temp, &xhci->op_regs->dev_notification);
-
        return 0;
 
 fail:
index 0639d8b7372b2c3e80e5d699c288b88751f2725d..fa80cc30c3fe769cd263f21da74edd408a814bf6 100644 (file)
@@ -524,6 +524,20 @@ static void xhci_set_doorbell_ptr(struct xhci_hcd *xhci)
                       "Doorbell array is located at offset 0x%x from cap regs base addr", offset);
 }
 
+/*
+ * Enable USB 3.0 device notifications for function remote wake, which is necessary
+ * for allowing USB 3.0 devices to do remote wakeup from U3 (device suspend).
+ */
+static void xhci_set_dev_notifications(struct xhci_hcd *xhci)
+{
+       u32 dev_notf;
+
+       dev_notf = readl(&xhci->op_regs->dev_notification);
+       dev_notf &= ~DEV_NOTE_MASK;
+       dev_notf |= DEV_NOTE_FWAKE;
+       writel(dev_notf, &xhci->op_regs->dev_notification);
+}
+
 /*
  * Initialize memory for HCD and xHC (one-time init).
  *
@@ -561,6 +575,9 @@ static int xhci_init(struct usb_hcd *hcd)
        /* Set Doorbell array pointer */
        xhci_set_doorbell_ptr(xhci);
 
+       /* Set USB 3.0 device notifications for function remote wake */
+       xhci_set_dev_notifications(xhci);
+
        /* Initializing Compliance Mode Recovery Data If Needed */
        if (xhci_compliance_mode_recovery_timer_quirk_check()) {
                xhci->quirks |= XHCI_COMP_MODE_QUIRK;
index 6c1758f8fd012dfde8c58c722fb9d65a69499dfb..31d945c4ac073572522b1e91e6e690b439abd1c4 100644 (file)
@@ -184,11 +184,10 @@ struct xhci_op_regs {
  * notification type that matches a bit set in this bit field.
  */
 #define        DEV_NOTE_MASK           (0xffff)
-#define ENABLE_DEV_NOTE(x)     (1 << (x))
 /* Most of the device notification types should only be used for debug.
  * SW does need to pay attention to function wake notifications.
  */
-#define        DEV_NOTE_FWAKE          ENABLE_DEV_NOTE(1)
+#define        DEV_NOTE_FWAKE          (1 << 1)
 
 /* CRCR - Command Ring Control Register - cmd_ring bitmasks */
 /* bit 0 - Cycle bit indicates the ownership of the command ring */