From: Andre Przywara <andre.przywara@arm.com>
To: "David S. Miller" <davem@davemloft.net>
Cc: Joerg Roedel <joro@8bytes.org>,
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 [thread overview]
Message-ID: <1442567375-6963-1-git-send-email-andre.przywara@arm.com> (raw)
In-Reply-To: <55FBD36C.5070301@arm.com>
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 <andre.przywara@arm.com>
---
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
next prev parent reply other threads:[~2015-09-18 9:08 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-17 8:40 [PATCH] iommu-common: only compile lib/iommu_common.c for Sparc64 Andre Przywara
2015-09-17 18:38 ` David Miller
2015-09-18 9:03 ` Andre Przywara
2015-09-18 9:09 ` Andre Przywara [this message]
2015-10-21 19:12 ` [PATCH] iommu-common: fix return type of iommu_tbl_range_alloc() Geert Uytterhoeven
2015-10-21 19:56 ` Sowmini Varadhan
2015-09-18 17:09 ` [PATCH] iommu-common: only compile lib/iommu_common.c for Sparc64 David Miller
2015-09-18 17:28 ` Andre Przywara
2015-09-21 17:17 ` [PATCH] sparc(64)/iommu: fixup iommu_tbl_range_alloc() types Andre Przywara
2015-10-05 9:54 ` Andre Przywara
2015-11-04 16:38 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1442567375-6963-1-git-send-email-andre.przywara@arm.com \
--to=andre.przywara@arm.com \
--cc=davem@davemloft.net \
--cc=joro@8bytes.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sparclinux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®