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 53F2043EAA for ; Fri, 19 Apr 2024 07:24:19 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3ED994067D; Fri, 19 Apr 2024 07:24:19 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2101.outbound.protection.outlook.com [40.107.237.101]) by mails.dpdk.org (Postfix) with ESMTP id 2BDA7402E1; Fri, 19 Apr 2024 07:24:15 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KXoXvJOBvD5X6yWALjFCUK2h5n8DjKcnaninHvvwpJc7IxxQKx2zIIFlsgIdEVEAV/WZI2tIPZwQlsLCTpqX/s8el1mHDqGxKqt+vIRiyRkbpuPFR6d+t97fmhUFgmZVvQ6eMgzY2M8z/Q4n7q4W/0WkwGiND3FmY9QYMZHEEqt5EBa44s5hA9XfU9Co9/RS8vlQsHJme6XTdXvu8lmwkD8Vk4ZZ9Dm96anfup+lM7cqPaO/++LEr27JlhnYbQT704SLGiPLnpfP9+FH/x6dp4f7qhuyIort8D5nOn7pjKcX/1vY15/UbYc/3RSRBf+MAbQ0XcCZUu//DboKeX2YNw== 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=+XFsOUIpDJOabUFDJrulPSjJb4fVEk763f6hmQD4NNk=; b=IMT215IKl46YqPa0kT6n4OqqJvzbH05p0lOwsUPfAy9o9+WatsR5r1vbwz/jSZ13+Uxz+IJWpCMcL+OvI3WmJE1juzW0jDjTYcEXUUGBRs7DKwGdzncdJ1frAtj4waob/67KkaSdJoiSDtZ4/xDX+Soi9YC11v6HxFU9LN+VkZwArpGcqwH1orlJgW9FafiLv68PCJaRqMXu9cV48c5eAZAxI9g3ogQYM2OK+cbY+c3uB4XCFlMmiJJGPcgQudILdz5gDb2ldKCN2wSDK1f25D7VTTVIEHvayjUgW/rGwNWabDbpwlWINulDy8NQt4rZT8DlkFIRbTwAFoRn9upzeA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+XFsOUIpDJOabUFDJrulPSjJb4fVEk763f6hmQD4NNk=; b=QuncJNYCqM2czSprUA7QnOTY30F52ZQdbIhNYmKWpj+OF+9HJDrXVu1ruur8uF92ymQAk4bWu65y/NA8rNcbEeyXYZ8P+YICbPM5GL2jP4MNJ8wEg2brJdgTHHNa2vD6AFLe7VSXkTF1cu3M5dJoMBjN5IXxnUZvCUjPuD2Vhnk= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) by MW3PR13MB3961.namprd13.prod.outlook.com (2603:10b6:303:2c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.42; Fri, 19 Apr 2024 05:24:13 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::ec12:7411:559a:850e]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::ec12:7411:559a:850e%5]) with mapi id 15.20.7472.042; Fri, 19 Apr 2024 05:24:13 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Chaoyong He , stable@dpdk.org, Long Wu , Peng Zhang Subject: [PATCH v2 2/8] net/nfp: fix configuration BAR problem Date: Fri, 19 Apr 2024 13:23:43 +0800 Message-Id: <20240419052349.1294696-3-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20240419052349.1294696-1-chaoyong.he@corigine.com> References: <20240419031226.1191069-1-chaoyong.he@corigine.com> <20240419052349.1294696-1-chaoyong.he@corigine.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SG2PR03CA0087.apcprd03.prod.outlook.com (2603:1096:4:7c::15) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|MW3PR13MB3961:EE_ X-MS-Office365-Filtering-Correlation-Id: 356832a8-343a-43e7-306d-08dc6030f331 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?rFHfpwoYSYy7KrfgU52b17pNWfgpAIRYfzVyHr/JsW2+tROgp/1RNxKJUnj3?= =?us-ascii?Q?8BMvpxTWGNO/8RRm1R1YZOHG6PkcCCOkTORbuAuMr9wnD668r28K9hE3cPW1?= =?us-ascii?Q?b1jvy2b9Kzo5OdXJS19wh8bfnJoIjfgrIqGECDgzBZkg6Jw0fP/iG9lToH2A?= =?us-ascii?Q?o/4qibyl3ldQOeAjfQcBqaPnxJ0dloBBtKOzi87qk/caQ5JxZNeplOf+ZpSR?= =?us-ascii?Q?wBRK4Grmiow4SoFv8326hWxeogmza7omxKFkiXZhlYeOjb6cOmqn4cwChjeh?= =?us-ascii?Q?QVrJaLGIGYQU6my/bP8d/SlPLjjjuHUogFNGWr4b93qj8S76BPp9+3wTOy1a?= =?us-ascii?Q?qkrF7XF91mHJCnIOV50wVBvmA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4/lYvTiFGBPfiIzxcMz6Ewy4HfCc3QjoVuilGSlq/B+5Lvqu1sw0?= =?us-ascii?Q?2VPXPoSL08SyUA/mRpWARIPatPebpkJm1zPXd2WYgKwGkw=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR13MB5545.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(52116005)(1800799015)(366007)(376005)(38350700005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?a+MbXDl1qtVdn8gKjYToPme4lKnHcMGiM/PJHh4HEVvkFQcaDJDobKYyR30Q?= =?us-ascii?Q?ZtZZTBFqk7CvPlF/dvZusMrT4ihwEPCU+k/1eE001AV/4/zFWFeZcJO1M/UL?= =?us-ascii?Q?k1ZO3rkZpHwUm5obc3jh1II7PeI2eQQZSqHrd1gFs+xXcjwYC4wwuVrJCEdI?= =?us-ascii?Q?tpdam/Qr64g7PiejdJeZ2xO861xYxOOfl/sS0iXdZPwkvrdvdEelUrJsv9Pp?= =?us-ascii?Q?lnixkhuTZ+u6VRtMIPmH1rS4PWMqL+C5XJK9gpf8pdjm+xTWJsiqCOEpqojz?= =?us-ascii?Q?D1efSP+Lo298SfuzKDmdsECjFkrHMIeYPt98Ajrx9eOjVl5DStineViiXRr8?= =?us-ascii?Q?9Wu33mQamuRNRS2Ecf0ySNBCMtu9Et2xALe6HZYbiuiDWaMAorFbjE4dQTgK?= =?us-ascii?Q?FEUxVQCy6YrVqd9Dxobc9Se0LiiTrDYnjg8r1tashuI/q0NNVXnjGjBgTIhQ?= =?us-ascii?Q?6/Pqd1b4lun+KPzO+/Z5XkTa9A0RQHvH0cwU3SwMEnYmtGXeoEfHNaf/hx7j?= =?us-ascii?Q?fC4i+U1t6uYgwuC6+uXLt+eW2MwgxLpoJNumauhwLue81h+QxP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NMhGhNKntQX1HsTW9TJ6rKdMasgoQaAYeMbBZ5kukuT?= =?us-ascii?Q?K3yiXySUdXZmGuavJ+VRWwzwfqVTmfTyP2bnzOdDMDxNSut6dSFWYQ9p62D2?= =?us-ascii?Q?IZ2Le934cAs5DxWsng9gQthKvkDk9Jkzs0tD912zdA86BcfImwO/fBG0OyCW?= =?us-ascii?Q?TQ=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 356832a8-343a-43e7-306d-08dc6030f331 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Apr 2024 05:24:13.5924 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: D1RCCMMDujddCRL/mini71/EcR30EwCBDNYHeD3pnq7fpi1g9nKzwkzDsz+R/xFRso3c34EapScVO1JLKLpz5cANttBnuRNGVOzcHWeO3Nw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR13MB3961 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org All the configuration bars are sit in an array, and the initial logic sort all the configuration BAR from small to large based on size and index, which result all valid bars are behind the invalid bars. But the BAR alloc logic search this array from the very beginning and only try limited times (equal to the valid bars number). It's ok for primary process because which has enough valid bars, and finally it can find one to use. But for secondary process and run with igb_uio driver, the valid bars are very limit, and it can not find one, and the logic will fail. Fix this by drop the sort logic, and search the bar array from the end to begin. Fixes: 1fbe51cd9c3a ("net/nfp: extend usage of BAR from 8 to 24") Cc: stable@dpdk.org Signed-off-by: Chaoyong He Reviewed-by: Long Wu Reviewed-by: Peng Zhang --- drivers/net/nfp/nfpcore/nfp6000_pcie.c | 34 +++++++++----------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/drivers/net/nfp/nfpcore/nfp6000_pcie.c b/drivers/net/nfp/nfpcore/nfp6000_pcie.c index a6fd89b6c8..ef1ffd6d01 100644 --- a/drivers/net/nfp/nfpcore/nfp6000_pcie.c +++ b/drivers/net/nfp/nfpcore/nfp6000_pcie.c @@ -263,19 +263,6 @@ nfp_bitsize_calc(uint64_t mask) return bit_size; } -static int -nfp_cmp_bars(const void *ptr_a, - const void *ptr_b) -{ - const struct nfp_bar *a = ptr_a; - const struct nfp_bar *b = ptr_b; - - if (a->bitsize == b->bitsize) - return a->index - b->index; - else - return a->bitsize - b->bitsize; -} - static bool nfp_bars_for_secondary(uint32_t index) { @@ -383,9 +370,6 @@ nfp_enable_bars(struct nfp_pcie_user *nfp) if (nfp_bar_write(nfp, bar, barcfg_msix_general) < 0) return -EIO; - /* Sort bars by bit size - use the smallest possible first. */ - qsort(&nfp->bar[0], nfp->bars, sizeof(nfp->bar[0]), nfp_cmp_bars); - return 0; } @@ -466,16 +450,18 @@ find_matching_bar(struct nfp_pcie_user *nfp, int width) { uint32_t n; + uint32_t index; - for (n = 0; n < nfp->bars; n++) { - struct nfp_bar *bar = &nfp->bar[n]; + for (n = RTE_DIM(nfp->bar) ; n > 0; n--) { + index = n - 1; + struct nfp_bar *bar = &nfp->bar[index]; if (bar->lock) continue; if (matching_bar_exist(bar, target, action, token, offset, size, width)) - return n; + return index; } return -1; @@ -493,10 +479,12 @@ find_unused_bar_noblock(struct nfp_pcie_user *nfp, { int ret; uint32_t n; + uint32_t index; const struct nfp_bar *bar; - for (n = 0; n < nfp->bars; n++) { - bar = &nfp->bar[n]; + for (n = RTE_DIM(nfp->bar); n > 0; n--) { + index = n - 1; + bar = &nfp->bar[index]; if (bar->bitsize == 0) continue; @@ -508,7 +496,7 @@ find_unused_bar_noblock(struct nfp_pcie_user *nfp, continue; if (!bar->lock) - return n; + return index; } return -EAGAIN; @@ -561,7 +549,7 @@ nfp_disable_bars(struct nfp_pcie_user *nfp) uint32_t i; struct nfp_bar *bar; - for (i = 0; i < nfp->bars; i++) { + for (i = 0; i < RTE_DIM(nfp->bar); i++) { bar = &nfp->bar[i]; if (bar->iomem != NULL) { bar->iomem = NULL; -- 2.39.1