Skip to contentSkip to conversation

Driver for new "VMD" device

PATCH Superseded Keith Busch 3 participants 5 messages Jan 12, 2016

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

PATCH v8 1/1 Driver for new "VMD" device

This is just the commit for the VMD driver. The other patches are the same from previous series here:

https://lkml.org/lkml/2015/12/21/353

Patch 2/6 is no longer applicable since someone already beat me to exporting those functions to API in commit a4289dc2ec3a5. Otherwise the others are still needed and cleanly apply. I wasn't sure if I should repost the entire series or just the one file that changed.

Changes since v7 are all checkpatch fixes:

Fixing 80 character lines.

Spacing, tabbing and new line fixes.

A macro semicolon fix.

An entry in the MAINTAINERS file.

The only checkpatch issue reported is warning on a normally "const" struct, but the warning is not applicable for the usage.

Keith Busch (1):
x86/PCI: Initial commit for new VMD device driver

 MAINTAINERS                   |   6 +
 arch/x86/Kconfig              |  13 +
 arch/x86/include/asm/hw_irq.h |   5 +
 arch/x86/pci/Makefile         |   2 +
 arch/x86/pci/vmd.c            | 699 ++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 725 insertions(+)
 create mode 100644 arch/x86/pci/vmd.c
Signature · 1 line
2.6.2.307.g37023ba
#1 lore raw

PATCH v8 1/1 x86/PCI: Initial commit for new VMD device driver

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 a VMD domain instead of the primary domain. The immediate benefit is that additional PCI-e domains allow more than 256 buses in a system by letting bus number be reused across different domains.

VMD domains do not define ACPI _SEG, so to avoid domain clashing with host bridges defining this segment, VMD domains start at 0x10000 which is greater than the highest possible 16-bit ACPI defined _SEG.

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, an MSI irq domain with irq_chip implementation, and dma operations necessary to use devices in 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 to 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 provides an irq_chip for independent IRQ allocation 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 endpoints.

---
 MAINTAINERS                   |   6 +
 arch/x86/Kconfig              |  13 +
 arch/x86/include/asm/hw_irq.h |   5 +
 arch/x86/pci/Makefile         |   2 +
 arch/x86/pci/vmd.c            | 699 ++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 725 insertions(+)
 create mode 100644 arch/x86/pci/vmd.c
MAINTAINERS +6 -0
index 020a3be..d86a23c 100644
@@ -8207,6 +8207,12 @@ S:	Maintained
 F:	Documentation/devicetree/bindings/pci/host-generic-pci.txt
 F:	drivers/pci/host/pci-host-generic.c
 
+PCI DRIVER FOR VMD
+M:	Keith Busch <[email protected]>
+L:	[email protected]
+S:	Supported
+F:	arch/x86/pci/vmd.c
+
 PCIE DRIVER FOR ST SPEAR13XX
 M:	Pratyush Anand <[email protected]>
 L:	[email protected]
arch/x86/Kconfig +13 -0
index 258965d..8cbcd64 100644
@@ -2684,6 +2684,19 @@ config PMC_ATOM
 	def_bool y
         depends on PCI
 
+config VMD
+	depends on 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. This provides
+	  additional bus resources than are otherwise possible with a
+	  single domain. If you know your system provides one of these and
+	  have devices attached to it, say Y; if you are not sure, say N.
+
 source "net/Kconfig"
 
 source "drivers/Kconfig"
arch/x86/include/asm/hw_irq.h +5 -0
index 1e3408e..1815b73 100644
@@ -130,6 +130,11 @@ struct irq_alloc_info {
 			char		*uv_name;
 		};
 #endif
+#if IS_ENABLED(CONFIG_VMD)
+		struct {
+			struct msi_desc *desc;
+		};
+#endif
 	};
 };
 
arch/x86/pci/Makefile +2 -0
index 5c6fc35..97062a6 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_VMD) += vmd.o
+
 ifeq ($(CONFIG_PCI_DEBUG),y)
 EXTRA_CFLAGS += -DDEBUG
 endif
arch/x86/pci/vmd.c new file +699 -0

699 lines not on this page · raw message

Signature · 1 line
2.6.2.307.g37023ba
#2 lore raw

Re: [PATCHv8] x86/PCI: Initial commit for new VMD device driver

reproduce:

Hi Keith,

[auto build test ERROR on tip/x86/core]
[also build test ERROR on v4.4 next-20160112]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]

url:    https://github.com/0day-ci/linux/commits/Keith-Busch/x86-PCI-Initial-commit-for-new-VMD-device-driver/20160113-003207
config: x86_64-allmodconfig (attached as .config)
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

>> arch/x86/pci/vmd.c:85:20: error: field 'dma_domain' has incomplete type
     struct dma_domain dma_domain;
                       ^
   arch/x86/pci/vmd.c: In function 'vmd_teardown_dma_ops':
>> arch/x86/pci/vmd.c:372:3: error: implicit declaration of function 'del_dma_domain' [-Werror=implicit-function-declaration]
      del_dma_domain(domain);
      ^
   arch/x86/pci/vmd.c: In function 'vmd_setup_dma_ops':
>> arch/x86/pci/vmd.c:387:8: error: dereferencing pointer to incomplete type 'struct dma_domain'
     domain->domain_nr = vmd->sysdata.domain;
           ^
>> arch/x86/pci/vmd.c:409:2: error: implicit declaration of function 'add_dma_domain' [-Werror=implicit-function-declaration]
     add_dma_domain(domain);
     ^
   arch/x86/pci/vmd.c: In function 'vmd_enable_domain':
   arch/x86/pci/vmd.c:559:2: error: implicit declaration of function 'dev_set_msi_domain' [-Werror=implicit-function-declaration]
     dev_set_msi_domain(&vmd->bus->dev, vmd->irq_domain);
     ^

cc1: some warnings being treated as errors

vim +/dma_domain +85 arch/x86/pci/vmd.c

    79		struct resource		resources[3];
    80		struct irq_domain	*irq_domain;
    81		struct pci_bus		*bus;
    82	
    83	#ifdef CONFIG_X86_DEV_DMA_OPS
    84		struct dma_map_ops	dma_ops;
  > 85		struct dma_domain	dma_domain;
    86	#endif
    87	};
    88	

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#3 lore raw

Re: [PATCHv8] x86/PCI: Initial commit for new VMD device driver

Quoted 1 line · kbuild test robot

[auto build test ERROR on tip/x86/core]

Looks a reason to repost the entire series, or maybe I should have replied to the existing thread with the dependencies.

Quoted 10 lines
url:    https://github.com/0day-ci/linux/commits/Keith-Busch/x86-PCI-Initial-commit-for-new-VMD-device-driver/20160113-003207
config: x86_64-allmodconfig (attached as .config)
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

Quoted 1 line
Quoted 1 line

arch/x86/pci/vmd.c:85:20: error: field 'dma_domain' has incomplete type

     struct dma_domain dma_domain;
#4 lore raw

Re: [PATCHv8] x86/PCI: Initial commit for new VMD device driver

Quoted 5 lines · Keith Busch
Quoted 1 line · kbuild test robot

[auto build test ERROR on tip/x86/core]

Looks a reason to repost the entire series, or maybe I should have replied to the existing thread with the dependencies.

Reposting the series as a whole makes my life much easier. I select all the patches in a series and apply them as a group, and that's much harder if individual patches in the series get superceded.

Quoted 10 lines
Quoted 10 lines
url:    https://github.com/0day-ci/linux/commits/Keith-Busch/x86-PCI-Initial-commit-for-new-VMD-device-driver/20160113-003207
config: x86_64-allmodconfig (attached as .config)
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

Quoted 1 line
Quoted 1 line

arch/x86/pci/vmd.c:85:20: error: field 'dma_domain' has incomplete type

     struct dma_domain dma_domain;