From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 36D8EA0503; Sun, 8 May 2022 08:29:21 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 89A4042892; Sun, 8 May 2022 08:27:40 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id E99E24288F; Sun, 8 May 2022 08:27:38 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2483ToE1011057; Sat, 7 May 2022 23:27:38 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0220; bh=dZRZb88ikt7oBrbfyNGiS7mohzJuroiXiVKZQndxAWY=; b=HZ7bds4PK3Asezzf0Js7xfHhKifIR9l7kzz5SgtPGaHbEm4Ubjm7Eb+EGZBJGni3fcah rHi83P5zhPw3qJiPi5eKvIGwR2gTzCjkZ/DjA0Zsc6ZKwpfrD83d38NfMCD8Xmq456pA GaLqyvO5xRHRmzYrHU+sZPb0ZpwNUYqADrLatlldc7nv0L3CiU5FP/dwaxmhffgikkqY kwXFgMG3xGaUGxBtxZLcIAFrYkE/A3Gfch5QWVVqVKxbYQP4zPWzYWhk573ZOsuvOAuw zbeXX+0k+QZTvMrxLvZQ1l81+MjtDSWfQk3eusRR2CkJjk0SJSHCQms9pk2T+ZoR+JKU 2w== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3fwp4psyqq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Sat, 07 May 2022 23:27:38 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sat, 7 May 2022 23:27:36 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Sat, 7 May 2022 23:27:36 -0700 Received: from hyd1588t430.marvell.com (unknown [10.29.52.204]) by maili.marvell.com (Postfix) with ESMTP id F06DD3F7053; Sat, 7 May 2022 23:27:33 -0700 (PDT) From: Nithin Dabilpuram To: , Nithin Dabilpuram , "Kiran Kumar K" , Sunil Kumar Kori , Satha Rao , Anatoly Burakov CC: , Subject: [PATCH v4 27/28] net/cnxk: fix hotplug detach sequence for first device Date: Sun, 8 May 2022 11:56:15 +0530 Message-ID: <20220508062616.3398-27-ndabilpuram@marvell.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <20220508062616.3398-1-ndabilpuram@marvell.com> References: <20220419055921.10566-1-ndabilpuram@marvell.com> <20220508062616.3398-1-ndabilpuram@marvell.com> MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-ORIG-GUID: GrcmYyIvzATy2ZaUR0-JOcGuns3ScYdI X-Proofpoint-GUID: GrcmYyIvzATy2ZaUR0-JOcGuns3ScYdI X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-08_02,2022-05-06_01,2022-02-23_01 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 Fix hotplug detach sequence to handle case where first PCI device that is hosting NPA LF is being destroyed while in use. Fixes: 5a4341c84979 ("net/cnxk: add platform specific probe and remove") Cc: stable@dpdk.org Signed-off-by: Nithin Dabilpuram --- drivers/net/cnxk/cn10k_ethdev.c | 6 +++++- drivers/net/cnxk/cn9k_ethdev.c | 6 +++++- drivers/net/cnxk/cnxk_ethdev.c | 8 ++++---- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/net/cnxk/cn10k_ethdev.c b/drivers/net/cnxk/cn10k_ethdev.c index bc9e10f..96eeae4 100644 --- a/drivers/net/cnxk/cn10k_ethdev.c +++ b/drivers/net/cnxk/cn10k_ethdev.c @@ -778,8 +778,12 @@ cn10k_nix_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) /* Find eth dev allocated */ eth_dev = rte_eth_dev_allocated(pci_dev->device.name); - if (!eth_dev) + if (!eth_dev) { + /* Ignore if ethdev is in mid of detach state in secondary */ + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return 0; return -ENOENT; + } if (rte_eal_process_type() != RTE_PROC_PRIMARY) { /* Setup callbacks for secondary process */ diff --git a/drivers/net/cnxk/cn9k_ethdev.c b/drivers/net/cnxk/cn9k_ethdev.c index de33fa7..b46f5da 100644 --- a/drivers/net/cnxk/cn9k_ethdev.c +++ b/drivers/net/cnxk/cn9k_ethdev.c @@ -708,8 +708,12 @@ cn9k_nix_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) /* Find eth dev allocated */ eth_dev = rte_eth_dev_allocated(pci_dev->device.name); - if (!eth_dev) + if (!eth_dev) { + /* Ignore if ethdev is in mid of detach state in secondary */ + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return 0; return -ENOENT; + } if (rte_eal_process_type() != RTE_PROC_PRIMARY) { /* Setup callbacks for secondary process */ diff --git a/drivers/net/cnxk/cnxk_ethdev.c b/drivers/net/cnxk/cnxk_ethdev.c index 12ff30f..3912c24 100644 --- a/drivers/net/cnxk/cnxk_ethdev.c +++ b/drivers/net/cnxk/cnxk_ethdev.c @@ -1781,9 +1781,6 @@ cnxk_eth_dev_uninit(struct rte_eth_dev *eth_dev, bool reset) struct rte_eth_fc_conf fc_conf; int rc, i; - /* Disable switch hdr pkind */ - roc_nix_switch_hdr_set(&dev->nix, 0, 0, 0, 0); - plt_free(eth_dev->security_ctx); eth_dev->security_ctx = NULL; @@ -1791,6 +1788,9 @@ cnxk_eth_dev_uninit(struct rte_eth_dev *eth_dev, bool reset) if (rte_eal_process_type() != RTE_PROC_PRIMARY) return 0; + /* Disable switch hdr pkind */ + roc_nix_switch_hdr_set(&dev->nix, 0, 0, 0, 0); + /* Clear the flag since we are closing down */ dev->configured = 0; @@ -1927,7 +1927,7 @@ cnxk_nix_remove(struct rte_pci_device *pci_dev) /* Check if this device is hosting common resource */ nix = roc_idev_npa_nix_get(); - if (nix->pci_dev != pci_dev) + if (!nix || nix->pci_dev != pci_dev) return 0; /* Try nix fini now */ -- 2.8.4