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 A58524304C; Sun, 13 Aug 2023 08:15:31 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7C4F9410F1; Sun, 13 Aug 2023 08:15:31 +0200 (CEST) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2059.outbound.protection.outlook.com [40.107.92.59]) by mails.dpdk.org (Postfix) with ESMTP id 8BE1A40EE7; Sun, 13 Aug 2023 08:15:30 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Tai74KoCrr1tIFt3QaqCyldI1rwmqZNm/F17bNU+kHSycDIHhZ44cj4San3uua0bDwUfPj60M9qXR4KZ1AMvC5QhzyzezUGhb5zUscqfF8qBfDP62GGnqAECN/9/3xZcYBoNAbWHd33Y+KBtVHsT8smi4J/FX/xXCZJVkhLNObsMFoqTaPqbu3L7sTd/zX7tIwjOlQZorjSK3CcL5jRg37+pQA8y2jMIENtxh2pHDkSf1nl8KRXNaXZiiy/C3zG3xUwHx5iNyRTkntZ4zplLu6/7IUPzu1Y2hdSwsp2NriNjrrV8thNmKtVcEQ/A7z8bSS/nxVQGbEdKJ/FvqprEQg== 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=G1oW8PCAvmIIpCkcj1UhCaYGmL3Gc3o++HXYiIPItGA=; b=PVwiWfTOSFoGwTLsNwpf4CiBPUkLaet/+qTaqvpl/qD6Jv+gERnHCDbtxpzpwUNa+Lye0cg5oSpX/kCsy057eQELIeVoQa1jwhye4eXry4JKSxwkp0P5I+WOOgZBonvy+MQTm61xSalCdXUxJw+S71n3M99BaR2zyD7itmRRtpmx9R7cLMRYdvbzs8JZwRnjRJzHMF5+jEoe0r/kAqCX42bZ32IP6zPqsbdmv5IMF/3Vk4+qsSPBMSRvUoQJtYokp9EGEcZWF2ZKw2FzeLMqj0i0SuYPpQS8gwoyKmbu0xEjSnwOWdRPNLssBThfC98viHQHtJlz15yaoOJqps3SXQ== 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=G1oW8PCAvmIIpCkcj1UhCaYGmL3Gc3o++HXYiIPItGA=; b=Cw4lne/q/T6PfJmRj7JgCR7tkU4MMACNF4DWwK0qzaH4bPDdLKEzMUKhfFweevZY85x5N4RnDBg5QefcUffr+Gz19lf3h35MGhOYvsFTSgSA6b2j/xNJ4PoQ6jG0e6x6+FXnbBt6m++9niwqa07yPrWHKZurpsdK60omw6ou+4E= 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 CY5PR12MB6323.namprd12.prod.outlook.com (2603:10b6:930:20::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6678.20; Sun, 13 Aug 2023 06:15:28 +0000 Received: from CH3PR12MB8308.namprd12.prod.outlook.com ([fe80::7eed:c168:1b20:c628]) by CH3PR12MB8308.namprd12.prod.outlook.com ([fe80::7eed:c168:1b20:c628%4]) with mapi id 15.20.6678.022; Sun, 13 Aug 2023 06:15:28 +0000 Message-ID: <661e8d7c-ac06-8d8d-9068-3d5812cb426b@amd.com> Date: Sun, 13 Aug 2023 11:45:14 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.14.0 Subject: Re: [PATCH] bus/pci: fix legacy device IO port map in secondary process Content-Language: en-US To: Wenwu Ma , dev@dpdk.org Cc: david.marchand@redhat.com, maxime.coquelin@redhat.com, chenbo.xia@intel.com, miao.li@intel.com, weix.ling@intel.com, stable@dpdk.org References: <20230807015820.1329972-1-wenwux.ma@intel.com> From: "Gupta, Nipun" In-Reply-To: <20230807015820.1329972-1-wenwux.ma@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: PN3PR01CA0036.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:97::15) To CH3PR12MB8308.namprd12.prod.outlook.com (2603:10b6:610:131::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PR12MB8308:EE_|CY5PR12MB6323:EE_ X-MS-Office365-Filtering-Correlation-Id: 7d29ff81-c955-4601-6db4-08db9bc4b061 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: v0jc64kpMFHrO0MmeZ8X5lVlYQLEHH67B5xlFX2gsT5o3LwhhfCCwWAHliKGb3dJVTNmMMQRmEx4ey4Wv09gJniFbKnCaaNOpVohNZBP7CsjJtgFKxdDKDNS1rb4WtX2JXfW+9EaYWcO6/zORmXtgzZTpBMp1Iq0kZYx0RvcW1/A1xw3c9L3V+HnHhJsLB+iUyFF3DAdbPaqYMBxDj6ME67ihI0Ls/uvetiOwCCEuUOUAVn2GPmmBSqBHSOOGqEUqLD1+19eFvp0JUyMdkChTzxIM3pqju3x99VO3X0wfeASH8NrtWNLnXsli2IE27KEOMRmiw4wlFAxobVn2+lbmfO+zfahfyvtlgX/wi0ZpHcCsKKP7QZ0nwpGRXceHhRWTqwybIGpskmqaYhB2R3nkDEBS0WW5yNjarDVDwiQdrrMEp8oOwfaC5gALlrfxpi6ertSdWYtkVUw1RhUdUjfABZHB45kRa5nN9jk2lTFeme5RKpqIe3P1FtmgC4mwX0e8/g9lodSYGRypyjMx8v3J/BDxHT9Jqeh1lXwx19F41nhgjMmy4Nj1UEiZwXokHMnmekb1wldz4kOQYbPC5F3Rz981R376OAUBbPU8y8v2sltD76OkoGr5exsCkhYpb49IVUOPXxLh9vjw5KmCD0qHA== 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:(13230028)(396003)(376002)(346002)(136003)(39860400002)(366004)(1800799006)(451199021)(186006)(2906002)(5660300002)(66946007)(8676002)(8936002)(41300700001)(4326008)(66899021)(66476007)(478600001)(2616005)(6486002)(6666004)(53546011)(66556008)(6506007)(6512007)(31686004)(316002)(83380400001)(86362001)(31696002)(36756003)(38100700002)(43740500002)(45980500001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?QVh0cnVaWFc5UDU2bTVib2NFNmJZS2JjbjZwZ0JjdWdNcnFUMWp4a3VJaERT?= =?utf-8?B?K0sxTU1qcGZFd3U0UHRGN2Q5RStLU0RDaHdRNHRBNTV0ZGx4STROODA4Z1NP?= =?utf-8?B?Tk1LZThNanhZeENzdXRxQmtoQ0x1eUtaeTg4aytxdnE3Ukk0bUl6WGM5SlJL?= =?utf-8?B?ODNTeWhVc1JPWVBTcFg4Mnl4SFZpNUlFa3dNMWVTWkh5MHdZSTlnWE1SNzZS?= =?utf-8?B?c0FIbmxYejVLc1EyNTU2TFhKVU9mNkVlUlRjcTRnR3A2a3prQ1dLZ29uZVVW?= =?utf-8?B?RGhPbXM0Ynl1T3dMcXZMelRVczM1bysvWHJ6QWMzZzQ1aFFBVGZCa0lUQ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kSUM3NFFqODlYZjZDczR5SWsxZGUyL2Nz?= =?utf-8?Q?ElpiSyebc+cdWo8bTpa8lUv+GJSWq4cftY1bEHazJLEm?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7d29ff81-c955-4601-6db4-08db9bc4b061 X-MS-Exchange-CrossTenant-AuthSource: CH3PR12MB8308.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Aug 2023 06:15:28.2029 (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: IRBL2MfmLSwZMOOiiNeFAm4rDJuonUJkTExVKZC2grT3CzPOtrd/yAIheU/Y6r0p X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6323 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 Hi Wenwu, On 8/7/2023 7:28 AM, Wenwu Ma wrote: > When doing IO port mapping for legacy device > in secondary process, the region information > is missing, so, we need to refill it. > > Fixes: 4b741542ecde ("bus/pci: avoid depending on private kernel value") > Cc: stable@dpdk.org > > Signed-off-by: Wenwu Ma > --- > drivers/bus/pci/linux/pci_vfio.c | 21 +++++++++++++++++++++ > 1 file changed, 21 insertions(+) > > diff --git a/drivers/bus/pci/linux/pci_vfio.c b/drivers/bus/pci/linux/pci_vfio.c > index e634de8322..eea1c9851e 100644 > --- a/drivers/bus/pci/linux/pci_vfio.c > +++ b/drivers/bus/pci/linux/pci_vfio.c > @@ -1306,6 +1306,11 @@ int > pci_vfio_ioport_map(struct rte_pci_device *dev, int bar, > struct rte_pci_ioport *p) > { > + struct vfio_device_info device_info = { .argsz = sizeof(device_info) }; > + char pci_addr[PATH_MAX] = {0}; > + int vfio_dev_fd; > + struct rte_pci_addr *loc = &dev->addr; > + int ret; > uint64_t size, offset; > > if (bar < VFIO_PCI_BAR0_REGION_INDEX || > @@ -1314,6 +1319,22 @@ pci_vfio_ioport_map(struct rte_pci_device *dev, int bar, > return -1; > } > > + if (rte_eal_process_type() == RTE_PROC_SECONDARY) { > + /* store PCI address string */ > + snprintf(pci_addr, sizeof(pci_addr), PCI_PRI_FMT, > + loc->domain, loc->bus, loc->devid, loc->function); > + > + ret = rte_vfio_setup_device(rte_pci_get_sysfs_path(), pci_addr, > + &vfio_dev_fd, &device_info); This looks better than fixing in "virtio_remap_pci". Ideally, these API should be called irrespective of PRIMARY or SECONDARY process here. Miao Li mentioned earlier that "rte_pci_map_device" is called from primary process, is it via "virtio_read_caps" API? Isn't there any other way to detect if it is a virtio legacy device without calling "rte_pci_map_device"? > + if (ret) > + return -1; > + > + ret = pci_vfio_fill_regions(dev, vfio_dev_fd, &device_info); > + if (ret) > + return -1; Corresponding cleanup required in "pci_vfio_ioport_unmap"? Thanks, Nipun > + > + } > + > if (pci_vfio_get_region(dev, bar, &size, &offset) != 0) { > RTE_LOG(ERR, EAL, "Cannot get offset of region %d.\n", bar); > return -1;