DPDK patches and discussions
 help / color / mirror / Atom feed
From: Takeshi Yoshimura <tyos@jp.ibm.com>
To: dev@dpdk.org
Cc: Takeshi Yoshimura <tyos@jp.ibm.com>
Subject: [dpdk-dev] [PATCH] vfio: retry creating sPAPR DMA window
Date: Fri,  7 Jun 2019 11:28:29 +0900	[thread overview]
Message-ID: <20190607022830.2044-1-tyos@jp.ibm.com> (raw)

sPAPR allows only page_shift from VFIO_IOMMU_SPAPR_TCE_GET_INFO ioctl.
However, Linux 4.17 or before returns incorrect page_shift for Power9.
I added the code for retrying creation of sPAPR DMA window.

Signed-off-by: Takeshi Yoshimura <tyos@jp.ibm.com>
---
 lib/librte_eal/linux/eal/eal_vfio.c | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/lib/librte_eal/linux/eal/eal_vfio.c b/lib/librte_eal/linux/eal/eal_vfio.c
index 6892a2c14..f16c5c3c0 100644
--- a/lib/librte_eal/linux/eal/eal_vfio.c
+++ b/lib/librte_eal/linux/eal/eal_vfio.c
@@ -1448,9 +1448,29 @@ vfio_spapr_create_new_dma_window(int vfio_container_fd,
 	/* create new DMA window */
 	ret = ioctl(vfio_container_fd, VFIO_IOMMU_SPAPR_TCE_CREATE, create);
 	if (ret) {
-		RTE_LOG(ERR, EAL, "  cannot create new DMA window, "
-				"error %i (%s)\n", errno, strerror(errno));
-		return -1;
+		/* try possible page_shift and levels for workaround */
+		uint32_t levels;
+
+		for (levels = 1; levels <= info.ddw.levels; levels++) {
+			uint32_t pgsizes = info.ddw.pgsizes;
+
+			while (pgsizes != 0) {
+				create->page_shift = 31 - __builtin_clz(pgsizes);
+				create->levels = levels;
+				ret = ioctl(vfio_container_fd,
+					VFIO_IOMMU_SPAPR_TCE_CREATE, create);
+				if (!ret)
+					break;
+				pgsizes &= ~(1 << create->page_shift);
+			}
+			if (!ret)
+				break;
+		}
+		if (ret) {
+			RTE_LOG(ERR, EAL, "  cannot create new DMA window, "
+					"error %i (%s)\n", errno, strerror(errno));
+			return -1;
+		}
 	}
 
 	if (create->start_addr != 0) {
-- 
2.17.1


             reply	other threads:[~2019-06-07  2:28 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-07  2:28 Takeshi Yoshimura [this message]
2019-07-04 16:01 ` Thomas Monjalon
2019-07-08 16:47   ` David Christensen
2019-07-08 17:45     ` Thomas Monjalon
2019-07-09 10:22       ` Burakov, Anatoly
2019-07-05  8:15 ` Burakov, Anatoly
2019-07-07 21:21   ` Thomas Monjalon
2019-07-10 10:32 ` Burakov, Anatoly
2019-07-10 12:17   ` Thomas Monjalon
2019-07-10 12:35     ` Burakov, Anatoly
2019-07-10 12:39       ` Thomas Monjalon
2019-07-10 16:01         ` Burakov, Anatoly
2019-07-11  0:50           ` David Christensen
2019-07-11  2:18         ` Takeshi T Yoshimura

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=20190607022830.2044-1-tyos@jp.ibm.com \
    --to=tyos@jp.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).