On Tue, May 17, 2016 at 05:54:01PM +0200, David Marchand wrote: > > +pci_uio_ioport_map(struct rte_pci_device *dev, int bar, > > + struct rte_pci_ioport *p) > > +{ > > + FILE *f; > > + char buf[BUFSIZ]; > > + char filename[PATH_MAX]; > > + uint64_t phys_addr, end_addr, flags; > > + int fd, i; > > + void *addr; > > + > > + /* open and read addresses of the corresponding resource in sysfs */ > > + snprintf(filename, sizeof(filename), "%s/" PCI_PRI_FMT "/resource", > > + SYSFS_PCI_DEVICES, dev->addr.domain, dev->addr.bus, > > + dev->addr.devid, dev->addr.function); > > + f = fopen(filename, "r"); > > + if (f == NULL) { > > + RTE_LOG(ERR, EAL, "Cannot open sysfs resource: %s\n", > > + strerror(errno)); > > + return -1; > > + } > > + for (i = 0; i < bar + 1; i++) { > > + if (fgets(buf, sizeof(buf), f) == NULL) { > > + RTE_LOG(ERR, EAL, "Cannot read sysfs resource\n"); > > + goto error; > > + } > > + } > > + if (pci_parse_one_sysfs_resource(buf, sizeof(buf), &phys_addr, > > + &end_addr, &flags) < 0) > > + goto error; > > + if ((flags & IORESOURCE_IO) == 0) { > > + RTE_LOG(ERR, EAL, "BAR %d is not an IO resource\n", bar); > > + goto error; > > + } > > + snprintf(filename, sizeof(filename), "%s/" PCI_PRI_FMT > > "/resource%d", > > + SYSFS_PCI_DEVICES, dev->addr.domain, dev->addr.bus, > > + dev->addr.devid, dev->addr.function, bar); > > + > > + /* mmap the pci resource */ > > + fd = open(filename, O_RDWR); > > + if (fd < 0) { > > + RTE_LOG(ERR, EAL, "Cannot open %s: %s\n", filename, > > + strerror(errno)); > > + goto error; > > + } > > + addr = mmap(NULL, end_addr + 1, PROT_READ | PROT_WRITE, > > + MAP_SHARED, fd, 0); > > Sorry, did not catch it in v1, but a close(fd) is missing here. > With this, I think the patchset looks good. > > Just missing some opinion from the virtio maintainers ?
Apologize for being late for review. Assuming you have done proper test, this patch set looks good to me. (well, I don't quite like the tons of "#ifdef ... #else ..#end" block though) A side note is that I noticed an ABI breakage introduced in this patch, so, this release is not a good fit? --yliu