DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH v4] vfio: fix sPAPR IOMMU DMA window size
@ 2017-08-08 11:16 Jonas Pfefferle
  2017-08-08 12:06 ` Burakov, Anatoly
  2017-08-10  6:03 ` Alexey Kardashevskiy
  0 siblings, 2 replies; 5+ messages in thread
From: Jonas Pfefferle @ 2017-08-08 11:16 UTC (permalink / raw)
  To: anatoly.burakov; +Cc: dev, aik, Jonas Pfefferle

DMA window size needs to be big enough to span all memory segment's
physical addresses. We do not need multiple levels of IOMMU tables
as we already span ~70TB of physical memory with 16MB hugepages.

Signed-off-by: Jonas Pfefferle <jpf@zurich.ibm.com>
---
v2:
* roundup to next power 2 function without loop.

v3:
* Replace roundup_next_pow2 with rte_align64pow2

v4:
* do not assume ordering of physical addresses of memsegs

 lib/librte_eal/linuxapp/eal/eal_vfio.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/lib/librte_eal/linuxapp/eal/eal_vfio.c b/lib/librte_eal/linuxapp/eal/eal_vfio.c
index 946df7e..7d5d61d 100644
--- a/lib/librte_eal/linuxapp/eal/eal_vfio.c
+++ b/lib/librte_eal/linuxapp/eal/eal_vfio.c
@@ -759,10 +759,19 @@ vfio_spapr_dma_map(int vfio_container_fd)
 		return -1;
 	}
 
-	/* calculate window size based on number of hugepages configured */
-	create.window_size = rte_eal_get_physmem_size();
+	/* create DMA window from 0 to max(phys_addr + len) */
+	for (i = 0; i < RTE_MAX_MEMSEG; i++) {
+		if (ms[i].addr == NULL)
+			break;
+
+		create.window_size = RTE_MAX(create.window_size,
+				ms[i].phys_addr + ms[i].len);
+	}
+
+	/* sPAPR requires window size to be a power of 2 */
+	create.window_size = rte_align64pow2(create.window_size);
 	create.page_shift = __builtin_ctzll(ms->hugepage_sz);
-	create.levels = 2;
+	create.levels = 1;
 
 	ret = ioctl(vfio_container_fd, VFIO_IOMMU_SPAPR_TCE_CREATE, &create);
 	if (ret) {
@@ -771,6 +780,11 @@ vfio_spapr_dma_map(int vfio_container_fd)
 		return -1;
 	}
 
+	if (create.start_addr != 0) {
+		RTE_LOG(ERR, EAL, "  DMA window start address != 0\n");
+		return -1;
+	}
+
 	/* 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;
-- 
2.7.4

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH v4] vfio: fix sPAPR IOMMU DMA window size
  2017-08-08 11:16 [dpdk-dev] [PATCH v4] vfio: fix sPAPR IOMMU DMA window size Jonas Pfefferle
@ 2017-08-08 12:06 ` Burakov, Anatoly
  2017-10-10 13:33   ` Thomas Monjalon
  2017-08-10  6:03 ` Alexey Kardashevskiy
  1 sibling, 1 reply; 5+ messages in thread
From: Burakov, Anatoly @ 2017-08-08 12:06 UTC (permalink / raw)
  To: Jonas Pfefferle; +Cc: dev, aik

> From: Jonas Pfefferle [mailto:jpf@zurich.ibm.com]
> Sent: Tuesday, August 8, 2017 12:17 PM
> To: Burakov, Anatoly <anatoly.burakov@intel.com>
> Cc: dev@dpdk.org; aik@ozlabs.ru; Jonas Pfefferle <jpf@zurich.ibm.com>
> Subject: [PATCH v4] vfio: fix sPAPR IOMMU DMA window size
> 
> DMA window size needs to be big enough to span all memory segment's
> physical addresses. We do not need multiple levels of IOMMU tables as we
> already span ~70TB of physical memory with 16MB hugepages.
> 
> Signed-off-by: Jonas Pfefferle <jpf@zurich.ibm.com>
> ---
> v2:
> * roundup to next power 2 function without loop.
> 
> v3:
> * Replace roundup_next_pow2 with rte_align64pow2
> 
> v4:
> * do not assume ordering of physical addresses of memsegs
> 
>  lib/librte_eal/linuxapp/eal/eal_vfio.c | 20 +++++++++++++++++---
>  1 file changed, 17 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/librte_eal/linuxapp/eal/eal_vfio.c
> b/lib/librte_eal/linuxapp/eal/eal_vfio.c
> index 946df7e..7d5d61d 100644
> --- a/lib/librte_eal/linuxapp/eal/eal_vfio.c
> +++ b/lib/librte_eal/linuxapp/eal/eal_vfio.c
> @@ -759,10 +759,19 @@ vfio_spapr_dma_map(int vfio_container_fd)
>  		return -1;
>  	}
> 
> -	/* calculate window size based on number of hugepages configured
> */
> -	create.window_size = rte_eal_get_physmem_size();
> +	/* create DMA window from 0 to max(phys_addr + len) */
> +	for (i = 0; i < RTE_MAX_MEMSEG; i++) {
> +		if (ms[i].addr == NULL)
> +			break;
> +
> +		create.window_size = RTE_MAX(create.window_size,
> +				ms[i].phys_addr + ms[i].len);
> +	}
> +
> +	/* sPAPR requires window size to be a power of 2 */
> +	create.window_size = rte_align64pow2(create.window_size);
>  	create.page_shift = __builtin_ctzll(ms->hugepage_sz);
> -	create.levels = 2;
> +	create.levels = 1;
> 
>  	ret = ioctl(vfio_container_fd, VFIO_IOMMU_SPAPR_TCE_CREATE,
> &create);
>  	if (ret) {
> @@ -771,6 +780,11 @@ vfio_spapr_dma_map(int vfio_container_fd)
>  		return -1;
>  	}
> 
> +	if (create.start_addr != 0) {
> +		RTE_LOG(ERR, EAL, "  DMA window start address != 0\n");
> +		return -1;
> +	}
> +
>  	/* 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;
> --
> 2.7.4

Acked by: Anatoly Burakov <anatoly.burakov@intel.com>

Thanks,
Anatoly

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH v4] vfio: fix sPAPR IOMMU DMA window size
  2017-08-08 11:16 [dpdk-dev] [PATCH v4] vfio: fix sPAPR IOMMU DMA window size Jonas Pfefferle
  2017-08-08 12:06 ` Burakov, Anatoly
@ 2017-08-10  6:03 ` Alexey Kardashevskiy
  2017-10-10  8:02   ` Jonas Pfefferle1
  1 sibling, 1 reply; 5+ messages in thread
From: Alexey Kardashevskiy @ 2017-08-10  6:03 UTC (permalink / raw)
  To: Jonas Pfefferle, anatoly.burakov; +Cc: dev

On 08/08/17 21:16, Jonas Pfefferle wrote:
> DMA window size needs to be big enough to span all memory segment's
> physical addresses. We do not need multiple levels of IOMMU tables
> as we already span ~70TB of physical memory with 16MB hugepages.
> 
> Signed-off-by: Jonas Pfefferle <jpf@zurich.ibm.com>


Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>



> ---
> v2:
> * roundup to next power 2 function without loop.
> 
> v3:
> * Replace roundup_next_pow2 with rte_align64pow2
> 
> v4:
> * do not assume ordering of physical addresses of memsegs
> 
>  lib/librte_eal/linuxapp/eal/eal_vfio.c | 20 +++++++++++++++++---
>  1 file changed, 17 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/librte_eal/linuxapp/eal/eal_vfio.c b/lib/librte_eal/linuxapp/eal/eal_vfio.c
> index 946df7e..7d5d61d 100644
> --- a/lib/librte_eal/linuxapp/eal/eal_vfio.c
> +++ b/lib/librte_eal/linuxapp/eal/eal_vfio.c
> @@ -759,10 +759,19 @@ vfio_spapr_dma_map(int vfio_container_fd)
>  		return -1;
>  	}
>  
> -	/* calculate window size based on number of hugepages configured */
> -	create.window_size = rte_eal_get_physmem_size();
> +	/* create DMA window from 0 to max(phys_addr + len) */
> +	for (i = 0; i < RTE_MAX_MEMSEG; i++) {
> +		if (ms[i].addr == NULL)
> +			break;
> +
> +		create.window_size = RTE_MAX(create.window_size,
> +				ms[i].phys_addr + ms[i].len);
> +	}
> +
> +	/* sPAPR requires window size to be a power of 2 */
> +	create.window_size = rte_align64pow2(create.window_size);
>  	create.page_shift = __builtin_ctzll(ms->hugepage_sz);
> -	create.levels = 2;
> +	create.levels = 1;
>  
>  	ret = ioctl(vfio_container_fd, VFIO_IOMMU_SPAPR_TCE_CREATE, &create);
>  	if (ret) {
> @@ -771,6 +780,11 @@ vfio_spapr_dma_map(int vfio_container_fd)
>  		return -1;
>  	}
>  
> +	if (create.start_addr != 0) {
> +		RTE_LOG(ERR, EAL, "  DMA window start address != 0\n");
> +		return -1;
> +	}
> +
>  	/* 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;
> 


-- 
Alexey

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH v4] vfio: fix sPAPR IOMMU DMA window size
  2017-08-10  6:03 ` Alexey Kardashevskiy
@ 2017-10-10  8:02   ` Jonas Pfefferle1
  0 siblings, 0 replies; 5+ messages in thread
From: Jonas Pfefferle1 @ 2017-10-10  8:02 UTC (permalink / raw)
  To: thomas; +Cc: anatoly.burakov, dev, Alexey Kardashevskiy

Hi Thomas,

Can you please apply this patch?

Thanks,
Jonas

Alexey Kardashevskiy <aik@ozlabs.ru> wrote on 08/10/2017 08:03:17 AM:

> From: Alexey Kardashevskiy <aik@ozlabs.ru>
> To: Jonas Pfefferle <jpf@zurich.ibm.com>, anatoly.burakov@intel.com
> Cc: dev@dpdk.org
> Date: 08/10/2017 08:03 AM
> Subject: Re: [PATCH v4] vfio: fix sPAPR IOMMU DMA window size
>
> On 08/08/17 21:16, Jonas Pfefferle wrote:
> > DMA window size needs to be big enough to span all memory segment's
> > physical addresses. We do not need multiple levels of IOMMU tables
> > as we already span ~70TB of physical memory with 16MB hugepages.
> >
> > Signed-off-by: Jonas Pfefferle <jpf@zurich.ibm.com>
>
>
> Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
>
>
>
> > ---
> > v2:
> > * roundup to next power 2 function without loop.
> >
> > v3:
> > * Replace roundup_next_pow2 with rte_align64pow2
> >
> > v4:
> > * do not assume ordering of physical addresses of memsegs
> >
> >  lib/librte_eal/linuxapp/eal/eal_vfio.c | 20 +++++++++++++++++---
> >  1 file changed, 17 insertions(+), 3 deletions(-)
> >
> > diff --git a/lib/librte_eal/linuxapp/eal/eal_vfio.c b/lib/
> librte_eal/linuxapp/eal/eal_vfio.c
> > index 946df7e..7d5d61d 100644
> > --- a/lib/librte_eal/linuxapp/eal/eal_vfio.c
> > +++ b/lib/librte_eal/linuxapp/eal/eal_vfio.c
> > @@ -759,10 +759,19 @@ vfio_spapr_dma_map(int vfio_container_fd)
> >        return -1;
> >     }
> >
> > -   /* calculate window size based on number of hugepages configured */
> > -   create.window_size = rte_eal_get_physmem_size();
> > +   /* create DMA window from 0 to max(phys_addr + len) */
> > +   for (i = 0; i < RTE_MAX_MEMSEG; i++) {
> > +      if (ms[i].addr == NULL)
> > +         break;
> > +
> > +      create.window_size = RTE_MAX(create.window_size,
> > +            ms[i].phys_addr + ms[i].len);
> > +   }
> > +
> > +   /* sPAPR requires window size to be a power of 2 */
> > +   create.window_size = rte_align64pow2(create.window_size);
> >     create.page_shift = __builtin_ctzll(ms->hugepage_sz);
> > -   create.levels = 2;
> > +   create.levels = 1;
> >
> >     ret = ioctl(vfio_container_fd, VFIO_IOMMU_SPAPR_TCE_CREATE,
&create);
> >     if (ret) {
> > @@ -771,6 +780,11 @@ vfio_spapr_dma_map(int vfio_container_fd)
> >        return -1;
> >     }
> >
> > +   if (create.start_addr != 0) {
> > +      RTE_LOG(ERR, EAL, "  DMA window start address != 0\n");
> > +      return -1;
> > +   }
> > +
> >     /* 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;
> >
>
>
> --
> Alexey
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-dev] [PATCH v4] vfio: fix sPAPR IOMMU DMA window size
  2017-08-08 12:06 ` Burakov, Anatoly
@ 2017-10-10 13:33   ` Thomas Monjalon
  0 siblings, 0 replies; 5+ messages in thread
From: Thomas Monjalon @ 2017-10-10 13:33 UTC (permalink / raw)
  To: Burakov, Anatoly; +Cc: dev, Jonas Pfefferle, aik

08/08/2017 14:06, Burakov, Anatoly:
> > From: Jonas Pfefferle [mailto:jpf@zurich.ibm.com]
> > Sent: Tuesday, August 8, 2017 12:17 PM
> > To: Burakov, Anatoly <anatoly.burakov@intel.com>
> > Cc: dev@dpdk.org; aik@ozlabs.ru; Jonas Pfefferle <jpf@zurich.ibm.com>
> > Subject: [PATCH v4] vfio: fix sPAPR IOMMU DMA window size
> > 
> > DMA window size needs to be big enough to span all memory segment's
> > physical addresses. We do not need multiple levels of IOMMU tables as we
> > already span ~70TB of physical memory with 16MB hugepages.
> > 
> > Signed-off-by: Jonas Pfefferle <jpf@zurich.ibm.com>
> 
> Acked by: Anatoly Burakov <anatoly.burakov@intel.com>

Applied, thanks

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-10-10 13:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-08 11:16 [dpdk-dev] [PATCH v4] vfio: fix sPAPR IOMMU DMA window size Jonas Pfefferle
2017-08-08 12:06 ` Burakov, Anatoly
2017-10-10 13:33   ` Thomas Monjalon
2017-08-10  6:03 ` Alexey Kardashevskiy
2017-10-10  8:02   ` Jonas Pfefferle1

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).