DPDK patches and discussions
 help / color / mirror / Atom feed
From: Andrew Boyer <andrew.boyer@amd.com>
To: <dev@dpdk.org>
Cc: Andrew Boyer <andrew.boyer@amd.com>, <stable@dpdk.org>
Subject: [PATCH v2 10/13] net/ionic: fix device close sequence to avoid crash
Date: Tue, 6 Feb 2024 18:18:46 -0800	[thread overview]
Message-ID: <20240207021849.52988-11-andrew.boyer@amd.com> (raw)
In-Reply-To: <20240202193238.62669-1-andrew.boyer@amd.com>

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 <andrew.boyer@amd.com>
---
 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


  parent reply	other threads:[~2024-02-07  2:20 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-02 19:32 [PATCH 00/13] net/ionic: miscellaneous fixes and improvements Andrew Boyer
2024-02-02 19:32 ` [PATCH 01/13] net/ionic: add stat for completion queue entries processed Andrew Boyer
2024-02-03  4:24   ` Stephen Hemminger
2024-02-05 12:49     ` Boyer, Andrew
2024-02-02 19:32 ` [PATCH 02/13] net/ionic: increase max supported MTU to 9750 bytes Andrew Boyer
2024-02-02 19:32 ` [PATCH 03/13] net/ionic: don't auto-enable Rx scatter-gather a second time Andrew Boyer
2024-02-02 19:32 ` [PATCH 04/13] net/ionic: fix missing volatile type for cqe pointers Andrew Boyer
2024-02-03  4:26   ` Stephen Hemminger
2024-02-05 13:33     ` Boyer, Andrew
2024-02-02 19:32 ` [PATCH 05/13] net/ionic: replace non-standard type in structure definition Andrew Boyer
2024-02-02 19:32 ` [PATCH 06/13] net/ionic: memcpy descriptors when using Q-in-CMB Andrew Boyer
2024-02-02 19:32 ` [PATCH 07/13] net/ionic: fix RSS query routine Andrew Boyer
2024-02-02 19:32 ` [PATCH 08/13] net/ionic: report 1G and 200G link speeds when applicable Andrew Boyer
2024-02-02 19:32 ` [PATCH 09/13] net/ionic: add flexible firmware xstat counters Andrew Boyer
2024-02-02 19:32 ` [PATCH 10/13] net/ionic: fix device close sequence to avoid crash Andrew Boyer
2024-02-02 19:32 ` [PATCH 11/13] net/ionic: optimize device close operation Andrew Boyer
2024-02-02 19:32 ` [PATCH 12/13] net/ionic: optimize device stop operation Andrew Boyer
2024-02-02 19:32 ` [PATCH 13/13] net/ionic: optimize device start operation Andrew Boyer
2024-02-03  4:28   ` Stephen Hemminger
2024-02-05 13:21     ` Boyer, Andrew
2024-02-05 18:44 ` [PATCH 00/13] net/ionic: miscellaneous fixes and improvements Patrick Robb
2024-02-05 19:41   ` Boyer, Andrew
2024-02-07  2:18 ` [PATCH v2 " Andrew Boyer
2024-02-07  2:18 ` [PATCH v2 01/13] net/ionic: add stat for completion queue entries processed Andrew Boyer
2024-02-07  2:18 ` [PATCH v2 02/13] net/ionic: increase max supported MTU to 9750 bytes Andrew Boyer
2024-02-07  2:18 ` [PATCH v2 03/13] net/ionic: don't auto-enable Rx scatter-gather a second time Andrew Boyer
2024-02-07  2:18 ` [PATCH v2 04/13] net/ionic: fix missing volatile type for cqe pointers Andrew Boyer
2024-02-07  2:18 ` [PATCH v2 05/13] net/ionic: replace non-standard type in structure definition Andrew Boyer
2024-02-07  2:18 ` [PATCH v2 06/13] net/ionic: memcpy descriptors when using Q-in-CMB Andrew Boyer
2024-02-07  2:18 ` [PATCH v2 07/13] net/ionic: fix RSS query routine Andrew Boyer
2024-02-07  2:18 ` [PATCH v2 08/13] net/ionic: report 1G and 200G link speeds when applicable Andrew Boyer
2024-02-07  2:18 ` [PATCH v2 09/13] net/ionic: add flexible firmware xstat counters Andrew Boyer
2024-02-07  2:18 ` Andrew Boyer [this message]
2024-02-07  2:18 ` [PATCH v2 11/13] net/ionic: optimize device close operation Andrew Boyer
2024-02-07  2:18 ` [PATCH v2 12/13] net/ionic: optimize device stop operation Andrew Boyer
2024-02-07  2:18 ` [PATCH v2 13/13] net/ionic: optimize device start operation Andrew Boyer
2024-02-07  3:13 ` [PATCH v3 00/13] net/ionic: miscellaneous fixes and improvements Andrew Boyer
2024-02-07  3:13   ` [PATCH v3 01/13] net/ionic: add stat for completion queue entries processed Andrew Boyer
2024-02-07  3:13   ` [PATCH v3 02/13] net/ionic: increase max supported MTU to 9750 bytes Andrew Boyer
2024-02-07  3:13   ` [PATCH v3 03/13] net/ionic: don't auto-enable Rx scatter-gather a second time Andrew Boyer
2024-02-07  3:13   ` [PATCH v3 04/13] net/ionic: fix missing volatile type for cqe pointers Andrew Boyer
2024-02-07  3:13   ` [PATCH v3 05/13] net/ionic: replace non-standard type in structure definition Andrew Boyer
2024-02-07  3:13   ` [PATCH v3 06/13] net/ionic: memcpy descriptors when using Q-in-CMB Andrew Boyer
2024-02-07  3:13   ` [PATCH v3 07/13] net/ionic: fix RSS query routine Andrew Boyer
2024-02-07  3:13   ` [PATCH v3 08/13] net/ionic: report 1G and 200G link speeds when applicable Andrew Boyer
2024-02-07  3:13   ` [PATCH v3 09/13] net/ionic: add flexible firmware xstat counters Andrew Boyer
2024-02-07  3:13   ` [PATCH v3 10/13] net/ionic: fix device close sequence to avoid crash Andrew Boyer
2024-02-07  3:13   ` [PATCH v3 11/13] net/ionic: optimize device close operation Andrew Boyer
2024-02-07  3:13   ` [PATCH v3 12/13] net/ionic: optimize device stop operation Andrew Boyer
2024-02-07  3:13   ` [PATCH v3 13/13] net/ionic: optimize device start operation Andrew Boyer
2024-02-07 15:45   ` [PATCH v3 00/13] net/ionic: miscellaneous fixes and improvements Ferruh Yigit
2024-02-08 15:32     ` Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240207021849.52988-11-andrew.boyer@amd.com \
    --to=andrew.boyer@amd.com \
    --cc=dev@dpdk.org \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).