From patchwork Fri Sep 7 15:58:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Stojaczyk, Dariusz" X-Patchwork-Id: 44420 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 999F8493D; Fri, 7 Sep 2018 18:00:34 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 9DA1C493D for ; Fri, 7 Sep 2018 18:00:33 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Sep 2018 09:00:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,343,1531810800"; d="scan'208";a="72433109" Received: from violet.igk.intel.com ([10.102.17.58]) by orsmga006.jf.intel.com with ESMTP; 07 Sep 2018 09:00:11 -0700 From: Darek Stojaczyk To: dev@dpdk.org, Santosh Shukla , Hemant Agrawal , Jerin Jacob Cc: Maxime Coquelin , Anatoly Burakov , Chas Williams , Darek Stojaczyk Date: Fri, 7 Sep 2018 17:58:43 +0200 Message-Id: <20180907155843.96465-1-dariusz.stojaczyk@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180907154703.83316-1-dariusz.stojaczyk@intel.com> References: <20180907154703.83316-1-dariusz.stojaczyk@intel.com> Subject: [dpdk-dev] [PATCH v2] eal/bus: use RTE_IOVA_PA only if phys addresses are available 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" When neither RTE_IOVA_VA nor RTE_IOVA_PA was explicitly requested, DPDK would currently fallback to the default RTE_IOVA_PA mode and possibly encounter a failure later on if running as a non-priviledged user. Attempting to use RTE_IOVA_VA if no phys addresses are available may help in this case. Signed-off-by: Darek Stojaczyk --- Changes since v1: * added a missing rte_memory.h include lib/librte_eal/common/eal_common_bus.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c index 0943851cc..68c581b8a 100644 --- a/lib/librte_eal/common/eal_common_bus.c +++ b/lib/librte_eal/common/eal_common_bus.c @@ -37,6 +37,7 @@ #include #include #include +#include #include "eal_private.h" @@ -236,9 +237,19 @@ rte_bus_get_iommu_class(void) mode |= bus->get_iommu_class(); } - if (mode != RTE_IOVA_VA) { - /* Use default IOVA mode */ - mode = RTE_IOVA_PA; + if (mode == RTE_IOVA_VA) + return RTE_IOVA_VA; + + if (mode & RTE_IOVA_PA) { + /* Not all buses support RTE_IOVA_VA, fallback to RTE_IOVA_PA */ + return RTE_IOVA_PA; + } + + if (rte_eal_using_phys_addrs()) { + /* Default to RTE_IOVA_PA only if it's supported */ + return RTE_IOVA_PA; } - return mode; + + /* Since RTE_IOVA_PA is unsupported, fallback to RTE_IOVA_VA */ + return RTE_IOVA_VA; }