aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/powerpc/Kconfig1
-rw-r--r--arch/powerpc/kernel/btext.c3
-rw-r--r--arch/powerpc/kernel/crash.c3
-rw-r--r--arch/powerpc/kernel/crash_dump.c3
-rw-r--r--arch/powerpc/kernel/machine_kexec.c3
-rw-r--r--arch/powerpc/kernel/prom.c2
-rw-r--r--arch/powerpc/kernel/rtas.c2
-rw-r--r--arch/powerpc/kernel/setup-common.c2
-rw-r--r--arch/powerpc/kernel/setup_64.c2
-rw-r--r--arch/powerpc/kernel/vdso.c3
-rw-r--r--arch/powerpc/mm/Makefile2
-rw-r--r--arch/powerpc/mm/hash_utils_64.c3
-rw-r--r--arch/powerpc/mm/init_32.c2
-rw-r--r--arch/powerpc/mm/init_64.c2
-rw-r--r--arch/powerpc/mm/mem.c2
-rw-r--r--arch/powerpc/mm/numa.c3
-rw-r--r--arch/powerpc/mm/ppc_mmu_32.c2
-rw-r--r--arch/powerpc/mm/stab.c4
-rw-r--r--arch/powerpc/platforms/cell/iommu.c2
-rw-r--r--arch/powerpc/platforms/maple/setup.c2
-rw-r--r--arch/powerpc/platforms/powermac/setup.c2
-rw-r--r--arch/powerpc/platforms/ps3/htab.c3
-rw-r--r--arch/powerpc/platforms/ps3/mm.c3
-rw-r--r--arch/powerpc/platforms/ps3/os-area.c3
-rw-r--r--arch/powerpc/sysdev/dart_iommu.c2
-rw-r--r--arch/sparc64/Kconfig1
-rw-r--r--include/asm-powerpc/abs_addr.h3
-rw-r--r--include/asm-powerpc/lmb.h82
-rw-r--r--include/asm-sparc64/lmb.h10
-rw-r--r--include/linux/lmb.h83
-rw-r--r--lib/Kconfig3
-rw-r--r--lib/Makefile2
-rw-r--r--lib/lmb.c (renamed from arch/powerpc/mm/lmb.c)141
33 files changed, 223 insertions, 163 deletions
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 5b8d8382b76..e4e13e0bca1 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -90,6 +90,7 @@ config PPC
90 select HAVE_IDE 90 select HAVE_IDE
91 select HAVE_OPROFILE 91 select HAVE_OPROFILE
92 select HAVE_KPROBES 92 select HAVE_KPROBES
93 select HAVE_LMB
93 94
94config EARLY_PRINTK 95config EARLY_PRINTK
95 bool 96 bool
diff --git a/arch/powerpc/kernel/btext.c b/arch/powerpc/kernel/btext.c
index 80e2eef05b2..9f937774549 100644
--- a/arch/powerpc/kernel/btext.c
+++ b/arch/powerpc/kernel/btext.c
@@ -7,6 +7,7 @@
7#include <linux/string.h> 7#include <linux/string.h>
8#include <linux/init.h> 8#include <linux/init.h>
9#include <linux/module.h> 9#include <linux/module.h>
10#include <linux/lmb.h>
10 11
11#include <asm/sections.h> 12#include <asm/sections.h>
12#include <asm/prom.h> 13#include <asm/prom.h>
@@ -15,7 +16,7 @@
15#include <asm/mmu.h> 16#include <asm/mmu.h>
16#include <asm/pgtable.h> 17#include <asm/pgtable.h>
17#include <asm/io.h> 18#include <asm/io.h>
18#include <asm/lmb.h> 19#include <asm/prom.h>
19#include <asm/processor.h> 20#include <asm/processor.h>
20#include <asm/udbg.h> 21#include <asm/udbg.h>
21 22
diff --git a/arch/powerpc/kernel/crash.c b/arch/powerpc/kernel/crash.c
index 571132ed12c..eae401de3f7 100644
--- a/arch/powerpc/kernel/crash.c
+++ b/arch/powerpc/kernel/crash.c
@@ -24,12 +24,13 @@
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/irq.h> 25#include <linux/irq.h>
26#include <linux/types.h> 26#include <linux/types.h>
27#include <linux/lmb.h>
27 28
28#include <asm/processor.h> 29#include <asm/processor.h>
29#include <asm/machdep.h> 30#include <asm/machdep.h>
30#include <asm/kexec.h> 31#include <asm/kexec.h>
31#include <asm/kdump.h> 32#include <asm/kdump.h>
32#include <asm/lmb.h> 33#include <asm/prom.h>
33#include <asm/firmware.h> 34#include <asm/firmware.h>
34#include <asm/smp.h> 35#include <asm/smp.h>
35#include <asm/system.h> 36#include <asm/system.h>
diff --git a/arch/powerpc/kernel/crash_dump.c b/arch/powerpc/kernel/crash_dump.c
index 29ff77c468a..9ee3c5278db 100644
--- a/arch/powerpc/kernel/crash_dump.c
+++ b/arch/powerpc/kernel/crash_dump.c
@@ -13,8 +13,9 @@
13 13
14#include <linux/crash_dump.h> 14#include <linux/crash_dump.h>
15#include <linux/bootmem.h> 15#include <linux/bootmem.h>
16#include <linux/lmb.h>
16#include <asm/kdump.h> 17#include <asm/kdump.h>
17#include <asm/lmb.h> 18#include <asm/prom.h>
18#include <asm/firmware.h> 19#include <asm/firmware.h>
19#include <asm/uaccess.h> 20#include <asm/uaccess.h>
20 21
diff --git a/arch/powerpc/kernel/machine_kexec.c b/arch/powerpc/kernel/machine_kexec.c
index c0c8e8c3ced..2d202f274e7 100644
--- a/arch/powerpc/kernel/machine_kexec.c
+++ b/arch/powerpc/kernel/machine_kexec.c
@@ -12,8 +12,9 @@
12#include <linux/kexec.h> 12#include <linux/kexec.h>
13#include <linux/reboot.h> 13#include <linux/reboot.h>
14#include <linux/threads.h> 14#include <linux/threads.h>
15#include <linux/lmb.h>
15#include <asm/machdep.h> 16#include <asm/machdep.h>
16#include <asm/lmb.h> 17#include <asm/prom.h>
17 18
18void machine_crash_shutdown(struct pt_regs *regs) 19void machine_crash_shutdown(struct pt_regs *regs)
19{ 20{
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index eac97f48b9b..ff600ef0b4d 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -31,10 +31,10 @@
31#include <linux/kexec.h> 31#include <linux/kexec.h>
32#include <linux/debugfs.h> 32#include <linux/debugfs.h>
33#include <linux/irq.h> 33#include <linux/irq.h>
34#include <linux/lmb.h>
34 35
35#include <asm/prom.h> 36#include <asm/prom.h>
36#include <asm/rtas.h> 37#include <asm/rtas.h>
37#include <asm/lmb.h>
38#include <asm/page.h> 38#include <asm/page.h>
39#include <asm/processor.h> 39#include <asm/processor.h>
40#include <asm/irq.h> 40#include <asm/irq.h>
diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
index 52e95c2158c..e2e78d967f3 100644
--- a/arch/powerpc/kernel/rtas.c
+++ b/arch/powerpc/kernel/rtas.c
@@ -22,6 +22,7 @@
22#include <linux/smp.h> 22#include <linux/smp.h>
23#include <linux/completion.h> 23#include <linux/completion.h>
24#include <linux/cpumask.h> 24#include <linux/cpumask.h>
25#include <linux/lmb.h>
25 26
26#include <asm/prom.h> 27#include <asm/prom.h>
27#include <asm/rtas.h> 28#include <asm/rtas.h>
@@ -34,7 +35,6 @@
34#include <asm/system.h> 35#include <asm/system.h>
35#include <asm/delay.h> 36#include <asm/delay.h>
36#include <asm/uaccess.h> 37#include <asm/uaccess.h>
37#include <asm/lmb.h>
38#include <asm/udbg.h> 38#include <asm/udbg.h>
39#include <asm/syscalls.h> 39#include <asm/syscalls.h>
40#include <asm/smp.h> 40#include <asm/smp.h>
diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
index 6adb5a1e98b..12cc41c16b0 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -34,6 +34,7 @@
34#include <linux/serial_8250.h> 34#include <linux/serial_8250.h>
35#include <linux/debugfs.h> 35#include <linux/debugfs.h>
36#include <linux/percpu.h> 36#include <linux/percpu.h>
37#include <linux/lmb.h>
37#include <asm/io.h> 38#include <asm/io.h>
38#include <asm/prom.h> 39#include <asm/prom.h>
39#include <asm/processor.h> 40#include <asm/processor.h>
@@ -56,7 +57,6 @@
56#include <asm/cache.h> 57#include <asm/cache.h>
57#include <asm/page.h> 58#include <asm/page.h>
58#include <asm/mmu.h> 59#include <asm/mmu.h>
59#include <asm/lmb.h>
60#include <asm/xmon.h> 60#include <asm/xmon.h>
61#include <asm/cputhreads.h> 61#include <asm/cputhreads.h>
62 62
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index 3b1529c103e..2c2d8315193 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -33,6 +33,7 @@
33#include <linux/serial_8250.h> 33#include <linux/serial_8250.h>
34#include <linux/bootmem.h> 34#include <linux/bootmem.h>
35#include <linux/pci.h> 35#include <linux/pci.h>
36#include <linux/lmb.h>
36#include <asm/io.h> 37#include <asm/io.h>
37#include <asm/kdump.h> 38#include <asm/kdump.h>
38#include <asm/prom.h> 39#include <asm/prom.h>
@@ -55,7 +56,6 @@
55#include <asm/cache.h> 56#include <asm/cache.h>
56#include <asm/page.h> 57#include <asm/page.h>
57#include <asm/mmu.h> 58#include <asm/mmu.h>
58#include <asm/lmb.h>
59#include <asm/firmware.h> 59#include <asm/firmware.h>
60#include <asm/xmon.h> 60#include <asm/xmon.h>
61#include <asm/udbg.h> 61#include <asm/udbg.h>
diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
index d3437c4c4a6..c21a626af67 100644
--- a/arch/powerpc/kernel/vdso.c
+++ b/arch/powerpc/kernel/vdso.c
@@ -21,13 +21,14 @@
21#include <linux/elf.h> 21#include <linux/elf.h>
22#include <linux/security.h> 22#include <linux/security.h>
23#include <linux/bootmem.h> 23#include <linux/bootmem.h>
24#include <linux/lmb.h>
24 25
25#include <asm/pgtable.h> 26#include <asm/pgtable.h>
26#include <asm/system.h> 27#include <asm/system.h>
27#include <asm/processor.h> 28#include <asm/processor.h>
28#include <asm/mmu.h> 29#include <asm/mmu.h>
29#include <asm/mmu_context.h> 30#include <asm/mmu_context.h>
30#include <asm/lmb.h> 31#include <asm/prom.h>
31#include <asm/machdep.h> 32#include <asm/machdep.h>
32#include <asm/cputable.h> 33#include <asm/cputable.h>
33#include <asm/sections.h> 34#include <asm/sections.h>
diff --git a/arch/powerpc/mm/Makefile b/arch/powerpc/mm/Makefile
index 41649a5d360..1c00e0196f6 100644
--- a/arch/powerpc/mm/Makefile
+++ b/arch/powerpc/mm/Makefile
@@ -6,7 +6,7 @@ ifeq ($(CONFIG_PPC64),y)
6EXTRA_CFLAGS += -mno-minimal-toc 6EXTRA_CFLAGS += -mno-minimal-toc
7endif 7endif
8 8
9obj-y := fault.o mem.o lmb.o \ 9obj-y := fault.o mem.o \
10 init_$(CONFIG_WORD_SIZE).o \ 10 init_$(CONFIG_WORD_SIZE).o \
11 pgtable_$(CONFIG_WORD_SIZE).o \ 11 pgtable_$(CONFIG_WORD_SIZE).o \
12 mmu_context_$(CONFIG_WORD_SIZE).o 12 mmu_context_$(CONFIG_WORD_SIZE).o
diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c
index 32f416175db..73b78486abf 100644
--- a/arch/powerpc/mm/hash_utils_64.c
+++ b/arch/powerpc/mm/hash_utils_64.c
@@ -31,6 +31,7 @@
31#include <linux/cache.h> 31#include <linux/cache.h>
32#include <linux/init.h> 32#include <linux/init.h>
33#include <linux/signal.h> 33#include <linux/signal.h>
34#include <linux/lmb.h>
34 35
35#include <asm/processor.h> 36#include <asm/processor.h>
36#include <asm/pgtable.h> 37#include <asm/pgtable.h>
@@ -41,7 +42,7 @@
41#include <asm/system.h> 42#include <asm/system.h>
42#include <asm/uaccess.h> 43#include <asm/uaccess.h>
43#include <asm/machdep.h> 44#include <asm/machdep.h>
44#include <asm/lmb.h> 45#include <asm/prom.h>
45#include <asm/abs_addr.h> 46#include <asm/abs_addr.h>
46#include <asm/tlbflush.h> 47#include <asm/tlbflush.h>
47#include <asm/io.h> 48#include <asm/io.h>
diff --git a/arch/powerpc/mm/init_32.c b/arch/powerpc/mm/init_32.c
index 977cb1ee5e7..59a725b8ece 100644
--- a/arch/powerpc/mm/init_32.c
+++ b/arch/powerpc/mm/init_32.c
@@ -30,6 +30,7 @@
30#include <linux/highmem.h> 30#include <linux/highmem.h>
31#include <linux/initrd.h> 31#include <linux/initrd.h>
32#include <linux/pagemap.h> 32#include <linux/pagemap.h>
33#include <linux/lmb.h>
33 34
34#include <asm/pgalloc.h> 35#include <asm/pgalloc.h>
35#include <asm/prom.h> 36#include <asm/prom.h>
@@ -41,7 +42,6 @@
41#include <asm/machdep.h> 42#include <asm/machdep.h>
42#include <asm/btext.h> 43#include <asm/btext.h>
43#include <asm/tlb.h> 44#include <asm/tlb.h>
44#include <asm/lmb.h>
45#include <asm/sections.h> 45#include <asm/sections.h>
46 46
47#include "mmu_decl.h" 47#include "mmu_decl.h"
diff --git a/arch/powerpc/mm/init_64.c b/arch/powerpc/mm/init_64.c
index c0f5cff7703..abeb0eb7931 100644
--- a/arch/powerpc/mm/init_64.c
+++ b/arch/powerpc/mm/init_64.c
@@ -38,11 +38,11 @@
38#include <linux/nodemask.h> 38#include <linux/nodemask.h>
39#include <linux/module.h> 39#include <linux/module.h>
40#include <linux/poison.h> 40#include <linux/poison.h>
41#include <linux/lmb.h>
41 42
42#include <asm/pgalloc.h> 43#include <asm/pgalloc.h>
43#include <asm/page.h> 44#include <asm/page.h>
44#include <asm/prom.h> 45#include <asm/prom.h>
45#include <asm/lmb.h>
46#include <asm/rtas.h> 46#include <asm/rtas.h>
47#include <asm/io.h> 47#include <asm/io.h>
48#include <asm/mmu_context.h> 48#include <asm/mmu_context.h>
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index be5c506779a..60c019cdc69 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -31,6 +31,7 @@
31#include <linux/initrd.h> 31#include <linux/initrd.h>
32#include <linux/pagemap.h> 32#include <linux/pagemap.h>
33#include <linux/suspend.h> 33#include <linux/suspend.h>
34#include <linux/lmb.h>
34 35
35#include <asm/pgalloc.h> 36#include <asm/pgalloc.h>
36#include <asm/prom.h> 37#include <asm/prom.h>
@@ -42,7 +43,6 @@
42#include <asm/machdep.h> 43#include <asm/machdep.h>
43#include <asm/btext.h> 44#include <asm/btext.h>
44#include <asm/tlb.h> 45#include <asm/tlb.h>
45#include <asm/lmb.h>
46#include <asm/sections.h> 46#include <asm/sections.h>
47#include <asm/vdso.h> 47#include <asm/vdso.h>
48 48
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index a300d254aac..1efd631211e 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -17,8 +17,9 @@
17#include <linux/nodemask.h> 17#include <linux/nodemask.h>
18#include <linux/cpu.h> 18#include <linux/cpu.h>
19#include <linux/notifier.h> 19#include <linux/notifier.h>
20#include <linux/lmb.h>
20#include <asm/sparsemem.h> 21#include <asm/sparsemem.h>
21#include <asm/lmb.h> 22#include <asm/prom.h>
22#include <asm/system.h> 23#include <asm/system.h>
23#include <asm/smp.h> 24#include <asm/smp.h>
24 25
diff --git a/arch/powerpc/mm/ppc_mmu_32.c b/arch/powerpc/mm/ppc_mmu_32.c
index 5c45d474cfc..72de3c79210 100644
--- a/arch/powerpc/mm/ppc_mmu_32.c
+++ b/arch/powerpc/mm/ppc_mmu_32.c
@@ -26,11 +26,11 @@
26#include <linux/mm.h> 26#include <linux/mm.h>
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/highmem.h> 28#include <linux/highmem.h>
29#include <linux/lmb.h>
29 30
30#include <asm/prom.h> 31#include <asm/prom.h>
31#include <asm/mmu.h> 32#include <asm/mmu.h>
32#include <asm/machdep.h> 33#include <asm/machdep.h>
33#include <asm/lmb.h>
34 34
35#include "mmu_decl.h" 35#include "mmu_decl.h"
36 36
diff --git a/arch/powerpc/mm/stab.c b/arch/powerpc/mm/stab.c
index 50448d5de9d..efbbd13d93e 100644
--- a/arch/powerpc/mm/stab.c
+++ b/arch/powerpc/mm/stab.c
@@ -12,12 +12,14 @@
12 * 2 of the License, or (at your option) any later version. 12 * 2 of the License, or (at your option) any later version.
13 */ 13 */
14 14
15#include <linux/lmb.h>
16
15#include <asm/pgtable.h> 17#include <asm/pgtable.h>
16#include <asm/mmu.h> 18#include <asm/mmu.h>
17#include <asm/mmu_context.h> 19#include <asm/mmu_context.h>
18#include <asm/paca.h> 20#include <asm/paca.h>
19#include <asm/cputable.h> 21#include <asm/cputable.h>
20#include <asm/lmb.h> 22#include <asm/prom.h>
21#include <asm/abs_addr.h> 23#include <asm/abs_addr.h>
22#include <asm/firmware.h> 24#include <asm/firmware.h>
23#include <asm/iseries/hv_call.h> 25#include <asm/iseries/hv_call.h>
diff --git a/arch/powerpc/platforms/cell/iommu.c b/arch/powerpc/platforms/cell/iommu.c
index edab631a8dc..61381586895 100644
--- a/arch/powerpc/platforms/cell/iommu.c
+++ b/arch/powerpc/platforms/cell/iommu.c
@@ -28,13 +28,13 @@
28#include <linux/notifier.h> 28#include <linux/notifier.h>
29#include <linux/of.h> 29#include <linux/of.h>
30#include <linux/of_platform.h> 30#include <linux/of_platform.h>
31#include <linux/lmb.h>
31 32
32#include <asm/prom.h> 33#include <asm/prom.h>
33#include <asm/iommu.h> 34#include <asm/iommu.h>
34#include <asm/machdep.h> 35#include <asm/machdep.h>
35#include <asm/pci-bridge.h> 36#include <asm/pci-bridge.h>
36#include <asm/udbg.h> 37#include <asm/udbg.h>
37#include <asm/lmb.h>
38#include <asm/firmware.h> 38#include <asm/firmware.h>
39#include <asm/cell-regs.h> 39#include <asm/cell-regs.h>
40 40
diff --git a/arch/powerpc/platforms/maple/setup.c b/arch/powerpc/platforms/maple/setup.c
index 3ce2d73b417..dadf33b5c09 100644
--- a/arch/powerpc/platforms/maple/setup.c
+++ b/arch/powerpc/platforms/maple/setup.c
@@ -43,6 +43,7 @@
43#include <linux/smp.h> 43#include <linux/smp.h>
44#include <linux/bitops.h> 44#include <linux/bitops.h>
45#include <linux/of_device.h> 45#include <linux/of_device.h>
46#include <linux/lmb.h>
46 47
47#include <asm/processor.h> 48#include <asm/processor.h>
48#include <asm/sections.h> 49#include <asm/sections.h>
@@ -57,7 +58,6 @@
57#include <asm/dma.h> 58#include <asm/dma.h>
58#include <asm/cputable.h> 59#include <asm/cputable.h>
59#include <asm/time.h> 60#include <asm/time.h>
60#include <asm/lmb.h>
61#include <asm/mpic.h> 61#include <asm/mpic.h>
62#include <asm/rtas.h> 62#include <asm/rtas.h>
63#include <asm/udbg.h> 63#include <asm/udbg.h>
diff --git a/arch/powerpc/platforms/powermac/setup.c b/arch/powerpc/platforms/powermac/setup.c
index 36ff1b6b7fa..59404baf911 100644
--- a/arch/powerpc/platforms/powermac/setup.c
+++ b/arch/powerpc/platforms/powermac/setup.c
@@ -53,6 +53,7 @@
53#include <linux/suspend.h> 53#include <linux/suspend.h>
54#include <linux/of_device.h> 54#include <linux/of_device.h>
55#include <linux/of_platform.h> 55#include <linux/of_platform.h>
56#include <linux/lmb.h>
56 57
57#include <asm/reg.h> 58#include <asm/reg.h>
58#include <asm/sections.h> 59#include <asm/sections.h>
@@ -74,7 +75,6 @@
74#include <asm/iommu.h> 75#include <asm/iommu.h>
75#include <asm/smu.h> 76#include <asm/smu.h>
76#include <asm/pmc.h> 77#include <asm/pmc.h>
77#include <asm/lmb.h>
78#include <asm/udbg.h> 78#include <asm/udbg.h>
79 79
80#include "pmac.h" 80#include "pmac.h"
diff --git a/arch/powerpc/platforms/ps3/htab.c b/arch/powerpc/platforms/ps3/htab.c
index 7382f195c4f..1cf901fa903 100644
--- a/arch/powerpc/platforms/ps3/htab.c
+++ b/arch/powerpc/platforms/ps3/htab.c
@@ -19,9 +19,10 @@
19 */ 19 */
20 20
21#include <linux/kernel.h> 21#include <linux/kernel.h>
22#include <linux/lmb.h>
22 23
23#include <asm/machdep.h> 24#include <asm/machdep.h>
24#include <asm/lmb.h> 25#include <asm/prom.h>
25#include <asm/udbg.h> 26#include <asm/udbg.h>
26#include <asm/lv1call.h> 27#include <asm/lv1call.h>
27#include <asm/ps3fb.h> 28#include <asm/ps3fb.h>
diff --git a/arch/powerpc/platforms/ps3/mm.c b/arch/powerpc/platforms/ps3/mm.c
index 68900476c84..5b3fb2b321a 100644
--- a/arch/powerpc/platforms/ps3/mm.c
+++ b/arch/powerpc/platforms/ps3/mm.c
@@ -21,9 +21,10 @@
21#include <linux/kernel.h> 21#include <linux/kernel.h>
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/memory_hotplug.h> 23#include <linux/memory_hotplug.h>
24#include <linux/lmb.h>
24 25
25#include <asm/firmware.h> 26#include <asm/firmware.h>
26#include <asm/lmb.h> 27#include <asm/prom.h>
27#include <asm/udbg.h> 28#include <asm/udbg.h>
28#include <asm/lv1call.h> 29#include <asm/lv1call.h>
29 30
diff --git a/arch/powerpc/platforms/ps3/os-area.c b/arch/powerpc/platforms/ps3/os-area.c
index b9ea09d9d2f..c73379ec914 100644
--- a/arch/powerpc/platforms/ps3/os-area.c
+++ b/arch/powerpc/platforms/ps3/os-area.c
@@ -24,8 +24,9 @@
24#include <linux/fs.h> 24#include <linux/fs.h>
25#include <linux/syscalls.h> 25#include <linux/syscalls.h>
26#include <linux/ctype.h> 26#include <linux/ctype.h>
27#include <linux/lmb.h>
27 28
28#include <asm/lmb.h> 29#include <asm/prom.h>
29 30
30#include "platform.h" 31#include "platform.h"
31 32
diff --git a/arch/powerpc/sysdev/dart_iommu.c b/arch/powerpc/sysdev/dart_iommu.c
index e0e24b01e3a..005c2ecf976 100644
--- a/arch/powerpc/sysdev/dart_iommu.c
+++ b/arch/powerpc/sysdev/dart_iommu.c
@@ -37,6 +37,7 @@
37#include <linux/dma-mapping.h> 37#include <linux/dma-mapping.h>
38#include <linux/vmalloc.h> 38#include <linux/vmalloc.h>
39#include <linux/suspend.h> 39#include <linux/suspend.h>
40#include <linux/lmb.h>
40#include <asm/io.h> 41#include <asm/io.h>
41#include <asm/prom.h> 42#include <asm/prom.h>
42#include <asm/iommu.h> 43#include <asm/iommu.h>
@@ -44,7 +45,6 @@
44#include <asm/machdep.h> 45#include <asm/machdep.h>
45#include <asm/abs_addr.h> 46#include <asm/abs_addr.h>
46#include <asm/cacheflush.h> 47#include <asm/cacheflush.h>
47#include <asm/lmb.h>
48#include <asm/ppc-pci.h> 48#include <asm/ppc-pci.h>
49 49
50#include "dart.h" 50#include "dart.h"
diff --git a/arch/sparc64/Kconfig b/arch/sparc64/Kconfig
index 3af378ddb6a..b18d24d249f 100644
--- a/arch/sparc64/Kconfig
+++ b/arch/sparc64/Kconfig
@@ -15,6 +15,7 @@ config SPARC64
15 bool 15 bool
16 default y 16 default y
17 select HAVE_IDE 17 select HAVE_IDE
18 select HAVE_LMB
18 help 19 help
19 SPARC is a family of RISC microprocessors designed and marketed by 20 SPARC is a family of RISC microprocessors designed and marketed by
20 Sun Microsystems, incorporated. This port covers the newer 64-bit 21 Sun Microsystems, incorporated. This port covers the newer 64-bit
diff --git a/include/asm-powerpc/abs_addr.h b/include/asm-powerpc/abs_addr.h
index 4aa220718b1..98324c5a828 100644
--- a/include/asm-powerpc/abs_addr.h
+++ b/include/asm-powerpc/abs_addr.h
@@ -12,10 +12,11 @@
12 * 2 of the License, or (at your option) any later version. 12 * 2 of the License, or (at your option) any later version.
13 */ 13 */
14 14
15#include <linux/lmb.h>
16
15#include <asm/types.h> 17#include <asm/types.h>
16#include <asm/page.h> 18#include <asm/page.h>
17#include <asm/prom.h> 19#include <asm/prom.h>
18#include <asm/lmb.h>
19#include <asm/firmware.h> 20#include <asm/firmware.h>
20 21
21struct mschunks_map { 22struct mschunks_map {
diff --git a/include/asm-powerpc/lmb.h b/include/asm-powerpc/lmb.h
index 5d1dc48a0bb..028184b6a16 100644
--- a/include/asm-powerpc/lmb.h
+++ b/include/asm-powerpc/lmb.h
@@ -1,81 +1,15 @@
1#ifndef _ASM_POWERPC_LMB_H 1#ifndef _ASM_POWERPC_LMB_H
2#define _ASM_POWERPC_LMB_H 2#define _ASM_POWERPC_LMB_H
3#ifdef __KERNEL__
4 3
5/* 4#include <asm/udbg.h>
6 * Definitions for talking to the Open Firmware PROM on
7 * Power Macintosh computers.
8 *
9 * Copyright (C) 2001 Peter Bergner, IBM Corp.
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version
14 * 2 of the License, or (at your option) any later version.
15 */
16 5
17#include <linux/init.h> 6#define LMB_DBG(fmt...) udbg_printf(fmt)
18#include <asm/prom.h>
19 7
20#define MAX_LMB_REGIONS 128 8#ifdef CONFIG_PPC32
9extern unsigned long __max_low_memory;
10#define LMB_REAL_LIMIT __max_low_memory
11#else
12#define LMB_REAL_LIMIT 0
13#endif
21 14
22struct lmb_property {
23 unsigned long base;
24 unsigned long size;
25};
26
27struct lmb_region {
28 unsigned long cnt;
29 unsigned long size;
30 struct lmb_property region[MAX_LMB_REGIONS+1];
31};
32
33struct lmb {
34 unsigned long debug;
35 unsigned long rmo_size;
36 struct lmb_region memory;
37 struct lmb_region reserved;
38};
39
40extern struct lmb lmb;
41
42extern void __init lmb_init(void);
43extern void __init lmb_analyze(void);
44extern long __init lmb_add(unsigned long base, unsigned long size);
45extern long __init lmb_reserve(unsigned long base, unsigned long size);
46extern unsigned long __init lmb_alloc(unsigned long size, unsigned long align);
47extern unsigned long __init lmb_alloc_base(unsigned long size,
48 unsigned long align, unsigned long max_addr);
49extern unsigned long __init __lmb_alloc_base(unsigned long size,
50 unsigned long align, unsigned long max_addr);
51extern unsigned long __init lmb_phys_mem_size(void);
52extern unsigned long __init lmb_end_of_DRAM(void);
53extern void __init lmb_enforce_memory_limit(unsigned long memory_limit);
54extern int __init lmb_is_reserved(unsigned long addr);
55
56extern void lmb_dump_all(void);
57
58static inline unsigned long
59lmb_size_bytes(struct lmb_region *type, unsigned long region_nr)
60{
61 return type->region[region_nr].size;
62}
63static inline unsigned long
64lmb_size_pages(struct lmb_region *type, unsigned long region_nr)
65{
66 return lmb_size_bytes(type, region_nr) >> PAGE_SHIFT;
67}
68static inline unsigned long
69lmb_start_pfn(struct lmb_region *type, unsigned long region_nr)
70{
71 return type->region[region_nr].base >> PAGE_SHIFT;
72}
73static inline unsigned long
74lmb_end_pfn(struct lmb_region *type, unsigned long region_nr)
75{
76 return lmb_start_pfn(type, region_nr) +
77 lmb_size_pages(type, region_nr);
78}
79
80#endif /* __KERNEL__ */
81#endif /* _ASM_POWERPC_LMB_H */ 15#endif /* _ASM_POWERPC_LMB_H */
diff --git a/include/asm-sparc64/lmb.h b/include/asm-sparc64/lmb.h
new file mode 100644
index 00000000000..6a352cbcf52
--- /dev/null
+++ b/include/asm-sparc64/lmb.h
@@ -0,0 +1,10 @@
1#ifndef _SPARC64_LMB_H
2#define _SPARC64_LMB_H
3
4#include <asm/oplib.h>
5
6#define LMB_DBG(fmt...) prom_printf(fmt)
7
8#define LMB_REAL_LIMIT 0
9
10#endif /* !(_SPARC64_LMB_H) */
diff --git a/include/linux/lmb.h b/include/linux/lmb.h
new file mode 100644
index 00000000000..632717c6a2b
--- /dev/null
+++ b/include/linux/lmb.h
@@ -0,0 +1,83 @@
1#ifndef _LINUX_LMB_H
2#define _LINUX_LMB_H
3#ifdef __KERNEL__
4
5/*
6 * Logical memory blocks.
7 *
8 * Copyright (C) 2001 Peter Bergner, IBM Corp.
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version
13 * 2 of the License, or (at your option) any later version.
14 */
15
16#include <linux/init.h>
17#include <linux/mm.h>
18
19#define MAX_LMB_REGIONS 128
20
21struct lmb_property {
22 u64 base;
23 u64 size;
24};
25
26struct lmb_region {
27 unsigned long cnt;
28 u64 size;
29 struct lmb_property region[MAX_LMB_REGIONS+1];
30};
31
32struct lmb {
33 unsigned long debug;
34 u64 rmo_size;
35 struct lmb_region memory;
36 struct lmb_region reserved;
37};
38
39extern struct lmb lmb;
40
41extern void __init lmb_init(void);
42extern void __init lmb_analyze(void);
43extern long __init lmb_add(u64 base, u64 size);
44extern long __init lmb_reserve(u64 base, u64 size);
45extern u64 __init lmb_alloc(u64 size, u64 align);
46extern u64 __init lmb_alloc_base(u64 size,
47 u64, u64 max_addr);
48extern u64 __init __lmb_alloc_base(u64 size,
49 u64 align, u64 max_addr);
50extern u64 __init lmb_phys_mem_size(void);
51extern u64 __init lmb_end_of_DRAM(void);
52extern void __init lmb_enforce_memory_limit(u64 memory_limit);
53extern int __init lmb_is_reserved(u64 addr);
54
55extern void lmb_dump_all(void);
56
57static inline u64
58lmb_size_bytes(struct lmb_region *type, unsigned long region_nr)
59{
60 return type->region[region_nr].size;
61}
62static inline u64
63lmb_size_pages(struct lmb_region *type, unsigned long region_nr)
64{
65 return lmb_size_bytes(type, region_nr) >> PAGE_SHIFT;
66}
67static inline u64
68lmb_start_pfn(struct lmb_region *type, unsigned long region_nr)
69{
70 return type->region[region_nr].base >> PAGE_SHIFT;
71}
72static inline u64
73lmb_end_pfn(struct lmb_region *type, unsigned long region_nr)
74{
75 return lmb_start_pfn(type, region_nr) +
76 lmb_size_pages(type, region_nr);
77}
78
79#include <asm/lmb.h>
80
81#endif /* __KERNEL__ */
82
83#endif /* _LINUX_LMB_H */
diff --git a/lib/Kconfig b/lib/Kconfig
index ba3d104994d..2d53dc092e8 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -141,4 +141,7 @@ config HAS_DMA
141config CHECK_SIGNATURE 141config CHECK_SIGNATURE
142 bool 142 bool
143 143
144config HAVE_LMB
145 boolean
146
144endmenu 147endmenu
diff --git a/lib/Makefile b/lib/Makefile
index 23de261a4c8..61bba16a0a2 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -70,6 +70,8 @@ obj-$(CONFIG_FAULT_INJECTION) += fault-inject.o
70 70
71lib-$(CONFIG_GENERIC_BUG) += bug.o 71lib-$(CONFIG_GENERIC_BUG) += bug.o
72 72
73obj-$(CONFIG_HAVE_LMB) += lmb.o
74
73hostprogs-y := gen_crc32table 75hostprogs-y := gen_crc32table
74clean-files := crc32table.h 76clean-files := crc32table.h
75 77
diff --git a/arch/powerpc/mm/lmb.c b/lib/lmb.c
index 4ce23bcf8a5..3c43b95fef4 100644
--- a/arch/powerpc/mm/lmb.c
+++ b/lib/lmb.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Peter Bergner, IBM Corp. June 2001. 4 * Peter Bergner, IBM Corp. June 2001.
5 * Copyright (C) 2001 Peter Bergner. 5 * Copyright (C) 2001 Peter Bergner.
6 * 6 *
7 * This program is free software; you can redistribute it and/or 7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License 8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 9 * as published by the Free Software Foundation; either version
@@ -13,19 +13,12 @@
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/init.h> 14#include <linux/init.h>
15#include <linux/bitops.h> 15#include <linux/bitops.h>
16#include <asm/types.h> 16#include <linux/lmb.h>
17#include <asm/page.h>
18#include <asm/prom.h>
19#include <asm/lmb.h>
20#ifdef CONFIG_PPC32
21#include "mmu_decl.h" /* for __max_low_memory */
22#endif
23 17
24#undef DEBUG 18#undef DEBUG
25 19
26#ifdef DEBUG 20#ifdef DEBUG
27#include <asm/udbg.h> 21#define DBG(fmt...) LMB_DBG(fmt)
28#define DBG(fmt...) udbg_printf(fmt)
29#else 22#else
30#define DBG(fmt...) 23#define DBG(fmt...)
31#endif 24#endif
@@ -41,33 +34,34 @@ void lmb_dump_all(void)
41 34
42 DBG("lmb_dump_all:\n"); 35 DBG("lmb_dump_all:\n");
43 DBG(" memory.cnt = 0x%lx\n", lmb.memory.cnt); 36 DBG(" memory.cnt = 0x%lx\n", lmb.memory.cnt);
44 DBG(" memory.size = 0x%lx\n", lmb.memory.size); 37 DBG(" memory.size = 0x%llx\n",
38 (unsigned long long)lmb.memory.size);
45 for (i=0; i < lmb.memory.cnt ;i++) { 39 for (i=0; i < lmb.memory.cnt ;i++) {
46 DBG(" memory.region[0x%x].base = 0x%lx\n", 40 DBG(" memory.region[0x%x].base = 0x%llx\n",
47 i, lmb.memory.region[i].base); 41 i, (unsigned long long)lmb.memory.region[i].base);
48 DBG(" .size = 0x%lx\n", 42 DBG(" .size = 0x%llx\n",
49 lmb.memory.region[i].size); 43 (unsigned long long)lmb.memory.region[i].size);
50 } 44 }
51 45
52 DBG("\n reserved.cnt = 0x%lx\n", lmb.reserved.cnt); 46 DBG("\n reserved.cnt = 0x%lx\n", lmb.reserved.cnt);
53 DBG(" reserved.size = 0x%lx\n", lmb.reserved.size); 47 DBG(" reserved.size = 0x%lx\n", lmb.reserved.size);
54 for (i=0; i < lmb.reserved.cnt ;i++) { 48 for (i=0; i < lmb.reserved.cnt ;i++) {
55 DBG(" reserved.region[0x%x].base = 0x%lx\n", 49 DBG(" reserved.region[0x%x].base = 0x%llx\n",
56 i, lmb.reserved.region[i].base); 50 i, (unsigned long long)lmb.reserved.region[i].base);
57 DBG(" .size = 0x%lx\n", 51 DBG(" .size = 0x%llx\n",
58 lmb.reserved.region[i].size); 52 (unsigned long long)lmb.reserved.region[i].size);
59 } 53 }
60#endif /* DEBUG */ 54#endif /* DEBUG */
61} 55}
62 56
63static unsigned long __init lmb_addrs_overlap(unsigned long base1, 57static unsigned long __init lmb_addrs_overlap(u64 base1,
64 unsigned long size1, unsigned long base2, unsigned long size2) 58 u64 size1, u64 base2, u64 size2)
65{ 59{
66 return ((base1 < (base2+size2)) && (base2 < (base1+size1))); 60 return ((base1 < (base2+size2)) && (base2 < (base1+size1)));
67} 61}
68 62
69static long __init lmb_addrs_adjacent(unsigned long base1, unsigned long size1, 63static long __init lmb_addrs_adjacent(u64 base1, u64 size1,
70 unsigned long base2, unsigned long size2) 64 u64 base2, u64 size2)
71{ 65{
72 if (base2 == base1 + size1) 66 if (base2 == base1 + size1)
73 return 1; 67 return 1;
@@ -80,10 +74,10 @@ static long __init lmb_addrs_adjacent(unsigned long base1, unsigned long size1,
80static long __init lmb_regions_adjacent(struct lmb_region *rgn, 74static long __init lmb_regions_adjacent(struct lmb_region *rgn,
81 unsigned long r1, unsigned long r2) 75 unsigned long r1, unsigned long r2)
82{ 76{
83 unsigned long base1 = rgn->region[r1].base; 77 u64 base1 = rgn->region[r1].base;
84 unsigned long size1 = rgn->region[r1].size; 78 u64 size1 = rgn->region[r1].size;
85 unsigned long base2 = rgn->region[r2].base; 79 u64 base2 = rgn->region[r2].base;
86 unsigned long size2 = rgn->region[r2].size; 80 u64 size2 = rgn->region[r2].size;
87 81
88 return lmb_addrs_adjacent(base1, size1, base2, size2); 82 return lmb_addrs_adjacent(base1, size1, base2, size2);
89} 83}
@@ -135,16 +129,21 @@ void __init lmb_analyze(void)
135} 129}
136 130
137/* This routine called with relocation disabled. */ 131/* This routine called with relocation disabled. */
138static long __init lmb_add_region(struct lmb_region *rgn, unsigned long base, 132static long __init lmb_add_region(struct lmb_region *rgn, u64 base, u64 size)
139 unsigned long size)
140{ 133{
141 unsigned long coalesced = 0; 134 unsigned long coalesced = 0;
142 long adjacent, i; 135 long adjacent, i;
143 136
137 if ((rgn->cnt == 1) && (rgn->region[0].size == 0)) {
138 rgn->region[0].base = base;
139 rgn->region[0].size = size;
140 return 0;
141 }
142
144 /* First try and coalesce this LMB with another. */ 143 /* First try and coalesce this LMB with another. */
145 for (i=0; i < rgn->cnt; i++) { 144 for (i=0; i < rgn->cnt; i++) {
146 unsigned long rgnbase = rgn->region[i].base; 145 u64 rgnbase = rgn->region[i].base;
147 unsigned long rgnsize = rgn->region[i].size; 146 u64 rgnsize = rgn->region[i].size;
148 147
149 if ((rgnbase == base) && (rgnsize == size)) 148 if ((rgnbase == base) && (rgnsize == size))
150 /* Already have this region, so we're done */ 149 /* Already have this region, so we're done */
@@ -185,13 +184,18 @@ static long __init lmb_add_region(struct lmb_region *rgn, unsigned long base,
185 break; 184 break;
186 } 185 }
187 } 186 }
187
188 if (base < rgn->region[0].base) {
189 rgn->region[0].base = base;
190 rgn->region[0].size = size;
191 }
188 rgn->cnt++; 192 rgn->cnt++;
189 193
190 return 0; 194 return 0;
191} 195}
192 196
193/* This routine may be called with relocation disabled. */ 197/* This routine may be called with relocation disabled. */
194long __init lmb_add(unsigned long base, unsigned long size) 198long __init lmb_add(u64 base, u64 size)
195{ 199{
196 struct lmb_region *_rgn = &(lmb.memory); 200 struct lmb_region *_rgn = &(lmb.memory);
197 201
@@ -203,7 +207,7 @@ long __init lmb_add(unsigned long base, unsigned long size)
203 207
204} 208}
205 209
206long __init lmb_reserve(unsigned long base, unsigned long size) 210long __init lmb_reserve(u64 base, u64 size)
207{ 211{
208 struct lmb_region *_rgn = &(lmb.reserved); 212 struct lmb_region *_rgn = &(lmb.reserved);
209 213
@@ -212,14 +216,14 @@ long __init lmb_reserve(unsigned long base, unsigned long size)
212 return lmb_add_region(_rgn, base, size); 216 return lmb_add_region(_rgn, base, size);
213} 217}
214 218
215long __init lmb_overlaps_region(struct lmb_region *rgn, unsigned long base, 219long __init lmb_overlaps_region(struct lmb_region *rgn, u64 base,
216 unsigned long size) 220 u64 size)
217{ 221{
218 unsigned long i; 222 unsigned long i;
219 223
220 for (i=0; i < rgn->cnt; i++) { 224 for (i=0; i < rgn->cnt; i++) {
221 unsigned long rgnbase = rgn->region[i].base; 225 u64 rgnbase = rgn->region[i].base;
222 unsigned long rgnsize = rgn->region[i].size; 226 u64 rgnsize = rgn->region[i].size;
223 if ( lmb_addrs_overlap(base,size,rgnbase,rgnsize) ) { 227 if ( lmb_addrs_overlap(base,size,rgnbase,rgnsize) ) {
224 break; 228 break;
225 } 229 }
@@ -228,54 +232,61 @@ long __init lmb_overlaps_region(struct lmb_region *rgn, unsigned long base,
228 return (i < rgn->cnt) ? i : -1; 232 return (i < rgn->cnt) ? i : -1;
229} 233}
230 234
231unsigned long __init lmb_alloc(unsigned long size, unsigned long align) 235u64 __init lmb_alloc(u64 size, u64 align)
232{ 236{
233 return lmb_alloc_base(size, align, LMB_ALLOC_ANYWHERE); 237 return lmb_alloc_base(size, align, LMB_ALLOC_ANYWHERE);
234} 238}
235 239
236unsigned long __init lmb_alloc_base(unsigned long size, unsigned long align, 240u64 __init lmb_alloc_base(u64 size, u64 align, u64 max_addr)
237 unsigned long max_addr)
238{ 241{
239 unsigned long alloc; 242 u64 alloc;
240 243
241 alloc = __lmb_alloc_base(size, align, max_addr); 244 alloc = __lmb_alloc_base(size, align, max_addr);
242 245
243 if (alloc == 0) 246 if (alloc == 0)
244 panic("ERROR: Failed to allocate 0x%lx bytes below 0x%lx.\n", 247 panic("ERROR: Failed to allocate 0x%llx bytes below 0x%llx.\n",
245 size, max_addr); 248 (unsigned long long) size, (unsigned long long) max_addr);
246 249
247 return alloc; 250 return alloc;
248} 251}
249 252
250unsigned long __init __lmb_alloc_base(unsigned long size, unsigned long align, 253static u64 lmb_align_down(u64 addr, u64 size)
251 unsigned long max_addr) 254{
255 return addr & ~(size - 1);
256}
257
258static u64 lmb_align_up(u64 addr, u64 size)
259{
260 return (addr + (size - 1)) & ~(size - 1);
261}
262
263u64 __init __lmb_alloc_base(u64 size, u64 align, u64 max_addr)
252{ 264{
253 long i, j; 265 long i, j;
254 unsigned long base = 0; 266 u64 base = 0;
255 267
256 BUG_ON(0 == size); 268 BUG_ON(0 == size);
257 269
258#ifdef CONFIG_PPC32 270 /* On some platforms, make sure we allocate lowmem */
259 /* On 32-bit, make sure we allocate lowmem */
260 if (max_addr == LMB_ALLOC_ANYWHERE) 271 if (max_addr == LMB_ALLOC_ANYWHERE)
261 max_addr = __max_low_memory; 272 max_addr = LMB_REAL_LIMIT;
262#endif 273
263 for (i = lmb.memory.cnt-1; i >= 0; i--) { 274 for (i = lmb.memory.cnt-1; i >= 0; i--) {
264 unsigned long lmbbase = lmb.memory.region[i].base; 275 u64 lmbbase = lmb.memory.region[i].base;
265 unsigned long lmbsize = lmb.memory.region[i].size; 276 u64 lmbsize = lmb.memory.region[i].size;
266 277
267 if (max_addr == LMB_ALLOC_ANYWHERE) 278 if (max_addr == LMB_ALLOC_ANYWHERE)
268 base = _ALIGN_DOWN(lmbbase + lmbsize - size, align); 279 base = lmb_align_down(lmbbase + lmbsize - size, align);
269 else if (lmbbase < max_addr) { 280 else if (lmbbase < max_addr) {
270 base = min(lmbbase + lmbsize, max_addr); 281 base = min(lmbbase + lmbsize, max_addr);
271 base = _ALIGN_DOWN(base - size, align); 282 base = lmb_align_down(base - size, align);
272 } else 283 } else
273 continue; 284 continue;
274 285
275 while ((lmbbase <= base) && 286 while ((lmbbase <= base) &&
276 ((j = lmb_overlaps_region(&lmb.reserved, base, size)) >= 0) ) 287 ((j = lmb_overlaps_region(&lmb.reserved, base, size)) >= 0) )
277 base = _ALIGN_DOWN(lmb.reserved.region[j].base - size, 288 base = lmb_align_down(lmb.reserved.region[j].base - size,
278 align); 289 align);
279 290
280 if ((base != 0) && (lmbbase <= base)) 291 if ((base != 0) && (lmbbase <= base))
281 break; 292 break;
@@ -284,18 +295,19 @@ unsigned long __init __lmb_alloc_base(unsigned long size, unsigned long align,
284 if (i < 0) 295 if (i < 0)
285 return 0; 296 return 0;
286 297
287 lmb_add_region(&lmb.reserved, base, size); 298 if (lmb_add_region(&lmb.reserved, base, lmb_align_up(size, align)) < 0)
299 return 0;
288 300
289 return base; 301 return base;
290} 302}
291 303
292/* You must call lmb_analyze() before this. */ 304/* You must call lmb_analyze() before this. */
293unsigned long __init lmb_phys_mem_size(void) 305u64 __init lmb_phys_mem_size(void)
294{ 306{
295 return lmb.memory.size; 307 return lmb.memory.size;
296} 308}
297 309
298unsigned long __init lmb_end_of_DRAM(void) 310u64 __init lmb_end_of_DRAM(void)
299{ 311{
300 int idx = lmb.memory.cnt - 1; 312 int idx = lmb.memory.cnt - 1;
301 313
@@ -303,9 +315,10 @@ unsigned long __init lmb_end_of_DRAM(void)
303} 315}
304 316
305/* You must call lmb_analyze() after this. */ 317/* You must call lmb_analyze() after this. */
306void __init lmb_enforce_memory_limit(unsigned long memory_limit) 318void __init lmb_enforce_memory_limit(u64 memory_limit)
307{ 319{
308 unsigned long i, limit; 320 unsigned long i;
321 u64 limit;
309 struct lmb_property *p; 322 struct lmb_property *p;
310 323
311 if (! memory_limit) 324 if (! memory_limit)
@@ -343,13 +356,13 @@ void __init lmb_enforce_memory_limit(unsigned long memory_limit)
343 } 356 }
344} 357}
345 358
346int __init lmb_is_reserved(unsigned long addr) 359int __init lmb_is_reserved(u64 addr)
347{ 360{
348 int i; 361 int i;
349 362
350 for (i = 0; i < lmb.reserved.cnt; i++) { 363 for (i = 0; i < lmb.reserved.cnt; i++) {
351 unsigned long upper = lmb.reserved.region[i].base + 364 u64 upper = lmb.reserved.region[i].base +
352 lmb.reserved.region[i].size - 1; 365 lmb.reserved.region[i].size - 1;
353 if ((addr >= lmb.reserved.region[i].base) && (addr <= upper)) 366 if ((addr >= lmb.reserved.region[i].base) && (addr <= upper))
354 return 1; 367 return 1;
355 } 368 }