Welcome to Soft32 Linux Forums!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

[PATCH v2 0/9] x86: handle HW IOMMU initialization failure..

 
Goto page 1, 2
   Soft32 Home -> Linux -> Kernel RSS
Next:  [GIT PULL] hw-breakpoints: Various fixes  
Author Message
FUJITA Tomonori

External


Since: Dec 13, 2006
Posts: 126



(Msg. 1) Posted: Tue Nov 10, 2009 5:20 am
Post subject: [PATCH v2 0/9] x86: handle HW IOMMU initialization failure gracefully
Archived from groups: linux>kernel (more info?)

This patchset is against tip/master.

The first version is:

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

The changes since v1 are:

- replaced Chris' bootmem patches with the 6/9 patch to implement
free_bootmem_late in a simple way (thanks to Pekka).

- fixed the bug to break 'iommu=soft' boot opiton (found by Joerg).

- moved iommu_init_noop() to x86_init.c

- added Muli's Acked-by to Calgary patch.


==
arch/ia64/kernel/pci-swiotlb.c | 4 +-
arch/powerpc/kernel/setup_32.c | 2 +-
arch/powerpc/kernel/setup_64.c | 2 +-
arch/x86/include/asm/amd_iommu.h | 2 -
arch/x86/include/asm/calgary.h | 2 -
arch/x86/include/asm/gart.h | 5 +---
arch/x86/include/asm/iommu.h | 1 -
arch/x86/include/asm/x86_init.h | 9 +++++++
arch/x86/kernel/amd_iommu.c | 2 +-
arch/x86/kernel/amd_iommu_init.c | 19 +++-----------
arch/x86/kernel/aperture_64.c | 4 ++-
arch/x86/kernel/pci-calgary_64.c | 19 ++++-----------
arch/x86/kernel/pci-dma.c | 27 ++++++++++-----------
arch/x86/kernel/pci-gart_64.c | 16 ++++-------
arch/x86/kernel/pci-nommu.c | 9 -------
arch/x86/kernel/pci-swiotlb.c | 10 +++----
arch/x86/kernel/x86_init.c | 5 ++++
drivers/pci/dmar.c | 7 ++++-
drivers/pci/intel-iommu.c | 4 +-
include/linux/bootmem.h | 1 +
include/linux/dmar.h | 10 -------
include/linux/swiotlb.h | 5 ++-
lib/swiotlb.c | 49 +++++++++++++++++++++++++++++++------
mm/bootmem.c | 24 ++++++++++++++++++
24 files changed, 131 insertions(+), 107 deletions(-)


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

External


Since: Dec 13, 2006
Posts: 126



(Msg. 2) Posted: Tue Nov 10, 2009 5:20 am
Post subject: [PATCH -v2 5/9] intel-iommu: convert detect_intel_iommu to use iommu_init hook [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

This changes detect_intel_iommu() to set intel_iommu_init() to
iommu_init hook if detect_intel_iommu() finds the IOMMU.

Signed-off-by: FUJITA Tomonori <fujita.tomonori.RemoveThis@lab.ntt.co.jp>
---
arch/x86/kernel/pci-dma.c | 2 --
drivers/pci/dmar.c | 4 ++++
include/linux/dmar.h | 10 ----------
3 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index 5ca44a9..bed05e2 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -294,8 +294,6 @@ static int __init pci_iommu_init(void)

x86_init.iommu.iommu_init();

- intel_iommu_init();
-
no_iommu_init();
return 0;
}
diff --git a/drivers/pci/dmar.c b/drivers/pci/dmar.c
index 22b02c6..bce9cd7 100644
--- a/drivers/pci/dmar.c
+++ b/drivers/pci/dmar.c
@@ -617,6 +617,10 @@ void __init detect_intel_iommu(void)
!dmar_disabled)
iommu_detected = 1;
#endif
+#ifdef CONFIG_X86
+ if (ret)
+ x86_init.iommu.iommu_init = intel_iommu_init;
+#endif
}
early_acpi_os_unmap_memory(dmar_tbl, dmar_tbl_size);
dmar_tbl = NULL;
diff --git a/include/linux/dmar.h b/include/linux/dmar.h
index a05cd1c..d814d7d 100644
--- a/include/linux/dmar.h
+++ b/include/linux/dmar.h
@@ -218,16 +218,6 @@ struct dmar_atsr_unit {
u8 include_all:1; /* include all ports */
};

-/* Intel DMAR initialization functions */
extern int intel_iommu_init(void);
-#else
-static inline int intel_iommu_init(void)
-{
-#ifdef CONFIG_INTR_REMAP
- return dmar_dev_scope_init();
-#else
- return -ENODEV;
#endif
-}
-#endif /* !CONFIG_DMAR */
#endif /* __DMAR_H__ */
--
1.5.6.5

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

External


Since: Dec 13, 2006
Posts: 126



(Msg. 3) Posted: Tue Nov 10, 2009 5:20 am
Post subject: [PATCH -v2 7/9] swiotlb: add swiotlb_free function [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

swiotlb_free function frees all allocated memory for swiotlb.

We need to initialize swiotlb before IOMMU initialization (x86 and
powerpc needs to allocate memory from bootmem allocator). If IOMMU
initialization is successful, we need to free swiotlb resource (don't
want to waste 64MB).

Signed-off-by: FUJITA Tomonori <fujita.tomonori.TakeThisOut@lab.ntt.co.jp>
---
include/linux/swiotlb.h | 1 +
lib/swiotlb.c | 30 ++++++++++++++++++++++++++++++
2 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
index 73b1f1c..51b6cc2 100644
--- a/include/linux/swiotlb.h
+++ b/include/linux/swiotlb.h
@@ -88,4 +88,5 @@ swiotlb_dma_mapping_error(struct device *hwdev, dma_addr_t dma_addr);
extern int
swiotlb_dma_supported(struct device *hwdev, u64 mask);

+extern void __init swiotlb_free(void);
#endif /* __LINUX_SWIOTLB_H */
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index ac25cd2..eee512b 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -97,6 +97,8 @@ static phys_addr_t *io_tlb_orig_addr;
*/
static DEFINE_SPINLOCK(io_tlb_lock);

+static int late_alloc;
+
static int __init
setup_io_tlb_npages(char *str)
{
@@ -262,6 +264,8 @@ swiotlb_late_init_with_default_size(size_t default_size)

swiotlb_print_info(bytes);

+ late_alloc = 1;
+
return 0;

cleanup4:
@@ -281,6 +285,32 @@ cleanup1:
return -ENOMEM;
}

+void __init swiotlb_free(void)
+{
+ if (!io_tlb_overflow_buffer)
+ return;
+
+ if (late_alloc) {
+ free_pages((unsigned long)io_tlb_overflow_buffer,
+ get_order(io_tlb_overflow));
+ free_pages((unsigned long)io_tlb_orig_addr,
+ get_order(io_tlb_nslabs * sizeof(phys_addr_t)));
+ free_pages((unsigned long)io_tlb_list, get_order(io_tlb_nslabs *
+ sizeof(int)));
+ free_pages((unsigned long)io_tlb_start,
+ get_order(io_tlb_nslabs << IO_TLB_SHIFT));
+ } else {
+ free_bootmem_late(__pa(io_tlb_overflow_buffer),
+ io_tlb_overflow);
+ free_bootmem_late(__pa(io_tlb_orig_addr),
+ io_tlb_nslabs * sizeof(phys_addr_t));
+ free_bootmem_late(__pa(io_tlb_list),
+ io_tlb_nslabs * sizeof(int));
+ free_bootmem_late(__pa(io_tlb_start),
+ io_tlb_nslabs << IO_TLB_SHIFT);
+ }
+}
+
static int is_swiotlb_buffer(phys_addr_t paddr)
{
return paddr >= virt_to_phys(io_tlb_start) &&
--
1.5.6.5

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

External


Since: Dec 13, 2006
Posts: 126



(Msg. 4) Posted: Tue Nov 10, 2009 5:20 am
Post subject: [PATCH -v2 8/9] swiotlb: export swiotlb_print_info [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

This enables us to avoid printing swiotlb memory info when we
initialize swiotlb. After swiotlb initialization, we could find that
we dont' need swiotlb.

This patch removes the code to print swiotlb memory info in
swiotlb_init() and exports the function to do that.

Cc: tony.luck.TakeThisOut@intel.com
Cc: benh.TakeThisOut@kernel.crashing.org
Signed-off-by: FUJITA Tomonori <fujita.tomonori.TakeThisOut@lab.ntt.co.jp>
---
arch/ia64/kernel/pci-swiotlb.c | 4 ++--
arch/powerpc/kernel/setup_32.c | 2 +-
arch/powerpc/kernel/setup_64.c | 2 +-
arch/x86/kernel/pci-swiotlb.c | 3 +--
include/linux/swiotlb.h | 4 ++--
lib/swiotlb.c | 15 ++++++++-------
6 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/arch/ia64/kernel/pci-swiotlb.c b/arch/ia64/kernel/pci-swiotlb.c
index 285aae8..53292ab 100644
--- a/arch/ia64/kernel/pci-swiotlb.c
+++ b/arch/ia64/kernel/pci-swiotlb.c
@@ -41,7 +41,7 @@ struct dma_map_ops swiotlb_dma_ops = {
void __init swiotlb_dma_init(void)
{
dma_ops = &swiotlb_dma_ops;
- swiotlb_init();
+ swiotlb_init(1);
}

void __init pci_swiotlb_init(void)
@@ -51,7 +51,7 @@ void __init pci_swiotlb_init(void)
swiotlb = 1;
printk(KERN_INFO "PCI-DMA: Re-initialize machine vector.\n");
machvec_init("dig");
- swiotlb_init();
+ swiotlb_init(1);
dma_ops = &swiotlb_dma_ops;
#else
panic("Unable to find Intel IOMMU");
diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c
index 53bcf3d..b152de3 100644
--- a/arch/powerpc/kernel/setup_32.c
+++ b/arch/powerpc/kernel/setup_32.c
@@ -345,7 +345,7 @@ void __init setup_arch(char **cmdline_p)

#ifdef CONFIG_SWIOTLB
if (ppc_swiotlb_enable)
- swiotlb_init();
+ swiotlb_init(1);
#endif

paging_init();
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index 04f638d..df2c9e9 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -550,7 +550,7 @@ void __init setup_arch(char **cmdline_p)

#ifdef CONFIG_SWIOTLB
if (ppc_swiotlb_enable)
- swiotlb_init();
+ swiotlb_init(1);
#endif

paging_init();
diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
index aaa6b78..ea20ef7 100644
--- a/arch/x86/kernel/pci-swiotlb.c
+++ b/arch/x86/kernel/pci-swiotlb.c
@@ -52,8 +52,7 @@ void __init pci_swiotlb_init(void)
if (swiotlb_force)
swiotlb = 1;
if (swiotlb) {
- printk(KERN_INFO "PCI-DMA: Using software bounce buffering for IO (SWIOTLB)\n");
- swiotlb_init();
+ swiotlb_init(0);
dma_ops = &swiotlb_dma_ops;
}
}
diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
index 51b6cc2..6b70068 100644
--- a/include/linux/swiotlb.h
+++ b/include/linux/swiotlb.h
@@ -20,8 +20,7 @@ struct scatterlist;
*/
#define IO_TLB_SHIFT 11

-extern void
-swiotlb_init(void);
+extern void swiotlb_init(int verbose);

extern void
*swiotlb_alloc_coherent(struct device *hwdev, size_t size,
@@ -89,4 +88,5 @@ extern int
swiotlb_dma_supported(struct device *hwdev, u64 mask);

extern void __init swiotlb_free(void);
+extern void swiotlb_print_info(void);
#endif /* __LINUX_SWIOTLB_H */
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index eee512b..0c12d7c 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -123,8 +123,9 @@ static dma_addr_t swiotlb_virt_to_bus(struct device *hwdev,
return phys_to_dma(hwdev, virt_to_phys(address));
}

-static void swiotlb_print_info(unsigned long bytes)
+void swiotlb_print_info(void)
{
+ unsigned long bytes = io_tlb_nslabs << IO_TLB_SHIFT;
phys_addr_t pstart, pend;

pstart = virt_to_phys(io_tlb_start);
@@ -142,7 +143,7 @@ static void swiotlb_print_info(unsigned long bytes)
* structures for the software IO TLB used to implement the DMA API.
*/
void __init
-swiotlb_init_with_default_size(size_t default_size)
+swiotlb_init_with_default_size(size_t default_size, int verbose)
{
unsigned long i, bytes;

@@ -178,14 +179,14 @@ swiotlb_init_with_default_size(size_t default_size)
io_tlb_overflow_buffer = alloc_bootmem_low(io_tlb_overflow);
if (!io_tlb_overflow_buffer)
panic("Cannot allocate SWIOTLB overflow buffer!\n");
-
- swiotlb_print_info(bytes);
+ if (verbose)
+ swiotlb_print_info();
}

void __init
-swiotlb_init(void)
+swiotlb_init(int verbose)
{
- swiotlb_init_with_default_size(64 * (1<<20)); /* default to 64MB */
+ swiotlb_init_with_default_size(64 * (1<<20), verbose); /* default to 64MB */
}

/*
@@ -262,7 +263,7 @@ swiotlb_late_init_with_default_size(size_t default_size)
if (!io_tlb_overflow_buffer)
goto cleanup4;

- swiotlb_print_info(bytes);
+ swiotlb_print_info();

late_alloc = 1;

--
1.5.6.5

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

External


Since: Dec 13, 2006
Posts: 126



(Msg. 5) Posted: Tue Nov 10, 2009 5:20 am
Post subject: [PATCH -v2 2/9] Calgary: convert detect_calgary to use iommu_init hook [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

This changes detect_calgary() to set init_calgary() to iommu_init hook
if detect_calgary() finds the Calgary IOMMU.

We can kill the code to check if we found the IOMMU in init_calgary()
since detect_calgary() sets init_calgary() only when it found the
IOMMU.

Signed-off-by: FUJITA Tomonori <fujita.tomonori.DeleteThis@lab.ntt.co.jp>
Acked-by: Muli Ben-Yehuda <muli.DeleteThis@il.ibm.com>
---
arch/x86/include/asm/calgary.h | 2 --
arch/x86/kernel/pci-calgary_64.c | 11 +++++------
arch/x86/kernel/pci-dma.c | 2 --
3 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/arch/x86/include/asm/calgary.h b/arch/x86/include/asm/calgary.h
index b03bedb..0918654 100644
--- a/arch/x86/include/asm/calgary.h
+++ b/arch/x86/include/asm/calgary.h
@@ -62,10 +62,8 @@ struct cal_chipset_ops {
extern int use_calgary;

#ifdef CONFIG_CALGARY_IOMMU
-extern int calgary_iommu_init(void);
extern void detect_calgary(void);
#else
-static inline int calgary_iommu_init(void) { return 1; }
static inline void detect_calgary(void) { return; }
#endif

diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
index 971a3be..47bd419 100644
--- a/arch/x86/kernel/pci-calgary_64.c
+++ b/arch/x86/kernel/pci-calgary_64.c
@@ -46,6 +46,7 @@
#include <asm/dma.h>
#include <asm/rio.h>
#include <asm/bios_ebda.h>
+#include <asm/x86_init.h>

#ifdef CONFIG_CALGARY_IOMMU_ENABLED_BY_DEFAULT
int use_calgary __read_mostly = 1;
@@ -1344,6 +1345,8 @@ static void __init get_tce_space_from_tar(void)
return;
}

+int __init calgary_iommu_init(void);
+
void __init detect_calgary(void)
{
int bus;
@@ -1445,6 +1448,8 @@ void __init detect_calgary(void)
/* swiotlb for devices that aren't behind the Calgary. */
if (max_pfn > MAX_DMA32_PFN)
swiotlb = 1;
+
+ x86_init.iommu.iommu_init = calgary_iommu_init;
}
return;

@@ -1461,12 +1466,6 @@ int __init calgary_iommu_init(void)
{
int ret;

- if (no_iommu || (swiotlb && !calgary_detected))
- return -ENODEV;
-
- if (!calgary_detected)
- return -ENODEV;
-
/* ok, we're trying to use Calgary - let's roll */
printk(KERN_INFO "PCI-DMA: Using Calgary IOMMU\n");

diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index a13478d..0224da8 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -294,8 +294,6 @@ static int __init pci_iommu_init(void)

x86_init.iommu.iommu_init();

- calgary_iommu_init();
-
intel_iommu_init();

amd_iommu_init();
--
1.5.6.5

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

External


Since: Dec 13, 2006
Posts: 126



(Msg. 6) Posted: Tue Nov 10, 2009 5:20 am
Post subject: [PATCH -v2 9/9] x86: handle HW IOMMU initialization failure gracely [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

If HW IOMMU initialization fails (Intel VT-d often does typically due
to BIOS bugs), we fall back to nommu. It doesn't work for the majority
since nowadays we have more than 4GB memory so we must use swiotlb
instead of nommu.

The problem is that it's too late to initialize swiotlb when HW IOMMU
initialization fails. We need to allocate swiotlb memory earlier from
bootmem allocator. Chris explained the issue in detail:

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

The current x86 IOMMU initialization sequence is too complicated and
handling the above issue makes it more hacky.

This patch changes x86 IOMMU initialization sequence to handle the
above issue cleanly.

The new x86 IOMMU initialization sequence are:

1. initializing swiotlb (and setting swiotlb to 1) in the case of
(max_pfn > MAX_DMA32_PFN && !no_iommu). dma_ops is set to
swiotlb_dma_ops or nommu_dma_ops. if swiotlb usage is forced by the
boot option, we finish here.

2. calling the detection functions of all the IOMMUs

3. the detection function sets x86_init.iommu.iommu_init to the IOMMU
initialization function (so we can avoid calling the initialization
functions of all the IOMMUs needlessly).

4. if the IOMMU initialization function doesn't need to swiotlb then
sets swiotlb to zero (e.g. the initialization is sucessful).

5. if we find that swiotlb is set to zero, we free swiotlb resource.

Signed-off-by: FUJITA Tomonori <fujita.tomonori.RemoveThis@lab.ntt.co.jp>
---
arch/x86/include/asm/iommu.h | 1 -
arch/x86/kernel/amd_iommu.c | 2 +-
arch/x86/kernel/amd_iommu_init.c | 2 +-
arch/x86/kernel/aperture_64.c | 2 +-
arch/x86/kernel/pci-calgary_64.c | 10 +---------
arch/x86/kernel/pci-dma.c | 21 +++++++++++++--------
arch/x86/kernel/pci-gart_64.c | 1 +
arch/x86/kernel/pci-nommu.c | 9 ---------
arch/x86/kernel/pci-swiotlb.c | 7 +++----
drivers/pci/dmar.c | 3 +--
drivers/pci/intel-iommu.c | 4 ++--
lib/swiotlb.c | 4 +++-
12 files changed, 27 insertions(+), 39 deletions(-)

diff --git a/arch/x86/include/asm/iommu.h b/arch/x86/include/asm/iommu.h
index 878b307..df42a71 100644
--- a/arch/x86/include/asm/iommu.h
+++ b/arch/x86/include/asm/iommu.h
@@ -2,7 +2,6 @@
#define _ASM_X86_IOMMU_H

static inline void iommu_shutdown_noop(void) {}
-extern void no_iommu_init(void);
extern struct dma_map_ops nommu_dma_ops;
extern int force_iommu, no_iommu;
extern int iommu_detected;
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
index 0285521..66237fd 100644
--- a/arch/x86/kernel/amd_iommu.c
+++ b/arch/x86/kernel/amd_iommu.c
@@ -2110,8 +2110,8 @@ int __init amd_iommu_init_dma_ops(void)
prealloc_protection_domains();

iommu_detected = 1;
- force_iommu = 1;
bad_dma_address = 0;
+ swiotlb = 0;
#ifdef CONFIG_GART_IOMMU
gart_iommu_aperture_disabled = 1;
gart_iommu_aperture = 0;
diff --git a/arch/x86/kernel/amd_iommu_init.c b/arch/x86/kernel/amd_iommu_init.c
index c41aabd..0d4581e 100644
--- a/arch/x86/kernel/amd_iommu_init.c
+++ b/arch/x86/kernel/amd_iommu_init.c
@@ -1330,7 +1330,7 @@ static int __init early_amd_iommu_detect(struct acpi_table_header *table)

void __init amd_iommu_detect(void)
{
- if (swiotlb || no_iommu || (iommu_detected && !gart_iommu_aperture))
+ if (no_iommu || (iommu_detected && !gart_iommu_aperture))
return;

if (acpi_table_parse("IVRS", early_amd_iommu_detect) == 0) {
diff --git a/arch/x86/kernel/aperture_64.c b/arch/x86/kernel/aperture_64.c
index 03933cf..e0dfb68 100644
--- a/arch/x86/kernel/aperture_64.c
+++ b/arch/x86/kernel/aperture_64.c
@@ -458,7 +458,7 @@ out:

if (aper_alloc) {
/* Got the aperture from the AGP bridge */
- } else if (swiotlb && !valid_agp) {
+ } else if (!valid_agp) {
/* Do nothing */
} else if ((!no_iommu && max_pfn > MAX_DMA32_PFN) ||
force_iommu ||
diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
index 47bd419..833f491 100644
--- a/arch/x86/kernel/pci-calgary_64.c
+++ b/arch/x86/kernel/pci-calgary_64.c
@@ -1360,7 +1360,7 @@ void __init detect_calgary(void)
* if the user specified iommu=off or iommu=soft or we found
* another HW IOMMU already, bail out.
*/
- if (swiotlb || no_iommu || iommu_detected)
+ if (no_iommu || iommu_detected)
return;

if (!use_calgary)
@@ -1445,10 +1445,6 @@ void __init detect_calgary(void)
printk(KERN_INFO "PCI-DMA: Calgary TCE table spec is %d\n",
specified_table_size);

- /* swiotlb for devices that aren't behind the Calgary. */
- if (max_pfn > MAX_DMA32_PFN)
- swiotlb = 1;
-
x86_init.iommu.iommu_init = calgary_iommu_init;
}
return;
@@ -1476,11 +1472,7 @@ int __init calgary_iommu_init(void)
return ret;
}

- force_iommu = 1;
bad_dma_address = 0x0;
- /* dma_ops is set to swiotlb or nommu */
- if (!dma_ops)
- dma_ops = &nommu_dma_ops;

return 0;
}
diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index bed05e2..a234e63 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -124,24 +124,24 @@ static void __init dma32_free_bootmem(void)

void __init pci_iommu_alloc(void)
{
+ /* swiotlb is forced by the boot option */
+ int use_swiotlb = swiotlb;
#ifdef CONFIG_X86_64
/* free the range so iommu could get some range less than 4G */
dma32_free_bootmem();
#endif
+ pci_swiotlb_init();
+ if (use_swiotlb)
+ return;

- /*
- * The order of these functions is important for
- * fall-back/fail-over reasons
- */
gart_iommu_hole_init();

detect_calgary();

detect_intel_iommu();

+ /* needs to be called after gart_iommu_hole_init */
amd_iommu_detect();
-
- pci_swiotlb_init();
}

void *dma_generic_alloc_coherent(struct device *dev, size_t size,
@@ -291,10 +291,15 @@ static int __init pci_iommu_init(void)
#ifdef CONFIG_PCI
dma_debug_add_bus(&pci_bus_type);
#endif
-
x86_init.iommu.iommu_init();

- no_iommu_init();
+ if (swiotlb) {
+ printk(KERN_INFO "PCI-DMA: "
+ "Using software bounce buffering for IO (SWIOTLB)\n");
+ swiotlb_print_info();
+ } else
+ swiotlb_free();
+
return 0;
}
/* Must execute after PCI subsystem */
diff --git a/arch/x86/kernel/pci-gart_64.c b/arch/x86/kernel/pci-gart_64.c
index 0410bd3..919182e 100644
--- a/arch/x86/kernel/pci-gart_64.c
+++ b/arch/x86/kernel/pci-gart_64.c
@@ -833,6 +833,7 @@ int __init gart_iommu_init(void)
flush_gart();
dma_ops = &gart_dma_ops;
x86_platform.iommu_shutdown = gart_iommu_shutdown;
+ swiotlb = 0;

return 0;
}
diff --git a/arch/x86/kernel/pci-nommu.c b/arch/x86/kernel/pci-nommu.c
index a3933d4..875e382 100644
--- a/arch/x86/kernel/pci-nommu.c
+++ b/arch/x86/kernel/pci-nommu.c
@@ -103,12 +103,3 @@ struct dma_map_ops nommu_dma_ops = {
.sync_sg_for_device = nommu_sync_sg_for_device,
.is_phys = 1,
};
-
-void __init no_iommu_init(void)
-{
- if (dma_ops)
- return;
-
- force_iommu = 0; /* no HW IOMMU */
- dma_ops = &nommu_dma_ops;
-}
diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
index ea20ef7..17ce422 100644
--- a/arch/x86/kernel/pci-swiotlb.c
+++ b/arch/x86/kernel/pci-swiotlb.c
@@ -46,13 +46,12 @@ void __init pci_swiotlb_init(void)
{
/* don't initialize swiotlb if iommu=off (no_iommu=1) */
#ifdef CONFIG_X86_64
- if ((!iommu_detected && !no_iommu && max_pfn > MAX_DMA32_PFN))
+ if (!no_iommu && max_pfn > MAX_DMA32_PFN)
swiotlb = 1;
#endif
- if (swiotlb_force)
- swiotlb = 1;
if (swiotlb) {
swiotlb_init(0);
dma_ops = &swiotlb_dma_ops;
- }
+ } else
+ dma_ops = &nommu_dma_ops;
}
diff --git a/drivers/pci/dmar.c b/drivers/pci/dmar.c
index bce9cd7..4373996 100644
--- a/drivers/pci/dmar.c
+++ b/drivers/pci/dmar.c
@@ -613,8 +613,7 @@ void __init detect_intel_iommu(void)
"x2apic and Intr-remapping.\n");
#endif
#ifdef CONFIG_DMAR
- if (ret && !no_iommu && !iommu_detected && !swiotlb &&
- !dmar_disabled)
+ if (ret && !no_iommu && !iommu_detected && !dmar_disabled)
iommu_detected = 1;
#endif
#ifdef CONFIG_X86
diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
index b1e97e6..c7a8bcf 100644
--- a/drivers/pci/intel-iommu.c
+++ b/drivers/pci/intel-iommu.c
@@ -3231,7 +3231,7 @@ int __init intel_iommu_init(void)
* Check the need for DMA-remapping initialization now.
* Above initialization will also be used by Interrupt-remapping.
*/
- if (no_iommu || swiotlb || dmar_disabled)
+ if (no_iommu || dmar_disabled)
return -ENODEV;

iommu_init_mempool();
@@ -3252,7 +3252,7 @@ int __init intel_iommu_init(void)
"PCI-DMA: Intel(R) Virtualization Technology for Directed I/O\n");

init_timer(&unmap_timer);
- force_iommu = 1;
+ swiotlb = 0;
dma_ops = &intel_dma_ops;

init_iommu_sysfs();
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index 0c12d7c..e6755a0 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -109,8 +109,10 @@ setup_io_tlb_npages(char *str)
}
if (*str == ',')
++str;
- if (!strcmp(str, "force"))
+ if (!strcmp(str, "force")) {
swiotlb_force = 1;
+ swiotlb = 1;
+ }
return 1;
}
__setup("swiotlb=", setup_io_tlb_npages);
--
1.5.6.5

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

External


Since: Dec 13, 2006
Posts: 126



(Msg. 7) Posted: Tue Nov 10, 2009 5:20 am
Post subject: [PATCH -v2 1/9] add iommu_init to x86_init_ops [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

We call the detections functions of all the IOMMUs then all their
initialization functions. The latter is pointless since we don't
detect multiple different IOMMUs. What we need to do is calling the
initialization function of the detected IOMMU.

This adds iommu_init hook to x86_init_ops so if an IOMMU detection
function can set its initialization function to the hook.

Signed-off-by: FUJITA Tomonori <fujita.tomonori RemoveThis @lab.ntt.co.jp>
---
arch/x86/include/asm/x86_init.h | 9 +++++++++
arch/x86/kernel/pci-dma.c | 2 ++
arch/x86/kernel/x86_init.c | 5 +++++
3 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
index 66008ed..d8e7145 100644
--- a/arch/x86/include/asm/x86_init.h
+++ b/arch/x86/include/asm/x86_init.h
@@ -91,6 +91,14 @@ struct x86_init_timers {
};

/**
+ * struct x86_init_iommu - platform specific iommu setup
+ * @iommu_init: platform specific iommu setup
+ */
+struct x86_init_iommu {
+ int (*iommu_init)(void);
+};
+
+/**
* struct x86_init_ops - functions for platform specific setup
*
*/
@@ -101,6 +109,7 @@ struct x86_init_ops {
struct x86_init_oem oem;
struct x86_init_paging paging;
struct x86_init_timers timers;
+ struct x86_init_iommu iommu;
};

/**
diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index 839d49a..a13478d 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -292,6 +292,8 @@ static int __init pci_iommu_init(void)
dma_debug_add_bus(&pci_bus_type);
#endif

+ x86_init.iommu.iommu_init();
+
calgary_iommu_init();

intel_iommu_init();
diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
index bc9b230..c46984d 100644
--- a/arch/x86/kernel/x86_init.c
+++ b/arch/x86/kernel/x86_init.c
@@ -19,6 +19,7 @@
void __cpuinit x86_init_noop(void) { }
void __init x86_init_uint_noop(unsigned int unused) { }
void __init x86_init_pgd_noop(pgd_t *unused) { }
+int __init iommu_init_noop(void) { return 0; }

/*
* The platform setup functions are preset with the default functions
@@ -63,6 +64,10 @@ struct x86_init_ops x86_init __initdata = {
.tsc_pre_init = x86_init_noop,
.timer_init = hpet_time_init,
},
+
+ .iommu = {
+ .iommu_init = iommu_init_noop,
+ },
};

struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
--
1.5.6.5

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

External


Since: Dec 13, 2006
Posts: 126



(Msg. 8) Posted: Tue Nov 10, 2009 5:20 am
Post subject: [PATCH -v2 3/9] GART: convert gart_iommu_hole_init to use iommu_init hook [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

This changes gart_iommu_hole_init() to set gart_iommu_init() to
iommu_init hook if gart_iommu_hole_init() finds the GART IOMMU.

We can kill the code to check if we found the IOMMU in
gart_iommu_init() since gart_iommu_hole_init() sets gart_iommu_init()
only when it found the IOMMU.

Signed-off-by: FUJITA Tomonori <fujita.tomonori.DeleteThis@lab.ntt.co.jp>
---
arch/x86/include/asm/gart.h | 5 +----
arch/x86/kernel/aperture_64.c | 2 ++
arch/x86/kernel/pci-dma.c | 2 --
arch/x86/kernel/pci-gart_64.c | 15 +++++----------
4 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/arch/x86/include/asm/gart.h b/arch/x86/include/asm/gart.h
index 4fdd5b3..4ac5b0f 100644
--- a/arch/x86/include/asm/gart.h
+++ b/arch/x86/include/asm/gart.h
@@ -35,7 +35,7 @@ extern int gart_iommu_aperture_allowed;
extern int gart_iommu_aperture_disabled;

extern void early_gart_iommu_check(void);
-extern void gart_iommu_init(void);
+extern int gart_iommu_init(void);
extern void __init gart_parse_options(char *);
extern void gart_iommu_hole_init(void);

@@ -47,9 +47,6 @@ 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_parse_options(char *options)
{
}
diff --git a/arch/x86/kernel/aperture_64.c b/arch/x86/kernel/aperture_64.c
index 128111d..03933cf 100644
--- a/arch/x86/kernel/aperture_64.c
+++ b/arch/x86/kernel/aperture_64.c
@@ -28,6 +28,7 @@
#include <asm/pci-direct.h>
#include <asm/dma.h>
#include <asm/k8.h>
+#include <asm/x86_init.h>

int gart_iommu_aperture;
int gart_iommu_aperture_disabled __initdata;
@@ -400,6 +401,7 @@ void __init gart_iommu_hole_init(void)

iommu_detected = 1;
gart_iommu_aperture = 1;
+ x86_init.iommu.iommu_init = gart_iommu_init;

aper_order = (read_pci_config(bus, slot, 3, AMD64_GARTAPERTURECTL) >> 1) & 7;
aper_size = (32 * 1024 * 1024) << aper_order;
diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index 0224da8..ecde854 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -298,8 +298,6 @@ static int __init pci_iommu_init(void)

amd_iommu_init();

- gart_iommu_init();
-
no_iommu_init();
return 0;
}
diff --git a/arch/x86/kernel/pci-gart_64.c b/arch/x86/kernel/pci-gart_64.c
index eb46ab3..0410bd3 100644
--- a/arch/x86/kernel/pci-gart_64.c
+++ b/arch/x86/kernel/pci-gart_64.c
@@ -709,7 +709,7 @@ static void gart_iommu_shutdown(void)
}
}

-void __init gart_iommu_init(void)
+int __init gart_iommu_init(void)
{
struct agp_kern_info info;
unsigned long iommu_start;
@@ -719,7 +719,7 @@ void __init gart_iommu_init(void)
long i;

if (cache_k8_northbridges() < 0 || num_k8_northbridges == 0)
- return;
+ return 0;

#ifndef CONFIG_AGP_AMD64
no_agp = 1;
@@ -731,13 +731,6 @@ void __init gart_iommu_init(void)
(agp_copy_info(agp_bridge, &info) < 0);
#endif

- if (swiotlb)
- return;
-
- /* Did we detect a different HW IOMMU? */
- if (iommu_detected && !gart_iommu_aperture)
- return;
-
if (no_iommu ||
(!force_iommu && max_pfn <= MAX_DMA32_PFN) ||
!gart_iommu_aperture ||
@@ -747,7 +740,7 @@ void __init gart_iommu_init(void)
"but GART IOMMU not available.\n");
printk(KERN_WARNING "falling back to iommu=soft.\n");
}
- return;
+ return 0;
}

/* need to map that range */
@@ -840,6 +833,8 @@ void __init gart_iommu_init(void)
flush_gart();
dma_ops = &gart_dma_ops;
x86_platform.iommu_shutdown = gart_iommu_shutdown;
+
+ return 0;
}

void __init gart_parse_options(char *p)
--
1.5.6.5

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

External


Since: Dec 13, 2006
Posts: 126



(Msg. 9) Posted: Tue Nov 10, 2009 5:20 am
Post subject: [PATCH -v2 6/9] bootmem: add free_bootmem_late [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Add a new function for freeing bootmem after the bootmem allocator has
been released and the unreserved pages given to the page allocator.
This allows us to reserve bootmem and then release it if we later
discover it was not needed.

Signed-off-by: FUJITA Tomonori <fujita.tomonori.TakeThisOut@lab.ntt.co.jp>
Cc: hannes.TakeThisOut@cmpxchg.org
Cc: akpm.TakeThisOut@linux-foundation.org
Cc: tj.TakeThisOut@kernel.org
Acked-by: Pekka Enberg <penberg.TakeThisOut@cs.helsinki.fi>
---
include/linux/bootmem.h | 1 +
mm/bootmem.c | 24 ++++++++++++++++++++++++
2 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h
index dd97fb8..b10ec49 100644
--- a/include/linux/bootmem.h
+++ b/include/linux/bootmem.h
@@ -53,6 +53,7 @@ extern void free_bootmem_node(pg_data_t *pgdat,
unsigned long addr,
unsigned long size);
extern void free_bootmem(unsigned long addr, unsigned long size);
+extern void free_bootmem_late(unsigned long addr, unsigned long size);

/*
* Flags for reserve_bootmem (also if CONFIG_HAVE_ARCH_BOOTMEM_NODE,
diff --git a/mm/bootmem.c b/mm/bootmem.c
index ca92991..30f1702 100644
--- a/mm/bootmem.c
+++ b/mm/bootmem.c
@@ -143,6 +143,30 @@ unsigned long __init init_bootmem(unsigned long start, unsigned long pages)
return init_bootmem_core(NODE_DATA(0)->bdata, start, 0, pages);
}

+/*
+ * free_bootmem_late - free bootmem pages directly to page allocator
+ * @addr: starting address of the range
+ * @size: size of the range in bytes
+ *
+ * This is only useful when the bootmem allocator has already been torn
+ * down, but we are still initializing the system. Pages are given directly
+ * to the page allocator, no bootmem metadata is updated because it is gone.
+ */
+void __init free_bootmem_late(unsigned long addr, unsigned long size)
+{
+ unsigned long cursor, end;
+
+ kmemleak_free_part(__va(addr), size);
+
+ cursor = PFN_UP(addr);
+ end = PFN_DOWN(addr + size);
+
+ for (; cursor < end; cursor++) {
+ __free_pages_bootmem(pfn_to_page(cursor), 0);
+ totalram_pages++;
+ }
+}
+
static unsigned long __init free_all_bootmem_core(bootmem_data_t *bdata)
{
int aligned;
--
1.5.6.5

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

External


Since: Nov 05, 2003
Posts: 2922



(Msg. 10) Posted: Tue Nov 10, 2009 5:20 am
Post subject: Re: [PATCH v2 0/9] x86: handle HW IOMMU initialization failure gracefully [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

* FUJITA Tomonori <fujita.tomonori.DeleteThis@lab.ntt.co.jp> wrote:

> This patchset is against tip/master.
>
> The first version is:
>
> http://marc.info/?l=linux-kernel&m=125671300920411&w=2
>
> The changes since v1 are:
>
> - replaced Chris' bootmem patches with the 6/9 patch to implement
> free_bootmem_late in a simple way (thanks to Pekka).
>
> - fixed the bug to break 'iommu=soft' boot opiton (found by Joerg).
>
> - moved iommu_init_noop() to x86_init.c
>
> - added Muli's Acked-by to Calgary patch.
>
>
> ==
> arch/ia64/kernel/pci-swiotlb.c | 4 +-
> arch/powerpc/kernel/setup_32.c | 2 +-
> arch/powerpc/kernel/setup_64.c | 2 +-
> arch/x86/include/asm/amd_iommu.h | 2 -
> arch/x86/include/asm/calgary.h | 2 -
> arch/x86/include/asm/gart.h | 5 +---
> arch/x86/include/asm/iommu.h | 1 -
> arch/x86/include/asm/x86_init.h | 9 +++++++
> arch/x86/kernel/amd_iommu.c | 2 +-
> arch/x86/kernel/amd_iommu_init.c | 19 +++-----------
> arch/x86/kernel/aperture_64.c | 4 ++-
> arch/x86/kernel/pci-calgary_64.c | 19 ++++-----------
> arch/x86/kernel/pci-dma.c | 27 ++++++++++-----------
> arch/x86/kernel/pci-gart_64.c | 16 ++++-------
> arch/x86/kernel/pci-nommu.c | 9 -------
> arch/x86/kernel/pci-swiotlb.c | 10 +++----
> arch/x86/kernel/x86_init.c | 5 ++++
> drivers/pci/dmar.c | 7 ++++-
> drivers/pci/intel-iommu.c | 4 +-
> include/linux/bootmem.h | 1 +
> include/linux/dmar.h | 10 -------
> include/linux/swiotlb.h | 5 ++-
> lib/swiotlb.c | 49 +++++++++++++++++++++++++++++++------
> mm/bootmem.c | 24 ++++++++++++++++++
> 24 files changed, 131 insertions(+), 107 deletions(-)

Nice changes! I've applied them to tip:core/iommu (with the small build
fix i mentioned in the previous mail) and will push them out later
today.

Thanks,

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

External


Since: Nov 05, 2003
Posts: 2922



(Msg. 11) Posted: Tue Nov 10, 2009 5:20 am
Post subject: Re: [PATCH -v2 5/9] intel-iommu: convert detect_intel_iommu to use iommu_init hook [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

* FUJITA Tomonori <fujita.tomonori.RemoveThis@lab.ntt.co.jp> wrote:

> This changes detect_intel_iommu() to set intel_iommu_init() to
> iommu_init hook if detect_intel_iommu() finds the IOMMU.
>
> Signed-off-by: FUJITA Tomonori <fujita.tomonori.RemoveThis@lab.ntt.co.jp>
> ---
> arch/x86/kernel/pci-dma.c | 2 --
> drivers/pci/dmar.c | 4 ++++
> include/linux/dmar.h | 10 ----------
> 3 files changed, 4 insertions(+), 12 deletions(-)

FYI, the !CONFIG_DMAR case needed the fix below. (Wrt. the -ENODEV: it
doesnt matter right now as we dont check the result of ->iommu_init(),
but i kept it consistent with device initialization principles.)

Ingo

diff --git a/include/linux/dmar.h b/include/linux/dmar.h
index d814d7d..df0cfb3 100644
--- a/include/linux/dmar.h
+++ b/include/linux/dmar.h
@@ -219,5 +219,8 @@ struct dmar_atsr_unit {
};

extern int intel_iommu_init(void);
-#endif
+#else /* !CONFIG_DMAR: */
+static inline int intel_iommu_init(void) { return -ENODEV; }
+#endif /* CONFIG_DMAR */
+
#endif /* __DMAR_H__ */
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo.RemoveThis@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to top
Login to vote
Ingo Molnar

External


Since: Nov 05, 2003
Posts: 2922



(Msg. 12) Posted: Tue Nov 10, 2009 7:20 am
Post subject: Re: [PATCH -v2 7/9] swiotlb: add swiotlb_free function [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

this patch needed the fix below, for the !CONFIG_SWIOTLB case.

Ingo

diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
index 6b70068..eb9bdb4 100644
--- a/include/linux/swiotlb.h
+++ b/include/linux/swiotlb.h
@@ -87,6 +87,11 @@ swiotlb_dma_mapping_error(struct device *hwdev, dma_addr_t dma_addr);
extern int
swiotlb_dma_supported(struct device *hwdev, u64 mask);

+#ifdef CONFIG_SWIOTLB
extern void __init swiotlb_free(void);
+#else
+static inline void swiotlb_free(void) { }
+#endif
+
extern void swiotlb_print_info(void);
#endif /* __LINUX_SWIOTLB_H */

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

External


Since: Nov 05, 2003
Posts: 2922



(Msg. 13) Posted: Tue Nov 10, 2009 7:20 am
Post subject: Re: [PATCH -v2 9/9] x86: handle HW IOMMU initialization failure gracely [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

this patch needed the fixlet below. (it could be cleaned up later
perhaps to not need the #ifdef - but wanted to keep it simple for now.)

Ingo

------------->
diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
index c7a8bcf..43d755a 100644
--- a/drivers/pci/intel-iommu.c
+++ b/drivers/pci/intel-iommu.c
@@ -3252,7 +3252,9 @@ int __init intel_iommu_init(void)
"PCI-DMA: Intel(R) Virtualization Technology for Directed I/O\n");

init_timer(&unmap_timer);
+#ifdef CONFIG_SWIOTLB
swiotlb = 0;
+#endif
dma_ops = &intel_dma_ops;

init_iommu_sysfs();
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo DeleteThis @vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to top
Login to vote
Johannes Weiner

External


Since: Nov 06, 2008
Posts: 56



(Msg. 14) Posted: Tue Nov 10, 2009 7:20 am
Post subject: Re: [PATCH -v2 6/9] bootmem: add free_bootmem_late [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Tue, Nov 10, 2009 at 07:46:17PM +0900, FUJITA Tomonori wrote:
> Add a new function for freeing bootmem after the bootmem allocator has
> been released and the unreserved pages given to the page allocator.
> This allows us to reserve bootmem and then release it if we later
> discover it was not needed.
>
> Signed-off-by: FUJITA Tomonori <fujita.tomonori.DeleteThis@lab.ntt.co.jp>
> Cc: hannes.DeleteThis@cmpxchg.org
> Cc: akpm.DeleteThis@linux-foundation.org
> Cc: tj.DeleteThis@kernel.org
> Acked-by: Pekka Enberg <penberg.DeleteThis@cs.helsinki.fi>
> ---
> include/linux/bootmem.h | 1 +
> mm/bootmem.c | 24 ++++++++++++++++++++++++
> 2 files changed, 25 insertions(+), 0 deletions(-)
>
> diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h
> index dd97fb8..b10ec49 100644
> --- a/include/linux/bootmem.h
> +++ b/include/linux/bootmem.h
> @@ -53,6 +53,7 @@ extern void free_bootmem_node(pg_data_t *pgdat,
> unsigned long addr,
> unsigned long size);
> extern void free_bootmem(unsigned long addr, unsigned long size);
> +extern void free_bootmem_late(unsigned long addr, unsigned long size);
>
> /*
> * Flags for reserve_bootmem (also if CONFIG_HAVE_ARCH_BOOTMEM_NODE,
> diff --git a/mm/bootmem.c b/mm/bootmem.c
> index ca92991..30f1702 100644
> --- a/mm/bootmem.c
> +++ b/mm/bootmem.c
> @@ -143,6 +143,30 @@ unsigned long __init init_bootmem(unsigned long start, unsigned long pages)
> return init_bootmem_core(NODE_DATA(0)->bdata, start, 0, pages);
> }
>
> +/*
> + * free_bootmem_late - free bootmem pages directly to page allocator
> + * @addr: starting address of the range
> + * @size: size of the range in bytes
> + *
> + * This is only useful when the bootmem allocator has already been torn
> + * down, but we are still initializing the system. Pages are given directly
> + * to the page allocator, no bootmem metadata is updated because it is gone.
> + */
> +void __init free_bootmem_late(unsigned long addr, unsigned long size)
> +{
> + unsigned long cursor, end;
> +
> + kmemleak_free_part(__va(addr), size);
> +
> + cursor = PFN_UP(addr);
> + end = PFN_DOWN(addr + size);
> +
> + for (; cursor < end; cursor++) {
> + __free_pages_bootmem(pfn_to_page(cursor), 0);
> + totalram_pages++;
> + }
> +}

I find it a bit weird that free_all_bootmem() callers have to take
care of totalram_pages while this function does the accounting on its
own.

And I think the function is more logically placed right below
free_bootmem(), like you did in the header.

These are no show-stoppers for me, though, and otherwise the patch
looks simple and straight-forward. Feel free to add

Reviewed-by: Johannes Weiner <hannes.DeleteThis@cmpxchg.org>

Thanks!
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo.DeleteThis@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to top
Login to vote
FUJITA Tomonori

External


Since: Dec 13, 2006
Posts: 126



(Msg. 15) Posted: Tue Nov 10, 2009 7:20 am
Post subject: Re: [PATCH v2 0/9] x86: handle HW IOMMU initialization failure gracefully [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Tue, 10 Nov 2009 12:55:55 +0100
Ingo Molnar <mingo DeleteThis @elte.hu> wrote:

>
> hm, one of the swiotlb patches caused this bootup crash:

Sorry about that. I totally forgot about x86_32.

the following patch fixes this? Sorry that I'm away from the workplace
and can't test it.

diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index a234e63..63eebee 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -129,6 +129,8 @@ void __init pci_iommu_alloc(void)
#ifdef CONFIG_X86_64
/* free the range so iommu could get some range less than 4G */
dma32_free_bootmem();
+#else
+ dma_ops = &nommu_dma_ops;
#endif
pci_swiotlb_init();
if (use_swiotlb)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo DeleteThis @vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to top
Login to vote
Display posts from previous:   
Related Topics:
[PATCH] DRM: handle pci_enable_device failure - Signed-off-by: Jeff Garzik <jeff@garzik.org> diff --git a/drivers/char/drm/drm_stub.c b/drivers/char/drm/drm_stu...

[PATCH 3/3] SPARC: Handle request_irq() failure - Signed-off-by: Monakhov Dmitriy <dmonakhov@openvz.org> --- drivers/sbus/char/uctrl.c | 8 +++++++- 1 files ch...

[PATCH] 3c59x: Handle pci_enable_device() failure while re.. - Handle pci_enable_device() failure while resuming, we can safely exit here. Signed-off-by: Monakhov Dmitriy..

[PATCH] libata: handle ata_pci_device_do_resume() failure .. - Since commit:553c4aa630af7bc885e056d0436e4eb7f238579b ata_pci_device_do_resume() can return error code, all callers was...

[PATCH] floppy: handle device_create_file() failure while .. - This patch kills the "ignoring return value of 'device_create_file'" warning message. Signed-off-by: Monakho...

[PATCH] MPT fusion: handle mpt_resume() failure while resu.. - Since mpt-fusion-handle-pci-layer-error-on-resume.patch function mpt_resume() can return error code. Signed-off-by:..
       Soft32 Home -> Linux -> Kernel All times are: Pacific Time (US & Canada) (change)
Goto page 1, 2
Page 1 of 2

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Categories:
 Windows
  Linux
 Mac
 PDA


[ Contact us | Terms of Service/Privacy Policy ]