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 62FECC624CF for ; Tue, 1 Sep 2026 10:20:13 +0000 (UTC) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4C8E640B9D; Tue, 1 Sep 2026 12:19:42 +0200 (CEST) Received: from inva020.nxp.com (inva020.nxp.com [92.121.34.13]) by mails.dpdk.org (Postfix) with ESMTP id DC0C140B8C for ; Tue, 1 Sep 2026 12:19:39 +0200 (CEST) Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id BD6731A0004; Tue, 1 Sep 2026 12:19:39 +0200 (CEST) Received: from aprdc01srsp001v.ap-rdc01.nxp.com (aprdc01srsp001v.ap-rdc01.nxp.com [165.114.16.16]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 8595C1A0010; Tue, 1 Sep 2026 12:19:39 +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 06FEC18000B7; Tue, 1 Sep 2026 18:19:37 +0800 (+08) From: Hemant Agrawal To: stephen@networkplumber.org, thomas@monjalon.net, dev@dpdk.org Cc: Prashant Gupta Subject: [PATCH v15 06/23] drivers: add process-type guards for secondary process Date: Tue, 1 Sep 2026 15:49:09 +0530 Message-Id: <20260901101926.1574209-7-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20260901101926.1574209-1-hemant.agrawal@nxp.com> References: <20260820144312.3922316-1-hemant.agrawal@nxp.com> <20260901101926.1574209-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 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