Skip to content

Commit bf84bcf

Browse files
Gagandeep Singhferruhy
authored andcommitted
net/dpaa: improve port cleanup
During DPAA cleanup in FMCLESS mode, application can see segmentation fault in device close API and in DPAA destructor execution. Segmentation fault in device close is because driver reducing the number of queues initialised during device configuration without releasing the actual queues. And segmentation fault in DPAA destruction is because it is trying to access RTE* devices whose memory has been released in rte_eal_cleanup() call by the application. This patch improves the behavior. Signed-off-by: Gagandeep Singh <[email protected]> Acked-by: Hemant Agrawal <[email protected]>
1 parent d5e5023 commit bf84bcf

File tree

2 files changed

+13
-25
lines changed

2 files changed

+13
-25
lines changed

drivers/net/dpaa/dpaa_ethdev.c

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -561,10 +561,10 @@ static int dpaa_eth_dev_close(struct rte_eth_dev *dev)
561561
if (dpaa_intf->cgr_rx) {
562562
for (loop = 0; loop < dpaa_intf->nb_rx_queues; loop++)
563563
qman_delete_cgr(&dpaa_intf->cgr_rx[loop]);
564+
rte_free(dpaa_intf->cgr_rx);
565+
dpaa_intf->cgr_rx = NULL;
564566
}
565567

566-
rte_free(dpaa_intf->cgr_rx);
567-
dpaa_intf->cgr_rx = NULL;
568568
/* Release TX congestion Groups */
569569
if (dpaa_intf->cgr_tx) {
570570
for (loop = 0; loop < MAX_DPAA_CORES; loop++)
@@ -578,6 +578,15 @@ static int dpaa_eth_dev_close(struct rte_eth_dev *dev)
578578

579579
rte_free(dpaa_intf->tx_queues);
580580
dpaa_intf->tx_queues = NULL;
581+
if (dpaa_intf->port_handle) {
582+
if (dpaa_fm_deconfig(dpaa_intf, fif))
583+
DPAA_PMD_WARN("DPAA FM "
584+
"deconfig failed\n");
585+
}
586+
if (fif->num_profiles) {
587+
if (dpaa_port_vsp_cleanup(dpaa_intf, fif))
588+
DPAA_PMD_WARN("DPAA FM vsp cleanup failed\n");
589+
}
581590

582591
return ret;
583592
}
@@ -2607,26 +2616,6 @@ static void __attribute__((destructor(102))) dpaa_finish(void)
26072616
return;
26082617

26092618
if (!(default_q || fmc_q)) {
2610-
unsigned int i;
2611-
2612-
for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
2613-
if (rte_eth_devices[i].dev_ops == &dpaa_devops) {
2614-
struct rte_eth_dev *dev = &rte_eth_devices[i];
2615-
struct dpaa_if *dpaa_intf =
2616-
dev->data->dev_private;
2617-
struct fman_if *fif =
2618-
dev->process_private;
2619-
if (dpaa_intf->port_handle)
2620-
if (dpaa_fm_deconfig(dpaa_intf, fif))
2621-
DPAA_PMD_WARN("DPAA FM "
2622-
"deconfig failed");
2623-
if (fif->num_profiles) {
2624-
if (dpaa_port_vsp_cleanup(dpaa_intf,
2625-
fif))
2626-
DPAA_PMD_WARN("DPAA FM vsp cleanup failed");
2627-
}
2628-
}
2629-
}
26302619
if (is_global_init)
26312620
if (dpaa_fm_term())
26322621
DPAA_PMD_WARN("DPAA FM term failed");

drivers/net/dpaa/dpaa_flow.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <rte_dpaa_logs.h>
1414
#include <fmlib/fm_port_ext.h>
1515
#include <fmlib/fm_vsp_ext.h>
16+
#include <rte_pmd_dpaa.h>
1617

1718
#define DPAA_MAX_NUM_ETH_DEV 8
1819

@@ -795,8 +796,6 @@ int dpaa_fm_config(struct rte_eth_dev *dev, uint64_t req_dist_set)
795796
return -1;
796797
}
797798

798-
dpaa_intf->nb_rx_queues = dev->data->nb_rx_queues;
799-
800799
/* Open FM Port and set it in port info */
801800
ret = set_fm_port_handle(dpaa_intf, req_dist_set, fif);
802801
if (ret) {
@@ -805,7 +804,7 @@ int dpaa_fm_config(struct rte_eth_dev *dev, uint64_t req_dist_set)
805804
}
806805

807806
if (fif->num_profiles) {
808-
for (i = 0; i < dpaa_intf->nb_rx_queues; i++)
807+
for (i = 0; i < dev->data->nb_rx_queues; i++)
809808
dpaa_intf->rx_queues[i].vsp_id =
810809
fm_default_vsp_id(fif);
811810

0 commit comments

Comments
 (0)