DPDK patches and discussions
 help / color / mirror / Atom feed
From: David Marchand <david.marchand@redhat.com>
To: David Christensen <drc@linux.vnet.ibm.com>
Cc: dev <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH] bus/pci: support iova=va on PowerNV systems
Date: Fri, 13 Mar 2020 10:09:05 +0100	[thread overview]
Message-ID: <CAJFAV8z8m7sG5hZkTGb=D=x5kDY=uxPqb0uYZazQjVvMEuQ7Mw@mail.gmail.com> (raw)
In-Reply-To: <20200226195033.33877-1-drc@linux.vnet.ibm.com>

On Wed, Feb 26, 2020 at 8:50 PM David Christensen
<drc@linux.vnet.ibm.com> wrote:
>
> Bare metal PowerNV systems include a DPDK supported IOMMU that allows
> IOVA=VA support. Test for the platform type and report virtual address
> support if running on a PowerNV system.

I can't test it, so I'll trust you on this :-).
Comments below.


>
> Signed-off-by: David Christensen <drc@linux.vnet.ibm.com>
> ---
>  drivers/bus/pci/linux/pci.c | 29 +++++++++++++++++++++++++++++
>  1 file changed, 29 insertions(+)
>
> diff --git a/drivers/bus/pci/linux/pci.c b/drivers/bus/pci/linux/pci.c
> index 740a2cdad..696dc177e 100644
> --- a/drivers/bus/pci/linux/pci.c
> +++ b/drivers/bus/pci/linux/pci.c
> @@ -549,6 +549,35 @@ pci_device_iommu_support_va(const struct rte_pci_device *dev)
>  bool
>  pci_device_iommu_support_va(__rte_unused const struct rte_pci_device *dev)
>  {
> +       /*
> +        * IOMMU is always present on a PowerNV host (IOMMUv2).
> +        * IOMMU is also present in a KVM/QEMU VM (IOMMUv1) but is not
> +        * currently supported by DPDK. Test for our current environment
> +        * and report VA support as appropriate.
> +        */
> +
> +       char *line = 0;

Nit: NULL

> +       size_t len = 0;
> +       char filename[PATH_MAX] = "/proc/cpuinfo";
> +       FILE *fp = fopen(filename, "r");
> +
> +       if (fp == NULL) {
> +               RTE_LOG(ERR, EAL, "%s(): can't open %s: %s\n",
> +                       __func__, filename, strerror(errno));
> +               return false;
> +       }
> +
> +       /* Check for a PowerNV platform */
> +       while (getline(&line, &len, fp) != -1) {

From here, you leak line.

man getline

       ssize_t getline(char **lineptr, size_t *n, FILE *stream);

       If  *lineptr is NULL, then getline() will allocate a buffer for storing
       the line, which should be freed by the user program.   (In  this  case,
       the value in *n is ignored.)


> +               if (strstr(line, "platform") != NULL)

Nit, to avoid multiple level of indent, how about invert the check:

if (strstr(line, "platform") == NULL)
    continue;

> +                       if (strstr(line, "PowerNV") != NULL) {
> +                               RTE_LOG(DEBUG, EAL, "Running on a PowerNV system\n");

Not really helpful, it does not indicate that this system iommu supports VA.


> +                               fclose(fp);
> +                               return true;
> +                       }
> +       }
> +       fclose(fp);
> +
>         return false;
>  }
>  #else
> --
> 2.18.1
>


-- 
David Marchand


  reply	other threads:[~2020-03-13  9:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-26 19:50 David Christensen
2020-03-13  9:09 ` David Marchand [this message]
2020-03-16 16:09   ` David Christensen
2020-03-16 20:38 ` [dpdk-dev] [PATCH v2] " David Christensen
2020-04-25 14:54   ` David Marchand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAJFAV8z8m7sG5hZkTGb=D=x5kDY=uxPqb0uYZazQjVvMEuQ7Mw@mail.gmail.com' \
    --to=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=drc@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).