[dpdk-dev] [PATCH v8 05/12] eal: Fix uio mapping differences between linuxapp and bsdapp

David Marchand david.marchand at 6wind.com
Tue Jul 7 10:04:42 CEST 2015


On Mon, Jul 6, 2015 at 8:24 AM, Tetsuya Mukawa <mukawa at igel.co.jp> 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 at 6wind.com>

-- 
David Marchand


More information about the dev mailing list