[prev in list] [next in list] [prev in thread] [next in thread]
List: linux-rdma
Subject: [PATCH] net: ethernet: mellanox: correct page conversion
From: timur () codeaurora ! org
Date: 2015-02-26 18:59:28
Message-ID: 1424977168-19523-1-git-send-email-timur () codeaurora ! org
[Download RAW message or body]
From: Sinan Kaya <okaya@codeaurora.org>
Current code is assuming that the addresses returned
by dma_alloc_coherent is a logical address. This is
not true on ARM/ARM64 systems. This patch uses
dma_to_phys API to reach to the actual physical address
and then convert to the page pointer.
Signed-off-by: Sinan Kaya <okaya@codeaurora.org>
---
drivers/net/ethernet/mellanox/mlx4/alloc.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx4/alloc.c b/drivers/net/ethernet/mellanox/mlx4/alloc.c
index 963dd7e..8eca66a 100644
--- a/drivers/net/ethernet/mellanox/mlx4/alloc.c
+++ b/drivers/net/ethernet/mellanox/mlx4/alloc.c
@@ -634,8 +634,13 @@ int mlx4_buf_alloc(struct mlx4_dev *dev, int size, int max_direct,
pages = kmalloc(sizeof *pages * buf->nbufs, gfp);
if (!pages)
goto err_free;
- for (i = 0; i < buf->nbufs; ++i)
- pages[i] = virt_to_page(buf->page_list[i].buf);
+ for (i = 0; i < buf->nbufs; ++i) {
+ phys_addr_t phys;
+
+ phys = dma_to_phys(&dev->pdev->dev,
+ buf->page_list[i].map);
+ pages[i] = phys_to_page(phys);
+ }
buf->direct.buf = vmap(pages, buf->nbufs, VM_MAP, PAGE_KERNEL);
kfree(pages);
if (!buf->direct.buf)
--
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic