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 B3630A0C52; Mon, 1 Nov 2021 08:37:32 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A8C7C41104; Mon, 1 Nov 2021 08:37:26 +0100 (CET) Received: from AZHDRRW-EX02.NVIDIA.COM (azhdrrw-ex02.nvidia.com [20.64.145.131]) by mails.dpdk.org (Postfix) with ESMTP id BAB1D410FE; Mon, 1 Nov 2021 08:37:24 +0100 (CET) Received: from NAM02-BN1-obe.outbound.protection.outlook.com (104.47.51.47) by mxs.oss.nvidia.com (10.13.234.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.858.15; Mon, 1 Nov 2021 00:37:23 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Llr05C/SFEWAOeH2PkRuRmEWeD3ckQNE2I9K04AKbtoqNNcL/s3C+TiM4kuyd0SlW/LnQZ1IXqS9BoG/vkNU0n83kIBgLCfFI/9JOhmGFU6n3f1P6WrIzlYq9o5XVZ5yDl7CdSk7gnzqkTVSH16roLNoHhvRR0WjaB9YQUEMhlji+WzTGQwTI1qJWbmGuvsuRizF4PiizXmZaauydMm2JpnN5hPlDbztRnuANw2Ib4SqTwWPBfAzL2GdUk+KnaZBAe5wLn3IOHY/qjGg3xT+57rMGPzG5iuGhjFJuDANr0YHgzPTSBaO+VphWDbWR98C7+V2aw7+iJNLDn00NOJKRg== 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=5UVJlvazGUekMdzKtoQRIEN5ZQfemS3byuLadRqdqeE=; b=OxUXegPjQgppx7nuI8nqdUu10BIe8U7M+Z0MTq47SsMcHWUqqP7idrus3uxS3bWOC0pToqlfmGz8ttsPkPhPR66g8tCFwF2w4lJqCKRLH4PPc0AsCNnMgnbb24hW31todM3ERW4qCP/uJBxDlbqKthxjLlv6+6VuFbLJU/nTqZCOp3nwKQ4X8AvIo+2urXl9WcFQvMwhRKQY2ODwGP8lW4ed+ECsL0keKAlHM/xBwa/knnmIiyiF1koSJ/JCFKwuWgmQjWCtsgGFokfpUPoUR6xFNGOd2USNLoqNn26Z9luAdHTfKsCLNoJ9H19zoyf2xwrn0pMVDVkkNdQY0kMiqw== 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=5UVJlvazGUekMdzKtoQRIEN5ZQfemS3byuLadRqdqeE=; b=pMpagOKt9VOCWmCQzCT67Piwg/1ZJADHmkLt4Som2Ze3lKJX5UGwlwMo4K5n3mBTRp/g+3Xffrzygnznfaq1NZPkLJtK23q86kXmIq288vCRdPfxmJeWgLJZJhlbZOkGri7Oor8SJXLRmbJ3AsYvzNNfTokDLn0QQ8VuUnuRR9rkPfMZVwnWO7arUbNtW/vXtuJf+Lfyp/zGS3gJrNjWqvcCTjSN6QIQwTecgd4RTX+S1OZbygXhyiP5/UkfrDYsIHeosC0TD/FBSU+9SBVF6cert3BdMErG3WVTwEUb31Y0GaJ2jN+kynfs4LQYLTu6z6ehBsXiO7oMxLtuXNj35A== Received: from MW4PR04CA0338.namprd04.prod.outlook.com (2603:10b6:303:8a::13) by MN2PR12MB2926.namprd12.prod.outlook.com (2603:10b6:208:10a::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.15; Mon, 1 Nov 2021 07:37:19 +0000 Received: from CO1NAM11FT024.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8a:cafe::fe) by MW4PR04CA0338.outlook.office365.com (2603:10b6:303:8a::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4649.15 via Frontend Transport; Mon, 1 Nov 2021 07:37:19 +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 CO1NAM11FT024.mail.protection.outlook.com (10.13.174.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4649.14 via Frontend Transport; Mon, 1 Nov 2021 07:37:19 +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; Mon, 1 Nov 2021 07:37:17 +0000 From: Dmitry Kozlyuk To: CC: Anatoly Burakov , , , Bruce Richardson Date: Mon, 1 Nov 2021 09:36:59 +0200 Message-ID: <20211101073701.825389-2-dkozlyuk@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211101073701.825389-1-dkozlyuk@nvidia.com> References: <20211029084051.679233-1-dkozlyuk@nvidia.com> <20211101073701.825389-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: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f187ad47-a3f4-4907-eea2-08d99d0a6f46 X-MS-TrafficTypeDiagnostic: MN2PR12MB2926: 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: axnZaJmf81YH6r4twIo7f+xuo9Oa/FQTqhOeCQp49B+vYl/eDp1kadeCJ7CJPiBlDao3p/TQzngXvratbnDgVs94R2j+MB5zkoWjQgE3kQzV8KVAIi2cjtMjDntnRq7qA7QYcUZFNuMGNSi4Ng1/gQtgvaDko2V0kosOLIZXRnEfbvs+03AF4r+e097ZSNLEuRoXvqZ9Hc2XfUxsg/dkIRWv/DoOmdqpvYoxj+nE10uGlrnw547ZfQnDAj/HuMeyUsfK2ju49kf5XGZ1f04WmgiLTD7MfdC3/jot3YXZQzGjEeurwJxmumrLOPMPzt+2ipaTg5/VO24+pYH5WosJd6lGWjHTcnr5Ej2+yIYOCyje0RH3OpXQXwiiUtvKRfU8Y4AFOas9roC3XQ8RLnOxzRicMKKqi0cvsi3U7TT7f/O2kR4CPJ0WimSqXr+1Z1s/i4I9VWhzDsR70v3I4MJ/KLToF86yRkvyPpD1h4y9PTMnt9ryZXuW54xs/4nmm59VKsUdjThAXcBcinobZ/QTemkMgIPekwozYyTpCAO/J1EKWeeW6eG3cjGCO08ab7X/Tsowit67sG48l5Y6whj3hcrEPYnL0Yxn/e9p5opCHocq6HR9vYfMPEooUW+njFlYxK2phMLuXflwJnZtuRs21yemj1JQ5nF3KNM2a+VH02rz7HTmFkoMf21YMXFCWAcJT2VlZgQYnV05qTm4pYXOaA== 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)(86362001)(336012)(82310400003)(1076003)(7696005)(508600001)(2616005)(70586007)(426003)(5660300002)(70206006)(47076005)(55016002)(450100002)(6666004)(2906002)(6916009)(186003)(356005)(36906005)(83380400001)(36860700001)(107886003)(16526019)(4326008)(8936002)(6286002)(316002)(36756003)(8676002)(26005)(54906003)(7636003); DIR:OUT; SFP:1101; X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Nov 2021 07:37:19.0679 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f187ad47-a3f4-4907-eea2-08d99d0a6f46 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: CO1NAM11FT024.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB2926 Subject: [dpdk-dev] [PATCH v2 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 --- 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..519a645344 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,21 +779,32 @@ 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_LOG(INFO, EAL, "Selected IOVA mode '%s'\n", rte_eal_iova_mode() == RTE_IOVA_PA ? "PA" : "VA"); + rte_eal_get_configuration()->iova_mode = iova_mode; if (internal_conf->no_hugetlbfs == 0) { /* rte_config isn't initialized yet */ -- 2.25.1