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 D3CBCA0487 for ; Wed, 3 Jul 2019 12:17:24 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CD9B41B203; Wed, 3 Jul 2019 12:17:23 +0200 (CEST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 37FD25B3C for ; Wed, 3 Jul 2019 12:17:22 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Jul 2019 03:17:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,446,1557212400"; d="scan'208";a="157925152" Received: from aburakov-mobl1.ger.corp.intel.com (HELO [10.237.220.126]) ([10.237.220.126]) by orsmga008.jf.intel.com with ESMTP; 03 Jul 2019 03:17:18 -0700 To: David Marchand , dev@dpdk.org Cc: benjamin.walker@intel.com, jerinj@marvell.com, maxime.coquelin@redhat.com, thomas@monjalon.net, Bruce Richardson References: <20190530174819.1160221-1-benjamin.walker@intel.com> <1560505157-9769-1-git-send-email-david.marchand@redhat.com> <1560505157-9769-3-git-send-email-david.marchand@redhat.com> From: "Burakov, Anatoly" Message-ID: <1cc18fa3-8ea7-e980-2007-e9a68d0a3f39@intel.com> Date: Wed, 3 Jul 2019 11:17:17 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <1560505157-9769-3-git-send-email-david.marchand@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v2 2/3] eal: compute IOVA mode based on PA availability 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 14-Jun-19 10:39 AM, David Marchand wrote: > From: Ben Walker > > Currently, if the bus selects IOVA as PA, the memory init can fail when > lacking access to physical addresses. > This can be quite hard for normal users to understand what is wrong > since this is the default behavior. > > Catch this situation earlier in eal init by validating physical addresses > availability, or select IOVA when no clear preferrence had been expressed. > > The bus code is changed so that it reports when it does not care about > the IOVA mode and let the eal init decide. > > In Linux implementation, rework rte_eal_using_phys_addrs() so that it can > be called earlier but still avoid a circular dependency with > rte_mem_virt2phys(). > In FreeBSD implementation, rte_eal_using_phys_addrs() always returns > false, so the detection part is left as is. > > If librte_kni is compiled in and the KNI kmod is loaded, > - if the buses requested VA, force to PA if physical addresses are > available as it was done before, > - else, keep iova as VA, KNI init will fail later. > > Signed-off-by: Ben Walker > Signed-off-by: David Marchand > --- > + /* autodetect the IOVA mapping mode */ > + enum rte_iova_mode iova_mode = rte_bus_get_iommu_class(); > > + if (iova_mode == RTE_IOVA_DC) { > + iova_mode = phys_addrs ? RTE_IOVA_PA : RTE_IOVA_VA; > + RTE_LOG(DEBUG, EAL, > + "Buses did not request a specific IOVA mode, using '%s' based on physical addresses availability.\n", > + phys_addrs ? "PA" : "VA"); > + } > +#ifdef RTE_LIBRTE_KNI > /* Workaround for KNI which requires physical address to work */ > - if (rte_eal_get_configuration()->iova_mode == RTE_IOVA_VA && > + if (iova_mode == RTE_IOVA_VA && > rte_eal_check_module("rte_kni") == 1) { > - rte_eal_get_configuration()->iova_mode = RTE_IOVA_PA; > - RTE_LOG(WARNING, EAL, > - "Some devices want IOVA as VA but PA will be used because.. " > - "KNI module inserted\n"); > + if (phys_addrs) { > + iova_mode = RTE_IOVA_PA; > + RTE_LOG(WARNING, EAL, "Forcing IOVA as 'PA' because KNI module is loaded\n"); > + } else { > + RTE_LOG(DEBUG, EAL, "KNI can not work since physical addresses are unavailable\n"); > + } > } > +#endif Why the ifdefs? I don't think there's something specific to KNI there, rte_eal_check_module() works absent of KNI. Otherwise LGTM, Acked-by: Anatoly Burakov I wish we would make IOVA as VA the default already, but at least picking it automatically when physical addresses aren't available is a good start :) -- Thanks, Anatoly