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 <changpeng....@intel.com> --- 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