PCI: Add support for PASID capability
v2 cover PCI: Add support for PASID capability
Hi,
here is the second version of the patch-set implementing support for the PRI and PASID capabilities into the Linux kernel. These capabilities of a PCIe device are tightly coupled with ATS, but not with IOV. So these patches start by moving the ATS code into its own file: ats.c.
Support for the other two capabilities is based on that change.
Regards,
Joerg
Changes to v1:
* Improved Kconfig help-text for PASID
* Some editing in the commit messages
Diffstat:
drivers/pci/Kconfig | 26 +++ drivers/pci/Makefile | 1 + drivers/pci/ats.c | 438 ++++++++++++++++++++++++++++++++++++++++++++++ drivers/pci/iov.c | 142 --------------- include/linux/pci-ats.h | 75 ++++++++ include/linux/pci_regs.h | 20 ++ 6 files changed, 560 insertions(+), 142 deletions(-)
PATCH v2 1/4 PCI: Move ATS implementation into own file
ATS does not depend on IOV support, so move the code into its own file. This file will also include support for the PRI and PASID capabilities later.
Also give ATS its own Kconfig variable to allow selecting it without IOV support.
--- drivers/pci/Kconfig | 4 + drivers/pci/Makefile | 1 + drivers/pci/ats.c | 155 +++++++++++++++++++++++++++++++++++++++++++++++ drivers/pci/iov.c | 142 ------------------------------------------- include/linux/pci-ats.h | 2 + 5 files changed, 162 insertions(+), 142 deletions(-) create mode 100644 drivers/pci/ats.c
drivers/pci/Kconfig +4 -0
@@ -71,9 +71,13 @@ config HT_IRQ If unsure say Y. +config PCI_ATS + bool + config PCI_IOV bool "PCI IOV support" depends on PCI + select PCI_ATS help I/O Virtualization is a PCI feature supported by some devices which allows them to create virtual devices which share their
drivers/pci/Makefile +1 -0
@@ -29,6 +29,7 @@ obj-$(CONFIG_PCI_MSI) += msi.o # Build the Hypertransport interrupt support obj-$(CONFIG_HT_IRQ) += htirq.o +obj-$(CONFIG_PCI_ATS) += ats.o obj-$(CONFIG_PCI_IOV) += iov.o #
drivers/pci/ats.c new file +155 -0
155 lines not on this page · raw message
drivers/pci/iov.c +0 -142
145 lines not on this page · raw message
include/linux/pci-ats.h +2 -0
@@ -1,6 +1,8 @@ #ifndef LINUX_PCI_ATS_H #define LINUX_PCI_ATS_H +#include <linux/pci.h> + /* Address Translation Service */ struct pci_ats { int pos; /* capability position */
Signature · 1 line
1.7.4.1
Jesse Barnes
AppliedRe: [PATCH 1/4] PCI: Move ATS implementation into own file
Quoted 8 lines · On Tue, 27 Sep 2011 15:57:13 +0200 Joerg Roedel <[email protected]> wrote:
ATS does not depend on IOV support, so move the code into its own file. This file will also include support for the PRI and PASID capabilities later.
Also give ATS its ownKconfigvariable to allow selecting it without IOV support.Signed-off-by Joerg Roedel <[email protected]>---
Applied this series to linux-next, thanks.
Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
PATCH v2 2/4 PCI: Export ATS functions to modules
In reply to Joerg RoedelThis patch makes the ATS functions usable for modules. They will be used by a module implementing some advanced AMD IOMMU features.
--- drivers/pci/ats.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
drivers/pci/ats.c +3 -0
@@ -90,6 +90,7 @@ int pci_enable_ats(struct pci_dev *dev, int ps)return 0 ; } +EXPORT_SYMBOL_GPL (pci_enable_ats);/** * pci_disable_ats - disable the ATS capability
@@ -120,6 +121,7 @@ void pci_disable_ats(struct pci_dev *dev)if (!dev->is_physfn)ats_free_one (dev); } +EXPORT_SYMBOL_GPL (pci_disable_ats);/** * pci_ats_queue_depth - query the ATS Invalidate Queue Depth
@@ -153,3 +155,4 @@ int pci_ats_queue_depth(struct pci_dev *dev)return PCI_ATS_CAP_QDEP (cap) ?PCI_ATS_CAP_QDEP (cap) :PCI_ATS_MAX_QDEP ; } +EXPORT_SYMBOL_GPL (pci_ats_queue_depth);
Signature · 1 line
1.7.4.1
PATCH v2 3/4 PCI: Add implementation for PRI capability
In reply to Joerg RoedelImplement the necessary functions to handle PRI capabilities on PCIe devices. With PRI devices behind an IOMMU can signal page fault conditions to software and recover from such faults.
--- drivers/pci/Kconfig | 9 +++ drivers/pci/ats.c | 167 ++++++++++++++++++++++++++++++++++++++++++++++ include/linux/pci-ats.h | 42 ++++++++++++ include/linux/pci_regs.h | 12 +++ 4 files changed, 230 insertions(+), 0 deletions(-)
drivers/pci/Kconfig +9 -0
@@ -85,6 +85,15 @@ config PCI_IOV If unsure, say N. +config PCI_PRI + bool "PCI PRI support" + select PCI_ATS + help + PRI is the PCI Page Request Interface. It allows PCI devices that are + behind an IOMMU to recover from page faults. + + If unsure, say N. + config PCI_IOAPIC bool depends on PCI
drivers/pci/ats.c +167 -0
179 lines not on this page · raw message
include/linux/pci-ats.h +42 -0
52 lines not on this page · raw message
include/linux/pci_regs.h +12 -0
@@ -663,6 +663,18 @@#define PCI_ATS_CTRL_STU (x) ((x) & 0x1f)/* Smallest Translation Unit */ #define PCI_ATS_MIN_STU 12/* shift of minimum STU block */ +/* Page Request Interface */ +#define PCI_PRI_CAP 0x13/* PRI capability ID */ +#define PCI_PRI_CONTROL_OFF 0x04/* Offset of control register */ +#define PCI_PRI_STATUS_OFF 0x06/* Offset of status register */ +#define PCI_PRI_ENABLE 0x0001/* Enable mask */ +#define PCI_PRI_RESET 0x0002/* Reset bit mask */ +#define PCI_PRI_STATUS_RF 0x0001/* Request Failure */ +#define PCI_PRI_STATUS_UPRGI 0x0002/* Unexpected PRG index */ +#define PCI_PRI_STATUS_STOPPED 0x0100/* PRI Stopped */ +#define PCI_PRI_MAX_REQ_OFF 0x08/* Cap offset for max reqs supported */ +#define PCI_PRI_ALLOC_REQ_OFF 0x0c/* Cap offset for max reqs allowed */ +/* Single Root I/O Virtualization */ #define PCI_SRIOV_CAP 0x04/* SR-IOV Capabilities */ #define PCI_SRIOV_CAP_VFM 0x01/* VF Migration Capable */
Signature · 1 line
1.7.4.1
Re: [PATCH 3/4] PCI: Add implementation for PRI capability
Quoted 21 lines · Joerg Roedel
Implement the necessary functions to handle PRI capabilities on PCIe devices. With PRI devices behind an IOMMU can signal page fault conditions to software and recover from such faults.
Signed-off-by Joerg Roedel <[email protected]>---
drivers/pci/Kconfig | 9 +++
drivers/pci/ats.c | 167 ++++++++++++++++++++++++++++++++++++++++++++++include/linux/pci-ats.h| 42 ++++++++++++include/linux/pci_regs.h| 12 +++4 files changed, 230 insertions(+), 0 deletions(-)drivers/pci/Kconfig +0
-0@@ -85,6 +85,15 @@ config PCI_IOVIf unsure, say N.
Quoted 2 lines
+config
PCI_PRI
+ bool "PCI PRI support"
Shouldn't this depend on PCI?
It doesn't seem to hurt on PCI-less platforms, but I prefer not seeing PCI-related
questions when CONFIG_PCI is not set.
drivers/pci/Kconfig config PCI_IOV · line 96
Quoted 7 lines
+ select
PCI_ATS
+ help
+ PRI is the PCI Page Request Interface. It allows PCI devices that are
+ behind an IOMMU to recover from page faults.drivers/pci/Kconfig +3
-0+ + If unsure, say N. +
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Re: [PATCH 3/4] PCI: Add implementation for PRI capability
Quoted 22 lines · Geert Uytterhoeven
Quoted 21 lines · Joerg Roedel
Implement the necessary functions to handle PRI capabilities on PCIe devices. With PRI devices behind an IOMMU can signal page fault conditions to software and recover from such faults.
Signed-off-by Joerg Roedel <[email protected]>---
drivers/pci/Kconfig | 9 +++
drivers/pci/ats.c | 167 ++++++++++++++++++++++++++++++++++++++++++++++include/linux/pci-ats.h| 42 ++++++++++++include/linux/pci_regs.h| 12 +++4 files changed, 230 insertions(+), 0 deletions(-)drivers/pci/Kconfig +0
-0@@ -85,6 +85,15 @@ config PCI_IOVIf unsure, say N.
Quoted 7 lines
Quoted 2 lines
+config
PCI_PRI
+ bool "PCI PRI support"Shouldn't this depend on PCI?
It doesn't seem to hurt on PCI-less platforms, but I prefer not seeing PCI-related questions when
CONFIG_PCIis not set.
You are right, I send a fix soon. Thanks for the report.
Joerg
Signature · 5 lines
AMD Operating System Research Center Advanced Micro Devices GmbH Einsteinring 24 85609 Dornach General Managers: Alberto Bozzo, Andrew Bowd Registration: Dornach, Landkr. Muenchen; Registerger. Muenchen, HRB Nr. 43632
PATCH v2 4/4 PCI: Add support for PASID capability
In reply to Joerg RoedelDevices supporting Process Address Space Identifiers (PASIDs) can use an IOMMU to access multiple IO address spaces at the same time. A PCIe device indicates support for this feature by implementing the PASID capability. This patch adds support for the capability to the Linux kernel.
--- drivers/pci/Kconfig | 13 +++++ drivers/pci/ats.c | 113 ++++++++++++++++++++++++++++++++++++++++++++++ include/linux/pci-ats.h | 31 +++++++++++++ include/linux/pci_regs.h | 8 +++ 4 files changed, 165 insertions(+), 0 deletions(-)
drivers/pci/Kconfig +13 -0
@@ -94,6 +94,19 @@ config PCI_PRI If unsure, say N. +config PCI_PASID + bool "PCI PASID support" + depends on PCI + select PCI_ATS + help + Process Address Space Identifiers (PASIDs) can be used by PCI devices + to access more than one IO address space at the same time. To make + use of this feature an IOMMU is required which also supports PASIDs. + Select this option if you have such an IOMMU and want to compile the + driver for it into your kernel. + + If unsure, say N. + config PCI_IOAPIC bool depends on PCI
drivers/pci/ats.c +113 -0
122 lines not on this page · raw message
include/linux/pci-ats.h +31 -0
@@ -93,4 +93,35 @@ static inline int pci_pri_status(struct pci_dev *pdev) }#endif /* CONFIG_PCI_PRI */ +#ifdef CONFIG_PCI_PASID + +extern int pci_enable_pasid (struct pci_dev *pdev,int features); +extern void pci_disable_pasid (struct pci_dev *pdev); +extern int pci_pasid_features (struct pci_dev *pdev); +extern int pci_max_pasids (struct pci_dev *pdev); + +#else /* CONFIG_PCI_PASID */ + +static inline int pci_enable_pasid (struct pci_dev *pdev,int features) +{ +return -EINVAL ; +} + +static inline void pci_disable_pasid (struct pci_dev *pdev) +{ +} + +static inline int pci_pasid_features (struct pci_dev *pdev) +{ +return -EINVAL ; +} + +static inline int pci_max_pasids (struct pci_dev *pdev) +{ +return -EINVAL ; +} + +#endif /* CONFIG_PCI_PASID */ + +#endif /* LINUX_PCI_ATS_H*/
include/linux/pci_regs.h +8 -0
@@ -675,6 +675,14 @@#define PCI_PRI_MAX_REQ_OFF 0x08/* Cap offset for max reqs supported */ #define PCI_PRI_ALLOC_REQ_OFF 0x0c/* Cap offset for max reqs allowed */ +/* PASID capability */ +#define PCI_PASID_CAP 0x1b/* PASID capability ID */ +#define PCI_PASID_CAP_OFF 0x04/* PASID feature register */ +#define PCI_PASID_CONTROL_OFF 0x06/* PASID control register */ +#define PCI_PASID_ENABLE 0x01/* Enable/Supported bit */ +#define PCI_PASID_EXEC 0x02/* Exec permissions Enable/Supported */ +#define PCI_PASID_PRIV 0x04/* Priviledge Mode Enable/Support */ +/* Single Root I/O Virtualization */ #define PCI_SRIOV_CAP 0x04/* SR-IOV Capabilities */ #define PCI_SRIOV_CAP_VFM 0x01/* VF Migration Capable */
Signature · 1 line
1.7.4.1
Quoted 20 lines · Joerg Roedel
Hi,
here is the second version of the patch-set implementing support for the PRI and PASID capabilities into the Linux kernel. These capabilities of a PCIe device are tightly coupled with ATS, but not with IOV. So these patches start by moving the ATS code into its own file:
ats.c.Support for the other two capabilities is based on that change.
Regards,
Joerg
Changes to v1:
* Improved
Kconfighelp-text for PASID
* Some editing in the commit messagesDiffstat:
Quoted 7 lines
drivers/pci/Kconfig | 26 +++ drivers/pci/Makefile | 1 + drivers/pci/ats.c | 438 ++++++++++++++++++++++++++++++++++++++++++++++ drivers/pci/iov.c | 142 --------------- include/linux/pci-ats.h | 75 ++++++++ include/linux/pci_regs.h | 20 ++ 6 files changed, 560 insertions(+), 142 deletions(-)
Ping?
Quoted 10 lines · On Fri, 7 Oct 2011 14:31:33 +0200 Joerg Roedel <[email protected]> wrote:
Quoted 9 lines · Joerg Roedel
Hi,
here is the second version of the patch-set implementing support for the PRI and PASID capabilities into the Linux kernel. These capabilities of a PCIe device are tightly coupled with ATS, but not with IOV. So these patches start by moving the ATS code into its own file:
ats.c.Support for the other two capabilities is based on that change.
I've got this one queued up, but would definitely appreciate some reviewed-bys on it.
Thanks,
Jesse
Quoted 12 lines · Jesse Barnes
Quoted 9 lines · On Fri, 7 Oct 2011 14:31:33 +0200 Joerg Roedel <[email protected]> wrote:
Quoted 8 lines · Joerg Roedel
Hi,
here is the second version of the patch-set implementing support for the PRI and PASID capabilities into the Linux kernel. These capabilities of a PCIe device are tightly coupled with ATS, but not with IOV. So these patches start by moving the ATS code into its own file:
ats.c.
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Support for the other two capabilities is based on that change.
I've got this one queued up, but would definitely appreciate some reviewed-bys on it.
For patches 1-4: