patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH 19.11] net/mlx5: fix incorrect r/w lock usage in DMA unmap
@ 2021-08-11  8:31 Feifei Wang
  2021-08-11  8:48 ` Christian Ehrhardt
  0 siblings, 1 reply; 2+ messages in thread
From: Feifei Wang @ 2021-08-11  8:31 UTC (permalink / raw)
  To: christian.ehrhardt; +Cc: stable, nd, Feifei Wang, shahafs, Ruifeng Wang

[ upstream commit 1c196da274b82e6f1642bde7b1c407a2066caee1 ]

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 <feifei.wang2@arm.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
---
 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 54a11bd5d1..71c2254c91 100644
--- a/drivers/net/mlx5/mlx5_mr.c
+++ b/drivers/net/mlx5/mlx5_mr.c
@@ -1397,10 +1397,10 @@ mlx5_dma_unmap(struct rte_pci_device *pdev, void *addr,
 	}
 	priv = dev->data->dev_private;
 	sh = priv->sh;
-	rte_rwlock_read_lock(&sh->mr.rwlock);
+	rte_rwlock_write_lock(&sh->mr.rwlock);
 	mr = mr_lookup_dev_list(sh, &entry, (uintptr_t)addr);
 	if (!mr) {
-		rte_rwlock_read_unlock(&sh->mr.rwlock);
+		rte_rwlock_write_unlock(&sh->mr.rwlock);
 		DRV_LOG(WARNING, "address 0x%" PRIxPTR " wasn't registered "
 				 "to PCI device %p", (uintptr_t)addr,
 				 (void *)pdev);
@@ -1424,7 +1424,7 @@ mlx5_dma_unmap(struct rte_pci_device *pdev, void *addr,
 	++sh->mr.dev_gen;
 	DEBUG("broadcasting local cache flush, gen=%d",	sh->mr.dev_gen);
 	rte_smp_wmb();
-	rte_rwlock_read_unlock(&sh->mr.rwlock);
+	rte_rwlock_write_unlock(&sh->mr.rwlock);
 	return 0;
 }
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dpdk-stable] [PATCH 19.11] net/mlx5: fix incorrect r/w lock usage in DMA unmap
  2021-08-11  8:31 [dpdk-stable] [PATCH 19.11] net/mlx5: fix incorrect r/w lock usage in DMA unmap Feifei Wang
@ 2021-08-11  8:48 ` Christian Ehrhardt
  0 siblings, 0 replies; 2+ messages in thread
From: Christian Ehrhardt @ 2021-08-11  8:48 UTC (permalink / raw)
  To: Feifei Wang; +Cc: dpdk stable, nd, Shahaf Shuler, Ruifeng Wang

On Wed, Aug 11, 2021 at 10:31 AM Feifei Wang <feifei.wang2@arm.com> wrote:
>
> [ upstream commit 1c196da274b82e6f1642bde7b1c407a2066caee1 ]
>
> For mlx5 DMA unmap, write lock should be used for rebuilding memory
> region cache table rather than read lock.

Thank you, applied to the WIP 19.11 branch

> Fixes: 989e999d9305 ("net/mlx5: support PCI device DMA map and unmap")
> Cc: shahafs@mellanox.com
> Cc: stable@dpdk.org
>
> Signed-off-by: Feifei Wang <feifei.wang2@arm.com>
> Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
> ---
>  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 54a11bd5d1..71c2254c91 100644
> --- a/drivers/net/mlx5/mlx5_mr.c
> +++ b/drivers/net/mlx5/mlx5_mr.c
> @@ -1397,10 +1397,10 @@ mlx5_dma_unmap(struct rte_pci_device *pdev, void *addr,
>         }
>         priv = dev->data->dev_private;
>         sh = priv->sh;
> -       rte_rwlock_read_lock(&sh->mr.rwlock);
> +       rte_rwlock_write_lock(&sh->mr.rwlock);
>         mr = mr_lookup_dev_list(sh, &entry, (uintptr_t)addr);
>         if (!mr) {
> -               rte_rwlock_read_unlock(&sh->mr.rwlock);
> +               rte_rwlock_write_unlock(&sh->mr.rwlock);
>                 DRV_LOG(WARNING, "address 0x%" PRIxPTR " wasn't registered "
>                                  "to PCI device %p", (uintptr_t)addr,
>                                  (void *)pdev);
> @@ -1424,7 +1424,7 @@ mlx5_dma_unmap(struct rte_pci_device *pdev, void *addr,
>         ++sh->mr.dev_gen;
>         DEBUG("broadcasting local cache flush, gen=%d", sh->mr.dev_gen);
>         rte_smp_wmb();
> -       rte_rwlock_read_unlock(&sh->mr.rwlock);
> +       rte_rwlock_write_unlock(&sh->mr.rwlock);
>         return 0;
>  }
>
> --
> 2.25.1
>


-- 
Christian Ehrhardt
Staff Engineer, Ubuntu Server
Canonical Ltd

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-08-11  8:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-11  8:31 [dpdk-stable] [PATCH 19.11] net/mlx5: fix incorrect r/w lock usage in DMA unmap Feifei Wang
2021-08-11  8:48 ` Christian Ehrhardt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).