Skip to contentSkip to conversation

Driver for new PCI-e device

RFC PATCH In review Keith Busch 3 participants 6 messages Aug 27, 2015 – Aug 29, 2015

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

cover Driver for new PCI-e device

The Intel Volume Management Device (VMD) is an integrated endpoint on the platform's PCIe root complex that acts as a host bridge to a secondary PCIe domain. BIOS can reassign one or more root ports to appear within VMD domains instead of the primary domain. This driver enables and enumerates the VMD domain using the root bus configuration interface provided by the PCI subsystem.

Keith Busch (2):
x86: PCI bus specific MSI operations x86/pci: Initial commit for new VMD device driver

 arch/x86/Kconfig           |   11 ++
 arch/x86/include/asm/pci.h |    3 +
 arch/x86/kernel/x86_init.c |   19 ++
 arch/x86/pci/Makefile      |    2 +
 arch/x86/pci/vmd.c         |  412 ++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 447 insertions(+)
 create mode 100644 arch/x86/pci/vmd.c
Signature · 1 line
1.7.10.4
#1 lore raw

RFC PATCH 1/2 x86: PCI bus specific MSI operations

This patch adds struct x86_msi_ops to x86's PCI sysdata. This gives a host bridge driver the option to provide alternate MSI Data Register and MSI-X Table Entry programming for devices in PCI domains that do not subscribe to usual "IOAPIC" format.

---
 arch/x86/include/asm/pci.h |    3 +++
 arch/x86/kernel/x86_init.c |   19 +++++++++++++++++++
 2 files changed, 22 insertions(+)
arch/x86/include/asm/pci.h +3 -0
index 4625943..98f3802 100644
@@ -20,6 +20,9 @@ struct pci_sysdata {
 #ifdef CONFIG_X86_64
 	void		*iommu;		/* IOMMU private data */
 #endif
+#ifdef CONFIG_PCI_MSI
+	struct x86_msi_ops *msi_ops;
+#endif
 };
 
 extern int pci_routeirq;
arch/x86/kernel/x86_init.c +19 -0
index 3839628..416de84 100644
@@ -118,21 +118,40 @@ struct x86_msi_ops x86_msi = {
 /* MSI arch specific hooks */
 int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
 {
+	struct pci_sysdata *sysdata = dev->bus->sysdata;
+
+	if (sysdata && sysdata->msi_ops && sysdata->msi_ops->setup_msi_irqs)
+		return sysdata->msi_ops->setup_msi_irqs(dev, nvec, type);
 	return x86_msi.setup_msi_irqs(dev, nvec, type);
 }
 
 void arch_teardown_msi_irqs(struct pci_dev *dev)
 {
+	struct pci_sysdata *sysdata = dev->bus->sysdata;
+
+	if (sysdata && sysdata->msi_ops && sysdata->msi_ops->teardown_msi_irqs)
+		return sysdata->msi_ops->teardown_msi_irqs(dev);
 	x86_msi.teardown_msi_irqs(dev);
 }
 
 void arch_teardown_msi_irq(unsigned int irq)
 {
+	struct msi_desc *desc =  irq_get_msi_desc(irq);
+	struct pci_sysdata *sysdata = NULL;
+
+	if (desc)
+		sysdata = desc->dev->bus->sysdata;
+	if (sysdata && sysdata->msi_ops && sysdata->msi_ops->teardown_msi_irq)
+		return sysdata->msi_ops->teardown_msi_irq(irq);
 	x86_msi.teardown_msi_irq(irq);
 }
 
 void arch_restore_msi_irqs(struct pci_dev *dev)
 {
+	struct pci_sysdata *sysdata = dev->bus->sysdata;
+
+	if (sysdata && sysdata->msi_ops && sysdata->msi_ops->restore_msi_irqs)
+		return sysdata->msi_ops->restore_msi_irqs(dev);
 	x86_msi.restore_msi_irqs(dev);
 }
 #endif
Signature · 1 line
1.7.10.4
#2 lore raw

Re: [RFC PATCH 1/2] x86: PCI bus specific MSI operations

Quoted 4 lines · Keith Busch

This patch adds struct x86_msi_ops to x86's PCI sysdata. This gives a host bridge driver the option to provide alternate MSI Data Register and MSI-X Table Entry programming for devices in PCI domains that do not subscribe to usual "IOAPIC" format.

I'm not too fond about more ad hoc indirection and special casing. We should be able to handle this with hierarchical irq domains. Jiang might have an idea how to do that for your case.

Thanks,

tglx

#3 lore raw

Re: [RFC PATCH 1/2] x86: PCI bus specific MSI operations

Quoted 10 lines · Thomas Gleixner
Quoted 4 lines · Keith Busch

This patch adds struct x86_msi_ops to x86's PCI sysdata. This gives a host bridge driver the option to provide alternate MSI Data Register and MSI-X Table Entry programming for devices in PCI domains that do not subscribe to usual "IOAPIC" format.

I'm not too fond about more ad hoc indirection and special casing. We should be able to handle this with hierarchical irq domains. Jiang might have an idea how to do that for your case.

Thank you for the suggestion, I will take a closer look at this again. All the better if we don't require an arch specific dependency.

I asked Jiang about domain hierarchies a few weeks ago and understood these are suited for irq controllers, but the VMD device is an aggregator.

Here's a little more h/w info in case it helps steer me in the right
direction: VMD muxes all the device interrupts in its PCI domain into one of several VMD h/w irqs. The VMD driver then has to de-mux that into CPU side irqs for each device.

#4 lore raw

Re: [RFC PATCH 1/2] x86: PCI bus specific MSI operations

In reply to Thomas Gleixner
Quoted 10 lines · Thomas Gleixner
Quoted 4 lines · Keith Busch

This patch adds struct x86_msi_ops to x86's PCI sysdata. This gives a host bridge driver the option to provide alternate MSI Data Register and MSI-X Table Entry programming for devices in PCI domains that do not subscribe to usual "IOAPIC" format.

I'm not too fond about more ad hoc indirection and special casing. We should be able to handle this with hierarchical irq domains. Jiang might have an idea how to do that for your case.

Hi Thomas and Keith,
I have noticed this patch set yesterday, but still investigating the
better way to handle this. Basically I think
we should build per-domain/per-bus/per-device PCI MSI irqdomain, just like what ARM have done. That will give us a clear picture. But I need more information about the hardware topology
to correctly build up the hierarchical irqdomain, especially the relationship between the embedded host bridge and IOMMU units.
Keith, could you please help to provide some doc with
hardware details?
Thanks!
Gerry

#5 lore raw

RFC PATCH 2/2 x86/pci: Initial commit for new VMD device driver

In reply to Keith Busch

The Intel Volume Management Device (VMD) is an integrated endpoint on the platform's PCIe root complex that acts as a host bridge to a secondary PCIe domain. BIOS can reassign one or more root ports to appear within the VMD domain instead of the primary domain.

This driver enumerates and enables the domain using the root bus configuration interface provided by the PCI subsystem. The driver provides configuration space accessor functions (pci_ops), bus and memory resources, MSI configuration functions, and irq_chip implementation necessary to support the domain through the VMD endpoint's interface.

VMD routes I/O as follows:

1) Configuration Space: BAR 0 ("CFGBAR") of VMD provides the base address and size for configuration space register access to VMD-owned root ports. It works similarly to MMCONFIG for extended configuration space. Bus numbering is independent and does not conflict with the primary domain.

2) MMIO Space: BARs 2 and 4 ("MEMBAR1" and "MEMBAR2") of VMD provide the base address, size, and type for MMIO register access. These addresses are not translated by VMD hardware; they are simply reservations to be distributed to root ports' memory base/limit registers and subdivided among devices downstream.

3) DMA: To interact appropriately with IOMMU, the source ID DMA read and write requests are translated to the bus-device-function of the VMD endpoint. Otherwise, DMA operates normally without VMD-specific address translation.

4) Interrupts: Part of VMD's BAR 4 is reserved for VMD's MSI-X Table and PBA. MSIs from VMD domain devices and ports are remapped to appear if they were issued using one of VMD's MSI-X table entries. Each MSI and MSI-X addresses of VMD-owned devices and ports have a special format where the address refers specific entries in VMD's MSI-X table. As with DMA, the interrupt source id is translated to VMD's bus-device-function.

The driver provides its own MSI and MSI-X configuration functions specific to how MSi messages are used within the VMD domain, and it provides an irq_chip for indepdent IRQ allocation and to relay interrupts from VMD's interrupt handler to the appropriate device driver's handler.

5) Errors: PCIe error message are intercepted by the root ports normally (e.g. AER), except with VMD, system errors (i.e. firmware first) are disabled by default. AER and hotplug interrupts are translated in the same way as endpoint interrupts.

6) VMD does not support INTx interrupts or IO ports. Devices or drivers requiring these features should either not be placed below VMD-owned root ports, or VMD should be disabled by BIOS for such enpdoints.

Contributers to this patch include:

Artur Paszkiewicz <[email protected]>
Bryan Veal <[email protected]>
Jon Derrick <[email protected]>

---
 arch/x86/Kconfig      |   11 ++
 arch/x86/pci/Makefile |    2 +
 arch/x86/pci/vmd.c    |  412 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 425 insertions(+)
 create mode 100644 arch/x86/pci/vmd.c
arch/x86/Kconfig +11 -0
index b3a1a5d..a8cad59 100644
@@ -2584,6 +2584,17 @@ config PMC_ATOM
 	def_bool y
         depends on PCI
 
+config VMDDEV
+	depends on PCI && PCI_DOMAINS && PCI_MSI
+	tristate "Volume Management Device Driver"
+	default N
+	---help---
+	Adds support for the Intel Volume Manage Device (VMD). VMD is
+	a secondary PCI host bridge that allows PCI Express root ports,
+	and devices attached to them, to be removed from the default PCI
+	domain and placed within the VMD domain. If your system provides
+	one of these, and you have devices attached to it, say "Y".
+
 source "net/Kconfig"
 
 source "drivers/Kconfig"
arch/x86/pci/Makefile +2 -0
index 5c6fc35..c204079 100644
@@ -23,6 +23,8 @@ obj-y				+= bus_numa.o
 obj-$(CONFIG_AMD_NB)		+= amd_bus.o
 obj-$(CONFIG_PCI_CNB20LE_QUIRK)	+= broadcom_bus.o
 
+obj-$(CONFIG_VMDDEV) += vmd.o
+
 ifeq ($(CONFIG_PCI_DEBUG),y)
 EXTRA_CFLAGS += -DDEBUG
 endif
arch/x86/pci/vmd.c new file +412 -0

412 lines not on this page · raw message

Signature · 1 line
1.7.10.4