From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from e28smtp04.in.ibm.com (e28smtp04.in.ibm.com [122.248.162.4]) (using TLSv1 with cipher CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id B3C701A03D4 for ; Sat, 19 Sep 2015 23:04:39 +1000 (AEST) Received: from /spool/local by e28smtp04.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sat, 19 Sep 2015 18:34:36 +0530 Received: from d28relay03.in.ibm.com (d28relay03.in.ibm.com [9.184.220.60]) by d28dlp01.in.ibm.com (Postfix) with ESMTP id 3A616E0024 for ; Sat, 19 Sep 2015 18:34:07 +0530 (IST) Received: from d28av04.in.ibm.com (d28av04.in.ibm.com [9.184.220.66]) by d28relay03.in.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t8JD4VFv721210 for ; Sat, 19 Sep 2015 18:34:32 +0530 Received: from d28av04.in.ibm.com (localhost [127.0.0.1]) by d28av04.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t8JD4UvU014966 for ; Sat, 19 Sep 2015 18:34:31 +0530 From: Wei Yang To: benh@kernel.crashing.org, paulus@samba.org, mpe@ellerman.id.au Cc: linuxppc-dev@lists.ozlabs.org, Wei Yang Subject: [PATCH] powerpc/iommu: use iommu_num_pages() to calculate the number of iommu page Date: Sat, 19 Sep 2015 21:04:27 +0800 Message-Id: <1442667867-1802-1-git-send-email-weiyang@linux.vnet.ibm.com> List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , On PowerPC, currently we support different value of PAGE_SIZE and different value of IOMMU Page Size. In case the PAGE_SIZE is 4K and the IOMMU Page Size is 16M, and driver asked for some DMA less than 16M, the current calculation would return 0 and the following allocation in iommu_alloc() would fail. This patch uses iommu_num_pages() to calculate it. Signed-off-by: Wei Yang --- arch/powerpc/kernel/iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c index a8e3490..9885397 100644 --- a/arch/powerpc/kernel/iommu.c +++ b/arch/powerpc/kernel/iommu.c @@ -842,7 +842,7 @@ void *iommu_alloc_coherent(struct device *dev, struct iommu_table *tbl, memset(ret, 0, size); /* Set up tces to cover the allocated range */ - nio_pages = size >> tbl->it_page_shift; + nio_pages = iommu_num_pages(0, size, IOMMU_PAGE_SIZE(tbl)); io_order = get_iommu_order(size, tbl); mapping = iommu_alloc(dev, tbl, ret, nio_pages, DMA_BIDIRECTIONAL, mask >> tbl->it_page_shift, io_order, NULL); -- 2.5.0