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 E9060A0563; Fri, 3 Jun 2022 15:59:07 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 90ECF4069D; Fri, 3 Jun 2022 15:59:07 +0200 (CEST) Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-eopbgr150085.outbound.protection.outlook.com [40.107.15.85]) by mails.dpdk.org (Postfix) with ESMTP id 64BFC40694 for ; Fri, 3 Jun 2022 15:59:06 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dAnfbmZjBsqNOvXaQRZdU1htPv3nZVO33U2fS8Z1l3LbFl9YPEdvwf2bXJy/nJ6EHtrKkbqMxKpXithj9tVK65fP2n/BnxAtBrm9kr0BWtWKg15/UHl/J8g7TFTqs5gFUsEVhJAunTwkX/N44w9cYwehAiiH/vEpCj7gcYei1H+VE2omA88w5jtg2QWPAlIsqah0QMnE4ygHDIHUi+lAexKyyAYojGTzDMWjOemviXFNXAAhc96aZqIMYiZGmHYCEQbgrXBnzQcPA4zA3V5hzt20Bat4ckKcWA/3yNN7/QWtI2uR0qE9jHLdsQS2BnuGl4p49BXActS8izauLpimyQ== 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=g5hMKBZrfttANYM6Y1RJKjqiY/g8vFzWl1Jp+Bkmiug=; b=F4SVT5dwTCHSJAfs5FLmvGbRwaW/XW4PIKAOOzz9q66CLfhVneCTU1rN+uxcWlwd1oyxCSAGmP1/lvZjB+WZam+/+FufLCX3i6IbSFxlw60Fu9mY+ZyMKb8ZOy2bloCXTiE952CU2YN4EBA5YHrYT3lKc7F7Wes8R1G7x4k1s+yuzuIpPawPHHc2FuM/Db/1m/5HIyHZr/X5iW3Tv9BZGLYfrf3W0VnOHlf6RsS/xD8or3LXcG0998nEdhSvYbhwbIG5lP0DiwC8drHnJUPIjU8k8ql0KFjSzHqBonPgOwFwzv75M80vpZ94taeMcM7gwbd4o2J43h7riGCrNz49Nw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=g5hMKBZrfttANYM6Y1RJKjqiY/g8vFzWl1Jp+Bkmiug=; b=jcmU7TGAcNhnjjxS1rpXGs5qnTiYujGlFBrTSJv1kaShQ7de0mlFZ2/KMU7Qk2/YkPJfuRAuzHzB9ROforGxuY9G1psyK68FpaKF30NckzFWDsszf6NhH7k8o8s330tSJWwaUxQVkpMTrZLNNNxgi+wSTV5ui71EQ7NfVENBhqY= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from AS8PR04MB9064.eurprd04.prod.outlook.com (2603:10a6:20b:447::17) by AS8PR04MB7525.eurprd04.prod.outlook.com (2603:10a6:20b:29b::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.15; Fri, 3 Jun 2022 13:59:04 +0000 Received: from AS8PR04MB9064.eurprd04.prod.outlook.com ([fe80::7441:a97b:6d91:2943]) by AS8PR04MB9064.eurprd04.prod.outlook.com ([fe80::7441:a97b:6d91:2943%7]) with mapi id 15.20.5293.018; Fri, 3 Jun 2022 13:59:04 +0000 Message-ID: <21b2fe06-ab71-87b6-2942-fea89cf9e9e8@oss.nxp.com> Date: Fri, 3 Jun 2022 19:28:56 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [RFC v2] bus/fslmc: fix invalid use of default VFIO config Content-Language: en-US To: Romain Delhomel , hemant.agrawal@nxp.com, sachin.saxena@oss.nxp.com Cc: dev@dpdk.org, olivier.matz@6wind.com, stephane.gonauer@6wind.com, guillaume.gaudonville@6wind.com, elias.boutaleb@6wind.com References: <20220531092753.10825-1-romain.delhomel@6wind.com> From: Hemant Agrawal In-Reply-To: <20220531092753.10825-1-romain.delhomel@6wind.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: SI2PR06CA0010.apcprd06.prod.outlook.com (2603:1096:4:186::6) To AS8PR04MB9064.eurprd04.prod.outlook.com (2603:10a6:20b:447::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 36cf572e-563b-4ae0-5d3f-08da456937bf X-MS-TrafficTypeDiagnostic: AS8PR04MB7525:EE_ X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Tu+REzvEiaILQoLSHrORg9eTFT0eKB//pWG86qOleGS6uw1tM7zbKh+Z2G9soUkApHw84myeKjO9ToNCHYwlTBx9dw4GIZnzl3T4fsU3ndbBVrV/aPXToF1N+8KVjEwX3TrvtNAjKv+ji4SgD1NHuKoyLlskjta4Uunv//JlLj+FFNVg89BnUR5liyDFf1jPqyJLUEb9McTYzpgSuh6CiNZMQEEbCNdlaDnWf/s3SOhiMzYaOZf7h4tUJvPCu64RiNE7zWO0neVYWOq+iMKMPk3AYDLWuUKAW1Vejythv7yfQfPjKyYYgsQXNZWowzKhwcSFiAK1gGEVWc/VMf/UeYbpM6PLUJ64xqD7Pym7Qef9iRBuyeS82mAVpCWcVRyKOEbI+KLDLvfaMsWBTxYK5f00ZVBwC5J7NL+6K0Aa1Z9+mwI3bP5RHYwmbL0ArIuig473spGod5VUbAkGG1Z9jP/GyfaGQOInPqJh6aHNhpB4bwjSg8cuThQ2powvA/XGTpELFDsmpbaXCK3+vj9l3P7SdWaDY38ZyU4oro0hF6kEtfyQe+nqyR4x6uApT5Vztg086RfeceA3sNIIb0ybG/ep3EvzsZgvF/9WKjbJwr57a8FzfoRGoNGDzIaerqrXQYIhU83C9CZJ6Fba0WkSO0ErqoJDtapMaWrGxuIcnvvg2QiBrEzmZGXBCHv2DFU/ZrA2r+UAXGCgNfBvLiKTKsoqfLB6HRVxLl6qs0yvDMd5Y0Ov1Dq6K/EHpDfqCOE6aCJ83rSyYzdu8QZe0m/w5g== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR04MB9064.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(6506007)(2906002)(52116002)(31686004)(38100700002)(53546011)(83380400001)(2616005)(38350700002)(6512007)(26005)(6666004)(508600001)(186003)(6486002)(8936002)(316002)(31696002)(6636002)(66556008)(8676002)(66946007)(86362001)(4326008)(66476007)(44832011)(5660300002)(45980500001)(43740500002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?YUpaVjNQRzN5UXF2S0JUVW1TK25Sckh4UDBQMGJGcTlJaEN5THJSdGl0K2Zp?= =?utf-8?B?UzYzYnVSMmprRVdIQ0pndHFGZmpNZC90WC95SHY2bm5JQWxueHZ5aXUyeVJt?= =?utf-8?B?bzdYWnlwa09wZi9YR0xxdENTb3pSTFNwY1JuaF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WYUJiQldpQXRCRFoxaE1GaDh3?= =?utf-8?B?VldxNjBaUDJ3MWhrcVQ5VktSTkhwa0RSMllGeVNJSDRUdXd0N0swVkpZMmh0?= =?utf-8?B?QVZwWnFUM0tMZ2ZZSFhDK0ZuVTVlMjYxN2xmUkFDR0loSW9JUTlRMGRScEhl?= =?utf-8?B?VmYrWWY1QVZvaTRORFczN3N1SU1BVGo2R0g2RTIxL1huckJOUXJMdU5jOTQ5?= =?utf-8?B?dUdqbFhMSEJ2eG5sTWJ0Tk9Dc1AxemdvS2h5N2c4UXJ4L1BiOGpBckxHeW81?= =?utf-8?B?dnFmVHZIdDFKNDJsODJLK1dMUEtySVVkTHZXQ0xtaFJvbkpkM1ZwR2duMmgy?= =?utf-8?B?NldKMWZxUHpyVHplUGQrZjFPY0xnc2VoSnRxaEVaK3FjNlNHL3dyZEpnMjJB?= =?utf-8?Q?99sLtXI6w2LWUohs=3D?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 36cf572e-563b-4ae0-5d3f-08da456937bf X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB9064.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jun 2022 13:59:04.5061 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: DM0NQsG2+2GWA5KTn3zaSUTdmuH/eDwmDwbhRMdXEXSombHpMk2D7sVICBtwJxp1nhvZkVBzMBTWlo6w7uKMfg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7525 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: , Reply-To: hemant.agrawal@nxp.com Errors-To: dev-bounces@dpdk.org Tested ok Acked-by:  Hemant Agrawal On 5/31/2022 2:57 PM, Romain Delhomel wrote: > At device probe, the fslmc bus driver calls rte_vfio_get_group_fd() to > get a fd associated to a vfio group. This function first checks if the > group is already opened, else it opens /dev/vfio/%u, and increases the > number of active groups in default_vfio_cfg (which references the > default vfio container). > > When adding the first group to a vfio_cfg, the caller is supposed to > pick an IOMMU type and set up DMA mappings for container, as it's done > by pci bus, but it is not done here. Instead, a new container is created > and used. > > This prevents the pci bus driver, which uses the default_vfio_cfg > container, to configure the container because > default_vfio_cfg->active_group > 1. > > This patch fixes the issue by always creating a new container (and its > associated vfio_cfg) and binding the group to it. > > Fixes: a69f79300262 ("bus/fslmc: support multi VFIO group") > Signed-off-by: Romain Delhomel > --- > v2: > * Fix wrong indentation > > drivers/bus/fslmc/fslmc_vfio.c | 10 +++++++++- > 1 file changed, 9 insertions(+), 1 deletion(-) > > diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c > index b4704eeae4e2..abe1cab2ee20 100644 > --- a/drivers/bus/fslmc/fslmc_vfio.c > +++ b/drivers/bus/fslmc/fslmc_vfio.c > @@ -979,6 +979,7 @@ fslmc_vfio_setup_group(void) > { > int groupid; > int ret; > + int vfio_container_fd; > struct vfio_group_status status = { .argsz = sizeof(status) }; > > /* if already done once */ > @@ -997,8 +998,15 @@ fslmc_vfio_setup_group(void) > return 0; > } > > + ret = rte_vfio_container_create(); > + if (ret < 0) { > + DPAA2_BUS_ERR("Failed to open VFIO container"); > + return ret; > + } > + vfio_container_fd = ret; > + > /* Get the actual group fd */ > - ret = rte_vfio_get_group_fd(groupid); > + ret = rte_vfio_container_group_bind(vfio_container_fd, groupid); > if (ret < 0) > return ret; > vfio_group.fd = ret;