From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id DA0FA1B518 for ; Thu, 4 Oct 2018 17:49:53 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Oct 2018 08:49:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,340,1534834800"; d="scan'208";a="78483533" Received: from aburakov-mobl1.ger.corp.intel.com (HELO [10.237.220.113]) ([10.237.220.113]) by orsmga007.jf.intel.com with ESMTP; 04 Oct 2018 08:49:49 -0700 To: Alejandro Lucero , dev , Maxime Coquelin References: <1535719857-19092-1-git-send-email-alejandro.lucero@netronome.com> <1535719857-19092-4-git-send-email-alejandro.lucero@netronome.com> <6b0b9159-d25b-56aa-0ca0-dd61b5206b04@intel.com> From: "Burakov, Anatoly" Message-ID: Date: Thu, 4 Oct 2018 16:49:49 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-dev] [PATCH v2 3/5] bus/pci: use IOVAs check when setting IOVA mode 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: , X-List-Received-Date: Thu, 04 Oct 2018 15:49:54 -0000 On 04-Oct-18 2:35 PM, Alejandro Lucero wrote: > > > On Wed, Oct 3, 2018 at 1:56 PM Burakov, Anatoly > > wrote: > > On 31-Aug-18 1:50 PM, Alejandro Lucero wrote: > > Although VT-d emulation currently only supports 39 bits, it could > > be iovas being within that supported range. This patch allows > > IOVA mode in such a case. > > > > Indeed, memory initialization code can be modified for using lower > > virtual addresses than those used by the kernel for 64 bits processes > > by default, and therefore memsegs iovas can use 39 bits or less for > > most system. And this is likely 100% true for VMs. > > > > Signed-off-by: Alejandro Lucero > > > --- > >   drivers/bus/pci/linux/pci.c | 15 ++++++++++----- > >   1 file changed, 10 insertions(+), 5 deletions(-) > > > > diff --git a/drivers/bus/pci/linux/pci.c > b/drivers/bus/pci/linux/pci.c > > index 04648ac..215dc10 100644 > > --- a/drivers/bus/pci/linux/pci.c > > +++ b/drivers/bus/pci/linux/pci.c > > @@ -588,10 +588,11 @@ > >       fclose(fp); > > > >       mgaw = ((vtd_cap_reg & VTD_CAP_MGAW_MASK) >> > VTD_CAP_MGAW_SHIFT) + 1; > > -     if (mgaw < X86_VA_WIDTH) > > -             return false; > > > > -     return true; > > +     if (!rte_eal_check_dma_mask(mgaw)) > > +             return true; > > +     else > > +             return false; > > return rte_eal_check_dma_mask(mgaw) == 0; ? > > > I guess that works and is more elegant. > Thanks. > > > >   } > >   #elif defined(RTE_ARCH_PPC_64) > >   static bool > > @@ -615,13 +616,17 @@ > >   { > >       struct rte_pci_device *dev = NULL; > >       struct rte_pci_driver *drv = NULL; > > +     int iommu_dma_mask_check_done = 0; > > > >       FOREACH_DRIVER_ON_PCIBUS(drv) { > >               FOREACH_DEVICE_ON_PCIBUS(dev) { > >                       if (!rte_pci_match(drv, dev)) > >                               continue; > > -                     if (!pci_one_device_iommu_support_va(dev)) > > -                             return false; > > +                     if (!iommu_dma_mask_check_done) { > > +                             if > (!pci_one_device_iommu_support_va(dev)) > > +                                     return false; > > +                             iommu_dma_mask_check_done  = 1; > > +                     } > >               } > > The commit message doesn't explain why are we only checking a single > device. Indeed, i am not 100% clear as to why, so some explanation in > the commit message and preferably a comment in code would be more than > welcome :) > > > Because the pci_one_device_iommu_support_va function does always the > same whatever the device is used in the call. So, this code was always wrong and needlessly checked each device when it could've checked it a single time? OK, that makes it a bit clearer. Still, needs to be documented in comments/commit message :) The commit message IMO looks quite irrelevant to what happens in the commit. It almost feels like this commit should be split in two - first change the mgaw check, and then fix the PCI bus code to not check needlessly. -- Thanks, Anatoly