Skip to contentSkip to conversation

PCI: move early dump functionality from x86 arch into the common code

PATCH Superseded Sinan Kaya 2 participants 7 messages May 30, 2018 – Jun 1, 2018

Subsystems (4)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Sinan Kaya

author
#0 lore raw

PATCH 1/1 PCI: move early dump functionality from x86 arch into the common code

Move early dump functionality into common code so that it is available for all archtiectures. 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.

---
 Documentation/admin-guide/kernel-parameters.txt |  2 +-
 arch/x86/include/asm/pci-direct.h               |  5 ---
 arch/x86/kernel/setup.c                         |  5 ---
 arch/x86/pci/common.c                           |  4 --
 arch/x86/pci/early.c                            | 50 -------------------------
 drivers/pci/pci.c                               |  4 ++
 drivers/pci/pci.h                               |  2 +-
 drivers/pci/probe.c                             | 19 ++++++++++
 8 files changed, 25 insertions(+), 66 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +1 -1
index c247612..4459270 100644
@@ -2986,7 +2986,7 @@
 			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
arch/x86/include/asm/pci-direct.h +0 -5
index e1084f7..e5e2129 100644
@@ -14,9 +14,4 @@ extern void write_pci_config(u8 bus, u8 slot, u8 func, u8 offset, u32 val);
 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 */
arch/x86/kernel/setup.c +0 -5
index 2f86d88..480f250 100644
@@ -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();
 
arch/x86/pci/common.c +0 -4
index 563049c..d4ec117 100644
@@ -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;
arch/x86/pci/early.c +0 -50

53 lines not on this page · raw message

drivers/pci/pci.c +4 -0
index 7c03701..ae5a2ae 100644
@@ -115,6 +115,8 @@ static bool pcie_ari_disabled;
 /* If set, the PCIe ATS capability will not be used. */
 static bool pcie_ats_disabled;
 
+bool pci_early_dump;
+
 bool pci_ats_disabled(void)
 {
 	return pcie_ats_disabled;
@@ -5848,6 +5850,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)) {
drivers/pci/pci.h +1 -1
index c358e7a0..9c66b7d 100644
@@ -7,7 +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);
 
 /* Functions internal to the PCI core code */
drivers/pci/probe.c +19 -0
index 3840207..b1f068d 100644
@@ -1549,6 +1549,22 @@ 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;
+
+	dev_info(&pdev->dev, "pci 0000:%02x:%02x.%d config space:\n",
+		 pdev->bus->number, PCI_SLOT(pdev->devfn),
+		 PCI_FUNC(pdev->devfn));
+
+	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 +1614,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);
 
Signature · 1 line
2.7.4
author
#1 lore raw

arch/x86/pci/early.c void write_pci_config_16(u8 bus, u8 slot, u8 func, u8 offset, u16 val) · line 58

Quoted 5 lines · Sinan Kaya
arch/x86/pci/early.c +0 -5
-int early_pci_allowed(void)
-{
-	return (pci_probe & (PCI_PROBE_CONF1|PCI_PROBE_NOEARLY)) ==
-			PCI_PROBE_CONF1;
-}

I should have kept this. I'll wait for more feedback before posting the next rev.

Signature · 3 lines
Sinan Kaya
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
author
#2 lore raw
In reply to Sinan Kaya
Quoted 6 lines · Sinan Kaya

Move early dump functionality into common code so that it is available for all archtiectures. 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.

Quoted 10 lines
---
 Documentation/admin-guide/kernel-parameters.txt |  2 +-
 arch/x86/include/asm/pci-direct.h               |  5 ---
 arch/x86/kernel/setup.c                         |  5 ---
 arch/x86/pci/common.c                           |  4 --
 arch/x86/pci/early.c                            | 50 -------------------------
 drivers/pci/pci.c                               |  4 ++
 drivers/pci/pci.h                               |  2 +-
 drivers/pci/probe.c                             | 19 ++++++++++
 8 files changed, 25 insertions(+), 66 deletions(-)

Any feedback on the direction?

Signature · 3 lines
Sinan Kaya
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
#3 lore raw
In reply to Sinan Kaya

drivers/pci/pci.c static bool pcie_ari_disabled; · line 119

Quoted 10 lines · Sinan Kaya

Move early dump functionality into common code so that it is available for all archtiectures. 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.

/* If set, the PCIe ATS capability will not be used. */ static bool pcie_ats_disabled;

drivers/pci/pci.c +2 -0
+bool pci_early_dump;
+

I didn't check above these, but maybe a good idea to add one line comment what is this about?

drivers/pci/pci.h line 11

Quoted 5 lines

extern const unsigned char pcie_link_speed[];

drivers/pci/pci.h +1 -1
-
+extern bool pci_early_dump;
 bool pcie_cap_has_lnkctl(const struct pci_dev *dev);

Hmm... I would rather not attach this line to some function declarations.

drivers/pci/probe.c static int pci_intx_mask_broken(struct pci_dev *dev) · line 1559

Quoted 8 lines
drivers/pci/probe.c +8 -0
+static void early_dump_pci_device(struct pci_dev *pdev)
+{
+       u32 value[256 / 4];
+       int i;
+
+       dev_info(&pdev->dev, "pci 0000:%02x:%02x.%d config space:\n",
+                pdev->bus->number, PCI_SLOT(pdev->devfn),
+                PCI_FUNC(pdev->devfn));

Shouldn't be this changed to pci_info() ?

Quoted 7 lines
drivers/pci/probe.c +7 -0
+
+       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);
+}
Signature · 2 lines
With Best Regards,
Andy Shevchenko
author
#4 lore raw
Quoted 6 lines · Andy Shevchenko
Quoted 4 lines · Sinan Kaya

Move early dump functionality into common code so that it is available for all archtiectures. 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.

Quoted 8 lines

drivers/pci/pci.c static bool pcie_ari_disabled; · line 119

Quoted 5 lines

/* If set, the PCIe ATS capability will not be used. */ static bool pcie_ats_disabled;

drivers/pci/pci.c +2 -0
+bool pci_early_dump;
+

I didn't check above these, but maybe a good idea to add one line comment what is this about?

This was discussed here:

https://www.spinics.net/lists/linux-pci/msg72859.html

Quoted 9 lines

drivers/pci/pci.h line 11

Quoted 7 lines

extern const unsigned char pcie_link_speed[];

drivers/pci/pci.h +1 -1
-
+extern bool pci_early_dump;
 bool pcie_cap_has_lnkctl(const struct pci_dev *dev);

Hmm... I would rather not attach this line to some function declarations.

Sure

Quoted 11 lines

drivers/pci/probe.c static int pci_intx_mask_broken(struct pci_dev *dev) · line 1559

Quoted 9 lines
drivers/pci/probe.c +8 -0
+static void early_dump_pci_device(struct pci_dev *pdev)
+{
+       u32 value[256 / 4];
+       int i;
+
+       dev_info(&pdev->dev, "pci 0000:%02x:%02x.%d config space:\n",
+                pdev->bus->number, PCI_SLOT(pdev->devfn),
+                PCI_FUNC(pdev->devfn));

Shouldn't be this changed to pci_info() ?

Yeah, I need to get used to pci_info().

Quoted 9 lines
Quoted 8 lines
drivers/pci/probe.c +7 -0
+
+       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);
+}
Signature · 3 lines
Sinan Kaya
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
#5 lore raw
Quoted 16 lines · Sinan Kaya
Quoted 6 lines · Andy Shevchenko
Quoted 4 lines · Sinan Kaya

Move early dump functionality into common code so that it is available for all archtiectures. 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.

Quoted 8 lines

drivers/pci/pci.c static bool pcie_ari_disabled; · line 119

Quoted 5 lines

/* If set, the PCIe ATS capability will not be used. */ static bool pcie_ats_disabled;

drivers/pci/pci.c +2 -0
+bool pci_early_dump;
+

I didn't check above these, but maybe a good idea to add one line comment what is this about?

Quoted 3 lines

This was discussed here:

https://www.spinics.net/lists/linux-pci/msg72859.html

I understand what is it. What I'm pointing is the variable in the source without any comment. In the context you have in diff previous one has a comment.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author
#6 lore raw
Quoted 6 lines · Andy Shevchenko
Quoted 3 lines

This was discussed here:

https://www.spinics.net/lists/linux-pci/msg72859.html

I understand what is it. What I'm pointing is the variable in the source without any comment. In the context you have in diff previous one has a comment.

oh, ok. I can take care of that too.

Signature · 3 lines
Sinan Kaya
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.