From patchwork Thu Nov 23 15:51:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Ehrhardt X-Patchwork-Id: 134588 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C4FDC433AC; Thu, 23 Nov 2023 16:52:03 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B7CCE42F0B; Thu, 23 Nov 2023 16:52:03 +0100 (CET) Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by mails.dpdk.org (Postfix) with ESMTP id 074A742F0B for ; Thu, 23 Nov 2023 16:52:03 +0100 (CET) Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id CE5AB406D3 for ; Thu, 23 Nov 2023 15:52:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1700754722; bh=vBTN66N67BzxWYV/bemFonc7ERUGcD24Z7x37wuNaOs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Jb6dRawR5zFVN+3XJePC9Ya5iPUmLHSM/+ZHJCuRWTVrpUSuo6Mu8csNhzbysWvNr crr2MhS6a12ni2x37UTEHPFVk9nW8TdGOnjlVAtjtj+WDWoGBX2dCEiEDG0xzX1WO+ iYUfQafkFE8nEPVZ04YodF4OkOYRN+gCeRyTZyu0ROYbDOtyQkkF1kvY2fz+xTHPwV 132uF7hJDBiCpeJLty1WwSHzbjaEzDd8rHJ8QBEnmFQSj1OpvIBiBBQVnSsHDm+7gi D04amC70DG67FGKMocZ9aLivv1sbbDOCTFkBSnT06obl84nqy/G6paskNS/6uhksbs lBgNAzhZAs5jg== Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-a047f347c1cso193512366b.1 for ; Thu, 23 Nov 2023 07:52:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700754722; x=1701359522; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vBTN66N67BzxWYV/bemFonc7ERUGcD24Z7x37wuNaOs=; b=lqBvYSljRVUsApdfKFRDi8GZRYCmLu50Y2EjnMvvr9ICpxWPlx5Ej/gPkO10ofIASp 0XU3tfE4EBU1VOouSHqjY9k8b70y1w/kGMqQ3nP0DohkFa6uJg81v3Y+BAson6VF/Ie0 TENX7cWVUiSQ7Lh390GaBtSjWjSrcW5mIo3hsJyXCK9laJ3+vOD3Mh2IEuW+KpzsVn7q vxtr2iTqaGhkIcAPDl/pV7gPKT3fWJs8bTcyslFrUNfUEsN0cyyArY59fOT4+Bm3+/dx yHqNR0GBkWxMRqTZAJg/bDmQLCp9PTH6K/fEGnF88pLPVNBEN142SGYZeu/JWGJ0nm16 UIyA== X-Gm-Message-State: AOJu0YxVvuI73stzRiQWxwJuLfw4ZK8/7oMvqXctrLfoEuAPVlzgHh7t CllCuDPFIKATwoy75RY96/S3uIuKHOsMPxQH8s8OFJMVrWyDi9sixm9XBzRS08dmJO3iEZqEX9Z 1hXmLomT4ohpYohTzfprmCZlPCCm1 X-Received: by 2002:a17:906:19c8:b0:9fd:79b3:e2b3 with SMTP id h8-20020a17090619c800b009fd79b3e2b3mr2814127ejd.9.1700754721732; Thu, 23 Nov 2023 07:52:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IHL/uQ0e/I2COFoT7dAv7ScLxzazASoakWBrV56xoEdjoXY/RYXAJwSrxpWpIrKQ4QXgUvN7A== X-Received: by 2002:a17:906:19c8:b0:9fd:79b3:e2b3 with SMTP id h8-20020a17090619c800b009fd79b3e2b3mr2814120ejd.9.1700754721459; Thu, 23 Nov 2023 07:52:01 -0800 (PST) Received: from Keschdeichel.fritz.box ([2a02:6d40:39cc:3f00:f31c:f858:3d7f:329d]) by smtp.gmail.com with ESMTPSA id mm21-20020a170906cc5500b009fd490c4cb6sm933879ejb.39.2023.11.23.07.52.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 07:52:01 -0800 (PST) From: christian.ehrhardt@canonical.com To: dev Cc: Luca Boccassi , David Wilder , Christian Ehrhardt Subject: [PATCH 1/1] eal/linux: force iova-mode va without pa available Date: Thu, 23 Nov 2023 16:51:49 +0100 Message-Id: <20231123155149.306556-2-christian.ehrhardt@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231123155149.306556-1-christian.ehrhardt@canonical.com> References: <20231123155149.306556-1-christian.ehrhardt@canonical.com> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: David Wilder When using --no-huge option physical address are not guaranteed to be persistent. This change effectively makes "--no-huge" the same as "--no-huge --iova-mode=va". When --no-huge is used (or any other condition making physical addresses unavailable) setting --iova-mode=pa will have no effect. Signed-off-by: Christian Ehrhardt --- doc/guides/prog_guide/env_abstraction_layer.rst | 9 ++++++--- lib/eal/linux/eal.c | 14 ++++++++------ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/doc/guides/prog_guide/env_abstraction_layer.rst b/doc/guides/prog_guide/env_abstraction_layer.rst index 6debf54efb..20c7355e0f 100644 --- a/doc/guides/prog_guide/env_abstraction_layer.rst +++ b/doc/guides/prog_guide/env_abstraction_layer.rst @@ -559,9 +559,12 @@ IOVA Mode is selected by considering what the current usable Devices on the system require and/or support. On FreeBSD, RTE_IOVA_PA is always the default. On Linux, the IOVA mode is -detected based on a 2-step heuristic detailed below. +detected based on a heuristic detailed below. -For the first step, EAL asks each bus its requirement in terms of IOVA mode +For the first step, if no Physical Addresses are available RTE_IOVA_VA is +selected. + +Then EAL asks each bus its requirement in terms of IOVA mode and decides on a preferred IOVA mode. - if all buses report RTE_IOVA_PA, then the preferred IOVA mode is RTE_IOVA_PA, @@ -575,7 +578,7 @@ and decides on a preferred IOVA mode. If the buses have expressed no preference on which IOVA mode to pick, then a default is selected using the following logic: -- if physical addresses are not available, RTE_IOVA_VA mode is used +- if enable_iova_as_pa was not set at build RTE_IOVA_VA mode is used - if /sys/kernel/iommu_groups is not empty, RTE_IOVA_VA mode is used - otherwise, RTE_IOVA_PA mode is used diff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c index 57da058cec..7d0eedef57 100644 --- a/lib/eal/linux/eal.c +++ b/lib/eal/linux/eal.c @@ -1067,6 +1067,14 @@ rte_eal_init(int argc, char **argv) phys_addrs = rte_eal_using_phys_addrs() != 0; + if (!phys_addrs) { + /* if we have no access to physical addresses, + * pick IOVA as VA mode. + */ + iova_mode = RTE_IOVA_VA; + RTE_LOG(INFO, EAL, "Physical addresses are unavailable, selecting IOVA as VA mode.\n"); + } + /* if no EAL option "--iova-mode=", use bus IOVA scheme */ if (internal_conf->iova_mode == RTE_IOVA_DC) { /* autodetect the IOVA mapping mode */ @@ -1078,12 +1086,6 @@ rte_eal_init(int argc, char **argv) if (!RTE_IOVA_IN_MBUF) { iova_mode = RTE_IOVA_VA; RTE_LOG(DEBUG, EAL, "IOVA as VA mode is forced by build option.\n"); - } else if (!phys_addrs) { - /* if we have no access to physical addresses, - * pick IOVA as VA mode. - */ - iova_mode = RTE_IOVA_VA; - RTE_LOG(DEBUG, EAL, "Physical addresses are unavailable, selecting IOVA as VA mode.\n"); } else if (is_iommu_enabled()) { /* we have an IOMMU, pick IOVA as VA mode */ iova_mode = RTE_IOVA_VA;