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] sparc(64)/iommu: fixup iommu_tbl_range_alloc() types
Date: Mon, 21 Sep 2015 18:17:09 +0100 [thread overview]
Message-ID: <1442855829-11245-1-git-send-email-andre.przywara@arm.com> (raw)
In-Reply-To: <55FC49B8.3020100@arm.com>
With DMA_ERROR_CODE now being dma_addr_t in most architectures, it
turned out that iommu_tbl_range_alloc (defined in lib/iommu-common.c)
is actually using a wrong return type.
This was easily fixed in a previous patch, but now the types in the
callers do not match anymore.
This patch fixes the obvious mismatches to allow sane comparisons with
the error return value.
Compile-tested on sparc, sparc64, x86, ARM, arm64.
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
---
Hi David,
as promised my first naive try on fixing the callers of
iommu_tbl_range_alloc() as well. This goes on top of the return type
fix I sent on Friday.
Please let me know if that makes sense or whether I am looking in the
totally wrong direction.
Cheers,
Andre.
arch/sparc/kernel/iommu.c | 5 +++--
arch/sparc/kernel/ldc.c | 5 +++--
arch/sparc/kernel/pci_sun4v.c | 7 ++++---
3 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/arch/sparc/kernel/iommu.c b/arch/sparc/kernel/iommu.c
index 5320689..7d04a87 100644
--- a/arch/sparc/kernel/iommu.c
+++ b/arch/sparc/kernel/iommu.c
@@ -157,7 +157,7 @@ static inline iopte_t *alloc_npages(struct device *dev,
struct iommu *iommu,
unsigned long npages)
{
- unsigned long entry;
+ dma_addr_t entry;
entry = iommu_tbl_range_alloc(dev, &iommu->tbl, npages, NULL,
(unsigned long)(-1), 0);
@@ -476,7 +476,8 @@ static int dma_4u_map_sg(struct device *dev, struct scatterlist *sglist,
IO_PAGE_SIZE) >> IO_PAGE_SHIFT;
base_shift = iommu->tbl.table_map_base >> IO_PAGE_SHIFT;
for_each_sg(sglist, s, nelems, i) {
- unsigned long paddr, npages, entry, out_entry = 0, slen;
+ unsigned long paddr, npages, slen;
+ dma_addr_t entry, out_entry = 0;
iopte_t *base;
slen = s->length;
diff --git a/arch/sparc/kernel/ldc.c b/arch/sparc/kernel/ldc.c
index 1ae5eb1..41e79cb 100644
--- a/arch/sparc/kernel/ldc.c
+++ b/arch/sparc/kernel/ldc.c
@@ -10,6 +10,7 @@
#include <linux/delay.h>
#include <linux/errno.h>
#include <linux/string.h>
+#include <linux/dma-mapping.h>
#include <linux/scatterlist.h>
#include <linux/interrupt.h>
#include <linux/list.h>
@@ -1949,11 +1950,11 @@ static u64 make_cookie(u64 index, u64 pgsz_code, u64 page_offset)
static struct ldc_mtable_entry *alloc_npages(struct ldc_iommu *iommu,
unsigned long npages)
{
- long entry;
+ dma_addr_t entry;
entry = iommu_tbl_range_alloc(NULL, &iommu->iommu_map_table,
npages, NULL, (unsigned long)-1, 0);
- if (unlikely(entry < 0))
+ if (unlikely(entry == DMA_ERROR_CODE))
return NULL;
return iommu->page_table + entry;
diff --git a/arch/sparc/kernel/pci_sun4v.c b/arch/sparc/kernel/pci_sun4v.c
index d2fe57d..f86902f 100644
--- a/arch/sparc/kernel/pci_sun4v.c
+++ b/arch/sparc/kernel/pci_sun4v.c
@@ -136,7 +136,7 @@ static void *dma_4v_alloc_coherent(struct device *dev, size_t size,
struct iommu *iommu;
struct page *page;
void *ret;
- long entry;
+ dma_addr_t entry;
int nid;
size = IO_PAGE_ALIGN(size);
@@ -242,7 +242,7 @@ static dma_addr_t dma_4v_map_page(struct device *dev, struct page *page,
unsigned long i, base_paddr;
u32 bus_addr, ret;
unsigned long prot;
- long entry;
+ dma_addr_t entry;
iommu = dev->archdata.iommu;
@@ -361,7 +361,8 @@ static int dma_4v_map_sg(struct device *dev, struct scatterlist *sglist,
IO_PAGE_SIZE) >> IO_PAGE_SHIFT;
base_shift = iommu->tbl.table_map_base >> IO_PAGE_SHIFT;
for_each_sg(sglist, s, nelems, i) {
- unsigned long paddr, npages, entry, out_entry = 0, slen;
+ unsigned long paddr, npages, slen;
+ dma_addr_t entry, out_entry = 0;
slen = s->length;
/* Sanity check */
--
2.5.1
next prev parent reply other threads:[~2015-09-21 17:16 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 ` [PATCH] iommu-common: fix return type of iommu_tbl_range_alloc() Andre Przywara
2015-10-21 19:12 ` 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 ` Andre Przywara [this message]
2015-10-05 9:54 ` [PATCH] sparc(64)/iommu: fixup iommu_tbl_range_alloc() types 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=1442855829-11245-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®