2008-07-11 01:24:50

by FUJITA Tomonori

[permalink] [raw]
Subject: [PATCH 0/4] x86: IOMMU cleanups

This patchset cleans up IOMMU stuff, including a sequel to the GART
cleanups:

http://lkml.org/lkml/2008/7/9/488

This is against tip/master.


2008-07-11 01:25:04

by FUJITA Tomonori

[permalink] [raw]
Subject: [PATCH 2/4] x86: remove ifdef CONFIG_GART_IOMMU in pci-dma.c

Our way to handle gart_* functions for CONFIG_GART_IOMMU and
!CONFIG_GART_IOMMU cases is inconsistent.

We have some dummy gart_* functions in !CONFIG_GART_IOMMU case and
also use ifdef CONFIG_GART_IOMMU tricks in pci-dma.c to call some
gart_* functions in only CONFIG_GART_IOMMU case.

This patch removes ifdef CONFIG_GART_IOMMU in pci-dma.c and always use
dummy gart_* functions in iommu.h.

Signed-off-by: FUJITA Tomonori <[email protected]>
---
arch/x86/kernel/pci-dma.c | 6 ------
include/asm-x86/iommu.h | 10 +++++++++-
2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index 6eb7470..034fe1c 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -114,9 +114,7 @@ void __init pci_iommu_alloc(void)
* The order of these functions is important for
* fall-back/fail-over reasons
*/
-#ifdef CONFIG_GART_IOMMU
gart_iommu_hole_init();
-#endif

#ifdef CONFIG_CALGARY_IOMMU
detect_calgary();
@@ -184,9 +182,7 @@ static __init int iommu_setup(char *p)
swiotlb = 1;
#endif

-#ifdef CONFIG_GART_IOMMU
gart_parse_options(p);
-#endif

#ifdef CONFIG_CALGARY_IOMMU
if (!strncmp(p, "calgary", 7))
@@ -390,9 +386,7 @@ static int __init pci_iommu_init(void)

amd_iommu_init();

-#ifdef CONFIG_GART_IOMMU
gart_iommu_init();
-#endif

no_iommu_init();
return 0;
diff --git a/include/asm-x86/iommu.h b/include/asm-x86/iommu.h
index 068c9a4..d63166f 100644
--- a/include/asm-x86/iommu.h
+++ b/include/asm-x86/iommu.h
@@ -25,10 +25,18 @@ extern void gart_iommu_hole_init(void);
static inline void early_gart_iommu_check(void)
{
}
-
+static inline void gart_iommu_init(void)
+{
+}
static inline void gart_iommu_shutdown(void)
{
}
+static inline void gart_parse_options(char *options)
+{
+}
+static inline void gart_iommu_hole_init(void)
+{
+}
#endif

#endif
--
1.5.5.GIT

2008-07-11 01:25:44

by FUJITA Tomonori

[permalink] [raw]
Subject: [PATCH 4/4] x86: remove ifdef CONFIG_SWIOTLB in pci-dma.c

As other IOMMUs do, this puts dummy pci_swiotlb_init() in swiotlb.h
and remove ifdef CONFIG_SWIOTLB in pci-dma.c.

Signed-off-by: FUJITA Tomonori <[email protected]>
---
arch/x86/kernel/pci-dma.c | 2 --
include/asm-x86/swiotlb.h | 6 ++++--
2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index 2377de7..e01b616 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -122,9 +122,7 @@ void __init pci_iommu_alloc(void)

amd_iommu_detect();

-#ifdef CONFIG_SWIOTLB
pci_swiotlb_init();
-#endif
}
#endif

diff --git a/include/asm-x86/swiotlb.h b/include/asm-x86/swiotlb.h
index f5d9e74..c706a74 100644
--- a/include/asm-x86/swiotlb.h
+++ b/include/asm-x86/swiotlb.h
@@ -45,12 +45,14 @@ extern int swiotlb_force;

#ifdef CONFIG_SWIOTLB
extern int swiotlb;
+extern void pci_swiotlb_init(void);
#else
#define swiotlb 0
+static inline void pci_swiotlb_init(void)
+{
+}
#endif

-extern void pci_swiotlb_init(void);
-
static inline void dma_mark_clean(void *addr, size_t size) {}

#endif /* _ASM_SWIOTLB_H */
--
1.5.5.GIT

2008-07-11 01:25:29

by FUJITA Tomonori

[permalink] [raw]
Subject: [PATCH 1/4] x86: make only GART code include gart.h

gart.h has only GART-specific stuff. Only GART code needs it. Other
IOMMU stuff should include iommu.h instead of gart.h.

Signed-off-by: FUJITA Tomonori <[email protected]>
---
arch/x86/kernel/amd_iommu.c | 2 +-
arch/x86/kernel/amd_iommu_init.c | 2 +-
arch/x86/kernel/aperture_64.c | 1 +
arch/x86/kernel/early-quirks.c | 5 +----
arch/x86/kernel/pci-calgary_64.c | 2 +-
arch/x86/kernel/pci-dma.c | 2 +-
arch/x86/kernel/pci-gart_64.c | 1 +
arch/x86/kernel/pci-nommu.c | 2 +-
arch/x86/kernel/pci-swiotlb_64.c | 2 +-
arch/x86/kernel/setup.c | 2 +-
drivers/pci/intel-iommu.c | 2 +-
include/asm-x86/gart.h | 1 -
12 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
index f2766d8..cf2f74b 100644
--- a/arch/x86/kernel/amd_iommu.c
+++ b/arch/x86/kernel/amd_iommu.c
@@ -23,7 +23,7 @@
#include <linux/scatterlist.h>
#include <linux/iommu-helper.h>
#include <asm/proto.h>
-#include <asm/gart.h>
+#include <asm/iommu.h>
#include <asm/amd_iommu_types.h>
#include <asm/amd_iommu.h>

diff --git a/arch/x86/kernel/amd_iommu_init.c b/arch/x86/kernel/amd_iommu_init.c
index bb02800..00de43d 100644
--- a/arch/x86/kernel/amd_iommu_init.c
+++ b/arch/x86/kernel/amd_iommu_init.c
@@ -25,7 +25,7 @@
#include <asm/pci-direct.h>
#include <asm/amd_iommu_types.h>
#include <asm/amd_iommu.h>
-#include <asm/gart.h>
+#include <asm/iommu.h>

/*
* definitions for the ACPI scanning code
diff --git a/arch/x86/kernel/aperture_64.c b/arch/x86/kernel/aperture_64.c
index 9f90780..44e2182 100644
--- a/arch/x86/kernel/aperture_64.c
+++ b/arch/x86/kernel/aperture_64.c
@@ -21,6 +21,7 @@
#include <linux/suspend.h>
#include <asm/e820.h>
#include <asm/io.h>
+#include <asm/iommu.h>
#include <asm/gart.h>
#include <asm/pci-direct.h>
#include <asm/dma.h>
diff --git a/arch/x86/kernel/early-quirks.c b/arch/x86/kernel/early-quirks.c
index a4665f3..510b8e3 100644
--- a/arch/x86/kernel/early-quirks.c
+++ b/arch/x86/kernel/early-quirks.c
@@ -16,10 +16,7 @@
#include <asm/dma.h>
#include <asm/io_apic.h>
#include <asm/apic.h>
-
-#ifdef CONFIG_GART_IOMMU
-#include <asm/gart.h>
-#endif
+#include <asm/iommu.h>

static void __init fix_hypertransport_config(int num, int slot, int func)
{
diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
index 4035759..d9e804d 100644
--- a/arch/x86/kernel/pci-calgary_64.c
+++ b/arch/x86/kernel/pci-calgary_64.c
@@ -36,7 +36,7 @@
#include <linux/delay.h>
#include <linux/scatterlist.h>
#include <linux/iommu-helper.h>
-#include <asm/gart.h>
+#include <asm/iommu.h>
#include <asm/calgary.h>
#include <asm/tce.h>
#include <asm/pci-direct.h>
diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index b7dd70f..6eb7470 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -5,7 +5,7 @@

#include <asm/proto.h>
#include <asm/dma.h>
-#include <asm/gart.h>
+#include <asm/iommu.h>
#include <asm/calgary.h>
#include <asm/amd_iommu.h>

diff --git a/arch/x86/kernel/pci-gart_64.c b/arch/x86/kernel/pci-gart_64.c
index d0d18db..949ca98 100644
--- a/arch/x86/kernel/pci-gart_64.c
+++ b/arch/x86/kernel/pci-gart_64.c
@@ -32,6 +32,7 @@
#include <asm/mtrr.h>
#include <asm/pgtable.h>
#include <asm/proto.h>
+#include <asm/iommu.h>
#include <asm/gart.h>
#include <asm/cacheflush.h>
#include <asm/swiotlb.h>
diff --git a/arch/x86/kernel/pci-nommu.c b/arch/x86/kernel/pci-nommu.c
index aec43d5..792b917 100644
--- a/arch/x86/kernel/pci-nommu.c
+++ b/arch/x86/kernel/pci-nommu.c
@@ -7,7 +7,7 @@
#include <linux/dma-mapping.h>
#include <linux/scatterlist.h>

-#include <asm/gart.h>
+#include <asm/iommu.h>
#include <asm/processor.h>
#include <asm/dma.h>

diff --git a/arch/x86/kernel/pci-swiotlb_64.c b/arch/x86/kernel/pci-swiotlb_64.c
index 82299cd..20df839 100644
--- a/arch/x86/kernel/pci-swiotlb_64.c
+++ b/arch/x86/kernel/pci-swiotlb_64.c
@@ -5,7 +5,7 @@
#include <linux/module.h>
#include <linux/dma-mapping.h>

-#include <asm/gart.h>
+#include <asm/iommu.h>
#include <asm/swiotlb.h>
#include <asm/dma.h>

diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 098208d..fef7d0a 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -96,7 +96,7 @@
#include <asm/smp.h>
#include <asm/desc.h>
#include <asm/dma.h>
-#include <asm/gart.h>
+#include <asm/iommu.h>
#include <asm/mmu_context.h>
#include <asm/proto.h>

diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
index bb06423..7868065 100644
--- a/drivers/pci/intel-iommu.c
+++ b/drivers/pci/intel-iommu.c
@@ -37,7 +37,7 @@
#include "intel-iommu.h"
#include <asm/proto.h> /* force_iommu in this header in x86-64*/
#include <asm/cacheflush.h>
-#include <asm/gart.h>
+#include <asm/iommu.h>
#include "pci.h"

#define IS_GFX_DEVICE(pdev) ((pdev->class >> 16) == PCI_BASE_CLASS_DISPLAY)
diff --git a/include/asm-x86/gart.h b/include/asm-x86/gart.h
index 33b9aee..3f62a83 100644
--- a/include/asm-x86/gart.h
+++ b/include/asm-x86/gart.h
@@ -2,7 +2,6 @@
#define _ASM_X8664_GART_H 1

#include <asm/e820.h>
-#include <asm/iommu.h>

extern void set_up_gart_resume(u32, u32);

--
1.5.5.GIT

2008-07-11 01:47:22

by FUJITA Tomonori

[permalink] [raw]
Subject: [PATCH 3/4] x86: remove ifdef CONFIG_CALGARY_IOMMU in pci-dma.c

asm-x86/calgary.h has dummy calgary_iommu_init() and detect_calgary()
in !CONFIG_CALGARY_IOMMU case. So we don't need ifdef
CONFIG_CALGARY_IOMMU in pci-dma.c.

Signed-off-by: FUJITA Tomonori <[email protected]>
Cc: Alexis Bruemmer <[email protected]>
---
arch/x86/kernel/pci-dma.c | 4 ----
1 files changed, 0 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index 034fe1c..2377de7 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -116,9 +116,7 @@ void __init pci_iommu_alloc(void)
*/
gart_iommu_hole_init();

-#ifdef CONFIG_CALGARY_IOMMU
detect_calgary();
-#endif

detect_intel_iommu();

@@ -378,9 +376,7 @@ EXPORT_SYMBOL(dma_free_coherent);

static int __init pci_iommu_init(void)
{
-#ifdef CONFIG_CALGARY_IOMMU
calgary_iommu_init();
-#endif

intel_iommu_init();

--
1.5.5.GIT

2008-07-11 08:33:20

by Muli Ben-Yehuda

[permalink] [raw]
Subject: Re: [PATCH 0/4] x86: IOMMU cleanups

On Fri, Jul 11, 2008 at 10:23:41AM +0900, FUJITA Tomonori wrote:
> This patchset cleans up IOMMU stuff, including a sequel to the GART
> cleanups:
>
> http://lkml.org/lkml/2008/7/9/488
>
> This is against tip/master.

I heartily endorse this patchset. Thanks for doing it!

Cheers,
Muli

2008-07-11 09:02:36

by Ingo Molnar

[permalink] [raw]
Subject: Re: [PATCH 0/4] x86: IOMMU cleanups


* Muli Ben-Yehuda <[email protected]> wrote:

> On Fri, Jul 11, 2008 at 10:23:41AM +0900, FUJITA Tomonori wrote:
> > This patchset cleans up IOMMU stuff, including a sequel to the GART
> > cleanups:
> >
> > http://lkml.org/lkml/2008/7/9/488
> >
> > This is against tip/master.
>
> I heartily endorse this patchset. Thanks for doing it!

thanks - the series looks really nice and i've applied it to
tip/x86/gart.

I've also added:

Acked-by: Muli Ben-Yehuda <[email protected]>

... if you dont mind.

Ingo

2008-07-11 12:37:26

by Muli Ben-Yehuda

[permalink] [raw]
Subject: Re: [PATCH 0/4] x86: IOMMU cleanups

On Fri, Jul 11, 2008 at 11:01:49AM +0200, Ingo Molnar wrote:
>
> * Muli Ben-Yehuda <[email protected]> wrote:
>
> > On Fri, Jul 11, 2008 at 10:23:41AM +0900, FUJITA Tomonori wrote:
> > > This patchset cleans up IOMMU stuff, including a sequel to the GART
> > > cleanups:
> > >
> > > http://lkml.org/lkml/2008/7/9/488
> > >
> > > This is against tip/master.
> >
> > I heartily endorse this patchset. Thanks for doing it!
>
> thanks - the series looks really nice and i've applied it to
> tip/x86/gart.
>
> I've also added:
>
> Acked-by: Muli Ben-Yehuda <[email protected]>
>
> ... if you dont mind.

I don't mind at all.

(the reason I didn't ack it at first is that I try to review *and*
test a patchset first before formally acking it...)

Cheers,
Muli

2008-07-14 23:57:31

by FUJITA Tomonori

[permalink] [raw]
Subject: Re: [PATCH 0/4] x86: IOMMU cleanups

On Fri, 11 Jul 2008 11:01:49 +0200
Ingo Molnar <[email protected]> wrote:

>
> * Muli Ben-Yehuda <[email protected]> wrote:
>
> > On Fri, Jul 11, 2008 at 10:23:41AM +0900, FUJITA Tomonori wrote:
> > > This patchset cleans up IOMMU stuff, including a sequel to the GART
> > > cleanups:
> > >
> > > http://lkml.org/lkml/2008/7/9/488
> > >
> > > This is against tip/master.
> >
> > I heartily endorse this patchset. Thanks for doing it!
>
> thanks - the series looks really nice and i've applied it to
> tip/x86/gart.

This missed the merge window? It's not urgent at all but it's clean
and pretty safe, I think.

2008-07-18 21:49:59

by Ingo Molnar

[permalink] [raw]
Subject: Re: [PATCH 0/4] x86: IOMMU cleanups


* FUJITA Tomonori <[email protected]> wrote:

> On Fri, 11 Jul 2008 11:01:49 +0200
> Ingo Molnar <[email protected]> wrote:
>
> >
> > * Muli Ben-Yehuda <[email protected]> wrote:
> >
> > > On Fri, Jul 11, 2008 at 10:23:41AM +0900, FUJITA Tomonori wrote:
> > > > This patchset cleans up IOMMU stuff, including a sequel to the GART
> > > > cleanups:
> > > >
> > > > http://lkml.org/lkml/2008/7/9/488
> > > >
> > > > This is against tip/master.
> > >
> > > I heartily endorse this patchset. Thanks for doing it!
> >
> > thanks - the series looks really nice and i've applied it to
> > tip/x86/gart.
>
> This missed the merge window? It's not urgent at all but it's clean
> and pretty safe, I think.

i think we can still push them in this merge window, they have been
problem-free so far.

Ingo