X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fbus%2Fpci%2Flinux%2Fpci_uio.c;h=097dc19225d6ef4968a5b1dd693bcba79b2f833c;hb=9d2b24593724a98d03f16c18c1e40622911572be;hp=09ecbb7aad25c86d92bd68c76c001b5c18666206;hpb=d3110b124af64199b0901223c7e0117f7480480f;p=dpdk.git diff --git a/drivers/bus/pci/linux/pci_uio.c b/drivers/bus/pci/linux/pci_uio.c index 09ecbb7aad..097dc19225 100644 --- a/drivers/bus/pci/linux/pci_uio.c +++ b/drivers/bus/pci/linux/pci_uio.c @@ -16,10 +16,10 @@ #include #endif +#include #include #include #include -#include #include #include @@ -268,7 +268,7 @@ pci_uio_alloc_resource(struct rte_pci_device *dev, goto error; } - snprintf((*uio_res)->path, sizeof((*uio_res)->path), "%s", devname); + strlcpy((*uio_res)->path, devname, sizeof((*uio_res)->path)); memcpy(&(*uio_res)->pci_addr, &dev->addr, sizeof((*uio_res)->pci_addr)); return 0; @@ -314,12 +314,11 @@ pci_uio_map_resource_by_index(struct rte_pci_device *dev, int res_idx, loc->domain, loc->bus, loc->devid, loc->function, res_idx); - if (access(devname, R_OK|W_OK) != -1) { - fd = open(devname, O_RDWR); - if (fd < 0) - RTE_LOG(INFO, EAL, "%s cannot be mapped. " - "Fall-back to non prefetchable mode.\n", - devname); + fd = open(devname, O_RDWR); + if (fd < 0 && errno != ENOENT) { + RTE_LOG(INFO, EAL, "%s cannot be mapped. " + "Fall-back to non prefetchable mode.\n", + devname); } } @@ -352,6 +351,8 @@ pci_uio_map_resource_by_index(struct rte_pci_device *dev, int res_idx, 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; @@ -376,6 +377,12 @@ pci_uio_ioport_map(struct rte_pci_device *dev, int bar, int uio_num; unsigned long start; + if (rte_eal_iopl_init() != 0) { + RTE_LOG(ERR, EAL, "%s(): insufficient ioport permissions for PCI device %s\n", + __func__, dev->name); + return -1; + } + uio_num = pci_get_uio_dev(dev, dirname, sizeof(dirname), 0); if (uio_num < 0) return -1;