Re: [PATCH] add iommu_num_pages helper function

From: FUJITA Tomonori
Date: Tue Jul 29 2008 - 00:40:13 EST


On Tue, 29 Jul 2008 13:56:52 +1000
Stephen Rothwell <sfr@xxxxxxxxxxxxxxxx> wrote:

> Hi,
>
> On Tue, 29 Jul 2008 10:46:31 +0900 FUJITA Tomonori <fujita.tomonori@xxxxxxxxxxxxx> wrote:
> >
> > > So, I assume a patch created on July 25 is not destined for 2.6.27,
> >
> > Hmm, seems that they will go into 2.6.27:
> >
> > http://marc.info/?l=linux-kernel&m=121729275722287&w=2
> >
> >
> > > right? Especially since it breaks another architecture build and has
> > > only made it to linux-next on July 29 ... and needs more work given the
> > > comments already on this patch.
> >
> > It doesn't break another architecture build since only x86 IOMMUs use
> > the helper function. But as I pointed out, it doesn't work for some
> > architectures.
>
> Um, did you see the linux-next build report I posted (possibly not):
>
> arch/powerpc/kernel/iommu.c:56: error: static declaration of 'iommu_num_pages' follows non-static declaration
> include/linux/iommu-helper.h:11: error: previous declaration of 'iommu_num_pages' was here
>
> This is now a build of 2.6.27-rc1 for powerpc64 ppc64_defconfig ...

Ah, really sorry. Yeah, it breaks POWER and SPARC builds.


> So we have a patch first posted to lkml on July 25 first hits linux-next
> on July 29 and is no in Linus' tree on July 29. A grep would have found
> the problem.
>
> More care required ...

Agreed... As I said before, this is not urgent at all so we didn't
need to rush.


A fix has already been posted?

==
From: FUJITA Tomonori <fujita.tomonori@xxxxxxxxxxxxx>
Subject: [PATCH] move iommu_num_pages helper to x86

This IOMMU helper function doesn't work for some architectures:

http://marc.info/?l=linux-kernel&m=121699304403202&w=2

It also breaks POWER and SPARC builds:

http://marc.info/?l=linux-kernel&m=121730388001890&w=2

Currently, only x86 IOMMUs use this so let's move it to x86 for
now.

Reported-by: Stephen Rothwell <sfr@xxxxxxxxxxxxxxxx>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@xxxxxxxxxxxxx>
---
arch/x86/kernel/pci-dma.c | 8 ++++++++
include/asm-x86/iommu.h | 2 ++
include/linux/iommu-helper.h | 1 -
lib/iommu-helper.c | 8 --------
4 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index 8dbffb8..87d4d69 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -123,6 +123,14 @@ void __init pci_iommu_alloc(void)

pci_swiotlb_init();
}
+
+unsigned long iommu_num_pages(unsigned long addr, unsigned long len)
+{
+ unsigned long size = roundup((addr & ~PAGE_MASK) + len, PAGE_SIZE);
+
+ return size >> PAGE_SHIFT;
+}
+EXPORT_SYMBOL(iommu_num_pages);
#endif

/*
diff --git a/include/asm-x86/iommu.h b/include/asm-x86/iommu.h
index ecc8061..5f888cc 100644
--- a/include/asm-x86/iommu.h
+++ b/include/asm-x86/iommu.h
@@ -7,6 +7,8 @@ extern struct dma_mapping_ops nommu_dma_ops;
extern int force_iommu, no_iommu;
extern int iommu_detected;

+extern unsigned long iommu_num_pages(unsigned long addr, unsigned long len);
+
#ifdef CONFIG_GART_IOMMU
extern int gart_iommu_aperture;
extern int gart_iommu_aperture_allowed;
diff --git a/include/linux/iommu-helper.h b/include/linux/iommu-helper.h
index f8598f5..c975caf 100644
--- a/include/linux/iommu-helper.h
+++ b/include/linux/iommu-helper.h
@@ -8,4 +8,3 @@ extern unsigned long iommu_area_alloc(unsigned long *map, unsigned long size,
unsigned long align_mask);
extern void iommu_area_free(unsigned long *map, unsigned long start,
unsigned int nr);
-extern unsigned long iommu_num_pages(unsigned long addr, unsigned long len);
diff --git a/lib/iommu-helper.c b/lib/iommu-helper.c
index 889ddce..a3b8d4c 100644
--- a/lib/iommu-helper.c
+++ b/lib/iommu-helper.c
@@ -80,11 +80,3 @@ void iommu_area_free(unsigned long *map, unsigned long start, unsigned int nr)
}
}
EXPORT_SYMBOL(iommu_area_free);
-
-unsigned long iommu_num_pages(unsigned long addr, unsigned long len)
-{
- unsigned long size = roundup((addr & ~PAGE_MASK) + len, PAGE_SIZE);
-
- return size >> PAGE_SHIFT;
-}
-EXPORT_SYMBOL(iommu_num_pages);
--
1.5.5.GIT

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/