Skip to content

Commit

Permalink
net/ionic: fix device close
Browse files Browse the repository at this point in the history
[ upstream commit 73028be3b4d4d52f5d73becfd22bff3f57a81252 ]

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: 175e4e7 ("net/ionic: complete release on close")

Signed-off-by: Andrew Boyer <andrew.boyer@amd.com>
  • Loading branch information
andrewb24 authored and kevintraynor committed Mar 5, 2024
1 parent bee2ac7 commit 3b7cc64
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions drivers/net/ionic/ionic_ethdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -952,16 +952,17 @@ 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);
ionic_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 */

lif->adapter = NULL;
rte_free(adapter);

return 0;
Expand Down Expand Up @@ -1038,21 +1039,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;
}
Expand Down Expand Up @@ -1257,18 +1255,19 @@ eth_ionic_pci_remove(struct rte_pci_device *pci_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", pci_dev->device.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",
pci_dev->device.name);

return 0;
return ret;
}

static struct rte_pci_driver rte_ionic_pmd = {
Expand Down

0 comments on commit 3b7cc64

Please sign in to comment.