On Thu, Feb 26, 2015 at 8:59 PM,  <[email protected]> wrote:
> From: Sinan Kaya <[email protected]>
>
> 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 <[email protected]>
> ---
>  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.
>

This will not compile on non ARM arch. For example x86:

drivers/net/ethernet/mellanox/mlx4/alloc.c: In function ‘mlx4_buf_alloc’:
drivers/net/ethernet/mellanox/mlx4/alloc.c:642:5: error: implicit
declaration of function ‘phys_to_page’
[-Werror=implicit-function-declaration]
     pages[i] = phys_to_page(phys);

Amir
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to