From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Marchand Subject: Re: [PATCH v8 05/12] eal: Fix uio mapping differences between linuxapp and bsdapp Date: Tue, 7 Jul 2015 10:04:42 +0200 Message-ID: References: <1435652668-3380-12-git-send-email-mukawa@igel.co.jp> <1436163861-3025-1-git-send-email-mukawa@igel.co.jp> <1436163861-3025-6-git-send-email-mukawa@igel.co.jp> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Cc: "dev@dpdk.org" To: Tetsuya Mukawa Return-path: Received: from mail-ob0-f177.google.com (mail-ob0-f177.google.com [209.85.214.177]) by dpdk.org (Postfix) with ESMTP id 567BD5A52 for ; Tue, 7 Jul 2015 10:04:43 +0200 (CEST) Received: by obdbs4 with SMTP id bs4so123592145obd.3 for ; Tue, 07 Jul 2015 01:04:42 -0700 (PDT) In-Reply-To: <1436163861-3025-6-git-send-email-mukawa@igel.co.jp> 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 Mon, Jul 6, 2015 at 8:24 AM, Tetsuya Mukawa wrote: > diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c > b/lib/librte_eal/bsdapp/eal/eal_pci.c > index 21d1e66..92d9886 100644 > --- a/lib/librte_eal/bsdapp/eal/eal_pci.c > +++ b/lib/librte_eal/bsdapp/eal/eal_pci.c > > @@ -170,19 +154,33 @@ pci_uio_map_secondary(struct rte_pci_device *dev) > TAILQ_FOREACH(uio_res, uio_res_list, next) { > > /* skip this element if it doesn't match our PCI address */ > - if (memcmp(&uio_res->pci_addr, &dev->addr, > sizeof(dev->addr))) > + if (rte_eal_compare_pci_addr(&uio_res->pci_addr, > &dev->addr)) > continue; > > for (i = 0; i != uio_res->nb_maps; i++) { > - if (pci_map_resource(uio_res->maps[i].addr, > - uio_res->path, > - > (off_t)uio_res->maps[i].offset, > - (size_t)uio_res->maps[i].size) > - != uio_res->maps[i].addr) { > + /* > + * open devname, to mmap it > + */ > + fd = open(uio_res->maps[i].path, O_RDWR); > + if (fd < 0) { > + RTE_LOG(ERR, EAL, "Cannot open %s: %s\n", > + uio_res->maps[i].path, > strerror(errno)); > + return -1; > + } > + > + void *mapaddr = > pci_map_resource(uio_res->maps[i].addr, > + fd, (off_t)uio_res->maps[i].offset, > + (size_t)uio_res->maps[i].size, 0); > I suppose you can close fd here > + if (mapaddr != uio_res->maps[i].addr) { > RTE_LOG(ERR, EAL, > - "Cannot mmap device resource\n"); > + "Cannot mmap device resource file > %s to address: %p\n", > + uio_res->maps[i].path, > + uio_res->maps[i].addr); > + close(fd); > and remove it from here > return -1; > } > + /* fd is not needed in slave process, close it */ > + close(fd); > and here. The rest is ok for me. Acked-by: David Marchand -- David Marchand