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 C3F81A0548; Thu, 27 May 2021 11:48:18 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 462C840150; Thu, 27 May 2021 11:48:18 +0200 (CEST) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mails.dpdk.org (Postfix) with ESMTP id A9B2540143; Thu, 27 May 2021 11:48:16 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E43E713A1; Thu, 27 May 2021 02:48:15 -0700 (PDT) Received: from net-x86-dell-8268.shanghai.arm.com (net-x86-dell-8268.shanghai.arm.com [10.169.210.132]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 13A6E3F73D; Thu, 27 May 2021 02:48:12 -0700 (PDT) From: Feifei Wang To: Matan Azrad , Shahaf Shuler , Viacheslav Ovsiienko Cc: dev@dpdk.org, nd@arm.com, Feifei Wang , shahafs@mellanox.com, stable@dpdk.org, Ruifeng Wang Date: Thu, 27 May 2021 17:48:06 +0800 Message-Id: <20210527094806.1383353-1-feifei.wang2@arm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] net/mlx5: fix incorrect r/w lock usage in DMA unmap 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 Sender: "dev" For mlx5 DMA unmap, write lock should be used for rebuilding memory region cache table rather than read lock. Fixes: 989e999d9305 ("net/mlx5: support PCI device DMA map and unmap") Cc: shahafs@mellanox.com Cc: stable@dpdk.org Signed-off-by: Feifei Wang Reviewed-by: Ruifeng Wang --- drivers/net/mlx5/mlx5_mr.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/mlx5/mlx5_mr.c b/drivers/net/mlx5/mlx5_mr.c index e791b6338d..45a122f4f9 100644 --- a/drivers/net/mlx5/mlx5_mr.c +++ b/drivers/net/mlx5/mlx5_mr.c @@ -395,10 +395,10 @@ mlx5_dma_unmap(struct rte_pci_device *pdev, void *addr, } priv = dev->data->dev_private; sh = priv->sh; - rte_rwlock_read_lock(&sh->share_cache.rwlock); + rte_rwlock_write_lock(&sh->share_cache.rwlock); mr = mlx5_mr_lookup_list(&sh->share_cache, &entry, (uintptr_t)addr); if (!mr) { - rte_rwlock_read_unlock(&sh->share_cache.rwlock); + rte_rwlock_write_unlock(&sh->share_cache.rwlock); DRV_LOG(WARNING, "address 0x%" PRIxPTR " wasn't registered " "to PCI device %p", (uintptr_t)addr, (void *)pdev); @@ -423,7 +423,7 @@ mlx5_dma_unmap(struct rte_pci_device *pdev, void *addr, DRV_LOG(DEBUG, "broadcasting local cache flush, gen=%d", sh->share_cache.dev_gen); rte_smp_wmb(); - rte_rwlock_read_unlock(&sh->share_cache.rwlock); + rte_rwlock_write_unlock(&sh->share_cache.rwlock); return 0; } -- 2.25.1