From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753005AbbIRJI1 (ORCPT ); Fri, 18 Sep 2015 05:08:27 -0400 Received: from foss.arm.com ([217.140.101.70]:45273 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752035AbbIRJIZ (ORCPT ); Fri, 18 Sep 2015 05:08:25 -0400 From: Andre Przywara To: "David S. Miller" Cc: Joerg Roedel , sparclinux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH] iommu-common: fix return type of iommu_tbl_range_alloc() Date: Fri, 18 Sep 2015 10:09:35 +0100 Message-Id: <1442567375-6963-1-git-send-email-andre.przywara@arm.com> X-Mailer: git-send-email 2.5.1 In-Reply-To: <55FBD36C.5070301@arm.com> References: <55FBD36C.5070301@arm.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Though iommu_tbl_range_alloc() is only used by Sparc code, the function itself lives in lib/iommu-common.c and is thus included in other architecture's code as well. When compiled on a 32-bit architecture using 64-bit DMA addresses (ARM with LPAE), there is a compiler warning about a type mismatch between dma_addr_t and the return type of this function: In file included from /src/linux/include/linux/dma-mapping.h:86:0, from /src/linux/lib/iommu-common.c:11: /src/linux/lib/iommu-common.c: In function 'iommu_tbl_range_alloc': /src/linux/arch/arm/include/asm/dma-mapping.h:16:24: warning: large integer implicitly truncated to unsigned type [-Woverflow] #define DMA_ERROR_CODE (~(dma_addr_t)0x0) ^ /src/linux/lib/iommu-common.c:127:10: note: in expansion of macro 'DMA_ERROR_CODE' return DMA_ERROR_CODE; If I am not mistaken, dma_addr_t on both Sparc variants is always 32-bit, so we don't need necessarily to adjust the callers, just the function itself. This still isn't right (since now the types in the caller mismatch, though in a different way the compiler does not complain about), but works as a fix for the 4.3 release. I couldn't spot any warnings on the architectures I managed to compile. Compile tested on Sparc, Sparc64, PowerPC64, ARM, ARM64, x86. Signed-off-by: Andre Przywara --- include/linux/iommu-common.h | 12 ++++++------ lib/iommu-common.c | 15 ++++++++------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/include/linux/iommu-common.h b/include/linux/iommu-common.h index bbced83..fdff585 100644 --- a/include/linux/iommu-common.h +++ b/include/linux/iommu-common.h @@ -37,12 +37,12 @@ extern void iommu_tbl_pool_init(struct iommu_map_table *iommu, bool large_pool, u32 npools, bool skip_span_boundary_check); -extern unsigned long iommu_tbl_range_alloc(struct device *dev, - struct iommu_map_table *iommu, - unsigned long npages, - unsigned long *handle, - unsigned long mask, - unsigned int align_order); +extern dma_addr_t iommu_tbl_range_alloc(struct device *dev, + struct iommu_map_table *iommu, + unsigned long npages, + unsigned long *handle, + unsigned long mask, + unsigned int align_order); extern void iommu_tbl_range_free(struct iommu_map_table *iommu, u64 dma_addr, unsigned long npages, diff --git a/lib/iommu-common.c b/lib/iommu-common.c index ff19f66..6f0324e 100644 --- a/lib/iommu-common.c +++ b/lib/iommu-common.c @@ -99,15 +99,16 @@ void iommu_tbl_pool_init(struct iommu_map_table *iommu, } EXPORT_SYMBOL(iommu_tbl_pool_init); -unsigned long iommu_tbl_range_alloc(struct device *dev, - struct iommu_map_table *iommu, - unsigned long npages, - unsigned long *handle, - unsigned long mask, - unsigned int align_order) +dma_addr_t iommu_tbl_range_alloc(struct device *dev, + struct iommu_map_table *iommu, + unsigned long npages, + unsigned long *handle, + unsigned long mask, + unsigned int align_order) { unsigned int pool_hash = __this_cpu_read(iommu_hash_common); - unsigned long n, end, start, limit, boundary_size; + dma_addr_t n; + unsigned long end, start, limit, boundary_size; struct iommu_pool *pool; int pass = 0; unsigned int pool_nr; -- 2.5.1