Skip to content

Commit

Permalink
net/octeontx: fix port close
Browse files Browse the repository at this point in the history
[ upstream commit 39e0717 ]

Segmentation fault has been observed while closing the ethernet
port. Reason for the segfault is, eth port close also shuts down
event device while other ethernet port is still using the event
device.

Fixes: da6c687 ("net/octeontx: add start and stop support")

Signed-off-by: Harman Kalra <hkalra@marvell.com>
  • Loading branch information
Harman Kalra authored and steevenlee committed Jul 19, 2022
1 parent c9f6c89 commit ac50182
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions drivers/net/octeontx/octeontx_ethdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
#include "octeontx_rxtx.h"
#include "octeontx_logs.h"

/* Useful in stopping/closing event device if no of
* eth ports are using it.
*/
uint16_t evdev_refcnt;

struct evdev_priv_data {
OFFLOAD_FLAGS; /*Sequence should not be changed */
} __rte_cache_aligned;
Expand Down Expand Up @@ -490,7 +495,11 @@ octeontx_dev_close(struct rte_eth_dev *dev)
if (rte_eal_process_type() != RTE_PROC_PRIMARY)
return 0;

rte_event_dev_close(nic->evdev);
/* Stopping/closing event device once all eth ports are closed. */
if (__atomic_sub_fetch(&evdev_refcnt, 1, __ATOMIC_ACQUIRE) == 0) {
rte_event_dev_stop(nic->evdev);
rte_event_dev_close(nic->evdev);
}

octeontx_dev_flow_ctrl_fini(dev);

Expand Down Expand Up @@ -681,8 +690,6 @@ octeontx_dev_stop(struct rte_eth_dev *dev)

PMD_INIT_FUNC_TRACE();

rte_event_dev_stop(nic->evdev);

ret = octeontx_port_stop(nic);
if (ret < 0) {
octeontx_log_err("failed to req stop port %d res=%d",
Expand Down Expand Up @@ -1346,6 +1353,7 @@ octeontx_create(struct rte_vdev_device *dev, int port, uint8_t evdev,
nic->pko_vfid = pko_vfid;
nic->port_id = port;
nic->evdev = evdev;
__atomic_add_fetch(&evdev_refcnt, 1, __ATOMIC_ACQUIRE);

res = octeontx_port_open(nic);
if (res < 0)
Expand Down Expand Up @@ -1595,6 +1603,7 @@ octeontx_probe(struct rte_vdev_device *dev)
}
}

__atomic_store_n(&evdev_refcnt, 0, __ATOMIC_RELEASE);
/*
* Do 1:1 links for ports & queues. All queues would be mapped to
* one port. If there are more ports than queues, then some ports
Expand Down

0 comments on commit ac50182

Please sign in to comment.