From patchwork Thu Feb 26 18:59:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timur Tabi X-Patchwork-Id: 5895601 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 85E42BF440 for ; Thu, 26 Feb 2015 19:00:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AAF32203AA for ; Thu, 26 Feb 2015 19:00:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CC75B2039C for ; Thu, 26 Feb 2015 18:59:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754545AbbBZS7t (ORCPT ); Thu, 26 Feb 2015 13:59:49 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:53905 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753933AbbBZS7q (ORCPT ); Thu, 26 Feb 2015 13:59:46 -0500 Received: from smtp.codeaurora.org (localhost [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id 2CAC514177D; Thu, 26 Feb 2015 18:59:46 +0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 486) id 1B6D6141782; Thu, 26 Feb 2015 18:59:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from timur-ubuntu.qualcomm.com (rrcs-67-52-129-61.west.biz.rr.com [67.52.129.61]) (using TLSv1.1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: timur@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 3AA9114177D; Thu, 26 Feb 2015 18:59:45 +0000 (UTC) From: timur@codeaurora.org To: Roland Dreier , linux-rdma@vger.kernel.org, Eli Cohen Cc: Sinan Kaya Subject: [PATCH] net: ethernet: mellanox: correct page conversion Date: Thu, 26 Feb 2015 12:59:28 -0600 Message-Id: <1424977168-19523-1-git-send-email-timur@codeaurora.org> X-Mailer: git-send-email 1.8.2.1 X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Sinan Kaya 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 --- 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)