From patchwork Tue Jan 14 15:45:20 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Cohen X-Patchwork-Id: 3486391 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 104A4C02DC for ; Tue, 14 Jan 2014 15:46:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EDAF02022A for ; Tue, 14 Jan 2014 15:46:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DBC9D2021B for ; Tue, 14 Jan 2014 15:46:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751660AbaANPqA (ORCPT ); Tue, 14 Jan 2014 10:46:00 -0500 Received: from mail-ee0-f53.google.com ([74.125.83.53]:56484 "EHLO mail-ee0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751550AbaANPqA (ORCPT ); Tue, 14 Jan 2014 10:46:00 -0500 Received: by mail-ee0-f53.google.com with SMTP id t10so302301eei.26 for ; Tue, 14 Jan 2014 07:45:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=mmJlFldfu1zssyrCS2tYWCUTOP475XI22NPMpgf23Hc=; b=ecX+GJyUbqgvwk6PZMP8PvnQNRXMDIuQdfIpCWr7ENIS69lsKaHuOEzEVl31yu/bW1 EWjihYp/mC0NK/y89tnA8j9AmV2KDa2lci4AzRMTy+yGvWfLRLdZaxZj/PMVMWsgWnCB C7nunAJe2uJsJaq+5zU/d0Kqn7ZdwgjEbhBwnfHCVrIrX3bMSB8BEsJvHxsuh8zj6Csg jNn35hSLi4hTCyaO83TmT1L9YeA/TE4j3uUp+2RU08VK6QVyiammPdLwAowRWI8wcTPq v3G8qWGu83qeBgbgFFdSZnYH1fzwfBwuLtvSc19uEIKh+0uyn4IOrUFgLLKxjWwxdSSO yNFg== X-Gm-Message-State: ALoCoQnisIIerc4Q0B7upOFKKcuperHj0KPMrgwCQlhgvB0D6p1ss+vG07g76YhRHZCeGnwcy6je X-Received: by 10.14.177.200 with SMTP id d48mr3204180eem.8.1389714359078; Tue, 14 Jan 2014 07:45:59 -0800 (PST) Received: from localhost (out.voltaire.com. [193.47.165.251]) by mx.google.com with ESMTPSA id v7sm2633813eel.2.2014.01.14.07.45.58 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 14 Jan 2014 07:45:58 -0800 (PST) From: Eli Cohen To: roland@kernel.org Cc: linux-rdma@vger.kernel.org, davem@davemloft.net, ogerlitz@mellanox.com, Eli Cohen Subject: [PATCH for-next 11/14] mlx5_core: Fix PowerPC support Date: Tue, 14 Jan 2014 17:45:20 +0200 Message-Id: <1389714323-20130-12-git-send-email-eli@mellanox.com> X-Mailer: git-send-email 1.8.5.2 In-Reply-To: <1389714323-20130-1-git-send-email-eli@mellanox.com> References: <1389714323-20130-1-git-send-email-eli@mellanox.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 1. Fix derivation of sub-page index from the dma address in free_4k. 2. Fix the DMA address passed to dma_unmap_page by masking it properly. Signed-off-by: Eli Cohen --- drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c | 9 +++++---- include/linux/mlx5/device.h | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c b/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c index c35c432..d59790a 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c @@ -99,7 +99,7 @@ enum { enum { MLX5_MAX_RECLAIM_TIME_MILI = 5000, - MLX5_NUM_4K_IN_PAGE = PAGE_SIZE / 4096, + MLX5_NUM_4K_IN_PAGE = PAGE_SIZE / MLX5_ADAPTER_PAGE_SIZE, }; static int insert_page(struct mlx5_core_dev *dev, u64 addr, struct page *page, u16 func_id) @@ -206,7 +206,7 @@ static int alloc_4k(struct mlx5_core_dev *dev, u64 *addr) if (!fp->free_count) list_del(&fp->list); - *addr = fp->addr + n * 4096; + *addr = fp->addr + n * MLX5_ADAPTER_PAGE_SIZE; return 0; } @@ -222,14 +222,15 @@ static void free_4k(struct mlx5_core_dev *dev, u64 addr) return; } - n = (addr & ~PAGE_MASK) % 4096; + n = (addr & ~PAGE_MASK) >> MLX5_ADAPTER_PAGE_SHIFT; fwp->free_count++; set_bit(n, &fwp->bitmask); if (fwp->free_count == MLX5_NUM_4K_IN_PAGE) { rb_erase(&fwp->rb_node, &dev->priv.page_root); if (fwp->free_count != 1) list_del(&fwp->list); - dma_unmap_page(&dev->pdev->dev, addr, PAGE_SIZE, DMA_BIDIRECTIONAL); + dma_unmap_page(&dev->pdev->dev, addr & PAGE_MASK, PAGE_SIZE, + DMA_BIDIRECTIONAL); __free_page(fwp->page); kfree(fwp); } else if (fwp->free_count == 1) { diff --git a/include/linux/mlx5/device.h b/include/linux/mlx5/device.h index 87e2371..1d05909 100644 --- a/include/linux/mlx5/device.h +++ b/include/linux/mlx5/device.h @@ -234,7 +234,8 @@ enum { }; enum { - MLX5_ADAPTER_PAGE_SHIFT = 12 + MLX5_ADAPTER_PAGE_SHIFT = 12, + MLX5_ADAPTER_PAGE_SIZE = 1 << MLX5_ADAPTER_PAGE_SHIFT, }; enum {