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 89FD143A1B; Wed, 7 Feb 2024 03:20:55 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E5FE742DF0; Wed, 7 Feb 2024 03:20:07 +0100 (CET) Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2084.outbound.protection.outlook.com [40.107.101.84]) by mails.dpdk.org (Postfix) with ESMTP id 727C442DD2; Wed, 7 Feb 2024 03:19:57 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FH6dhrK3myi/pwzzPM+0SkLJTLp/IHFHcr0wpEL9lJrF4Eiud2YyAxPjI8wa+SqyZwqMdvK0oN3GBLYfSCPChudEGkDu+pCkNLXjX1QgBdlZyRWhtD+0pCcI2UgPCMh44SEU6TYH3uboWXYILL81PHvOq39DDyFbU8hTkndZhXgynY78MtcHYWsKAJZiesic3OuRS3Pp5k5I+IhpbOaXStWYZtwyr04CZ8wqH+WoxJjOZRKAf56IfnPOGq3f4gQlmYLHkcxXGV00lyZzC7k3F44lvOXC1mA6tTOIMYnho4FWTJmW1ZCCxZ8as6Z6j34K+9LgNYELNC4xAgszRfr1ig== 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=c1t+U8pLZaeW5hzpRJRJ9+MBIyEhVNXD/wTJvv3Nxal8CE13+Re87F/q9wc5vT15XYxkP/eoec/fs7J1QxcZ/HZXsfiwJTvAGoLtO/Z++uEmigMQnrf3oBbLuaqVehjyLTIAuqDRYdHxr+qAxMEO1yxobrsYvCra844eVie+ukKA3w6oSoh2Bzx80hW0EbqieTjiC9qds5CIvZ24iT4fWPkKnfVmkwMjfIsciy4Jx9x1O2d6QtSEm4h4Rguei8wDZ6COW0tuMnGzmGKQpfPbmHgWw+zynbmJ4p95gc7EgfGlg2gZgBh9BgtPMxvb+2ivTgeZOIpPZfaxPTYbPWMgZA== 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=EhkdmE+u5S5oPSZmHHkKtPJOH4FugTQIPOwM0l/GwtYJDss+qKvgZjNZRjqwOovIUzc6kO+UrQO9UM1w5CPdOs0ILUqeuoxvbuLvvxkAk3Ax9pmXR170YYZjg0Id/WGb5S8C9iJ3EEY0/MMLxd2hom6WWC8s/snV5o7wgjtvYTY= Received: from PR3PR09CA0015.eurprd09.prod.outlook.com (2603:10a6:102:b7::20) by CH3PR12MB9169.namprd12.prod.outlook.com (2603:10b6:610:1a0::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7270.16; Wed, 7 Feb 2024 02:19:55 +0000 Received: from SA2PEPF000015CC.namprd03.prod.outlook.com (2603:10a6:102:b7:cafe::d2) by PR3PR09CA0015.outlook.office365.com (2603:10a6:102:b7::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.36 via Frontend Transport; Wed, 7 Feb 2024 02:19:55 +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 SA2PEPF000015CC.mail.protection.outlook.com (10.167.241.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7249.19 via Frontend Transport; Wed, 7 Feb 2024 02:19:54 +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; Tue, 6 Feb 2024 20:19:48 -0600 From: Andrew Boyer To: CC: Andrew Boyer , Subject: [PATCH v2 10/13] net/ionic: fix device close sequence to avoid crash Date: Tue, 6 Feb 2024 18:18:46 -0800 Message-ID: <20240207021849.52988-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: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF000015CC:EE_|CH3PR12MB9169:EE_ X-MS-Office365-Filtering-Correlation-Id: 3371ed31-753d-4ed3-2126-08dc2783461f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HM9Bb2NF6uRo7fi9wEm+IJtqO9vDSAEeBcHX5adBc9rTblsyDev+jIrSB61VT7yMYNNbjgqpoq3FPh5noMcnX4bO/0eqz6p9+m7IShkmIX/rQUX2UJAXMYkJe8TB692RFFACAYxFYDDmTsfu1oaAi8Ye99pbBOJF+bzZPDUd2sU9Kuuzu1Fy5Co9g6X5lXWYJb4OMweTMW3r+dS0LWCJHcgRvQ3nWcazrhf8r+vrvIV2ZgOwTDptLs1qoSKICbJcV0rCEXRx7WlIsVJHZiLgj855ZVgfd4ifhm+l6SrJX0ZJfKKvRr7dbnY4J0IZ6dVsxJHDgJFqihPi8vJHlCx2Uf/XFOBwKI72ObunfzP94CgFhd66aD16FWN8ZRrQmrT10nTBKfI6B7BLtnX4U/3v4SVAcdPjSHaThgfA7Ge+/tKNrxLj18LyWfTjWA7OjgaP8QmeUbUB2gHnAOqoDaj3TD/zDsGbGjky+94Qf/OzVDNOOSGPO1PZwQoyYFjytBxdfiy/H7Ri3VIo9HccDIC4JU8fZvTSumgsT+EPeCh5gWjokJD7y6yZivF+Xg0C6hG3gyG+N09Sp7aR7jZfuXXl2c//XW5oux/lSU+zKs4TRglCvuTemzFu5y8+Jw+5yBHicrBigVP7GkXKOPC4qS+WVJh4VYYI2VPxs1rhdxft4cxH54S7yiQwP4F7T3UwmyjJeOyRF5ZYLQBZaa1If9M3udLGo6uw9pb3Nl6ssoE6y/zRAyCi5k2brdkquLzFEfsqzhJn+o59Z5Q+ZsQsbNIt+A== 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)(136003)(39860400002)(376002)(396003)(346002)(230922051799003)(186009)(451199024)(1800799012)(64100799003)(82310400011)(36840700001)(46966006)(40470700004)(36756003)(44832011)(5660300002)(2906002)(41300700001)(86362001)(426003)(47076005)(83380400001)(336012)(16526019)(26005)(2616005)(36860700001)(40480700001)(478600001)(40460700003)(1076003)(81166007)(356005)(82740400003)(70586007)(8936002)(6916009)(316002)(70206006)(450100002)(4326008)(54906003)(8676002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2024 02:19:54.9630 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3371ed31-753d-4ed3-2126-08dc2783461f 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: SA2PEPF000015CC.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB9169 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