From: Prashant Gupta <[email protected]>

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 <[email protected]>
---
 drivers/dma/dpaa/dpaa_qdma.c   | 14 ++++++++++++++
 drivers/net/dpaa/dpaa_ethdev.c |  6 +++++-
 2 files changed, 19 insertions(+), 1 deletion(-)

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 99361b747f..811f19421d 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 */
@@ -2684,6 +2684,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 ? rte_eth_dev_release_port(eth_dev) : 0;
+
        if (eth_dev && eth_dev->state != RTE_ETH_DEV_UNUSED) {
                int close_ret = dpaa_eth_dev_close(eth_dev);
 
-- 
2.25.1

Reply via email to