From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id D4BF22986 for ; Tue, 8 Aug 2017 11:18:14 +0200 (CEST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Aug 2017 02:18:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,342,1498546800"; d="scan'208";a="1001248178" Received: from irsmsx101.ger.corp.intel.com ([163.33.3.153]) by orsmga003.jf.intel.com with ESMTP; 08 Aug 2017 02:18:12 -0700 Received: from irsmsx109.ger.corp.intel.com ([169.254.13.187]) by IRSMSX101.ger.corp.intel.com ([163.33.3.153]) with mapi id 14.03.0319.002; Tue, 8 Aug 2017 10:15:25 +0100 From: "Burakov, Anatoly" To: Jonas Pfefferle CC: "dev@dpdk.org" , "aik@ozlabs.ru" Thread-Topic: [PATCH v3] vfio: fix sPAPR IOMMU DMA window size Thread-Index: AQHTECIgLueaB22C+UCozdMrzosURqJ6LReg Date: Tue, 8 Aug 2017 09:15:24 +0000 Message-ID: References: <1502181667-17949-1-git-send-email-jpf@zurich.ibm.com> In-Reply-To: <1502181667-17949-1-git-send-email-jpf@zurich.ibm.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_IC x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNWI2NjFiNDAtZjliOS00YWE0LWE0NjgtNzA0NGUzNjBkNmQ1IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6InpBUTIzMzJKejJXNVwvclJJV1lGb1JsRk9uVnhVWEE1YU40QTlSQ0RDVnVrPSJ9 dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [163.33.239.181] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v3] vfio: fix sPAPR IOMMU DMA window size X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Aug 2017 09:18:15 -0000 From: Jonas Pfefferle [mailto:jpf@zurich.ibm.com] > Sent: Tuesday, August 8, 2017 9:41 AM > To: Burakov, Anatoly > Cc: dev@dpdk.org; aik@ozlabs.ru; Jonas Pfefferle > Subject: [PATCH v3] vfio: fix sPAPR IOMMU DMA window size >=20 > 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. >=20 > Signed-off-by: Jonas Pfefferle > --- > v2: > * roundup to next power 2 function without loop. >=20 > v3: > * Replace roundup_next_pow2 with rte_align64pow2 >=20 > lib/librte_eal/linuxapp/eal/eal_vfio.c | 13 ++++++++++--- > 1 file changed, 10 insertions(+), 3 deletions(-) >=20 > diff --git a/lib/librte_eal/linuxapp/eal/eal_vfio.c > b/lib/librte_eal/linuxapp/eal/eal_vfio.c > index 946df7e..550c41c 100644 > --- a/lib/librte_eal/linuxapp/eal/eal_vfio.c > +++ b/lib/librte_eal/linuxapp/eal/eal_vfio.c > @@ -759,10 +759,12 @@ vfio_spapr_dma_map(int vfio_container_fd) > return -1; > } >=20 > - /* calculate window size based on number of hugepages configured > */ > - create.window_size =3D rte_eal_get_physmem_size(); > + /* physicaly pages are sorted descending i.e. ms[0].phys_addr is max > */ Do we always expect that to be the case in the future? Maybe it would be sa= fer to walk the memsegs list. Thanks, Anatoly > + /* create DMA window from 0 to max(phys_addr + len) */ > + /* sPAPR requires window size to be a power of 2 */ > + create.window_size =3D rte_align64pow2(ms[0].phys_addr + > ms[0].len); > create.page_shift =3D __builtin_ctzll(ms->hugepage_sz); > - create.levels =3D 2; > + create.levels =3D 1; >=20 > ret =3D ioctl(vfio_container_fd, VFIO_IOMMU_SPAPR_TCE_CREATE, > &create); > if (ret) { > @@ -771,6 +773,11 @@ vfio_spapr_dma_map(int vfio_container_fd) > return -1; > } >=20 > + if (create.start_addr !=3D 0) { > + RTE_LOG(ERR, EAL, " DMA window start address !=3D 0\n"); > + return -1; > + } > + > /* map all DPDK segments for DMA. use 1:1 PA to IOVA mapping */ > for (i =3D 0; i < RTE_MAX_MEMSEG; i++) { > struct vfio_iommu_type1_dma_map dma_map; > -- > 2.7.4