From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ilya Maximets Subject: [PATCH v2] net/virtio: avoid annoying IOPL call related errors Date: Fri, 23 Nov 2018 17:36:20 +0300 Message-ID: <20181123143620.10480-1-i.maximets@samsung.com> References: <20181123141739.11214-1-i.maximets@samsung.com> Content-Type: text/plain; charset="utf-8" Cc: Maxime Coquelin , Tiwei Bie , Zhihong Wang , Thomas Monjalon , Ferruh Yigit , Ian Stokes , Kevin Traynor , Ilya Maximets To: dev@dpdk.org, David Marchand Return-path: Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by dpdk.org (Postfix) with ESMTP id 17AAE1B5A0 for ; Fri, 23 Nov 2018 15:36:28 +0100 (CET) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20181123143627euoutp02da60bed1fb7c4ba73e1df1484af765a7~px5RfUPcw1012410124euoutp02H for ; Fri, 23 Nov 2018 14:36:27 +0000 (GMT) In-Reply-To: <20181123141739.11214-1-i.maximets@samsung.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" In case of running with not enough capabilities, i.e. running as non-root user any application linked with DPDK prints the message about IOPL call failure even if it was just called like './testpmd --help'. For example, this beaks most of the OVS unit tests if it built with DPDK support. Let's register the virtio driver unconditionally and print error message while probing the device. Silent iopl() call left in the constructor to have privileges as early as possible as it was before. Signed-off-by: Ilya Maximets --- Version 2: * Fixed possible fd leak on BSD. We can avoid test failures in OVS by filtering the output like this: https://patchwork.ozlabs.org/project/openvswitch/list/?series=77706 But it still looks very inconvenient for me to have this message in the output of every command for the DPDK linked app. drivers/net/virtio/virtio_ethdev.c | 11 ++++++----- lib/librte_eal/bsdapp/eal/eal.c | 6 ++++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index e1fe36a23..2ba66d291 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -1760,6 +1760,11 @@ vdpa_mode_selected(struct rte_devargs *devargs) static int eth_virtio_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, struct rte_pci_device *pci_dev) { + if (rte_eal_iopl_init() != 0) { + PMD_INIT_LOG(ERR, "IOPL call failed - cannot use virtio PMD"); + return 1; + } + /* virtio pmd skips probe if device needs to work in vdpa mode */ if (vdpa_mode_selected(pci_dev->device.devargs)) return 1; @@ -1785,11 +1790,7 @@ static struct rte_pci_driver rte_virtio_pmd = { RTE_INIT(rte_virtio_pmd_init) { - if (rte_eal_iopl_init() != 0) { - PMD_INIT_LOG(ERR, "IOPL call failed - cannot use virtio PMD"); - return; - } - + rte_eal_iopl_init(); rte_pci_register(&rte_virtio_pmd); } diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c index 508cbc46f..b8152a75c 100644 --- a/lib/librte_eal/bsdapp/eal/eal.c +++ b/lib/librte_eal/bsdapp/eal/eal.c @@ -556,9 +556,11 @@ int rte_eal_has_hugepages(void) int rte_eal_iopl_init(void) { - static int fd; + static int fd = -1; + + if (fd < 0) + fd = open("/dev/io", O_RDWR); - fd = open("/dev/io", O_RDWR); if (fd < 0) return -1; /* keep fd open for iopl */ -- 2.17.1