From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A2E58A0C4E; Tue, 2 Nov 2021 11:08:41 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7DE7F41101; Tue, 2 Nov 2021 11:08:38 +0100 (CET) Received: from AZHDRRW-EX01.nvidia.com (azhdrrw-ex01.nvidia.com [20.51.104.162]) by mails.dpdk.org (Postfix) with ESMTP id B64D940689; Tue, 2 Nov 2021 11:08:36 +0100 (CET) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.100) by mxs.oss.nvidia.com (10.13.234.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.858.15; Tue, 2 Nov 2021 03:08:35 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZosbvaN1zb/K0Ng3ulD5Al98S0NPvpzydxbW6vhgB9WxdpA5FeCHFs3bhDfndCU7XdPE5roEwDkzh5E0j6lIZN1MZROR2NEVvFE296fExGtWlxJGCU6KXz/JeTiY0di5DMjusJoHbQKH5M7S3vfV52kOLNfWYsun6QhwLUiPwVa0hprmkjEPB+smcgwW1rFWvy6WAFrC1ZfCoit32zr6Y2MUDH8qdYrnFA1m2dlLvBcG+TZwx1nhY0MTewBcjpIXoxJfHod+8AWPptl1livbNkjFP8cYS6Zxr5hPTBGbJkLwyFmiWbLzNMXFvlg3kr7/cMsIrzdj5zlj3daE3Gqcvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=IADcUGopLti3pFcusO7sSbfhD+0bfc0oCGw5L2d23jQ=; b=ExrlsXGH54L25Hrg93NMXYyzvQ7dpzdmYezili7wMVXpS/tDW6fG/aZM1m2nA6MxVA8YCWXv0OQRPsJLtaZnFkEBoHyxSBfp4LftZYtg6oNADq2uQ54VFMVPqlIWdDrFQ4PU4FJXpyEsWNxqhRsQb2ZIzdy0qR656ARPS962UxzD/7wIoTVwSP+QBSlGUp6GxuOaaJVGMJBf3mi2xkLgprYEgnH5Ha2jhRbTusvy6fAryuOjv0/sdmmbmJvqtfMEaJpwupOtAGTmP0hhNGm8WKwxUP8bEncMuI7PprDKyQ+rbInt8M2RMpGAO3WFTd/a4ZKMSqyIsQbsoZHd+zQwew== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IADcUGopLti3pFcusO7sSbfhD+0bfc0oCGw5L2d23jQ=; b=fIoI874ZcQZ9ITTZCbIPvb1TXibmYdIqDtxwU2//BQNjswZsnFAmQDnc0w608+xSLA8ej9QieQvCzDnO0JlkO2pdbK2gHi4je+ukNm00BLdlB4jFZjip6/+Sm1jgmSBRIdvjCRga4myuaNGs+sHHQ4ei1zpmyUDcjxysgLIBATLrUKD1fu9WRt9sNogAYZgvc0emVkc7ypXLvXTt2LTlWDBgEBB3/kTAttfXsEn7IDMirT+hzsYknpY0Rko2RhJ9j/xckial3NI0qJDSBEgexdYxoO9U4o4LYVVJ/K5lrtd24FRdzLL9hd4hGB+K/k/3MjSGelZKYe0Bol+PRDSgRw== Received: from BN0PR04CA0108.namprd04.prod.outlook.com (2603:10b6:408:ec::23) by BN9PR12MB5162.namprd12.prod.outlook.com (2603:10b6:408:11b::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.15; Tue, 2 Nov 2021 10:08:33 +0000 Received: from BN8NAM11FT014.eop-nam11.prod.protection.outlook.com (2603:10b6:408:ec:cafe::1) by BN0PR04CA0108.outlook.office365.com (2603:10b6:408:ec::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10 via Frontend Transport; Tue, 2 Nov 2021 10:08:33 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by BN8NAM11FT014.mail.protection.outlook.com (10.13.177.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4649.14 via Frontend Transport; Tue, 2 Nov 2021 10:08:33 +0000 Received: from nvidia.com (172.20.187.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 2 Nov 2021 10:08:31 +0000 From: Dmitry Kozlyuk To: CC: , , Bruce Richardson Date: Tue, 2 Nov 2021 12:08:15 +0200 Message-ID: <20211102100817.916303-2-dkozlyuk@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211102100817.916303-1-dkozlyuk@nvidia.com> References: <20211101073701.825389-1-dkozlyuk@nvidia.com> <20211102100817.916303-1-dkozlyuk@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL111.nvidia.com (172.20.187.18) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f12ffa80-d526-41e6-4c18-08d99de8ba67 X-MS-TrafficTypeDiagnostic: BN9PR12MB5162: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: u8j7+I9eJed3rDEGnx5kvCpRxmONMmeCT8ryBhPKLJZBdj1oqKnnewWksJM+OpPN4zgHKOgPXmpkIQgewI0HjuWP/ho/bbOakVn5vp69P16pQ6u8vtNUUs+1y90BKlEmdTyz1CS8jqqsf1WFi1aEOuWvLYncVD+Xitysjca6LM9ytr7cs44AJC2TIvjX1yov1nNzXQwbla84lc//+MmVkKDxedTpK+Tcd/PKabdlkCopgnvuoPvoY8R4zysPN/HxJD4/czpeDb/Lo0m4pymZBJeuSk/alnDQ7b5jS/d8ayfnGyXM7tM6YXGcWjxB2KvOo/ZFplVbb3w7Cs3qgTSmBLMxSy/X+Dgb4Tihi1Mn8WJhzoGc9Xxp/6tZV6xGLCODBlvXioyZ/gPxYQdrQBLi6fFxWT8ABFDBzm+7dISsmUswwFf7S2TVMB55UdSrzKxCogy9STowO7WcWoFd4AywH0Sf716ImSUt0GXgEb4ud2PWJ6pAPdDQ2X60xtUdeU6ncSXKuXJ2p+55KSvHzZ76g6zIdXwXbMZwn57KyGKkOjBWDsRsLZvRO0XIdcT+Ok8SFsa7e9TphqJp+lGKOWSW0ODsa250iVeWF4vSRGwHj1YHDmR3OSyzRxHIT6TVleo2pDBoD1RxZF9Os1hdJcc0u7CMgcsEFYeOkr2AL579uHeorGxEMc5K0TimOZ6iFyPmwGjQMNYX0ZHsCytlgyUI/Q== X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(46966006)(36840700001)(36860700001)(55016002)(36756003)(6666004)(6286002)(107886003)(7696005)(8676002)(26005)(47076005)(16526019)(508600001)(316002)(4326008)(83380400001)(82310400003)(450100002)(336012)(54906003)(8936002)(86362001)(6916009)(2906002)(426003)(2616005)(356005)(1076003)(7636003)(186003)(70206006)(5660300002)(70586007); DIR:OUT; SFP:1101; X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Nov 2021 10:08:33.3222 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f12ffa80-d526-41e6-4c18-08d99de8ba67 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT014.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5162 Subject: [dpdk-dev] [PATCH v3 1/3] eal/freebsd: fix IOVA mode selection 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 Sender: "dev" FreeBSD EAL selected IOVA mode PA even in --no-huge mode where PA are not available. Memory zones were created with IOVA equal to RTE_BAD_IOVA with no indication this field is not usable. Change IOVA mode detection: 1. Always allow to force --iova-mode=va. 2. In --no-huge mode, disallow forcing --iova-mode=pa, and select VA. 3. Otherwise select IOVA mode according to bus requests, default to PA. In case contigmem is inaccessible, memory initialization will fail with a message indicating the cause. Fixes: c2361bab70c5 ("eal: compute IOVA mode based on PA availability") Cc: benjamin.walker@intel.com Cc: stable@dpdk.org Signed-off-by: Dmitry Kozlyuk Acked-by: Bruce Richardson --- lib/eal/freebsd/eal.c | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c index 9935356ed4..2c2baaa691 100644 --- a/lib/eal/freebsd/eal.c +++ b/lib/eal/freebsd/eal.c @@ -677,6 +677,8 @@ rte_eal_init(int argc, char **argv) const struct rte_config *config = rte_eal_get_configuration(); struct internal_config *internal_conf = eal_get_internal_configuration(); + bool has_phys_addr; + enum rte_iova_mode iova_mode; /* checks if the machine is adequate */ if (!rte_cpu_is_supported()) { @@ -777,19 +779,30 @@ rte_eal_init(int argc, char **argv) return -1; } - /* if no EAL option "--iova-mode=", use bus IOVA scheme */ - if (internal_conf->iova_mode == RTE_IOVA_DC) { - /* autodetect the IOVA mapping mode (default is RTE_IOVA_PA) */ - enum rte_iova_mode iova_mode = rte_bus_get_iommu_class(); - - if (iova_mode == RTE_IOVA_DC) - iova_mode = RTE_IOVA_PA; - rte_eal_get_configuration()->iova_mode = iova_mode; - } else { - rte_eal_get_configuration()->iova_mode = - internal_conf->iova_mode; + /* + * PA are only available for hugepages via contigmem. + * If contigmem is inaccessible, rte_eal_hugepage_init() will fail + * with a message describing the cause. + */ + has_phys_addr = internal_conf->no_hugetlbfs == 0; + iova_mode = internal_conf->iova_mode; + if (iova_mode == RTE_IOVA_PA && !has_phys_addr) { + rte_eal_init_alert("Cannot use IOVA as 'PA' since physical addresses are not available"); + rte_errno = EINVAL; + return -1; } - + if (iova_mode == RTE_IOVA_DC) { + RTE_LOG(DEBUG, EAL, "Specific IOVA mode is not requested, autodetecting\n"); + if (has_phys_addr) { + RTE_LOG(DEBUG, EAL, "Selecting IOVA mode according to bus requests\n"); + iova_mode = rte_bus_get_iommu_class(); + if (iova_mode == RTE_IOVA_DC) + iova_mode = RTE_IOVA_PA; + } else { + iova_mode = RTE_IOVA_VA; + } + } + rte_eal_get_configuration()->iova_mode = iova_mode; RTE_LOG(INFO, EAL, "Selected IOVA mode '%s'\n", rte_eal_iova_mode() == RTE_IOVA_PA ? "PA" : "VA"); -- 2.25.1