DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Zhang, Qi Z" <qi.z.zhang@intel.com>
To: Chas Williams <3chas3@gmail.com>, "dev@dpdk.org" <dev@dpdk.org>
Cc: "skhare@vmware.com" <skhare@vmware.com>, Chas Williams <chas3@att.com>
Subject: Re: [dpdk-dev] [PATCH] vfio: try physical address if virtual address	fails
Date: Mon, 27 Nov 2017 09:30:38 +0000	[thread overview]
Message-ID: <039ED4275CED7440929022BC67E706115311683A@SHSMSX103.ccr.corp.intel.com> (raw)
In-Reply-To: <20171124235718.6064-1-3chas3@gmail.com>

Hi William:

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Chas Williams
> Sent: Saturday, November 25, 2017 7:57 AM
> To: dev@dpdk.org
> Cc: skhare@vmware.com; Chas Williams <3chas3@gmail.com>; Chas
> Williams <chas3@att.com>
> Subject: [dpdk-dev] [PATCH] vfio: try physical address if virtual address fails
> 
> Some machines appear to have buggy DMAR mappings.  A typical mapping
> error looks like:
> 
>     DMAR: intel_iommu_map: iommu width (39) is not sufficient for the
> mapped address (7fc4fa800000)
>     DMAR: intel_iommu_map: iommu width (39) is not sufficient for the
> mapped address (7fc4fa800000)
>     DMAR: intel_iommu_map: iommu width (39) is not sufficient for the
> mapped address (7fc4fa800000)
>     DMAR: intel_iommu_map: iommu width (39) is not sufficient for the
> mapped address (7fc4fa800000)
> 
I met the same issue on some intel atom platform, the root cause is IOMMU only support 39 bit virtual address.
Not sure retry with physical address will be the right fix. I saw rte_eal_iova_mode is called at other place, it still take the virtual address as the mapped result, does that break something? 
So far the workaround may works by using --virtbase-addr to assign a address in range explicitly (for example 0x70,0000,0000)
Regards
Qi

> To work around this, attempt to do a physical address mapping if the virtual
> address mapping fails.
> 
> Fixes: e85a919286d2 ("vfio: honor IOVA mode before mapping")
> 
> Signed-off-by: Chas Williams <chas3@att.com>
> ---
>  lib/librte_eal/linuxapp/eal/eal_vfio.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/lib/librte_eal/linuxapp/eal/eal_vfio.c
> b/lib/librte_eal/linuxapp/eal/eal_vfio.c
> index 58f0123..6250676 100644
> --- a/lib/librte_eal/linuxapp/eal/eal_vfio.c
> +++ b/lib/librte_eal/linuxapp/eal/eal_vfio.c
> @@ -35,6 +35,7 @@
>  #include <fcntl.h>
>  #include <unistd.h>
>  #include <sys/ioctl.h>
> +#include <stdbool.h>
> 
>  #include <rte_log.h>
>  #include <rte_memory.h>
> @@ -702,6 +703,7 @@ vfio_type1_dma_map(int vfio_container_fd)
>  	/* map all DPDK segments for DMA. use 1:1 PA to IOVA mapping */
>  	for (i = 0; i < RTE_MAX_MEMSEG; i++) {
>  		struct vfio_iommu_type1_dma_map dma_map;
> +		int retried = false;
> 
>  		if (ms[i].addr == NULL)
>  			break;
> @@ -716,9 +718,15 @@ vfio_type1_dma_map(int vfio_container_fd)
>  			dma_map.iova = ms[i].iova;
>  		dma_map.flags = VFIO_DMA_MAP_FLAG_READ |
> VFIO_DMA_MAP_FLAG_WRITE;
> 
> +retry:
>  		ret = ioctl(vfio_container_fd, VFIO_IOMMU_MAP_DMA,
> &dma_map);
> 
>  		if (ret) {
> +			if (!retried && rte_eal_iova_mode() == RTE_IOVA_VA) {
> +				dma_map.iova = ms[i].iova;


> +				retried = true;
> +				goto retry;
> +			}
>  			RTE_LOG(ERR, EAL, "  cannot set up DMA remapping, "
>  					  "error %i (%s)\n", errno,
>  					  strerror(errno));
> --
> 2.9.5
Regards
Qi

  reply	other threads:[~2017-11-27  9:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-24 23:57 Chas Williams
2017-11-27  9:30 ` Zhang, Qi Z [this message]
2017-11-27 12:58   ` Chas Williams
2017-11-30  2:03     ` Chas Williams

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=039ED4275CED7440929022BC67E706115311683A@SHSMSX103.ccr.corp.intel.com \
    --to=qi.z.zhang@intel.com \
    --cc=3chas3@gmail.com \
    --cc=chas3@att.com \
    --cc=dev@dpdk.org \
    --cc=skhare@vmware.com \
    /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).