pci: use OS generic memory mapping functions
[dpdk.git] / drivers / bus / pci / linux / pci_uio.c
index 6dca05a..b622001 100644 (file)
@@ -345,12 +345,14 @@ pci_uio_map_resource_by_index(struct rte_pci_device *dev, int res_idx,
        mapaddr = pci_map_resource(pci_map_addr, fd, 0,
                        (size_t)dev->mem_resource[res_idx].len, 0);
        close(fd);
-       if (mapaddr == MAP_FAILED)
+       if (mapaddr == NULL)
                goto error;
 
        pci_map_addr = RTE_PTR_ADD(mapaddr,
                        (size_t)dev->mem_resource[res_idx].len);
 
+       pci_map_addr = RTE_PTR_ALIGN(pci_map_addr, sysconf(_SC_PAGE_SIZE));
+
        maps[map_idx].phaddr = dev->mem_resource[res_idx].phys_addr;
        maps[map_idx].size = dev->mem_resource[res_idx].len;
        maps[map_idx].addr = mapaddr;