From: David Christensen <drc@linux.vnet.ibm.com>
To: dev@dpdk.org
Cc: David Christensen <drc@linux.vnet.ibm.com>
Subject: [dpdk-dev] [PATCH v2] bus/pci: support iova=va on PowerNV systems
Date: Mon, 16 Mar 2020 13:38:28 -0700 [thread overview]
Message-ID: <20200316203828.27279-1-drc@linux.vnet.ibm.com> (raw)
In-Reply-To: <20200226195033.33877-1-drc@linux.vnet.ibm.com>
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(-)
diff --git a/drivers/bus/pci/linux/pci.c b/drivers/bus/pci/linux/pci.c
index 740a2cdad..a1e30b721 100644
--- a/drivers/bus/pci/linux/pci.c
+++ b/drivers/bus/pci/linux/pci.c
@@ -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
--
2.18.1
next prev parent reply other threads:[~2020-03-16 20:38 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-26 19:50 [dpdk-dev] [PATCH] " David Christensen
2020-03-13 9:09 ` David Marchand
2020-03-16 16:09 ` David Christensen
2020-03-16 20:38 ` David Christensen [this message]
2020-04-25 14:54 ` [dpdk-dev] [PATCH v2] " David Marchand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200316203828.27279-1-drc@linux.vnet.ibm.com \
--to=drc@linux.vnet.ibm.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).