Merge tag 'pci-v5.1-fixes-3' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci
authorLinus Torvalds <torvalds@linux-foundation.org>
Thu, 2 May 2019 15:29:24 +0000 (08:29 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 2 May 2019 15:29:24 +0000 (08:29 -0700)
Pull PCI fixes from Bjorn Helgaas:
 "I apologize for sending these so late in the cycle. We went back and
  forth about how to deal with the unexpected logging of intentional
  link state changes and finally decided to just config them off by
  default.

  PCI fixes:

   - Stop ignoring "pci=disable_acs_redir" parameter (Logan Gunthorpe)

   - Use shared MSI/MSI-X vector for Link Bandwidth Management (Alex
     Williamson)

   - Add Kconfig option for Link Bandwidth notification messages (Keith
     Busch)"

* tag 'pci-v5.1-fixes-3' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci:
  PCI/LINK: Add Kconfig option (default off)
  PCI/portdrv: Use shared MSI/MSI-X vector for Bandwidth Management
  PCI: Fix issue with "pci=disable_acs_redir" parameter being ignored

drivers/pci/pci.c
drivers/pci/pcie/Kconfig
drivers/pci/pcie/Makefile
drivers/pci/pcie/portdrv.h
drivers/pci/pcie/portdrv_core.c

index 7c1b362f599aebc4bbf66acb09fe67fb5d76ea39..766f5779db929fca76738a91df9793fc6af3fedb 100644 (file)
@@ -6262,8 +6262,7 @@ static int __init pci_setup(char *str)
                        } else if (!strncmp(str, "pcie_scan_all", 13)) {
                                pci_add_flags(PCI_SCAN_ALL_PCIE_DEVS);
                        } else if (!strncmp(str, "disable_acs_redir=", 18)) {
-                               disable_acs_redir_param =
-                                       kstrdup(str + 18, GFP_KERNEL);
+                               disable_acs_redir_param = str + 18;
                        } else {
                                printk(KERN_ERR "PCI: Unknown option `%s'\n",
                                                str);
@@ -6274,3 +6273,19 @@ static int __init pci_setup(char *str)
        return 0;
 }
 early_param("pci", pci_setup);
+
+/*
+ * 'disable_acs_redir_param' is initialized in pci_setup(), above, to point
+ * to data in the __initdata section which will be freed after the init
+ * sequence is complete. We can't allocate memory in pci_setup() because some
+ * architectures do not have any memory allocation service available during
+ * an early_param() call. So we allocate memory and copy the variable here
+ * before the init section is freed.
+ */
+static int __init pci_realloc_setup_params(void)
+{
+       disable_acs_redir_param = kstrdup(disable_acs_redir_param, GFP_KERNEL);
+
+       return 0;
+}
+pure_initcall(pci_realloc_setup_params);
index 5cbdbca904ac8e50760abbc4eecf834def9ab875..362eb8cfa53ba040c5ab955a03dd9773bb751ad3 100644 (file)
@@ -142,3 +142,11 @@ config PCIE_PTM
 
          This is only useful if you have devices that support PTM, but it
          is safe to enable even if you don't.
+
+config PCIE_BW
+       bool "PCI Express Bandwidth Change Notification"
+       depends on PCIEPORTBUS
+       help
+         This enables PCI Express Bandwidth Change Notification.  If
+         you know link width or rate changes occur only to correct
+         unreliable links, you may answer Y.
index f1d7bc1e5efae2561fecba886b15a17a17ee5c4b..efb9d2e71e9eecad1bc0298692d166114de5be6a 100644 (file)
@@ -3,7 +3,6 @@
 # Makefile for PCI Express features and port driver
 
 pcieportdrv-y                  := portdrv_core.o portdrv_pci.o err.o
-pcieportdrv-y                  += bw_notification.o
 
 obj-$(CONFIG_PCIEPORTBUS)      += pcieportdrv.o
 
@@ -13,3 +12,4 @@ obj-$(CONFIG_PCIEAER_INJECT)  += aer_inject.o
 obj-$(CONFIG_PCIE_PME)         += pme.o
 obj-$(CONFIG_PCIE_DPC)         += dpc.o
 obj-$(CONFIG_PCIE_PTM)         += ptm.o
+obj-$(CONFIG_PCIE_BW)          += bw_notification.o
index 1d50dc58ac400ae1a325f788ee33352aebf58c09..944827a8c7d363f0066f8002e891a988b11ca565 100644 (file)
@@ -49,7 +49,11 @@ int pcie_dpc_init(void);
 static inline int pcie_dpc_init(void) { return 0; }
 #endif
 
+#ifdef CONFIG_PCIE_BW
 int pcie_bandwidth_notification_init(void);
+#else
+static inline int pcie_bandwidth_notification_init(void) { return 0; }
+#endif
 
 /* Port Type */
 #define PCIE_ANY_PORT                  (~0)
index 7d04f9d087a62a94cf4edd5fdab4749d752f2c4e..1b330129089fea765919e7ae477298473edb843c 100644 (file)
@@ -55,7 +55,8 @@ static int pcie_message_numbers(struct pci_dev *dev, int mask,
         * 7.8.2, 7.10.10, 7.31.2.
         */
 
-       if (mask & (PCIE_PORT_SERVICE_PME | PCIE_PORT_SERVICE_HP)) {
+       if (mask & (PCIE_PORT_SERVICE_PME | PCIE_PORT_SERVICE_HP |
+                   PCIE_PORT_SERVICE_BWNOTIF)) {
                pcie_capability_read_word(dev, PCI_EXP_FLAGS, &reg16);
                *pme = (reg16 & PCI_EXP_FLAGS_IRQ) >> 9;
                nvec = *pme + 1;