ethernet: cxgb4: Fix dma_unmap_sg() nents value
Subsystems (3)
PATCH 1/1 ethernet: cxgb4: Fix dma_unmap_sg() nents value
The dma_unmap_sg() functions should be called with the same nents as the dma_map_sg(), not the value the map function returned.
--- drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +1 -1
@@ -3998,7 +3998,7 @@ static void adap_free_hma_mem(struct adapter *adapter)if (adapter->hma.flags &HMA_DMA_MAPPED_FLAG ) {dma_unmap_sg (adapter->pdev_dev, adapter->hma.sgt->sgl, - adapter->hma.sgt->nents,DMA_BIDIRECTIONAL ); + adapter->hma.sgt->orig_nents,DMA_BIDIRECTIONAL ); adapter->hma.flags &= ~HMA_DMA_MAPPED_FLAG ; }
Signature · 1 line
2.43.0
Potnuri Bharat Teja
maintainerQuoted 14 lines · Thomas Fourier
The
dma_unmap_sg()functions should be called with the same nents as thedma_map_sg(), not the value the map function returned.Fixes 8b4e6b3ca2ed ("cxgb4: Add HMA support")Signed-off-by Thomas Fourier <[email protected]>--- drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +0
-0
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c static void adap_free_hma_mem(struct adapter *adapter) · line 4003
Quoted 7 lines
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +1
-1@@ -3998,7 +3998,7 @@ static void adap_free_hma_mem(struct adapter *adapter)if (adapter->hma.flags &HMA_DMA_MAPPED_FLAG ) {dma_unmap_sg (adapter->pdev_dev, adapter->hma.sgt->sgl, - adapter->hma.sgt->nents,DMA_BIDIRECTIONAL ); + adapter->hma.sgt->orig_nents,DMA_BIDIRECTIONAL ); adapter->hma.flags &= ~HMA_DMA_MAPPED_FLAG ; }
Thanks for the patch Thomas.
this fix needs below change as well:
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +0 -0
@@ -4000,7 +4000,7 @@ static void adap_free_hma_mem(struct adapter *adapter) }
for_each_sg(adapter->hma.sgt->sgl, iter,
- adapter->hma.sgt->orig_nents, i) {
+ adapter->hma.sgt->nents, i) {
page = sg_page(iter);
if (page)
__free_pages(page, HMA_PAGE_ORDER); Quoted 3 lines
Signature · 1 line
2.43.0
Quoted 28 lines · Potnuri Bharat Teja
Quoted 14 lines · Thomas Fourier
The
dma_unmap_sg()functions should be called with the same nents as thedma_map_sg(), not the value the map function returned.Fixes 8b4e6b3ca2ed ("cxgb4: Add HMA support")Signed-off-by Thomas Fourier <[email protected]>--- drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +0
-0drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c static void adap_free_hma_mem(struct adapter *adapter) · line 4003
Quoted 7 lines
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +1
-1@@ -3998,7 +3998,7 @@ static void adap_free_hma_mem(struct adapter *adapter)if (adapter->hma.flags &HMA_DMA_MAPPED_FLAG ) {dma_unmap_sg (adapter->pdev_dev, adapter->hma.sgt->sgl, - adapter->hma.sgt->nents,DMA_BIDIRECTIONAL ); + adapter->hma.sgt->orig_nents,DMA_BIDIRECTIONAL ); adapter->hma.flags &= ~HMA_DMA_MAPPED_FLAG ; }Thanks for the patch Thomas.
this fix needs below change as well:
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c static void adap_free_hma_mem(struct adapter *adapter) · line 4006
Quoted 8 lines
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +1
-1@@ -4000,7 +4000,7 @@ static void adap_free_hma_mem(struct adapter *adapter) }for_each_sg (adapter->hma.sgt->sgl, iter, - adapter->hma.sgt->orig_nents, i) { + adapter->hma.sgt->nents, i) { page =sg_page (iter);if (page)__free_pages (page,HMA_PAGE_ORDER );
I don't think this change is correct since this loop iterates over all the pages
allocated at line 4076, not over the dma mapped pages.
It also seems that when passing the dma addresses to hardware,
the newpage assignment is not used line 4104 and that the dma mapping
length is not given to hardware. Is that correct?
Quoted 3 lines
Quoted 3 lines
Signature · 1 line
2.43.0
Quoted 40 lines · Thomas Fourier
Quoted 35 lines · Potnuri Bharat Teja
Quoted 14 lines · Thomas Fourier
The
dma_unmap_sg()functions should be called with the same nents as thedma_map_sg(), not the value the map function returned.Fixes 8b4e6b3ca2ed ("cxgb4: Add HMA support")Signed-off-by Thomas Fourier <[email protected]>---
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +0
-0drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c static void adap_free_hma_mem(struct adapter · line 4003
Quoted 7 lines
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +1
-1@@ -3998,7 +3998,7 @@ static void adap_free_hma_mem(struct adapter *adapter) if (adapter->hma.flags & HMA_DMA_MAPPED_FLAG) { dma_unmap_sg(adapter->pdev_dev, adapter->hma.sgt->sgl, - adapter->hma.sgt->nents, DMA_BIDIRECTIONAL); + adapter->hma.sgt->orig_nents, DMA_BIDIRECTIONAL); adapter->hma.flags &= ~HMA_DMA_MAPPED_FLAG; }Thanks for the patch Thomas.
this fix needs below change as well:drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +1
-1@@ -4000,7 +4000,7 @@ static void adap_free_hma_mem(struct adapter *adapter) } for_each_sg(adapter->hma.sgt->sgl, iter, - adapter->hma.sgt->orig_nents, i) { + adapter->hma.sgt->nents, i) { page = sg_page(iter); if (page)Quoted 1 line
__free_pages(page, HMA_PAGE_ORDER);I don't think this change is correct since this loop iterates over all the pages
Quoted 11 lines
allocated at line 4076, not over the dma mapped pages.
It also seems that when passing the dma addresses to hardware,
the newpage assignment is not used line 4104 and that the dma mapping
length is not given to hardware. Is that correct?
Quoted 3 lines
Quoted 3 lines
Signature · 1 line
2.43.0
Hello Potnuri,
Any update on this patch?
Thanks for your time,
Thomas