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 E326A4319B for ; Wed, 18 Oct 2023 14:38:50 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D7D0340ED3; Wed, 18 Oct 2023 14:38:50 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2088.outbound.protection.outlook.com [40.107.223.88]) by mails.dpdk.org (Postfix) with ESMTP id 52242402CD; Wed, 18 Oct 2023 14:38:48 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ahse0G57afNO1mLMhBvOKZW5/Ng83xYKA4wv57JMBWYJFfpZMsCcMfE/sTbVoGoIZA40P57ZLGO0IxR+Aydbm234l9bQHx7VOimwfiqRgbvXFt6FzLG8wBDlcpQUq7ozmq0iPl2n7Yn4wv894LEeXxUcPlwzS/aSRQ6zhoUHJZbRAODRDcDtLzopkp+b2L/JOKsTRg3JX50Y5WhuMZfVpND9fCUySTcZeylvrNCnIUtsxVeybk1s77eNKwBUyc5aWVntH+h5VFtiKJTXn3cZ2EPhRi9m6VDQr46Lhz6+gALk2T6n0LfHwOhA3HEGAoJRMiycubhVf3GKZqY0brrF8g== 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=BAZlLIQBo2QQfZa4ZzyfWpuizXZmjgSFagzO3lusRCk=; b=nIuxI6UYe9IygiqcFDnea6WyfsTV1oz43JfBHcC0HnOGlYRT7NXfUxxAVwby9UDd8Kb7LNNAuKAdfXq0/BnlmUXNSCJoNVRzCzCB7PNynWt1WP303Qb5tGzsLFIhQbP9hBvMtZzKpYsitLFFqtZUdnFwxA311W5oNYzrr/KKMDjjdNJYf6Ndletx35KMg8gEwlNR+pH7+MdSz8hfleQSA6EqeLtPCKW4LFkql1AppRTmHwCvztkvijCy3Pmoapw1bcpp6s6hDBGcI2lbZCueVo/XrovHY6A8wRqb94VHhvOF2D0wT44oxdEuqVFkAFuDFJ5ExZY5Uao6MKT6P1fkaQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BAZlLIQBo2QQfZa4ZzyfWpuizXZmjgSFagzO3lusRCk=; b=zzLL9pqc4gFBiLoegXN7u12JY6wvpt5KyvglZSm5H0lKbdfYXVzHNtXkTOaA8G6hnlM++ECpqEiP7ym3WZuUW60Rk7uoUnxJ2DuDAjM0Not8ewLND/J0/q/9yJJwbKOd31ezK/hpISQ1yIbiEKKA6I3kCXKWZOO1FFFwD78xK/Y= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from CH3PR12MB8308.namprd12.prod.outlook.com (2603:10b6:610:131::8) by DS0PR12MB6414.namprd12.prod.outlook.com (2603:10b6:8:cd::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.36; Wed, 18 Oct 2023 12:38:44 +0000 Received: from CH3PR12MB8308.namprd12.prod.outlook.com ([fe80::a652:eb45:86f0:f68f]) by CH3PR12MB8308.namprd12.prod.outlook.com ([fe80::a652:eb45:86f0:f68f%4]) with mapi id 15.20.6886.034; Wed, 18 Oct 2023 12:38:44 +0000 Message-ID: <2ba09d01-8241-43a9-be90-5fbbfc75b2e4@amd.com> Date: Wed, 18 Oct 2023 18:08:18 +0530 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4] bus/pci: fix legacy device IO port map in secondary process Content-Language: en-US To: David Marchand , "Ma, WenwuX" , "chenbo.xia@outlook.com" Cc: "dev@dpdk.org" , "maxime.coquelin@redhat.com" , "Li, Miao" , "Ling, WeiX" , "stable@dpdk.org" References: <20230807015820.1329972-1-wenwux.ma@intel.com> <20230830050713.58247-1-wenwux.ma@intel.com> From: "Gupta, Nipun" In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: BMXP287CA0003.INDP287.PROD.OUTLOOK.COM (2603:1096:b00:2c::16) To CH3PR12MB8308.namprd12.prod.outlook.com (2603:10b6:610:131::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR12MB8308:EE_|DS0PR12MB6414:EE_ X-MS-Office365-Filtering-Correlation-Id: c4b4eb97-3f0f-494c-cc0b-08dbcfd72a99 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: n4SR7cXkUWWhcCoPw285pZdKGjppp7bic+9ZquUTy0SDPmVAl4HTHvtEiwF4wAHgUscTxOGcDNfp6Syo7MPgMqQaBcrI0VroZcaq8FlToYvYuYYADeIIXB61sHl1a9oimI85EyLO93vL6y7u5ZQyHe+5KNKTPuv+FLwQNqavqBIDYTODREhH4Rc7vU6pWXlpJhk98sdY4eeeNUnP8/MpKA36zXHJZvom+3D4CiumyhdoyMnp6li7ppqouRxEpST7JRtzFrD7KFAeFBOFvLnoA5P4el2u3hW+EKcRrhDY5bz9PlRIRw/Zo56vbCw3jE8nNId5B8azcLRovuHkmioP86258IxL3B21qukyyuxSisTE+cRSWfTB+B+aEO6E4ZdemfqS5f0cAljQL/2ACZaNGNBH0jHdYJAeTs/jDRY52DoffXYeOPrZnk+3xKfY3bY/JpawWi7oOnNnHbGOatutgPjrlmDvcBJGt8BnX26x+x5t0NI2acoFm8WGbqzP+Gj/ZFVltKMjz8VqDf7YLOl4JTAg3UWXHRlqZsWXT08JNg6QXH8434pp0Pc2oT4mc8nxe8Yxe07OaC3gwsFADKu9pK7CLHl9roJjyXN+uzEttzs95a35Tj5wEH5QCWM8r5TnY4bg4hD61sMHvs2vEdvpWQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH3PR12MB8308.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(136003)(376002)(366004)(346002)(396003)(39860400002)(230922051799003)(186009)(1800799009)(451199024)(64100799003)(31686004)(54906003)(478600001)(110136005)(66476007)(6486002)(66946007)(66556008)(83380400001)(31696002)(86362001)(38100700002)(6512007)(5660300002)(36756003)(6666004)(2616005)(53546011)(6506007)(26005)(41300700001)(316002)(8676002)(4326008)(2906002)(8936002)(45980500001)(43740500002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?eE1YN09rSTdmRGpIRXN1RzZQNjQ5YlZCRGduTjQxYUkzR2RwZkUwNlh1bGpa?= =?utf-8?B?a0ZYMDM3NGNKcmdtNVZsSlJodGEyS2pkenpzdXlMTDAyQUxaVjlmbTlyd0Va?= =?utf-8?B?aUpaZjV5Tk1iSXk0YnAzQ3JnS1BQU3hEb3pJV3lmOEg5K1hlcjdpNTdBa3pT?= =?utf-8?B?UEFaNmpPSzFvZ3dUOVBnUDJXSWErSnMvdlEwS1YzbnQ1NGtLaUlocG14aFZ2?= =?utf-8?B?T2VZK1hscVRwMExWRDV5TWJKVEZiWWVMRTNaeDZualA4d3JHdUZURTNvZ1BF?= =?utf-8?B?Yk1kVTFFRWY1dno5VEVFWUhmNWR3ZThibDg2Yk8wQ2NYM0V4bnZIVDdjdDlI?= =?utf-8?B?VjQwUDlobF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-MS-Exchange-CrossTenant-Network-Message-Id: c4b4eb97-3f0f-494c-cc0b-08dbcfd72a99 X-MS-Exchange-CrossTenant-AuthSource: CH3PR12MB8308.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2023 12:38:44.3840 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ZLp0YkN+xwElny4h5RM49T1J2hQbAbdJHGK6pSfPNChp2xekqimsPXqMuoOVLiRw X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB6414 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 On 10/18/2023 3:35 PM, David Marchand wrote: > On Mon, Oct 9, 2023 at 5:06 AM Ma, WenwuX wrote: >>> From a pci bus API pov, nothing prevents a driver from mixing memory >>> mapped with vfio and ioport resources (iow, calls to >>> rte_pci_map_resource() and rte_pci_ioport_map()). >>> IOW, it may not be the case with the net/virtio driver but, in theory, >>> rte_pci_ioport_map()/pci_vfio_ioport_map() may be called after a >>> rte_pci_map_resource() call. >>> >>> In a similar manner, from the API pov, >>> rte_pci_ioport_map()/pci_vfio_ioport_map() may be called for multiple bars. >>> >>> In summary, nothing in this patch checks that vfio has been configured already >>> and I think we need a refcount to handle those situations. >>> >> We call rte_vfio_setup_device just to get device info, we can call rte_vfio_release_device as soon as pci_vfio_fill_regions is done. >> This avoids reference counting operations, do you think it works? > > Afaics, rte_vfio_setup_device should not be called if a call to > rte_pci_map_device for this device was successful (rte_pci_map_device > itself calls rte_vfio_setup_device). > And as a consequence, calling rte_vfio_release_device cannot be done > unconditionnally neither. Hi David, AFAIU, rte_vfio_setup_device() is written as re-entrant and does not create the DMA mapping again if it is already done for the iommu group. When this API is called again either for a device within the same group or from the device for which it is already called, it mainly only does the work for device info get. Though not the best thing to use like this, but if this is called multiple times it should not have any negative impact. As Wenmu mention that they need only device info from VFIO, a separate API to get device info can be added in eal_vfio.c/h. The device info portion of rte_vfio_setup_device() can be moved out to a new API, and rte_vfio_setup_device() can call this new API too? Thanks, Nipun