aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/00-INDEX6
-rw-r--r--Documentation/bus-virt-phys-mapping.txt (renamed from Documentation/IO-mapping.txt)0
-rw-r--r--Documentation/kernel-parameters.txt2
-rw-r--r--MAINTAINERS1
-rw-r--r--arch/arm/include/asm/atomic.h132
-rw-r--r--arch/arm/kernel/entry-armv.S16
-rw-r--r--arch/arm/kernel/kprobes-decode.c5
-rw-r--r--arch/arm/kernel/process.c23
-rw-r--r--arch/arm/mach-ux500/clock.c2
-rw-r--r--arch/arm/mach-ux500/cpu-db5500.c1
-rw-r--r--arch/arm/mm/cache-l2x0.c5
-rw-r--r--arch/arm/tools/mach-types152
-rw-r--r--arch/microblaze/Kconfig2
-rw-r--r--arch/microblaze/include/asm/memblock.h (renamed from arch/microblaze/include/asm/lmb.h)10
-rw-r--r--arch/microblaze/kernel/prom.c14
-rw-r--r--arch/microblaze/mm/init.c40
-rw-r--r--arch/powerpc/Kconfig2
-rw-r--r--arch/powerpc/include/asm/abs_addr.h2
-rw-r--r--arch/powerpc/include/asm/cpm.h24
-rw-r--r--arch/powerpc/include/asm/cpm1.h3
-rw-r--r--arch/powerpc/include/asm/lmb.h15
-rw-r--r--arch/powerpc/include/asm/memblock.h15
-rw-r--r--arch/powerpc/kernel/btext.c2
-rw-r--r--arch/powerpc/kernel/crash.c2
-rw-r--r--arch/powerpc/kernel/crash_dump.c4
-rw-r--r--arch/powerpc/kernel/dma-swiotlb.c2
-rw-r--r--arch/powerpc/kernel/dma.c4
-rw-r--r--arch/powerpc/kernel/fsl_booke_entry_mapping.S4
-rw-r--r--arch/powerpc/kernel/machine_kexec.c12
-rw-r--r--arch/powerpc/kernel/paca.c8
-rw-r--r--arch/powerpc/kernel/prom.c62
-rw-r--r--arch/powerpc/kernel/rtas.c6
-rw-r--r--arch/powerpc/kernel/setup-common.c2
-rw-r--r--arch/powerpc/kernel/setup_32.c16
-rw-r--r--arch/powerpc/kernel/setup_64.c20
-rw-r--r--arch/powerpc/kernel/vdso.c4
-rw-r--r--arch/powerpc/mm/40x_mmu.c2
-rw-r--r--arch/powerpc/mm/hash_utils_64.c26
-rw-r--r--arch/powerpc/mm/init_32.c16
-rw-r--r--arch/powerpc/mm/init_64.c2
-rw-r--r--arch/powerpc/mm/mem.c78
-rw-r--r--arch/powerpc/mm/numa.c84
-rw-r--r--arch/powerpc/mm/pgtable_32.c6
-rw-r--r--arch/powerpc/mm/pgtable_64.c4
-rw-r--r--arch/powerpc/mm/ppc_mmu_32.c4
-rw-r--r--arch/powerpc/mm/stab.c4
-rw-r--r--arch/powerpc/mm/tlb_nohash.c4
-rw-r--r--arch/powerpc/platforms/85xx/corenet_ds.c4
-rw-r--r--arch/powerpc/platforms/85xx/mpc8536_ds.c4
-rw-r--r--arch/powerpc/platforms/85xx/mpc85xx_ds.c4
-rw-r--r--arch/powerpc/platforms/85xx/mpc85xx_mds.c4
-rw-r--r--arch/powerpc/platforms/86xx/mpc86xx_hpcn.c4
-rw-r--r--arch/powerpc/platforms/cell/iommu.c10
-rw-r--r--arch/powerpc/platforms/embedded6xx/wii.c12
-rw-r--r--arch/powerpc/platforms/maple/setup.c2
-rw-r--r--arch/powerpc/platforms/pasemi/iommu.c4
-rw-r--r--arch/powerpc/platforms/powermac/setup.c4
-rw-r--r--arch/powerpc/platforms/ps3/htab.c2
-rw-r--r--arch/powerpc/platforms/ps3/mm.c6
-rw-r--r--arch/powerpc/platforms/ps3/os-area.c4
-rw-r--r--arch/powerpc/platforms/pseries/hotplug-memory.c38
-rw-r--r--arch/powerpc/platforms/pseries/iommu.c2
-rw-r--r--arch/powerpc/platforms/pseries/phyp_dump.c4
-rw-r--r--arch/powerpc/sysdev/dart_iommu.c8
-rw-r--r--arch/powerpc/sysdev/fsl_pci.c4
-rw-r--r--arch/powerpc/sysdev/micropatch.c30
-rw-r--r--arch/sh/Kconfig2
-rw-r--r--arch/sh/include/asm/lmb.h6
-rw-r--r--arch/sh/include/asm/memblock.h6
-rw-r--r--arch/sh/kernel/machine_kexec.c18
-rw-r--r--arch/sh/kernel/setup.c8
-rw-r--r--arch/sh/mm/init.c40
-rw-r--r--arch/sh/mm/numa.c8
-rw-r--r--arch/sparc/Kconfig2
-rw-r--r--arch/sparc/configs/sparc64_defconfig49
-rw-r--r--arch/sparc/include/asm/cache.h1
-rw-r--r--arch/sparc/include/asm/lmb.h10
-rw-r--r--arch/sparc/include/asm/memblock.h10
-rw-r--r--arch/sparc/include/asm/pgtable_32.h5
-rw-r--r--arch/sparc/kernel/mdesc.c16
-rw-r--r--arch/sparc/kernel/perf_event.c1
-rw-r--r--arch/sparc/kernel/prom_64.c4
-rw-r--r--arch/sparc/kernel/sun4d_irq.c2
-rw-r--r--arch/sparc/kernel/ttable.S2
-rw-r--r--arch/sparc/mm/init_64.c54
-rw-r--r--arch/sparc/mm/srmmu.c2
-rw-r--r--arch/sparc/mm/sun4c.c3
-rw-r--r--arch/x86/include/asm/x86_init.h2
-rw-r--r--arch/x86/kernel/apic/apic.c2
-rw-r--r--arch/x86/kernel/early-quirks.c18
-rw-r--r--arch/x86/kernel/entry_64.S4
-rw-r--r--arch/x86/kernel/kprobes.c2
-rw-r--r--arch/x86/kernel/mrst.c7
-rw-r--r--arch/x86/kernel/quirks.c5
-rw-r--r--arch/x86/kernel/setup_percpu.c17
-rw-r--r--arch/x86/kernel/x86_init.c7
-rw-r--r--arch/x86/kvm/mmu.c4
-rw-r--r--arch/x86/kvm/vmx.c7
-rw-r--r--arch/x86/pci/i386.c1
-rw-r--r--arch/x86/pci/mrst.c7
-rw-r--r--crypto/ablkcipher.c2
-rw-r--r--drivers/char/sysrq.c2
-rw-r--r--drivers/clocksource/cs5535-clockevt.c2
-rw-r--r--drivers/crypto/talitos.c6
-rw-r--r--drivers/edac/Kconfig2
-rw-r--r--drivers/edac/mpc85xx_edac.c1
-rw-r--r--drivers/gpio/cs5535-gpio.c2
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c3
-rw-r--r--drivers/gpu/drm/ttm/ttm_page_alloc.c2
-rw-r--r--drivers/input/keyboard/Kconfig4
-rw-r--r--drivers/input/mouse/Kconfig2
-rw-r--r--drivers/input/mouse/synaptics.c1
-rw-r--r--drivers/input/serio/Kconfig2
-rw-r--r--drivers/input/serio/i8042-x86ia64io.h10
-rw-r--r--drivers/input/touchscreen/w90p910_ts.c2
-rw-r--r--drivers/misc/cs5535-mfgpt.c2
-rw-r--r--drivers/mmc/host/sdhci-s3c.c20
-rw-r--r--drivers/net/ibmveth.c4
-rw-r--r--drivers/net/pcmcia/axnet_cs.c7
-rw-r--r--drivers/net/r8169.c2
-rw-r--r--drivers/net/wireless/ath/ath9k/hif_usb.c8
-rw-r--r--drivers/net/wireless/hostap/hostap_pci.c1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-sta.h11
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00dev.c10
-rw-r--r--drivers/pci/setup-res.c32
-rw-r--r--drivers/pcmcia/pcmcia_resource.c4
-rw-r--r--drivers/platform/x86/intel_scu_ipc.c12
-rw-r--r--drivers/power/ds2782_battery.c2
-rw-r--r--drivers/s390/block/dasd_devmap.c4
-rw-r--r--drivers/s390/cio/chsc.c2
-rw-r--r--drivers/sbus/char/openprom.c4
-rw-r--r--drivers/serial/suncore.c4
-rw-r--r--drivers/serial/sunsu.c13
-rw-r--r--drivers/spi/spi_mpc8xxx.c22
-rw-r--r--drivers/usb/gadget/f_fs.c2
-rw-r--r--drivers/vhost/net.c13
-rw-r--r--drivers/video/aty/radeon_pm.c2
-rw-r--r--fs/btrfs/ctree.c129
-rw-r--r--fs/btrfs/ioctl.c20
-rw-r--r--fs/ceph/auth_x.c3
-rw-r--r--fs/ceph/mds_client.c35
-rw-r--r--fs/ceph/mds_client.h1
-rw-r--r--fs/ceph/messenger.c71
-rw-r--r--fs/ceph/osdmap.c1
-rw-r--r--fs/cifs/cifsfs.c6
-rw-r--r--fs/cifs/dns_resolve.c69
-rw-r--r--fs/cifs/dns_resolve.h4
-rw-r--r--fs/dcache.c2
-rw-r--r--fs/gfs2/bmap.c1
-rw-r--r--fs/gfs2/dir.c2
-rw-r--r--fs/gfs2/glock.c12
-rw-r--r--fs/gfs2/inode.c12
-rw-r--r--fs/gfs2/quota.c10
-rw-r--r--fs/gfs2/quota.h2
-rw-r--r--fs/inode.c2
-rw-r--r--fs/jbd2/journal.c15
-rw-r--r--fs/jbd2/transaction.c9
-rw-r--r--fs/jffs2/xattr.c2
-rw-r--r--fs/mbcache.c5
-rw-r--r--fs/nfs/dir.c2
-rw-r--r--fs/nfs/internal.h3
-rw-r--r--fs/ocfs2/aops.c94
-rw-r--r--fs/ocfs2/dlm/dlmdomain.c3
-rw-r--r--fs/ocfs2/dlm/dlmmaster.c22
-rw-r--r--fs/ocfs2/dlm/dlmrecovery.c2
-rw-r--r--fs/ocfs2/file.c309
-rw-r--r--fs/ocfs2/file.h6
-rw-r--r--fs/ocfs2/journal.c30
-rw-r--r--fs/ocfs2/localalloc.c7
-rw-r--r--fs/ocfs2/quota_global.c2
-rw-r--r--fs/ocfs2/quota_local.c4
-rw-r--r--fs/ocfs2/refcounttree.c12
-rw-r--r--fs/ocfs2/suballoc.c2
-rw-r--r--fs/ocfs2/xattr.c200
-rw-r--r--fs/partitions/ibm.c14
-rw-r--r--fs/quota/dquot.c2
-rw-r--r--fs/ubifs/shrinker.c2
-rw-r--r--fs/ubifs/ubifs.h2
-rw-r--r--fs/xfs/linux-2.6/xfs_buf.c5
-rw-r--r--fs/xfs/linux-2.6/xfs_super.c2
-rw-r--r--fs/xfs/linux-2.6/xfs_sync.c130
-rw-r--r--fs/xfs/linux-2.6/xfs_sync.h2
-rw-r--r--fs/xfs/linux-2.6/xfs_trace.h3
-rw-r--r--fs/xfs/quota/xfs_qm.c7
-rw-r--r--fs/xfs/xfs_mount.h2
-rw-r--r--include/linux/fdtable.h3
-rw-r--r--include/linux/i8042.h12
-rw-r--r--include/linux/jbd2.h11
-rw-r--r--include/linux/lmb.h89
-rw-r--r--include/linux/memblock.h89
-rw-r--r--include/linux/mm.h2
-rw-r--r--include/linux/pci.h1
-rw-r--r--include/linux/syscalls.h6
-rw-r--r--include/linux/sysrq.h1
-rw-r--r--include/math-emu/op-common.h2
-rw-r--r--include/net/sock.h7
-rw-r--r--ipc/sem.c46
-rw-r--r--kernel/debug/debug_core.c2
-rw-r--r--kernel/debug/gdbstub.c9
-rw-r--r--kernel/debug/kdb/kdb_main.c7
-rw-r--r--kernel/early_res.c6
-rw-r--r--lib/Kconfig3
-rw-r--r--lib/Makefile2
-rw-r--r--lib/lmb.c541
-rw-r--r--mm/Kconfig3
-rw-r--r--mm/Makefile2
-rw-r--r--mm/bootmem.c24
-rw-r--r--mm/memblock.c541
-rw-r--r--mm/page_alloc.c8
-rw-r--r--mm/page_cgroup.c7
-rw-r--r--mm/vmscan.c10
-rw-r--r--net/bluetooth/hci_conn.c5
-rw-r--r--net/bluetooth/hci_event.c2
-rw-r--r--net/bluetooth/l2cap.c14
-rw-r--r--net/bridge/br_device.c9
-rw-r--r--net/bridge/br_forward.c23
-rw-r--r--net/core/dev.c20
-rw-r--r--net/core/neighbour.c5
-rw-r--r--net/dsa/Kconfig2
-rw-r--r--net/ipv4/ipmr.c8
-rw-r--r--net/ipv4/tcp.c1
-rw-r--r--net/ipv4/tcp_output.c3
-rw-r--r--net/ipv6/mip6.c3
-rw-r--r--net/phonet/pep.c1
-rw-r--r--net/sched/act_nat.c5
-rw-r--r--net/sunrpc/auth.c2
-rw-r--r--net/xfrm/xfrm_policy.c15
-rw-r--r--sound/soc/codecs/Kconfig4
-rw-r--r--sound/soc/codecs/wm8727.c2
-rw-r--r--sound/soc/codecs/wm8776.c1
-rw-r--r--sound/soc/codecs/wm8988.c1
-rw-r--r--sound/soc/sh/fsi.c27
-rw-r--r--tools/perf/arch/sparc/Makefile4
-rw-r--r--tools/perf/arch/sparc/util/dwarf-regs.c43
-rw-r--r--tools/perf/builtin-report.c2
-rwxr-xr-xtools/perf/util/PERF-VERSION-GEN17
-rw-r--r--tools/perf/util/callchain.c35
-rw-r--r--tools/perf/util/callchain.h5
238 files changed, 2758 insertions, 1773 deletions
diff --git a/Documentation/00-INDEX b/Documentation/00-INDEX
index dd10b51b4e65..5405f7aecefc 100644
--- a/Documentation/00-INDEX
+++ b/Documentation/00-INDEX
@@ -32,8 +32,6 @@ DocBook/
32 - directory with DocBook templates etc. for kernel documentation. 32 - directory with DocBook templates etc. for kernel documentation.
33HOWTO 33HOWTO
34 - the process and procedures of how to do Linux kernel development. 34 - the process and procedures of how to do Linux kernel development.
35IO-mapping.txt
36 - how to access I/O mapped memory from within device drivers.
37IPMI.txt 35IPMI.txt
38 - info on Linux Intelligent Platform Management Interface (IPMI) Driver. 36 - info on Linux Intelligent Platform Management Interface (IPMI) Driver.
39IRQ-affinity.txt 37IRQ-affinity.txt
@@ -84,6 +82,8 @@ blockdev/
84 - info on block devices & drivers 82 - info on block devices & drivers
85btmrvl.txt 83btmrvl.txt
86 - info on Marvell Bluetooth driver usage. 84 - info on Marvell Bluetooth driver usage.
85bus-virt-phys-mapping.txt
86 - how to access I/O mapped memory from within device drivers.
87cachetlb.txt 87cachetlb.txt
88 - describes the cache/TLB flushing interfaces Linux uses. 88 - describes the cache/TLB flushing interfaces Linux uses.
89cdrom/ 89cdrom/
@@ -168,6 +168,8 @@ initrd.txt
168 - how to use the RAM disk as an initial/temporary root filesystem. 168 - how to use the RAM disk as an initial/temporary root filesystem.
169input/ 169input/
170 - info on Linux input device support. 170 - info on Linux input device support.
171io-mapping.txt
172 - description of io_mapping functions in linux/io-mapping.h
171io_ordering.txt 173io_ordering.txt
172 - info on ordering I/O writes to memory-mapped addresses. 174 - info on ordering I/O writes to memory-mapped addresses.
173ioctl/ 175ioctl/
diff --git a/Documentation/IO-mapping.txt b/Documentation/bus-virt-phys-mapping.txt
index 1b5aa10df845..1b5aa10df845 100644
--- a/Documentation/IO-mapping.txt
+++ b/Documentation/bus-virt-phys-mapping.txt
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 82d6aeb5228f..4ddb58df081e 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -1265,7 +1265,7 @@ and is between 256 and 4096 characters. It is defined in the file
1265 If there are multiple matching configurations changing 1265 If there are multiple matching configurations changing
1266 the same attribute, the last one is used. 1266 the same attribute, the last one is used.
1267 1267
1268 lmb=debug [KNL] Enable lmb debug messages. 1268 memblock=debug [KNL] Enable memblock debug messages.
1269 1269
1270 load_ramdisk= [RAM] List of ramdisks to load from floppy 1270 load_ramdisk= [RAM] List of ramdisks to load from floppy
1271 See Documentation/blockdev/ramdisk.txt. 1271 See Documentation/blockdev/ramdisk.txt.
diff --git a/MAINTAINERS b/MAINTAINERS
index 58848125b8bf..db3d0f5061f9 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5336,6 +5336,7 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-2.6.git
5336T: git git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-next-2.6.git 5336T: git git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-next-2.6.git
5337S: Maintained 5337S: Maintained
5338F: arch/sparc/ 5338F: arch/sparc/
5339F: drivers/sbus
5339 5340
5340SPARC SERIAL DRIVERS 5341SPARC SERIAL DRIVERS
5341M: "David S. Miller" <davem@davemloft.net> 5342M: "David S. Miller" <davem@davemloft.net>
diff --git a/arch/arm/include/asm/atomic.h b/arch/arm/include/asm/atomic.h
index a0162fa94564..7e79503ab89b 100644
--- a/arch/arm/include/asm/atomic.h
+++ b/arch/arm/include/asm/atomic.h
@@ -40,12 +40,12 @@ static inline void atomic_add(int i, atomic_t *v)
40 int result; 40 int result;
41 41
42 __asm__ __volatile__("@ atomic_add\n" 42 __asm__ __volatile__("@ atomic_add\n"
43"1: ldrex %0, [%2]\n" 43"1: ldrex %0, [%3]\n"
44" add %0, %0, %3\n" 44" add %0, %0, %4\n"
45" strex %1, %0, [%2]\n" 45" strex %1, %0, [%3]\n"
46" teq %1, #0\n" 46" teq %1, #0\n"
47" bne 1b" 47" bne 1b"
48 : "=&r" (result), "=&r" (tmp) 48 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
49 : "r" (&v->counter), "Ir" (i) 49 : "r" (&v->counter), "Ir" (i)
50 : "cc"); 50 : "cc");
51} 51}
@@ -58,12 +58,12 @@ static inline int atomic_add_return(int i, atomic_t *v)
58 smp_mb(); 58 smp_mb();
59 59
60 __asm__ __volatile__("@ atomic_add_return\n" 60 __asm__ __volatile__("@ atomic_add_return\n"
61"1: ldrex %0, [%2]\n" 61"1: ldrex %0, [%3]\n"
62" add %0, %0, %3\n" 62" add %0, %0, %4\n"
63" strex %1, %0, [%2]\n" 63" strex %1, %0, [%3]\n"
64" teq %1, #0\n" 64" teq %1, #0\n"
65" bne 1b" 65" bne 1b"
66 : "=&r" (result), "=&r" (tmp) 66 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
67 : "r" (&v->counter), "Ir" (i) 67 : "r" (&v->counter), "Ir" (i)
68 : "cc"); 68 : "cc");
69 69
@@ -78,12 +78,12 @@ static inline void atomic_sub(int i, atomic_t *v)
78 int result; 78 int result;
79 79
80 __asm__ __volatile__("@ atomic_sub\n" 80 __asm__ __volatile__("@ atomic_sub\n"
81"1: ldrex %0, [%2]\n" 81"1: ldrex %0, [%3]\n"
82" sub %0, %0, %3\n" 82" sub %0, %0, %4\n"
83" strex %1, %0, [%2]\n" 83" strex %1, %0, [%3]\n"
84" teq %1, #0\n" 84" teq %1, #0\n"
85" bne 1b" 85" bne 1b"
86 : "=&r" (result), "=&r" (tmp) 86 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
87 : "r" (&v->counter), "Ir" (i) 87 : "r" (&v->counter), "Ir" (i)
88 : "cc"); 88 : "cc");
89} 89}
@@ -96,12 +96,12 @@ static inline int atomic_sub_return(int i, atomic_t *v)
96 smp_mb(); 96 smp_mb();
97 97
98 __asm__ __volatile__("@ atomic_sub_return\n" 98 __asm__ __volatile__("@ atomic_sub_return\n"
99"1: ldrex %0, [%2]\n" 99"1: ldrex %0, [%3]\n"
100" sub %0, %0, %3\n" 100" sub %0, %0, %4\n"
101" strex %1, %0, [%2]\n" 101" strex %1, %0, [%3]\n"
102" teq %1, #0\n" 102" teq %1, #0\n"
103" bne 1b" 103" bne 1b"
104 : "=&r" (result), "=&r" (tmp) 104 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
105 : "r" (&v->counter), "Ir" (i) 105 : "r" (&v->counter), "Ir" (i)
106 : "cc"); 106 : "cc");
107 107
@@ -118,11 +118,11 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)
118 118
119 do { 119 do {
120 __asm__ __volatile__("@ atomic_cmpxchg\n" 120 __asm__ __volatile__("@ atomic_cmpxchg\n"
121 "ldrex %1, [%2]\n" 121 "ldrex %1, [%3]\n"
122 "mov %0, #0\n" 122 "mov %0, #0\n"
123 "teq %1, %3\n" 123 "teq %1, %4\n"
124 "strexeq %0, %4, [%2]\n" 124 "strexeq %0, %5, [%3]\n"
125 : "=&r" (res), "=&r" (oldval) 125 : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
126 : "r" (&ptr->counter), "Ir" (old), "r" (new) 126 : "r" (&ptr->counter), "Ir" (old), "r" (new)
127 : "cc"); 127 : "cc");
128 } while (res); 128 } while (res);
@@ -137,12 +137,12 @@ static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
137 unsigned long tmp, tmp2; 137 unsigned long tmp, tmp2;
138 138
139 __asm__ __volatile__("@ atomic_clear_mask\n" 139 __asm__ __volatile__("@ atomic_clear_mask\n"
140"1: ldrex %0, [%2]\n" 140"1: ldrex %0, [%3]\n"
141" bic %0, %0, %3\n" 141" bic %0, %0, %4\n"
142" strex %1, %0, [%2]\n" 142" strex %1, %0, [%3]\n"
143" teq %1, #0\n" 143" teq %1, #0\n"
144" bne 1b" 144" bne 1b"
145 : "=&r" (tmp), "=&r" (tmp2) 145 : "=&r" (tmp), "=&r" (tmp2), "+Qo" (*addr)
146 : "r" (addr), "Ir" (mask) 146 : "r" (addr), "Ir" (mask)
147 : "cc"); 147 : "cc");
148} 148}
@@ -249,7 +249,7 @@ static inline u64 atomic64_read(atomic64_t *v)
249 __asm__ __volatile__("@ atomic64_read\n" 249 __asm__ __volatile__("@ atomic64_read\n"
250" ldrexd %0, %H0, [%1]" 250" ldrexd %0, %H0, [%1]"
251 : "=&r" (result) 251 : "=&r" (result)
252 : "r" (&v->counter) 252 : "r" (&v->counter), "Qo" (v->counter)
253 ); 253 );
254 254
255 return result; 255 return result;
@@ -260,11 +260,11 @@ static inline void atomic64_set(atomic64_t *v, u64 i)
260 u64 tmp; 260 u64 tmp;
261 261
262 __asm__ __volatile__("@ atomic64_set\n" 262 __asm__ __volatile__("@ atomic64_set\n"
263"1: ldrexd %0, %H0, [%1]\n" 263"1: ldrexd %0, %H0, [%2]\n"
264" strexd %0, %2, %H2, [%1]\n" 264" strexd %0, %3, %H3, [%2]\n"
265" teq %0, #0\n" 265" teq %0, #0\n"
266" bne 1b" 266" bne 1b"
267 : "=&r" (tmp) 267 : "=&r" (tmp), "=Qo" (v->counter)
268 : "r" (&v->counter), "r" (i) 268 : "r" (&v->counter), "r" (i)
269 : "cc"); 269 : "cc");
270} 270}
@@ -275,13 +275,13 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
275 unsigned long tmp; 275 unsigned long tmp;
276 276
277 __asm__ __volatile__("@ atomic64_add\n" 277 __asm__ __volatile__("@ atomic64_add\n"
278"1: ldrexd %0, %H0, [%2]\n" 278"1: ldrexd %0, %H0, [%3]\n"
279" adds %0, %0, %3\n" 279" adds %0, %0, %4\n"
280" adc %H0, %H0, %H3\n" 280" adc %H0, %H0, %H4\n"
281" strexd %1, %0, %H0, [%2]\n" 281" strexd %1, %0, %H0, [%3]\n"
282" teq %1, #0\n" 282" teq %1, #0\n"
283" bne 1b" 283" bne 1b"
284 : "=&r" (result), "=&r" (tmp) 284 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
285 : "r" (&v->counter), "r" (i) 285 : "r" (&v->counter), "r" (i)
286 : "cc"); 286 : "cc");
287} 287}
@@ -294,13 +294,13 @@ static inline u64 atomic64_add_return(u64 i, atomic64_t *v)
294 smp_mb(); 294 smp_mb();
295 295
296 __asm__ __volatile__("@ atomic64_add_return\n" 296 __asm__ __volatile__("@ atomic64_add_return\n"
297"1: ldrexd %0, %H0, [%2]\n" 297"1: ldrexd %0, %H0, [%3]\n"
298" adds %0, %0, %3\n" 298" adds %0, %0, %4\n"
299" adc %H0, %H0, %H3\n" 299" adc %H0, %H0, %H4\n"
300" strexd %1, %0, %H0, [%2]\n" 300" strexd %1, %0, %H0, [%3]\n"
301" teq %1, #0\n" 301" teq %1, #0\n"
302" bne 1b" 302" bne 1b"
303 : "=&r" (result), "=&r" (tmp) 303 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
304 : "r" (&v->counter), "r" (i) 304 : "r" (&v->counter), "r" (i)
305 : "cc"); 305 : "cc");
306 306
@@ -315,13 +315,13 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
315 unsigned long tmp; 315 unsigned long tmp;
316 316
317 __asm__ __volatile__("@ atomic64_sub\n" 317 __asm__ __volatile__("@ atomic64_sub\n"
318"1: ldrexd %0, %H0, [%2]\n" 318"1: ldrexd %0, %H0, [%3]\n"
319" subs %0, %0, %3\n" 319" subs %0, %0, %4\n"
320" sbc %H0, %H0, %H3\n" 320" sbc %H0, %H0, %H4\n"
321" strexd %1, %0, %H0, [%2]\n" 321" strexd %1, %0, %H0, [%3]\n"
322" teq %1, #0\n" 322" teq %1, #0\n"
323" bne 1b" 323" bne 1b"
324 : "=&r" (result), "=&r" (tmp) 324 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
325 : "r" (&v->counter), "r" (i) 325 : "r" (&v->counter), "r" (i)
326 : "cc"); 326 : "cc");
327} 327}
@@ -334,13 +334,13 @@ static inline u64 atomic64_sub_return(u64 i, atomic64_t *v)
334 smp_mb(); 334 smp_mb();
335 335
336 __asm__ __volatile__("@ atomic64_sub_return\n" 336 __asm__ __volatile__("@ atomic64_sub_return\n"
337"1: ldrexd %0, %H0, [%2]\n" 337"1: ldrexd %0, %H0, [%3]\n"
338" subs %0, %0, %3\n" 338" subs %0, %0, %4\n"
339" sbc %H0, %H0, %H3\n" 339" sbc %H0, %H0, %H4\n"
340" strexd %1, %0, %H0, [%2]\n" 340" strexd %1, %0, %H0, [%3]\n"
341" teq %1, #0\n" 341" teq %1, #0\n"
342" bne 1b" 342" bne 1b"
343 : "=&r" (result), "=&r" (tmp) 343 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
344 : "r" (&v->counter), "r" (i) 344 : "r" (&v->counter), "r" (i)
345 : "cc"); 345 : "cc");
346 346
@@ -358,12 +358,12 @@ static inline u64 atomic64_cmpxchg(atomic64_t *ptr, u64 old, u64 new)
358 358
359 do { 359 do {
360 __asm__ __volatile__("@ atomic64_cmpxchg\n" 360 __asm__ __volatile__("@ atomic64_cmpxchg\n"
361 "ldrexd %1, %H1, [%2]\n" 361 "ldrexd %1, %H1, [%3]\n"
362 "mov %0, #0\n" 362 "mov %0, #0\n"
363 "teq %1, %3\n" 363 "teq %1, %4\n"
364 "teqeq %H1, %H3\n" 364 "teqeq %H1, %H4\n"
365 "strexdeq %0, %4, %H4, [%2]" 365 "strexdeq %0, %5, %H5, [%3]"
366 : "=&r" (res), "=&r" (oldval) 366 : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
367 : "r" (&ptr->counter), "r" (old), "r" (new) 367 : "r" (&ptr->counter), "r" (old), "r" (new)
368 : "cc"); 368 : "cc");
369 } while (res); 369 } while (res);
@@ -381,11 +381,11 @@ static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
381 smp_mb(); 381 smp_mb();
382 382
383 __asm__ __volatile__("@ atomic64_xchg\n" 383 __asm__ __volatile__("@ atomic64_xchg\n"
384"1: ldrexd %0, %H0, [%2]\n" 384"1: ldrexd %0, %H0, [%3]\n"
385" strexd %1, %3, %H3, [%2]\n" 385" strexd %1, %4, %H4, [%3]\n"
386" teq %1, #0\n" 386" teq %1, #0\n"
387" bne 1b" 387" bne 1b"
388 : "=&r" (result), "=&r" (tmp) 388 : "=&r" (result), "=&r" (tmp), "+Qo" (ptr->counter)
389 : "r" (&ptr->counter), "r" (new) 389 : "r" (&ptr->counter), "r" (new)
390 : "cc"); 390 : "cc");
391 391
@@ -402,16 +402,16 @@ static inline u64 atomic64_dec_if_positive(atomic64_t *v)
402 smp_mb(); 402 smp_mb();
403 403
404 __asm__ __volatile__("@ atomic64_dec_if_positive\n" 404 __asm__ __volatile__("@ atomic64_dec_if_positive\n"
405"1: ldrexd %0, %H0, [%2]\n" 405"1: ldrexd %0, %H0, [%3]\n"
406" subs %0, %0, #1\n" 406" subs %0, %0, #1\n"
407" sbc %H0, %H0, #0\n" 407" sbc %H0, %H0, #0\n"
408" teq %H0, #0\n" 408" teq %H0, #0\n"
409" bmi 2f\n" 409" bmi 2f\n"
410" strexd %1, %0, %H0, [%2]\n" 410" strexd %1, %0, %H0, [%3]\n"
411" teq %1, #0\n" 411" teq %1, #0\n"
412" bne 1b\n" 412" bne 1b\n"
413"2:" 413"2:"
414 : "=&r" (result), "=&r" (tmp) 414 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
415 : "r" (&v->counter) 415 : "r" (&v->counter)
416 : "cc"); 416 : "cc");
417 417
@@ -429,18 +429,18 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
429 smp_mb(); 429 smp_mb();
430 430
431 __asm__ __volatile__("@ atomic64_add_unless\n" 431 __asm__ __volatile__("@ atomic64_add_unless\n"
432"1: ldrexd %0, %H0, [%3]\n" 432"1: ldrexd %0, %H0, [%4]\n"
433" teq %0, %4\n" 433" teq %0, %5\n"
434" teqeq %H0, %H4\n" 434" teqeq %H0, %H5\n"
435" moveq %1, #0\n" 435" moveq %1, #0\n"
436" beq 2f\n" 436" beq 2f\n"
437" adds %0, %0, %5\n" 437" adds %0, %0, %6\n"
438" adc %H0, %H0, %H5\n" 438" adc %H0, %H0, %H6\n"
439" strexd %2, %0, %H0, [%3]\n" 439" strexd %2, %0, %H0, [%4]\n"
440" teq %2, #0\n" 440" teq %2, #0\n"
441" bne 1b\n" 441" bne 1b\n"
442"2:" 442"2:"
443 : "=&r" (val), "=&r" (ret), "=&r" (tmp) 443 : "=&r" (val), "+r" (ret), "=&r" (tmp), "+Qo" (v->counter)
444 : "r" (&v->counter), "r" (u), "r" (a) 444 : "r" (&v->counter), "r" (u), "r" (a)
445 : "cc"); 445 : "cc");
446 446
diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
index 7ee48e7f8f31..3fd7861de4d1 100644
--- a/arch/arm/kernel/entry-armv.S
+++ b/arch/arm/kernel/entry-armv.S
@@ -162,8 +162,6 @@ ENDPROC(__und_invalid)
162 @ r4 - orig_r0 (see pt_regs definition in ptrace.h) 162 @ r4 - orig_r0 (see pt_regs definition in ptrace.h)
163 @ 163 @
164 stmia r5, {r0 - r4} 164 stmia r5, {r0 - r4}
165
166 asm_trace_hardirqs_off
167 .endm 165 .endm
168 166
169 .align 5 167 .align 5
@@ -204,7 +202,7 @@ __dabt_svc:
204 @ 202 @
205 @ IRQs off again before pulling preserved data off the stack 203 @ IRQs off again before pulling preserved data off the stack
206 @ 204 @
207 disable_irq 205 disable_irq_notrace
208 206
209 @ 207 @
210 @ restore SPSR and restart the instruction 208 @ restore SPSR and restart the instruction
@@ -218,6 +216,9 @@ ENDPROC(__dabt_svc)
218__irq_svc: 216__irq_svc:
219 svc_entry 217 svc_entry
220 218
219#ifdef CONFIG_TRACE_IRQFLAGS
220 bl trace_hardirqs_off
221#endif
221#ifdef CONFIG_PREEMPT 222#ifdef CONFIG_PREEMPT
222 get_thread_info tsk 223 get_thread_info tsk
223 ldr r8, [tsk, #TI_PREEMPT] @ get preempt count 224 ldr r8, [tsk, #TI_PREEMPT] @ get preempt count
@@ -291,7 +292,7 @@ __und_svc:
291 @ 292 @
292 @ IRQs off again before pulling preserved data off the stack 293 @ IRQs off again before pulling preserved data off the stack
293 @ 294 @
2941: disable_irq 2951: disable_irq_notrace
295 296
296 @ 297 @
297 @ restore SPSR and restart the instruction 298 @ restore SPSR and restart the instruction
@@ -327,7 +328,7 @@ __pabt_svc:
327 @ 328 @
328 @ IRQs off again before pulling preserved data off the stack 329 @ IRQs off again before pulling preserved data off the stack
329 @ 330 @
330 disable_irq 331 disable_irq_notrace
331 332
332 @ 333 @
333 @ restore SPSR and restart the instruction 334 @ restore SPSR and restart the instruction
@@ -393,8 +394,6 @@ ENDPROC(__pabt_svc)
393 @ Clear FP to mark the first stack frame 394 @ Clear FP to mark the first stack frame
394 @ 395 @
395 zero_fp 396 zero_fp
396
397 asm_trace_hardirqs_off
398 .endm 397 .endm
399 398
400 .macro kuser_cmpxchg_check 399 .macro kuser_cmpxchg_check
@@ -465,9 +464,6 @@ __irq_usr:
465 THUMB( movne r0, #0 ) 464 THUMB( movne r0, #0 )
466 THUMB( strne r0, [r0] ) 465 THUMB( strne r0, [r0] )
467#endif 466#endif
468#ifdef CONFIG_TRACE_IRQFLAGS
469 bl trace_hardirqs_on
470#endif
471 467
472 mov why, #0 468 mov why, #0
473 b ret_to_user 469 b ret_to_user
diff --git a/arch/arm/kernel/kprobes-decode.c b/arch/arm/kernel/kprobes-decode.c
index da1f94906a4e..8bccbfa693ff 100644
--- a/arch/arm/kernel/kprobes-decode.c
+++ b/arch/arm/kernel/kprobes-decode.c
@@ -583,13 +583,14 @@ static void __kprobes emulate_ldr(struct kprobe *p, struct pt_regs *regs)
583{ 583{
584 insn_llret_3arg_fn_t *i_fn = (insn_llret_3arg_fn_t *)&p->ainsn.insn[0]; 584 insn_llret_3arg_fn_t *i_fn = (insn_llret_3arg_fn_t *)&p->ainsn.insn[0];
585 kprobe_opcode_t insn = p->opcode; 585 kprobe_opcode_t insn = p->opcode;
586 long ppc = (long)p->addr + 8;
586 union reg_pair fnr; 587 union reg_pair fnr;
587 int rd = (insn >> 12) & 0xf; 588 int rd = (insn >> 12) & 0xf;
588 int rn = (insn >> 16) & 0xf; 589 int rn = (insn >> 16) & 0xf;
589 int rm = insn & 0xf; 590 int rm = insn & 0xf;
590 long rdv; 591 long rdv;
591 long rnv = regs->uregs[rn]; 592 long rnv = (rn == 15) ? ppc : regs->uregs[rn];
592 long rmv = regs->uregs[rm]; /* rm/rmv may be invalid, don't care. */ 593 long rmv = (rm == 15) ? ppc : regs->uregs[rm];
593 long cpsr = regs->ARM_cpsr; 594 long cpsr = regs->ARM_cpsr;
594 595
595 fnr.dr = insnslot_llret_3arg_rflags(rnv, 0, rmv, cpsr, i_fn); 596 fnr.dr = insnslot_llret_3arg_rflags(rnv, 0, rmv, cpsr, i_fn);
diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
index acf5e6fdb6dc..a4a9cc88bec7 100644
--- a/arch/arm/kernel/process.c
+++ b/arch/arm/kernel/process.c
@@ -351,17 +351,21 @@ EXPORT_SYMBOL(dump_fpu);
351 351
352/* 352/*
353 * Shuffle the argument into the correct register before calling the 353 * Shuffle the argument into the correct register before calling the
354 * thread function. r1 is the thread argument, r2 is the pointer to 354 * thread function. r4 is the thread argument, r5 is the pointer to
355 * the thread function, and r3 points to the exit function. 355 * the thread function, and r6 points to the exit function.
356 */ 356 */
357extern void kernel_thread_helper(void); 357extern void kernel_thread_helper(void);
358asm( ".pushsection .text\n" 358asm( ".pushsection .text\n"
359" .align\n" 359" .align\n"
360" .type kernel_thread_helper, #function\n" 360" .type kernel_thread_helper, #function\n"
361"kernel_thread_helper:\n" 361"kernel_thread_helper:\n"
362" mov r0, r1\n" 362#ifdef CONFIG_TRACE_IRQFLAGS
363" mov lr, r3\n" 363" bl trace_hardirqs_on\n"
364" mov pc, r2\n" 364#endif
365" msr cpsr_c, r7\n"
366" mov r0, r4\n"
367" mov lr, r6\n"
368" mov pc, r5\n"
365" .size kernel_thread_helper, . - kernel_thread_helper\n" 369" .size kernel_thread_helper, . - kernel_thread_helper\n"
366" .popsection"); 370" .popsection");
367 371
@@ -391,11 +395,12 @@ pid_t kernel_thread(int (*fn)(void *), void *arg, unsigned long flags)
391 395
392 memset(&regs, 0, sizeof(regs)); 396 memset(&regs, 0, sizeof(regs));
393 397
394 regs.ARM_r1 = (unsigned long)arg; 398 regs.ARM_r4 = (unsigned long)arg;
395 regs.ARM_r2 = (unsigned long)fn; 399 regs.ARM_r5 = (unsigned long)fn;
396 regs.ARM_r3 = (unsigned long)kernel_thread_exit; 400 regs.ARM_r6 = (unsigned long)kernel_thread_exit;
401 regs.ARM_r7 = SVC_MODE | PSR_ENDSTATE | PSR_ISETSTATE;
397 regs.ARM_pc = (unsigned long)kernel_thread_helper; 402 regs.ARM_pc = (unsigned long)kernel_thread_helper;
398 regs.ARM_cpsr = SVC_MODE | PSR_ENDSTATE | PSR_ISETSTATE; 403 regs.ARM_cpsr = regs.ARM_r7 | PSR_I_BIT;
399 404
400 return do_fork(flags|CLONE_VM|CLONE_UNTRACED, 0, &regs, 0, NULL, NULL); 405 return do_fork(flags|CLONE_VM|CLONE_UNTRACED, 0, &regs, 0, NULL, NULL);
401} 406}
diff --git a/arch/arm/mach-ux500/clock.c b/arch/arm/mach-ux500/clock.c
index fe84b9021c7a..0a1318fc8e2b 100644
--- a/arch/arm/mach-ux500/clock.c
+++ b/arch/arm/mach-ux500/clock.c
@@ -131,7 +131,7 @@ EXPORT_SYMBOL(clk_disable);
131 */ 131 */
132static unsigned long clk_mtu_get_rate(struct clk *clk) 132static unsigned long clk_mtu_get_rate(struct clk *clk)
133{ 133{
134 void __iomem *addr = __io_address(U8500_PRCMU_BASE) 134 void __iomem *addr = __io_address(UX500_PRCMU_BASE)
135 + PRCM_TCR; 135 + PRCM_TCR;
136 u32 tcr = readl(addr); 136 u32 tcr = readl(addr);
137 int mtu = (int) clk->data; 137 int mtu = (int) clk->data;
diff --git a/arch/arm/mach-ux500/cpu-db5500.c b/arch/arm/mach-ux500/cpu-db5500.c
index 6a3ac4539f16..e9278f6d67aa 100644
--- a/arch/arm/mach-ux500/cpu-db5500.c
+++ b/arch/arm/mach-ux500/cpu-db5500.c
@@ -21,6 +21,7 @@ static struct map_desc u5500_io_desc[] __initdata = {
21 __IO_DEV_DESC(U5500_GPIO2_BASE, SZ_4K), 21 __IO_DEV_DESC(U5500_GPIO2_BASE, SZ_4K),
22 __IO_DEV_DESC(U5500_GPIO3_BASE, SZ_4K), 22 __IO_DEV_DESC(U5500_GPIO3_BASE, SZ_4K),
23 __IO_DEV_DESC(U5500_GPIO4_BASE, SZ_4K), 23 __IO_DEV_DESC(U5500_GPIO4_BASE, SZ_4K),
24 __IO_DEV_DESC(U5500_PRCMU_BASE, SZ_4K),
24}; 25};
25 26
26static struct platform_device *u5500_platform_devs[] __initdata = { 27static struct platform_device *u5500_platform_devs[] __initdata = {
diff --git a/arch/arm/mm/cache-l2x0.c b/arch/arm/mm/cache-l2x0.c
index 9819869d2bc9..df4955885b21 100644
--- a/arch/arm/mm/cache-l2x0.c
+++ b/arch/arm/mm/cache-l2x0.c
@@ -218,6 +218,9 @@ void __init l2x0_init(void __iomem *base, __u32 aux_val, __u32 aux_mask)
218 cache_id = readl(l2x0_base + L2X0_CACHE_ID); 218 cache_id = readl(l2x0_base + L2X0_CACHE_ID);
219 aux = readl(l2x0_base + L2X0_AUX_CTRL); 219 aux = readl(l2x0_base + L2X0_AUX_CTRL);
220 220
221 aux &= aux_mask;
222 aux |= aux_val;
223
221 /* Determine the number of ways */ 224 /* Determine the number of ways */
222 switch (cache_id & L2X0_CACHE_ID_PART_MASK) { 225 switch (cache_id & L2X0_CACHE_ID_PART_MASK) {
223 case L2X0_CACHE_ID_PART_L310: 226 case L2X0_CACHE_ID_PART_L310:
@@ -248,8 +251,6 @@ void __init l2x0_init(void __iomem *base, __u32 aux_val, __u32 aux_mask)
248 if (!(readl(l2x0_base + L2X0_CTRL) & 1)) { 251 if (!(readl(l2x0_base + L2X0_CTRL) & 1)) {
249 252
250 /* l2x0 controller is disabled */ 253 /* l2x0 controller is disabled */
251 aux &= aux_mask;
252 aux |= aux_val;
253 writel(aux, l2x0_base + L2X0_AUX_CTRL); 254 writel(aux, l2x0_base + L2X0_AUX_CTRL);
254 255
255 l2x0_inv_all(); 256 l2x0_inv_all();
diff --git a/arch/arm/tools/mach-types b/arch/arm/tools/mach-types
index 8f10d24ae625..48cbdcb6bbd4 100644
--- a/arch/arm/tools/mach-types
+++ b/arch/arm/tools/mach-types
@@ -12,7 +12,7 @@
12# 12#
13# http://www.arm.linux.org.uk/developer/machines/?action=new 13# http://www.arm.linux.org.uk/developer/machines/?action=new
14# 14#
15# Last update: Sat May 1 10:36:42 2010 15# Last update: Mon Jul 12 21:10:14 2010
16# 16#
17# machine_is_xxx CONFIG_xxxx MACH_TYPE_xxx number 17# machine_is_xxx CONFIG_xxxx MACH_TYPE_xxx number
18# 18#
@@ -1994,7 +1994,7 @@ spark MACH_SPARK SPARK 2002
1994benzina MACH_BENZINA BENZINA 2003 1994benzina MACH_BENZINA BENZINA 2003
1995blaze MACH_BLAZE BLAZE 2004 1995blaze MACH_BLAZE BLAZE 2004
1996linkstation_ls_hgl MACH_LINKSTATION_LS_HGL LINKSTATION_LS_HGL 2005 1996linkstation_ls_hgl MACH_LINKSTATION_LS_HGL LINKSTATION_LS_HGL 2005
1997htckovsky MACH_HTCVENUS HTCVENUS 2006 1997htckovsky MACH_HTCKOVSKY HTCKOVSKY 2006
1998sony_prs505 MACH_SONY_PRS505 SONY_PRS505 2007 1998sony_prs505 MACH_SONY_PRS505 SONY_PRS505 2007
1999hanlin_v3 MACH_HANLIN_V3 HANLIN_V3 2008 1999hanlin_v3 MACH_HANLIN_V3 HANLIN_V3 2008
2000sapphira MACH_SAPPHIRA SAPPHIRA 2009 2000sapphira MACH_SAPPHIRA SAPPHIRA 2009
@@ -2609,7 +2609,7 @@ fujitsu_tvstbsoc1 MACH_FUJITSU_TVSTBSOC1 FUJITSU_TVSTBSOC1 2621
2609lexikon MACH_LEXIKON LEXIKON 2622 2609lexikon MACH_LEXIKON LEXIKON 2622
2610mini2440v2 MACH_MINI2440V2 MINI2440V2 2623 2610mini2440v2 MACH_MINI2440V2 MINI2440V2 2623
2611icontrol MACH_ICONTROL ICONTROL 2624 2611icontrol MACH_ICONTROL ICONTROL 2624
2612sheevad MACH_SHEEVAD SHEEVAD 2625 2612gplugd MACH_SHEEVAD SHEEVAD 2625
2613qsd8x50a_st1_1 MACH_QSD8X50A_ST1_1 QSD8X50A_ST1_1 2626 2613qsd8x50a_st1_1 MACH_QSD8X50A_ST1_1 QSD8X50A_ST1_1 2626
2614qsd8x50a_st1_5 MACH_QSD8X50A_ST1_5 QSD8X50A_ST1_5 2627 2614qsd8x50a_st1_5 MACH_QSD8X50A_ST1_5 QSD8X50A_ST1_5 2627
2615bee MACH_BEE BEE 2628 2615bee MACH_BEE BEE 2628
@@ -2804,3 +2804,149 @@ teton_bga MACH_TETON_BGA TETON_BGA 2816
2804snapper9g45 MACH_SNAPPER9G45 SNAPPER9G45 2817 2804snapper9g45 MACH_SNAPPER9G45 SNAPPER9G45 2817
2805tam3517 MACH_TAM3517 TAM3517 2818 2805tam3517 MACH_TAM3517 TAM3517 2818
2806pdc100 MACH_PDC100 PDC100 2819 2806pdc100 MACH_PDC100 PDC100 2819
2807eukrea_cpuimx25sd MACH_EUKREA_CPUIMX25 EUKREA_CPUIMX25 2820
2808eukrea_cpuimx35sd MACH_EUKREA_CPUIMX35 EUKREA_CPUIMX35 2821
2809eukrea_cpuimx51sd MACH_EUKREA_CPUIMX51SD EUKREA_CPUIMX51SD 2822
2810eukrea_cpuimx51 MACH_EUKREA_CPUIMX51 EUKREA_CPUIMX51 2823
2811p565 MACH_P565 P565 2824
2812acer_a4 MACH_ACER_A4 ACER_A4 2825
2813davinci_dm368_bip MACH_DAVINCI_DM368_BIP DAVINCI_DM368_BIP 2826
2814eshare MACH_ESHARE ESHARE 2827
2815hw_omapl138_europa MACH_HW_OMAPL138_EUROPA HW_OMAPL138_EUROPA 2828
2816wlbargn MACH_WLBARGN WLBARGN 2829
2817bm170 MACH_BM170 BM170 2830
2818netspace_mini_v2 MACH_NETSPACE_MINI_V2 NETSPACE_MINI_V2 2831
2819netspace_plug_v2 MACH_NETSPACE_PLUG_V2 NETSPACE_PLUG_V2 2832
2820siemens_l1 MACH_SIEMENS_L1 SIEMENS_L1 2833
2821elv_lcu1 MACH_ELV_LCU1 ELV_LCU1 2834
2822mcu1 MACH_MCU1 MCU1 2835
2823omap3_tao3530 MACH_OMAP3_TAO3530 OMAP3_TAO3530 2836
2824omap3_pcutouch MACH_OMAP3_PCUTOUCH OMAP3_PCUTOUCH 2837
2825smdkc210 MACH_SMDKC210 SMDKC210 2838
2826omap3_braillo MACH_OMAP3_BRAILLO OMAP3_BRAILLO 2839
2827spyplug MACH_SPYPLUG SPYPLUG 2840
2828ginger MACH_GINGER GINGER 2841
2829tny_t3530 MACH_TNY_T3530 TNY_T3530 2842
2830pca102 MACH_PCA102 PCA102 2843
2831spade MACH_SPADE SPADE 2844
2832mxc25_topaz MACH_MXC25_TOPAZ MXC25_TOPAZ 2845
2833t5325 MACH_T5325 T5325 2846
2834gw2361 MACH_GW2361 GW2361 2847
2835elog MACH_ELOG ELOG 2848
2836income MACH_INCOME INCOME 2849
2837bcm589x MACH_BCM589X BCM589X 2850
2838etna MACH_ETNA ETNA 2851
2839hawks MACH_HAWKS HAWKS 2852
2840meson MACH_MESON MESON 2853
2841xsbase255 MACH_XSBASE255 XSBASE255 2854
2842pvm2030 MACH_PVM2030 PVM2030 2855
2843mioa502 MACH_MIOA502 MIOA502 2856
2844vvbox_sdorig2 MACH_VVBOX_SDORIG2 VVBOX_SDORIG2 2857
2845vvbox_sdlite2 MACH_VVBOX_SDLITE2 VVBOX_SDLITE2 2858
2846vvbox_sdpro4 MACH_VVBOX_SDPRO4 VVBOX_SDPRO4 2859
2847htc_spv_m700 MACH_HTC_SPV_M700 HTC_SPV_M700 2860
2848mx257sx MACH_MX257SX MX257SX 2861
2849goni MACH_GONI GONI 2862
2850msm8x55_svlte_ffa MACH_MSM8X55_SVLTE_FFA MSM8X55_SVLTE_FFA 2863
2851msm8x55_svlte_surf MACH_MSM8X55_SVLTE_SURF MSM8X55_SVLTE_SURF 2864
2852quickstep MACH_QUICKSTEP QUICKSTEP 2865
2853dmw96 MACH_DMW96 DMW96 2866
2854hammerhead MACH_HAMMERHEAD HAMMERHEAD 2867
2855trident MACH_TRIDENT TRIDENT 2868
2856lightning MACH_LIGHTNING LIGHTNING 2869
2857iconnect MACH_ICONNECT ICONNECT 2870
2858autobot MACH_AUTOBOT AUTOBOT 2871
2859coconut MACH_COCONUT COCONUT 2872
2860durian MACH_DURIAN DURIAN 2873
2861cayenne MACH_CAYENNE CAYENNE 2874
2862fuji MACH_FUJI FUJI 2875
2863synology_6282 MACH_SYNOLOGY_6282 SYNOLOGY_6282 2876
2864em1sy MACH_EM1SY EM1SY 2877
2865m502 MACH_M502 M502 2878
2866matrix518 MACH_MATRIX518 MATRIX518 2879
2867tiny_gurnard MACH_TINY_GURNARD TINY_GURNARD 2880
2868spear1310 MACH_SPEAR1310 SPEAR1310 2881
2869bv07 MACH_BV07 BV07 2882
2870mxt_td61 MACH_MXT_TD61 MXT_TD61 2883
2871openrd_ultimate MACH_OPENRD_ULTIMATE OPENRD_ULTIMATE 2884
2872devixp MACH_DEVIXP DEVIXP 2885
2873miccpt MACH_MICCPT MICCPT 2886
2874mic256 MACH_MIC256 MIC256 2887
2875as1167 MACH_AS1167 AS1167 2888
2876omap3_ibiza MACH_OMAP3_IBIZA OMAP3_IBIZA 2889
2877u5500 MACH_U5500 U5500 2890
2878davinci_picto MACH_DAVINCI_PICTO DAVINCI_PICTO 2891
2879mecha MACH_MECHA MECHA 2892
2880bubba3 MACH_BUBBA3 BUBBA3 2893
2881pupitre MACH_PUPITRE PUPITRE 2894
2882tegra_harmony MACH_TEGRA_HARMONY TEGRA_HARMONY 2895
2883tegra_vogue MACH_TEGRA_VOGUE TEGRA_VOGUE 2896
2884tegra_e1165 MACH_TEGRA_E1165 TEGRA_E1165 2897
2885simplenet MACH_SIMPLENET SIMPLENET 2898
2886ec4350tbm MACH_EC4350TBM EC4350TBM 2899
2887pec_tc MACH_PEC_TC PEC_TC 2900
2888pec_hc2 MACH_PEC_HC2 PEC_HC2 2901
2889esl_mobilis_a MACH_ESL_MOBILIS_A ESL_MOBILIS_A 2902
2890esl_mobilis_b MACH_ESL_MOBILIS_B ESL_MOBILIS_B 2903
2891esl_wave_a MACH_ESL_WAVE_A ESL_WAVE_A 2904
2892esl_wave_b MACH_ESL_WAVE_B ESL_WAVE_B 2905
2893unisense_mmm MACH_UNISENSE_MMM UNISENSE_MMM 2906
2894blueshark MACH_BLUESHARK BLUESHARK 2907
2895e10 MACH_E10 E10 2908
2896app3k_robin MACH_APP3K_ROBIN APP3K_ROBIN 2909
2897pov15hd MACH_POV15HD POV15HD 2910
2898stella MACH_STELLA STELLA 2911
2899linkstation_lschl MACH_LINKSTATION_LSCHL LINKSTATION_LSCHL 2913
2900netwalker MACH_NETWALKER NETWALKER 2914
2901acsx106 MACH_ACSX106 ACSX106 2915
2902atlas5_c1 MACH_ATLAS5_C1 ATLAS5_C1 2916
2903nsb3ast MACH_NSB3AST NSB3AST 2917
2904gnet_slc MACH_GNET_SLC GNET_SLC 2918
2905af4000 MACH_AF4000 AF4000 2919
2906ark9431 MACH_ARK9431 ARK9431 2920
2907fs_s5pc100 MACH_FS_S5PC100 FS_S5PC100 2921
2908omap3505nova8 MACH_OMAP3505NOVA8 OMAP3505NOVA8 2922
2909omap3621_edp1 MACH_OMAP3621_EDP1 OMAP3621_EDP1 2923
2910oratisaes MACH_ORATISAES ORATISAES 2924
2911smdkv310 MACH_SMDKV310 SMDKV310 2925
2912siemens_l0 MACH_SIEMENS_L0 SIEMENS_L0 2926
2913ventana MACH_VENTANA VENTANA 2927
2914wm8505_7in_netbook MACH_WM8505_7IN_NETBOOK WM8505_7IN_NETBOOK 2928
2915ec4350sdb MACH_EC4350SDB EC4350SDB 2929
2916mimas MACH_MIMAS MIMAS 2930
2917titan MACH_TITAN TITAN 2931
2918craneboard MACH_CRANEBOARD CRANEBOARD 2932
2919es2440 MACH_ES2440 ES2440 2933
2920najay_a9263 MACH_NAJAY_A9263 NAJAY_A9263 2934
2921htctornado MACH_HTCTORNADO HTCTORNADO 2935
2922dimm_mx257 MACH_DIMM_MX257 DIMM_MX257 2936
2923jigen301 MACH_JIGEN JIGEN 2937
2924smdk6450 MACH_SMDK6450 SMDK6450 2938
2925meno_qng MACH_MENO_QNG MENO_QNG 2939
2926ns2416 MACH_NS2416 NS2416 2940
2927rpc353 MACH_RPC353 RPC353 2941
2928tq6410 MACH_TQ6410 TQ6410 2942
2929sky6410 MACH_SKY6410 SKY6410 2943
2930dynasty MACH_DYNASTY DYNASTY 2944
2931vivo MACH_VIVO VIVO 2945
2932bury_bl7582 MACH_BURY_BL7582 BURY_BL7582 2946
2933bury_bps5270 MACH_BURY_BPS5270 BURY_BPS5270 2947
2934basi MACH_BASI BASI 2948
2935tn200 MACH_TN200 TN200 2949
2936c2mmi MACH_C2MMI C2MMI 2950
2937meson_6236m MACH_MESON_6236M MESON_6236M 2951
2938meson_8626m MACH_MESON_8626M MESON_8626M 2952
2939tube MACH_TUBE TUBE 2953
2940messina MACH_MESSINA MESSINA 2954
2941mx50_arm2 MACH_MX50_ARM2 MX50_ARM2 2955
2942cetus9263 MACH_CETUS9263 CETUS9263 2956
2943brownstone MACH_BROWNSTONE BROWNSTONE 2957
2944vmx25 MACH_VMX25 VMX25 2958
2945vmx51 MACH_VMX51 VMX51 2959
2946abacus MACH_ABACUS ABACUS 2960
2947cm4745 MACH_CM4745 CM4745 2961
2948oratislink MACH_ORATISLINK ORATISLINK 2962
2949davinci_dm365_dvr MACH_DAVINCI_DM365_DVR DAVINCI_DM365_DVR 2963
2950netviz MACH_NETVIZ NETVIZ 2964
2951flexibity MACH_FLEXIBITY FLEXIBITY 2965
2952wlan_computer MACH_WLAN_COMPUTER WLAN_COMPUTER 2966
diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
index 76818f926539..505a08592423 100644
--- a/arch/microblaze/Kconfig
+++ b/arch/microblaze/Kconfig
@@ -5,7 +5,7 @@ mainmenu "Linux/Microblaze Kernel Configuration"
5 5
6config MICROBLAZE 6config MICROBLAZE
7 def_bool y 7 def_bool y
8 select HAVE_LMB 8 select HAVE_MEMBLOCK
9 select HAVE_FUNCTION_TRACER 9 select HAVE_FUNCTION_TRACER
10 select HAVE_FUNCTION_TRACE_MCOUNT_TEST 10 select HAVE_FUNCTION_TRACE_MCOUNT_TEST
11 select HAVE_FUNCTION_GRAPH_TRACER 11 select HAVE_FUNCTION_GRAPH_TRACER
diff --git a/arch/microblaze/include/asm/lmb.h b/arch/microblaze/include/asm/memblock.h
index a0a0a929c293..f9c2fa331d2a 100644
--- a/arch/microblaze/include/asm/lmb.h
+++ b/arch/microblaze/include/asm/memblock.h
@@ -6,12 +6,12 @@
6 * for more details. 6 * for more details.
7 */ 7 */
8 8
9#ifndef _ASM_MICROBLAZE_LMB_H 9#ifndef _ASM_MICROBLAZE_MEMBLOCK_H
10#define _ASM_MICROBLAZE_LMB_H 10#define _ASM_MICROBLAZE_MEMBLOCK_H
11 11
12/* LMB limit is OFF */ 12/* MEMBLOCK limit is OFF */
13#define LMB_REAL_LIMIT 0xFFFFFFFF 13#define MEMBLOCK_REAL_LIMIT 0xFFFFFFFF
14 14
15#endif /* _ASM_MICROBLAZE_LMB_H */ 15#endif /* _ASM_MICROBLAZE_MEMBLOCK_H */
16 16
17 17
diff --git a/arch/microblaze/kernel/prom.c b/arch/microblaze/kernel/prom.c
index a15ef6d67ca9..427b13b4740f 100644
--- a/arch/microblaze/kernel/prom.c
+++ b/arch/microblaze/kernel/prom.c
@@ -29,7 +29,7 @@
29#include <linux/kexec.h> 29#include <linux/kexec.h>
30#include <linux/debugfs.h> 30#include <linux/debugfs.h>
31#include <linux/irq.h> 31#include <linux/irq.h>
32#include <linux/lmb.h> 32#include <linux/memblock.h>
33 33
34#include <asm/prom.h> 34#include <asm/prom.h>
35#include <asm/page.h> 35#include <asm/page.h>
@@ -49,12 +49,12 @@ void __init early_init_dt_scan_chosen_arch(unsigned long node)
49 49
50void __init early_init_dt_add_memory_arch(u64 base, u64 size) 50void __init early_init_dt_add_memory_arch(u64 base, u64 size)
51{ 51{
52 lmb_add(base, size); 52 memblock_add(base, size);
53} 53}
54 54
55u64 __init early_init_dt_alloc_memory_arch(u64 size, u64 align) 55u64 __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
56{ 56{
57 return lmb_alloc(size, align); 57 return memblock_alloc(size, align);
58} 58}
59 59
60#ifdef CONFIG_EARLY_PRINTK 60#ifdef CONFIG_EARLY_PRINTK
@@ -104,8 +104,8 @@ void __init early_init_devtree(void *params)
104 */ 104 */
105 of_scan_flat_dt(early_init_dt_scan_chosen, NULL); 105 of_scan_flat_dt(early_init_dt_scan_chosen, NULL);
106 106
107 /* Scan memory nodes and rebuild LMBs */ 107 /* Scan memory nodes and rebuild MEMBLOCKs */
108 lmb_init(); 108 memblock_init();
109 of_scan_flat_dt(early_init_dt_scan_root, NULL); 109 of_scan_flat_dt(early_init_dt_scan_root, NULL);
110 of_scan_flat_dt(early_init_dt_scan_memory, NULL); 110 of_scan_flat_dt(early_init_dt_scan_memory, NULL);
111 111
@@ -113,9 +113,9 @@ void __init early_init_devtree(void *params)
113 strlcpy(boot_command_line, cmd_line, COMMAND_LINE_SIZE); 113 strlcpy(boot_command_line, cmd_line, COMMAND_LINE_SIZE);
114 parse_early_param(); 114 parse_early_param();
115 115
116 lmb_analyze(); 116 memblock_analyze();
117 117
118 pr_debug("Phys. mem: %lx\n", (unsigned long) lmb_phys_mem_size()); 118 pr_debug("Phys. mem: %lx\n", (unsigned long) memblock_phys_mem_size());
119 119
120 pr_debug(" <- early_init_devtree()\n"); 120 pr_debug(" <- early_init_devtree()\n");
121} 121}
diff --git a/arch/microblaze/mm/init.c b/arch/microblaze/mm/init.c
index cca3579d4268..db5934989926 100644
--- a/arch/microblaze/mm/init.c
+++ b/arch/microblaze/mm/init.c
@@ -10,7 +10,7 @@
10#include <linux/bootmem.h> 10#include <linux/bootmem.h>
11#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/kernel.h> 12#include <linux/kernel.h>
13#include <linux/lmb.h> 13#include <linux/memblock.h>
14#include <linux/mm.h> /* mem_init */ 14#include <linux/mm.h> /* mem_init */
15#include <linux/initrd.h> 15#include <linux/initrd.h>
16#include <linux/pagemap.h> 16#include <linux/pagemap.h>
@@ -76,10 +76,10 @@ void __init setup_memory(void)
76 u32 kernel_align_start, kernel_align_size; 76 u32 kernel_align_start, kernel_align_size;
77 77
78 /* Find main memory where is the kernel */ 78 /* Find main memory where is the kernel */
79 for (i = 0; i < lmb.memory.cnt; i++) { 79 for (i = 0; i < memblock.memory.cnt; i++) {
80 memory_start = (u32) lmb.memory.region[i].base; 80 memory_start = (u32) memblock.memory.region[i].base;
81 memory_end = (u32) lmb.memory.region[i].base 81 memory_end = (u32) memblock.memory.region[i].base
82 + (u32) lmb.memory.region[i].size; 82 + (u32) memblock.memory.region[i].size;
83 if ((memory_start <= (u32)_text) && 83 if ((memory_start <= (u32)_text) &&
84 ((u32)_text <= memory_end)) { 84 ((u32)_text <= memory_end)) {
85 memory_size = memory_end - memory_start; 85 memory_size = memory_end - memory_start;
@@ -100,7 +100,7 @@ void __init setup_memory(void)
100 kernel_align_start = PAGE_DOWN((u32)_text); 100 kernel_align_start = PAGE_DOWN((u32)_text);
101 /* ALIGN can be remove because _end in vmlinux.lds.S is align */ 101 /* ALIGN can be remove because _end in vmlinux.lds.S is align */
102 kernel_align_size = PAGE_UP((u32)klimit) - kernel_align_start; 102 kernel_align_size = PAGE_UP((u32)klimit) - kernel_align_start;
103 lmb_reserve(kernel_align_start, kernel_align_size); 103 memblock_reserve(kernel_align_start, kernel_align_size);
104 printk(KERN_INFO "%s: kernel addr=0x%08x-0x%08x size=0x%08x\n", 104 printk(KERN_INFO "%s: kernel addr=0x%08x-0x%08x size=0x%08x\n",
105 __func__, kernel_align_start, kernel_align_start 105 __func__, kernel_align_start, kernel_align_start
106 + kernel_align_size, kernel_align_size); 106 + kernel_align_size, kernel_align_size);
@@ -141,18 +141,18 @@ void __init setup_memory(void)
141 map_size = init_bootmem_node(&contig_page_data, 141 map_size = init_bootmem_node(&contig_page_data,
142 PFN_UP(TOPHYS((u32)klimit)), min_low_pfn, max_low_pfn); 142 PFN_UP(TOPHYS((u32)klimit)), min_low_pfn, max_low_pfn);
143#endif 143#endif
144 lmb_reserve(PFN_UP(TOPHYS((u32)klimit)) << PAGE_SHIFT, map_size); 144 memblock_reserve(PFN_UP(TOPHYS((u32)klimit)) << PAGE_SHIFT, map_size);
145 145
146 /* free bootmem is whole main memory */ 146 /* free bootmem is whole main memory */
147 free_bootmem(memory_start, memory_size); 147 free_bootmem(memory_start, memory_size);
148 148
149 /* reserve allocate blocks */ 149 /* reserve allocate blocks */
150 for (i = 0; i < lmb.reserved.cnt; i++) { 150 for (i = 0; i < memblock.reserved.cnt; i++) {
151 pr_debug("reserved %d - 0x%08x-0x%08x\n", i, 151 pr_debug("reserved %d - 0x%08x-0x%08x\n", i,
152 (u32) lmb.reserved.region[i].base, 152 (u32) memblock.reserved.region[i].base,
153 (u32) lmb_size_bytes(&lmb.reserved, i)); 153 (u32) memblock_size_bytes(&memblock.reserved, i));
154 reserve_bootmem(lmb.reserved.region[i].base, 154 reserve_bootmem(memblock.reserved.region[i].base,
155 lmb_size_bytes(&lmb.reserved, i) - 1, BOOTMEM_DEFAULT); 155 memblock_size_bytes(&memblock.reserved, i) - 1, BOOTMEM_DEFAULT);
156 } 156 }
157#ifdef CONFIG_MMU 157#ifdef CONFIG_MMU
158 init_bootmem_done = 1; 158 init_bootmem_done = 1;
@@ -235,7 +235,7 @@ static void mm_cmdline_setup(void)
235 if (maxmem && memory_size > maxmem) { 235 if (maxmem && memory_size > maxmem) {
236 memory_size = maxmem; 236 memory_size = maxmem;
237 memory_end = memory_start + memory_size; 237 memory_end = memory_start + memory_size;
238 lmb.memory.region[0].size = memory_size; 238 memblock.memory.region[0].size = memory_size;
239 } 239 }
240 } 240 }
241} 241}
@@ -273,19 +273,19 @@ asmlinkage void __init mmu_init(void)
273{ 273{
274 unsigned int kstart, ksize; 274 unsigned int kstart, ksize;
275 275
276 if (!lmb.reserved.cnt) { 276 if (!memblock.reserved.cnt) {
277 printk(KERN_EMERG "Error memory count\n"); 277 printk(KERN_EMERG "Error memory count\n");
278 machine_restart(NULL); 278 machine_restart(NULL);
279 } 279 }
280 280
281 if ((u32) lmb.memory.region[0].size < 0x1000000) { 281 if ((u32) memblock.memory.region[0].size < 0x1000000) {
282 printk(KERN_EMERG "Memory must be greater than 16MB\n"); 282 printk(KERN_EMERG "Memory must be greater than 16MB\n");
283 machine_restart(NULL); 283 machine_restart(NULL);
284 } 284 }
285 /* Find main memory where the kernel is */ 285 /* Find main memory where the kernel is */
286 memory_start = (u32) lmb.memory.region[0].base; 286 memory_start = (u32) memblock.memory.region[0].base;
287 memory_end = (u32) lmb.memory.region[0].base + 287 memory_end = (u32) memblock.memory.region[0].base +
288 (u32) lmb.memory.region[0].size; 288 (u32) memblock.memory.region[0].size;
289 memory_size = memory_end - memory_start; 289 memory_size = memory_end - memory_start;
290 290
291 mm_cmdline_setup(); /* FIXME parse args from command line - not used */ 291 mm_cmdline_setup(); /* FIXME parse args from command line - not used */
@@ -297,7 +297,7 @@ asmlinkage void __init mmu_init(void)
297 kstart = __pa(CONFIG_KERNEL_START); /* kernel start */ 297 kstart = __pa(CONFIG_KERNEL_START); /* kernel start */
298 /* kernel size */ 298 /* kernel size */
299 ksize = PAGE_ALIGN(((u32)_end - (u32)CONFIG_KERNEL_START)); 299 ksize = PAGE_ALIGN(((u32)_end - (u32)CONFIG_KERNEL_START));
300 lmb_reserve(kstart, ksize); 300 memblock_reserve(kstart, ksize);
301 301
302#if defined(CONFIG_BLK_DEV_INITRD) 302#if defined(CONFIG_BLK_DEV_INITRD)
303 /* Remove the init RAM disk from the available memory. */ 303 /* Remove the init RAM disk from the available memory. */
@@ -335,7 +335,7 @@ void __init *early_get_page(void)
335 * Mem start + 32MB -> here is limit 335 * Mem start + 32MB -> here is limit
336 * because of mem mapping from head.S 336 * because of mem mapping from head.S
337 */ 337 */
338 p = __va(lmb_alloc_base(PAGE_SIZE, PAGE_SIZE, 338 p = __va(memblock_alloc_base(PAGE_SIZE, PAGE_SIZE,
339 memory_start + 0x2000000)); 339 memory_start + 0x2000000));
340 } 340 }
341 return p; 341 return p;
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 6506bf4fbff1..2031a2846865 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -132,7 +132,7 @@ config PPC
132 select HAVE_ARCH_KGDB 132 select HAVE_ARCH_KGDB
133 select HAVE_KRETPROBES 133 select HAVE_KRETPROBES
134 select HAVE_ARCH_TRACEHOOK 134 select HAVE_ARCH_TRACEHOOK
135 select HAVE_LMB 135 select HAVE_MEMBLOCK
136 select HAVE_DMA_ATTRS 136 select HAVE_DMA_ATTRS
137 select HAVE_DMA_API_DEBUG 137 select HAVE_DMA_API_DEBUG
138 select USE_GENERIC_SMP_HELPERS if SMP 138 select USE_GENERIC_SMP_HELPERS if SMP
diff --git a/arch/powerpc/include/asm/abs_addr.h b/arch/powerpc/include/asm/abs_addr.h
index 98324c5a8286..9a846efe6382 100644
--- a/arch/powerpc/include/asm/abs_addr.h
+++ b/arch/powerpc/include/asm/abs_addr.h
@@ -12,7 +12,7 @@
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> 15#include <linux/memblock.h>
16 16
17#include <asm/types.h> 17#include <asm/types.h>
18#include <asm/page.h> 18#include <asm/page.h>
diff --git a/arch/powerpc/include/asm/cpm.h b/arch/powerpc/include/asm/cpm.h
index 0835eb977ba9..e50323fe941f 100644
--- a/arch/powerpc/include/asm/cpm.h
+++ b/arch/powerpc/include/asm/cpm.h
@@ -7,6 +7,30 @@
7#include <linux/of.h> 7#include <linux/of.h>
8 8
9/* 9/*
10 * SPI Parameter RAM common to QE and CPM.
11 */
12struct spi_pram {
13 __be16 rbase; /* Rx Buffer descriptor base address */
14 __be16 tbase; /* Tx Buffer descriptor base address */
15 u8 rfcr; /* Rx function code */
16 u8 tfcr; /* Tx function code */
17 __be16 mrblr; /* Max receive buffer length */
18 __be32 rstate; /* Internal */
19 __be32 rdp; /* Internal */
20 __be16 rbptr; /* Internal */
21 __be16 rbc; /* Internal */
22 __be32 rxtmp; /* Internal */
23 __be32 tstate; /* Internal */
24 __be32 tdp; /* Internal */
25 __be16 tbptr; /* Internal */
26 __be16 tbc; /* Internal */
27 __be32 txtmp; /* Internal */
28 __be32 res; /* Tx temp. */
29 __be16 rpbase; /* Relocation pointer (CPM1 only) */
30 __be16 res1; /* Reserved */
31};
32
33/*
10 * USB Controller pram common to QE and CPM. 34 * USB Controller pram common to QE and CPM.
11 */ 35 */
12struct usb_ctlr { 36struct usb_ctlr {
diff --git a/arch/powerpc/include/asm/cpm1.h b/arch/powerpc/include/asm/cpm1.h
index 81b01192f440..bd07650dca56 100644
--- a/arch/powerpc/include/asm/cpm1.h
+++ b/arch/powerpc/include/asm/cpm1.h
@@ -17,6 +17,7 @@
17#ifndef __CPM1__ 17#ifndef __CPM1__
18#define __CPM1__ 18#define __CPM1__
19 19
20#include <linux/init.h>
20#include <asm/8xx_immap.h> 21#include <asm/8xx_immap.h>
21#include <asm/ptrace.h> 22#include <asm/ptrace.h>
22#include <asm/cpm.h> 23#include <asm/cpm.h>
@@ -54,7 +55,7 @@ extern cpm8xx_t __iomem *cpmp; /* Pointer to comm processor */
54 55
55extern void cpm_setbrg(uint brg, uint rate); 56extern void cpm_setbrg(uint brg, uint rate);
56 57
57extern void cpm_load_patch(cpm8xx_t *cp); 58extern void __init cpm_load_patch(cpm8xx_t *cp);
58 59
59extern void cpm_reset(void); 60extern void cpm_reset(void);
60 61
diff --git a/arch/powerpc/include/asm/lmb.h b/arch/powerpc/include/asm/lmb.h
deleted file mode 100644
index 6f5fdf0a19ae..000000000000
--- a/arch/powerpc/include/asm/lmb.h
+++ /dev/null
@@ -1,15 +0,0 @@
1#ifndef _ASM_POWERPC_LMB_H
2#define _ASM_POWERPC_LMB_H
3
4#include <asm/udbg.h>
5
6#define LMB_DBG(fmt...) udbg_printf(fmt)
7
8#ifdef CONFIG_PPC32
9extern phys_addr_t lowmem_end_addr;
10#define LMB_REAL_LIMIT lowmem_end_addr
11#else
12#define LMB_REAL_LIMIT 0
13#endif
14
15#endif /* _ASM_POWERPC_LMB_H */
diff --git a/arch/powerpc/include/asm/memblock.h b/arch/powerpc/include/asm/memblock.h
new file mode 100644
index 000000000000..3c29728b56b1
--- /dev/null
+++ b/arch/powerpc/include/asm/memblock.h
@@ -0,0 +1,15 @@
1#ifndef _ASM_POWERPC_MEMBLOCK_H
2#define _ASM_POWERPC_MEMBLOCK_H
3
4#include <asm/udbg.h>
5
6#define MEMBLOCK_DBG(fmt...) udbg_printf(fmt)
7
8#ifdef CONFIG_PPC32
9extern phys_addr_t lowmem_end_addr;
10#define MEMBLOCK_REAL_LIMIT lowmem_end_addr
11#else
12#define MEMBLOCK_REAL_LIMIT 0
13#endif
14
15#endif /* _ASM_POWERPC_MEMBLOCK_H */
diff --git a/arch/powerpc/kernel/btext.c b/arch/powerpc/kernel/btext.c
index 26e58630ed7b..625942ae5585 100644
--- a/arch/powerpc/kernel/btext.c
+++ b/arch/powerpc/kernel/btext.c
@@ -7,7 +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#include <linux/memblock.h>
11 11
12#include <asm/sections.h> 12#include <asm/sections.h>
13#include <asm/prom.h> 13#include <asm/prom.h>
diff --git a/arch/powerpc/kernel/crash.c b/arch/powerpc/kernel/crash.c
index 29df48f2b61a..417f7b05a9ce 100644
--- a/arch/powerpc/kernel/crash.c
+++ b/arch/powerpc/kernel/crash.c
@@ -24,7 +24,7 @@
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#include <linux/memblock.h>
28 28
29#include <asm/processor.h> 29#include <asm/processor.h>
30#include <asm/machdep.h> 30#include <asm/machdep.h>
diff --git a/arch/powerpc/kernel/crash_dump.c b/arch/powerpc/kernel/crash_dump.c
index 5fb667a60894..40f524643ba6 100644
--- a/arch/powerpc/kernel/crash_dump.c
+++ b/arch/powerpc/kernel/crash_dump.c
@@ -13,7 +13,7 @@
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 <linux/memblock.h>
17#include <asm/code-patching.h> 17#include <asm/code-patching.h>
18#include <asm/kdump.h> 18#include <asm/kdump.h>
19#include <asm/prom.h> 19#include <asm/prom.h>
@@ -33,7 +33,7 @@ unsigned long long elfcorehdr_addr = ELFCORE_ADDR_MAX;
33#ifndef CONFIG_RELOCATABLE 33#ifndef CONFIG_RELOCATABLE
34void __init reserve_kdump_trampoline(void) 34void __init reserve_kdump_trampoline(void)
35{ 35{
36 lmb_reserve(0, KDUMP_RESERVE_LIMIT); 36 memblock_reserve(0, KDUMP_RESERVE_LIMIT);
37} 37}
38 38
39static void __init create_trampoline(unsigned long addr) 39static void __init create_trampoline(unsigned long addr)
diff --git a/arch/powerpc/kernel/dma-swiotlb.c b/arch/powerpc/kernel/dma-swiotlb.c
index e7fe218b8697..02f724f36753 100644
--- a/arch/powerpc/kernel/dma-swiotlb.c
+++ b/arch/powerpc/kernel/dma-swiotlb.c
@@ -71,7 +71,7 @@ static int ppc_swiotlb_bus_notify(struct notifier_block *nb,
71 sd->max_direct_dma_addr = 0; 71 sd->max_direct_dma_addr = 0;
72 72
73 /* May need to bounce if the device can't address all of DRAM */ 73 /* May need to bounce if the device can't address all of DRAM */
74 if ((dma_get_mask(dev) + 1) < lmb_end_of_DRAM()) 74 if ((dma_get_mask(dev) + 1) < memblock_end_of_DRAM())
75 set_dma_ops(dev, &swiotlb_dma_ops); 75 set_dma_ops(dev, &swiotlb_dma_ops);
76 76
77 return NOTIFY_DONE; 77 return NOTIFY_DONE;
diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c
index 8d1de6f31d5a..84d6367ec003 100644
--- a/arch/powerpc/kernel/dma.c
+++ b/arch/powerpc/kernel/dma.c
@@ -9,7 +9,7 @@
9#include <linux/dma-mapping.h> 9#include <linux/dma-mapping.h>
10#include <linux/dma-debug.h> 10#include <linux/dma-debug.h>
11#include <linux/gfp.h> 11#include <linux/gfp.h>
12#include <linux/lmb.h> 12#include <linux/memblock.h>
13#include <asm/bug.h> 13#include <asm/bug.h>
14#include <asm/abs_addr.h> 14#include <asm/abs_addr.h>
15 15
@@ -89,7 +89,7 @@ static int dma_direct_dma_supported(struct device *dev, u64 mask)
89 /* Could be improved so platforms can set the limit in case 89 /* Could be improved so platforms can set the limit in case
90 * they have limited DMA windows 90 * they have limited DMA windows
91 */ 91 */
92 return mask >= (lmb_end_of_DRAM() - 1); 92 return mask >= (memblock_end_of_DRAM() - 1);
93#else 93#else
94 return 1; 94 return 1;
95#endif 95#endif
diff --git a/arch/powerpc/kernel/fsl_booke_entry_mapping.S b/arch/powerpc/kernel/fsl_booke_entry_mapping.S
index beb4d78a2304..a92c79be2728 100644
--- a/arch/powerpc/kernel/fsl_booke_entry_mapping.S
+++ b/arch/powerpc/kernel/fsl_booke_entry_mapping.S
@@ -205,8 +205,7 @@ next_tlb_setup:
205 bdnz+ next_tlb_setup 205 bdnz+ next_tlb_setup
206 206
207/* 7. Jump to our 1:1 mapping */ 207/* 7. Jump to our 1:1 mapping */
208 li r6, 0 208 mr r6, r25
209
210#else 209#else
211 #error You need to specify the mapping or not use this at all. 210 #error You need to specify the mapping or not use this at all.
212#endif 211#endif
@@ -217,7 +216,6 @@ next_tlb_setup:
2171: mflr r9 2161: mflr r9
218 rlwimi r6,r9,0,20,31 217 rlwimi r6,r9,0,20,31
219 addi r6,r6,(2f - 1b) 218 addi r6,r6,(2f - 1b)
220 add r6, r6, r25
221 mtspr SPRN_SRR0,r6 219 mtspr SPRN_SRR0,r6
222 mtspr SPRN_SRR1,r7 220 mtspr SPRN_SRR1,r7
223 rfi /* start execution out of TLB1[0] entry */ 221 rfi /* start execution out of TLB1[0] entry */
diff --git a/arch/powerpc/kernel/machine_kexec.c b/arch/powerpc/kernel/machine_kexec.c
index bb3d893a8353..89f005116aac 100644
--- a/arch/powerpc/kernel/machine_kexec.c
+++ b/arch/powerpc/kernel/machine_kexec.c
@@ -12,7 +12,7 @@
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 <linux/memblock.h>
16#include <linux/of.h> 16#include <linux/of.h>
17#include <asm/machdep.h> 17#include <asm/machdep.h>
18#include <asm/prom.h> 18#include <asm/prom.h>
@@ -66,11 +66,11 @@ void __init reserve_crashkernel(void)
66 unsigned long long crash_size, crash_base; 66 unsigned long long crash_size, crash_base;
67 int ret; 67 int ret;
68 68
69 /* this is necessary because of lmb_phys_mem_size() */ 69 /* this is necessary because of memblock_phys_mem_size() */
70 lmb_analyze(); 70 memblock_analyze();
71 71
72 /* use common parsing */ 72 /* use common parsing */
73 ret = parse_crashkernel(boot_command_line, lmb_phys_mem_size(), 73 ret = parse_crashkernel(boot_command_line, memblock_phys_mem_size(),
74 &crash_size, &crash_base); 74 &crash_size, &crash_base);
75 if (ret == 0 && crash_size > 0) { 75 if (ret == 0 && crash_size > 0) {
76 crashk_res.start = crash_base; 76 crashk_res.start = crash_base;
@@ -133,9 +133,9 @@ void __init reserve_crashkernel(void)
133 "for crashkernel (System RAM: %ldMB)\n", 133 "for crashkernel (System RAM: %ldMB)\n",
134 (unsigned long)(crash_size >> 20), 134 (unsigned long)(crash_size >> 20),
135 (unsigned long)(crashk_res.start >> 20), 135 (unsigned long)(crashk_res.start >> 20),
136 (unsigned long)(lmb_phys_mem_size() >> 20)); 136 (unsigned long)(memblock_phys_mem_size() >> 20));
137 137
138 lmb_reserve(crashk_res.start, crash_size); 138 memblock_reserve(crashk_res.start, crash_size);
139} 139}
140 140
141int overlaps_crashkernel(unsigned long start, unsigned long size) 141int overlaps_crashkernel(unsigned long start, unsigned long size)
diff --git a/arch/powerpc/kernel/paca.c b/arch/powerpc/kernel/paca.c
index f88acf0218db..139a773853f4 100644
--- a/arch/powerpc/kernel/paca.c
+++ b/arch/powerpc/kernel/paca.c
@@ -9,7 +9,7 @@
9 9
10#include <linux/threads.h> 10#include <linux/threads.h>
11#include <linux/module.h> 11#include <linux/module.h>
12#include <linux/lmb.h> 12#include <linux/memblock.h>
13 13
14#include <asm/firmware.h> 14#include <asm/firmware.h>
15#include <asm/lppaca.h> 15#include <asm/lppaca.h>
@@ -117,7 +117,7 @@ void __init allocate_pacas(void)
117 * the first segment. On iSeries they must be within the area mapped 117 * the first segment. On iSeries they must be within the area mapped
118 * by the HV, which is HvPagesToMap * HVPAGESIZE bytes. 118 * by the HV, which is HvPagesToMap * HVPAGESIZE bytes.
119 */ 119 */
120 limit = min(0x10000000ULL, lmb.rmo_size); 120 limit = min(0x10000000ULL, memblock.rmo_size);
121 if (firmware_has_feature(FW_FEATURE_ISERIES)) 121 if (firmware_has_feature(FW_FEATURE_ISERIES))
122 limit = min(limit, HvPagesToMap * HVPAGESIZE); 122 limit = min(limit, HvPagesToMap * HVPAGESIZE);
123 123
@@ -128,7 +128,7 @@ void __init allocate_pacas(void)
128 128
129 paca_size = PAGE_ALIGN(sizeof(struct paca_struct) * nr_cpus); 129 paca_size = PAGE_ALIGN(sizeof(struct paca_struct) * nr_cpus);
130 130
131 paca = __va(lmb_alloc_base(paca_size, PAGE_SIZE, limit)); 131 paca = __va(memblock_alloc_base(paca_size, PAGE_SIZE, limit));
132 memset(paca, 0, paca_size); 132 memset(paca, 0, paca_size);
133 133
134 printk(KERN_DEBUG "Allocated %u bytes for %d pacas at %p\n", 134 printk(KERN_DEBUG "Allocated %u bytes for %d pacas at %p\n",
@@ -148,7 +148,7 @@ void __init free_unused_pacas(void)
148 if (new_size >= paca_size) 148 if (new_size >= paca_size)
149 return; 149 return;
150 150
151 lmb_free(__pa(paca) + new_size, paca_size - new_size); 151 memblock_free(__pa(paca) + new_size, paca_size - new_size);
152 152
153 printk(KERN_DEBUG "Freed %u bytes for unused pacas\n", 153 printk(KERN_DEBUG "Freed %u bytes for unused pacas\n",
154 paca_size - new_size); 154 paca_size - new_size);
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 05131d634e73..9d3953983fb7 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -31,7 +31,7 @@
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#include <linux/memblock.h>
35 35
36#include <asm/prom.h> 36#include <asm/prom.h>
37#include <asm/rtas.h> 37#include <asm/rtas.h>
@@ -98,7 +98,7 @@ static void __init move_device_tree(void)
98 98
99 if ((memory_limit && (start + size) > memory_limit) || 99 if ((memory_limit && (start + size) > memory_limit) ||
100 overlaps_crashkernel(start, size)) { 100 overlaps_crashkernel(start, size)) {
101 p = __va(lmb_alloc_base(size, PAGE_SIZE, lmb.rmo_size)); 101 p = __va(memblock_alloc_base(size, PAGE_SIZE, memblock.rmo_size));
102 memcpy(p, initial_boot_params, size); 102 memcpy(p, initial_boot_params, size);
103 initial_boot_params = (struct boot_param_header *)p; 103 initial_boot_params = (struct boot_param_header *)p;
104 DBG("Moved device tree to 0x%p\n", p); 104 DBG("Moved device tree to 0x%p\n", p);
@@ -411,13 +411,13 @@ static int __init early_init_dt_scan_drconf_memory(unsigned long node)
411{ 411{
412 __be32 *dm, *ls, *usm; 412 __be32 *dm, *ls, *usm;
413 unsigned long l, n, flags; 413 unsigned long l, n, flags;
414 u64 base, size, lmb_size; 414 u64 base, size, memblock_size;
415 unsigned int is_kexec_kdump = 0, rngs; 415 unsigned int is_kexec_kdump = 0, rngs;
416 416
417 ls = of_get_flat_dt_prop(node, "ibm,lmb-size", &l); 417 ls = of_get_flat_dt_prop(node, "ibm,memblock-size", &l);
418 if (ls == NULL || l < dt_root_size_cells * sizeof(__be32)) 418 if (ls == NULL || l < dt_root_size_cells * sizeof(__be32))
419 return 0; 419 return 0;
420 lmb_size = dt_mem_next_cell(dt_root_size_cells, &ls); 420 memblock_size = dt_mem_next_cell(dt_root_size_cells, &ls);
421 421
422 dm = of_get_flat_dt_prop(node, "ibm,dynamic-memory", &l); 422 dm = of_get_flat_dt_prop(node, "ibm,dynamic-memory", &l);
423 if (dm == NULL || l < sizeof(__be32)) 423 if (dm == NULL || l < sizeof(__be32))
@@ -442,11 +442,11 @@ static int __init early_init_dt_scan_drconf_memory(unsigned long node)
442 or if the block is not assigned to this partition (0x8) */ 442 or if the block is not assigned to this partition (0x8) */
443 if ((flags & 0x80) || !(flags & 0x8)) 443 if ((flags & 0x80) || !(flags & 0x8))
444 continue; 444 continue;
445 size = lmb_size; 445 size = memblock_size;
446 rngs = 1; 446 rngs = 1;
447 if (is_kexec_kdump) { 447 if (is_kexec_kdump) {
448 /* 448 /*
449 * For each lmb in ibm,dynamic-memory, a corresponding 449 * For each memblock in ibm,dynamic-memory, a corresponding
450 * entry in linux,drconf-usable-memory property contains 450 * entry in linux,drconf-usable-memory property contains
451 * a counter 'p' followed by 'p' (base, size) duple. 451 * a counter 'p' followed by 'p' (base, size) duple.
452 * Now read the counter from 452 * Now read the counter from
@@ -469,10 +469,10 @@ static int __init early_init_dt_scan_drconf_memory(unsigned long node)
469 if ((base + size) > 0x80000000ul) 469 if ((base + size) > 0x80000000ul)
470 size = 0x80000000ul - base; 470 size = 0x80000000ul - base;
471 } 471 }
472 lmb_add(base, size); 472 memblock_add(base, size);
473 } while (--rngs); 473 } while (--rngs);
474 } 474 }
475 lmb_dump_all(); 475 memblock_dump_all();
476 return 0; 476 return 0;
477} 477}
478#else 478#else
@@ -501,14 +501,14 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size)
501 } 501 }
502#endif 502#endif
503 503
504 lmb_add(base, size); 504 memblock_add(base, size);
505 505
506 memstart_addr = min((u64)memstart_addr, base); 506 memstart_addr = min((u64)memstart_addr, base);
507} 507}
508 508
509u64 __init early_init_dt_alloc_memory_arch(u64 size, u64 align) 509u64 __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
510{ 510{
511 return lmb_alloc(size, align); 511 return memblock_alloc(size, align);
512} 512}
513 513
514#ifdef CONFIG_BLK_DEV_INITRD 514#ifdef CONFIG_BLK_DEV_INITRD
@@ -534,12 +534,12 @@ static void __init early_reserve_mem(void)
534 /* before we do anything, lets reserve the dt blob */ 534 /* before we do anything, lets reserve the dt blob */
535 self_base = __pa((unsigned long)initial_boot_params); 535 self_base = __pa((unsigned long)initial_boot_params);
536 self_size = initial_boot_params->totalsize; 536 self_size = initial_boot_params->totalsize;
537 lmb_reserve(self_base, self_size); 537 memblock_reserve(self_base, self_size);
538 538
539#ifdef CONFIG_BLK_DEV_INITRD 539#ifdef CONFIG_BLK_DEV_INITRD
540 /* then reserve the initrd, if any */ 540 /* then reserve the initrd, if any */
541 if (initrd_start && (initrd_end > initrd_start)) 541 if (initrd_start && (initrd_end > initrd_start))
542 lmb_reserve(__pa(initrd_start), initrd_end - initrd_start); 542 memblock_reserve(__pa(initrd_start), initrd_end - initrd_start);
543#endif /* CONFIG_BLK_DEV_INITRD */ 543#endif /* CONFIG_BLK_DEV_INITRD */
544 544
545#ifdef CONFIG_PPC32 545#ifdef CONFIG_PPC32
@@ -560,7 +560,7 @@ static void __init early_reserve_mem(void)
560 if (base_32 == self_base && size_32 == self_size) 560 if (base_32 == self_base && size_32 == self_size)
561 continue; 561 continue;
562 DBG("reserving: %x -> %x\n", base_32, size_32); 562 DBG("reserving: %x -> %x\n", base_32, size_32);
563 lmb_reserve(base_32, size_32); 563 memblock_reserve(base_32, size_32);
564 } 564 }
565 return; 565 return;
566 } 566 }
@@ -571,7 +571,7 @@ static void __init early_reserve_mem(void)
571 if (size == 0) 571 if (size == 0)
572 break; 572 break;
573 DBG("reserving: %llx -> %llx\n", base, size); 573 DBG("reserving: %llx -> %llx\n", base, size);
574 lmb_reserve(base, size); 574 memblock_reserve(base, size);
575 } 575 }
576} 576}
577 577
@@ -594,7 +594,7 @@ static inline unsigned long phyp_dump_calculate_reserve_size(void)
594 return phyp_dump_info->reserve_bootvar; 594 return phyp_dump_info->reserve_bootvar;
595 595
596 /* divide by 20 to get 5% of value */ 596 /* divide by 20 to get 5% of value */
597 tmp = lmb_end_of_DRAM(); 597 tmp = memblock_end_of_DRAM();
598 do_div(tmp, 20); 598 do_div(tmp, 20);
599 599
600 /* round it down in multiples of 256 */ 600 /* round it down in multiples of 256 */
@@ -633,11 +633,11 @@ static void __init phyp_dump_reserve_mem(void)
633 if (phyp_dump_info->phyp_dump_is_active) { 633 if (phyp_dump_info->phyp_dump_is_active) {
634 /* Reserve *everything* above RMR.Area freed by userland tools*/ 634 /* Reserve *everything* above RMR.Area freed by userland tools*/
635 base = variable_reserve_size; 635 base = variable_reserve_size;
636 size = lmb_end_of_DRAM() - base; 636 size = memblock_end_of_DRAM() - base;
637 637
638 /* XXX crashed_ram_end is wrong, since it may be beyond 638 /* XXX crashed_ram_end is wrong, since it may be beyond
639 * the memory_limit, it will need to be adjusted. */ 639 * the memory_limit, it will need to be adjusted. */
640 lmb_reserve(base, size); 640 memblock_reserve(base, size);
641 641
642 phyp_dump_info->init_reserve_start = base; 642 phyp_dump_info->init_reserve_start = base;
643 phyp_dump_info->init_reserve_size = size; 643 phyp_dump_info->init_reserve_size = size;
@@ -645,8 +645,8 @@ static void __init phyp_dump_reserve_mem(void)
645 size = phyp_dump_info->cpu_state_size + 645 size = phyp_dump_info->cpu_state_size +
646 phyp_dump_info->hpte_region_size + 646 phyp_dump_info->hpte_region_size +
647 variable_reserve_size; 647 variable_reserve_size;
648 base = lmb_end_of_DRAM() - size; 648 base = memblock_end_of_DRAM() - size;
649 lmb_reserve(base, size); 649 memblock_reserve(base, size);
650 phyp_dump_info->init_reserve_start = base; 650 phyp_dump_info->init_reserve_start = base;
651 phyp_dump_info->init_reserve_size = size; 651 phyp_dump_info->init_reserve_size = size;
652 } 652 }
@@ -681,8 +681,8 @@ void __init early_init_devtree(void *params)
681 */ 681 */
682 of_scan_flat_dt(early_init_dt_scan_chosen, NULL); 682 of_scan_flat_dt(early_init_dt_scan_chosen, NULL);
683 683
684 /* Scan memory nodes and rebuild LMBs */ 684 /* Scan memory nodes and rebuild MEMBLOCKs */
685 lmb_init(); 685 memblock_init();
686 of_scan_flat_dt(early_init_dt_scan_root, NULL); 686 of_scan_flat_dt(early_init_dt_scan_root, NULL);
687 of_scan_flat_dt(early_init_dt_scan_memory_ppc, NULL); 687 of_scan_flat_dt(early_init_dt_scan_memory_ppc, NULL);
688 688
@@ -690,11 +690,11 @@ void __init early_init_devtree(void *params)
690 strlcpy(boot_command_line, cmd_line, COMMAND_LINE_SIZE); 690 strlcpy(boot_command_line, cmd_line, COMMAND_LINE_SIZE);
691 parse_early_param(); 691 parse_early_param();
692 692
693 /* Reserve LMB regions used by kernel, initrd, dt, etc... */ 693 /* Reserve MEMBLOCK regions used by kernel, initrd, dt, etc... */
694 lmb_reserve(PHYSICAL_START, __pa(klimit) - PHYSICAL_START); 694 memblock_reserve(PHYSICAL_START, __pa(klimit) - PHYSICAL_START);
695 /* If relocatable, reserve first 32k for interrupt vectors etc. */ 695 /* If relocatable, reserve first 32k for interrupt vectors etc. */
696 if (PHYSICAL_START > MEMORY_START) 696 if (PHYSICAL_START > MEMORY_START)
697 lmb_reserve(MEMORY_START, 0x8000); 697 memblock_reserve(MEMORY_START, 0x8000);
698 reserve_kdump_trampoline(); 698 reserve_kdump_trampoline();
699 reserve_crashkernel(); 699 reserve_crashkernel();
700 early_reserve_mem(); 700 early_reserve_mem();
@@ -706,17 +706,17 @@ void __init early_init_devtree(void *params)
706 706
707 /* Ensure that total memory size is page-aligned, because 707 /* Ensure that total memory size is page-aligned, because
708 * otherwise mark_bootmem() gets upset. */ 708 * otherwise mark_bootmem() gets upset. */
709 lmb_analyze(); 709 memblock_analyze();
710 memsize = lmb_phys_mem_size(); 710 memsize = memblock_phys_mem_size();
711 if ((memsize & PAGE_MASK) != memsize) 711 if ((memsize & PAGE_MASK) != memsize)
712 limit = memsize & PAGE_MASK; 712 limit = memsize & PAGE_MASK;
713 } 713 }
714 lmb_enforce_memory_limit(limit); 714 memblock_enforce_memory_limit(limit);
715 715
716 lmb_analyze(); 716 memblock_analyze();
717 lmb_dump_all(); 717 memblock_dump_all();
718 718
719 DBG("Phys. mem: %llx\n", lmb_phys_mem_size()); 719 DBG("Phys. mem: %llx\n", memblock_phys_mem_size());
720 720
721 /* We may need to relocate the flat tree, do it now. 721 /* We may need to relocate the flat tree, do it now.
722 * FIXME .. and the initrd too? */ 722 * FIXME .. and the initrd too? */
diff --git a/arch/powerpc/kernel/rtas.c b/arch/powerpc/kernel/rtas.c
index 0e1ec6f746f6..d0516dbee762 100644
--- a/arch/powerpc/kernel/rtas.c
+++ b/arch/powerpc/kernel/rtas.c
@@ -22,7 +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#include <linux/memblock.h>
26#include <linux/slab.h> 26#include <linux/slab.h>
27 27
28#include <asm/prom.h> 28#include <asm/prom.h>
@@ -934,11 +934,11 @@ void __init rtas_initialize(void)
934 */ 934 */
935#ifdef CONFIG_PPC64 935#ifdef CONFIG_PPC64
936 if (machine_is(pseries) && firmware_has_feature(FW_FEATURE_LPAR)) { 936 if (machine_is(pseries) && firmware_has_feature(FW_FEATURE_LPAR)) {
937 rtas_region = min(lmb.rmo_size, RTAS_INSTANTIATE_MAX); 937 rtas_region = min(memblock.rmo_size, RTAS_INSTANTIATE_MAX);
938 ibm_suspend_me_token = rtas_token("ibm,suspend-me"); 938 ibm_suspend_me_token = rtas_token("ibm,suspend-me");
939 } 939 }
940#endif 940#endif
941 rtas_rmo_buf = lmb_alloc_base(RTAS_RMOBUF_MAX, PAGE_SIZE, rtas_region); 941 rtas_rmo_buf = memblock_alloc_base(RTAS_RMOBUF_MAX, PAGE_SIZE, rtas_region);
942 942
943#ifdef CONFIG_RTAS_ERROR_LOGGING 943#ifdef CONFIG_RTAS_ERROR_LOGGING
944 rtas_last_error_token = rtas_token("rtas-last-error"); 944 rtas_last_error_token = rtas_token("rtas-last-error");
diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
index 5e4d852f640c..b7e6c7e193ae 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -33,7 +33,7 @@
33#include <linux/serial_8250.h> 33#include <linux/serial_8250.h>
34#include <linux/debugfs.h> 34#include <linux/debugfs.h>
35#include <linux/percpu.h> 35#include <linux/percpu.h>
36#include <linux/lmb.h> 36#include <linux/memblock.h>
37#include <linux/of_platform.h> 37#include <linux/of_platform.h>
38#include <asm/io.h> 38#include <asm/io.h>
39#include <asm/paca.h> 39#include <asm/paca.h>
diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c
index 7d84b210f168..a10ffc85ada7 100644
--- a/arch/powerpc/kernel/setup_32.c
+++ b/arch/powerpc/kernel/setup_32.c
@@ -16,7 +16,7 @@
16#include <linux/root_dev.h> 16#include <linux/root_dev.h>
17#include <linux/cpu.h> 17#include <linux/cpu.h>
18#include <linux/console.h> 18#include <linux/console.h>
19#include <linux/lmb.h> 19#include <linux/memblock.h>
20 20
21#include <asm/io.h> 21#include <asm/io.h>
22#include <asm/prom.h> 22#include <asm/prom.h>
@@ -246,12 +246,12 @@ static void __init irqstack_early_init(void)
246 unsigned int i; 246 unsigned int i;
247 247
248 /* interrupt stacks must be in lowmem, we get that for free on ppc32 248 /* interrupt stacks must be in lowmem, we get that for free on ppc32
249 * as the lmb is limited to lowmem by LMB_REAL_LIMIT */ 249 * as the memblock is limited to lowmem by MEMBLOCK_REAL_LIMIT */
250 for_each_possible_cpu(i) { 250 for_each_possible_cpu(i) {
251 softirq_ctx[i] = (struct thread_info *) 251 softirq_ctx[i] = (struct thread_info *)
252 __va(lmb_alloc(THREAD_SIZE, THREAD_SIZE)); 252 __va(memblock_alloc(THREAD_SIZE, THREAD_SIZE));
253 hardirq_ctx[i] = (struct thread_info *) 253 hardirq_ctx[i] = (struct thread_info *)
254 __va(lmb_alloc(THREAD_SIZE, THREAD_SIZE)); 254 __va(memblock_alloc(THREAD_SIZE, THREAD_SIZE));
255 } 255 }
256} 256}
257 257
@@ -261,15 +261,15 @@ static void __init exc_lvl_early_init(void)
261 unsigned int i; 261 unsigned int i;
262 262
263 /* interrupt stacks must be in lowmem, we get that for free on ppc32 263 /* interrupt stacks must be in lowmem, we get that for free on ppc32
264 * as the lmb is limited to lowmem by LMB_REAL_LIMIT */ 264 * as the memblock is limited to lowmem by MEMBLOCK_REAL_LIMIT */
265 for_each_possible_cpu(i) { 265 for_each_possible_cpu(i) {
266 critirq_ctx[i] = (struct thread_info *) 266 critirq_ctx[i] = (struct thread_info *)
267 __va(lmb_alloc(THREAD_SIZE, THREAD_SIZE)); 267 __va(memblock_alloc(THREAD_SIZE, THREAD_SIZE));
268#ifdef CONFIG_BOOKE 268#ifdef CONFIG_BOOKE
269 dbgirq_ctx[i] = (struct thread_info *) 269 dbgirq_ctx[i] = (struct thread_info *)
270 __va(lmb_alloc(THREAD_SIZE, THREAD_SIZE)); 270 __va(memblock_alloc(THREAD_SIZE, THREAD_SIZE));
271 mcheckirq_ctx[i] = (struct thread_info *) 271 mcheckirq_ctx[i] = (struct thread_info *)
272 __va(lmb_alloc(THREAD_SIZE, THREAD_SIZE)); 272 __va(memblock_alloc(THREAD_SIZE, THREAD_SIZE));
273#endif 273#endif
274 } 274 }
275} 275}
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index 643dcac40fcb..d135f93cb0f6 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -34,7 +34,7 @@
34#include <linux/bootmem.h> 34#include <linux/bootmem.h>
35#include <linux/pci.h> 35#include <linux/pci.h>
36#include <linux/lockdep.h> 36#include <linux/lockdep.h>
37#include <linux/lmb.h> 37#include <linux/memblock.h>
38#include <asm/io.h> 38#include <asm/io.h>
39#include <asm/kdump.h> 39#include <asm/kdump.h>
40#include <asm/prom.h> 40#include <asm/prom.h>
@@ -158,7 +158,7 @@ static void __init setup_paca(struct paca_struct *new_paca)
158 * the CPU that ignores the top 2 bits of the address in real 158 * the CPU that ignores the top 2 bits of the address in real
159 * mode so we can access kernel globals normally provided we 159 * mode so we can access kernel globals normally provided we
160 * only toy with things in the RMO region. From here, we do 160 * only toy with things in the RMO region. From here, we do
161 * some early parsing of the device-tree to setup out LMB 161 * some early parsing of the device-tree to setup out MEMBLOCK
162 * data structures, and allocate & initialize the hash table 162 * data structures, and allocate & initialize the hash table
163 * and segment tables so we can start running with translation 163 * and segment tables so we can start running with translation
164 * enabled. 164 * enabled.
@@ -404,7 +404,7 @@ void __init setup_system(void)
404 404
405 printk("-----------------------------------------------------\n"); 405 printk("-----------------------------------------------------\n");
406 printk("ppc64_pft_size = 0x%llx\n", ppc64_pft_size); 406 printk("ppc64_pft_size = 0x%llx\n", ppc64_pft_size);
407 printk("physicalMemorySize = 0x%llx\n", lmb_phys_mem_size()); 407 printk("physicalMemorySize = 0x%llx\n", memblock_phys_mem_size());
408 if (ppc64_caches.dline_size != 0x80) 408 if (ppc64_caches.dline_size != 0x80)
409 printk("ppc64_caches.dcache_line_size = 0x%x\n", 409 printk("ppc64_caches.dcache_line_size = 0x%x\n",
410 ppc64_caches.dline_size); 410 ppc64_caches.dline_size);
@@ -443,10 +443,10 @@ static void __init irqstack_early_init(void)
443 */ 443 */
444 for_each_possible_cpu(i) { 444 for_each_possible_cpu(i) {
445 softirq_ctx[i] = (struct thread_info *) 445 softirq_ctx[i] = (struct thread_info *)
446 __va(lmb_alloc_base(THREAD_SIZE, 446 __va(memblock_alloc_base(THREAD_SIZE,
447 THREAD_SIZE, limit)); 447 THREAD_SIZE, limit));
448 hardirq_ctx[i] = (struct thread_info *) 448 hardirq_ctx[i] = (struct thread_info *)
449 __va(lmb_alloc_base(THREAD_SIZE, 449 __va(memblock_alloc_base(THREAD_SIZE,
450 THREAD_SIZE, limit)); 450 THREAD_SIZE, limit));
451 } 451 }
452} 452}
@@ -458,11 +458,11 @@ static void __init exc_lvl_early_init(void)
458 458
459 for_each_possible_cpu(i) { 459 for_each_possible_cpu(i) {
460 critirq_ctx[i] = (struct thread_info *) 460 critirq_ctx[i] = (struct thread_info *)
461 __va(lmb_alloc(THREAD_SIZE, THREAD_SIZE)); 461 __va(memblock_alloc(THREAD_SIZE, THREAD_SIZE));
462 dbgirq_ctx[i] = (struct thread_info *) 462 dbgirq_ctx[i] = (struct thread_info *)
463 __va(lmb_alloc(THREAD_SIZE, THREAD_SIZE)); 463 __va(memblock_alloc(THREAD_SIZE, THREAD_SIZE));
464 mcheckirq_ctx[i] = (struct thread_info *) 464 mcheckirq_ctx[i] = (struct thread_info *)
465 __va(lmb_alloc(THREAD_SIZE, THREAD_SIZE)); 465 __va(memblock_alloc(THREAD_SIZE, THREAD_SIZE));
466 } 466 }
467} 467}
468#else 468#else
@@ -487,11 +487,11 @@ static void __init emergency_stack_init(void)
487 * bringup, we need to get at them in real mode. This means they 487 * bringup, we need to get at them in real mode. This means they
488 * must also be within the RMO region. 488 * must also be within the RMO region.
489 */ 489 */
490 limit = min(slb0_limit(), lmb.rmo_size); 490 limit = min(slb0_limit(), memblock.rmo_size);
491 491
492 for_each_possible_cpu(i) { 492 for_each_possible_cpu(i) {
493 unsigned long sp; 493 unsigned long sp;
494 sp = lmb_alloc_base(THREAD_SIZE, THREAD_SIZE, limit); 494 sp = memblock_alloc_base(THREAD_SIZE, THREAD_SIZE, limit);
495 sp += THREAD_SIZE; 495 sp += THREAD_SIZE;
496 paca[i].emergency_sp = __va(sp); 496 paca[i].emergency_sp = __va(sp);
497 } 497 }
diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
index d84d19224a95..13002fe206e7 100644
--- a/arch/powerpc/kernel/vdso.c
+++ b/arch/powerpc/kernel/vdso.c
@@ -22,7 +22,7 @@
22#include <linux/elf.h> 22#include <linux/elf.h>
23#include <linux/security.h> 23#include <linux/security.h>
24#include <linux/bootmem.h> 24#include <linux/bootmem.h>
25#include <linux/lmb.h> 25#include <linux/memblock.h>
26 26
27#include <asm/pgtable.h> 27#include <asm/pgtable.h>
28#include <asm/system.h> 28#include <asm/system.h>
@@ -734,7 +734,7 @@ static int __init vdso_init(void)
734 vdso_data->platform = machine_is(iseries) ? 0x200 : 0x100; 734 vdso_data->platform = machine_is(iseries) ? 0x200 : 0x100;
735 if (firmware_has_feature(FW_FEATURE_LPAR)) 735 if (firmware_has_feature(FW_FEATURE_LPAR))
736 vdso_data->platform |= 1; 736 vdso_data->platform |= 1;
737 vdso_data->physicalMemorySize = lmb_phys_mem_size(); 737 vdso_data->physicalMemorySize = memblock_phys_mem_size();
738 vdso_data->dcache_size = ppc64_caches.dsize; 738 vdso_data->dcache_size = ppc64_caches.dsize;
739 vdso_data->dcache_line_size = ppc64_caches.dline_size; 739 vdso_data->dcache_line_size = ppc64_caches.dline_size;
740 vdso_data->icache_size = ppc64_caches.isize; 740 vdso_data->icache_size = ppc64_caches.isize;
diff --git a/arch/powerpc/mm/40x_mmu.c b/arch/powerpc/mm/40x_mmu.c
index 65abfcfaaa9e..1dc2fa5ce1bd 100644
--- a/arch/powerpc/mm/40x_mmu.c
+++ b/arch/powerpc/mm/40x_mmu.c
@@ -135,7 +135,7 @@ unsigned long __init mmu_mapin_ram(unsigned long top)
135 /* If the size of RAM is not an exact power of two, we may not 135 /* If the size of RAM is not an exact power of two, we may not
136 * have covered RAM in its entirety with 16 and 4 MiB 136 * have covered RAM in its entirety with 16 and 4 MiB
137 * pages. Consequently, restrict the top end of RAM currently 137 * pages. Consequently, restrict the top end of RAM currently
138 * allocable so that calls to the LMB to allocate PTEs for "tail" 138 * allocable so that calls to the MEMBLOCK to allocate PTEs for "tail"
139 * coverage with normal-sized pages (or other reasons) do not 139 * coverage with normal-sized pages (or other reasons) do not
140 * attempt to allocate outside the allowed range. 140 * attempt to allocate outside the allowed range.
141 */ 141 */
diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c
index 3ecdcec0a39e..98f262de5585 100644
--- a/arch/powerpc/mm/hash_utils_64.c
+++ b/arch/powerpc/mm/hash_utils_64.c
@@ -31,7 +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#include <linux/memblock.h>
35 35
36#include <asm/processor.h> 36#include <asm/processor.h>
37#include <asm/pgtable.h> 37#include <asm/pgtable.h>
@@ -384,8 +384,8 @@ static int __init htab_dt_scan_hugepage_blocks(unsigned long node,
384 printk(KERN_INFO "Huge page(16GB) memory: " 384 printk(KERN_INFO "Huge page(16GB) memory: "
385 "addr = 0x%lX size = 0x%lX pages = %d\n", 385 "addr = 0x%lX size = 0x%lX pages = %d\n",
386 phys_addr, block_size, expected_pages); 386 phys_addr, block_size, expected_pages);
387 if (phys_addr + (16 * GB) <= lmb_end_of_DRAM()) { 387 if (phys_addr + (16 * GB) <= memblock_end_of_DRAM()) {
388 lmb_reserve(phys_addr, block_size * expected_pages); 388 memblock_reserve(phys_addr, block_size * expected_pages);
389 add_gpage(phys_addr, block_size, expected_pages); 389 add_gpage(phys_addr, block_size, expected_pages);
390 } 390 }
391 return 0; 391 return 0;
@@ -458,7 +458,7 @@ static void __init htab_init_page_sizes(void)
458 * and we have at least 1G of RAM at boot 458 * and we have at least 1G of RAM at boot
459 */ 459 */
460 if (mmu_psize_defs[MMU_PAGE_16M].shift && 460 if (mmu_psize_defs[MMU_PAGE_16M].shift &&
461 lmb_phys_mem_size() >= 0x40000000) 461 memblock_phys_mem_size() >= 0x40000000)
462 mmu_vmemmap_psize = MMU_PAGE_16M; 462 mmu_vmemmap_psize = MMU_PAGE_16M;
463 else if (mmu_psize_defs[MMU_PAGE_64K].shift) 463 else if (mmu_psize_defs[MMU_PAGE_64K].shift)
464 mmu_vmemmap_psize = MMU_PAGE_64K; 464 mmu_vmemmap_psize = MMU_PAGE_64K;
@@ -520,7 +520,7 @@ static unsigned long __init htab_get_table_size(void)
520 return 1UL << ppc64_pft_size; 520 return 1UL << ppc64_pft_size;
521 521
522 /* round mem_size up to next power of 2 */ 522 /* round mem_size up to next power of 2 */
523 mem_size = lmb_phys_mem_size(); 523 mem_size = memblock_phys_mem_size();
524 rnd_mem_size = 1UL << __ilog2(mem_size); 524 rnd_mem_size = 1UL << __ilog2(mem_size);
525 if (rnd_mem_size < mem_size) 525 if (rnd_mem_size < mem_size)
526 rnd_mem_size <<= 1; 526 rnd_mem_size <<= 1;
@@ -627,7 +627,7 @@ static void __init htab_initialize(void)
627 else 627 else
628 limit = 0; 628 limit = 0;
629 629
630 table = lmb_alloc_base(htab_size_bytes, htab_size_bytes, limit); 630 table = memblock_alloc_base(htab_size_bytes, htab_size_bytes, limit);
631 631
632 DBG("Hash table allocated at %lx, size: %lx\n", table, 632 DBG("Hash table allocated at %lx, size: %lx\n", table,
633 htab_size_bytes); 633 htab_size_bytes);
@@ -647,9 +647,9 @@ static void __init htab_initialize(void)
647 prot = pgprot_val(PAGE_KERNEL); 647 prot = pgprot_val(PAGE_KERNEL);
648 648
649#ifdef CONFIG_DEBUG_PAGEALLOC 649#ifdef CONFIG_DEBUG_PAGEALLOC
650 linear_map_hash_count = lmb_end_of_DRAM() >> PAGE_SHIFT; 650 linear_map_hash_count = memblock_end_of_DRAM() >> PAGE_SHIFT;
651 linear_map_hash_slots = __va(lmb_alloc_base(linear_map_hash_count, 651 linear_map_hash_slots = __va(memblock_alloc_base(linear_map_hash_count,
652 1, lmb.rmo_size)); 652 1, memblock.rmo_size));
653 memset(linear_map_hash_slots, 0, linear_map_hash_count); 653 memset(linear_map_hash_slots, 0, linear_map_hash_count);
654#endif /* CONFIG_DEBUG_PAGEALLOC */ 654#endif /* CONFIG_DEBUG_PAGEALLOC */
655 655
@@ -659,16 +659,16 @@ static void __init htab_initialize(void)
659 */ 659 */
660 660
661 /* create bolted the linear mapping in the hash table */ 661 /* create bolted the linear mapping in the hash table */
662 for (i=0; i < lmb.memory.cnt; i++) { 662 for (i=0; i < memblock.memory.cnt; i++) {
663 base = (unsigned long)__va(lmb.memory.region[i].base); 663 base = (unsigned long)__va(memblock.memory.region[i].base);
664 size = lmb.memory.region[i].size; 664 size = memblock.memory.region[i].size;
665 665
666 DBG("creating mapping for region: %lx..%lx (prot: %lx)\n", 666 DBG("creating mapping for region: %lx..%lx (prot: %lx)\n",
667 base, size, prot); 667 base, size, prot);
668 668
669#ifdef CONFIG_U3_DART 669#ifdef CONFIG_U3_DART
670 /* Do not map the DART space. Fortunately, it will be aligned 670 /* Do not map the DART space. Fortunately, it will be aligned
671 * in such a way that it will not cross two lmb regions and 671 * in such a way that it will not cross two memblock regions and
672 * will fit within a single 16Mb page. 672 * will fit within a single 16Mb page.
673 * The DART space is assumed to be a full 16Mb region even if 673 * The DART space is assumed to be a full 16Mb region even if
674 * we only use 2Mb of that space. We will use more of it later 674 * we only use 2Mb of that space. We will use more of it later
diff --git a/arch/powerpc/mm/init_32.c b/arch/powerpc/mm/init_32.c
index 767333005eb4..6a6975dc2654 100644
--- a/arch/powerpc/mm/init_32.c
+++ b/arch/powerpc/mm/init_32.c
@@ -30,7 +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#include <linux/memblock.h>
34#include <linux/gfp.h> 34#include <linux/gfp.h>
35 35
36#include <asm/pgalloc.h> 36#include <asm/pgalloc.h>
@@ -136,17 +136,17 @@ void __init MMU_init(void)
136 /* parse args from command line */ 136 /* parse args from command line */
137 MMU_setup(); 137 MMU_setup();
138 138
139 if (lmb.memory.cnt > 1) { 139 if (memblock.memory.cnt > 1) {
140#ifndef CONFIG_WII 140#ifndef CONFIG_WII
141 lmb.memory.cnt = 1; 141 memblock.memory.cnt = 1;
142 lmb_analyze(); 142 memblock_analyze();
143 printk(KERN_WARNING "Only using first contiguous memory region"); 143 printk(KERN_WARNING "Only using first contiguous memory region");
144#else 144#else
145 wii_memory_fixups(); 145 wii_memory_fixups();
146#endif 146#endif
147 } 147 }
148 148
149 total_lowmem = total_memory = lmb_end_of_DRAM() - memstart_addr; 149 total_lowmem = total_memory = memblock_end_of_DRAM() - memstart_addr;
150 lowmem_end_addr = memstart_addr + total_lowmem; 150 lowmem_end_addr = memstart_addr + total_lowmem;
151 151
152#ifdef CONFIG_FSL_BOOKE 152#ifdef CONFIG_FSL_BOOKE
@@ -161,8 +161,8 @@ void __init MMU_init(void)
161 lowmem_end_addr = memstart_addr + total_lowmem; 161 lowmem_end_addr = memstart_addr + total_lowmem;
162#ifndef CONFIG_HIGHMEM 162#ifndef CONFIG_HIGHMEM
163 total_memory = total_lowmem; 163 total_memory = total_lowmem;
164 lmb_enforce_memory_limit(lowmem_end_addr); 164 memblock_enforce_memory_limit(lowmem_end_addr);
165 lmb_analyze(); 165 memblock_analyze();
166#endif /* CONFIG_HIGHMEM */ 166#endif /* CONFIG_HIGHMEM */
167 } 167 }
168 168
@@ -200,7 +200,7 @@ void __init *early_get_page(void)
200 if (init_bootmem_done) { 200 if (init_bootmem_done) {
201 p = alloc_bootmem_pages(PAGE_SIZE); 201 p = alloc_bootmem_pages(PAGE_SIZE);
202 } else { 202 } else {
203 p = __va(lmb_alloc_base(PAGE_SIZE, PAGE_SIZE, 203 p = __va(memblock_alloc_base(PAGE_SIZE, PAGE_SIZE,
204 __initial_memory_limit_addr)); 204 __initial_memory_limit_addr));
205 } 205 }
206 return p; 206 return p;
diff --git a/arch/powerpc/mm/init_64.c b/arch/powerpc/mm/init_64.c
index e267f223fdff..71f1415e2472 100644
--- a/arch/powerpc/mm/init_64.c
+++ b/arch/powerpc/mm/init_64.c
@@ -40,7 +40,7 @@
40#include <linux/nodemask.h> 40#include <linux/nodemask.h>
41#include <linux/module.h> 41#include <linux/module.h>
42#include <linux/poison.h> 42#include <linux/poison.h>
43#include <linux/lmb.h> 43#include <linux/memblock.h>
44#include <linux/hugetlb.h> 44#include <linux/hugetlb.h>
45#include <linux/slab.h> 45#include <linux/slab.h>
46 46
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index 0f594d774bf7..1a84a8d00005 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -32,7 +32,7 @@
32#include <linux/initrd.h> 32#include <linux/initrd.h>
33#include <linux/pagemap.h> 33#include <linux/pagemap.h>
34#include <linux/suspend.h> 34#include <linux/suspend.h>
35#include <linux/lmb.h> 35#include <linux/memblock.h>
36#include <linux/hugetlb.h> 36#include <linux/hugetlb.h>
37 37
38#include <asm/pgalloc.h> 38#include <asm/pgalloc.h>
@@ -83,13 +83,13 @@ int page_is_ram(unsigned long pfn)
83#else 83#else
84 unsigned long paddr = (pfn << PAGE_SHIFT); 84 unsigned long paddr = (pfn << PAGE_SHIFT);
85 int i; 85 int i;
86 for (i=0; i < lmb.memory.cnt; i++) { 86 for (i=0; i < memblock.memory.cnt; i++) {
87 unsigned long base; 87 unsigned long base;
88 88
89 base = lmb.memory.region[i].base; 89 base = memblock.memory.region[i].base;
90 90
91 if ((paddr >= base) && 91 if ((paddr >= base) &&
92 (paddr < (base + lmb.memory.region[i].size))) { 92 (paddr < (base + memblock.memory.region[i].size))) {
93 return 1; 93 return 1;
94 } 94 }
95 } 95 }
@@ -142,14 +142,14 @@ int arch_add_memory(int nid, u64 start, u64 size)
142/* 142/*
143 * walk_memory_resource() needs to make sure there is no holes in a given 143 * walk_memory_resource() needs to make sure there is no holes in a given
144 * memory range. PPC64 does not maintain the memory layout in /proc/iomem. 144 * memory range. PPC64 does not maintain the memory layout in /proc/iomem.
145 * Instead it maintains it in lmb.memory structures. Walk through the 145 * Instead it maintains it in memblock.memory structures. Walk through the
146 * memory regions, find holes and callback for contiguous regions. 146 * memory regions, find holes and callback for contiguous regions.
147 */ 147 */
148int 148int
149walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages, 149walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages,
150 void *arg, int (*func)(unsigned long, unsigned long, void *)) 150 void *arg, int (*func)(unsigned long, unsigned long, void *))
151{ 151{
152 struct lmb_property res; 152 struct memblock_property res;
153 unsigned long pfn, len; 153 unsigned long pfn, len;
154 u64 end; 154 u64 end;
155 int ret = -1; 155 int ret = -1;
@@ -158,7 +158,7 @@ walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages,
158 res.size = (u64) nr_pages << PAGE_SHIFT; 158 res.size = (u64) nr_pages << PAGE_SHIFT;
159 159
160 end = res.base + res.size - 1; 160 end = res.base + res.size - 1;
161 while ((res.base < end) && (lmb_find(&res) >= 0)) { 161 while ((res.base < end) && (memblock_find(&res) >= 0)) {
162 pfn = (unsigned long)(res.base >> PAGE_SHIFT); 162 pfn = (unsigned long)(res.base >> PAGE_SHIFT);
163 len = (unsigned long)(res.size >> PAGE_SHIFT); 163 len = (unsigned long)(res.size >> PAGE_SHIFT);
164 ret = (*func)(pfn, len, arg); 164 ret = (*func)(pfn, len, arg);
@@ -184,8 +184,8 @@ void __init do_init_bootmem(void)
184 unsigned long total_pages; 184 unsigned long total_pages;
185 int boot_mapsize; 185 int boot_mapsize;
186 186
187 max_low_pfn = max_pfn = lmb_end_of_DRAM() >> PAGE_SHIFT; 187 max_low_pfn = max_pfn = memblock_end_of_DRAM() >> PAGE_SHIFT;
188 total_pages = (lmb_end_of_DRAM() - memstart_addr) >> PAGE_SHIFT; 188 total_pages = (memblock_end_of_DRAM() - memstart_addr) >> PAGE_SHIFT;
189#ifdef CONFIG_HIGHMEM 189#ifdef CONFIG_HIGHMEM
190 total_pages = total_lowmem >> PAGE_SHIFT; 190 total_pages = total_lowmem >> PAGE_SHIFT;
191 max_low_pfn = lowmem_end_addr >> PAGE_SHIFT; 191 max_low_pfn = lowmem_end_addr >> PAGE_SHIFT;
@@ -198,16 +198,16 @@ void __init do_init_bootmem(void)
198 */ 198 */
199 bootmap_pages = bootmem_bootmap_pages(total_pages); 199 bootmap_pages = bootmem_bootmap_pages(total_pages);
200 200
201 start = lmb_alloc(bootmap_pages << PAGE_SHIFT, PAGE_SIZE); 201 start = memblock_alloc(bootmap_pages << PAGE_SHIFT, PAGE_SIZE);
202 202
203 min_low_pfn = MEMORY_START >> PAGE_SHIFT; 203 min_low_pfn = MEMORY_START >> PAGE_SHIFT;
204 boot_mapsize = init_bootmem_node(NODE_DATA(0), start >> PAGE_SHIFT, min_low_pfn, max_low_pfn); 204 boot_mapsize = init_bootmem_node(NODE_DATA(0), start >> PAGE_SHIFT, min_low_pfn, max_low_pfn);
205 205
206 /* Add active regions with valid PFNs */ 206 /* Add active regions with valid PFNs */
207 for (i = 0; i < lmb.memory.cnt; i++) { 207 for (i = 0; i < memblock.memory.cnt; i++) {
208 unsigned long start_pfn, end_pfn; 208 unsigned long start_pfn, end_pfn;
209 start_pfn = lmb.memory.region[i].base >> PAGE_SHIFT; 209 start_pfn = memblock.memory.region[i].base >> PAGE_SHIFT;
210 end_pfn = start_pfn + lmb_size_pages(&lmb.memory, i); 210 end_pfn = start_pfn + memblock_size_pages(&memblock.memory, i);
211 add_active_range(0, start_pfn, end_pfn); 211 add_active_range(0, start_pfn, end_pfn);
212 } 212 }
213 213
@@ -218,17 +218,17 @@ void __init do_init_bootmem(void)
218 free_bootmem_with_active_regions(0, lowmem_end_addr >> PAGE_SHIFT); 218 free_bootmem_with_active_regions(0, lowmem_end_addr >> PAGE_SHIFT);
219 219
220 /* reserve the sections we're already using */ 220 /* reserve the sections we're already using */
221 for (i = 0; i < lmb.reserved.cnt; i++) { 221 for (i = 0; i < memblock.reserved.cnt; i++) {
222 unsigned long addr = lmb.reserved.region[i].base + 222 unsigned long addr = memblock.reserved.region[i].base +
223 lmb_size_bytes(&lmb.reserved, i) - 1; 223 memblock_size_bytes(&memblock.reserved, i) - 1;
224 if (addr < lowmem_end_addr) 224 if (addr < lowmem_end_addr)
225 reserve_bootmem(lmb.reserved.region[i].base, 225 reserve_bootmem(memblock.reserved.region[i].base,
226 lmb_size_bytes(&lmb.reserved, i), 226 memblock_size_bytes(&memblock.reserved, i),
227 BOOTMEM_DEFAULT); 227 BOOTMEM_DEFAULT);
228 else if (lmb.reserved.region[i].base < lowmem_end_addr) { 228 else if (memblock.reserved.region[i].base < lowmem_end_addr) {
229 unsigned long adjusted_size = lowmem_end_addr - 229 unsigned long adjusted_size = lowmem_end_addr -
230 lmb.reserved.region[i].base; 230 memblock.reserved.region[i].base;
231 reserve_bootmem(lmb.reserved.region[i].base, 231 reserve_bootmem(memblock.reserved.region[i].base,
232 adjusted_size, BOOTMEM_DEFAULT); 232 adjusted_size, BOOTMEM_DEFAULT);
233 } 233 }
234 } 234 }
@@ -236,9 +236,9 @@ void __init do_init_bootmem(void)
236 free_bootmem_with_active_regions(0, max_pfn); 236 free_bootmem_with_active_regions(0, max_pfn);
237 237
238 /* reserve the sections we're already using */ 238 /* reserve the sections we're already using */
239 for (i = 0; i < lmb.reserved.cnt; i++) 239 for (i = 0; i < memblock.reserved.cnt; i++)
240 reserve_bootmem(lmb.reserved.region[i].base, 240 reserve_bootmem(memblock.reserved.region[i].base,
241 lmb_size_bytes(&lmb.reserved, i), 241 memblock_size_bytes(&memblock.reserved, i),
242 BOOTMEM_DEFAULT); 242 BOOTMEM_DEFAULT);
243 243
244#endif 244#endif
@@ -251,20 +251,20 @@ void __init do_init_bootmem(void)
251/* mark pages that don't exist as nosave */ 251/* mark pages that don't exist as nosave */
252static int __init mark_nonram_nosave(void) 252static int __init mark_nonram_nosave(void)
253{ 253{
254 unsigned long lmb_next_region_start_pfn, 254 unsigned long memblock_next_region_start_pfn,
255 lmb_region_max_pfn; 255 memblock_region_max_pfn;
256 int i; 256 int i;
257 257
258 for (i = 0; i < lmb.memory.cnt - 1; i++) { 258 for (i = 0; i < memblock.memory.cnt - 1; i++) {
259 lmb_region_max_pfn = 259 memblock_region_max_pfn =
260 (lmb.memory.region[i].base >> PAGE_SHIFT) + 260 (memblock.memory.region[i].base >> PAGE_SHIFT) +
261 (lmb.memory.region[i].size >> PAGE_SHIFT); 261 (memblock.memory.region[i].size >> PAGE_SHIFT);
262 lmb_next_region_start_pfn = 262 memblock_next_region_start_pfn =
263 lmb.memory.region[i+1].base >> PAGE_SHIFT; 263 memblock.memory.region[i+1].base >> PAGE_SHIFT;
264 264
265 if (lmb_region_max_pfn < lmb_next_region_start_pfn) 265 if (memblock_region_max_pfn < memblock_next_region_start_pfn)
266 register_nosave_region(lmb_region_max_pfn, 266 register_nosave_region(memblock_region_max_pfn,
267 lmb_next_region_start_pfn); 267 memblock_next_region_start_pfn);
268 } 268 }
269 269
270 return 0; 270 return 0;
@@ -275,8 +275,8 @@ static int __init mark_nonram_nosave(void)
275 */ 275 */
276void __init paging_init(void) 276void __init paging_init(void)
277{ 277{
278 unsigned long total_ram = lmb_phys_mem_size(); 278 unsigned long total_ram = memblock_phys_mem_size();
279 phys_addr_t top_of_ram = lmb_end_of_DRAM(); 279 phys_addr_t top_of_ram = memblock_end_of_DRAM();
280 unsigned long max_zone_pfns[MAX_NR_ZONES]; 280 unsigned long max_zone_pfns[MAX_NR_ZONES];
281 281
282#ifdef CONFIG_PPC32 282#ifdef CONFIG_PPC32
@@ -327,7 +327,7 @@ void __init mem_init(void)
327 swiotlb_init(1); 327 swiotlb_init(1);
328#endif 328#endif
329 329
330 num_physpages = lmb.memory.size >> PAGE_SHIFT; 330 num_physpages = memblock.memory.size >> PAGE_SHIFT;
331 high_memory = (void *) __va(max_low_pfn * PAGE_SIZE); 331 high_memory = (void *) __va(max_low_pfn * PAGE_SIZE);
332 332
333#ifdef CONFIG_NEED_MULTIPLE_NODES 333#ifdef CONFIG_NEED_MULTIPLE_NODES
@@ -364,7 +364,7 @@ void __init mem_init(void)
364 highmem_mapnr = lowmem_end_addr >> PAGE_SHIFT; 364 highmem_mapnr = lowmem_end_addr >> PAGE_SHIFT;
365 for (pfn = highmem_mapnr; pfn < max_mapnr; ++pfn) { 365 for (pfn = highmem_mapnr; pfn < max_mapnr; ++pfn) {
366 struct page *page = pfn_to_page(pfn); 366 struct page *page = pfn_to_page(pfn);
367 if (lmb_is_reserved(pfn << PAGE_SHIFT)) 367 if (memblock_is_reserved(pfn << PAGE_SHIFT))
368 continue; 368 continue;
369 ClearPageReserved(page); 369 ClearPageReserved(page);
370 init_page_count(page); 370 init_page_count(page);
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index 80d110635d24..f47364585ecd 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -17,7 +17,7 @@
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 <linux/memblock.h>
21#include <linux/of.h> 21#include <linux/of.h>
22#include <linux/pfn.h> 22#include <linux/pfn.h>
23#include <asm/sparsemem.h> 23#include <asm/sparsemem.h>
@@ -351,7 +351,7 @@ struct of_drconf_cell {
351#define DRCONF_MEM_RESERVED 0x00000080 351#define DRCONF_MEM_RESERVED 0x00000080
352 352
353/* 353/*
354 * Read the next lmb list entry from the ibm,dynamic-memory property 354 * Read the next memblock list entry from the ibm,dynamic-memory property
355 * and return the information in the provided of_drconf_cell structure. 355 * and return the information in the provided of_drconf_cell structure.
356 */ 356 */
357static void read_drconf_cell(struct of_drconf_cell *drmem, const u32 **cellp) 357static void read_drconf_cell(struct of_drconf_cell *drmem, const u32 **cellp)
@@ -372,8 +372,8 @@ static void read_drconf_cell(struct of_drconf_cell *drmem, const u32 **cellp)
372/* 372/*
373 * Retreive and validate the ibm,dynamic-memory property of the device tree. 373 * Retreive and validate the ibm,dynamic-memory property of the device tree.
374 * 374 *
375 * The layout of the ibm,dynamic-memory property is a number N of lmb 375 * The layout of the ibm,dynamic-memory property is a number N of memblock
376 * list entries followed by N lmb list entries. Each lmb list entry 376 * list entries followed by N memblock list entries. Each memblock list entry
377 * contains information as layed out in the of_drconf_cell struct above. 377 * contains information as layed out in the of_drconf_cell struct above.
378 */ 378 */
379static int of_get_drconf_memory(struct device_node *memory, const u32 **dm) 379static int of_get_drconf_memory(struct device_node *memory, const u32 **dm)
@@ -398,15 +398,15 @@ static int of_get_drconf_memory(struct device_node *memory, const u32 **dm)
398} 398}
399 399
400/* 400/*
401 * Retreive and validate the ibm,lmb-size property for drconf memory 401 * Retreive and validate the ibm,memblock-size property for drconf memory
402 * from the device tree. 402 * from the device tree.
403 */ 403 */
404static u64 of_get_lmb_size(struct device_node *memory) 404static u64 of_get_memblock_size(struct device_node *memory)
405{ 405{
406 const u32 *prop; 406 const u32 *prop;
407 u32 len; 407 u32 len;
408 408
409 prop = of_get_property(memory, "ibm,lmb-size", &len); 409 prop = of_get_property(memory, "ibm,memblock-size", &len);
410 if (!prop || len < sizeof(unsigned int)) 410 if (!prop || len < sizeof(unsigned int))
411 return 0; 411 return 0;
412 412
@@ -540,19 +540,19 @@ static unsigned long __init numa_enforce_memory_limit(unsigned long start,
540 unsigned long size) 540 unsigned long size)
541{ 541{
542 /* 542 /*
543 * We use lmb_end_of_DRAM() in here instead of memory_limit because 543 * We use memblock_end_of_DRAM() in here instead of memory_limit because
544 * we've already adjusted it for the limit and it takes care of 544 * we've already adjusted it for the limit and it takes care of
545 * having memory holes below the limit. Also, in the case of 545 * having memory holes below the limit. Also, in the case of
546 * iommu_is_off, memory_limit is not set but is implicitly enforced. 546 * iommu_is_off, memory_limit is not set but is implicitly enforced.
547 */ 547 */
548 548
549 if (start + size <= lmb_end_of_DRAM()) 549 if (start + size <= memblock_end_of_DRAM())
550 return size; 550 return size;
551 551
552 if (start >= lmb_end_of_DRAM()) 552 if (start >= memblock_end_of_DRAM())
553 return 0; 553 return 0;
554 554
555 return lmb_end_of_DRAM() - start; 555 return memblock_end_of_DRAM() - start;
556} 556}
557 557
558/* 558/*
@@ -562,7 +562,7 @@ static unsigned long __init numa_enforce_memory_limit(unsigned long start,
562static inline int __init read_usm_ranges(const u32 **usm) 562static inline int __init read_usm_ranges(const u32 **usm)
563{ 563{
564 /* 564 /*
565 * For each lmb in ibm,dynamic-memory a corresponding 565 * For each memblock in ibm,dynamic-memory a corresponding
566 * entry in linux,drconf-usable-memory property contains 566 * entry in linux,drconf-usable-memory property contains
567 * a counter followed by that many (base, size) duple. 567 * a counter followed by that many (base, size) duple.
568 * read the counter from linux,drconf-usable-memory 568 * read the counter from linux,drconf-usable-memory
@@ -578,7 +578,7 @@ static void __init parse_drconf_memory(struct device_node *memory)
578{ 578{
579 const u32 *dm, *usm; 579 const u32 *dm, *usm;
580 unsigned int n, rc, ranges, is_kexec_kdump = 0; 580 unsigned int n, rc, ranges, is_kexec_kdump = 0;
581 unsigned long lmb_size, base, size, sz; 581 unsigned long memblock_size, base, size, sz;
582 int nid; 582 int nid;
583 struct assoc_arrays aa; 583 struct assoc_arrays aa;
584 584
@@ -586,8 +586,8 @@ static void __init parse_drconf_memory(struct device_node *memory)
586 if (!n) 586 if (!n)
587 return; 587 return;
588 588
589 lmb_size = of_get_lmb_size(memory); 589 memblock_size = of_get_memblock_size(memory);
590 if (!lmb_size) 590 if (!memblock_size)
591 return; 591 return;
592 592
593 rc = of_get_assoc_arrays(memory, &aa); 593 rc = of_get_assoc_arrays(memory, &aa);
@@ -611,7 +611,7 @@ static void __init parse_drconf_memory(struct device_node *memory)
611 continue; 611 continue;
612 612
613 base = drmem.base_addr; 613 base = drmem.base_addr;
614 size = lmb_size; 614 size = memblock_size;
615 ranges = 1; 615 ranges = 1;
616 616
617 if (is_kexec_kdump) { 617 if (is_kexec_kdump) {
@@ -731,7 +731,7 @@ new_range:
731 } 731 }
732 732
733 /* 733 /*
734 * Now do the same thing for each LMB listed in the ibm,dynamic-memory 734 * Now do the same thing for each MEMBLOCK listed in the ibm,dynamic-memory
735 * property in the ibm,dynamic-reconfiguration-memory node. 735 * property in the ibm,dynamic-reconfiguration-memory node.
736 */ 736 */
737 memory = of_find_node_by_path("/ibm,dynamic-reconfiguration-memory"); 737 memory = of_find_node_by_path("/ibm,dynamic-reconfiguration-memory");
@@ -743,8 +743,8 @@ new_range:
743 743
744static void __init setup_nonnuma(void) 744static void __init setup_nonnuma(void)
745{ 745{
746 unsigned long top_of_ram = lmb_end_of_DRAM(); 746 unsigned long top_of_ram = memblock_end_of_DRAM();
747 unsigned long total_ram = lmb_phys_mem_size(); 747 unsigned long total_ram = memblock_phys_mem_size();
748 unsigned long start_pfn, end_pfn; 748 unsigned long start_pfn, end_pfn;
749 unsigned int i, nid = 0; 749 unsigned int i, nid = 0;
750 750
@@ -753,9 +753,9 @@ static void __init setup_nonnuma(void)
753 printk(KERN_DEBUG "Memory hole size: %ldMB\n", 753 printk(KERN_DEBUG "Memory hole size: %ldMB\n",
754 (top_of_ram - total_ram) >> 20); 754 (top_of_ram - total_ram) >> 20);
755 755
756 for (i = 0; i < lmb.memory.cnt; ++i) { 756 for (i = 0; i < memblock.memory.cnt; ++i) {
757 start_pfn = lmb.memory.region[i].base >> PAGE_SHIFT; 757 start_pfn = memblock.memory.region[i].base >> PAGE_SHIFT;
758 end_pfn = start_pfn + lmb_size_pages(&lmb.memory, i); 758 end_pfn = start_pfn + memblock_size_pages(&memblock.memory, i);
759 759
760 fake_numa_create_new_node(end_pfn, &nid); 760 fake_numa_create_new_node(end_pfn, &nid);
761 add_active_range(nid, start_pfn, end_pfn); 761 add_active_range(nid, start_pfn, end_pfn);
@@ -813,7 +813,7 @@ static void __init dump_numa_memory_topology(void)
813 813
814 count = 0; 814 count = 0;
815 815
816 for (i = 0; i < lmb_end_of_DRAM(); 816 for (i = 0; i < memblock_end_of_DRAM();
817 i += (1 << SECTION_SIZE_BITS)) { 817 i += (1 << SECTION_SIZE_BITS)) {
818 if (early_pfn_to_nid(i >> PAGE_SHIFT) == node) { 818 if (early_pfn_to_nid(i >> PAGE_SHIFT) == node) {
819 if (count == 0) 819 if (count == 0)
@@ -833,7 +833,7 @@ static void __init dump_numa_memory_topology(void)
833} 833}
834 834
835/* 835/*
836 * Allocate some memory, satisfying the lmb or bootmem allocator where 836 * Allocate some memory, satisfying the memblock or bootmem allocator where
837 * required. nid is the preferred node and end is the physical address of 837 * required. nid is the preferred node and end is the physical address of
838 * the highest address in the node. 838 * the highest address in the node.
839 * 839 *
@@ -847,11 +847,11 @@ static void __init *careful_zallocation(int nid, unsigned long size,
847 int new_nid; 847 int new_nid;
848 unsigned long ret_paddr; 848 unsigned long ret_paddr;
849 849
850 ret_paddr = __lmb_alloc_base(size, align, end_pfn << PAGE_SHIFT); 850 ret_paddr = __memblock_alloc_base(size, align, end_pfn << PAGE_SHIFT);
851 851
852 /* retry over all memory */ 852 /* retry over all memory */
853 if (!ret_paddr) 853 if (!ret_paddr)
854 ret_paddr = __lmb_alloc_base(size, align, lmb_end_of_DRAM()); 854 ret_paddr = __memblock_alloc_base(size, align, memblock_end_of_DRAM());
855 855
856 if (!ret_paddr) 856 if (!ret_paddr)
857 panic("numa.c: cannot allocate %lu bytes for node %d", 857 panic("numa.c: cannot allocate %lu bytes for node %d",
@@ -861,14 +861,14 @@ static void __init *careful_zallocation(int nid, unsigned long size,
861 861
862 /* 862 /*
863 * We initialize the nodes in numeric order: 0, 1, 2... 863 * We initialize the nodes in numeric order: 0, 1, 2...
864 * and hand over control from the LMB allocator to the 864 * and hand over control from the MEMBLOCK allocator to the
865 * bootmem allocator. If this function is called for 865 * bootmem allocator. If this function is called for
866 * node 5, then we know that all nodes <5 are using the 866 * node 5, then we know that all nodes <5 are using the
867 * bootmem allocator instead of the LMB allocator. 867 * bootmem allocator instead of the MEMBLOCK allocator.
868 * 868 *
869 * So, check the nid from which this allocation came 869 * So, check the nid from which this allocation came
870 * and double check to see if we need to use bootmem 870 * and double check to see if we need to use bootmem
871 * instead of the LMB. We don't free the LMB memory 871 * instead of the MEMBLOCK. We don't free the MEMBLOCK memory
872 * since it would be useless. 872 * since it would be useless.
873 */ 873 */
874 new_nid = early_pfn_to_nid(ret_paddr >> PAGE_SHIFT); 874 new_nid = early_pfn_to_nid(ret_paddr >> PAGE_SHIFT);
@@ -893,9 +893,9 @@ static void mark_reserved_regions_for_nid(int nid)
893 struct pglist_data *node = NODE_DATA(nid); 893 struct pglist_data *node = NODE_DATA(nid);
894 int i; 894 int i;
895 895
896 for (i = 0; i < lmb.reserved.cnt; i++) { 896 for (i = 0; i < memblock.reserved.cnt; i++) {
897 unsigned long physbase = lmb.reserved.region[i].base; 897 unsigned long physbase = memblock.reserved.region[i].base;
898 unsigned long size = lmb.reserved.region[i].size; 898 unsigned long size = memblock.reserved.region[i].size;
899 unsigned long start_pfn = physbase >> PAGE_SHIFT; 899 unsigned long start_pfn = physbase >> PAGE_SHIFT;
900 unsigned long end_pfn = PFN_UP(physbase + size); 900 unsigned long end_pfn = PFN_UP(physbase + size);
901 struct node_active_region node_ar; 901 struct node_active_region node_ar;
@@ -903,7 +903,7 @@ static void mark_reserved_regions_for_nid(int nid)
903 node->node_spanned_pages; 903 node->node_spanned_pages;
904 904
905 /* 905 /*
906 * Check to make sure that this lmb.reserved area is 906 * Check to make sure that this memblock.reserved area is
907 * within the bounds of the node that we care about. 907 * within the bounds of the node that we care about.
908 * Checking the nid of the start and end points is not 908 * Checking the nid of the start and end points is not
909 * sufficient because the reserved area could span the 909 * sufficient because the reserved area could span the
@@ -961,7 +961,7 @@ void __init do_init_bootmem(void)
961 int nid; 961 int nid;
962 962
963 min_low_pfn = 0; 963 min_low_pfn = 0;
964 max_low_pfn = lmb_end_of_DRAM() >> PAGE_SHIFT; 964 max_low_pfn = memblock_end_of_DRAM() >> PAGE_SHIFT;
965 max_pfn = max_low_pfn; 965 max_pfn = max_low_pfn;
966 966
967 if (parse_numa_properties()) 967 if (parse_numa_properties())
@@ -1038,7 +1038,7 @@ void __init paging_init(void)
1038{ 1038{
1039 unsigned long max_zone_pfns[MAX_NR_ZONES]; 1039 unsigned long max_zone_pfns[MAX_NR_ZONES];
1040 memset(max_zone_pfns, 0, sizeof(max_zone_pfns)); 1040 memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
1041 max_zone_pfns[ZONE_DMA] = lmb_end_of_DRAM() >> PAGE_SHIFT; 1041 max_zone_pfns[ZONE_DMA] = memblock_end_of_DRAM() >> PAGE_SHIFT;
1042 free_area_init_nodes(max_zone_pfns); 1042 free_area_init_nodes(max_zone_pfns);
1043} 1043}
1044 1044
@@ -1072,7 +1072,7 @@ static int hot_add_drconf_scn_to_nid(struct device_node *memory,
1072{ 1072{
1073 const u32 *dm; 1073 const u32 *dm;
1074 unsigned int drconf_cell_cnt, rc; 1074 unsigned int drconf_cell_cnt, rc;
1075 unsigned long lmb_size; 1075 unsigned long memblock_size;
1076 struct assoc_arrays aa; 1076 struct assoc_arrays aa;
1077 int nid = -1; 1077 int nid = -1;
1078 1078
@@ -1080,8 +1080,8 @@ static int hot_add_drconf_scn_to_nid(struct device_node *memory,
1080 if (!drconf_cell_cnt) 1080 if (!drconf_cell_cnt)
1081 return -1; 1081 return -1;
1082 1082
1083 lmb_size = of_get_lmb_size(memory); 1083 memblock_size = of_get_memblock_size(memory);
1084 if (!lmb_size) 1084 if (!memblock_size)
1085 return -1; 1085 return -1;
1086 1086
1087 rc = of_get_assoc_arrays(memory, &aa); 1087 rc = of_get_assoc_arrays(memory, &aa);
@@ -1100,7 +1100,7 @@ static int hot_add_drconf_scn_to_nid(struct device_node *memory,
1100 continue; 1100 continue;
1101 1101
1102 if ((scn_addr < drmem.base_addr) 1102 if ((scn_addr < drmem.base_addr)
1103 || (scn_addr >= (drmem.base_addr + lmb_size))) 1103 || (scn_addr >= (drmem.base_addr + memblock_size)))
1104 continue; 1104 continue;
1105 1105
1106 nid = of_drconf_to_nid_single(&drmem, &aa); 1106 nid = of_drconf_to_nid_single(&drmem, &aa);
@@ -1113,7 +1113,7 @@ static int hot_add_drconf_scn_to_nid(struct device_node *memory,
1113/* 1113/*
1114 * Find the node associated with a hot added memory section for memory 1114 * Find the node associated with a hot added memory section for memory
1115 * represented in the device tree as a node (i.e. memory@XXXX) for 1115 * represented in the device tree as a node (i.e. memory@XXXX) for
1116 * each lmb. 1116 * each memblock.
1117 */ 1117 */
1118int hot_add_node_scn_to_nid(unsigned long scn_addr) 1118int hot_add_node_scn_to_nid(unsigned long scn_addr)
1119{ 1119{
@@ -1154,8 +1154,8 @@ int hot_add_node_scn_to_nid(unsigned long scn_addr)
1154 1154
1155/* 1155/*
1156 * Find the node associated with a hot added memory section. Section 1156 * Find the node associated with a hot added memory section. Section
1157 * corresponds to a SPARSEMEM section, not an LMB. It is assumed that 1157 * corresponds to a SPARSEMEM section, not an MEMBLOCK. It is assumed that
1158 * sections are fully contained within a single LMB. 1158 * sections are fully contained within a single MEMBLOCK.
1159 */ 1159 */
1160int hot_add_scn_to_nid(unsigned long scn_addr) 1160int hot_add_scn_to_nid(unsigned long scn_addr)
1161{ 1161{
diff --git a/arch/powerpc/mm/pgtable_32.c b/arch/powerpc/mm/pgtable_32.c
index 34347b2e7e31..a87ead0138b4 100644
--- a/arch/powerpc/mm/pgtable_32.c
+++ b/arch/powerpc/mm/pgtable_32.c
@@ -26,7 +26,7 @@
26#include <linux/vmalloc.h> 26#include <linux/vmalloc.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#include <linux/memblock.h>
30#include <linux/slab.h> 30#include <linux/slab.h>
31 31
32#include <asm/pgtable.h> 32#include <asm/pgtable.h>
@@ -198,7 +198,7 @@ __ioremap_caller(phys_addr_t addr, unsigned long size, unsigned long flags,
198 * mem_init() sets high_memory so only do the check after that. 198 * mem_init() sets high_memory so only do the check after that.
199 */ 199 */
200 if (mem_init_done && (p < virt_to_phys(high_memory)) && 200 if (mem_init_done && (p < virt_to_phys(high_memory)) &&
201 !(__allow_ioremap_reserved && lmb_is_region_reserved(p, size))) { 201 !(__allow_ioremap_reserved && memblock_is_region_reserved(p, size))) {
202 printk("__ioremap(): phys addr 0x%llx is RAM lr %p\n", 202 printk("__ioremap(): phys addr 0x%llx is RAM lr %p\n",
203 (unsigned long long)p, __builtin_return_address(0)); 203 (unsigned long long)p, __builtin_return_address(0));
204 return NULL; 204 return NULL;
@@ -331,7 +331,7 @@ void __init mapin_ram(void)
331 s = mmu_mapin_ram(top); 331 s = mmu_mapin_ram(top);
332 __mapin_ram_chunk(s, top); 332 __mapin_ram_chunk(s, top);
333 333
334 top = lmb_end_of_DRAM(); 334 top = memblock_end_of_DRAM();
335 s = wii_mmu_mapin_mem2(top); 335 s = wii_mmu_mapin_mem2(top);
336 __mapin_ram_chunk(s, top); 336 __mapin_ram_chunk(s, top);
337 } 337 }
diff --git a/arch/powerpc/mm/pgtable_64.c b/arch/powerpc/mm/pgtable_64.c
index d050fc8d9714..21d6dfab7942 100644
--- a/arch/powerpc/mm/pgtable_64.c
+++ b/arch/powerpc/mm/pgtable_64.c
@@ -34,7 +34,7 @@
34#include <linux/vmalloc.h> 34#include <linux/vmalloc.h>
35#include <linux/init.h> 35#include <linux/init.h>
36#include <linux/bootmem.h> 36#include <linux/bootmem.h>
37#include <linux/lmb.h> 37#include <linux/memblock.h>
38#include <linux/slab.h> 38#include <linux/slab.h>
39 39
40#include <asm/pgalloc.h> 40#include <asm/pgalloc.h>
@@ -67,7 +67,7 @@ static void *early_alloc_pgtable(unsigned long size)
67 if (init_bootmem_done) 67 if (init_bootmem_done)
68 pt = __alloc_bootmem(size, size, __pa(MAX_DMA_ADDRESS)); 68 pt = __alloc_bootmem(size, size, __pa(MAX_DMA_ADDRESS));
69 else 69 else
70 pt = __va(lmb_alloc_base(size, size, 70 pt = __va(memblock_alloc_base(size, size,
71 __pa(MAX_DMA_ADDRESS))); 71 __pa(MAX_DMA_ADDRESS)));
72 memset(pt, 0, size); 72 memset(pt, 0, size);
73 73
diff --git a/arch/powerpc/mm/ppc_mmu_32.c b/arch/powerpc/mm/ppc_mmu_32.c
index f11c2cdcb0fe..f8a01829d64f 100644
--- a/arch/powerpc/mm/ppc_mmu_32.c
+++ b/arch/powerpc/mm/ppc_mmu_32.c
@@ -26,7 +26,7 @@
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#include <linux/memblock.h>
30 30
31#include <asm/prom.h> 31#include <asm/prom.h>
32#include <asm/mmu.h> 32#include <asm/mmu.h>
@@ -223,7 +223,7 @@ void __init MMU_init_hw(void)
223 * Find some memory for the hash table. 223 * Find some memory for the hash table.
224 */ 224 */
225 if ( ppc_md.progress ) ppc_md.progress("hash:find piece", 0x322); 225 if ( ppc_md.progress ) ppc_md.progress("hash:find piece", 0x322);
226 Hash = __va(lmb_alloc_base(Hash_size, Hash_size, 226 Hash = __va(memblock_alloc_base(Hash_size, Hash_size,
227 __initial_memory_limit_addr)); 227 __initial_memory_limit_addr));
228 cacheable_memzero(Hash, Hash_size); 228 cacheable_memzero(Hash, Hash_size);
229 _SDR1 = __pa(Hash) | SDR1_LOW_BITS; 229 _SDR1 = __pa(Hash) | SDR1_LOW_BITS;
diff --git a/arch/powerpc/mm/stab.c b/arch/powerpc/mm/stab.c
index 687fddaa24c5..446a01842a73 100644
--- a/arch/powerpc/mm/stab.c
+++ b/arch/powerpc/mm/stab.c
@@ -12,7 +12,7 @@
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> 15#include <linux/memblock.h>
16 16
17#include <asm/pgtable.h> 17#include <asm/pgtable.h>
18#include <asm/mmu.h> 18#include <asm/mmu.h>
@@ -252,7 +252,7 @@ void __init stabs_alloc(void)
252 if (cpu == 0) 252 if (cpu == 0)
253 continue; /* stab for CPU 0 is statically allocated */ 253 continue; /* stab for CPU 0 is statically allocated */
254 254
255 newstab = lmb_alloc_base(HW_PAGE_SIZE, HW_PAGE_SIZE, 255 newstab = memblock_alloc_base(HW_PAGE_SIZE, HW_PAGE_SIZE,
256 1<<SID_SHIFT); 256 1<<SID_SHIFT);
257 newstab = (unsigned long)__va(newstab); 257 newstab = (unsigned long)__va(newstab);
258 258
diff --git a/arch/powerpc/mm/tlb_nohash.c b/arch/powerpc/mm/tlb_nohash.c
index e81d5d67f834..d8695b02a968 100644
--- a/arch/powerpc/mm/tlb_nohash.c
+++ b/arch/powerpc/mm/tlb_nohash.c
@@ -34,7 +34,7 @@
34#include <linux/pagemap.h> 34#include <linux/pagemap.h>
35#include <linux/preempt.h> 35#include <linux/preempt.h>
36#include <linux/spinlock.h> 36#include <linux/spinlock.h>
37#include <linux/lmb.h> 37#include <linux/memblock.h>
38 38
39#include <asm/tlbflush.h> 39#include <asm/tlbflush.h>
40#include <asm/tlb.h> 40#include <asm/tlb.h>
@@ -426,7 +426,7 @@ static void __early_init_mmu(int boot_cpu)
426 /* Set the global containing the top of the linear mapping 426 /* Set the global containing the top of the linear mapping
427 * for use by the TLB miss code 427 * for use by the TLB miss code
428 */ 428 */
429 linear_map_top = lmb_end_of_DRAM(); 429 linear_map_top = memblock_end_of_DRAM();
430 430
431 /* A sync won't hurt us after mucking around with 431 /* A sync won't hurt us after mucking around with
432 * the MMU configuration 432 * the MMU configuration
diff --git a/arch/powerpc/platforms/85xx/corenet_ds.c b/arch/powerpc/platforms/85xx/corenet_ds.c
index 534c2ecc89d9..2ab338c9ac37 100644
--- a/arch/powerpc/platforms/85xx/corenet_ds.c
+++ b/arch/powerpc/platforms/85xx/corenet_ds.c
@@ -16,7 +16,7 @@
16#include <linux/kdev_t.h> 16#include <linux/kdev_t.h>
17#include <linux/delay.h> 17#include <linux/delay.h>
18#include <linux/interrupt.h> 18#include <linux/interrupt.h>
19#include <linux/lmb.h> 19#include <linux/memblock.h>
20 20
21#include <asm/system.h> 21#include <asm/system.h>
22#include <asm/time.h> 22#include <asm/time.h>
@@ -100,7 +100,7 @@ void __init corenet_ds_setup_arch(void)
100#endif 100#endif
101 101
102#ifdef CONFIG_SWIOTLB 102#ifdef CONFIG_SWIOTLB
103 if (lmb_end_of_DRAM() > max) { 103 if (memblock_end_of_DRAM() > max) {
104 ppc_swiotlb_enable = 1; 104 ppc_swiotlb_enable = 1;
105 set_pci_dma_ops(&swiotlb_dma_ops); 105 set_pci_dma_ops(&swiotlb_dma_ops);
106 ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb; 106 ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
diff --git a/arch/powerpc/platforms/85xx/mpc8536_ds.c b/arch/powerpc/platforms/85xx/mpc8536_ds.c
index 004b7d36cdb7..f79f2f102141 100644
--- a/arch/powerpc/platforms/85xx/mpc8536_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc8536_ds.c
@@ -17,7 +17,7 @@
17#include <linux/seq_file.h> 17#include <linux/seq_file.h>
18#include <linux/interrupt.h> 18#include <linux/interrupt.h>
19#include <linux/of_platform.h> 19#include <linux/of_platform.h>
20#include <linux/lmb.h> 20#include <linux/memblock.h>
21 21
22#include <asm/system.h> 22#include <asm/system.h>
23#include <asm/time.h> 23#include <asm/time.h>
@@ -94,7 +94,7 @@ static void __init mpc8536_ds_setup_arch(void)
94#endif 94#endif
95 95
96#ifdef CONFIG_SWIOTLB 96#ifdef CONFIG_SWIOTLB
97 if (lmb_end_of_DRAM() > max) { 97 if (memblock_end_of_DRAM() > max) {
98 ppc_swiotlb_enable = 1; 98 ppc_swiotlb_enable = 1;
99 set_pci_dma_ops(&swiotlb_dma_ops); 99 set_pci_dma_ops(&swiotlb_dma_ops);
100 ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb; 100 ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ds.c b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
index 544011a562fb..8190bc25bf27 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_ds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ds.c
@@ -20,7 +20,7 @@
20#include <linux/seq_file.h> 20#include <linux/seq_file.h>
21#include <linux/interrupt.h> 21#include <linux/interrupt.h>
22#include <linux/of_platform.h> 22#include <linux/of_platform.h>
23#include <linux/lmb.h> 23#include <linux/memblock.h>
24 24
25#include <asm/system.h> 25#include <asm/system.h>
26#include <asm/time.h> 26#include <asm/time.h>
@@ -190,7 +190,7 @@ static void __init mpc85xx_ds_setup_arch(void)
190#endif 190#endif
191 191
192#ifdef CONFIG_SWIOTLB 192#ifdef CONFIG_SWIOTLB
193 if (lmb_end_of_DRAM() > max) { 193 if (memblock_end_of_DRAM() > max) {
194 ppc_swiotlb_enable = 1; 194 ppc_swiotlb_enable = 1;
195 set_pci_dma_ops(&swiotlb_dma_ops); 195 set_pci_dma_ops(&swiotlb_dma_ops);
196 ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb; 196 ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_mds.c b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
index 8fe87fc61485..494513682d70 100644
--- a/arch/powerpc/platforms/85xx/mpc85xx_mds.c
+++ b/arch/powerpc/platforms/85xx/mpc85xx_mds.c
@@ -33,7 +33,7 @@
33#include <linux/of_platform.h> 33#include <linux/of_platform.h>
34#include <linux/of_device.h> 34#include <linux/of_device.h>
35#include <linux/phy.h> 35#include <linux/phy.h>
36#include <linux/lmb.h> 36#include <linux/memblock.h>
37 37
38#include <asm/system.h> 38#include <asm/system.h>
39#include <asm/atomic.h> 39#include <asm/atomic.h>
@@ -325,7 +325,7 @@ static void __init mpc85xx_mds_setup_arch(void)
325#endif /* CONFIG_QUICC_ENGINE */ 325#endif /* CONFIG_QUICC_ENGINE */
326 326
327#ifdef CONFIG_SWIOTLB 327#ifdef CONFIG_SWIOTLB
328 if (lmb_end_of_DRAM() > max) { 328 if (memblock_end_of_DRAM() > max) {
329 ppc_swiotlb_enable = 1; 329 ppc_swiotlb_enable = 1;
330 set_pci_dma_ops(&swiotlb_dma_ops); 330 set_pci_dma_ops(&swiotlb_dma_ops);
331 ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb; 331 ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
diff --git a/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c b/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
index 2aa69a69bcc8..b11c3535f350 100644
--- a/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
+++ b/arch/powerpc/platforms/86xx/mpc86xx_hpcn.c
@@ -19,7 +19,7 @@
19#include <linux/delay.h> 19#include <linux/delay.h>
20#include <linux/seq_file.h> 20#include <linux/seq_file.h>
21#include <linux/of_platform.h> 21#include <linux/of_platform.h>
22#include <linux/lmb.h> 22#include <linux/memblock.h>
23 23
24#include <asm/system.h> 24#include <asm/system.h>
25#include <asm/time.h> 25#include <asm/time.h>
@@ -103,7 +103,7 @@ mpc86xx_hpcn_setup_arch(void)
103#endif 103#endif
104 104
105#ifdef CONFIG_SWIOTLB 105#ifdef CONFIG_SWIOTLB
106 if (lmb_end_of_DRAM() > max) { 106 if (memblock_end_of_DRAM() > max) {
107 ppc_swiotlb_enable = 1; 107 ppc_swiotlb_enable = 1;
108 set_pci_dma_ops(&swiotlb_dma_ops); 108 set_pci_dma_ops(&swiotlb_dma_ops);
109 ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb; 109 ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
diff --git a/arch/powerpc/platforms/cell/iommu.c b/arch/powerpc/platforms/cell/iommu.c
index 4326b737d913..3712900471ba 100644
--- a/arch/powerpc/platforms/cell/iommu.c
+++ b/arch/powerpc/platforms/cell/iommu.c
@@ -29,7 +29,7 @@
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/slab.h> 31#include <linux/slab.h>
32#include <linux/lmb.h> 32#include <linux/memblock.h>
33 33
34#include <asm/prom.h> 34#include <asm/prom.h>
35#include <asm/iommu.h> 35#include <asm/iommu.h>
@@ -845,10 +845,10 @@ static int __init cell_iommu_init_disabled(void)
845 /* If we found a DMA window, we check if it's big enough to enclose 845 /* If we found a DMA window, we check if it's big enough to enclose
846 * all of physical memory. If not, we force enable IOMMU 846 * all of physical memory. If not, we force enable IOMMU
847 */ 847 */
848 if (np && size < lmb_end_of_DRAM()) { 848 if (np && size < memblock_end_of_DRAM()) {
849 printk(KERN_WARNING "iommu: force-enabled, dma window" 849 printk(KERN_WARNING "iommu: force-enabled, dma window"
850 " (%ldMB) smaller than total memory (%lldMB)\n", 850 " (%ldMB) smaller than total memory (%lldMB)\n",
851 size >> 20, lmb_end_of_DRAM() >> 20); 851 size >> 20, memblock_end_of_DRAM() >> 20);
852 return -ENODEV; 852 return -ENODEV;
853 } 853 }
854 854
@@ -1064,7 +1064,7 @@ static int __init cell_iommu_fixed_mapping_init(void)
1064 } 1064 }
1065 1065
1066 fbase = _ALIGN_UP(fbase, 1 << IO_SEGMENT_SHIFT); 1066 fbase = _ALIGN_UP(fbase, 1 << IO_SEGMENT_SHIFT);
1067 fsize = lmb_phys_mem_size(); 1067 fsize = memblock_phys_mem_size();
1068 1068
1069 if ((fbase + fsize) <= 0x800000000ul) 1069 if ((fbase + fsize) <= 0x800000000ul)
1070 hbase = 0; /* use the device tree window */ 1070 hbase = 0; /* use the device tree window */
@@ -1169,7 +1169,7 @@ static int __init cell_iommu_init(void)
1169 * Note: should we make sure we have the IOMMU actually disabled ? 1169 * Note: should we make sure we have the IOMMU actually disabled ?
1170 */ 1170 */
1171 if (iommu_is_off || 1171 if (iommu_is_off ||
1172 (!iommu_force_on && lmb_end_of_DRAM() <= 0x80000000ull)) 1172 (!iommu_force_on && memblock_end_of_DRAM() <= 0x80000000ull))
1173 if (cell_iommu_init_disabled() == 0) 1173 if (cell_iommu_init_disabled() == 0)
1174 goto bail; 1174 goto bail;
1175 1175
diff --git a/arch/powerpc/platforms/embedded6xx/wii.c b/arch/powerpc/platforms/embedded6xx/wii.c
index 174a04ac4806..5cdcc7c8d973 100644
--- a/arch/powerpc/platforms/embedded6xx/wii.c
+++ b/arch/powerpc/platforms/embedded6xx/wii.c
@@ -20,7 +20,7 @@
20#include <linux/seq_file.h> 20#include <linux/seq_file.h>
21#include <linux/kexec.h> 21#include <linux/kexec.h>
22#include <linux/of_platform.h> 22#include <linux/of_platform.h>
23#include <linux/lmb.h> 23#include <linux/memblock.h>
24#include <mm/mmu_decl.h> 24#include <mm/mmu_decl.h>
25 25
26#include <asm/io.h> 26#include <asm/io.h>
@@ -65,7 +65,7 @@ static int __init page_aligned(unsigned long x)
65 65
66void __init wii_memory_fixups(void) 66void __init wii_memory_fixups(void)
67{ 67{
68 struct lmb_property *p = lmb.memory.region; 68 struct memblock_property *p = memblock.memory.region;
69 69
70 /* 70 /*
71 * This is part of a workaround to allow the use of two 71 * This is part of a workaround to allow the use of two
@@ -77,7 +77,7 @@ void __init wii_memory_fixups(void)
77 * between both ranges. 77 * between both ranges.
78 */ 78 */
79 79
80 BUG_ON(lmb.memory.cnt != 2); 80 BUG_ON(memblock.memory.cnt != 2);
81 BUG_ON(!page_aligned(p[0].base) || !page_aligned(p[1].base)); 81 BUG_ON(!page_aligned(p[0].base) || !page_aligned(p[1].base));
82 82
83 p[0].size = _ALIGN_DOWN(p[0].size, PAGE_SIZE); 83 p[0].size = _ALIGN_DOWN(p[0].size, PAGE_SIZE);
@@ -92,11 +92,11 @@ void __init wii_memory_fixups(void)
92 92
93 p[0].size += wii_hole_size + p[1].size; 93 p[0].size += wii_hole_size + p[1].size;
94 94
95 lmb.memory.cnt = 1; 95 memblock.memory.cnt = 1;
96 lmb_analyze(); 96 memblock_analyze();
97 97
98 /* reserve the hole */ 98 /* reserve the hole */
99 lmb_reserve(wii_hole_start, wii_hole_size); 99 memblock_reserve(wii_hole_start, wii_hole_size);
100 100
101 /* allow ioremapping the address space in the hole */ 101 /* allow ioremapping the address space in the hole */
102 __allow_ioremap_reserved = 1; 102 __allow_ioremap_reserved = 1;
diff --git a/arch/powerpc/platforms/maple/setup.c b/arch/powerpc/platforms/maple/setup.c
index 39df70529d29..3fff8d979b41 100644
--- a/arch/powerpc/platforms/maple/setup.c
+++ b/arch/powerpc/platforms/maple/setup.c
@@ -41,7 +41,7 @@
41#include <linux/smp.h> 41#include <linux/smp.h>
42#include <linux/bitops.h> 42#include <linux/bitops.h>
43#include <linux/of_device.h> 43#include <linux/of_device.h>
44#include <linux/lmb.h> 44#include <linux/memblock.h>
45 45
46#include <asm/processor.h> 46#include <asm/processor.h>
47#include <asm/sections.h> 47#include <asm/sections.h>
diff --git a/arch/powerpc/platforms/pasemi/iommu.c b/arch/powerpc/platforms/pasemi/iommu.c
index 7b1d608ea3c8..1f9fb2c57761 100644
--- a/arch/powerpc/platforms/pasemi/iommu.c
+++ b/arch/powerpc/platforms/pasemi/iommu.c
@@ -204,7 +204,7 @@ int __init iob_init(struct device_node *dn)
204 pr_debug(" -> %s\n", __func__); 204 pr_debug(" -> %s\n", __func__);
205 205
206 /* Allocate a spare page to map all invalid IOTLB pages. */ 206 /* Allocate a spare page to map all invalid IOTLB pages. */
207 tmp = lmb_alloc(IOBMAP_PAGE_SIZE, IOBMAP_PAGE_SIZE); 207 tmp = memblock_alloc(IOBMAP_PAGE_SIZE, IOBMAP_PAGE_SIZE);
208 if (!tmp) 208 if (!tmp)
209 panic("IOBMAP: Cannot allocate spare page!"); 209 panic("IOBMAP: Cannot allocate spare page!");
210 /* Empty l1 is marked invalid */ 210 /* Empty l1 is marked invalid */
@@ -275,7 +275,7 @@ void __init alloc_iobmap_l2(void)
275 return; 275 return;
276#endif 276#endif
277 /* For 2G space, 8x64 pages (2^21 bytes) is max total l2 size */ 277 /* For 2G space, 8x64 pages (2^21 bytes) is max total l2 size */
278 iob_l2_base = (u32 *)abs_to_virt(lmb_alloc_base(1UL<<21, 1UL<<21, 0x80000000)); 278 iob_l2_base = (u32 *)abs_to_virt(memblock_alloc_base(1UL<<21, 1UL<<21, 0x80000000));
279 279
280 printk(KERN_INFO "IOBMAP L2 allocated at: %p\n", iob_l2_base); 280 printk(KERN_INFO "IOBMAP L2 allocated at: %p\n", iob_l2_base);
281} 281}
diff --git a/arch/powerpc/platforms/powermac/setup.c b/arch/powerpc/platforms/powermac/setup.c
index f1d0132ebcc7..9deb274841f1 100644
--- a/arch/powerpc/platforms/powermac/setup.c
+++ b/arch/powerpc/platforms/powermac/setup.c
@@ -51,7 +51,7 @@
51#include <linux/suspend.h> 51#include <linux/suspend.h>
52#include <linux/of_device.h> 52#include <linux/of_device.h>
53#include <linux/of_platform.h> 53#include <linux/of_platform.h>
54#include <linux/lmb.h> 54#include <linux/memblock.h>
55 55
56#include <asm/reg.h> 56#include <asm/reg.h>
57#include <asm/sections.h> 57#include <asm/sections.h>
@@ -619,7 +619,7 @@ static int __init pmac_probe(void)
619 * driver needs that. We have to allocate it now. We allocate 4k 619 * driver needs that. We have to allocate it now. We allocate 4k
620 * (1 small page) for now. 620 * (1 small page) for now.
621 */ 621 */
622 smu_cmdbuf_abs = lmb_alloc_base(4096, 4096, 0x80000000UL); 622 smu_cmdbuf_abs = memblock_alloc_base(4096, 4096, 0x80000000UL);
623#endif /* CONFIG_PMAC_SMU */ 623#endif /* CONFIG_PMAC_SMU */
624 624
625 return 1; 625 return 1;
diff --git a/arch/powerpc/platforms/ps3/htab.c b/arch/powerpc/platforms/ps3/htab.c
index 1e8a1e39dfe8..2c0ed87f2024 100644
--- a/arch/powerpc/platforms/ps3/htab.c
+++ b/arch/powerpc/platforms/ps3/htab.c
@@ -19,7 +19,7 @@
19 */ 19 */
20 20
21#include <linux/kernel.h> 21#include <linux/kernel.h>
22#include <linux/lmb.h> 22#include <linux/memblock.h>
23 23
24#include <asm/machdep.h> 24#include <asm/machdep.h>
25#include <asm/prom.h> 25#include <asm/prom.h>
diff --git a/arch/powerpc/platforms/ps3/mm.c b/arch/powerpc/platforms/ps3/mm.c
index 7925751e464a..c2045880e674 100644
--- a/arch/powerpc/platforms/ps3/mm.c
+++ b/arch/powerpc/platforms/ps3/mm.c
@@ -21,7 +21,7 @@
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#include <linux/memblock.h>
25#include <linux/slab.h> 25#include <linux/slab.h>
26 26
27#include <asm/cell-regs.h> 27#include <asm/cell-regs.h>
@@ -318,8 +318,8 @@ static int __init ps3_mm_add_memory(void)
318 return result; 318 return result;
319 } 319 }
320 320
321 lmb_add(start_addr, map.r1.size); 321 memblock_add(start_addr, map.r1.size);
322 lmb_analyze(); 322 memblock_analyze();
323 323
324 result = online_pages(start_pfn, nr_pages); 324 result = online_pages(start_pfn, nr_pages);
325 325
diff --git a/arch/powerpc/platforms/ps3/os-area.c b/arch/powerpc/platforms/ps3/os-area.c
index dd521a181f23..5b759b669598 100644
--- a/arch/powerpc/platforms/ps3/os-area.c
+++ b/arch/powerpc/platforms/ps3/os-area.c
@@ -24,7 +24,7 @@
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#include <linux/memblock.h>
28#include <linux/of.h> 28#include <linux/of.h>
29#include <linux/slab.h> 29#include <linux/slab.h>
30 30
@@ -723,7 +723,7 @@ static void os_area_queue_work(void)
723 * flash to a high address in the boot memory region and then puts that RAM 723 * flash to a high address in the boot memory region and then puts that RAM
724 * address and the byte count into the repository for retrieval by the guest. 724 * address and the byte count into the repository for retrieval by the guest.
725 * We copy the data we want into a static variable and allow the memory setup 725 * We copy the data we want into a static variable and allow the memory setup
726 * by the HV to be claimed by the lmb manager. 726 * by the HV to be claimed by the memblock manager.
727 * 727 *
728 * The os area mirror will not be available to a second stage kernel, and 728 * The os area mirror will not be available to a second stage kernel, and
729 * the header verify will fail. In this case, the saved_params values will 729 * the header verify will fail. In this case, the saved_params values will
diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c
index 01e7b5bb3c1d..deab5f946090 100644
--- a/arch/powerpc/platforms/pseries/hotplug-memory.c
+++ b/arch/powerpc/platforms/pseries/hotplug-memory.c
@@ -10,14 +10,14 @@
10 */ 10 */
11 11
12#include <linux/of.h> 12#include <linux/of.h>
13#include <linux/lmb.h> 13#include <linux/memblock.h>
14#include <linux/vmalloc.h> 14#include <linux/vmalloc.h>
15#include <asm/firmware.h> 15#include <asm/firmware.h>
16#include <asm/machdep.h> 16#include <asm/machdep.h>
17#include <asm/pSeries_reconfig.h> 17#include <asm/pSeries_reconfig.h>
18#include <asm/sparsemem.h> 18#include <asm/sparsemem.h>
19 19
20static int pseries_remove_lmb(unsigned long base, unsigned int lmb_size) 20static int pseries_remove_memblock(unsigned long base, unsigned int memblock_size)
21{ 21{
22 unsigned long start, start_pfn; 22 unsigned long start, start_pfn;
23 struct zone *zone; 23 struct zone *zone;
@@ -26,7 +26,7 @@ static int pseries_remove_lmb(unsigned long base, unsigned int lmb_size)
26 start_pfn = base >> PAGE_SHIFT; 26 start_pfn = base >> PAGE_SHIFT;
27 27
28 if (!pfn_valid(start_pfn)) { 28 if (!pfn_valid(start_pfn)) {
29 lmb_remove(base, lmb_size); 29 memblock_remove(base, memblock_size);
30 return 0; 30 return 0;
31 } 31 }
32 32
@@ -41,20 +41,20 @@ static int pseries_remove_lmb(unsigned long base, unsigned int lmb_size)
41 * to sysfs "state" file and we can't remove sysfs entries 41 * to sysfs "state" file and we can't remove sysfs entries
42 * while writing to it. So we have to defer it to here. 42 * while writing to it. So we have to defer it to here.
43 */ 43 */
44 ret = __remove_pages(zone, start_pfn, lmb_size >> PAGE_SHIFT); 44 ret = __remove_pages(zone, start_pfn, memblock_size >> PAGE_SHIFT);
45 if (ret) 45 if (ret)
46 return ret; 46 return ret;
47 47
48 /* 48 /*
49 * Update memory regions for memory remove 49 * Update memory regions for memory remove
50 */ 50 */
51 lmb_remove(base, lmb_size); 51 memblock_remove(base, memblock_size);
52 52
53 /* 53 /*
54 * Remove htab bolted mappings for this section of memory 54 * Remove htab bolted mappings for this section of memory
55 */ 55 */
56 start = (unsigned long)__va(base); 56 start = (unsigned long)__va(base);
57 ret = remove_section_mapping(start, start + lmb_size); 57 ret = remove_section_mapping(start, start + memblock_size);
58 58
59 /* Ensure all vmalloc mappings are flushed in case they also 59 /* Ensure all vmalloc mappings are flushed in case they also
60 * hit that section of memory 60 * hit that section of memory
@@ -69,7 +69,7 @@ static int pseries_remove_memory(struct device_node *np)
69 const char *type; 69 const char *type;
70 const unsigned int *regs; 70 const unsigned int *regs;
71 unsigned long base; 71 unsigned long base;
72 unsigned int lmb_size; 72 unsigned int memblock_size;
73 int ret = -EINVAL; 73 int ret = -EINVAL;
74 74
75 /* 75 /*
@@ -80,16 +80,16 @@ static int pseries_remove_memory(struct device_node *np)
80 return 0; 80 return 0;
81 81
82 /* 82 /*
83 * Find the bae address and size of the lmb 83 * Find the bae address and size of the memblock
84 */ 84 */
85 regs = of_get_property(np, "reg", NULL); 85 regs = of_get_property(np, "reg", NULL);
86 if (!regs) 86 if (!regs)
87 return ret; 87 return ret;
88 88
89 base = *(unsigned long *)regs; 89 base = *(unsigned long *)regs;
90 lmb_size = regs[3]; 90 memblock_size = regs[3];
91 91
92 ret = pseries_remove_lmb(base, lmb_size); 92 ret = pseries_remove_memblock(base, memblock_size);
93 return ret; 93 return ret;
94} 94}
95 95
@@ -98,7 +98,7 @@ static int pseries_add_memory(struct device_node *np)
98 const char *type; 98 const char *type;
99 const unsigned int *regs; 99 const unsigned int *regs;
100 unsigned long base; 100 unsigned long base;
101 unsigned int lmb_size; 101 unsigned int memblock_size;
102 int ret = -EINVAL; 102 int ret = -EINVAL;
103 103
104 /* 104 /*
@@ -109,43 +109,43 @@ static int pseries_add_memory(struct device_node *np)
109 return 0; 109 return 0;
110 110
111 /* 111 /*
112 * Find the base and size of the lmb 112 * Find the base and size of the memblock
113 */ 113 */
114 regs = of_get_property(np, "reg", NULL); 114 regs = of_get_property(np, "reg", NULL);
115 if (!regs) 115 if (!regs)
116 return ret; 116 return ret;
117 117
118 base = *(unsigned long *)regs; 118 base = *(unsigned long *)regs;
119 lmb_size = regs[3]; 119 memblock_size = regs[3];
120 120
121 /* 121 /*
122 * Update memory region to represent the memory add 122 * Update memory region to represent the memory add
123 */ 123 */
124 ret = lmb_add(base, lmb_size); 124 ret = memblock_add(base, memblock_size);
125 return (ret < 0) ? -EINVAL : 0; 125 return (ret < 0) ? -EINVAL : 0;
126} 126}
127 127
128static int pseries_drconf_memory(unsigned long *base, unsigned int action) 128static int pseries_drconf_memory(unsigned long *base, unsigned int action)
129{ 129{
130 struct device_node *np; 130 struct device_node *np;
131 const unsigned long *lmb_size; 131 const unsigned long *memblock_size;
132 int rc; 132 int rc;
133 133
134 np = of_find_node_by_path("/ibm,dynamic-reconfiguration-memory"); 134 np = of_find_node_by_path("/ibm,dynamic-reconfiguration-memory");
135 if (!np) 135 if (!np)
136 return -EINVAL; 136 return -EINVAL;
137 137
138 lmb_size = of_get_property(np, "ibm,lmb-size", NULL); 138 memblock_size = of_get_property(np, "ibm,memblock-size", NULL);
139 if (!lmb_size) { 139 if (!memblock_size) {
140 of_node_put(np); 140 of_node_put(np);
141 return -EINVAL; 141 return -EINVAL;
142 } 142 }
143 143
144 if (action == PSERIES_DRCONF_MEM_ADD) { 144 if (action == PSERIES_DRCONF_MEM_ADD) {
145 rc = lmb_add(*base, *lmb_size); 145 rc = memblock_add(*base, *memblock_size);
146 rc = (rc < 0) ? -EINVAL : 0; 146 rc = (rc < 0) ? -EINVAL : 0;
147 } else if (action == PSERIES_DRCONF_MEM_REMOVE) { 147 } else if (action == PSERIES_DRCONF_MEM_REMOVE) {
148 rc = pseries_remove_lmb(*base, *lmb_size); 148 rc = pseries_remove_memblock(*base, *memblock_size);
149 } else { 149 } else {
150 rc = -EINVAL; 150 rc = -EINVAL;
151 } 151 }
diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c
index d26182d42cbf..395848e30c52 100644
--- a/arch/powerpc/platforms/pseries/iommu.c
+++ b/arch/powerpc/platforms/pseries/iommu.c
@@ -66,7 +66,7 @@ static int tce_build_pSeries(struct iommu_table *tbl, long index,
66 tcep = ((u64 *)tbl->it_base) + index; 66 tcep = ((u64 *)tbl->it_base) + index;
67 67
68 while (npages--) { 68 while (npages--) {
69 /* can't move this out since we might cross LMB boundary */ 69 /* can't move this out since we might cross MEMBLOCK boundary */
70 rpn = (virt_to_abs(uaddr)) >> TCE_SHIFT; 70 rpn = (virt_to_abs(uaddr)) >> TCE_SHIFT;
71 *tcep = proto_tce | (rpn & TCE_RPN_MASK) << TCE_RPN_SHIFT; 71 *tcep = proto_tce | (rpn & TCE_RPN_MASK) << TCE_RPN_SHIFT;
72 72
diff --git a/arch/powerpc/platforms/pseries/phyp_dump.c b/arch/powerpc/platforms/pseries/phyp_dump.c
index 7ebd9e88d369..6e7742da0072 100644
--- a/arch/powerpc/platforms/pseries/phyp_dump.c
+++ b/arch/powerpc/platforms/pseries/phyp_dump.c
@@ -255,12 +255,12 @@ void invalidate_last_dump(struct phyp_dump_header *ph, unsigned long addr)
255 255
256/* ------------------------------------------------- */ 256/* ------------------------------------------------- */
257/** 257/**
258 * release_memory_range -- release memory previously lmb_reserved 258 * release_memory_range -- release memory previously memblock_reserved
259 * @start_pfn: starting physical frame number 259 * @start_pfn: starting physical frame number
260 * @nr_pages: number of pages to free. 260 * @nr_pages: number of pages to free.
261 * 261 *
262 * This routine will release memory that had been previously 262 * This routine will release memory that had been previously
263 * lmb_reserved in early boot. The released memory becomes 263 * memblock_reserved in early boot. The released memory becomes
264 * available for genreal use. 264 * available for genreal use.
265 */ 265 */
266static void release_memory_range(unsigned long start_pfn, 266static void release_memory_range(unsigned long start_pfn,
diff --git a/arch/powerpc/sysdev/dart_iommu.c b/arch/powerpc/sysdev/dart_iommu.c
index c8b96ed7c015..559db2b846a9 100644
--- a/arch/powerpc/sysdev/dart_iommu.c
+++ b/arch/powerpc/sysdev/dart_iommu.c
@@ -36,7 +36,7 @@
36#include <linux/dma-mapping.h> 36#include <linux/dma-mapping.h>
37#include <linux/vmalloc.h> 37#include <linux/vmalloc.h>
38#include <linux/suspend.h> 38#include <linux/suspend.h>
39#include <linux/lmb.h> 39#include <linux/memblock.h>
40#include <linux/gfp.h> 40#include <linux/gfp.h>
41#include <asm/io.h> 41#include <asm/io.h>
42#include <asm/prom.h> 42#include <asm/prom.h>
@@ -232,7 +232,7 @@ static int __init dart_init(struct device_node *dart_node)
232 * that to work around what looks like a problem with the HT bridge 232 * that to work around what looks like a problem with the HT bridge
233 * prefetching into invalid pages and corrupting data 233 * prefetching into invalid pages and corrupting data
234 */ 234 */
235 tmp = lmb_alloc(DART_PAGE_SIZE, DART_PAGE_SIZE); 235 tmp = memblock_alloc(DART_PAGE_SIZE, DART_PAGE_SIZE);
236 dart_emptyval = DARTMAP_VALID | ((tmp >> DART_PAGE_SHIFT) & 236 dart_emptyval = DARTMAP_VALID | ((tmp >> DART_PAGE_SHIFT) &
237 DARTMAP_RPNMASK); 237 DARTMAP_RPNMASK);
238 238
@@ -407,7 +407,7 @@ void __init alloc_dart_table(void)
407 if (iommu_is_off) 407 if (iommu_is_off)
408 return; 408 return;
409 409
410 if (!iommu_force_on && lmb_end_of_DRAM() <= 0x40000000ull) 410 if (!iommu_force_on && memblock_end_of_DRAM() <= 0x40000000ull)
411 return; 411 return;
412 412
413 /* 512 pages (2MB) is max DART tablesize. */ 413 /* 512 pages (2MB) is max DART tablesize. */
@@ -416,7 +416,7 @@ void __init alloc_dart_table(void)
416 * will blow up an entire large page anyway in the kernel mapping 416 * will blow up an entire large page anyway in the kernel mapping
417 */ 417 */
418 dart_tablebase = (unsigned long) 418 dart_tablebase = (unsigned long)
419 abs_to_virt(lmb_alloc_base(1UL<<24, 1UL<<24, 0x80000000L)); 419 abs_to_virt(memblock_alloc_base(1UL<<24, 1UL<<24, 0x80000000L));
420 420
421 printk(KERN_INFO "DART table allocated at: %lx\n", dart_tablebase); 421 printk(KERN_INFO "DART table allocated at: %lx\n", dart_tablebase);
422} 422}
diff --git a/arch/powerpc/sysdev/fsl_pci.c b/arch/powerpc/sysdev/fsl_pci.c
index a14760fe513a..356c6a0e1b23 100644
--- a/arch/powerpc/sysdev/fsl_pci.c
+++ b/arch/powerpc/sysdev/fsl_pci.c
@@ -23,7 +23,7 @@
23#include <linux/string.h> 23#include <linux/string.h>
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/bootmem.h> 25#include <linux/bootmem.h>
26#include <linux/lmb.h> 26#include <linux/memblock.h>
27#include <linux/log2.h> 27#include <linux/log2.h>
28#include <linux/slab.h> 28#include <linux/slab.h>
29 29
@@ -190,7 +190,7 @@ static void __init setup_pci_atmu(struct pci_controller *hose,
190 pr_info("%s: PCICSRBAR @ 0x%x\n", name, pcicsrbar); 190 pr_info("%s: PCICSRBAR @ 0x%x\n", name, pcicsrbar);
191 191
192 /* Setup inbound mem window */ 192 /* Setup inbound mem window */
193 mem = lmb_end_of_DRAM(); 193 mem = memblock_end_of_DRAM();
194 sz = min(mem, paddr_lo); 194 sz = min(mem, paddr_lo);
195 mem_log = __ilog2_u64(sz); 195 mem_log = __ilog2_u64(sz);
196 196
diff --git a/arch/powerpc/sysdev/micropatch.c b/arch/powerpc/sysdev/micropatch.c
index d8d602840757..c0bb76ef7242 100644
--- a/arch/powerpc/sysdev/micropatch.c
+++ b/arch/powerpc/sysdev/micropatch.c
@@ -4,6 +4,7 @@
4 * also relocates SMC2, but this would require additional changes 4 * also relocates SMC2, but this would require additional changes
5 * to uart.c, so I am holding off on that for a moment. 5 * to uart.c, so I am holding off on that for a moment.
6 */ 6 */
7#include <linux/init.h>
7#include <linux/errno.h> 8#include <linux/errno.h>
8#include <linux/sched.h> 9#include <linux/sched.h>
9#include <linux/kernel.h> 10#include <linux/kernel.h>
@@ -16,6 +17,7 @@
16#include <asm/page.h> 17#include <asm/page.h>
17#include <asm/pgtable.h> 18#include <asm/pgtable.h>
18#include <asm/8xx_immap.h> 19#include <asm/8xx_immap.h>
20#include <asm/cpm.h>
19#include <asm/cpm1.h> 21#include <asm/cpm1.h>
20 22
21/* 23/*
@@ -24,7 +26,7 @@
24 26
25#ifdef CONFIG_I2C_SPI_UCODE_PATCH 27#ifdef CONFIG_I2C_SPI_UCODE_PATCH
26 28
27uint patch_2000[] = { 29static uint patch_2000[] __initdata = {
28 0x7FFFEFD9, 30 0x7FFFEFD9,
29 0x3FFD0000, 31 0x3FFD0000,
30 0x7FFB49F7, 32 0x7FFB49F7,
@@ -143,7 +145,7 @@ uint patch_2000[] = {
143 0x5F8247F8 145 0x5F8247F8
144}; 146};
145 147
146uint patch_2f00[] = { 148static uint patch_2f00[] __initdata = {
147 0x3E303430, 149 0x3E303430,
148 0x34343737, 150 0x34343737,
149 0xABF7BF9B, 151 0xABF7BF9B,
@@ -182,7 +184,7 @@ uint patch_2f00[] = {
182 184
183#ifdef CONFIG_I2C_SPI_SMC1_UCODE_PATCH 185#ifdef CONFIG_I2C_SPI_SMC1_UCODE_PATCH
184 186
185uint patch_2000[] = { 187static uint patch_2000[] __initdata = {
186 0x3fff0000, 188 0x3fff0000,
187 0x3ffd0000, 189 0x3ffd0000,
188 0x3ffb0000, 190 0x3ffb0000,
@@ -505,7 +507,7 @@ uint patch_2000[] = {
505 0x6079e2bb 507 0x6079e2bb
506}; 508};
507 509
508uint patch_2f00[] = { 510static uint patch_2f00[] __initdata = {
509 0x30303030, 511 0x30303030,
510 0x3e3e3434, 512 0x3e3e3434,
511 0xabbf9b99, 513 0xabbf9b99,
@@ -572,7 +574,7 @@ uint patch_2f00[] = {
572 0xf22f3f23 574 0xf22f3f23
573}; 575};
574 576
575uint patch_2e00[] = { 577static uint patch_2e00[] __initdata = {
576 0x27eeeeee, 578 0x27eeeeee,
577 0xeeeeeeee, 579 0xeeeeeeee,
578 0xeeeeeeee, 580 0xeeeeeeee,
@@ -598,7 +600,7 @@ uint patch_2e00[] = {
598 600
599#ifdef CONFIG_USB_SOF_UCODE_PATCH 601#ifdef CONFIG_USB_SOF_UCODE_PATCH
600 602
601uint patch_2000[] = { 603static uint patch_2000[] __initdata = {
602 0x7fff0000, 604 0x7fff0000,
603 0x7ffd0000, 605 0x7ffd0000,
604 0x7ffb0000, 606 0x7ffb0000,
@@ -613,21 +615,25 @@ uint patch_2000[] = {
613 0x60750000 615 0x60750000
614}; 616};
615 617
616uint patch_2f00[] = { 618static uint patch_2f00[] __initdata = {
617 0x3030304c, 619 0x3030304c,
618 0xcab9e441, 620 0xcab9e441,
619 0xa1aaf220 621 0xa1aaf220
620}; 622};
621#endif 623#endif
622 624
623void 625void __init cpm_load_patch(cpm8xx_t *cp)
624cpm_load_patch(cpm8xx_t *cp)
625{ 626{
626 volatile uint *dp; /* Dual-ported RAM. */ 627 volatile uint *dp; /* Dual-ported RAM. */
627 volatile cpm8xx_t *commproc; 628 volatile cpm8xx_t *commproc;
629#if defined(CONFIG_I2C_SPI_UCODE_PATCH) || \
630 defined(CONFIG_I2C_SPI_SMC1_UCODE_PATCH)
628 volatile iic_t *iip; 631 volatile iic_t *iip;
629 volatile spi_t *spp; 632 volatile struct spi_pram *spp;
633#ifdef CONFIG_I2C_SPI_SMC1_UCODE_PATCH
630 volatile smc_uart_t *smp; 634 volatile smc_uart_t *smp;
635#endif
636#endif
631 int i; 637 int i;
632 638
633 commproc = cp; 639 commproc = cp;
@@ -668,8 +674,8 @@ cpm_load_patch(cpm8xx_t *cp)
668 /* Put SPI above the IIC, also 32-byte aligned. 674 /* Put SPI above the IIC, also 32-byte aligned.
669 */ 675 */
670 i = (RPBASE + sizeof(iic_t) + 31) & ~31; 676 i = (RPBASE + sizeof(iic_t) + 31) & ~31;
671 spp = (spi_t *)&commproc->cp_dparam[PROFF_SPI]; 677 spp = (struct spi_pram *)&commproc->cp_dparam[PROFF_SPI];
672 spp->spi_rpbase = i; 678 spp->rpbase = i;
673 679
674# if defined(CONFIG_I2C_SPI_UCODE_PATCH) 680# if defined(CONFIG_I2C_SPI_UCODE_PATCH)
675 commproc->cp_cpmcr1 = 0x802a; 681 commproc->cp_cpmcr1 = 0x802a;
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index 573fca1fbd9b..82868fee21fd 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -10,7 +10,7 @@ config SUPERH
10 select EMBEDDED 10 select EMBEDDED
11 select HAVE_CLK 11 select HAVE_CLK
12 select HAVE_IDE if HAS_IOPORT 12 select HAVE_IDE if HAS_IOPORT
13 select HAVE_LMB 13 select HAVE_MEMBLOCK
14 select HAVE_OPROFILE 14 select HAVE_OPROFILE
15 select HAVE_GENERIC_DMA_COHERENT 15 select HAVE_GENERIC_DMA_COHERENT
16 select HAVE_ARCH_TRACEHOOK 16 select HAVE_ARCH_TRACEHOOK
diff --git a/arch/sh/include/asm/lmb.h b/arch/sh/include/asm/lmb.h
deleted file mode 100644
index 9b437f657ffa..000000000000
--- a/arch/sh/include/asm/lmb.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef __ASM_SH_LMB_H
2#define __ASM_SH_LMB_H
3
4#define LMB_REAL_LIMIT 0
5
6#endif /* __ASM_SH_LMB_H */
diff --git a/arch/sh/include/asm/memblock.h b/arch/sh/include/asm/memblock.h
new file mode 100644
index 000000000000..dfe683b88075
--- /dev/null
+++ b/arch/sh/include/asm/memblock.h
@@ -0,0 +1,6 @@
1#ifndef __ASM_SH_MEMBLOCK_H
2#define __ASM_SH_MEMBLOCK_H
3
4#define MEMBLOCK_REAL_LIMIT 0
5
6#endif /* __ASM_SH_MEMBLOCK_H */
diff --git a/arch/sh/kernel/machine_kexec.c b/arch/sh/kernel/machine_kexec.c
index 5a559e666eb3..e2a3af31ff99 100644
--- a/arch/sh/kernel/machine_kexec.c
+++ b/arch/sh/kernel/machine_kexec.c
@@ -15,7 +15,7 @@
15#include <linux/numa.h> 15#include <linux/numa.h>
16#include <linux/ftrace.h> 16#include <linux/ftrace.h>
17#include <linux/suspend.h> 17#include <linux/suspend.h>
18#include <linux/lmb.h> 18#include <linux/memblock.h>
19#include <asm/pgtable.h> 19#include <asm/pgtable.h>
20#include <asm/pgalloc.h> 20#include <asm/pgalloc.h>
21#include <asm/mmu_context.h> 21#include <asm/mmu_context.h>
@@ -157,10 +157,10 @@ void __init reserve_crashkernel(void)
157 unsigned long long crash_size, crash_base; 157 unsigned long long crash_size, crash_base;
158 int ret; 158 int ret;
159 159
160 /* this is necessary because of lmb_phys_mem_size() */ 160 /* this is necessary because of memblock_phys_mem_size() */
161 lmb_analyze(); 161 memblock_analyze();
162 162
163 ret = parse_crashkernel(boot_command_line, lmb_phys_mem_size(), 163 ret = parse_crashkernel(boot_command_line, memblock_phys_mem_size(),
164 &crash_size, &crash_base); 164 &crash_size, &crash_base);
165 if (ret == 0 && crash_size > 0) { 165 if (ret == 0 && crash_size > 0) {
166 crashk_res.start = crash_base; 166 crashk_res.start = crash_base;
@@ -172,14 +172,14 @@ void __init reserve_crashkernel(void)
172 172
173 crash_size = PAGE_ALIGN(crashk_res.end - crashk_res.start + 1); 173 crash_size = PAGE_ALIGN(crashk_res.end - crashk_res.start + 1);
174 if (!crashk_res.start) { 174 if (!crashk_res.start) {
175 unsigned long max = lmb_end_of_DRAM() - memory_limit; 175 unsigned long max = memblock_end_of_DRAM() - memory_limit;
176 crashk_res.start = __lmb_alloc_base(crash_size, PAGE_SIZE, max); 176 crashk_res.start = __memblock_alloc_base(crash_size, PAGE_SIZE, max);
177 if (!crashk_res.start) { 177 if (!crashk_res.start) {
178 pr_err("crashkernel allocation failed\n"); 178 pr_err("crashkernel allocation failed\n");
179 goto disable; 179 goto disable;
180 } 180 }
181 } else { 181 } else {
182 ret = lmb_reserve(crashk_res.start, crash_size); 182 ret = memblock_reserve(crashk_res.start, crash_size);
183 if (unlikely(ret < 0)) { 183 if (unlikely(ret < 0)) {
184 pr_err("crashkernel reservation failed - " 184 pr_err("crashkernel reservation failed - "
185 "memory is in use\n"); 185 "memory is in use\n");
@@ -192,7 +192,7 @@ void __init reserve_crashkernel(void)
192 /* 192 /*
193 * Crash kernel trumps memory limit 193 * Crash kernel trumps memory limit
194 */ 194 */
195 if ((lmb_end_of_DRAM() - memory_limit) <= crashk_res.end) { 195 if ((memblock_end_of_DRAM() - memory_limit) <= crashk_res.end) {
196 memory_limit = 0; 196 memory_limit = 0;
197 pr_info("Disabled memory limit for crashkernel\n"); 197 pr_info("Disabled memory limit for crashkernel\n");
198 } 198 }
@@ -201,7 +201,7 @@ void __init reserve_crashkernel(void)
201 "for crashkernel (System RAM: %ldMB)\n", 201 "for crashkernel (System RAM: %ldMB)\n",
202 (unsigned long)(crash_size >> 20), 202 (unsigned long)(crash_size >> 20),
203 (unsigned long)(crashk_res.start), 203 (unsigned long)(crashk_res.start),
204 (unsigned long)(lmb_phys_mem_size() >> 20)); 204 (unsigned long)(memblock_phys_mem_size() >> 20));
205 205
206 return; 206 return;
207 207
diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c
index 272734681d29..e769401a78ba 100644
--- a/arch/sh/kernel/setup.c
+++ b/arch/sh/kernel/setup.c
@@ -30,7 +30,7 @@
30#include <linux/clk.h> 30#include <linux/clk.h>
31#include <linux/delay.h> 31#include <linux/delay.h>
32#include <linux/platform_device.h> 32#include <linux/platform_device.h>
33#include <linux/lmb.h> 33#include <linux/memblock.h>
34#include <asm/uaccess.h> 34#include <asm/uaccess.h>
35#include <asm/io.h> 35#include <asm/io.h>
36#include <asm/page.h> 36#include <asm/page.h>
@@ -141,10 +141,10 @@ void __init check_for_initrd(void)
141 goto disable; 141 goto disable;
142 } 142 }
143 143
144 if (unlikely(end > lmb_end_of_DRAM())) { 144 if (unlikely(end > memblock_end_of_DRAM())) {
145 pr_err("initrd extends beyond end of memory " 145 pr_err("initrd extends beyond end of memory "
146 "(0x%08lx > 0x%08lx)\ndisabling initrd\n", 146 "(0x%08lx > 0x%08lx)\ndisabling initrd\n",
147 end, (unsigned long)lmb_end_of_DRAM()); 147 end, (unsigned long)memblock_end_of_DRAM());
148 goto disable; 148 goto disable;
149 } 149 }
150 150
@@ -161,7 +161,7 @@ void __init check_for_initrd(void)
161 initrd_start = (unsigned long)__va(__pa(start)); 161 initrd_start = (unsigned long)__va(__pa(start));
162 initrd_end = initrd_start + INITRD_SIZE; 162 initrd_end = initrd_start + INITRD_SIZE;
163 163
164 lmb_reserve(__pa(initrd_start), INITRD_SIZE); 164 memblock_reserve(__pa(initrd_start), INITRD_SIZE);
165 165
166 return; 166 return;
167 167
diff --git a/arch/sh/mm/init.c b/arch/sh/mm/init.c
index 46f84de62469..d0e249100e98 100644
--- a/arch/sh/mm/init.c
+++ b/arch/sh/mm/init.c
@@ -16,7 +16,7 @@
16#include <linux/pagemap.h> 16#include <linux/pagemap.h>
17#include <linux/percpu.h> 17#include <linux/percpu.h>
18#include <linux/io.h> 18#include <linux/io.h>
19#include <linux/lmb.h> 19#include <linux/memblock.h>
20#include <linux/dma-mapping.h> 20#include <linux/dma-mapping.h>
21#include <asm/mmu_context.h> 21#include <asm/mmu_context.h>
22#include <asm/mmzone.h> 22#include <asm/mmzone.h>
@@ -33,7 +33,7 @@ pgd_t swapper_pg_dir[PTRS_PER_PGD];
33 33
34void __init generic_mem_init(void) 34void __init generic_mem_init(void)
35{ 35{
36 lmb_add(__MEMORY_START, __MEMORY_SIZE); 36 memblock_add(__MEMORY_START, __MEMORY_SIZE);
37} 37}
38 38
39void __init __weak plat_mem_setup(void) 39void __init __weak plat_mem_setup(void)
@@ -176,12 +176,12 @@ void __init allocate_pgdat(unsigned int nid)
176 get_pfn_range_for_nid(nid, &start_pfn, &end_pfn); 176 get_pfn_range_for_nid(nid, &start_pfn, &end_pfn);
177 177
178#ifdef CONFIG_NEED_MULTIPLE_NODES 178#ifdef CONFIG_NEED_MULTIPLE_NODES
179 phys = __lmb_alloc_base(sizeof(struct pglist_data), 179 phys = __memblock_alloc_base(sizeof(struct pglist_data),
180 SMP_CACHE_BYTES, end_pfn << PAGE_SHIFT); 180 SMP_CACHE_BYTES, end_pfn << PAGE_SHIFT);
181 /* Retry with all of system memory */ 181 /* Retry with all of system memory */
182 if (!phys) 182 if (!phys)
183 phys = __lmb_alloc_base(sizeof(struct pglist_data), 183 phys = __memblock_alloc_base(sizeof(struct pglist_data),
184 SMP_CACHE_BYTES, lmb_end_of_DRAM()); 184 SMP_CACHE_BYTES, memblock_end_of_DRAM());
185 if (!phys) 185 if (!phys)
186 panic("Can't allocate pgdat for node %d\n", nid); 186 panic("Can't allocate pgdat for node %d\n", nid);
187 187
@@ -212,7 +212,7 @@ static void __init bootmem_init_one_node(unsigned int nid)
212 212
213 total_pages = bootmem_bootmap_pages(p->node_spanned_pages); 213 total_pages = bootmem_bootmap_pages(p->node_spanned_pages);
214 214
215 paddr = lmb_alloc(total_pages << PAGE_SHIFT, PAGE_SIZE); 215 paddr = memblock_alloc(total_pages << PAGE_SHIFT, PAGE_SIZE);
216 if (!paddr) 216 if (!paddr)
217 panic("Can't allocate bootmap for nid[%d]\n", nid); 217 panic("Can't allocate bootmap for nid[%d]\n", nid);
218 218
@@ -227,9 +227,9 @@ static void __init bootmem_init_one_node(unsigned int nid)
227 */ 227 */
228 if (nid == 0) { 228 if (nid == 0) {
229 /* Reserve the sections we're already using. */ 229 /* Reserve the sections we're already using. */
230 for (i = 0; i < lmb.reserved.cnt; i++) 230 for (i = 0; i < memblock.reserved.cnt; i++)
231 reserve_bootmem(lmb.reserved.region[i].base, 231 reserve_bootmem(memblock.reserved.region[i].base,
232 lmb_size_bytes(&lmb.reserved, i), 232 memblock_size_bytes(&memblock.reserved, i),
233 BOOTMEM_DEFAULT); 233 BOOTMEM_DEFAULT);
234 } 234 }
235 235
@@ -241,10 +241,10 @@ static void __init do_init_bootmem(void)
241 int i; 241 int i;
242 242
243 /* Add active regions with valid PFNs. */ 243 /* Add active regions with valid PFNs. */
244 for (i = 0; i < lmb.memory.cnt; i++) { 244 for (i = 0; i < memblock.memory.cnt; i++) {
245 unsigned long start_pfn, end_pfn; 245 unsigned long start_pfn, end_pfn;
246 start_pfn = lmb.memory.region[i].base >> PAGE_SHIFT; 246 start_pfn = memblock.memory.region[i].base >> PAGE_SHIFT;
247 end_pfn = start_pfn + lmb_size_pages(&lmb.memory, i); 247 end_pfn = start_pfn + memblock_size_pages(&memblock.memory, i);
248 __add_active_range(0, start_pfn, end_pfn); 248 __add_active_range(0, start_pfn, end_pfn);
249 } 249 }
250 250
@@ -276,7 +276,7 @@ static void __init early_reserve_mem(void)
276 * this catches the (definitely buggy) case of us accidentally 276 * this catches the (definitely buggy) case of us accidentally
277 * initializing the bootmem allocator with an invalid RAM area. 277 * initializing the bootmem allocator with an invalid RAM area.
278 */ 278 */
279 lmb_reserve(__MEMORY_START + CONFIG_ZERO_PAGE_OFFSET, 279 memblock_reserve(__MEMORY_START + CONFIG_ZERO_PAGE_OFFSET,
280 (PFN_PHYS(start_pfn) + PAGE_SIZE - 1) - 280 (PFN_PHYS(start_pfn) + PAGE_SIZE - 1) -
281 (__MEMORY_START + CONFIG_ZERO_PAGE_OFFSET)); 281 (__MEMORY_START + CONFIG_ZERO_PAGE_OFFSET));
282 282
@@ -284,7 +284,7 @@ static void __init early_reserve_mem(void)
284 * Reserve physical pages below CONFIG_ZERO_PAGE_OFFSET. 284 * Reserve physical pages below CONFIG_ZERO_PAGE_OFFSET.
285 */ 285 */
286 if (CONFIG_ZERO_PAGE_OFFSET != 0) 286 if (CONFIG_ZERO_PAGE_OFFSET != 0)
287 lmb_reserve(__MEMORY_START, CONFIG_ZERO_PAGE_OFFSET); 287 memblock_reserve(__MEMORY_START, CONFIG_ZERO_PAGE_OFFSET);
288 288
289 /* 289 /*
290 * Handle additional early reservations 290 * Handle additional early reservations
@@ -299,27 +299,27 @@ void __init paging_init(void)
299 unsigned long vaddr, end; 299 unsigned long vaddr, end;
300 int nid; 300 int nid;
301 301
302 lmb_init(); 302 memblock_init();
303 303
304 sh_mv.mv_mem_init(); 304 sh_mv.mv_mem_init();
305 305
306 early_reserve_mem(); 306 early_reserve_mem();
307 307
308 lmb_enforce_memory_limit(memory_limit); 308 memblock_enforce_memory_limit(memory_limit);
309 lmb_analyze(); 309 memblock_analyze();
310 310
311 lmb_dump_all(); 311 memblock_dump_all();
312 312
313 /* 313 /*
314 * Determine low and high memory ranges: 314 * Determine low and high memory ranges:
315 */ 315 */
316 max_low_pfn = max_pfn = lmb_end_of_DRAM() >> PAGE_SHIFT; 316 max_low_pfn = max_pfn = memblock_end_of_DRAM() >> PAGE_SHIFT;
317 min_low_pfn = __MEMORY_START >> PAGE_SHIFT; 317 min_low_pfn = __MEMORY_START >> PAGE_SHIFT;
318 318
319 nodes_clear(node_online_map); 319 nodes_clear(node_online_map);
320 320
321 memory_start = (unsigned long)__va(__MEMORY_START); 321 memory_start = (unsigned long)__va(__MEMORY_START);
322 memory_end = memory_start + (memory_limit ?: lmb_phys_mem_size()); 322 memory_end = memory_start + (memory_limit ?: memblock_phys_mem_size());
323 323
324 uncached_init(); 324 uncached_init();
325 pmb_init(); 325 pmb_init();
diff --git a/arch/sh/mm/numa.c b/arch/sh/mm/numa.c
index a2e645f64a37..3d85225b9e95 100644
--- a/arch/sh/mm/numa.c
+++ b/arch/sh/mm/numa.c
@@ -9,7 +9,7 @@
9 */ 9 */
10#include <linux/module.h> 10#include <linux/module.h>
11#include <linux/bootmem.h> 11#include <linux/bootmem.h>
12#include <linux/lmb.h> 12#include <linux/memblock.h>
13#include <linux/mm.h> 13#include <linux/mm.h>
14#include <linux/numa.h> 14#include <linux/numa.h>
15#include <linux/pfn.h> 15#include <linux/pfn.h>
@@ -39,12 +39,12 @@ void __init setup_bootmem_node(int nid, unsigned long start, unsigned long end)
39 pmb_bolt_mapping((unsigned long)__va(start), start, end - start, 39 pmb_bolt_mapping((unsigned long)__va(start), start, end - start,
40 PAGE_KERNEL); 40 PAGE_KERNEL);
41 41
42 lmb_add(start, end - start); 42 memblock_add(start, end - start);
43 43
44 __add_active_range(nid, start_pfn, end_pfn); 44 __add_active_range(nid, start_pfn, end_pfn);
45 45
46 /* Node-local pgdat */ 46 /* Node-local pgdat */
47 NODE_DATA(nid) = __va(lmb_alloc_base(sizeof(struct pglist_data), 47 NODE_DATA(nid) = __va(memblock_alloc_base(sizeof(struct pglist_data),
48 SMP_CACHE_BYTES, end)); 48 SMP_CACHE_BYTES, end));
49 memset(NODE_DATA(nid), 0, sizeof(struct pglist_data)); 49 memset(NODE_DATA(nid), 0, sizeof(struct pglist_data));
50 50
@@ -54,7 +54,7 @@ void __init setup_bootmem_node(int nid, unsigned long start, unsigned long end)
54 54
55 /* Node-local bootmap */ 55 /* Node-local bootmap */
56 bootmap_pages = bootmem_bootmap_pages(end_pfn - start_pfn); 56 bootmap_pages = bootmem_bootmap_pages(end_pfn - start_pfn);
57 bootmem_paddr = lmb_alloc_base(bootmap_pages << PAGE_SHIFT, 57 bootmem_paddr = memblock_alloc_base(bootmap_pages << PAGE_SHIFT,
58 PAGE_SIZE, end); 58 PAGE_SIZE, end);
59 init_bootmem_node(NODE_DATA(nid), bootmem_paddr >> PAGE_SHIFT, 59 init_bootmem_node(NODE_DATA(nid), bootmem_paddr >> PAGE_SHIFT,
60 start_pfn, end_pfn); 60 start_pfn, end_pfn);
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 6f1470baa314..c0015db247ba 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -42,7 +42,7 @@ config SPARC64
42 select HAVE_FUNCTION_TRACE_MCOUNT_TEST 42 select HAVE_FUNCTION_TRACE_MCOUNT_TEST
43 select HAVE_KRETPROBES 43 select HAVE_KRETPROBES
44 select HAVE_KPROBES 44 select HAVE_KPROBES
45 select HAVE_LMB 45 select HAVE_MEMBLOCK
46 select HAVE_SYSCALL_WRAPPERS 46 select HAVE_SYSCALL_WRAPPERS
47 select HAVE_DYNAMIC_FTRACE 47 select HAVE_DYNAMIC_FTRACE
48 select HAVE_FTRACE_MCOUNT_RECORD 48 select HAVE_FTRACE_MCOUNT_RECORD
diff --git a/arch/sparc/configs/sparc64_defconfig b/arch/sparc/configs/sparc64_defconfig
index 259e3fd50993..1dc07a0014c1 100644
--- a/arch/sparc/configs/sparc64_defconfig
+++ b/arch/sparc/configs/sparc64_defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.34-rc3 3# Linux kernel version: 2.6.34
4# Sat Apr 3 15:49:56 2010 4# Wed May 26 21:14:01 2010
5# 5#
6CONFIG_64BIT=y 6CONFIG_64BIT=y
7CONFIG_SPARC=y 7CONFIG_SPARC=y
@@ -107,10 +107,9 @@ CONFIG_PERF_COUNTERS=y
107# CONFIG_DEBUG_PERF_USE_VMALLOC is not set 107# CONFIG_DEBUG_PERF_USE_VMALLOC is not set
108CONFIG_VM_EVENT_COUNTERS=y 108CONFIG_VM_EVENT_COUNTERS=y
109CONFIG_PCI_QUIRKS=y 109CONFIG_PCI_QUIRKS=y
110CONFIG_SLUB_DEBUG=y
111# CONFIG_COMPAT_BRK is not set 110# CONFIG_COMPAT_BRK is not set
112# CONFIG_SLAB is not set 111CONFIG_SLAB=y
113CONFIG_SLUB=y 112# CONFIG_SLUB is not set
114# CONFIG_SLOB is not set 113# CONFIG_SLOB is not set
115CONFIG_PROFILING=y 114CONFIG_PROFILING=y
116CONFIG_TRACEPOINTS=y 115CONFIG_TRACEPOINTS=y
@@ -239,6 +238,7 @@ CONFIG_SPARSEMEM_VMEMMAP_ENABLE=y
239CONFIG_SPARSEMEM_VMEMMAP=y 238CONFIG_SPARSEMEM_VMEMMAP=y
240CONFIG_PAGEFLAGS_EXTENDED=y 239CONFIG_PAGEFLAGS_EXTENDED=y
241CONFIG_SPLIT_PTLOCK_CPUS=4 240CONFIG_SPLIT_PTLOCK_CPUS=4
241# CONFIG_COMPACTION is not set
242CONFIG_MIGRATION=y 242CONFIG_MIGRATION=y
243CONFIG_PHYS_ADDR_T_64BIT=y 243CONFIG_PHYS_ADDR_T_64BIT=y
244CONFIG_ZONE_DMA_FLAG=0 244CONFIG_ZONE_DMA_FLAG=0
@@ -351,6 +351,7 @@ CONFIG_IPV6_TUNNEL=m
351# CONFIG_RDS is not set 351# CONFIG_RDS is not set
352# CONFIG_TIPC is not set 352# CONFIG_TIPC is not set
353# CONFIG_ATM is not set 353# CONFIG_ATM is not set
354# CONFIG_L2TP is not set
354# CONFIG_BRIDGE is not set 355# CONFIG_BRIDGE is not set
355# CONFIG_NET_DSA is not set 356# CONFIG_NET_DSA is not set
356CONFIG_VLAN_8021Q=m 357CONFIG_VLAN_8021Q=m
@@ -367,6 +368,7 @@ CONFIG_VLAN_8021Q=m
367# CONFIG_IEEE802154 is not set 368# CONFIG_IEEE802154 is not set
368# CONFIG_NET_SCHED is not set 369# CONFIG_NET_SCHED is not set
369# CONFIG_DCB is not set 370# CONFIG_DCB is not set
371CONFIG_RPS=y
370 372
371# 373#
372# Network testing 374# Network testing
@@ -386,9 +388,14 @@ CONFIG_WIRELESS=y
386# 388#
387# CFG80211 needs to be enabled for MAC80211 389# CFG80211 needs to be enabled for MAC80211
388# 390#
391
392#
393# Some wireless drivers require a rate control algorithm
394#
389# CONFIG_WIMAX is not set 395# CONFIG_WIMAX is not set
390# CONFIG_RFKILL is not set 396# CONFIG_RFKILL is not set
391# CONFIG_NET_9P is not set 397# CONFIG_NET_9P is not set
398# CONFIG_CAIF is not set
392 399
393# 400#
394# Device Drivers 401# Device Drivers
@@ -658,6 +665,7 @@ CONFIG_PHYLIB=m
658# CONFIG_NATIONAL_PHY is not set 665# CONFIG_NATIONAL_PHY is not set
659# CONFIG_STE10XP is not set 666# CONFIG_STE10XP is not set
660# CONFIG_LSI_ET1011C_PHY is not set 667# CONFIG_LSI_ET1011C_PHY is not set
668# CONFIG_MICREL_PHY is not set
661# CONFIG_MDIO_BITBANG is not set 669# CONFIG_MDIO_BITBANG is not set
662CONFIG_NET_ETHERNET=y 670CONFIG_NET_ETHERNET=y
663CONFIG_MII=m 671CONFIG_MII=m
@@ -734,6 +742,8 @@ CONFIG_NETDEV_10000=y
734# CONFIG_CHELSIO_T1 is not set 742# CONFIG_CHELSIO_T1 is not set
735CONFIG_CHELSIO_T3_DEPENDS=y 743CONFIG_CHELSIO_T3_DEPENDS=y
736# CONFIG_CHELSIO_T3 is not set 744# CONFIG_CHELSIO_T3 is not set
745CONFIG_CHELSIO_T4_DEPENDS=y
746# CONFIG_CHELSIO_T4 is not set
737# CONFIG_ENIC is not set 747# CONFIG_ENIC is not set
738# CONFIG_IXGBE is not set 748# CONFIG_IXGBE is not set
739# CONFIG_IXGBEVF is not set 749# CONFIG_IXGBEVF is not set
@@ -766,6 +776,7 @@ CONFIG_NIU=m
766# CONFIG_USB_PEGASUS is not set 776# CONFIG_USB_PEGASUS is not set
767# CONFIG_USB_RTL8150 is not set 777# CONFIG_USB_RTL8150 is not set
768# CONFIG_USB_USBNET is not set 778# CONFIG_USB_USBNET is not set
779# CONFIG_USB_IPHETH is not set
769# CONFIG_WAN is not set 780# CONFIG_WAN is not set
770# CONFIG_FDDI is not set 781# CONFIG_FDDI is not set
771# CONFIG_HIPPI is not set 782# CONFIG_HIPPI is not set
@@ -778,7 +789,6 @@ CONFIG_PPP_DEFLATE=m
778CONFIG_PPP_BSDCOMP=m 789CONFIG_PPP_BSDCOMP=m
779CONFIG_PPP_MPPE=m 790CONFIG_PPP_MPPE=m
780CONFIG_PPPOE=m 791CONFIG_PPPOE=m
781# CONFIG_PPPOL2TP is not set
782# CONFIG_SLIP is not set 792# CONFIG_SLIP is not set
783CONFIG_SLHC=m 793CONFIG_SLHC=m
784# CONFIG_NET_FC is not set 794# CONFIG_NET_FC is not set
@@ -816,6 +826,7 @@ CONFIG_INPUT_KEYBOARD=y
816CONFIG_KEYBOARD_ATKBD=y 826CONFIG_KEYBOARD_ATKBD=y
817# CONFIG_QT2160 is not set 827# CONFIG_QT2160 is not set
818CONFIG_KEYBOARD_LKKBD=m 828CONFIG_KEYBOARD_LKKBD=m
829# CONFIG_KEYBOARD_TCA6416 is not set
819# CONFIG_KEYBOARD_MAX7359 is not set 830# CONFIG_KEYBOARD_MAX7359 is not set
820# CONFIG_KEYBOARD_NEWTON is not set 831# CONFIG_KEYBOARD_NEWTON is not set
821# CONFIG_KEYBOARD_OPENCORES is not set 832# CONFIG_KEYBOARD_OPENCORES is not set
@@ -840,6 +851,7 @@ CONFIG_MOUSE_SERIAL=y
840# CONFIG_INPUT_TABLET is not set 851# CONFIG_INPUT_TABLET is not set
841# CONFIG_INPUT_TOUCHSCREEN is not set 852# CONFIG_INPUT_TOUCHSCREEN is not set
842CONFIG_INPUT_MISC=y 853CONFIG_INPUT_MISC=y
854# CONFIG_INPUT_AD714X is not set
843CONFIG_INPUT_SPARCSPKR=y 855CONFIG_INPUT_SPARCSPKR=y
844# CONFIG_INPUT_ATI_REMOTE is not set 856# CONFIG_INPUT_ATI_REMOTE is not set
845# CONFIG_INPUT_ATI_REMOTE2 is not set 857# CONFIG_INPUT_ATI_REMOTE2 is not set
@@ -848,6 +860,7 @@ CONFIG_INPUT_SPARCSPKR=y
848# CONFIG_INPUT_YEALINK is not set 860# CONFIG_INPUT_YEALINK is not set
849# CONFIG_INPUT_CM109 is not set 861# CONFIG_INPUT_CM109 is not set
850# CONFIG_INPUT_UINPUT is not set 862# CONFIG_INPUT_UINPUT is not set
863# CONFIG_INPUT_PCF8574 is not set
851 864
852# 865#
853# Hardware I/O ports 866# Hardware I/O ports
@@ -871,6 +884,7 @@ CONFIG_HW_CONSOLE=y
871# CONFIG_VT_HW_CONSOLE_BINDING is not set 884# CONFIG_VT_HW_CONSOLE_BINDING is not set
872# CONFIG_DEVKMEM is not set 885# CONFIG_DEVKMEM is not set
873# CONFIG_SERIAL_NONSTANDARD is not set 886# CONFIG_SERIAL_NONSTANDARD is not set
887# CONFIG_N_GSM is not set
874# CONFIG_NOZOMI is not set 888# CONFIG_NOZOMI is not set
875 889
876# 890#
@@ -893,6 +907,8 @@ CONFIG_SERIAL_CORE_CONSOLE=y
893# CONFIG_SERIAL_JSM is not set 907# CONFIG_SERIAL_JSM is not set
894# CONFIG_SERIAL_TIMBERDALE is not set 908# CONFIG_SERIAL_TIMBERDALE is not set
895# CONFIG_SERIAL_GRLIB_GAISLER_APBUART is not set 909# CONFIG_SERIAL_GRLIB_GAISLER_APBUART is not set
910# CONFIG_SERIAL_ALTERA_JTAGUART is not set
911# CONFIG_SERIAL_ALTERA_UART is not set
896CONFIG_UNIX98_PTYS=y 912CONFIG_UNIX98_PTYS=y
897# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set 913# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set
898# CONFIG_LEGACY_PTYS is not set 914# CONFIG_LEGACY_PTYS is not set
@@ -1306,11 +1322,14 @@ CONFIG_USB_HIDDEV=y
1306CONFIG_HID_A4TECH=y 1322CONFIG_HID_A4TECH=y
1307CONFIG_HID_APPLE=y 1323CONFIG_HID_APPLE=y
1308CONFIG_HID_BELKIN=y 1324CONFIG_HID_BELKIN=y
1325# CONFIG_HID_CANDO is not set
1309CONFIG_HID_CHERRY=y 1326CONFIG_HID_CHERRY=y
1310CONFIG_HID_CHICONY=y 1327CONFIG_HID_CHICONY=y
1328# CONFIG_HID_PRODIKEYS is not set
1311CONFIG_HID_CYPRESS=y 1329CONFIG_HID_CYPRESS=y
1312CONFIG_HID_DRAGONRISE=y 1330CONFIG_HID_DRAGONRISE=y
1313# CONFIG_DRAGONRISE_FF is not set 1331# CONFIG_DRAGONRISE_FF is not set
1332# CONFIG_HID_EGALAX is not set
1314CONFIG_HID_EZKEY=y 1333CONFIG_HID_EZKEY=y
1315CONFIG_HID_KYE=y 1334CONFIG_HID_KYE=y
1316CONFIG_HID_GYRATION=y 1335CONFIG_HID_GYRATION=y
@@ -1328,7 +1347,9 @@ CONFIG_HID_ORTEK=y
1328CONFIG_HID_PANTHERLORD=y 1347CONFIG_HID_PANTHERLORD=y
1329# CONFIG_PANTHERLORD_FF is not set 1348# CONFIG_PANTHERLORD_FF is not set
1330CONFIG_HID_PETALYNX=y 1349CONFIG_HID_PETALYNX=y
1350# CONFIG_HID_PICOLCD is not set
1331# CONFIG_HID_QUANTA is not set 1351# CONFIG_HID_QUANTA is not set
1352# CONFIG_HID_ROCCAT_KONE is not set
1332CONFIG_HID_SAMSUNG=y 1353CONFIG_HID_SAMSUNG=y
1333CONFIG_HID_SONY=y 1354CONFIG_HID_SONY=y
1334# CONFIG_HID_STANTUM is not set 1355# CONFIG_HID_STANTUM is not set
@@ -1342,6 +1363,7 @@ CONFIG_HID_THRUSTMASTER=y
1342# CONFIG_THRUSTMASTER_FF is not set 1363# CONFIG_THRUSTMASTER_FF is not set
1343CONFIG_HID_ZEROPLUS=y 1364CONFIG_HID_ZEROPLUS=y
1344# CONFIG_ZEROPLUS_FF is not set 1365# CONFIG_ZEROPLUS_FF is not set
1366# CONFIG_HID_ZYDACRON is not set
1345CONFIG_USB_SUPPORT=y 1367CONFIG_USB_SUPPORT=y
1346CONFIG_USB_ARCH_HAS_HCD=y 1368CONFIG_USB_ARCH_HAS_HCD=y
1347CONFIG_USB_ARCH_HAS_OHCI=y 1369CONFIG_USB_ARCH_HAS_OHCI=y
@@ -1356,7 +1378,6 @@ CONFIG_USB=y
1356# CONFIG_USB_DEVICEFS is not set 1378# CONFIG_USB_DEVICEFS is not set
1357# CONFIG_USB_DEVICE_CLASS is not set 1379# CONFIG_USB_DEVICE_CLASS is not set
1358# CONFIG_USB_DYNAMIC_MINORS is not set 1380# CONFIG_USB_DYNAMIC_MINORS is not set
1359# CONFIG_USB_OTG is not set
1360# CONFIG_USB_MON is not set 1381# CONFIG_USB_MON is not set
1361# CONFIG_USB_WUSB is not set 1382# CONFIG_USB_WUSB is not set
1362# CONFIG_USB_WUSB_CBAF is not set 1383# CONFIG_USB_WUSB_CBAF is not set
@@ -1521,10 +1542,6 @@ CONFIG_RTC_DRV_STARFIRE=y
1521# CONFIG_DMADEVICES is not set 1542# CONFIG_DMADEVICES is not set
1522# CONFIG_AUXDISPLAY is not set 1543# CONFIG_AUXDISPLAY is not set
1523# CONFIG_UIO is not set 1544# CONFIG_UIO is not set
1524
1525#
1526# TI VLYNQ
1527#
1528# CONFIG_STAGING is not set 1545# CONFIG_STAGING is not set
1529 1546
1530# 1547#
@@ -1706,8 +1723,8 @@ CONFIG_BOOTPARAM_HUNG_TASK_PANIC_VALUE=0
1706CONFIG_SCHEDSTATS=y 1723CONFIG_SCHEDSTATS=y
1707# CONFIG_TIMER_STATS is not set 1724# CONFIG_TIMER_STATS is not set
1708# CONFIG_DEBUG_OBJECTS is not set 1725# CONFIG_DEBUG_OBJECTS is not set
1709# CONFIG_SLUB_DEBUG_ON is not set 1726# CONFIG_DEBUG_SLAB is not set
1710# CONFIG_SLUB_STATS is not set 1727# CONFIG_DEBUG_KMEMLEAK is not set
1711# CONFIG_DEBUG_RT_MUTEXES is not set 1728# CONFIG_DEBUG_RT_MUTEXES is not set
1712# CONFIG_RT_MUTEX_TESTER is not set 1729# CONFIG_RT_MUTEX_TESTER is not set
1713# CONFIG_DEBUG_SPINLOCK is not set 1730# CONFIG_DEBUG_SPINLOCK is not set
@@ -1742,6 +1759,9 @@ CONFIG_SYSCTL_SYSCALL_CHECK=y
1742# CONFIG_DEBUG_PAGEALLOC is not set 1759# CONFIG_DEBUG_PAGEALLOC is not set
1743CONFIG_NOP_TRACER=y 1760CONFIG_NOP_TRACER=y
1744CONFIG_HAVE_FUNCTION_TRACER=y 1761CONFIG_HAVE_FUNCTION_TRACER=y
1762CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y
1763CONFIG_HAVE_FUNCTION_GRAPH_FP_TEST=y
1764CONFIG_HAVE_FUNCTION_TRACE_MCOUNT_TEST=y
1745CONFIG_HAVE_DYNAMIC_FTRACE=y 1765CONFIG_HAVE_DYNAMIC_FTRACE=y
1746CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y 1766CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y
1747CONFIG_HAVE_SYSCALL_TRACEPOINTS=y 1767CONFIG_HAVE_SYSCALL_TRACEPOINTS=y
@@ -1769,12 +1789,12 @@ CONFIG_BLK_DEV_IO_TRACE=y
1769# CONFIG_RING_BUFFER_BENCHMARK is not set 1789# CONFIG_RING_BUFFER_BENCHMARK is not set
1770# CONFIG_DYNAMIC_DEBUG is not set 1790# CONFIG_DYNAMIC_DEBUG is not set
1771# CONFIG_DMA_API_DEBUG is not set 1791# CONFIG_DMA_API_DEBUG is not set
1792# CONFIG_ATOMIC64_SELFTEST is not set
1772# CONFIG_SAMPLES is not set 1793# CONFIG_SAMPLES is not set
1773CONFIG_HAVE_ARCH_KGDB=y 1794CONFIG_HAVE_ARCH_KGDB=y
1774# CONFIG_KGDB is not set 1795# CONFIG_KGDB is not set
1775# CONFIG_DEBUG_STACK_USAGE is not set 1796# CONFIG_DEBUG_STACK_USAGE is not set
1776# CONFIG_DEBUG_DCFLUSH is not set 1797# CONFIG_DEBUG_DCFLUSH is not set
1777# CONFIG_STACK_DEBUG is not set
1778# CONFIG_DEBUG_STRICT_USER_COPY_CHECKS is not set 1798# CONFIG_DEBUG_STRICT_USER_COPY_CHECKS is not set
1779 1799
1780# 1800#
@@ -1895,6 +1915,7 @@ CONFIG_CRYPTO_DEFLATE=y
1895# 1915#
1896# CONFIG_CRYPTO_ANSI_CPRNG is not set 1916# CONFIG_CRYPTO_ANSI_CPRNG is not set
1897CONFIG_CRYPTO_HW=y 1917CONFIG_CRYPTO_HW=y
1918# CONFIG_CRYPTO_DEV_NIAGARA2 is not set
1898# CONFIG_CRYPTO_DEV_HIFN_795X is not set 1919# CONFIG_CRYPTO_DEV_HIFN_795X is not set
1899CONFIG_BINARY_PRINTF=y 1920CONFIG_BINARY_PRINTF=y
1900 1921
diff --git a/arch/sparc/include/asm/cache.h b/arch/sparc/include/asm/cache.h
index 0588b8c7faa2..69358b590c91 100644
--- a/arch/sparc/include/asm/cache.h
+++ b/arch/sparc/include/asm/cache.h
@@ -11,7 +11,6 @@
11 11
12#define L1_CACHE_SHIFT 5 12#define L1_CACHE_SHIFT 5
13#define L1_CACHE_BYTES 32 13#define L1_CACHE_BYTES 32
14#define L1_CACHE_ALIGN(x) ((((x)+(L1_CACHE_BYTES-1))&~(L1_CACHE_BYTES-1)))
15 14
16#ifdef CONFIG_SPARC32 15#ifdef CONFIG_SPARC32
17#define SMP_CACHE_BYTES_SHIFT 5 16#define SMP_CACHE_BYTES_SHIFT 5
diff --git a/arch/sparc/include/asm/lmb.h b/arch/sparc/include/asm/lmb.h
deleted file mode 100644
index 6a352cbcf520..000000000000
--- a/arch/sparc/include/asm/lmb.h
+++ /dev/null
@@ -1,10 +0,0 @@
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/arch/sparc/include/asm/memblock.h b/arch/sparc/include/asm/memblock.h
new file mode 100644
index 000000000000..f12af880649b
--- /dev/null
+++ b/arch/sparc/include/asm/memblock.h
@@ -0,0 +1,10 @@
1#ifndef _SPARC64_MEMBLOCK_H
2#define _SPARC64_MEMBLOCK_H
3
4#include <asm/oplib.h>
5
6#define MEMBLOCK_DBG(fmt...) prom_printf(fmt)
7
8#define MEMBLOCK_REAL_LIMIT 0
9
10#endif /* !(_SPARC64_MEMBLOCK_H) */
diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
index 77f906d8cc21..0ece77f47753 100644
--- a/arch/sparc/include/asm/pgtable_32.h
+++ b/arch/sparc/include/asm/pgtable_32.h
@@ -142,13 +142,12 @@ BTFIXUPDEF_CALL_CONST(unsigned long, pgd_page_vaddr, pgd_t)
142#define pmd_page(pmd) BTFIXUP_CALL(pmd_page)(pmd) 142#define pmd_page(pmd) BTFIXUP_CALL(pmd_page)(pmd)
143#define pgd_page_vaddr(pgd) BTFIXUP_CALL(pgd_page_vaddr)(pgd) 143#define pgd_page_vaddr(pgd) BTFIXUP_CALL(pgd_page_vaddr)(pgd)
144 144
145BTFIXUPDEF_SETHI(none_mask)
146BTFIXUPDEF_CALL_CONST(int, pte_present, pte_t) 145BTFIXUPDEF_CALL_CONST(int, pte_present, pte_t)
147BTFIXUPDEF_CALL(void, pte_clear, pte_t *) 146BTFIXUPDEF_CALL(void, pte_clear, pte_t *)
148 147
149static inline int pte_none(pte_t pte) 148static inline int pte_none(pte_t pte)
150{ 149{
151 return !(pte_val(pte) & ~BTFIXUP_SETHI(none_mask)); 150 return !pte_val(pte);
152} 151}
153 152
154#define pte_present(pte) BTFIXUP_CALL(pte_present)(pte) 153#define pte_present(pte) BTFIXUP_CALL(pte_present)(pte)
@@ -160,7 +159,7 @@ BTFIXUPDEF_CALL(void, pmd_clear, pmd_t *)
160 159
161static inline int pmd_none(pmd_t pmd) 160static inline int pmd_none(pmd_t pmd)
162{ 161{
163 return !(pmd_val(pmd) & ~BTFIXUP_SETHI(none_mask)); 162 return !pmd_val(pmd);
164} 163}
165 164
166#define pmd_bad(pmd) BTFIXUP_CALL(pmd_bad)(pmd) 165#define pmd_bad(pmd) BTFIXUP_CALL(pmd_bad)(pmd)
diff --git a/arch/sparc/kernel/mdesc.c b/arch/sparc/kernel/mdesc.c
index cdc91d919e93..83e85c2e802a 100644
--- a/arch/sparc/kernel/mdesc.c
+++ b/arch/sparc/kernel/mdesc.c
@@ -4,7 +4,7 @@
4 */ 4 */
5#include <linux/kernel.h> 5#include <linux/kernel.h>
6#include <linux/types.h> 6#include <linux/types.h>
7#include <linux/lmb.h> 7#include <linux/memblock.h>
8#include <linux/log2.h> 8#include <linux/log2.h>
9#include <linux/list.h> 9#include <linux/list.h>
10#include <linux/slab.h> 10#include <linux/slab.h>
@@ -86,7 +86,7 @@ static void mdesc_handle_init(struct mdesc_handle *hp,
86 hp->handle_size = handle_size; 86 hp->handle_size = handle_size;
87} 87}
88 88
89static struct mdesc_handle * __init mdesc_lmb_alloc(unsigned int mdesc_size) 89static struct mdesc_handle * __init mdesc_memblock_alloc(unsigned int mdesc_size)
90{ 90{
91 unsigned int handle_size, alloc_size; 91 unsigned int handle_size, alloc_size;
92 struct mdesc_handle *hp; 92 struct mdesc_handle *hp;
@@ -97,7 +97,7 @@ static struct mdesc_handle * __init mdesc_lmb_alloc(unsigned int mdesc_size)
97 mdesc_size); 97 mdesc_size);
98 alloc_size = PAGE_ALIGN(handle_size); 98 alloc_size = PAGE_ALIGN(handle_size);
99 99
100 paddr = lmb_alloc(alloc_size, PAGE_SIZE); 100 paddr = memblock_alloc(alloc_size, PAGE_SIZE);
101 101
102 hp = NULL; 102 hp = NULL;
103 if (paddr) { 103 if (paddr) {
@@ -107,7 +107,7 @@ static struct mdesc_handle * __init mdesc_lmb_alloc(unsigned int mdesc_size)
107 return hp; 107 return hp;
108} 108}
109 109
110static void mdesc_lmb_free(struct mdesc_handle *hp) 110static void mdesc_memblock_free(struct mdesc_handle *hp)
111{ 111{
112 unsigned int alloc_size; 112 unsigned int alloc_size;
113 unsigned long start; 113 unsigned long start;
@@ -120,9 +120,9 @@ static void mdesc_lmb_free(struct mdesc_handle *hp)
120 free_bootmem_late(start, alloc_size); 120 free_bootmem_late(start, alloc_size);
121} 121}
122 122
123static struct mdesc_mem_ops lmb_mdesc_ops = { 123static struct mdesc_mem_ops memblock_mdesc_ops = {
124 .alloc = mdesc_lmb_alloc, 124 .alloc = mdesc_memblock_alloc,
125 .free = mdesc_lmb_free, 125 .free = mdesc_memblock_free,
126}; 126};
127 127
128static struct mdesc_handle *mdesc_kmalloc(unsigned int mdesc_size) 128static struct mdesc_handle *mdesc_kmalloc(unsigned int mdesc_size)
@@ -914,7 +914,7 @@ void __init sun4v_mdesc_init(void)
914 914
915 printk("MDESC: Size is %lu bytes.\n", len); 915 printk("MDESC: Size is %lu bytes.\n", len);
916 916
917 hp = mdesc_alloc(len, &lmb_mdesc_ops); 917 hp = mdesc_alloc(len, &memblock_mdesc_ops);
918 if (hp == NULL) { 918 if (hp == NULL) {
919 prom_printf("MDESC: alloc of %lu bytes failed.\n", len); 919 prom_printf("MDESC: alloc of %lu bytes failed.\n", len);
920 prom_halt(); 920 prom_halt();
diff --git a/arch/sparc/kernel/perf_event.c b/arch/sparc/kernel/perf_event.c
index 0ec92c8861dd..44faabc3c02c 100644
--- a/arch/sparc/kernel/perf_event.c
+++ b/arch/sparc/kernel/perf_event.c
@@ -657,6 +657,7 @@ static u64 maybe_change_configuration(struct cpu_hw_events *cpuc, u64 pcr)
657 cpuc->current_idx[i] = idx; 657 cpuc->current_idx[i] = idx;
658 658
659 enc = perf_event_get_enc(cpuc->events[i]); 659 enc = perf_event_get_enc(cpuc->events[i]);
660 pcr &= ~mask_for_index(idx);
660 pcr |= event_encoding(enc, idx); 661 pcr |= event_encoding(enc, idx);
661 } 662 }
662out: 663out:
diff --git a/arch/sparc/kernel/prom_64.c b/arch/sparc/kernel/prom_64.c
index fb06ac2bd38f..466a32763ea8 100644
--- a/arch/sparc/kernel/prom_64.c
+++ b/arch/sparc/kernel/prom_64.c
@@ -20,7 +20,7 @@
20#include <linux/string.h> 20#include <linux/string.h>
21#include <linux/mm.h> 21#include <linux/mm.h>
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/lmb.h> 23#include <linux/memblock.h>
24#include <linux/of_device.h> 24#include <linux/of_device.h>
25 25
26#include <asm/prom.h> 26#include <asm/prom.h>
@@ -34,7 +34,7 @@
34 34
35void * __init prom_early_alloc(unsigned long size) 35void * __init prom_early_alloc(unsigned long size)
36{ 36{
37 unsigned long paddr = lmb_alloc(size, SMP_CACHE_BYTES); 37 unsigned long paddr = memblock_alloc(size, SMP_CACHE_BYTES);
38 void *ret; 38 void *ret;
39 39
40 if (!paddr) { 40 if (!paddr) {
diff --git a/arch/sparc/kernel/sun4d_irq.c b/arch/sparc/kernel/sun4d_irq.c
index ab036a72de5a..e11b4612dabb 100644
--- a/arch/sparc/kernel/sun4d_irq.c
+++ b/arch/sparc/kernel/sun4d_irq.c
@@ -183,7 +183,7 @@ void sun4d_free_irq(unsigned int irq, void *dev_id)
183 goto out_unlock; 183 goto out_unlock;
184 } 184 }
185 185
186 if (action && tmp) 186 if (tmp)
187 tmp->next = action->next; 187 tmp->next = action->next;
188 else 188 else
189 *actionp = action->next; 189 *actionp = action->next;
diff --git a/arch/sparc/kernel/ttable.S b/arch/sparc/kernel/ttable.S
index 76d837fc47d3..c6dfdaa29e20 100644
--- a/arch/sparc/kernel/ttable.S
+++ b/arch/sparc/kernel/ttable.S
@@ -64,7 +64,7 @@ tl0_irq6: TRAP_IRQ(smp_call_function_single_client, 6)
64tl0_irq6: BTRAP(0x46) 64tl0_irq6: BTRAP(0x46)
65#endif 65#endif
66tl0_irq7: TRAP_IRQ(deferred_pcr_work_irq, 7) 66tl0_irq7: TRAP_IRQ(deferred_pcr_work_irq, 7)
67#ifdef CONFIG_KGDB 67#if defined(CONFIG_KGDB) && defined(CONFIG_SMP)
68tl0_irq8: TRAP_IRQ(smp_kgdb_capture_client, 8) 68tl0_irq8: TRAP_IRQ(smp_kgdb_capture_client, 8)
69#else 69#else
70tl0_irq8: BTRAP(0x48) 70tl0_irq8: BTRAP(0x48)
diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
index b2831dc3c121..f0434513df15 100644
--- a/arch/sparc/mm/init_64.c
+++ b/arch/sparc/mm/init_64.c
@@ -23,7 +23,7 @@
23#include <linux/cache.h> 23#include <linux/cache.h>
24#include <linux/sort.h> 24#include <linux/sort.h>
25#include <linux/percpu.h> 25#include <linux/percpu.h>
26#include <linux/lmb.h> 26#include <linux/memblock.h>
27#include <linux/mmzone.h> 27#include <linux/mmzone.h>
28#include <linux/gfp.h> 28#include <linux/gfp.h>
29 29
@@ -726,7 +726,7 @@ static void __init find_ramdisk(unsigned long phys_base)
726 initrd_start = ramdisk_image; 726 initrd_start = ramdisk_image;
727 initrd_end = ramdisk_image + sparc_ramdisk_size; 727 initrd_end = ramdisk_image + sparc_ramdisk_size;
728 728
729 lmb_reserve(initrd_start, sparc_ramdisk_size); 729 memblock_reserve(initrd_start, sparc_ramdisk_size);
730 730
731 initrd_start += PAGE_OFFSET; 731 initrd_start += PAGE_OFFSET;
732 initrd_end += PAGE_OFFSET; 732 initrd_end += PAGE_OFFSET;
@@ -822,7 +822,7 @@ static void __init allocate_node_data(int nid)
822 struct pglist_data *p; 822 struct pglist_data *p;
823 823
824#ifdef CONFIG_NEED_MULTIPLE_NODES 824#ifdef CONFIG_NEED_MULTIPLE_NODES
825 paddr = lmb_alloc_nid(sizeof(struct pglist_data), 825 paddr = memblock_alloc_nid(sizeof(struct pglist_data),
826 SMP_CACHE_BYTES, nid, nid_range); 826 SMP_CACHE_BYTES, nid, nid_range);
827 if (!paddr) { 827 if (!paddr) {
828 prom_printf("Cannot allocate pglist_data for nid[%d]\n", nid); 828 prom_printf("Cannot allocate pglist_data for nid[%d]\n", nid);
@@ -843,7 +843,7 @@ static void __init allocate_node_data(int nid)
843 if (p->node_spanned_pages) { 843 if (p->node_spanned_pages) {
844 num_pages = bootmem_bootmap_pages(p->node_spanned_pages); 844 num_pages = bootmem_bootmap_pages(p->node_spanned_pages);
845 845
846 paddr = lmb_alloc_nid(num_pages << PAGE_SHIFT, PAGE_SIZE, nid, 846 paddr = memblock_alloc_nid(num_pages << PAGE_SHIFT, PAGE_SIZE, nid,
847 nid_range); 847 nid_range);
848 if (!paddr) { 848 if (!paddr) {
849 prom_printf("Cannot allocate bootmap for nid[%d]\n", 849 prom_printf("Cannot allocate bootmap for nid[%d]\n",
@@ -974,11 +974,11 @@ static void __init add_node_ranges(void)
974{ 974{
975 int i; 975 int i;
976 976
977 for (i = 0; i < lmb.memory.cnt; i++) { 977 for (i = 0; i < memblock.memory.cnt; i++) {
978 unsigned long size = lmb_size_bytes(&lmb.memory, i); 978 unsigned long size = memblock_size_bytes(&memblock.memory, i);
979 unsigned long start, end; 979 unsigned long start, end;
980 980
981 start = lmb.memory.region[i].base; 981 start = memblock.memory.region[i].base;
982 end = start + size; 982 end = start + size;
983 while (start < end) { 983 while (start < end) {
984 unsigned long this_end; 984 unsigned long this_end;
@@ -1010,7 +1010,7 @@ static int __init grab_mlgroups(struct mdesc_handle *md)
1010 if (!count) 1010 if (!count)
1011 return -ENOENT; 1011 return -ENOENT;
1012 1012
1013 paddr = lmb_alloc(count * sizeof(struct mdesc_mlgroup), 1013 paddr = memblock_alloc(count * sizeof(struct mdesc_mlgroup),
1014 SMP_CACHE_BYTES); 1014 SMP_CACHE_BYTES);
1015 if (!paddr) 1015 if (!paddr)
1016 return -ENOMEM; 1016 return -ENOMEM;
@@ -1051,7 +1051,7 @@ static int __init grab_mblocks(struct mdesc_handle *md)
1051 if (!count) 1051 if (!count)
1052 return -ENOENT; 1052 return -ENOENT;
1053 1053
1054 paddr = lmb_alloc(count * sizeof(struct mdesc_mblock), 1054 paddr = memblock_alloc(count * sizeof(struct mdesc_mblock),
1055 SMP_CACHE_BYTES); 1055 SMP_CACHE_BYTES);
1056 if (!paddr) 1056 if (!paddr)
1057 return -ENOMEM; 1057 return -ENOMEM;
@@ -1279,8 +1279,8 @@ static int bootmem_init_numa(void)
1279 1279
1280static void __init bootmem_init_nonnuma(void) 1280static void __init bootmem_init_nonnuma(void)
1281{ 1281{
1282 unsigned long top_of_ram = lmb_end_of_DRAM(); 1282 unsigned long top_of_ram = memblock_end_of_DRAM();
1283 unsigned long total_ram = lmb_phys_mem_size(); 1283 unsigned long total_ram = memblock_phys_mem_size();
1284 unsigned int i; 1284 unsigned int i;
1285 1285
1286 numadbg("bootmem_init_nonnuma()\n"); 1286 numadbg("bootmem_init_nonnuma()\n");
@@ -1292,15 +1292,15 @@ static void __init bootmem_init_nonnuma(void)
1292 1292
1293 init_node_masks_nonnuma(); 1293 init_node_masks_nonnuma();
1294 1294
1295 for (i = 0; i < lmb.memory.cnt; i++) { 1295 for (i = 0; i < memblock.memory.cnt; i++) {
1296 unsigned long size = lmb_size_bytes(&lmb.memory, i); 1296 unsigned long size = memblock_size_bytes(&memblock.memory, i);
1297 unsigned long start_pfn, end_pfn; 1297 unsigned long start_pfn, end_pfn;
1298 1298
1299 if (!size) 1299 if (!size)
1300 continue; 1300 continue;
1301 1301
1302 start_pfn = lmb.memory.region[i].base >> PAGE_SHIFT; 1302 start_pfn = memblock.memory.region[i].base >> PAGE_SHIFT;
1303 end_pfn = start_pfn + lmb_size_pages(&lmb.memory, i); 1303 end_pfn = start_pfn + memblock_size_pages(&memblock.memory, i);
1304 add_active_range(0, start_pfn, end_pfn); 1304 add_active_range(0, start_pfn, end_pfn);
1305 } 1305 }
1306 1306
@@ -1338,9 +1338,9 @@ static void __init trim_reserved_in_node(int nid)
1338 1338
1339 numadbg(" trim_reserved_in_node(%d)\n", nid); 1339 numadbg(" trim_reserved_in_node(%d)\n", nid);
1340 1340
1341 for (i = 0; i < lmb.reserved.cnt; i++) { 1341 for (i = 0; i < memblock.reserved.cnt; i++) {
1342 unsigned long start = lmb.reserved.region[i].base; 1342 unsigned long start = memblock.reserved.region[i].base;
1343 unsigned long size = lmb_size_bytes(&lmb.reserved, i); 1343 unsigned long size = memblock_size_bytes(&memblock.reserved, i);
1344 unsigned long end = start + size; 1344 unsigned long end = start + size;
1345 1345
1346 reserve_range_in_node(nid, start, end); 1346 reserve_range_in_node(nid, start, end);
@@ -1384,7 +1384,7 @@ static unsigned long __init bootmem_init(unsigned long phys_base)
1384 unsigned long end_pfn; 1384 unsigned long end_pfn;
1385 int nid; 1385 int nid;
1386 1386
1387 end_pfn = lmb_end_of_DRAM() >> PAGE_SHIFT; 1387 end_pfn = memblock_end_of_DRAM() >> PAGE_SHIFT;
1388 max_pfn = max_low_pfn = end_pfn; 1388 max_pfn = max_low_pfn = end_pfn;
1389 min_low_pfn = (phys_base >> PAGE_SHIFT); 1389 min_low_pfn = (phys_base >> PAGE_SHIFT);
1390 1390
@@ -1734,7 +1734,7 @@ void __init paging_init(void)
1734 sun4v_ktsb_init(); 1734 sun4v_ktsb_init();
1735 } 1735 }
1736 1736
1737 lmb_init(); 1737 memblock_init();
1738 1738
1739 /* Find available physical memory... 1739 /* Find available physical memory...
1740 * 1740 *
@@ -1752,17 +1752,17 @@ void __init paging_init(void)
1752 phys_base = 0xffffffffffffffffUL; 1752 phys_base = 0xffffffffffffffffUL;
1753 for (i = 0; i < pavail_ents; i++) { 1753 for (i = 0; i < pavail_ents; i++) {
1754 phys_base = min(phys_base, pavail[i].phys_addr); 1754 phys_base = min(phys_base, pavail[i].phys_addr);
1755 lmb_add(pavail[i].phys_addr, pavail[i].reg_size); 1755 memblock_add(pavail[i].phys_addr, pavail[i].reg_size);
1756 } 1756 }
1757 1757
1758 lmb_reserve(kern_base, kern_size); 1758 memblock_reserve(kern_base, kern_size);
1759 1759
1760 find_ramdisk(phys_base); 1760 find_ramdisk(phys_base);
1761 1761
1762 lmb_enforce_memory_limit(cmdline_memory_size); 1762 memblock_enforce_memory_limit(cmdline_memory_size);
1763 1763
1764 lmb_analyze(); 1764 memblock_analyze();
1765 lmb_dump_all(); 1765 memblock_dump_all();
1766 1766
1767 set_bit(0, mmu_context_bmap); 1767 set_bit(0, mmu_context_bmap);
1768 1768
@@ -1816,8 +1816,8 @@ void __init paging_init(void)
1816 */ 1816 */
1817 for_each_possible_cpu(i) { 1817 for_each_possible_cpu(i) {
1818 /* XXX Use node local allocations... XXX */ 1818 /* XXX Use node local allocations... XXX */
1819 softirq_stack[i] = __va(lmb_alloc(THREAD_SIZE, THREAD_SIZE)); 1819 softirq_stack[i] = __va(memblock_alloc(THREAD_SIZE, THREAD_SIZE));
1820 hardirq_stack[i] = __va(lmb_alloc(THREAD_SIZE, THREAD_SIZE)); 1820 hardirq_stack[i] = __va(memblock_alloc(THREAD_SIZE, THREAD_SIZE));
1821 } 1821 }
1822 1822
1823 /* Setup bootmem... */ 1823 /* Setup bootmem... */
diff --git a/arch/sparc/mm/srmmu.c b/arch/sparc/mm/srmmu.c
index f5f75a58e0b3..b0b43aa5e45a 100644
--- a/arch/sparc/mm/srmmu.c
+++ b/arch/sparc/mm/srmmu.c
@@ -2215,8 +2215,6 @@ void __init ld_mmu_srmmu(void)
2215 BTFIXUPSET_CALL(pmd_page, srmmu_pmd_page, BTFIXUPCALL_NORM); 2215 BTFIXUPSET_CALL(pmd_page, srmmu_pmd_page, BTFIXUPCALL_NORM);
2216 BTFIXUPSET_CALL(pgd_page_vaddr, srmmu_pgd_page, BTFIXUPCALL_NORM); 2216 BTFIXUPSET_CALL(pgd_page_vaddr, srmmu_pgd_page, BTFIXUPCALL_NORM);
2217 2217
2218 BTFIXUPSET_SETHI(none_mask, 0xF0000000);
2219
2220 BTFIXUPSET_CALL(pte_present, srmmu_pte_present, BTFIXUPCALL_NORM); 2218 BTFIXUPSET_CALL(pte_present, srmmu_pte_present, BTFIXUPCALL_NORM);
2221 BTFIXUPSET_CALL(pte_clear, srmmu_pte_clear, BTFIXUPCALL_SWAPO0G0); 2219 BTFIXUPSET_CALL(pte_clear, srmmu_pte_clear, BTFIXUPCALL_SWAPO0G0);
2222 2220
diff --git a/arch/sparc/mm/sun4c.c b/arch/sparc/mm/sun4c.c
index cf38846753dd..4289f90f8697 100644
--- a/arch/sparc/mm/sun4c.c
+++ b/arch/sparc/mm/sun4c.c
@@ -2087,9 +2087,6 @@ void __init ld_mmu_sun4c(void)
2087 2087
2088 BTFIXUPSET_CALL(set_pte, sun4c_set_pte, BTFIXUPCALL_STO1O0); 2088 BTFIXUPSET_CALL(set_pte, sun4c_set_pte, BTFIXUPCALL_STO1O0);
2089 2089
2090 /* The 2.4.18 code does not set this on sun4c, how does it work? XXX */
2091 /* BTFIXUPSET_SETHI(none_mask, 0x00000000); */ /* Defaults to zero? */
2092
2093 BTFIXUPSET_CALL(pte_pfn, sun4c_pte_pfn, BTFIXUPCALL_NORM); 2090 BTFIXUPSET_CALL(pte_pfn, sun4c_pte_pfn, BTFIXUPCALL_NORM);
2094#if 0 /* PAGE_SHIFT <= 12 */ /* Eek. Investigate. XXX */ 2091#if 0 /* PAGE_SHIFT <= 12 */ /* Eek. Investigate. XXX */
2095 BTFIXUPSET_CALL(pmd_page, sun4c_pmd_page, BTFIXUPCALL_ANDNINT(PAGE_SIZE - 1)); 2092 BTFIXUPSET_CALL(pmd_page, sun4c_pmd_page, BTFIXUPCALL_ANDNINT(PAGE_SIZE - 1));
diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
index 519b54327d75..baa579c8e038 100644
--- a/arch/x86/include/asm/x86_init.h
+++ b/arch/x86/include/asm/x86_init.h
@@ -142,6 +142,7 @@ struct x86_cpuinit_ops {
142 * @set_wallclock: set time back to HW clock 142 * @set_wallclock: set time back to HW clock
143 * @is_untracked_pat_range exclude from PAT logic 143 * @is_untracked_pat_range exclude from PAT logic
144 * @nmi_init enable NMI on cpus 144 * @nmi_init enable NMI on cpus
145 * @i8042_detect pre-detect if i8042 controller exists
145 */ 146 */
146struct x86_platform_ops { 147struct x86_platform_ops {
147 unsigned long (*calibrate_tsc)(void); 148 unsigned long (*calibrate_tsc)(void);
@@ -150,6 +151,7 @@ struct x86_platform_ops {
150 void (*iommu_shutdown)(void); 151 void (*iommu_shutdown)(void);
151 bool (*is_untracked_pat_range)(u64 start, u64 end); 152 bool (*is_untracked_pat_range)(u64 start, u64 end);
152 void (*nmi_init)(void); 153 void (*nmi_init)(void);
154 int (*i8042_detect)(void);
153}; 155};
154 156
155extern struct x86_init_ops x86_init; 157extern struct x86_init_ops x86_init;
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index c02cc692985c..a96489ee6cab 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -921,7 +921,7 @@ void disable_local_APIC(void)
921 unsigned int value; 921 unsigned int value;
922 922
923 /* APIC hasn't been mapped yet */ 923 /* APIC hasn't been mapped yet */
924 if (!apic_phys) 924 if (!x2apic_mode && !apic_phys)
925 return; 925 return;
926 926
927 clear_local_APIC(); 927 clear_local_APIC();
diff --git a/arch/x86/kernel/early-quirks.c b/arch/x86/kernel/early-quirks.c
index ebdb85cf2686..e5cc7e82e60d 100644
--- a/arch/x86/kernel/early-quirks.c
+++ b/arch/x86/kernel/early-quirks.c
@@ -18,6 +18,7 @@
18#include <asm/apic.h> 18#include <asm/apic.h>
19#include <asm/iommu.h> 19#include <asm/iommu.h>
20#include <asm/gart.h> 20#include <asm/gart.h>
21#include <asm/hpet.h>
21 22
22static void __init fix_hypertransport_config(int num, int slot, int func) 23static void __init fix_hypertransport_config(int num, int slot, int func)
23{ 24{
@@ -191,6 +192,21 @@ static void __init ati_bugs_contd(int num, int slot, int func)
191} 192}
192#endif 193#endif
193 194
195/*
196 * Force the read back of the CMP register in hpet_next_event()
197 * to work around the problem that the CMP register write seems to be
198 * delayed. See hpet_next_event() for details.
199 *
200 * We do this on all SMBUS incarnations for now until we have more
201 * information about the affected chipsets.
202 */
203static void __init ati_hpet_bugs(int num, int slot, int func)
204{
205#ifdef CONFIG_HPET_TIMER
206 hpet_readback_cmp = 1;
207#endif
208}
209
194#define QFLAG_APPLY_ONCE 0x1 210#define QFLAG_APPLY_ONCE 0x1
195#define QFLAG_APPLIED 0x2 211#define QFLAG_APPLIED 0x2
196#define QFLAG_DONE (QFLAG_APPLY_ONCE|QFLAG_APPLIED) 212#define QFLAG_DONE (QFLAG_APPLY_ONCE|QFLAG_APPLIED)
@@ -220,6 +236,8 @@ static struct chipset early_qrk[] __initdata = {
220 PCI_CLASS_SERIAL_SMBUS, PCI_ANY_ID, 0, ati_bugs }, 236 PCI_CLASS_SERIAL_SMBUS, PCI_ANY_ID, 0, ati_bugs },
221 { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_SBX00_SMBUS, 237 { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_SBX00_SMBUS,
222 PCI_CLASS_SERIAL_SMBUS, PCI_ANY_ID, 0, ati_bugs_contd }, 238 PCI_CLASS_SERIAL_SMBUS, PCI_ANY_ID, 0, ati_bugs_contd },
239 { PCI_VENDOR_ID_ATI, PCI_ANY_ID,
240 PCI_CLASS_SERIAL_SMBUS, PCI_ANY_ID, 0, ati_hpet_bugs },
223 {} 241 {}
224}; 242};
225 243
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index 0697ff139837..4db7c4d12ffa 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -571,8 +571,8 @@ auditsys:
571 * masked off. 571 * masked off.
572 */ 572 */
573sysret_audit: 573sysret_audit:
574 movq %rax,%rsi /* second arg, syscall return value */ 574 movq RAX-ARGOFFSET(%rsp),%rsi /* second arg, syscall return value */
575 cmpq $0,%rax /* is it < 0? */ 575 cmpq $0,%rsi /* is it < 0? */
576 setl %al /* 1 if so, 0 if not */ 576 setl %al /* 1 if so, 0 if not */
577 movzbl %al,%edi /* zero-extend that into %edi */ 577 movzbl %al,%edi /* zero-extend that into %edi */
578 inc %edi /* first arg, 0->1(AUDITSC_SUCCESS), 1->2(AUDITSC_FAILURE) */ 578 inc %edi /* first arg, 0->1(AUDITSC_SUCCESS), 1->2(AUDITSC_FAILURE) */
diff --git a/arch/x86/kernel/kprobes.c b/arch/x86/kernel/kprobes.c
index 345a4b1fe144..675879b65ce6 100644
--- a/arch/x86/kernel/kprobes.c
+++ b/arch/x86/kernel/kprobes.c
@@ -640,8 +640,8 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
640 /* Skip cs, ip, orig_ax and gs. */ \ 640 /* Skip cs, ip, orig_ax and gs. */ \
641 " subl $16, %esp\n" \ 641 " subl $16, %esp\n" \
642 " pushl %fs\n" \ 642 " pushl %fs\n" \
643 " pushl %ds\n" \
644 " pushl %es\n" \ 643 " pushl %es\n" \
644 " pushl %ds\n" \
645 " pushl %eax\n" \ 645 " pushl %eax\n" \
646 " pushl %ebp\n" \ 646 " pushl %ebp\n" \
647 " pushl %edi\n" \ 647 " pushl %edi\n" \
diff --git a/arch/x86/kernel/mrst.c b/arch/x86/kernel/mrst.c
index e796448f0eb5..5915e0b33303 100644
--- a/arch/x86/kernel/mrst.c
+++ b/arch/x86/kernel/mrst.c
@@ -216,6 +216,12 @@ static void __init mrst_setup_boot_clock(void)
216 setup_boot_APIC_clock(); 216 setup_boot_APIC_clock();
217}; 217};
218 218
219/* MID systems don't have i8042 controller */
220static int mrst_i8042_detect(void)
221{
222 return 0;
223}
224
219/* 225/*
220 * Moorestown specific x86_init function overrides and early setup 226 * Moorestown specific x86_init function overrides and early setup
221 * calls. 227 * calls.
@@ -233,6 +239,7 @@ void __init x86_mrst_early_setup(void)
233 x86_cpuinit.setup_percpu_clockev = mrst_setup_secondary_clock; 239 x86_cpuinit.setup_percpu_clockev = mrst_setup_secondary_clock;
234 240
235 x86_platform.calibrate_tsc = mrst_calibrate_tsc; 241 x86_platform.calibrate_tsc = mrst_calibrate_tsc;
242 x86_platform.i8042_detect = mrst_i8042_detect;
236 x86_init.pci.init = pci_mrst_init; 243 x86_init.pci.init = pci_mrst_init;
237 x86_init.pci.fixup_irqs = x86_init_noop; 244 x86_init.pci.fixup_irqs = x86_init_noop;
238 245
diff --git a/arch/x86/kernel/quirks.c b/arch/x86/kernel/quirks.c
index e72d3fc6547d..939b9e98245f 100644
--- a/arch/x86/kernel/quirks.c
+++ b/arch/x86/kernel/quirks.c
@@ -498,15 +498,10 @@ void force_hpet_resume(void)
498 * See erratum #27 (Misinterpreted MSI Requests May Result in 498 * See erratum #27 (Misinterpreted MSI Requests May Result in
499 * Corrupted LPC DMA Data) in AMD Publication #46837, 499 * Corrupted LPC DMA Data) in AMD Publication #46837,
500 * "SB700 Family Product Errata", Rev. 1.0, March 2010. 500 * "SB700 Family Product Errata", Rev. 1.0, March 2010.
501 *
502 * Also force the read back of the CMP register in hpet_next_event()
503 * to work around the problem that the CMP register write seems to be
504 * delayed. See hpet_next_event() for details.
505 */ 501 */
506static void force_disable_hpet_msi(struct pci_dev *unused) 502static void force_disable_hpet_msi(struct pci_dev *unused)
507{ 503{
508 hpet_msi_disable = 1; 504 hpet_msi_disable = 1;
509 hpet_readback_cmp = 1;
510} 505}
511 506
512DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_SBX00_SMBUS, 507DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_SBX00_SMBUS,
diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
index de3b63ae3da2..a60df9ae6454 100644
--- a/arch/x86/kernel/setup_percpu.c
+++ b/arch/x86/kernel/setup_percpu.c
@@ -238,6 +238,15 @@ void __init setup_per_cpu_areas(void)
238#ifdef CONFIG_NUMA 238#ifdef CONFIG_NUMA
239 per_cpu(x86_cpu_to_node_map, cpu) = 239 per_cpu(x86_cpu_to_node_map, cpu) =
240 early_per_cpu_map(x86_cpu_to_node_map, cpu); 240 early_per_cpu_map(x86_cpu_to_node_map, cpu);
241 /*
242 * Ensure that the boot cpu numa_node is correct when the boot
243 * cpu is on a node that doesn't have memory installed.
244 * Also cpu_up() will call cpu_to_node() for APs when
245 * MEMORY_HOTPLUG is defined, before per_cpu(numa_node) is set
246 * up later with c_init aka intel_init/amd_init.
247 * So set them all (boot cpu and all APs).
248 */
249 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
241#endif 250#endif
242#endif 251#endif
243 /* 252 /*
@@ -257,14 +266,6 @@ void __init setup_per_cpu_areas(void)
257 early_per_cpu_ptr(x86_cpu_to_node_map) = NULL; 266 early_per_cpu_ptr(x86_cpu_to_node_map) = NULL;
258#endif 267#endif
259 268
260#if defined(CONFIG_X86_64) && defined(CONFIG_NUMA)
261 /*
262 * make sure boot cpu numa_node is right, when boot cpu is on the
263 * node that doesn't have mem installed
264 */
265 set_cpu_numa_node(boot_cpu_id, early_cpu_to_node(boot_cpu_id));
266#endif
267
268 /* Setup node to cpumask map */ 269 /* Setup node to cpumask map */
269 setup_node_to_cpumask_map(); 270 setup_node_to_cpumask_map();
270 271
diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
index 61a1e8c7e19f..cd6da6bf3eca 100644
--- a/arch/x86/kernel/x86_init.c
+++ b/arch/x86/kernel/x86_init.c
@@ -5,6 +5,7 @@
5 */ 5 */
6#include <linux/init.h> 6#include <linux/init.h>
7#include <linux/ioport.h> 7#include <linux/ioport.h>
8#include <linux/module.h>
8 9
9#include <asm/bios_ebda.h> 10#include <asm/bios_ebda.h>
10#include <asm/paravirt.h> 11#include <asm/paravirt.h>
@@ -85,6 +86,7 @@ struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
85}; 86};
86 87
87static void default_nmi_init(void) { }; 88static void default_nmi_init(void) { };
89static int default_i8042_detect(void) { return 1; };
88 90
89struct x86_platform_ops x86_platform = { 91struct x86_platform_ops x86_platform = {
90 .calibrate_tsc = native_calibrate_tsc, 92 .calibrate_tsc = native_calibrate_tsc,
@@ -92,5 +94,8 @@ struct x86_platform_ops x86_platform = {
92 .set_wallclock = mach_set_rtc_mmss, 94 .set_wallclock = mach_set_rtc_mmss,
93 .iommu_shutdown = iommu_shutdown_noop, 95 .iommu_shutdown = iommu_shutdown_noop,
94 .is_untracked_pat_range = is_ISA_range, 96 .is_untracked_pat_range = is_ISA_range,
95 .nmi_init = default_nmi_init 97 .nmi_init = default_nmi_init,
98 .i8042_detect = default_i8042_detect
96}; 99};
100
101EXPORT_SYMBOL_GPL(x86_platform);
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index a6f695d76928..b1ed0a1a5913 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -1879,6 +1879,8 @@ static void mmu_set_spte(struct kvm_vcpu *vcpu, u64 *sptep,
1879 pgprintk("hfn old %lx new %lx\n", 1879 pgprintk("hfn old %lx new %lx\n",
1880 spte_to_pfn(*sptep), pfn); 1880 spte_to_pfn(*sptep), pfn);
1881 rmap_remove(vcpu->kvm, sptep); 1881 rmap_remove(vcpu->kvm, sptep);
1882 __set_spte(sptep, shadow_trap_nonpresent_pte);
1883 kvm_flush_remote_tlbs(vcpu->kvm);
1882 } else 1884 } else
1883 was_rmapped = 1; 1885 was_rmapped = 1;
1884 } 1886 }
@@ -2924,7 +2926,7 @@ static int kvm_mmu_remove_some_alloc_mmu_pages(struct kvm *kvm)
2924 return kvm_mmu_zap_page(kvm, page) + 1; 2926 return kvm_mmu_zap_page(kvm, page) + 1;
2925} 2927}
2926 2928
2927static int mmu_shrink(int nr_to_scan, gfp_t gfp_mask) 2929static int mmu_shrink(struct shrinker *shrink, int nr_to_scan, gfp_t gfp_mask)
2928{ 2930{
2929 struct kvm *kvm; 2931 struct kvm *kvm;
2930 struct kvm *kvm_freed = NULL; 2932 struct kvm *kvm_freed = NULL;
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 859a01a07dbf..ee03679efe78 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -1744,18 +1744,15 @@ static void enter_lmode(struct kvm_vcpu *vcpu)
1744 (guest_tr_ar & ~AR_TYPE_MASK) 1744 (guest_tr_ar & ~AR_TYPE_MASK)
1745 | AR_TYPE_BUSY_64_TSS); 1745 | AR_TYPE_BUSY_64_TSS);
1746 } 1746 }
1747 vcpu->arch.efer |= EFER_LMA; 1747 vmx_set_efer(vcpu, vcpu->arch.efer | EFER_LMA);
1748 vmx_set_efer(vcpu, vcpu->arch.efer);
1749} 1748}
1750 1749
1751static void exit_lmode(struct kvm_vcpu *vcpu) 1750static void exit_lmode(struct kvm_vcpu *vcpu)
1752{ 1751{
1753 vcpu->arch.efer &= ~EFER_LMA;
1754
1755 vmcs_write32(VM_ENTRY_CONTROLS, 1752 vmcs_write32(VM_ENTRY_CONTROLS,
1756 vmcs_read32(VM_ENTRY_CONTROLS) 1753 vmcs_read32(VM_ENTRY_CONTROLS)
1757 & ~VM_ENTRY_IA32E_MODE); 1754 & ~VM_ENTRY_IA32E_MODE);
1758 vmx_set_efer(vcpu, vcpu->arch.efer); 1755 vmx_set_efer(vcpu, vcpu->arch.efer & ~EFER_LMA);
1759} 1756}
1760 1757
1761#endif 1758#endif
diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c
index 6fdb3ec30c31..55253095be84 100644
--- a/arch/x86/pci/i386.c
+++ b/arch/x86/pci/i386.c
@@ -184,6 +184,7 @@ static void __init pcibios_allocate_resources(int pass)
184 idx, r, disabled, pass); 184 idx, r, disabled, pass);
185 if (pci_claim_resource(dev, idx) < 0) { 185 if (pci_claim_resource(dev, idx) < 0) {
186 /* We'll assign a new address later */ 186 /* We'll assign a new address later */
187 dev->fw_addr[idx] = r->start;
187 r->end -= r->start; 188 r->end -= r->start;
188 r->start = 0; 189 r->start = 0;
189 } 190 }
diff --git a/arch/x86/pci/mrst.c b/arch/x86/pci/mrst.c
index 7ef3a2735df3..cb29191cee58 100644
--- a/arch/x86/pci/mrst.c
+++ b/arch/x86/pci/mrst.c
@@ -66,8 +66,9 @@ static int fixed_bar_cap(struct pci_bus *bus, unsigned int devfn)
66 devfn, pos, 4, &pcie_cap)) 66 devfn, pos, 4, &pcie_cap))
67 return 0; 67 return 0;
68 68
69 if (pcie_cap == 0xffffffff) 69 if (PCI_EXT_CAP_ID(pcie_cap) == 0x0000 ||
70 return 0; 70 PCI_EXT_CAP_ID(pcie_cap) == 0xffff)
71 break;
71 72
72 if (PCI_EXT_CAP_ID(pcie_cap) == PCI_EXT_CAP_ID_VNDR) { 73 if (PCI_EXT_CAP_ID(pcie_cap) == PCI_EXT_CAP_ID_VNDR) {
73 raw_pci_ext_ops->read(pci_domain_nr(bus), bus->number, 74 raw_pci_ext_ops->read(pci_domain_nr(bus), bus->number,
@@ -76,7 +77,7 @@ static int fixed_bar_cap(struct pci_bus *bus, unsigned int devfn)
76 return pos; 77 return pos;
77 } 78 }
78 79
79 pos = pcie_cap >> 20; 80 pos = PCI_EXT_CAP_NEXT(pcie_cap);
80 } 81 }
81 82
82 return 0; 83 return 0;
diff --git a/crypto/ablkcipher.c b/crypto/ablkcipher.c
index 98a66103f4f2..a854df2a5a4b 100644
--- a/crypto/ablkcipher.c
+++ b/crypto/ablkcipher.c
@@ -165,7 +165,7 @@ static inline int ablkcipher_next_slow(struct ablkcipher_request *req,
165 165
166 p = kmalloc(n, GFP_ATOMIC); 166 p = kmalloc(n, GFP_ATOMIC);
167 if (!p) 167 if (!p)
168 ablkcipher_walk_done(req, walk, -ENOMEM); 168 return ablkcipher_walk_done(req, walk, -ENOMEM);
169 169
170 base = p + 1; 170 base = p + 1;
171 171
diff --git a/drivers/char/sysrq.c b/drivers/char/sysrq.c
index 5d64e3acb000..878ac0c2cc68 100644
--- a/drivers/char/sysrq.c
+++ b/drivers/char/sysrq.c
@@ -493,7 +493,7 @@ static void __sysrq_put_key_op(int key, struct sysrq_key_op *op_p)
493 sysrq_key_table[i] = op_p; 493 sysrq_key_table[i] = op_p;
494} 494}
495 495
496static void __handle_sysrq(int key, struct tty_struct *tty, int check_mask) 496void __handle_sysrq(int key, struct tty_struct *tty, int check_mask)
497{ 497{
498 struct sysrq_key_op *op_p; 498 struct sysrq_key_op *op_p;
499 int orig_log_level; 499 int orig_log_level;
diff --git a/drivers/clocksource/cs5535-clockevt.c b/drivers/clocksource/cs5535-clockevt.c
index d7be69f13154..b7dab32ce63c 100644
--- a/drivers/clocksource/cs5535-clockevt.c
+++ b/drivers/clocksource/cs5535-clockevt.c
@@ -194,6 +194,6 @@ err_timer:
194 194
195module_init(cs5535_mfgpt_init); 195module_init(cs5535_mfgpt_init);
196 196
197MODULE_AUTHOR("Andres Salomon <dilinger@collabora.co.uk>"); 197MODULE_AUTHOR("Andres Salomon <dilinger@queued.net>");
198MODULE_DESCRIPTION("CS5535/CS5536 MFGPT clock event driver"); 198MODULE_DESCRIPTION("CS5535/CS5536 MFGPT clock event driver");
199MODULE_LICENSE("GPL"); 199MODULE_LICENSE("GPL");
diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c
index 637c105f53d2..bd78acf3c365 100644
--- a/drivers/crypto/talitos.c
+++ b/drivers/crypto/talitos.c
@@ -1183,10 +1183,14 @@ static size_t sg_copy_end_to_buffer(struct scatterlist *sgl, unsigned int nents,
1183 /* Copy part of this segment */ 1183 /* Copy part of this segment */
1184 ignore = skip - offset; 1184 ignore = skip - offset;
1185 len = miter.length - ignore; 1185 len = miter.length - ignore;
1186 if (boffset + len > buflen)
1187 len = buflen - boffset;
1186 memcpy(buf + boffset, miter.addr + ignore, len); 1188 memcpy(buf + boffset, miter.addr + ignore, len);
1187 } else { 1189 } else {
1188 /* Copy all of this segment */ 1190 /* Copy all of this segment (up to buflen) */
1189 len = miter.length; 1191 len = miter.length;
1192 if (boffset + len > buflen)
1193 len = buflen - boffset;
1190 memcpy(buf + boffset, miter.addr, len); 1194 memcpy(buf + boffset, miter.addr, len);
1191 } 1195 }
1192 boffset += len; 1196 boffset += len;
diff --git a/drivers/edac/Kconfig b/drivers/edac/Kconfig
index aedef7941b22..0d2f9dbb47e4 100644
--- a/drivers/edac/Kconfig
+++ b/drivers/edac/Kconfig
@@ -209,7 +209,7 @@ config EDAC_I5100
209 209
210config EDAC_MPC85XX 210config EDAC_MPC85XX
211 tristate "Freescale MPC83xx / MPC85xx" 211 tristate "Freescale MPC83xx / MPC85xx"
212 depends on EDAC_MM_EDAC && FSL_SOC && (PPC_83xx || MPC85xx) 212 depends on EDAC_MM_EDAC && FSL_SOC && (PPC_83xx || PPC_85xx)
213 help 213 help
214 Support for error detection and correction on the Freescale 214 Support for error detection and correction on the Freescale
215 MPC8349, MPC8560, MPC8540, MPC8548 215 MPC8349, MPC8560, MPC8540, MPC8548
diff --git a/drivers/edac/mpc85xx_edac.c b/drivers/edac/mpc85xx_edac.c
index 52ca09bf4726..f39b00a46eda 100644
--- a/drivers/edac/mpc85xx_edac.c
+++ b/drivers/edac/mpc85xx_edac.c
@@ -1120,6 +1120,7 @@ static struct of_device_id mpc85xx_mc_err_of_match[] = {
1120 { .compatible = "fsl,mpc8555-memory-controller", }, 1120 { .compatible = "fsl,mpc8555-memory-controller", },
1121 { .compatible = "fsl,mpc8560-memory-controller", }, 1121 { .compatible = "fsl,mpc8560-memory-controller", },
1122 { .compatible = "fsl,mpc8568-memory-controller", }, 1122 { .compatible = "fsl,mpc8568-memory-controller", },
1123 { .compatible = "fsl,mpc8569-memory-controller", },
1123 { .compatible = "fsl,mpc8572-memory-controller", }, 1124 { .compatible = "fsl,mpc8572-memory-controller", },
1124 { .compatible = "fsl,mpc8349-memory-controller", }, 1125 { .compatible = "fsl,mpc8349-memory-controller", },
1125 { .compatible = "fsl,p2020-memory-controller", }, 1126 { .compatible = "fsl,p2020-memory-controller", },
diff --git a/drivers/gpio/cs5535-gpio.c b/drivers/gpio/cs5535-gpio.c
index f73a1555e49d..e23c06893d19 100644
--- a/drivers/gpio/cs5535-gpio.c
+++ b/drivers/gpio/cs5535-gpio.c
@@ -352,6 +352,6 @@ static void __exit cs5535_gpio_exit(void)
352module_init(cs5535_gpio_init); 352module_init(cs5535_gpio_init);
353module_exit(cs5535_gpio_exit); 353module_exit(cs5535_gpio_exit);
354 354
355MODULE_AUTHOR("Andres Salomon <dilinger@collabora.co.uk>"); 355MODULE_AUTHOR("Andres Salomon <dilinger@queued.net>");
356MODULE_DESCRIPTION("AMD CS5535/CS5536 GPIO driver"); 356MODULE_DESCRIPTION("AMD CS5535/CS5536 GPIO driver");
357MODULE_LICENSE("GPL"); 357MODULE_LICENSE("GPL");
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 43ce3809ef64..51bd301cf10d 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -2241,6 +2241,7 @@ i915_gem_object_get_pages(struct drm_gem_object *obj,
2241 page = read_cache_page_gfp(mapping, i, 2241 page = read_cache_page_gfp(mapping, i,
2242 GFP_HIGHUSER | 2242 GFP_HIGHUSER |
2243 __GFP_COLD | 2243 __GFP_COLD |
2244 __GFP_RECLAIMABLE |
2244 gfpmask); 2245 gfpmask);
2245 if (IS_ERR(page)) 2246 if (IS_ERR(page))
2246 goto err_pages; 2247 goto err_pages;
@@ -4987,7 +4988,7 @@ i915_gpu_is_active(struct drm_device *dev)
4987} 4988}
4988 4989
4989static int 4990static int
4990i915_gem_shrink(int nr_to_scan, gfp_t gfp_mask) 4991i915_gem_shrink(struct shrinker *shrink, int nr_to_scan, gfp_t gfp_mask)
4991{ 4992{
4992 drm_i915_private_t *dev_priv, *next_dev; 4993 drm_i915_private_t *dev_priv, *next_dev;
4993 struct drm_i915_gem_object *obj_priv, *next_obj; 4994 struct drm_i915_gem_object *obj_priv, *next_obj;
diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
index f394b3b2fadf..ca904799f018 100644
--- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
+++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
@@ -394,7 +394,7 @@ static int ttm_pool_get_num_unused_pages(void)
394/** 394/**
395 * Callback for mm to request pool to reduce number of page held. 395 * Callback for mm to request pool to reduce number of page held.
396 */ 396 */
397static int ttm_pool_mm_shrink(int shrink_pages, gfp_t gfp_mask) 397static int ttm_pool_mm_shrink(struct shrinker *shrink, int shrink_pages, gfp_t gfp_mask)
398{ 398{
399 static atomic_t start_pool = ATOMIC_INIT(0); 399 static atomic_t start_pool = ATOMIC_INIT(0);
400 unsigned i; 400 unsigned i;
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index 0f9a4785d798..3525f533e186 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -69,11 +69,11 @@ config KEYBOARD_ATARI
69 module will be called atakbd. 69 module will be called atakbd.
70 70
71config KEYBOARD_ATKBD 71config KEYBOARD_ATKBD
72 tristate "AT keyboard" if EMBEDDED || !X86 || X86_MRST 72 tristate "AT keyboard" if EMBEDDED || !X86
73 default y 73 default y
74 select SERIO 74 select SERIO
75 select SERIO_LIBPS2 75 select SERIO_LIBPS2
76 select SERIO_I8042 if X86 && !X86_MRST 76 select SERIO_I8042 if X86
77 select SERIO_GSCPS2 if GSC 77 select SERIO_GSCPS2 if GSC
78 help 78 help
79 Say Y here if you want to use a standard AT or PS/2 keyboard. Usually 79 Say Y here if you want to use a standard AT or PS/2 keyboard. Usually
diff --git a/drivers/input/mouse/Kconfig b/drivers/input/mouse/Kconfig
index eeb58c1cac16..c714ca2407f8 100644
--- a/drivers/input/mouse/Kconfig
+++ b/drivers/input/mouse/Kconfig
@@ -17,7 +17,7 @@ config MOUSE_PS2
17 default y 17 default y
18 select SERIO 18 select SERIO
19 select SERIO_LIBPS2 19 select SERIO_LIBPS2
20 select SERIO_I8042 if X86 && !X86_MRST 20 select SERIO_I8042 if X86
21 select SERIO_GSCPS2 if GSC 21 select SERIO_GSCPS2 if GSC
22 help 22 help
23 Say Y here if you have a PS/2 mouse connected to your system. This 23 Say Y here if you have a PS/2 mouse connected to your system. This
diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index 40cea334ad13..9ba9c4a17e15 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -206,6 +206,7 @@ static int synaptics_resolution(struct psmouse *psmouse)
206 unsigned char max[3]; 206 unsigned char max[3];
207 207
208 if (SYN_ID_MAJOR(priv->identity) < 4) 208 if (SYN_ID_MAJOR(priv->identity) < 4)
209 return 0;
209 210
210 if (synaptics_send_cmd(psmouse, SYN_QUE_RESOLUTION, res) == 0) { 211 if (synaptics_send_cmd(psmouse, SYN_QUE_RESOLUTION, res) == 0) {
211 if (res[0] != 0 && (res[1] & 0x80) && res[2] != 0) { 212 if (res[0] != 0 && (res[1] & 0x80) && res[2] != 0) {
diff --git a/drivers/input/serio/Kconfig b/drivers/input/serio/Kconfig
index 256b9e9394dc..3bfe8fafc6ad 100644
--- a/drivers/input/serio/Kconfig
+++ b/drivers/input/serio/Kconfig
@@ -22,7 +22,7 @@ config SERIO_I8042
22 tristate "i8042 PC Keyboard controller" if EMBEDDED || !X86 22 tristate "i8042 PC Keyboard controller" if EMBEDDED || !X86
23 default y 23 default y
24 depends on !PARISC && (!ARM || ARCH_SHARK || FOOTBRIDGE_HOST) && \ 24 depends on !PARISC && (!ARM || ARCH_SHARK || FOOTBRIDGE_HOST) && \
25 (!SUPERH || SH_CAYMAN) && !M68K && !BLACKFIN && !X86_MRST 25 (!SUPERH || SH_CAYMAN) && !M68K && !BLACKFIN
26 help 26 help
27 i8042 is the chip over which the standard AT keyboard and PS/2 27 i8042 is the chip over which the standard AT keyboard and PS/2
28 mouse are connected to the computer. If you use these devices, 28 mouse are connected to the computer. If you use these devices,
diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h
index 6168469ad1a6..81003c4739f4 100644
--- a/drivers/input/serio/i8042-x86ia64io.h
+++ b/drivers/input/serio/i8042-x86ia64io.h
@@ -7,6 +7,10 @@
7 * the Free Software Foundation. 7 * the Free Software Foundation.
8 */ 8 */
9 9
10#ifdef CONFIG_X86
11#include <asm/x86_init.h>
12#endif
13
10/* 14/*
11 * Names. 15 * Names.
12 */ 16 */
@@ -840,6 +844,12 @@ static int __init i8042_platform_init(void)
840{ 844{
841 int retval; 845 int retval;
842 846
847#ifdef CONFIG_X86
848 /* Just return if pre-detection shows no i8042 controller exist */
849 if (!x86_platform.i8042_detect())
850 return -ENODEV;
851#endif
852
843/* 853/*
844 * On ix86 platforms touching the i8042 data register region can do really 854 * On ix86 platforms touching the i8042 data register region can do really
845 * bad things. Because of this the region is always reserved on ix86 boxes. 855 * bad things. Because of this the region is always reserved on ix86 boxes.
diff --git a/drivers/input/touchscreen/w90p910_ts.c b/drivers/input/touchscreen/w90p910_ts.c
index cc18265be1a8..7a45d68c3516 100644
--- a/drivers/input/touchscreen/w90p910_ts.c
+++ b/drivers/input/touchscreen/w90p910_ts.c
@@ -233,7 +233,7 @@ static int __devinit w90x900ts_probe(struct platform_device *pdev)
233 w90p910_ts->state = TS_IDLE; 233 w90p910_ts->state = TS_IDLE;
234 spin_lock_init(&w90p910_ts->lock); 234 spin_lock_init(&w90p910_ts->lock);
235 setup_timer(&w90p910_ts->timer, w90p910_check_pen_up, 235 setup_timer(&w90p910_ts->timer, w90p910_check_pen_up,
236 (unsigned long)&w90p910_ts); 236 (unsigned long)w90p910_ts);
237 237
238 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 238 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
239 if (!res) { 239 if (!res) {
diff --git a/drivers/misc/cs5535-mfgpt.c b/drivers/misc/cs5535-mfgpt.c
index 9bec24db4d41..2d44b3300104 100644
--- a/drivers/misc/cs5535-mfgpt.c
+++ b/drivers/misc/cs5535-mfgpt.c
@@ -366,6 +366,6 @@ static int __init cs5535_mfgpt_init(void)
366 366
367module_init(cs5535_mfgpt_init); 367module_init(cs5535_mfgpt_init);
368 368
369MODULE_AUTHOR("Andres Salomon <dilinger@collabora.co.uk>"); 369MODULE_AUTHOR("Andres Salomon <dilinger@queued.net>");
370MODULE_DESCRIPTION("CS5535/CS5536 MFGPT timer driver"); 370MODULE_DESCRIPTION("CS5535/CS5536 MFGPT timer driver");
371MODULE_LICENSE("GPL"); 371MODULE_LICENSE("GPL");
diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
index af217924a76e..ad30f074ee15 100644
--- a/drivers/mmc/host/sdhci-s3c.c
+++ b/drivers/mmc/host/sdhci-s3c.c
@@ -365,6 +365,26 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
365 365
366static int __devexit sdhci_s3c_remove(struct platform_device *pdev) 366static int __devexit sdhci_s3c_remove(struct platform_device *pdev)
367{ 367{
368 struct sdhci_host *host = platform_get_drvdata(pdev);
369 struct sdhci_s3c *sc = sdhci_priv(host);
370 int ptr;
371
372 sdhci_remove_host(host, 1);
373
374 for (ptr = 0; ptr < 3; ptr++) {
375 clk_disable(sc->clk_bus[ptr]);
376 clk_put(sc->clk_bus[ptr]);
377 }
378 clk_disable(sc->clk_io);
379 clk_put(sc->clk_io);
380
381 iounmap(host->ioaddr);
382 release_resource(sc->ioarea);
383 kfree(sc->ioarea);
384
385 sdhci_free_host(host);
386 platform_set_drvdata(pdev, NULL);
387
368 return 0; 388 return 0;
369} 389}
370 390
diff --git a/drivers/net/ibmveth.c b/drivers/net/ibmveth.c
index 7acb3edc47ef..2602852cc55a 100644
--- a/drivers/net/ibmveth.c
+++ b/drivers/net/ibmveth.c
@@ -677,7 +677,7 @@ static int ibmveth_close(struct net_device *netdev)
677 if (!adapter->pool_config) 677 if (!adapter->pool_config)
678 netif_stop_queue(netdev); 678 netif_stop_queue(netdev);
679 679
680 free_irq(netdev->irq, netdev); 680 h_vio_signal(adapter->vdev->unit_address, VIO_IRQ_DISABLE);
681 681
682 do { 682 do {
683 lpar_rc = h_free_logical_lan(adapter->vdev->unit_address); 683 lpar_rc = h_free_logical_lan(adapter->vdev->unit_address);
@@ -689,6 +689,8 @@ static int ibmveth_close(struct net_device *netdev)
689 lpar_rc); 689 lpar_rc);
690 } 690 }
691 691
692 free_irq(netdev->irq, netdev);
693
692 adapter->rx_no_buffer = *(u64*)(((char*)adapter->buffer_list_addr) + 4096 - 8); 694 adapter->rx_no_buffer = *(u64*)(((char*)adapter->buffer_list_addr) + 4096 - 8);
693 695
694 ibmveth_cleanup(adapter); 696 ibmveth_cleanup(adapter);
diff --git a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c
index 5b3dfb4ab279..33525bf2a3d3 100644
--- a/drivers/net/pcmcia/axnet_cs.c
+++ b/drivers/net/pcmcia/axnet_cs.c
@@ -1168,6 +1168,7 @@ static irqreturn_t ax_interrupt(int irq, void *dev_id)
1168 int interrupts, nr_serviced = 0, i; 1168 int interrupts, nr_serviced = 0, i;
1169 struct ei_device *ei_local; 1169 struct ei_device *ei_local;
1170 int handled = 0; 1170 int handled = 0;
1171 unsigned long flags;
1171 1172
1172 e8390_base = dev->base_addr; 1173 e8390_base = dev->base_addr;
1173 ei_local = netdev_priv(dev); 1174 ei_local = netdev_priv(dev);
@@ -1176,7 +1177,7 @@ static irqreturn_t ax_interrupt(int irq, void *dev_id)
1176 * Protect the irq test too. 1177 * Protect the irq test too.
1177 */ 1178 */
1178 1179
1179 spin_lock(&ei_local->page_lock); 1180 spin_lock_irqsave(&ei_local->page_lock, flags);
1180 1181
1181 if (ei_local->irqlock) 1182 if (ei_local->irqlock)
1182 { 1183 {
@@ -1188,7 +1189,7 @@ static irqreturn_t ax_interrupt(int irq, void *dev_id)
1188 dev->name, inb_p(e8390_base + EN0_ISR), 1189 dev->name, inb_p(e8390_base + EN0_ISR),
1189 inb_p(e8390_base + EN0_IMR)); 1190 inb_p(e8390_base + EN0_IMR));
1190#endif 1191#endif
1191 spin_unlock(&ei_local->page_lock); 1192 spin_unlock_irqrestore(&ei_local->page_lock, flags);
1192 return IRQ_NONE; 1193 return IRQ_NONE;
1193 } 1194 }
1194 1195
@@ -1261,7 +1262,7 @@ static irqreturn_t ax_interrupt(int irq, void *dev_id)
1261 ei_local->irqlock = 0; 1262 ei_local->irqlock = 0;
1262 outb_p(ENISR_ALL, e8390_base + EN0_IMR); 1263 outb_p(ENISR_ALL, e8390_base + EN0_IMR);
1263 1264
1264 spin_unlock(&ei_local->page_lock); 1265 spin_unlock_irqrestore(&ei_local->page_lock, flags);
1265 return IRQ_RETVAL(handled); 1266 return IRQ_RETVAL(handled);
1266} 1267}
1267 1268
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index 96b6cfbf0a3a..cdc6a5c2e70d 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -1316,7 +1316,7 @@ static void rtl8169_get_mac_version(struct rtl8169_private *tp,
1316 { 0x7c800000, 0x28000000, RTL_GIGA_MAC_VER_26 }, 1316 { 0x7c800000, 0x28000000, RTL_GIGA_MAC_VER_26 },
1317 1317
1318 /* 8168C family. */ 1318 /* 8168C family. */
1319 { 0x7cf00000, 0x3ca00000, RTL_GIGA_MAC_VER_24 }, 1319 { 0x7cf00000, 0x3cb00000, RTL_GIGA_MAC_VER_24 },
1320 { 0x7cf00000, 0x3c900000, RTL_GIGA_MAC_VER_23 }, 1320 { 0x7cf00000, 0x3c900000, RTL_GIGA_MAC_VER_23 },
1321 { 0x7cf00000, 0x3c800000, RTL_GIGA_MAC_VER_18 }, 1321 { 0x7cf00000, 0x3c800000, RTL_GIGA_MAC_VER_18 },
1322 { 0x7c800000, 0x3c800000, RTL_GIGA_MAC_VER_24 }, 1322 { 0x7c800000, 0x3c800000, RTL_GIGA_MAC_VER_24 },
diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.c b/drivers/net/wireless/ath/ath9k/hif_usb.c
index 77b359162d6c..23c15aa9fbd5 100644
--- a/drivers/net/wireless/ath/ath9k/hif_usb.c
+++ b/drivers/net/wireless/ath/ath9k/hif_usb.c
@@ -730,13 +730,17 @@ static int ath9k_hif_usb_alloc_urbs(struct hif_device_usb *hif_dev)
730 730
731 /* RX */ 731 /* RX */
732 if (ath9k_hif_usb_alloc_rx_urbs(hif_dev) < 0) 732 if (ath9k_hif_usb_alloc_rx_urbs(hif_dev) < 0)
733 goto err; 733 goto err_rx;
734 734
735 /* Register Read */ 735 /* Register Read */
736 if (ath9k_hif_usb_alloc_reg_in_urb(hif_dev) < 0) 736 if (ath9k_hif_usb_alloc_reg_in_urb(hif_dev) < 0)
737 goto err; 737 goto err_reg;
738 738
739 return 0; 739 return 0;
740err_reg:
741 ath9k_hif_usb_dealloc_rx_urbs(hif_dev);
742err_rx:
743 ath9k_hif_usb_dealloc_tx_urbs(hif_dev);
740err: 744err:
741 return -ENOMEM; 745 return -ENOMEM;
742} 746}
diff --git a/drivers/net/wireless/hostap/hostap_pci.c b/drivers/net/wireless/hostap/hostap_pci.c
index d24dc7dc0723..972a9c3af39e 100644
--- a/drivers/net/wireless/hostap/hostap_pci.c
+++ b/drivers/net/wireless/hostap/hostap_pci.c
@@ -330,6 +330,7 @@ static int prism2_pci_probe(struct pci_dev *pdev,
330 330
331 dev->irq = pdev->irq; 331 dev->irq = pdev->irq;
332 hw_priv->mem_start = mem; 332 hw_priv->mem_start = mem;
333 dev->base_addr = (unsigned long) mem;
333 334
334 prism2_pci_cor_sreset(local); 335 prism2_pci_cor_sreset(local);
335 336
diff --git a/drivers/net/wireless/iwlwifi/iwl-sta.h b/drivers/net/wireless/iwlwifi/iwl-sta.h
index c2a453a1a991..dc43ebd1f1fd 100644
--- a/drivers/net/wireless/iwlwifi/iwl-sta.h
+++ b/drivers/net/wireless/iwlwifi/iwl-sta.h
@@ -97,6 +97,17 @@ static inline void iwl_clear_driver_stations(struct iwl_priv *priv)
97 spin_lock_irqsave(&priv->sta_lock, flags); 97 spin_lock_irqsave(&priv->sta_lock, flags);
98 memset(priv->stations, 0, sizeof(priv->stations)); 98 memset(priv->stations, 0, sizeof(priv->stations));
99 priv->num_stations = 0; 99 priv->num_stations = 0;
100
101 /*
102 * Remove all key information that is not stored as part of station
103 * information since mac80211 may not have had a
104 * chance to remove all the keys. When device is reconfigured by
105 * mac80211 after an error all keys will be reconfigured.
106 */
107 priv->ucode_key_table = 0;
108 priv->key_mapping_key = 0;
109 memset(priv->wep_keys, 0, sizeof(priv->wep_keys));
110
100 spin_unlock_irqrestore(&priv->sta_lock, flags); 111 spin_unlock_irqrestore(&priv->sta_lock, flags);
101} 112}
102 113
diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c
index 3ae468c4d760..f20d3eeeea7f 100644
--- a/drivers/net/wireless/rt2x00/rt2x00dev.c
+++ b/drivers/net/wireless/rt2x00/rt2x00dev.c
@@ -854,6 +854,11 @@ int rt2x00lib_probe_dev(struct rt2x00_dev *rt2x00dev)
854 BIT(NL80211_IFTYPE_WDS); 854 BIT(NL80211_IFTYPE_WDS);
855 855
856 /* 856 /*
857 * Initialize configuration work.
858 */
859 INIT_WORK(&rt2x00dev->intf_work, rt2x00lib_intf_scheduled);
860
861 /*
857 * Let the driver probe the device to detect the capabilities. 862 * Let the driver probe the device to detect the capabilities.
858 */ 863 */
859 retval = rt2x00dev->ops->lib->probe_hw(rt2x00dev); 864 retval = rt2x00dev->ops->lib->probe_hw(rt2x00dev);
@@ -863,11 +868,6 @@ int rt2x00lib_probe_dev(struct rt2x00_dev *rt2x00dev)
863 } 868 }
864 869
865 /* 870 /*
866 * Initialize configuration work.
867 */
868 INIT_WORK(&rt2x00dev->intf_work, rt2x00lib_intf_scheduled);
869
870 /*
871 * Allocate queue array. 871 * Allocate queue array.
872 */ 872 */
873 retval = rt2x00queue_allocate(rt2x00dev); 873 retval = rt2x00queue_allocate(rt2x00dev);
diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c
index 92379e2d37e7..2aaa13150de3 100644
--- a/drivers/pci/setup-res.c
+++ b/drivers/pci/setup-res.c
@@ -156,6 +156,38 @@ static int __pci_assign_resource(struct pci_bus *bus, struct pci_dev *dev,
156 pcibios_align_resource, dev); 156 pcibios_align_resource, dev);
157 } 157 }
158 158
159 if (ret < 0 && dev->fw_addr[resno]) {
160 struct resource *root, *conflict;
161 resource_size_t start, end;
162
163 /*
164 * If we failed to assign anything, let's try the address
165 * where firmware left it. That at least has a chance of
166 * working, which is better than just leaving it disabled.
167 */
168
169 if (res->flags & IORESOURCE_IO)
170 root = &ioport_resource;
171 else
172 root = &iomem_resource;
173
174 start = res->start;
175 end = res->end;
176 res->start = dev->fw_addr[resno];
177 res->end = res->start + size - 1;
178 dev_info(&dev->dev, "BAR %d: trying firmware assignment %pR\n",
179 resno, res);
180 conflict = request_resource_conflict(root, res);
181 if (conflict) {
182 dev_info(&dev->dev,
183 "BAR %d: %pR conflicts with %s %pR\n", resno,
184 res, conflict->name, conflict);
185 res->start = start;
186 res->end = end;
187 } else
188 ret = 0;
189 }
190
159 if (!ret) { 191 if (!ret) {
160 res->flags &= ~IORESOURCE_STARTALIGN; 192 res->flags &= ~IORESOURCE_STARTALIGN;
161 dev_info(&dev->dev, "BAR %d: assigned %pR\n", resno, res); 193 dev_info(&dev->dev, "BAR %d: assigned %pR\n", resno, res);
diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c
index 29f91fac1dff..a4cd9adfcbc0 100644
--- a/drivers/pcmcia/pcmcia_resource.c
+++ b/drivers/pcmcia/pcmcia_resource.c
@@ -857,8 +857,10 @@ void pcmcia_disable_device(struct pcmcia_device *p_dev)
857{ 857{
858 pcmcia_release_configuration(p_dev); 858 pcmcia_release_configuration(p_dev);
859 pcmcia_release_io(p_dev, &p_dev->io); 859 pcmcia_release_io(p_dev, &p_dev->io);
860 if (p_dev->_irq) 860 if (p_dev->_irq) {
861 free_irq(p_dev->irq, p_dev->priv); 861 free_irq(p_dev->irq, p_dev->priv);
862 p_dev->_irq = 0;
863 }
862 if (p_dev->win) 864 if (p_dev->win)
863 pcmcia_release_window(p_dev, p_dev->win); 865 pcmcia_release_window(p_dev, p_dev->win);
864} 866}
diff --git a/drivers/platform/x86/intel_scu_ipc.c b/drivers/platform/x86/intel_scu_ipc.c
index 40658e3385b4..bb2f1fba637b 100644
--- a/drivers/platform/x86/intel_scu_ipc.c
+++ b/drivers/platform/x86/intel_scu_ipc.c
@@ -489,7 +489,7 @@ int intel_scu_ipc_simple_command(int cmd, int sub)
489 mutex_unlock(&ipclock); 489 mutex_unlock(&ipclock);
490 return -ENODEV; 490 return -ENODEV;
491 } 491 }
492 ipc_command(cmd << 12 | sub); 492 ipc_command(sub << 12 | cmd);
493 err = busy_loop(); 493 err = busy_loop();
494 mutex_unlock(&ipclock); 494 mutex_unlock(&ipclock);
495 return err; 495 return err;
@@ -501,9 +501,9 @@ EXPORT_SYMBOL(intel_scu_ipc_simple_command);
501 * @cmd: command 501 * @cmd: command
502 * @sub: sub type 502 * @sub: sub type
503 * @in: input data 503 * @in: input data
504 * @inlen: input length 504 * @inlen: input length in dwords
505 * @out: output data 505 * @out: output data
506 * @outlein: output length 506 * @outlein: output length in dwords
507 * 507 *
508 * Issue a command to the SCU which involves data transfers. Do the 508 * Issue a command to the SCU which involves data transfers. Do the
509 * data copies under the lock but leave it for the caller to interpret 509 * data copies under the lock but leave it for the caller to interpret
@@ -524,7 +524,7 @@ int intel_scu_ipc_command(int cmd, int sub, u32 *in, int inlen,
524 for (i = 0; i < inlen; i++) 524 for (i = 0; i < inlen; i++)
525 ipc_data_writel(*in++, 4 * i); 525 ipc_data_writel(*in++, 4 * i);
526 526
527 ipc_command((cmd << 12) | sub | (inlen << 18)); 527 ipc_command((sub << 12) | cmd | (inlen << 18));
528 err = busy_loop(); 528 err = busy_loop();
529 529
530 for (i = 0; i < outlen; i++) 530 for (i = 0; i < outlen; i++)
@@ -556,6 +556,10 @@ int intel_scu_ipc_i2c_cntrl(u32 addr, u32 *data)
556 u32 cmd = 0; 556 u32 cmd = 0;
557 557
558 mutex_lock(&ipclock); 558 mutex_lock(&ipclock);
559 if (ipcdev.pdev == NULL) {
560 mutex_unlock(&ipclock);
561 return -ENODEV;
562 }
559 cmd = (addr >> 24) & 0xFF; 563 cmd = (addr >> 24) & 0xFF;
560 if (cmd == IPC_I2C_READ) { 564 if (cmd == IPC_I2C_READ) {
561 writel(addr, ipcdev.i2c_base + IPC_I2C_CNTRL_ADDR); 565 writel(addr, ipcdev.i2c_base + IPC_I2C_CNTRL_ADDR);
diff --git a/drivers/power/ds2782_battery.c b/drivers/power/ds2782_battery.c
index d762a0cbc6af..2afbeec8b791 100644
--- a/drivers/power/ds2782_battery.c
+++ b/drivers/power/ds2782_battery.c
@@ -163,7 +163,7 @@ static int ds2782_get_capacity(struct ds278x_info *info, int *capacity)
163 if (err) 163 if (err)
164 return err; 164 return err;
165 *capacity = raw; 165 *capacity = raw;
166 return raw; 166 return 0;
167} 167}
168 168
169static int ds2786_get_current(struct ds278x_info *info, int *current_uA) 169static int ds2786_get_current(struct ds278x_info *info, int *current_uA)
diff --git a/drivers/s390/block/dasd_devmap.c b/drivers/s390/block/dasd_devmap.c
index 34d51dd4c539..bed7b4634ccd 100644
--- a/drivers/s390/block/dasd_devmap.c
+++ b/drivers/s390/block/dasd_devmap.c
@@ -948,8 +948,10 @@ static ssize_t dasd_alias_show(struct device *dev,
948 if (device->discipline && device->discipline->get_uid && 948 if (device->discipline && device->discipline->get_uid &&
949 !device->discipline->get_uid(device, &uid)) { 949 !device->discipline->get_uid(device, &uid)) {
950 if (uid.type == UA_BASE_PAV_ALIAS || 950 if (uid.type == UA_BASE_PAV_ALIAS ||
951 uid.type == UA_HYPER_PAV_ALIAS) 951 uid.type == UA_HYPER_PAV_ALIAS) {
952 dasd_put_device(device);
952 return sprintf(buf, "1\n"); 953 return sprintf(buf, "1\n");
954 }
953 } 955 }
954 dasd_put_device(device); 956 dasd_put_device(device);
955 957
diff --git a/drivers/s390/cio/chsc.c b/drivers/s390/cio/chsc.c
index ce7cb87479fe..407d0e9adfaf 100644
--- a/drivers/s390/cio/chsc.c
+++ b/drivers/s390/cio/chsc.c
@@ -713,7 +713,7 @@ int chsc_determine_base_channel_path_desc(struct chp_id chpid,
713 ret = chsc_determine_channel_path_desc(chpid, 0, 0, 0, 0, chsc_resp); 713 ret = chsc_determine_channel_path_desc(chpid, 0, 0, 0, 0, chsc_resp);
714 if (ret) 714 if (ret)
715 goto out_free; 715 goto out_free;
716 memcpy(desc, &chsc_resp->data, chsc_resp->length); 716 memcpy(desc, &chsc_resp->data, sizeof(*desc));
717out_free: 717out_free:
718 kfree(chsc_resp); 718 kfree(chsc_resp);
719 return ret; 719 return ret;
diff --git a/drivers/sbus/char/openprom.c b/drivers/sbus/char/openprom.c
index d53e62ab09da..aacbe14e2e7a 100644
--- a/drivers/sbus/char/openprom.c
+++ b/drivers/sbus/char/openprom.c
@@ -554,7 +554,7 @@ static int opiocgetnext(unsigned int cmd, void __user *argp)
554static int openprom_bsd_ioctl(struct file * file, 554static int openprom_bsd_ioctl(struct file * file,
555 unsigned int cmd, unsigned long arg) 555 unsigned int cmd, unsigned long arg)
556{ 556{
557 DATA *data = (DATA *) file->private_data; 557 DATA *data = file->private_data;
558 void __user *argp = (void __user *)arg; 558 void __user *argp = (void __user *)arg;
559 int err; 559 int err;
560 560
@@ -601,7 +601,7 @@ static int openprom_bsd_ioctl(struct file * file,
601static long openprom_ioctl(struct file * file, 601static long openprom_ioctl(struct file * file,
602 unsigned int cmd, unsigned long arg) 602 unsigned int cmd, unsigned long arg)
603{ 603{
604 DATA *data = (DATA *) file->private_data; 604 DATA *data = file->private_data;
605 605
606 switch (cmd) { 606 switch (cmd) {
607 case OPROMGETOPT: 607 case OPROMGETOPT:
diff --git a/drivers/serial/suncore.c b/drivers/serial/suncore.c
index ed7d958b0a01..544f2e25d0e5 100644
--- a/drivers/serial/suncore.c
+++ b/drivers/serial/suncore.c
@@ -71,7 +71,9 @@ int sunserial_console_match(struct console *con, struct device_node *dp,
71 71
72 con->index = line; 72 con->index = line;
73 drv->cons = con; 73 drv->cons = con;
74 add_preferred_console(con->name, line, NULL); 74
75 if (!console_set_on_cmdline)
76 add_preferred_console(con->name, line, NULL);
75 77
76 return 1; 78 return 1;
77} 79}
diff --git a/drivers/serial/sunsu.c b/drivers/serial/sunsu.c
index 234459c2f012..ffbf4553f665 100644
--- a/drivers/serial/sunsu.c
+++ b/drivers/serial/sunsu.c
@@ -1500,20 +1500,25 @@ out_unmap:
1500static int __devexit su_remove(struct of_device *op) 1500static int __devexit su_remove(struct of_device *op)
1501{ 1501{
1502 struct uart_sunsu_port *up = dev_get_drvdata(&op->dev); 1502 struct uart_sunsu_port *up = dev_get_drvdata(&op->dev);
1503 bool kbdms = false;
1503 1504
1504 if (up->su_type == SU_PORT_MS || 1505 if (up->su_type == SU_PORT_MS ||
1505 up->su_type == SU_PORT_KBD) { 1506 up->su_type == SU_PORT_KBD)
1507 kbdms = true;
1508
1509 if (kbdms) {
1506#ifdef CONFIG_SERIO 1510#ifdef CONFIG_SERIO
1507 serio_unregister_port(&up->serio); 1511 serio_unregister_port(&up->serio);
1508#endif 1512#endif
1509 kfree(up); 1513 } else if (up->port.type != PORT_UNKNOWN)
1510 } else if (up->port.type != PORT_UNKNOWN) {
1511 uart_remove_one_port(&sunsu_reg, &up->port); 1514 uart_remove_one_port(&sunsu_reg, &up->port);
1512 }
1513 1515
1514 if (up->port.membase) 1516 if (up->port.membase)
1515 of_iounmap(&op->resource[0], up->port.membase, up->reg_size); 1517 of_iounmap(&op->resource[0], up->port.membase, up->reg_size);
1516 1518
1519 if (kbdms)
1520 kfree(up);
1521
1517 dev_set_drvdata(&op->dev, NULL); 1522 dev_set_drvdata(&op->dev, NULL);
1518 1523
1519 return 0; 1524 return 0;
diff --git a/drivers/spi/spi_mpc8xxx.c b/drivers/spi/spi_mpc8xxx.c
index ffa111a7e9d4..97ab0a81338a 100644
--- a/drivers/spi/spi_mpc8xxx.c
+++ b/drivers/spi/spi_mpc8xxx.c
@@ -66,28 +66,6 @@ struct mpc8xxx_spi_reg {
66 __be32 receive; 66 __be32 receive;
67}; 67};
68 68
69/* SPI Parameter RAM */
70struct spi_pram {
71 __be16 rbase; /* Rx Buffer descriptor base address */
72 __be16 tbase; /* Tx Buffer descriptor base address */
73 u8 rfcr; /* Rx function code */
74 u8 tfcr; /* Tx function code */
75 __be16 mrblr; /* Max receive buffer length */
76 __be32 rstate; /* Internal */
77 __be32 rdp; /* Internal */
78 __be16 rbptr; /* Internal */
79 __be16 rbc; /* Internal */
80 __be32 rxtmp; /* Internal */
81 __be32 tstate; /* Internal */
82 __be32 tdp; /* Internal */
83 __be16 tbptr; /* Internal */
84 __be16 tbc; /* Internal */
85 __be32 txtmp; /* Internal */
86 __be32 res; /* Tx temp. */
87 __be16 rpbase; /* Relocation pointer (CPM1 only) */
88 __be16 res1; /* Reserved */
89};
90
91/* SPI Controller mode register definitions */ 69/* SPI Controller mode register definitions */
92#define SPMODE_LOOP (1 << 30) 70#define SPMODE_LOOP (1 << 30)
93#define SPMODE_CI_INACTIVEHIGH (1 << 29) 71#define SPMODE_CI_INACTIVEHIGH (1 << 29)
diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c
index d69eccf5f197..2aaa0f75c6cf 100644
--- a/drivers/usb/gadget/f_fs.c
+++ b/drivers/usb/gadget/f_fs.c
@@ -136,7 +136,7 @@ struct ffs_data {
136 * handling setup requests immidiatelly user space may be so 136 * handling setup requests immidiatelly user space may be so
137 * slow that another setup will be sent to the gadget but this 137 * slow that another setup will be sent to the gadget but this
138 * time not to us but another function and then there could be 138 * time not to us but another function and then there could be
139 * a race. Is taht the case? Or maybe we can use cdev->req 139 * a race. Is that the case? Or maybe we can use cdev->req
140 * after all, maybe we just need some spinlock for that? */ 140 * after all, maybe we just need some spinlock for that? */
141 struct usb_request *ep0req; /* P: mutex */ 141 struct usb_request *ep0req; /* P: mutex */
142 struct completion ep0req_completion; /* P: mutex */ 142 struct completion ep0req_completion; /* P: mutex */
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index 57a593c58cf4..d219070fed3d 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -177,8 +177,8 @@ static void handle_tx(struct vhost_net *net)
177 break; 177 break;
178 } 178 }
179 if (err != len) 179 if (err != len)
180 pr_err("Truncated TX packet: " 180 pr_debug("Truncated TX packet: "
181 " len %d != %zd\n", err, len); 181 " len %d != %zd\n", err, len);
182 vhost_add_used_and_signal(&net->dev, vq, head, 0); 182 vhost_add_used_and_signal(&net->dev, vq, head, 0);
183 total_len += len; 183 total_len += len;
184 if (unlikely(total_len >= VHOST_NET_WEIGHT)) { 184 if (unlikely(total_len >= VHOST_NET_WEIGHT)) {
@@ -275,8 +275,8 @@ static void handle_rx(struct vhost_net *net)
275 } 275 }
276 /* TODO: Should check and handle checksum. */ 276 /* TODO: Should check and handle checksum. */
277 if (err > len) { 277 if (err > len) {
278 pr_err("Discarded truncated rx packet: " 278 pr_debug("Discarded truncated rx packet: "
279 " len %d > %zd\n", err, len); 279 " len %d > %zd\n", err, len);
280 vhost_discard_vq_desc(vq); 280 vhost_discard_vq_desc(vq);
281 continue; 281 continue;
282 } 282 }
@@ -534,11 +534,16 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd)
534 rcu_assign_pointer(vq->private_data, sock); 534 rcu_assign_pointer(vq->private_data, sock);
535 vhost_net_enable_vq(n, vq); 535 vhost_net_enable_vq(n, vq);
536done: 536done:
537 mutex_unlock(&vq->mutex);
538
537 if (oldsock) { 539 if (oldsock) {
538 vhost_net_flush_vq(n, index); 540 vhost_net_flush_vq(n, index);
539 fput(oldsock->file); 541 fput(oldsock->file);
540 } 542 }
541 543
544 mutex_unlock(&n->dev.mutex);
545 return 0;
546
542err_vq: 547err_vq:
543 mutex_unlock(&vq->mutex); 548 mutex_unlock(&vq->mutex);
544err: 549err:
diff --git a/drivers/video/aty/radeon_pm.c b/drivers/video/aty/radeon_pm.c
index 515cf1978d19..c4e17642d9c5 100644
--- a/drivers/video/aty/radeon_pm.c
+++ b/drivers/video/aty/radeon_pm.c
@@ -2872,7 +2872,7 @@ void radeonfb_pm_init(struct radeonfb_info *rinfo, int dynclk, int ignore_devlis
2872 } 2872 }
2873 2873
2874#if 0 2874#if 0
2875 /* Power down TV DAC, taht saves a significant amount of power, 2875 /* Power down TV DAC, that saves a significant amount of power,
2876 * we'll have something better once we actually have some TVOut 2876 * we'll have something better once we actually have some TVOut
2877 * support 2877 * support
2878 */ 2878 */
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 0d1d966b0fe4..c3df14ce2cc2 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -2304,12 +2304,17 @@ noinline int btrfs_leaf_free_space(struct btrfs_root *root,
2304 return ret; 2304 return ret;
2305} 2305}
2306 2306
2307/*
2308 * min slot controls the lowest index we're willing to push to the
2309 * right. We'll push up to and including min_slot, but no lower
2310 */
2307static noinline int __push_leaf_right(struct btrfs_trans_handle *trans, 2311static noinline int __push_leaf_right(struct btrfs_trans_handle *trans,
2308 struct btrfs_root *root, 2312 struct btrfs_root *root,
2309 struct btrfs_path *path, 2313 struct btrfs_path *path,
2310 int data_size, int empty, 2314 int data_size, int empty,
2311 struct extent_buffer *right, 2315 struct extent_buffer *right,
2312 int free_space, u32 left_nritems) 2316 int free_space, u32 left_nritems,
2317 u32 min_slot)
2313{ 2318{
2314 struct extent_buffer *left = path->nodes[0]; 2319 struct extent_buffer *left = path->nodes[0];
2315 struct extent_buffer *upper = path->nodes[1]; 2320 struct extent_buffer *upper = path->nodes[1];
@@ -2327,7 +2332,7 @@ static noinline int __push_leaf_right(struct btrfs_trans_handle *trans,
2327 if (empty) 2332 if (empty)
2328 nr = 0; 2333 nr = 0;
2329 else 2334 else
2330 nr = 1; 2335 nr = max_t(u32, 1, min_slot);
2331 2336
2332 if (path->slots[0] >= left_nritems) 2337 if (path->slots[0] >= left_nritems)
2333 push_space += data_size; 2338 push_space += data_size;
@@ -2469,10 +2474,14 @@ out_unlock:
2469 * 2474 *
2470 * returns 1 if the push failed because the other node didn't have enough 2475 * returns 1 if the push failed because the other node didn't have enough
2471 * room, 0 if everything worked out and < 0 if there were major errors. 2476 * room, 0 if everything worked out and < 0 if there were major errors.
2477 *
2478 * this will push starting from min_slot to the end of the leaf. It won't
2479 * push any slot lower than min_slot
2472 */ 2480 */
2473static int push_leaf_right(struct btrfs_trans_handle *trans, struct btrfs_root 2481static int push_leaf_right(struct btrfs_trans_handle *trans, struct btrfs_root
2474 *root, struct btrfs_path *path, int data_size, 2482 *root, struct btrfs_path *path,
2475 int empty) 2483 int min_data_size, int data_size,
2484 int empty, u32 min_slot)
2476{ 2485{
2477 struct extent_buffer *left = path->nodes[0]; 2486 struct extent_buffer *left = path->nodes[0];
2478 struct extent_buffer *right; 2487 struct extent_buffer *right;
@@ -2514,8 +2523,8 @@ static int push_leaf_right(struct btrfs_trans_handle *trans, struct btrfs_root
2514 if (left_nritems == 0) 2523 if (left_nritems == 0)
2515 goto out_unlock; 2524 goto out_unlock;
2516 2525
2517 return __push_leaf_right(trans, root, path, data_size, empty, 2526 return __push_leaf_right(trans, root, path, min_data_size, empty,
2518 right, free_space, left_nritems); 2527 right, free_space, left_nritems, min_slot);
2519out_unlock: 2528out_unlock:
2520 btrfs_tree_unlock(right); 2529 btrfs_tree_unlock(right);
2521 free_extent_buffer(right); 2530 free_extent_buffer(right);
@@ -2525,12 +2534,17 @@ out_unlock:
2525/* 2534/*
2526 * push some data in the path leaf to the left, trying to free up at 2535 * push some data in the path leaf to the left, trying to free up at
2527 * least data_size bytes. returns zero if the push worked, nonzero otherwise 2536 * least data_size bytes. returns zero if the push worked, nonzero otherwise
2537 *
2538 * max_slot can put a limit on how far into the leaf we'll push items. The
2539 * item at 'max_slot' won't be touched. Use (u32)-1 to make us do all the
2540 * items
2528 */ 2541 */
2529static noinline int __push_leaf_left(struct btrfs_trans_handle *trans, 2542static noinline int __push_leaf_left(struct btrfs_trans_handle *trans,
2530 struct btrfs_root *root, 2543 struct btrfs_root *root,
2531 struct btrfs_path *path, int data_size, 2544 struct btrfs_path *path, int data_size,
2532 int empty, struct extent_buffer *left, 2545 int empty, struct extent_buffer *left,
2533 int free_space, int right_nritems) 2546 int free_space, u32 right_nritems,
2547 u32 max_slot)
2534{ 2548{
2535 struct btrfs_disk_key disk_key; 2549 struct btrfs_disk_key disk_key;
2536 struct extent_buffer *right = path->nodes[0]; 2550 struct extent_buffer *right = path->nodes[0];
@@ -2549,9 +2563,9 @@ static noinline int __push_leaf_left(struct btrfs_trans_handle *trans,
2549 slot = path->slots[1]; 2563 slot = path->slots[1];
2550 2564
2551 if (empty) 2565 if (empty)
2552 nr = right_nritems; 2566 nr = min(right_nritems, max_slot);
2553 else 2567 else
2554 nr = right_nritems - 1; 2568 nr = min(right_nritems - 1, max_slot);
2555 2569
2556 for (i = 0; i < nr; i++) { 2570 for (i = 0; i < nr; i++) {
2557 item = btrfs_item_nr(right, i); 2571 item = btrfs_item_nr(right, i);
@@ -2712,10 +2726,14 @@ out:
2712/* 2726/*
2713 * push some data in the path leaf to the left, trying to free up at 2727 * push some data in the path leaf to the left, trying to free up at
2714 * least data_size bytes. returns zero if the push worked, nonzero otherwise 2728 * least data_size bytes. returns zero if the push worked, nonzero otherwise
2729 *
2730 * max_slot can put a limit on how far into the leaf we'll push items. The
2731 * item at 'max_slot' won't be touched. Use (u32)-1 to make us push all the
2732 * items
2715 */ 2733 */
2716static int push_leaf_left(struct btrfs_trans_handle *trans, struct btrfs_root 2734static int push_leaf_left(struct btrfs_trans_handle *trans, struct btrfs_root
2717 *root, struct btrfs_path *path, int data_size, 2735 *root, struct btrfs_path *path, int min_data_size,
2718 int empty) 2736 int data_size, int empty, u32 max_slot)
2719{ 2737{
2720 struct extent_buffer *right = path->nodes[0]; 2738 struct extent_buffer *right = path->nodes[0];
2721 struct extent_buffer *left; 2739 struct extent_buffer *left;
@@ -2761,8 +2779,9 @@ static int push_leaf_left(struct btrfs_trans_handle *trans, struct btrfs_root
2761 goto out; 2779 goto out;
2762 } 2780 }
2763 2781
2764 return __push_leaf_left(trans, root, path, data_size, 2782 return __push_leaf_left(trans, root, path, min_data_size,
2765 empty, left, free_space, right_nritems); 2783 empty, left, free_space, right_nritems,
2784 max_slot);
2766out: 2785out:
2767 btrfs_tree_unlock(left); 2786 btrfs_tree_unlock(left);
2768 free_extent_buffer(left); 2787 free_extent_buffer(left);
@@ -2855,6 +2874,64 @@ static noinline int copy_for_split(struct btrfs_trans_handle *trans,
2855} 2874}
2856 2875
2857/* 2876/*
2877 * double splits happen when we need to insert a big item in the middle
2878 * of a leaf. A double split can leave us with 3 mostly empty leaves:
2879 * leaf: [ slots 0 - N] [ our target ] [ N + 1 - total in leaf ]
2880 * A B C
2881 *
2882 * We avoid this by trying to push the items on either side of our target
2883 * into the adjacent leaves. If all goes well we can avoid the double split
2884 * completely.
2885 */
2886static noinline int push_for_double_split(struct btrfs_trans_handle *trans,
2887 struct btrfs_root *root,
2888 struct btrfs_path *path,
2889 int data_size)
2890{
2891 int ret;
2892 int progress = 0;
2893 int slot;
2894 u32 nritems;
2895
2896 slot = path->slots[0];
2897
2898 /*
2899 * try to push all the items after our slot into the
2900 * right leaf
2901 */
2902 ret = push_leaf_right(trans, root, path, 1, data_size, 0, slot);
2903 if (ret < 0)
2904 return ret;
2905
2906 if (ret == 0)
2907 progress++;
2908
2909 nritems = btrfs_header_nritems(path->nodes[0]);
2910 /*
2911 * our goal is to get our slot at the start or end of a leaf. If
2912 * we've done so we're done
2913 */
2914 if (path->slots[0] == 0 || path->slots[0] == nritems)
2915 return 0;
2916
2917 if (btrfs_leaf_free_space(root, path->nodes[0]) >= data_size)
2918 return 0;
2919
2920 /* try to push all the items before our slot into the next leaf */
2921 slot = path->slots[0];
2922 ret = push_leaf_left(trans, root, path, 1, data_size, 0, slot);
2923 if (ret < 0)
2924 return ret;
2925
2926 if (ret == 0)
2927 progress++;
2928
2929 if (progress)
2930 return 0;
2931 return 1;
2932}
2933
2934/*
2858 * split the path's leaf in two, making sure there is at least data_size 2935 * split the path's leaf in two, making sure there is at least data_size
2859 * available for the resulting leaf level of the path. 2936 * available for the resulting leaf level of the path.
2860 * 2937 *
@@ -2876,6 +2953,7 @@ static noinline int split_leaf(struct btrfs_trans_handle *trans,
2876 int wret; 2953 int wret;
2877 int split; 2954 int split;
2878 int num_doubles = 0; 2955 int num_doubles = 0;
2956 int tried_avoid_double = 0;
2879 2957
2880 l = path->nodes[0]; 2958 l = path->nodes[0];
2881 slot = path->slots[0]; 2959 slot = path->slots[0];
@@ -2884,12 +2962,14 @@ static noinline int split_leaf(struct btrfs_trans_handle *trans,
2884 return -EOVERFLOW; 2962 return -EOVERFLOW;
2885 2963
2886 /* first try to make some room by pushing left and right */ 2964 /* first try to make some room by pushing left and right */
2887 if (data_size && ins_key->type != BTRFS_DIR_ITEM_KEY) { 2965 if (data_size) {
2888 wret = push_leaf_right(trans, root, path, data_size, 0); 2966 wret = push_leaf_right(trans, root, path, data_size,
2967 data_size, 0, 0);
2889 if (wret < 0) 2968 if (wret < 0)
2890 return wret; 2969 return wret;
2891 if (wret) { 2970 if (wret) {
2892 wret = push_leaf_left(trans, root, path, data_size, 0); 2971 wret = push_leaf_left(trans, root, path, data_size,
2972 data_size, 0, (u32)-1);
2893 if (wret < 0) 2973 if (wret < 0)
2894 return wret; 2974 return wret;
2895 } 2975 }
@@ -2923,6 +3003,8 @@ again:
2923 if (mid != nritems && 3003 if (mid != nritems &&
2924 leaf_space_used(l, mid, nritems - mid) + 3004 leaf_space_used(l, mid, nritems - mid) +
2925 data_size > BTRFS_LEAF_DATA_SIZE(root)) { 3005 data_size > BTRFS_LEAF_DATA_SIZE(root)) {
3006 if (data_size && !tried_avoid_double)
3007 goto push_for_double;
2926 split = 2; 3008 split = 2;
2927 } 3009 }
2928 } 3010 }
@@ -2939,6 +3021,8 @@ again:
2939 if (mid != nritems && 3021 if (mid != nritems &&
2940 leaf_space_used(l, mid, nritems - mid) + 3022 leaf_space_used(l, mid, nritems - mid) +
2941 data_size > BTRFS_LEAF_DATA_SIZE(root)) { 3023 data_size > BTRFS_LEAF_DATA_SIZE(root)) {
3024 if (data_size && !tried_avoid_double)
3025 goto push_for_double;
2942 split = 2 ; 3026 split = 2 ;
2943 } 3027 }
2944 } 3028 }
@@ -3019,6 +3103,13 @@ again:
3019 } 3103 }
3020 3104
3021 return ret; 3105 return ret;
3106
3107push_for_double:
3108 push_for_double_split(trans, root, path, data_size);
3109 tried_avoid_double = 1;
3110 if (btrfs_leaf_free_space(root, path->nodes[0]) >= data_size)
3111 return 0;
3112 goto again;
3022} 3113}
3023 3114
3024static noinline int setup_leaf_for_split(struct btrfs_trans_handle *trans, 3115static noinline int setup_leaf_for_split(struct btrfs_trans_handle *trans,
@@ -3915,13 +4006,15 @@ int btrfs_del_items(struct btrfs_trans_handle *trans, struct btrfs_root *root,
3915 extent_buffer_get(leaf); 4006 extent_buffer_get(leaf);
3916 4007
3917 btrfs_set_path_blocking(path); 4008 btrfs_set_path_blocking(path);
3918 wret = push_leaf_left(trans, root, path, 1, 1); 4009 wret = push_leaf_left(trans, root, path, 1, 1,
4010 1, (u32)-1);
3919 if (wret < 0 && wret != -ENOSPC) 4011 if (wret < 0 && wret != -ENOSPC)
3920 ret = wret; 4012 ret = wret;
3921 4013
3922 if (path->nodes[0] == leaf && 4014 if (path->nodes[0] == leaf &&
3923 btrfs_header_nritems(leaf)) { 4015 btrfs_header_nritems(leaf)) {
3924 wret = push_leaf_right(trans, root, path, 1, 1); 4016 wret = push_leaf_right(trans, root, path, 1,
4017 1, 1, 0);
3925 if (wret < 0 && wret != -ENOSPC) 4018 if (wret < 0 && wret != -ENOSPC)
3926 ret = wret; 4019 ret = wret;
3927 } 4020 }
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 4dbaf89b1337..9254b3d58dbe 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -1458,7 +1458,7 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,
1458 */ 1458 */
1459 1459
1460 /* the destination must be opened for writing */ 1460 /* the destination must be opened for writing */
1461 if (!(file->f_mode & FMODE_WRITE)) 1461 if (!(file->f_mode & FMODE_WRITE) || (file->f_flags & O_APPEND))
1462 return -EINVAL; 1462 return -EINVAL;
1463 1463
1464 ret = mnt_want_write(file->f_path.mnt); 1464 ret = mnt_want_write(file->f_path.mnt);
@@ -1511,7 +1511,7 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,
1511 1511
1512 /* determine range to clone */ 1512 /* determine range to clone */
1513 ret = -EINVAL; 1513 ret = -EINVAL;
1514 if (off >= src->i_size || off + len > src->i_size) 1514 if (off + len > src->i_size || off + len < off)
1515 goto out_unlock; 1515 goto out_unlock;
1516 if (len == 0) 1516 if (len == 0)
1517 olen = len = src->i_size - off; 1517 olen = len = src->i_size - off;
@@ -1578,6 +1578,7 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,
1578 u64 disko = 0, diskl = 0; 1578 u64 disko = 0, diskl = 0;
1579 u64 datao = 0, datal = 0; 1579 u64 datao = 0, datal = 0;
1580 u8 comp; 1580 u8 comp;
1581 u64 endoff;
1581 1582
1582 size = btrfs_item_size_nr(leaf, slot); 1583 size = btrfs_item_size_nr(leaf, slot);
1583 read_extent_buffer(leaf, buf, 1584 read_extent_buffer(leaf, buf,
@@ -1712,9 +1713,18 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd,
1712 btrfs_release_path(root, path); 1713 btrfs_release_path(root, path);
1713 1714
1714 inode->i_mtime = inode->i_ctime = CURRENT_TIME; 1715 inode->i_mtime = inode->i_ctime = CURRENT_TIME;
1715 if (new_key.offset + datal > inode->i_size) 1716
1716 btrfs_i_size_write(inode, 1717 /*
1717 new_key.offset + datal); 1718 * we round up to the block size at eof when
1719 * determining which extents to clone above,
1720 * but shouldn't round up the file size
1721 */
1722 endoff = new_key.offset + datal;
1723 if (endoff > off+olen)
1724 endoff = off+olen;
1725 if (endoff > inode->i_size)
1726 btrfs_i_size_write(inode, endoff);
1727
1718 BTRFS_I(inode)->flags = BTRFS_I(src)->flags; 1728 BTRFS_I(inode)->flags = BTRFS_I(src)->flags;
1719 ret = btrfs_update_inode(trans, root, inode); 1729 ret = btrfs_update_inode(trans, root, inode);
1720 BUG_ON(ret); 1730 BUG_ON(ret);
diff --git a/fs/ceph/auth_x.c b/fs/ceph/auth_x.c
index 3fe49042d8ad..6d44053ecff1 100644
--- a/fs/ceph/auth_x.c
+++ b/fs/ceph/auth_x.c
@@ -613,6 +613,9 @@ static void ceph_x_destroy(struct ceph_auth_client *ac)
613 remove_ticket_handler(ac, th); 613 remove_ticket_handler(ac, th);
614 } 614 }
615 615
616 if (xi->auth_authorizer.buf)
617 ceph_buffer_put(xi->auth_authorizer.buf);
618
616 kfree(ac->private); 619 kfree(ac->private);
617 ac->private = NULL; 620 ac->private = NULL;
618} 621}
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
index 3ab79f6c4ce8..416c08d315db 100644
--- a/fs/ceph/mds_client.c
+++ b/fs/ceph/mds_client.c
@@ -1514,6 +1514,9 @@ static struct ceph_msg *create_request_message(struct ceph_mds_client *mdsc,
1514 ceph_encode_filepath(&p, end, ino1, path1); 1514 ceph_encode_filepath(&p, end, ino1, path1);
1515 ceph_encode_filepath(&p, end, ino2, path2); 1515 ceph_encode_filepath(&p, end, ino2, path2);
1516 1516
1517 /* make note of release offset, in case we need to replay */
1518 req->r_request_release_offset = p - msg->front.iov_base;
1519
1517 /* cap releases */ 1520 /* cap releases */
1518 releases = 0; 1521 releases = 0;
1519 if (req->r_inode_drop) 1522 if (req->r_inode_drop)
@@ -1580,6 +1583,32 @@ static int __prepare_send_request(struct ceph_mds_client *mdsc,
1580 dout("prepare_send_request %p tid %lld %s (attempt %d)\n", req, 1583 dout("prepare_send_request %p tid %lld %s (attempt %d)\n", req,
1581 req->r_tid, ceph_mds_op_name(req->r_op), req->r_attempts); 1584 req->r_tid, ceph_mds_op_name(req->r_op), req->r_attempts);
1582 1585
1586 if (req->r_got_unsafe) {
1587 /*
1588 * Replay. Do not regenerate message (and rebuild
1589 * paths, etc.); just use the original message.
1590 * Rebuilding paths will break for renames because
1591 * d_move mangles the src name.
1592 */
1593 msg = req->r_request;
1594 rhead = msg->front.iov_base;
1595
1596 flags = le32_to_cpu(rhead->flags);
1597 flags |= CEPH_MDS_FLAG_REPLAY;
1598 rhead->flags = cpu_to_le32(flags);
1599
1600 if (req->r_target_inode)
1601 rhead->ino = cpu_to_le64(ceph_ino(req->r_target_inode));
1602
1603 rhead->num_retry = req->r_attempts - 1;
1604
1605 /* remove cap/dentry releases from message */
1606 rhead->num_releases = 0;
1607 msg->hdr.front_len = cpu_to_le32(req->r_request_release_offset);
1608 msg->front.iov_len = req->r_request_release_offset;
1609 return 0;
1610 }
1611
1583 if (req->r_request) { 1612 if (req->r_request) {
1584 ceph_msg_put(req->r_request); 1613 ceph_msg_put(req->r_request);
1585 req->r_request = NULL; 1614 req->r_request = NULL;
@@ -1601,13 +1630,9 @@ static int __prepare_send_request(struct ceph_mds_client *mdsc,
1601 rhead->flags = cpu_to_le32(flags); 1630 rhead->flags = cpu_to_le32(flags);
1602 rhead->num_fwd = req->r_num_fwd; 1631 rhead->num_fwd = req->r_num_fwd;
1603 rhead->num_retry = req->r_attempts - 1; 1632 rhead->num_retry = req->r_attempts - 1;
1633 rhead->ino = 0;
1604 1634
1605 dout(" r_locked_dir = %p\n", req->r_locked_dir); 1635 dout(" r_locked_dir = %p\n", req->r_locked_dir);
1606
1607 if (req->r_target_inode && req->r_got_unsafe)
1608 rhead->ino = cpu_to_le64(ceph_ino(req->r_target_inode));
1609 else
1610 rhead->ino = 0;
1611 return 0; 1636 return 0;
1612} 1637}
1613 1638
diff --git a/fs/ceph/mds_client.h b/fs/ceph/mds_client.h
index b292fa42a66d..952410c60d09 100644
--- a/fs/ceph/mds_client.h
+++ b/fs/ceph/mds_client.h
@@ -188,6 +188,7 @@ struct ceph_mds_request {
188 int r_old_inode_drop, r_old_inode_unless; 188 int r_old_inode_drop, r_old_inode_unless;
189 189
190 struct ceph_msg *r_request; /* original request */ 190 struct ceph_msg *r_request; /* original request */
191 int r_request_release_offset;
191 struct ceph_msg *r_reply; 192 struct ceph_msg *r_reply;
192 struct ceph_mds_reply_info_parsed r_reply_info; 193 struct ceph_mds_reply_info_parsed r_reply_info;
193 int r_err; 194 int r_err;
diff --git a/fs/ceph/messenger.c b/fs/ceph/messenger.c
index 9ad43a310a41..15167b2daa55 100644
--- a/fs/ceph/messenger.c
+++ b/fs/ceph/messenger.c
@@ -43,7 +43,8 @@ static void ceph_fault(struct ceph_connection *con);
43 * nicely render a sockaddr as a string. 43 * nicely render a sockaddr as a string.
44 */ 44 */
45#define MAX_ADDR_STR 20 45#define MAX_ADDR_STR 20
46static char addr_str[MAX_ADDR_STR][40]; 46#define MAX_ADDR_STR_LEN 60
47static char addr_str[MAX_ADDR_STR][MAX_ADDR_STR_LEN];
47static DEFINE_SPINLOCK(addr_str_lock); 48static DEFINE_SPINLOCK(addr_str_lock);
48static int last_addr_str; 49static int last_addr_str;
49 50
@@ -52,7 +53,6 @@ const char *pr_addr(const struct sockaddr_storage *ss)
52 int i; 53 int i;
53 char *s; 54 char *s;
54 struct sockaddr_in *in4 = (void *)ss; 55 struct sockaddr_in *in4 = (void *)ss;
55 unsigned char *quad = (void *)&in4->sin_addr.s_addr;
56 struct sockaddr_in6 *in6 = (void *)ss; 56 struct sockaddr_in6 *in6 = (void *)ss;
57 57
58 spin_lock(&addr_str_lock); 58 spin_lock(&addr_str_lock);
@@ -64,25 +64,13 @@ const char *pr_addr(const struct sockaddr_storage *ss)
64 64
65 switch (ss->ss_family) { 65 switch (ss->ss_family) {
66 case AF_INET: 66 case AF_INET:
67 sprintf(s, "%u.%u.%u.%u:%u", 67 snprintf(s, MAX_ADDR_STR_LEN, "%pI4:%u", &in4->sin_addr,
68 (unsigned int)quad[0], 68 (unsigned int)ntohs(in4->sin_port));
69 (unsigned int)quad[1],
70 (unsigned int)quad[2],
71 (unsigned int)quad[3],
72 (unsigned int)ntohs(in4->sin_port));
73 break; 69 break;
74 70
75 case AF_INET6: 71 case AF_INET6:
76 sprintf(s, "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x:%u", 72 snprintf(s, MAX_ADDR_STR_LEN, "[%pI6c]:%u", &in6->sin6_addr,
77 in6->sin6_addr.s6_addr16[0], 73 (unsigned int)ntohs(in6->sin6_port));
78 in6->sin6_addr.s6_addr16[1],
79 in6->sin6_addr.s6_addr16[2],
80 in6->sin6_addr.s6_addr16[3],
81 in6->sin6_addr.s6_addr16[4],
82 in6->sin6_addr.s6_addr16[5],
83 in6->sin6_addr.s6_addr16[6],
84 in6->sin6_addr.s6_addr16[7],
85 (unsigned int)ntohs(in6->sin6_port));
86 break; 74 break;
87 75
88 default: 76 default:
@@ -215,12 +203,13 @@ static void set_sock_callbacks(struct socket *sock,
215 */ 203 */
216static struct socket *ceph_tcp_connect(struct ceph_connection *con) 204static struct socket *ceph_tcp_connect(struct ceph_connection *con)
217{ 205{
218 struct sockaddr *paddr = (struct sockaddr *)&con->peer_addr.in_addr; 206 struct sockaddr_storage *paddr = &con->peer_addr.in_addr;
219 struct socket *sock; 207 struct socket *sock;
220 int ret; 208 int ret;
221 209
222 BUG_ON(con->sock); 210 BUG_ON(con->sock);
223 ret = sock_create_kern(AF_INET, SOCK_STREAM, IPPROTO_TCP, &sock); 211 ret = sock_create_kern(con->peer_addr.in_addr.ss_family, SOCK_STREAM,
212 IPPROTO_TCP, &sock);
224 if (ret) 213 if (ret)
225 return ERR_PTR(ret); 214 return ERR_PTR(ret);
226 con->sock = sock; 215 con->sock = sock;
@@ -234,7 +223,8 @@ static struct socket *ceph_tcp_connect(struct ceph_connection *con)
234 223
235 dout("connect %s\n", pr_addr(&con->peer_addr.in_addr)); 224 dout("connect %s\n", pr_addr(&con->peer_addr.in_addr));
236 225
237 ret = sock->ops->connect(sock, paddr, sizeof(*paddr), O_NONBLOCK); 226 ret = sock->ops->connect(sock, (struct sockaddr *)paddr, sizeof(*paddr),
227 O_NONBLOCK);
238 if (ret == -EINPROGRESS) { 228 if (ret == -EINPROGRESS) {
239 dout("connect %s EINPROGRESS sk_state = %u\n", 229 dout("connect %s EINPROGRESS sk_state = %u\n",
240 pr_addr(&con->peer_addr.in_addr), 230 pr_addr(&con->peer_addr.in_addr),
@@ -1009,19 +999,32 @@ int ceph_parse_ips(const char *c, const char *end,
1009 struct sockaddr_in *in4 = (void *)ss; 999 struct sockaddr_in *in4 = (void *)ss;
1010 struct sockaddr_in6 *in6 = (void *)ss; 1000 struct sockaddr_in6 *in6 = (void *)ss;
1011 int port; 1001 int port;
1002 char delim = ',';
1003
1004 if (*p == '[') {
1005 delim = ']';
1006 p++;
1007 }
1012 1008
1013 memset(ss, 0, sizeof(*ss)); 1009 memset(ss, 0, sizeof(*ss));
1014 if (in4_pton(p, end - p, (u8 *)&in4->sin_addr.s_addr, 1010 if (in4_pton(p, end - p, (u8 *)&in4->sin_addr.s_addr,
1015 ',', &ipend)) { 1011 delim, &ipend))
1016 ss->ss_family = AF_INET; 1012 ss->ss_family = AF_INET;
1017 } else if (in6_pton(p, end - p, (u8 *)&in6->sin6_addr.s6_addr, 1013 else if (in6_pton(p, end - p, (u8 *)&in6->sin6_addr.s6_addr,
1018 ',', &ipend)) { 1014 delim, &ipend))
1019 ss->ss_family = AF_INET6; 1015 ss->ss_family = AF_INET6;
1020 } else { 1016 else
1021 goto bad; 1017 goto bad;
1022 }
1023 p = ipend; 1018 p = ipend;
1024 1019
1020 if (delim == ']') {
1021 if (*p != ']') {
1022 dout("missing matching ']'\n");
1023 goto bad;
1024 }
1025 p++;
1026 }
1027
1025 /* port? */ 1028 /* port? */
1026 if (p < end && *p == ':') { 1029 if (p < end && *p == ':') {
1027 port = 0; 1030 port = 0;
@@ -1055,7 +1058,7 @@ int ceph_parse_ips(const char *c, const char *end,
1055 return 0; 1058 return 0;
1056 1059
1057bad: 1060bad:
1058 pr_err("parse_ips bad ip '%s'\n", c); 1061 pr_err("parse_ips bad ip '%.*s'\n", (int)(end - c), c);
1059 return -EINVAL; 1062 return -EINVAL;
1060} 1063}
1061 1064
@@ -2015,20 +2018,20 @@ void ceph_con_revoke(struct ceph_connection *con, struct ceph_msg *msg)
2015{ 2018{
2016 mutex_lock(&con->mutex); 2019 mutex_lock(&con->mutex);
2017 if (!list_empty(&msg->list_head)) { 2020 if (!list_empty(&msg->list_head)) {
2018 dout("con_revoke %p msg %p\n", con, msg); 2021 dout("con_revoke %p msg %p - was on queue\n", con, msg);
2019 list_del_init(&msg->list_head); 2022 list_del_init(&msg->list_head);
2020 ceph_msg_put(msg); 2023 ceph_msg_put(msg);
2021 msg->hdr.seq = 0; 2024 msg->hdr.seq = 0;
2022 if (con->out_msg == msg) { 2025 }
2023 ceph_msg_put(con->out_msg); 2026 if (con->out_msg == msg) {
2024 con->out_msg = NULL; 2027 dout("con_revoke %p msg %p - was sending\n", con, msg);
2025 } 2028 con->out_msg = NULL;
2026 if (con->out_kvec_is_msg) { 2029 if (con->out_kvec_is_msg) {
2027 con->out_skip = con->out_kvec_bytes; 2030 con->out_skip = con->out_kvec_bytes;
2028 con->out_kvec_is_msg = false; 2031 con->out_kvec_is_msg = false;
2029 } 2032 }
2030 } else { 2033 ceph_msg_put(msg);
2031 dout("con_revoke %p msg %p - not queued (sent?)\n", con, msg); 2034 msg->hdr.seq = 0;
2032 } 2035 }
2033 mutex_unlock(&con->mutex); 2036 mutex_unlock(&con->mutex);
2034} 2037}
diff --git a/fs/ceph/osdmap.c b/fs/ceph/osdmap.c
index 50ce64ebd330..277f8b339577 100644
--- a/fs/ceph/osdmap.c
+++ b/fs/ceph/osdmap.c
@@ -568,6 +568,7 @@ struct ceph_osdmap *osdmap_decode(void **p, void *end)
568 if (ev > CEPH_PG_POOL_VERSION) { 568 if (ev > CEPH_PG_POOL_VERSION) {
569 pr_warning("got unknown v %d > %d of ceph_pg_pool\n", 569 pr_warning("got unknown v %d > %d of ceph_pg_pool\n",
570 ev, CEPH_PG_POOL_VERSION); 570 ev, CEPH_PG_POOL_VERSION);
571 kfree(pi);
571 goto bad; 572 goto bad;
572 } 573 }
573 __decode_pool(p, pi); 574 __decode_pool(p, pi);
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 484e52bb40bb..2cb1a70214d7 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -923,7 +923,7 @@ init_cifs(void)
923 goto out_unregister_filesystem; 923 goto out_unregister_filesystem;
924#endif 924#endif
925#ifdef CONFIG_CIFS_DFS_UPCALL 925#ifdef CONFIG_CIFS_DFS_UPCALL
926 rc = register_key_type(&key_type_dns_resolver); 926 rc = cifs_init_dns_resolver();
927 if (rc) 927 if (rc)
928 goto out_unregister_key_type; 928 goto out_unregister_key_type;
929#endif 929#endif
@@ -935,7 +935,7 @@ init_cifs(void)
935 935
936 out_unregister_resolver_key: 936 out_unregister_resolver_key:
937#ifdef CONFIG_CIFS_DFS_UPCALL 937#ifdef CONFIG_CIFS_DFS_UPCALL
938 unregister_key_type(&key_type_dns_resolver); 938 cifs_exit_dns_resolver();
939 out_unregister_key_type: 939 out_unregister_key_type:
940#endif 940#endif
941#ifdef CONFIG_CIFS_UPCALL 941#ifdef CONFIG_CIFS_UPCALL
@@ -961,7 +961,7 @@ exit_cifs(void)
961 cifs_proc_clean(); 961 cifs_proc_clean();
962#ifdef CONFIG_CIFS_DFS_UPCALL 962#ifdef CONFIG_CIFS_DFS_UPCALL
963 cifs_dfs_release_automount_timer(); 963 cifs_dfs_release_automount_timer();
964 unregister_key_type(&key_type_dns_resolver); 964 cifs_exit_dns_resolver();
965#endif 965#endif
966#ifdef CONFIG_CIFS_UPCALL 966#ifdef CONFIG_CIFS_UPCALL
967 unregister_key_type(&cifs_spnego_key_type); 967 unregister_key_type(&cifs_spnego_key_type);
diff --git a/fs/cifs/dns_resolve.c b/fs/cifs/dns_resolve.c
index 4db2c5e7283f..49315cbf742d 100644
--- a/fs/cifs/dns_resolve.c
+++ b/fs/cifs/dns_resolve.c
@@ -24,12 +24,16 @@
24 */ 24 */
25 25
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/keyctl.h>
28#include <linux/key-type.h>
27#include <keys/user-type.h> 29#include <keys/user-type.h>
28#include "dns_resolve.h" 30#include "dns_resolve.h"
29#include "cifsglob.h" 31#include "cifsglob.h"
30#include "cifsproto.h" 32#include "cifsproto.h"
31#include "cifs_debug.h" 33#include "cifs_debug.h"
32 34
35static const struct cred *dns_resolver_cache;
36
33/* Checks if supplied name is IP address 37/* Checks if supplied name is IP address
34 * returns: 38 * returns:
35 * 1 - name is IP 39 * 1 - name is IP
@@ -94,6 +98,7 @@ struct key_type key_type_dns_resolver = {
94int 98int
95dns_resolve_server_name_to_ip(const char *unc, char **ip_addr) 99dns_resolve_server_name_to_ip(const char *unc, char **ip_addr)
96{ 100{
101 const struct cred *saved_cred;
97 int rc = -EAGAIN; 102 int rc = -EAGAIN;
98 struct key *rkey = ERR_PTR(-EAGAIN); 103 struct key *rkey = ERR_PTR(-EAGAIN);
99 char *name; 104 char *name;
@@ -133,8 +138,15 @@ dns_resolve_server_name_to_ip(const char *unc, char **ip_addr)
133 goto skip_upcall; 138 goto skip_upcall;
134 } 139 }
135 140
141 saved_cred = override_creds(dns_resolver_cache);
136 rkey = request_key(&key_type_dns_resolver, name, ""); 142 rkey = request_key(&key_type_dns_resolver, name, "");
143 revert_creds(saved_cred);
137 if (!IS_ERR(rkey)) { 144 if (!IS_ERR(rkey)) {
145 if (!(rkey->perm & KEY_USR_VIEW)) {
146 down_read(&rkey->sem);
147 rkey->perm |= KEY_USR_VIEW;
148 up_read(&rkey->sem);
149 }
138 len = rkey->type_data.x[0]; 150 len = rkey->type_data.x[0];
139 data = rkey->payload.data; 151 data = rkey->payload.data;
140 } else { 152 } else {
@@ -165,4 +177,61 @@ out:
165 return rc; 177 return rc;
166} 178}
167 179
180int __init cifs_init_dns_resolver(void)
181{
182 struct cred *cred;
183 struct key *keyring;
184 int ret;
185
186 printk(KERN_NOTICE "Registering the %s key type\n",
187 key_type_dns_resolver.name);
188
189 /* create an override credential set with a special thread keyring in
190 * which DNS requests are cached
191 *
192 * this is used to prevent malicious redirections from being installed
193 * with add_key().
194 */
195 cred = prepare_kernel_cred(NULL);
196 if (!cred)
197 return -ENOMEM;
198
199 keyring = key_alloc(&key_type_keyring, ".dns_resolver", 0, 0, cred,
200 (KEY_POS_ALL & ~KEY_POS_SETATTR) |
201 KEY_USR_VIEW | KEY_USR_READ,
202 KEY_ALLOC_NOT_IN_QUOTA);
203 if (IS_ERR(keyring)) {
204 ret = PTR_ERR(keyring);
205 goto failed_put_cred;
206 }
207
208 ret = key_instantiate_and_link(keyring, NULL, 0, NULL, NULL);
209 if (ret < 0)
210 goto failed_put_key;
211
212 ret = register_key_type(&key_type_dns_resolver);
213 if (ret < 0)
214 goto failed_put_key;
215
216 /* instruct request_key() to use this special keyring as a cache for
217 * the results it looks up */
218 cred->thread_keyring = keyring;
219 cred->jit_keyring = KEY_REQKEY_DEFL_THREAD_KEYRING;
220 dns_resolver_cache = cred;
221 return 0;
222
223failed_put_key:
224 key_put(keyring);
225failed_put_cred:
226 put_cred(cred);
227 return ret;
228}
168 229
230void __exit cifs_exit_dns_resolver(void)
231{
232 key_revoke(dns_resolver_cache->thread_keyring);
233 unregister_key_type(&key_type_dns_resolver);
234 put_cred(dns_resolver_cache);
235 printk(KERN_NOTICE "Unregistered %s key type\n",
236 key_type_dns_resolver.name);
237}
diff --git a/fs/cifs/dns_resolve.h b/fs/cifs/dns_resolve.h
index 966e9288930b..26b9eaa9f5ee 100644
--- a/fs/cifs/dns_resolve.h
+++ b/fs/cifs/dns_resolve.h
@@ -24,8 +24,8 @@
24#define _DNS_RESOLVE_H 24#define _DNS_RESOLVE_H
25 25
26#ifdef __KERNEL__ 26#ifdef __KERNEL__
27#include <linux/key-type.h> 27extern int __init cifs_init_dns_resolver(void);
28extern struct key_type key_type_dns_resolver; 28extern void __exit cifs_exit_dns_resolver(void);
29extern int dns_resolve_server_name_to_ip(const char *unc, char **ip_addr); 29extern int dns_resolve_server_name_to_ip(const char *unc, char **ip_addr);
30#endif /* KERNEL */ 30#endif /* KERNEL */
31 31
diff --git a/fs/dcache.c b/fs/dcache.c
index c8c78ba07827..86d4db15473e 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -896,7 +896,7 @@ EXPORT_SYMBOL(shrink_dcache_parent);
896 * 896 *
897 * In this case we return -1 to tell the caller that we baled. 897 * In this case we return -1 to tell the caller that we baled.
898 */ 898 */
899static int shrink_dcache_memory(int nr, gfp_t gfp_mask) 899static int shrink_dcache_memory(struct shrinker *shrink, int nr, gfp_t gfp_mask)
900{ 900{
901 if (nr) { 901 if (nr) {
902 if (!(gfp_mask & __GFP_FS)) 902 if (!(gfp_mask & __GFP_FS))
diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c
index 4a48c0f4b402..84da64b551b2 100644
--- a/fs/gfs2/bmap.c
+++ b/fs/gfs2/bmap.c
@@ -1041,6 +1041,7 @@ static int trunc_start(struct gfs2_inode *ip, u64 size)
1041 1041
1042 if (gfs2_is_stuffed(ip)) { 1042 if (gfs2_is_stuffed(ip)) {
1043 u64 dsize = size + sizeof(struct gfs2_inode); 1043 u64 dsize = size + sizeof(struct gfs2_inode);
1044 ip->i_disksize = size;
1044 ip->i_inode.i_mtime = ip->i_inode.i_ctime = CURRENT_TIME; 1045 ip->i_inode.i_mtime = ip->i_inode.i_ctime = CURRENT_TIME;
1045 gfs2_trans_add_bh(ip->i_gl, dibh, 1); 1046 gfs2_trans_add_bh(ip->i_gl, dibh, 1);
1046 gfs2_dinode_out(ip, dibh->b_data); 1047 gfs2_dinode_out(ip, dibh->b_data);
diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c
index 8295c5b5d4a9..26ca3361a8bc 100644
--- a/fs/gfs2/dir.c
+++ b/fs/gfs2/dir.c
@@ -392,7 +392,7 @@ static int gfs2_dirent_find_space(const struct gfs2_dirent *dent,
392 unsigned totlen = be16_to_cpu(dent->de_rec_len); 392 unsigned totlen = be16_to_cpu(dent->de_rec_len);
393 393
394 if (gfs2_dirent_sentinel(dent)) 394 if (gfs2_dirent_sentinel(dent))
395 actual = GFS2_DIRENT_SIZE(0); 395 actual = 0;
396 if (totlen - actual >= required) 396 if (totlen - actual >= required)
397 return 1; 397 return 1;
398 return 0; 398 return 0;
diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
index ddcdbf493536..0898f3ec8212 100644
--- a/fs/gfs2/glock.c
+++ b/fs/gfs2/glock.c
@@ -706,8 +706,18 @@ static void glock_work_func(struct work_struct *work)
706{ 706{
707 unsigned long delay = 0; 707 unsigned long delay = 0;
708 struct gfs2_glock *gl = container_of(work, struct gfs2_glock, gl_work.work); 708 struct gfs2_glock *gl = container_of(work, struct gfs2_glock, gl_work.work);
709 struct gfs2_holder *gh;
709 int drop_ref = 0; 710 int drop_ref = 0;
710 711
712 if (unlikely(test_bit(GLF_FROZEN, &gl->gl_flags))) {
713 spin_lock(&gl->gl_spin);
714 gh = find_first_waiter(gl);
715 if (gh && (gh->gh_flags & LM_FLAG_NOEXP) &&
716 test_and_clear_bit(GLF_FROZEN, &gl->gl_flags))
717 set_bit(GLF_REPLY_PENDING, &gl->gl_flags);
718 spin_unlock(&gl->gl_spin);
719 }
720
711 if (test_and_clear_bit(GLF_REPLY_PENDING, &gl->gl_flags)) { 721 if (test_and_clear_bit(GLF_REPLY_PENDING, &gl->gl_flags)) {
712 finish_xmote(gl, gl->gl_reply); 722 finish_xmote(gl, gl->gl_reply);
713 drop_ref = 1; 723 drop_ref = 1;
@@ -1348,7 +1358,7 @@ void gfs2_glock_complete(struct gfs2_glock *gl, int ret)
1348} 1358}
1349 1359
1350 1360
1351static int gfs2_shrink_glock_memory(int nr, gfp_t gfp_mask) 1361static int gfs2_shrink_glock_memory(struct shrinker *shrink, int nr, gfp_t gfp_mask)
1352{ 1362{
1353 struct gfs2_glock *gl; 1363 struct gfs2_glock *gl;
1354 int may_demote; 1364 int may_demote;
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index b5612cbb62a5..f03afd9c44bc 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -169,7 +169,7 @@ struct inode *gfs2_inode_lookup(struct super_block *sb,
169{ 169{
170 struct inode *inode; 170 struct inode *inode;
171 struct gfs2_inode *ip; 171 struct gfs2_inode *ip;
172 struct gfs2_glock *io_gl; 172 struct gfs2_glock *io_gl = NULL;
173 int error; 173 int error;
174 174
175 inode = gfs2_iget(sb, no_addr); 175 inode = gfs2_iget(sb, no_addr);
@@ -198,6 +198,7 @@ struct inode *gfs2_inode_lookup(struct super_block *sb,
198 ip->i_iopen_gh.gh_gl->gl_object = ip; 198 ip->i_iopen_gh.gh_gl->gl_object = ip;
199 199
200 gfs2_glock_put(io_gl); 200 gfs2_glock_put(io_gl);
201 io_gl = NULL;
201 202
202 if ((type == DT_UNKNOWN) && (no_formal_ino == 0)) 203 if ((type == DT_UNKNOWN) && (no_formal_ino == 0))
203 goto gfs2_nfsbypass; 204 goto gfs2_nfsbypass;
@@ -228,7 +229,8 @@ gfs2_nfsbypass:
228fail_glock: 229fail_glock:
229 gfs2_glock_dq(&ip->i_iopen_gh); 230 gfs2_glock_dq(&ip->i_iopen_gh);
230fail_iopen: 231fail_iopen:
231 gfs2_glock_put(io_gl); 232 if (io_gl)
233 gfs2_glock_put(io_gl);
232fail_put: 234fail_put:
233 if (inode->i_state & I_NEW) 235 if (inode->i_state & I_NEW)
234 ip->i_gl->gl_object = NULL; 236 ip->i_gl->gl_object = NULL;
@@ -256,7 +258,7 @@ void gfs2_process_unlinked_inode(struct super_block *sb, u64 no_addr)
256{ 258{
257 struct gfs2_sbd *sdp; 259 struct gfs2_sbd *sdp;
258 struct gfs2_inode *ip; 260 struct gfs2_inode *ip;
259 struct gfs2_glock *io_gl; 261 struct gfs2_glock *io_gl = NULL;
260 int error; 262 int error;
261 struct gfs2_holder gh; 263 struct gfs2_holder gh;
262 struct inode *inode; 264 struct inode *inode;
@@ -293,6 +295,7 @@ void gfs2_process_unlinked_inode(struct super_block *sb, u64 no_addr)
293 295
294 ip->i_iopen_gh.gh_gl->gl_object = ip; 296 ip->i_iopen_gh.gh_gl->gl_object = ip;
295 gfs2_glock_put(io_gl); 297 gfs2_glock_put(io_gl);
298 io_gl = NULL;
296 299
297 inode->i_mode = DT2IF(DT_UNKNOWN); 300 inode->i_mode = DT2IF(DT_UNKNOWN);
298 301
@@ -319,7 +322,8 @@ void gfs2_process_unlinked_inode(struct super_block *sb, u64 no_addr)
319fail_glock: 322fail_glock:
320 gfs2_glock_dq(&ip->i_iopen_gh); 323 gfs2_glock_dq(&ip->i_iopen_gh);
321fail_iopen: 324fail_iopen:
322 gfs2_glock_put(io_gl); 325 if (io_gl)
326 gfs2_glock_put(io_gl);
323fail_put: 327fail_put:
324 ip->i_gl->gl_object = NULL; 328 ip->i_gl->gl_object = NULL;
325 gfs2_glock_put(ip->i_gl); 329 gfs2_glock_put(ip->i_gl);
diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c
index 49667d68769e..8f02d3db8f42 100644
--- a/fs/gfs2/quota.c
+++ b/fs/gfs2/quota.c
@@ -77,7 +77,7 @@ static LIST_HEAD(qd_lru_list);
77static atomic_t qd_lru_count = ATOMIC_INIT(0); 77static atomic_t qd_lru_count = ATOMIC_INIT(0);
78static DEFINE_SPINLOCK(qd_lru_lock); 78static DEFINE_SPINLOCK(qd_lru_lock);
79 79
80int gfs2_shrink_qd_memory(int nr, gfp_t gfp_mask) 80int gfs2_shrink_qd_memory(struct shrinker *shrink, int nr, gfp_t gfp_mask)
81{ 81{
82 struct gfs2_quota_data *qd; 82 struct gfs2_quota_data *qd;
83 struct gfs2_sbd *sdp; 83 struct gfs2_sbd *sdp;
@@ -694,10 +694,8 @@ get_a_page:
694 if (!buffer_mapped(bh)) 694 if (!buffer_mapped(bh))
695 goto unlock_out; 695 goto unlock_out;
696 /* If it's a newly allocated disk block for quota, zero it */ 696 /* If it's a newly allocated disk block for quota, zero it */
697 if (buffer_new(bh)) { 697 if (buffer_new(bh))
698 memset(bh->b_data, 0, bh->b_size); 698 zero_user(page, pos - blocksize, bh->b_size);
699 set_buffer_uptodate(bh);
700 }
701 } 699 }
702 700
703 if (PageUptodate(page)) 701 if (PageUptodate(page))
@@ -723,7 +721,7 @@ get_a_page:
723 721
724 /* If quota straddles page boundary, we need to update the rest of the 722 /* If quota straddles page boundary, we need to update the rest of the
725 * quota at the beginning of the next page */ 723 * quota at the beginning of the next page */
726 if (offset != 0) { /* first page, offset is closer to PAGE_CACHE_SIZE */ 724 if ((offset + sizeof(struct gfs2_quota)) > PAGE_CACHE_SIZE) {
727 ptr = ptr + nbytes; 725 ptr = ptr + nbytes;
728 nbytes = sizeof(struct gfs2_quota) - nbytes; 726 nbytes = sizeof(struct gfs2_quota) - nbytes;
729 offset = 0; 727 offset = 0;
diff --git a/fs/gfs2/quota.h b/fs/gfs2/quota.h
index 195f60c8bd14..e7d236ca48bd 100644
--- a/fs/gfs2/quota.h
+++ b/fs/gfs2/quota.h
@@ -51,7 +51,7 @@ static inline int gfs2_quota_lock_check(struct gfs2_inode *ip)
51 return ret; 51 return ret;
52} 52}
53 53
54extern int gfs2_shrink_qd_memory(int nr, gfp_t gfp_mask); 54extern int gfs2_shrink_qd_memory(struct shrinker *shrink, int nr, gfp_t gfp_mask);
55extern const struct quotactl_ops gfs2_quotactl_ops; 55extern const struct quotactl_ops gfs2_quotactl_ops;
56 56
57#endif /* __QUOTA_DOT_H__ */ 57#endif /* __QUOTA_DOT_H__ */
diff --git a/fs/inode.c b/fs/inode.c
index 2bee20ae3d65..722860b323a9 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -512,7 +512,7 @@ static void prune_icache(int nr_to_scan)
512 * This function is passed the number of inodes to scan, and it returns the 512 * This function is passed the number of inodes to scan, and it returns the
513 * total number of remaining possibly-reclaimable inodes. 513 * total number of remaining possibly-reclaimable inodes.
514 */ 514 */
515static int shrink_icache_memory(int nr, gfp_t gfp_mask) 515static int shrink_icache_memory(struct shrinker *shrink, int nr, gfp_t gfp_mask)
516{ 516{
517 if (nr) { 517 if (nr) {
518 /* 518 /*
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index bc2ff5932769..036880895bfc 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -297,7 +297,6 @@ int jbd2_journal_write_metadata_buffer(transaction_t *transaction,
297 struct page *new_page; 297 struct page *new_page;
298 unsigned int new_offset; 298 unsigned int new_offset;
299 struct buffer_head *bh_in = jh2bh(jh_in); 299 struct buffer_head *bh_in = jh2bh(jh_in);
300 struct jbd2_buffer_trigger_type *triggers;
301 journal_t *journal = transaction->t_journal; 300 journal_t *journal = transaction->t_journal;
302 301
303 /* 302 /*
@@ -328,21 +327,21 @@ repeat:
328 done_copy_out = 1; 327 done_copy_out = 1;
329 new_page = virt_to_page(jh_in->b_frozen_data); 328 new_page = virt_to_page(jh_in->b_frozen_data);
330 new_offset = offset_in_page(jh_in->b_frozen_data); 329 new_offset = offset_in_page(jh_in->b_frozen_data);
331 triggers = jh_in->b_frozen_triggers;
332 } else { 330 } else {
333 new_page = jh2bh(jh_in)->b_page; 331 new_page = jh2bh(jh_in)->b_page;
334 new_offset = offset_in_page(jh2bh(jh_in)->b_data); 332 new_offset = offset_in_page(jh2bh(jh_in)->b_data);
335 triggers = jh_in->b_triggers;
336 } 333 }
337 334
338 mapped_data = kmap_atomic(new_page, KM_USER0); 335 mapped_data = kmap_atomic(new_page, KM_USER0);
339 /* 336 /*
340 * Fire any commit trigger. Do this before checking for escaping, 337 * Fire data frozen trigger if data already wasn't frozen. Do this
341 * as the trigger may modify the magic offset. If a copy-out 338 * before checking for escaping, as the trigger may modify the magic
342 * happens afterwards, it will have the correct data in the buffer. 339 * offset. If a copy-out happens afterwards, it will have the correct
340 * data in the buffer.
343 */ 341 */
344 jbd2_buffer_commit_trigger(jh_in, mapped_data + new_offset, 342 if (!done_copy_out)
345 triggers); 343 jbd2_buffer_frozen_trigger(jh_in, mapped_data + new_offset,
344 jh_in->b_triggers);
346 345
347 /* 346 /*
348 * Check for escaping 347 * Check for escaping
diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
index e214d68620ac..b8e0806681bb 100644
--- a/fs/jbd2/transaction.c
+++ b/fs/jbd2/transaction.c
@@ -725,6 +725,9 @@ done:
725 page = jh2bh(jh)->b_page; 725 page = jh2bh(jh)->b_page;
726 offset = ((unsigned long) jh2bh(jh)->b_data) & ~PAGE_MASK; 726 offset = ((unsigned long) jh2bh(jh)->b_data) & ~PAGE_MASK;
727 source = kmap_atomic(page, KM_USER0); 727 source = kmap_atomic(page, KM_USER0);
728 /* Fire data frozen trigger just before we copy the data */
729 jbd2_buffer_frozen_trigger(jh, source + offset,
730 jh->b_triggers);
728 memcpy(jh->b_frozen_data, source+offset, jh2bh(jh)->b_size); 731 memcpy(jh->b_frozen_data, source+offset, jh2bh(jh)->b_size);
729 kunmap_atomic(source, KM_USER0); 732 kunmap_atomic(source, KM_USER0);
730 733
@@ -963,15 +966,15 @@ void jbd2_journal_set_triggers(struct buffer_head *bh,
963 jh->b_triggers = type; 966 jh->b_triggers = type;
964} 967}
965 968
966void jbd2_buffer_commit_trigger(struct journal_head *jh, void *mapped_data, 969void jbd2_buffer_frozen_trigger(struct journal_head *jh, void *mapped_data,
967 struct jbd2_buffer_trigger_type *triggers) 970 struct jbd2_buffer_trigger_type *triggers)
968{ 971{
969 struct buffer_head *bh = jh2bh(jh); 972 struct buffer_head *bh = jh2bh(jh);
970 973
971 if (!triggers || !triggers->t_commit) 974 if (!triggers || !triggers->t_frozen)
972 return; 975 return;
973 976
974 triggers->t_commit(triggers, bh, mapped_data, bh->b_size); 977 triggers->t_frozen(triggers, bh, mapped_data, bh->b_size);
975} 978}
976 979
977void jbd2_buffer_abort_trigger(struct journal_head *jh, 980void jbd2_buffer_abort_trigger(struct journal_head *jh,
diff --git a/fs/jffs2/xattr.c b/fs/jffs2/xattr.c
index a2d58c96f1b4..d258e261bdc7 100644
--- a/fs/jffs2/xattr.c
+++ b/fs/jffs2/xattr.c
@@ -626,7 +626,7 @@ void jffs2_xattr_free_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *i
626 626
627static int check_xattr_ref_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic) 627static int check_xattr_ref_inode(struct jffs2_sb_info *c, struct jffs2_inode_cache *ic)
628{ 628{
629 /* success of check_xattr_ref_inode() means taht inode (ic) dose not have 629 /* success of check_xattr_ref_inode() means that inode (ic) dose not have
630 * duplicate name/value pairs. If duplicate name/value pair would be found, 630 * duplicate name/value pairs. If duplicate name/value pair would be found,
631 * one will be removed. 631 * one will be removed.
632 */ 632 */
diff --git a/fs/mbcache.c b/fs/mbcache.c
index ec88ff3d04a9..e28f21b95344 100644
--- a/fs/mbcache.c
+++ b/fs/mbcache.c
@@ -115,7 +115,7 @@ mb_cache_indexes(struct mb_cache *cache)
115 * What the mbcache registers as to get shrunk dynamically. 115 * What the mbcache registers as to get shrunk dynamically.
116 */ 116 */
117 117
118static int mb_cache_shrink_fn(int nr_to_scan, gfp_t gfp_mask); 118static int mb_cache_shrink_fn(struct shrinker *shrink, int nr_to_scan, gfp_t gfp_mask);
119 119
120static struct shrinker mb_cache_shrinker = { 120static struct shrinker mb_cache_shrinker = {
121 .shrink = mb_cache_shrink_fn, 121 .shrink = mb_cache_shrink_fn,
@@ -191,13 +191,14 @@ forget:
191 * This function is called by the kernel memory management when memory 191 * This function is called by the kernel memory management when memory
192 * gets low. 192 * gets low.
193 * 193 *
194 * @shrink: (ignored)
194 * @nr_to_scan: Number of objects to scan 195 * @nr_to_scan: Number of objects to scan
195 * @gfp_mask: (ignored) 196 * @gfp_mask: (ignored)
196 * 197 *
197 * Returns the number of objects which are present in the cache. 198 * Returns the number of objects which are present in the cache.
198 */ 199 */
199static int 200static int
200mb_cache_shrink_fn(int nr_to_scan, gfp_t gfp_mask) 201mb_cache_shrink_fn(struct shrinker *shrink, int nr_to_scan, gfp_t gfp_mask)
201{ 202{
202 LIST_HEAD(free_list); 203 LIST_HEAD(free_list);
203 struct list_head *l, *ltmp; 204 struct list_head *l, *ltmp;
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 782b431ef91c..e60416d3f818 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -1710,7 +1710,7 @@ static void nfs_access_free_list(struct list_head *head)
1710 } 1710 }
1711} 1711}
1712 1712
1713int nfs_access_cache_shrinker(int nr_to_scan, gfp_t gfp_mask) 1713int nfs_access_cache_shrinker(struct shrinker *shrink, int nr_to_scan, gfp_t gfp_mask)
1714{ 1714{
1715 LIST_HEAD(head); 1715 LIST_HEAD(head);
1716 struct nfs_inode *nfsi; 1716 struct nfs_inode *nfsi;
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index d8bd619e386c..e70f44b9b3f4 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -205,7 +205,8 @@ extern struct rpc_procinfo nfs4_procedures[];
205void nfs_close_context(struct nfs_open_context *ctx, int is_sync); 205void nfs_close_context(struct nfs_open_context *ctx, int is_sync);
206 206
207/* dir.c */ 207/* dir.c */
208extern int nfs_access_cache_shrinker(int nr_to_scan, gfp_t gfp_mask); 208extern int nfs_access_cache_shrinker(struct shrinker *shrink,
209 int nr_to_scan, gfp_t gfp_mask);
209 210
210/* inode.c */ 211/* inode.c */
211extern struct workqueue_struct *nfsiod_workqueue; 212extern struct workqueue_struct *nfsiod_workqueue;
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
index 3623ca20cc18..356e976772bf 100644
--- a/fs/ocfs2/aops.c
+++ b/fs/ocfs2/aops.c
@@ -196,15 +196,14 @@ int ocfs2_get_block(struct inode *inode, sector_t iblock,
196 dump_stack(); 196 dump_stack();
197 goto bail; 197 goto bail;
198 } 198 }
199
200 past_eof = ocfs2_blocks_for_bytes(inode->i_sb, i_size_read(inode));
201 mlog(0, "Inode %lu, past_eof = %llu\n", inode->i_ino,
202 (unsigned long long)past_eof);
203
204 if (create && (iblock >= past_eof))
205 set_buffer_new(bh_result);
206 } 199 }
207 200
201 past_eof = ocfs2_blocks_for_bytes(inode->i_sb, i_size_read(inode));
202 mlog(0, "Inode %lu, past_eof = %llu\n", inode->i_ino,
203 (unsigned long long)past_eof);
204 if (create && (iblock >= past_eof))
205 set_buffer_new(bh_result);
206
208bail: 207bail:
209 if (err < 0) 208 if (err < 0)
210 err = -EIO; 209 err = -EIO;
@@ -459,36 +458,6 @@ int walk_page_buffers( handle_t *handle,
459 return ret; 458 return ret;
460} 459}
461 460
462handle_t *ocfs2_start_walk_page_trans(struct inode *inode,
463 struct page *page,
464 unsigned from,
465 unsigned to)
466{
467 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
468 handle_t *handle;
469 int ret = 0;
470
471 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
472 if (IS_ERR(handle)) {
473 ret = -ENOMEM;
474 mlog_errno(ret);
475 goto out;
476 }
477
478 if (ocfs2_should_order_data(inode)) {
479 ret = ocfs2_jbd2_file_inode(handle, inode);
480 if (ret < 0)
481 mlog_errno(ret);
482 }
483out:
484 if (ret) {
485 if (!IS_ERR(handle))
486 ocfs2_commit_trans(osb, handle);
487 handle = ERR_PTR(ret);
488 }
489 return handle;
490}
491
492static sector_t ocfs2_bmap(struct address_space *mapping, sector_t block) 461static sector_t ocfs2_bmap(struct address_space *mapping, sector_t block)
493{ 462{
494 sector_t status; 463 sector_t status;
@@ -1131,23 +1100,37 @@ out:
1131 */ 1100 */
1132static int ocfs2_grab_pages_for_write(struct address_space *mapping, 1101static int ocfs2_grab_pages_for_write(struct address_space *mapping,
1133 struct ocfs2_write_ctxt *wc, 1102 struct ocfs2_write_ctxt *wc,
1134 u32 cpos, loff_t user_pos, int new, 1103 u32 cpos, loff_t user_pos,
1104 unsigned user_len, int new,
1135 struct page *mmap_page) 1105 struct page *mmap_page)
1136{ 1106{
1137 int ret = 0, i; 1107 int ret = 0, i;
1138 unsigned long start, target_index, index; 1108 unsigned long start, target_index, end_index, index;
1139 struct inode *inode = mapping->host; 1109 struct inode *inode = mapping->host;
1110 loff_t last_byte;
1140 1111
1141 target_index = user_pos >> PAGE_CACHE_SHIFT; 1112 target_index = user_pos >> PAGE_CACHE_SHIFT;
1142 1113
1143 /* 1114 /*
1144 * Figure out how many pages we'll be manipulating here. For 1115 * Figure out how many pages we'll be manipulating here. For
1145 * non allocating write, we just change the one 1116 * non allocating write, we just change the one
1146 * page. Otherwise, we'll need a whole clusters worth. 1117 * page. Otherwise, we'll need a whole clusters worth. If we're
1118 * writing past i_size, we only need enough pages to cover the
1119 * last page of the write.
1147 */ 1120 */
1148 if (new) { 1121 if (new) {
1149 wc->w_num_pages = ocfs2_pages_per_cluster(inode->i_sb); 1122 wc->w_num_pages = ocfs2_pages_per_cluster(inode->i_sb);
1150 start = ocfs2_align_clusters_to_page_index(inode->i_sb, cpos); 1123 start = ocfs2_align_clusters_to_page_index(inode->i_sb, cpos);
1124 /*
1125 * We need the index *past* the last page we could possibly
1126 * touch. This is the page past the end of the write or
1127 * i_size, whichever is greater.
1128 */
1129 last_byte = max(user_pos + user_len, i_size_read(inode));
1130 BUG_ON(last_byte < 1);
1131 end_index = ((last_byte - 1) >> PAGE_CACHE_SHIFT) + 1;
1132 if ((start + wc->w_num_pages) > end_index)
1133 wc->w_num_pages = end_index - start;
1151 } else { 1134 } else {
1152 wc->w_num_pages = 1; 1135 wc->w_num_pages = 1;
1153 start = target_index; 1136 start = target_index;
@@ -1620,21 +1603,20 @@ out:
1620 * write path can treat it as an non-allocating write, which has no 1603 * write path can treat it as an non-allocating write, which has no
1621 * special case code for sparse/nonsparse files. 1604 * special case code for sparse/nonsparse files.
1622 */ 1605 */
1623static int ocfs2_expand_nonsparse_inode(struct inode *inode, loff_t pos, 1606static int ocfs2_expand_nonsparse_inode(struct inode *inode,
1624 unsigned len, 1607 struct buffer_head *di_bh,
1608 loff_t pos, unsigned len,
1625 struct ocfs2_write_ctxt *wc) 1609 struct ocfs2_write_ctxt *wc)
1626{ 1610{
1627 int ret; 1611 int ret;
1628 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
1629 loff_t newsize = pos + len; 1612 loff_t newsize = pos + len;
1630 1613
1631 if (ocfs2_sparse_alloc(osb)) 1614 BUG_ON(ocfs2_sparse_alloc(OCFS2_SB(inode->i_sb)));
1632 return 0;
1633 1615
1634 if (newsize <= i_size_read(inode)) 1616 if (newsize <= i_size_read(inode))
1635 return 0; 1617 return 0;
1636 1618
1637 ret = ocfs2_extend_no_holes(inode, newsize, pos); 1619 ret = ocfs2_extend_no_holes(inode, di_bh, newsize, pos);
1638 if (ret) 1620 if (ret)
1639 mlog_errno(ret); 1621 mlog_errno(ret);
1640 1622
@@ -1644,6 +1626,18 @@ static int ocfs2_expand_nonsparse_inode(struct inode *inode, loff_t pos,
1644 return ret; 1626 return ret;
1645} 1627}
1646 1628
1629static int ocfs2_zero_tail(struct inode *inode, struct buffer_head *di_bh,
1630 loff_t pos)
1631{
1632 int ret = 0;
1633
1634 BUG_ON(!ocfs2_sparse_alloc(OCFS2_SB(inode->i_sb)));
1635 if (pos > i_size_read(inode))
1636 ret = ocfs2_zero_extend(inode, di_bh, pos);
1637
1638 return ret;
1639}
1640
1647int ocfs2_write_begin_nolock(struct address_space *mapping, 1641int ocfs2_write_begin_nolock(struct address_space *mapping,
1648 loff_t pos, unsigned len, unsigned flags, 1642 loff_t pos, unsigned len, unsigned flags,
1649 struct page **pagep, void **fsdata, 1643 struct page **pagep, void **fsdata,
@@ -1679,7 +1673,11 @@ int ocfs2_write_begin_nolock(struct address_space *mapping,
1679 } 1673 }
1680 } 1674 }
1681 1675
1682 ret = ocfs2_expand_nonsparse_inode(inode, pos, len, wc); 1676 if (ocfs2_sparse_alloc(osb))
1677 ret = ocfs2_zero_tail(inode, di_bh, pos);
1678 else
1679 ret = ocfs2_expand_nonsparse_inode(inode, di_bh, pos, len,
1680 wc);
1683 if (ret) { 1681 if (ret) {
1684 mlog_errno(ret); 1682 mlog_errno(ret);
1685 goto out; 1683 goto out;
@@ -1789,7 +1787,7 @@ int ocfs2_write_begin_nolock(struct address_space *mapping,
1789 * that we can zero and flush if we error after adding the 1787 * that we can zero and flush if we error after adding the
1790 * extent. 1788 * extent.
1791 */ 1789 */
1792 ret = ocfs2_grab_pages_for_write(mapping, wc, wc->w_cpos, pos, 1790 ret = ocfs2_grab_pages_for_write(mapping, wc, wc->w_cpos, pos, len,
1793 cluster_of_pages, mmap_page); 1791 cluster_of_pages, mmap_page);
1794 if (ret) { 1792 if (ret) {
1795 mlog_errno(ret); 1793 mlog_errno(ret);
diff --git a/fs/ocfs2/dlm/dlmdomain.c b/fs/ocfs2/dlm/dlmdomain.c
index 6b5a492e1749..153abb5abef0 100644
--- a/fs/ocfs2/dlm/dlmdomain.c
+++ b/fs/ocfs2/dlm/dlmdomain.c
@@ -1671,7 +1671,7 @@ struct dlm_ctxt * dlm_register_domain(const char *domain,
1671 struct dlm_ctxt *dlm = NULL; 1671 struct dlm_ctxt *dlm = NULL;
1672 struct dlm_ctxt *new_ctxt = NULL; 1672 struct dlm_ctxt *new_ctxt = NULL;
1673 1673
1674 if (strlen(domain) > O2NM_MAX_NAME_LEN) { 1674 if (strlen(domain) >= O2NM_MAX_NAME_LEN) {
1675 ret = -ENAMETOOLONG; 1675 ret = -ENAMETOOLONG;
1676 mlog(ML_ERROR, "domain name length too long\n"); 1676 mlog(ML_ERROR, "domain name length too long\n");
1677 goto leave; 1677 goto leave;
@@ -1709,6 +1709,7 @@ retry:
1709 } 1709 }
1710 1710
1711 if (dlm_protocol_compare(&dlm->fs_locking_proto, fs_proto)) { 1711 if (dlm_protocol_compare(&dlm->fs_locking_proto, fs_proto)) {
1712 spin_unlock(&dlm_domain_lock);
1712 mlog(ML_ERROR, 1713 mlog(ML_ERROR,
1713 "Requested locking protocol version is not " 1714 "Requested locking protocol version is not "
1714 "compatible with already registered domain " 1715 "compatible with already registered domain "
diff --git a/fs/ocfs2/dlm/dlmmaster.c b/fs/ocfs2/dlm/dlmmaster.c
index 4a7506a4e314..94b97fc6a88e 100644
--- a/fs/ocfs2/dlm/dlmmaster.c
+++ b/fs/ocfs2/dlm/dlmmaster.c
@@ -2808,14 +2808,8 @@ again:
2808 mlog(0, "trying again...\n"); 2808 mlog(0, "trying again...\n");
2809 goto again; 2809 goto again;
2810 } 2810 }
2811 /* now that we are sure the MIGRATING state is there, drop
2812 * the unneded state which blocked threads trying to DIRTY */
2813 spin_lock(&res->spinlock);
2814 BUG_ON(!(res->state & DLM_LOCK_RES_BLOCK_DIRTY));
2815 BUG_ON(!(res->state & DLM_LOCK_RES_MIGRATING));
2816 res->state &= ~DLM_LOCK_RES_BLOCK_DIRTY;
2817 spin_unlock(&res->spinlock);
2818 2811
2812 ret = 0;
2819 /* did the target go down or die? */ 2813 /* did the target go down or die? */
2820 spin_lock(&dlm->spinlock); 2814 spin_lock(&dlm->spinlock);
2821 if (!test_bit(target, dlm->domain_map)) { 2815 if (!test_bit(target, dlm->domain_map)) {
@@ -2826,9 +2820,21 @@ again:
2826 spin_unlock(&dlm->spinlock); 2820 spin_unlock(&dlm->spinlock);
2827 2821
2828 /* 2822 /*
2823 * if target is down, we need to clear DLM_LOCK_RES_BLOCK_DIRTY for
2824 * another try; otherwise, we are sure the MIGRATING state is there,
2825 * drop the unneded state which blocked threads trying to DIRTY
2826 */
2827 spin_lock(&res->spinlock);
2828 BUG_ON(!(res->state & DLM_LOCK_RES_BLOCK_DIRTY));
2829 res->state &= ~DLM_LOCK_RES_BLOCK_DIRTY;
2830 if (!ret)
2831 BUG_ON(!(res->state & DLM_LOCK_RES_MIGRATING));
2832 spin_unlock(&res->spinlock);
2833
2834 /*
2829 * at this point: 2835 * at this point:
2830 * 2836 *
2831 * o the DLM_LOCK_RES_MIGRATING flag is set 2837 * o the DLM_LOCK_RES_MIGRATING flag is set if target not down
2832 * o there are no pending asts on this lockres 2838 * o there are no pending asts on this lockres
2833 * o all processes trying to reserve an ast on this 2839 * o all processes trying to reserve an ast on this
2834 * lockres must wait for the MIGRATING flag to clear 2840 * lockres must wait for the MIGRATING flag to clear
diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c
index f8b75ce4be70..9dfaac73b36d 100644
--- a/fs/ocfs2/dlm/dlmrecovery.c
+++ b/fs/ocfs2/dlm/dlmrecovery.c
@@ -463,7 +463,7 @@ static int dlm_do_recovery(struct dlm_ctxt *dlm)
463 if (dlm->reco.dead_node == O2NM_INVALID_NODE_NUM) { 463 if (dlm->reco.dead_node == O2NM_INVALID_NODE_NUM) {
464 int bit; 464 int bit;
465 465
466 bit = find_next_bit (dlm->recovery_map, O2NM_MAX_NODES+1, 0); 466 bit = find_next_bit (dlm->recovery_map, O2NM_MAX_NODES, 0);
467 if (bit >= O2NM_MAX_NODES || bit < 0) 467 if (bit >= O2NM_MAX_NODES || bit < 0)
468 dlm_set_reco_dead_node(dlm, O2NM_INVALID_NODE_NUM); 468 dlm_set_reco_dead_node(dlm, O2NM_INVALID_NODE_NUM);
469 else 469 else
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index 6a13ea64c447..2b10b36d1577 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -724,28 +724,55 @@ leave:
724 return status; 724 return status;
725} 725}
726 726
727/*
728 * While a write will already be ordering the data, a truncate will not.
729 * Thus, we need to explicitly order the zeroed pages.
730 */
731static handle_t *ocfs2_zero_start_ordered_transaction(struct inode *inode)
732{
733 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
734 handle_t *handle = NULL;
735 int ret = 0;
736
737 if (!ocfs2_should_order_data(inode))
738 goto out;
739
740 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
741 if (IS_ERR(handle)) {
742 ret = -ENOMEM;
743 mlog_errno(ret);
744 goto out;
745 }
746
747 ret = ocfs2_jbd2_file_inode(handle, inode);
748 if (ret < 0)
749 mlog_errno(ret);
750
751out:
752 if (ret) {
753 if (!IS_ERR(handle))
754 ocfs2_commit_trans(osb, handle);
755 handle = ERR_PTR(ret);
756 }
757 return handle;
758}
759
727/* Some parts of this taken from generic_cont_expand, which turned out 760/* Some parts of this taken from generic_cont_expand, which turned out
728 * to be too fragile to do exactly what we need without us having to 761 * to be too fragile to do exactly what we need without us having to
729 * worry about recursive locking in ->write_begin() and ->write_end(). */ 762 * worry about recursive locking in ->write_begin() and ->write_end(). */
730static int ocfs2_write_zero_page(struct inode *inode, 763static int ocfs2_write_zero_page(struct inode *inode, u64 abs_from,
731 u64 size) 764 u64 abs_to)
732{ 765{
733 struct address_space *mapping = inode->i_mapping; 766 struct address_space *mapping = inode->i_mapping;
734 struct page *page; 767 struct page *page;
735 unsigned long index; 768 unsigned long index = abs_from >> PAGE_CACHE_SHIFT;
736 unsigned int offset;
737 handle_t *handle = NULL; 769 handle_t *handle = NULL;
738 int ret; 770 int ret = 0;
771 unsigned zero_from, zero_to, block_start, block_end;
739 772
740 offset = (size & (PAGE_CACHE_SIZE-1)); /* Within page */ 773 BUG_ON(abs_from >= abs_to);
741 /* ugh. in prepare/commit_write, if from==to==start of block, we 774 BUG_ON(abs_to > (((u64)index + 1) << PAGE_CACHE_SHIFT));
742 ** skip the prepare. make sure we never send an offset for the start 775 BUG_ON(abs_from & (inode->i_blkbits - 1));
743 ** of a block
744 */
745 if ((offset & (inode->i_sb->s_blocksize - 1)) == 0) {
746 offset++;
747 }
748 index = size >> PAGE_CACHE_SHIFT;
749 776
750 page = grab_cache_page(mapping, index); 777 page = grab_cache_page(mapping, index);
751 if (!page) { 778 if (!page) {
@@ -754,31 +781,56 @@ static int ocfs2_write_zero_page(struct inode *inode,
754 goto out; 781 goto out;
755 } 782 }
756 783
757 ret = ocfs2_prepare_write_nolock(inode, page, offset, offset); 784 /* Get the offsets within the page that we want to zero */
758 if (ret < 0) { 785 zero_from = abs_from & (PAGE_CACHE_SIZE - 1);
759 mlog_errno(ret); 786 zero_to = abs_to & (PAGE_CACHE_SIZE - 1);
760 goto out_unlock; 787 if (!zero_to)
761 } 788 zero_to = PAGE_CACHE_SIZE;
762 789
763 if (ocfs2_should_order_data(inode)) { 790 mlog(0,
764 handle = ocfs2_start_walk_page_trans(inode, page, offset, 791 "abs_from = %llu, abs_to = %llu, index = %lu, zero_from = %u, zero_to = %u\n",
765 offset); 792 (unsigned long long)abs_from, (unsigned long long)abs_to,
766 if (IS_ERR(handle)) { 793 index, zero_from, zero_to);
767 ret = PTR_ERR(handle); 794
768 handle = NULL; 795 /* We know that zero_from is block aligned */
796 for (block_start = zero_from; block_start < zero_to;
797 block_start = block_end) {
798 block_end = block_start + (1 << inode->i_blkbits);
799
800 /*
801 * block_start is block-aligned. Bump it by one to
802 * force ocfs2_{prepare,commit}_write() to zero the
803 * whole block.
804 */
805 ret = ocfs2_prepare_write_nolock(inode, page,
806 block_start + 1,
807 block_start + 1);
808 if (ret < 0) {
809 mlog_errno(ret);
769 goto out_unlock; 810 goto out_unlock;
770 } 811 }
771 }
772 812
773 /* must not update i_size! */ 813 if (!handle) {
774 ret = block_commit_write(page, offset, offset); 814 handle = ocfs2_zero_start_ordered_transaction(inode);
775 if (ret < 0) 815 if (IS_ERR(handle)) {
776 mlog_errno(ret); 816 ret = PTR_ERR(handle);
777 else 817 handle = NULL;
778 ret = 0; 818 break;
819 }
820 }
821
822 /* must not update i_size! */
823 ret = block_commit_write(page, block_start + 1,
824 block_start + 1);
825 if (ret < 0)
826 mlog_errno(ret);
827 else
828 ret = 0;
829 }
779 830
780 if (handle) 831 if (handle)
781 ocfs2_commit_trans(OCFS2_SB(inode->i_sb), handle); 832 ocfs2_commit_trans(OCFS2_SB(inode->i_sb), handle);
833
782out_unlock: 834out_unlock:
783 unlock_page(page); 835 unlock_page(page);
784 page_cache_release(page); 836 page_cache_release(page);
@@ -786,22 +838,114 @@ out:
786 return ret; 838 return ret;
787} 839}
788 840
789static int ocfs2_zero_extend(struct inode *inode, 841/*
790 u64 zero_to_size) 842 * Find the next range to zero. We do this in terms of bytes because
843 * that's what ocfs2_zero_extend() wants, and it is dealing with the
844 * pagecache. We may return multiple extents.
845 *
846 * zero_start and zero_end are ocfs2_zero_extend()s current idea of what
847 * needs to be zeroed. range_start and range_end return the next zeroing
848 * range. A subsequent call should pass the previous range_end as its
849 * zero_start. If range_end is 0, there's nothing to do.
850 *
851 * Unwritten extents are skipped over. Refcounted extents are CoWd.
852 */
853static int ocfs2_zero_extend_get_range(struct inode *inode,
854 struct buffer_head *di_bh,
855 u64 zero_start, u64 zero_end,
856 u64 *range_start, u64 *range_end)
791{ 857{
792 int ret = 0; 858 int rc = 0, needs_cow = 0;
793 u64 start_off; 859 u32 p_cpos, zero_clusters = 0;
794 struct super_block *sb = inode->i_sb; 860 u32 zero_cpos =
861 zero_start >> OCFS2_SB(inode->i_sb)->s_clustersize_bits;
862 u32 last_cpos = ocfs2_clusters_for_bytes(inode->i_sb, zero_end);
863 unsigned int num_clusters = 0;
864 unsigned int ext_flags = 0;
795 865
796 start_off = ocfs2_align_bytes_to_blocks(sb, i_size_read(inode)); 866 while (zero_cpos < last_cpos) {
797 while (start_off < zero_to_size) { 867 rc = ocfs2_get_clusters(inode, zero_cpos, &p_cpos,
798 ret = ocfs2_write_zero_page(inode, start_off); 868 &num_clusters, &ext_flags);
799 if (ret < 0) { 869 if (rc) {
800 mlog_errno(ret); 870 mlog_errno(rc);
871 goto out;
872 }
873
874 if (p_cpos && !(ext_flags & OCFS2_EXT_UNWRITTEN)) {
875 zero_clusters = num_clusters;
876 if (ext_flags & OCFS2_EXT_REFCOUNTED)
877 needs_cow = 1;
878 break;
879 }
880
881 zero_cpos += num_clusters;
882 }
883 if (!zero_clusters) {
884 *range_end = 0;
885 goto out;
886 }
887
888 while ((zero_cpos + zero_clusters) < last_cpos) {
889 rc = ocfs2_get_clusters(inode, zero_cpos + zero_clusters,
890 &p_cpos, &num_clusters,
891 &ext_flags);
892 if (rc) {
893 mlog_errno(rc);
801 goto out; 894 goto out;
802 } 895 }
803 896
804 start_off += sb->s_blocksize; 897 if (!p_cpos || (ext_flags & OCFS2_EXT_UNWRITTEN))
898 break;
899 if (ext_flags & OCFS2_EXT_REFCOUNTED)
900 needs_cow = 1;
901 zero_clusters += num_clusters;
902 }
903 if ((zero_cpos + zero_clusters) > last_cpos)
904 zero_clusters = last_cpos - zero_cpos;
905
906 if (needs_cow) {
907 rc = ocfs2_refcount_cow(inode, di_bh, zero_cpos, zero_clusters,
908 UINT_MAX);
909 if (rc) {
910 mlog_errno(rc);
911 goto out;
912 }
913 }
914
915 *range_start = ocfs2_clusters_to_bytes(inode->i_sb, zero_cpos);
916 *range_end = ocfs2_clusters_to_bytes(inode->i_sb,
917 zero_cpos + zero_clusters);
918
919out:
920 return rc;
921}
922
923/*
924 * Zero one range returned from ocfs2_zero_extend_get_range(). The caller
925 * has made sure that the entire range needs zeroing.
926 */
927static int ocfs2_zero_extend_range(struct inode *inode, u64 range_start,
928 u64 range_end)
929{
930 int rc = 0;
931 u64 next_pos;
932 u64 zero_pos = range_start;
933
934 mlog(0, "range_start = %llu, range_end = %llu\n",
935 (unsigned long long)range_start,
936 (unsigned long long)range_end);
937 BUG_ON(range_start >= range_end);
938
939 while (zero_pos < range_end) {
940 next_pos = (zero_pos & PAGE_CACHE_MASK) + PAGE_CACHE_SIZE;
941 if (next_pos > range_end)
942 next_pos = range_end;
943 rc = ocfs2_write_zero_page(inode, zero_pos, next_pos);
944 if (rc < 0) {
945 mlog_errno(rc);
946 break;
947 }
948 zero_pos = next_pos;
805 949
806 /* 950 /*
807 * Very large extends have the potential to lock up 951 * Very large extends have the potential to lock up
@@ -810,16 +954,63 @@ static int ocfs2_zero_extend(struct inode *inode,
810 cond_resched(); 954 cond_resched();
811 } 955 }
812 956
813out: 957 return rc;
958}
959
960int ocfs2_zero_extend(struct inode *inode, struct buffer_head *di_bh,
961 loff_t zero_to_size)
962{
963 int ret = 0;
964 u64 zero_start, range_start = 0, range_end = 0;
965 struct super_block *sb = inode->i_sb;
966
967 zero_start = ocfs2_align_bytes_to_blocks(sb, i_size_read(inode));
968 mlog(0, "zero_start %llu for i_size %llu\n",
969 (unsigned long long)zero_start,
970 (unsigned long long)i_size_read(inode));
971 while (zero_start < zero_to_size) {
972 ret = ocfs2_zero_extend_get_range(inode, di_bh, zero_start,
973 zero_to_size,
974 &range_start,
975 &range_end);
976 if (ret) {
977 mlog_errno(ret);
978 break;
979 }
980 if (!range_end)
981 break;
982 /* Trim the ends */
983 if (range_start < zero_start)
984 range_start = zero_start;
985 if (range_end > zero_to_size)
986 range_end = zero_to_size;
987
988 ret = ocfs2_zero_extend_range(inode, range_start,
989 range_end);
990 if (ret) {
991 mlog_errno(ret);
992 break;
993 }
994 zero_start = range_end;
995 }
996
814 return ret; 997 return ret;
815} 998}
816 999
817int ocfs2_extend_no_holes(struct inode *inode, u64 new_i_size, u64 zero_to) 1000int ocfs2_extend_no_holes(struct inode *inode, struct buffer_head *di_bh,
1001 u64 new_i_size, u64 zero_to)
818{ 1002{
819 int ret; 1003 int ret;
820 u32 clusters_to_add; 1004 u32 clusters_to_add;
821 struct ocfs2_inode_info *oi = OCFS2_I(inode); 1005 struct ocfs2_inode_info *oi = OCFS2_I(inode);
822 1006
1007 /*
1008 * Only quota files call this without a bh, and they can't be
1009 * refcounted.
1010 */
1011 BUG_ON(!di_bh && (oi->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL));
1012 BUG_ON(!di_bh && !(oi->ip_flags & OCFS2_INODE_SYSTEM_FILE));
1013
823 clusters_to_add = ocfs2_clusters_for_bytes(inode->i_sb, new_i_size); 1014 clusters_to_add = ocfs2_clusters_for_bytes(inode->i_sb, new_i_size);
824 if (clusters_to_add < oi->ip_clusters) 1015 if (clusters_to_add < oi->ip_clusters)
825 clusters_to_add = 0; 1016 clusters_to_add = 0;
@@ -840,7 +1031,7 @@ int ocfs2_extend_no_holes(struct inode *inode, u64 new_i_size, u64 zero_to)
840 * still need to zero the area between the old i_size and the 1031 * still need to zero the area between the old i_size and the
841 * new i_size. 1032 * new i_size.
842 */ 1033 */
843 ret = ocfs2_zero_extend(inode, zero_to); 1034 ret = ocfs2_zero_extend(inode, di_bh, zero_to);
844 if (ret < 0) 1035 if (ret < 0)
845 mlog_errno(ret); 1036 mlog_errno(ret);
846 1037
@@ -862,27 +1053,15 @@ static int ocfs2_extend_file(struct inode *inode,
862 goto out; 1053 goto out;
863 1054
864 if (i_size_read(inode) == new_i_size) 1055 if (i_size_read(inode) == new_i_size)
865 goto out; 1056 goto out;
866 BUG_ON(new_i_size < i_size_read(inode)); 1057 BUG_ON(new_i_size < i_size_read(inode));
867 1058
868 /* 1059 /*
869 * Fall through for converting inline data, even if the fs
870 * supports sparse files.
871 *
872 * The check for inline data here is legal - nobody can add
873 * the feature since we have i_mutex. We must check it again
874 * after acquiring ip_alloc_sem though, as paths like mmap
875 * might have raced us to converting the inode to extents.
876 */
877 if (!(oi->ip_dyn_features & OCFS2_INLINE_DATA_FL)
878 && ocfs2_sparse_alloc(OCFS2_SB(inode->i_sb)))
879 goto out_update_size;
880
881 /*
882 * The alloc sem blocks people in read/write from reading our 1060 * The alloc sem blocks people in read/write from reading our
883 * allocation until we're done changing it. We depend on 1061 * allocation until we're done changing it. We depend on
884 * i_mutex to block other extend/truncate calls while we're 1062 * i_mutex to block other extend/truncate calls while we're
885 * here. 1063 * here. We even have to hold it for sparse files because there
1064 * might be some tail zeroing.
886 */ 1065 */
887 down_write(&oi->ip_alloc_sem); 1066 down_write(&oi->ip_alloc_sem);
888 1067
@@ -899,14 +1078,16 @@ static int ocfs2_extend_file(struct inode *inode,
899 ret = ocfs2_convert_inline_data_to_extents(inode, di_bh); 1078 ret = ocfs2_convert_inline_data_to_extents(inode, di_bh);
900 if (ret) { 1079 if (ret) {
901 up_write(&oi->ip_alloc_sem); 1080 up_write(&oi->ip_alloc_sem);
902
903 mlog_errno(ret); 1081 mlog_errno(ret);
904 goto out; 1082 goto out;
905 } 1083 }
906 } 1084 }
907 1085
908 if (!ocfs2_sparse_alloc(OCFS2_SB(inode->i_sb))) 1086 if (ocfs2_sparse_alloc(OCFS2_SB(inode->i_sb)))
909 ret = ocfs2_extend_no_holes(inode, new_i_size, new_i_size); 1087 ret = ocfs2_zero_extend(inode, di_bh, new_i_size);
1088 else
1089 ret = ocfs2_extend_no_holes(inode, di_bh, new_i_size,
1090 new_i_size);
910 1091
911 up_write(&oi->ip_alloc_sem); 1092 up_write(&oi->ip_alloc_sem);
912 1093
diff --git a/fs/ocfs2/file.h b/fs/ocfs2/file.h
index d66cf4f7c70e..97bf761c9e7c 100644
--- a/fs/ocfs2/file.h
+++ b/fs/ocfs2/file.h
@@ -54,8 +54,10 @@ int ocfs2_add_inode_data(struct ocfs2_super *osb,
54int ocfs2_simple_size_update(struct inode *inode, 54int ocfs2_simple_size_update(struct inode *inode,
55 struct buffer_head *di_bh, 55 struct buffer_head *di_bh,
56 u64 new_i_size); 56 u64 new_i_size);
57int ocfs2_extend_no_holes(struct inode *inode, u64 new_i_size, 57int ocfs2_extend_no_holes(struct inode *inode, struct buffer_head *di_bh,
58 u64 zero_to); 58 u64 new_i_size, u64 zero_to);
59int ocfs2_zero_extend(struct inode *inode, struct buffer_head *di_bh,
60 loff_t zero_to);
59int ocfs2_setattr(struct dentry *dentry, struct iattr *attr); 61int ocfs2_setattr(struct dentry *dentry, struct iattr *attr);
60int ocfs2_getattr(struct vfsmount *mnt, struct dentry *dentry, 62int ocfs2_getattr(struct vfsmount *mnt, struct dentry *dentry,
61 struct kstat *stat); 63 struct kstat *stat);
diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
index 47878cf16418..625de9d7088c 100644
--- a/fs/ocfs2/journal.c
+++ b/fs/ocfs2/journal.c
@@ -472,7 +472,7 @@ static inline struct ocfs2_triggers *to_ocfs2_trigger(struct jbd2_buffer_trigger
472 return container_of(triggers, struct ocfs2_triggers, ot_triggers); 472 return container_of(triggers, struct ocfs2_triggers, ot_triggers);
473} 473}
474 474
475static void ocfs2_commit_trigger(struct jbd2_buffer_trigger_type *triggers, 475static void ocfs2_frozen_trigger(struct jbd2_buffer_trigger_type *triggers,
476 struct buffer_head *bh, 476 struct buffer_head *bh,
477 void *data, size_t size) 477 void *data, size_t size)
478{ 478{
@@ -491,7 +491,7 @@ static void ocfs2_commit_trigger(struct jbd2_buffer_trigger_type *triggers,
491 * Quota blocks have their own trigger because the struct ocfs2_block_check 491 * Quota blocks have their own trigger because the struct ocfs2_block_check
492 * offset depends on the blocksize. 492 * offset depends on the blocksize.
493 */ 493 */
494static void ocfs2_dq_commit_trigger(struct jbd2_buffer_trigger_type *triggers, 494static void ocfs2_dq_frozen_trigger(struct jbd2_buffer_trigger_type *triggers,
495 struct buffer_head *bh, 495 struct buffer_head *bh,
496 void *data, size_t size) 496 void *data, size_t size)
497{ 497{
@@ -511,7 +511,7 @@ static void ocfs2_dq_commit_trigger(struct jbd2_buffer_trigger_type *triggers,
511 * Directory blocks also have their own trigger because the 511 * Directory blocks also have their own trigger because the
512 * struct ocfs2_block_check offset depends on the blocksize. 512 * struct ocfs2_block_check offset depends on the blocksize.
513 */ 513 */
514static void ocfs2_db_commit_trigger(struct jbd2_buffer_trigger_type *triggers, 514static void ocfs2_db_frozen_trigger(struct jbd2_buffer_trigger_type *triggers,
515 struct buffer_head *bh, 515 struct buffer_head *bh,
516 void *data, size_t size) 516 void *data, size_t size)
517{ 517{
@@ -544,7 +544,7 @@ static void ocfs2_abort_trigger(struct jbd2_buffer_trigger_type *triggers,
544 544
545static struct ocfs2_triggers di_triggers = { 545static struct ocfs2_triggers di_triggers = {
546 .ot_triggers = { 546 .ot_triggers = {
547 .t_commit = ocfs2_commit_trigger, 547 .t_frozen = ocfs2_frozen_trigger,
548 .t_abort = ocfs2_abort_trigger, 548 .t_abort = ocfs2_abort_trigger,
549 }, 549 },
550 .ot_offset = offsetof(struct ocfs2_dinode, i_check), 550 .ot_offset = offsetof(struct ocfs2_dinode, i_check),
@@ -552,7 +552,7 @@ static struct ocfs2_triggers di_triggers = {
552 552
553static struct ocfs2_triggers eb_triggers = { 553static struct ocfs2_triggers eb_triggers = {
554 .ot_triggers = { 554 .ot_triggers = {
555 .t_commit = ocfs2_commit_trigger, 555 .t_frozen = ocfs2_frozen_trigger,
556 .t_abort = ocfs2_abort_trigger, 556 .t_abort = ocfs2_abort_trigger,
557 }, 557 },
558 .ot_offset = offsetof(struct ocfs2_extent_block, h_check), 558 .ot_offset = offsetof(struct ocfs2_extent_block, h_check),
@@ -560,7 +560,7 @@ static struct ocfs2_triggers eb_triggers = {
560 560
561static struct ocfs2_triggers rb_triggers = { 561static struct ocfs2_triggers rb_triggers = {
562 .ot_triggers = { 562 .ot_triggers = {
563 .t_commit = ocfs2_commit_trigger, 563 .t_frozen = ocfs2_frozen_trigger,
564 .t_abort = ocfs2_abort_trigger, 564 .t_abort = ocfs2_abort_trigger,
565 }, 565 },
566 .ot_offset = offsetof(struct ocfs2_refcount_block, rf_check), 566 .ot_offset = offsetof(struct ocfs2_refcount_block, rf_check),
@@ -568,7 +568,7 @@ static struct ocfs2_triggers rb_triggers = {
568 568
569static struct ocfs2_triggers gd_triggers = { 569static struct ocfs2_triggers gd_triggers = {
570 .ot_triggers = { 570 .ot_triggers = {
571 .t_commit = ocfs2_commit_trigger, 571 .t_frozen = ocfs2_frozen_trigger,
572 .t_abort = ocfs2_abort_trigger, 572 .t_abort = ocfs2_abort_trigger,
573 }, 573 },
574 .ot_offset = offsetof(struct ocfs2_group_desc, bg_check), 574 .ot_offset = offsetof(struct ocfs2_group_desc, bg_check),
@@ -576,14 +576,14 @@ static struct ocfs2_triggers gd_triggers = {
576 576
577static struct ocfs2_triggers db_triggers = { 577static struct ocfs2_triggers db_triggers = {
578 .ot_triggers = { 578 .ot_triggers = {
579 .t_commit = ocfs2_db_commit_trigger, 579 .t_frozen = ocfs2_db_frozen_trigger,
580 .t_abort = ocfs2_abort_trigger, 580 .t_abort = ocfs2_abort_trigger,
581 }, 581 },
582}; 582};
583 583
584static struct ocfs2_triggers xb_triggers = { 584static struct ocfs2_triggers xb_triggers = {
585 .ot_triggers = { 585 .ot_triggers = {
586 .t_commit = ocfs2_commit_trigger, 586 .t_frozen = ocfs2_frozen_trigger,
587 .t_abort = ocfs2_abort_trigger, 587 .t_abort = ocfs2_abort_trigger,
588 }, 588 },
589 .ot_offset = offsetof(struct ocfs2_xattr_block, xb_check), 589 .ot_offset = offsetof(struct ocfs2_xattr_block, xb_check),
@@ -591,14 +591,14 @@ static struct ocfs2_triggers xb_triggers = {
591 591
592static struct ocfs2_triggers dq_triggers = { 592static struct ocfs2_triggers dq_triggers = {
593 .ot_triggers = { 593 .ot_triggers = {
594 .t_commit = ocfs2_dq_commit_trigger, 594 .t_frozen = ocfs2_dq_frozen_trigger,
595 .t_abort = ocfs2_abort_trigger, 595 .t_abort = ocfs2_abort_trigger,
596 }, 596 },
597}; 597};
598 598
599static struct ocfs2_triggers dr_triggers = { 599static struct ocfs2_triggers dr_triggers = {
600 .ot_triggers = { 600 .ot_triggers = {
601 .t_commit = ocfs2_commit_trigger, 601 .t_frozen = ocfs2_frozen_trigger,
602 .t_abort = ocfs2_abort_trigger, 602 .t_abort = ocfs2_abort_trigger,
603 }, 603 },
604 .ot_offset = offsetof(struct ocfs2_dx_root_block, dr_check), 604 .ot_offset = offsetof(struct ocfs2_dx_root_block, dr_check),
@@ -606,7 +606,7 @@ static struct ocfs2_triggers dr_triggers = {
606 606
607static struct ocfs2_triggers dl_triggers = { 607static struct ocfs2_triggers dl_triggers = {
608 .ot_triggers = { 608 .ot_triggers = {
609 .t_commit = ocfs2_commit_trigger, 609 .t_frozen = ocfs2_frozen_trigger,
610 .t_abort = ocfs2_abort_trigger, 610 .t_abort = ocfs2_abort_trigger,
611 }, 611 },
612 .ot_offset = offsetof(struct ocfs2_dx_leaf, dl_check), 612 .ot_offset = offsetof(struct ocfs2_dx_leaf, dl_check),
@@ -1936,7 +1936,7 @@ void ocfs2_orphan_scan_work(struct work_struct *work)
1936 mutex_lock(&os->os_lock); 1936 mutex_lock(&os->os_lock);
1937 ocfs2_queue_orphan_scan(osb); 1937 ocfs2_queue_orphan_scan(osb);
1938 if (atomic_read(&os->os_state) == ORPHAN_SCAN_ACTIVE) 1938 if (atomic_read(&os->os_state) == ORPHAN_SCAN_ACTIVE)
1939 schedule_delayed_work(&os->os_orphan_scan_work, 1939 queue_delayed_work(ocfs2_wq, &os->os_orphan_scan_work,
1940 ocfs2_orphan_scan_timeout()); 1940 ocfs2_orphan_scan_timeout());
1941 mutex_unlock(&os->os_lock); 1941 mutex_unlock(&os->os_lock);
1942} 1942}
@@ -1976,8 +1976,8 @@ void ocfs2_orphan_scan_start(struct ocfs2_super *osb)
1976 atomic_set(&os->os_state, ORPHAN_SCAN_INACTIVE); 1976 atomic_set(&os->os_state, ORPHAN_SCAN_INACTIVE);
1977 else { 1977 else {
1978 atomic_set(&os->os_state, ORPHAN_SCAN_ACTIVE); 1978 atomic_set(&os->os_state, ORPHAN_SCAN_ACTIVE);
1979 schedule_delayed_work(&os->os_orphan_scan_work, 1979 queue_delayed_work(ocfs2_wq, &os->os_orphan_scan_work,
1980 ocfs2_orphan_scan_timeout()); 1980 ocfs2_orphan_scan_timeout());
1981 } 1981 }
1982} 1982}
1983 1983
diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
index 3d7419682dc0..ec6adbf8f551 100644
--- a/fs/ocfs2/localalloc.c
+++ b/fs/ocfs2/localalloc.c
@@ -118,6 +118,7 @@ unsigned int ocfs2_la_default_mb(struct ocfs2_super *osb)
118{ 118{
119 unsigned int la_mb; 119 unsigned int la_mb;
120 unsigned int gd_mb; 120 unsigned int gd_mb;
121 unsigned int la_max_mb;
121 unsigned int megs_per_slot; 122 unsigned int megs_per_slot;
122 struct super_block *sb = osb->sb; 123 struct super_block *sb = osb->sb;
123 124
@@ -182,6 +183,12 @@ unsigned int ocfs2_la_default_mb(struct ocfs2_super *osb)
182 if (megs_per_slot < la_mb) 183 if (megs_per_slot < la_mb)
183 la_mb = megs_per_slot; 184 la_mb = megs_per_slot;
184 185
186 /* We can't store more bits than we can in a block. */
187 la_max_mb = ocfs2_clusters_to_megabytes(osb->sb,
188 ocfs2_local_alloc_size(sb) * 8);
189 if (la_mb > la_max_mb)
190 la_mb = la_max_mb;
191
185 return la_mb; 192 return la_mb;
186} 193}
187 194
diff --git a/fs/ocfs2/quota_global.c b/fs/ocfs2/quota_global.c
index 2bb35fe00511..4607923eb24c 100644
--- a/fs/ocfs2/quota_global.c
+++ b/fs/ocfs2/quota_global.c
@@ -775,7 +775,7 @@ static int ocfs2_acquire_dquot(struct dquot *dquot)
775 * locking allocators ranks above a transaction start 775 * locking allocators ranks above a transaction start
776 */ 776 */
777 WARN_ON(journal_current_handle()); 777 WARN_ON(journal_current_handle());
778 status = ocfs2_extend_no_holes(gqinode, 778 status = ocfs2_extend_no_holes(gqinode, NULL,
779 gqinode->i_size + (need_alloc << sb->s_blocksize_bits), 779 gqinode->i_size + (need_alloc << sb->s_blocksize_bits),
780 gqinode->i_size); 780 gqinode->i_size);
781 if (status < 0) 781 if (status < 0)
diff --git a/fs/ocfs2/quota_local.c b/fs/ocfs2/quota_local.c
index 8bd70d4d184d..dc78764ccc4c 100644
--- a/fs/ocfs2/quota_local.c
+++ b/fs/ocfs2/quota_local.c
@@ -971,7 +971,7 @@ static struct ocfs2_quota_chunk *ocfs2_local_quota_add_chunk(
971 u64 p_blkno; 971 u64 p_blkno;
972 972
973 /* We are protected by dqio_sem so no locking needed */ 973 /* We are protected by dqio_sem so no locking needed */
974 status = ocfs2_extend_no_holes(lqinode, 974 status = ocfs2_extend_no_holes(lqinode, NULL,
975 lqinode->i_size + 2 * sb->s_blocksize, 975 lqinode->i_size + 2 * sb->s_blocksize,
976 lqinode->i_size); 976 lqinode->i_size);
977 if (status < 0) { 977 if (status < 0) {
@@ -1114,7 +1114,7 @@ static struct ocfs2_quota_chunk *ocfs2_extend_local_quota_file(
1114 return ocfs2_local_quota_add_chunk(sb, type, offset); 1114 return ocfs2_local_quota_add_chunk(sb, type, offset);
1115 1115
1116 /* We are protected by dqio_sem so no locking needed */ 1116 /* We are protected by dqio_sem so no locking needed */
1117 status = ocfs2_extend_no_holes(lqinode, 1117 status = ocfs2_extend_no_holes(lqinode, NULL,
1118 lqinode->i_size + sb->s_blocksize, 1118 lqinode->i_size + sb->s_blocksize,
1119 lqinode->i_size); 1119 lqinode->i_size);
1120 if (status < 0) { 1120 if (status < 0) {
diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c
index 4793f36f6518..3ac5aa733e9c 100644
--- a/fs/ocfs2/refcounttree.c
+++ b/fs/ocfs2/refcounttree.c
@@ -2931,6 +2931,12 @@ static int ocfs2_duplicate_clusters_by_page(handle_t *handle,
2931 2931
2932 offset = ((loff_t)cpos) << OCFS2_SB(sb)->s_clustersize_bits; 2932 offset = ((loff_t)cpos) << OCFS2_SB(sb)->s_clustersize_bits;
2933 end = offset + (new_len << OCFS2_SB(sb)->s_clustersize_bits); 2933 end = offset + (new_len << OCFS2_SB(sb)->s_clustersize_bits);
2934 /*
2935 * We only duplicate pages until we reach the page contains i_size - 1.
2936 * So trim 'end' to i_size.
2937 */
2938 if (end > i_size_read(context->inode))
2939 end = i_size_read(context->inode);
2934 2940
2935 while (offset < end) { 2941 while (offset < end) {
2936 page_index = offset >> PAGE_CACHE_SHIFT; 2942 page_index = offset >> PAGE_CACHE_SHIFT;
@@ -4166,6 +4172,12 @@ static int __ocfs2_reflink(struct dentry *old_dentry,
4166 struct inode *inode = old_dentry->d_inode; 4172 struct inode *inode = old_dentry->d_inode;
4167 struct buffer_head *new_bh = NULL; 4173 struct buffer_head *new_bh = NULL;
4168 4174
4175 if (OCFS2_I(inode)->ip_flags & OCFS2_INODE_SYSTEM_FILE) {
4176 ret = -EINVAL;
4177 mlog_errno(ret);
4178 goto out;
4179 }
4180
4169 ret = filemap_fdatawrite(inode->i_mapping); 4181 ret = filemap_fdatawrite(inode->i_mapping);
4170 if (ret) { 4182 if (ret) {
4171 mlog_errno(ret); 4183 mlog_errno(ret);
diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
index f4c2a9eb8c4d..a8e6a95a353f 100644
--- a/fs/ocfs2/suballoc.c
+++ b/fs/ocfs2/suballoc.c
@@ -741,7 +741,7 @@ static int ocfs2_block_group_alloc(struct ocfs2_super *osb,
741 le16_to_cpu(bg->bg_free_bits_count)); 741 le16_to_cpu(bg->bg_free_bits_count));
742 le32_add_cpu(&cl->cl_recs[alloc_rec].c_total, 742 le32_add_cpu(&cl->cl_recs[alloc_rec].c_total,
743 le16_to_cpu(bg->bg_bits)); 743 le16_to_cpu(bg->bg_bits));
744 cl->cl_recs[alloc_rec].c_blkno = cpu_to_le64(bg->bg_blkno); 744 cl->cl_recs[alloc_rec].c_blkno = bg->bg_blkno;
745 if (le16_to_cpu(cl->cl_next_free_rec) < le16_to_cpu(cl->cl_count)) 745 if (le16_to_cpu(cl->cl_next_free_rec) < le16_to_cpu(cl->cl_count))
746 le16_add_cpu(&cl->cl_next_free_rec, 1); 746 le16_add_cpu(&cl->cl_next_free_rec, 1);
747 747
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
index e97b34842cfe..d03469f61801 100644
--- a/fs/ocfs2/xattr.c
+++ b/fs/ocfs2/xattr.c
@@ -709,7 +709,7 @@ static int ocfs2_xattr_extend_allocation(struct inode *inode,
709 struct ocfs2_xattr_value_buf *vb, 709 struct ocfs2_xattr_value_buf *vb,
710 struct ocfs2_xattr_set_ctxt *ctxt) 710 struct ocfs2_xattr_set_ctxt *ctxt)
711{ 711{
712 int status = 0; 712 int status = 0, credits;
713 handle_t *handle = ctxt->handle; 713 handle_t *handle = ctxt->handle;
714 enum ocfs2_alloc_restarted why; 714 enum ocfs2_alloc_restarted why;
715 u32 prev_clusters, logical_start = le32_to_cpu(vb->vb_xv->xr_clusters); 715 u32 prev_clusters, logical_start = le32_to_cpu(vb->vb_xv->xr_clusters);
@@ -719,38 +719,54 @@ static int ocfs2_xattr_extend_allocation(struct inode *inode,
719 719
720 ocfs2_init_xattr_value_extent_tree(&et, INODE_CACHE(inode), vb); 720 ocfs2_init_xattr_value_extent_tree(&et, INODE_CACHE(inode), vb);
721 721
722 status = vb->vb_access(handle, INODE_CACHE(inode), vb->vb_bh, 722 while (clusters_to_add) {
723 OCFS2_JOURNAL_ACCESS_WRITE); 723 status = vb->vb_access(handle, INODE_CACHE(inode), vb->vb_bh,
724 if (status < 0) { 724 OCFS2_JOURNAL_ACCESS_WRITE);
725 mlog_errno(status); 725 if (status < 0) {
726 goto leave; 726 mlog_errno(status);
727 } 727 break;
728 }
728 729
729 prev_clusters = le32_to_cpu(vb->vb_xv->xr_clusters); 730 prev_clusters = le32_to_cpu(vb->vb_xv->xr_clusters);
730 status = ocfs2_add_clusters_in_btree(handle, 731 status = ocfs2_add_clusters_in_btree(handle,
731 &et, 732 &et,
732 &logical_start, 733 &logical_start,
733 clusters_to_add, 734 clusters_to_add,
734 0, 735 0,
735 ctxt->data_ac, 736 ctxt->data_ac,
736 ctxt->meta_ac, 737 ctxt->meta_ac,
737 &why); 738 &why);
738 if (status < 0) { 739 if ((status < 0) && (status != -EAGAIN)) {
739 mlog_errno(status); 740 if (status != -ENOSPC)
740 goto leave; 741 mlog_errno(status);
741 } 742 break;
743 }
742 744
743 ocfs2_journal_dirty(handle, vb->vb_bh); 745 ocfs2_journal_dirty(handle, vb->vb_bh);
744 746
745 clusters_to_add -= le32_to_cpu(vb->vb_xv->xr_clusters) - prev_clusters; 747 clusters_to_add -= le32_to_cpu(vb->vb_xv->xr_clusters) -
748 prev_clusters;
746 749
747 /* 750 if (why != RESTART_NONE && clusters_to_add) {
748 * We should have already allocated enough space before the transaction, 751 /*
749 * so no need to restart. 752 * We can only fail in case the alloc file doesn't give
750 */ 753 * up enough clusters.
751 BUG_ON(why != RESTART_NONE || clusters_to_add); 754 */
752 755 BUG_ON(why == RESTART_META);
753leave: 756
757 mlog(0, "restarting xattr value extension for %u"
758 " clusters,.\n", clusters_to_add);
759 credits = ocfs2_calc_extend_credits(inode->i_sb,
760 &vb->vb_xv->xr_list,
761 clusters_to_add);
762 status = ocfs2_extend_trans(handle, credits);
763 if (status < 0) {
764 status = -ENOMEM;
765 mlog_errno(status);
766 break;
767 }
768 }
769 }
754 770
755 return status; 771 return status;
756} 772}
@@ -6788,16 +6804,15 @@ out:
6788 return ret; 6804 return ret;
6789} 6805}
6790 6806
6791static int ocfs2_reflink_xattr_buckets(handle_t *handle, 6807static int ocfs2_reflink_xattr_bucket(handle_t *handle,
6792 u64 blkno, u64 new_blkno, u32 clusters, 6808 u64 blkno, u64 new_blkno, u32 clusters,
6809 u32 *cpos, int num_buckets,
6793 struct ocfs2_alloc_context *meta_ac, 6810 struct ocfs2_alloc_context *meta_ac,
6794 struct ocfs2_alloc_context *data_ac, 6811 struct ocfs2_alloc_context *data_ac,
6795 struct ocfs2_reflink_xattr_tree_args *args) 6812 struct ocfs2_reflink_xattr_tree_args *args)
6796{ 6813{
6797 int i, j, ret = 0; 6814 int i, j, ret = 0;
6798 struct super_block *sb = args->reflink->old_inode->i_sb; 6815 struct super_block *sb = args->reflink->old_inode->i_sb;
6799 u32 bpc = ocfs2_xattr_buckets_per_cluster(OCFS2_SB(sb));
6800 u32 num_buckets = clusters * bpc;
6801 int bpb = args->old_bucket->bu_blocks; 6816 int bpb = args->old_bucket->bu_blocks;
6802 struct ocfs2_xattr_value_buf vb = { 6817 struct ocfs2_xattr_value_buf vb = {
6803 .vb_access = ocfs2_journal_access, 6818 .vb_access = ocfs2_journal_access,
@@ -6816,14 +6831,6 @@ static int ocfs2_reflink_xattr_buckets(handle_t *handle,
6816 break; 6831 break;
6817 } 6832 }
6818 6833
6819 /*
6820 * The real bucket num in this series of blocks is stored
6821 * in the 1st bucket.
6822 */
6823 if (i == 0)
6824 num_buckets = le16_to_cpu(
6825 bucket_xh(args->old_bucket)->xh_num_buckets);
6826
6827 ret = ocfs2_xattr_bucket_journal_access(handle, 6834 ret = ocfs2_xattr_bucket_journal_access(handle,
6828 args->new_bucket, 6835 args->new_bucket,
6829 OCFS2_JOURNAL_ACCESS_CREATE); 6836 OCFS2_JOURNAL_ACCESS_CREATE);
@@ -6837,6 +6844,18 @@ static int ocfs2_reflink_xattr_buckets(handle_t *handle,
6837 bucket_block(args->old_bucket, j), 6844 bucket_block(args->old_bucket, j),
6838 sb->s_blocksize); 6845 sb->s_blocksize);
6839 6846
6847 /*
6848 * Record the start cpos so that we can use it to initialize
6849 * our xattr tree we also set the xh_num_bucket for the new
6850 * bucket.
6851 */
6852 if (i == 0) {
6853 *cpos = le32_to_cpu(bucket_xh(args->new_bucket)->
6854 xh_entries[0].xe_name_hash);
6855 bucket_xh(args->new_bucket)->xh_num_buckets =
6856 cpu_to_le16(num_buckets);
6857 }
6858
6840 ocfs2_xattr_bucket_journal_dirty(handle, args->new_bucket); 6859 ocfs2_xattr_bucket_journal_dirty(handle, args->new_bucket);
6841 6860
6842 ret = ocfs2_reflink_xattr_header(handle, args->reflink, 6861 ret = ocfs2_reflink_xattr_header(handle, args->reflink,
@@ -6866,6 +6885,7 @@ static int ocfs2_reflink_xattr_buckets(handle_t *handle,
6866 } 6885 }
6867 6886
6868 ocfs2_xattr_bucket_journal_dirty(handle, args->new_bucket); 6887 ocfs2_xattr_bucket_journal_dirty(handle, args->new_bucket);
6888
6869 ocfs2_xattr_bucket_relse(args->old_bucket); 6889 ocfs2_xattr_bucket_relse(args->old_bucket);
6870 ocfs2_xattr_bucket_relse(args->new_bucket); 6890 ocfs2_xattr_bucket_relse(args->new_bucket);
6871 } 6891 }
@@ -6874,6 +6894,75 @@ static int ocfs2_reflink_xattr_buckets(handle_t *handle,
6874 ocfs2_xattr_bucket_relse(args->new_bucket); 6894 ocfs2_xattr_bucket_relse(args->new_bucket);
6875 return ret; 6895 return ret;
6876} 6896}
6897
6898static int ocfs2_reflink_xattr_buckets(handle_t *handle,
6899 struct inode *inode,
6900 struct ocfs2_reflink_xattr_tree_args *args,
6901 struct ocfs2_extent_tree *et,
6902 struct ocfs2_alloc_context *meta_ac,
6903 struct ocfs2_alloc_context *data_ac,
6904 u64 blkno, u32 cpos, u32 len)
6905{
6906 int ret, first_inserted = 0;
6907 u32 p_cluster, num_clusters, reflink_cpos = 0;
6908 u64 new_blkno;
6909 unsigned int num_buckets, reflink_buckets;
6910 unsigned int bpc =
6911 ocfs2_xattr_buckets_per_cluster(OCFS2_SB(inode->i_sb));
6912
6913 ret = ocfs2_read_xattr_bucket(args->old_bucket, blkno);
6914 if (ret) {
6915 mlog_errno(ret);
6916 goto out;
6917 }
6918 num_buckets = le16_to_cpu(bucket_xh(args->old_bucket)->xh_num_buckets);
6919 ocfs2_xattr_bucket_relse(args->old_bucket);
6920
6921 while (len && num_buckets) {
6922 ret = ocfs2_claim_clusters(handle, data_ac,
6923 1, &p_cluster, &num_clusters);
6924 if (ret) {
6925 mlog_errno(ret);
6926 goto out;
6927 }
6928
6929 new_blkno = ocfs2_clusters_to_blocks(inode->i_sb, p_cluster);
6930 reflink_buckets = min(num_buckets, bpc * num_clusters);
6931
6932 ret = ocfs2_reflink_xattr_bucket(handle, blkno,
6933 new_blkno, num_clusters,
6934 &reflink_cpos, reflink_buckets,
6935 meta_ac, data_ac, args);
6936 if (ret) {
6937 mlog_errno(ret);
6938 goto out;
6939 }
6940
6941 /*
6942 * For the 1st allocated cluster, we make it use the same cpos
6943 * so that the xattr tree looks the same as the original one
6944 * in the most case.
6945 */
6946 if (!first_inserted) {
6947 reflink_cpos = cpos;
6948 first_inserted = 1;
6949 }
6950 ret = ocfs2_insert_extent(handle, et, reflink_cpos, new_blkno,
6951 num_clusters, 0, meta_ac);
6952 if (ret)
6953 mlog_errno(ret);
6954
6955 mlog(0, "insert new xattr extent rec start %llu len %u to %u\n",
6956 (unsigned long long)new_blkno, num_clusters, reflink_cpos);
6957
6958 len -= num_clusters;
6959 blkno += ocfs2_clusters_to_blocks(inode->i_sb, num_clusters);
6960 num_buckets -= reflink_buckets;
6961 }
6962out:
6963 return ret;
6964}
6965
6877/* 6966/*
6878 * Create the same xattr extent record in the new inode's xattr tree. 6967 * Create the same xattr extent record in the new inode's xattr tree.
6879 */ 6968 */
@@ -6885,8 +6974,6 @@ static int ocfs2_reflink_xattr_rec(struct inode *inode,
6885 void *para) 6974 void *para)
6886{ 6975{
6887 int ret, credits = 0; 6976 int ret, credits = 0;
6888 u32 p_cluster, num_clusters;
6889 u64 new_blkno;
6890 handle_t *handle; 6977 handle_t *handle;
6891 struct ocfs2_reflink_xattr_tree_args *args = 6978 struct ocfs2_reflink_xattr_tree_args *args =
6892 (struct ocfs2_reflink_xattr_tree_args *)para; 6979 (struct ocfs2_reflink_xattr_tree_args *)para;
@@ -6895,6 +6982,9 @@ static int ocfs2_reflink_xattr_rec(struct inode *inode,
6895 struct ocfs2_alloc_context *data_ac = NULL; 6982 struct ocfs2_alloc_context *data_ac = NULL;
6896 struct ocfs2_extent_tree et; 6983 struct ocfs2_extent_tree et;
6897 6984
6985 mlog(0, "reflink xattr buckets %llu len %u\n",
6986 (unsigned long long)blkno, len);
6987
6898 ocfs2_init_xattr_tree_extent_tree(&et, 6988 ocfs2_init_xattr_tree_extent_tree(&et,
6899 INODE_CACHE(args->reflink->new_inode), 6989 INODE_CACHE(args->reflink->new_inode),
6900 args->new_blk_bh); 6990 args->new_blk_bh);
@@ -6914,32 +7004,12 @@ static int ocfs2_reflink_xattr_rec(struct inode *inode,
6914 goto out; 7004 goto out;
6915 } 7005 }
6916 7006
6917 ret = ocfs2_claim_clusters(handle, data_ac, 7007 ret = ocfs2_reflink_xattr_buckets(handle, inode, args, &et,
6918 len, &p_cluster, &num_clusters); 7008 meta_ac, data_ac,
6919 if (ret) { 7009 blkno, cpos, len);
6920 mlog_errno(ret);
6921 goto out_commit;
6922 }
6923
6924 new_blkno = ocfs2_clusters_to_blocks(osb->sb, p_cluster);
6925
6926 mlog(0, "reflink xattr buckets %llu to %llu, len %u\n",
6927 (unsigned long long)blkno, (unsigned long long)new_blkno, len);
6928 ret = ocfs2_reflink_xattr_buckets(handle, blkno, new_blkno, len,
6929 meta_ac, data_ac, args);
6930 if (ret) {
6931 mlog_errno(ret);
6932 goto out_commit;
6933 }
6934
6935 mlog(0, "insert new xattr extent rec start %llu len %u to %u\n",
6936 (unsigned long long)new_blkno, len, cpos);
6937 ret = ocfs2_insert_extent(handle, &et, cpos, new_blkno,
6938 len, 0, meta_ac);
6939 if (ret) 7010 if (ret)
6940 mlog_errno(ret); 7011 mlog_errno(ret);
6941 7012
6942out_commit:
6943 ocfs2_commit_trans(osb, handle); 7013 ocfs2_commit_trans(osb, handle);
6944 7014
6945out: 7015out:
diff --git a/fs/partitions/ibm.c b/fs/partitions/ibm.c
index 3e73de5967ff..fc8497643fd0 100644
--- a/fs/partitions/ibm.c
+++ b/fs/partitions/ibm.c
@@ -74,6 +74,7 @@ int ibm_partition(struct parsed_partitions *state)
74 } *label; 74 } *label;
75 unsigned char *data; 75 unsigned char *data;
76 Sector sect; 76 Sector sect;
77 sector_t labelsect;
77 78
78 res = 0; 79 res = 0;
79 blocksize = bdev_logical_block_size(bdev); 80 blocksize = bdev_logical_block_size(bdev);
@@ -98,10 +99,19 @@ int ibm_partition(struct parsed_partitions *state)
98 goto out_freeall; 99 goto out_freeall;
99 100
100 /* 101 /*
102 * Special case for FBA disks: label sector does not depend on
103 * blocksize.
104 */
105 if ((info->cu_type == 0x6310 && info->dev_type == 0x9336) ||
106 (info->cu_type == 0x3880 && info->dev_type == 0x3370))
107 labelsect = info->label_block;
108 else
109 labelsect = info->label_block * (blocksize >> 9);
110
111 /*
101 * Get volume label, extract name and type. 112 * Get volume label, extract name and type.
102 */ 113 */
103 data = read_part_sector(state, info->label_block*(blocksize/512), 114 data = read_part_sector(state, labelsect, &sect);
104 &sect);
105 if (data == NULL) 115 if (data == NULL)
106 goto out_readerr; 116 goto out_readerr;
107 117
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index 12c233da1b6b..437d2ca2de97 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -676,7 +676,7 @@ static void prune_dqcache(int count)
676 * This is called from kswapd when we think we need some 676 * This is called from kswapd when we think we need some
677 * more memory 677 * more memory
678 */ 678 */
679static int shrink_dqcache_memory(int nr, gfp_t gfp_mask) 679static int shrink_dqcache_memory(struct shrinker *shrink, int nr, gfp_t gfp_mask)
680{ 680{
681 if (nr) { 681 if (nr) {
682 spin_lock(&dq_list_lock); 682 spin_lock(&dq_list_lock);
diff --git a/fs/ubifs/shrinker.c b/fs/ubifs/shrinker.c
index 02feb59cefca..0b201114a5ad 100644
--- a/fs/ubifs/shrinker.c
+++ b/fs/ubifs/shrinker.c
@@ -277,7 +277,7 @@ static int kick_a_thread(void)
277 return 0; 277 return 0;
278} 278}
279 279
280int ubifs_shrinker(int nr, gfp_t gfp_mask) 280int ubifs_shrinker(struct shrinker *shrink, int nr, gfp_t gfp_mask)
281{ 281{
282 int freed, contention = 0; 282 int freed, contention = 0;
283 long clean_zn_cnt = atomic_long_read(&ubifs_clean_zn_cnt); 283 long clean_zn_cnt = atomic_long_read(&ubifs_clean_zn_cnt);
diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h
index 2eef553d50c8..04310878f449 100644
--- a/fs/ubifs/ubifs.h
+++ b/fs/ubifs/ubifs.h
@@ -1575,7 +1575,7 @@ int ubifs_tnc_start_commit(struct ubifs_info *c, struct ubifs_zbranch *zroot);
1575int ubifs_tnc_end_commit(struct ubifs_info *c); 1575int ubifs_tnc_end_commit(struct ubifs_info *c);
1576 1576
1577/* shrinker.c */ 1577/* shrinker.c */
1578int ubifs_shrinker(int nr_to_scan, gfp_t gfp_mask); 1578int ubifs_shrinker(struct shrinker *shrink, int nr_to_scan, gfp_t gfp_mask);
1579 1579
1580/* commit.c */ 1580/* commit.c */
1581int ubifs_bg_thread(void *info); 1581int ubifs_bg_thread(void *info);
diff --git a/fs/xfs/linux-2.6/xfs_buf.c b/fs/xfs/linux-2.6/xfs_buf.c
index 649ade8ef598..2ee3f7a60163 100644
--- a/fs/xfs/linux-2.6/xfs_buf.c
+++ b/fs/xfs/linux-2.6/xfs_buf.c
@@ -45,7 +45,7 @@
45 45
46static kmem_zone_t *xfs_buf_zone; 46static kmem_zone_t *xfs_buf_zone;
47STATIC int xfsbufd(void *); 47STATIC int xfsbufd(void *);
48STATIC int xfsbufd_wakeup(int, gfp_t); 48STATIC int xfsbufd_wakeup(struct shrinker *, int, gfp_t);
49STATIC void xfs_buf_delwri_queue(xfs_buf_t *, int); 49STATIC void xfs_buf_delwri_queue(xfs_buf_t *, int);
50static struct shrinker xfs_buf_shake = { 50static struct shrinker xfs_buf_shake = {
51 .shrink = xfsbufd_wakeup, 51 .shrink = xfsbufd_wakeup,
@@ -340,7 +340,7 @@ _xfs_buf_lookup_pages(
340 __func__, gfp_mask); 340 __func__, gfp_mask);
341 341
342 XFS_STATS_INC(xb_page_retries); 342 XFS_STATS_INC(xb_page_retries);
343 xfsbufd_wakeup(0, gfp_mask); 343 xfsbufd_wakeup(NULL, 0, gfp_mask);
344 congestion_wait(BLK_RW_ASYNC, HZ/50); 344 congestion_wait(BLK_RW_ASYNC, HZ/50);
345 goto retry; 345 goto retry;
346 } 346 }
@@ -1762,6 +1762,7 @@ xfs_buf_runall_queues(
1762 1762
1763STATIC int 1763STATIC int
1764xfsbufd_wakeup( 1764xfsbufd_wakeup(
1765 struct shrinker *shrink,
1765 int priority, 1766 int priority,
1766 gfp_t mask) 1767 gfp_t mask)
1767{ 1768{
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c
index f2d1718c9165..80938c736c27 100644
--- a/fs/xfs/linux-2.6/xfs_super.c
+++ b/fs/xfs/linux-2.6/xfs_super.c
@@ -1883,7 +1883,6 @@ init_xfs_fs(void)
1883 goto out_cleanup_procfs; 1883 goto out_cleanup_procfs;
1884 1884
1885 vfs_initquota(); 1885 vfs_initquota();
1886 xfs_inode_shrinker_init();
1887 1886
1888 error = register_filesystem(&xfs_fs_type); 1887 error = register_filesystem(&xfs_fs_type);
1889 if (error) 1888 if (error)
@@ -1911,7 +1910,6 @@ exit_xfs_fs(void)
1911{ 1910{
1912 vfs_exitquota(); 1911 vfs_exitquota();
1913 unregister_filesystem(&xfs_fs_type); 1912 unregister_filesystem(&xfs_fs_type);
1914 xfs_inode_shrinker_destroy();
1915 xfs_sysctl_unregister(); 1913 xfs_sysctl_unregister();
1916 xfs_cleanup_procfs(); 1914 xfs_cleanup_procfs();
1917 xfs_buf_terminate(); 1915 xfs_buf_terminate();
diff --git a/fs/xfs/linux-2.6/xfs_sync.c b/fs/xfs/linux-2.6/xfs_sync.c
index ef7f0218bccb..a51a07c3a70c 100644
--- a/fs/xfs/linux-2.6/xfs_sync.c
+++ b/fs/xfs/linux-2.6/xfs_sync.c
@@ -144,6 +144,41 @@ restart:
144 return last_error; 144 return last_error;
145} 145}
146 146
147/*
148 * Select the next per-ag structure to iterate during the walk. The reclaim
149 * walk is optimised only to walk AGs with reclaimable inodes in them.
150 */
151static struct xfs_perag *
152xfs_inode_ag_iter_next_pag(
153 struct xfs_mount *mp,
154 xfs_agnumber_t *first,
155 int tag)
156{
157 struct xfs_perag *pag = NULL;
158
159 if (tag == XFS_ICI_RECLAIM_TAG) {
160 int found;
161 int ref;
162
163 spin_lock(&mp->m_perag_lock);
164 found = radix_tree_gang_lookup_tag(&mp->m_perag_tree,
165 (void **)&pag, *first, 1, tag);
166 if (found <= 0) {
167 spin_unlock(&mp->m_perag_lock);
168 return NULL;
169 }
170 *first = pag->pag_agno + 1;
171 /* open coded pag reference increment */
172 ref = atomic_inc_return(&pag->pag_ref);
173 spin_unlock(&mp->m_perag_lock);
174 trace_xfs_perag_get_reclaim(mp, pag->pag_agno, ref, _RET_IP_);
175 } else {
176 pag = xfs_perag_get(mp, *first);
177 (*first)++;
178 }
179 return pag;
180}
181
147int 182int
148xfs_inode_ag_iterator( 183xfs_inode_ag_iterator(
149 struct xfs_mount *mp, 184 struct xfs_mount *mp,
@@ -154,16 +189,15 @@ xfs_inode_ag_iterator(
154 int exclusive, 189 int exclusive,
155 int *nr_to_scan) 190 int *nr_to_scan)
156{ 191{
192 struct xfs_perag *pag;
157 int error = 0; 193 int error = 0;
158 int last_error = 0; 194 int last_error = 0;
159 xfs_agnumber_t ag; 195 xfs_agnumber_t ag;
160 int nr; 196 int nr;
161 197
162 nr = nr_to_scan ? *nr_to_scan : INT_MAX; 198 nr = nr_to_scan ? *nr_to_scan : INT_MAX;
163 for (ag = 0; ag < mp->m_sb.sb_agcount; ag++) { 199 ag = 0;
164 struct xfs_perag *pag; 200 while ((pag = xfs_inode_ag_iter_next_pag(mp, &ag, tag))) {
165
166 pag = xfs_perag_get(mp, ag);
167 error = xfs_inode_ag_walk(mp, pag, execute, flags, tag, 201 error = xfs_inode_ag_walk(mp, pag, execute, flags, tag,
168 exclusive, &nr); 202 exclusive, &nr);
169 xfs_perag_put(pag); 203 xfs_perag_put(pag);
@@ -640,6 +674,17 @@ __xfs_inode_set_reclaim_tag(
640 radix_tree_tag_set(&pag->pag_ici_root, 674 radix_tree_tag_set(&pag->pag_ici_root,
641 XFS_INO_TO_AGINO(ip->i_mount, ip->i_ino), 675 XFS_INO_TO_AGINO(ip->i_mount, ip->i_ino),
642 XFS_ICI_RECLAIM_TAG); 676 XFS_ICI_RECLAIM_TAG);
677
678 if (!pag->pag_ici_reclaimable) {
679 /* propagate the reclaim tag up into the perag radix tree */
680 spin_lock(&ip->i_mount->m_perag_lock);
681 radix_tree_tag_set(&ip->i_mount->m_perag_tree,
682 XFS_INO_TO_AGNO(ip->i_mount, ip->i_ino),
683 XFS_ICI_RECLAIM_TAG);
684 spin_unlock(&ip->i_mount->m_perag_lock);
685 trace_xfs_perag_set_reclaim(ip->i_mount, pag->pag_agno,
686 -1, _RET_IP_);
687 }
643 pag->pag_ici_reclaimable++; 688 pag->pag_ici_reclaimable++;
644} 689}
645 690
@@ -674,6 +719,16 @@ __xfs_inode_clear_reclaim_tag(
674 radix_tree_tag_clear(&pag->pag_ici_root, 719 radix_tree_tag_clear(&pag->pag_ici_root,
675 XFS_INO_TO_AGINO(mp, ip->i_ino), XFS_ICI_RECLAIM_TAG); 720 XFS_INO_TO_AGINO(mp, ip->i_ino), XFS_ICI_RECLAIM_TAG);
676 pag->pag_ici_reclaimable--; 721 pag->pag_ici_reclaimable--;
722 if (!pag->pag_ici_reclaimable) {
723 /* clear the reclaim tag from the perag radix tree */
724 spin_lock(&ip->i_mount->m_perag_lock);
725 radix_tree_tag_clear(&ip->i_mount->m_perag_tree,
726 XFS_INO_TO_AGNO(ip->i_mount, ip->i_ino),
727 XFS_ICI_RECLAIM_TAG);
728 spin_unlock(&ip->i_mount->m_perag_lock);
729 trace_xfs_perag_clear_reclaim(ip->i_mount, pag->pag_agno,
730 -1, _RET_IP_);
731 }
677} 732}
678 733
679/* 734/*
@@ -828,83 +883,52 @@ xfs_reclaim_inodes(
828 883
829/* 884/*
830 * Shrinker infrastructure. 885 * Shrinker infrastructure.
831 *
832 * This is all far more complex than it needs to be. It adds a global list of
833 * mounts because the shrinkers can only call a global context. We need to make
834 * the shrinkers pass a context to avoid the need for global state.
835 */ 886 */
836static LIST_HEAD(xfs_mount_list);
837static struct rw_semaphore xfs_mount_list_lock;
838
839static int 887static int
840xfs_reclaim_inode_shrink( 888xfs_reclaim_inode_shrink(
889 struct shrinker *shrink,
841 int nr_to_scan, 890 int nr_to_scan,
842 gfp_t gfp_mask) 891 gfp_t gfp_mask)
843{ 892{
844 struct xfs_mount *mp; 893 struct xfs_mount *mp;
845 struct xfs_perag *pag; 894 struct xfs_perag *pag;
846 xfs_agnumber_t ag; 895 xfs_agnumber_t ag;
847 int reclaimable = 0; 896 int reclaimable;
848 897
898 mp = container_of(shrink, struct xfs_mount, m_inode_shrink);
849 if (nr_to_scan) { 899 if (nr_to_scan) {
850 if (!(gfp_mask & __GFP_FS)) 900 if (!(gfp_mask & __GFP_FS))
851 return -1; 901 return -1;
852 902
853 down_read(&xfs_mount_list_lock); 903 xfs_inode_ag_iterator(mp, xfs_reclaim_inode, 0,
854 list_for_each_entry(mp, &xfs_mount_list, m_mplist) {
855 xfs_inode_ag_iterator(mp, xfs_reclaim_inode, 0,
856 XFS_ICI_RECLAIM_TAG, 1, &nr_to_scan); 904 XFS_ICI_RECLAIM_TAG, 1, &nr_to_scan);
857 if (nr_to_scan <= 0) 905 /* if we don't exhaust the scan, don't bother coming back */
858 break; 906 if (nr_to_scan > 0)
859 } 907 return -1;
860 up_read(&xfs_mount_list_lock); 908 }
861 }
862 909
863 down_read(&xfs_mount_list_lock); 910 reclaimable = 0;
864 list_for_each_entry(mp, &xfs_mount_list, m_mplist) { 911 ag = 0;
865 for (ag = 0; ag < mp->m_sb.sb_agcount; ag++) { 912 while ((pag = xfs_inode_ag_iter_next_pag(mp, &ag,
866 pag = xfs_perag_get(mp, ag); 913 XFS_ICI_RECLAIM_TAG))) {
867 reclaimable += pag->pag_ici_reclaimable; 914 reclaimable += pag->pag_ici_reclaimable;
868 xfs_perag_put(pag); 915 xfs_perag_put(pag);
869 }
870 } 916 }
871 up_read(&xfs_mount_list_lock);
872 return reclaimable; 917 return reclaimable;
873} 918}
874 919
875static struct shrinker xfs_inode_shrinker = {
876 .shrink = xfs_reclaim_inode_shrink,
877 .seeks = DEFAULT_SEEKS,
878};
879
880void __init
881xfs_inode_shrinker_init(void)
882{
883 init_rwsem(&xfs_mount_list_lock);
884 register_shrinker(&xfs_inode_shrinker);
885}
886
887void
888xfs_inode_shrinker_destroy(void)
889{
890 ASSERT(list_empty(&xfs_mount_list));
891 unregister_shrinker(&xfs_inode_shrinker);
892}
893
894void 920void
895xfs_inode_shrinker_register( 921xfs_inode_shrinker_register(
896 struct xfs_mount *mp) 922 struct xfs_mount *mp)
897{ 923{
898 down_write(&xfs_mount_list_lock); 924 mp->m_inode_shrink.shrink = xfs_reclaim_inode_shrink;
899 list_add_tail(&mp->m_mplist, &xfs_mount_list); 925 mp->m_inode_shrink.seeks = DEFAULT_SEEKS;
900 up_write(&xfs_mount_list_lock); 926 register_shrinker(&mp->m_inode_shrink);
901} 927}
902 928
903void 929void
904xfs_inode_shrinker_unregister( 930xfs_inode_shrinker_unregister(
905 struct xfs_mount *mp) 931 struct xfs_mount *mp)
906{ 932{
907 down_write(&xfs_mount_list_lock); 933 unregister_shrinker(&mp->m_inode_shrink);
908 list_del(&mp->m_mplist);
909 up_write(&xfs_mount_list_lock);
910} 934}
diff --git a/fs/xfs/linux-2.6/xfs_sync.h b/fs/xfs/linux-2.6/xfs_sync.h
index cdcbaaca9880..e28139aaa4aa 100644
--- a/fs/xfs/linux-2.6/xfs_sync.h
+++ b/fs/xfs/linux-2.6/xfs_sync.h
@@ -55,8 +55,6 @@ int xfs_inode_ag_iterator(struct xfs_mount *mp,
55 int (*execute)(struct xfs_inode *ip, struct xfs_perag *pag, int flags), 55 int (*execute)(struct xfs_inode *ip, struct xfs_perag *pag, int flags),
56 int flags, int tag, int write_lock, int *nr_to_scan); 56 int flags, int tag, int write_lock, int *nr_to_scan);
57 57
58void xfs_inode_shrinker_init(void);
59void xfs_inode_shrinker_destroy(void);
60void xfs_inode_shrinker_register(struct xfs_mount *mp); 58void xfs_inode_shrinker_register(struct xfs_mount *mp);
61void xfs_inode_shrinker_unregister(struct xfs_mount *mp); 59void xfs_inode_shrinker_unregister(struct xfs_mount *mp);
62 60
diff --git a/fs/xfs/linux-2.6/xfs_trace.h b/fs/xfs/linux-2.6/xfs_trace.h
index 73d5aa117384..302820690904 100644
--- a/fs/xfs/linux-2.6/xfs_trace.h
+++ b/fs/xfs/linux-2.6/xfs_trace.h
@@ -124,7 +124,10 @@ DEFINE_EVENT(xfs_perag_class, name, \
124 unsigned long caller_ip), \ 124 unsigned long caller_ip), \
125 TP_ARGS(mp, agno, refcount, caller_ip)) 125 TP_ARGS(mp, agno, refcount, caller_ip))
126DEFINE_PERAG_REF_EVENT(xfs_perag_get); 126DEFINE_PERAG_REF_EVENT(xfs_perag_get);
127DEFINE_PERAG_REF_EVENT(xfs_perag_get_reclaim);
127DEFINE_PERAG_REF_EVENT(xfs_perag_put); 128DEFINE_PERAG_REF_EVENT(xfs_perag_put);
129DEFINE_PERAG_REF_EVENT(xfs_perag_set_reclaim);
130DEFINE_PERAG_REF_EVENT(xfs_perag_clear_reclaim);
128 131
129TRACE_EVENT(xfs_attr_list_node_descend, 132TRACE_EVENT(xfs_attr_list_node_descend,
130 TP_PROTO(struct xfs_attr_list_context *ctx, 133 TP_PROTO(struct xfs_attr_list_context *ctx,
diff --git a/fs/xfs/quota/xfs_qm.c b/fs/xfs/quota/xfs_qm.c
index 8c117ff2e3ab..67c018392d62 100644
--- a/fs/xfs/quota/xfs_qm.c
+++ b/fs/xfs/quota/xfs_qm.c
@@ -69,7 +69,7 @@ STATIC void xfs_qm_list_destroy(xfs_dqlist_t *);
69 69
70STATIC int xfs_qm_init_quotainos(xfs_mount_t *); 70STATIC int xfs_qm_init_quotainos(xfs_mount_t *);
71STATIC int xfs_qm_init_quotainfo(xfs_mount_t *); 71STATIC int xfs_qm_init_quotainfo(xfs_mount_t *);
72STATIC int xfs_qm_shake(int, gfp_t); 72STATIC int xfs_qm_shake(struct shrinker *, int, gfp_t);
73 73
74static struct shrinker xfs_qm_shaker = { 74static struct shrinker xfs_qm_shaker = {
75 .shrink = xfs_qm_shake, 75 .shrink = xfs_qm_shake,
@@ -2117,7 +2117,10 @@ xfs_qm_shake_freelist(
2117 */ 2117 */
2118/* ARGSUSED */ 2118/* ARGSUSED */
2119STATIC int 2119STATIC int
2120xfs_qm_shake(int nr_to_scan, gfp_t gfp_mask) 2120xfs_qm_shake(
2121 struct shrinker *shrink,
2122 int nr_to_scan,
2123 gfp_t gfp_mask)
2121{ 2124{
2122 int ndqused, nfree, n; 2125 int ndqused, nfree, n;
2123 2126
diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h
index 1d2c7eed4eda..5761087ee8ea 100644
--- a/fs/xfs/xfs_mount.h
+++ b/fs/xfs/xfs_mount.h
@@ -259,7 +259,7 @@ typedef struct xfs_mount {
259 wait_queue_head_t m_wait_single_sync_task; 259 wait_queue_head_t m_wait_single_sync_task;
260 __int64_t m_update_flags; /* sb flags we need to update 260 __int64_t m_update_flags; /* sb flags we need to update
261 on the next remount,rw */ 261 on the next remount,rw */
262 struct list_head m_mplist; /* inode shrinker mount list */ 262 struct shrinker m_inode_shrink; /* inode reclaim shrinker */
263} xfs_mount_t; 263} xfs_mount_t;
264 264
265/* 265/*
diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h
index 013dc529e95f..d147461bc271 100644
--- a/include/linux/fdtable.h
+++ b/include/linux/fdtable.h
@@ -61,7 +61,8 @@ struct files_struct {
61 (rcu_dereference_check((fdtfd), \ 61 (rcu_dereference_check((fdtfd), \
62 rcu_read_lock_held() || \ 62 rcu_read_lock_held() || \
63 lockdep_is_held(&(files)->file_lock) || \ 63 lockdep_is_held(&(files)->file_lock) || \
64 atomic_read(&(files)->count) == 1)) 64 atomic_read(&(files)->count) == 1 || \
65 rcu_my_thread_group_empty()))
65 66
66#define files_fdtable(files) \ 67#define files_fdtable(files) \
67 (rcu_dereference_check_fdtable((files), (files)->fdt)) 68 (rcu_dereference_check_fdtable((files), (files)->fdt))
diff --git a/include/linux/i8042.h b/include/linux/i8042.h
index 9bf6870ee5f4..a986ff588944 100644
--- a/include/linux/i8042.h
+++ b/include/linux/i8042.h
@@ -46,31 +46,31 @@ int i8042_remove_filter(bool (*filter)(unsigned char data, unsigned char str,
46 46
47#else 47#else
48 48
49void i8042_lock_chip(void) 49static inline void i8042_lock_chip(void)
50{ 50{
51} 51}
52 52
53void i8042_unlock_chip(void) 53static inline void i8042_unlock_chip(void)
54{ 54{
55} 55}
56 56
57int i8042_command(unsigned char *param, int command) 57static inline int i8042_command(unsigned char *param, int command)
58{ 58{
59 return -ENODEV; 59 return -ENODEV;
60} 60}
61 61
62bool i8042_check_port_owner(const struct serio *serio) 62static inline bool i8042_check_port_owner(const struct serio *serio)
63{ 63{
64 return false; 64 return false;
65} 65}
66 66
67int i8042_install_filter(bool (*filter)(unsigned char data, unsigned char str, 67static inline int i8042_install_filter(bool (*filter)(unsigned char data, unsigned char str,
68 struct serio *serio)) 68 struct serio *serio))
69{ 69{
70 return -ENODEV; 70 return -ENODEV;
71} 71}
72 72
73int i8042_remove_filter(bool (*filter)(unsigned char data, unsigned char str, 73static inline int i8042_remove_filter(bool (*filter)(unsigned char data, unsigned char str,
74 struct serio *serio)) 74 struct serio *serio))
75{ 75{
76 return -ENODEV; 76 return -ENODEV;
diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h
index a4d2e9f7088a..adf832dec3f3 100644
--- a/include/linux/jbd2.h
+++ b/include/linux/jbd2.h
@@ -1026,11 +1026,12 @@ void __jbd2_journal_insert_checkpoint(struct journal_head *, transaction_t *);
1026 1026
1027struct jbd2_buffer_trigger_type { 1027struct jbd2_buffer_trigger_type {
1028 /* 1028 /*
1029 * Fired just before a buffer is written to the journal. 1029 * Fired a the moment data to write to the journal are known to be
1030 * mapped_data is a mapped buffer that is the frozen data for 1030 * stable - so either at the moment b_frozen_data is created or just
1031 * commit. 1031 * before a buffer is written to the journal. mapped_data is a mapped
1032 * buffer that is the frozen data for commit.
1032 */ 1033 */
1033 void (*t_commit)(struct jbd2_buffer_trigger_type *type, 1034 void (*t_frozen)(struct jbd2_buffer_trigger_type *type,
1034 struct buffer_head *bh, void *mapped_data, 1035 struct buffer_head *bh, void *mapped_data,
1035 size_t size); 1036 size_t size);
1036 1037
@@ -1042,7 +1043,7 @@ struct jbd2_buffer_trigger_type {
1042 struct buffer_head *bh); 1043 struct buffer_head *bh);
1043}; 1044};
1044 1045
1045extern void jbd2_buffer_commit_trigger(struct journal_head *jh, 1046extern void jbd2_buffer_frozen_trigger(struct journal_head *jh,
1046 void *mapped_data, 1047 void *mapped_data,
1047 struct jbd2_buffer_trigger_type *triggers); 1048 struct jbd2_buffer_trigger_type *triggers);
1048extern void jbd2_buffer_abort_trigger(struct journal_head *jh, 1049extern void jbd2_buffer_abort_trigger(struct journal_head *jh,
diff --git a/include/linux/lmb.h b/include/linux/lmb.h
deleted file mode 100644
index f3d14333ebed..000000000000
--- a/include/linux/lmb.h
+++ /dev/null
@@ -1,89 +0,0 @@
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 lmb_add(u64 base, u64 size);
44extern long lmb_remove(u64 base, u64 size);
45extern long __init lmb_free(u64 base, u64 size);
46extern long __init lmb_reserve(u64 base, u64 size);
47extern u64 __init lmb_alloc_nid(u64 size, u64 align, int nid,
48 u64 (*nid_range)(u64, u64, int *));
49extern u64 __init lmb_alloc(u64 size, u64 align);
50extern u64 __init lmb_alloc_base(u64 size,
51 u64, u64 max_addr);
52extern u64 __init __lmb_alloc_base(u64 size,
53 u64 align, u64 max_addr);
54extern u64 __init lmb_phys_mem_size(void);
55extern u64 lmb_end_of_DRAM(void);
56extern void __init lmb_enforce_memory_limit(u64 memory_limit);
57extern int __init lmb_is_reserved(u64 addr);
58extern int lmb_is_region_reserved(u64 base, u64 size);
59extern int lmb_find(struct lmb_property *res);
60
61extern void lmb_dump_all(void);
62
63static inline u64
64lmb_size_bytes(struct lmb_region *type, unsigned long region_nr)
65{
66 return type->region[region_nr].size;
67}
68static inline u64
69lmb_size_pages(struct lmb_region *type, unsigned long region_nr)
70{
71 return lmb_size_bytes(type, region_nr) >> PAGE_SHIFT;
72}
73static inline u64
74lmb_start_pfn(struct lmb_region *type, unsigned long region_nr)
75{
76 return type->region[region_nr].base >> PAGE_SHIFT;
77}
78static inline u64
79lmb_end_pfn(struct lmb_region *type, unsigned long region_nr)
80{
81 return lmb_start_pfn(type, region_nr) +
82 lmb_size_pages(type, region_nr);
83}
84
85#include <asm/lmb.h>
86
87#endif /* __KERNEL__ */
88
89#endif /* _LINUX_LMB_H */
diff --git a/include/linux/memblock.h b/include/linux/memblock.h
new file mode 100644
index 000000000000..a59faf2b5edd
--- /dev/null
+++ b/include/linux/memblock.h
@@ -0,0 +1,89 @@
1#ifndef _LINUX_MEMBLOCK_H
2#define _LINUX_MEMBLOCK_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_MEMBLOCK_REGIONS 128
20
21struct memblock_property {
22 u64 base;
23 u64 size;
24};
25
26struct memblock_region {
27 unsigned long cnt;
28 u64 size;
29 struct memblock_property region[MAX_MEMBLOCK_REGIONS+1];
30};
31
32struct memblock {
33 unsigned long debug;
34 u64 rmo_size;
35 struct memblock_region memory;
36 struct memblock_region reserved;
37};
38
39extern struct memblock memblock;
40
41extern void __init memblock_init(void);
42extern void __init memblock_analyze(void);
43extern long memblock_add(u64 base, u64 size);
44extern long memblock_remove(u64 base, u64 size);
45extern long __init memblock_free(u64 base, u64 size);
46extern long __init memblock_reserve(u64 base, u64 size);
47extern u64 __init memblock_alloc_nid(u64 size, u64 align, int nid,
48 u64 (*nid_range)(u64, u64, int *));
49extern u64 __init memblock_alloc(u64 size, u64 align);
50extern u64 __init memblock_alloc_base(u64 size,
51 u64, u64 max_addr);
52extern u64 __init __memblock_alloc_base(u64 size,
53 u64 align, u64 max_addr);
54extern u64 __init memblock_phys_mem_size(void);
55extern u64 memblock_end_of_DRAM(void);
56extern void __init memblock_enforce_memory_limit(u64 memory_limit);
57extern int __init memblock_is_reserved(u64 addr);
58extern int memblock_is_region_reserved(u64 base, u64 size);
59extern int memblock_find(struct memblock_property *res);
60
61extern void memblock_dump_all(void);
62
63static inline u64
64memblock_size_bytes(struct memblock_region *type, unsigned long region_nr)
65{
66 return type->region[region_nr].size;
67}
68static inline u64
69memblock_size_pages(struct memblock_region *type, unsigned long region_nr)
70{
71 return memblock_size_bytes(type, region_nr) >> PAGE_SHIFT;
72}
73static inline u64
74memblock_start_pfn(struct memblock_region *type, unsigned long region_nr)
75{
76 return type->region[region_nr].base >> PAGE_SHIFT;
77}
78static inline u64
79memblock_end_pfn(struct memblock_region *type, unsigned long region_nr)
80{
81 return memblock_start_pfn(type, region_nr) +
82 memblock_size_pages(type, region_nr);
83}
84
85#include <asm/memblock.h>
86
87#endif /* __KERNEL__ */
88
89#endif /* _LINUX_MEMBLOCK_H */
diff --git a/include/linux/mm.h b/include/linux/mm.h
index b969efb03787..a2b48041b910 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -999,7 +999,7 @@ static inline void sync_mm_rss(struct task_struct *task, struct mm_struct *mm)
999 * querying the cache size, so a fastpath for that case is appropriate. 999 * querying the cache size, so a fastpath for that case is appropriate.
1000 */ 1000 */
1001struct shrinker { 1001struct shrinker {
1002 int (*shrink)(int nr_to_scan, gfp_t gfp_mask); 1002 int (*shrink)(struct shrinker *, int nr_to_scan, gfp_t gfp_mask);
1003 int seeks; /* seeks to recreate an obj */ 1003 int seeks; /* seeks to recreate an obj */
1004 1004
1005 /* These are for internal use */ 1005 /* These are for internal use */
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 7cb00845f150..f26fda76b87f 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -288,6 +288,7 @@ struct pci_dev {
288 */ 288 */
289 unsigned int irq; 289 unsigned int irq;
290 struct resource resource[DEVICE_COUNT_RESOURCE]; /* I/O and memory regions + expansion ROMs */ 290 struct resource resource[DEVICE_COUNT_RESOURCE]; /* I/O and memory regions + expansion ROMs */
291 resource_size_t fw_addr[DEVICE_COUNT_RESOURCE]; /* FW-assigned addr */
291 292
292 /* These fields are used by common fixups */ 293 /* These fields are used by common fixups */
293 unsigned int transparent:1; /* Transparent PCI bridge */ 294 unsigned int transparent:1; /* Transparent PCI bridge */
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 7f614ce274a9..13ebb5413a79 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -124,7 +124,8 @@ extern struct trace_event_functions enter_syscall_print_funcs;
124extern struct trace_event_functions exit_syscall_print_funcs; 124extern struct trace_event_functions exit_syscall_print_funcs;
125 125
126#define SYSCALL_TRACE_ENTER_EVENT(sname) \ 126#define SYSCALL_TRACE_ENTER_EVENT(sname) \
127 static struct syscall_metadata __syscall_meta_##sname; \ 127 static struct syscall_metadata \
128 __attribute__((__aligned__(4))) __syscall_meta_##sname; \
128 static struct ftrace_event_call \ 129 static struct ftrace_event_call \
129 __attribute__((__aligned__(4))) event_enter_##sname; \ 130 __attribute__((__aligned__(4))) event_enter_##sname; \
130 static struct ftrace_event_call __used \ 131 static struct ftrace_event_call __used \
@@ -138,7 +139,8 @@ extern struct trace_event_functions exit_syscall_print_funcs;
138 } 139 }
139 140
140#define SYSCALL_TRACE_EXIT_EVENT(sname) \ 141#define SYSCALL_TRACE_EXIT_EVENT(sname) \
141 static struct syscall_metadata __syscall_meta_##sname; \ 142 static struct syscall_metadata \
143 __attribute__((__aligned__(4))) __syscall_meta_##sname; \
142 static struct ftrace_event_call \ 144 static struct ftrace_event_call \
143 __attribute__((__aligned__(4))) event_exit_##sname; \ 145 __attribute__((__aligned__(4))) event_exit_##sname; \
144 static struct ftrace_event_call __used \ 146 static struct ftrace_event_call __used \
diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
index 4496322e28dd..609e8ca5f534 100644
--- a/include/linux/sysrq.h
+++ b/include/linux/sysrq.h
@@ -45,6 +45,7 @@ struct sysrq_key_op {
45 */ 45 */
46 46
47void handle_sysrq(int key, struct tty_struct *tty); 47void handle_sysrq(int key, struct tty_struct *tty);
48void __handle_sysrq(int key, struct tty_struct *tty, int check_mask);
48int register_sysrq_key(int key, struct sysrq_key_op *op); 49int register_sysrq_key(int key, struct sysrq_key_op *op);
49int unregister_sysrq_key(int key, struct sysrq_key_op *op); 50int unregister_sysrq_key(int key, struct sysrq_key_op *op);
50struct sysrq_key_op *__sysrq_get_key_op(int key); 51struct sysrq_key_op *__sysrq_get_key_op(int key);
diff --git a/include/math-emu/op-common.h b/include/math-emu/op-common.h
index fd882261225e..9696a5e2c437 100644
--- a/include/math-emu/op-common.h
+++ b/include/math-emu/op-common.h
@@ -799,7 +799,7 @@ do { \
799 X##_e -= (_FP_W_TYPE_SIZE - rsize); \ 799 X##_e -= (_FP_W_TYPE_SIZE - rsize); \
800 X##_e = rsize - X##_e - 1; \ 800 X##_e = rsize - X##_e - 1; \
801 \ 801 \
802 if (_FP_FRACBITS_##fs < rsize && _FP_WFRACBITS_##fs < X##_e) \ 802 if (_FP_FRACBITS_##fs < rsize && _FP_WFRACBITS_##fs <= X##_e) \
803 __FP_FRAC_SRS_1(ur_, (X##_e - _FP_WFRACBITS_##fs + 1), rsize);\ 803 __FP_FRAC_SRS_1(ur_, (X##_e - _FP_WFRACBITS_##fs + 1), rsize);\
804 _FP_FRAC_DISASSEMBLE_##wc(X, ur_, rsize); \ 804 _FP_FRAC_DISASSEMBLE_##wc(X, ur_, rsize); \
805 if ((_FP_WFRACBITS_##fs - X##_e - 1) > 0) \ 805 if ((_FP_WFRACBITS_##fs - X##_e - 1) > 0) \
diff --git a/include/net/sock.h b/include/net/sock.h
index 731150d52799..0a691ea7654a 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -1224,12 +1224,7 @@ static inline void sk_tx_queue_clear(struct sock *sk)
1224 1224
1225static inline int sk_tx_queue_get(const struct sock *sk) 1225static inline int sk_tx_queue_get(const struct sock *sk)
1226{ 1226{
1227 return sk->sk_tx_queue_mapping; 1227 return sk ? sk->sk_tx_queue_mapping : -1;
1228}
1229
1230static inline bool sk_tx_queue_recorded(const struct sock *sk)
1231{
1232 return (sk && sk->sk_tx_queue_mapping >= 0);
1233} 1228}
1234 1229
1235static inline void sk_set_socket(struct sock *sk, struct socket *sock) 1230static inline void sk_set_socket(struct sock *sk, struct socket *sock)
diff --git a/ipc/sem.c b/ipc/sem.c
index 506c8491a8d1..40a8f462a822 100644
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -1256,6 +1256,33 @@ out:
1256 return un; 1256 return un;
1257} 1257}
1258 1258
1259
1260/**
1261 * get_queue_result - Retrieve the result code from sem_queue
1262 * @q: Pointer to queue structure
1263 *
1264 * Retrieve the return code from the pending queue. If IN_WAKEUP is found in
1265 * q->status, then we must loop until the value is replaced with the final
1266 * value: This may happen if a task is woken up by an unrelated event (e.g.
1267 * signal) and in parallel the task is woken up by another task because it got
1268 * the requested semaphores.
1269 *
1270 * The function can be called with or without holding the semaphore spinlock.
1271 */
1272static int get_queue_result(struct sem_queue *q)
1273{
1274 int error;
1275
1276 error = q->status;
1277 while (unlikely(error == IN_WAKEUP)) {
1278 cpu_relax();
1279 error = q->status;
1280 }
1281
1282 return error;
1283}
1284
1285
1259SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops, 1286SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops,
1260 unsigned, nsops, const struct timespec __user *, timeout) 1287 unsigned, nsops, const struct timespec __user *, timeout)
1261{ 1288{
@@ -1409,15 +1436,18 @@ SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops,
1409 else 1436 else
1410 schedule(); 1437 schedule();
1411 1438
1412 error = queue.status; 1439 error = get_queue_result(&queue);
1413 while(unlikely(error == IN_WAKEUP)) {
1414 cpu_relax();
1415 error = queue.status;
1416 }
1417 1440
1418 if (error != -EINTR) { 1441 if (error != -EINTR) {
1419 /* fast path: update_queue already obtained all requested 1442 /* fast path: update_queue already obtained all requested
1420 * resources */ 1443 * resources.
1444 * Perform a smp_mb(): User space could assume that semop()
1445 * is a memory barrier: Without the mb(), the cpu could
1446 * speculatively read in user space stale data that was
1447 * overwritten by the previous owner of the semaphore.
1448 */
1449 smp_mb();
1450
1421 goto out_free; 1451 goto out_free;
1422 } 1452 }
1423 1453
@@ -1427,10 +1457,12 @@ SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops,
1427 goto out_free; 1457 goto out_free;
1428 } 1458 }
1429 1459
1460 error = get_queue_result(&queue);
1461
1430 /* 1462 /*
1431 * If queue.status != -EINTR we are woken up by another process 1463 * If queue.status != -EINTR we are woken up by another process
1432 */ 1464 */
1433 error = queue.status; 1465
1434 if (error != -EINTR) { 1466 if (error != -EINTR) {
1435 goto out_unlock_free; 1467 goto out_unlock_free;
1436 } 1468 }
diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
index 5cb7cd1de10c..8bc5eeffec8a 100644
--- a/kernel/debug/debug_core.c
+++ b/kernel/debug/debug_core.c
@@ -605,13 +605,13 @@ cpu_master_loop:
605 if (dbg_kdb_mode) { 605 if (dbg_kdb_mode) {
606 kgdb_connected = 1; 606 kgdb_connected = 1;
607 error = kdb_stub(ks); 607 error = kdb_stub(ks);
608 kgdb_connected = 0;
608 } else { 609 } else {
609 error = gdb_serial_stub(ks); 610 error = gdb_serial_stub(ks);
610 } 611 }
611 612
612 if (error == DBG_PASS_EVENT) { 613 if (error == DBG_PASS_EVENT) {
613 dbg_kdb_mode = !dbg_kdb_mode; 614 dbg_kdb_mode = !dbg_kdb_mode;
614 kgdb_connected = 0;
615 } else if (error == DBG_SWITCH_CPU_EVENT) { 615 } else if (error == DBG_SWITCH_CPU_EVENT) {
616 dbg_cpu_switch(cpu, dbg_switch_cpu); 616 dbg_cpu_switch(cpu, dbg_switch_cpu);
617 goto cpu_loop; 617 goto cpu_loop;
diff --git a/kernel/debug/gdbstub.c b/kernel/debug/gdbstub.c
index 4b17b3269525..e8fd6868682d 100644
--- a/kernel/debug/gdbstub.c
+++ b/kernel/debug/gdbstub.c
@@ -621,10 +621,8 @@ static void gdb_cmd_query(struct kgdb_state *ks)
621 switch (remcom_in_buffer[1]) { 621 switch (remcom_in_buffer[1]) {
622 case 's': 622 case 's':
623 case 'f': 623 case 'f':
624 if (memcmp(remcom_in_buffer + 2, "ThreadInfo", 10)) { 624 if (memcmp(remcom_in_buffer + 2, "ThreadInfo", 10))
625 error_packet(remcom_out_buffer, -EINVAL);
626 break; 625 break;
627 }
628 626
629 i = 0; 627 i = 0;
630 remcom_out_buffer[0] = 'm'; 628 remcom_out_buffer[0] = 'm';
@@ -665,10 +663,9 @@ static void gdb_cmd_query(struct kgdb_state *ks)
665 pack_threadid(remcom_out_buffer + 2, thref); 663 pack_threadid(remcom_out_buffer + 2, thref);
666 break; 664 break;
667 case 'T': 665 case 'T':
668 if (memcmp(remcom_in_buffer + 1, "ThreadExtraInfo,", 16)) { 666 if (memcmp(remcom_in_buffer + 1, "ThreadExtraInfo,", 16))
669 error_packet(remcom_out_buffer, -EINVAL);
670 break; 667 break;
671 } 668
672 ks->threadid = 0; 669 ks->threadid = 0;
673 ptr = remcom_in_buffer + 17; 670 ptr = remcom_in_buffer + 17;
674 kgdb_hex2long(&ptr, &ks->threadid); 671 kgdb_hex2long(&ptr, &ks->threadid);
diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
index 184cd8209c36..ebe4a287419e 100644
--- a/kernel/debug/kdb/kdb_main.c
+++ b/kernel/debug/kdb/kdb_main.c
@@ -1820,9 +1820,8 @@ static int kdb_sr(int argc, const char **argv)
1820{ 1820{
1821 if (argc != 1) 1821 if (argc != 1)
1822 return KDB_ARGCOUNT; 1822 return KDB_ARGCOUNT;
1823 sysrq_toggle_support(1);
1824 kdb_trap_printk++; 1823 kdb_trap_printk++;
1825 handle_sysrq(*argv[1], NULL); 1824 __handle_sysrq(*argv[1], NULL, 0);
1826 kdb_trap_printk--; 1825 kdb_trap_printk--;
1827 1826
1828 return 0; 1827 return 0;
@@ -1883,6 +1882,7 @@ static int kdb_lsmod(int argc, const char **argv)
1883 kdb_printf(" (Loading)"); 1882 kdb_printf(" (Loading)");
1884 else 1883 else
1885 kdb_printf(" (Live)"); 1884 kdb_printf(" (Live)");
1885 kdb_printf(" 0x%p", mod->module_core);
1886 1886
1887#ifdef CONFIG_MODULE_UNLOAD 1887#ifdef CONFIG_MODULE_UNLOAD
1888 { 1888 {
@@ -2291,6 +2291,9 @@ static int kdb_ll(int argc, const char **argv)
2291 while (va) { 2291 while (va) {
2292 char buf[80]; 2292 char buf[80];
2293 2293
2294 if (KDB_FLAG(CMD_INTERRUPT))
2295 return 0;
2296
2294 sprintf(buf, "%s " kdb_machreg_fmt "\n", command, va); 2297 sprintf(buf, "%s " kdb_machreg_fmt "\n", command, va);
2295 diag = kdb_parse(buf); 2298 diag = kdb_parse(buf);
2296 if (diag) 2299 if (diag)
diff --git a/kernel/early_res.c b/kernel/early_res.c
index 31aa9332ef3f..7bfae887f211 100644
--- a/kernel/early_res.c
+++ b/kernel/early_res.c
@@ -7,6 +7,8 @@
7#include <linux/bootmem.h> 7#include <linux/bootmem.h>
8#include <linux/mm.h> 8#include <linux/mm.h>
9#include <linux/early_res.h> 9#include <linux/early_res.h>
10#include <linux/slab.h>
11#include <linux/kmemleak.h>
10 12
11/* 13/*
12 * Early reserved memory areas. 14 * Early reserved memory areas.
@@ -319,6 +321,8 @@ void __init free_early(u64 start, u64 end)
319 struct early_res *r; 321 struct early_res *r;
320 int i; 322 int i;
321 323
324 kmemleak_free_part(__va(start), end - start);
325
322 i = find_overlapped_early(start, end); 326 i = find_overlapped_early(start, end);
323 r = &early_res[i]; 327 r = &early_res[i];
324 if (i >= max_early_res || r->end != end || r->start != start) 328 if (i >= max_early_res || r->end != end || r->start != start)
@@ -333,6 +337,8 @@ void __init free_early_partial(u64 start, u64 end)
333 struct early_res *r; 337 struct early_res *r;
334 int i; 338 int i;
335 339
340 kmemleak_free_part(__va(start), end - start);
341
336 if (start == end) 342 if (start == end)
337 return; 343 return;
338 344
diff --git a/lib/Kconfig b/lib/Kconfig
index 170d8ca901d8..5b916bc0fbae 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -181,9 +181,6 @@ config HAS_DMA
181config CHECK_SIGNATURE 181config CHECK_SIGNATURE
182 bool 182 bool
183 183
184config HAVE_LMB
185 boolean
186
187config CPUMASK_OFFSTACK 184config CPUMASK_OFFSTACK
188 bool "Force CPU masks off stack" if DEBUG_PER_CPU_MAPS 185 bool "Force CPU masks off stack" if DEBUG_PER_CPU_MAPS
189 help 186 help
diff --git a/lib/Makefile b/lib/Makefile
index 3f1062cbbff4..0bfabba1bb32 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -89,8 +89,6 @@ obj-$(CONFIG_CPU_NOTIFIER_ERROR_INJECT) += cpu-notifier-error-inject.o
89 89
90lib-$(CONFIG_GENERIC_BUG) += bug.o 90lib-$(CONFIG_GENERIC_BUG) += bug.o
91 91
92obj-$(CONFIG_HAVE_LMB) += lmb.o
93
94obj-$(CONFIG_HAVE_ARCH_TRACEHOOK) += syscall.o 92obj-$(CONFIG_HAVE_ARCH_TRACEHOOK) += syscall.o
95 93
96obj-$(CONFIG_DYNAMIC_DEBUG) += dynamic_debug.o 94obj-$(CONFIG_DYNAMIC_DEBUG) += dynamic_debug.o
diff --git a/lib/lmb.c b/lib/lmb.c
deleted file mode 100644
index b1fc52606524..000000000000
--- a/lib/lmb.c
+++ /dev/null
@@ -1,541 +0,0 @@
1/*
2 * Procedures for maintaining information about logical memory blocks.
3 *
4 * Peter Bergner, IBM Corp. June 2001.
5 * Copyright (C) 2001 Peter Bergner.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 */
12
13#include <linux/kernel.h>
14#include <linux/init.h>
15#include <linux/bitops.h>
16#include <linux/lmb.h>
17
18#define LMB_ALLOC_ANYWHERE 0
19
20struct lmb lmb;
21
22static int lmb_debug;
23
24static int __init early_lmb(char *p)
25{
26 if (p && strstr(p, "debug"))
27 lmb_debug = 1;
28 return 0;
29}
30early_param("lmb", early_lmb);
31
32static void lmb_dump(struct lmb_region *region, char *name)
33{
34 unsigned long long base, size;
35 int i;
36
37 pr_info(" %s.cnt = 0x%lx\n", name, region->cnt);
38
39 for (i = 0; i < region->cnt; i++) {
40 base = region->region[i].base;
41 size = region->region[i].size;
42
43 pr_info(" %s[0x%x]\t0x%016llx - 0x%016llx, 0x%llx bytes\n",
44 name, i, base, base + size - 1, size);
45 }
46}
47
48void lmb_dump_all(void)
49{
50 if (!lmb_debug)
51 return;
52
53 pr_info("LMB configuration:\n");
54 pr_info(" rmo_size = 0x%llx\n", (unsigned long long)lmb.rmo_size);
55 pr_info(" memory.size = 0x%llx\n", (unsigned long long)lmb.memory.size);
56
57 lmb_dump(&lmb.memory, "memory");
58 lmb_dump(&lmb.reserved, "reserved");
59}
60
61static unsigned long lmb_addrs_overlap(u64 base1, u64 size1, u64 base2,
62 u64 size2)
63{
64 return ((base1 < (base2 + size2)) && (base2 < (base1 + size1)));
65}
66
67static long lmb_addrs_adjacent(u64 base1, u64 size1, u64 base2, u64 size2)
68{
69 if (base2 == base1 + size1)
70 return 1;
71 else if (base1 == base2 + size2)
72 return -1;
73
74 return 0;
75}
76
77static long lmb_regions_adjacent(struct lmb_region *rgn,
78 unsigned long r1, unsigned long r2)
79{
80 u64 base1 = rgn->region[r1].base;
81 u64 size1 = rgn->region[r1].size;
82 u64 base2 = rgn->region[r2].base;
83 u64 size2 = rgn->region[r2].size;
84
85 return lmb_addrs_adjacent(base1, size1, base2, size2);
86}
87
88static void lmb_remove_region(struct lmb_region *rgn, unsigned long r)
89{
90 unsigned long i;
91
92 for (i = r; i < rgn->cnt - 1; i++) {
93 rgn->region[i].base = rgn->region[i + 1].base;
94 rgn->region[i].size = rgn->region[i + 1].size;
95 }
96 rgn->cnt--;
97}
98
99/* Assumption: base addr of region 1 < base addr of region 2 */
100static void lmb_coalesce_regions(struct lmb_region *rgn,
101 unsigned long r1, unsigned long r2)
102{
103 rgn->region[r1].size += rgn->region[r2].size;
104 lmb_remove_region(rgn, r2);
105}
106
107void __init lmb_init(void)
108{
109 /* Create a dummy zero size LMB which will get coalesced away later.
110 * This simplifies the lmb_add() code below...
111 */
112 lmb.memory.region[0].base = 0;
113 lmb.memory.region[0].size = 0;
114 lmb.memory.cnt = 1;
115
116 /* Ditto. */
117 lmb.reserved.region[0].base = 0;
118 lmb.reserved.region[0].size = 0;
119 lmb.reserved.cnt = 1;
120}
121
122void __init lmb_analyze(void)
123{
124 int i;
125
126 lmb.memory.size = 0;
127
128 for (i = 0; i < lmb.memory.cnt; i++)
129 lmb.memory.size += lmb.memory.region[i].size;
130}
131
132static long lmb_add_region(struct lmb_region *rgn, u64 base, u64 size)
133{
134 unsigned long coalesced = 0;
135 long adjacent, i;
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
143 /* First try and coalesce this LMB with another. */
144 for (i = 0; i < rgn->cnt; i++) {
145 u64 rgnbase = rgn->region[i].base;
146 u64 rgnsize = rgn->region[i].size;
147
148 if ((rgnbase == base) && (rgnsize == size))
149 /* Already have this region, so we're done */
150 return 0;
151
152 adjacent = lmb_addrs_adjacent(base, size, rgnbase, rgnsize);
153 if (adjacent > 0) {
154 rgn->region[i].base -= size;
155 rgn->region[i].size += size;
156 coalesced++;
157 break;
158 } else if (adjacent < 0) {
159 rgn->region[i].size += size;
160 coalesced++;
161 break;
162 }
163 }
164
165 if ((i < rgn->cnt - 1) && lmb_regions_adjacent(rgn, i, i+1)) {
166 lmb_coalesce_regions(rgn, i, i+1);
167 coalesced++;
168 }
169
170 if (coalesced)
171 return coalesced;
172 if (rgn->cnt >= MAX_LMB_REGIONS)
173 return -1;
174
175 /* Couldn't coalesce the LMB, so add it to the sorted table. */
176 for (i = rgn->cnt - 1; i >= 0; i--) {
177 if (base < rgn->region[i].base) {
178 rgn->region[i+1].base = rgn->region[i].base;
179 rgn->region[i+1].size = rgn->region[i].size;
180 } else {
181 rgn->region[i+1].base = base;
182 rgn->region[i+1].size = size;
183 break;
184 }
185 }
186
187 if (base < rgn->region[0].base) {
188 rgn->region[0].base = base;
189 rgn->region[0].size = size;
190 }
191 rgn->cnt++;
192
193 return 0;
194}
195
196long lmb_add(u64 base, u64 size)
197{
198 struct lmb_region *_rgn = &lmb.memory;
199
200 /* On pSeries LPAR systems, the first LMB is our RMO region. */
201 if (base == 0)
202 lmb.rmo_size = size;
203
204 return lmb_add_region(_rgn, base, size);
205
206}
207
208static long __lmb_remove(struct lmb_region *rgn, u64 base, u64 size)
209{
210 u64 rgnbegin, rgnend;
211 u64 end = base + size;
212 int i;
213
214 rgnbegin = rgnend = 0; /* supress gcc warnings */
215
216 /* Find the region where (base, size) belongs to */
217 for (i=0; i < rgn->cnt; i++) {
218 rgnbegin = rgn->region[i].base;
219 rgnend = rgnbegin + rgn->region[i].size;
220
221 if ((rgnbegin <= base) && (end <= rgnend))
222 break;
223 }
224
225 /* Didn't find the region */
226 if (i == rgn->cnt)
227 return -1;
228
229 /* Check to see if we are removing entire region */
230 if ((rgnbegin == base) && (rgnend == end)) {
231 lmb_remove_region(rgn, i);
232 return 0;
233 }
234
235 /* Check to see if region is matching at the front */
236 if (rgnbegin == base) {
237 rgn->region[i].base = end;
238 rgn->region[i].size -= size;
239 return 0;
240 }
241
242 /* Check to see if the region is matching at the end */
243 if (rgnend == end) {
244 rgn->region[i].size -= size;
245 return 0;
246 }
247
248 /*
249 * We need to split the entry - adjust the current one to the
250 * beginging of the hole and add the region after hole.
251 */
252 rgn->region[i].size = base - rgn->region[i].base;
253 return lmb_add_region(rgn, end, rgnend - end);
254}
255
256long lmb_remove(u64 base, u64 size)
257{
258 return __lmb_remove(&lmb.memory, base, size);
259}
260
261long __init lmb_free(u64 base, u64 size)
262{
263 return __lmb_remove(&lmb.reserved, base, size);
264}
265
266long __init lmb_reserve(u64 base, u64 size)
267{
268 struct lmb_region *_rgn = &lmb.reserved;
269
270 BUG_ON(0 == size);
271
272 return lmb_add_region(_rgn, base, size);
273}
274
275long lmb_overlaps_region(struct lmb_region *rgn, u64 base, u64 size)
276{
277 unsigned long i;
278
279 for (i = 0; i < rgn->cnt; i++) {
280 u64 rgnbase = rgn->region[i].base;
281 u64 rgnsize = rgn->region[i].size;
282 if (lmb_addrs_overlap(base, size, rgnbase, rgnsize))
283 break;
284 }
285
286 return (i < rgn->cnt) ? i : -1;
287}
288
289static u64 lmb_align_down(u64 addr, u64 size)
290{
291 return addr & ~(size - 1);
292}
293
294static u64 lmb_align_up(u64 addr, u64 size)
295{
296 return (addr + (size - 1)) & ~(size - 1);
297}
298
299static u64 __init lmb_alloc_nid_unreserved(u64 start, u64 end,
300 u64 size, u64 align)
301{
302 u64 base, res_base;
303 long j;
304
305 base = lmb_align_down((end - size), align);
306 while (start <= base) {
307 j = lmb_overlaps_region(&lmb.reserved, base, size);
308 if (j < 0) {
309 /* this area isn't reserved, take it */
310 if (lmb_add_region(&lmb.reserved, base, size) < 0)
311 base = ~(u64)0;
312 return base;
313 }
314 res_base = lmb.reserved.region[j].base;
315 if (res_base < size)
316 break;
317 base = lmb_align_down(res_base - size, align);
318 }
319
320 return ~(u64)0;
321}
322
323static u64 __init lmb_alloc_nid_region(struct lmb_property *mp,
324 u64 (*nid_range)(u64, u64, int *),
325 u64 size, u64 align, int nid)
326{
327 u64 start, end;
328
329 start = mp->base;
330 end = start + mp->size;
331
332 start = lmb_align_up(start, align);
333 while (start < end) {
334 u64 this_end;
335 int this_nid;
336
337 this_end = nid_range(start, end, &this_nid);
338 if (this_nid == nid) {
339 u64 ret = lmb_alloc_nid_unreserved(start, this_end,
340 size, align);
341 if (ret != ~(u64)0)
342 return ret;
343 }
344 start = this_end;
345 }
346
347 return ~(u64)0;
348}
349
350u64 __init lmb_alloc_nid(u64 size, u64 align, int nid,
351 u64 (*nid_range)(u64 start, u64 end, int *nid))
352{
353 struct lmb_region *mem = &lmb.memory;
354 int i;
355
356 BUG_ON(0 == size);
357
358 size = lmb_align_up(size, align);
359
360 for (i = 0; i < mem->cnt; i++) {
361 u64 ret = lmb_alloc_nid_region(&mem->region[i],
362 nid_range,
363 size, align, nid);
364 if (ret != ~(u64)0)
365 return ret;
366 }
367
368 return lmb_alloc(size, align);
369}
370
371u64 __init lmb_alloc(u64 size, u64 align)
372{
373 return lmb_alloc_base(size, align, LMB_ALLOC_ANYWHERE);
374}
375
376u64 __init lmb_alloc_base(u64 size, u64 align, u64 max_addr)
377{
378 u64 alloc;
379
380 alloc = __lmb_alloc_base(size, align, max_addr);
381
382 if (alloc == 0)
383 panic("ERROR: Failed to allocate 0x%llx bytes below 0x%llx.\n",
384 (unsigned long long) size, (unsigned long long) max_addr);
385
386 return alloc;
387}
388
389u64 __init __lmb_alloc_base(u64 size, u64 align, u64 max_addr)
390{
391 long i, j;
392 u64 base = 0;
393 u64 res_base;
394
395 BUG_ON(0 == size);
396
397 size = lmb_align_up(size, align);
398
399 /* On some platforms, make sure we allocate lowmem */
400 /* Note that LMB_REAL_LIMIT may be LMB_ALLOC_ANYWHERE */
401 if (max_addr == LMB_ALLOC_ANYWHERE)
402 max_addr = LMB_REAL_LIMIT;
403
404 for (i = lmb.memory.cnt - 1; i >= 0; i--) {
405 u64 lmbbase = lmb.memory.region[i].base;
406 u64 lmbsize = lmb.memory.region[i].size;
407
408 if (lmbsize < size)
409 continue;
410 if (max_addr == LMB_ALLOC_ANYWHERE)
411 base = lmb_align_down(lmbbase + lmbsize - size, align);
412 else if (lmbbase < max_addr) {
413 base = min(lmbbase + lmbsize, max_addr);
414 base = lmb_align_down(base - size, align);
415 } else
416 continue;
417
418 while (base && lmbbase <= base) {
419 j = lmb_overlaps_region(&lmb.reserved, base, size);
420 if (j < 0) {
421 /* this area isn't reserved, take it */
422 if (lmb_add_region(&lmb.reserved, base, size) < 0)
423 return 0;
424 return base;
425 }
426 res_base = lmb.reserved.region[j].base;
427 if (res_base < size)
428 break;
429 base = lmb_align_down(res_base - size, align);
430 }
431 }
432 return 0;
433}
434
435/* You must call lmb_analyze() before this. */
436u64 __init lmb_phys_mem_size(void)
437{
438 return lmb.memory.size;
439}
440
441u64 lmb_end_of_DRAM(void)
442{
443 int idx = lmb.memory.cnt - 1;
444
445 return (lmb.memory.region[idx].base + lmb.memory.region[idx].size);
446}
447
448/* You must call lmb_analyze() after this. */
449void __init lmb_enforce_memory_limit(u64 memory_limit)
450{
451 unsigned long i;
452 u64 limit;
453 struct lmb_property *p;
454
455 if (!memory_limit)
456 return;
457
458 /* Truncate the lmb regions to satisfy the memory limit. */
459 limit = memory_limit;
460 for (i = 0; i < lmb.memory.cnt; i++) {
461 if (limit > lmb.memory.region[i].size) {
462 limit -= lmb.memory.region[i].size;
463 continue;
464 }
465
466 lmb.memory.region[i].size = limit;
467 lmb.memory.cnt = i + 1;
468 break;
469 }
470
471 if (lmb.memory.region[0].size < lmb.rmo_size)
472 lmb.rmo_size = lmb.memory.region[0].size;
473
474 memory_limit = lmb_end_of_DRAM();
475
476 /* And truncate any reserves above the limit also. */
477 for (i = 0; i < lmb.reserved.cnt; i++) {
478 p = &lmb.reserved.region[i];
479
480 if (p->base > memory_limit)
481 p->size = 0;
482 else if ((p->base + p->size) > memory_limit)
483 p->size = memory_limit - p->base;
484
485 if (p->size == 0) {
486 lmb_remove_region(&lmb.reserved, i);
487 i--;
488 }
489 }
490}
491
492int __init lmb_is_reserved(u64 addr)
493{
494 int i;
495
496 for (i = 0; i < lmb.reserved.cnt; i++) {
497 u64 upper = lmb.reserved.region[i].base +
498 lmb.reserved.region[i].size - 1;
499 if ((addr >= lmb.reserved.region[i].base) && (addr <= upper))
500 return 1;
501 }
502 return 0;
503}
504
505int lmb_is_region_reserved(u64 base, u64 size)
506{
507 return lmb_overlaps_region(&lmb.reserved, base, size);
508}
509
510/*
511 * Given a <base, len>, find which memory regions belong to this range.
512 * Adjust the request and return a contiguous chunk.
513 */
514int lmb_find(struct lmb_property *res)
515{
516 int i;
517 u64 rstart, rend;
518
519 rstart = res->base;
520 rend = rstart + res->size - 1;
521
522 for (i = 0; i < lmb.memory.cnt; i++) {
523 u64 start = lmb.memory.region[i].base;
524 u64 end = start + lmb.memory.region[i].size - 1;
525
526 if (start > rend)
527 return -1;
528
529 if ((end >= rstart) && (start < rend)) {
530 /* adjust the request */
531 if (rstart < start)
532 rstart = start;
533 if (rend > end)
534 rend = end;
535 res->base = rstart;
536 res->size = rend - rstart + 1;
537 return 0;
538 }
539 }
540 return -1;
541}
diff --git a/mm/Kconfig b/mm/Kconfig
index 527136b22384..f4e516e9c37c 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -128,6 +128,9 @@ config SPARSEMEM_VMEMMAP
128 pfn_to_page and page_to_pfn operations. This is the most 128 pfn_to_page and page_to_pfn operations. This is the most
129 efficient option when sufficient kernel resources are available. 129 efficient option when sufficient kernel resources are available.
130 130
131config HAVE_MEMBLOCK
132 boolean
133
131# eventually, we can have this option just 'select SPARSEMEM' 134# eventually, we can have this option just 'select SPARSEMEM'
132config MEMORY_HOTPLUG 135config MEMORY_HOTPLUG
133 bool "Allow for memory hot-add" 136 bool "Allow for memory hot-add"
diff --git a/mm/Makefile b/mm/Makefile
index 8982504bd03b..34b2546a9e37 100644
--- a/mm/Makefile
+++ b/mm/Makefile
@@ -15,6 +15,8 @@ obj-y := bootmem.o filemap.o mempool.o oom_kill.o fadvise.o \
15 $(mmu-y) 15 $(mmu-y)
16obj-y += init-mm.o 16obj-y += init-mm.o
17 17
18obj-$(CONFIG_HAVE_MEMBLOCK) += memblock.o
19
18obj-$(CONFIG_BOUNCE) += bounce.o 20obj-$(CONFIG_BOUNCE) += bounce.o
19obj-$(CONFIG_SWAP) += page_io.o swap_state.o swapfile.o thrash.o 21obj-$(CONFIG_SWAP) += page_io.o swap_state.o swapfile.o thrash.o
20obj-$(CONFIG_HAS_DMA) += dmapool.o 22obj-$(CONFIG_HAS_DMA) += dmapool.o
diff --git a/mm/bootmem.c b/mm/bootmem.c
index 58c66cc5056a..142c84a54993 100644
--- a/mm/bootmem.c
+++ b/mm/bootmem.c
@@ -833,15 +833,24 @@ static void * __init ___alloc_bootmem_node(bootmem_data_t *bdata,
833void * __init __alloc_bootmem_node(pg_data_t *pgdat, unsigned long size, 833void * __init __alloc_bootmem_node(pg_data_t *pgdat, unsigned long size,
834 unsigned long align, unsigned long goal) 834 unsigned long align, unsigned long goal)
835{ 835{
836 void *ptr;
837
836 if (WARN_ON_ONCE(slab_is_available())) 838 if (WARN_ON_ONCE(slab_is_available()))
837 return kzalloc_node(size, GFP_NOWAIT, pgdat->node_id); 839 return kzalloc_node(size, GFP_NOWAIT, pgdat->node_id);
838 840
839#ifdef CONFIG_NO_BOOTMEM 841#ifdef CONFIG_NO_BOOTMEM
840 return __alloc_memory_core_early(pgdat->node_id, size, align, 842 ptr = __alloc_memory_core_early(pgdat->node_id, size, align,
843 goal, -1ULL);
844 if (ptr)
845 return ptr;
846
847 ptr = __alloc_memory_core_early(MAX_NUMNODES, size, align,
841 goal, -1ULL); 848 goal, -1ULL);
842#else 849#else
843 return ___alloc_bootmem_node(pgdat->bdata, size, align, goal, 0); 850 ptr = ___alloc_bootmem_node(pgdat->bdata, size, align, goal, 0);
844#endif 851#endif
852
853 return ptr;
845} 854}
846 855
847void * __init __alloc_bootmem_node_high(pg_data_t *pgdat, unsigned long size, 856void * __init __alloc_bootmem_node_high(pg_data_t *pgdat, unsigned long size,
@@ -977,14 +986,21 @@ void * __init __alloc_bootmem_low(unsigned long size, unsigned long align,
977void * __init __alloc_bootmem_low_node(pg_data_t *pgdat, unsigned long size, 986void * __init __alloc_bootmem_low_node(pg_data_t *pgdat, unsigned long size,
978 unsigned long align, unsigned long goal) 987 unsigned long align, unsigned long goal)
979{ 988{
989 void *ptr;
990
980 if (WARN_ON_ONCE(slab_is_available())) 991 if (WARN_ON_ONCE(slab_is_available()))
981 return kzalloc_node(size, GFP_NOWAIT, pgdat->node_id); 992 return kzalloc_node(size, GFP_NOWAIT, pgdat->node_id);
982 993
983#ifdef CONFIG_NO_BOOTMEM 994#ifdef CONFIG_NO_BOOTMEM
984 return __alloc_memory_core_early(pgdat->node_id, size, align, 995 ptr = __alloc_memory_core_early(pgdat->node_id, size, align,
996 goal, ARCH_LOW_ADDRESS_LIMIT);
997 if (ptr)
998 return ptr;
999 ptr = __alloc_memory_core_early(MAX_NUMNODES, size, align,
985 goal, ARCH_LOW_ADDRESS_LIMIT); 1000 goal, ARCH_LOW_ADDRESS_LIMIT);
986#else 1001#else
987 return ___alloc_bootmem_node(pgdat->bdata, size, align, 1002 ptr = ___alloc_bootmem_node(pgdat->bdata, size, align,
988 goal, ARCH_LOW_ADDRESS_LIMIT); 1003 goal, ARCH_LOW_ADDRESS_LIMIT);
989#endif 1004#endif
1005 return ptr;
990} 1006}
diff --git a/mm/memblock.c b/mm/memblock.c
new file mode 100644
index 000000000000..3024eb30fc27
--- /dev/null
+++ b/mm/memblock.c
@@ -0,0 +1,541 @@
1/*
2 * Procedures for maintaining information about logical memory blocks.
3 *
4 * Peter Bergner, IBM Corp. June 2001.
5 * Copyright (C) 2001 Peter Bergner.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 */
12
13#include <linux/kernel.h>
14#include <linux/init.h>
15#include <linux/bitops.h>
16#include <linux/memblock.h>
17
18#define MEMBLOCK_ALLOC_ANYWHERE 0
19
20struct memblock memblock;
21
22static int memblock_debug;
23
24static int __init early_memblock(char *p)
25{
26 if (p && strstr(p, "debug"))
27 memblock_debug = 1;
28 return 0;
29}
30early_param("memblock", early_memblock);
31
32static void memblock_dump(struct memblock_region *region, char *name)
33{
34 unsigned long long base, size;
35 int i;
36
37 pr_info(" %s.cnt = 0x%lx\n", name, region->cnt);
38
39 for (i = 0; i < region->cnt; i++) {
40 base = region->region[i].base;
41 size = region->region[i].size;
42
43 pr_info(" %s[0x%x]\t0x%016llx - 0x%016llx, 0x%llx bytes\n",
44 name, i, base, base + size - 1, size);
45 }
46}
47
48void memblock_dump_all(void)
49{
50 if (!memblock_debug)
51 return;
52
53 pr_info("MEMBLOCK configuration:\n");
54 pr_info(" rmo_size = 0x%llx\n", (unsigned long long)memblock.rmo_size);
55 pr_info(" memory.size = 0x%llx\n", (unsigned long long)memblock.memory.size);
56
57 memblock_dump(&memblock.memory, "memory");
58 memblock_dump(&memblock.reserved, "reserved");
59}
60
61static unsigned long memblock_addrs_overlap(u64 base1, u64 size1, u64 base2,
62 u64 size2)
63{
64 return ((base1 < (base2 + size2)) && (base2 < (base1 + size1)));
65}
66
67static long memblock_addrs_adjacent(u64 base1, u64 size1, u64 base2, u64 size2)
68{
69 if (base2 == base1 + size1)
70 return 1;
71 else if (base1 == base2 + size2)
72 return -1;
73
74 return 0;
75}
76
77static long memblock_regions_adjacent(struct memblock_region *rgn,
78 unsigned long r1, unsigned long r2)
79{
80 u64 base1 = rgn->region[r1].base;
81 u64 size1 = rgn->region[r1].size;
82 u64 base2 = rgn->region[r2].base;
83 u64 size2 = rgn->region[r2].size;
84
85 return memblock_addrs_adjacent(base1, size1, base2, size2);
86}
87
88static void memblock_remove_region(struct memblock_region *rgn, unsigned long r)
89{
90 unsigned long i;
91
92 for (i = r; i < rgn->cnt - 1; i++) {
93 rgn->region[i].base = rgn->region[i + 1].base;
94 rgn->region[i].size = rgn->region[i + 1].size;
95 }
96 rgn->cnt--;
97}
98
99/* Assumption: base addr of region 1 < base addr of region 2 */
100static void memblock_coalesce_regions(struct memblock_region *rgn,
101 unsigned long r1, unsigned long r2)
102{
103 rgn->region[r1].size += rgn->region[r2].size;
104 memblock_remove_region(rgn, r2);
105}
106
107void __init memblock_init(void)
108{
109 /* Create a dummy zero size MEMBLOCK which will get coalesced away later.
110 * This simplifies the memblock_add() code below...
111 */
112 memblock.memory.region[0].base = 0;
113 memblock.memory.region[0].size = 0;
114 memblock.memory.cnt = 1;
115
116 /* Ditto. */
117 memblock.reserved.region[0].base = 0;
118 memblock.reserved.region[0].size = 0;
119 memblock.reserved.cnt = 1;
120}
121
122void __init memblock_analyze(void)
123{
124 int i;
125
126 memblock.memory.size = 0;
127
128 for (i = 0; i < memblock.memory.cnt; i++)
129 memblock.memory.size += memblock.memory.region[i].size;
130}
131
132static long memblock_add_region(struct memblock_region *rgn, u64 base, u64 size)
133{
134 unsigned long coalesced = 0;
135 long adjacent, i;
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
143 /* First try and coalesce this MEMBLOCK with another. */
144 for (i = 0; i < rgn->cnt; i++) {
145 u64 rgnbase = rgn->region[i].base;
146 u64 rgnsize = rgn->region[i].size;
147
148 if ((rgnbase == base) && (rgnsize == size))
149 /* Already have this region, so we're done */
150 return 0;
151
152 adjacent = memblock_addrs_adjacent(base, size, rgnbase, rgnsize);
153 if (adjacent > 0) {
154 rgn->region[i].base -= size;
155 rgn->region[i].size += size;
156 coalesced++;
157 break;
158 } else if (adjacent < 0) {
159 rgn->region[i].size += size;
160 coalesced++;
161 break;
162 }
163 }
164
165 if ((i < rgn->cnt - 1) && memblock_regions_adjacent(rgn, i, i+1)) {
166 memblock_coalesce_regions(rgn, i, i+1);
167 coalesced++;
168 }
169
170 if (coalesced)
171 return coalesced;
172 if (rgn->cnt >= MAX_MEMBLOCK_REGIONS)
173 return -1;
174
175 /* Couldn't coalesce the MEMBLOCK, so add it to the sorted table. */
176 for (i = rgn->cnt - 1; i >= 0; i--) {
177 if (base < rgn->region[i].base) {
178 rgn->region[i+1].base = rgn->region[i].base;
179 rgn->region[i+1].size = rgn->region[i].size;
180 } else {
181 rgn->region[i+1].base = base;
182 rgn->region[i+1].size = size;
183 break;
184 }
185 }
186
187 if (base < rgn->region[0].base) {
188 rgn->region[0].base = base;
189 rgn->region[0].size = size;
190 }
191 rgn->cnt++;
192
193 return 0;
194}
195
196long memblock_add(u64 base, u64 size)
197{
198 struct memblock_region *_rgn = &memblock.memory;
199
200 /* On pSeries LPAR systems, the first MEMBLOCK is our RMO region. */
201 if (base == 0)
202 memblock.rmo_size = size;
203
204 return memblock_add_region(_rgn, base, size);
205
206}
207
208static long __memblock_remove(struct memblock_region *rgn, u64 base, u64 size)
209{
210 u64 rgnbegin, rgnend;
211 u64 end = base + size;
212 int i;
213
214 rgnbegin = rgnend = 0; /* supress gcc warnings */
215
216 /* Find the region where (base, size) belongs to */
217 for (i=0; i < rgn->cnt; i++) {
218 rgnbegin = rgn->region[i].base;
219 rgnend = rgnbegin + rgn->region[i].size;
220
221 if ((rgnbegin <= base) && (end <= rgnend))
222 break;
223 }
224
225 /* Didn't find the region */
226 if (i == rgn->cnt)
227 return -1;
228
229 /* Check to see if we are removing entire region */
230 if ((rgnbegin == base) && (rgnend == end)) {
231 memblock_remove_region(rgn, i);
232 return 0;
233 }
234
235 /* Check to see if region is matching at the front */
236 if (rgnbegin == base) {
237 rgn->region[i].base = end;
238 rgn->region[i].size -= size;
239 return 0;
240 }
241
242 /* Check to see if the region is matching at the end */
243 if (rgnend == end) {
244 rgn->region[i].size -= size;
245 return 0;
246 }
247
248 /*
249 * We need to split the entry - adjust the current one to the
250 * beginging of the hole and add the region after hole.
251 */
252 rgn->region[i].size = base - rgn->region[i].base;
253 return memblock_add_region(rgn, end, rgnend - end);
254}
255
256long memblock_remove(u64 base, u64 size)
257{
258 return __memblock_remove(&memblock.memory, base, size);
259}
260
261long __init memblock_free(u64 base, u64 size)
262{
263 return __memblock_remove(&memblock.reserved, base, size);
264}
265
266long __init memblock_reserve(u64 base, u64 size)
267{
268 struct memblock_region *_rgn = &memblock.reserved;
269
270 BUG_ON(0 == size);
271
272 return memblock_add_region(_rgn, base, size);
273}
274
275long memblock_overlaps_region(struct memblock_region *rgn, u64 base, u64 size)
276{
277 unsigned long i;
278
279 for (i = 0; i < rgn->cnt; i++) {
280 u64 rgnbase = rgn->region[i].base;
281 u64 rgnsize = rgn->region[i].size;
282 if (memblock_addrs_overlap(base, size, rgnbase, rgnsize))
283 break;
284 }
285
286 return (i < rgn->cnt) ? i : -1;
287}
288
289static u64 memblock_align_down(u64 addr, u64 size)
290{
291 return addr & ~(size - 1);
292}
293
294static u64 memblock_align_up(u64 addr, u64 size)
295{
296 return (addr + (size - 1)) & ~(size - 1);
297}
298
299static u64 __init memblock_alloc_nid_unreserved(u64 start, u64 end,
300 u64 size, u64 align)
301{
302 u64 base, res_base;
303 long j;
304
305 base = memblock_align_down((end - size), align);
306 while (start <= base) {
307 j = memblock_overlaps_region(&memblock.reserved, base, size);
308 if (j < 0) {
309 /* this area isn't reserved, take it */
310 if (memblock_add_region(&memblock.reserved, base, size) < 0)
311 base = ~(u64)0;
312 return base;
313 }
314 res_base = memblock.reserved.region[j].base;
315 if (res_base < size)
316 break;
317 base = memblock_align_down(res_base - size, align);
318 }
319
320 return ~(u64)0;
321}
322
323static u64 __init memblock_alloc_nid_region(struct memblock_property *mp,
324 u64 (*nid_range)(u64, u64, int *),
325 u64 size, u64 align, int nid)
326{
327 u64 start, end;
328
329 start = mp->base;
330 end = start + mp->size;
331
332 start = memblock_align_up(start, align);
333 while (start < end) {
334 u64 this_end;
335 int this_nid;
336
337 this_end = nid_range(start, end, &this_nid);
338 if (this_nid == nid) {
339 u64 ret = memblock_alloc_nid_unreserved(start, this_end,
340 size, align);
341 if (ret != ~(u64)0)
342 return ret;
343 }
344 start = this_end;
345 }
346
347 return ~(u64)0;
348}
349
350u64 __init memblock_alloc_nid(u64 size, u64 align, int nid,
351 u64 (*nid_range)(u64 start, u64 end, int *nid))
352{
353 struct memblock_region *mem = &memblock.memory;
354 int i;
355
356 BUG_ON(0 == size);
357
358 size = memblock_align_up(size, align);
359
360 for (i = 0; i < mem->cnt; i++) {
361 u64 ret = memblock_alloc_nid_region(&mem->region[i],
362 nid_range,
363 size, align, nid);
364 if (ret != ~(u64)0)
365 return ret;
366 }
367
368 return memblock_alloc(size, align);
369}
370
371u64 __init memblock_alloc(u64 size, u64 align)
372{
373 return memblock_alloc_base(size, align, MEMBLOCK_ALLOC_ANYWHERE);
374}
375
376u64 __init memblock_alloc_base(u64 size, u64 align, u64 max_addr)
377{
378 u64 alloc;
379
380 alloc = __memblock_alloc_base(size, align, max_addr);
381
382 if (alloc == 0)
383 panic("ERROR: Failed to allocate 0x%llx bytes below 0x%llx.\n",
384 (unsigned long long) size, (unsigned long long) max_addr);
385
386 return alloc;
387}
388
389u64 __init __memblock_alloc_base(u64 size, u64 align, u64 max_addr)
390{
391 long i, j;
392 u64 base = 0;
393 u64 res_base;
394
395 BUG_ON(0 == size);
396
397 size = memblock_align_up(size, align);
398
399 /* On some platforms, make sure we allocate lowmem */
400 /* Note that MEMBLOCK_REAL_LIMIT may be MEMBLOCK_ALLOC_ANYWHERE */
401 if (max_addr == MEMBLOCK_ALLOC_ANYWHERE)
402 max_addr = MEMBLOCK_REAL_LIMIT;
403
404 for (i = memblock.memory.cnt - 1; i >= 0; i--) {
405 u64 memblockbase = memblock.memory.region[i].base;
406 u64 memblocksize = memblock.memory.region[i].size;
407
408 if (memblocksize < size)
409 continue;
410 if (max_addr == MEMBLOCK_ALLOC_ANYWHERE)
411 base = memblock_align_down(memblockbase + memblocksize - size, align);
412 else if (memblockbase < max_addr) {
413 base = min(memblockbase + memblocksize, max_addr);
414 base = memblock_align_down(base - size, align);
415 } else
416 continue;
417
418 while (base && memblockbase <= base) {
419 j = memblock_overlaps_region(&memblock.reserved, base, size);
420 if (j < 0) {
421 /* this area isn't reserved, take it */
422 if (memblock_add_region(&memblock.reserved, base, size) < 0)
423 return 0;
424 return base;
425 }
426 res_base = memblock.reserved.region[j].base;
427 if (res_base < size)
428 break;
429 base = memblock_align_down(res_base - size, align);
430 }
431 }
432 return 0;
433}
434
435/* You must call memblock_analyze() before this. */
436u64 __init memblock_phys_mem_size(void)
437{
438 return memblock.memory.size;
439}
440
441u64 memblock_end_of_DRAM(void)
442{
443 int idx = memblock.memory.cnt - 1;
444
445 return (memblock.memory.region[idx].base + memblock.memory.region[idx].size);
446}
447
448/* You must call memblock_analyze() after this. */
449void __init memblock_enforce_memory_limit(u64 memory_limit)
450{
451 unsigned long i;
452 u64 limit;
453 struct memblock_property *p;
454
455 if (!memory_limit)
456 return;
457
458 /* Truncate the memblock regions to satisfy the memory limit. */
459 limit = memory_limit;
460 for (i = 0; i < memblock.memory.cnt; i++) {
461 if (limit > memblock.memory.region[i].size) {
462 limit -= memblock.memory.region[i].size;
463 continue;
464 }
465
466 memblock.memory.region[i].size = limit;
467 memblock.memory.cnt = i + 1;
468 break;
469 }
470
471 if (memblock.memory.region[0].size < memblock.rmo_size)
472 memblock.rmo_size = memblock.memory.region[0].size;
473
474 memory_limit = memblock_end_of_DRAM();
475
476 /* And truncate any reserves above the limit also. */
477 for (i = 0; i < memblock.reserved.cnt; i++) {
478 p = &memblock.reserved.region[i];
479
480 if (p->base > memory_limit)
481 p->size = 0;
482 else if ((p->base + p->size) > memory_limit)
483 p->size = memory_limit - p->base;
484
485 if (p->size == 0) {
486 memblock_remove_region(&memblock.reserved, i);
487 i--;
488 }
489 }
490}
491
492int __init memblock_is_reserved(u64 addr)
493{
494 int i;
495
496 for (i = 0; i < memblock.reserved.cnt; i++) {
497 u64 upper = memblock.reserved.region[i].base +
498 memblock.reserved.region[i].size - 1;
499 if ((addr >= memblock.reserved.region[i].base) && (addr <= upper))
500 return 1;
501 }
502 return 0;
503}
504
505int memblock_is_region_reserved(u64 base, u64 size)
506{
507 return memblock_overlaps_region(&memblock.reserved, base, size);
508}
509
510/*
511 * Given a <base, len>, find which memory regions belong to this range.
512 * Adjust the request and return a contiguous chunk.
513 */
514int memblock_find(struct memblock_property *res)
515{
516 int i;
517 u64 rstart, rend;
518
519 rstart = res->base;
520 rend = rstart + res->size - 1;
521
522 for (i = 0; i < memblock.memory.cnt; i++) {
523 u64 start = memblock.memory.region[i].base;
524 u64 end = start + memblock.memory.region[i].size - 1;
525
526 if (start > rend)
527 return -1;
528
529 if ((end >= rstart) && (start < rend)) {
530 /* adjust the request */
531 if (rstart < start)
532 rstart = start;
533 if (rend > end)
534 rend = end;
535 res->base = rstart;
536 res->size = rend - rstart + 1;
537 return 0;
538 }
539 }
540 return -1;
541}
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 431214b941ac..9bd339eb04c6 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -3634,6 +3634,9 @@ void * __init __alloc_memory_core_early(int nid, u64 size, u64 align,
3634 int i; 3634 int i;
3635 void *ptr; 3635 void *ptr;
3636 3636
3637 if (limit > get_max_mapped())
3638 limit = get_max_mapped();
3639
3637 /* need to go over early_node_map to find out good range for node */ 3640 /* need to go over early_node_map to find out good range for node */
3638 for_each_active_range_index_in_nid(i, nid) { 3641 for_each_active_range_index_in_nid(i, nid) {
3639 u64 addr; 3642 u64 addr;
@@ -3659,6 +3662,11 @@ void * __init __alloc_memory_core_early(int nid, u64 size, u64 align,
3659 ptr = phys_to_virt(addr); 3662 ptr = phys_to_virt(addr);
3660 memset(ptr, 0, size); 3663 memset(ptr, 0, size);
3661 reserve_early_without_check(addr, addr + size, "BOOTMEM"); 3664 reserve_early_without_check(addr, addr + size, "BOOTMEM");
3665 /*
3666 * The min_count is set to 0 so that bootmem allocated blocks
3667 * are never reported as leaks.
3668 */
3669 kmemleak_alloc(ptr, size, 0, 0);
3662 return ptr; 3670 return ptr;
3663 } 3671 }
3664 3672
diff --git a/mm/page_cgroup.c b/mm/page_cgroup.c
index 6c0081441a32..5bffada7cde1 100644
--- a/mm/page_cgroup.c
+++ b/mm/page_cgroup.c
@@ -9,6 +9,7 @@
9#include <linux/vmalloc.h> 9#include <linux/vmalloc.h>
10#include <linux/cgroup.h> 10#include <linux/cgroup.h>
11#include <linux/swapops.h> 11#include <linux/swapops.h>
12#include <linux/kmemleak.h>
12 13
13static void __meminit 14static void __meminit
14__init_page_cgroup(struct page_cgroup *pc, unsigned long pfn) 15__init_page_cgroup(struct page_cgroup *pc, unsigned long pfn)
@@ -126,6 +127,12 @@ static int __init_refok init_section_page_cgroup(unsigned long pfn)
126 if (!base) 127 if (!base)
127 base = vmalloc(table_size); 128 base = vmalloc(table_size);
128 } 129 }
130 /*
131 * The value stored in section->page_cgroup is (base - pfn)
132 * and it does not point to the memory block allocated above,
133 * causing kmemleak false positives.
134 */
135 kmemleak_not_leak(base);
129 } else { 136 } else {
130 /* 137 /*
131 * We don't have to allocate page_cgroup again, but 138 * We don't have to allocate page_cgroup again, but
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 9c7e57cc63a3..b94fe1b3da43 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -213,8 +213,9 @@ unsigned long shrink_slab(unsigned long scanned, gfp_t gfp_mask,
213 list_for_each_entry(shrinker, &shrinker_list, list) { 213 list_for_each_entry(shrinker, &shrinker_list, list) {
214 unsigned long long delta; 214 unsigned long long delta;
215 unsigned long total_scan; 215 unsigned long total_scan;
216 unsigned long max_pass = (*shrinker->shrink)(0, gfp_mask); 216 unsigned long max_pass;
217 217
218 max_pass = (*shrinker->shrink)(shrinker, 0, gfp_mask);
218 delta = (4 * scanned) / shrinker->seeks; 219 delta = (4 * scanned) / shrinker->seeks;
219 delta *= max_pass; 220 delta *= max_pass;
220 do_div(delta, lru_pages + 1); 221 do_div(delta, lru_pages + 1);
@@ -242,8 +243,9 @@ unsigned long shrink_slab(unsigned long scanned, gfp_t gfp_mask,
242 int shrink_ret; 243 int shrink_ret;
243 int nr_before; 244 int nr_before;
244 245
245 nr_before = (*shrinker->shrink)(0, gfp_mask); 246 nr_before = (*shrinker->shrink)(shrinker, 0, gfp_mask);
246 shrink_ret = (*shrinker->shrink)(this_scan, gfp_mask); 247 shrink_ret = (*shrinker->shrink)(shrinker, this_scan,
248 gfp_mask);
247 if (shrink_ret == -1) 249 if (shrink_ret == -1)
248 break; 250 break;
249 if (shrink_ret < nr_before) 251 if (shrink_ret < nr_before)
@@ -296,7 +298,7 @@ static int may_write_to_queue(struct backing_dev_info *bdi)
296static void handle_write_error(struct address_space *mapping, 298static void handle_write_error(struct address_space *mapping,
297 struct page *page, int error) 299 struct page *page, int error)
298{ 300{
299 lock_page(page); 301 lock_page_nosync(page);
300 if (page_mapping(page) == mapping) 302 if (page_mapping(page) == mapping)
301 mapping_set_error(mapping, error); 303 mapping_set_error(mapping, error);
302 unlock_page(page); 304 unlock_page(page);
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index b10e3cdb08f8..800b6b9fbbae 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -358,6 +358,11 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8
358 acl->sec_level = sec_level; 358 acl->sec_level = sec_level;
359 acl->auth_type = auth_type; 359 acl->auth_type = auth_type;
360 hci_acl_connect(acl); 360 hci_acl_connect(acl);
361 } else {
362 if (acl->sec_level < sec_level)
363 acl->sec_level = sec_level;
364 if (acl->auth_type < auth_type)
365 acl->auth_type = auth_type;
361 } 366 }
362 367
363 if (type == ACL_LINK) 368 if (type == ACL_LINK)
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 6c57fc71c7e2..786b5de0bac4 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1049,6 +1049,8 @@ static inline void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *s
1049 if (conn) { 1049 if (conn) {
1050 if (!ev->status) 1050 if (!ev->status)
1051 conn->link_mode |= HCI_LM_AUTH; 1051 conn->link_mode |= HCI_LM_AUTH;
1052 else
1053 conn->sec_level = BT_SECURITY_LOW;
1052 1054
1053 clear_bit(HCI_CONN_AUTH_PEND, &conn->pend); 1055 clear_bit(HCI_CONN_AUTH_PEND, &conn->pend);
1054 1056
diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
index 1b682a5aa061..cf3c4073a8a6 100644
--- a/net/bluetooth/l2cap.c
+++ b/net/bluetooth/l2cap.c
@@ -401,6 +401,11 @@ static inline void l2cap_send_rr_or_rnr(struct l2cap_pinfo *pi, u16 control)
401 l2cap_send_sframe(pi, control); 401 l2cap_send_sframe(pi, control);
402} 402}
403 403
404static inline int __l2cap_no_conn_pending(struct sock *sk)
405{
406 return !(l2cap_pi(sk)->conf_state & L2CAP_CONF_CONNECT_PEND);
407}
408
404static void l2cap_do_start(struct sock *sk) 409static void l2cap_do_start(struct sock *sk)
405{ 410{
406 struct l2cap_conn *conn = l2cap_pi(sk)->conn; 411 struct l2cap_conn *conn = l2cap_pi(sk)->conn;
@@ -409,12 +414,13 @@ static void l2cap_do_start(struct sock *sk)
409 if (!(conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_DONE)) 414 if (!(conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_DONE))
410 return; 415 return;
411 416
412 if (l2cap_check_security(sk)) { 417 if (l2cap_check_security(sk) && __l2cap_no_conn_pending(sk)) {
413 struct l2cap_conn_req req; 418 struct l2cap_conn_req req;
414 req.scid = cpu_to_le16(l2cap_pi(sk)->scid); 419 req.scid = cpu_to_le16(l2cap_pi(sk)->scid);
415 req.psm = l2cap_pi(sk)->psm; 420 req.psm = l2cap_pi(sk)->psm;
416 421
417 l2cap_pi(sk)->ident = l2cap_get_ident(conn); 422 l2cap_pi(sk)->ident = l2cap_get_ident(conn);
423 l2cap_pi(sk)->conf_state |= L2CAP_CONF_CONNECT_PEND;
418 424
419 l2cap_send_cmd(conn, l2cap_pi(sk)->ident, 425 l2cap_send_cmd(conn, l2cap_pi(sk)->ident,
420 L2CAP_CONN_REQ, sizeof(req), &req); 426 L2CAP_CONN_REQ, sizeof(req), &req);
@@ -464,12 +470,14 @@ static void l2cap_conn_start(struct l2cap_conn *conn)
464 } 470 }
465 471
466 if (sk->sk_state == BT_CONNECT) { 472 if (sk->sk_state == BT_CONNECT) {
467 if (l2cap_check_security(sk)) { 473 if (l2cap_check_security(sk) &&
474 __l2cap_no_conn_pending(sk)) {
468 struct l2cap_conn_req req; 475 struct l2cap_conn_req req;
469 req.scid = cpu_to_le16(l2cap_pi(sk)->scid); 476 req.scid = cpu_to_le16(l2cap_pi(sk)->scid);
470 req.psm = l2cap_pi(sk)->psm; 477 req.psm = l2cap_pi(sk)->psm;
471 478
472 l2cap_pi(sk)->ident = l2cap_get_ident(conn); 479 l2cap_pi(sk)->ident = l2cap_get_ident(conn);
480 l2cap_pi(sk)->conf_state |= L2CAP_CONF_CONNECT_PEND;
473 481
474 l2cap_send_cmd(conn, l2cap_pi(sk)->ident, 482 l2cap_send_cmd(conn, l2cap_pi(sk)->ident,
475 L2CAP_CONN_REQ, sizeof(req), &req); 483 L2CAP_CONN_REQ, sizeof(req), &req);
@@ -2912,7 +2920,6 @@ static inline int l2cap_connect_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hd
2912 l2cap_pi(sk)->ident = 0; 2920 l2cap_pi(sk)->ident = 0;
2913 l2cap_pi(sk)->dcid = dcid; 2921 l2cap_pi(sk)->dcid = dcid;
2914 l2cap_pi(sk)->conf_state |= L2CAP_CONF_REQ_SENT; 2922 l2cap_pi(sk)->conf_state |= L2CAP_CONF_REQ_SENT;
2915
2916 l2cap_pi(sk)->conf_state &= ~L2CAP_CONF_CONNECT_PEND; 2923 l2cap_pi(sk)->conf_state &= ~L2CAP_CONF_CONNECT_PEND;
2917 2924
2918 l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ, 2925 l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ,
@@ -4404,6 +4411,7 @@ static int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt)
4404 req.psm = l2cap_pi(sk)->psm; 4411 req.psm = l2cap_pi(sk)->psm;
4405 4412
4406 l2cap_pi(sk)->ident = l2cap_get_ident(conn); 4413 l2cap_pi(sk)->ident = l2cap_get_ident(conn);
4414 l2cap_pi(sk)->conf_state |= L2CAP_CONF_CONNECT_PEND;
4407 4415
4408 l2cap_send_cmd(conn, l2cap_pi(sk)->ident, 4416 l2cap_send_cmd(conn, l2cap_pi(sk)->ident,
4409 L2CAP_CONN_REQ, sizeof(req), &req); 4417 L2CAP_CONN_REQ, sizeof(req), &req);
diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c
index eedf2c94820e..753fc4221f3c 100644
--- a/net/bridge/br_device.c
+++ b/net/bridge/br_device.c
@@ -217,14 +217,6 @@ static bool br_devices_support_netpoll(struct net_bridge *br)
217 return count != 0 && ret; 217 return count != 0 && ret;
218} 218}
219 219
220static void br_poll_controller(struct net_device *br_dev)
221{
222 struct netpoll *np = br_dev->npinfo->netpoll;
223
224 if (np->real_dev != br_dev)
225 netpoll_poll_dev(np->real_dev);
226}
227
228void br_netpoll_cleanup(struct net_device *dev) 220void br_netpoll_cleanup(struct net_device *dev)
229{ 221{
230 struct net_bridge *br = netdev_priv(dev); 222 struct net_bridge *br = netdev_priv(dev);
@@ -295,7 +287,6 @@ static const struct net_device_ops br_netdev_ops = {
295 .ndo_do_ioctl = br_dev_ioctl, 287 .ndo_do_ioctl = br_dev_ioctl,
296#ifdef CONFIG_NET_POLL_CONTROLLER 288#ifdef CONFIG_NET_POLL_CONTROLLER
297 .ndo_netpoll_cleanup = br_netpoll_cleanup, 289 .ndo_netpoll_cleanup = br_netpoll_cleanup,
298 .ndo_poll_controller = br_poll_controller,
299#endif 290#endif
300}; 291};
301 292
diff --git a/net/bridge/br_forward.c b/net/bridge/br_forward.c
index a4e72a89e4ff..595da45f9088 100644
--- a/net/bridge/br_forward.c
+++ b/net/bridge/br_forward.c
@@ -50,14 +50,7 @@ int br_dev_queue_push_xmit(struct sk_buff *skb)
50 kfree_skb(skb); 50 kfree_skb(skb);
51 else { 51 else {
52 skb_push(skb, ETH_HLEN); 52 skb_push(skb, ETH_HLEN);
53 53 dev_queue_xmit(skb);
54#ifdef CONFIG_NET_POLL_CONTROLLER
55 if (unlikely(skb->dev->priv_flags & IFF_IN_NETPOLL)) {
56 netpoll_send_skb(skb->dev->npinfo->netpoll, skb);
57 skb->dev->priv_flags &= ~IFF_IN_NETPOLL;
58 } else
59#endif
60 dev_queue_xmit(skb);
61 } 54 }
62 } 55 }
63 56
@@ -73,23 +66,9 @@ int br_forward_finish(struct sk_buff *skb)
73 66
74static void __br_deliver(const struct net_bridge_port *to, struct sk_buff *skb) 67static void __br_deliver(const struct net_bridge_port *to, struct sk_buff *skb)
75{ 68{
76#ifdef CONFIG_NET_POLL_CONTROLLER
77 struct net_bridge *br = to->br;
78 if (unlikely(br->dev->priv_flags & IFF_IN_NETPOLL)) {
79 struct netpoll *np;
80 to->dev->npinfo = skb->dev->npinfo;
81 np = skb->dev->npinfo->netpoll;
82 np->real_dev = np->dev = to->dev;
83 to->dev->priv_flags |= IFF_IN_NETPOLL;
84 }
85#endif
86 skb->dev = to->dev; 69 skb->dev = to->dev;
87 NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev, 70 NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev,
88 br_forward_finish); 71 br_forward_finish);
89#ifdef CONFIG_NET_POLL_CONTROLLER
90 if (skb->dev->npinfo)
91 skb->dev->npinfo->netpoll->dev = br->dev;
92#endif
93} 72}
94 73
95static void __br_forward(const struct net_bridge_port *to, struct sk_buff *skb) 74static void __br_forward(const struct net_bridge_port *to, struct sk_buff *skb)
diff --git a/net/core/dev.c b/net/core/dev.c
index 723a34710ad4..0ea10f849be8 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1911,8 +1911,16 @@ static int dev_gso_segment(struct sk_buff *skb)
1911 */ 1911 */
1912static inline void skb_orphan_try(struct sk_buff *skb) 1912static inline void skb_orphan_try(struct sk_buff *skb)
1913{ 1913{
1914 if (!skb_tx(skb)->flags) 1914 struct sock *sk = skb->sk;
1915
1916 if (sk && !skb_tx(skb)->flags) {
1917 /* skb_tx_hash() wont be able to get sk.
1918 * We copy sk_hash into skb->rxhash
1919 */
1920 if (!skb->rxhash)
1921 skb->rxhash = sk->sk_hash;
1915 skb_orphan(skb); 1922 skb_orphan(skb);
1923 }
1916} 1924}
1917 1925
1918int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev, 1926int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev,
@@ -1998,8 +2006,7 @@ u16 skb_tx_hash(const struct net_device *dev, const struct sk_buff *skb)
1998 if (skb->sk && skb->sk->sk_hash) 2006 if (skb->sk && skb->sk->sk_hash)
1999 hash = skb->sk->sk_hash; 2007 hash = skb->sk->sk_hash;
2000 else 2008 else
2001 hash = (__force u16) skb->protocol; 2009 hash = (__force u16) skb->protocol ^ skb->rxhash;
2002
2003 hash = jhash_1word(hash, hashrnd); 2010 hash = jhash_1word(hash, hashrnd);
2004 2011
2005 return (u16) (((u64) hash * dev->real_num_tx_queues) >> 32); 2012 return (u16) (((u64) hash * dev->real_num_tx_queues) >> 32);
@@ -2022,12 +2029,11 @@ static inline u16 dev_cap_txqueue(struct net_device *dev, u16 queue_index)
2022static struct netdev_queue *dev_pick_tx(struct net_device *dev, 2029static struct netdev_queue *dev_pick_tx(struct net_device *dev,
2023 struct sk_buff *skb) 2030 struct sk_buff *skb)
2024{ 2031{
2025 u16 queue_index; 2032 int queue_index;
2026 struct sock *sk = skb->sk; 2033 struct sock *sk = skb->sk;
2027 2034
2028 if (sk_tx_queue_recorded(sk)) { 2035 queue_index = sk_tx_queue_get(sk);
2029 queue_index = sk_tx_queue_get(sk); 2036 if (queue_index < 0) {
2030 } else {
2031 const struct net_device_ops *ops = dev->netdev_ops; 2037 const struct net_device_ops *ops = dev->netdev_ops;
2032 2038
2033 if (ops->ndo_select_queue) { 2039 if (ops->ndo_select_queue) {
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index 6ba1c0eece03..a4e0a7482c2b 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -949,7 +949,10 @@ static void neigh_update_hhs(struct neighbour *neigh)
949{ 949{
950 struct hh_cache *hh; 950 struct hh_cache *hh;
951 void (*update)(struct hh_cache*, const struct net_device*, const unsigned char *) 951 void (*update)(struct hh_cache*, const struct net_device*, const unsigned char *)
952 = neigh->dev->header_ops->cache_update; 952 = NULL;
953
954 if (neigh->dev->header_ops)
955 update = neigh->dev->header_ops->cache_update;
953 956
954 if (update) { 957 if (update) {
955 for (hh = neigh->hh; hh; hh = hh->hh_next) { 958 for (hh = neigh->hh; hh; hh = hh->hh_next) {
diff --git a/net/dsa/Kconfig b/net/dsa/Kconfig
index c51b55400dc5..11201784d29a 100644
--- a/net/dsa/Kconfig
+++ b/net/dsa/Kconfig
@@ -1,7 +1,7 @@
1menuconfig NET_DSA 1menuconfig NET_DSA
2 bool "Distributed Switch Architecture support" 2 bool "Distributed Switch Architecture support"
3 default n 3 default n
4 depends on EXPERIMENTAL && !S390 4 depends on EXPERIMENTAL && NET_ETHERNET && !S390
5 select PHYLIB 5 select PHYLIB
6 ---help--- 6 ---help---
7 This allows you to use hardware switch chips that use 7 This allows you to use hardware switch chips that use
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index 757f25eb9b4b..7f6273506eea 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -442,8 +442,10 @@ static netdev_tx_t reg_vif_xmit(struct sk_buff *skb, struct net_device *dev)
442 int err; 442 int err;
443 443
444 err = ipmr_fib_lookup(net, &fl, &mrt); 444 err = ipmr_fib_lookup(net, &fl, &mrt);
445 if (err < 0) 445 if (err < 0) {
446 kfree_skb(skb);
446 return err; 447 return err;
448 }
447 449
448 read_lock(&mrt_lock); 450 read_lock(&mrt_lock);
449 dev->stats.tx_bytes += skb->len; 451 dev->stats.tx_bytes += skb->len;
@@ -1728,8 +1730,10 @@ int ip_mr_input(struct sk_buff *skb)
1728 goto dont_forward; 1730 goto dont_forward;
1729 1731
1730 err = ipmr_fib_lookup(net, &skb_rtable(skb)->fl, &mrt); 1732 err = ipmr_fib_lookup(net, &skb_rtable(skb)->fl, &mrt);
1731 if (err < 0) 1733 if (err < 0) {
1734 kfree_skb(skb);
1732 return err; 1735 return err;
1736 }
1733 1737
1734 if (!local) { 1738 if (!local) {
1735 if (IPCB(skb)->opt.router_alert) { 1739 if (IPCB(skb)->opt.router_alert) {
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 6596b4feeddc..65afeaec15b7 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -608,6 +608,7 @@ ssize_t tcp_splice_read(struct socket *sock, loff_t *ppos,
608 ssize_t spliced; 608 ssize_t spliced;
609 int ret; 609 int ret;
610 610
611 sock_rps_record_flow(sk);
611 /* 612 /*
612 * We can't seek on a socket input 613 * We can't seek on a socket input
613 */ 614 */
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index b4ed957f201a..7ed9dc1042d1 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -2208,6 +2208,9 @@ void tcp_xmit_retransmit_queue(struct sock *sk)
2208 int mib_idx; 2208 int mib_idx;
2209 int fwd_rexmitting = 0; 2209 int fwd_rexmitting = 0;
2210 2210
2211 if (!tp->packets_out)
2212 return;
2213
2211 if (!tp->lost_out) 2214 if (!tp->lost_out)
2212 tp->retransmit_high = tp->snd_una; 2215 tp->retransmit_high = tp->snd_una;
2213 2216
diff --git a/net/ipv6/mip6.c b/net/ipv6/mip6.c
index 2794b6002836..d6e9599d0705 100644
--- a/net/ipv6/mip6.c
+++ b/net/ipv6/mip6.c
@@ -347,11 +347,12 @@ static const struct xfrm_type mip6_destopt_type =
347 347
348static int mip6_rthdr_input(struct xfrm_state *x, struct sk_buff *skb) 348static int mip6_rthdr_input(struct xfrm_state *x, struct sk_buff *skb)
349{ 349{
350 struct ipv6hdr *iph = ipv6_hdr(skb);
350 struct rt2_hdr *rt2 = (struct rt2_hdr *)skb->data; 351 struct rt2_hdr *rt2 = (struct rt2_hdr *)skb->data;
351 int err = rt2->rt_hdr.nexthdr; 352 int err = rt2->rt_hdr.nexthdr;
352 353
353 spin_lock(&x->lock); 354 spin_lock(&x->lock);
354 if (!ipv6_addr_equal(&rt2->addr, (struct in6_addr *)x->coaddr) && 355 if (!ipv6_addr_equal(&iph->daddr, (struct in6_addr *)x->coaddr) &&
355 !ipv6_addr_any((struct in6_addr *)x->coaddr)) 356 !ipv6_addr_any((struct in6_addr *)x->coaddr))
356 err = -ENOENT; 357 err = -ENOENT;
357 spin_unlock(&x->lock); 358 spin_unlock(&x->lock);
diff --git a/net/phonet/pep.c b/net/phonet/pep.c
index 94d72e85a475..b2a3ae6cad78 100644
--- a/net/phonet/pep.c
+++ b/net/phonet/pep.c
@@ -698,6 +698,7 @@ static struct sock *pep_sock_accept(struct sock *sk, int flags, int *errp)
698 newsk = NULL; 698 newsk = NULL;
699 goto out; 699 goto out;
700 } 700 }
701 kfree_skb(oskb);
701 702
702 sock_hold(sk); 703 sock_hold(sk);
703 pep_sk(newsk)->listener = sk; 704 pep_sk(newsk)->listener = sk;
diff --git a/net/sched/act_nat.c b/net/sched/act_nat.c
index 570949417f38..724553e8ed7b 100644
--- a/net/sched/act_nat.c
+++ b/net/sched/act_nat.c
@@ -205,7 +205,7 @@ static int tcf_nat(struct sk_buff *skb, struct tc_action *a,
205 { 205 {
206 struct icmphdr *icmph; 206 struct icmphdr *icmph;
207 207
208 if (!pskb_may_pull(skb, ihl + sizeof(*icmph) + sizeof(*iph))) 208 if (!pskb_may_pull(skb, ihl + sizeof(*icmph)))
209 goto drop; 209 goto drop;
210 210
211 icmph = (void *)(skb_network_header(skb) + ihl); 211 icmph = (void *)(skb_network_header(skb) + ihl);
@@ -215,6 +215,9 @@ static int tcf_nat(struct sk_buff *skb, struct tc_action *a,
215 (icmph->type != ICMP_PARAMETERPROB)) 215 (icmph->type != ICMP_PARAMETERPROB))
216 break; 216 break;
217 217
218 if (!pskb_may_pull(skb, ihl + sizeof(*icmph) + sizeof(*iph)))
219 goto drop;
220
218 iph = (void *)(icmph + 1); 221 iph = (void *)(icmph + 1);
219 if (egress) 222 if (egress)
220 addr = iph->daddr; 223 addr = iph->daddr;
diff --git a/net/sunrpc/auth.c b/net/sunrpc/auth.c
index 73affb8624fa..8dc47f1d0001 100644
--- a/net/sunrpc/auth.c
+++ b/net/sunrpc/auth.c
@@ -267,7 +267,7 @@ rpcauth_prune_expired(struct list_head *free, int nr_to_scan)
267 * Run memory cache shrinker. 267 * Run memory cache shrinker.
268 */ 268 */
269static int 269static int
270rpcauth_cache_shrinker(int nr_to_scan, gfp_t gfp_mask) 270rpcauth_cache_shrinker(struct shrinker *shrink, int nr_to_scan, gfp_t gfp_mask)
271{ 271{
272 LIST_HEAD(free); 272 LIST_HEAD(free);
273 int res; 273 int res;
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index af1c173be4ad..a7ec5a8a2380 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -1594,8 +1594,8 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
1594 1594
1595 /* Try to instantiate a bundle */ 1595 /* Try to instantiate a bundle */
1596 err = xfrm_tmpl_resolve(pols, num_pols, fl, xfrm, family); 1596 err = xfrm_tmpl_resolve(pols, num_pols, fl, xfrm, family);
1597 if (err < 0) { 1597 if (err <= 0) {
1598 if (err != -EAGAIN) 1598 if (err != 0 && err != -EAGAIN)
1599 XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTPOLERROR); 1599 XFRM_INC_STATS(net, LINUX_MIB_XFRMOUTPOLERROR);
1600 return ERR_PTR(err); 1600 return ERR_PTR(err);
1601 } 1601 }
@@ -1678,6 +1678,13 @@ xfrm_bundle_lookup(struct net *net, struct flowi *fl, u16 family, u8 dir,
1678 goto make_dummy_bundle; 1678 goto make_dummy_bundle;
1679 dst_hold(&xdst->u.dst); 1679 dst_hold(&xdst->u.dst);
1680 return oldflo; 1680 return oldflo;
1681 } else if (new_xdst == NULL) {
1682 num_xfrms = 0;
1683 if (oldflo == NULL)
1684 goto make_dummy_bundle;
1685 xdst->num_xfrms = 0;
1686 dst_hold(&xdst->u.dst);
1687 return oldflo;
1681 } 1688 }
1682 1689
1683 /* Kill the previous bundle */ 1690 /* Kill the previous bundle */
@@ -1760,6 +1767,10 @@ restart:
1760 xfrm_pols_put(pols, num_pols); 1767 xfrm_pols_put(pols, num_pols);
1761 err = PTR_ERR(xdst); 1768 err = PTR_ERR(xdst);
1762 goto dropdst; 1769 goto dropdst;
1770 } else if (xdst == NULL) {
1771 num_xfrms = 0;
1772 drop_pols = num_pols;
1773 goto no_transform;
1763 } 1774 }
1764 1775
1765 spin_lock_bh(&xfrm_policy_sk_bundle_lock); 1776 spin_lock_bh(&xfrm_policy_sk_bundle_lock);
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index 31ac5538fe7e..5da30eb6ad00 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -83,8 +83,8 @@ config SND_SOC_ALL_CODECS
83 83
84config SND_SOC_WM_HUBS 84config SND_SOC_WM_HUBS
85 tristate 85 tristate
86 default y if SND_SOC_WM8993=y 86 default y if SND_SOC_WM8993=y || SND_SOC_WM8994=y
87 default m if SND_SOC_WM8993=m 87 default m if SND_SOC_WM8993=m || SND_SOC_WM8994=m
88 88
89config SND_SOC_AC97_CODEC 89config SND_SOC_AC97_CODEC
90 tristate 90 tristate
diff --git a/sound/soc/codecs/wm8727.c b/sound/soc/codecs/wm8727.c
index 1072621e93fd..9d1df2628136 100644
--- a/sound/soc/codecs/wm8727.c
+++ b/sound/soc/codecs/wm8727.c
@@ -127,6 +127,8 @@ static __devinit int wm8727_platform_probe(struct platform_device *pdev)
127 goto err_codec; 127 goto err_codec;
128 } 128 }
129 129
130 return 0;
131
130err_codec: 132err_codec:
131 snd_soc_unregister_codec(codec); 133 snd_soc_unregister_codec(codec);
132err: 134err:
diff --git a/sound/soc/codecs/wm8776.c b/sound/soc/codecs/wm8776.c
index 7e4a627b4c7e..4e212ed62ea6 100644
--- a/sound/soc/codecs/wm8776.c
+++ b/sound/soc/codecs/wm8776.c
@@ -94,7 +94,6 @@ SOC_DAPM_SINGLE("Bypass Switch", WM8776_OUTMUX, 2, 1, 0),
94 94
95static const struct snd_soc_dapm_widget wm8776_dapm_widgets[] = { 95static const struct snd_soc_dapm_widget wm8776_dapm_widgets[] = {
96SND_SOC_DAPM_INPUT("AUX"), 96SND_SOC_DAPM_INPUT("AUX"),
97SND_SOC_DAPM_INPUT("AUX"),
98 97
99SND_SOC_DAPM_INPUT("AIN1"), 98SND_SOC_DAPM_INPUT("AIN1"),
100SND_SOC_DAPM_INPUT("AIN2"), 99SND_SOC_DAPM_INPUT("AIN2"),
diff --git a/sound/soc/codecs/wm8988.c b/sound/soc/codecs/wm8988.c
index 0417dae32e6f..19ad590ca0b3 100644
--- a/sound/soc/codecs/wm8988.c
+++ b/sound/soc/codecs/wm8988.c
@@ -885,7 +885,6 @@ static int wm8988_register(struct wm8988_priv *wm8988,
885 ret = snd_soc_register_dai(&wm8988_dai); 885 ret = snd_soc_register_dai(&wm8988_dai);
886 if (ret != 0) { 886 if (ret != 0) {
887 dev_err(codec->dev, "Failed to register DAI: %d\n", ret); 887 dev_err(codec->dev, "Failed to register DAI: %d\n", ret);
888 snd_soc_unregister_codec(codec);
889 goto err_codec; 888 goto err_codec;
890 } 889 }
891 890
diff --git a/sound/soc/sh/fsi.c b/sound/soc/sh/fsi.c
index 3396a0db06ba..ec4acac49ebd 100644
--- a/sound/soc/sh/fsi.c
+++ b/sound/soc/sh/fsi.c
@@ -683,20 +683,15 @@ static int fsi_dai_startup(struct snd_pcm_substream *substream,
683 683
684 /* clock inversion (CKG2) */ 684 /* clock inversion (CKG2) */
685 data = 0; 685 data = 0;
686 switch (SH_FSI_INVERSION_MASK & flags) { 686 if (SH_FSI_LRM_INV & flags)
687 case SH_FSI_LRM_INV: 687 data |= 1 << 12;
688 data = 1 << 12; 688 if (SH_FSI_BRM_INV & flags)
689 break; 689 data |= 1 << 8;
690 case SH_FSI_BRM_INV: 690 if (SH_FSI_LRS_INV & flags)
691 data = 1 << 8; 691 data |= 1 << 4;
692 break; 692 if (SH_FSI_BRS_INV & flags)
693 case SH_FSI_LRS_INV: 693 data |= 1 << 0;
694 data = 1 << 4; 694
695 break;
696 case SH_FSI_BRS_INV:
697 data = 1 << 0;
698 break;
699 }
700 fsi_reg_write(fsi, CKG2, data); 695 fsi_reg_write(fsi, CKG2, data);
701 696
702 /* do fmt, di fmt */ 697 /* do fmt, di fmt */
@@ -726,15 +721,15 @@ static int fsi_dai_startup(struct snd_pcm_substream *substream,
726 break; 721 break;
727 case SH_FSI_FMT_TDM: 722 case SH_FSI_FMT_TDM:
728 msg = "TDM"; 723 msg = "TDM";
729 data = CR_FMT(CR_TDM) | (fsi->chan - 1);
730 fsi->chan = is_play ? 724 fsi->chan = is_play ?
731 SH_FSI_GET_CH_O(flags) : SH_FSI_GET_CH_I(flags); 725 SH_FSI_GET_CH_O(flags) : SH_FSI_GET_CH_I(flags);
726 data = CR_FMT(CR_TDM) | (fsi->chan - 1);
732 break; 727 break;
733 case SH_FSI_FMT_TDM_DELAY: 728 case SH_FSI_FMT_TDM_DELAY:
734 msg = "TDM Delay"; 729 msg = "TDM Delay";
735 data = CR_FMT(CR_TDM_D) | (fsi->chan - 1);
736 fsi->chan = is_play ? 730 fsi->chan = is_play ?
737 SH_FSI_GET_CH_O(flags) : SH_FSI_GET_CH_I(flags); 731 SH_FSI_GET_CH_O(flags) : SH_FSI_GET_CH_I(flags);
732 data = CR_FMT(CR_TDM_D) | (fsi->chan - 1);
738 break; 733 break;
739 default: 734 default:
740 dev_err(dai->dev, "unknown format.\n"); 735 dev_err(dai->dev, "unknown format.\n");
diff --git a/tools/perf/arch/sparc/Makefile b/tools/perf/arch/sparc/Makefile
new file mode 100644
index 000000000000..15130b50dfe3
--- /dev/null
+++ b/tools/perf/arch/sparc/Makefile
@@ -0,0 +1,4 @@
1ifndef NO_DWARF
2PERF_HAVE_DWARF_REGS := 1
3LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/dwarf-regs.o
4endif
diff --git a/tools/perf/arch/sparc/util/dwarf-regs.c b/tools/perf/arch/sparc/util/dwarf-regs.c
new file mode 100644
index 000000000000..0ab88483720c
--- /dev/null
+++ b/tools/perf/arch/sparc/util/dwarf-regs.c
@@ -0,0 +1,43 @@
1/*
2 * Mapping of DWARF debug register numbers into register names.
3 *
4 * Copyright (C) 2010 David S. Miller <davem@davemloft.net>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#include <libio.h>
13#include <dwarf-regs.h>
14
15#define SPARC_MAX_REGS 96
16
17const char *sparc_regs_table[SPARC_MAX_REGS] = {
18 "%g0", "%g1", "%g2", "%g3", "%g4", "%g5", "%g6", "%g7",
19 "%o0", "%o1", "%o2", "%o3", "%o4", "%o5", "%sp", "%o7",
20 "%l0", "%l1", "%l2", "%l3", "%l4", "%l5", "%l6", "%l7",
21 "%i0", "%i1", "%i2", "%i3", "%i4", "%i5", "%fp", "%i7",
22 "%f0", "%f1", "%f2", "%f3", "%f4", "%f5", "%f6", "%f7",
23 "%f8", "%f9", "%f10", "%f11", "%f12", "%f13", "%f14", "%f15",
24 "%f16", "%f17", "%f18", "%f19", "%f20", "%f21", "%f22", "%f23",
25 "%f24", "%f25", "%f26", "%f27", "%f28", "%f29", "%f30", "%f31",
26 "%f32", "%f33", "%f34", "%f35", "%f36", "%f37", "%f38", "%f39",
27 "%f40", "%f41", "%f42", "%f43", "%f44", "%f45", "%f46", "%f47",
28 "%f48", "%f49", "%f50", "%f51", "%f52", "%f53", "%f54", "%f55",
29 "%f56", "%f57", "%f58", "%f59", "%f60", "%f61", "%f62", "%f63",
30};
31
32/**
33 * get_arch_regstr() - lookup register name from it's DWARF register number
34 * @n: the DWARF register number
35 *
36 * get_arch_regstr() returns the name of the register in struct
37 * regdwarfnum_table from it's DWARF register number. If the register is not
38 * found in the table, this returns NULL;
39 */
40const char *get_arch_regstr(unsigned int n)
41{
42 return (n <= SPARC_MAX_REGS) ? sparc_regs_table[n] : NULL;
43}
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 359205782964..fd7407c7205c 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -107,7 +107,7 @@ static int perf_session__add_hist_entry(struct perf_session *self,
107 goto out_free_syms; 107 goto out_free_syms;
108 err = 0; 108 err = 0;
109 if (symbol_conf.use_callchain) { 109 if (symbol_conf.use_callchain) {
110 err = append_chain(he->callchain, data->callchain, syms); 110 err = append_chain(he->callchain, data->callchain, syms, data->period);
111 if (err) 111 if (err)
112 goto out_free_syms; 112 goto out_free_syms;
113 } 113 }
diff --git a/tools/perf/util/PERF-VERSION-GEN b/tools/perf/util/PERF-VERSION-GEN
index 49ece7921914..97d76562a1a0 100755
--- a/tools/perf/util/PERF-VERSION-GEN
+++ b/tools/perf/util/PERF-VERSION-GEN
@@ -5,17 +5,13 @@ if [ $# -eq 1 ] ; then
5fi 5fi
6 6
7GVF=${OUTPUT}PERF-VERSION-FILE 7GVF=${OUTPUT}PERF-VERSION-FILE
8DEF_VER=v0.0.2.PERF
9 8
10LF=' 9LF='
11' 10'
12 11
13# First see if there is a version file (included in release tarballs), 12# First check if there is a .git to get the version from git describe
14# then try git-describe, then default. 13# otherwise try to get the version from the kernel makefile
15if test -f version 14if test -d ../../.git -o -f ../../.git &&
16then
17 VN=$(cat version) || VN="$DEF_VER"
18elif test -d .git -o -f .git &&
19 VN=$(git describe --abbrev=4 HEAD 2>/dev/null) && 15 VN=$(git describe --abbrev=4 HEAD 2>/dev/null) &&
20 case "$VN" in 16 case "$VN" in
21 *$LF*) (exit 1) ;; 17 *$LF*) (exit 1) ;;
@@ -27,7 +23,12 @@ elif test -d .git -o -f .git &&
27then 23then
28 VN=$(echo "$VN" | sed -e 's/-/./g'); 24 VN=$(echo "$VN" | sed -e 's/-/./g');
29else 25else
30 VN="$DEF_VER" 26 eval `grep '^VERSION\s*=' ../../Makefile|tr -d ' '`
27 eval `grep '^PATCHLEVEL\s*=' ../../Makefile|tr -d ' '`
28 eval `grep '^SUBLEVEL\s*=' ../../Makefile|tr -d ' '`
29 eval `grep '^EXTRAVERSION\s*=' ../../Makefile|tr -d ' '`
30
31 VN="${VERSION}.${PATCHLEVEL}.${SUBLEVEL}${EXTRAVERSION}"
31fi 32fi
32 33
33VN=$(expr "$VN" : v*'\(.*\)') 34VN=$(expr "$VN" : v*'\(.*\)')
diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c
index 62b69ad4aa73..52c777e451ed 100644
--- a/tools/perf/util/callchain.c
+++ b/tools/perf/util/callchain.c
@@ -230,7 +230,7 @@ fill_node(struct callchain_node *node, struct resolved_chain *chain, int start)
230 230
231static void 231static void
232add_child(struct callchain_node *parent, struct resolved_chain *chain, 232add_child(struct callchain_node *parent, struct resolved_chain *chain,
233 int start) 233 int start, u64 period)
234{ 234{
235 struct callchain_node *new; 235 struct callchain_node *new;
236 236
@@ -238,7 +238,7 @@ add_child(struct callchain_node *parent, struct resolved_chain *chain,
238 fill_node(new, chain, start); 238 fill_node(new, chain, start);
239 239
240 new->children_hit = 0; 240 new->children_hit = 0;
241 new->hit = 1; 241 new->hit = period;
242} 242}
243 243
244/* 244/*
@@ -248,7 +248,8 @@ add_child(struct callchain_node *parent, struct resolved_chain *chain,
248 */ 248 */
249static void 249static void
250split_add_child(struct callchain_node *parent, struct resolved_chain *chain, 250split_add_child(struct callchain_node *parent, struct resolved_chain *chain,
251 struct callchain_list *to_split, int idx_parents, int idx_local) 251 struct callchain_list *to_split, int idx_parents, int idx_local,
252 u64 period)
252{ 253{
253 struct callchain_node *new; 254 struct callchain_node *new;
254 struct list_head *old_tail; 255 struct list_head *old_tail;
@@ -275,41 +276,41 @@ split_add_child(struct callchain_node *parent, struct resolved_chain *chain,
275 /* create a new child for the new branch if any */ 276 /* create a new child for the new branch if any */
276 if (idx_total < chain->nr) { 277 if (idx_total < chain->nr) {
277 parent->hit = 0; 278 parent->hit = 0;
278 add_child(parent, chain, idx_total); 279 add_child(parent, chain, idx_total, period);
279 parent->children_hit++; 280 parent->children_hit += period;
280 } else { 281 } else {
281 parent->hit = 1; 282 parent->hit = period;
282 } 283 }
283} 284}
284 285
285static int 286static int
286__append_chain(struct callchain_node *root, struct resolved_chain *chain, 287__append_chain(struct callchain_node *root, struct resolved_chain *chain,
287 unsigned int start); 288 unsigned int start, u64 period);
288 289
289static void 290static void
290__append_chain_children(struct callchain_node *root, 291__append_chain_children(struct callchain_node *root,
291 struct resolved_chain *chain, 292 struct resolved_chain *chain,
292 unsigned int start) 293 unsigned int start, u64 period)
293{ 294{
294 struct callchain_node *rnode; 295 struct callchain_node *rnode;
295 296
296 /* lookup in childrens */ 297 /* lookup in childrens */
297 chain_for_each_child(rnode, root) { 298 chain_for_each_child(rnode, root) {
298 unsigned int ret = __append_chain(rnode, chain, start); 299 unsigned int ret = __append_chain(rnode, chain, start, period);
299 300
300 if (!ret) 301 if (!ret)
301 goto inc_children_hit; 302 goto inc_children_hit;
302 } 303 }
303 /* nothing in children, add to the current node */ 304 /* nothing in children, add to the current node */
304 add_child(root, chain, start); 305 add_child(root, chain, start, period);
305 306
306inc_children_hit: 307inc_children_hit:
307 root->children_hit++; 308 root->children_hit += period;
308} 309}
309 310
310static int 311static int
311__append_chain(struct callchain_node *root, struct resolved_chain *chain, 312__append_chain(struct callchain_node *root, struct resolved_chain *chain,
312 unsigned int start) 313 unsigned int start, u64 period)
313{ 314{
314 struct callchain_list *cnode; 315 struct callchain_list *cnode;
315 unsigned int i = start; 316 unsigned int i = start;
@@ -345,18 +346,18 @@ __append_chain(struct callchain_node *root, struct resolved_chain *chain,
345 346
346 /* we match only a part of the node. Split it and add the new chain */ 347 /* we match only a part of the node. Split it and add the new chain */
347 if (i - start < root->val_nr) { 348 if (i - start < root->val_nr) {
348 split_add_child(root, chain, cnode, start, i - start); 349 split_add_child(root, chain, cnode, start, i - start, period);
349 return 0; 350 return 0;
350 } 351 }
351 352
352 /* we match 100% of the path, increment the hit */ 353 /* we match 100% of the path, increment the hit */
353 if (i - start == root->val_nr && i == chain->nr) { 354 if (i - start == root->val_nr && i == chain->nr) {
354 root->hit++; 355 root->hit += period;
355 return 0; 356 return 0;
356 } 357 }
357 358
358 /* We match the node and still have a part remaining */ 359 /* We match the node and still have a part remaining */
359 __append_chain_children(root, chain, i); 360 __append_chain_children(root, chain, i, period);
360 361
361 return 0; 362 return 0;
362} 363}
@@ -380,7 +381,7 @@ static void filter_context(struct ip_callchain *old, struct resolved_chain *new,
380 381
381 382
382int append_chain(struct callchain_node *root, struct ip_callchain *chain, 383int append_chain(struct callchain_node *root, struct ip_callchain *chain,
383 struct map_symbol *syms) 384 struct map_symbol *syms, u64 period)
384{ 385{
385 struct resolved_chain *filtered; 386 struct resolved_chain *filtered;
386 387
@@ -397,7 +398,7 @@ int append_chain(struct callchain_node *root, struct ip_callchain *chain,
397 if (!filtered->nr) 398 if (!filtered->nr)
398 goto end; 399 goto end;
399 400
400 __append_chain_children(root, filtered, 0); 401 __append_chain_children(root, filtered, 0, period);
401end: 402end:
402 free(filtered); 403 free(filtered);
403 404
diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h
index 1ca73e4a2723..f2e9ee164bd8 100644
--- a/tools/perf/util/callchain.h
+++ b/tools/perf/util/callchain.h
@@ -49,6 +49,9 @@ static inline void callchain_init(struct callchain_node *node)
49 INIT_LIST_HEAD(&node->brothers); 49 INIT_LIST_HEAD(&node->brothers);
50 INIT_LIST_HEAD(&node->children); 50 INIT_LIST_HEAD(&node->children);
51 INIT_LIST_HEAD(&node->val); 51 INIT_LIST_HEAD(&node->val);
52
53 node->parent = NULL;
54 node->hit = 0;
52} 55}
53 56
54static inline u64 cumul_hits(struct callchain_node *node) 57static inline u64 cumul_hits(struct callchain_node *node)
@@ -58,7 +61,7 @@ static inline u64 cumul_hits(struct callchain_node *node)
58 61
59int register_callchain_param(struct callchain_param *param); 62int register_callchain_param(struct callchain_param *param);
60int append_chain(struct callchain_node *root, struct ip_callchain *chain, 63int append_chain(struct callchain_node *root, struct ip_callchain *chain,
61 struct map_symbol *syms); 64 struct map_symbol *syms, u64 period);
62 65
63bool ip_callchain__valid(struct ip_callchain *chain, event_t *event); 66bool ip_callchain__valid(struct ip_callchain *chain, event_t *event);
64#endif /* __PERF_CALLCHAIN_H */ 67#endif /* __PERF_CALLCHAIN_H */