From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id EB9101B885 for ; Thu, 1 Feb 2018 02:13:11 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 Jan 2018 17:13:07 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,442,1511856000"; d="scan'208";a="31060455" Received: from fedora.sh.intel.com ([10.67.114.176]) by orsmga002.jf.intel.com with ESMTP; 31 Jan 2018 17:13:06 -0800 From: Changpeng Liu To: dev@dpdk.org Cc: changpeng.liu@intel.com, ferruh.yigit@intel.com Date: Thu, 1 Feb 2018 09:18:22 +0800 Message-Id: <1517447902-4166-1-git-send-email-changpeng.liu@intel.com> X-Mailer: git-send-email 1.9.3 Subject: [dpdk-dev] [PATCH] pci/uio: enable prefetchable resources mapping 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: Thu, 01 Feb 2018 01:13:12 -0000 For PCI prefetchable resources, Linux will create a write combined file as well, the library will try to map resourceX_wc file first, if the file does not exist, then it will map resourceX as usual. Signed-off-by: Changpeng Liu --- drivers/bus/pci/linux/pci_uio.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/bus/pci/linux/pci_uio.c b/drivers/bus/pci/linux/pci_uio.c index d423e4b..2957a5f 100644 --- a/drivers/bus/pci/linux/pci_uio.c +++ b/drivers/bus/pci/linux/pci_uio.c @@ -293,7 +293,7 @@ /* update devname for mmap */ snprintf(devname, sizeof(devname), - "%s/" PCI_PRI_FMT "/resource%d", + "%s/" PCI_PRI_FMT "/resource%d_wc", rte_pci_get_sysfs_path(), loc->domain, loc->bus, loc->devid, loc->function, res_idx); @@ -307,13 +307,22 @@ } /* - * open resource file, to mmap it + * open prefetchable resource file first, try to mmap it */ fd = open(devname, O_RDWR); if (fd < 0) { - RTE_LOG(ERR, EAL, "Cannot open %s: %s\n", - devname, strerror(errno)); - goto error; + snprintf(devname, sizeof(devname), + "%s/" PCI_PRI_FMT "/resource%d", + rte_pci_get_sysfs_path(), + loc->domain, loc->bus, loc->devid, + loc->function, res_idx); + /* then try to map resource file */ + fd = open(devname, O_RDWR); + if (fd < 0) { + RTE_LOG(ERR, EAL, "Cannot open %s: %s\n", + devname, strerror(errno)); + goto error; + } } /* try mapping somewhere close to the end of hugepages */ -- 1.9.3