From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6555CA5FCE for ; Mon, 5 Oct 2026 08:54:43 +0000 (UTC) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F1D8840DDD; Mon, 5 Oct 2026 10:53:53 +0200 (CEST) Received: from inva021.nxp.com (inva021.nxp.com [92.121.34.21]) by mails.dpdk.org (Postfix) with ESMTP id F10EE40290 for ; Mon, 5 Oct 2026 10:53:43 +0200 (CEST) Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id D549F2000AA; Mon, 5 Oct 2026 10:53:43 +0200 (CEST) Received: from aprdc01srsp001v.ap-rdc01.nxp.com (aprdc01srsp001v.ap-rdc01.nxp.com [165.114.16.16]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 9EAAC200090; Mon, 5 Oct 2026 10:53:43 +0200 (CEST) Received: from lsv03583.swis.in-blr01.nxp.com (lsv03583.swis.in-blr01.nxp.com [92.120.146.12]) by aprdc01srsp001v.ap-rdc01.nxp.com (Postfix) with ESMTP id 192B6180022C; Mon, 5 Oct 2026 16:53:43 +0800 (+08) From: Hemant Agrawal To: stephen@networkplumber.org, thomas@monjalon.net, dev@dpdk.org Cc: Prashant Gupta Subject: [PATCH v20 09/27] drivers: add process-type guards for secondary process Date: Mon, 5 Oct 2026 14:23:19 +0530 Message-Id: <20261005085337.1069213-10-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20261005085337.1069213-1-hemant.agrawal@nxp.com> References: <20261001112430.251845-1-hemant.agrawal@nxp.com> <20261005085337.1069213-1-hemant.agrawal@nxp.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Virus-Scanned: ClamAV using ClamSMTP X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Prashant Gupta 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 --- 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 30a9a34a6d..1aa2f61ffb 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 */ @@ -2692,6 +2692,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