Skip to content

Commit 433efe7

Browse files
Sanjay R Mehtajonmason
authored andcommitted
ntb_tool: pass correct struct device to dma_alloc_coherent
Currently, ntb->dev is passed to dma_alloc_coherent and dma_free_coherent calls. The returned dma_addr_t is the CPU physical address. This works fine as long as IOMMU is disabled. But when IOMMU is enabled, we need to make sure that IOVA is returned for dma_addr_t. So the correct way to achieve this is by changing the first parameter of dma_alloc_coherent() as ntb->pdev->dev instead. Fixes: 5648e56 ("NTB: ntb_perf: Add full multi-port NTB API support") Signed-off-by: Sanjay R Mehta <sanju.mehta@amd.com> Signed-off-by: Arindam Nath <arindam.nath@amd.com> Signed-off-by: Jon Mason <jdmason@kudzu.us>
1 parent 98f4e14 commit 433efe7

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎drivers/ntb/test/ntb_tool.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ static int tool_setup_mw(struct tool_ctx *tc, int pidx, int widx,
590590
inmw->size = min_t(resource_size_t, req_size, size);
591591
inmw->size = round_up(inmw->size, addr_align);
592592
inmw->size = round_up(inmw->size, size_align);
593-
inmw->mm_base = dma_alloc_coherent(&tc->ntb->dev, inmw->size,
593+
inmw->mm_base = dma_alloc_coherent(&tc->ntb->pdev->dev, inmw->size,
594594
&inmw->dma_base, GFP_KERNEL);
595595
if (!inmw->mm_base)
596596
return -ENOMEM;
@@ -612,7 +612,7 @@ static int tool_setup_mw(struct tool_ctx *tc, int pidx, int widx,
612612
return 0;
613613

614614
err_free_dma:
615-
dma_free_coherent(&tc->ntb->dev, inmw->size, inmw->mm_base,
615+
dma_free_coherent(&tc->ntb->pdev->dev, inmw->size, inmw->mm_base,
616616
inmw->dma_base);
617617
inmw->mm_base = NULL;
618618
inmw->dma_base = 0;
@@ -629,7 +629,7 @@ static void tool_free_mw(struct tool_ctx *tc, int pidx, int widx)
629629

630630
if (inmw->mm_base != NULL) {
631631
ntb_mw_clear_trans(tc->ntb, pidx, widx);
632-
dma_free_coherent(&tc->ntb->dev, inmw->size,
632+
dma_free_coherent(&tc->ntb->pdev->dev, inmw->size,
633633
inmw->mm_base, inmw->dma_base);
634634
}
635635

0 commit comments

Comments
 (0)