From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id ADAD6A0567; Fri, 13 Mar 2020 10:09:22 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E5A7C1C011; Fri, 13 Mar 2020 10:09:21 +0100 (CET) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by dpdk.org (Postfix) with ESMTP id 832461C00E for ; Fri, 13 Mar 2020 10:09:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584090559; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3EcpLIQTkPDIOKWbpyWa99NPZD8ierjrgYjeQzAsJEw=; b=aU5XFC5/ov/pdI9jhvR/C2FGGH5WqiCqTWjLlkwZ8kmXNwGFXOkk9fRfo+C7/Ash6HFfwY 5DHx4O97b3coelP94ywKLuL/SOwhr1rjrKf0IhAAxgTB5SgBeZzuxCtxP5G4rtax6jtUIC 9GUF48GTfd93kVmGnfY36ujQMDs0SS0= Received: from mail-vk1-f200.google.com (mail-vk1-f200.google.com [209.85.221.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-332-wSPC87xOOke44I_ATO4Zlg-1; Fri, 13 Mar 2020 05:09:17 -0400 X-MC-Unique: wSPC87xOOke44I_ATO4Zlg-1 Received: by mail-vk1-f200.google.com with SMTP id y5so3491871vkg.19 for ; Fri, 13 Mar 2020 02:09:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=fDCoz/lZ0RHrRAnJnI2QwoFp1v9IXfg6mNwTzQHFvmk=; b=MqUjVpHLKE1amXuhQiq2RU0rZXnEBrEzu2krYke13Wv6EM+Uie602hVbxkys2X0Xbb 1ohSuZXjczoQCUi3775mxoBIqylZwemodTzpdZaqIJZYTylVt/lLGHI5HOJP1x4LcVWE 4+WCDPIRdPvy+hT1A1jyvspkqXwW7ZEsv8EBfMjyxlzdVC5lEyn4zQrwTwzN2jQ5x610 q8A+puK7UF4dkkrDRXcdZegjQSqXC6+75MVxJRm1J4xK4i3YNVXnEFyrC2kKAtvBt16U EML6znoTmE155sEylibWRsrwa4X5+jRxHTMgKAz+qVXxp1ugT5uWpSm/mWZ2Wlk0k17M 0nmw== X-Gm-Message-State: ANhLgQ2XAzMbibDuAbq8PScCYYk6wYsVKpSBWOzQ1SwWO/BqcOAmrGQm k1QtPBRzOeMcryCB5d7/441TulQqNDkUrc1D0U88eF0ElzETlTIRgAukLC3OK6ill/qAppEym19 xZxoJP7nDaMrSSUrHCPI= X-Received: by 2002:a67:643:: with SMTP id 64mr8634784vsg.180.1584090557125; Fri, 13 Mar 2020 02:09:17 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuA5UDrKQuG3P+UnuJTmEYrXFB2c8KeKBFRNPvhe9eZIN9CVjP+I83q9ZWN6aVyybvLvGQ/usJo2q3IyHSDy/s= X-Received: by 2002:a67:643:: with SMTP id 64mr8634765vsg.180.1584090556715; Fri, 13 Mar 2020 02:09:16 -0700 (PDT) MIME-Version: 1.0 References: <20200226195033.33877-1-drc@linux.vnet.ibm.com> In-Reply-To: <20200226195033.33877-1-drc@linux.vnet.ibm.com> From: David Marchand Date: Fri, 13 Mar 2020 10:09:05 +0100 Message-ID: To: David Christensen Cc: dev X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [dpdk-dev] [PATCH] bus/pci: support iova=va on PowerNV systems X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Wed, Feb 26, 2020 at 8:50 PM David Christensen wrote: > > Bare metal PowerNV systems include a DPDK supported IOMMU that allows > IOVA=3DVA 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 > --- > 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_dev= ice *dev) > bool > pci_device_iommu_support_va(__rte_unused const struct rte_pci_device *de= v) > { > + /* > + * 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 =3D 0; Nit: NULL > + size_t len =3D 0; > + char filename[PATH_MAX] =3D "/proc/cpuinfo"; > + FILE *fp =3D fopen(filename, "r"); > + > + if (fp =3D=3D 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) !=3D -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 stor= ing the line, which should be freed by the user program. (In this ca= se, the value in *n is ignored.) > + if (strstr(line, "platform") !=3D NULL) Nit, to avoid multiple level of indent, how about invert the check: if (strstr(line, "platform") =3D=3D NULL) continue; > + if (strstr(line, "PowerNV") !=3D 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 > --=20 David Marchand