From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Burakov, Anatoly" Subject: Re: [PATCH v2 3/5] bus/pci: use IOVAs check when setting IOVA mode Date: Wed, 3 Oct 2018 13:55:55 +0100 Message-ID: <6b0b9159-d25b-56aa-0ca0-dd61b5206b04@intel.com> References: <1535719857-19092-1-git-send-email-alejandro.lucero@netronome.com> <1535719857-19092-4-git-send-email-alejandro.lucero@netronome.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Cc: stable@dpdk.org To: Alejandro Lucero , dev@dpdk.org Return-path: In-Reply-To: <1535719857-19092-4-git-send-email-alejandro.lucero@netronome.com> Content-Language: en-US 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 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; ? > } > #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 :) > } > return true; > -- Thanks, Anatoly