From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 3FCC72A58 for ; Tue, 14 Jul 2015 07:07:18 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 13 Jul 2015 22:07:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,469,1432623600"; d="scan'208";a="746615938" Received: from kmsmsx154.gar.corp.intel.com ([172.21.73.14]) by fmsmga001.fm.intel.com with ESMTP; 13 Jul 2015 22:07:16 -0700 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by KMSMSX154.gar.corp.intel.com (172.21.73.14) with Microsoft SMTP Server (TLS) id 14.3.224.2; Tue, 14 Jul 2015 13:03:07 +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; Tue, 14 Jul 2015 13:03:05 +0800 From: "Qiu, Michael" To: Tetsuya Mukawa , "dev@dpdk.org" Thread-Topic: [PATCH] eal: fix vfio device never works. Thread-Index: AQHQu6MJLsBHm5qwrE2iTGtyZxkNXQ== Date: Tue, 14 Jul 2015 05:03:04 +0000 Message-ID: <533710CFB86FA344BFBF2D6802E60286046BA583@SHSMSX101.ccr.corp.intel.com> References: <1436514439-4893-1-git-send-email-michael.qiu@intel.com> <1436596189-1831-1-git-send-email-mukawa@igel.co.jp> 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] [PATCH] eal: fix vfio device never works. 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: Tue, 14 Jul 2015 05:07:19 -0000 Hi, Tetsuya=0A= =0A= So this patch make linux app back to original?=0A= =0A= Thanks,=0A= Michael=0A= =0A= On 7/11/2015 2:30 PM, Tetsuya Mukawa wrote:=0A= > The patch fixes vfio initialization issue introduced by below patch.=0A= > - Commit 35b3313e322b ("pci: merge mapping functions for linux and bsd")= =0A= >=0A= > Root cause is that VFIO_PRESENT is inaccessible in eal common level.=0A= > To fix it, remove pci_map/unmap_device from common code, then implement= =0A= > in linux and bsd code.=0A= >=0A= > Reported-by: Michael Qiu =0A= > Signed-off-by: Tetsuya Mukawa =0A= > ---=0A= > lib/librte_eal/bsdapp/eal/eal_pci.c | 39 ++++++++++++++++++++++++=0A= > lib/librte_eal/common/eal_common_pci.c | 55 ----------------------------= ------=0A= > lib/librte_eal/common/eal_private.h | 18 +++++++++++=0A= > lib/librte_eal/linuxapp/eal/eal_pci.c | 50 ++++++++++++++++++++++++++++= +++=0A= > 4 files changed, 107 insertions(+), 55 deletions(-)=0A= >=0A= > diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c b/lib/librte_eal/bsdapp/= eal/eal_pci.c=0A= > index 12f39d9..ed31222 100644=0A= > --- a/lib/librte_eal/bsdapp/eal/eal_pci.c=0A= > +++ b/lib/librte_eal/bsdapp/eal/eal_pci.c=0A= > @@ -92,6 +92,45 @@ pci_unbind_kernel_driver(struct rte_pci_device *dev __= rte_unused)=0A= > return -ENOTSUP;=0A= > }=0A= > =0A= > +/* Map pci device */=0A= > +int=0A= > +pci_map_device(struct rte_pci_device *dev)=0A= > +{=0A= > + int ret =3D -1;=0A= > +=0A= > + /* try mapping the NIC resources */=0A= > + switch (dev->kdrv) {=0A= > + case RTE_KDRV_NIC_UIO:=0A= > + /* map resources for devices that use uio */=0A= > + ret =3D pci_uio_map_resource(dev);=0A= > + break;=0A= > + default:=0A= > + RTE_LOG(DEBUG, EAL,=0A= > + " Not managed by a supported kernel driver, skipped\n");=0A= > + ret =3D 1;=0A= > + break;=0A= > + }=0A= > +=0A= > + return ret;=0A= > +}=0A= > +=0A= > +/* Unmap pci device */=0A= > +void=0A= > +pci_unmap_device(struct rte_pci_device *dev)=0A= > +{=0A= > + /* try unmapping the NIC resources */=0A= > + switch (dev->kdrv) {=0A= > + case RTE_KDRV_NIC_UIO:=0A= > + /* unmap resources for devices that use uio */=0A= > + pci_uio_unmap_resource(dev);=0A= > + break;=0A= > + default:=0A= > + RTE_LOG(DEBUG, EAL,=0A= > + " Not managed by a supported kernel driver, skipped\n");=0A= > + break;=0A= > + }=0A= > +}=0A= > +=0A= > void=0A= > pci_uio_free_resource(struct rte_pci_device *dev,=0A= > struct mapped_pci_resource *uio_res)=0A= > diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/comm= on/eal_common_pci.c=0A= > index 3805aed..60e40e0 100644=0A= > --- a/lib/librte_eal/common/eal_common_pci.c=0A= > +++ b/lib/librte_eal/common/eal_common_pci.c=0A= > @@ -137,61 +137,6 @@ pci_unmap_resource(void *requested_addr, size_t size= )=0A= > requested_addr);=0A= > }=0A= > =0A= > -/* Map pci device */=0A= > -static int=0A= > -pci_map_device(struct rte_pci_device *dev)=0A= > -{=0A= > - int ret =3D -1;=0A= > -=0A= > - /* try mapping the NIC resources using VFIO if it exists */=0A= > - switch (dev->kdrv) {=0A= > - case RTE_KDRV_VFIO:=0A= > -#ifdef VFIO_PRESENT=0A= > - if (pci_vfio_is_enabled())=0A= > - ret =3D pci_vfio_map_resource(dev);=0A= > -#endif=0A= > - break;=0A= > - case RTE_KDRV_IGB_UIO:=0A= > - case RTE_KDRV_UIO_GENERIC:=0A= > - case RTE_KDRV_NIC_UIO:=0A= > - /* map resources for devices that use uio */=0A= > - ret =3D pci_uio_map_resource(dev);=0A= > - break;=0A= > - default:=0A= > - RTE_LOG(DEBUG, EAL, " Not managed by a supported kernel driver,"=0A= > - " skipped\n");=0A= > - ret =3D 1;=0A= > - break;=0A= > - }=0A= > -=0A= > - return ret;=0A= > -}=0A= > -=0A= > -/* Unmap pci device */=0A= > -static void=0A= > -pci_unmap_device(struct rte_pci_device *dev)=0A= > -{=0A= > - if (dev =3D=3D NULL)=0A= > - return;=0A= > -=0A= > - /* try unmapping the NIC resources using VFIO if it exists */=0A= > - switch (dev->kdrv) {=0A= > - case RTE_KDRV_VFIO:=0A= > - RTE_LOG(ERR, EAL, "Hotplug doesn't support vfio yet\n");=0A= > - break;=0A= > - case RTE_KDRV_IGB_UIO:=0A= > - case RTE_KDRV_UIO_GENERIC:=0A= > - case RTE_KDRV_NIC_UIO:=0A= > - /* unmap resources for devices that use uio */=0A= > - pci_uio_unmap_resource(dev);=0A= > - break;=0A= > - default:=0A= > - RTE_LOG(DEBUG, EAL, " Not managed by a supported kernel driver,"=0A= > - " skipped\n");=0A= > - break;=0A= > - }=0A= > -}=0A= > -=0A= > /*=0A= > * If vendor/device ID match, call the devinit() function of the=0A= > * driver.=0A= > diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/= eal_private.h=0A= > index e16bb68..73363f6 100644=0A= > --- a/lib/librte_eal/common/eal_private.h=0A= > +++ b/lib/librte_eal/common/eal_private.h=0A= > @@ -165,6 +165,24 @@ struct rte_pci_device;=0A= > int pci_unbind_kernel_driver(struct rte_pci_device *dev);=0A= > =0A= > /**=0A= > + * Map this device=0A= > + *=0A= > + * This function is private to EAL.=0A= > + *=0A= > + * @return=0A= > + * 0 on success, negative on error and positive if no driver=0A= > + * is found for the device.=0A= > + */=0A= > +int pci_map_device(struct rte_pci_device *dev);=0A= > +=0A= > +/**=0A= > + * Unmap this device=0A= > + *=0A= > + * This function is private to EAL.=0A= > + */=0A= > +void pci_unmap_device(struct rte_pci_device *dev);=0A= > +=0A= > +/**=0A= > * Map the PCI resource of a PCI device in virtual memory=0A= > *=0A= > * This function is private to EAL.=0A= > diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linux= app/eal/eal_pci.c=0A= > index 1d5a13b..9a28ede 100644=0A= > --- a/lib/librte_eal/linuxapp/eal/eal_pci.c=0A= > +++ b/lib/librte_eal/linuxapp/eal/eal_pci.c=0A= > @@ -123,6 +123,56 @@ pci_get_kernel_driver_by_path(const char *filename, = char *dri_name)=0A= > return -1;=0A= > }=0A= > =0A= > +/* Map pci device */=0A= > +int=0A= > +pci_map_device(struct rte_pci_device *dev)=0A= > +{=0A= > + int ret =3D -1;=0A= > +=0A= > + /* try mapping the NIC resources using VFIO if it exists */=0A= > + switch (dev->kdrv) {=0A= > + case RTE_KDRV_VFIO:=0A= > +#ifdef VFIO_PRESENT=0A= > + if (pci_vfio_is_enabled())=0A= > + ret =3D pci_vfio_map_resource(dev);=0A= > +#endif=0A= > + break;=0A= > + case RTE_KDRV_IGB_UIO:=0A= > + case RTE_KDRV_UIO_GENERIC:=0A= > + /* map resources for devices that use uio */=0A= > + ret =3D pci_uio_map_resource(dev);=0A= > + break;=0A= > + default:=0A= > + RTE_LOG(DEBUG, EAL,=0A= > + " Not managed by a supported kernel driver, skipped\n");=0A= > + ret =3D 1;=0A= > + break;=0A= > + }=0A= > +=0A= > + return ret;=0A= > +}=0A= > +=0A= > +/* Unmap pci device */=0A= > +void=0A= > +pci_unmap_device(struct rte_pci_device *dev)=0A= > +{=0A= > + /* try unmapping the NIC resources using VFIO if it exists */=0A= > + switch (dev->kdrv) {=0A= > + case RTE_KDRV_VFIO:=0A= > + RTE_LOG(ERR, EAL, "Hotplug doesn't support vfio yet\n");=0A= > + break;=0A= > + case RTE_KDRV_IGB_UIO:=0A= > + case RTE_KDRV_UIO_GENERIC:=0A= > + /* unmap resources for devices that use uio */=0A= > + pci_uio_unmap_resource(dev);=0A= > + break;=0A= > + default:=0A= > + RTE_LOG(DEBUG, EAL,=0A= > + " Not managed by a supported kernel driver, skipped\n");=0A= > + break;=0A= > + }=0A= > +}=0A= > +=0A= > void *=0A= > pci_find_max_end_va(void)=0A= > {=0A= =0A=