From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id A25CFA04C0; Tue, 29 Sep 2020 06:33:21 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B195C1D588; Tue, 29 Sep 2020 06:33:19 +0200 (CEST) Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2069.outbound.protection.outlook.com [40.107.20.69]) by dpdk.org (Postfix) with ESMTP id 9FF441D587 for ; Tue, 29 Sep 2020 06:33:16 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NMCze++i1C4rVd2ZwrVqIyKREmLzzOn8iFWgJvEbBTcsvQ7zp0mO+zRzCZS+tiXnE52/rJwpO5O9YA0bVoW/Xn83QScZPbs3QOgUye0xegseyHnJ2Gqp/4iWCjIHXlKlNFqRTZDNDWCS76eQcZ3+eq2d5sxtGHTygflpJUV1CGNsQokyHuf52KnJYQLSOhyopPDBZlB5k6nxb+WzzIZ6cqC/bxmVDOunx6cTyNSMizHzajwenAOnom0ZuQWpHcbESxauHSbaola8HN/Wkd4bAloa8KG7L/UU6mZv0yP3Y71Pcxl6qTMdUvK1WzgTbBudcTv0tu7WK99jqBNjrKadPQ== 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-SenderADCheck; bh=kbeT6XZqdpst/gRV+bUBfVz8Up9KGj7m+PsqNltOUbc=; b=Qq7r0obEyyS9Mxk3cDX6rLwNFVzi+tEfuql9NgtnsWwKoZlq2JBUjEfqov5mWONFKmiVAhanjoClMCfn1Heht08pOBfwYtsWO/ZvtbgNbl7K1oFc+R8yAC3c8CpeJZT7dBGfo7Clnc+YdaGmWfqJcwdvgxGAXiu8lExV/HtG4cb2Np1h5gQZIPS0QSw2TKwghkkwNcIKKXUU5aUxY/5YtCFD/L1+uacO+NVN41JhorRKtesvSOd9vvjlgRechY+82WmKhGSWpmsbd9hsKgyF0Su/d8g6Se0OAjblUTiEzgAGmFPyXLSnome0NFJm1HbBCLr1N/jebWJA3tLllsfEKA== 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=kbeT6XZqdpst/gRV+bUBfVz8Up9KGj7m+PsqNltOUbc=; b=c6s5Y9bTuQL4Su6DS0jmPPvmuthsu4sdTGlsAhX6ER1OVTmbixfiPLWF4X360yB1GoW5eb+UIMtl1orGQq6rka9CzvBCPiFADvVB7GsVfjspAYCbtEzeMPSEKb4plIhZoeB1TIUdWQ7zhdcgZf7HM33a8+f07DEl722EVBs33Uo= Authentication-Results: dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=none action=none header.from=oss.nxp.com; Received: from VI1PR04MB5837.eurprd04.prod.outlook.com (2603:10a6:803:ec::28) by VI1PR04MB4208.eurprd04.prod.outlook.com (2603:10a6:803:45::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.23; Tue, 29 Sep 2020 04:33:14 +0000 Received: from VI1PR04MB5837.eurprd04.prod.outlook.com ([fe80::cc01:9fe2:2544:8a4b]) by VI1PR04MB5837.eurprd04.prod.outlook.com ([fe80::cc01:9fe2:2544:8a4b%7]) with mapi id 15.20.3391.030; Tue, 29 Sep 2020 04:33:14 +0000 To: rohit.raj@nxp.com, Ray Kinsella , Neil Horman Cc: dev@dpdk.org References: <20200824082414.30535-1-rohit.raj@nxp.com> <20200826055233.26075-1-rohit.raj@nxp.com> From: "Sachin Saxena (OSS)" Message-ID: Date: Tue, 29 Sep 2020 10:03:03 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 In-Reply-To: <20200826055233.26075-1-rohit.raj@nxp.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-ClientProxiedBy: SG2PR02CA0104.apcprd02.prod.outlook.com (2603:1096:4:92::20) To VI1PR04MB5837.eurprd04.prod.outlook.com (2603:10a6:803:ec::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [192.168.42.101] (223.225.48.231) by SG2PR02CA0104.apcprd02.prod.outlook.com (2603:1096:4:92::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.21 via Frontend Transport; Tue, 29 Sep 2020 04:33:10 +0000 X-Originating-IP: [223.225.48.231] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 6425bc1e-b61f-486a-f043-08d86430c659 X-MS-TrafficTypeDiagnostic: VI1PR04MB4208: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1775; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ky+ilHlqeBK940xdwBirGT6KH//D78B4lQq+NnrZnguIVLRAUg1jxM+aGr1UaMppguFZV2+CdxDybW4RVOWSWmKySQcMe0XtIyyovs9ohk50DqF+STC3LaqibrU0rtsBCC+KJo3f765gEX5Ucxh3C5xL4rSv/ZUptOdYI89QJO0Tz/xCpEKQkb/UbORvofb9PZSm30MvDEvYJFlymIqZVyb9H2DzWdXwkR6w31N5HC2upBfO7iC0VyasM2f3OEtVV7daDZTvUp/rn7oHmNt88GOeZZ0aBHbXlDXzNQXyCIH8ubbD1S4FAdBP1JT/ATL6nzpCAcBrTEuDjhXcjgq3QUyCs3Ada6P8GFx24fTiv+lkr+mVzsbjgjeJs8tUH7Xt7di+gY+prp6gtsGoMr85pvaoMxrAE/CCju4pdTw47eCQwb+FV9JmoLuprSsOZ/kp X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5837.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(396003)(346002)(366004)(136003)(376002)(39860400002)(6486002)(6666004)(8676002)(8936002)(86362001)(66556008)(31686004)(66476007)(31696002)(5660300002)(2906002)(66946007)(83380400001)(53546011)(55236004)(16526019)(186003)(26005)(16576012)(110136005)(478600001)(52116002)(2616005)(4326008)(956004)(316002)(43740500002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: E1miaEkSpz/FeeGFKMDiR/D4sym6nprc1XxG84A+V8CFrWAdB9/o9uXeyG5Y02ZzGSYCHcYrm1JCs8f/a2/5aEvs4566hMEV9HGxGKPY2CFDqbs1hAS2fhagwONBClgTkAAr5gt5MfV79RnELud0CSBbMtAR5HOFAZbL69LQXSpsYGrkoMgq0zdbGWegDKaVD+p44l67tXM0bn8MlW6qOxgdgOABtDskcJ9qIKpE5mgb32Qn81DESrudzK1FoRoPUwTRoo7Ye5KnRxJYruP5I1XjhHbHSNnvoLxmTsopdj/+2CXi84aX9oi2WaHqx8wKeW1aUOOYfeP0te6DqZ663wZohd61ztedkC/U2W++2vRVS+Fa+IfnoAXxwqL1MPWVQO+m/kIE4TmyXFnG22/I1ER45yUS42HaJN1Lvofz5gheuAT5+yQBeUl7i8fNXcHQWG0GOkuudp4scP5GGZohW15n0IcSHyehYNonwBhvu1pYeeEFK9uYP2+tcjK+6Uqr5D1pQ/pVP3lBalsZeWdC0jwUpFpcjx1ojcj5mel4GBcQQ+XxMT3LthB5QXAIJDek53dwHV3HbMEyuyEkgihNR43HajcfavfOvlvG/+ggVuBocDoicJoBpnFTZcUybHu6AFqMKe3eJAiRx0/S8anKyA== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6425bc1e-b61f-486a-f043-08d86430c659 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5837.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Sep 2020 04:33:14.3403 (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: P5Xnzf7Y/iDqfioYIVC9MIfV4RgFK3xiBiYkHzMnuxmPAV7F6Jdhl/Slz65FoKqaPIYCgH5+btNoSRLGRDaf2g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4208 Subject: Re: [dpdk-dev] [PATCH v3 1/3] eal: add API for bus close X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 26-Aug-20 11:22 AM, rohit.raj@nxp.com wrote: > From: Rohit Raj > > As per the current code we have API for bus probe, but the > bus close API is missing. This breaks the multi process > scenarios as objects are not cleaned while terminating the > secondary processes. > > This patch adds a new API rte_bus_close() for cleanup of > bus objects which were acquired during probe. > > Signed-off-by: Rohit Raj > --- > > v3: > * nit: combined nested if statements > > v2: > * Moved rte_bus_close call to rte_eal_cleanup path. > > lib/librte_eal/common/eal_common_bus.c | 32 +++++++++++++++++++++++++- > lib/librte_eal/include/rte_bus.h | 25 +++++++++++++++++++- > lib/librte_eal/linux/eal.c | 1 + > lib/librte_eal/rte_eal_version.map | 3 +++ > 4 files changed, 59 insertions(+), 2 deletions(-) > > diff --git a/lib/librte_eal/common/eal_common_bus.c b/lib/librte_eal/common/eal_common_bus.c > index baa5b532a..5fd7cf6c5 100644 > --- a/lib/librte_eal/common/eal_common_bus.c > +++ b/lib/librte_eal/common/eal_common_bus.c > @@ -1,5 +1,5 @@ > /* SPDX-License-Identifier: BSD-3-Clause > - * Copyright 2016 NXP > + * Copyright 2016,2020 NXP > */ > > #include > @@ -56,6 +56,36 @@ rte_bus_scan(void) > return 0; > } > > +int > +rte_bus_close(void) > +{ > + int ret; > + struct rte_bus *bus, *vbus = NULL; > + > + TAILQ_FOREACH(bus, &rte_bus_list, next) { > + if (!strcmp(bus->name, "vdev")) { > + vbus = bus; > + continue; > + } > + > + if (bus->close) { > + ret = bus->close(); > + if (ret) > + RTE_LOG(ERR, EAL, "Bus (%s) close failed.\n", > + bus->name); > + } > + } > + > + if (vbus && vbus->close) { > + ret = vbus->close(); > + if (ret) > + RTE_LOG(ERR, EAL, "Bus (%s) close failed.\n", > + vbus->name); > + } > + > + return 0; > +} > + > /* Probe all devices of all buses */ > int > rte_bus_probe(void) > diff --git a/lib/librte_eal/include/rte_bus.h b/lib/librte_eal/include/rte_bus.h > index d3034d0ed..af4787b18 100644 > --- a/lib/librte_eal/include/rte_bus.h > +++ b/lib/librte_eal/include/rte_bus.h > @@ -1,5 +1,5 @@ > /* SPDX-License-Identifier: BSD-3-Clause > - * Copyright 2016 NXP > + * Copyright 2016,2020 NXP > */ > > #ifndef _RTE_BUS_H_ > @@ -67,6 +67,18 @@ typedef int (*rte_bus_scan_t)(void); > */ > typedef int (*rte_bus_probe_t)(void); > > +/** > + * Implementation specific close function which is responsible for closing > + * devices on that bus. > + * > + * This is called while iterating over each registered bus. > + * > + * @return > + * 0 for successful close > + * !0 for any error while closing > + */ > +typedef int (*rte_bus_close_t)(void); > + > /** > * Device iterator to find a device on a bus. > * > @@ -248,6 +260,7 @@ struct rte_bus { > const char *name; /**< Name of the bus */ > rte_bus_scan_t scan; /**< Scan for devices attached to bus */ > rte_bus_probe_t probe; /**< Probe devices on bus */ > + rte_bus_close_t close; /**< Close devices on bus */ > rte_bus_find_device_t find_device; /**< Find a device on the bus */ > rte_bus_plug_t plug; /**< Probe single device for drivers */ > rte_bus_unplug_t unplug; /**< Remove single device from driver */ > @@ -301,6 +314,16 @@ int rte_bus_scan(void); > */ > int rte_bus_probe(void); > > +/** > + * For each device on the buses, call the device specific close. > + * > + * @return > + * 0 for successful close > + * !0 otherwise > + */ > +__rte_experimental > +int rte_bus_close(void); > + > /** > * Dump information of all the buses registered with EAL. > * > diff --git a/lib/librte_eal/linux/eal.c b/lib/librte_eal/linux/eal.c > index 0960f01d0..a8a63d8ca 100644 > --- a/lib/librte_eal/linux/eal.c > +++ b/lib/librte_eal/linux/eal.c > @@ -1357,6 +1357,7 @@ rte_eal_cleanup(void) > > if (rte_eal_process_type() == RTE_PROC_PRIMARY) > rte_memseg_walk(mark_freeable, NULL); > + rte_bus_close(); Since this is common framework change, we should introduce similar call for "rte_bus_close" in FreeBSD and Windows version also. > rte_service_finalize(); > rte_mp_channel_cleanup(); > rte_trace_save(); > diff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map > index 0b18e2ef8..dc5266f22 100644 > --- a/lib/librte_eal/rte_eal_version.map > +++ b/lib/librte_eal/rte_eal_version.map > @@ -397,6 +397,9 @@ EXPERIMENTAL { > rte_mp_disable; > rte_thread_register; > rte_thread_unregister; > + > + # added in 20.11 > + rte_bus_close; > }; > > INTERNAL {