From mboxrd@z Thu Jan 1 00:00:00 1970 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) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20181123143627euoutp02da60bed1fb7c4ba73e1df1484af765a7~px5RfUPcw1012410124euoutp02H DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1542983787; bh=n2OLb357xXx4ukPd3zWIjR0k/ZNAvG932sVSpvDSCQw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c1NpVrfJotFuJAlhyXC06d5zsS8anMpZ7CWzNHrmA7+JV/xu5dp/jiEo4QtnM5724 A84HcR82GAJZl8x138ezBNd/izi5LNfvQGA+mkPg54dMkFpds8R0vUmZuO9ShFv279 LF9ehMF5TC+fs11WhvFNxdHhaEbk/yOojN+BGaAM= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20181123143626eucas1p276c7b4217f4e27ccadd54875deac1a6e~px5Q49AbJ0936409364eucas1p27; Fri, 23 Nov 2018 14:36:26 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id F4.90.04441.A6018FB5; Fri, 23 Nov 2018 14:36:26 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20181123143625eucas1p1def3421fa13b5aec7204549932c75bb7~px5QIBUne1016810168eucas1p1k; Fri, 23 Nov 2018 14:36:25 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20181123143625eusmtrp2750316f02ad86a8fde5becaaf5a438c4~px5P3K-5x1488714887eusmtrp2V; Fri, 23 Nov 2018 14:36:25 +0000 (GMT) X-AuditID: cbfec7f2-5c9ff70000001159-67-5bf8106a19a9 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 57.2F.04284.96018FB5; Fri, 23 Nov 2018 14:36:25 +0000 (GMT) Received: from imaximets.rnd.samsung.ru (unknown [106.109.129.180]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20181123143624eusmtip1420ffe4ff2171b22ad61801fe556e004~px5PM5yAv0464204642eusmtip1t; Fri, 23 Nov 2018 14:36:24 +0000 (GMT) From: Ilya Maximets To: dev@dpdk.org, David Marchand Cc: Maxime Coquelin , Tiwei Bie , Zhihong Wang , Thomas Monjalon , Ferruh Yigit , Ian Stokes , Kevin Traynor , Ilya Maximets Date: Fri, 23 Nov 2018 17:36:20 +0300 Message-Id: <20181123143620.10480-1-i.maximets@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181123141739.11214-1-i.maximets@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprIKsWRmVeSWpSXmKPExsWy7djP87pZAj+iDZ4/lrVY0dHOYvHu03Ym izt7T7NbXGn/yW6x8eFZVou1hz6wWxzr3MNi8enBCRaLrQ3/mSw2X5zE5MDlcbH/DqPHrwVL WT0W73nJ5HHs5jR2j/f7rrJ59G1ZxRjAFsVlk5Kak1mWWqRvl8CV0XP+DHvBJuGKLdv3sjQw fubvYuTkkBAwkTgwq42pi5GLQ0hgBaPEw/nf2CGcL4wSH47dYoRwPjNKfLv0hBWmZevzSywQ ieWMEg1d/9ggnB+MElNudLOAVLEJ6EicWn2EEcQWEbCWaFq1CKyIWWAfk8Ts9y+ZQRLCA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MNFQKq2Xn1IuMERr4FjAyrGEVSS4tz03OLDfWKE3OLS/PS9ZLzczcxAgN827Gfm3cw XtoYfIhRgINRiYfXgPlHtBBrYllxZe4hRgkOZiUR3ibF79FCvCmJlVWpRfnxRaU5qcWHGE2B jprILCWanA+MvrySeENTQ3MLS0NzY3NjMwslcd7zBpVRQgLpiSWp2ampBalFMH1MHJxSDYxx 13eu8Jz1613U7jtp07Z19R3cfq5M2WDF5NM6jVv9I26sdNFukt/1zlD3y/pu1+O/ZHh1Xoc9 e6B2+tRMoSuhR8W/TtQSD91/c/6ayT/fx9pl8G6fPcdApi7h1L6Lqhv/l2xJeRbg+FM6r4FP 4pTjq/m3vx6Y5fZQsv2fSJKAw5bz3zjip9l9UWIpzkg01GIuKk4EAOhE1iaGAgAA X-CMS-MailID: 20181123143625eucas1p1def3421fa13b5aec7204549932c75bb7 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20181123143625eucas1p1def3421fa13b5aec7204549932c75bb7 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20181123143625eucas1p1def3421fa13b5aec7204549932c75bb7 References: <20181123141739.11214-1-i.maximets@samsung.com> Subject: [dpdk-dev] [PATCH v2] net/virtio: avoid annoying IOPL call related errors 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: Fri, 23 Nov 2018 14:36:29 -0000 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