From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id ED4545A65 for ; Fri, 10 Jul 2015 09:58:02 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP; 10 Jul 2015 00:58:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,445,1432623600"; d="scan'208";a="726284183" Received: from pgsmsx107.gar.corp.intel.com ([10.221.44.105]) by orsmga001.jf.intel.com with ESMTP; 10 Jul 2015 00:58:00 -0700 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by PGSMSX107.gar.corp.intel.com (10.221.44.105) with Microsoft SMTP Server (TLS) id 14.3.224.2; Fri, 10 Jul 2015 15:55:42 +0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.246]) by shsmsx102.ccr.corp.intel.com ([169.254.2.165]) with mapi id 14.03.0224.002; Fri, 10 Jul 2015 15:54:10 +0800 From: "Qiu, Michael" To: Stephen Hemminger , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [RFC] vfio: only map regions VFIO supports Thread-Index: AQHQuc7ozMfOvIJ1xkWqCxAhV3StCw== Date: Fri, 10 Jul 2015 07:54:10 +0000 Message-ID: <533710CFB86FA344BFBF2D6802E60286046B663B@SHSMSX101.ccr.corp.intel.com> References: <1436395131-11205-1-git-send-email-stephen@networkplumber.org> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [RFC] vfio: only map regions VFIO supports X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Jul 2015 07:58:03 -0000 Hi, Stephen=0A= =0A= This patch does not work for fm10k with vfio, see error below:=0A= =0A= EAL: PCI device 0000:84:00.0 on NUMA socket 1=0A= EAL: probe driver: 8086:15a4 rte_pmd_fm10k=0A= EAL: PCI memory mapped at 0x7f1980000000=0A= EAL: Trying to map BAR 2 that contains the MSI-X table. Trying offsets:=0A= 0000:0000, 1000:1000=0A= EAL: PCI memory mapped at 0x7f1980401000=0A= EAL: pci_map_resource(): cannot mmap(105, 0x7f1980402000, 0x4000000,=0A= 0x0): Invalid argument (0xffffffffffffffff)=0A= EAL: 0000:84:00.0 mapping BAR4 failed: Invalid argument=0A= EAL: Error - exiting with code: 1=0A= Cause: Requested device 0000:84:00.0 cannot be used=0A= =0A= =0A= Thanks,=0A= Michael=0A= =0A= On 7/9/2015 6:39 AM, Stephen Hemminger wrote:=0A= > The FM10K driver has 3 BARS numbered 0, 4, and 8. But the kernel=0A= > VFIO driver only allows mapping 0-5 anything bigger than that will=0A= > return -EINVAL (see kernel source vfio_pci.c:vfio_pci_mmap).=0A= >=0A= > The workaround is to limit the DPDK EAL VFIO support only map=0A= > the regions that will work. The FM10K driver is not using BAR8=0A= > in current code anyway.=0A= >=0A= > Signed-off-by: Stephen Hemminger =0A= > ---=0A= > lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 6 ++++--=0A= > 1 file changed, 4 insertions(+), 2 deletions(-)=0A= >=0A= > diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c b/lib/librte_eal/= linuxapp/eal/eal_pci_vfio.c=0A= > index 426953a..e269e75 100644=0A= > --- a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c=0A= > +++ b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c=0A= > @@ -549,7 +549,7 @@ pci_vfio_map_resource(struct rte_pci_device *dev)=0A= > int iommu_group_no;=0A= > char pci_addr[PATH_MAX] =3D {0};=0A= > struct rte_pci_addr *loc =3D &dev->addr;=0A= > - int i, ret, msix_bar;=0A= > + int i, ret, msix_bar, nmaps;=0A= > struct mapped_pci_resource *vfio_res =3D NULL;=0A= > struct mapped_pci_res_list *vfio_res_list =3D RTE_TAILQ_CAST(rte_vfio_t= ailq.head, mapped_pci_res_list);=0A= > =0A= > @@ -724,7 +724,9 @@ pci_vfio_map_resource(struct rte_pci_device *dev)=0A= > /* map BARs */=0A= > maps =3D vfio_res->maps;=0A= > =0A= > - for (i =3D 0; i < (int) vfio_res->nb_maps; i++) {=0A= > + /* VFIO supports limited (0-5) maps */=0A= > + nmaps =3D RTE_MIN(vfio_res->nb_maps, VFIO_PCI_ROM_REGION_INDEX - 1);=0A= > + for (i =3D 0; i < nmaps; i++) {=0A= > struct vfio_region_info reg =3D { .argsz =3D sizeof(reg) };=0A= > void *bar_addr;=0A= > struct memreg {=0A= =0A=