From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yuanhan Liu Subject: Re: [PATCH v2 5/7] eal/linux: mmap ioports on ppc64 Date: Mon, 23 May 2016 21:07:49 +0800 Message-ID: <20160523130749.GJ5641@yliu-dev.sh.intel.com> References: <1463143859-3105-1-git-send-email-olivier.matz@6wind.com> <1463479192-2488-1-git-send-email-olivier.matz@6wind.com> <1463479192-2488-6-git-send-email-olivier.matz@6wind.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Olivier Matz , "dev@dpdk.org" , Chao Zhu , "Xie, Huawei" To: David Marchand Return-path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id F0254592F for ; Mon, 23 May 2016 15:06:37 +0200 (CEST) Content-Disposition: inline In-Reply-To: List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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