]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
PCI: Make early dump functionality generic
authorSinan Kaya <okaya@codeaurora.org>
Tue, 5 Jun 2018 02:16:09 +0000 (22:16 -0400)
committerBjorn Helgaas <helgaas@kernel.org>
Sat, 30 Jun 2018 01:06:07 +0000 (20:06 -0500)
Move early dump functionality into common code so that it is available for
all architectures.  No need to carry arch-specific reads around as the read
hooks are already initialized by the time pci_setup_device() is getting
called during scan.

Tested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Sinan Kaya <okaya@codeaurora.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Documentation/admin-guide/kernel-parameters.txt
arch/x86/include/asm/pci-direct.h
arch/x86/kernel/setup.c
arch/x86/pci/common.c
arch/x86/pci/early.c
drivers/pci/pci.c
drivers/pci/pci.h
drivers/pci/probe.c

index efc7aa7a067099f6bacdb860cde13f2d876030a8..f11b9485ed7fd79518d786a3edcd75f8b71ca17c 100644 (file)
                        See also Documentation/blockdev/paride.txt.
 
        pci=option[,option...]  [PCI] various PCI subsystem options:
-               earlydump       [X86] dump PCI config space before the kernel
+               earlydump       dump PCI config space before the kernel
                                changes anything
                off             [X86] don't probe for the PCI bus
                bios            [X86-32] force use of PCI BIOS, don't access
index e1084f71a295d401692db27ac027e3ed2fe47d08..94597a3cf3d0f14fa1e81989437cf43a485d59e0 100644 (file)
@@ -15,8 +15,4 @@ extern void write_pci_config_byte(u8 bus, u8 slot, u8 func, u8 offset, u8 val);
 extern void write_pci_config_16(u8 bus, u8 slot, u8 func, u8 offset, u16 val);
 
 extern int early_pci_allowed(void);
-
-extern unsigned int pci_early_dump_regs;
-extern void early_dump_pci_device(u8 bus, u8 slot, u8 func);
-extern void early_dump_pci_devices(void);
 #endif /* _ASM_X86_PCI_DIRECT_H */
index 2f86d883dd9508992adc57fcfcf3e8056554ebde..480f250b3c4fa5d56a7fc33b1d0190771624967a 100644 (file)
@@ -991,11 +991,6 @@ void __init setup_arch(char **cmdline_p)
                setup_clear_cpu_cap(X86_FEATURE_APIC);
        }
 
-#ifdef CONFIG_PCI
-       if (pci_early_dump_regs)
-               early_dump_pci_devices();
-#endif
-
        e820__reserve_setup_data();
        e820__finish_early_params();
 
index 563049c483a12c5fe587e463fb96bff4dde22c5a..d4ec117c1142e0f155be3f3a17f4f675d64f4135 100644 (file)
@@ -22,7 +22,6 @@
 unsigned int pci_probe = PCI_PROBE_BIOS | PCI_PROBE_CONF1 | PCI_PROBE_CONF2 |
                                PCI_PROBE_MMCONF;
 
-unsigned int pci_early_dump_regs;
 static int pci_bf_sort;
 int pci_routeirq;
 int noioapicquirk;
@@ -599,9 +598,6 @@ char *__init pcibios_setup(char *str)
                pci_probe |= PCI_BIG_ROOT_WINDOW;
                return NULL;
 #endif
-       } else if (!strcmp(str, "earlydump")) {
-               pci_early_dump_regs = 1;
-               return NULL;
        } else if (!strcmp(str, "routeirq")) {
                pci_routeirq = 1;
                return NULL;
index e5f753cbb1c3dc2c9a5ade77176dd3669e6a29ab..f5fc953e584832901a6f45cd130f29a321c6b280 100644 (file)
@@ -57,47 +57,3 @@ int early_pci_allowed(void)
                        PCI_PROBE_CONF1;
 }
 
-void early_dump_pci_device(u8 bus, u8 slot, u8 func)
-{
-       u32 value[256 / 4];
-       int i;
-
-       pr_info("pci 0000:%02x:%02x.%d config space:\n", bus, slot, func);
-
-       for (i = 0; i < 256; i += 4)
-               value[i / 4] = read_pci_config(bus, slot, func, i);
-
-       print_hex_dump(KERN_INFO, "", DUMP_PREFIX_OFFSET, 16, 1, value, 256, false);
-}
-
-void early_dump_pci_devices(void)
-{
-       unsigned bus, slot, func;
-
-       if (!early_pci_allowed())
-               return;
-
-       for (bus = 0; bus < 256; bus++) {
-               for (slot = 0; slot < 32; slot++) {
-                       for (func = 0; func < 8; func++) {
-                               u32 class;
-                               u8 type;
-
-                               class = read_pci_config(bus, slot, func,
-                                                       PCI_CLASS_REVISION);
-                               if (class == 0xffffffff)
-                                       continue;
-
-                               early_dump_pci_device(bus, slot, func);
-
-                               if (func == 0) {
-                                       type = read_pci_config_byte(bus, slot,
-                                                                   func,
-                                                              PCI_HEADER_TYPE);
-                                       if (!(type & 0x80))
-                                               break;
-                               }
-                       }
-               }
-       }
-}
index 1b20c4392f09427e1c3bfc3b92df2a462006940a..e1b0bbd05fa32aeb2601b30a515cfb50672b8f11 100644 (file)
@@ -115,6 +115,9 @@ static bool pcie_ari_disabled;
 /* If set, the PCIe ATS capability will not be used. */
 static bool pcie_ats_disabled;
 
+/* If set, the PCI config space of each device is printed during boot. */
+bool pci_early_dump;
+
 bool pci_ats_disabled(void)
 {
        return pcie_ats_disabled;
@@ -5833,6 +5836,8 @@ static int __init pci_setup(char *str)
                                pcie_ats_disabled = true;
                        } else if (!strcmp(str, "noaer")) {
                                pci_no_aer();
+                       } else if (!strcmp(str, "earlydump")) {
+                               pci_early_dump = true;
                        } else if (!strncmp(str, "realloc=", 8)) {
                                pci_realloc_get_opt(str + 8);
                        } else if (!strncmp(str, "realloc", 7)) {
index c358e7a07f3faf2abbfff9de4b9e219ae6558e58..c33265e02c3ae03ab60a55d251feece32e1f77c1 100644 (file)
@@ -7,6 +7,7 @@
 #define PCI_VSEC_ID_INTEL_TBT  0x1234  /* Thunderbolt */
 
 extern const unsigned char pcie_link_speed[];
+extern bool pci_early_dump;
 
 bool pcie_cap_has_lnkctl(const struct pci_dev *dev);
 
index ac876e32de4b0fe4aaebf98209590720375daa50..84034a685f83797f7f0bd78712ef567a3bf1f7ae 100644 (file)
@@ -1549,6 +1549,20 @@ static int pci_intx_mask_broken(struct pci_dev *dev)
        return 0;
 }
 
+static void early_dump_pci_device(struct pci_dev *pdev)
+{
+       u32 value[256 / 4];
+       int i;
+
+       pci_info(pdev, "config space:\n");
+
+       for (i = 0; i < 256; i += 4)
+               pci_read_config_dword(pdev, i, &value[i / 4]);
+
+       print_hex_dump(KERN_INFO, "", DUMP_PREFIX_OFFSET, 16, 1,
+                      value, 256, false);
+}
+
 /**
  * pci_setup_device - Fill in class and map information of a device
  * @dev: the device structure to fill
@@ -1598,6 +1612,9 @@ int pci_setup_device(struct pci_dev *dev)
        pci_printk(KERN_DEBUG, dev, "[%04x:%04x] type %02x class %#08x\n",
                   dev->vendor, dev->device, dev->hdr_type, dev->class);
 
+       if (pci_early_dump)
+               early_dump_pci_device(dev);
+
        /* Need to have dev->class ready */
        dev->cfg_size = pci_cfg_space_size(dev);