From patchwork Mon May 23 16:10:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harman Kalra X-Patchwork-Id: 111635 X-Patchwork-Delegate: jerinj@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 26FDDA00C2; Mon, 23 May 2022 18:11:15 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9A03F42670; Mon, 23 May 2022 18:11:12 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 5AED241143 for ; Mon, 23 May 2022 18:11:11 +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 24NAorxu020041 for ; Mon, 23 May 2022 09:11:10 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0220; bh=ElwPjVtyFcwVCbU/ZRUmtthq2glHiwt7Vpfrsusm+bo=; b=Bl9f7z+7xLTjJZXf6P6SA6HFZa2e30J6cYgdum65d1bPm5XlT+4Cp9Czxy8JMfNTrSSK boW7w4qEKWvSYMVLsv7wJVxLUG3wdnjTf88lK9HYvH8JOrNQ38GPbJIlC7f47QKd06sc GhiBYOze0bZmnTA4OKRRKyPITREhJIv0vWvXBVdXGFMrRgEsK9bcov1rDtXqU43iq08w 7jJjALJlWdFH42Gtpr9DAmXoRqrKtwWA4CuQj7yE6M1ATbPRxESaFRq7IUWG8/LhJ7BM ZWoQgJg2EK6RvEgeavERrrbR317EAxDTNuKEZqZMDD06U3ND/pXJ2H9zvC6o31/QDhFS pQ== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3g6wepet8k-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Mon, 23 May 2022 09:11:10 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 23 May 2022 09:11:09 -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; Mon, 23 May 2022 09:11:09 -0700 Received: from localhost.localdomain (unknown [10.29.52.211]) by maili.marvell.com (Postfix) with ESMTP id 3ADEB3F70A5; Mon, 23 May 2022 09:11:07 -0700 (PDT) From: Harman Kalra To: , Harman Kalra Subject: [PATCH v2 02/11] net/octeontx: fix port close Date: Mon, 23 May 2022 21:40:51 +0530 Message-ID: <20220523161100.86280-2-hkalra@marvell.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20220523161100.86280-1-hkalra@marvell.com> References: <20220517173941.189330-2-hkalra@marvell.com> <20220523161100.86280-1-hkalra@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: rPcymCUHbxYlvP0QzakCfTddx44_OQ2A X-Proofpoint-ORIG-GUID: rPcymCUHbxYlvP0QzakCfTddx44_OQ2A X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-23_07,2022-05-23_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 Segmentation fault has been observed while closing the ethernet port. Reason for the segfault is, eth port close also shuts down event device while other ethernet port is still using the event device. Fixes: da6c687471a3 ("net/octeontx: add start and stop support") Signed-off-by: Harman Kalra --- drivers/net/octeontx/octeontx_ethdev.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/net/octeontx/octeontx_ethdev.c b/drivers/net/octeontx/octeontx_ethdev.c index f5ea9de8ef..6469fd0a96 100644 --- a/drivers/net/octeontx/octeontx_ethdev.c +++ b/drivers/net/octeontx/octeontx_ethdev.c @@ -26,6 +26,11 @@ #include "octeontx_rxtx.h" #include "octeontx_logs.h" +/* Useful in stopping/closing event device if no of + * eth ports are using it. + */ +uint16_t evdev_refcnt; + struct evdev_priv_data { OFFLOAD_FLAGS; /*Sequence should not be changed */ } __rte_cache_aligned; @@ -491,7 +496,11 @@ octeontx_dev_close(struct rte_eth_dev *dev) if (rte_eal_process_type() != RTE_PROC_PRIMARY) return 0; - rte_event_dev_close(nic->evdev); + /* Stopping/closing event device once all eth ports are closed. */ + if (__atomic_sub_fetch(&evdev_refcnt, 1, __ATOMIC_ACQUIRE) == 0) { + rte_event_dev_stop(nic->evdev); + rte_event_dev_close(nic->evdev); + } octeontx_dev_flow_ctrl_fini(dev); @@ -671,8 +680,6 @@ octeontx_dev_stop(struct rte_eth_dev *dev) PMD_INIT_FUNC_TRACE(); - rte_event_dev_stop(nic->evdev); - ret = octeontx_port_stop(nic); if (ret < 0) { octeontx_log_err("failed to req stop port %d res=%d", @@ -1333,6 +1340,7 @@ octeontx_create(struct rte_vdev_device *dev, int port, uint8_t evdev, nic->pko_vfid = pko_vfid; nic->port_id = port; nic->evdev = evdev; + __atomic_add_fetch(&evdev_refcnt, 1, __ATOMIC_ACQUIRE); res = octeontx_port_open(nic); if (res < 0) @@ -1582,6 +1590,7 @@ octeontx_probe(struct rte_vdev_device *dev) } } + __atomic_store_n(&evdev_refcnt, 0, __ATOMIC_RELEASE); /* * Do 1:1 links for ports & queues. All queues would be mapped to * one port. If there are more ports than queues, then some ports