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 1130A43A53; Fri, 2 Feb 2024 20:34:29 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5AF1842EBB; Fri, 2 Feb 2024 20:33:35 +0100 (CET) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2063.outbound.protection.outlook.com [40.107.94.63]) by mails.dpdk.org (Postfix) with ESMTP id 515ED42EB1; Fri, 2 Feb 2024 20:33:33 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B3h1Hg1HDJ1JpYQFj6MQfKlppwJY4Y6kcFIDYH1R8v88ydW6FQ81FatmEDtPjJYOocStI2QmnklgAa6RSpp92tglFV2p2xCWUPEcJtQGyUZGqQzJyRgIOP2xRrC2Llj7fFmkGIN42fGZBWdnGJQi02LjEL6Db7/KPPo+S9Rd8VTmJacPhzuJB1C0xp6oWC1bdXsVS02omZrZjJ7CwaeWeX8YYCYYS0z/3oQP4c5aPcsKH+97TxgJerpgGKnok0z2OPGXmbde+Mj2yMe4HTHOY5Zy7ToM13Md6Wa7rFaru7Wto6IV4daaLaGTeQxxHxdZBU074F1H+RNdVPtt/xtAMA== 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=LcRgPIMTJAnmXNj/5UNG2ORGY/fyNR4AsY07IQOYQQ4=; b=WVStlJhWBKjX2dtjHCDwqrBdawT5taOUZ/U/XrAdhCKgYdpQUQlI7t6SHM5l5aH0+p51PIyrPBbu92odSr58WSBrAO63gdQnZm7kQIcH7cijaNttnzl1OsnRg6q3+FvJ1+J60MXB72U3L7zuTUPOgOp2Rk5yWeFSnEuBUWEOubwIPIqRFtindcGy6EcC9vdlc84JFWnAsGwEBIuLFoZoDngk2634bAeE3JFG/h9NsG6g/VSJlPNTUUylpMkgt6arqzueSMFMYPM9843FbYV3ZIWVZEgfdUsDg+t+VYkSw0vdK6dnjCxM1EUvWXEb9pK/sGYCSDWzFvzjXOI8bEUWMg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=dpdk.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) 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=LcRgPIMTJAnmXNj/5UNG2ORGY/fyNR4AsY07IQOYQQ4=; b=Ex3lfbeUYNj5NTcZRVWxXXNvcrx+H8XUj038IYQm7vIZZMratC8JQ43X4InpDbpb61806VFzWJvvPZ8yPDSmPKD2+p87Zannolbzy5wo7qsc1HePvlW351sK/lSnIKPDhVCr4wS0gwrqSx8ODxZ5AN50AL4oPmpBGZIDoh5Lc1A= Received: from DS0PR17CA0023.namprd17.prod.outlook.com (2603:10b6:8:191::24) by PH0PR12MB8821.namprd12.prod.outlook.com (2603:10b6:510:28d::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7270.12; Fri, 2 Feb 2024 19:33:25 +0000 Received: from DS1PEPF00017094.namprd03.prod.outlook.com (2603:10b6:8:191:cafe::aa) by DS0PR17CA0023.outlook.office365.com (2603:10b6:8:191::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.30 via Frontend Transport; Fri, 2 Feb 2024 19:33:25 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS1PEPF00017094.mail.protection.outlook.com (10.167.17.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7249.19 via Frontend Transport; Fri, 2 Feb 2024 19:33:25 +0000 Received: from driver-dev1.pensando.io (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Fri, 2 Feb 2024 13:33:24 -0600 From: Andrew Boyer To: CC: Andrew Boyer , Subject: [PATCH 10/13] net/ionic: fix device close sequence to avoid crash Date: Fri, 2 Feb 2024 11:32:35 -0800 Message-ID: <20240202193238.62669-11-andrew.boyer@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240202193238.62669-1-andrew.boyer@amd.com> References: <20240202193238.62669-1-andrew.boyer@amd.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF00017094:EE_|PH0PR12MB8821:EE_ X-MS-Office365-Filtering-Correlation-Id: 8519e23b-bf57-4bf5-d06a-08dc2425d31f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DOo860vTRuAMtJoNNlRptmwkS35OX520OXnRzSwKmCIiNrNEeoxwiUsmSUuo6XcMQSzmskzkWiRnWqvw55WAmtfO+CtOwo0efBXCKRB1Z5oV9mNcJyAUAWb56l95F5oIe+STb7WMB3OhaqFsjk7hcYLnZLllENWqFt6WXnnqoQfFhcxuYhZzqebFg1lVT9woLvSfe5d9QhjCDfI7eZyXszrbFG4HxnMQJFc3oQ6+u0Zjzc0pfiRm+3SOTdN6LlAhVBdrOAAB/vzwSnXWnu9NzWdXQe76jqPinJpSev1dlMG0ua0yCfg8Sf6XeXB8X95omsaXhTJB9FzWoGwh2JZt5GvjAKDTMo5PPPSrTclFa/0iWIsV/IQ19ZKi7O84d9e2c74P9ine8ZyFF4rKTu5CeKFIdU1P1AM5HO26R/LqIXSuPEqzQlkH0sAFPkhaDsI6W4rhSy3jo0UVVrVkD3kSW9QeRo/Bx36EAaswcFw53SYuwBmNwigSCYk+uL5ltslYQ/OU2rBOTAVP6DnsUSwRcGiFKz3mTmMr0/J33QP1CqVBAhPkF5VK6Mbx8mnh1XLn4FmR3hSpw5kBgHmCuWnvzh9EHuiTbFzU5k3aszsHHsf7F78m0sOejnQtHUSy7utdIzfJKeE3jtI6VZZxvnyFCNCAuD1cUNcWkPZ5NJeLdlwu1fjn/pclNl9ulA/q2e2Vl4wHhNRNScUqjJoNGHSSkGXQ3uTMMsYkqokzxGsaEua/kUQlOCSrx3M5yJbNcF1g5X1MHCi6vSycEe7HGS/pnA== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(376002)(136003)(346002)(39860400002)(396003)(230922051799003)(64100799003)(186009)(82310400011)(1800799012)(451199024)(36840700001)(40470700004)(46966006)(478600001)(41300700001)(82740400003)(83380400001)(40480700001)(36860700001)(40460700003)(81166007)(356005)(47076005)(336012)(16526019)(6666004)(54906003)(36756003)(6916009)(5660300002)(316002)(44832011)(8676002)(8936002)(4326008)(450100002)(70206006)(26005)(2906002)(426003)(70586007)(86362001)(2616005)(1076003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2024 19:33:25.3453 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8519e23b-bf57-4bf5-d06a-08dc2425d31f X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS1PEPF00017094.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB8821 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 The close routine should release all resources, but not call rte_eth_dev_destroy(). As written this code will call rte_eth_dev_release_port() twice and segfault. Instead, move rte_eth_dev_destroy() to the remove routine. eth_ionic_dev_uninit() will call close if necessary. Fixes: 175e4e7ed760 ("net/ionic: complete release on close") Cc: stable@dpdk.org Signed-off-by: Andrew Boyer --- drivers/net/ionic/ionic_ethdev.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/net/ionic/ionic_ethdev.c b/drivers/net/ionic/ionic_ethdev.c index 7c55a26956..bedcf958e2 100644 --- a/drivers/net/ionic/ionic_ethdev.c +++ b/drivers/net/ionic/ionic_ethdev.c @@ -1009,19 +1009,21 @@ ionic_dev_close(struct rte_eth_dev *eth_dev) ionic_lif_stop(lif); - ionic_lif_free_queues(lif); - IONIC_PRINT(NOTICE, "Removing device %s", eth_dev->device->name); if (adapter->intf->unconfigure_intr) (*adapter->intf->unconfigure_intr)(adapter); - rte_eth_dev_destroy(eth_dev, eth_ionic_dev_uninit); - ionic_port_reset(adapter); ionic_reset(adapter); + + ionic_lif_free_queues(lif); + ionic_lif_deinit(lif); + ionic_lif_free(lif); /* Does not free LIF object */ + if (adapter->intf->unmap_bars) (*adapter->intf->unmap_bars)(adapter); + lif->adapter = NULL; rte_free(adapter); return 0; @@ -1098,21 +1100,18 @@ eth_ionic_dev_init(struct rte_eth_dev *eth_dev, void *init_params) static int eth_ionic_dev_uninit(struct rte_eth_dev *eth_dev) { - struct ionic_lif *lif = IONIC_ETH_DEV_TO_LIF(eth_dev); - struct ionic_adapter *adapter = lif->adapter; - IONIC_PRINT_CALL(); if (rte_eal_process_type() != RTE_PROC_PRIMARY) return 0; - adapter->lif = NULL; - - ionic_lif_deinit(lif); - ionic_lif_free(lif); + if (eth_dev->state != RTE_ETH_DEV_UNUSED) + ionic_dev_close(eth_dev); - if (!(lif->state & IONIC_LIF_F_FW_RESET)) - ionic_lif_reset(lif); + eth_dev->dev_ops = NULL; + eth_dev->rx_pkt_burst = NULL; + eth_dev->tx_pkt_burst = NULL; + eth_dev->tx_pkt_prepare = NULL; return 0; } @@ -1267,17 +1266,18 @@ eth_ionic_dev_remove(struct rte_device *rte_dev) { char name[RTE_ETH_NAME_MAX_LEN]; struct rte_eth_dev *eth_dev; + int ret = 0; /* Adapter lookup is using the eth_dev name */ snprintf(name, sizeof(name), "%s_lif", rte_dev->name); eth_dev = rte_eth_dev_allocated(name); if (eth_dev) - ionic_dev_close(eth_dev); + ret = rte_eth_dev_destroy(eth_dev, eth_ionic_dev_uninit); else IONIC_PRINT(DEBUG, "Cannot find device %s", rte_dev->name); - return 0; + return ret; } RTE_LOG_REGISTER_DEFAULT(ionic_logtype, NOTICE); -- 2.17.1