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 1BA9943A2A; Wed, 7 Feb 2024 04:14:53 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8AFE342DFC; Wed, 7 Feb 2024 04:14:29 +0100 (CET) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2078.outbound.protection.outlook.com [40.107.92.78]) by mails.dpdk.org (Postfix) with ESMTP id DF16F42DBB; Wed, 7 Feb 2024 04:14:23 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MC5nhYhNerC4M+KEHB/d573v3MJeW8QuaNG+q0cTt+KdpeSriE3jxbtiisFcxZs/9MFX4di4BP+py9JRm4HWPh8eRNhDwCEjutwCNPgzJ7I/7i/FDZNOBQzS6UJ1HT7EaTtlsAvV6IyOvdcM0q+jryH1fmHEmdZU7A1fkKNTCKK/gk1qcX0bygj4w7v73D6qUk7wow8uYNXwpjr8cV/PwJ/g+tem8n7hBmmDwaQ7fNOhxfnwvJ0JUpAjJZbet6ch4ug9oe0T/Us2FjGaGiahreMdQw8zTbSyVwkgDMGy87Sl5nmTXrFGLJQARGBebwJSkaYO0zbGclmNEhHJTEglvQ== 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=LlDhuDNdgNKPwGFAPVDEjfBE45TBCZxZ5Atj3msuepTS3pjQYGGyGVljf8Q6tnrJEMzhN1QxJCrWGQydZnONwtSPoyC6eyPKbQCWpdkFhJwy2RFcnWFRNOcSQfcQJv0n4Clre5xtMYR4lHn4s54Tesuv+2kB8TJu3lk2P321VBJLLtIVwmq6dP19O0RBbLWKBwGt0VChjVyjOZebwrtN5kcGs78abkF4W8bK1A9FijgnM3FhXVGHP8I65E7uwCCKSxwD7kT1uXJlPt8gXfcBgoYhDoUrFJwWwrn6/KNMnDxsdOvBOBzKk1TQIxraKSUpSo/ZC47B5RPjy0wek5h2yg== 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=xwEN8z3uie7OMex18Wq8v0giPq2w5R6zoZLvpNmpBgj6HvC1qlc4aXIMLjJ/5QkKbrKQ8ERbQ7cVDvl2XB2VsYBS4rB4w2hqx9K9BL6CZg+SO77EbhgyCzCaRDjAT5LhAkOZMYp0+EJqsF/t6bBx97QvvsYCee/cV8NFNWNNDII= Received: from DM6PR02CA0147.namprd02.prod.outlook.com (2603:10b6:5:332::14) by CH2PR12MB4167.namprd12.prod.outlook.com (2603:10b6:610:7a::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7270.17; Wed, 7 Feb 2024 03:14:22 +0000 Received: from CO1PEPF000044F7.namprd21.prod.outlook.com (2603:10b6:5:332:cafe::5f) by DM6PR02CA0147.outlook.office365.com (2603:10b6:5:332::14) 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 03:14:22 +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 CO1PEPF000044F7.mail.protection.outlook.com (10.167.241.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7292.0 via Frontend Transport; Wed, 7 Feb 2024 03:14:21 +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 21:14:18 -0600 From: Andrew Boyer To: CC: Andrew Boyer , Subject: [PATCH v3 10/13] net/ionic: fix device close sequence to avoid crash Date: Tue, 6 Feb 2024 19:13:14 -0800 Message-ID: <20240207031317.32293-11-andrew.boyer@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240207031317.32293-1-andrew.boyer@amd.com> References: <20240202193238.62669-1-andrew.boyer@amd.com> <20240207031317.32293-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: CO1PEPF000044F7:EE_|CH2PR12MB4167:EE_ X-MS-Office365-Filtering-Correlation-Id: 35192e18-22da-4fc1-8d76-08dc278ae15c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NGQIWcY+V8b7SlpTnINZ7WXbsKRFOF/W1fgKh+VxYHcumKdD99Fn1tWu3086Dk97NtJ2yciBTyI1rAk/uxWFi6VPWRcCqaAf02JT6iDRiWf+H7CWVBXJm6WozzsAAR+Q3jf2kJOAZ3StZG6vfmZ2TkuheoPW0yQqI4cC+RpBbN2myipgsxDiOR5XJx7DxCkQ8d6hu7oA93sSm4jepwAj4eBDp74+zYVQQ7EvIDqG3vgKJ3ey7OBlynQdyvogaMX1pMbvEbHSMVRD9mLb13fQVhpdSjVfwl2kC3MifFZ6DO8+27q364MpU8kTJa41ZVZXjF3h7e35YhlpdFKvjeUmBPiDaFqQwfEL0Y38h/x5j6HhMaRyYRmNzWZdZBRa/odPVXTM5xUZP1tuMobTzN3sr55qmiVrNxpLkgbsE4QD0XR51vhAEOyE786a6BcjRH2bwoLjUnkZMWrcYqTgF3OEFva1zMBgp6Y1uxI8yM+53reDvt22oarlt5c33zWNN+m2Ih8z4d/RvIF9BhJRS7qPKoTgiIfmkP6wl736pqCQR/pHKg9Yacj9eZtsHED81tlPIHTsK577use1du7Gp8mUfsnNE3K3gWM+LpmoCKvOfySh30uHBpVKYf8PFJkIIEvBjalgy4dV6NHv2Z64waSq5x506w6+Cmy8Fe/F7+2w911s7L5UOLAyImj67nGMdXf5kN3ZeMclcPdBNliCacwlBJDsON+jV7WnGNyFNDnGNdGTJnoTf8Ehqfskaqs8pt6GnCm2EQj39Hy26mh0P9Y6Tw== 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)(39860400002)(136003)(346002)(396003)(376002)(230922051799003)(82310400011)(186009)(64100799003)(451199024)(1800799012)(46966006)(36840700001)(40470700004)(41300700001)(36756003)(426003)(478600001)(316002)(5660300002)(8936002)(8676002)(70586007)(450100002)(6916009)(70206006)(4326008)(54906003)(86362001)(44832011)(36860700001)(47076005)(82740400003)(2616005)(356005)(81166007)(83380400001)(1076003)(16526019)(6666004)(26005)(336012)(2906002)(40480700001)(40460700003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Feb 2024 03:14:21.8114 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 35192e18-22da-4fc1-8d76-08dc278ae15c 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: CO1PEPF000044F7.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4167 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