From patchwork Tue Jul 5 15:00:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ferruh Yigit X-Patchwork-Id: 14570 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 631675938; Tue, 5 Jul 2016 17:01:04 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 19B38591F for ; Tue, 5 Jul 2016 17:01:01 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP; 05 Jul 2016 08:01:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.26,580,1459839600"; d="scan'208"; a="1011282939" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga002.jf.intel.com with ESMTP; 05 Jul 2016 08:01:01 -0700 Received: from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com [10.237.217.46]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id u65F0w6u027311; Tue, 5 Jul 2016 16:00:58 +0100 Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id u65F0woB012413; Tue, 5 Jul 2016 16:00:58 +0100 Received: (from fyigit@localhost) by sivswdev02.ir.intel.com with id u65F0v5i012409; Tue, 5 Jul 2016 16:00:57 +0100 X-Authentication-Warning: sivswdev02.ir.intel.com: fyigit set sender to ferruh.yigit@intel.com using -f From: Ferruh Yigit To: dev@dpdk.org Cc: Stephen Hemminger Date: Tue, 5 Jul 2016 16:00:52 +0100 Message-Id: <1467730852-12040-1-git-send-email-ferruh.yigit@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1467385678-16205-1-git-send-email-ferruh.yigit@intel.com> References: <1467385678-16205-1-git-send-email-ferruh.yigit@intel.com> Subject: [dpdk-dev] [PATCH v4] igb_uio: fix possible mmap failure for Linux >= v4.5 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" mmap the iomem range of the PCI device fails for kernels that enabled CONFIG_IO_STRICT_DEVMEM option: EAL: pci_map_resource(): cannot mmap(39, 0x7f1c51800000, 0x100000, 0x0): Invalid argument (0xffffffffffffffff) CONFIG_IO_STRICT_DEVMEM is introduced in Linux v4.5 and not enabled by default: Linux commit: 90a545e restrict /dev/mem to idle io memory ranges As a workaround igb_uio can stop reserving PCI memory resources, from kernel point of view iomem region looks like idle and mmap works again. This matches uio_pci_generic usage. With this update device iomem range is not protected against any other kernel drivers or userspace access. But this shouldn't be a problem for dpdk usage module since purpose of the igb_uio module is to provide userspace access. Fixes: af75078fece3 ("first public release") Signed-off-by: Ferruh Yigit --- v4: * release notes, resolved issues section updated for this fix --- doc/guides/rel_notes/release_16_07.rst | 14 ++++++++++++++ lib/librte_eal/linuxapp/igb_uio/igb_uio.c | 13 ------------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/doc/guides/rel_notes/release_16_07.rst b/doc/guides/rel_notes/release_16_07.rst index 569f562..1ddcdab 100644 --- a/doc/guides/rel_notes/release_16_07.rst +++ b/doc/guides/rel_notes/release_16_07.rst @@ -231,6 +231,20 @@ Examples Other ~~~~~ +* **igb_uio: Fixed possible mmap failure for Linux >= v4.5.** + + mmaping the iomem range of the PCI device fails for kernels that + enabled CONFIG_IO_STRICT_DEVMEM option: + + EAL: pci_map_resource(): + cannot mmap(39, 0x7f1c51800000, 0x100000, 0x0): + Invalid argument (0xffffffffffffffff) + + CONFIG_IO_STRICT_DEVMEM is introduced in Linux v4.5 + + Updated igb_uio to stop reserving PCI memory resources, from + kernel point of view iomem region looks like idle and mmap worked + again. This matches uio_pci_generic usage. Known Issues ------------ diff --git a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c b/lib/librte_eal/linuxapp/igb_uio/igb_uio.c index 45a5720..df41e45 100644 --- a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c +++ b/lib/librte_eal/linuxapp/igb_uio/igb_uio.c @@ -342,16 +342,6 @@ igbuio_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) goto fail_free; } - /* - * reserve device's PCI memory regions for use by this - * module - */ - err = pci_request_regions(dev, "igb_uio"); - if (err != 0) { - dev_err(&dev->dev, "Cannot request regions\n"); - goto fail_disable; - } - /* enable bus mastering on the device */ pci_set_master(dev); @@ -441,8 +431,6 @@ fail_release_iomem: igbuio_pci_release_iomem(&udev->info); if (udev->mode == RTE_INTR_MODE_MSIX) pci_disable_msix(udev->pdev); - pci_release_regions(dev); -fail_disable: pci_disable_device(dev); fail_free: kfree(udev); @@ -460,7 +448,6 @@ igbuio_pci_remove(struct pci_dev *dev) igbuio_pci_release_iomem(&udev->info); if (udev->mode == RTE_INTR_MODE_MSIX) pci_disable_msix(dev); - pci_release_regions(dev); pci_disable_device(dev); pci_set_drvdata(dev, NULL); kfree(udev);