From mboxrd@z Thu Jan 1 00:00:00 1970 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) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP; 23 May 2016 06:06:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,355,1459839600"; d="scan'208";a="986848162" Received: from yliu-dev.sh.intel.com (HELO yliu-dev) ([10.239.67.162]) by fmsmga002.fm.intel.com with ESMTP; 23 May 2016 06:06:27 -0700 Date: Mon, 23 May 2016 21:07:49 +0800 From: Yuanhan Liu To: David Marchand Cc: Olivier Matz , "dev@dpdk.org" , Chao Zhu , "Xie, Huawei" 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 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Subject: Re: [dpdk-dev] [PATCH v2 5/7] eal/linux: mmap ioports on ppc64 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 May 2016 13:06:38 -0000 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