net/mlx5: fix incorrect r/w lock usage in DMA unmap
PATCH 1/1 net/mlx5: fix incorrect r/w lock usage in DMA unmap
For mlx5 DMA unmap, write lock should be used for rebuilding memory region cache table rather than read lock.
--- drivers/net/mlx5/mlx5_mr.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/mlx5/mlx5_mr.c +3 -3
@@ -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 ; }
Signature · 1 line
2.25.1
Hi, Slava
Would you please help review this patch?
Thanks.
Best Regards
Feifei
Quoted 55 lines
-----邮件原件-----
发件人: Feifei Wang <[email protected]>
发送时间: 2021年5月27日 17:48
收件人: Matan Azrad <[email protected]>; Shahaf Shuler <[email protected]>; Viacheslav Ovsiienko <[email protected]> 抄送: [email protected]; nd <[email protected]>; Feifei Wang <[email protected]>; [email protected]; [email protected]; Ruifeng Wang <[email protected]>
主题: [PATCH] net/mlx5: fix incorrect r/w lock usage in DMA unmapFor 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")Signed-off-by Feifei Wang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>--- drivers/net/mlx5/mlx5_mr.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/net/mlx5/mlx5_mr.c index renamed from drivers/net/mlx5/mlx5_mr.c +0
-0
e791b6338d..45a122f4f9100644drivers/net/mlx5/mlx5_mr.c +2
-2@@ -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'tregistered "
drivers/net/mlx5/mlx5_mr.c +1
-2"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
Slava Ovsiienko
Acked-byHi, Feifei
Sorry for the delayed review.
I think it is a good catch, thank you for the patch.
With best regards,
Slava
Quoted 77 lines
-----Original Message-----
From: Feifei Wang <[email protected]>
Sent: Tuesday, June 22, 2021 4:54
To: Feifei Wang <[email protected]>; Matan Azrad <[email protected]>; Shahaf Shuler <[email protected]>; Slava Ovsiienko <[email protected]>
Cc: [email protected]; nd <[email protected]>; Shahaf Shuler <[email protected]>; [email protected]; Ruifeng Wang <[email protected]>; nd <[email protected]>
Subject: 回复: [PATCH] net/mlx5: fix incorrect r/w lock usage in DMA unmapHi, Slava
Would you please help review this patch?
Thanks.Best Regards
FeifeiQuoted 6 lines
-----邮件原件-----
发件人: Feifei Wang <[email protected]>
发送时间: 2021年5月27日 17:48
收件人: Matan Azrad <[email protected]>; Shahaf Shuler <[email protected]>; Viacheslav Ovsiienko <[email protected]> 抄送: [email protected]; nd <[email protected]>; Feifei Wangdrivers/net/mlx5/mlx5_mr.c mlx5_dma_unmap(struct rte_pci_device *pdev,
Quoted 23 lines
[email protected]; [email protected]; Ruifeng Wang <[email protected]>
主题: [PATCH] net/mlx5: fix incorrect r/w lock usage in DMA unmapFor 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")Signed-off-by Feifei Wang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>--- drivers/net/mlx5/mlx5_mr.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/net/mlx5/mlx5_mr.c +0
-0index
e791b6338d..45a122f4f9100644drivers/net/mlx5/mlx5_mr.c +0
-0@@ -395,10 +395,10 @@ mlx5_dma_unmap(struct rte_pci_device *pdev,void
drivers/net/mlx5/mlx5_mr.c mlx5_dma_unmap(struct rte_pci_device *pdev, void *addr,
Quoted 7 lines
drivers/net/mlx5/mlx5_mr.c +1
-1*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);
drivers/net/mlx5/mlx5_mr.c mlx5_dma_unmap(struct rte_pci_device *pdev, void *addr,
Quoted 4 lines
drivers/net/mlx5/mlx5_mr.c +1
-1if (!mr) { - rte_rwlock_read_unlock(&sh->share_cache.rwlock); + rte_rwlock_write_unlock(&sh->share_cache.rwlock); DRV_LOG(WARNING, "address 0x%" PRIxPTR " wasn'tregistered "
Quoted 14 lines
drivers/net/mlx5/mlx5_mr.c +0
-0"to PCI device %p", (uintptr_t)addr,drivers/net/mlx5/mlx5_mr.c +1
-2(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
Hi, Slava
That's OK. Thanks for your reviewing.
Best Regards
Feifei
Quoted 101 lines
-----邮件原件-----
发件人: Slava Ovsiienko <[email protected]>
发送时间: 2021年7月1日 22:27
收件人: Feifei Wang <[email protected]>; Matan Azrad <[email protected]>; Shahaf Shuler <[email protected]> 抄送: [email protected]; nd <[email protected]>; Shahaf Shuler <[email protected]>; [email protected]; Ruifeng Wang <[email protected]>; nd <[email protected]>
主题: RE: [PATCH] net/mlx5: fix incorrect r/w lock usage in DMA unmapHi, Feifei
Sorry for the delayed review.
I think it is a good catch, thank you for the patch.With best regards,
SlavaQuoted 7 lines
-----Original Message-----
From: Feifei Wang <[email protected]>
Sent: Tuesday, June 22, 2021 4:54
To: Feifei Wang <[email protected]>; Matan Azrad <[email protected]>; Shahaf Shuler <[email protected]>; Slava Ovsiienko <[email protected]>
Cc: [email protected]; nd <[email protected]>; Shahaf ShulerQuoted 1 line
[email protected]; Ruifeng Wang <[email protected]>; nd
Quoted 51 lines
Subject: 回复: [PATCH] net/mlx5: fix incorrect r/w lock usage in DMA unmap
Hi, Slava
Would you please help review this patch?
Thanks.Best Regards
FeifeiQuoted 6 lines
-----邮件原件-----
发件人: Feifei Wang <[email protected]>
发送时间: 2021年5月27日 17:48
收件人: Matan Azrad <[email protected]>; Shahaf Shuler <[email protected]>; Viacheslav Ovsiienko <[email protected]> 抄送: [email protected]; nd <[email protected]>; Feifei Wangdrivers/net/mlx5/mlx5_mr.c mlx5_dma_unmap(struct rte_pci_device *pdev,
Quoted 24 lines
[email protected]; [email protected]; Ruifeng Wang <[email protected]>
主题: [PATCH] net/mlx5: fix incorrect r/w lock usage in DMA unmapFor 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 andunmap")
Cc: [email protected]
Cc: [email protected]Signed-off-by Feifei Wang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>--- drivers/net/mlx5/mlx5_mr.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/net/mlx5/mlx5_mr.c +0
-0index
e791b6338d..45a122f4f9100644drivers/net/mlx5/mlx5_mr.c +0
-0@@ -395,10 +395,10 @@ mlx5_dma_unmap(struct rte_pci_device *pdev,void
drivers/net/mlx5/mlx5_mr.c mlx5_dma_unmap(struct rte_pci_device *pdev, void *addr,
Quoted 7 lines
drivers/net/mlx5/mlx5_mr.c +1
-1*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);
Quoted 8 lines
drivers/net/mlx5/mlx5_mr.c mlx5_dma_unmap(struct rte_pci_device *pdev, void *addr,
Quoted 4 lines
drivers/net/mlx5/mlx5_mr.c +1
-1if (!mr) { - rte_rwlock_read_unlock(&sh->share_cache.rwlock); + rte_rwlock_write_unlock(&sh->share_cache.rwlock); DRV_LOG(WARNING, "address 0x%" PRIxPTR " wasn'tregistered "
drivers/net/mlx5/mlx5_mr.c mlx5_dma_unmap(struct rte_pci_device *pdev,
Quoted 3 lines
drivers/net/mlx5/mlx5_mr.c +0
-0"to PCI device %p", (uintptr_t)addr,drivers/net/mlx5/mlx5_mr.c +0
-0(void *)pdev);@@ -423,7 +423,7 @@ mlx5_dma_unmap(struct rte_pci_device *pdev,void
Quoted 11 lines
Quoted 11 lines
drivers/net/mlx5/mlx5_mr.c +1
-2*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
Hi,
Quoted 14 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Feifei Wang
Sent: Thursday, May 27, 2021 12:48 PM
To: Matan Azrad <[email protected]>; Shahaf Shuler <[email protected]>; Slava Ovsiienko <[email protected]>
Cc: [email protected]; [email protected]; Feifei Wang <[email protected]>; Shahaf Shuler <[email protected]>; [email protected]; Ruifeng Wang <[email protected]>
Subject: [dpdk-dev] [PATCH] net/mlx5: fix incorrect r/w lock usage in DMA unmapFor mlx5 DMA unmap, write lock should be used for rebuilding memory region cache table rather than read lock.
Quoted 6 lines
Fixes 989e999d9305 ("net/mlx5: support PCI device DMA map and unmap")Signed-off-by Feifei Wang <[email protected]>Reviewed-by Ruifeng Wang <[email protected]>
Patch rebased and applied to next-net-mlx,
Kindest regards,
Raslan Darawsheh