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 EE613A0540 for ; Mon, 30 May 2022 13:10:23 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DE54142BAB; Mon, 30 May 2022 13:10:23 +0200 (CEST) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2044.outbound.protection.outlook.com [40.107.236.44]) by mails.dpdk.org (Postfix) with ESMTP id 72E1742B78; Mon, 30 May 2022 13:10:21 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bMZlcMxJIi24f+5O2R+9/aWOZIFs5RbVGfPWLcVTakyhHUmvR+9IZsq3sHnVJlRIBwvAKVIGiIpbnKskh9CYxWLLCdDCJoH7eMKqunfPQUjZdWGs1z0S7fMbLv6AKAkX6QeQ12BbAkl3f1MAJYC/QISpL31Bc22aeX9d/cV24MRbBtfQ5pKwa6afQp9SiVc5AFk1j6JgglJuK2uXEGAG26iHM/R1sTHOd5+Z3Pyi7b3+GbLyGSaTXjYq6zYI7DsMRvVo9efbBOg+nraEbWJaoh+DMbvNWfP7lEGs5/paqx6lQvGuLOfmOA1XpohVGW/XWSG1rI3jwX3Dk0V25VN0BA== 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=EqrP5XthnwQHZSZq+5A/4j6OPX3HMy9rderWe20NgG4=; b=AZGpqxX7yjEAXbKyeZhlNap3VgVg/BWuYCxqf7ZX3MCZRN9hv73ODnccD3X+h+8vCHu476NJBVfdxfuAqc5X1kAPJy5U0DpJ8NUvwJPFQaZqT0Um/gsQZvtMpBRNTVESm65soX1qXhn6su8HmrMST0pX4wf9fWA6owzdx25MFQKtAEyKH9TpvUdeiSHM+6TSEONlpHKPXHDFDzsh5oMn+rx6BAR2pSq3ihFI6fA7X2dzxJJTjNcMlHpH+NwbyydgyyAsQHhzbIFeo1+YMn/Pbw5S8I6SEFVBEEQTUbjDldZd2Fgz1rQmZbiEyMXcSF8+yiocxU3MqkfyhH2gNFIS1Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.80.198) smtp.rcpttodomain=monjalon.net smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=EqrP5XthnwQHZSZq+5A/4j6OPX3HMy9rderWe20NgG4=; b=rJwsx1qK1cnuNf8dzsckhGa5ZXnSQXoXPG1BA+IFWZt2UAq+JMi3TKzW/RJLFSeHcVPnNcw1I4W9YqDVfY2dyXFmJ44CxWwkupexhpylcHuEPew3w/qRbruHnIc4cFLUKZKup/mmL/GF2S1sFMk+FigEManlDuKYg/BptOBHm5A= Received: from SA9PR13CA0161.namprd13.prod.outlook.com (2603:10b6:806:28::16) by CH2PR02MB6933.namprd02.prod.outlook.com (2603:10b6:610:88::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.13; Mon, 30 May 2022 11:10:19 +0000 Received: from SN1NAM02FT0018.eop-nam02.prod.protection.outlook.com (2603:10b6:806:28:cafe::f4) by SA9PR13CA0161.outlook.office365.com (2603:10b6:806:28::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.6 via Frontend Transport; Mon, 30 May 2022 11:10:19 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.80.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.80.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.80.198; helo=xir-pvapexch02.xlnx.xilinx.com; pr=C Received: from xir-pvapexch02.xlnx.xilinx.com (149.199.80.198) by SN1NAM02FT0018.mail.protection.outlook.com (10.97.5.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5293.13 via Frontend Transport; Mon, 30 May 2022 11:10:18 +0000 Received: from xir-pvapexch01.xlnx.xilinx.com (172.21.17.15) by xir-pvapexch02.xlnx.xilinx.com (172.21.17.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Mon, 30 May 2022 12:10:16 +0100 Received: from smtp.xilinx.com (172.21.105.198) by xir-pvapexch01.xlnx.xilinx.com (172.21.17.15) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Mon, 30 May 2022 12:10:16 +0100 Envelope-to: thomas@monjalon.net, humin29@huawei.com, ferruh.yigit@intel.com, andrew.rybchenko@oktetlabs.ru, david.marchand@redhat.com, lihuisong@huawei.com, dev@dpdk.org, stable@dpdk.org, bruce.richardson@intel.com Received: from [10.71.118.169] (port=51160) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1nvdHs-0004OL-GQ; Mon, 30 May 2022 12:10:16 +0100 Message-ID: <11bac61b-87c4-ce18-2744-ae5bb4d45253@xilinx.com> Date: Mon, 30 May 2022 12:10:16 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH] ethdev: fix push new event Content-Language: en-US To: Thomas Monjalon , "Min Hu (Connor)" , Ferruh Yigit , Andrew Rybchenko , David Marchand , "lihuisong (C)" CC: dev , dpdk stable , Bruce Richardson References: <20220521065549.33451-1-humin29@huawei.com> <2199956.o7ts2hSHzF@thomas> <3a28b653-b83a-6cb5-bf5a-a04c144ba497@huawei.com> <11986117.O9o76ZdvQC@thomas> From: Ferruh Yigit In-Reply-To: <11986117.O9o76ZdvQC@thomas> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: eebf859b-7cf4-4072-6e7b-08da422cfb19 X-MS-TrafficTypeDiagnostic: CH2PR02MB6933:EE_ 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: xk2rEdZuLvQkbVKNISEB5oAmD7SWhXxZdVzqpJ9/BSYTaF2hCq858s5dc0TNsR6uWFcM2KFVv/e9X3z9qAhwHxhteRx+2Tqi4C5RjdP3ASC/dgRGTQVZVh5fR5AAYRJVH9CjZyZ63B1P+JZqyaaVcAwSyriIkSctwITy4nzyFPMWmP3bPDDgLU3/gHVF5TaLIPAQUHGGtebRibNmKcsCzvB4dmbjdKVbEPYqO4uCSNoe8VMstd4s8tlqYlbEynZyutU5f39Yw5+61MVbP+7ogfL0KNqHx1mE92bDjc/V3CQR/5iuqRm+IrcdsEnW8YdaDU1Zbh5x5arV5/hYT8OIMMfWI3YkbzOm9XpWnS8x6NvvhupT0g89Er5M1u5Wdt11+ZS7UXN2jxnGiFSrZtBdi5g01wwrBWxQmFxR+504cHY5+utaFeLkMTgN3aPl1VaaIs9XavMrOX6sXOlgtcueTKTCVTnVAYO2idvNWu9FVMv7Ss/YsVjSbyA3OMz/uwWCfUosHZXSgLYpuqvHHNP9Mz4YqFRaWbOf6RzoNhEKcKCDyxQ/t8h32R7YP5I9OqZqGOGkK75Yvixtsl7Tfpu3FC+lACFDasHQf4+/hvhTgjFZCkpWva34xIfW9KShAXJY4gu6ubtEk8HBnC0RGwc+siV6ur/DaHIprkjJSjHSBk7YnkGlPwnzZLUI0azcOplq+qru4SMqM6+NOcZ2kZAIwL0i5XjJcedQ8pENx57P9uA= X-Forefront-Antispam-Report: CIP:149.199.80.198; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:xir-pvapexch02.xlnx.xilinx.com; PTR:unknown-80-198.xilinx.com; CAT:NONE; SFS:(13230001)(4636009)(36840700001)(40470700004)(46966006)(508600001)(5660300002)(4326008)(8676002)(70206006)(70586007)(31696002)(186003)(82310400005)(40460700003)(8936002)(26005)(9786002)(83380400001)(7636003)(36860700001)(356005)(2616005)(44832011)(53546011)(2906002)(54906003)(31686004)(110136005)(36756003)(47076005)(426003)(336012)(316002)(50156003)(43740500002); DIR:OUT; SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 May 2022 11:10:18.2276 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: eebf859b-7cf4-4072-6e7b-08da422cfb19 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.80.198]; Helo=[xir-pvapexch02.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: SN1NAM02FT0018.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR02MB6933 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 5/30/2022 9:28 AM, Thomas Monjalon wrote: > [CAUTION: External Email] > > 28/05/2022 10:53, lihuisong (C): >> >> 在 2022/5/23 22:36, Thomas Monjalon 写道: >>> 23/05/2022 11:51, David Marchand: >>>> On Sat, May 21, 2022 at 8:57 AM Min Hu (Connor) wrote: >>>>> From: Huisong Li >>>>> >>>>> The 'state' in struct rte_eth_dev may be used to update some information >>>>> when app receive these events. For example, when app receives a new event, >>>>> app may get the socket id of this port by calling rte_eth_dev_socket_id to >>>>> setup the attached port. The 'state' is used in rte_eth_dev_socket_id. >>>>> >>>>> If the state isn't modified to RTE_ETH_DEV_ATTACHED before pushing the new >>>>> event, app will get the socket id failed. So this patch moves pushing event >>>>> operation after the state updated. >>>>> >>>>> Fixes: 99a2dd955fba ("lib: remove librte_ prefix from directory names") >>>> A patch moving code is unlikely to be at fault. >>>> >>>> >>>> Looking at the patch which moved those notifications in this point of >>>> the code, the state update was pushed after the notification on >>>> purpose. >>>> See be8cd210379a ("ethdev: fix port probing notification") >>>> >>>> ethdev: fix port probing notification >>>> >>>> The new device was notified as soon as it was allocated. >>>> It leads to use a device which is not yet initialized. >>>> >>>> The notification must be published after the initialization is done >>>> by the PMD, but before the state is changed, in order to let >>>> notified entities taking ownership before general availability. >>>> >>>> >>>> Do we need an intermediate state during probing? >>> Possibly. Currently we have only 3 states: >>> RTE_ETH_DEV_UNUSED >>> RTE_ETH_DEV_ATTACHED >>> RTE_ETH_DEV_REMOVED >>> >>> We may add RTE_ETH_DEV_ALLOCATED just before calling >>> rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_NEW, NULL); >>> Then we would need to check against RTE_ETH_DEV_ALLOCATED >>> in some ethdev functions. >>> >> Hi, Thomas, >> >> Do you mean that we need to modify some funcions like following? >> >> int rte_eth_dev_is_valid_port(uint16_t port_id) >> { >> if (port_id >= RTE_MAX_ETHPORTS || >> (rte_eth_devices[port_id].state != *RTE_ETH_DEV_ALLOCATED*)) >> return 0; Won't this mark ATTACHED devices as invalid? If the state flow will be as UNUSED -> ALLOCATED -> ATTACHED, above check should be against 'ATTACHED' I think. >> else >> return 1; >> } >> >> uint16_t rte_eth_find_next(uint16_t port_id) >> { >> while (port_id < RTE_MAX_ETHPORTS && >> rte_eth_devices[port_id].state != *RTE_ETH_DEV_ALLOCATED*) >> port_id++; >> >> if (port_id >= RTE_MAX_ETHPORTS) >> return RTE_MAX_ETHPORTS; >> >> return port_id; >> } > > Yes this is what I mean. > >