From patchwork Sun Mar 24 08:55:05 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 230404 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 914372C00C0 for ; Sun, 24 Mar 2013 19:55:37 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753153Ab3CXIzg (ORCPT ); Sun, 24 Mar 2013 04:55:36 -0400 Received: from mail-pb0-f50.google.com ([209.85.160.50]:49309 "EHLO mail-pb0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753139Ab3CXIzf (ORCPT ); Sun, 24 Mar 2013 04:55:35 -0400 Received: by mail-pb0-f50.google.com with SMTP id up1so3671816pbc.9 for ; Sun, 24 Mar 2013 01:55:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=5sQCfoD/ki+t9VAKVlnOcHHkevXutJ5ZD4cVjmrBOsY=; b=iPHa1qyhrjiLRwGGnFcaGzR9RdpcF4+X8R98ceMURDQFuj0yuVQIchAoxTYtOZ0Kqu go5DjIoOSnAGuBbK3e1UI6EonPnsknkwPKkxVYimNR8r4KKySTsaKjPsJ408+Z8iAhm9 nMBChKJMrxSXayjsDwYdf0s0oURZJwB6pPvMkjR3kD2kNTtRpDKc1EVLlToHDmLz3oHC BKWHCkyyqk75Kg5m0JQ3Hu02HT06FID03GSr2++es/yPUyVuqLJRPTSNAw1hXdvblgaW bDMlsOTIY0XOiBKYeWNFaSnYJPtfl3aokixeDAYT2s6fdVVHKeSJVWbDdf5Nnan9Ca6X CjEw== X-Received: by 10.66.252.162 with SMTP id zt2mr12294481pac.1.1364115335030; Sun, 24 Mar 2013 01:55:35 -0700 (PDT) Received: from localhost.localdomain (p2126-ipbf3106hodogaya.kanagawa.ocn.ne.jp. [114.149.157.126]) by mx.google.com with ESMTPS id y1sm9009092pbg.10.2013.03.24.01.55.33 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 24 Mar 2013 01:55:34 -0700 (PDT) From: Akinobu Mita To: sparclinux@vger.kernel.org Cc: Akinobu Mita , "David S. Miller" Subject: [PATCH 2/3] sparc/iommu: use BITS_TO_LONGS() to calculate bitmap size Date: Sun, 24 Mar 2013 17:55:05 +0900 Message-Id: <1364115306-17716-2-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1364115306-17716-1-git-send-email-akinobu.mita@gmail.com> References: <1364115306-17716-1-git-send-email-akinobu.mita@gmail.com> Sender: sparclinux-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: sparclinux@vger.kernel.org The size of bitmaps which is accessed by bitops must be a multiple of the sizeof(long). So it would be better to use BITS_TO_LONGS() to calculate the bitmap size although IOMMU_NPTES is a multiple of BITS_PER_LONG. This also fixes typo in the comment for IOMMU_NPTES. Signed-off-by: Akinobu Mita Cc: "David S. Miller" Cc: sparclinux@vger.kernel.org --- arch/sparc/mm/iommu.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/sparc/mm/iommu.c b/arch/sparc/mm/iommu.c index 0f4f719..f9027fd 100644 --- a/arch/sparc/mm/iommu.c +++ b/arch/sparc/mm/iommu.c @@ -34,7 +34,7 @@ #define IOMMU_RNGE IOMMU_RNGE_256MB #define IOMMU_START 0xF0000000 #define IOMMU_WINSIZE (256*1024*1024U) -#define IOMMU_NPTES (IOMMU_WINSIZE/PAGE_SIZE) /* 64K PTEs, 265KB */ +#define IOMMU_NPTES (IOMMU_WINSIZE/PAGE_SIZE) /* 64K PTEs, 256KB */ #define IOMMU_ORDER 6 /* 4096 * (1<<6) */ /* srmmu.c */ @@ -103,10 +103,11 @@ static void __init sbus_iommu_init(struct platform_device *op) iommu->regs->base = __pa((unsigned long) iommu->page_table) >> 4; iommu_invalidate(iommu->regs); - bitmap = kmalloc(IOMMU_NPTES>>3, GFP_KERNEL); + bitmap = kmalloc(BITS_TO_LONGS(IOMMU_NPTES) * sizeof(unsigned long), + GFP_KERNEL); if (!bitmap) { - prom_printf("Unable to allocate iommu bitmap [%d]\n", - (int)(IOMMU_NPTES>>3)); + prom_printf("Unable to allocate iommu bitmap [%ld]\n", + BITS_TO_LONGS(IOMMU_NPTES) * sizeof(unsigned long)); prom_halt(); } bit_map_init(&iommu->usemap, bitmap, IOMMU_NPTES);