Skip to content

Commit

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

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 cpaelzer committed Jul 7, 2022
1 parent 69b3923 commit 07d9cd4
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 @@ -24,6 +24,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 octeontx_vdev_init_params {
uint8_t nr_port;
};
Expand Down Expand Up @@ -336,7 +341,11 @@ octeontx_dev_close(struct rte_eth_dev *dev)
if (rte_eal_process_type() != RTE_PROC_PRIMARY)
return;

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);
}

ret = octeontx_pko_channel_close(nic->base_ochan);
if (ret < 0) {
Expand Down Expand Up @@ -429,8 +438,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 @@ -1059,6 +1066,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 @@ -1287,6 +1295,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 07d9cd4

Please sign in to comment.