Skip to contentSkip to conversation

Create pci slot files for SMBIOS Type 9 entries

PATCH In review [email protected] 3 participants 4 messages Feb 18, 2016 – Apr 13, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 Create pci slot files for SMBIOS Type 9 entries

The following diff builds on the "[PATCHv3] Save SMBIOS Type 9 System Slots"

This will create a /sys/bus/pci/slots/XXX file for each Type 9 entry. This will be \
used for systemd enumeration of NICs.

Only build if CONFIG_DMI is set

---
 arch/x86/pci/common.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
arch/x86/pci/common.c +21 -0
index eccd4d9..bfa3c85 100644
@@ -173,6 +173,27 @@ void pcibios_fixup_bus(struct pci_bus *b)
 
 void pcibios_add_bus(struct pci_bus *bus)
 {
+#ifdef CONFIG_DMI
+	const struct dmi_device *dmi;
+	struct dmi_dev_onboard *dslot;
+	char sname[128];
+
+	dmi = NULL;
+	while ((dmi = dmi_find_device(DMI_DEV_TYPE_DEV_SLOT,
+				      NULL, dmi)) != NULL) {
+		dslot = dmi->device_data;
+		if (dslot->segment == pci_domain_nr(bus) &&
+		    dslot->bus == bus->number) {
+			dev_info(&bus->dev, "Found SMBIOS Slot %s\n",
+				 dslot->dev.name);
+			snprintf(sname, sizeof(sname), "%s-%d",
+				 dslot->dev.name,
+				 dslot->instance);
+			pci_create_slot(bus, dslot->devfn,
+					sname, NULL);
+		}
+	}
+#endif
 	acpi_pci_add_bus(bus);
 }
 
Signature · 10 lines
2.5.0






 
--jordan hargrave
 Dell Enterprise Linux Engineering  
#1 lore raw

Hi Jordan,

Quoted 31 lines · On Thu, Feb 18, 2016 at 08:40:32PM +0000, [email protected] wrote:

The following diff builds on the "[PATCHv3] Save SMBIOS Type 9 System Slots"

This will create a /sys/bus/pci/slots/XXX file for each Type 9 entry. This will be \
used for systemd enumeration of NICs.

Only build if CONFIG_DMI is set

---
 arch/x86/pci/common.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
arch/x86/pci/common.c +11 -0
index eccd4d9..bfa3c85 100644
@@ -173,6 +173,27 @@ void pcibios_fixup_bus(struct pci_bus *b)
 
 void pcibios_add_bus(struct pci_bus *bus)
 {
+#ifdef CONFIG_DMI
+	const struct dmi_device *dmi;
+	struct dmi_dev_onboard *dslot;
+	char sname[128];
+
+	dmi = NULL;
+	while ((dmi = dmi_find_device(DMI_DEV_TYPE_DEV_SLOT,
+				      NULL, dmi)) != NULL) {
+		dslot = dmi->device_data;
+		if (dslot->segment == pci_domain_nr(bus) &&
+		    dslot->bus == bus->number) {

arch/x86/pci/common.c void pcibios_fixup_bus(struct pci_bus *b) · line 196

Quoted 10 lines
arch/x86/pci/common.c +10 -0
+			dev_info(&bus->dev, "Found SMBIOS Slot %s\n",
+				 dslot->dev.name);
+			snprintf(sname, sizeof(sname), "%s-%d",
+				 dslot->dev.name,
+				 dslot->instance);
+			pci_create_slot(bus, dslot->devfn,
+					sname, NULL);
+		}
+	}
+#endif

arm64, ia64, and x86 all support CONFIG_DMI, so this would have to be a bit more generic.

Is there a spec that describes this SMBIOS entry? It seems to have segment/bus/devfn, so maybe this should be done on a per-device basis, not a per-bus basis?

Does this do the same thing ctrl_slot_setup() does with get_SMBIOS_entry()? (This is in the cpqphp hotplug driver; I have no idea if anybody still uses that.)

There's quite a collection of pci_create_slot() callers, and I'd like to know how this new addition would coexist with the others. In particular, what about the one in pciehp? I think we only expose a slot name in sysfs if pciehp claims a downstream port, but I'm not sure that's the right thing. The slot number might be useful even if the slot doesn't support hotplug or if hotplug is disabled for some reason.

Quoted 17 lines
arch/x86/pci/common.c +0 -0
 	acpi_pci_add_bus(bus);
 }
 
Signature · 13 lines
2.5.0






 
--jordan hargrave
 Dell Enterprise Linux Engineering  --
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw
Quoted 39 lines · Bjorn Helgaas

Hi Jordan,

Quoted 36 lines · On Thu, Feb 18, 2016 at 08:40:32PM +0000, [email protected] wrote:

The following diff builds on the "[PATCHv3] Save SMBIOS Type 9 System Slots"

This will create a /sys/bus/pci/slots/XXX file for each Type 9 entry. This will be \
used for systemd enumeration of NICs.

Only build if CONFIG_DMI is set

---
 arch/x86/pci/common.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
arch/x86/pci/common.c +16 -0
index eccd4d9..bfa3c85 100644
@@ -173,6 +173,27 @@ void pcibios_fixup_bus(struct pci_bus *b)
 
 void pcibios_add_bus(struct pci_bus *bus)
 {
+#ifdef CONFIG_DMI
+     const struct dmi_device *dmi;
+     struct dmi_dev_onboard *dslot;
+     char sname[128];
+
+     dmi = NULL;
+     while ((dmi = dmi_find_device(DMI_DEV_TYPE_DEV_SLOT,
+                                   NULL, dmi)) != NULL) {
+             dslot = dmi->device_data;
+             if (dslot->segment == pci_domain_nr(bus) &&
+                 dslot->bus == bus->number) {
+                     dev_info(&bus->dev, "Found SMBIOS Slot %s\n",
+                              dslot->dev.name);
+                     snprintf(sname, sizeof(sname), "%s-%d",
+                              dslot->dev.name,
+                              dslot->instance);
Quoted 8 lines

arch/x86/pci/common.c void pcibios_fixup_bus(struct pci_bus *b) · line 196

Quoted 5 lines
arch/x86/pci/common.c +5 -0
+                     pci_create_slot(bus, dslot->devfn,
+                                     sname, NULL);
+             }
+     }
+#endif

arm64, ia64, and x86 all support CONFIG_DMI, so this would have to be a bit more generic.

The SMBIOS tables for DMI_DEV_TYPE_DEV_SLOT are scanned in firmware/dmi_scan.c which requires CONFIG_DMI

Quoted 5 lines

Is there a spec that describes this SMBIOS entry? It seems to have segment/bus/devfn, so maybe this should be done on a per-device basis, not a per-bus basis?

Yes, the SMBIOS specification for Type 9 System Slots. The fields for PCI mapping were added in SMBIOS 2.6

https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.0.0.pdf

Quoted 3 lines

Does this do the same thing ctrl_slot_setup() does with get_SMBIOS_entry()? (This is in the cpqphp hotplug driver; I have no idea if anybody still uses that.)

Looks like cpqphp driver is looking for SMBIOS Type 9, but < 2.5 table structure. It's looking for the slot ID number (this number is equivalent to dslot->instance).

Quoted 9 lines

There's quite a collection of pci_create_slot() callers, and I'd like to know how this new addition would coexist with the others. In particular, what about the one in pciehp? I think we only expose a slot name in sysfs if pciehp claims a downstream port, but I'm not sure that's the right thing. The slot number might be useful even if the slot doesn't support hotplug or if hotplug is disabled for some reason.

pciehp requires the BIOS has setup the slot number in PCI properly.... I've seen systems with two PCIE 'slots' which had the same slot number. Of course the SMBIOS table requires the BIOS got it right too....

Quoted 17 lines
Quoted 17 lines
arch/x86/pci/common.c +0 -1
      acpi_pci_add_bus(bus);
 }
 
--

2.5.0

--jordan hargrave
Dell Enterprise Linux Engineering --
To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
Quoted 49 lines · Jordan Hargrave
Quoted 39 lines · Bjorn Helgaas

Hi Jordan,

Quoted 36 lines · On Thu, Feb 18, 2016 at 08:40:32PM +0000, [email protected] wrote:

The following diff builds on the "[PATCHv3] Save SMBIOS Type 9 System Slots"

This will create a /sys/bus/pci/slots/XXX file for each Type 9 entry. This will be \
used for systemd enumeration of NICs.

Only build if CONFIG_DMI is set

---
 arch/x86/pci/common.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
arch/x86/pci/common.c +16 -0
index eccd4d9..bfa3c85 100644
@@ -173,6 +173,27 @@ void pcibios_fixup_bus(struct pci_bus *b)
 
 void pcibios_add_bus(struct pci_bus *bus)
 {
+#ifdef CONFIG_DMI
+     const struct dmi_device *dmi;
+     struct dmi_dev_onboard *dslot;
+     char sname[128];
+
+     dmi = NULL;
+     while ((dmi = dmi_find_device(DMI_DEV_TYPE_DEV_SLOT,
+                                   NULL, dmi)) != NULL) {
+             dslot = dmi->device_data;
+             if (dslot->segment == pci_domain_nr(bus) &&
+                 dslot->bus == bus->number) {
+                     dev_info(&bus->dev, "Found SMBIOS Slot %s\n",
+                              dslot->dev.name);
+                     snprintf(sname, sizeof(sname), "%s-%d",
+                              dslot->dev.name,
+                              dslot->instance);
Quoted 8 lines

arch/x86/pci/common.c void pcibios_fixup_bus(struct pci_bus *b) · line 196

Quoted 5 lines
arch/x86/pci/common.c +5 -0
+                     pci_create_slot(bus, dslot->devfn,
+                                     sname, NULL);
+             }
+     }
+#endif

arm64, ia64, and x86 all support CONFIG_DMI, so this would have to be a bit more generic.

Quoted 2 lines

The SMBIOS tables for DMI_DEV_TYPE_DEV_SLOT are scanned in firmware/dmi_scan.c which requires CONFIG_DMI

Right. My point is that arm64, ia64, and x86 can all have SMBIOS tables, but the code you're adding to parse them and add sysfs info is only for x86. If we're going to do this, we should do it for all arches that support SMBIOS, not just x86.

Quoted 9 lines
Quoted 4 lines

Is there a spec that describes this SMBIOS entry? It seems to have segment/bus/devfn, so maybe this should be done on a per-device basis, not a per-bus basis?

Yes, the SMBIOS specification for Type 9 System Slots. The fields for PCI mapping were added in SMBIOS 2.6

https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.0.0.pdf

Thanks. Let's include that link in the changelog of the next iteration.

Quoted 19 lines
Quoted 3 lines

Does this do the same thing ctrl_slot_setup() does with get_SMBIOS_entry()? (This is in the cpqphp hotplug driver; I have no idea if anybody still uses that.)

Looks like cpqphp driver is looking for SMBIOS Type 9, but < 2.5 table structure. It's looking for the slot ID number (this number is equivalent to dslot->instance).

Quoted 9 lines

There's quite a collection of pci_create_slot() callers, and I'd like to know how this new addition would coexist with the others. In particular, what about the one in pciehp? I think we only expose a slot name in sysfs if pciehp claims a downstream port, but I'm not sure that's the right thing. The slot number might be useful even if the slot doesn't support hotplug or if hotplug is disabled for some reason.

Quoted 4 lines

pciehp requires the BIOS has setup the slot number in PCI properly.... I've seen systems with two PCIE 'slots' which had the same slot number. Of course the SMBIOS table requires the BIOS got it right too....

I don't know what the answer is; I'm just trying to make the point that we have several sources of slot information, the process of exposing that via sysfs is already a bit messy, and adding more from SMBIOS will only make it messier. So I'd like to have a better understanding of how it all works.

The slot info from the PCIe capability is not necessarily unique, even if the BIOS gets everything right. If you hot-add a PCIe expansion chassis, BIOS isn't involved in setting up those new slots, so the PCIe slot capability probably contains slot numbers hardwired into the chassis.

Bjorn