[PATCH v26 09/26] drivers: add process-type guards for secondary process
Hemant Agrawal
hemant.agrawal at nxp.com
Thu Oct 15 16:11:27 CEST 2026
From: Prashant Gupta <prashant.gupta_3 at nxp.com>
The DPAA QDMA and net/dpaa drivers run primary-only code from paths that
a secondary process also executes.
In dma/dpaa, struct fsl_qdma_engine is allocated from shared memory, but
the register bases stored in it are process-private mmap()s of the QDMA
CCSR region created by the primary. A secondary that probes the device
would advertise a dmadev whose MMIO pointers are not mapped in its own
address space. Reject the probe with -ENOTSUP until a secondary can
establish its own mapping.
In net/dpaa, rte_dpaa_remove() also does primary-only bookkeeping: it
decrements the driver device count and frees the shared Tx
scatter-gather mempool when that count reaches zero. Both are set up
only on the primary probe path, so a secondary must not run them. Let a
secondary release just its local ethdev port and return.
Signed-off-by: Prashant Gupta <prashant.gupta_3 at nxp.com>
---
drivers/bus/dpaa/dpaa_bus.c | 3 ++-
drivers/dma/dpaa/dpaa_qdma.c | 14 ++++++++++++++
drivers/net/dpaa/dpaa_ethdev.c | 6 +++++-
3 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/drivers/bus/dpaa/dpaa_bus.c b/drivers/bus/dpaa/dpaa_bus.c
index 5442f8f893..e9bfc7b956 100644
--- a/drivers/bus/dpaa/dpaa_bus.c
+++ b/drivers/bus/dpaa/dpaa_bus.c
@@ -804,7 +804,8 @@ dpaa_bus_probe_device(struct rte_driver *drv, struct rte_device *dev)
int ret;
ret = dpaa_drv->probe(dpaa_drv, dpaa_dev);
- if (ret != 0)
+ /* A positive return means the driver declined the device. */
+ if (ret < 0)
DPAA_BUS_ERR("unable to probe: %s", dpaa_dev->name);
return ret;
diff --git a/drivers/dma/dpaa/dpaa_qdma.c b/drivers/dma/dpaa/dpaa_qdma.c
index e2cb157c43..0234042ded 100644
--- a/drivers/dma/dpaa/dpaa_qdma.c
+++ b/drivers/dma/dpaa/dpaa_qdma.c
@@ -1433,6 +1433,20 @@ dpaa_qdma_probe(__rte_unused struct rte_dpaa_driver *dpaa_drv,
struct rte_dma_dev *dmadev;
int ret;
+ /*
+ * struct fsl_qdma_engine lives in memory shared with the primary, and
+ * reg_base in it is a process-private mmap of the QDMA CCSR region that
+ * is only valid in the primary. Until a secondary can establish its own
+ * mapping, do not advertise the device here: registering it would hand
+ * out a usable dmadev whose MMIO pointers are not mapped in this
+ * process.
+ */
+ if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
+ DPAA_QDMA_WARN("%s: not supported in secondary process",
+ dpaa_dev->device.name);
+ return -ENOTSUP;
+ }
+
dmadev = rte_dma_pmd_allocate(dpaa_dev->device.name,
rte_socket_id(),
sizeof(struct fsl_qdma_engine));
diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index 1688acfb30..049723cb19 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright 2016 Freescale Semiconductor, Inc. All rights reserved.
- * Copyright 2017-2020,2022-2025 NXP
+ * Copyright 2017-2020,2022-2026 NXP
*
*/
/* System headers */
@@ -2691,6 +2691,10 @@ rte_dpaa_remove(struct rte_dpaa_device *dpaa_dev)
PMD_INIT_FUNC_TRACE();
eth_dev = rte_eth_dev_allocated(dpaa_dev->device.name);
+
+ if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+ return eth_dev != NULL ? rte_eth_dev_release_port(eth_dev) : 0;
+
if (eth_dev != NULL && eth_dev->state != RTE_ETH_DEV_UNUSED) {
ret = dpaa_eth_dev_close(eth_dev);
if (ret != 0)
--
2.25.1
More information about the dev
mailing list