[v2] bus/pci: support iova=va on PowerNV systems
Checks
Commit Message
All recent POWER systems, Power 8 and 9 specifically, support an IOMMU
(it can't be disabled). The functionality of the IOMMU is different
depending on whether it's running on a bare metal PowerNV system or in
a virtual environment (PowerVM LPAR or KVM/QEMU). DPDK currently
supports the IOMMU found on PowerNV platforms, sPAPRv2, so IOVA=VA
mode can be enabled when the correct platform is detected.
The POWER IOMMU type can't be detected through mechansims such as
parsing files in the /sys heirarchy like x86_64 systems so the
/proc/cpuinfo file is parsed to determine whether Linux is running
on bare metal (i.e. PowerNV) or in a virtual environment (KVM/QEMU).
Signed-off-by: David Christensen <drc@linux.vnet.ibm.com>
---
v2:
* Fixed memory leak from use of getline
* Fixed nits for NULL memory address and indent levels
* Modified commit message description on logic for detecting IOMMU
on a POWER system
---
drivers/bus/pci/linux/pci.c | 35 ++++++++++++++++++++++++++++++++++-
1 file changed, 34 insertions(+), 1 deletion(-)
Comments
On Mon, Mar 16, 2020 at 9:38 PM David Christensen
<drc@linux.vnet.ibm.com> wrote:
>
> All recent POWER systems, Power 8 and 9 specifically, support an IOMMU
> (it can't be disabled). The functionality of the IOMMU is different
> depending on whether it's running on a bare metal PowerNV system or in
> a virtual environment (PowerVM LPAR or KVM/QEMU). DPDK currently
> supports the IOMMU found on PowerNV platforms, sPAPRv2, so IOVA=VA
> mode can be enabled when the correct platform is detected.
>
> The POWER IOMMU type can't be detected through mechansims such as
mechanisms
> parsing files in the /sys heirarchy like x86_64 systems so the
hierarchy
> /proc/cpuinfo file is parsed to determine whether Linux is running
> on bare metal (i.e. PowerNV) or in a virtual environment (KVM/QEMU).
>
> Signed-off-by: David Christensen <drc@linux.vnet.ibm.com>
Applied, thanks.
@@ -549,7 +549,40 @@ pci_device_iommu_support_va(const struct rte_pci_device *dev)
bool
pci_device_iommu_support_va(__rte_unused const struct rte_pci_device *dev)
{
- return false;
+ /*
+ * IOMMU is always present on a PowerNV host (IOMMUv2).
+ * IOMMU is also present in a KVM/QEMU VM (IOMMUv1) but is not
+ * currently supported by DPDK. Test for our current environment
+ * and report VA support as appropriate.
+ */
+
+ char *line = NULL;
+ size_t len = 0;
+ char filename[PATH_MAX] = "/proc/cpuinfo";
+ FILE *fp = fopen(filename, "r");
+ bool ret = false;
+
+ if (fp == NULL) {
+ RTE_LOG(ERR, EAL, "%s(): can't open %s: %s\n",
+ __func__, filename, strerror(errno));
+ return ret;
+ }
+
+ /* Check for a PowerNV platform */
+ while (getline(&line, &len, fp) != -1) {
+ if (strstr(line, "platform") != NULL)
+ continue;
+
+ if (strstr(line, "PowerNV") != NULL) {
+ RTE_LOG(DEBUG, EAL, "Running on a PowerNV system\n");
+ ret = true;
+ break;
+ }
+ }
+
+ free(line);
+ fclose(fp);
+ return ret;
}
#else
bool