aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-11-12 00:34:19 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-11-12 00:34:19 -0500
commit66a173b926891023e34e78cb32f4681d19777e01 (patch)
treee6018f50fbceea7c07e6e27368ee817f9adb34f2
parent11db81a59d0b2e563e30512cd76f23d0db384780 (diff)
parent0c4888ef1d8a8b82c29075ce7e257ff795af15c7 (diff)
Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc
Pull powerpc updates from Benjamin Herrenschmidt: "The bulk of this is LE updates. One should now be able to build an LE kernel and even run some things in it. I'm still sitting on a handful of patches to enable the new ABI that I *might* still send this merge window around, but due to the incertainty (they are pretty fresh) I want to keep them separate. Other notable changes are some infrastructure bits to better handle PCI pass-through under KVM, some bits and pieces added to the new PowerNV platform support such as access to the CPU SCOM bus via sysfs, and support for EEH error handling on PHB3 (Power8 PCIe). We also grew arch_get_random_long() for both pseries and powernv when running on P7+ and P8, exploiting the HW rng. And finally various embedded updates from freescale" * 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc: (154 commits) powerpc: Fix fatal SLB miss when restoring PPR powerpc/powernv: Reserve the correct PE number powerpc/powernv: Add PE to its own PELTV powerpc/powernv: Add support for indirect XSCOM via debugfs powerpc/scom: Improve debugfs interface powerpc/scom: Enable 64-bit addresses powerpc/boot: Properly handle the base "of" boot wrapper powerpc/bpf: Support MOD operation powerpc/bpf: Fix DIVWU instruction opcode of: Move definition of of_find_next_cache_node into common code. powerpc: Remove big endianness assumption in of_find_next_cache_node powerpc/tm: Remove interrupt disable in __switch_to() powerpc: word-at-a-time optimization for 64-bit Little Endian powerpc/bpf: BPF JIT compiler for 64-bit Little Endian powerpc: Only save/restore SDR1 if in hypervisor mode powerpc/pmu: Fix ADB_PMU_LED_IDE dependencies powerpc/nvram: Fix endian issue when using the partition length powerpc/nvram: Fix endian issue when reading the NVRAM size powerpc/nvram: Scan partitions only once powerpc/mpc512x: remove unnecessary #if ...
-rw-r--r--arch/powerpc/Kconfig12
-rw-r--r--arch/powerpc/Makefile37
-rw-r--r--arch/powerpc/boot/Makefile3
-rw-r--r--arch/powerpc/boot/dts/b4860emu.dts218
-rw-r--r--arch/powerpc/boot/dts/b4qds.dtsi51
-rw-r--r--arch/powerpc/boot/dts/c293pcie.dts1
-rw-r--r--arch/powerpc/boot/dts/fsl/b4420si-pre.dtsi2
-rw-r--r--arch/powerpc/boot/dts/fsl/b4860si-post.dtsi2
-rw-r--r--arch/powerpc/boot/dts/fsl/b4860si-pre.dtsi2
-rw-r--r--arch/powerpc/boot/dts/fsl/bsc9131si-post.dtsi2
-rw-r--r--arch/powerpc/boot/dts/fsl/bsc9131si-pre.dtsi3
-rw-r--r--arch/powerpc/boot/dts/t4240emu.dts268
-rw-r--r--arch/powerpc/boot/dts/t4240qds.dts73
-rwxr-xr-xarch/powerpc/boot/wrapper8
-rw-r--r--arch/powerpc/configs/corenet32_smp_defconfig7
-rw-r--r--arch/powerpc/configs/corenet64_smp_defconfig5
-rw-r--r--arch/powerpc/configs/mpc85xx_defconfig1
-rw-r--r--arch/powerpc/configs/mpc85xx_smp_defconfig1
-rw-r--r--arch/powerpc/configs/ppc64_defconfig27
-rw-r--r--arch/powerpc/configs/ppc64e_defconfig12
-rw-r--r--arch/powerpc/configs/ppc6xx_defconfig2
-rw-r--r--arch/powerpc/configs/pseries_defconfig25
-rw-r--r--arch/powerpc/include/asm/archrandom.h32
-rw-r--r--arch/powerpc/include/asm/checksum.h5
-rw-r--r--arch/powerpc/include/asm/emulated_ops.h1
-rw-r--r--arch/powerpc/include/asm/hvsi.h16
-rw-r--r--arch/powerpc/include/asm/io.h69
-rw-r--r--arch/powerpc/include/asm/lppaca.h12
-rw-r--r--arch/powerpc/include/asm/machdep.h16
-rw-r--r--arch/powerpc/include/asm/mmu-hash64.h4
-rw-r--r--arch/powerpc/include/asm/opal.h109
-rw-r--r--arch/powerpc/include/asm/page.h4
-rw-r--r--arch/powerpc/include/asm/pgtable-ppc64.h2
-rw-r--r--arch/powerpc/include/asm/ppc-opcode.h8
-rw-r--r--arch/powerpc/include/asm/ppc_asm.h142
-rw-r--r--arch/powerpc/include/asm/processor.h91
-rw-r--r--arch/powerpc/include/asm/prom.h3
-rw-r--r--arch/powerpc/include/asm/reg.h7
-rw-r--r--arch/powerpc/include/asm/reg_booke.h8
-rw-r--r--arch/powerpc/include/asm/scom.h23
-rw-r--r--arch/powerpc/include/asm/setup.h4
-rw-r--r--arch/powerpc/include/asm/sfp-machine.h2
-rw-r--r--arch/powerpc/include/asm/string.h4
-rw-r--r--arch/powerpc/include/asm/switch_to.h1
-rw-r--r--arch/powerpc/include/asm/word-at-a-time.h78
-rw-r--r--arch/powerpc/include/asm/xor.h67
-rw-r--r--arch/powerpc/include/uapi/asm/byteorder.h4
-rw-r--r--arch/powerpc/kernel/align.c173
-rw-r--r--arch/powerpc/kernel/asm-offsets.c29
-rw-r--r--arch/powerpc/kernel/eeh.c6
-rw-r--r--arch/powerpc/kernel/entry_64.S50
-rw-r--r--arch/powerpc/kernel/exceptions-64e.S6
-rw-r--r--arch/powerpc/kernel/fpu.S86
-rw-r--r--arch/powerpc/kernel/ftrace.c4
-rw-r--r--arch/powerpc/kernel/head_64.S3
-rw-r--r--arch/powerpc/kernel/head_8xx.S3
-rw-r--r--arch/powerpc/kernel/head_fsl_booke.S10
-rw-r--r--arch/powerpc/kernel/kgdb.c6
-rw-r--r--arch/powerpc/kernel/legacy_serial.c2
-rw-r--r--arch/powerpc/kernel/machine_kexec_64.c2
-rw-r--r--arch/powerpc/kernel/misc_32.S14
-rw-r--r--arch/powerpc/kernel/module.c3
-rw-r--r--arch/powerpc/kernel/module_32.c3
-rw-r--r--arch/powerpc/kernel/module_64.c19
-rw-r--r--arch/powerpc/kernel/nvram_64.c10
-rw-r--r--arch/powerpc/kernel/paca.c6
-rw-r--r--arch/powerpc/kernel/pci_of_scan.c4
-rw-r--r--arch/powerpc/kernel/ppc_ksyms.c10
-rw-r--r--arch/powerpc/kernel/process.c67
-rw-r--r--arch/powerpc/kernel/prom.c31
-rw-r--r--arch/powerpc/kernel/prom_init.c28
-rw-r--r--arch/powerpc/kernel/ptrace.c209
-rw-r--r--arch/powerpc/kernel/ptrace32.c13
-rw-r--r--arch/powerpc/kernel/rtas_pci.c6
-rw-r--r--arch/powerpc/kernel/setup-common.c2
-rw-r--r--arch/powerpc/kernel/setup.h9
-rw-r--r--arch/powerpc/kernel/setup_32.c2
-rw-r--r--arch/powerpc/kernel/setup_64.c2
-rw-r--r--arch/powerpc/kernel/signal_32.c81
-rw-r--r--arch/powerpc/kernel/signal_64.c32
-rw-r--r--arch/powerpc/kernel/swsusp_asm64.S4
-rw-r--r--arch/powerpc/kernel/tm.S49
-rw-r--r--arch/powerpc/kernel/traps.c56
-rw-r--r--arch/powerpc/kernel/vdso.c3
-rw-r--r--arch/powerpc/kernel/vdso32/vdso32.lds.S4
-rw-r--r--arch/powerpc/kernel/vdso64/vdso64.lds.S4
-rw-r--r--arch/powerpc/kernel/vecemu.c6
-rw-r--r--arch/powerpc/kernel/vector.S80
-rw-r--r--arch/powerpc/kernel/vio.c4
-rw-r--r--arch/powerpc/kvm/Kconfig1
-rw-r--r--arch/powerpc/kvm/book3s_pr.c36
-rw-r--r--arch/powerpc/kvm/booke.c19
-rw-r--r--arch/powerpc/lib/Makefile21
-rw-r--r--arch/powerpc/lib/copyuser_power7.S54
-rw-r--r--arch/powerpc/lib/memcpy_power7.S55
-rw-r--r--arch/powerpc/lib/sstep.c97
-rw-r--r--arch/powerpc/lib/xor_vmx.c177
-rw-r--r--arch/powerpc/mm/hash_native_64.c46
-rw-r--r--arch/powerpc/mm/hash_utils_64.c38
-rw-r--r--arch/powerpc/mm/init_32.c5
-rw-r--r--arch/powerpc/mm/init_64.c51
-rw-r--r--arch/powerpc/mm/numa.c8
-rw-r--r--arch/powerpc/mm/pgtable.c19
-rw-r--r--arch/powerpc/net/bpf_jit.h11
-rw-r--r--arch/powerpc/net/bpf_jit_64.S9
-rw-r--r--arch/powerpc/net/bpf_jit_comp.c37
-rw-r--r--arch/powerpc/platforms/512x/mpc512x_shared.c18
-rw-r--r--arch/powerpc/platforms/52xx/Kconfig2
-rw-r--r--arch/powerpc/platforms/52xx/mpc52xx_pic.c5
-rw-r--r--arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c1
-rw-r--r--arch/powerpc/platforms/85xx/Kconfig101
-rw-r--r--arch/powerpc/platforms/85xx/Makefile8
-rw-r--r--arch/powerpc/platforms/85xx/b4_qds.c102
-rw-r--r--arch/powerpc/platforms/85xx/corenet_ds.c96
-rw-r--r--arch/powerpc/platforms/85xx/corenet_ds.h19
-rw-r--r--arch/powerpc/platforms/85xx/corenet_generic.c182
-rw-r--r--arch/powerpc/platforms/85xx/p1010rdb.c2
-rw-r--r--arch/powerpc/platforms/85xx/p2041_rdb.c87
-rw-r--r--arch/powerpc/platforms/85xx/p3041_ds.c89
-rw-r--r--arch/powerpc/platforms/85xx/p4080_ds.c87
-rw-r--r--arch/powerpc/platforms/85xx/p5020_ds.c93
-rw-r--r--arch/powerpc/platforms/85xx/p5040_ds.c84
-rw-r--r--arch/powerpc/platforms/85xx/t4240_qds.c93
-rw-r--r--arch/powerpc/platforms/8xx/tqm8xx_setup.c4
-rw-r--r--arch/powerpc/platforms/Kconfig.cputype9
-rw-r--r--arch/powerpc/platforms/chrp/nvram.c4
-rw-r--r--arch/powerpc/platforms/embedded6xx/hlwd-pic.c1
-rw-r--r--arch/powerpc/platforms/powernv/Kconfig2
-rw-r--r--arch/powerpc/platforms/powernv/Makefile4
-rw-r--r--arch/powerpc/platforms/powernv/eeh-ioda.c153
-rw-r--r--arch/powerpc/platforms/powernv/eeh-powernv.c5
-rw-r--r--arch/powerpc/platforms/powernv/opal-flash.c667
-rw-r--r--arch/powerpc/platforms/powernv/opal-nvram.c4
-rw-r--r--arch/powerpc/platforms/powernv/opal-rtc.c12
-rw-r--r--arch/powerpc/platforms/powernv/opal-wrappers.S16
-rw-r--r--arch/powerpc/platforms/powernv/opal-xscom.c128
-rw-r--r--arch/powerpc/platforms/powernv/opal.c57
-rw-r--r--arch/powerpc/platforms/powernv/pci-ioda.c110
-rw-r--r--arch/powerpc/platforms/powernv/pci-p5ioc2.c4
-rw-r--r--arch/powerpc/platforms/powernv/pci.c78
-rw-r--r--arch/powerpc/platforms/powernv/pci.h6
-rw-r--r--arch/powerpc/platforms/powernv/rng.c125
-rw-r--r--arch/powerpc/platforms/pseries/Makefile2
-rw-r--r--arch/powerpc/platforms/pseries/iommu.c59
-rw-r--r--arch/powerpc/platforms/pseries/nvram.c10
-rw-r--r--arch/powerpc/platforms/pseries/rng.c44
-rw-r--r--arch/powerpc/platforms/wsp/scom_smp.c18
-rw-r--r--arch/powerpc/platforms/wsp/scom_wsp.c12
-rw-r--r--arch/powerpc/platforms/wsp/wsp.c13
-rw-r--r--arch/powerpc/sysdev/Kconfig2
-rw-r--r--arch/powerpc/sysdev/fsl_pci.c5
-rw-r--r--arch/powerpc/sysdev/fsl_soc.h3
-rw-r--r--arch/powerpc/sysdev/mpic.c8
-rw-r--r--arch/powerpc/sysdev/mv64x60_dev.c2
-rw-r--r--arch/powerpc/sysdev/scom.c168
-rw-r--r--arch/powerpc/sysdev/xics/ics-opal.c17
-rw-r--r--drivers/char/hw_random/Kconfig13
-rw-r--r--drivers/char/hw_random/Makefile1
-rw-r--r--drivers/char/hw_random/powernv-rng.c81
-rw-r--r--drivers/char/hw_random/pseries-rng.c14
-rw-r--r--drivers/macintosh/Kconfig1
-rw-r--r--drivers/of/base.c31
-rw-r--r--drivers/tty/hvc/hvc_opal.c4
-rw-r--r--drivers/tty/hvc/hvsi_lib.c25
-rw-r--r--include/linux/hashtable.h15
-rw-r--r--include/linux/mm.h14
-rw-r--r--include/linux/of.h2
-rw-r--r--include/linux/page-flags.h4
168 files changed, 4200 insertions, 2125 deletions
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index b365d5cbb722..2f898d63eb96 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -97,7 +97,7 @@ config PPC
97 select VIRT_TO_BUS if !PPC64 97 select VIRT_TO_BUS if !PPC64
98 select HAVE_IDE 98 select HAVE_IDE
99 select HAVE_IOREMAP_PROT 99 select HAVE_IOREMAP_PROT
100 select HAVE_EFFICIENT_UNALIGNED_ACCESS 100 select HAVE_EFFICIENT_UNALIGNED_ACCESS if !CPU_LITTLE_ENDIAN
101 select HAVE_KPROBES 101 select HAVE_KPROBES
102 select HAVE_ARCH_KGDB 102 select HAVE_ARCH_KGDB
103 select HAVE_KRETPROBES 103 select HAVE_KRETPROBES
@@ -140,6 +140,9 @@ config PPC
140 select HAVE_DEBUG_STACKOVERFLOW 140 select HAVE_DEBUG_STACKOVERFLOW
141 select HAVE_IRQ_EXIT_ON_IRQ_STACK 141 select HAVE_IRQ_EXIT_ON_IRQ_STACK
142 142
143config GENERIC_CSUM
144 def_bool CPU_LITTLE_ENDIAN
145
143config EARLY_PRINTK 146config EARLY_PRINTK
144 bool 147 bool
145 default y 148 default y
@@ -405,7 +408,7 @@ config CRASH_DUMP
405 408
406config FA_DUMP 409config FA_DUMP
407 bool "Firmware-assisted dump" 410 bool "Firmware-assisted dump"
408 depends on PPC64 && PPC_RTAS && CRASH_DUMP 411 depends on PPC64 && PPC_RTAS && CRASH_DUMP && KEXEC
409 help 412 help
410 A robust mechanism to get reliable kernel crash dump with 413 A robust mechanism to get reliable kernel crash dump with
411 assistance from firmware. This approach does not use kexec, 414 assistance from firmware. This approach does not use kexec,
@@ -418,7 +421,7 @@ config FA_DUMP
418 421
419config IRQ_ALL_CPUS 422config IRQ_ALL_CPUS
420 bool "Distribute interrupts on all CPUs by default" 423 bool "Distribute interrupts on all CPUs by default"
421 depends on SMP && !MV64360 424 depends on SMP
422 help 425 help
423 This option gives the kernel permission to distribute IRQs across 426 This option gives the kernel permission to distribute IRQs across
424 multiple CPUs. Saying N here will route all IRQs to the first 427 multiple CPUs. Saying N here will route all IRQs to the first
@@ -1010,6 +1013,9 @@ config PHYSICAL_START
1010 default "0x00000000" 1013 default "0x00000000"
1011endif 1014endif
1012 1015
1016config ARCH_RANDOM
1017 def_bool n
1018
1013source "net/Kconfig" 1019source "net/Kconfig"
1014 1020
1015source "drivers/Kconfig" 1021source "drivers/Kconfig"
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 51cfb78d4061..607acf54a425 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -36,17 +36,26 @@ KBUILD_DEFCONFIG := ppc64_defconfig
36endif 36endif
37 37
38ifeq ($(CONFIG_PPC64),y) 38ifeq ($(CONFIG_PPC64),y)
39OLDARCH := ppc64
40
41new_nm := $(shell if $(NM) --help 2>&1 | grep -- '--synthetic' > /dev/null; then echo y; else echo n; fi) 39new_nm := $(shell if $(NM) --help 2>&1 | grep -- '--synthetic' > /dev/null; then echo y; else echo n; fi)
42 40
43ifeq ($(new_nm),y) 41ifeq ($(new_nm),y)
44NM := $(NM) --synthetic 42NM := $(NM) --synthetic
45endif 43endif
44endif
46 45
46ifeq ($(CONFIG_PPC64),y)
47ifeq ($(CONFIG_CPU_LITTLE_ENDIAN),y)
48OLDARCH := ppc64le
49else
50OLDARCH := ppc64
51endif
52else
53ifeq ($(CONFIG_CPU_LITTLE_ENDIAN),y)
54OLDARCH := ppcle
47else 55else
48OLDARCH := ppc 56OLDARCH := ppc
49endif 57endif
58endif
50 59
51# It seems there are times we use this Makefile without 60# It seems there are times we use this Makefile without
52# including the config file, but this replicates the old behaviour 61# including the config file, but this replicates the old behaviour
@@ -56,11 +65,29 @@ endif
56 65
57UTS_MACHINE := $(OLDARCH) 66UTS_MACHINE := $(OLDARCH)
58 67
68ifeq ($(CONFIG_CPU_LITTLE_ENDIAN),y)
69override CC += -mlittle-endian -mno-strict-align
70override AS += -mlittle-endian
71override LD += -EL
72override CROSS32CC += -mlittle-endian
73override CROSS32AS += -mlittle-endian
74LDEMULATION := lppc
75GNUTARGET := powerpcle
76MULTIPLEWORD := -mno-multiple
77else
78override CC += -mbig-endian
79override AS += -mbig-endian
80override LD += -EB
81LDEMULATION := ppc
82GNUTARGET := powerpc
83MULTIPLEWORD := -mmultiple
84endif
85
59ifeq ($(HAS_BIARCH),y) 86ifeq ($(HAS_BIARCH),y)
60override AS += -a$(CONFIG_WORD_SIZE) 87override AS += -a$(CONFIG_WORD_SIZE)
61override LD += -m elf$(CONFIG_WORD_SIZE)ppc 88override LD += -m elf$(CONFIG_WORD_SIZE)$(LDEMULATION)
62override CC += -m$(CONFIG_WORD_SIZE) 89override CC += -m$(CONFIG_WORD_SIZE)
63override AR := GNUTARGET=elf$(CONFIG_WORD_SIZE)-powerpc $(AR) 90override AR := GNUTARGET=elf$(CONFIG_WORD_SIZE)-$(GNUTARGET) $(AR)
64endif 91endif
65 92
66LDFLAGS_vmlinux-y := -Bstatic 93LDFLAGS_vmlinux-y := -Bstatic
@@ -86,7 +113,7 @@ endif
86CFLAGS-$(CONFIG_PPC64) := -mtraceback=no -mcall-aixdesc 113CFLAGS-$(CONFIG_PPC64) := -mtraceback=no -mcall-aixdesc
87CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mcmodel=medium,-mminimal-toc) 114CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mcmodel=medium,-mminimal-toc)
88CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mno-pointers-to-nested-functions) 115CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mno-pointers-to-nested-functions)
89CFLAGS-$(CONFIG_PPC32) := -ffixed-r2 -mmultiple 116CFLAGS-$(CONFIG_PPC32) := -ffixed-r2 $(MULTIPLEWORD)
90 117
91ifeq ($(CONFIG_PPC_BOOK3S_64),y) 118ifeq ($(CONFIG_PPC_BOOK3S_64),y)
92CFLAGS-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=power7,-mtune=power4) 119CFLAGS-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=power7,-mtune=power4)
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 15ca2255f438..ca7f08cc4afd 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -22,7 +22,8 @@ all: $(obj)/zImage
22BOOTCFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ 22BOOTCFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
23 -fno-strict-aliasing -Os -msoft-float -pipe \ 23 -fno-strict-aliasing -Os -msoft-float -pipe \
24 -fomit-frame-pointer -fno-builtin -fPIC -nostdinc \ 24 -fomit-frame-pointer -fno-builtin -fPIC -nostdinc \
25 -isystem $(shell $(CROSS32CC) -print-file-name=include) 25 -isystem $(shell $(CROSS32CC) -print-file-name=include) \
26 -mbig-endian
26BOOTAFLAGS := -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional -nostdinc 27BOOTAFLAGS := -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional -nostdinc
27 28
28ifdef CONFIG_DEBUG_INFO 29ifdef CONFIG_DEBUG_INFO
diff --git a/arch/powerpc/boot/dts/b4860emu.dts b/arch/powerpc/boot/dts/b4860emu.dts
new file mode 100644
index 000000000000..7290021f2dfc
--- /dev/null
+++ b/arch/powerpc/boot/dts/b4860emu.dts
@@ -0,0 +1,218 @@
1/*
2 * B4860 emulator Device Tree Source
3 *
4 * Copyright 2013 Freescale Semiconductor Inc.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * * Neither the name of Freescale Semiconductor nor the
14 * names of its contributors may be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 *
18 * ALTERNATIVELY, this software may be distributed under the terms of the
19 * GNU General Public License ("GPL") as published by the Free Software
20 * Foundation, either version 2 of that License or (at your option) any
21 * later version.
22 *
23 * This software is provided by Freescale Semiconductor "as is" and any
24 * express or implied warranties, including, but not limited to, the implied
25 * warranties of merchantability and fitness for a particular purpose are
26 * disclaimed. In no event shall Freescale Semiconductor be liable for any
27 * direct, indirect, incidental, special, exemplary, or consequential damages
28 * (including, but not limited to, procurement of substitute goods or services;
29 * loss of use, data, or profits; or business interruption) however caused and
30 * on any theory of liability, whether in contract, strict liability, or tort
31 * (including negligence or otherwise) arising in any way out of the use of
32 * this software, even if advised of the possibility of such damage.
33 */
34
35/dts-v1/;
36
37/include/ "fsl/e6500_power_isa.dtsi"
38
39/ {
40 compatible = "fsl,B4860";
41 #address-cells = <2>;
42 #size-cells = <2>;
43 interrupt-parent = <&mpic>;
44
45 aliases {
46 ccsr = &soc;
47
48 serial0 = &serial0;
49 serial1 = &serial1;
50 serial2 = &serial2;
51 serial3 = &serial3;
52 dma0 = &dma0;
53 dma1 = &dma1;
54 };
55
56 cpus {
57 #address-cells = <1>;
58 #size-cells = <0>;
59
60 cpu0: PowerPC,e6500@0 {
61 device_type = "cpu";
62 reg = <0 1>;
63 next-level-cache = <&L2>;
64 };
65 cpu1: PowerPC,e6500@2 {
66 device_type = "cpu";
67 reg = <2 3>;
68 next-level-cache = <&L2>;
69 };
70 cpu2: PowerPC,e6500@4 {
71 device_type = "cpu";
72 reg = <4 5>;
73 next-level-cache = <&L2>;
74 };
75 cpu3: PowerPC,e6500@6 {
76 device_type = "cpu";
77 reg = <6 7>;
78 next-level-cache = <&L2>;
79 };
80 };
81};
82
83/ {
84 model = "fsl,B4860QDS";
85 compatible = "fsl,B4860EMU", "fsl,B4860QDS";
86 #address-cells = <2>;
87 #size-cells = <2>;
88 interrupt-parent = <&mpic>;
89
90 ifc: localbus@ffe124000 {
91 reg = <0xf 0xfe124000 0 0x2000>;
92 ranges = <0 0 0xf 0xe8000000 0x08000000
93 2 0 0xf 0xff800000 0x00010000
94 3 0 0xf 0xffdf0000 0x00008000>;
95
96 nor@0,0 {
97 #address-cells = <1>;
98 #size-cells = <1>;
99 compatible = "cfi-flash";
100 reg = <0x0 0x0 0x8000000>;
101 bank-width = <2>;
102 device-width = <1>;
103 };
104 };
105
106 memory {
107 device_type = "memory";
108 };
109
110 soc: soc@ffe000000 {
111 ranges = <0x00000000 0xf 0xfe000000 0x1000000>;
112 reg = <0xf 0xfe000000 0 0x00001000>;
113 };
114};
115
116&ifc {
117 #address-cells = <2>;
118 #size-cells = <1>;
119 compatible = "fsl,ifc", "simple-bus";
120 interrupts = <25 2 0 0>;
121};
122
123&soc {
124 #address-cells = <1>;
125 #size-cells = <1>;
126 device_type = "soc";
127 compatible = "simple-bus";
128
129 soc-sram-error {
130 compatible = "fsl,soc-sram-error";
131 interrupts = <16 2 1 2>;
132 };
133
134 corenet-law@0 {
135 compatible = "fsl,corenet-law";
136 reg = <0x0 0x1000>;
137 fsl,num-laws = <32>;
138 };
139
140 ddr1: memory-controller@8000 {
141 compatible = "fsl,qoriq-memory-controller-v4.5", "fsl,qoriq-memory-controller";
142 reg = <0x8000 0x1000>;
143 interrupts = <16 2 1 8>;
144 };
145
146 ddr2: memory-controller@9000 {
147 compatible = "fsl,qoriq-memory-controller-v4.5","fsl,qoriq-memory-controller";
148 reg = <0x9000 0x1000>;
149 interrupts = <16 2 1 9>;
150 };
151
152 cpc: l3-cache-controller@10000 {
153 compatible = "fsl,b4-l3-cache-controller", "cache";
154 reg = <0x10000 0x1000
155 0x11000 0x1000>;
156 interrupts = <16 2 1 4>;
157 };
158
159 corenet-cf@18000 {
160 compatible = "fsl,b4-corenet-cf";
161 reg = <0x18000 0x1000>;
162 interrupts = <16 2 1 0>;
163 fsl,ccf-num-csdids = <32>;
164 fsl,ccf-num-snoopids = <32>;
165 };
166
167 iommu@20000 {
168 compatible = "fsl,pamu-v1.0", "fsl,pamu";
169 reg = <0x20000 0x4000>;
170 #address-cells = <1>;
171 #size-cells = <1>;
172 interrupts = <
173 24 2 0 0
174 16 2 1 1>;
175 pamu0: pamu@0 {
176 reg = <0 0x1000>;
177 fsl,primary-cache-geometry = <8 1>;
178 fsl,secondary-cache-geometry = <32 2>;
179 };
180 };
181
182/include/ "fsl/qoriq-mpic.dtsi"
183
184 guts: global-utilities@e0000 {
185 compatible = "fsl,b4-device-config";
186 reg = <0xe0000 0xe00>;
187 fsl,has-rstcr;
188 fsl,liodn-bits = <12>;
189 };
190
191 clockgen: global-utilities@e1000 {
192 compatible = "fsl,b4-clockgen", "fsl,qoriq-clockgen-2.0";
193 reg = <0xe1000 0x1000>;
194 };
195
196/include/ "fsl/qoriq-dma-0.dtsi"
197 dma@100300 {
198 fsl,iommu-parent = <&pamu0>;
199 fsl,liodn-reg = <&guts 0x580>; /* DMA1LIODNR */
200 };
201
202/include/ "fsl/qoriq-dma-1.dtsi"
203 dma@101300 {
204 fsl,iommu-parent = <&pamu0>;
205 fsl,liodn-reg = <&guts 0x584>; /* DMA2LIODNR */
206 };
207
208/include/ "fsl/qoriq-i2c-0.dtsi"
209/include/ "fsl/qoriq-i2c-1.dtsi"
210/include/ "fsl/qoriq-duart-0.dtsi"
211/include/ "fsl/qoriq-duart-1.dtsi"
212
213 L2: l2-cache-controller@c20000 {
214 compatible = "fsl,b4-l2-cache-controller";
215 reg = <0xc20000 0x1000>;
216 next-level-cache = <&cpc>;
217 };
218};
diff --git a/arch/powerpc/boot/dts/b4qds.dtsi b/arch/powerpc/boot/dts/b4qds.dtsi
index e6d2f8f90544..8b47edcfabf0 100644
--- a/arch/powerpc/boot/dts/b4qds.dtsi
+++ b/arch/powerpc/boot/dts/b4qds.dtsi
@@ -120,25 +120,38 @@
120 }; 120 };
121 121
122 i2c@118000 { 122 i2c@118000 {
123 eeprom@50 { 123 mux@77 {
124 compatible = "at24,24c64"; 124 compatible = "nxp,pca9547";
125 reg = <0x50>; 125 reg = <0x77>;
126 }; 126 #address-cells = <1>;
127 eeprom@51 { 127 #size-cells = <0>;
128 compatible = "at24,24c256"; 128
129 reg = <0x51>; 129 i2c@0 {
130 }; 130 #address-cells = <1>;
131 eeprom@53 { 131 #size-cells = <0>;
132 compatible = "at24,24c256"; 132 reg = <0>;
133 reg = <0x53>; 133
134 }; 134 eeprom@50 {
135 eeprom@57 { 135 compatible = "at24,24c64";
136 compatible = "at24,24c256"; 136 reg = <0x50>;
137 reg = <0x57>; 137 };
138 }; 138 eeprom@51 {
139 rtc@68 { 139 compatible = "at24,24c256";
140 compatible = "dallas,ds3232"; 140 reg = <0x51>;
141 reg = <0x68>; 141 };
142 eeprom@53 {
143 compatible = "at24,24c256";
144 reg = <0x53>;
145 };
146 eeprom@57 {
147 compatible = "at24,24c256";
148 reg = <0x57>;
149 };
150 rtc@68 {
151 compatible = "dallas,ds3232";
152 reg = <0x68>;
153 };
154 };
142 }; 155 };
143 }; 156 };
144 157
diff --git a/arch/powerpc/boot/dts/c293pcie.dts b/arch/powerpc/boot/dts/c293pcie.dts
index 1238bda8901f..6681cc21030b 100644
--- a/arch/powerpc/boot/dts/c293pcie.dts
+++ b/arch/powerpc/boot/dts/c293pcie.dts
@@ -45,6 +45,7 @@
45 ifc: ifc@fffe1e000 { 45 ifc: ifc@fffe1e000 {
46 reg = <0xf 0xffe1e000 0 0x2000>; 46 reg = <0xf 0xffe1e000 0 0x2000>;
47 ranges = <0x0 0x0 0xf 0xec000000 0x04000000 47 ranges = <0x0 0x0 0xf 0xec000000 0x04000000
48 0x1 0x0 0xf 0xff800000 0x00010000
48 0x2 0x0 0xf 0xffdf0000 0x00010000>; 49 0x2 0x0 0xf 0xffdf0000 0x00010000>;
49 50
50 }; 51 };
diff --git a/arch/powerpc/boot/dts/fsl/b4420si-pre.dtsi b/arch/powerpc/boot/dts/fsl/b4420si-pre.dtsi
index 7b4426e0a5a5..c6e451affb05 100644
--- a/arch/powerpc/boot/dts/fsl/b4420si-pre.dtsi
+++ b/arch/powerpc/boot/dts/fsl/b4420si-pre.dtsi
@@ -34,6 +34,8 @@
34 34
35/dts-v1/; 35/dts-v1/;
36 36
37/include/ "e6500_power_isa.dtsi"
38
37/ { 39/ {
38 compatible = "fsl,B4420"; 40 compatible = "fsl,B4420";
39 #address-cells = <2>; 41 #address-cells = <2>;
diff --git a/arch/powerpc/boot/dts/fsl/b4860si-post.dtsi b/arch/powerpc/boot/dts/fsl/b4860si-post.dtsi
index e5cf6c81dd66..981397518fc6 100644
--- a/arch/powerpc/boot/dts/fsl/b4860si-post.dtsi
+++ b/arch/powerpc/boot/dts/fsl/b4860si-post.dtsi
@@ -41,7 +41,7 @@
41 41
42&rio { 42&rio {
43 compatible = "fsl,srio"; 43 compatible = "fsl,srio";
44 interrupts = <16 2 1 11>; 44 interrupts = <16 2 1 20>;
45 #address-cells = <2>; 45 #address-cells = <2>;
46 #size-cells = <2>; 46 #size-cells = <2>;
47 fsl,iommu-parent = <&pamu0>; 47 fsl,iommu-parent = <&pamu0>;
diff --git a/arch/powerpc/boot/dts/fsl/b4860si-pre.dtsi b/arch/powerpc/boot/dts/fsl/b4860si-pre.dtsi
index 5263fa46a3fb..9bc26b147900 100644
--- a/arch/powerpc/boot/dts/fsl/b4860si-pre.dtsi
+++ b/arch/powerpc/boot/dts/fsl/b4860si-pre.dtsi
@@ -34,6 +34,8 @@
34 34
35/dts-v1/; 35/dts-v1/;
36 36
37/include/ "e6500_power_isa.dtsi"
38
37/ { 39/ {
38 compatible = "fsl,B4860"; 40 compatible = "fsl,B4860";
39 #address-cells = <2>; 41 #address-cells = <2>;
diff --git a/arch/powerpc/boot/dts/fsl/bsc9131si-post.dtsi b/arch/powerpc/boot/dts/fsl/bsc9131si-post.dtsi
index 5180d9d37989..0c0efa94cfb4 100644
--- a/arch/powerpc/boot/dts/fsl/bsc9131si-post.dtsi
+++ b/arch/powerpc/boot/dts/fsl/bsc9131si-post.dtsi
@@ -130,7 +130,7 @@ usb@22000 {
130 130
131/include/ "pq3-esdhc-0.dtsi" 131/include/ "pq3-esdhc-0.dtsi"
132 sdhc@2e000 { 132 sdhc@2e000 {
133 fsl,sdhci-auto-cmd12; 133 sdhci,auto-cmd12;
134 interrupts = <41 0x2 0 0>; 134 interrupts = <41 0x2 0 0>;
135 }; 135 };
136 136
diff --git a/arch/powerpc/boot/dts/fsl/bsc9131si-pre.dtsi b/arch/powerpc/boot/dts/fsl/bsc9131si-pre.dtsi
index 743e4aeda349..f6ec4a67560c 100644
--- a/arch/powerpc/boot/dts/fsl/bsc9131si-pre.dtsi
+++ b/arch/powerpc/boot/dts/fsl/bsc9131si-pre.dtsi
@@ -33,6 +33,9 @@
33 */ 33 */
34 34
35/dts-v1/; 35/dts-v1/;
36
37/include/ "e500v2_power_isa.dtsi"
38
36/ { 39/ {
37 compatible = "fsl,BSC9131"; 40 compatible = "fsl,BSC9131";
38 #address-cells = <2>; 41 #address-cells = <2>;
diff --git a/arch/powerpc/boot/dts/t4240emu.dts b/arch/powerpc/boot/dts/t4240emu.dts
new file mode 100644
index 000000000000..ee24ab335598
--- /dev/null
+++ b/arch/powerpc/boot/dts/t4240emu.dts
@@ -0,0 +1,268 @@
1/*
2 * T4240 emulator Device Tree Source
3 *
4 * Copyright 2013 Freescale Semiconductor Inc.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * * Neither the name of Freescale Semiconductor nor the
14 * names of its contributors may be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 *
18 * ALTERNATIVELY, this software may be distributed under the terms of the
19 * GNU General Public License ("GPL") as published by the Free Software
20 * Foundation, either version 2 of that License or (at your option) any
21 * later version.
22 *
23 * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor "AS IS" AND ANY
24 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
27 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35/dts-v1/;
36
37/include/ "fsl/e6500_power_isa.dtsi"
38/ {
39 compatible = "fsl,T4240";
40 #address-cells = <2>;
41 #size-cells = <2>;
42 interrupt-parent = <&mpic>;
43
44 aliases {
45 ccsr = &soc;
46
47 serial0 = &serial0;
48 serial1 = &serial1;
49 serial2 = &serial2;
50 serial3 = &serial3;
51 dma0 = &dma0;
52 dma1 = &dma1;
53 };
54
55 cpus {
56 #address-cells = <1>;
57 #size-cells = <0>;
58
59 cpu0: PowerPC,e6500@0 {
60 device_type = "cpu";
61 reg = <0 1>;
62 next-level-cache = <&L2_1>;
63 };
64 cpu1: PowerPC,e6500@2 {
65 device_type = "cpu";
66 reg = <2 3>;
67 next-level-cache = <&L2_1>;
68 };
69 cpu2: PowerPC,e6500@4 {
70 device_type = "cpu";
71 reg = <4 5>;
72 next-level-cache = <&L2_1>;
73 };
74 cpu3: PowerPC,e6500@6 {
75 device_type = "cpu";
76 reg = <6 7>;
77 next-level-cache = <&L2_1>;
78 };
79
80 cpu4: PowerPC,e6500@8 {
81 device_type = "cpu";
82 reg = <8 9>;
83 next-level-cache = <&L2_2>;
84 };
85 cpu5: PowerPC,e6500@10 {
86 device_type = "cpu";
87 reg = <10 11>;
88 next-level-cache = <&L2_2>;
89 };
90 cpu6: PowerPC,e6500@12 {
91 device_type = "cpu";
92 reg = <12 13>;
93 next-level-cache = <&L2_2>;
94 };
95 cpu7: PowerPC,e6500@14 {
96 device_type = "cpu";
97 reg = <14 15>;
98 next-level-cache = <&L2_2>;
99 };
100
101 cpu8: PowerPC,e6500@16 {
102 device_type = "cpu";
103 reg = <16 17>;
104 next-level-cache = <&L2_3>;
105 };
106 cpu9: PowerPC,e6500@18 {
107 device_type = "cpu";
108 reg = <18 19>;
109 next-level-cache = <&L2_3>;
110 };
111 cpu10: PowerPC,e6500@20 {
112 device_type = "cpu";
113 reg = <20 21>;
114 next-level-cache = <&L2_3>;
115 };
116 cpu11: PowerPC,e6500@22 {
117 device_type = "cpu";
118 reg = <22 23>;
119 next-level-cache = <&L2_3>;
120 };
121 };
122};
123
124/ {
125 model = "fsl,T4240QDS";
126 compatible = "fsl,T4240EMU", "fsl,T4240QDS";
127 #address-cells = <2>;
128 #size-cells = <2>;
129 interrupt-parent = <&mpic>;
130
131 ifc: localbus@ffe124000 {
132 reg = <0xf 0xfe124000 0 0x2000>;
133 ranges = <0 0 0xf 0xe8000000 0x08000000
134 2 0 0xf 0xff800000 0x00010000
135 3 0 0xf 0xffdf0000 0x00008000>;
136
137 nor@0,0 {
138 #address-cells = <1>;
139 #size-cells = <1>;
140 compatible = "cfi-flash";
141 reg = <0x0 0x0 0x8000000>;
142
143 bank-width = <2>;
144 device-width = <1>;
145 };
146
147 };
148
149 memory {
150 device_type = "memory";
151 };
152
153 soc: soc@ffe000000 {
154 ranges = <0x00000000 0xf 0xfe000000 0x1000000>;
155 reg = <0xf 0xfe000000 0 0x00001000>;
156
157 };
158};
159
160&ifc {
161 #address-cells = <2>;
162 #size-cells = <1>;
163 compatible = "fsl,ifc", "simple-bus";
164 interrupts = <25 2 0 0>;
165};
166
167&soc {
168 #address-cells = <1>;
169 #size-cells = <1>;
170 device_type = "soc";
171 compatible = "simple-bus";
172
173 soc-sram-error {
174 compatible = "fsl,soc-sram-error";
175 interrupts = <16 2 1 29>;
176 };
177
178 corenet-law@0 {
179 compatible = "fsl,corenet-law";
180 reg = <0x0 0x1000>;
181 fsl,num-laws = <32>;
182 };
183
184 ddr1: memory-controller@8000 {
185 compatible = "fsl,qoriq-memory-controller-v4.7",
186 "fsl,qoriq-memory-controller";
187 reg = <0x8000 0x1000>;
188 interrupts = <16 2 1 23>;
189 };
190
191 ddr2: memory-controller@9000 {
192 compatible = "fsl,qoriq-memory-controller-v4.7",
193 "fsl,qoriq-memory-controller";
194 reg = <0x9000 0x1000>;
195 interrupts = <16 2 1 22>;
196 };
197
198 ddr3: memory-controller@a000 {
199 compatible = "fsl,qoriq-memory-controller-v4.7",
200 "fsl,qoriq-memory-controller";
201 reg = <0xa000 0x1000>;
202 interrupts = <16 2 1 21>;
203 };
204
205 cpc: l3-cache-controller@10000 {
206 compatible = "fsl,t4240-l3-cache-controller", "cache";
207 reg = <0x10000 0x1000
208 0x11000 0x1000
209 0x12000 0x1000>;
210 interrupts = <16 2 1 27
211 16 2 1 26
212 16 2 1 25>;
213 };
214
215 corenet-cf@18000 {
216 compatible = "fsl,corenet-cf";
217 reg = <0x18000 0x1000>;
218 interrupts = <16 2 1 31>;
219 fsl,ccf-num-csdids = <32>;
220 fsl,ccf-num-snoopids = <32>;
221 };
222
223 iommu@20000 {
224 compatible = "fsl,pamu-v1.0", "fsl,pamu";
225 reg = <0x20000 0x6000>;
226 interrupts = <
227 24 2 0 0
228 16 2 1 30>;
229 };
230
231/include/ "fsl/qoriq-mpic.dtsi"
232
233 guts: global-utilities@e0000 {
234 compatible = "fsl,t4240-device-config", "fsl,qoriq-device-config-2.0";
235 reg = <0xe0000 0xe00>;
236 fsl,has-rstcr;
237 fsl,liodn-bits = <12>;
238 };
239
240 clockgen: global-utilities@e1000 {
241 compatible = "fsl,t4240-clockgen", "fsl,qoriq-clockgen-2.0";
242 reg = <0xe1000 0x1000>;
243 };
244
245/include/ "fsl/qoriq-dma-0.dtsi"
246/include/ "fsl/qoriq-dma-1.dtsi"
247
248/include/ "fsl/qoriq-i2c-0.dtsi"
249/include/ "fsl/qoriq-i2c-1.dtsi"
250/include/ "fsl/qoriq-duart-0.dtsi"
251/include/ "fsl/qoriq-duart-1.dtsi"
252
253 L2_1: l2-cache-controller@c20000 {
254 compatible = "fsl,t4240-l2-cache-controller";
255 reg = <0xc20000 0x40000>;
256 next-level-cache = <&cpc>;
257 };
258 L2_2: l2-cache-controller@c60000 {
259 compatible = "fsl,t4240-l2-cache-controller";
260 reg = <0xc60000 0x40000>;
261 next-level-cache = <&cpc>;
262 };
263 L2_3: l2-cache-controller@ca0000 {
264 compatible = "fsl,t4240-l2-cache-controller";
265 reg = <0xca0000 0x40000>;
266 next-level-cache = <&cpc>;
267 };
268};
diff --git a/arch/powerpc/boot/dts/t4240qds.dts b/arch/powerpc/boot/dts/t4240qds.dts
index 0555976dd0f3..63e81b010804 100644
--- a/arch/powerpc/boot/dts/t4240qds.dts
+++ b/arch/powerpc/boot/dts/t4240qds.dts
@@ -118,36 +118,53 @@
118 }; 118 };
119 119
120 i2c@118000 { 120 i2c@118000 {
121 eeprom@51 { 121 mux@77 {
122 compatible = "at24,24c256"; 122 compatible = "nxp,pca9547";
123 reg = <0x51>; 123 reg = <0x77>;
124 }; 124 #address-cells = <1>;
125 eeprom@52 { 125 #size-cells = <0>;
126 compatible = "at24,24c256"; 126
127 reg = <0x52>; 127 i2c@0 {
128 }; 128 #address-cells = <1>;
129 eeprom@53 { 129 #size-cells = <0>;
130 compatible = "at24,24c256"; 130 reg = <0>;
131 reg = <0x53>; 131
132 }; 132 eeprom@51 {
133 eeprom@54 { 133 compatible = "at24,24c256";
134 compatible = "at24,24c256"; 134 reg = <0x51>;
135 reg = <0x54>; 135 };
136 }; 136 eeprom@52 {
137 eeprom@55 { 137 compatible = "at24,24c256";
138 compatible = "at24,24c256"; 138 reg = <0x52>;
139 reg = <0x55>; 139 };
140 }; 140 eeprom@53 {
141 eeprom@56 { 141 compatible = "at24,24c256";
142 compatible = "at24,24c256"; 142 reg = <0x53>;
143 reg = <0x56>; 143 };
144 }; 144 eeprom@54 {
145 rtc@68 { 145 compatible = "at24,24c256";
146 compatible = "dallas,ds3232"; 146 reg = <0x54>;
147 reg = <0x68>; 147 };
148 interrupts = <0x1 0x1 0 0>; 148 eeprom@55 {
149 compatible = "at24,24c256";
150 reg = <0x55>;
151 };
152 eeprom@56 {
153 compatible = "at24,24c256";
154 reg = <0x56>;
155 };
156 rtc@68 {
157 compatible = "dallas,ds3232";
158 reg = <0x68>;
159 interrupts = <0x1 0x1 0 0>;
160 };
161 };
149 }; 162 };
150 }; 163 };
164
165 sdhc@114000 {
166 voltage-ranges = <1800 1800 3300 3300>;
167 };
151 }; 168 };
152 169
153 pci0: pcie@ffe240000 { 170 pci0: pcie@ffe240000 {
diff --git a/arch/powerpc/boot/wrapper b/arch/powerpc/boot/wrapper
index cd7af841ba05..2e1af74a64be 100755
--- a/arch/powerpc/boot/wrapper
+++ b/arch/powerpc/boot/wrapper
@@ -147,21 +147,29 @@ link_address='0x400000'
147make_space=y 147make_space=y
148 148
149case "$platform" in 149case "$platform" in
150of)
151 platformo="$object/of.o $object/epapr.o"
152 make_space=n
153 ;;
150pseries) 154pseries)
151 platformo="$object/of.o $object/epapr.o" 155 platformo="$object/of.o $object/epapr.o"
152 link_address='0x4000000' 156 link_address='0x4000000'
157 make_space=n
153 ;; 158 ;;
154maple) 159maple)
155 platformo="$object/of.o $object/epapr.o" 160 platformo="$object/of.o $object/epapr.o"
156 link_address='0x400000' 161 link_address='0x400000'
162 make_space=n
157 ;; 163 ;;
158pmac|chrp) 164pmac|chrp)
159 platformo="$object/of.o $object/epapr.o" 165 platformo="$object/of.o $object/epapr.o"
166 make_space=n
160 ;; 167 ;;
161coff) 168coff)
162 platformo="$object/crt0.o $object/of.o $object/epapr.o" 169 platformo="$object/crt0.o $object/of.o $object/epapr.o"
163 lds=$object/zImage.coff.lds 170 lds=$object/zImage.coff.lds
164 link_address='0x500000' 171 link_address='0x500000'
172 make_space=n
165 pie= 173 pie=
166 ;; 174 ;;
167miboot|uboot*) 175miboot|uboot*)
diff --git a/arch/powerpc/configs/corenet32_smp_defconfig b/arch/powerpc/configs/corenet32_smp_defconfig
index 3dfab4c40c76..bbd794deb6eb 100644
--- a/arch/powerpc/configs/corenet32_smp_defconfig
+++ b/arch/powerpc/configs/corenet32_smp_defconfig
@@ -23,11 +23,7 @@ CONFIG_MODVERSIONS=y
23# CONFIG_BLK_DEV_BSG is not set 23# CONFIG_BLK_DEV_BSG is not set
24CONFIG_PARTITION_ADVANCED=y 24CONFIG_PARTITION_ADVANCED=y
25CONFIG_MAC_PARTITION=y 25CONFIG_MAC_PARTITION=y
26CONFIG_P2041_RDB=y 26CONFIG_CORENET_GENERIC=y
27CONFIG_P3041_DS=y
28CONFIG_P4080_DS=y
29CONFIG_P5020_DS=y
30CONFIG_P5040_DS=y
31CONFIG_HIGHMEM=y 27CONFIG_HIGHMEM=y
32# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set 28# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
33CONFIG_BINFMT_MISC=m 29CONFIG_BINFMT_MISC=m
@@ -104,6 +100,7 @@ CONFIG_FSL_PQ_MDIO=y
104CONFIG_E1000=y 100CONFIG_E1000=y
105CONFIG_E1000E=y 101CONFIG_E1000E=y
106CONFIG_VITESSE_PHY=y 102CONFIG_VITESSE_PHY=y
103CONFIG_AT803X_PHY=y
107CONFIG_FIXED_PHY=y 104CONFIG_FIXED_PHY=y
108# CONFIG_INPUT_MOUSEDEV is not set 105# CONFIG_INPUT_MOUSEDEV is not set
109# CONFIG_INPUT_KEYBOARD is not set 106# CONFIG_INPUT_KEYBOARD is not set
diff --git a/arch/powerpc/configs/corenet64_smp_defconfig b/arch/powerpc/configs/corenet64_smp_defconfig
index fa94fb3bb44d..63508ddee11c 100644
--- a/arch/powerpc/configs/corenet64_smp_defconfig
+++ b/arch/powerpc/configs/corenet64_smp_defconfig
@@ -21,10 +21,7 @@ CONFIG_MODVERSIONS=y
21# CONFIG_BLK_DEV_BSG is not set 21# CONFIG_BLK_DEV_BSG is not set
22CONFIG_PARTITION_ADVANCED=y 22CONFIG_PARTITION_ADVANCED=y
23CONFIG_MAC_PARTITION=y 23CONFIG_MAC_PARTITION=y
24CONFIG_B4_QDS=y 24CONFIG_CORENET_GENERIC=y
25CONFIG_P5020_DS=y
26CONFIG_P5040_DS=y
27CONFIG_T4240_QDS=y
28# CONFIG_PPC_OF_BOOT_TRAMPOLINE is not set 25# CONFIG_PPC_OF_BOOT_TRAMPOLINE is not set
29CONFIG_BINFMT_MISC=m 26CONFIG_BINFMT_MISC=m
30CONFIG_MATH_EMULATION=y 27CONFIG_MATH_EMULATION=y
diff --git a/arch/powerpc/configs/mpc85xx_defconfig b/arch/powerpc/configs/mpc85xx_defconfig
index dc098d988211..d2e0fab5ee5b 100644
--- a/arch/powerpc/configs/mpc85xx_defconfig
+++ b/arch/powerpc/configs/mpc85xx_defconfig
@@ -138,6 +138,7 @@ CONFIG_MARVELL_PHY=y
138CONFIG_DAVICOM_PHY=y 138CONFIG_DAVICOM_PHY=y
139CONFIG_CICADA_PHY=y 139CONFIG_CICADA_PHY=y
140CONFIG_VITESSE_PHY=y 140CONFIG_VITESSE_PHY=y
141CONFIG_AT803X_PHY=y
141CONFIG_FIXED_PHY=y 142CONFIG_FIXED_PHY=y
142CONFIG_INPUT_FF_MEMLESS=m 143CONFIG_INPUT_FF_MEMLESS=m
143# CONFIG_INPUT_MOUSEDEV is not set 144# CONFIG_INPUT_MOUSEDEV is not set
diff --git a/arch/powerpc/configs/mpc85xx_smp_defconfig b/arch/powerpc/configs/mpc85xx_smp_defconfig
index 5bca60161bb3..4cb7b59e98bd 100644
--- a/arch/powerpc/configs/mpc85xx_smp_defconfig
+++ b/arch/powerpc/configs/mpc85xx_smp_defconfig
@@ -138,6 +138,7 @@ CONFIG_MARVELL_PHY=y
138CONFIG_DAVICOM_PHY=y 138CONFIG_DAVICOM_PHY=y
139CONFIG_CICADA_PHY=y 139CONFIG_CICADA_PHY=y
140CONFIG_VITESSE_PHY=y 140CONFIG_VITESSE_PHY=y
141CONFIG_AT803X_PHY=y
141CONFIG_FIXED_PHY=y 142CONFIG_FIXED_PHY=y
142CONFIG_INPUT_FF_MEMLESS=m 143CONFIG_INPUT_FF_MEMLESS=m
143# CONFIG_INPUT_MOUSEDEV is not set 144# CONFIG_INPUT_MOUSEDEV is not set
diff --git a/arch/powerpc/configs/ppc64_defconfig b/arch/powerpc/configs/ppc64_defconfig
index 0e8cfd09da2f..581a3bcae728 100644
--- a/arch/powerpc/configs/ppc64_defconfig
+++ b/arch/powerpc/configs/ppc64_defconfig
@@ -2,7 +2,6 @@ CONFIG_PPC64=y
2CONFIG_ALTIVEC=y 2CONFIG_ALTIVEC=y
3CONFIG_VSX=y 3CONFIG_VSX=y
4CONFIG_SMP=y 4CONFIG_SMP=y
5CONFIG_EXPERIMENTAL=y
6CONFIG_SYSVIPC=y 5CONFIG_SYSVIPC=y
7CONFIG_POSIX_MQUEUE=y 6CONFIG_POSIX_MQUEUE=y
8CONFIG_IRQ_DOMAIN_DEBUG=y 7CONFIG_IRQ_DOMAIN_DEBUG=y
@@ -25,7 +24,6 @@ CONFIG_MODULE_UNLOAD=y
25CONFIG_MODVERSIONS=y 24CONFIG_MODVERSIONS=y
26CONFIG_MODULE_SRCVERSION_ALL=y 25CONFIG_MODULE_SRCVERSION_ALL=y
27CONFIG_PARTITION_ADVANCED=y 26CONFIG_PARTITION_ADVANCED=y
28CONFIG_EFI_PARTITION=y
29CONFIG_PPC_SPLPAR=y 27CONFIG_PPC_SPLPAR=y
30CONFIG_SCANLOG=m 28CONFIG_SCANLOG=m
31CONFIG_PPC_SMLPAR=y 29CONFIG_PPC_SMLPAR=y
@@ -50,12 +48,10 @@ CONFIG_CPU_FREQ_PMAC64=y
50CONFIG_HZ_100=y 48CONFIG_HZ_100=y
51CONFIG_BINFMT_MISC=m 49CONFIG_BINFMT_MISC=m
52CONFIG_PPC_TRANSACTIONAL_MEM=y 50CONFIG_PPC_TRANSACTIONAL_MEM=y
53CONFIG_HOTPLUG_CPU=y
54CONFIG_KEXEC=y 51CONFIG_KEXEC=y
55CONFIG_IRQ_ALL_CPUS=y 52CONFIG_IRQ_ALL_CPUS=y
56CONFIG_MEMORY_HOTREMOVE=y 53CONFIG_MEMORY_HOTREMOVE=y
57CONFIG_SCHED_SMT=y 54CONFIG_SCHED_SMT=y
58CONFIG_PPC_DENORMALISATION=y
59CONFIG_PCCARD=y 55CONFIG_PCCARD=y
60CONFIG_ELECTRA_CF=y 56CONFIG_ELECTRA_CF=y
61CONFIG_HOTPLUG_PCI=y 57CONFIG_HOTPLUG_PCI=y
@@ -89,7 +85,6 @@ CONFIG_NF_CONNTRACK_PPTP=m
89CONFIG_NF_CONNTRACK_SIP=m 85CONFIG_NF_CONNTRACK_SIP=m
90CONFIG_NF_CONNTRACK_TFTP=m 86CONFIG_NF_CONNTRACK_TFTP=m
91CONFIG_NF_CT_NETLINK=m 87CONFIG_NF_CT_NETLINK=m
92CONFIG_NETFILTER_TPROXY=m
93CONFIG_NETFILTER_XT_TARGET_CLASSIFY=m 88CONFIG_NETFILTER_XT_TARGET_CLASSIFY=m
94CONFIG_NETFILTER_XT_TARGET_CONNMARK=m 89CONFIG_NETFILTER_XT_TARGET_CONNMARK=m
95CONFIG_NETFILTER_XT_TARGET_DSCP=m 90CONFIG_NETFILTER_XT_TARGET_DSCP=m
@@ -131,7 +126,6 @@ CONFIG_NETFILTER_XT_MATCH_STRING=m
131CONFIG_NETFILTER_XT_MATCH_TCPMSS=m 126CONFIG_NETFILTER_XT_MATCH_TCPMSS=m
132CONFIG_NETFILTER_XT_MATCH_U32=m 127CONFIG_NETFILTER_XT_MATCH_U32=m
133CONFIG_NF_CONNTRACK_IPV4=m 128CONFIG_NF_CONNTRACK_IPV4=m
134CONFIG_IP_NF_QUEUE=m
135CONFIG_IP_NF_IPTABLES=m 129CONFIG_IP_NF_IPTABLES=m
136CONFIG_IP_NF_MATCH_AH=m 130CONFIG_IP_NF_MATCH_AH=m
137CONFIG_IP_NF_MATCH_ECN=m 131CONFIG_IP_NF_MATCH_ECN=m
@@ -157,6 +151,7 @@ CONFIG_BLK_DEV_LOOP=y
157CONFIG_BLK_DEV_NBD=m 151CONFIG_BLK_DEV_NBD=m
158CONFIG_BLK_DEV_RAM=y 152CONFIG_BLK_DEV_RAM=y
159CONFIG_BLK_DEV_RAM_SIZE=65536 153CONFIG_BLK_DEV_RAM_SIZE=65536
154CONFIG_VIRTIO_BLK=m
160CONFIG_IDE=y 155CONFIG_IDE=y
161CONFIG_BLK_DEV_IDECD=y 156CONFIG_BLK_DEV_IDECD=y
162CONFIG_BLK_DEV_GENERIC=y 157CONFIG_BLK_DEV_GENERIC=y
@@ -185,6 +180,10 @@ CONFIG_SCSI_IPR=y
185CONFIG_SCSI_QLA_FC=m 180CONFIG_SCSI_QLA_FC=m
186CONFIG_SCSI_QLA_ISCSI=m 181CONFIG_SCSI_QLA_ISCSI=m
187CONFIG_SCSI_LPFC=m 182CONFIG_SCSI_LPFC=m
183CONFIG_SCSI_VIRTIO=m
184CONFIG_SCSI_DH=m
185CONFIG_SCSI_DH_RDAC=m
186CONFIG_SCSI_DH_ALUA=m
188CONFIG_ATA=y 187CONFIG_ATA=y
189CONFIG_SATA_SIL24=y 188CONFIG_SATA_SIL24=y
190CONFIG_SATA_SVW=y 189CONFIG_SATA_SVW=y
@@ -203,6 +202,9 @@ CONFIG_DM_SNAPSHOT=m
203CONFIG_DM_MIRROR=m 202CONFIG_DM_MIRROR=m
204CONFIG_DM_ZERO=m 203CONFIG_DM_ZERO=m
205CONFIG_DM_MULTIPATH=m 204CONFIG_DM_MULTIPATH=m
205CONFIG_DM_MULTIPATH_QL=m
206CONFIG_DM_MULTIPATH_ST=m
207CONFIG_DM_UEVENT=y
206CONFIG_ADB_PMU=y 208CONFIG_ADB_PMU=y
207CONFIG_PMAC_SMU=y 209CONFIG_PMAC_SMU=y
208CONFIG_THERM_PM72=y 210CONFIG_THERM_PM72=y
@@ -216,6 +218,8 @@ CONFIG_DUMMY=m
216CONFIG_NETCONSOLE=y 218CONFIG_NETCONSOLE=y
217CONFIG_NETPOLL_TRAP=y 219CONFIG_NETPOLL_TRAP=y
218CONFIG_TUN=m 220CONFIG_TUN=m
221CONFIG_VIRTIO_NET=m
222CONFIG_VHOST_NET=m
219CONFIG_VORTEX=y 223CONFIG_VORTEX=y
220CONFIG_ACENIC=m 224CONFIG_ACENIC=m
221CONFIG_ACENIC_OMIT_TIGON_I=y 225CONFIG_ACENIC_OMIT_TIGON_I=y
@@ -262,6 +266,7 @@ CONFIG_HVC_CONSOLE=y
262CONFIG_HVC_RTAS=y 266CONFIG_HVC_RTAS=y
263CONFIG_HVC_BEAT=y 267CONFIG_HVC_BEAT=y
264CONFIG_HVCS=m 268CONFIG_HVCS=m
269CONFIG_VIRTIO_CONSOLE=m
265CONFIG_IBM_BSR=m 270CONFIG_IBM_BSR=m
266CONFIG_RAW_DRIVER=y 271CONFIG_RAW_DRIVER=y
267CONFIG_I2C_CHARDEV=y 272CONFIG_I2C_CHARDEV=y
@@ -301,7 +306,6 @@ CONFIG_HID_GYRATION=y
301CONFIG_HID_PANTHERLORD=y 306CONFIG_HID_PANTHERLORD=y
302CONFIG_HID_PETALYNX=y 307CONFIG_HID_PETALYNX=y
303CONFIG_HID_SAMSUNG=y 308CONFIG_HID_SAMSUNG=y
304CONFIG_HID_SONY=y
305CONFIG_HID_SUNPLUS=y 309CONFIG_HID_SUNPLUS=y
306CONFIG_USB_HIDDEV=y 310CONFIG_USB_HIDDEV=y
307CONFIG_USB=y 311CONFIG_USB=y
@@ -328,6 +332,8 @@ CONFIG_EDAC_MM_EDAC=y
328CONFIG_EDAC_PASEMI=y 332CONFIG_EDAC_PASEMI=y
329CONFIG_RTC_CLASS=y 333CONFIG_RTC_CLASS=y
330CONFIG_RTC_DRV_DS1307=y 334CONFIG_RTC_DRV_DS1307=y
335CONFIG_VIRTIO_PCI=m
336CONFIG_VIRTIO_BALLOON=m
331CONFIG_EXT2_FS=y 337CONFIG_EXT2_FS=y
332CONFIG_EXT2_FS_XATTR=y 338CONFIG_EXT2_FS_XATTR=y
333CONFIG_EXT2_FS_POSIX_ACL=y 339CONFIG_EXT2_FS_POSIX_ACL=y
@@ -386,21 +392,19 @@ CONFIG_NLS_UTF8=y
386CONFIG_CRC_T10DIF=y 392CONFIG_CRC_T10DIF=y
387CONFIG_MAGIC_SYSRQ=y 393CONFIG_MAGIC_SYSRQ=y
388CONFIG_DEBUG_KERNEL=y 394CONFIG_DEBUG_KERNEL=y
395CONFIG_DEBUG_STACK_USAGE=y
396CONFIG_DEBUG_STACKOVERFLOW=y
389CONFIG_LOCKUP_DETECTOR=y 397CONFIG_LOCKUP_DETECTOR=y
390CONFIG_DEBUG_MUTEXES=y 398CONFIG_DEBUG_MUTEXES=y
391CONFIG_DEBUG_STACK_USAGE=y
392CONFIG_LATENCYTOP=y 399CONFIG_LATENCYTOP=y
393CONFIG_SCHED_TRACER=y 400CONFIG_SCHED_TRACER=y
394CONFIG_BLK_DEV_IO_TRACE=y 401CONFIG_BLK_DEV_IO_TRACE=y
395CONFIG_DEBUG_STACKOVERFLOW=y
396CONFIG_CODE_PATCHING_SELFTEST=y 402CONFIG_CODE_PATCHING_SELFTEST=y
397CONFIG_FTR_FIXUP_SELFTEST=y 403CONFIG_FTR_FIXUP_SELFTEST=y
398CONFIG_MSI_BITMAP_SELFTEST=y 404CONFIG_MSI_BITMAP_SELFTEST=y
399CONFIG_XMON=y 405CONFIG_XMON=y
400CONFIG_BOOTX_TEXT=y 406CONFIG_BOOTX_TEXT=y
401CONFIG_PPC_EARLY_DEBUG=y 407CONFIG_PPC_EARLY_DEBUG=y
402CONFIG_PPC_EARLY_DEBUG_BOOTX=y
403CONFIG_CRYPTO_NULL=m
404CONFIG_CRYPTO_TEST=m 408CONFIG_CRYPTO_TEST=m
405CONFIG_CRYPTO_PCBC=m 409CONFIG_CRYPTO_PCBC=m
406CONFIG_CRYPTO_HMAC=y 410CONFIG_CRYPTO_HMAC=y
@@ -422,4 +426,3 @@ CONFIG_CRYPTO_DEV_NX_ENCRYPT=m
422CONFIG_VIRTUALIZATION=y 426CONFIG_VIRTUALIZATION=y
423CONFIG_KVM_BOOK3S_64=m 427CONFIG_KVM_BOOK3S_64=m
424CONFIG_KVM_BOOK3S_64_HV=y 428CONFIG_KVM_BOOK3S_64_HV=y
425CONFIG_VHOST_NET=m
diff --git a/arch/powerpc/configs/ppc64e_defconfig b/arch/powerpc/configs/ppc64e_defconfig
index 0085dc4642c5..f627fda08953 100644
--- a/arch/powerpc/configs/ppc64e_defconfig
+++ b/arch/powerpc/configs/ppc64e_defconfig
@@ -1,7 +1,6 @@
1CONFIG_PPC64=y 1CONFIG_PPC64=y
2CONFIG_PPC_BOOK3E_64=y 2CONFIG_PPC_BOOK3E_64=y
3CONFIG_SMP=y 3CONFIG_SMP=y
4CONFIG_EXPERIMENTAL=y
5CONFIG_SYSVIPC=y 4CONFIG_SYSVIPC=y
6CONFIG_POSIX_MQUEUE=y 5CONFIG_POSIX_MQUEUE=y
7CONFIG_NO_HZ=y 6CONFIG_NO_HZ=y
@@ -23,7 +22,7 @@ CONFIG_MODULE_SRCVERSION_ALL=y
23CONFIG_PARTITION_ADVANCED=y 22CONFIG_PARTITION_ADVANCED=y
24CONFIG_MAC_PARTITION=y 23CONFIG_MAC_PARTITION=y
25CONFIG_EFI_PARTITION=y 24CONFIG_EFI_PARTITION=y
26CONFIG_P5020_DS=y 25CONFIG_CORENET_GENERIC=y
27CONFIG_CPU_FREQ=y 26CONFIG_CPU_FREQ=y
28CONFIG_CPU_FREQ_GOV_POWERSAVE=y 27CONFIG_CPU_FREQ_GOV_POWERSAVE=y
29CONFIG_CPU_FREQ_GOV_USERSPACE=y 28CONFIG_CPU_FREQ_GOV_USERSPACE=y
@@ -61,7 +60,6 @@ CONFIG_NF_CONNTRACK_PPTP=m
61CONFIG_NF_CONNTRACK_SIP=m 60CONFIG_NF_CONNTRACK_SIP=m
62CONFIG_NF_CONNTRACK_TFTP=m 61CONFIG_NF_CONNTRACK_TFTP=m
63CONFIG_NF_CT_NETLINK=m 62CONFIG_NF_CT_NETLINK=m
64CONFIG_NETFILTER_TPROXY=m
65CONFIG_NETFILTER_XT_TARGET_CLASSIFY=m 63CONFIG_NETFILTER_XT_TARGET_CLASSIFY=m
66CONFIG_NETFILTER_XT_TARGET_CONNMARK=m 64CONFIG_NETFILTER_XT_TARGET_CONNMARK=m
67CONFIG_NETFILTER_XT_TARGET_DSCP=m 65CONFIG_NETFILTER_XT_TARGET_DSCP=m
@@ -103,7 +101,6 @@ CONFIG_NETFILTER_XT_MATCH_STRING=m
103CONFIG_NETFILTER_XT_MATCH_TCPMSS=m 101CONFIG_NETFILTER_XT_MATCH_TCPMSS=m
104CONFIG_NETFILTER_XT_MATCH_U32=m 102CONFIG_NETFILTER_XT_MATCH_U32=m
105CONFIG_NF_CONNTRACK_IPV4=m 103CONFIG_NF_CONNTRACK_IPV4=m
106CONFIG_IP_NF_QUEUE=m
107CONFIG_IP_NF_IPTABLES=m 104CONFIG_IP_NF_IPTABLES=m
108CONFIG_IP_NF_MATCH_AH=m 105CONFIG_IP_NF_MATCH_AH=m
109CONFIG_IP_NF_MATCH_ECN=m 106CONFIG_IP_NF_MATCH_ECN=m
@@ -193,7 +190,6 @@ CONFIG_PPP_SYNC_TTY=m
193CONFIG_INPUT_EVDEV=m 190CONFIG_INPUT_EVDEV=m
194CONFIG_INPUT_MISC=y 191CONFIG_INPUT_MISC=y
195# CONFIG_SERIO_SERPORT is not set 192# CONFIG_SERIO_SERPORT is not set
196CONFIG_VT_HW_CONSOLE_BINDING=y
197CONFIG_SERIAL_8250=y 193CONFIG_SERIAL_8250=y
198CONFIG_SERIAL_8250_CONSOLE=y 194CONFIG_SERIAL_8250_CONSOLE=y
199# CONFIG_HW_RANDOM is not set 195# CONFIG_HW_RANDOM is not set
@@ -230,7 +226,6 @@ CONFIG_HID_NTRIG=y
230CONFIG_HID_PANTHERLORD=y 226CONFIG_HID_PANTHERLORD=y
231CONFIG_HID_PETALYNX=y 227CONFIG_HID_PETALYNX=y
232CONFIG_HID_SAMSUNG=y 228CONFIG_HID_SAMSUNG=y
233CONFIG_HID_SONY=y
234CONFIG_HID_SUNPLUS=y 229CONFIG_HID_SUNPLUS=y
235CONFIG_HID_GREENASIA=y 230CONFIG_HID_GREENASIA=y
236CONFIG_HID_SMARTJOYPLUS=y 231CONFIG_HID_SMARTJOYPLUS=y
@@ -302,19 +297,18 @@ CONFIG_NLS_UTF8=y
302CONFIG_CRC_T10DIF=y 297CONFIG_CRC_T10DIF=y
303CONFIG_MAGIC_SYSRQ=y 298CONFIG_MAGIC_SYSRQ=y
304CONFIG_DEBUG_KERNEL=y 299CONFIG_DEBUG_KERNEL=y
300CONFIG_DEBUG_STACK_USAGE=y
301CONFIG_DEBUG_STACKOVERFLOW=y
305CONFIG_DETECT_HUNG_TASK=y 302CONFIG_DETECT_HUNG_TASK=y
306CONFIG_DEBUG_MUTEXES=y 303CONFIG_DEBUG_MUTEXES=y
307CONFIG_DEBUG_STACK_USAGE=y
308CONFIG_LATENCYTOP=y 304CONFIG_LATENCYTOP=y
309CONFIG_IRQSOFF_TRACER=y 305CONFIG_IRQSOFF_TRACER=y
310CONFIG_SCHED_TRACER=y 306CONFIG_SCHED_TRACER=y
311CONFIG_BLK_DEV_IO_TRACE=y 307CONFIG_BLK_DEV_IO_TRACE=y
312CONFIG_DEBUG_STACKOVERFLOW=y
313CONFIG_CODE_PATCHING_SELFTEST=y 308CONFIG_CODE_PATCHING_SELFTEST=y
314CONFIG_FTR_FIXUP_SELFTEST=y 309CONFIG_FTR_FIXUP_SELFTEST=y
315CONFIG_MSI_BITMAP_SELFTEST=y 310CONFIG_MSI_BITMAP_SELFTEST=y
316CONFIG_XMON=y 311CONFIG_XMON=y
317CONFIG_CRYPTO_NULL=m
318CONFIG_CRYPTO_TEST=m 312CONFIG_CRYPTO_TEST=m
319CONFIG_CRYPTO_CCM=m 313CONFIG_CRYPTO_CCM=m
320CONFIG_CRYPTO_GCM=m 314CONFIG_CRYPTO_GCM=m
diff --git a/arch/powerpc/configs/ppc6xx_defconfig b/arch/powerpc/configs/ppc6xx_defconfig
index 20ebfaf7234b..c2353bf059fd 100644
--- a/arch/powerpc/configs/ppc6xx_defconfig
+++ b/arch/powerpc/configs/ppc6xx_defconfig
@@ -71,7 +71,7 @@ CONFIG_QUICC_ENGINE=y
71CONFIG_QE_GPIO=y 71CONFIG_QE_GPIO=y
72CONFIG_PPC_BESTCOMM=y 72CONFIG_PPC_BESTCOMM=y
73CONFIG_GPIO_MPC8XXX=y 73CONFIG_GPIO_MPC8XXX=y
74CONFIG_MCU_MPC8349EMITX=m 74CONFIG_MCU_MPC8349EMITX=y
75CONFIG_HIGHMEM=y 75CONFIG_HIGHMEM=y
76CONFIG_NO_HZ=y 76CONFIG_NO_HZ=y
77CONFIG_HIGH_RES_TIMERS=y 77CONFIG_HIGH_RES_TIMERS=y
diff --git a/arch/powerpc/configs/pseries_defconfig b/arch/powerpc/configs/pseries_defconfig
index 1d4b9763895d..e9a8b4e0a0f6 100644
--- a/arch/powerpc/configs/pseries_defconfig
+++ b/arch/powerpc/configs/pseries_defconfig
@@ -3,7 +3,6 @@ CONFIG_ALTIVEC=y
3CONFIG_VSX=y 3CONFIG_VSX=y
4CONFIG_SMP=y 4CONFIG_SMP=y
5CONFIG_NR_CPUS=2048 5CONFIG_NR_CPUS=2048
6CONFIG_EXPERIMENTAL=y
7CONFIG_SYSVIPC=y 6CONFIG_SYSVIPC=y
8CONFIG_POSIX_MQUEUE=y 7CONFIG_POSIX_MQUEUE=y
9CONFIG_AUDIT=y 8CONFIG_AUDIT=y
@@ -33,7 +32,6 @@ CONFIG_MODULE_UNLOAD=y
33CONFIG_MODVERSIONS=y 32CONFIG_MODVERSIONS=y
34CONFIG_MODULE_SRCVERSION_ALL=y 33CONFIG_MODULE_SRCVERSION_ALL=y
35CONFIG_PARTITION_ADVANCED=y 34CONFIG_PARTITION_ADVANCED=y
36CONFIG_EFI_PARTITION=y
37CONFIG_PPC_SPLPAR=y 35CONFIG_PPC_SPLPAR=y
38CONFIG_SCANLOG=m 36CONFIG_SCANLOG=m
39CONFIG_PPC_SMLPAR=y 37CONFIG_PPC_SMLPAR=y
@@ -44,7 +42,6 @@ CONFIG_IBMEBUS=y
44CONFIG_HZ_100=y 42CONFIG_HZ_100=y
45CONFIG_BINFMT_MISC=m 43CONFIG_BINFMT_MISC=m
46CONFIG_PPC_TRANSACTIONAL_MEM=y 44CONFIG_PPC_TRANSACTIONAL_MEM=y
47CONFIG_HOTPLUG_CPU=y
48CONFIG_KEXEC=y 45CONFIG_KEXEC=y
49CONFIG_IRQ_ALL_CPUS=y 46CONFIG_IRQ_ALL_CPUS=y
50CONFIG_MEMORY_HOTPLUG=y 47CONFIG_MEMORY_HOTPLUG=y
@@ -52,7 +49,6 @@ CONFIG_MEMORY_HOTREMOVE=y
52CONFIG_PPC_64K_PAGES=y 49CONFIG_PPC_64K_PAGES=y
53CONFIG_PPC_SUBPAGE_PROT=y 50CONFIG_PPC_SUBPAGE_PROT=y
54CONFIG_SCHED_SMT=y 51CONFIG_SCHED_SMT=y
55CONFIG_PPC_DENORMALISATION=y
56CONFIG_HOTPLUG_PCI=y 52CONFIG_HOTPLUG_PCI=y
57CONFIG_HOTPLUG_PCI_RPA=m 53CONFIG_HOTPLUG_PCI_RPA=m
58CONFIG_HOTPLUG_PCI_RPA_DLPAR=m 54CONFIG_HOTPLUG_PCI_RPA_DLPAR=m
@@ -113,7 +109,6 @@ CONFIG_NETFILTER_XT_MATCH_TCPMSS=m
113CONFIG_NETFILTER_XT_MATCH_TIME=m 109CONFIG_NETFILTER_XT_MATCH_TIME=m
114CONFIG_NETFILTER_XT_MATCH_U32=m 110CONFIG_NETFILTER_XT_MATCH_U32=m
115CONFIG_NF_CONNTRACK_IPV4=m 111CONFIG_NF_CONNTRACK_IPV4=m
116CONFIG_IP_NF_QUEUE=m
117CONFIG_IP_NF_IPTABLES=m 112CONFIG_IP_NF_IPTABLES=m
118CONFIG_IP_NF_MATCH_AH=m 113CONFIG_IP_NF_MATCH_AH=m
119CONFIG_IP_NF_MATCH_ECN=m 114CONFIG_IP_NF_MATCH_ECN=m
@@ -132,6 +127,7 @@ CONFIG_BLK_DEV_LOOP=y
132CONFIG_BLK_DEV_NBD=m 127CONFIG_BLK_DEV_NBD=m
133CONFIG_BLK_DEV_RAM=y 128CONFIG_BLK_DEV_RAM=y
134CONFIG_BLK_DEV_RAM_SIZE=65536 129CONFIG_BLK_DEV_RAM_SIZE=65536
130CONFIG_VIRTIO_BLK=m
135CONFIG_IDE=y 131CONFIG_IDE=y
136CONFIG_BLK_DEV_IDECD=y 132CONFIG_BLK_DEV_IDECD=y
137CONFIG_BLK_DEV_GENERIC=y 133CONFIG_BLK_DEV_GENERIC=y
@@ -157,6 +153,10 @@ CONFIG_SCSI_IPR=y
157CONFIG_SCSI_QLA_FC=m 153CONFIG_SCSI_QLA_FC=m
158CONFIG_SCSI_QLA_ISCSI=m 154CONFIG_SCSI_QLA_ISCSI=m
159CONFIG_SCSI_LPFC=m 155CONFIG_SCSI_LPFC=m
156CONFIG_SCSI_VIRTIO=m
157CONFIG_SCSI_DH=m
158CONFIG_SCSI_DH_RDAC=m
159CONFIG_SCSI_DH_ALUA=m
160CONFIG_ATA=y 160CONFIG_ATA=y
161# CONFIG_ATA_SFF is not set 161# CONFIG_ATA_SFF is not set
162CONFIG_MD=y 162CONFIG_MD=y
@@ -174,11 +174,16 @@ CONFIG_DM_SNAPSHOT=m
174CONFIG_DM_MIRROR=m 174CONFIG_DM_MIRROR=m
175CONFIG_DM_ZERO=m 175CONFIG_DM_ZERO=m
176CONFIG_DM_MULTIPATH=m 176CONFIG_DM_MULTIPATH=m
177CONFIG_DM_MULTIPATH_QL=m
178CONFIG_DM_MULTIPATH_ST=m
179CONFIG_DM_UEVENT=y
177CONFIG_BONDING=m 180CONFIG_BONDING=m
178CONFIG_DUMMY=m 181CONFIG_DUMMY=m
179CONFIG_NETCONSOLE=y 182CONFIG_NETCONSOLE=y
180CONFIG_NETPOLL_TRAP=y 183CONFIG_NETPOLL_TRAP=y
181CONFIG_TUN=m 184CONFIG_TUN=m
185CONFIG_VIRTIO_NET=m
186CONFIG_VHOST_NET=m
182CONFIG_VORTEX=y 187CONFIG_VORTEX=y
183CONFIG_ACENIC=m 188CONFIG_ACENIC=m
184CONFIG_ACENIC_OMIT_TIGON_I=y 189CONFIG_ACENIC_OMIT_TIGON_I=y
@@ -216,6 +221,7 @@ CONFIG_SERIAL_JSM=m
216CONFIG_HVC_CONSOLE=y 221CONFIG_HVC_CONSOLE=y
217CONFIG_HVC_RTAS=y 222CONFIG_HVC_RTAS=y
218CONFIG_HVCS=m 223CONFIG_HVCS=m
224CONFIG_VIRTIO_CONSOLE=m
219CONFIG_IBM_BSR=m 225CONFIG_IBM_BSR=m
220CONFIG_GEN_RTC=y 226CONFIG_GEN_RTC=y
221CONFIG_RAW_DRIVER=y 227CONFIG_RAW_DRIVER=y
@@ -237,7 +243,6 @@ CONFIG_HID_GYRATION=y
237CONFIG_HID_PANTHERLORD=y 243CONFIG_HID_PANTHERLORD=y
238CONFIG_HID_PETALYNX=y 244CONFIG_HID_PETALYNX=y
239CONFIG_HID_SAMSUNG=y 245CONFIG_HID_SAMSUNG=y
240CONFIG_HID_SONY=y
241CONFIG_HID_SUNPLUS=y 246CONFIG_HID_SUNPLUS=y
242CONFIG_USB_HIDDEV=y 247CONFIG_USB_HIDDEV=y
243CONFIG_USB=y 248CONFIG_USB=y
@@ -258,6 +263,8 @@ CONFIG_INFINIBAND_IPOIB=m
258CONFIG_INFINIBAND_IPOIB_CM=y 263CONFIG_INFINIBAND_IPOIB_CM=y
259CONFIG_INFINIBAND_SRP=m 264CONFIG_INFINIBAND_SRP=m
260CONFIG_INFINIBAND_ISER=m 265CONFIG_INFINIBAND_ISER=m
266CONFIG_VIRTIO_PCI=m
267CONFIG_VIRTIO_BALLOON=m
261CONFIG_EXT2_FS=y 268CONFIG_EXT2_FS=y
262CONFIG_EXT2_FS_XATTR=y 269CONFIG_EXT2_FS_XATTR=y
263CONFIG_EXT2_FS_POSIX_ACL=y 270CONFIG_EXT2_FS_POSIX_ACL=y
@@ -314,18 +321,17 @@ CONFIG_NLS_UTF8=y
314CONFIG_CRC_T10DIF=y 321CONFIG_CRC_T10DIF=y
315CONFIG_MAGIC_SYSRQ=y 322CONFIG_MAGIC_SYSRQ=y
316CONFIG_DEBUG_KERNEL=y 323CONFIG_DEBUG_KERNEL=y
317CONFIG_LOCKUP_DETECTOR=y
318CONFIG_DEBUG_STACK_USAGE=y 324CONFIG_DEBUG_STACK_USAGE=y
325CONFIG_DEBUG_STACKOVERFLOW=y
326CONFIG_LOCKUP_DETECTOR=y
319CONFIG_LATENCYTOP=y 327CONFIG_LATENCYTOP=y
320CONFIG_SCHED_TRACER=y 328CONFIG_SCHED_TRACER=y
321CONFIG_BLK_DEV_IO_TRACE=y 329CONFIG_BLK_DEV_IO_TRACE=y
322CONFIG_DEBUG_STACKOVERFLOW=y
323CONFIG_CODE_PATCHING_SELFTEST=y 330CONFIG_CODE_PATCHING_SELFTEST=y
324CONFIG_FTR_FIXUP_SELFTEST=y 331CONFIG_FTR_FIXUP_SELFTEST=y
325CONFIG_MSI_BITMAP_SELFTEST=y 332CONFIG_MSI_BITMAP_SELFTEST=y
326CONFIG_XMON=y 333CONFIG_XMON=y
327CONFIG_XMON_DEFAULT=y 334CONFIG_XMON_DEFAULT=y
328CONFIG_CRYPTO_NULL=m
329CONFIG_CRYPTO_TEST=m 335CONFIG_CRYPTO_TEST=m
330CONFIG_CRYPTO_PCBC=m 336CONFIG_CRYPTO_PCBC=m
331CONFIG_CRYPTO_HMAC=y 337CONFIG_CRYPTO_HMAC=y
@@ -347,4 +353,3 @@ CONFIG_CRYPTO_DEV_NX_ENCRYPT=m
347CONFIG_VIRTUALIZATION=y 353CONFIG_VIRTUALIZATION=y
348CONFIG_KVM_BOOK3S_64=m 354CONFIG_KVM_BOOK3S_64=m
349CONFIG_KVM_BOOK3S_64_HV=y 355CONFIG_KVM_BOOK3S_64_HV=y
350CONFIG_VHOST_NET=m
diff --git a/arch/powerpc/include/asm/archrandom.h b/arch/powerpc/include/asm/archrandom.h
new file mode 100644
index 000000000000..d853d163ba47
--- /dev/null
+++ b/arch/powerpc/include/asm/archrandom.h
@@ -0,0 +1,32 @@
1#ifndef _ASM_POWERPC_ARCHRANDOM_H
2#define _ASM_POWERPC_ARCHRANDOM_H
3
4#ifdef CONFIG_ARCH_RANDOM
5
6#include <asm/machdep.h>
7
8static inline int arch_get_random_long(unsigned long *v)
9{
10 if (ppc_md.get_random_long)
11 return ppc_md.get_random_long(v);
12
13 return 0;
14}
15
16static inline int arch_get_random_int(unsigned int *v)
17{
18 unsigned long val;
19 int rc;
20
21 rc = arch_get_random_long(&val);
22 if (rc)
23 *v = val;
24
25 return rc;
26}
27
28int powernv_get_random_long(unsigned long *v);
29
30#endif /* CONFIG_ARCH_RANDOM */
31
32#endif /* _ASM_POWERPC_ARCHRANDOM_H */
diff --git a/arch/powerpc/include/asm/checksum.h b/arch/powerpc/include/asm/checksum.h
index ce0c28495f9a..8251a3ba870f 100644
--- a/arch/powerpc/include/asm/checksum.h
+++ b/arch/powerpc/include/asm/checksum.h
@@ -14,6 +14,9 @@
14 * which always checksum on 4 octet boundaries. ihl is the number 14 * which always checksum on 4 octet boundaries. ihl is the number
15 * of 32-bit words and is always >= 5. 15 * of 32-bit words and is always >= 5.
16 */ 16 */
17#ifdef CONFIG_GENERIC_CSUM
18#include <asm-generic/checksum.h>
19#else
17extern __sum16 ip_fast_csum(const void *iph, unsigned int ihl); 20extern __sum16 ip_fast_csum(const void *iph, unsigned int ihl);
18 21
19/* 22/*
@@ -123,5 +126,7 @@ static inline __wsum csum_tcpudp_nofold(__be32 saddr, __be32 daddr,
123 return sum; 126 return sum;
124#endif 127#endif
125} 128}
129
130#endif
126#endif /* __KERNEL__ */ 131#endif /* __KERNEL__ */
127#endif 132#endif
diff --git a/arch/powerpc/include/asm/emulated_ops.h b/arch/powerpc/include/asm/emulated_ops.h
index 5a8b82aa7241..4358e3002f35 100644
--- a/arch/powerpc/include/asm/emulated_ops.h
+++ b/arch/powerpc/include/asm/emulated_ops.h
@@ -43,6 +43,7 @@ extern struct ppc_emulated {
43 struct ppc_emulated_entry popcntb; 43 struct ppc_emulated_entry popcntb;
44 struct ppc_emulated_entry spe; 44 struct ppc_emulated_entry spe;
45 struct ppc_emulated_entry string; 45 struct ppc_emulated_entry string;
46 struct ppc_emulated_entry sync;
46 struct ppc_emulated_entry unaligned; 47 struct ppc_emulated_entry unaligned;
47#ifdef CONFIG_MATH_EMULATION 48#ifdef CONFIG_MATH_EMULATION
48 struct ppc_emulated_entry math; 49 struct ppc_emulated_entry math;
diff --git a/arch/powerpc/include/asm/hvsi.h b/arch/powerpc/include/asm/hvsi.h
index d3f64f361814..d4a5315718ca 100644
--- a/arch/powerpc/include/asm/hvsi.h
+++ b/arch/powerpc/include/asm/hvsi.h
@@ -25,7 +25,7 @@
25struct hvsi_header { 25struct hvsi_header {
26 uint8_t type; 26 uint8_t type;
27 uint8_t len; 27 uint8_t len;
28 uint16_t seqno; 28 __be16 seqno;
29} __attribute__((packed)); 29} __attribute__((packed));
30 30
31struct hvsi_data { 31struct hvsi_data {
@@ -35,24 +35,24 @@ struct hvsi_data {
35 35
36struct hvsi_control { 36struct hvsi_control {
37 struct hvsi_header hdr; 37 struct hvsi_header hdr;
38 uint16_t verb; 38 __be16 verb;
39 /* optional depending on verb: */ 39 /* optional depending on verb: */
40 uint32_t word; 40 __be32 word;
41 uint32_t mask; 41 __be32 mask;
42} __attribute__((packed)); 42} __attribute__((packed));
43 43
44struct hvsi_query { 44struct hvsi_query {
45 struct hvsi_header hdr; 45 struct hvsi_header hdr;
46 uint16_t verb; 46 __be16 verb;
47} __attribute__((packed)); 47} __attribute__((packed));
48 48
49struct hvsi_query_response { 49struct hvsi_query_response {
50 struct hvsi_header hdr; 50 struct hvsi_header hdr;
51 uint16_t verb; 51 __be16 verb;
52 uint16_t query_seqno; 52 __be16 query_seqno;
53 union { 53 union {
54 uint8_t version; 54 uint8_t version;
55 uint32_t mctrl_word; 55 __be32 mctrl_word;
56 } u; 56 } u;
57} __attribute__((packed)); 57} __attribute__((packed));
58 58
diff --git a/arch/powerpc/include/asm/io.h b/arch/powerpc/include/asm/io.h
index 5a64757dc0d1..575fbf81fad0 100644
--- a/arch/powerpc/include/asm/io.h
+++ b/arch/powerpc/include/asm/io.h
@@ -21,7 +21,7 @@ extern struct pci_dev *isa_bridge_pcidev;
21/* 21/*
22 * has legacy ISA devices ? 22 * has legacy ISA devices ?
23 */ 23 */
24#define arch_has_dev_port() (isa_bridge_pcidev != NULL) 24#define arch_has_dev_port() (isa_bridge_pcidev != NULL || isa_io_special)
25#endif 25#endif
26 26
27#include <linux/device.h> 27#include <linux/device.h>
@@ -113,7 +113,7 @@ extern bool isa_io_special;
113 113
114/* gcc 4.0 and older doesn't have 'Z' constraint */ 114/* gcc 4.0 and older doesn't have 'Z' constraint */
115#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ == 0) 115#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ == 0)
116#define DEF_MMIO_IN_LE(name, size, insn) \ 116#define DEF_MMIO_IN_X(name, size, insn) \
117static inline u##size name(const volatile u##size __iomem *addr) \ 117static inline u##size name(const volatile u##size __iomem *addr) \
118{ \ 118{ \
119 u##size ret; \ 119 u##size ret; \
@@ -122,7 +122,7 @@ static inline u##size name(const volatile u##size __iomem *addr) \
122 return ret; \ 122 return ret; \
123} 123}
124 124
125#define DEF_MMIO_OUT_LE(name, size, insn) \ 125#define DEF_MMIO_OUT_X(name, size, insn) \
126static inline void name(volatile u##size __iomem *addr, u##size val) \ 126static inline void name(volatile u##size __iomem *addr, u##size val) \
127{ \ 127{ \
128 __asm__ __volatile__("sync;"#insn" %1,0,%2" \ 128 __asm__ __volatile__("sync;"#insn" %1,0,%2" \
@@ -130,7 +130,7 @@ static inline void name(volatile u##size __iomem *addr, u##size val) \
130 IO_SET_SYNC_FLAG(); \ 130 IO_SET_SYNC_FLAG(); \
131} 131}
132#else /* newer gcc */ 132#else /* newer gcc */
133#define DEF_MMIO_IN_LE(name, size, insn) \ 133#define DEF_MMIO_IN_X(name, size, insn) \
134static inline u##size name(const volatile u##size __iomem *addr) \ 134static inline u##size name(const volatile u##size __iomem *addr) \
135{ \ 135{ \
136 u##size ret; \ 136 u##size ret; \
@@ -139,7 +139,7 @@ static inline u##size name(const volatile u##size __iomem *addr) \
139 return ret; \ 139 return ret; \
140} 140}
141 141
142#define DEF_MMIO_OUT_LE(name, size, insn) \ 142#define DEF_MMIO_OUT_X(name, size, insn) \
143static inline void name(volatile u##size __iomem *addr, u##size val) \ 143static inline void name(volatile u##size __iomem *addr, u##size val) \
144{ \ 144{ \
145 __asm__ __volatile__("sync;"#insn" %1,%y0" \ 145 __asm__ __volatile__("sync;"#insn" %1,%y0" \
@@ -148,7 +148,7 @@ static inline void name(volatile u##size __iomem *addr, u##size val) \
148} 148}
149#endif 149#endif
150 150
151#define DEF_MMIO_IN_BE(name, size, insn) \ 151#define DEF_MMIO_IN_D(name, size, insn) \
152static inline u##size name(const volatile u##size __iomem *addr) \ 152static inline u##size name(const volatile u##size __iomem *addr) \
153{ \ 153{ \
154 u##size ret; \ 154 u##size ret; \
@@ -157,7 +157,7 @@ static inline u##size name(const volatile u##size __iomem *addr) \
157 return ret; \ 157 return ret; \
158} 158}
159 159
160#define DEF_MMIO_OUT_BE(name, size, insn) \ 160#define DEF_MMIO_OUT_D(name, size, insn) \
161static inline void name(volatile u##size __iomem *addr, u##size val) \ 161static inline void name(volatile u##size __iomem *addr, u##size val) \
162{ \ 162{ \
163 __asm__ __volatile__("sync;"#insn"%U0%X0 %1,%0" \ 163 __asm__ __volatile__("sync;"#insn"%U0%X0 %1,%0" \
@@ -165,22 +165,37 @@ static inline void name(volatile u##size __iomem *addr, u##size val) \
165 IO_SET_SYNC_FLAG(); \ 165 IO_SET_SYNC_FLAG(); \
166} 166}
167 167
168DEF_MMIO_IN_D(in_8, 8, lbz);
169DEF_MMIO_OUT_D(out_8, 8, stb);
168 170
169DEF_MMIO_IN_BE(in_8, 8, lbz); 171#ifdef __BIG_ENDIAN__
170DEF_MMIO_IN_BE(in_be16, 16, lhz); 172DEF_MMIO_IN_D(in_be16, 16, lhz);
171DEF_MMIO_IN_BE(in_be32, 32, lwz); 173DEF_MMIO_IN_D(in_be32, 32, lwz);
172DEF_MMIO_IN_LE(in_le16, 16, lhbrx); 174DEF_MMIO_IN_X(in_le16, 16, lhbrx);
173DEF_MMIO_IN_LE(in_le32, 32, lwbrx); 175DEF_MMIO_IN_X(in_le32, 32, lwbrx);
174 176
175DEF_MMIO_OUT_BE(out_8, 8, stb); 177DEF_MMIO_OUT_D(out_be16, 16, sth);
176DEF_MMIO_OUT_BE(out_be16, 16, sth); 178DEF_MMIO_OUT_D(out_be32, 32, stw);
177DEF_MMIO_OUT_BE(out_be32, 32, stw); 179DEF_MMIO_OUT_X(out_le16, 16, sthbrx);
178DEF_MMIO_OUT_LE(out_le16, 16, sthbrx); 180DEF_MMIO_OUT_X(out_le32, 32, stwbrx);
179DEF_MMIO_OUT_LE(out_le32, 32, stwbrx); 181#else
182DEF_MMIO_IN_X(in_be16, 16, lhbrx);
183DEF_MMIO_IN_X(in_be32, 32, lwbrx);
184DEF_MMIO_IN_D(in_le16, 16, lhz);
185DEF_MMIO_IN_D(in_le32, 32, lwz);
186
187DEF_MMIO_OUT_X(out_be16, 16, sthbrx);
188DEF_MMIO_OUT_X(out_be32, 32, stwbrx);
189DEF_MMIO_OUT_D(out_le16, 16, sth);
190DEF_MMIO_OUT_D(out_le32, 32, stw);
191
192#endif /* __BIG_ENDIAN */
180 193
181#ifdef __powerpc64__ 194#ifdef __powerpc64__
182DEF_MMIO_OUT_BE(out_be64, 64, std); 195
183DEF_MMIO_IN_BE(in_be64, 64, ld); 196#ifdef __BIG_ENDIAN__
197DEF_MMIO_OUT_D(out_be64, 64, std);
198DEF_MMIO_IN_D(in_be64, 64, ld);
184 199
185/* There is no asm instructions for 64 bits reverse loads and stores */ 200/* There is no asm instructions for 64 bits reverse loads and stores */
186static inline u64 in_le64(const volatile u64 __iomem *addr) 201static inline u64 in_le64(const volatile u64 __iomem *addr)
@@ -192,6 +207,22 @@ static inline void out_le64(volatile u64 __iomem *addr, u64 val)
192{ 207{
193 out_be64(addr, swab64(val)); 208 out_be64(addr, swab64(val));
194} 209}
210#else
211DEF_MMIO_OUT_D(out_le64, 64, std);
212DEF_MMIO_IN_D(in_le64, 64, ld);
213
214/* There is no asm instructions for 64 bits reverse loads and stores */
215static inline u64 in_be64(const volatile u64 __iomem *addr)
216{
217 return swab64(in_le64(addr));
218}
219
220static inline void out_be64(volatile u64 __iomem *addr, u64 val)
221{
222 out_le64(addr, swab64(val));
223}
224
225#endif
195#endif /* __powerpc64__ */ 226#endif /* __powerpc64__ */
196 227
197/* 228/*
diff --git a/arch/powerpc/include/asm/lppaca.h b/arch/powerpc/include/asm/lppaca.h
index 4470d1e34d23..844c28de7ec0 100644
--- a/arch/powerpc/include/asm/lppaca.h
+++ b/arch/powerpc/include/asm/lppaca.h
@@ -84,8 +84,8 @@ struct lppaca {
84 * the processor is yielded (either because of an OS yield or a 84 * the processor is yielded (either because of an OS yield or a
85 * hypervisor preempt). An even value implies that the processor is 85 * hypervisor preempt). An even value implies that the processor is
86 * currently executing. 86 * currently executing.
87 * NOTE: This value will ALWAYS be zero for dedicated processors and 87 * NOTE: Even dedicated processor partitions can yield so this
88 * will NEVER be zero for shared processors (ie, initialized to a 1). 88 * field cannot be used to determine if we are shared or dedicated.
89 */ 89 */
90 volatile __be32 yield_count; 90 volatile __be32 yield_count;
91 volatile __be32 dispersion_count; /* dispatch changed physical cpu */ 91 volatile __be32 dispersion_count; /* dispatch changed physical cpu */
@@ -106,15 +106,15 @@ extern struct lppaca lppaca[];
106#define lppaca_of(cpu) (*paca[cpu].lppaca_ptr) 106#define lppaca_of(cpu) (*paca[cpu].lppaca_ptr)
107 107
108/* 108/*
109 * Old kernels used a reserved bit in the VPA to determine if it was running 109 * We are using a non architected field to determine if a partition is
110 * in shared processor mode. New kernels look for a non zero yield count 110 * shared or dedicated. This currently works on both KVM and PHYP, but
111 * but KVM still needs to set the bit to keep the old stuff happy. 111 * we will have to transition to something better.
112 */ 112 */
113#define LPPACA_OLD_SHARED_PROC 2 113#define LPPACA_OLD_SHARED_PROC 2
114 114
115static inline bool lppaca_shared_proc(struct lppaca *l) 115static inline bool lppaca_shared_proc(struct lppaca *l)
116{ 116{
117 return l->yield_count != 0; 117 return !!(l->__old_status & LPPACA_OLD_SHARED_PROC);
118} 118}
119 119
120/* 120/*
diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h
index 8b480901165a..ad3025d0880b 100644
--- a/arch/powerpc/include/asm/machdep.h
+++ b/arch/powerpc/include/asm/machdep.h
@@ -78,6 +78,18 @@ struct machdep_calls {
78 long index); 78 long index);
79 void (*tce_flush)(struct iommu_table *tbl); 79 void (*tce_flush)(struct iommu_table *tbl);
80 80
81 /* _rm versions are for real mode use only */
82 int (*tce_build_rm)(struct iommu_table *tbl,
83 long index,
84 long npages,
85 unsigned long uaddr,
86 enum dma_data_direction direction,
87 struct dma_attrs *attrs);
88 void (*tce_free_rm)(struct iommu_table *tbl,
89 long index,
90 long npages);
91 void (*tce_flush_rm)(struct iommu_table *tbl);
92
81 void __iomem * (*ioremap)(phys_addr_t addr, unsigned long size, 93 void __iomem * (*ioremap)(phys_addr_t addr, unsigned long size,
82 unsigned long flags, void *caller); 94 unsigned long flags, void *caller);
83 void (*iounmap)(volatile void __iomem *token); 95 void (*iounmap)(volatile void __iomem *token);
@@ -263,6 +275,10 @@ struct machdep_calls {
263 ssize_t (*cpu_probe)(const char *, size_t); 275 ssize_t (*cpu_probe)(const char *, size_t);
264 ssize_t (*cpu_release)(const char *, size_t); 276 ssize_t (*cpu_release)(const char *, size_t);
265#endif 277#endif
278
279#ifdef CONFIG_ARCH_RANDOM
280 int (*get_random_long)(unsigned long *v);
281#endif
266}; 282};
267 283
268extern void e500_idle(void); 284extern void e500_idle(void);
diff --git a/arch/powerpc/include/asm/mmu-hash64.h b/arch/powerpc/include/asm/mmu-hash64.h
index c4cf01197273..807014dde821 100644
--- a/arch/powerpc/include/asm/mmu-hash64.h
+++ b/arch/powerpc/include/asm/mmu-hash64.h
@@ -135,8 +135,8 @@ extern char initial_stab[];
135#ifndef __ASSEMBLY__ 135#ifndef __ASSEMBLY__
136 136
137struct hash_pte { 137struct hash_pte {
138 unsigned long v; 138 __be64 v;
139 unsigned long r; 139 __be64 r;
140}; 140};
141 141
142extern struct hash_pte *htab_address; 142extern struct hash_pte *htab_address;
diff --git a/arch/powerpc/include/asm/opal.h b/arch/powerpc/include/asm/opal.h
index c5cd72833d6e..033c06be1d84 100644
--- a/arch/powerpc/include/asm/opal.h
+++ b/arch/powerpc/include/asm/opal.h
@@ -129,6 +129,9 @@ extern int opal_enter_rtas(struct rtas_args *args,
129#define OPAL_LPC_READ 67 129#define OPAL_LPC_READ 67
130#define OPAL_LPC_WRITE 68 130#define OPAL_LPC_WRITE 68
131#define OPAL_RETURN_CPU 69 131#define OPAL_RETURN_CPU 69
132#define OPAL_FLASH_VALIDATE 76
133#define OPAL_FLASH_MANAGE 77
134#define OPAL_FLASH_UPDATE 78
132 135
133#ifndef __ASSEMBLY__ 136#ifndef __ASSEMBLY__
134 137
@@ -460,10 +463,12 @@ enum {
460 463
461enum { 464enum {
462 OPAL_PHB_ERROR_DATA_TYPE_P7IOC = 1, 465 OPAL_PHB_ERROR_DATA_TYPE_P7IOC = 1,
466 OPAL_PHB_ERROR_DATA_TYPE_PHB3 = 2
463}; 467};
464 468
465enum { 469enum {
466 OPAL_P7IOC_NUM_PEST_REGS = 128, 470 OPAL_P7IOC_NUM_PEST_REGS = 128,
471 OPAL_PHB3_NUM_PEST_REGS = 256
467}; 472};
468 473
469struct OpalIoPhbErrorCommon { 474struct OpalIoPhbErrorCommon {
@@ -531,28 +536,94 @@ struct OpalIoP7IOCPhbErrorData {
531 uint64_t pestB[OPAL_P7IOC_NUM_PEST_REGS]; 536 uint64_t pestB[OPAL_P7IOC_NUM_PEST_REGS];
532}; 537};
533 538
539struct OpalIoPhb3ErrorData {
540 struct OpalIoPhbErrorCommon common;
541
542 uint32_t brdgCtl;
543
544 /* PHB3 UTL regs */
545 uint32_t portStatusReg;
546 uint32_t rootCmplxStatus;
547 uint32_t busAgentStatus;
548
549 /* PHB3 cfg regs */
550 uint32_t deviceStatus;
551 uint32_t slotStatus;
552 uint32_t linkStatus;
553 uint32_t devCmdStatus;
554 uint32_t devSecStatus;
555
556 /* cfg AER regs */
557 uint32_t rootErrorStatus;
558 uint32_t uncorrErrorStatus;
559 uint32_t corrErrorStatus;
560 uint32_t tlpHdr1;
561 uint32_t tlpHdr2;
562 uint32_t tlpHdr3;
563 uint32_t tlpHdr4;
564 uint32_t sourceId;
565
566 uint32_t rsv3;
567
568 /* Record data about the call to allocate a buffer */
569 uint64_t errorClass;
570 uint64_t correlator;
571
572 uint64_t nFir; /* 000 */
573 uint64_t nFirMask; /* 003 */
574 uint64_t nFirWOF; /* 008 */
575
576 /* PHB3 MMIO Error Regs */
577 uint64_t phbPlssr; /* 120 */
578 uint64_t phbCsr; /* 110 */
579 uint64_t lemFir; /* C00 */
580 uint64_t lemErrorMask; /* C18 */
581 uint64_t lemWOF; /* C40 */
582 uint64_t phbErrorStatus; /* C80 */
583 uint64_t phbFirstErrorStatus; /* C88 */
584 uint64_t phbErrorLog0; /* CC0 */
585 uint64_t phbErrorLog1; /* CC8 */
586 uint64_t mmioErrorStatus; /* D00 */
587 uint64_t mmioFirstErrorStatus; /* D08 */
588 uint64_t mmioErrorLog0; /* D40 */
589 uint64_t mmioErrorLog1; /* D48 */
590 uint64_t dma0ErrorStatus; /* D80 */
591 uint64_t dma0FirstErrorStatus; /* D88 */
592 uint64_t dma0ErrorLog0; /* DC0 */
593 uint64_t dma0ErrorLog1; /* DC8 */
594 uint64_t dma1ErrorStatus; /* E00 */
595 uint64_t dma1FirstErrorStatus; /* E08 */
596 uint64_t dma1ErrorLog0; /* E40 */
597 uint64_t dma1ErrorLog1; /* E48 */
598 uint64_t pestA[OPAL_PHB3_NUM_PEST_REGS];
599 uint64_t pestB[OPAL_PHB3_NUM_PEST_REGS];
600};
601
534typedef struct oppanel_line { 602typedef struct oppanel_line {
535 const char * line; 603 const char * line;
536 uint64_t line_len; 604 uint64_t line_len;
537} oppanel_line_t; 605} oppanel_line_t;
538 606
607/* /sys/firmware/opal */
608extern struct kobject *opal_kobj;
609
539/* API functions */ 610/* API functions */
540int64_t opal_console_write(int64_t term_number, int64_t *length, 611int64_t opal_console_write(int64_t term_number, __be64 *length,
541 const uint8_t *buffer); 612 const uint8_t *buffer);
542int64_t opal_console_read(int64_t term_number, int64_t *length, 613int64_t opal_console_read(int64_t term_number, __be64 *length,
543 uint8_t *buffer); 614 uint8_t *buffer);
544int64_t opal_console_write_buffer_space(int64_t term_number, 615int64_t opal_console_write_buffer_space(int64_t term_number,
545 int64_t *length); 616 __be64 *length);
546int64_t opal_rtc_read(uint32_t *year_month_day, 617int64_t opal_rtc_read(__be32 *year_month_day,
547 uint64_t *hour_minute_second_millisecond); 618 __be64 *hour_minute_second_millisecond);
548int64_t opal_rtc_write(uint32_t year_month_day, 619int64_t opal_rtc_write(uint32_t year_month_day,
549 uint64_t hour_minute_second_millisecond); 620 uint64_t hour_minute_second_millisecond);
550int64_t opal_cec_power_down(uint64_t request); 621int64_t opal_cec_power_down(uint64_t request);
551int64_t opal_cec_reboot(void); 622int64_t opal_cec_reboot(void);
552int64_t opal_read_nvram(uint64_t buffer, uint64_t size, uint64_t offset); 623int64_t opal_read_nvram(uint64_t buffer, uint64_t size, uint64_t offset);
553int64_t opal_write_nvram(uint64_t buffer, uint64_t size, uint64_t offset); 624int64_t opal_write_nvram(uint64_t buffer, uint64_t size, uint64_t offset);
554int64_t opal_handle_interrupt(uint64_t isn, uint64_t *outstanding_event_mask); 625int64_t opal_handle_interrupt(uint64_t isn, __be64 *outstanding_event_mask);
555int64_t opal_poll_events(uint64_t *outstanding_event_mask); 626int64_t opal_poll_events(__be64 *outstanding_event_mask);
556int64_t opal_pci_set_hub_tce_memory(uint64_t hub_id, uint64_t tce_mem_addr, 627int64_t opal_pci_set_hub_tce_memory(uint64_t hub_id, uint64_t tce_mem_addr,
557 uint64_t tce_mem_size); 628 uint64_t tce_mem_size);
558int64_t opal_pci_set_phb_tce_memory(uint64_t phb_id, uint64_t tce_mem_addr, 629int64_t opal_pci_set_phb_tce_memory(uint64_t phb_id, uint64_t tce_mem_addr,
@@ -560,9 +631,9 @@ int64_t opal_pci_set_phb_tce_memory(uint64_t phb_id, uint64_t tce_mem_addr,
560int64_t opal_pci_config_read_byte(uint64_t phb_id, uint64_t bus_dev_func, 631int64_t opal_pci_config_read_byte(uint64_t phb_id, uint64_t bus_dev_func,
561 uint64_t offset, uint8_t *data); 632 uint64_t offset, uint8_t *data);
562int64_t opal_pci_config_read_half_word(uint64_t phb_id, uint64_t bus_dev_func, 633int64_t opal_pci_config_read_half_word(uint64_t phb_id, uint64_t bus_dev_func,
563 uint64_t offset, uint16_t *data); 634 uint64_t offset, __be16 *data);
564int64_t opal_pci_config_read_word(uint64_t phb_id, uint64_t bus_dev_func, 635int64_t opal_pci_config_read_word(uint64_t phb_id, uint64_t bus_dev_func,
565 uint64_t offset, uint32_t *data); 636 uint64_t offset, __be32 *data);
566int64_t opal_pci_config_write_byte(uint64_t phb_id, uint64_t bus_dev_func, 637int64_t opal_pci_config_write_byte(uint64_t phb_id, uint64_t bus_dev_func,
567 uint64_t offset, uint8_t data); 638 uint64_t offset, uint8_t data);
568int64_t opal_pci_config_write_half_word(uint64_t phb_id, uint64_t bus_dev_func, 639int64_t opal_pci_config_write_half_word(uint64_t phb_id, uint64_t bus_dev_func,
@@ -570,14 +641,14 @@ int64_t opal_pci_config_write_half_word(uint64_t phb_id, uint64_t bus_dev_func,
570int64_t opal_pci_config_write_word(uint64_t phb_id, uint64_t bus_dev_func, 641int64_t opal_pci_config_write_word(uint64_t phb_id, uint64_t bus_dev_func,
571 uint64_t offset, uint32_t data); 642 uint64_t offset, uint32_t data);
572int64_t opal_set_xive(uint32_t isn, uint16_t server, uint8_t priority); 643int64_t opal_set_xive(uint32_t isn, uint16_t server, uint8_t priority);
573int64_t opal_get_xive(uint32_t isn, uint16_t *server, uint8_t *priority); 644int64_t opal_get_xive(uint32_t isn, __be16 *server, uint8_t *priority);
574int64_t opal_register_exception_handler(uint64_t opal_exception, 645int64_t opal_register_exception_handler(uint64_t opal_exception,
575 uint64_t handler_address, 646 uint64_t handler_address,
576 uint64_t glue_cache_line); 647 uint64_t glue_cache_line);
577int64_t opal_pci_eeh_freeze_status(uint64_t phb_id, uint64_t pe_number, 648int64_t opal_pci_eeh_freeze_status(uint64_t phb_id, uint64_t pe_number,
578 uint8_t *freeze_state, 649 uint8_t *freeze_state,
579 uint16_t *pci_error_type, 650 __be16 *pci_error_type,
580 uint64_t *phb_status); 651 __be64 *phb_status);
581int64_t opal_pci_eeh_freeze_clear(uint64_t phb_id, uint64_t pe_number, 652int64_t opal_pci_eeh_freeze_clear(uint64_t phb_id, uint64_t pe_number,
582 uint64_t eeh_action_token); 653 uint64_t eeh_action_token);
583int64_t opal_pci_shpc(uint64_t phb_id, uint64_t shpc_action, uint8_t *state); 654int64_t opal_pci_shpc(uint64_t phb_id, uint64_t shpc_action, uint8_t *state);
@@ -614,13 +685,13 @@ int64_t opal_pci_msi_eoi(uint64_t phb_id, uint32_t hw_irq);
614int64_t opal_pci_set_xive_pe(uint64_t phb_id, uint32_t pe_number, 685int64_t opal_pci_set_xive_pe(uint64_t phb_id, uint32_t pe_number,
615 uint32_t xive_num); 686 uint32_t xive_num);
616int64_t opal_get_xive_source(uint64_t phb_id, uint32_t xive_num, 687int64_t opal_get_xive_source(uint64_t phb_id, uint32_t xive_num,
617 int32_t *interrupt_source_number); 688 __be32 *interrupt_source_number);
618int64_t opal_get_msi_32(uint64_t phb_id, uint32_t mve_number, uint32_t xive_num, 689int64_t opal_get_msi_32(uint64_t phb_id, uint32_t mve_number, uint32_t xive_num,
619 uint8_t msi_range, uint32_t *msi_address, 690 uint8_t msi_range, __be32 *msi_address,
620 uint32_t *message_data); 691 __be32 *message_data);
621int64_t opal_get_msi_64(uint64_t phb_id, uint32_t mve_number, 692int64_t opal_get_msi_64(uint64_t phb_id, uint32_t mve_number,
622 uint32_t xive_num, uint8_t msi_range, 693 uint32_t xive_num, uint8_t msi_range,
623 uint64_t *msi_address, uint32_t *message_data); 694 __be64 *msi_address, __be32 *message_data);
624int64_t opal_start_cpu(uint64_t thread_number, uint64_t start_address); 695int64_t opal_start_cpu(uint64_t thread_number, uint64_t start_address);
625int64_t opal_query_cpu_status(uint64_t thread_number, uint8_t *thread_status); 696int64_t opal_query_cpu_status(uint64_t thread_number, uint8_t *thread_status);
626int64_t opal_write_oppanel(oppanel_line_t *lines, uint64_t num_lines); 697int64_t opal_write_oppanel(oppanel_line_t *lines, uint64_t num_lines);
@@ -642,7 +713,7 @@ int64_t opal_pci_fence_phb(uint64_t phb_id);
642int64_t opal_pci_reinit(uint64_t phb_id, uint8_t reinit_scope); 713int64_t opal_pci_reinit(uint64_t phb_id, uint8_t reinit_scope);
643int64_t opal_pci_mask_pe_error(uint64_t phb_id, uint16_t pe_number, uint8_t error_type, uint8_t mask_action); 714int64_t opal_pci_mask_pe_error(uint64_t phb_id, uint16_t pe_number, uint8_t error_type, uint8_t mask_action);
644int64_t opal_set_slot_led_status(uint64_t phb_id, uint64_t slot_id, uint8_t led_type, uint8_t led_action); 715int64_t opal_set_slot_led_status(uint64_t phb_id, uint64_t slot_id, uint8_t led_type, uint8_t led_action);
645int64_t opal_get_epow_status(uint64_t *status); 716int64_t opal_get_epow_status(__be64 *status);
646int64_t opal_set_system_attention_led(uint8_t led_action); 717int64_t opal_set_system_attention_led(uint8_t led_action);
647int64_t opal_pci_next_error(uint64_t phb_id, uint64_t *first_frozen_pe, 718int64_t opal_pci_next_error(uint64_t phb_id, uint64_t *first_frozen_pe,
648 uint16_t *pci_error_type, uint16_t *severity); 719 uint16_t *pci_error_type, uint16_t *severity);
@@ -656,6 +727,9 @@ int64_t opal_lpc_write(uint32_t chip_id, enum OpalLPCAddressType addr_type,
656 uint32_t addr, uint32_t data, uint32_t sz); 727 uint32_t addr, uint32_t data, uint32_t sz);
657int64_t opal_lpc_read(uint32_t chip_id, enum OpalLPCAddressType addr_type, 728int64_t opal_lpc_read(uint32_t chip_id, enum OpalLPCAddressType addr_type,
658 uint32_t addr, uint32_t *data, uint32_t sz); 729 uint32_t addr, uint32_t *data, uint32_t sz);
730int64_t opal_validate_flash(uint64_t buffer, uint32_t *size, uint32_t *result);
731int64_t opal_manage_flash(uint8_t op);
732int64_t opal_update_flash(uint64_t blk_list);
659 733
660/* Internal functions */ 734/* Internal functions */
661extern int early_init_dt_scan_opal(unsigned long node, const char *uname, int depth, void *data); 735extern int early_init_dt_scan_opal(unsigned long node, const char *uname, int depth, void *data);
@@ -684,6 +758,7 @@ extern int opal_set_rtc_time(struct rtc_time *tm);
684extern void opal_get_rtc_time(struct rtc_time *tm); 758extern void opal_get_rtc_time(struct rtc_time *tm);
685extern unsigned long opal_get_boot_time(void); 759extern unsigned long opal_get_boot_time(void);
686extern void opal_nvram_init(void); 760extern void opal_nvram_init(void);
761extern void opal_flash_init(void);
687 762
688extern int opal_machine_check(struct pt_regs *regs); 763extern int opal_machine_check(struct pt_regs *regs);
689 764
diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
index b9f426212d3a..32e4e212b9c1 100644
--- a/arch/powerpc/include/asm/page.h
+++ b/arch/powerpc/include/asm/page.h
@@ -78,7 +78,7 @@ extern unsigned int HPAGE_SHIFT;
78 * 78 *
79 * Also, KERNELBASE >= PAGE_OFFSET and PHYSICAL_START >= MEMORY_START 79 * Also, KERNELBASE >= PAGE_OFFSET and PHYSICAL_START >= MEMORY_START
80 * 80 *
81 * There are two was to determine a physical address from a virtual one: 81 * There are two ways to determine a physical address from a virtual one:
82 * va = pa + PAGE_OFFSET - MEMORY_START 82 * va = pa + PAGE_OFFSET - MEMORY_START
83 * va = pa + KERNELBASE - PHYSICAL_START 83 * va = pa + KERNELBASE - PHYSICAL_START
84 * 84 *
@@ -403,7 +403,7 @@ void arch_free_page(struct page *page, int order);
403 403
404struct vm_area_struct; 404struct vm_area_struct;
405 405
406#ifdef CONFIG_PPC_64K_PAGES 406#if defined(CONFIG_PPC_64K_PAGES) && defined(CONFIG_PPC64)
407typedef pte_t *pgtable_t; 407typedef pte_t *pgtable_t;
408#else 408#else
409typedef struct page *pgtable_t; 409typedef struct page *pgtable_t;
diff --git a/arch/powerpc/include/asm/pgtable-ppc64.h b/arch/powerpc/include/asm/pgtable-ppc64.h
index 46db09414a10..4a191c472867 100644
--- a/arch/powerpc/include/asm/pgtable-ppc64.h
+++ b/arch/powerpc/include/asm/pgtable-ppc64.h
@@ -394,6 +394,8 @@ static inline void mark_hpte_slot_valid(unsigned char *hpte_slot_array,
394 hpte_slot_array[index] = hidx << 4 | 0x1 << 3; 394 hpte_slot_array[index] = hidx << 4 | 0x1 << 3;
395} 395}
396 396
397struct page *realmode_pfn_to_page(unsigned long pfn);
398
397static inline char *get_hpte_slot_array(pmd_t *pmdp) 399static inline char *get_hpte_slot_array(pmd_t *pmdp)
398{ 400{
399 /* 401 /*
diff --git a/arch/powerpc/include/asm/ppc-opcode.h b/arch/powerpc/include/asm/ppc-opcode.h
index d7fe9f5b46d4..3132bb9365f3 100644
--- a/arch/powerpc/include/asm/ppc-opcode.h
+++ b/arch/powerpc/include/asm/ppc-opcode.h
@@ -143,6 +143,8 @@
143#define PPC_INST_LSWX 0x7c00042a 143#define PPC_INST_LSWX 0x7c00042a
144#define PPC_INST_LWARX 0x7c000028 144#define PPC_INST_LWARX 0x7c000028
145#define PPC_INST_LWSYNC 0x7c2004ac 145#define PPC_INST_LWSYNC 0x7c2004ac
146#define PPC_INST_SYNC 0x7c0004ac
147#define PPC_INST_SYNC_MASK 0xfc0007fe
146#define PPC_INST_LXVD2X 0x7c000698 148#define PPC_INST_LXVD2X 0x7c000698
147#define PPC_INST_MCRXR 0x7c000400 149#define PPC_INST_MCRXR 0x7c000400
148#define PPC_INST_MCRXR_MASK 0xfc0007fe 150#define PPC_INST_MCRXR_MASK 0xfc0007fe
@@ -181,6 +183,7 @@
181#define PPC_INST_TLBIVAX 0x7c000624 183#define PPC_INST_TLBIVAX 0x7c000624
182#define PPC_INST_TLBSRX_DOT 0x7c0006a5 184#define PPC_INST_TLBSRX_DOT 0x7c0006a5
183#define PPC_INST_XXLOR 0xf0000510 185#define PPC_INST_XXLOR 0xf0000510
186#define PPC_INST_XXSWAPD 0xf0000250
184#define PPC_INST_XVCPSGNDP 0xf0000780 187#define PPC_INST_XVCPSGNDP 0xf0000780
185#define PPC_INST_TRECHKPT 0x7c0007dd 188#define PPC_INST_TRECHKPT 0x7c0007dd
186#define PPC_INST_TRECLAIM 0x7c00075d 189#define PPC_INST_TRECLAIM 0x7c00075d
@@ -200,6 +203,7 @@
200/* Misc instructions for BPF compiler */ 203/* Misc instructions for BPF compiler */
201#define PPC_INST_LD 0xe8000000 204#define PPC_INST_LD 0xe8000000
202#define PPC_INST_LHZ 0xa0000000 205#define PPC_INST_LHZ 0xa0000000
206#define PPC_INST_LHBRX 0x7c00062c
203#define PPC_INST_LWZ 0x80000000 207#define PPC_INST_LWZ 0x80000000
204#define PPC_INST_STD 0xf8000000 208#define PPC_INST_STD 0xf8000000
205#define PPC_INST_STDU 0xf8000001 209#define PPC_INST_STDU 0xf8000001
@@ -218,7 +222,7 @@
218#define PPC_INST_MULLW 0x7c0001d6 222#define PPC_INST_MULLW 0x7c0001d6
219#define PPC_INST_MULHWU 0x7c000016 223#define PPC_INST_MULHWU 0x7c000016
220#define PPC_INST_MULLI 0x1c000000 224#define PPC_INST_MULLI 0x1c000000
221#define PPC_INST_DIVWU 0x7c0003d6 225#define PPC_INST_DIVWU 0x7c000396
222#define PPC_INST_RLWINM 0x54000000 226#define PPC_INST_RLWINM 0x54000000
223#define PPC_INST_RLDICR 0x78000004 227#define PPC_INST_RLDICR 0x78000004
224#define PPC_INST_SLW 0x7c000030 228#define PPC_INST_SLW 0x7c000030
@@ -344,6 +348,8 @@
344 VSX_XX1((s), a, b)) 348 VSX_XX1((s), a, b))
345#define XXLOR(t, a, b) stringify_in_c(.long PPC_INST_XXLOR | \ 349#define XXLOR(t, a, b) stringify_in_c(.long PPC_INST_XXLOR | \
346 VSX_XX3((t), a, b)) 350 VSX_XX3((t), a, b))
351#define XXSWAPD(t, a) stringify_in_c(.long PPC_INST_XXSWAPD | \
352 VSX_XX3((t), a, a))
347#define XVCPSGNDP(t, a, b) stringify_in_c(.long (PPC_INST_XVCPSGNDP | \ 353#define XVCPSGNDP(t, a, b) stringify_in_c(.long (PPC_INST_XVCPSGNDP | \
348 VSX_XX3((t), (a), (b)))) 354 VSX_XX3((t), (a), (b))))
349 355
diff --git a/arch/powerpc/include/asm/ppc_asm.h b/arch/powerpc/include/asm/ppc_asm.h
index 599545738af3..3c1acc31a092 100644
--- a/arch/powerpc/include/asm/ppc_asm.h
+++ b/arch/powerpc/include/asm/ppc_asm.h
@@ -98,123 +98,51 @@ END_FW_FTR_SECTION_IFSET(FW_FEATURE_SPLPAR)
98#define REST_8GPRS(n, base) REST_4GPRS(n, base); REST_4GPRS(n+4, base) 98#define REST_8GPRS(n, base) REST_4GPRS(n, base); REST_4GPRS(n+4, base)
99#define REST_10GPRS(n, base) REST_8GPRS(n, base); REST_2GPRS(n+8, base) 99#define REST_10GPRS(n, base) REST_8GPRS(n, base); REST_2GPRS(n+8, base)
100 100
101#define SAVE_FPR(n, base) stfd n,THREAD_FPR0+8*TS_FPRWIDTH*(n)(base) 101#define SAVE_FPR(n, base) stfd n,8*TS_FPRWIDTH*(n)(base)
102#define SAVE_2FPRS(n, base) SAVE_FPR(n, base); SAVE_FPR(n+1, base) 102#define SAVE_2FPRS(n, base) SAVE_FPR(n, base); SAVE_FPR(n+1, base)
103#define SAVE_4FPRS(n, base) SAVE_2FPRS(n, base); SAVE_2FPRS(n+2, base) 103#define SAVE_4FPRS(n, base) SAVE_2FPRS(n, base); SAVE_2FPRS(n+2, base)
104#define SAVE_8FPRS(n, base) SAVE_4FPRS(n, base); SAVE_4FPRS(n+4, base) 104#define SAVE_8FPRS(n, base) SAVE_4FPRS(n, base); SAVE_4FPRS(n+4, base)
105#define SAVE_16FPRS(n, base) SAVE_8FPRS(n, base); SAVE_8FPRS(n+8, base) 105#define SAVE_16FPRS(n, base) SAVE_8FPRS(n, base); SAVE_8FPRS(n+8, base)
106#define SAVE_32FPRS(n, base) SAVE_16FPRS(n, base); SAVE_16FPRS(n+16, base) 106#define SAVE_32FPRS(n, base) SAVE_16FPRS(n, base); SAVE_16FPRS(n+16, base)
107#define REST_FPR(n, base) lfd n,THREAD_FPR0+8*TS_FPRWIDTH*(n)(base) 107#define REST_FPR(n, base) lfd n,8*TS_FPRWIDTH*(n)(base)
108#define REST_2FPRS(n, base) REST_FPR(n, base); REST_FPR(n+1, base) 108#define REST_2FPRS(n, base) REST_FPR(n, base); REST_FPR(n+1, base)
109#define REST_4FPRS(n, base) REST_2FPRS(n, base); REST_2FPRS(n+2, base) 109#define REST_4FPRS(n, base) REST_2FPRS(n, base); REST_2FPRS(n+2, base)
110#define REST_8FPRS(n, base) REST_4FPRS(n, base); REST_4FPRS(n+4, base) 110#define REST_8FPRS(n, base) REST_4FPRS(n, base); REST_4FPRS(n+4, base)
111#define REST_16FPRS(n, base) REST_8FPRS(n, base); REST_8FPRS(n+8, base) 111#define REST_16FPRS(n, base) REST_8FPRS(n, base); REST_8FPRS(n+8, base)
112#define REST_32FPRS(n, base) REST_16FPRS(n, base); REST_16FPRS(n+16, base) 112#define REST_32FPRS(n, base) REST_16FPRS(n, base); REST_16FPRS(n+16, base)
113 113
114#define SAVE_VR(n,b,base) li b,THREAD_VR0+(16*(n)); stvx n,base,b 114#define SAVE_VR(n,b,base) li b,16*(n); stvx n,base,b
115#define SAVE_2VRS(n,b,base) SAVE_VR(n,b,base); SAVE_VR(n+1,b,base) 115#define SAVE_2VRS(n,b,base) SAVE_VR(n,b,base); SAVE_VR(n+1,b,base)
116#define SAVE_4VRS(n,b,base) SAVE_2VRS(n,b,base); SAVE_2VRS(n+2,b,base) 116#define SAVE_4VRS(n,b,base) SAVE_2VRS(n,b,base); SAVE_2VRS(n+2,b,base)
117#define SAVE_8VRS(n,b,base) SAVE_4VRS(n,b,base); SAVE_4VRS(n+4,b,base) 117#define SAVE_8VRS(n,b,base) SAVE_4VRS(n,b,base); SAVE_4VRS(n+4,b,base)
118#define SAVE_16VRS(n,b,base) SAVE_8VRS(n,b,base); SAVE_8VRS(n+8,b,base) 118#define SAVE_16VRS(n,b,base) SAVE_8VRS(n,b,base); SAVE_8VRS(n+8,b,base)
119#define SAVE_32VRS(n,b,base) SAVE_16VRS(n,b,base); SAVE_16VRS(n+16,b,base) 119#define SAVE_32VRS(n,b,base) SAVE_16VRS(n,b,base); SAVE_16VRS(n+16,b,base)
120#define REST_VR(n,b,base) li b,THREAD_VR0+(16*(n)); lvx n,base,b 120#define REST_VR(n,b,base) li b,16*(n); lvx n,base,b
121#define REST_2VRS(n,b,base) REST_VR(n,b,base); REST_VR(n+1,b,base) 121#define REST_2VRS(n,b,base) REST_VR(n,b,base); REST_VR(n+1,b,base)
122#define REST_4VRS(n,b,base) REST_2VRS(n,b,base); REST_2VRS(n+2,b,base) 122#define REST_4VRS(n,b,base) REST_2VRS(n,b,base); REST_2VRS(n+2,b,base)
123#define REST_8VRS(n,b,base) REST_4VRS(n,b,base); REST_4VRS(n+4,b,base) 123#define REST_8VRS(n,b,base) REST_4VRS(n,b,base); REST_4VRS(n+4,b,base)
124#define REST_16VRS(n,b,base) REST_8VRS(n,b,base); REST_8VRS(n+8,b,base) 124#define REST_16VRS(n,b,base) REST_8VRS(n,b,base); REST_8VRS(n+8,b,base)
125#define REST_32VRS(n,b,base) REST_16VRS(n,b,base); REST_16VRS(n+16,b,base) 125#define REST_32VRS(n,b,base) REST_16VRS(n,b,base); REST_16VRS(n+16,b,base)
126 126
127/* Save/restore FPRs, VRs and VSRs from their checkpointed backups in 127#ifdef __BIG_ENDIAN__
128 * thread_struct: 128#define STXVD2X_ROT(n,b,base) STXVD2X(n,b,base)
129 */ 129#define LXVD2X_ROT(n,b,base) LXVD2X(n,b,base)
130#define SAVE_FPR_TRANSACT(n, base) stfd n,THREAD_TRANSACT_FPR0+ \ 130#else
131 8*TS_FPRWIDTH*(n)(base) 131#define STXVD2X_ROT(n,b,base) XXSWAPD(n,n); \
132#define SAVE_2FPRS_TRANSACT(n, base) SAVE_FPR_TRANSACT(n, base); \ 132 STXVD2X(n,b,base); \
133 SAVE_FPR_TRANSACT(n+1, base) 133 XXSWAPD(n,n)
134#define SAVE_4FPRS_TRANSACT(n, base) SAVE_2FPRS_TRANSACT(n, base); \
135 SAVE_2FPRS_TRANSACT(n+2, base)
136#define SAVE_8FPRS_TRANSACT(n, base) SAVE_4FPRS_TRANSACT(n, base); \
137 SAVE_4FPRS_TRANSACT(n+4, base)
138#define SAVE_16FPRS_TRANSACT(n, base) SAVE_8FPRS_TRANSACT(n, base); \
139 SAVE_8FPRS_TRANSACT(n+8, base)
140#define SAVE_32FPRS_TRANSACT(n, base) SAVE_16FPRS_TRANSACT(n, base); \
141 SAVE_16FPRS_TRANSACT(n+16, base)
142
143#define REST_FPR_TRANSACT(n, base) lfd n,THREAD_TRANSACT_FPR0+ \
144 8*TS_FPRWIDTH*(n)(base)
145#define REST_2FPRS_TRANSACT(n, base) REST_FPR_TRANSACT(n, base); \
146 REST_FPR_TRANSACT(n+1, base)
147#define REST_4FPRS_TRANSACT(n, base) REST_2FPRS_TRANSACT(n, base); \
148 REST_2FPRS_TRANSACT(n+2, base)
149#define REST_8FPRS_TRANSACT(n, base) REST_4FPRS_TRANSACT(n, base); \
150 REST_4FPRS_TRANSACT(n+4, base)
151#define REST_16FPRS_TRANSACT(n, base) REST_8FPRS_TRANSACT(n, base); \
152 REST_8FPRS_TRANSACT(n+8, base)
153#define REST_32FPRS_TRANSACT(n, base) REST_16FPRS_TRANSACT(n, base); \
154 REST_16FPRS_TRANSACT(n+16, base)
155
156
157#define SAVE_VR_TRANSACT(n,b,base) li b,THREAD_TRANSACT_VR0+(16*(n)); \
158 stvx n,b,base
159#define SAVE_2VRS_TRANSACT(n,b,base) SAVE_VR_TRANSACT(n,b,base); \
160 SAVE_VR_TRANSACT(n+1,b,base)
161#define SAVE_4VRS_TRANSACT(n,b,base) SAVE_2VRS_TRANSACT(n,b,base); \
162 SAVE_2VRS_TRANSACT(n+2,b,base)
163#define SAVE_8VRS_TRANSACT(n,b,base) SAVE_4VRS_TRANSACT(n,b,base); \
164 SAVE_4VRS_TRANSACT(n+4,b,base)
165#define SAVE_16VRS_TRANSACT(n,b,base) SAVE_8VRS_TRANSACT(n,b,base); \
166 SAVE_8VRS_TRANSACT(n+8,b,base)
167#define SAVE_32VRS_TRANSACT(n,b,base) SAVE_16VRS_TRANSACT(n,b,base); \
168 SAVE_16VRS_TRANSACT(n+16,b,base)
169
170#define REST_VR_TRANSACT(n,b,base) li b,THREAD_TRANSACT_VR0+(16*(n)); \
171 lvx n,b,base
172#define REST_2VRS_TRANSACT(n,b,base) REST_VR_TRANSACT(n,b,base); \
173 REST_VR_TRANSACT(n+1,b,base)
174#define REST_4VRS_TRANSACT(n,b,base) REST_2VRS_TRANSACT(n,b,base); \
175 REST_2VRS_TRANSACT(n+2,b,base)
176#define REST_8VRS_TRANSACT(n,b,base) REST_4VRS_TRANSACT(n,b,base); \
177 REST_4VRS_TRANSACT(n+4,b,base)
178#define REST_16VRS_TRANSACT(n,b,base) REST_8VRS_TRANSACT(n,b,base); \
179 REST_8VRS_TRANSACT(n+8,b,base)
180#define REST_32VRS_TRANSACT(n,b,base) REST_16VRS_TRANSACT(n,b,base); \
181 REST_16VRS_TRANSACT(n+16,b,base)
182
183
184#define SAVE_VSR_TRANSACT(n,b,base) li b,THREAD_TRANSACT_VSR0+(16*(n)); \
185 STXVD2X(n,R##base,R##b)
186#define SAVE_2VSRS_TRANSACT(n,b,base) SAVE_VSR_TRANSACT(n,b,base); \
187 SAVE_VSR_TRANSACT(n+1,b,base)
188#define SAVE_4VSRS_TRANSACT(n,b,base) SAVE_2VSRS_TRANSACT(n,b,base); \
189 SAVE_2VSRS_TRANSACT(n+2,b,base)
190#define SAVE_8VSRS_TRANSACT(n,b,base) SAVE_4VSRS_TRANSACT(n,b,base); \
191 SAVE_4VSRS_TRANSACT(n+4,b,base)
192#define SAVE_16VSRS_TRANSACT(n,b,base) SAVE_8VSRS_TRANSACT(n,b,base); \
193 SAVE_8VSRS_TRANSACT(n+8,b,base)
194#define SAVE_32VSRS_TRANSACT(n,b,base) SAVE_16VSRS_TRANSACT(n,b,base); \
195 SAVE_16VSRS_TRANSACT(n+16,b,base)
196
197#define REST_VSR_TRANSACT(n,b,base) li b,THREAD_TRANSACT_VSR0+(16*(n)); \
198 LXVD2X(n,R##base,R##b)
199#define REST_2VSRS_TRANSACT(n,b,base) REST_VSR_TRANSACT(n,b,base); \
200 REST_VSR_TRANSACT(n+1,b,base)
201#define REST_4VSRS_TRANSACT(n,b,base) REST_2VSRS_TRANSACT(n,b,base); \
202 REST_2VSRS_TRANSACT(n+2,b,base)
203#define REST_8VSRS_TRANSACT(n,b,base) REST_4VSRS_TRANSACT(n,b,base); \
204 REST_4VSRS_TRANSACT(n+4,b,base)
205#define REST_16VSRS_TRANSACT(n,b,base) REST_8VSRS_TRANSACT(n,b,base); \
206 REST_8VSRS_TRANSACT(n+8,b,base)
207#define REST_32VSRS_TRANSACT(n,b,base) REST_16VSRS_TRANSACT(n,b,base); \
208 REST_16VSRS_TRANSACT(n+16,b,base)
209 134
135#define LXVD2X_ROT(n,b,base) LXVD2X(n,b,base); \
136 XXSWAPD(n,n)
137#endif
210/* Save the lower 32 VSRs in the thread VSR region */ 138/* Save the lower 32 VSRs in the thread VSR region */
211#define SAVE_VSR(n,b,base) li b,THREAD_VSR0+(16*(n)); STXVD2X(n,R##base,R##b) 139#define SAVE_VSR(n,b,base) li b,16*(n); STXVD2X_ROT(n,R##base,R##b)
212#define SAVE_2VSRS(n,b,base) SAVE_VSR(n,b,base); SAVE_VSR(n+1,b,base) 140#define SAVE_2VSRS(n,b,base) SAVE_VSR(n,b,base); SAVE_VSR(n+1,b,base)
213#define SAVE_4VSRS(n,b,base) SAVE_2VSRS(n,b,base); SAVE_2VSRS(n+2,b,base) 141#define SAVE_4VSRS(n,b,base) SAVE_2VSRS(n,b,base); SAVE_2VSRS(n+2,b,base)
214#define SAVE_8VSRS(n,b,base) SAVE_4VSRS(n,b,base); SAVE_4VSRS(n+4,b,base) 142#define SAVE_8VSRS(n,b,base) SAVE_4VSRS(n,b,base); SAVE_4VSRS(n+4,b,base)
215#define SAVE_16VSRS(n,b,base) SAVE_8VSRS(n,b,base); SAVE_8VSRS(n+8,b,base) 143#define SAVE_16VSRS(n,b,base) SAVE_8VSRS(n,b,base); SAVE_8VSRS(n+8,b,base)
216#define SAVE_32VSRS(n,b,base) SAVE_16VSRS(n,b,base); SAVE_16VSRS(n+16,b,base) 144#define SAVE_32VSRS(n,b,base) SAVE_16VSRS(n,b,base); SAVE_16VSRS(n+16,b,base)
217#define REST_VSR(n,b,base) li b,THREAD_VSR0+(16*(n)); LXVD2X(n,R##base,R##b) 145#define REST_VSR(n,b,base) li b,16*(n); LXVD2X_ROT(n,R##base,R##b)
218#define REST_2VSRS(n,b,base) REST_VSR(n,b,base); REST_VSR(n+1,b,base) 146#define REST_2VSRS(n,b,base) REST_VSR(n,b,base); REST_VSR(n+1,b,base)
219#define REST_4VSRS(n,b,base) REST_2VSRS(n,b,base); REST_2VSRS(n+2,b,base) 147#define REST_4VSRS(n,b,base) REST_2VSRS(n,b,base); REST_2VSRS(n+2,b,base)
220#define REST_8VSRS(n,b,base) REST_4VSRS(n,b,base); REST_4VSRS(n+4,b,base) 148#define REST_8VSRS(n,b,base) REST_4VSRS(n,b,base); REST_4VSRS(n+4,b,base)
@@ -478,13 +406,6 @@ BEGIN_FTR_SECTION_NESTED(945) \
478 std ra,TASKTHREADPPR(rb); \ 406 std ra,TASKTHREADPPR(rb); \
479END_FTR_SECTION_NESTED(CPU_FTR_HAS_PPR,CPU_FTR_HAS_PPR,945) 407END_FTR_SECTION_NESTED(CPU_FTR_HAS_PPR,CPU_FTR_HAS_PPR,945)
480 408
481#define RESTORE_PPR(ra, rb) \
482BEGIN_FTR_SECTION_NESTED(946) \
483 ld ra,PACACURRENT(r13); \
484 ld rb,TASKTHREADPPR(ra); \
485 mtspr SPRN_PPR,rb; /* Restore PPR */ \
486END_FTR_SECTION_NESTED(CPU_FTR_HAS_PPR,CPU_FTR_HAS_PPR,946)
487
488#endif 409#endif
489 410
490/* 411/*
@@ -832,6 +753,35 @@ END_FTR_SECTION_NESTED(CPU_FTR_HAS_PPR,CPU_FTR_HAS_PPR,946)
832#define N_SLINE 68 753#define N_SLINE 68
833#define N_SO 100 754#define N_SO 100
834 755
835#endif /* __ASSEMBLY__ */ 756/*
757 * Create an endian fixup trampoline
758 *
759 * This starts with a "tdi 0,0,0x48" instruction which is
760 * essentially a "trap never", and thus akin to a nop.
761 *
762 * The opcode for this instruction read with the wrong endian
763 * however results in a b . + 8
764 *
765 * So essentially we use that trick to execute the following
766 * trampoline in "reverse endian" if we are running with the
767 * MSR_LE bit set the "wrong" way for whatever endianness the
768 * kernel is built for.
769 */
836 770
771#ifdef CONFIG_PPC_BOOK3E
772#define FIXUP_ENDIAN
773#else
774#define FIXUP_ENDIAN \
775 tdi 0,0,0x48; /* Reverse endian of b . + 8 */ \
776 b $+36; /* Skip trampoline if endian is good */ \
777 .long 0x05009f42; /* bcl 20,31,$+4 */ \
778 .long 0xa602487d; /* mflr r10 */ \
779 .long 0x1c004a39; /* addi r10,r10,28 */ \
780 .long 0xa600607d; /* mfmsr r11 */ \
781 .long 0x01006b69; /* xori r11,r11,1 */ \
782 .long 0xa6035a7d; /* mtsrr0 r10 */ \
783 .long 0xa6037b7d; /* mtsrr1 r11 */ \
784 .long 0x2400004c /* rfid */
785#endif /* !CONFIG_PPC_BOOK3E */
786#endif /* __ASSEMBLY__ */
837#endif /* _ASM_POWERPC_PPC_ASM_H */ 787#endif /* _ASM_POWERPC_PPC_ASM_H */
diff --git a/arch/powerpc/include/asm/processor.h b/arch/powerpc/include/asm/processor.h
index ce4de5aed7b5..7794b2b04eb2 100644
--- a/arch/powerpc/include/asm/processor.h
+++ b/arch/powerpc/include/asm/processor.h
@@ -14,8 +14,18 @@
14 14
15#ifdef CONFIG_VSX 15#ifdef CONFIG_VSX
16#define TS_FPRWIDTH 2 16#define TS_FPRWIDTH 2
17
18#ifdef __BIG_ENDIAN__
19#define TS_FPROFFSET 0
20#define TS_VSRLOWOFFSET 1
21#else
22#define TS_FPROFFSET 1
23#define TS_VSRLOWOFFSET 0
24#endif
25
17#else 26#else
18#define TS_FPRWIDTH 1 27#define TS_FPRWIDTH 1
28#define TS_FPROFFSET 0
19#endif 29#endif
20 30
21#ifdef CONFIG_PPC64 31#ifdef CONFIG_PPC64
@@ -142,26 +152,22 @@ typedef struct {
142 unsigned long seg; 152 unsigned long seg;
143} mm_segment_t; 153} mm_segment_t;
144 154
145#define TS_FPROFFSET 0 155#define TS_FPR(i) fp_state.fpr[i][TS_FPROFFSET]
146#define TS_VSRLOWOFFSET 1 156#define TS_TRANS_FPR(i) transact_fp.fpr[i][TS_FPROFFSET]
147#define TS_FPR(i) fpr[i][TS_FPROFFSET]
148#define TS_TRANS_FPR(i) transact_fpr[i][TS_FPROFFSET]
149 157
150struct thread_struct { 158/* FP and VSX 0-31 register set */
151 unsigned long ksp; /* Kernel stack pointer */ 159struct thread_fp_state {
152#ifdef CONFIG_PPC64 160 u64 fpr[32][TS_FPRWIDTH] __attribute__((aligned(16)));
153 unsigned long ksp_vsid; 161 u64 fpscr; /* Floating point status */
154#endif 162};
155 struct pt_regs *regs; /* Pointer to saved register state */ 163
156 mm_segment_t fs; /* for get_fs() validation */ 164/* Complete AltiVec register set including VSCR */
157#ifdef CONFIG_BOOKE 165struct thread_vr_state {
158 /* BookE base exception scratch space; align on cacheline */ 166 vector128 vr[32] __attribute__((aligned(16)));
159 unsigned long normsave[8] ____cacheline_aligned; 167 vector128 vscr __attribute__((aligned(16)));
160#endif 168};
161#ifdef CONFIG_PPC32 169
162 void *pgdir; /* root of page-table tree */ 170struct debug_reg {
163 unsigned long ksp_limit; /* if ksp <= ksp_limit stack overflow */
164#endif
165#ifdef CONFIG_PPC_ADV_DEBUG_REGS 171#ifdef CONFIG_PPC_ADV_DEBUG_REGS
166 /* 172 /*
167 * The following help to manage the use of Debug Control Registers 173 * The following help to manage the use of Debug Control Registers
@@ -198,13 +204,26 @@ struct thread_struct {
198 unsigned long dvc2; 204 unsigned long dvc2;
199#endif 205#endif
200#endif 206#endif
201 /* FP and VSX 0-31 register set */ 207};
202 double fpr[32][TS_FPRWIDTH] __attribute__((aligned(16)));
203 struct {
204 208
205 unsigned int pad; 209struct thread_struct {
206 unsigned int val; /* Floating point status */ 210 unsigned long ksp; /* Kernel stack pointer */
207 } fpscr; 211#ifdef CONFIG_PPC64
212 unsigned long ksp_vsid;
213#endif
214 struct pt_regs *regs; /* Pointer to saved register state */
215 mm_segment_t fs; /* for get_fs() validation */
216#ifdef CONFIG_BOOKE
217 /* BookE base exception scratch space; align on cacheline */
218 unsigned long normsave[8] ____cacheline_aligned;
219#endif
220#ifdef CONFIG_PPC32
221 void *pgdir; /* root of page-table tree */
222 unsigned long ksp_limit; /* if ksp <= ksp_limit stack overflow */
223#endif
224 struct debug_reg debug;
225 struct thread_fp_state fp_state;
226 struct thread_fp_state *fp_save_area;
208 int fpexc_mode; /* floating-point exception mode */ 227 int fpexc_mode; /* floating-point exception mode */
209 unsigned int align_ctl; /* alignment handling control */ 228 unsigned int align_ctl; /* alignment handling control */
210#ifdef CONFIG_PPC64 229#ifdef CONFIG_PPC64
@@ -222,10 +241,8 @@ struct thread_struct {
222 struct arch_hw_breakpoint hw_brk; /* info on the hardware breakpoint */ 241 struct arch_hw_breakpoint hw_brk; /* info on the hardware breakpoint */
223 unsigned long trap_nr; /* last trap # on this thread */ 242 unsigned long trap_nr; /* last trap # on this thread */
224#ifdef CONFIG_ALTIVEC 243#ifdef CONFIG_ALTIVEC
225 /* Complete AltiVec register set */ 244 struct thread_vr_state vr_state;
226 vector128 vr[32] __attribute__((aligned(16))); 245 struct thread_vr_state *vr_save_area;
227 /* AltiVec status */
228 vector128 vscr __attribute__((aligned(16)));
229 unsigned long vrsave; 246 unsigned long vrsave;
230 int used_vr; /* set if process has used altivec */ 247 int used_vr; /* set if process has used altivec */
231#endif /* CONFIG_ALTIVEC */ 248#endif /* CONFIG_ALTIVEC */
@@ -262,13 +279,8 @@ struct thread_struct {
262 * transact_fpr[] is the new set of transactional values. 279 * transact_fpr[] is the new set of transactional values.
263 * VRs work the same way. 280 * VRs work the same way.
264 */ 281 */
265 double transact_fpr[32][TS_FPRWIDTH]; 282 struct thread_fp_state transact_fp;
266 struct { 283 struct thread_vr_state transact_vr;
267 unsigned int pad;
268 unsigned int val; /* Floating point status */
269 } transact_fpscr;
270 vector128 transact_vr[32] __attribute__((aligned(16)));
271 vector128 transact_vscr __attribute__((aligned(16)));
272 unsigned long transact_vrsave; 284 unsigned long transact_vrsave;
273#endif /* CONFIG_PPC_TRANSACTIONAL_MEM */ 285#endif /* CONFIG_PPC_TRANSACTIONAL_MEM */
274#ifdef CONFIG_KVM_BOOK3S_32_HANDLER 286#ifdef CONFIG_KVM_BOOK3S_32_HANDLER
@@ -322,8 +334,6 @@ struct thread_struct {
322 .ksp = INIT_SP, \ 334 .ksp = INIT_SP, \
323 .regs = (struct pt_regs *)INIT_SP - 1, /* XXX bogus, I think */ \ 335 .regs = (struct pt_regs *)INIT_SP - 1, /* XXX bogus, I think */ \
324 .fs = KERNEL_DS, \ 336 .fs = KERNEL_DS, \
325 .fpr = {{0}}, \
326 .fpscr = { .val = 0, }, \
327 .fpexc_mode = 0, \ 337 .fpexc_mode = 0, \
328 .ppr = INIT_PPR, \ 338 .ppr = INIT_PPR, \
329} 339}
@@ -361,6 +371,11 @@ extern int set_endian(struct task_struct *tsk, unsigned int val);
361extern int get_unalign_ctl(struct task_struct *tsk, unsigned long adr); 371extern int get_unalign_ctl(struct task_struct *tsk, unsigned long adr);
362extern int set_unalign_ctl(struct task_struct *tsk, unsigned int val); 372extern int set_unalign_ctl(struct task_struct *tsk, unsigned int val);
363 373
374extern void load_fp_state(struct thread_fp_state *fp);
375extern void store_fp_state(struct thread_fp_state *fp);
376extern void load_vr_state(struct thread_vr_state *vr);
377extern void store_vr_state(struct thread_vr_state *vr);
378
364static inline unsigned int __unpack_fe01(unsigned long msr_bits) 379static inline unsigned int __unpack_fe01(unsigned long msr_bits)
365{ 380{
366 return ((msr_bits & MSR_FE0) >> 10) | ((msr_bits & MSR_FE1) >> 8); 381 return ((msr_bits & MSR_FE0) >> 10) | ((msr_bits & MSR_FE1) >> 8);
diff --git a/arch/powerpc/include/asm/prom.h b/arch/powerpc/include/asm/prom.h
index 7d0c7f3a7171..bf09e5a065b8 100644
--- a/arch/powerpc/include/asm/prom.h
+++ b/arch/powerpc/include/asm/prom.h
@@ -44,9 +44,6 @@ void of_parse_dma_window(struct device_node *dn, const __be32 *dma_window,
44 44
45extern void kdump_move_device_tree(void); 45extern void kdump_move_device_tree(void);
46 46
47/* cache lookup */
48struct device_node *of_find_next_cache_node(struct device_node *np);
49
50#ifdef CONFIG_NUMA 47#ifdef CONFIG_NUMA
51extern int of_node_to_nid(struct device_node *device); 48extern int of_node_to_nid(struct device_node *device);
52#else 49#else
diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
index 10d1ef016bf1..126f6e98f84d 100644
--- a/arch/powerpc/include/asm/reg.h
+++ b/arch/powerpc/include/asm/reg.h
@@ -115,7 +115,12 @@
115#define MSR_64BIT MSR_SF 115#define MSR_64BIT MSR_SF
116 116
117/* Server variant */ 117/* Server variant */
118#define MSR_ (MSR_ME | MSR_RI | MSR_IR | MSR_DR | MSR_ISF |MSR_HV) 118#define __MSR (MSR_ME | MSR_RI | MSR_IR | MSR_DR | MSR_ISF |MSR_HV)
119#ifdef __BIG_ENDIAN__
120#define MSR_ __MSR
121#else
122#define MSR_ (__MSR | MSR_LE)
123#endif
119#define MSR_KERNEL (MSR_ | MSR_64BIT) 124#define MSR_KERNEL (MSR_ | MSR_64BIT)
120#define MSR_USER32 (MSR_ | MSR_PR | MSR_EE) 125#define MSR_USER32 (MSR_ | MSR_PR | MSR_EE)
121#define MSR_USER64 (MSR_USER32 | MSR_64BIT) 126#define MSR_USER64 (MSR_USER32 | MSR_64BIT)
diff --git a/arch/powerpc/include/asm/reg_booke.h b/arch/powerpc/include/asm/reg_booke.h
index ed8f836da094..2e31aacd8acc 100644
--- a/arch/powerpc/include/asm/reg_booke.h
+++ b/arch/powerpc/include/asm/reg_booke.h
@@ -381,7 +381,7 @@
381#define DBCR0_IA34T 0x00004000 /* Instr Addr 3-4 range Toggle */ 381#define DBCR0_IA34T 0x00004000 /* Instr Addr 3-4 range Toggle */
382#define DBCR0_FT 0x00000001 /* Freeze Timers on debug event */ 382#define DBCR0_FT 0x00000001 /* Freeze Timers on debug event */
383 383
384#define dbcr_iac_range(task) ((task)->thread.dbcr0) 384#define dbcr_iac_range(task) ((task)->thread.debug.dbcr0)
385#define DBCR_IAC12I DBCR0_IA12 /* Range Inclusive */ 385#define DBCR_IAC12I DBCR0_IA12 /* Range Inclusive */
386#define DBCR_IAC12X (DBCR0_IA12 | DBCR0_IA12X) /* Range Exclusive */ 386#define DBCR_IAC12X (DBCR0_IA12 | DBCR0_IA12X) /* Range Exclusive */
387#define DBCR_IAC12MODE (DBCR0_IA12 | DBCR0_IA12X) /* IAC 1-2 Mode Bits */ 387#define DBCR_IAC12MODE (DBCR0_IA12 | DBCR0_IA12X) /* IAC 1-2 Mode Bits */
@@ -395,7 +395,7 @@
395#define DBCR1_DAC1W 0x20000000 /* DAC1 Write Debug Event */ 395#define DBCR1_DAC1W 0x20000000 /* DAC1 Write Debug Event */
396#define DBCR1_DAC2W 0x10000000 /* DAC2 Write Debug Event */ 396#define DBCR1_DAC2W 0x10000000 /* DAC2 Write Debug Event */
397 397
398#define dbcr_dac(task) ((task)->thread.dbcr1) 398#define dbcr_dac(task) ((task)->thread.debug.dbcr1)
399#define DBCR_DAC1R DBCR1_DAC1R 399#define DBCR_DAC1R DBCR1_DAC1R
400#define DBCR_DAC1W DBCR1_DAC1W 400#define DBCR_DAC1W DBCR1_DAC1W
401#define DBCR_DAC2R DBCR1_DAC2R 401#define DBCR_DAC2R DBCR1_DAC2R
@@ -441,7 +441,7 @@
441#define DBCR0_CRET 0x00000020 /* Critical Return Debug Event */ 441#define DBCR0_CRET 0x00000020 /* Critical Return Debug Event */
442#define DBCR0_FT 0x00000001 /* Freeze Timers on debug event */ 442#define DBCR0_FT 0x00000001 /* Freeze Timers on debug event */
443 443
444#define dbcr_dac(task) ((task)->thread.dbcr0) 444#define dbcr_dac(task) ((task)->thread.debug.dbcr0)
445#define DBCR_DAC1R DBCR0_DAC1R 445#define DBCR_DAC1R DBCR0_DAC1R
446#define DBCR_DAC1W DBCR0_DAC1W 446#define DBCR_DAC1W DBCR0_DAC1W
447#define DBCR_DAC2R DBCR0_DAC2R 447#define DBCR_DAC2R DBCR0_DAC2R
@@ -475,7 +475,7 @@
475#define DBCR1_IAC34MX 0x000000C0 /* Instr Addr 3-4 range eXclusive */ 475#define DBCR1_IAC34MX 0x000000C0 /* Instr Addr 3-4 range eXclusive */
476#define DBCR1_IAC34AT 0x00000001 /* Instr Addr 3-4 range Toggle */ 476#define DBCR1_IAC34AT 0x00000001 /* Instr Addr 3-4 range Toggle */
477 477
478#define dbcr_iac_range(task) ((task)->thread.dbcr1) 478#define dbcr_iac_range(task) ((task)->thread.debug.dbcr1)
479#define DBCR_IAC12I DBCR1_IAC12M /* Range Inclusive */ 479#define DBCR_IAC12I DBCR1_IAC12M /* Range Inclusive */
480#define DBCR_IAC12X DBCR1_IAC12MX /* Range Exclusive */ 480#define DBCR_IAC12X DBCR1_IAC12MX /* Range Exclusive */
481#define DBCR_IAC12MODE DBCR1_IAC12MX /* IAC 1-2 Mode Bits */ 481#define DBCR_IAC12MODE DBCR1_IAC12MX /* IAC 1-2 Mode Bits */
diff --git a/arch/powerpc/include/asm/scom.h b/arch/powerpc/include/asm/scom.h
index 0cabfd7bc2d1..f5cde45b1161 100644
--- a/arch/powerpc/include/asm/scom.h
+++ b/arch/powerpc/include/asm/scom.h
@@ -54,8 +54,8 @@ struct scom_controller {
54 scom_map_t (*map)(struct device_node *ctrl_dev, u64 reg, u64 count); 54 scom_map_t (*map)(struct device_node *ctrl_dev, u64 reg, u64 count);
55 void (*unmap)(scom_map_t map); 55 void (*unmap)(scom_map_t map);
56 56
57 u64 (*read)(scom_map_t map, u32 reg); 57 int (*read)(scom_map_t map, u64 reg, u64 *value);
58 void (*write)(scom_map_t map, u32 reg, u64 value); 58 int (*write)(scom_map_t map, u64 reg, u64 value);
59}; 59};
60 60
61extern const struct scom_controller *scom_controller; 61extern const struct scom_controller *scom_controller;
@@ -133,10 +133,18 @@ static inline void scom_unmap(scom_map_t map)
133 * scom_read - Read a SCOM register 133 * scom_read - Read a SCOM register
134 * @map: Result of scom_map 134 * @map: Result of scom_map
135 * @reg: Register index within that map 135 * @reg: Register index within that map
136 * @value: Updated with the value read
137 *
138 * Returns 0 (success) or a negative error code
136 */ 139 */
137static inline u64 scom_read(scom_map_t map, u32 reg) 140static inline int scom_read(scom_map_t map, u64 reg, u64 *value)
138{ 141{
139 return scom_controller->read(map, reg); 142 int rc;
143
144 rc = scom_controller->read(map, reg, value);
145 if (rc)
146 *value = 0xfffffffffffffffful;
147 return rc;
140} 148}
141 149
142/** 150/**
@@ -144,12 +152,15 @@ static inline u64 scom_read(scom_map_t map, u32 reg)
144 * @map: Result of scom_map 152 * @map: Result of scom_map
145 * @reg: Register index within that map 153 * @reg: Register index within that map
146 * @value: Value to write 154 * @value: Value to write
155 *
156 * Returns 0 (success) or a negative error code
147 */ 157 */
148static inline void scom_write(scom_map_t map, u32 reg, u64 value) 158static inline int scom_write(scom_map_t map, u64 reg, u64 value)
149{ 159{
150 scom_controller->write(map, reg, value); 160 return scom_controller->write(map, reg, value);
151} 161}
152 162
163
153#endif /* CONFIG_PPC_SCOM */ 164#endif /* CONFIG_PPC_SCOM */
154#endif /* __ASSEMBLY__ */ 165#endif /* __ASSEMBLY__ */
155#endif /* __KERNEL__ */ 166#endif /* __KERNEL__ */
diff --git a/arch/powerpc/include/asm/setup.h b/arch/powerpc/include/asm/setup.h
index d3ca85529b8b..703a8412dac2 100644
--- a/arch/powerpc/include/asm/setup.h
+++ b/arch/powerpc/include/asm/setup.h
@@ -23,6 +23,10 @@ extern void reloc_got2(unsigned long);
23 23
24#define PTRRELOC(x) ((typeof(x)) add_reloc_offset((unsigned long)(x))) 24#define PTRRELOC(x) ((typeof(x)) add_reloc_offset((unsigned long)(x)))
25 25
26void check_for_initrd(void);
27void do_init_bootmem(void);
28void setup_panic(void);
29
26#endif /* !__ASSEMBLY__ */ 30#endif /* !__ASSEMBLY__ */
27 31
28#endif /* _ASM_POWERPC_SETUP_H */ 32#endif /* _ASM_POWERPC_SETUP_H */
diff --git a/arch/powerpc/include/asm/sfp-machine.h b/arch/powerpc/include/asm/sfp-machine.h
index 3a7a67a0d006..d89beaba26ff 100644
--- a/arch/powerpc/include/asm/sfp-machine.h
+++ b/arch/powerpc/include/asm/sfp-machine.h
@@ -125,7 +125,7 @@
125#define FP_EX_DIVZERO (1 << (31 - 5)) 125#define FP_EX_DIVZERO (1 << (31 - 5))
126#define FP_EX_INEXACT (1 << (31 - 6)) 126#define FP_EX_INEXACT (1 << (31 - 6))
127 127
128#define __FPU_FPSCR (current->thread.fpscr.val) 128#define __FPU_FPSCR (current->thread.fp_state.fpscr)
129 129
130/* We only actually write to the destination register 130/* We only actually write to the destination register
131 * if exceptions signalled (if any) will not trap. 131 * if exceptions signalled (if any) will not trap.
diff --git a/arch/powerpc/include/asm/string.h b/arch/powerpc/include/asm/string.h
index e40010abcaf1..0dffad6bcc84 100644
--- a/arch/powerpc/include/asm/string.h
+++ b/arch/powerpc/include/asm/string.h
@@ -10,7 +10,9 @@
10#define __HAVE_ARCH_STRNCMP 10#define __HAVE_ARCH_STRNCMP
11#define __HAVE_ARCH_STRCAT 11#define __HAVE_ARCH_STRCAT
12#define __HAVE_ARCH_MEMSET 12#define __HAVE_ARCH_MEMSET
13#ifdef __BIG_ENDIAN__
13#define __HAVE_ARCH_MEMCPY 14#define __HAVE_ARCH_MEMCPY
15#endif
14#define __HAVE_ARCH_MEMMOVE 16#define __HAVE_ARCH_MEMMOVE
15#define __HAVE_ARCH_MEMCMP 17#define __HAVE_ARCH_MEMCMP
16#define __HAVE_ARCH_MEMCHR 18#define __HAVE_ARCH_MEMCHR
@@ -22,7 +24,9 @@ extern int strcmp(const char *,const char *);
22extern int strncmp(const char *, const char *, __kernel_size_t); 24extern int strncmp(const char *, const char *, __kernel_size_t);
23extern char * strcat(char *, const char *); 25extern char * strcat(char *, const char *);
24extern void * memset(void *,int,__kernel_size_t); 26extern void * memset(void *,int,__kernel_size_t);
27#ifdef __BIG_ENDIAN__
25extern void * memcpy(void *,const void *,__kernel_size_t); 28extern void * memcpy(void *,const void *,__kernel_size_t);
29#endif
26extern void * memmove(void *,const void *,__kernel_size_t); 30extern void * memmove(void *,const void *,__kernel_size_t);
27extern int memcmp(const void *,const void *,__kernel_size_t); 31extern int memcmp(const void *,const void *,__kernel_size_t);
28extern void * memchr(const void *,int,__kernel_size_t); 32extern void * memchr(const void *,int,__kernel_size_t);
diff --git a/arch/powerpc/include/asm/switch_to.h b/arch/powerpc/include/asm/switch_to.h
index 2be5618cdec6..9ee12610af02 100644
--- a/arch/powerpc/include/asm/switch_to.h
+++ b/arch/powerpc/include/asm/switch_to.h
@@ -35,6 +35,7 @@ extern void giveup_vsx(struct task_struct *);
35extern void enable_kernel_spe(void); 35extern void enable_kernel_spe(void);
36extern void giveup_spe(struct task_struct *); 36extern void giveup_spe(struct task_struct *);
37extern void load_up_spe(struct task_struct *); 37extern void load_up_spe(struct task_struct *);
38extern void switch_booke_debug_regs(struct thread_struct *new_thread);
38 39
39#ifndef CONFIG_SMP 40#ifndef CONFIG_SMP
40extern void discard_lazy_cpu_state(void); 41extern void discard_lazy_cpu_state(void);
diff --git a/arch/powerpc/include/asm/word-at-a-time.h b/arch/powerpc/include/asm/word-at-a-time.h
index d0b6d4ac6dda..9a5c928bb3c6 100644
--- a/arch/powerpc/include/asm/word-at-a-time.h
+++ b/arch/powerpc/include/asm/word-at-a-time.h
@@ -8,6 +8,8 @@
8#include <linux/kernel.h> 8#include <linux/kernel.h>
9#include <asm/asm-compat.h> 9#include <asm/asm-compat.h>
10 10
11#ifdef __BIG_ENDIAN__
12
11struct word_at_a_time { 13struct word_at_a_time {
12 const unsigned long high_bits, low_bits; 14 const unsigned long high_bits, low_bits;
13}; 15};
@@ -38,4 +40,80 @@ static inline bool has_zero(unsigned long val, unsigned long *data, const struct
38 return (val + c->high_bits) & ~rhs; 40 return (val + c->high_bits) & ~rhs;
39} 41}
40 42
43#else
44
45struct word_at_a_time {
46 const unsigned long one_bits, high_bits;
47};
48
49#define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
50
51#ifdef CONFIG_64BIT
52
53/* Alan Modra's little-endian strlen tail for 64-bit */
54#define create_zero_mask(mask) (mask)
55
56static inline unsigned long find_zero(unsigned long mask)
57{
58 unsigned long leading_zero_bits;
59 long trailing_zero_bit_mask;
60
61 asm ("addi %1,%2,-1\n\t"
62 "andc %1,%1,%2\n\t"
63 "popcntd %0,%1"
64 : "=r" (leading_zero_bits), "=&r" (trailing_zero_bit_mask)
65 : "r" (mask));
66 return leading_zero_bits >> 3;
67}
68
69#else /* 32-bit case */
70
71/*
72 * This is largely generic for little-endian machines, but the
73 * optimal byte mask counting is probably going to be something
74 * that is architecture-specific. If you have a reliably fast
75 * bit count instruction, that might be better than the multiply
76 * and shift, for example.
77 */
78
79/* Carl Chatfield / Jan Achrenius G+ version for 32-bit */
80static inline long count_masked_bytes(long mask)
81{
82 /* (000000 0000ff 00ffff ffffff) -> ( 1 1 2 3 ) */
83 long a = (0x0ff0001+mask) >> 23;
84 /* Fix the 1 for 00 case */
85 return a & mask;
86}
87
88static inline unsigned long create_zero_mask(unsigned long bits)
89{
90 bits = (bits - 1) & ~bits;
91 return bits >> 7;
92}
93
94static inline unsigned long find_zero(unsigned long mask)
95{
96 return count_masked_bytes(mask);
97}
98
99#endif
100
101/* Return nonzero if it has a zero */
102static inline unsigned long has_zero(unsigned long a, unsigned long *bits, const struct word_at_a_time *c)
103{
104 unsigned long mask = ((a - c->one_bits) & ~a) & c->high_bits;
105 *bits = mask;
106 return mask;
107}
108
109static inline unsigned long prep_zero_mask(unsigned long a, unsigned long bits, const struct word_at_a_time *c)
110{
111 return bits;
112}
113
114/* The mask we created is directly usable as a bytemask */
115#define zero_bytemask(mask) (mask)
116
117#endif
118
41#endif /* _ASM_WORD_AT_A_TIME_H */ 119#endif /* _ASM_WORD_AT_A_TIME_H */
diff --git a/arch/powerpc/include/asm/xor.h b/arch/powerpc/include/asm/xor.h
index c82eb12a5b18..0abb97f3be10 100644
--- a/arch/powerpc/include/asm/xor.h
+++ b/arch/powerpc/include/asm/xor.h
@@ -1 +1,68 @@
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15 *
16 * Copyright (C) IBM Corporation, 2012
17 *
18 * Author: Anton Blanchard <anton@au.ibm.com>
19 */
20#ifndef _ASM_POWERPC_XOR_H
21#define _ASM_POWERPC_XOR_H
22
23#ifdef CONFIG_ALTIVEC
24
25#include <asm/cputable.h>
26
27void xor_altivec_2(unsigned long bytes, unsigned long *v1_in,
28 unsigned long *v2_in);
29void xor_altivec_3(unsigned long bytes, unsigned long *v1_in,
30 unsigned long *v2_in, unsigned long *v3_in);
31void xor_altivec_4(unsigned long bytes, unsigned long *v1_in,
32 unsigned long *v2_in, unsigned long *v3_in,
33 unsigned long *v4_in);
34void xor_altivec_5(unsigned long bytes, unsigned long *v1_in,
35 unsigned long *v2_in, unsigned long *v3_in,
36 unsigned long *v4_in, unsigned long *v5_in);
37
38static struct xor_block_template xor_block_altivec = {
39 .name = "altivec",
40 .do_2 = xor_altivec_2,
41 .do_3 = xor_altivec_3,
42 .do_4 = xor_altivec_4,
43 .do_5 = xor_altivec_5,
44};
45
46#define XOR_SPEED_ALTIVEC() \
47 do { \
48 if (cpu_has_feature(CPU_FTR_ALTIVEC)) \
49 xor_speed(&xor_block_altivec); \
50 } while (0)
51#else
52#define XOR_SPEED_ALTIVEC()
53#endif
54
55/* Also try the generic routines. */
1#include <asm-generic/xor.h> 56#include <asm-generic/xor.h>
57
58#undef XOR_TRY_TEMPLATES
59#define XOR_TRY_TEMPLATES \
60do { \
61 xor_speed(&xor_block_8regs); \
62 xor_speed(&xor_block_8regs_p); \
63 xor_speed(&xor_block_32regs); \
64 xor_speed(&xor_block_32regs_p); \
65 XOR_SPEED_ALTIVEC(); \
66} while (0)
67
68#endif /* _ASM_POWERPC_XOR_H */
diff --git a/arch/powerpc/include/uapi/asm/byteorder.h b/arch/powerpc/include/uapi/asm/byteorder.h
index aa6cc4fac965..ca931d074000 100644
--- a/arch/powerpc/include/uapi/asm/byteorder.h
+++ b/arch/powerpc/include/uapi/asm/byteorder.h
@@ -7,6 +7,10 @@
7 * as published by the Free Software Foundation; either version 7 * as published by the Free Software Foundation; either version
8 * 2 of the License, or (at your option) any later version. 8 * 2 of the License, or (at your option) any later version.
9 */ 9 */
10#ifdef __LITTLE_ENDIAN__
11#include <linux/byteorder/little_endian.h>
12#else
10#include <linux/byteorder/big_endian.h> 13#include <linux/byteorder/big_endian.h>
14#endif
11 15
12#endif /* _ASM_POWERPC_BYTEORDER_H */ 16#endif /* _ASM_POWERPC_BYTEORDER_H */
diff --git a/arch/powerpc/kernel/align.c b/arch/powerpc/kernel/align.c
index a27ccd5dc6b9..de91f3ae631e 100644
--- a/arch/powerpc/kernel/align.c
+++ b/arch/powerpc/kernel/align.c
@@ -54,8 +54,6 @@ struct aligninfo {
54/* DSISR bits reported for a DCBZ instruction: */ 54/* DSISR bits reported for a DCBZ instruction: */
55#define DCBZ 0x5f /* 8xx/82xx dcbz faults when cache not enabled */ 55#define DCBZ 0x5f /* 8xx/82xx dcbz faults when cache not enabled */
56 56
57#define SWAP(a, b) (t = (a), (a) = (b), (b) = t)
58
59/* 57/*
60 * The PowerPC stores certain bits of the instruction that caused the 58 * The PowerPC stores certain bits of the instruction that caused the
61 * alignment exception in the DSISR register. This array maps those 59 * alignment exception in the DSISR register. This array maps those
@@ -256,11 +254,17 @@ static int emulate_dcbz(struct pt_regs *regs, unsigned char __user *addr)
256 * bottom 4 bytes of each register, and the loads clear the 254 * bottom 4 bytes of each register, and the loads clear the
257 * top 4 bytes of the affected register. 255 * top 4 bytes of the affected register.
258 */ 256 */
257#ifdef __BIG_ENDIAN__
259#ifdef CONFIG_PPC64 258#ifdef CONFIG_PPC64
260#define REG_BYTE(rp, i) *((u8 *)((rp) + ((i) >> 2)) + ((i) & 3) + 4) 259#define REG_BYTE(rp, i) *((u8 *)((rp) + ((i) >> 2)) + ((i) & 3) + 4)
261#else 260#else
262#define REG_BYTE(rp, i) *((u8 *)(rp) + (i)) 261#define REG_BYTE(rp, i) *((u8 *)(rp) + (i))
263#endif 262#endif
263#endif
264
265#ifdef __LITTLE_ENDIAN__
266#define REG_BYTE(rp, i) (*(((u8 *)((rp) + ((i)>>2)) + ((i)&3))))
267#endif
264 268
265#define SWIZ_PTR(p) ((unsigned char __user *)((p) ^ swiz)) 269#define SWIZ_PTR(p) ((unsigned char __user *)((p) ^ swiz))
266 270
@@ -305,6 +309,15 @@ static int emulate_multiple(struct pt_regs *regs, unsigned char __user *addr,
305 nb0 = nb + reg * 4 - 128; 309 nb0 = nb + reg * 4 - 128;
306 nb = 128 - reg * 4; 310 nb = 128 - reg * 4;
307 } 311 }
312#ifdef __LITTLE_ENDIAN__
313 /*
314 * String instructions are endian neutral but the code
315 * below is not. Force byte swapping on so that the
316 * effects of swizzling are undone in the load/store
317 * loops below.
318 */
319 flags ^= SW;
320#endif
308 } else { 321 } else {
309 /* lwm, stmw */ 322 /* lwm, stmw */
310 nb = (32 - reg) * 4; 323 nb = (32 - reg) * 4;
@@ -458,7 +471,7 @@ static struct aligninfo spe_aligninfo[32] = {
458static int emulate_spe(struct pt_regs *regs, unsigned int reg, 471static int emulate_spe(struct pt_regs *regs, unsigned int reg,
459 unsigned int instr) 472 unsigned int instr)
460{ 473{
461 int t, ret; 474 int ret;
462 union { 475 union {
463 u64 ll; 476 u64 ll;
464 u32 w[2]; 477 u32 w[2];
@@ -581,24 +594,18 @@ static int emulate_spe(struct pt_regs *regs, unsigned int reg,
581 if (flags & SW) { 594 if (flags & SW) {
582 switch (flags & 0xf0) { 595 switch (flags & 0xf0) {
583 case E8: 596 case E8:
584 SWAP(data.v[0], data.v[7]); 597 data.ll = swab64(data.ll);
585 SWAP(data.v[1], data.v[6]);
586 SWAP(data.v[2], data.v[5]);
587 SWAP(data.v[3], data.v[4]);
588 break; 598 break;
589 case E4: 599 case E4:
590 600 data.w[0] = swab32(data.w[0]);
591 SWAP(data.v[0], data.v[3]); 601 data.w[1] = swab32(data.w[1]);
592 SWAP(data.v[1], data.v[2]);
593 SWAP(data.v[4], data.v[7]);
594 SWAP(data.v[5], data.v[6]);
595 break; 602 break;
596 /* Its half word endian */ 603 /* Its half word endian */
597 default: 604 default:
598 SWAP(data.v[0], data.v[1]); 605 data.h[0] = swab16(data.h[0]);
599 SWAP(data.v[2], data.v[3]); 606 data.h[1] = swab16(data.h[1]);
600 SWAP(data.v[4], data.v[5]); 607 data.h[2] = swab16(data.h[2]);
601 SWAP(data.v[6], data.v[7]); 608 data.h[3] = swab16(data.h[3]);
602 break; 609 break;
603 } 610 }
604 } 611 }
@@ -658,14 +665,31 @@ static int emulate_vsx(unsigned char __user *addr, unsigned int reg,
658 flush_vsx_to_thread(current); 665 flush_vsx_to_thread(current);
659 666
660 if (reg < 32) 667 if (reg < 32)
661 ptr = (char *) &current->thread.TS_FPR(reg); 668 ptr = (char *) &current->thread.fp_state.fpr[reg][0];
662 else 669 else
663 ptr = (char *) &current->thread.vr[reg - 32]; 670 ptr = (char *) &current->thread.vr_state.vr[reg - 32];
664 671
665 lptr = (unsigned long *) ptr; 672 lptr = (unsigned long *) ptr;
666 673
674#ifdef __LITTLE_ENDIAN__
675 if (flags & SW) {
676 elsize = length;
677 sw = length-1;
678 } else {
679 /*
680 * The elements are BE ordered, even in LE mode, so process
681 * them in reverse order.
682 */
683 addr += length - elsize;
684
685 /* 8 byte memory accesses go in the top 8 bytes of the VR */
686 if (length == 8)
687 ptr += 8;
688 }
689#else
667 if (flags & SW) 690 if (flags & SW)
668 sw = elsize-1; 691 sw = elsize-1;
692#endif
669 693
670 for (j = 0; j < length; j += elsize) { 694 for (j = 0; j < length; j += elsize) {
671 for (i = 0; i < elsize; ++i) { 695 for (i = 0; i < elsize; ++i) {
@@ -675,19 +699,31 @@ static int emulate_vsx(unsigned char __user *addr, unsigned int reg,
675 ret |= __get_user(ptr[i^sw], addr + i); 699 ret |= __get_user(ptr[i^sw], addr + i);
676 } 700 }
677 ptr += elsize; 701 ptr += elsize;
702#ifdef __LITTLE_ENDIAN__
703 addr -= elsize;
704#else
678 addr += elsize; 705 addr += elsize;
706#endif
679 } 707 }
680 708
709#ifdef __BIG_ENDIAN__
710#define VSX_HI 0
711#define VSX_LO 1
712#else
713#define VSX_HI 1
714#define VSX_LO 0
715#endif
716
681 if (!ret) { 717 if (!ret) {
682 if (flags & U) 718 if (flags & U)
683 regs->gpr[areg] = regs->dar; 719 regs->gpr[areg] = regs->dar;
684 720
685 /* Splat load copies the same data to top and bottom 8 bytes */ 721 /* Splat load copies the same data to top and bottom 8 bytes */
686 if (flags & SPLT) 722 if (flags & SPLT)
687 lptr[1] = lptr[0]; 723 lptr[VSX_LO] = lptr[VSX_HI];
688 /* For 8 byte loads, zero the top 8 bytes */ 724 /* For 8 byte loads, zero the low 8 bytes */
689 else if (!(flags & ST) && (8 == length)) 725 else if (!(flags & ST) && (8 == length))
690 lptr[1] = 0; 726 lptr[VSX_LO] = 0;
691 } else 727 } else
692 return -EFAULT; 728 return -EFAULT;
693 729
@@ -710,18 +746,28 @@ int fix_alignment(struct pt_regs *regs)
710 unsigned int dsisr; 746 unsigned int dsisr;
711 unsigned char __user *addr; 747 unsigned char __user *addr;
712 unsigned long p, swiz; 748 unsigned long p, swiz;
713 int ret, t; 749 int ret, i;
714 union { 750 union data {
715 u64 ll; 751 u64 ll;
716 double dd; 752 double dd;
717 unsigned char v[8]; 753 unsigned char v[8];
718 struct { 754 struct {
755#ifdef __LITTLE_ENDIAN__
756 int low32;
757 unsigned hi32;
758#else
719 unsigned hi32; 759 unsigned hi32;
720 int low32; 760 int low32;
761#endif
721 } x32; 762 } x32;
722 struct { 763 struct {
764#ifdef __LITTLE_ENDIAN__
765 short low16;
766 unsigned char hi48[6];
767#else
723 unsigned char hi48[6]; 768 unsigned char hi48[6];
724 short low16; 769 short low16;
770#endif
725 } x16; 771 } x16;
726 } data; 772 } data;
727 773
@@ -780,8 +826,9 @@ int fix_alignment(struct pt_regs *regs)
780 826
781 /* Byteswap little endian loads and stores */ 827 /* Byteswap little endian loads and stores */
782 swiz = 0; 828 swiz = 0;
783 if (regs->msr & MSR_LE) { 829 if ((regs->msr & MSR_LE) != (MSR_KERNEL & MSR_LE)) {
784 flags ^= SW; 830 flags ^= SW;
831#ifdef __BIG_ENDIAN__
785 /* 832 /*
786 * So-called "PowerPC little endian" mode works by 833 * So-called "PowerPC little endian" mode works by
787 * swizzling addresses rather than by actually doing 834 * swizzling addresses rather than by actually doing
@@ -794,6 +841,7 @@ int fix_alignment(struct pt_regs *regs)
794 */ 841 */
795 if (cpu_has_feature(CPU_FTR_PPC_LE)) 842 if (cpu_has_feature(CPU_FTR_PPC_LE))
796 swiz = 7; 843 swiz = 7;
844#endif
797 } 845 }
798 846
799 /* DAR has the operand effective address */ 847 /* DAR has the operand effective address */
@@ -818,7 +866,7 @@ int fix_alignment(struct pt_regs *regs)
818 elsize = 8; 866 elsize = 8;
819 867
820 flags = 0; 868 flags = 0;
821 if (regs->msr & MSR_LE) 869 if ((regs->msr & MSR_LE) != (MSR_KERNEL & MSR_LE))
822 flags |= SW; 870 flags |= SW;
823 if (instruction & 0x100) 871 if (instruction & 0x100)
824 flags |= ST; 872 flags |= ST;
@@ -878,32 +926,36 @@ int fix_alignment(struct pt_regs *regs)
878 * get it from register values 926 * get it from register values
879 */ 927 */
880 if (!(flags & ST)) { 928 if (!(flags & ST)) {
881 data.ll = 0; 929 unsigned int start = 0;
882 ret = 0; 930
883 p = (unsigned long) addr;
884 switch (nb) { 931 switch (nb) {
885 case 8:
886 ret |= __get_user_inatomic(data.v[0], SWIZ_PTR(p++));
887 ret |= __get_user_inatomic(data.v[1], SWIZ_PTR(p++));
888 ret |= __get_user_inatomic(data.v[2], SWIZ_PTR(p++));
889 ret |= __get_user_inatomic(data.v[3], SWIZ_PTR(p++));
890 case 4: 932 case 4:
891 ret |= __get_user_inatomic(data.v[4], SWIZ_PTR(p++)); 933 start = offsetof(union data, x32.low32);
892 ret |= __get_user_inatomic(data.v[5], SWIZ_PTR(p++)); 934 break;
893 case 2: 935 case 2:
894 ret |= __get_user_inatomic(data.v[6], SWIZ_PTR(p++)); 936 start = offsetof(union data, x16.low16);
895 ret |= __get_user_inatomic(data.v[7], SWIZ_PTR(p++)); 937 break;
896 if (unlikely(ret))
897 return -EFAULT;
898 } 938 }
939
940 data.ll = 0;
941 ret = 0;
942 p = (unsigned long)addr;
943
944 for (i = 0; i < nb; i++)
945 ret |= __get_user_inatomic(data.v[start + i],
946 SWIZ_PTR(p++));
947
948 if (unlikely(ret))
949 return -EFAULT;
950
899 } else if (flags & F) { 951 } else if (flags & F) {
900 data.dd = current->thread.TS_FPR(reg); 952 data.ll = current->thread.TS_FPR(reg);
901 if (flags & S) { 953 if (flags & S) {
902 /* Single-precision FP store requires conversion... */ 954 /* Single-precision FP store requires conversion... */
903#ifdef CONFIG_PPC_FPU 955#ifdef CONFIG_PPC_FPU
904 preempt_disable(); 956 preempt_disable();
905 enable_kernel_fp(); 957 enable_kernel_fp();
906 cvt_df(&data.dd, (float *)&data.v[4]); 958 cvt_df(&data.dd, (float *)&data.x32.low32);
907 preempt_enable(); 959 preempt_enable();
908#else 960#else
909 return 0; 961 return 0;
@@ -915,17 +967,13 @@ int fix_alignment(struct pt_regs *regs)
915 if (flags & SW) { 967 if (flags & SW) {
916 switch (nb) { 968 switch (nb) {
917 case 8: 969 case 8:
918 SWAP(data.v[0], data.v[7]); 970 data.ll = swab64(data.ll);
919 SWAP(data.v[1], data.v[6]);
920 SWAP(data.v[2], data.v[5]);
921 SWAP(data.v[3], data.v[4]);
922 break; 971 break;
923 case 4: 972 case 4:
924 SWAP(data.v[4], data.v[7]); 973 data.x32.low32 = swab32(data.x32.low32);
925 SWAP(data.v[5], data.v[6]);
926 break; 974 break;
927 case 2: 975 case 2:
928 SWAP(data.v[6], data.v[7]); 976 data.x16.low16 = swab16(data.x16.low16);
929 break; 977 break;
930 } 978 }
931 } 979 }
@@ -947,7 +995,7 @@ int fix_alignment(struct pt_regs *regs)
947#ifdef CONFIG_PPC_FPU 995#ifdef CONFIG_PPC_FPU
948 preempt_disable(); 996 preempt_disable();
949 enable_kernel_fp(); 997 enable_kernel_fp();
950 cvt_fd((float *)&data.v[4], &data.dd); 998 cvt_fd((float *)&data.x32.low32, &data.dd);
951 preempt_enable(); 999 preempt_enable();
952#else 1000#else
953 return 0; 1001 return 0;
@@ -957,25 +1005,28 @@ int fix_alignment(struct pt_regs *regs)
957 1005
958 /* Store result to memory or update registers */ 1006 /* Store result to memory or update registers */
959 if (flags & ST) { 1007 if (flags & ST) {
960 ret = 0; 1008 unsigned int start = 0;
961 p = (unsigned long) addr; 1009
962 switch (nb) { 1010 switch (nb) {
963 case 8:
964 ret |= __put_user_inatomic(data.v[0], SWIZ_PTR(p++));
965 ret |= __put_user_inatomic(data.v[1], SWIZ_PTR(p++));
966 ret |= __put_user_inatomic(data.v[2], SWIZ_PTR(p++));
967 ret |= __put_user_inatomic(data.v[3], SWIZ_PTR(p++));
968 case 4: 1011 case 4:
969 ret |= __put_user_inatomic(data.v[4], SWIZ_PTR(p++)); 1012 start = offsetof(union data, x32.low32);
970 ret |= __put_user_inatomic(data.v[5], SWIZ_PTR(p++)); 1013 break;
971 case 2: 1014 case 2:
972 ret |= __put_user_inatomic(data.v[6], SWIZ_PTR(p++)); 1015 start = offsetof(union data, x16.low16);
973 ret |= __put_user_inatomic(data.v[7], SWIZ_PTR(p++)); 1016 break;
974 } 1017 }
1018
1019 ret = 0;
1020 p = (unsigned long)addr;
1021
1022 for (i = 0; i < nb; i++)
1023 ret |= __put_user_inatomic(data.v[start + i],
1024 SWIZ_PTR(p++));
1025
975 if (unlikely(ret)) 1026 if (unlikely(ret))
976 return -EFAULT; 1027 return -EFAULT;
977 } else if (flags & F) 1028 } else if (flags & F)
978 current->thread.TS_FPR(reg) = data.dd; 1029 current->thread.TS_FPR(reg) = data.ll;
979 else 1030 else
980 regs->gpr[reg] = data.ll; 1031 regs->gpr[reg] = data.ll;
981 1032
diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
index 502c7a4e73f7..e60a3697932c 100644
--- a/arch/powerpc/kernel/asm-offsets.c
+++ b/arch/powerpc/kernel/asm-offsets.c
@@ -90,16 +90,17 @@ int main(void)
90 DEFINE(THREAD_NORMSAVES, offsetof(struct thread_struct, normsave[0])); 90 DEFINE(THREAD_NORMSAVES, offsetof(struct thread_struct, normsave[0]));
91#endif 91#endif
92 DEFINE(THREAD_FPEXC_MODE, offsetof(struct thread_struct, fpexc_mode)); 92 DEFINE(THREAD_FPEXC_MODE, offsetof(struct thread_struct, fpexc_mode));
93 DEFINE(THREAD_FPR0, offsetof(struct thread_struct, fpr[0])); 93 DEFINE(THREAD_FPSTATE, offsetof(struct thread_struct, fp_state));
94 DEFINE(THREAD_FPSCR, offsetof(struct thread_struct, fpscr)); 94 DEFINE(THREAD_FPSAVEAREA, offsetof(struct thread_struct, fp_save_area));
95 DEFINE(FPSTATE_FPSCR, offsetof(struct thread_fp_state, fpscr));
95#ifdef CONFIG_ALTIVEC 96#ifdef CONFIG_ALTIVEC
96 DEFINE(THREAD_VR0, offsetof(struct thread_struct, vr[0])); 97 DEFINE(THREAD_VRSTATE, offsetof(struct thread_struct, vr_state));
98 DEFINE(THREAD_VRSAVEAREA, offsetof(struct thread_struct, vr_save_area));
97 DEFINE(THREAD_VRSAVE, offsetof(struct thread_struct, vrsave)); 99 DEFINE(THREAD_VRSAVE, offsetof(struct thread_struct, vrsave));
98 DEFINE(THREAD_VSCR, offsetof(struct thread_struct, vscr));
99 DEFINE(THREAD_USED_VR, offsetof(struct thread_struct, used_vr)); 100 DEFINE(THREAD_USED_VR, offsetof(struct thread_struct, used_vr));
101 DEFINE(VRSTATE_VSCR, offsetof(struct thread_vr_state, vscr));
100#endif /* CONFIG_ALTIVEC */ 102#endif /* CONFIG_ALTIVEC */
101#ifdef CONFIG_VSX 103#ifdef CONFIG_VSX
102 DEFINE(THREAD_VSR0, offsetof(struct thread_struct, fpr));
103 DEFINE(THREAD_USED_VSR, offsetof(struct thread_struct, used_vsr)); 104 DEFINE(THREAD_USED_VSR, offsetof(struct thread_struct, used_vsr));
104#endif /* CONFIG_VSX */ 105#endif /* CONFIG_VSX */
105#ifdef CONFIG_PPC64 106#ifdef CONFIG_PPC64
@@ -114,7 +115,7 @@ int main(void)
114#endif /* CONFIG_SPE */ 115#endif /* CONFIG_SPE */
115#endif /* CONFIG_PPC64 */ 116#endif /* CONFIG_PPC64 */
116#if defined(CONFIG_4xx) || defined(CONFIG_BOOKE) 117#if defined(CONFIG_4xx) || defined(CONFIG_BOOKE)
117 DEFINE(THREAD_DBCR0, offsetof(struct thread_struct, dbcr0)); 118 DEFINE(THREAD_DBCR0, offsetof(struct thread_struct, debug.dbcr0));
118#endif 119#endif
119#ifdef CONFIG_KVM_BOOK3S_32_HANDLER 120#ifdef CONFIG_KVM_BOOK3S_32_HANDLER
120 DEFINE(THREAD_KVM_SVCPU, offsetof(struct thread_struct, kvm_shadow_vcpu)); 121 DEFINE(THREAD_KVM_SVCPU, offsetof(struct thread_struct, kvm_shadow_vcpu));
@@ -143,20 +144,12 @@ int main(void)
143 DEFINE(THREAD_TM_PPR, offsetof(struct thread_struct, tm_ppr)); 144 DEFINE(THREAD_TM_PPR, offsetof(struct thread_struct, tm_ppr));
144 DEFINE(THREAD_TM_DSCR, offsetof(struct thread_struct, tm_dscr)); 145 DEFINE(THREAD_TM_DSCR, offsetof(struct thread_struct, tm_dscr));
145 DEFINE(PT_CKPT_REGS, offsetof(struct thread_struct, ckpt_regs)); 146 DEFINE(PT_CKPT_REGS, offsetof(struct thread_struct, ckpt_regs));
146 DEFINE(THREAD_TRANSACT_VR0, offsetof(struct thread_struct, 147 DEFINE(THREAD_TRANSACT_VRSTATE, offsetof(struct thread_struct,
147 transact_vr[0])); 148 transact_vr));
148 DEFINE(THREAD_TRANSACT_VSCR, offsetof(struct thread_struct,
149 transact_vscr));
150 DEFINE(THREAD_TRANSACT_VRSAVE, offsetof(struct thread_struct, 149 DEFINE(THREAD_TRANSACT_VRSAVE, offsetof(struct thread_struct,
151 transact_vrsave)); 150 transact_vrsave));
152 DEFINE(THREAD_TRANSACT_FPR0, offsetof(struct thread_struct, 151 DEFINE(THREAD_TRANSACT_FPSTATE, offsetof(struct thread_struct,
153 transact_fpr[0])); 152 transact_fp));
154 DEFINE(THREAD_TRANSACT_FPSCR, offsetof(struct thread_struct,
155 transact_fpscr));
156#ifdef CONFIG_VSX
157 DEFINE(THREAD_TRANSACT_VSR0, offsetof(struct thread_struct,
158 transact_fpr[0]));
159#endif
160 /* Local pt_regs on stack for Transactional Memory funcs. */ 153 /* Local pt_regs on stack for Transactional Memory funcs. */
161 DEFINE(TM_FRAME_SIZE, STACK_FRAME_OVERHEAD + 154 DEFINE(TM_FRAME_SIZE, STACK_FRAME_OVERHEAD +
162 sizeof(struct pt_regs) + 16); 155 sizeof(struct pt_regs) + 16);
diff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c
index 55593ee2d5aa..1fb331db34c8 100644
--- a/arch/powerpc/kernel/eeh.c
+++ b/arch/powerpc/kernel/eeh.c
@@ -327,11 +327,11 @@ static int eeh_phb_check_failure(struct eeh_pe *pe)
327 /* Isolate the PHB and send event */ 327 /* Isolate the PHB and send event */
328 eeh_pe_state_mark(phb_pe, EEH_PE_ISOLATED); 328 eeh_pe_state_mark(phb_pe, EEH_PE_ISOLATED);
329 eeh_serialize_unlock(flags); 329 eeh_serialize_unlock(flags);
330 eeh_send_failure_event(phb_pe);
331 330
332 pr_err("EEH: PHB#%x failure detected\n", 331 pr_err("EEH: PHB#%x failure detected\n",
333 phb_pe->phb->global_number); 332 phb_pe->phb->global_number);
334 dump_stack(); 333 dump_stack();
334 eeh_send_failure_event(phb_pe);
335 335
336 return 1; 336 return 1;
337out: 337out:
@@ -454,8 +454,6 @@ int eeh_dev_check_failure(struct eeh_dev *edev)
454 eeh_pe_state_mark(pe, EEH_PE_ISOLATED); 454 eeh_pe_state_mark(pe, EEH_PE_ISOLATED);
455 eeh_serialize_unlock(flags); 455 eeh_serialize_unlock(flags);
456 456
457 eeh_send_failure_event(pe);
458
459 /* Most EEH events are due to device driver bugs. Having 457 /* Most EEH events are due to device driver bugs. Having
460 * a stack trace will help the device-driver authors figure 458 * a stack trace will help the device-driver authors figure
461 * out what happened. So print that out. 459 * out what happened. So print that out.
@@ -464,6 +462,8 @@ int eeh_dev_check_failure(struct eeh_dev *edev)
464 pe->addr, pe->phb->global_number); 462 pe->addr, pe->phb->global_number);
465 dump_stack(); 463 dump_stack();
466 464
465 eeh_send_failure_event(pe);
466
467 return 1; 467 return 1;
468 468
469dn_unlock: 469dn_unlock:
diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
index c04cdf70d487..bbfb0294b354 100644
--- a/arch/powerpc/kernel/entry_64.S
+++ b/arch/powerpc/kernel/entry_64.S
@@ -673,9 +673,7 @@ _GLOBAL(ret_from_except_lite)
673 673
674resume_kernel: 674resume_kernel:
675 /* check current_thread_info, _TIF_EMULATE_STACK_STORE */ 675 /* check current_thread_info, _TIF_EMULATE_STACK_STORE */
676 CURRENT_THREAD_INFO(r9, r1) 676 andis. r8,r4,_TIF_EMULATE_STACK_STORE@h
677 ld r8,TI_FLAGS(r9)
678 andis. r8,r8,_TIF_EMULATE_STACK_STORE@h
679 beq+ 1f 677 beq+ 1f
680 678
681 addi r8,r1,INT_FRAME_SIZE /* Get the kprobed function entry */ 679 addi r8,r1,INT_FRAME_SIZE /* Get the kprobed function entry */
@@ -820,6 +818,12 @@ fast_exception_return:
820 andi. r0,r3,MSR_RI 818 andi. r0,r3,MSR_RI
821 beq- unrecov_restore 819 beq- unrecov_restore
822 820
821 /* Load PPR from thread struct before we clear MSR:RI */
822BEGIN_FTR_SECTION
823 ld r2,PACACURRENT(r13)
824 ld r2,TASKTHREADPPR(r2)
825END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR)
826
823 /* 827 /*
824 * Clear RI before restoring r13. If we are returning to 828 * Clear RI before restoring r13. If we are returning to
825 * userspace and we take an exception after restoring r13, 829 * userspace and we take an exception after restoring r13,
@@ -840,8 +844,10 @@ fast_exception_return:
840 */ 844 */
841 andi. r0,r3,MSR_PR 845 andi. r0,r3,MSR_PR
842 beq 1f 846 beq 1f
847BEGIN_FTR_SECTION
848 mtspr SPRN_PPR,r2 /* Restore PPR */
849END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR)
843 ACCOUNT_CPU_USER_EXIT(r2, r4) 850 ACCOUNT_CPU_USER_EXIT(r2, r4)
844 RESTORE_PPR(r2, r4)
845 REST_GPR(13, r1) 851 REST_GPR(13, r1)
8461: 8521:
847 mtspr SPRN_SRR1,r3 853 mtspr SPRN_SRR1,r3
@@ -1017,7 +1023,7 @@ _GLOBAL(enter_rtas)
1017 1023
1018 li r9,1 1024 li r9,1
1019 rldicr r9,r9,MSR_SF_LG,(63-MSR_SF_LG) 1025 rldicr r9,r9,MSR_SF_LG,(63-MSR_SF_LG)
1020 ori r9,r9,MSR_IR|MSR_DR|MSR_FE0|MSR_FE1|MSR_FP|MSR_RI 1026 ori r9,r9,MSR_IR|MSR_DR|MSR_FE0|MSR_FE1|MSR_FP|MSR_RI|MSR_LE
1021 andc r6,r0,r9 1027 andc r6,r0,r9
1022 sync /* disable interrupts so SRR0/1 */ 1028 sync /* disable interrupts so SRR0/1 */
1023 mtmsrd r0 /* don't get trashed */ 1029 mtmsrd r0 /* don't get trashed */
@@ -1032,6 +1038,8 @@ _GLOBAL(enter_rtas)
1032 b . /* prevent speculative execution */ 1038 b . /* prevent speculative execution */
1033 1039
1034_STATIC(rtas_return_loc) 1040_STATIC(rtas_return_loc)
1041 FIXUP_ENDIAN
1042
1035 /* relocation is off at this point */ 1043 /* relocation is off at this point */
1036 GET_PACA(r4) 1044 GET_PACA(r4)
1037 clrldi r4,r4,2 /* convert to realmode address */ 1045 clrldi r4,r4,2 /* convert to realmode address */
@@ -1103,28 +1111,30 @@ _GLOBAL(enter_prom)
1103 std r10,_CCR(r1) 1111 std r10,_CCR(r1)
1104 std r11,_MSR(r1) 1112 std r11,_MSR(r1)
1105 1113
1106 /* Get the PROM entrypoint */ 1114 /* Put PROM address in SRR0 */
1107 mtlr r4 1115 mtsrr0 r4
1108 1116
1109 /* Switch MSR to 32 bits mode 1117 /* Setup our trampoline return addr in LR */
1118 bcl 20,31,$+4
11190: mflr r4
1120 addi r4,r4,(1f - 0b)
1121 mtlr r4
1122
1123 /* Prepare a 32-bit mode big endian MSR
1110 */ 1124 */
1111#ifdef CONFIG_PPC_BOOK3E 1125#ifdef CONFIG_PPC_BOOK3E
1112 rlwinm r11,r11,0,1,31 1126 rlwinm r11,r11,0,1,31
1113 mtmsr r11 1127 mtsrr1 r11
1128 rfi
1114#else /* CONFIG_PPC_BOOK3E */ 1129#else /* CONFIG_PPC_BOOK3E */
1115 mfmsr r11 1130 LOAD_REG_IMMEDIATE(r12, MSR_SF | MSR_ISF | MSR_LE)
1116 li r12,1 1131 andc r11,r11,r12
1117 rldicr r12,r12,MSR_SF_LG,(63-MSR_SF_LG) 1132 mtsrr1 r11
1118 andc r11,r11,r12 1133 rfid
1119 li r12,1
1120 rldicr r12,r12,MSR_ISF_LG,(63-MSR_ISF_LG)
1121 andc r11,r11,r12
1122 mtmsrd r11
1123#endif /* CONFIG_PPC_BOOK3E */ 1134#endif /* CONFIG_PPC_BOOK3E */
1124 isync
1125 1135
1126 /* Enter PROM here... */ 11361: /* Return from OF */
1127 blrl 1137 FIXUP_ENDIAN
1128 1138
1129 /* Just make sure that r1 top 32 bits didn't get 1139 /* Just make sure that r1 top 32 bits didn't get
1130 * corrupt by OF 1140 * corrupt by OF
diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
index 2d067049db27..e7751561fd1d 100644
--- a/arch/powerpc/kernel/exceptions-64e.S
+++ b/arch/powerpc/kernel/exceptions-64e.S
@@ -399,7 +399,7 @@ interrupt_end_book3e:
399 399
400/* Altivec Unavailable Interrupt */ 400/* Altivec Unavailable Interrupt */
401 START_EXCEPTION(altivec_unavailable); 401 START_EXCEPTION(altivec_unavailable);
402 NORMAL_EXCEPTION_PROLOG(0x200, BOOKE_INTERRUPT_ALTIVEC_UNAVAIL, 402 NORMAL_EXCEPTION_PROLOG(0x200, BOOKE_INTERRUPT_SPE_ALTIVEC_UNAVAIL,
403 PROLOG_ADDITION_NONE) 403 PROLOG_ADDITION_NONE)
404 /* we can probably do a shorter exception entry for that one... */ 404 /* we can probably do a shorter exception entry for that one... */
405 EXCEPTION_COMMON(0x200, PACA_EXGEN, INTS_KEEP) 405 EXCEPTION_COMMON(0x200, PACA_EXGEN, INTS_KEEP)
@@ -421,7 +421,8 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
421 421
422/* AltiVec Assist */ 422/* AltiVec Assist */
423 START_EXCEPTION(altivec_assist); 423 START_EXCEPTION(altivec_assist);
424 NORMAL_EXCEPTION_PROLOG(0x220, BOOKE_INTERRUPT_ALTIVEC_ASSIST, 424 NORMAL_EXCEPTION_PROLOG(0x220,
425 BOOKE_INTERRUPT_SPE_FP_DATA_ALTIVEC_ASSIST,
425 PROLOG_ADDITION_NONE) 426 PROLOG_ADDITION_NONE)
426 EXCEPTION_COMMON(0x220, PACA_EXGEN, INTS_DISABLE) 427 EXCEPTION_COMMON(0x220, PACA_EXGEN, INTS_DISABLE)
427 bl .save_nvgprs 428 bl .save_nvgprs
@@ -607,6 +608,7 @@ kernel_dbg_exc:
607 NORMAL_EXCEPTION_PROLOG(0x260, BOOKE_INTERRUPT_PERFORMANCE_MONITOR, 608 NORMAL_EXCEPTION_PROLOG(0x260, BOOKE_INTERRUPT_PERFORMANCE_MONITOR,
608 PROLOG_ADDITION_NONE) 609 PROLOG_ADDITION_NONE)
609 EXCEPTION_COMMON(0x260, PACA_EXGEN, INTS_DISABLE) 610 EXCEPTION_COMMON(0x260, PACA_EXGEN, INTS_DISABLE)
611 CHECK_NAPPING()
610 addi r3,r1,STACK_FRAME_OVERHEAD 612 addi r3,r1,STACK_FRAME_OVERHEAD
611 bl .performance_monitor_exception 613 bl .performance_monitor_exception
612 b .ret_from_except_lite 614 b .ret_from_except_lite
diff --git a/arch/powerpc/kernel/fpu.S b/arch/powerpc/kernel/fpu.S
index caeaabf11a2f..f7f5b8bed68f 100644
--- a/arch/powerpc/kernel/fpu.S
+++ b/arch/powerpc/kernel/fpu.S
@@ -35,15 +35,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_VSX); \
352: REST_32VSRS(n,c,base); \ 352: REST_32VSRS(n,c,base); \
363: 363:
37 37
38#define __REST_32FPVSRS_TRANSACT(n,c,base) \
39BEGIN_FTR_SECTION \
40 b 2f; \
41END_FTR_SECTION_IFSET(CPU_FTR_VSX); \
42 REST_32FPRS_TRANSACT(n,base); \
43 b 3f; \
442: REST_32VSRS_TRANSACT(n,c,base); \
453:
46
47#define __SAVE_32FPVSRS(n,c,base) \ 38#define __SAVE_32FPVSRS(n,c,base) \
48BEGIN_FTR_SECTION \ 39BEGIN_FTR_SECTION \
49 b 2f; \ 40 b 2f; \
@@ -54,40 +45,12 @@ END_FTR_SECTION_IFSET(CPU_FTR_VSX); \
543: 453:
55#else 46#else
56#define __REST_32FPVSRS(n,b,base) REST_32FPRS(n, base) 47#define __REST_32FPVSRS(n,b,base) REST_32FPRS(n, base)
57#define __REST_32FPVSRS_TRANSACT(n,b,base) REST_32FPRS(n, base)
58#define __SAVE_32FPVSRS(n,b,base) SAVE_32FPRS(n, base) 48#define __SAVE_32FPVSRS(n,b,base) SAVE_32FPRS(n, base)
59#endif 49#endif
60#define REST_32FPVSRS(n,c,base) __REST_32FPVSRS(n,__REG_##c,__REG_##base) 50#define REST_32FPVSRS(n,c,base) __REST_32FPVSRS(n,__REG_##c,__REG_##base)
61#define REST_32FPVSRS_TRANSACT(n,c,base) \
62 __REST_32FPVSRS_TRANSACT(n,__REG_##c,__REG_##base)
63#define SAVE_32FPVSRS(n,c,base) __SAVE_32FPVSRS(n,__REG_##c,__REG_##base) 51#define SAVE_32FPVSRS(n,c,base) __SAVE_32FPVSRS(n,__REG_##c,__REG_##base)
64 52
65#ifdef CONFIG_PPC_TRANSACTIONAL_MEM 53#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
66/*
67 * Wrapper to call load_up_fpu from C.
68 * void do_load_up_fpu(struct pt_regs *regs);
69 */
70_GLOBAL(do_load_up_fpu)
71 mflr r0
72 std r0, 16(r1)
73 stdu r1, -112(r1)
74
75 subi r6, r3, STACK_FRAME_OVERHEAD
76 /* load_up_fpu expects r12=MSR, r13=PACA, and returns
77 * with r12 = new MSR.
78 */
79 ld r12,_MSR(r6)
80 GET_PACA(r13)
81
82 bl load_up_fpu
83 std r12,_MSR(r6)
84
85 ld r0, 112+16(r1)
86 addi r1, r1, 112
87 mtlr r0
88 blr
89
90
91/* void do_load_up_transact_fpu(struct thread_struct *thread) 54/* void do_load_up_transact_fpu(struct thread_struct *thread)
92 * 55 *
93 * This is similar to load_up_fpu but for the transactional version of the FP 56 * This is similar to load_up_fpu but for the transactional version of the FP
@@ -105,9 +68,10 @@ END_FTR_SECTION_IFSET(CPU_FTR_VSX)
105 SYNC 68 SYNC
106 MTMSRD(r5) 69 MTMSRD(r5)
107 70
108 lfd fr0,THREAD_TRANSACT_FPSCR(r3) 71 addi r7,r3,THREAD_TRANSACT_FPSTATE
72 lfd fr0,FPSTATE_FPSCR(r7)
109 MTFSF_L(fr0) 73 MTFSF_L(fr0)
110 REST_32FPVSRS_TRANSACT(0, R4, R3) 74 REST_32FPVSRS(0, R4, R7)
111 75
112 /* FP/VSX off again */ 76 /* FP/VSX off again */
113 MTMSRD(r6) 77 MTMSRD(r6)
@@ -117,11 +81,33 @@ END_FTR_SECTION_IFSET(CPU_FTR_VSX)
117#endif /* CONFIG_PPC_TRANSACTIONAL_MEM */ 81#endif /* CONFIG_PPC_TRANSACTIONAL_MEM */
118 82
119/* 83/*
84 * Load state from memory into FP registers including FPSCR.
85 * Assumes the caller has enabled FP in the MSR.
86 */
87_GLOBAL(load_fp_state)
88 lfd fr0,FPSTATE_FPSCR(r3)
89 MTFSF_L(fr0)
90 REST_32FPVSRS(0, R4, R3)
91 blr
92
93/*
94 * Store FP state into memory, including FPSCR
95 * Assumes the caller has enabled FP in the MSR.
96 */
97_GLOBAL(store_fp_state)
98 SAVE_32FPVSRS(0, R4, R3)
99 mffs fr0
100 stfd fr0,FPSTATE_FPSCR(r3)
101 blr
102
103/*
120 * This task wants to use the FPU now. 104 * This task wants to use the FPU now.
121 * On UP, disable FP for the task which had the FPU previously, 105 * On UP, disable FP for the task which had the FPU previously,
122 * and save its floating-point registers in its thread_struct. 106 * and save its floating-point registers in its thread_struct.
123 * Load up this task's FP registers from its thread_struct, 107 * Load up this task's FP registers from its thread_struct,
124 * enable the FPU for the current task and return to the task. 108 * enable the FPU for the current task and return to the task.
109 * Note that on 32-bit this can only use registers that will be
110 * restored by fast_exception_return, i.e. r3 - r6, r10 and r11.
125 */ 111 */
126_GLOBAL(load_up_fpu) 112_GLOBAL(load_up_fpu)
127 mfmsr r5 113 mfmsr r5
@@ -147,9 +133,10 @@ END_FTR_SECTION_IFSET(CPU_FTR_VSX)
147 beq 1f 133 beq 1f
148 toreal(r4) 134 toreal(r4)
149 addi r4,r4,THREAD /* want last_task_used_math->thread */ 135 addi r4,r4,THREAD /* want last_task_used_math->thread */
150 SAVE_32FPVSRS(0, R5, R4) 136 addi r10,r4,THREAD_FPSTATE
137 SAVE_32FPVSRS(0, R5, R10)
151 mffs fr0 138 mffs fr0
152 stfd fr0,THREAD_FPSCR(r4) 139 stfd fr0,FPSTATE_FPSCR(r10)
153 PPC_LL r5,PT_REGS(r4) 140 PPC_LL r5,PT_REGS(r4)
154 toreal(r5) 141 toreal(r5)
155 PPC_LL r4,_MSR-STACK_FRAME_OVERHEAD(r5) 142 PPC_LL r4,_MSR-STACK_FRAME_OVERHEAD(r5)
@@ -160,7 +147,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_VSX)
160#endif /* CONFIG_SMP */ 147#endif /* CONFIG_SMP */
161 /* enable use of FP after return */ 148 /* enable use of FP after return */
162#ifdef CONFIG_PPC32 149#ifdef CONFIG_PPC32
163 mfspr r5,SPRN_SPRG_THREAD /* current task's THREAD (phys) */ 150 mfspr r5,SPRN_SPRG_THREAD /* current task's THREAD (phys) */
164 lwz r4,THREAD_FPEXC_MODE(r5) 151 lwz r4,THREAD_FPEXC_MODE(r5)
165 ori r9,r9,MSR_FP /* enable FP for current */ 152 ori r9,r9,MSR_FP /* enable FP for current */
166 or r9,r9,r4 153 or r9,r9,r4
@@ -172,9 +159,10 @@ END_FTR_SECTION_IFSET(CPU_FTR_VSX)
172 or r12,r12,r4 159 or r12,r12,r4
173 std r12,_MSR(r1) 160 std r12,_MSR(r1)
174#endif 161#endif
175 lfd fr0,THREAD_FPSCR(r5) 162 addi r10,r5,THREAD_FPSTATE
163 lfd fr0,FPSTATE_FPSCR(r10)
176 MTFSF_L(fr0) 164 MTFSF_L(fr0)
177 REST_32FPVSRS(0, R4, R5) 165 REST_32FPVSRS(0, R4, R10)
178#ifndef CONFIG_SMP 166#ifndef CONFIG_SMP
179 subi r4,r5,THREAD 167 subi r4,r5,THREAD
180 fromreal(r4) 168 fromreal(r4)
@@ -206,11 +194,15 @@ END_FTR_SECTION_IFSET(CPU_FTR_VSX)
206 PPC_LCMPI 0,r3,0 194 PPC_LCMPI 0,r3,0
207 beqlr- /* if no previous owner, done */ 195 beqlr- /* if no previous owner, done */
208 addi r3,r3,THREAD /* want THREAD of task */ 196 addi r3,r3,THREAD /* want THREAD of task */
197 PPC_LL r6,THREAD_FPSAVEAREA(r3)
209 PPC_LL r5,PT_REGS(r3) 198 PPC_LL r5,PT_REGS(r3)
210 PPC_LCMPI 0,r5,0 199 PPC_LCMPI 0,r6,0
211 SAVE_32FPVSRS(0, R4 ,R3) 200 bne 2f
201 addi r6,r3,THREAD_FPSTATE
2022: PPC_LCMPI 0,r5,0
203 SAVE_32FPVSRS(0, R4, R6)
212 mffs fr0 204 mffs fr0
213 stfd fr0,THREAD_FPSCR(r3) 205 stfd fr0,FPSTATE_FPSCR(r6)
214 beq 1f 206 beq 1f
215 PPC_LL r4,_MSR-STACK_FRAME_OVERHEAD(r5) 207 PPC_LL r4,_MSR-STACK_FRAME_OVERHEAD(r5)
216 li r3,MSR_FP|MSR_FE0|MSR_FE1 208 li r3,MSR_FP|MSR_FE0|MSR_FE1
diff --git a/arch/powerpc/kernel/ftrace.c b/arch/powerpc/kernel/ftrace.c
index 1fb78561096a..9b27b293a922 100644
--- a/arch/powerpc/kernel/ftrace.c
+++ b/arch/powerpc/kernel/ftrace.c
@@ -174,7 +174,11 @@ __ftrace_make_nop(struct module *mod,
174 174
175 pr_devel(" %08x %08x\n", jmp[0], jmp[1]); 175 pr_devel(" %08x %08x\n", jmp[0], jmp[1]);
176 176
177#ifdef __LITTLE_ENDIAN__
178 ptr = ((unsigned long)jmp[1] << 32) + jmp[0];
179#else
177 ptr = ((unsigned long)jmp[0] << 32) + jmp[1]; 180 ptr = ((unsigned long)jmp[0] << 32) + jmp[1];
181#endif
178 182
179 /* This should match what was called */ 183 /* This should match what was called */
180 if (ptr != ppc_function_entry((void *)addr)) { 184 if (ptr != ppc_function_entry((void *)addr)) {
diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S
index 3d11d8038dee..2ae41aba4053 100644
--- a/arch/powerpc/kernel/head_64.S
+++ b/arch/powerpc/kernel/head_64.S
@@ -68,6 +68,7 @@ _stext:
68_GLOBAL(__start) 68_GLOBAL(__start)
69 /* NOP this out unconditionally */ 69 /* NOP this out unconditionally */
70BEGIN_FTR_SECTION 70BEGIN_FTR_SECTION
71 FIXUP_ENDIAN
71 b .__start_initialization_multiplatform 72 b .__start_initialization_multiplatform
72END_FTR_SECTION(0, 1) 73END_FTR_SECTION(0, 1)
73 74
@@ -115,6 +116,7 @@ __run_at_load:
115 */ 116 */
116 .globl __secondary_hold 117 .globl __secondary_hold
117__secondary_hold: 118__secondary_hold:
119 FIXUP_ENDIAN
118#ifndef CONFIG_PPC_BOOK3E 120#ifndef CONFIG_PPC_BOOK3E
119 mfmsr r24 121 mfmsr r24
120 ori r24,r24,MSR_RI 122 ori r24,r24,MSR_RI
@@ -205,6 +207,7 @@ _GLOBAL(generic_secondary_thread_init)
205 * as SCOM before entry). 207 * as SCOM before entry).
206 */ 208 */
207_GLOBAL(generic_secondary_smp_init) 209_GLOBAL(generic_secondary_smp_init)
210 FIXUP_ENDIAN
208 mr r24,r3 211 mr r24,r3
209 mr r25,r4 212 mr r25,r4
210 213
diff --git a/arch/powerpc/kernel/head_8xx.S b/arch/powerpc/kernel/head_8xx.S
index 1b92a97b1b04..7ee876d2adb5 100644
--- a/arch/powerpc/kernel/head_8xx.S
+++ b/arch/powerpc/kernel/head_8xx.S
@@ -858,6 +858,9 @@ initial_mmu:
858 addis r11, r11, 0x0080 /* Add 8M */ 858 addis r11, r11, 0x0080 /* Add 8M */
859 mtspr SPRN_MD_RPN, r11 859 mtspr SPRN_MD_RPN, r11
860 860
861 addi r10, r10, 0x0100
862 mtspr SPRN_MD_CTR, r10
863
861 addis r8, r8, 0x0080 /* Add 8M */ 864 addis r8, r8, 0x0080 /* Add 8M */
862 mtspr SPRN_MD_EPN, r8 865 mtspr SPRN_MD_EPN, r8
863 mtspr SPRN_MD_TWC, r9 866 mtspr SPRN_MD_TWC, r9
diff --git a/arch/powerpc/kernel/head_fsl_booke.S b/arch/powerpc/kernel/head_fsl_booke.S
index 289afaffbbb5..f45726a1d963 100644
--- a/arch/powerpc/kernel/head_fsl_booke.S
+++ b/arch/powerpc/kernel/head_fsl_booke.S
@@ -555,27 +555,27 @@ END_FTR_SECTION_IFSET(CPU_FTR_EMB_HV)
555#ifdef CONFIG_SPE 555#ifdef CONFIG_SPE
556 /* SPE Unavailable */ 556 /* SPE Unavailable */
557 START_EXCEPTION(SPEUnavailable) 557 START_EXCEPTION(SPEUnavailable)
558 NORMAL_EXCEPTION_PROLOG(SPE_UNAVAIL) 558 NORMAL_EXCEPTION_PROLOG(SPE_ALTIVEC_UNAVAIL)
559 beq 1f 559 beq 1f
560 bl load_up_spe 560 bl load_up_spe
561 b fast_exception_return 561 b fast_exception_return
5621: addi r3,r1,STACK_FRAME_OVERHEAD 5621: addi r3,r1,STACK_FRAME_OVERHEAD
563 EXC_XFER_EE_LITE(0x2010, KernelSPE) 563 EXC_XFER_EE_LITE(0x2010, KernelSPE)
564#else 564#else
565 EXCEPTION(0x2020, SPE_UNAVAIL, SPEUnavailable, \ 565 EXCEPTION(0x2020, SPE_ALTIVEC_UNAVAIL, SPEUnavailable, \
566 unknown_exception, EXC_XFER_EE) 566 unknown_exception, EXC_XFER_EE)
567#endif /* CONFIG_SPE */ 567#endif /* CONFIG_SPE */
568 568
569 /* SPE Floating Point Data */ 569 /* SPE Floating Point Data */
570#ifdef CONFIG_SPE 570#ifdef CONFIG_SPE
571 EXCEPTION(0x2030, SPE_FP_DATA, SPEFloatingPointData, \ 571 EXCEPTION(0x2030, SPE_FP_DATA_ALTIVEC_ASSIST, SPEFloatingPointData,
572 SPEFloatingPointException, EXC_XFER_EE); 572 SPEFloatingPointException, EXC_XFER_EE)
573 573
574 /* SPE Floating Point Round */ 574 /* SPE Floating Point Round */
575 EXCEPTION(0x2050, SPE_FP_ROUND, SPEFloatingPointRound, \ 575 EXCEPTION(0x2050, SPE_FP_ROUND, SPEFloatingPointRound, \
576 SPEFloatingPointRoundException, EXC_XFER_EE) 576 SPEFloatingPointRoundException, EXC_XFER_EE)
577#else 577#else
578 EXCEPTION(0x2040, SPE_FP_DATA, SPEFloatingPointData, \ 578 EXCEPTION(0x2040, SPE_FP_DATA_ALTIVEC_ASSIST, SPEFloatingPointData,
579 unknown_exception, EXC_XFER_EE) 579 unknown_exception, EXC_XFER_EE)
580 EXCEPTION(0x2050, SPE_FP_ROUND, SPEFloatingPointRound, \ 580 EXCEPTION(0x2050, SPE_FP_ROUND, SPEFloatingPointRound, \
581 unknown_exception, EXC_XFER_EE) 581 unknown_exception, EXC_XFER_EE)
diff --git a/arch/powerpc/kernel/kgdb.c b/arch/powerpc/kernel/kgdb.c
index c1eef241017a..83e89d310734 100644
--- a/arch/powerpc/kernel/kgdb.c
+++ b/arch/powerpc/kernel/kgdb.c
@@ -151,15 +151,16 @@ static int kgdb_handle_breakpoint(struct pt_regs *regs)
151 return 1; 151 return 1;
152} 152}
153 153
154static DEFINE_PER_CPU(struct thread_info, kgdb_thread_info);
154static int kgdb_singlestep(struct pt_regs *regs) 155static int kgdb_singlestep(struct pt_regs *regs)
155{ 156{
156 struct thread_info *thread_info, *exception_thread_info; 157 struct thread_info *thread_info, *exception_thread_info;
157 struct thread_info *backup_current_thread_info; 158 struct thread_info *backup_current_thread_info =
159 &__get_cpu_var(kgdb_thread_info);
158 160
159 if (user_mode(regs)) 161 if (user_mode(regs))
160 return 0; 162 return 0;
161 163
162 backup_current_thread_info = kmalloc(sizeof(struct thread_info), GFP_KERNEL);
163 /* 164 /*
164 * On Book E and perhaps other processors, singlestep is handled on 165 * On Book E and perhaps other processors, singlestep is handled on
165 * the critical exception stack. This causes current_thread_info() 166 * the critical exception stack. This causes current_thread_info()
@@ -185,7 +186,6 @@ static int kgdb_singlestep(struct pt_regs *regs)
185 /* Restore current_thread_info lastly. */ 186 /* Restore current_thread_info lastly. */
186 memcpy(exception_thread_info, backup_current_thread_info, sizeof *thread_info); 187 memcpy(exception_thread_info, backup_current_thread_info, sizeof *thread_info);
187 188
188 kfree(backup_current_thread_info);
189 return 1; 189 return 1;
190} 190}
191 191
diff --git a/arch/powerpc/kernel/legacy_serial.c b/arch/powerpc/kernel/legacy_serial.c
index 22e88dd2f34a..40bd7bd4e19a 100644
--- a/arch/powerpc/kernel/legacy_serial.c
+++ b/arch/powerpc/kernel/legacy_serial.c
@@ -35,7 +35,7 @@ static struct legacy_serial_info {
35 phys_addr_t taddr; 35 phys_addr_t taddr;
36} legacy_serial_infos[MAX_LEGACY_SERIAL_PORTS]; 36} legacy_serial_infos[MAX_LEGACY_SERIAL_PORTS];
37 37
38static struct __initdata of_device_id legacy_serial_parents[] = { 38static struct of_device_id legacy_serial_parents[] __initdata = {
39 {.type = "soc",}, 39 {.type = "soc",},
40 {.type = "tsi-bridge",}, 40 {.type = "tsi-bridge",},
41 {.type = "opb", }, 41 {.type = "opb", },
diff --git a/arch/powerpc/kernel/machine_kexec_64.c b/arch/powerpc/kernel/machine_kexec_64.c
index 611acdf30096..be4e6d648f60 100644
--- a/arch/powerpc/kernel/machine_kexec_64.c
+++ b/arch/powerpc/kernel/machine_kexec_64.c
@@ -312,7 +312,7 @@ static union thread_union kexec_stack __init_task_data =
312 */ 312 */
313struct paca_struct kexec_paca; 313struct paca_struct kexec_paca;
314 314
315/* Our assembly helper, in kexec_stub.S */ 315/* Our assembly helper, in misc_64.S */
316extern void kexec_sequence(void *newstack, unsigned long start, 316extern void kexec_sequence(void *newstack, unsigned long start,
317 void *image, void *control, 317 void *image, void *control,
318 void (*clear_all)(void)) __noreturn; 318 void (*clear_all)(void)) __noreturn;
diff --git a/arch/powerpc/kernel/misc_32.S b/arch/powerpc/kernel/misc_32.S
index 2b0ad9845363..e47d268727a4 100644
--- a/arch/powerpc/kernel/misc_32.S
+++ b/arch/powerpc/kernel/misc_32.S
@@ -659,6 +659,20 @@ _GLOBAL(__lshrdi3)
659 blr 659 blr
660 660
661/* 661/*
662 * 64-bit comparison: __cmpdi2(s64 a, s64 b)
663 * Returns 0 if a < b, 1 if a == b, 2 if a > b.
664 */
665_GLOBAL(__cmpdi2)
666 cmpw r3,r5
667 li r3,1
668 bne 1f
669 cmplw r4,r6
670 beqlr
6711: li r3,0
672 bltlr
673 li r3,2
674 blr
675/*
662 * 64-bit comparison: __ucmpdi2(u64 a, u64 b) 676 * 64-bit comparison: __ucmpdi2(u64 a, u64 b)
663 * Returns 0 if a < b, 1 if a == b, 2 if a > b. 677 * Returns 0 if a < b, 1 if a == b, 2 if a > b.
664 */ 678 */
diff --git a/arch/powerpc/kernel/module.c b/arch/powerpc/kernel/module.c
index 2d275707f419..9547381b631a 100644
--- a/arch/powerpc/kernel/module.c
+++ b/arch/powerpc/kernel/module.c
@@ -25,8 +25,7 @@
25#include <asm/uaccess.h> 25#include <asm/uaccess.h>
26#include <asm/firmware.h> 26#include <asm/firmware.h>
27#include <linux/sort.h> 27#include <linux/sort.h>
28 28#include <asm/setup.h>
29#include "setup.h"
30 29
31LIST_HEAD(module_bug_list); 30LIST_HEAD(module_bug_list);
32 31
diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
index 2e3200ca485f..6cff040bf456 100644
--- a/arch/powerpc/kernel/module_32.c
+++ b/arch/powerpc/kernel/module_32.c
@@ -26,8 +26,7 @@
26#include <linux/cache.h> 26#include <linux/cache.h>
27#include <linux/bug.h> 27#include <linux/bug.h>
28#include <linux/sort.h> 28#include <linux/sort.h>
29 29#include <asm/setup.h>
30#include "setup.h"
31 30
32#if 0 31#if 0
33#define DEBUGP printk 32#define DEBUGP printk
diff --git a/arch/powerpc/kernel/module_64.c b/arch/powerpc/kernel/module_64.c
index 6ee59a0eb268..12664c130d73 100644
--- a/arch/powerpc/kernel/module_64.c
+++ b/arch/powerpc/kernel/module_64.c
@@ -26,8 +26,7 @@
26#include <asm/firmware.h> 26#include <asm/firmware.h>
27#include <asm/code-patching.h> 27#include <asm/code-patching.h>
28#include <linux/sort.h> 28#include <linux/sort.h>
29 29#include <asm/setup.h>
30#include "setup.h"
31 30
32/* FIXME: We don't do .init separately. To do this, we'd need to have 31/* FIXME: We don't do .init separately. To do this, we'd need to have
33 a separate r2 value in the init and core section, and stub between 32 a separate r2 value in the init and core section, and stub between
@@ -62,6 +61,16 @@ struct ppc64_stub_entry
62 r2) into the stub. */ 61 r2) into the stub. */
63static struct ppc64_stub_entry ppc64_stub = 62static struct ppc64_stub_entry ppc64_stub =
64{ .jump = { 63{ .jump = {
64#ifdef __LITTLE_ENDIAN__
65 0x00, 0x00, 0x82, 0x3d, /* addis r12,r2, <high> */
66 0x00, 0x00, 0x8c, 0x39, /* addi r12,r12, <low> */
67 /* Save current r2 value in magic place on the stack. */
68 0x28, 0x00, 0x41, 0xf8, /* std r2,40(r1) */
69 0x20, 0x00, 0x6c, 0xe9, /* ld r11,32(r12) */
70 0x28, 0x00, 0x4c, 0xe8, /* ld r2,40(r12) */
71 0xa6, 0x03, 0x69, 0x7d, /* mtctr r11 */
72 0x20, 0x04, 0x80, 0x4e /* bctr */
73#else
65 0x3d, 0x82, 0x00, 0x00, /* addis r12,r2, <high> */ 74 0x3d, 0x82, 0x00, 0x00, /* addis r12,r2, <high> */
66 0x39, 0x8c, 0x00, 0x00, /* addi r12,r12, <low> */ 75 0x39, 0x8c, 0x00, 0x00, /* addi r12,r12, <low> */
67 /* Save current r2 value in magic place on the stack. */ 76 /* Save current r2 value in magic place on the stack. */
@@ -70,6 +79,7 @@ static struct ppc64_stub_entry ppc64_stub =
70 0xe8, 0x4c, 0x00, 0x28, /* ld r2,40(r12) */ 79 0xe8, 0x4c, 0x00, 0x28, /* ld r2,40(r12) */
71 0x7d, 0x69, 0x03, 0xa6, /* mtctr r11 */ 80 0x7d, 0x69, 0x03, 0xa6, /* mtctr r11 */
72 0x4e, 0x80, 0x04, 0x20 /* bctr */ 81 0x4e, 0x80, 0x04, 0x20 /* bctr */
82#endif
73} }; 83} };
74 84
75/* Count how many different 24-bit relocations (different symbol, 85/* Count how many different 24-bit relocations (different symbol,
@@ -269,8 +279,13 @@ static inline int create_stub(Elf64_Shdr *sechdrs,
269 279
270 *entry = ppc64_stub; 280 *entry = ppc64_stub;
271 281
282#ifdef __LITTLE_ENDIAN__
283 loc1 = (Elf64_Half *)&entry->jump[0];
284 loc2 = (Elf64_Half *)&entry->jump[4];
285#else
272 loc1 = (Elf64_Half *)&entry->jump[2]; 286 loc1 = (Elf64_Half *)&entry->jump[2];
273 loc2 = (Elf64_Half *)&entry->jump[6]; 287 loc2 = (Elf64_Half *)&entry->jump[6];
288#endif
274 289
275 /* Stub uses address relative to r2. */ 290 /* Stub uses address relative to r2. */
276 reladdr = (unsigned long)entry - my_r2(sechdrs, me); 291 reladdr = (unsigned long)entry - my_r2(sechdrs, me);
diff --git a/arch/powerpc/kernel/nvram_64.c b/arch/powerpc/kernel/nvram_64.c
index 8213ee1eb05a..fd82c289ab1c 100644
--- a/arch/powerpc/kernel/nvram_64.c
+++ b/arch/powerpc/kernel/nvram_64.c
@@ -223,9 +223,13 @@ static int __init nvram_write_header(struct nvram_partition * part)
223{ 223{
224 loff_t tmp_index; 224 loff_t tmp_index;
225 int rc; 225 int rc;
226 226 struct nvram_header phead;
227
228 memcpy(&phead, &part->header, NVRAM_HEADER_LEN);
229 phead.length = cpu_to_be16(phead.length);
230
227 tmp_index = part->index; 231 tmp_index = part->index;
228 rc = ppc_md.nvram_write((char *)&part->header, NVRAM_HEADER_LEN, &tmp_index); 232 rc = ppc_md.nvram_write((char *)&phead, NVRAM_HEADER_LEN, &tmp_index);
229 233
230 return rc; 234 return rc;
231} 235}
@@ -505,6 +509,8 @@ int __init nvram_scan_partitions(void)
505 509
506 memcpy(&phead, header, NVRAM_HEADER_LEN); 510 memcpy(&phead, header, NVRAM_HEADER_LEN);
507 511
512 phead.length = be16_to_cpu(phead.length);
513
508 err = 0; 514 err = 0;
509 c_sum = nvram_checksum(&phead); 515 c_sum = nvram_checksum(&phead);
510 if (c_sum != phead.checksum) { 516 if (c_sum != phead.checksum) {
diff --git a/arch/powerpc/kernel/paca.c b/arch/powerpc/kernel/paca.c
index 3fc16e3beb9f..0620eaaaad45 100644
--- a/arch/powerpc/kernel/paca.c
+++ b/arch/powerpc/kernel/paca.c
@@ -46,7 +46,7 @@ struct lppaca lppaca[] = {
46static struct lppaca *extra_lppacas; 46static struct lppaca *extra_lppacas;
47static long __initdata lppaca_size; 47static long __initdata lppaca_size;
48 48
49static void allocate_lppacas(int nr_cpus, unsigned long limit) 49static void __init allocate_lppacas(int nr_cpus, unsigned long limit)
50{ 50{
51 if (nr_cpus <= NR_LPPACAS) 51 if (nr_cpus <= NR_LPPACAS)
52 return; 52 return;
@@ -57,7 +57,7 @@ static void allocate_lppacas(int nr_cpus, unsigned long limit)
57 PAGE_SIZE, limit)); 57 PAGE_SIZE, limit));
58} 58}
59 59
60static struct lppaca *new_lppaca(int cpu) 60static struct lppaca * __init new_lppaca(int cpu)
61{ 61{
62 struct lppaca *lp; 62 struct lppaca *lp;
63 63
@@ -70,7 +70,7 @@ static struct lppaca *new_lppaca(int cpu)
70 return lp; 70 return lp;
71} 71}
72 72
73static void free_lppacas(void) 73static void __init free_lppacas(void)
74{ 74{
75 long new_size = 0, nr; 75 long new_size = 0, nr;
76 76
diff --git a/arch/powerpc/kernel/pci_of_scan.c b/arch/powerpc/kernel/pci_of_scan.c
index 4368ec6fdc8c..ac0b034f9ae0 100644
--- a/arch/powerpc/kernel/pci_of_scan.c
+++ b/arch/powerpc/kernel/pci_of_scan.c
@@ -302,7 +302,7 @@ static struct pci_dev *of_scan_pci_dev(struct pci_bus *bus,
302 struct device_node *dn) 302 struct device_node *dn)
303{ 303{
304 struct pci_dev *dev = NULL; 304 struct pci_dev *dev = NULL;
305 const u32 *reg; 305 const __be32 *reg;
306 int reglen, devfn; 306 int reglen, devfn;
307 307
308 pr_debug(" * %s\n", dn->full_name); 308 pr_debug(" * %s\n", dn->full_name);
@@ -312,7 +312,7 @@ static struct pci_dev *of_scan_pci_dev(struct pci_bus *bus,
312 reg = of_get_property(dn, "reg", &reglen); 312 reg = of_get_property(dn, "reg", &reglen);
313 if (reg == NULL || reglen < 20) 313 if (reg == NULL || reglen < 20)
314 return NULL; 314 return NULL;
315 devfn = (reg[0] >> 8) & 0xff; 315 devfn = (of_read_number(reg, 1) >> 8) & 0xff;
316 316
317 /* Check if the PCI device is already there */ 317 /* Check if the PCI device is already there */
318 dev = pci_get_slot(bus, devfn); 318 dev = pci_get_slot(bus, devfn);
diff --git a/arch/powerpc/kernel/ppc_ksyms.c b/arch/powerpc/kernel/ppc_ksyms.c
index 21646dbe1bb3..3bd77edd7610 100644
--- a/arch/powerpc/kernel/ppc_ksyms.c
+++ b/arch/powerpc/kernel/ppc_ksyms.c
@@ -79,10 +79,12 @@ EXPORT_SYMBOL(strlen);
79EXPORT_SYMBOL(strcmp); 79EXPORT_SYMBOL(strcmp);
80EXPORT_SYMBOL(strncmp); 80EXPORT_SYMBOL(strncmp);
81 81
82#ifndef CONFIG_GENERIC_CSUM
82EXPORT_SYMBOL(csum_partial); 83EXPORT_SYMBOL(csum_partial);
83EXPORT_SYMBOL(csum_partial_copy_generic); 84EXPORT_SYMBOL(csum_partial_copy_generic);
84EXPORT_SYMBOL(ip_fast_csum); 85EXPORT_SYMBOL(ip_fast_csum);
85EXPORT_SYMBOL(csum_tcpudp_magic); 86EXPORT_SYMBOL(csum_tcpudp_magic);
87#endif
86 88
87EXPORT_SYMBOL(__copy_tofrom_user); 89EXPORT_SYMBOL(__copy_tofrom_user);
88EXPORT_SYMBOL(__clear_user); 90EXPORT_SYMBOL(__clear_user);
@@ -98,9 +100,13 @@ EXPORT_SYMBOL(start_thread);
98 100
99#ifdef CONFIG_PPC_FPU 101#ifdef CONFIG_PPC_FPU
100EXPORT_SYMBOL(giveup_fpu); 102EXPORT_SYMBOL(giveup_fpu);
103EXPORT_SYMBOL(load_fp_state);
104EXPORT_SYMBOL(store_fp_state);
101#endif 105#endif
102#ifdef CONFIG_ALTIVEC 106#ifdef CONFIG_ALTIVEC
103EXPORT_SYMBOL(giveup_altivec); 107EXPORT_SYMBOL(giveup_altivec);
108EXPORT_SYMBOL(load_vr_state);
109EXPORT_SYMBOL(store_vr_state);
104#endif /* CONFIG_ALTIVEC */ 110#endif /* CONFIG_ALTIVEC */
105#ifdef CONFIG_VSX 111#ifdef CONFIG_VSX
106EXPORT_SYMBOL(giveup_vsx); 112EXPORT_SYMBOL(giveup_vsx);
@@ -143,10 +149,14 @@ EXPORT_SYMBOL(__ashldi3);
143EXPORT_SYMBOL(__lshrdi3); 149EXPORT_SYMBOL(__lshrdi3);
144int __ucmpdi2(unsigned long long, unsigned long long); 150int __ucmpdi2(unsigned long long, unsigned long long);
145EXPORT_SYMBOL(__ucmpdi2); 151EXPORT_SYMBOL(__ucmpdi2);
152int __cmpdi2(long long, long long);
153EXPORT_SYMBOL(__cmpdi2);
146#endif 154#endif
147long long __bswapdi2(long long); 155long long __bswapdi2(long long);
148EXPORT_SYMBOL(__bswapdi2); 156EXPORT_SYMBOL(__bswapdi2);
157#ifdef __BIG_ENDIAN__
149EXPORT_SYMBOL(memcpy); 158EXPORT_SYMBOL(memcpy);
159#endif
150EXPORT_SYMBOL(memset); 160EXPORT_SYMBOL(memset);
151EXPORT_SYMBOL(memmove); 161EXPORT_SYMBOL(memmove);
152EXPORT_SYMBOL(memcmp); 162EXPORT_SYMBOL(memcmp);
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 96d2fdf3aa9e..75c2d1009985 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -314,28 +314,28 @@ static DEFINE_PER_CPU(struct arch_hw_breakpoint, current_brk);
314 */ 314 */
315static void set_debug_reg_defaults(struct thread_struct *thread) 315static void set_debug_reg_defaults(struct thread_struct *thread)
316{ 316{
317 thread->iac1 = thread->iac2 = 0; 317 thread->debug.iac1 = thread->debug.iac2 = 0;
318#if CONFIG_PPC_ADV_DEBUG_IACS > 2 318#if CONFIG_PPC_ADV_DEBUG_IACS > 2
319 thread->iac3 = thread->iac4 = 0; 319 thread->debug.iac3 = thread->debug.iac4 = 0;
320#endif 320#endif
321 thread->dac1 = thread->dac2 = 0; 321 thread->debug.dac1 = thread->debug.dac2 = 0;
322#if CONFIG_PPC_ADV_DEBUG_DVCS > 0 322#if CONFIG_PPC_ADV_DEBUG_DVCS > 0
323 thread->dvc1 = thread->dvc2 = 0; 323 thread->debug.dvc1 = thread->debug.dvc2 = 0;
324#endif 324#endif
325 thread->dbcr0 = 0; 325 thread->debug.dbcr0 = 0;
326#ifdef CONFIG_BOOKE 326#ifdef CONFIG_BOOKE
327 /* 327 /*
328 * Force User/Supervisor bits to b11 (user-only MSR[PR]=1) 328 * Force User/Supervisor bits to b11 (user-only MSR[PR]=1)
329 */ 329 */
330 thread->dbcr1 = DBCR1_IAC1US | DBCR1_IAC2US | \ 330 thread->debug.dbcr1 = DBCR1_IAC1US | DBCR1_IAC2US |
331 DBCR1_IAC3US | DBCR1_IAC4US; 331 DBCR1_IAC3US | DBCR1_IAC4US;
332 /* 332 /*
333 * Force Data Address Compare User/Supervisor bits to be User-only 333 * Force Data Address Compare User/Supervisor bits to be User-only
334 * (0b11 MSR[PR]=1) and set all other bits in DBCR2 register to be 0. 334 * (0b11 MSR[PR]=1) and set all other bits in DBCR2 register to be 0.
335 */ 335 */
336 thread->dbcr2 = DBCR2_DAC1US | DBCR2_DAC2US; 336 thread->debug.dbcr2 = DBCR2_DAC1US | DBCR2_DAC2US;
337#else 337#else
338 thread->dbcr1 = 0; 338 thread->debug.dbcr1 = 0;
339#endif 339#endif
340} 340}
341 341
@@ -348,22 +348,22 @@ static void prime_debug_regs(struct thread_struct *thread)
348 */ 348 */
349 mtmsr(mfmsr() & ~MSR_DE); 349 mtmsr(mfmsr() & ~MSR_DE);
350 350
351 mtspr(SPRN_IAC1, thread->iac1); 351 mtspr(SPRN_IAC1, thread->debug.iac1);
352 mtspr(SPRN_IAC2, thread->iac2); 352 mtspr(SPRN_IAC2, thread->debug.iac2);
353#if CONFIG_PPC_ADV_DEBUG_IACS > 2 353#if CONFIG_PPC_ADV_DEBUG_IACS > 2
354 mtspr(SPRN_IAC3, thread->iac3); 354 mtspr(SPRN_IAC3, thread->debug.iac3);
355 mtspr(SPRN_IAC4, thread->iac4); 355 mtspr(SPRN_IAC4, thread->debug.iac4);
356#endif 356#endif
357 mtspr(SPRN_DAC1, thread->dac1); 357 mtspr(SPRN_DAC1, thread->debug.dac1);
358 mtspr(SPRN_DAC2, thread->dac2); 358 mtspr(SPRN_DAC2, thread->debug.dac2);
359#if CONFIG_PPC_ADV_DEBUG_DVCS > 0 359#if CONFIG_PPC_ADV_DEBUG_DVCS > 0
360 mtspr(SPRN_DVC1, thread->dvc1); 360 mtspr(SPRN_DVC1, thread->debug.dvc1);
361 mtspr(SPRN_DVC2, thread->dvc2); 361 mtspr(SPRN_DVC2, thread->debug.dvc2);
362#endif 362#endif
363 mtspr(SPRN_DBCR0, thread->dbcr0); 363 mtspr(SPRN_DBCR0, thread->debug.dbcr0);
364 mtspr(SPRN_DBCR1, thread->dbcr1); 364 mtspr(SPRN_DBCR1, thread->debug.dbcr1);
365#ifdef CONFIG_BOOKE 365#ifdef CONFIG_BOOKE
366 mtspr(SPRN_DBCR2, thread->dbcr2); 366 mtspr(SPRN_DBCR2, thread->debug.dbcr2);
367#endif 367#endif
368} 368}
369/* 369/*
@@ -371,12 +371,13 @@ static void prime_debug_regs(struct thread_struct *thread)
371 * debug registers, set the debug registers from the values 371 * debug registers, set the debug registers from the values
372 * stored in the new thread. 372 * stored in the new thread.
373 */ 373 */
374static void switch_booke_debug_regs(struct thread_struct *new_thread) 374void switch_booke_debug_regs(struct thread_struct *new_thread)
375{ 375{
376 if ((current->thread.dbcr0 & DBCR0_IDM) 376 if ((current->thread.debug.dbcr0 & DBCR0_IDM)
377 || (new_thread->dbcr0 & DBCR0_IDM)) 377 || (new_thread->debug.dbcr0 & DBCR0_IDM))
378 prime_debug_regs(new_thread); 378 prime_debug_regs(new_thread);
379} 379}
380EXPORT_SYMBOL_GPL(switch_booke_debug_regs);
380#else /* !CONFIG_PPC_ADV_DEBUG_REGS */ 381#else /* !CONFIG_PPC_ADV_DEBUG_REGS */
381#ifndef CONFIG_HAVE_HW_BREAKPOINT 382#ifndef CONFIG_HAVE_HW_BREAKPOINT
382static void set_debug_reg_defaults(struct thread_struct *thread) 383static void set_debug_reg_defaults(struct thread_struct *thread)
@@ -596,12 +597,13 @@ struct task_struct *__switch_to(struct task_struct *prev,
596 struct task_struct *new) 597 struct task_struct *new)
597{ 598{
598 struct thread_struct *new_thread, *old_thread; 599 struct thread_struct *new_thread, *old_thread;
599 unsigned long flags;
600 struct task_struct *last; 600 struct task_struct *last;
601#ifdef CONFIG_PPC_BOOK3S_64 601#ifdef CONFIG_PPC_BOOK3S_64
602 struct ppc64_tlb_batch *batch; 602 struct ppc64_tlb_batch *batch;
603#endif 603#endif
604 604
605 WARN_ON(!irqs_disabled());
606
605 /* Back up the TAR across context switches. 607 /* Back up the TAR across context switches.
606 * Note that the TAR is not available for use in the kernel. (To 608 * Note that the TAR is not available for use in the kernel. (To
607 * provide this, the TAR should be backed up/restored on exception 609 * provide this, the TAR should be backed up/restored on exception
@@ -721,8 +723,6 @@ struct task_struct *__switch_to(struct task_struct *prev,
721 } 723 }
722#endif /* CONFIG_PPC_BOOK3S_64 */ 724#endif /* CONFIG_PPC_BOOK3S_64 */
723 725
724 local_irq_save(flags);
725
726 /* 726 /*
727 * We can't take a PMU exception inside _switch() since there is a 727 * We can't take a PMU exception inside _switch() since there is a
728 * window where the kernel stack SLB and the kernel stack are out 728 * window where the kernel stack SLB and the kernel stack are out
@@ -742,8 +742,6 @@ struct task_struct *__switch_to(struct task_struct *prev,
742 } 742 }
743#endif /* CONFIG_PPC_BOOK3S_64 */ 743#endif /* CONFIG_PPC_BOOK3S_64 */
744 744
745 local_irq_restore(flags);
746
747 return last; 745 return last;
748} 746}
749 747
@@ -1008,6 +1006,11 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
1008 p->thread.ptrace_bps[0] = NULL; 1006 p->thread.ptrace_bps[0] = NULL;
1009#endif 1007#endif
1010 1008
1009 p->thread.fp_save_area = NULL;
1010#ifdef CONFIG_ALTIVEC
1011 p->thread.vr_save_area = NULL;
1012#endif
1013
1011#ifdef CONFIG_PPC_STD_MMU_64 1014#ifdef CONFIG_PPC_STD_MMU_64
1012 if (mmu_has_feature(MMU_FTR_SLB)) { 1015 if (mmu_has_feature(MMU_FTR_SLB)) {
1013 unsigned long sp_vsid; 1016 unsigned long sp_vsid;
@@ -1113,12 +1116,12 @@ void start_thread(struct pt_regs *regs, unsigned long start, unsigned long sp)
1113#ifdef CONFIG_VSX 1116#ifdef CONFIG_VSX
1114 current->thread.used_vsr = 0; 1117 current->thread.used_vsr = 0;
1115#endif 1118#endif
1116 memset(current->thread.fpr, 0, sizeof(current->thread.fpr)); 1119 memset(&current->thread.fp_state, 0, sizeof(current->thread.fp_state));
1117 current->thread.fpscr.val = 0; 1120 current->thread.fp_save_area = NULL;
1118#ifdef CONFIG_ALTIVEC 1121#ifdef CONFIG_ALTIVEC
1119 memset(current->thread.vr, 0, sizeof(current->thread.vr)); 1122 memset(&current->thread.vr_state, 0, sizeof(current->thread.vr_state));
1120 memset(&current->thread.vscr, 0, sizeof(current->thread.vscr)); 1123 current->thread.vr_state.vscr.u[3] = 0x00010000; /* Java mode disabled */
1121 current->thread.vscr.u[3] = 0x00010000; /* Java mode disabled */ 1124 current->thread.vr_save_area = NULL;
1122 current->thread.vrsave = 0; 1125 current->thread.vrsave = 0;
1123 current->thread.used_vr = 0; 1126 current->thread.used_vr = 0;
1124#endif /* CONFIG_ALTIVEC */ 1127#endif /* CONFIG_ALTIVEC */
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index b7634ce41dbc..4432fd86a6d2 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -761,37 +761,6 @@ void __init early_init_devtree(void *params)
761 *******/ 761 *******/
762 762
763/** 763/**
764 * of_find_next_cache_node - Find a node's subsidiary cache
765 * @np: node of type "cpu" or "cache"
766 *
767 * Returns a node pointer with refcount incremented, use
768 * of_node_put() on it when done. Caller should hold a reference
769 * to np.
770 */
771struct device_node *of_find_next_cache_node(struct device_node *np)
772{
773 struct device_node *child;
774 const phandle *handle;
775
776 handle = of_get_property(np, "l2-cache", NULL);
777 if (!handle)
778 handle = of_get_property(np, "next-level-cache", NULL);
779
780 if (handle)
781 return of_find_node_by_phandle(*handle);
782
783 /* OF on pmac has nodes instead of properties named "l2-cache"
784 * beneath CPU nodes.
785 */
786 if (!strcmp(np->type, "cpu"))
787 for_each_child_of_node(np, child)
788 if (!strcmp(child->type, "cache"))
789 return child;
790
791 return NULL;
792}
793
794/**
795 * of_get_ibm_chip_id - Returns the IBM "chip-id" of a device 764 * of_get_ibm_chip_id - Returns the IBM "chip-id" of a device
796 * @np: device node of the device 765 * @np: device node of the device
797 * 766 *
diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c
index 5fe2842e8bab..cb64a6e1dc51 100644
--- a/arch/powerpc/kernel/prom_init.c
+++ b/arch/powerpc/kernel/prom_init.c
@@ -858,7 +858,8 @@ static void __init prom_send_capabilities(void)
858{ 858{
859 ihandle root; 859 ihandle root;
860 prom_arg_t ret; 860 prom_arg_t ret;
861 __be32 *cores; 861 u32 cores;
862 unsigned char *ptcores;
862 863
863 root = call_prom("open", 1, 1, ADDR("/")); 864 root = call_prom("open", 1, 1, ADDR("/"));
864 if (root != 0) { 865 if (root != 0) {
@@ -868,15 +869,30 @@ static void __init prom_send_capabilities(void)
868 * (we assume this is the same for all cores) and use it to 869 * (we assume this is the same for all cores) and use it to
869 * divide NR_CPUS. 870 * divide NR_CPUS.
870 */ 871 */
871 cores = (__be32 *)&ibm_architecture_vec[IBM_ARCH_VEC_NRCORES_OFFSET]; 872
872 if (be32_to_cpup(cores) != NR_CPUS) { 873 /* The core value may start at an odd address. If such a word
874 * access is made at a cache line boundary, this leads to an
875 * exception which may not be handled at this time.
876 * Forcing a per byte access to avoid exception.
877 */
878 ptcores = &ibm_architecture_vec[IBM_ARCH_VEC_NRCORES_OFFSET];
879 cores = 0;
880 cores |= ptcores[0] << 24;
881 cores |= ptcores[1] << 16;
882 cores |= ptcores[2] << 8;
883 cores |= ptcores[3];
884 if (cores != NR_CPUS) {
873 prom_printf("WARNING ! " 885 prom_printf("WARNING ! "
874 "ibm_architecture_vec structure inconsistent: %lu!\n", 886 "ibm_architecture_vec structure inconsistent: %lu!\n",
875 be32_to_cpup(cores)); 887 cores);
876 } else { 888 } else {
877 *cores = cpu_to_be32(DIV_ROUND_UP(NR_CPUS, prom_count_smt_threads())); 889 cores = DIV_ROUND_UP(NR_CPUS, prom_count_smt_threads());
878 prom_printf("Max number of cores passed to firmware: %lu (NR_CPUS = %lu)\n", 890 prom_printf("Max number of cores passed to firmware: %lu (NR_CPUS = %lu)\n",
879 be32_to_cpup(cores), NR_CPUS); 891 cores, NR_CPUS);
892 ptcores[0] = (cores >> 24) & 0xff;
893 ptcores[1] = (cores >> 16) & 0xff;
894 ptcores[2] = (cores >> 8) & 0xff;
895 ptcores[3] = cores & 0xff;
880 } 896 }
881 897
882 /* try calling the ibm,client-architecture-support method */ 898 /* try calling the ibm,client-architecture-support method */
diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
index 9a0d24c390a3..75fb40498b41 100644
--- a/arch/powerpc/kernel/ptrace.c
+++ b/arch/powerpc/kernel/ptrace.c
@@ -362,7 +362,7 @@ static int fpr_get(struct task_struct *target, const struct user_regset *regset,
362 void *kbuf, void __user *ubuf) 362 void *kbuf, void __user *ubuf)
363{ 363{
364#ifdef CONFIG_VSX 364#ifdef CONFIG_VSX
365 double buf[33]; 365 u64 buf[33];
366 int i; 366 int i;
367#endif 367#endif
368 flush_fp_to_thread(target); 368 flush_fp_to_thread(target);
@@ -371,15 +371,15 @@ static int fpr_get(struct task_struct *target, const struct user_regset *regset,
371 /* copy to local buffer then write that out */ 371 /* copy to local buffer then write that out */
372 for (i = 0; i < 32 ; i++) 372 for (i = 0; i < 32 ; i++)
373 buf[i] = target->thread.TS_FPR(i); 373 buf[i] = target->thread.TS_FPR(i);
374 memcpy(&buf[32], &target->thread.fpscr, sizeof(double)); 374 buf[32] = target->thread.fp_state.fpscr;
375 return user_regset_copyout(&pos, &count, &kbuf, &ubuf, buf, 0, -1); 375 return user_regset_copyout(&pos, &count, &kbuf, &ubuf, buf, 0, -1);
376 376
377#else 377#else
378 BUILD_BUG_ON(offsetof(struct thread_struct, fpscr) != 378 BUILD_BUG_ON(offsetof(struct thread_fp_state, fpscr) !=
379 offsetof(struct thread_struct, TS_FPR(32))); 379 offsetof(struct thread_fp_state, fpr[32][0]));
380 380
381 return user_regset_copyout(&pos, &count, &kbuf, &ubuf, 381 return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
382 &target->thread.fpr, 0, -1); 382 &target->thread.fp_state, 0, -1);
383#endif 383#endif
384} 384}
385 385
@@ -388,7 +388,7 @@ static int fpr_set(struct task_struct *target, const struct user_regset *regset,
388 const void *kbuf, const void __user *ubuf) 388 const void *kbuf, const void __user *ubuf)
389{ 389{
390#ifdef CONFIG_VSX 390#ifdef CONFIG_VSX
391 double buf[33]; 391 u64 buf[33];
392 int i; 392 int i;
393#endif 393#endif
394 flush_fp_to_thread(target); 394 flush_fp_to_thread(target);
@@ -400,14 +400,14 @@ static int fpr_set(struct task_struct *target, const struct user_regset *regset,
400 return i; 400 return i;
401 for (i = 0; i < 32 ; i++) 401 for (i = 0; i < 32 ; i++)
402 target->thread.TS_FPR(i) = buf[i]; 402 target->thread.TS_FPR(i) = buf[i];
403 memcpy(&target->thread.fpscr, &buf[32], sizeof(double)); 403 target->thread.fp_state.fpscr = buf[32];
404 return 0; 404 return 0;
405#else 405#else
406 BUILD_BUG_ON(offsetof(struct thread_struct, fpscr) != 406 BUILD_BUG_ON(offsetof(struct thread_fp_state, fpscr) !=
407 offsetof(struct thread_struct, TS_FPR(32))); 407 offsetof(struct thread_fp_state, fpr[32][0]));
408 408
409 return user_regset_copyin(&pos, &count, &kbuf, &ubuf, 409 return user_regset_copyin(&pos, &count, &kbuf, &ubuf,
410 &target->thread.fpr, 0, -1); 410 &target->thread.fp_state, 0, -1);
411#endif 411#endif
412} 412}
413 413
@@ -440,11 +440,11 @@ static int vr_get(struct task_struct *target, const struct user_regset *regset,
440 440
441 flush_altivec_to_thread(target); 441 flush_altivec_to_thread(target);
442 442
443 BUILD_BUG_ON(offsetof(struct thread_struct, vscr) != 443 BUILD_BUG_ON(offsetof(struct thread_vr_state, vscr) !=
444 offsetof(struct thread_struct, vr[32])); 444 offsetof(struct thread_vr_state, vr[32]));
445 445
446 ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, 446 ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
447 &target->thread.vr, 0, 447 &target->thread.vr_state, 0,
448 33 * sizeof(vector128)); 448 33 * sizeof(vector128));
449 if (!ret) { 449 if (!ret) {
450 /* 450 /*
@@ -471,11 +471,12 @@ static int vr_set(struct task_struct *target, const struct user_regset *regset,
471 471
472 flush_altivec_to_thread(target); 472 flush_altivec_to_thread(target);
473 473
474 BUILD_BUG_ON(offsetof(struct thread_struct, vscr) != 474 BUILD_BUG_ON(offsetof(struct thread_vr_state, vscr) !=
475 offsetof(struct thread_struct, vr[32])); 475 offsetof(struct thread_vr_state, vr[32]));
476 476
477 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, 477 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
478 &target->thread.vr, 0, 33 * sizeof(vector128)); 478 &target->thread.vr_state, 0,
479 33 * sizeof(vector128));
479 if (!ret && count > 0) { 480 if (!ret && count > 0) {
480 /* 481 /*
481 * We use only the first word of vrsave. 482 * We use only the first word of vrsave.
@@ -514,13 +515,13 @@ static int vsr_get(struct task_struct *target, const struct user_regset *regset,
514 unsigned int pos, unsigned int count, 515 unsigned int pos, unsigned int count,
515 void *kbuf, void __user *ubuf) 516 void *kbuf, void __user *ubuf)
516{ 517{
517 double buf[32]; 518 u64 buf[32];
518 int ret, i; 519 int ret, i;
519 520
520 flush_vsx_to_thread(target); 521 flush_vsx_to_thread(target);
521 522
522 for (i = 0; i < 32 ; i++) 523 for (i = 0; i < 32 ; i++)
523 buf[i] = target->thread.fpr[i][TS_VSRLOWOFFSET]; 524 buf[i] = target->thread.fp_state.fpr[i][TS_VSRLOWOFFSET];
524 ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, 525 ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
525 buf, 0, 32 * sizeof(double)); 526 buf, 0, 32 * sizeof(double));
526 527
@@ -531,7 +532,7 @@ static int vsr_set(struct task_struct *target, const struct user_regset *regset,
531 unsigned int pos, unsigned int count, 532 unsigned int pos, unsigned int count,
532 const void *kbuf, const void __user *ubuf) 533 const void *kbuf, const void __user *ubuf)
533{ 534{
534 double buf[32]; 535 u64 buf[32];
535 int ret,i; 536 int ret,i;
536 537
537 flush_vsx_to_thread(target); 538 flush_vsx_to_thread(target);
@@ -539,7 +540,7 @@ static int vsr_set(struct task_struct *target, const struct user_regset *regset,
539 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, 540 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
540 buf, 0, 32 * sizeof(double)); 541 buf, 0, 32 * sizeof(double));
541 for (i = 0; i < 32 ; i++) 542 for (i = 0; i < 32 ; i++)
542 target->thread.fpr[i][TS_VSRLOWOFFSET] = buf[i]; 543 target->thread.fp_state.fpr[i][TS_VSRLOWOFFSET] = buf[i];
543 544
544 545
545 return ret; 546 return ret;
@@ -657,7 +658,7 @@ static const struct user_regset native_regsets[] = {
657#endif 658#endif
658#ifdef CONFIG_SPE 659#ifdef CONFIG_SPE
659 [REGSET_SPE] = { 660 [REGSET_SPE] = {
660 .n = 35, 661 .core_note_type = NT_PPC_SPE, .n = 35,
661 .size = sizeof(u32), .align = sizeof(u32), 662 .size = sizeof(u32), .align = sizeof(u32),
662 .active = evr_active, .get = evr_get, .set = evr_set 663 .active = evr_active, .get = evr_get, .set = evr_set
663 }, 664 },
@@ -854,8 +855,8 @@ void user_enable_single_step(struct task_struct *task)
854 855
855 if (regs != NULL) { 856 if (regs != NULL) {
856#ifdef CONFIG_PPC_ADV_DEBUG_REGS 857#ifdef CONFIG_PPC_ADV_DEBUG_REGS
857 task->thread.dbcr0 &= ~DBCR0_BT; 858 task->thread.debug.dbcr0 &= ~DBCR0_BT;
858 task->thread.dbcr0 |= DBCR0_IDM | DBCR0_IC; 859 task->thread.debug.dbcr0 |= DBCR0_IDM | DBCR0_IC;
859 regs->msr |= MSR_DE; 860 regs->msr |= MSR_DE;
860#else 861#else
861 regs->msr &= ~MSR_BE; 862 regs->msr &= ~MSR_BE;
@@ -871,8 +872,8 @@ void user_enable_block_step(struct task_struct *task)
871 872
872 if (regs != NULL) { 873 if (regs != NULL) {
873#ifdef CONFIG_PPC_ADV_DEBUG_REGS 874#ifdef CONFIG_PPC_ADV_DEBUG_REGS
874 task->thread.dbcr0 &= ~DBCR0_IC; 875 task->thread.debug.dbcr0 &= ~DBCR0_IC;
875 task->thread.dbcr0 = DBCR0_IDM | DBCR0_BT; 876 task->thread.debug.dbcr0 = DBCR0_IDM | DBCR0_BT;
876 regs->msr |= MSR_DE; 877 regs->msr |= MSR_DE;
877#else 878#else
878 regs->msr &= ~MSR_SE; 879 regs->msr &= ~MSR_SE;
@@ -894,16 +895,16 @@ void user_disable_single_step(struct task_struct *task)
894 * And, after doing so, if all debug flags are off, turn 895 * And, after doing so, if all debug flags are off, turn
895 * off DBCR0(IDM) and MSR(DE) .... Torez 896 * off DBCR0(IDM) and MSR(DE) .... Torez
896 */ 897 */
897 task->thread.dbcr0 &= ~DBCR0_IC; 898 task->thread.debug.dbcr0 &= ~(DBCR0_IC|DBCR0_BT);
898 /* 899 /*
899 * Test to see if any of the DBCR_ACTIVE_EVENTS bits are set. 900 * Test to see if any of the DBCR_ACTIVE_EVENTS bits are set.
900 */ 901 */
901 if (!DBCR_ACTIVE_EVENTS(task->thread.dbcr0, 902 if (!DBCR_ACTIVE_EVENTS(task->thread.debug.dbcr0,
902 task->thread.dbcr1)) { 903 task->thread.debug.dbcr1)) {
903 /* 904 /*
904 * All debug events were off..... 905 * All debug events were off.....
905 */ 906 */
906 task->thread.dbcr0 &= ~DBCR0_IDM; 907 task->thread.debug.dbcr0 &= ~DBCR0_IDM;
907 regs->msr &= ~MSR_DE; 908 regs->msr &= ~MSR_DE;
908 } 909 }
909#else 910#else
@@ -1022,14 +1023,14 @@ int ptrace_set_debugreg(struct task_struct *task, unsigned long addr,
1022 */ 1023 */
1023 1024
1024 /* DAC's hold the whole address without any mode flags */ 1025 /* DAC's hold the whole address without any mode flags */
1025 task->thread.dac1 = data & ~0x3UL; 1026 task->thread.debug.dac1 = data & ~0x3UL;
1026 1027
1027 if (task->thread.dac1 == 0) { 1028 if (task->thread.debug.dac1 == 0) {
1028 dbcr_dac(task) &= ~(DBCR_DAC1R | DBCR_DAC1W); 1029 dbcr_dac(task) &= ~(DBCR_DAC1R | DBCR_DAC1W);
1029 if (!DBCR_ACTIVE_EVENTS(task->thread.dbcr0, 1030 if (!DBCR_ACTIVE_EVENTS(task->thread.debug.dbcr0,
1030 task->thread.dbcr1)) { 1031 task->thread.debug.dbcr1)) {
1031 task->thread.regs->msr &= ~MSR_DE; 1032 task->thread.regs->msr &= ~MSR_DE;
1032 task->thread.dbcr0 &= ~DBCR0_IDM; 1033 task->thread.debug.dbcr0 &= ~DBCR0_IDM;
1033 } 1034 }
1034 return 0; 1035 return 0;
1035 } 1036 }
@@ -1041,7 +1042,7 @@ int ptrace_set_debugreg(struct task_struct *task, unsigned long addr,
1041 1042
1042 /* Set the Internal Debugging flag (IDM bit 1) for the DBCR0 1043 /* Set the Internal Debugging flag (IDM bit 1) for the DBCR0
1043 register */ 1044 register */
1044 task->thread.dbcr0 |= DBCR0_IDM; 1045 task->thread.debug.dbcr0 |= DBCR0_IDM;
1045 1046
1046 /* Check for write and read flags and set DBCR0 1047 /* Check for write and read flags and set DBCR0
1047 accordingly */ 1048 accordingly */
@@ -1071,10 +1072,10 @@ static long set_instruction_bp(struct task_struct *child,
1071 struct ppc_hw_breakpoint *bp_info) 1072 struct ppc_hw_breakpoint *bp_info)
1072{ 1073{
1073 int slot; 1074 int slot;
1074 int slot1_in_use = ((child->thread.dbcr0 & DBCR0_IAC1) != 0); 1075 int slot1_in_use = ((child->thread.debug.dbcr0 & DBCR0_IAC1) != 0);
1075 int slot2_in_use = ((child->thread.dbcr0 & DBCR0_IAC2) != 0); 1076 int slot2_in_use = ((child->thread.debug.dbcr0 & DBCR0_IAC2) != 0);
1076 int slot3_in_use = ((child->thread.dbcr0 & DBCR0_IAC3) != 0); 1077 int slot3_in_use = ((child->thread.debug.dbcr0 & DBCR0_IAC3) != 0);
1077 int slot4_in_use = ((child->thread.dbcr0 & DBCR0_IAC4) != 0); 1078 int slot4_in_use = ((child->thread.debug.dbcr0 & DBCR0_IAC4) != 0);
1078 1079
1079 if (dbcr_iac_range(child) & DBCR_IAC12MODE) 1080 if (dbcr_iac_range(child) & DBCR_IAC12MODE)
1080 slot2_in_use = 1; 1081 slot2_in_use = 1;
@@ -1093,9 +1094,9 @@ static long set_instruction_bp(struct task_struct *child,
1093 /* We need a pair of IAC regsisters */ 1094 /* We need a pair of IAC regsisters */
1094 if ((!slot1_in_use) && (!slot2_in_use)) { 1095 if ((!slot1_in_use) && (!slot2_in_use)) {
1095 slot = 1; 1096 slot = 1;
1096 child->thread.iac1 = bp_info->addr; 1097 child->thread.debug.iac1 = bp_info->addr;
1097 child->thread.iac2 = bp_info->addr2; 1098 child->thread.debug.iac2 = bp_info->addr2;
1098 child->thread.dbcr0 |= DBCR0_IAC1; 1099 child->thread.debug.dbcr0 |= DBCR0_IAC1;
1099 if (bp_info->addr_mode == 1100 if (bp_info->addr_mode ==
1100 PPC_BREAKPOINT_MODE_RANGE_EXCLUSIVE) 1101 PPC_BREAKPOINT_MODE_RANGE_EXCLUSIVE)
1101 dbcr_iac_range(child) |= DBCR_IAC12X; 1102 dbcr_iac_range(child) |= DBCR_IAC12X;
@@ -1104,9 +1105,9 @@ static long set_instruction_bp(struct task_struct *child,
1104#if CONFIG_PPC_ADV_DEBUG_IACS > 2 1105#if CONFIG_PPC_ADV_DEBUG_IACS > 2
1105 } else if ((!slot3_in_use) && (!slot4_in_use)) { 1106 } else if ((!slot3_in_use) && (!slot4_in_use)) {
1106 slot = 3; 1107 slot = 3;
1107 child->thread.iac3 = bp_info->addr; 1108 child->thread.debug.iac3 = bp_info->addr;
1108 child->thread.iac4 = bp_info->addr2; 1109 child->thread.debug.iac4 = bp_info->addr2;
1109 child->thread.dbcr0 |= DBCR0_IAC3; 1110 child->thread.debug.dbcr0 |= DBCR0_IAC3;
1110 if (bp_info->addr_mode == 1111 if (bp_info->addr_mode ==
1111 PPC_BREAKPOINT_MODE_RANGE_EXCLUSIVE) 1112 PPC_BREAKPOINT_MODE_RANGE_EXCLUSIVE)
1112 dbcr_iac_range(child) |= DBCR_IAC34X; 1113 dbcr_iac_range(child) |= DBCR_IAC34X;
@@ -1126,30 +1127,30 @@ static long set_instruction_bp(struct task_struct *child,
1126 */ 1127 */
1127 if (slot2_in_use || (slot3_in_use == slot4_in_use)) { 1128 if (slot2_in_use || (slot3_in_use == slot4_in_use)) {
1128 slot = 1; 1129 slot = 1;
1129 child->thread.iac1 = bp_info->addr; 1130 child->thread.debug.iac1 = bp_info->addr;
1130 child->thread.dbcr0 |= DBCR0_IAC1; 1131 child->thread.debug.dbcr0 |= DBCR0_IAC1;
1131 goto out; 1132 goto out;
1132 } 1133 }
1133 } 1134 }
1134 if (!slot2_in_use) { 1135 if (!slot2_in_use) {
1135 slot = 2; 1136 slot = 2;
1136 child->thread.iac2 = bp_info->addr; 1137 child->thread.debug.iac2 = bp_info->addr;
1137 child->thread.dbcr0 |= DBCR0_IAC2; 1138 child->thread.debug.dbcr0 |= DBCR0_IAC2;
1138#if CONFIG_PPC_ADV_DEBUG_IACS > 2 1139#if CONFIG_PPC_ADV_DEBUG_IACS > 2
1139 } else if (!slot3_in_use) { 1140 } else if (!slot3_in_use) {
1140 slot = 3; 1141 slot = 3;
1141 child->thread.iac3 = bp_info->addr; 1142 child->thread.debug.iac3 = bp_info->addr;
1142 child->thread.dbcr0 |= DBCR0_IAC3; 1143 child->thread.debug.dbcr0 |= DBCR0_IAC3;
1143 } else if (!slot4_in_use) { 1144 } else if (!slot4_in_use) {
1144 slot = 4; 1145 slot = 4;
1145 child->thread.iac4 = bp_info->addr; 1146 child->thread.debug.iac4 = bp_info->addr;
1146 child->thread.dbcr0 |= DBCR0_IAC4; 1147 child->thread.debug.dbcr0 |= DBCR0_IAC4;
1147#endif 1148#endif
1148 } else 1149 } else
1149 return -ENOSPC; 1150 return -ENOSPC;
1150 } 1151 }
1151out: 1152out:
1152 child->thread.dbcr0 |= DBCR0_IDM; 1153 child->thread.debug.dbcr0 |= DBCR0_IDM;
1153 child->thread.regs->msr |= MSR_DE; 1154 child->thread.regs->msr |= MSR_DE;
1154 1155
1155 return slot; 1156 return slot;
@@ -1159,49 +1160,49 @@ static int del_instruction_bp(struct task_struct *child, int slot)
1159{ 1160{
1160 switch (slot) { 1161 switch (slot) {
1161 case 1: 1162 case 1:
1162 if ((child->thread.dbcr0 & DBCR0_IAC1) == 0) 1163 if ((child->thread.debug.dbcr0 & DBCR0_IAC1) == 0)
1163 return -ENOENT; 1164 return -ENOENT;
1164 1165
1165 if (dbcr_iac_range(child) & DBCR_IAC12MODE) { 1166 if (dbcr_iac_range(child) & DBCR_IAC12MODE) {
1166 /* address range - clear slots 1 & 2 */ 1167 /* address range - clear slots 1 & 2 */
1167 child->thread.iac2 = 0; 1168 child->thread.debug.iac2 = 0;
1168 dbcr_iac_range(child) &= ~DBCR_IAC12MODE; 1169 dbcr_iac_range(child) &= ~DBCR_IAC12MODE;
1169 } 1170 }
1170 child->thread.iac1 = 0; 1171 child->thread.debug.iac1 = 0;
1171 child->thread.dbcr0 &= ~DBCR0_IAC1; 1172 child->thread.debug.dbcr0 &= ~DBCR0_IAC1;
1172 break; 1173 break;
1173 case 2: 1174 case 2:
1174 if ((child->thread.dbcr0 & DBCR0_IAC2) == 0) 1175 if ((child->thread.debug.dbcr0 & DBCR0_IAC2) == 0)
1175 return -ENOENT; 1176 return -ENOENT;
1176 1177
1177 if (dbcr_iac_range(child) & DBCR_IAC12MODE) 1178 if (dbcr_iac_range(child) & DBCR_IAC12MODE)
1178 /* used in a range */ 1179 /* used in a range */
1179 return -EINVAL; 1180 return -EINVAL;
1180 child->thread.iac2 = 0; 1181 child->thread.debug.iac2 = 0;
1181 child->thread.dbcr0 &= ~DBCR0_IAC2; 1182 child->thread.debug.dbcr0 &= ~DBCR0_IAC2;
1182 break; 1183 break;
1183#if CONFIG_PPC_ADV_DEBUG_IACS > 2 1184#if CONFIG_PPC_ADV_DEBUG_IACS > 2
1184 case 3: 1185 case 3:
1185 if ((child->thread.dbcr0 & DBCR0_IAC3) == 0) 1186 if ((child->thread.debug.dbcr0 & DBCR0_IAC3) == 0)
1186 return -ENOENT; 1187 return -ENOENT;
1187 1188
1188 if (dbcr_iac_range(child) & DBCR_IAC34MODE) { 1189 if (dbcr_iac_range(child) & DBCR_IAC34MODE) {
1189 /* address range - clear slots 3 & 4 */ 1190 /* address range - clear slots 3 & 4 */
1190 child->thread.iac4 = 0; 1191 child->thread.debug.iac4 = 0;
1191 dbcr_iac_range(child) &= ~DBCR_IAC34MODE; 1192 dbcr_iac_range(child) &= ~DBCR_IAC34MODE;
1192 } 1193 }
1193 child->thread.iac3 = 0; 1194 child->thread.debug.iac3 = 0;
1194 child->thread.dbcr0 &= ~DBCR0_IAC3; 1195 child->thread.debug.dbcr0 &= ~DBCR0_IAC3;
1195 break; 1196 break;
1196 case 4: 1197 case 4:
1197 if ((child->thread.dbcr0 & DBCR0_IAC4) == 0) 1198 if ((child->thread.debug.dbcr0 & DBCR0_IAC4) == 0)
1198 return -ENOENT; 1199 return -ENOENT;
1199 1200
1200 if (dbcr_iac_range(child) & DBCR_IAC34MODE) 1201 if (dbcr_iac_range(child) & DBCR_IAC34MODE)
1201 /* Used in a range */ 1202 /* Used in a range */
1202 return -EINVAL; 1203 return -EINVAL;
1203 child->thread.iac4 = 0; 1204 child->thread.debug.iac4 = 0;
1204 child->thread.dbcr0 &= ~DBCR0_IAC4; 1205 child->thread.debug.dbcr0 &= ~DBCR0_IAC4;
1205 break; 1206 break;
1206#endif 1207#endif
1207 default: 1208 default:
@@ -1231,18 +1232,18 @@ static int set_dac(struct task_struct *child, struct ppc_hw_breakpoint *bp_info)
1231 dbcr_dac(child) |= DBCR_DAC1R; 1232 dbcr_dac(child) |= DBCR_DAC1R;
1232 if (bp_info->trigger_type & PPC_BREAKPOINT_TRIGGER_WRITE) 1233 if (bp_info->trigger_type & PPC_BREAKPOINT_TRIGGER_WRITE)
1233 dbcr_dac(child) |= DBCR_DAC1W; 1234 dbcr_dac(child) |= DBCR_DAC1W;
1234 child->thread.dac1 = (unsigned long)bp_info->addr; 1235 child->thread.debug.dac1 = (unsigned long)bp_info->addr;
1235#if CONFIG_PPC_ADV_DEBUG_DVCS > 0 1236#if CONFIG_PPC_ADV_DEBUG_DVCS > 0
1236 if (byte_enable) { 1237 if (byte_enable) {
1237 child->thread.dvc1 = 1238 child->thread.debug.dvc1 =
1238 (unsigned long)bp_info->condition_value; 1239 (unsigned long)bp_info->condition_value;
1239 child->thread.dbcr2 |= 1240 child->thread.debug.dbcr2 |=
1240 ((byte_enable << DBCR2_DVC1BE_SHIFT) | 1241 ((byte_enable << DBCR2_DVC1BE_SHIFT) |
1241 (condition_mode << DBCR2_DVC1M_SHIFT)); 1242 (condition_mode << DBCR2_DVC1M_SHIFT));
1242 } 1243 }
1243#endif 1244#endif
1244#ifdef CONFIG_PPC_ADV_DEBUG_DAC_RANGE 1245#ifdef CONFIG_PPC_ADV_DEBUG_DAC_RANGE
1245 } else if (child->thread.dbcr2 & DBCR2_DAC12MODE) { 1246 } else if (child->thread.debug.dbcr2 & DBCR2_DAC12MODE) {
1246 /* Both dac1 and dac2 are part of a range */ 1247 /* Both dac1 and dac2 are part of a range */
1247 return -ENOSPC; 1248 return -ENOSPC;
1248#endif 1249#endif
@@ -1252,19 +1253,19 @@ static int set_dac(struct task_struct *child, struct ppc_hw_breakpoint *bp_info)
1252 dbcr_dac(child) |= DBCR_DAC2R; 1253 dbcr_dac(child) |= DBCR_DAC2R;
1253 if (bp_info->trigger_type & PPC_BREAKPOINT_TRIGGER_WRITE) 1254 if (bp_info->trigger_type & PPC_BREAKPOINT_TRIGGER_WRITE)
1254 dbcr_dac(child) |= DBCR_DAC2W; 1255 dbcr_dac(child) |= DBCR_DAC2W;
1255 child->thread.dac2 = (unsigned long)bp_info->addr; 1256 child->thread.debug.dac2 = (unsigned long)bp_info->addr;
1256#if CONFIG_PPC_ADV_DEBUG_DVCS > 0 1257#if CONFIG_PPC_ADV_DEBUG_DVCS > 0
1257 if (byte_enable) { 1258 if (byte_enable) {
1258 child->thread.dvc2 = 1259 child->thread.debug.dvc2 =
1259 (unsigned long)bp_info->condition_value; 1260 (unsigned long)bp_info->condition_value;
1260 child->thread.dbcr2 |= 1261 child->thread.debug.dbcr2 |=
1261 ((byte_enable << DBCR2_DVC2BE_SHIFT) | 1262 ((byte_enable << DBCR2_DVC2BE_SHIFT) |
1262 (condition_mode << DBCR2_DVC2M_SHIFT)); 1263 (condition_mode << DBCR2_DVC2M_SHIFT));
1263 } 1264 }
1264#endif 1265#endif
1265 } else 1266 } else
1266 return -ENOSPC; 1267 return -ENOSPC;
1267 child->thread.dbcr0 |= DBCR0_IDM; 1268 child->thread.debug.dbcr0 |= DBCR0_IDM;
1268 child->thread.regs->msr |= MSR_DE; 1269 child->thread.regs->msr |= MSR_DE;
1269 1270
1270 return slot + 4; 1271 return slot + 4;
@@ -1276,32 +1277,32 @@ static int del_dac(struct task_struct *child, int slot)
1276 if ((dbcr_dac(child) & (DBCR_DAC1R | DBCR_DAC1W)) == 0) 1277 if ((dbcr_dac(child) & (DBCR_DAC1R | DBCR_DAC1W)) == 0)
1277 return -ENOENT; 1278 return -ENOENT;
1278 1279
1279 child->thread.dac1 = 0; 1280 child->thread.debug.dac1 = 0;
1280 dbcr_dac(child) &= ~(DBCR_DAC1R | DBCR_DAC1W); 1281 dbcr_dac(child) &= ~(DBCR_DAC1R | DBCR_DAC1W);
1281#ifdef CONFIG_PPC_ADV_DEBUG_DAC_RANGE 1282#ifdef CONFIG_PPC_ADV_DEBUG_DAC_RANGE
1282 if (child->thread.dbcr2 & DBCR2_DAC12MODE) { 1283 if (child->thread.debug.dbcr2 & DBCR2_DAC12MODE) {
1283 child->thread.dac2 = 0; 1284 child->thread.debug.dac2 = 0;
1284 child->thread.dbcr2 &= ~DBCR2_DAC12MODE; 1285 child->thread.debug.dbcr2 &= ~DBCR2_DAC12MODE;
1285 } 1286 }
1286 child->thread.dbcr2 &= ~(DBCR2_DVC1M | DBCR2_DVC1BE); 1287 child->thread.debug.dbcr2 &= ~(DBCR2_DVC1M | DBCR2_DVC1BE);
1287#endif 1288#endif
1288#if CONFIG_PPC_ADV_DEBUG_DVCS > 0 1289#if CONFIG_PPC_ADV_DEBUG_DVCS > 0
1289 child->thread.dvc1 = 0; 1290 child->thread.debug.dvc1 = 0;
1290#endif 1291#endif
1291 } else if (slot == 2) { 1292 } else if (slot == 2) {
1292 if ((dbcr_dac(child) & (DBCR_DAC2R | DBCR_DAC2W)) == 0) 1293 if ((dbcr_dac(child) & (DBCR_DAC2R | DBCR_DAC2W)) == 0)
1293 return -ENOENT; 1294 return -ENOENT;
1294 1295
1295#ifdef CONFIG_PPC_ADV_DEBUG_DAC_RANGE 1296#ifdef CONFIG_PPC_ADV_DEBUG_DAC_RANGE
1296 if (child->thread.dbcr2 & DBCR2_DAC12MODE) 1297 if (child->thread.debug.dbcr2 & DBCR2_DAC12MODE)
1297 /* Part of a range */ 1298 /* Part of a range */
1298 return -EINVAL; 1299 return -EINVAL;
1299 child->thread.dbcr2 &= ~(DBCR2_DVC2M | DBCR2_DVC2BE); 1300 child->thread.debug.dbcr2 &= ~(DBCR2_DVC2M | DBCR2_DVC2BE);
1300#endif 1301#endif
1301#if CONFIG_PPC_ADV_DEBUG_DVCS > 0 1302#if CONFIG_PPC_ADV_DEBUG_DVCS > 0
1302 child->thread.dvc2 = 0; 1303 child->thread.debug.dvc2 = 0;
1303#endif 1304#endif
1304 child->thread.dac2 = 0; 1305 child->thread.debug.dac2 = 0;
1305 dbcr_dac(child) &= ~(DBCR_DAC2R | DBCR_DAC2W); 1306 dbcr_dac(child) &= ~(DBCR_DAC2R | DBCR_DAC2W);
1306 } else 1307 } else
1307 return -EINVAL; 1308 return -EINVAL;
@@ -1343,22 +1344,22 @@ static int set_dac_range(struct task_struct *child,
1343 return -EIO; 1344 return -EIO;
1344 } 1345 }
1345 1346
1346 if (child->thread.dbcr0 & 1347 if (child->thread.debug.dbcr0 &
1347 (DBCR0_DAC1R | DBCR0_DAC1W | DBCR0_DAC2R | DBCR0_DAC2W)) 1348 (DBCR0_DAC1R | DBCR0_DAC1W | DBCR0_DAC2R | DBCR0_DAC2W))
1348 return -ENOSPC; 1349 return -ENOSPC;
1349 1350
1350 if (bp_info->trigger_type & PPC_BREAKPOINT_TRIGGER_READ) 1351 if (bp_info->trigger_type & PPC_BREAKPOINT_TRIGGER_READ)
1351 child->thread.dbcr0 |= (DBCR0_DAC1R | DBCR0_IDM); 1352 child->thread.debug.dbcr0 |= (DBCR0_DAC1R | DBCR0_IDM);
1352 if (bp_info->trigger_type & PPC_BREAKPOINT_TRIGGER_WRITE) 1353 if (bp_info->trigger_type & PPC_BREAKPOINT_TRIGGER_WRITE)
1353 child->thread.dbcr0 |= (DBCR0_DAC1W | DBCR0_IDM); 1354 child->thread.debug.dbcr0 |= (DBCR0_DAC1W | DBCR0_IDM);
1354 child->thread.dac1 = bp_info->addr; 1355 child->thread.debug.dac1 = bp_info->addr;
1355 child->thread.dac2 = bp_info->addr2; 1356 child->thread.debug.dac2 = bp_info->addr2;
1356 if (mode == PPC_BREAKPOINT_MODE_RANGE_INCLUSIVE) 1357 if (mode == PPC_BREAKPOINT_MODE_RANGE_INCLUSIVE)
1357 child->thread.dbcr2 |= DBCR2_DAC12M; 1358 child->thread.debug.dbcr2 |= DBCR2_DAC12M;
1358 else if (mode == PPC_BREAKPOINT_MODE_RANGE_EXCLUSIVE) 1359 else if (mode == PPC_BREAKPOINT_MODE_RANGE_EXCLUSIVE)
1359 child->thread.dbcr2 |= DBCR2_DAC12MX; 1360 child->thread.debug.dbcr2 |= DBCR2_DAC12MX;
1360 else /* PPC_BREAKPOINT_MODE_MASK */ 1361 else /* PPC_BREAKPOINT_MODE_MASK */
1361 child->thread.dbcr2 |= DBCR2_DAC12MM; 1362 child->thread.debug.dbcr2 |= DBCR2_DAC12MM;
1362 child->thread.regs->msr |= MSR_DE; 1363 child->thread.regs->msr |= MSR_DE;
1363 1364
1364 return 5; 1365 return 5;
@@ -1489,9 +1490,9 @@ static long ppc_del_hwdebug(struct task_struct *child, long data)
1489 rc = del_dac(child, (int)data - 4); 1490 rc = del_dac(child, (int)data - 4);
1490 1491
1491 if (!rc) { 1492 if (!rc) {
1492 if (!DBCR_ACTIVE_EVENTS(child->thread.dbcr0, 1493 if (!DBCR_ACTIVE_EVENTS(child->thread.debug.dbcr0,
1493 child->thread.dbcr1)) { 1494 child->thread.debug.dbcr1)) {
1494 child->thread.dbcr0 &= ~DBCR0_IDM; 1495 child->thread.debug.dbcr0 &= ~DBCR0_IDM;
1495 child->thread.regs->msr &= ~MSR_DE; 1496 child->thread.regs->msr &= ~MSR_DE;
1496 } 1497 }
1497 } 1498 }
@@ -1554,10 +1555,10 @@ long arch_ptrace(struct task_struct *child, long request,
1554 1555
1555 flush_fp_to_thread(child); 1556 flush_fp_to_thread(child);
1556 if (fpidx < (PT_FPSCR - PT_FPR0)) 1557 if (fpidx < (PT_FPSCR - PT_FPR0))
1557 tmp = ((unsigned long *)child->thread.fpr) 1558 memcpy(&tmp, &child->thread.fp_state.fpr,
1558 [fpidx * TS_FPRWIDTH]; 1559 sizeof(long));
1559 else 1560 else
1560 tmp = child->thread.fpscr.val; 1561 tmp = child->thread.fp_state.fpscr;
1561 } 1562 }
1562 ret = put_user(tmp, datalp); 1563 ret = put_user(tmp, datalp);
1563 break; 1564 break;
@@ -1587,10 +1588,10 @@ long arch_ptrace(struct task_struct *child, long request,
1587 1588
1588 flush_fp_to_thread(child); 1589 flush_fp_to_thread(child);
1589 if (fpidx < (PT_FPSCR - PT_FPR0)) 1590 if (fpidx < (PT_FPSCR - PT_FPR0))
1590 ((unsigned long *)child->thread.fpr) 1591 memcpy(&child->thread.fp_state.fpr, &data,
1591 [fpidx * TS_FPRWIDTH] = data; 1592 sizeof(long));
1592 else 1593 else
1593 child->thread.fpscr.val = data; 1594 child->thread.fp_state.fpscr = data;
1594 ret = 0; 1595 ret = 0;
1595 } 1596 }
1596 break; 1597 break;
@@ -1669,7 +1670,7 @@ long arch_ptrace(struct task_struct *child, long request,
1669 if (addr > 0) 1670 if (addr > 0)
1670 break; 1671 break;
1671#ifdef CONFIG_PPC_ADV_DEBUG_REGS 1672#ifdef CONFIG_PPC_ADV_DEBUG_REGS
1672 ret = put_user(child->thread.dac1, datalp); 1673 ret = put_user(child->thread.debug.dac1, datalp);
1673#else 1674#else
1674 dabr_fake = ((child->thread.hw_brk.address & (~HW_BRK_TYPE_DABR)) | 1675 dabr_fake = ((child->thread.hw_brk.address & (~HW_BRK_TYPE_DABR)) |
1675 (child->thread.hw_brk.type & HW_BRK_TYPE_DABR)); 1676 (child->thread.hw_brk.type & HW_BRK_TYPE_DABR));
diff --git a/arch/powerpc/kernel/ptrace32.c b/arch/powerpc/kernel/ptrace32.c
index f51599e941c7..f52b7db327c8 100644
--- a/arch/powerpc/kernel/ptrace32.c
+++ b/arch/powerpc/kernel/ptrace32.c
@@ -43,7 +43,6 @@
43#define FPRNUMBER(i) (((i) - PT_FPR0) >> 1) 43#define FPRNUMBER(i) (((i) - PT_FPR0) >> 1)
44#define FPRHALF(i) (((i) - PT_FPR0) & 1) 44#define FPRHALF(i) (((i) - PT_FPR0) & 1)
45#define FPRINDEX(i) TS_FPRWIDTH * FPRNUMBER(i) * 2 + FPRHALF(i) 45#define FPRINDEX(i) TS_FPRWIDTH * FPRNUMBER(i) * 2 + FPRHALF(i)
46#define FPRINDEX_3264(i) (TS_FPRWIDTH * ((i) - PT_FPR0))
47 46
48long compat_arch_ptrace(struct task_struct *child, compat_long_t request, 47long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
49 compat_ulong_t caddr, compat_ulong_t cdata) 48 compat_ulong_t caddr, compat_ulong_t cdata)
@@ -105,7 +104,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
105 * to be an array of unsigned int (32 bits) - the 104 * to be an array of unsigned int (32 bits) - the
106 * index passed in is based on this assumption. 105 * index passed in is based on this assumption.
107 */ 106 */
108 tmp = ((unsigned int *)child->thread.fpr) 107 tmp = ((unsigned int *)child->thread.fp_state.fpr)
109 [FPRINDEX(index)]; 108 [FPRINDEX(index)];
110 } 109 }
111 ret = put_user((unsigned int)tmp, (u32 __user *)data); 110 ret = put_user((unsigned int)tmp, (u32 __user *)data);
@@ -147,8 +146,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
147 if (numReg >= PT_FPR0) { 146 if (numReg >= PT_FPR0) {
148 flush_fp_to_thread(child); 147 flush_fp_to_thread(child);
149 /* get 64 bit FPR */ 148 /* get 64 bit FPR */
150 tmp = ((u64 *)child->thread.fpr) 149 tmp = child->thread.fp_state.fpr[numReg - PT_FPR0][0];
151 [FPRINDEX_3264(numReg)];
152 } else { /* register within PT_REGS struct */ 150 } else { /* register within PT_REGS struct */
153 unsigned long tmp2; 151 unsigned long tmp2;
154 ret = ptrace_get_reg(child, numReg, &tmp2); 152 ret = ptrace_get_reg(child, numReg, &tmp2);
@@ -207,7 +205,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
207 * to be an array of unsigned int (32 bits) - the 205 * to be an array of unsigned int (32 bits) - the
208 * index passed in is based on this assumption. 206 * index passed in is based on this assumption.
209 */ 207 */
210 ((unsigned int *)child->thread.fpr) 208 ((unsigned int *)child->thread.fp_state.fpr)
211 [FPRINDEX(index)] = data; 209 [FPRINDEX(index)] = data;
212 ret = 0; 210 ret = 0;
213 } 211 }
@@ -251,8 +249,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
251 u64 *tmp; 249 u64 *tmp;
252 flush_fp_to_thread(child); 250 flush_fp_to_thread(child);
253 /* get 64 bit FPR ... */ 251 /* get 64 bit FPR ... */
254 tmp = &(((u64 *)child->thread.fpr) 252 tmp = &child->thread.fp_state.fpr[numReg - PT_FPR0][0];
255 [FPRINDEX_3264(numReg)]);
256 /* ... write the 32 bit part we want */ 253 /* ... write the 32 bit part we want */
257 ((u32 *)tmp)[index % 2] = data; 254 ((u32 *)tmp)[index % 2] = data;
258 ret = 0; 255 ret = 0;
@@ -269,7 +266,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
269 if (addr > 0) 266 if (addr > 0)
270 break; 267 break;
271#ifdef CONFIG_PPC_ADV_DEBUG_REGS 268#ifdef CONFIG_PPC_ADV_DEBUG_REGS
272 ret = put_user(child->thread.dac1, (u32 __user *)data); 269 ret = put_user(child->thread.debug.dac1, (u32 __user *)data);
273#else 270#else
274 dabr_fake = ( 271 dabr_fake = (
275 (child->thread.hw_brk.address & (~HW_BRK_TYPE_DABR)) | 272 (child->thread.hw_brk.address & (~HW_BRK_TYPE_DABR)) |
diff --git a/arch/powerpc/kernel/rtas_pci.c b/arch/powerpc/kernel/rtas_pci.c
index 6e7b7cdeec65..7d4c7172f38e 100644
--- a/arch/powerpc/kernel/rtas_pci.c
+++ b/arch/powerpc/kernel/rtas_pci.c
@@ -223,7 +223,7 @@ unsigned long get_phb_buid(struct device_node *phb)
223static int phb_set_bus_ranges(struct device_node *dev, 223static int phb_set_bus_ranges(struct device_node *dev,
224 struct pci_controller *phb) 224 struct pci_controller *phb)
225{ 225{
226 const int *bus_range; 226 const __be32 *bus_range;
227 unsigned int len; 227 unsigned int len;
228 228
229 bus_range = of_get_property(dev, "bus-range", &len); 229 bus_range = of_get_property(dev, "bus-range", &len);
@@ -231,8 +231,8 @@ static int phb_set_bus_ranges(struct device_node *dev,
231 return 1; 231 return 1;
232 } 232 }
233 233
234 phb->first_busno = bus_range[0]; 234 phb->first_busno = be32_to_cpu(bus_range[0]);
235 phb->last_busno = bus_range[1]; 235 phb->last_busno = be32_to_cpu(bus_range[1]);
236 236
237 return 0; 237 return 0;
238} 238}
diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
index 3d261c071fc8..febc80445d25 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -62,8 +62,6 @@
62#include <mm/mmu_decl.h> 62#include <mm/mmu_decl.h>
63#include <asm/fadump.h> 63#include <asm/fadump.h>
64 64
65#include "setup.h"
66
67#ifdef DEBUG 65#ifdef DEBUG
68#include <asm/udbg.h> 66#include <asm/udbg.h>
69#define DBG(fmt...) udbg_printf(fmt) 67#define DBG(fmt...) udbg_printf(fmt)
diff --git a/arch/powerpc/kernel/setup.h b/arch/powerpc/kernel/setup.h
deleted file mode 100644
index 4c67ad7fae08..000000000000
--- a/arch/powerpc/kernel/setup.h
+++ /dev/null
@@ -1,9 +0,0 @@
1#ifndef _POWERPC_KERNEL_SETUP_H
2#define _POWERPC_KERNEL_SETUP_H
3
4void check_for_initrd(void);
5void do_init_bootmem(void);
6void setup_panic(void);
7extern int do_early_xmon;
8
9#endif /* _POWERPC_KERNEL_SETUP_H */
diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c
index a4bbcae72578..b903dc5cf944 100644
--- a/arch/powerpc/kernel/setup_32.c
+++ b/arch/powerpc/kernel/setup_32.c
@@ -40,8 +40,6 @@
40#include <asm/mmu_context.h> 40#include <asm/mmu_context.h>
41#include <asm/epapr_hcalls.h> 41#include <asm/epapr_hcalls.h>
42 42
43#include "setup.h"
44
45#define DBG(fmt...) 43#define DBG(fmt...)
46 44
47extern void bootx_init(unsigned long r4, unsigned long phys); 45extern void bootx_init(unsigned long r4, unsigned long phys);
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index 278ca93e1f28..4085aaa9478f 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -68,8 +68,6 @@
68#include <asm/hugetlb.h> 68#include <asm/hugetlb.h>
69#include <asm/epapr_hcalls.h> 69#include <asm/epapr_hcalls.h>
70 70
71#include "setup.h"
72
73#ifdef DEBUG 71#ifdef DEBUG
74#define DBG(fmt...) udbg_printf(fmt) 72#define DBG(fmt...) udbg_printf(fmt)
75#else 73#else
diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
index bebdf1a1a540..1a410aa57fb7 100644
--- a/arch/powerpc/kernel/signal_32.c
+++ b/arch/powerpc/kernel/signal_32.c
@@ -265,27 +265,27 @@ struct rt_sigframe {
265unsigned long copy_fpr_to_user(void __user *to, 265unsigned long copy_fpr_to_user(void __user *to,
266 struct task_struct *task) 266 struct task_struct *task)
267{ 267{
268 double buf[ELF_NFPREG]; 268 u64 buf[ELF_NFPREG];
269 int i; 269 int i;
270 270
271 /* save FPR copy to local buffer then write to the thread_struct */ 271 /* save FPR copy to local buffer then write to the thread_struct */
272 for (i = 0; i < (ELF_NFPREG - 1) ; i++) 272 for (i = 0; i < (ELF_NFPREG - 1) ; i++)
273 buf[i] = task->thread.TS_FPR(i); 273 buf[i] = task->thread.TS_FPR(i);
274 memcpy(&buf[i], &task->thread.fpscr, sizeof(double)); 274 buf[i] = task->thread.fp_state.fpscr;
275 return __copy_to_user(to, buf, ELF_NFPREG * sizeof(double)); 275 return __copy_to_user(to, buf, ELF_NFPREG * sizeof(double));
276} 276}
277 277
278unsigned long copy_fpr_from_user(struct task_struct *task, 278unsigned long copy_fpr_from_user(struct task_struct *task,
279 void __user *from) 279 void __user *from)
280{ 280{
281 double buf[ELF_NFPREG]; 281 u64 buf[ELF_NFPREG];
282 int i; 282 int i;
283 283
284 if (__copy_from_user(buf, from, ELF_NFPREG * sizeof(double))) 284 if (__copy_from_user(buf, from, ELF_NFPREG * sizeof(double)))
285 return 1; 285 return 1;
286 for (i = 0; i < (ELF_NFPREG - 1) ; i++) 286 for (i = 0; i < (ELF_NFPREG - 1) ; i++)
287 task->thread.TS_FPR(i) = buf[i]; 287 task->thread.TS_FPR(i) = buf[i];
288 memcpy(&task->thread.fpscr, &buf[i], sizeof(double)); 288 task->thread.fp_state.fpscr = buf[i];
289 289
290 return 0; 290 return 0;
291} 291}
@@ -293,25 +293,25 @@ unsigned long copy_fpr_from_user(struct task_struct *task,
293unsigned long copy_vsx_to_user(void __user *to, 293unsigned long copy_vsx_to_user(void __user *to,
294 struct task_struct *task) 294 struct task_struct *task)
295{ 295{
296 double buf[ELF_NVSRHALFREG]; 296 u64 buf[ELF_NVSRHALFREG];
297 int i; 297 int i;
298 298
299 /* save FPR copy to local buffer then write to the thread_struct */ 299 /* save FPR copy to local buffer then write to the thread_struct */
300 for (i = 0; i < ELF_NVSRHALFREG; i++) 300 for (i = 0; i < ELF_NVSRHALFREG; i++)
301 buf[i] = task->thread.fpr[i][TS_VSRLOWOFFSET]; 301 buf[i] = task->thread.fp_state.fpr[i][TS_VSRLOWOFFSET];
302 return __copy_to_user(to, buf, ELF_NVSRHALFREG * sizeof(double)); 302 return __copy_to_user(to, buf, ELF_NVSRHALFREG * sizeof(double));
303} 303}
304 304
305unsigned long copy_vsx_from_user(struct task_struct *task, 305unsigned long copy_vsx_from_user(struct task_struct *task,
306 void __user *from) 306 void __user *from)
307{ 307{
308 double buf[ELF_NVSRHALFREG]; 308 u64 buf[ELF_NVSRHALFREG];
309 int i; 309 int i;
310 310
311 if (__copy_from_user(buf, from, ELF_NVSRHALFREG * sizeof(double))) 311 if (__copy_from_user(buf, from, ELF_NVSRHALFREG * sizeof(double)))
312 return 1; 312 return 1;
313 for (i = 0; i < ELF_NVSRHALFREG ; i++) 313 for (i = 0; i < ELF_NVSRHALFREG ; i++)
314 task->thread.fpr[i][TS_VSRLOWOFFSET] = buf[i]; 314 task->thread.fp_state.fpr[i][TS_VSRLOWOFFSET] = buf[i];
315 return 0; 315 return 0;
316} 316}
317 317
@@ -319,27 +319,27 @@ unsigned long copy_vsx_from_user(struct task_struct *task,
319unsigned long copy_transact_fpr_to_user(void __user *to, 319unsigned long copy_transact_fpr_to_user(void __user *to,
320 struct task_struct *task) 320 struct task_struct *task)
321{ 321{
322 double buf[ELF_NFPREG]; 322 u64 buf[ELF_NFPREG];
323 int i; 323 int i;
324 324
325 /* save FPR copy to local buffer then write to the thread_struct */ 325 /* save FPR copy to local buffer then write to the thread_struct */
326 for (i = 0; i < (ELF_NFPREG - 1) ; i++) 326 for (i = 0; i < (ELF_NFPREG - 1) ; i++)
327 buf[i] = task->thread.TS_TRANS_FPR(i); 327 buf[i] = task->thread.TS_TRANS_FPR(i);
328 memcpy(&buf[i], &task->thread.transact_fpscr, sizeof(double)); 328 buf[i] = task->thread.transact_fp.fpscr;
329 return __copy_to_user(to, buf, ELF_NFPREG * sizeof(double)); 329 return __copy_to_user(to, buf, ELF_NFPREG * sizeof(double));
330} 330}
331 331
332unsigned long copy_transact_fpr_from_user(struct task_struct *task, 332unsigned long copy_transact_fpr_from_user(struct task_struct *task,
333 void __user *from) 333 void __user *from)
334{ 334{
335 double buf[ELF_NFPREG]; 335 u64 buf[ELF_NFPREG];
336 int i; 336 int i;
337 337
338 if (__copy_from_user(buf, from, ELF_NFPREG * sizeof(double))) 338 if (__copy_from_user(buf, from, ELF_NFPREG * sizeof(double)))
339 return 1; 339 return 1;
340 for (i = 0; i < (ELF_NFPREG - 1) ; i++) 340 for (i = 0; i < (ELF_NFPREG - 1) ; i++)
341 task->thread.TS_TRANS_FPR(i) = buf[i]; 341 task->thread.TS_TRANS_FPR(i) = buf[i];
342 memcpy(&task->thread.transact_fpscr, &buf[i], sizeof(double)); 342 task->thread.transact_fp.fpscr = buf[i];
343 343
344 return 0; 344 return 0;
345} 345}
@@ -347,25 +347,25 @@ unsigned long copy_transact_fpr_from_user(struct task_struct *task,
347unsigned long copy_transact_vsx_to_user(void __user *to, 347unsigned long copy_transact_vsx_to_user(void __user *to,
348 struct task_struct *task) 348 struct task_struct *task)
349{ 349{
350 double buf[ELF_NVSRHALFREG]; 350 u64 buf[ELF_NVSRHALFREG];
351 int i; 351 int i;
352 352
353 /* save FPR copy to local buffer then write to the thread_struct */ 353 /* save FPR copy to local buffer then write to the thread_struct */
354 for (i = 0; i < ELF_NVSRHALFREG; i++) 354 for (i = 0; i < ELF_NVSRHALFREG; i++)
355 buf[i] = task->thread.transact_fpr[i][TS_VSRLOWOFFSET]; 355 buf[i] = task->thread.transact_fp.fpr[i][TS_VSRLOWOFFSET];
356 return __copy_to_user(to, buf, ELF_NVSRHALFREG * sizeof(double)); 356 return __copy_to_user(to, buf, ELF_NVSRHALFREG * sizeof(double));
357} 357}
358 358
359unsigned long copy_transact_vsx_from_user(struct task_struct *task, 359unsigned long copy_transact_vsx_from_user(struct task_struct *task,
360 void __user *from) 360 void __user *from)
361{ 361{
362 double buf[ELF_NVSRHALFREG]; 362 u64 buf[ELF_NVSRHALFREG];
363 int i; 363 int i;
364 364
365 if (__copy_from_user(buf, from, ELF_NVSRHALFREG * sizeof(double))) 365 if (__copy_from_user(buf, from, ELF_NVSRHALFREG * sizeof(double)))
366 return 1; 366 return 1;
367 for (i = 0; i < ELF_NVSRHALFREG ; i++) 367 for (i = 0; i < ELF_NVSRHALFREG ; i++)
368 task->thread.transact_fpr[i][TS_VSRLOWOFFSET] = buf[i]; 368 task->thread.transact_fp.fpr[i][TS_VSRLOWOFFSET] = buf[i];
369 return 0; 369 return 0;
370} 370}
371#endif /* CONFIG_PPC_TRANSACTIONAL_MEM */ 371#endif /* CONFIG_PPC_TRANSACTIONAL_MEM */
@@ -373,14 +373,14 @@ unsigned long copy_transact_vsx_from_user(struct task_struct *task,
373inline unsigned long copy_fpr_to_user(void __user *to, 373inline unsigned long copy_fpr_to_user(void __user *to,
374 struct task_struct *task) 374 struct task_struct *task)
375{ 375{
376 return __copy_to_user(to, task->thread.fpr, 376 return __copy_to_user(to, task->thread.fp_state.fpr,
377 ELF_NFPREG * sizeof(double)); 377 ELF_NFPREG * sizeof(double));
378} 378}
379 379
380inline unsigned long copy_fpr_from_user(struct task_struct *task, 380inline unsigned long copy_fpr_from_user(struct task_struct *task,
381 void __user *from) 381 void __user *from)
382{ 382{
383 return __copy_from_user(task->thread.fpr, from, 383 return __copy_from_user(task->thread.fp_state.fpr, from,
384 ELF_NFPREG * sizeof(double)); 384 ELF_NFPREG * sizeof(double));
385} 385}
386 386
@@ -388,14 +388,14 @@ inline unsigned long copy_fpr_from_user(struct task_struct *task,
388inline unsigned long copy_transact_fpr_to_user(void __user *to, 388inline unsigned long copy_transact_fpr_to_user(void __user *to,
389 struct task_struct *task) 389 struct task_struct *task)
390{ 390{
391 return __copy_to_user(to, task->thread.transact_fpr, 391 return __copy_to_user(to, task->thread.transact_fp.fpr,
392 ELF_NFPREG * sizeof(double)); 392 ELF_NFPREG * sizeof(double));
393} 393}
394 394
395inline unsigned long copy_transact_fpr_from_user(struct task_struct *task, 395inline unsigned long copy_transact_fpr_from_user(struct task_struct *task,
396 void __user *from) 396 void __user *from)
397{ 397{
398 return __copy_from_user(task->thread.transact_fpr, from, 398 return __copy_from_user(task->thread.transact_fp.fpr, from,
399 ELF_NFPREG * sizeof(double)); 399 ELF_NFPREG * sizeof(double));
400} 400}
401#endif /* CONFIG_PPC_TRANSACTIONAL_MEM */ 401#endif /* CONFIG_PPC_TRANSACTIONAL_MEM */
@@ -423,7 +423,7 @@ static int save_user_regs(struct pt_regs *regs, struct mcontext __user *frame,
423 /* save altivec registers */ 423 /* save altivec registers */
424 if (current->thread.used_vr) { 424 if (current->thread.used_vr) {
425 flush_altivec_to_thread(current); 425 flush_altivec_to_thread(current);
426 if (__copy_to_user(&frame->mc_vregs, current->thread.vr, 426 if (__copy_to_user(&frame->mc_vregs, &current->thread.vr_state,
427 ELF_NVRREG * sizeof(vector128))) 427 ELF_NVRREG * sizeof(vector128)))
428 return 1; 428 return 1;
429 /* set MSR_VEC in the saved MSR value to indicate that 429 /* set MSR_VEC in the saved MSR value to indicate that
@@ -534,17 +534,17 @@ static int save_tm_user_regs(struct pt_regs *regs,
534 /* save altivec registers */ 534 /* save altivec registers */
535 if (current->thread.used_vr) { 535 if (current->thread.used_vr) {
536 flush_altivec_to_thread(current); 536 flush_altivec_to_thread(current);
537 if (__copy_to_user(&frame->mc_vregs, current->thread.vr, 537 if (__copy_to_user(&frame->mc_vregs, &current->thread.vr_state,
538 ELF_NVRREG * sizeof(vector128))) 538 ELF_NVRREG * sizeof(vector128)))
539 return 1; 539 return 1;
540 if (msr & MSR_VEC) { 540 if (msr & MSR_VEC) {
541 if (__copy_to_user(&tm_frame->mc_vregs, 541 if (__copy_to_user(&tm_frame->mc_vregs,
542 current->thread.transact_vr, 542 &current->thread.transact_vr,
543 ELF_NVRREG * sizeof(vector128))) 543 ELF_NVRREG * sizeof(vector128)))
544 return 1; 544 return 1;
545 } else { 545 } else {
546 if (__copy_to_user(&tm_frame->mc_vregs, 546 if (__copy_to_user(&tm_frame->mc_vregs,
547 current->thread.vr, 547 &current->thread.vr_state,
548 ELF_NVRREG * sizeof(vector128))) 548 ELF_NVRREG * sizeof(vector128)))
549 return 1; 549 return 1;
550 } 550 }
@@ -692,11 +692,12 @@ static long restore_user_regs(struct pt_regs *regs,
692 regs->msr &= ~MSR_VEC; 692 regs->msr &= ~MSR_VEC;
693 if (msr & MSR_VEC) { 693 if (msr & MSR_VEC) {
694 /* restore altivec registers from the stack */ 694 /* restore altivec registers from the stack */
695 if (__copy_from_user(current->thread.vr, &sr->mc_vregs, 695 if (__copy_from_user(&current->thread.vr_state, &sr->mc_vregs,
696 sizeof(sr->mc_vregs))) 696 sizeof(sr->mc_vregs)))
697 return 1; 697 return 1;
698 } else if (current->thread.used_vr) 698 } else if (current->thread.used_vr)
699 memset(current->thread.vr, 0, ELF_NVRREG * sizeof(vector128)); 699 memset(&current->thread.vr_state, 0,
700 ELF_NVRREG * sizeof(vector128));
700 701
701 /* Always get VRSAVE back */ 702 /* Always get VRSAVE back */
702 if (__get_user(current->thread.vrsave, (u32 __user *)&sr->mc_vregs[32])) 703 if (__get_user(current->thread.vrsave, (u32 __user *)&sr->mc_vregs[32]))
@@ -722,7 +723,7 @@ static long restore_user_regs(struct pt_regs *regs,
722 return 1; 723 return 1;
723 } else if (current->thread.used_vsr) 724 } else if (current->thread.used_vsr)
724 for (i = 0; i < 32 ; i++) 725 for (i = 0; i < 32 ; i++)
725 current->thread.fpr[i][TS_VSRLOWOFFSET] = 0; 726 current->thread.fp_state.fpr[i][TS_VSRLOWOFFSET] = 0;
726#endif /* CONFIG_VSX */ 727#endif /* CONFIG_VSX */
727 /* 728 /*
728 * force the process to reload the FP registers from 729 * force the process to reload the FP registers from
@@ -798,15 +799,16 @@ static long restore_tm_user_regs(struct pt_regs *regs,
798 regs->msr &= ~MSR_VEC; 799 regs->msr &= ~MSR_VEC;
799 if (msr & MSR_VEC) { 800 if (msr & MSR_VEC) {
800 /* restore altivec registers from the stack */ 801 /* restore altivec registers from the stack */
801 if (__copy_from_user(current->thread.vr, &sr->mc_vregs, 802 if (__copy_from_user(&current->thread.vr_state, &sr->mc_vregs,
802 sizeof(sr->mc_vregs)) || 803 sizeof(sr->mc_vregs)) ||
803 __copy_from_user(current->thread.transact_vr, 804 __copy_from_user(&current->thread.transact_vr,
804 &tm_sr->mc_vregs, 805 &tm_sr->mc_vregs,
805 sizeof(sr->mc_vregs))) 806 sizeof(sr->mc_vregs)))
806 return 1; 807 return 1;
807 } else if (current->thread.used_vr) { 808 } else if (current->thread.used_vr) {
808 memset(current->thread.vr, 0, ELF_NVRREG * sizeof(vector128)); 809 memset(&current->thread.vr_state, 0,
809 memset(current->thread.transact_vr, 0, 810 ELF_NVRREG * sizeof(vector128));
811 memset(&current->thread.transact_vr, 0,
810 ELF_NVRREG * sizeof(vector128)); 812 ELF_NVRREG * sizeof(vector128));
811 } 813 }
812 814
@@ -838,8 +840,8 @@ static long restore_tm_user_regs(struct pt_regs *regs,
838 return 1; 840 return 1;
839 } else if (current->thread.used_vsr) 841 } else if (current->thread.used_vsr)
840 for (i = 0; i < 32 ; i++) { 842 for (i = 0; i < 32 ; i++) {
841 current->thread.fpr[i][TS_VSRLOWOFFSET] = 0; 843 current->thread.fp_state.fpr[i][TS_VSRLOWOFFSET] = 0;
842 current->thread.transact_fpr[i][TS_VSRLOWOFFSET] = 0; 844 current->thread.transact_fp.fpr[i][TS_VSRLOWOFFSET] = 0;
843 } 845 }
844#endif /* CONFIG_VSX */ 846#endif /* CONFIG_VSX */
845 847
@@ -1030,7 +1032,7 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
1030 if (__put_user(0, &rt_sf->uc.uc_link)) 1032 if (__put_user(0, &rt_sf->uc.uc_link))
1031 goto badframe; 1033 goto badframe;
1032 1034
1033 current->thread.fpscr.val = 0; /* turn off all fp exceptions */ 1035 current->thread.fp_state.fpscr = 0; /* turn off all fp exceptions */
1034 1036
1035 /* create a stack frame for the caller of the handler */ 1037 /* create a stack frame for the caller of the handler */
1036 newsp = ((unsigned long)rt_sf) - (__SIGNAL_FRAMESIZE + 16); 1038 newsp = ((unsigned long)rt_sf) - (__SIGNAL_FRAMESIZE + 16);
@@ -1045,8 +1047,9 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
1045 regs->gpr[5] = (unsigned long) &rt_sf->uc; 1047 regs->gpr[5] = (unsigned long) &rt_sf->uc;
1046 regs->gpr[6] = (unsigned long) rt_sf; 1048 regs->gpr[6] = (unsigned long) rt_sf;
1047 regs->nip = (unsigned long) ka->sa.sa_handler; 1049 regs->nip = (unsigned long) ka->sa.sa_handler;
1048 /* enter the signal handler in big-endian mode */ 1050 /* enter the signal handler in native-endian mode */
1049 regs->msr &= ~MSR_LE; 1051 regs->msr &= ~MSR_LE;
1052 regs->msr |= (MSR_KERNEL & MSR_LE);
1050#ifdef CONFIG_PPC_TRANSACTIONAL_MEM 1053#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
1051 /* Remove TM bits from thread's MSR. The MSR in the sigcontext 1054 /* Remove TM bits from thread's MSR. The MSR in the sigcontext
1052 * just indicates to userland that we were doing a transaction, but we 1055 * just indicates to userland that we were doing a transaction, but we
@@ -1309,7 +1312,7 @@ int sys_debug_setcontext(struct ucontext __user *ctx,
1309 unsigned char tmp; 1312 unsigned char tmp;
1310 unsigned long new_msr = regs->msr; 1313 unsigned long new_msr = regs->msr;
1311#ifdef CONFIG_PPC_ADV_DEBUG_REGS 1314#ifdef CONFIG_PPC_ADV_DEBUG_REGS
1312 unsigned long new_dbcr0 = current->thread.dbcr0; 1315 unsigned long new_dbcr0 = current->thread.debug.dbcr0;
1313#endif 1316#endif
1314 1317
1315 for (i=0; i<ndbg; i++) { 1318 for (i=0; i<ndbg; i++) {
@@ -1324,7 +1327,7 @@ int sys_debug_setcontext(struct ucontext __user *ctx,
1324 } else { 1327 } else {
1325 new_dbcr0 &= ~DBCR0_IC; 1328 new_dbcr0 &= ~DBCR0_IC;
1326 if (!DBCR_ACTIVE_EVENTS(new_dbcr0, 1329 if (!DBCR_ACTIVE_EVENTS(new_dbcr0,
1327 current->thread.dbcr1)) { 1330 current->thread.debug.dbcr1)) {
1328 new_msr &= ~MSR_DE; 1331 new_msr &= ~MSR_DE;
1329 new_dbcr0 &= ~DBCR0_IDM; 1332 new_dbcr0 &= ~DBCR0_IDM;
1330 } 1333 }
@@ -1359,7 +1362,7 @@ int sys_debug_setcontext(struct ucontext __user *ctx,
1359 the user is really doing something wrong. */ 1362 the user is really doing something wrong. */
1360 regs->msr = new_msr; 1363 regs->msr = new_msr;
1361#ifdef CONFIG_PPC_ADV_DEBUG_REGS 1364#ifdef CONFIG_PPC_ADV_DEBUG_REGS
1362 current->thread.dbcr0 = new_dbcr0; 1365 current->thread.debug.dbcr0 = new_dbcr0;
1363#endif 1366#endif
1364 1367
1365 if (!access_ok(VERIFY_READ, ctx, sizeof(*ctx)) 1368 if (!access_ok(VERIFY_READ, ctx, sizeof(*ctx))
@@ -1462,7 +1465,7 @@ int handle_signal32(unsigned long sig, struct k_sigaction *ka,
1462 1465
1463 regs->link = tramp; 1466 regs->link = tramp;
1464 1467
1465 current->thread.fpscr.val = 0; /* turn off all fp exceptions */ 1468 current->thread.fp_state.fpscr = 0; /* turn off all fp exceptions */
1466 1469
1467 /* create a stack frame for the caller of the handler */ 1470 /* create a stack frame for the caller of the handler */
1468 newsp = ((unsigned long)frame) - __SIGNAL_FRAMESIZE; 1471 newsp = ((unsigned long)frame) - __SIGNAL_FRAMESIZE;
diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
index f93ec2835a13..b3c615764c9b 100644
--- a/arch/powerpc/kernel/signal_64.c
+++ b/arch/powerpc/kernel/signal_64.c
@@ -103,7 +103,8 @@ static long setup_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs,
103 if (current->thread.used_vr) { 103 if (current->thread.used_vr) {
104 flush_altivec_to_thread(current); 104 flush_altivec_to_thread(current);
105 /* Copy 33 vec registers (vr0..31 and vscr) to the stack */ 105 /* Copy 33 vec registers (vr0..31 and vscr) to the stack */
106 err |= __copy_to_user(v_regs, current->thread.vr, 33 * sizeof(vector128)); 106 err |= __copy_to_user(v_regs, &current->thread.vr_state,
107 33 * sizeof(vector128));
107 /* set MSR_VEC in the MSR value in the frame to indicate that sc->v_reg) 108 /* set MSR_VEC in the MSR value in the frame to indicate that sc->v_reg)
108 * contains valid data. 109 * contains valid data.
109 */ 110 */
@@ -195,18 +196,18 @@ static long setup_tm_sigcontexts(struct sigcontext __user *sc,
195 if (current->thread.used_vr) { 196 if (current->thread.used_vr) {
196 flush_altivec_to_thread(current); 197 flush_altivec_to_thread(current);
197 /* Copy 33 vec registers (vr0..31 and vscr) to the stack */ 198 /* Copy 33 vec registers (vr0..31 and vscr) to the stack */
198 err |= __copy_to_user(v_regs, current->thread.vr, 199 err |= __copy_to_user(v_regs, &current->thread.vr_state,
199 33 * sizeof(vector128)); 200 33 * sizeof(vector128));
200 /* If VEC was enabled there are transactional VRs valid too, 201 /* If VEC was enabled there are transactional VRs valid too,
201 * else they're a copy of the checkpointed VRs. 202 * else they're a copy of the checkpointed VRs.
202 */ 203 */
203 if (msr & MSR_VEC) 204 if (msr & MSR_VEC)
204 err |= __copy_to_user(tm_v_regs, 205 err |= __copy_to_user(tm_v_regs,
205 current->thread.transact_vr, 206 &current->thread.transact_vr,
206 33 * sizeof(vector128)); 207 33 * sizeof(vector128));
207 else 208 else
208 err |= __copy_to_user(tm_v_regs, 209 err |= __copy_to_user(tm_v_regs,
209 current->thread.vr, 210 &current->thread.vr_state,
210 33 * sizeof(vector128)); 211 33 * sizeof(vector128));
211 212
212 /* set MSR_VEC in the MSR value in the frame to indicate 213 /* set MSR_VEC in the MSR value in the frame to indicate
@@ -349,10 +350,10 @@ static long restore_sigcontext(struct pt_regs *regs, sigset_t *set, int sig,
349 return -EFAULT; 350 return -EFAULT;
350 /* Copy 33 vec registers (vr0..31 and vscr) from the stack */ 351 /* Copy 33 vec registers (vr0..31 and vscr) from the stack */
351 if (v_regs != NULL && (msr & MSR_VEC) != 0) 352 if (v_regs != NULL && (msr & MSR_VEC) != 0)
352 err |= __copy_from_user(current->thread.vr, v_regs, 353 err |= __copy_from_user(&current->thread.vr_state, v_regs,
353 33 * sizeof(vector128)); 354 33 * sizeof(vector128));
354 else if (current->thread.used_vr) 355 else if (current->thread.used_vr)
355 memset(current->thread.vr, 0, 33 * sizeof(vector128)); 356 memset(&current->thread.vr_state, 0, 33 * sizeof(vector128));
356 /* Always get VRSAVE back */ 357 /* Always get VRSAVE back */
357 if (v_regs != NULL) 358 if (v_regs != NULL)
358 err |= __get_user(current->thread.vrsave, (u32 __user *)&v_regs[33]); 359 err |= __get_user(current->thread.vrsave, (u32 __user *)&v_regs[33]);
@@ -374,7 +375,7 @@ static long restore_sigcontext(struct pt_regs *regs, sigset_t *set, int sig,
374 err |= copy_vsx_from_user(current, v_regs); 375 err |= copy_vsx_from_user(current, v_regs);
375 else 376 else
376 for (i = 0; i < 32 ; i++) 377 for (i = 0; i < 32 ; i++)
377 current->thread.fpr[i][TS_VSRLOWOFFSET] = 0; 378 current->thread.fp_state.fpr[i][TS_VSRLOWOFFSET] = 0;
378#endif 379#endif
379 return err; 380 return err;
380} 381}
@@ -468,14 +469,14 @@ static long restore_tm_sigcontexts(struct pt_regs *regs,
468 return -EFAULT; 469 return -EFAULT;
469 /* Copy 33 vec registers (vr0..31 and vscr) from the stack */ 470 /* Copy 33 vec registers (vr0..31 and vscr) from the stack */
470 if (v_regs != NULL && tm_v_regs != NULL && (msr & MSR_VEC) != 0) { 471 if (v_regs != NULL && tm_v_regs != NULL && (msr & MSR_VEC) != 0) {
471 err |= __copy_from_user(current->thread.vr, v_regs, 472 err |= __copy_from_user(&current->thread.vr_state, v_regs,
472 33 * sizeof(vector128)); 473 33 * sizeof(vector128));
473 err |= __copy_from_user(current->thread.transact_vr, tm_v_regs, 474 err |= __copy_from_user(&current->thread.transact_vr, tm_v_regs,
474 33 * sizeof(vector128)); 475 33 * sizeof(vector128));
475 } 476 }
476 else if (current->thread.used_vr) { 477 else if (current->thread.used_vr) {
477 memset(current->thread.vr, 0, 33 * sizeof(vector128)); 478 memset(&current->thread.vr_state, 0, 33 * sizeof(vector128));
478 memset(current->thread.transact_vr, 0, 33 * sizeof(vector128)); 479 memset(&current->thread.transact_vr, 0, 33 * sizeof(vector128));
479 } 480 }
480 /* Always get VRSAVE back */ 481 /* Always get VRSAVE back */
481 if (v_regs != NULL && tm_v_regs != NULL) { 482 if (v_regs != NULL && tm_v_regs != NULL) {
@@ -507,8 +508,8 @@ static long restore_tm_sigcontexts(struct pt_regs *regs,
507 err |= copy_transact_vsx_from_user(current, tm_v_regs); 508 err |= copy_transact_vsx_from_user(current, tm_v_regs);
508 } else { 509 } else {
509 for (i = 0; i < 32 ; i++) { 510 for (i = 0; i < 32 ; i++) {
510 current->thread.fpr[i][TS_VSRLOWOFFSET] = 0; 511 current->thread.fp_state.fpr[i][TS_VSRLOWOFFSET] = 0;
511 current->thread.transact_fpr[i][TS_VSRLOWOFFSET] = 0; 512 current->thread.transact_fp.fpr[i][TS_VSRLOWOFFSET] = 0;
512 } 513 }
513 } 514 }
514#endif 515#endif
@@ -747,7 +748,7 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info,
747 goto badframe; 748 goto badframe;
748 749
749 /* Make sure signal handler doesn't get spurious FP exceptions */ 750 /* Make sure signal handler doesn't get spurious FP exceptions */
750 current->thread.fpscr.val = 0; 751 current->thread.fp_state.fpscr = 0;
751#ifdef CONFIG_PPC_TRANSACTIONAL_MEM 752#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
752 /* Remove TM bits from thread's MSR. The MSR in the sigcontext 753 /* Remove TM bits from thread's MSR. The MSR in the sigcontext
753 * just indicates to userland that we were doing a transaction, but we 754 * just indicates to userland that we were doing a transaction, but we
@@ -773,8 +774,9 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info,
773 774
774 /* Set up "regs" so we "return" to the signal handler. */ 775 /* Set up "regs" so we "return" to the signal handler. */
775 err |= get_user(regs->nip, &funct_desc_ptr->entry); 776 err |= get_user(regs->nip, &funct_desc_ptr->entry);
776 /* enter the signal handler in big-endian mode */ 777 /* enter the signal handler in native-endian mode */
777 regs->msr &= ~MSR_LE; 778 regs->msr &= ~MSR_LE;
779 regs->msr |= (MSR_KERNEL & MSR_LE);
778 regs->gpr[1] = newsp; 780 regs->gpr[1] = newsp;
779 err |= get_user(regs->gpr[2], &funct_desc_ptr->toc); 781 err |= get_user(regs->gpr[2], &funct_desc_ptr->toc);
780 regs->gpr[3] = signr; 782 regs->gpr[3] = signr;
diff --git a/arch/powerpc/kernel/swsusp_asm64.S b/arch/powerpc/kernel/swsusp_asm64.S
index 22045984835f..988f38dced0f 100644
--- a/arch/powerpc/kernel/swsusp_asm64.S
+++ b/arch/powerpc/kernel/swsusp_asm64.S
@@ -114,7 +114,9 @@ _GLOBAL(swsusp_arch_suspend)
114 SAVE_SPECIAL(MSR) 114 SAVE_SPECIAL(MSR)
115 SAVE_SPECIAL(XER) 115 SAVE_SPECIAL(XER)
116#ifdef CONFIG_PPC_BOOK3S_64 116#ifdef CONFIG_PPC_BOOK3S_64
117BEGIN_FW_FTR_SECTION
117 SAVE_SPECIAL(SDR1) 118 SAVE_SPECIAL(SDR1)
119END_FW_FTR_SECTION_IFCLR(FW_FEATURE_LPAR)
118#else 120#else
119 SAVE_SPR(TCR) 121 SAVE_SPR(TCR)
120 122
@@ -231,7 +233,9 @@ nothing_to_copy:
231 /* can't use RESTORE_SPECIAL(MSR) */ 233 /* can't use RESTORE_SPECIAL(MSR) */
232 ld r0, SL_MSR(r11) 234 ld r0, SL_MSR(r11)
233 mtmsrd r0, 0 235 mtmsrd r0, 0
236BEGIN_FW_FTR_SECTION
234 RESTORE_SPECIAL(SDR1) 237 RESTORE_SPECIAL(SDR1)
238END_FW_FTR_SECTION_IFCLR(FW_FEATURE_LPAR)
235#else 239#else
236 /* Restore SPRG1, be used to save paca */ 240 /* Restore SPRG1, be used to save paca */
237 ld r0, SL_SPRG1(r11) 241 ld r0, SL_SPRG1(r11)
diff --git a/arch/powerpc/kernel/tm.S b/arch/powerpc/kernel/tm.S
index cd809eaa8b5c..ef47bcbd4352 100644
--- a/arch/powerpc/kernel/tm.S
+++ b/arch/powerpc/kernel/tm.S
@@ -12,16 +12,15 @@
12#include <asm/reg.h> 12#include <asm/reg.h>
13 13
14#ifdef CONFIG_VSX 14#ifdef CONFIG_VSX
15/* See fpu.S, this is very similar but to save/restore checkpointed FPRs/VSRs */ 15/* See fpu.S, this is borrowed from there */
16#define __SAVE_32FPRS_VSRS_TRANSACT(n,c,base) \ 16#define __SAVE_32FPRS_VSRS(n,c,base) \
17BEGIN_FTR_SECTION \ 17BEGIN_FTR_SECTION \
18 b 2f; \ 18 b 2f; \
19END_FTR_SECTION_IFSET(CPU_FTR_VSX); \ 19END_FTR_SECTION_IFSET(CPU_FTR_VSX); \
20 SAVE_32FPRS_TRANSACT(n,base); \ 20 SAVE_32FPRS(n,base); \
21 b 3f; \ 21 b 3f; \
222: SAVE_32VSRS_TRANSACT(n,c,base); \ 222: SAVE_32VSRS(n,c,base); \
233: 233:
24/* ...and this is just plain borrowed from there. */
25#define __REST_32FPRS_VSRS(n,c,base) \ 24#define __REST_32FPRS_VSRS(n,c,base) \
26BEGIN_FTR_SECTION \ 25BEGIN_FTR_SECTION \
27 b 2f; \ 26 b 2f; \
@@ -31,11 +30,11 @@ END_FTR_SECTION_IFSET(CPU_FTR_VSX); \
312: REST_32VSRS(n,c,base); \ 302: REST_32VSRS(n,c,base); \
323: 313:
33#else 32#else
34#define __SAVE_32FPRS_VSRS_TRANSACT(n,c,base) SAVE_32FPRS_TRANSACT(n, base) 33#define __SAVE_32FPRS_VSRS(n,c,base) SAVE_32FPRS(n, base)
35#define __REST_32FPRS_VSRS(n,c,base) REST_32FPRS(n, base) 34#define __REST_32FPRS_VSRS(n,c,base) REST_32FPRS(n, base)
36#endif 35#endif
37#define SAVE_32FPRS_VSRS_TRANSACT(n,c,base) \ 36#define SAVE_32FPRS_VSRS(n,c,base) \
38 __SAVE_32FPRS_VSRS_TRANSACT(n,__REG_##c,__REG_##base) 37 __SAVE_32FPRS_VSRS(n,__REG_##c,__REG_##base)
39#define REST_32FPRS_VSRS(n,c,base) \ 38#define REST_32FPRS_VSRS(n,c,base) \
40 __REST_32FPRS_VSRS(n,__REG_##c,__REG_##base) 39 __REST_32FPRS_VSRS(n,__REG_##c,__REG_##base)
41 40
@@ -107,7 +106,7 @@ DSCR_DEFAULT:
107_GLOBAL(tm_reclaim) 106_GLOBAL(tm_reclaim)
108 mfcr r6 107 mfcr r6
109 mflr r0 108 mflr r0
110 std r6, 8(r1) 109 stw r6, 8(r1)
111 std r0, 16(r1) 110 std r0, 16(r1)
112 std r2, 40(r1) 111 std r2, 40(r1)
113 stdu r1, -TM_FRAME_SIZE(r1) 112 stdu r1, -TM_FRAME_SIZE(r1)
@@ -157,10 +156,11 @@ _GLOBAL(tm_reclaim)
157 andis. r0, r4, MSR_VEC@h 156 andis. r0, r4, MSR_VEC@h
158 beq dont_backup_vec 157 beq dont_backup_vec
159 158
160 SAVE_32VRS_TRANSACT(0, r6, r3) /* r6 scratch, r3 thread */ 159 addi r7, r3, THREAD_TRANSACT_VRSTATE
160 SAVE_32VRS(0, r6, r7) /* r6 scratch, r7 transact vr state */
161 mfvscr vr0 161 mfvscr vr0
162 li r6, THREAD_TRANSACT_VSCR 162 li r6, VRSTATE_VSCR
163 stvx vr0, r3, r6 163 stvx vr0, r7, r6
164dont_backup_vec: 164dont_backup_vec:
165 mfspr r0, SPRN_VRSAVE 165 mfspr r0, SPRN_VRSAVE
166 std r0, THREAD_TRANSACT_VRSAVE(r3) 166 std r0, THREAD_TRANSACT_VRSAVE(r3)
@@ -168,10 +168,11 @@ dont_backup_vec:
168 andi. r0, r4, MSR_FP 168 andi. r0, r4, MSR_FP
169 beq dont_backup_fp 169 beq dont_backup_fp
170 170
171 SAVE_32FPRS_VSRS_TRANSACT(0, R6, R3) /* r6 scratch, r3 thread */ 171 addi r7, r3, THREAD_TRANSACT_FPSTATE
172 SAVE_32FPRS_VSRS(0, R6, R7) /* r6 scratch, r7 transact fp state */
172 173
173 mffs fr0 174 mffs fr0
174 stfd fr0,THREAD_TRANSACT_FPSCR(r3) 175 stfd fr0,FPSTATE_FPSCR(r7)
175 176
176dont_backup_fp: 177dont_backup_fp:
177 /* The moment we treclaim, ALL of our GPRs will switch 178 /* The moment we treclaim, ALL of our GPRs will switch
@@ -284,7 +285,7 @@ dont_backup_fp:
284 REST_NVGPRS(r1) 285 REST_NVGPRS(r1)
285 286
286 addi r1, r1, TM_FRAME_SIZE 287 addi r1, r1, TM_FRAME_SIZE
287 ld r4, 8(r1) 288 lwz r4, 8(r1)
288 ld r0, 16(r1) 289 ld r0, 16(r1)
289 mtcr r4 290 mtcr r4
290 mtlr r0 291 mtlr r0
@@ -309,7 +310,7 @@ dont_backup_fp:
309_GLOBAL(tm_recheckpoint) 310_GLOBAL(tm_recheckpoint)
310 mfcr r5 311 mfcr r5
311 mflr r0 312 mflr r0
312 std r5, 8(r1) 313 stw r5, 8(r1)
313 std r0, 16(r1) 314 std r0, 16(r1)
314 std r2, 40(r1) 315 std r2, 40(r1)
315 stdu r1, -TM_FRAME_SIZE(r1) 316 stdu r1, -TM_FRAME_SIZE(r1)
@@ -358,10 +359,11 @@ _GLOBAL(tm_recheckpoint)
358 andis. r0, r4, MSR_VEC@h 359 andis. r0, r4, MSR_VEC@h
359 beq dont_restore_vec 360 beq dont_restore_vec
360 361
361 li r5, THREAD_VSCR 362 addi r8, r3, THREAD_VRSTATE
362 lvx vr0, r3, r5 363 li r5, VRSTATE_VSCR
364 lvx vr0, r8, r5
363 mtvscr vr0 365 mtvscr vr0
364 REST_32VRS(0, r5, r3) /* r5 scratch, r3 THREAD ptr */ 366 REST_32VRS(0, r5, r8) /* r5 scratch, r8 ptr */
365dont_restore_vec: 367dont_restore_vec:
366 ld r5, THREAD_VRSAVE(r3) 368 ld r5, THREAD_VRSAVE(r3)
367 mtspr SPRN_VRSAVE, r5 369 mtspr SPRN_VRSAVE, r5
@@ -370,9 +372,10 @@ dont_restore_vec:
370 andi. r0, r4, MSR_FP 372 andi. r0, r4, MSR_FP
371 beq dont_restore_fp 373 beq dont_restore_fp
372 374
373 lfd fr0, THREAD_FPSCR(r3) 375 addi r8, r3, THREAD_FPSTATE
376 lfd fr0, FPSTATE_FPSCR(r8)
374 MTFSF_L(fr0) 377 MTFSF_L(fr0)
375 REST_32FPRS_VSRS(0, R4, R3) 378 REST_32FPRS_VSRS(0, R4, R8)
376 379
377dont_restore_fp: 380dont_restore_fp:
378 mtmsr r6 /* FP/Vec off again! */ 381 mtmsr r6 /* FP/Vec off again! */
@@ -441,7 +444,7 @@ restore_gprs:
441 REST_NVGPRS(r1) 444 REST_NVGPRS(r1)
442 445
443 addi r1, r1, TM_FRAME_SIZE 446 addi r1, r1, TM_FRAME_SIZE
444 ld r4, 8(r1) 447 lwz r4, 8(r1)
445 ld r0, 16(r1) 448 ld r0, 16(r1)
446 mtcr r4 449 mtcr r4
447 mtlr r0 450 mtlr r0
diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index f783c932faeb..62c3dd8c69f2 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -351,8 +351,8 @@ static inline int check_io_access(struct pt_regs *regs)
351#define REASON_TRAP ESR_PTR 351#define REASON_TRAP ESR_PTR
352 352
353/* single-step stuff */ 353/* single-step stuff */
354#define single_stepping(regs) (current->thread.dbcr0 & DBCR0_IC) 354#define single_stepping(regs) (current->thread.debug.dbcr0 & DBCR0_IC)
355#define clear_single_step(regs) (current->thread.dbcr0 &= ~DBCR0_IC) 355#define clear_single_step(regs) (current->thread.debug.dbcr0 &= ~DBCR0_IC)
356 356
357#else 357#else
358/* On non-4xx, the reason for the machine check or program 358/* On non-4xx, the reason for the machine check or program
@@ -816,7 +816,7 @@ static void parse_fpe(struct pt_regs *regs)
816 816
817 flush_fp_to_thread(current); 817 flush_fp_to_thread(current);
818 818
819 code = __parse_fpscr(current->thread.fpscr.val); 819 code = __parse_fpscr(current->thread.fp_state.fpscr);
820 820
821 _exception(SIGFPE, regs, code, regs->nip); 821 _exception(SIGFPE, regs, code, regs->nip);
822} 822}
@@ -1018,6 +1018,13 @@ static int emulate_instruction(struct pt_regs *regs)
1018 return emulate_isel(regs, instword); 1018 return emulate_isel(regs, instword);
1019 } 1019 }
1020 1020
1021 /* Emulate sync instruction variants */
1022 if ((instword & PPC_INST_SYNC_MASK) == PPC_INST_SYNC) {
1023 PPC_WARN_EMULATED(sync, regs);
1024 asm volatile("sync");
1025 return 0;
1026 }
1027
1021#ifdef CONFIG_PPC64 1028#ifdef CONFIG_PPC64
1022 /* Emulate the mfspr rD, DSCR. */ 1029 /* Emulate the mfspr rD, DSCR. */
1023 if ((((instword & PPC_INST_MFSPR_DSCR_USER_MASK) == 1030 if ((((instword & PPC_INST_MFSPR_DSCR_USER_MASK) ==
@@ -1069,7 +1076,7 @@ static int emulate_math(struct pt_regs *regs)
1069 return 0; 1076 return 0;
1070 case 1: { 1077 case 1: {
1071 int code = 0; 1078 int code = 0;
1072 code = __parse_fpscr(current->thread.fpscr.val); 1079 code = __parse_fpscr(current->thread.fp_state.fpscr);
1073 _exception(SIGFPE, regs, code, regs->nip); 1080 _exception(SIGFPE, regs, code, regs->nip);
1074 return 0; 1081 return 0;
1075 } 1082 }
@@ -1371,8 +1378,6 @@ void facility_unavailable_exception(struct pt_regs *regs)
1371 1378
1372#ifdef CONFIG_PPC_TRANSACTIONAL_MEM 1379#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
1373 1380
1374extern void do_load_up_fpu(struct pt_regs *regs);
1375
1376void fp_unavailable_tm(struct pt_regs *regs) 1381void fp_unavailable_tm(struct pt_regs *regs)
1377{ 1382{
1378 /* Note: This does not handle any kind of FP laziness. */ 1383 /* Note: This does not handle any kind of FP laziness. */
@@ -1403,8 +1408,6 @@ void fp_unavailable_tm(struct pt_regs *regs)
1403} 1408}
1404 1409
1405#ifdef CONFIG_ALTIVEC 1410#ifdef CONFIG_ALTIVEC
1406extern void do_load_up_altivec(struct pt_regs *regs);
1407
1408void altivec_unavailable_tm(struct pt_regs *regs) 1411void altivec_unavailable_tm(struct pt_regs *regs)
1409{ 1412{
1410 /* See the comments in fp_unavailable_tm(). This function operates 1413 /* See the comments in fp_unavailable_tm(). This function operates
@@ -1465,7 +1468,8 @@ void SoftwareEmulation(struct pt_regs *regs)
1465 1468
1466 if (!user_mode(regs)) { 1469 if (!user_mode(regs)) {
1467 debugger(regs); 1470 debugger(regs);
1468 die("Kernel Mode Software FPU Emulation", regs, SIGFPE); 1471 die("Kernel Mode Unimplemented Instruction or SW FPU Emulation",
1472 regs, SIGFPE);
1469 } 1473 }
1470 1474
1471 if (!emulate_math(regs)) 1475 if (!emulate_math(regs))
@@ -1486,7 +1490,7 @@ static void handle_debug(struct pt_regs *regs, unsigned long debug_status)
1486 if (debug_status & (DBSR_DAC1R | DBSR_DAC1W)) { 1490 if (debug_status & (DBSR_DAC1R | DBSR_DAC1W)) {
1487 dbcr_dac(current) &= ~(DBCR_DAC1R | DBCR_DAC1W); 1491 dbcr_dac(current) &= ~(DBCR_DAC1R | DBCR_DAC1W);
1488#ifdef CONFIG_PPC_ADV_DEBUG_DAC_RANGE 1492#ifdef CONFIG_PPC_ADV_DEBUG_DAC_RANGE
1489 current->thread.dbcr2 &= ~DBCR2_DAC12MODE; 1493 current->thread.debug.dbcr2 &= ~DBCR2_DAC12MODE;
1490#endif 1494#endif
1491 do_send_trap(regs, mfspr(SPRN_DAC1), debug_status, TRAP_HWBKPT, 1495 do_send_trap(regs, mfspr(SPRN_DAC1), debug_status, TRAP_HWBKPT,
1492 5); 1496 5);
@@ -1497,24 +1501,24 @@ static void handle_debug(struct pt_regs *regs, unsigned long debug_status)
1497 6); 1501 6);
1498 changed |= 0x01; 1502 changed |= 0x01;
1499 } else if (debug_status & DBSR_IAC1) { 1503 } else if (debug_status & DBSR_IAC1) {
1500 current->thread.dbcr0 &= ~DBCR0_IAC1; 1504 current->thread.debug.dbcr0 &= ~DBCR0_IAC1;
1501 dbcr_iac_range(current) &= ~DBCR_IAC12MODE; 1505 dbcr_iac_range(current) &= ~DBCR_IAC12MODE;
1502 do_send_trap(regs, mfspr(SPRN_IAC1), debug_status, TRAP_HWBKPT, 1506 do_send_trap(regs, mfspr(SPRN_IAC1), debug_status, TRAP_HWBKPT,
1503 1); 1507 1);
1504 changed |= 0x01; 1508 changed |= 0x01;
1505 } else if (debug_status & DBSR_IAC2) { 1509 } else if (debug_status & DBSR_IAC2) {
1506 current->thread.dbcr0 &= ~DBCR0_IAC2; 1510 current->thread.debug.dbcr0 &= ~DBCR0_IAC2;
1507 do_send_trap(regs, mfspr(SPRN_IAC2), debug_status, TRAP_HWBKPT, 1511 do_send_trap(regs, mfspr(SPRN_IAC2), debug_status, TRAP_HWBKPT,
1508 2); 1512 2);
1509 changed |= 0x01; 1513 changed |= 0x01;
1510 } else if (debug_status & DBSR_IAC3) { 1514 } else if (debug_status & DBSR_IAC3) {
1511 current->thread.dbcr0 &= ~DBCR0_IAC3; 1515 current->thread.debug.dbcr0 &= ~DBCR0_IAC3;
1512 dbcr_iac_range(current) &= ~DBCR_IAC34MODE; 1516 dbcr_iac_range(current) &= ~DBCR_IAC34MODE;
1513 do_send_trap(regs, mfspr(SPRN_IAC3), debug_status, TRAP_HWBKPT, 1517 do_send_trap(regs, mfspr(SPRN_IAC3), debug_status, TRAP_HWBKPT,
1514 3); 1518 3);
1515 changed |= 0x01; 1519 changed |= 0x01;
1516 } else if (debug_status & DBSR_IAC4) { 1520 } else if (debug_status & DBSR_IAC4) {
1517 current->thread.dbcr0 &= ~DBCR0_IAC4; 1521 current->thread.debug.dbcr0 &= ~DBCR0_IAC4;
1518 do_send_trap(regs, mfspr(SPRN_IAC4), debug_status, TRAP_HWBKPT, 1522 do_send_trap(regs, mfspr(SPRN_IAC4), debug_status, TRAP_HWBKPT,
1519 4); 1523 4);
1520 changed |= 0x01; 1524 changed |= 0x01;
@@ -1524,19 +1528,20 @@ static void handle_debug(struct pt_regs *regs, unsigned long debug_status)
1524 * Check all other debug flags and see if that bit needs to be turned 1528 * Check all other debug flags and see if that bit needs to be turned
1525 * back on or not. 1529 * back on or not.
1526 */ 1530 */
1527 if (DBCR_ACTIVE_EVENTS(current->thread.dbcr0, current->thread.dbcr1)) 1531 if (DBCR_ACTIVE_EVENTS(current->thread.debug.dbcr0,
1532 current->thread.debug.dbcr1))
1528 regs->msr |= MSR_DE; 1533 regs->msr |= MSR_DE;
1529 else 1534 else
1530 /* Make sure the IDM flag is off */ 1535 /* Make sure the IDM flag is off */
1531 current->thread.dbcr0 &= ~DBCR0_IDM; 1536 current->thread.debug.dbcr0 &= ~DBCR0_IDM;
1532 1537
1533 if (changed & 0x01) 1538 if (changed & 0x01)
1534 mtspr(SPRN_DBCR0, current->thread.dbcr0); 1539 mtspr(SPRN_DBCR0, current->thread.debug.dbcr0);
1535} 1540}
1536 1541
1537void __kprobes DebugException(struct pt_regs *regs, unsigned long debug_status) 1542void __kprobes DebugException(struct pt_regs *regs, unsigned long debug_status)
1538{ 1543{
1539 current->thread.dbsr = debug_status; 1544 current->thread.debug.dbsr = debug_status;
1540 1545
1541 /* Hack alert: On BookE, Branch Taken stops on the branch itself, while 1546 /* Hack alert: On BookE, Branch Taken stops on the branch itself, while
1542 * on server, it stops on the target of the branch. In order to simulate 1547 * on server, it stops on the target of the branch. In order to simulate
@@ -1553,8 +1558,8 @@ void __kprobes DebugException(struct pt_regs *regs, unsigned long debug_status)
1553 1558
1554 /* Do the single step trick only when coming from userspace */ 1559 /* Do the single step trick only when coming from userspace */
1555 if (user_mode(regs)) { 1560 if (user_mode(regs)) {
1556 current->thread.dbcr0 &= ~DBCR0_BT; 1561 current->thread.debug.dbcr0 &= ~DBCR0_BT;
1557 current->thread.dbcr0 |= DBCR0_IDM | DBCR0_IC; 1562 current->thread.debug.dbcr0 |= DBCR0_IDM | DBCR0_IC;
1558 regs->msr |= MSR_DE; 1563 regs->msr |= MSR_DE;
1559 return; 1564 return;
1560 } 1565 }
@@ -1582,13 +1587,13 @@ void __kprobes DebugException(struct pt_regs *regs, unsigned long debug_status)
1582 return; 1587 return;
1583 1588
1584 if (user_mode(regs)) { 1589 if (user_mode(regs)) {
1585 current->thread.dbcr0 &= ~DBCR0_IC; 1590 current->thread.debug.dbcr0 &= ~DBCR0_IC;
1586 if (DBCR_ACTIVE_EVENTS(current->thread.dbcr0, 1591 if (DBCR_ACTIVE_EVENTS(current->thread.debug.dbcr0,
1587 current->thread.dbcr1)) 1592 current->thread.debug.dbcr1))
1588 regs->msr |= MSR_DE; 1593 regs->msr |= MSR_DE;
1589 else 1594 else
1590 /* Make sure the IDM bit is off */ 1595 /* Make sure the IDM bit is off */
1591 current->thread.dbcr0 &= ~DBCR0_IDM; 1596 current->thread.debug.dbcr0 &= ~DBCR0_IDM;
1592 } 1597 }
1593 1598
1594 _exception(SIGTRAP, regs, TRAP_TRACE, regs->nip); 1599 _exception(SIGTRAP, regs, TRAP_TRACE, regs->nip);
@@ -1634,7 +1639,7 @@ void altivec_assist_exception(struct pt_regs *regs)
1634 /* XXX quick hack for now: set the non-Java bit in the VSCR */ 1639 /* XXX quick hack for now: set the non-Java bit in the VSCR */
1635 printk_ratelimited(KERN_ERR "Unrecognized altivec instruction " 1640 printk_ratelimited(KERN_ERR "Unrecognized altivec instruction "
1636 "in %s at %lx\n", current->comm, regs->nip); 1641 "in %s at %lx\n", current->comm, regs->nip);
1637 current->thread.vscr.u[3] |= 0x10000; 1642 current->thread.vr_state.vscr.u[3] |= 0x10000;
1638 } 1643 }
1639} 1644}
1640#endif /* CONFIG_ALTIVEC */ 1645#endif /* CONFIG_ALTIVEC */
@@ -1815,6 +1820,7 @@ struct ppc_emulated ppc_emulated = {
1815 WARN_EMULATED_SETUP(popcntb), 1820 WARN_EMULATED_SETUP(popcntb),
1816 WARN_EMULATED_SETUP(spe), 1821 WARN_EMULATED_SETUP(spe),
1817 WARN_EMULATED_SETUP(string), 1822 WARN_EMULATED_SETUP(string),
1823 WARN_EMULATED_SETUP(sync),
1818 WARN_EMULATED_SETUP(unaligned), 1824 WARN_EMULATED_SETUP(unaligned),
1819#ifdef CONFIG_MATH_EMULATION 1825#ifdef CONFIG_MATH_EMULATION
1820 WARN_EMULATED_SETUP(math), 1826 WARN_EMULATED_SETUP(math),
diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
index 1d9c92621b36..094e45c16a17 100644
--- a/arch/powerpc/kernel/vdso.c
+++ b/arch/powerpc/kernel/vdso.c
@@ -34,8 +34,7 @@
34#include <asm/firmware.h> 34#include <asm/firmware.h>
35#include <asm/vdso.h> 35#include <asm/vdso.h>
36#include <asm/vdso_datapage.h> 36#include <asm/vdso_datapage.h>
37 37#include <asm/setup.h>
38#include "setup.h"
39 38
40#undef DEBUG 39#undef DEBUG
41 40
diff --git a/arch/powerpc/kernel/vdso32/vdso32.lds.S b/arch/powerpc/kernel/vdso32/vdso32.lds.S
index f223409629b9..e58ee10fa5c0 100644
--- a/arch/powerpc/kernel/vdso32/vdso32.lds.S
+++ b/arch/powerpc/kernel/vdso32/vdso32.lds.S
@@ -4,7 +4,11 @@
4 */ 4 */
5#include <asm/vdso.h> 5#include <asm/vdso.h>
6 6
7#ifdef __LITTLE_ENDIAN__
8OUTPUT_FORMAT("elf32-powerpcle", "elf32-powerpcle", "elf32-powerpcle")
9#else
7OUTPUT_FORMAT("elf32-powerpc", "elf32-powerpc", "elf32-powerpc") 10OUTPUT_FORMAT("elf32-powerpc", "elf32-powerpc", "elf32-powerpc")
11#endif
8OUTPUT_ARCH(powerpc:common) 12OUTPUT_ARCH(powerpc:common)
9ENTRY(_start) 13ENTRY(_start)
10 14
diff --git a/arch/powerpc/kernel/vdso64/vdso64.lds.S b/arch/powerpc/kernel/vdso64/vdso64.lds.S
index e4863819663b..64fb183a47c2 100644
--- a/arch/powerpc/kernel/vdso64/vdso64.lds.S
+++ b/arch/powerpc/kernel/vdso64/vdso64.lds.S
@@ -4,7 +4,11 @@
4 */ 4 */
5#include <asm/vdso.h> 5#include <asm/vdso.h>
6 6
7#ifdef __LITTLE_ENDIAN__
8OUTPUT_FORMAT("elf64-powerpcle", "elf64-powerpcle", "elf64-powerpcle")
9#else
7OUTPUT_FORMAT("elf64-powerpc", "elf64-powerpc", "elf64-powerpc") 10OUTPUT_FORMAT("elf64-powerpc", "elf64-powerpc", "elf64-powerpc")
11#endif
8OUTPUT_ARCH(powerpc:common64) 12OUTPUT_ARCH(powerpc:common64)
9ENTRY(_start) 13ENTRY(_start)
10 14
diff --git a/arch/powerpc/kernel/vecemu.c b/arch/powerpc/kernel/vecemu.c
index 604d0947cb20..c4bfadb2606b 100644
--- a/arch/powerpc/kernel/vecemu.c
+++ b/arch/powerpc/kernel/vecemu.c
@@ -271,7 +271,7 @@ int emulate_altivec(struct pt_regs *regs)
271 vb = (instr >> 11) & 0x1f; 271 vb = (instr >> 11) & 0x1f;
272 vc = (instr >> 6) & 0x1f; 272 vc = (instr >> 6) & 0x1f;
273 273
274 vrs = current->thread.vr; 274 vrs = current->thread.vr_state.vr;
275 switch (instr & 0x3f) { 275 switch (instr & 0x3f) {
276 case 10: 276 case 10:
277 switch (vc) { 277 switch (vc) {
@@ -320,12 +320,12 @@ int emulate_altivec(struct pt_regs *regs)
320 case 14: /* vctuxs */ 320 case 14: /* vctuxs */
321 for (i = 0; i < 4; ++i) 321 for (i = 0; i < 4; ++i)
322 vrs[vd].u[i] = ctuxs(vrs[vb].u[i], va, 322 vrs[vd].u[i] = ctuxs(vrs[vb].u[i], va,
323 &current->thread.vscr.u[3]); 323 &current->thread.vr_state.vscr.u[3]);
324 break; 324 break;
325 case 15: /* vctsxs */ 325 case 15: /* vctsxs */
326 for (i = 0; i < 4; ++i) 326 for (i = 0; i < 4; ++i)
327 vrs[vd].u[i] = ctsxs(vrs[vb].u[i], va, 327 vrs[vd].u[i] = ctsxs(vrs[vb].u[i], va,
328 &current->thread.vscr.u[3]); 328 &current->thread.vr_state.vscr.u[3]);
329 break; 329 break;
330 default: 330 default:
331 return -EINVAL; 331 return -EINVAL;
diff --git a/arch/powerpc/kernel/vector.S b/arch/powerpc/kernel/vector.S
index 9e20999aaef2..0458a9aaba9d 100644
--- a/arch/powerpc/kernel/vector.S
+++ b/arch/powerpc/kernel/vector.S
@@ -8,29 +8,6 @@
8#include <asm/ptrace.h> 8#include <asm/ptrace.h>
9 9
10#ifdef CONFIG_PPC_TRANSACTIONAL_MEM 10#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
11/*
12 * Wrapper to call load_up_altivec from C.
13 * void do_load_up_altivec(struct pt_regs *regs);
14 */
15_GLOBAL(do_load_up_altivec)
16 mflr r0
17 std r0, 16(r1)
18 stdu r1, -112(r1)
19
20 subi r6, r3, STACK_FRAME_OVERHEAD
21 /* load_up_altivec expects r12=MSR, r13=PACA, and returns
22 * with r12 = new MSR.
23 */
24 ld r12,_MSR(r6)
25 GET_PACA(r13)
26 bl load_up_altivec
27 std r12,_MSR(r6)
28
29 ld r0, 112+16(r1)
30 addi r1, r1, 112
31 mtlr r0
32 blr
33
34/* void do_load_up_transact_altivec(struct thread_struct *thread) 11/* void do_load_up_transact_altivec(struct thread_struct *thread)
35 * 12 *
36 * This is similar to load_up_altivec but for the transactional version of the 13 * This is similar to load_up_altivec but for the transactional version of the
@@ -46,10 +23,11 @@ _GLOBAL(do_load_up_transact_altivec)
46 li r4,1 23 li r4,1
47 stw r4,THREAD_USED_VR(r3) 24 stw r4,THREAD_USED_VR(r3)
48 25
49 li r10,THREAD_TRANSACT_VSCR 26 li r10,THREAD_TRANSACT_VRSTATE+VRSTATE_VSCR
50 lvx vr0,r10,r3 27 lvx vr0,r10,r3
51 mtvscr vr0 28 mtvscr vr0
52 REST_32VRS_TRANSACT(0,r4,r3) 29 addi r10,r3,THREAD_TRANSACT_VRSTATE
30 REST_32VRS(0,r4,r10)
53 31
54 /* Disable VEC again. */ 32 /* Disable VEC again. */
55 MTMSRD(r6) 33 MTMSRD(r6)
@@ -59,12 +37,36 @@ _GLOBAL(do_load_up_transact_altivec)
59#endif 37#endif
60 38
61/* 39/*
62 * load_up_altivec(unused, unused, tsk) 40 * Load state from memory into VMX registers including VSCR.
41 * Assumes the caller has enabled VMX in the MSR.
42 */
43_GLOBAL(load_vr_state)
44 li r4,VRSTATE_VSCR
45 lvx vr0,r4,r3
46 mtvscr vr0
47 REST_32VRS(0,r4,r3)
48 blr
49
50/*
51 * Store VMX state into memory, including VSCR.
52 * Assumes the caller has enabled VMX in the MSR.
53 */
54_GLOBAL(store_vr_state)
55 SAVE_32VRS(0, r4, r3)
56 mfvscr vr0
57 li r4, VRSTATE_VSCR
58 stvx vr0, r4, r3
59 blr
60
61/*
63 * Disable VMX for the task which had it previously, 62 * Disable VMX for the task which had it previously,
64 * and save its vector registers in its thread_struct. 63 * and save its vector registers in its thread_struct.
65 * Enables the VMX for use in the kernel on return. 64 * Enables the VMX for use in the kernel on return.
66 * On SMP we know the VMX is free, since we give it up every 65 * On SMP we know the VMX is free, since we give it up every
67 * switch (ie, no lazy save of the vector registers). 66 * switch (ie, no lazy save of the vector registers).
67 *
68 * Note that on 32-bit this can only use registers that will be
69 * restored by fast_exception_return, i.e. r3 - r6, r10 and r11.
68 */ 70 */
69_GLOBAL(load_up_altivec) 71_GLOBAL(load_up_altivec)
70 mfmsr r5 /* grab the current MSR */ 72 mfmsr r5 /* grab the current MSR */
@@ -90,10 +92,11 @@ _GLOBAL(load_up_altivec)
90 /* Save VMX state to last_task_used_altivec's THREAD struct */ 92 /* Save VMX state to last_task_used_altivec's THREAD struct */
91 toreal(r4) 93 toreal(r4)
92 addi r4,r4,THREAD 94 addi r4,r4,THREAD
93 SAVE_32VRS(0,r5,r4) 95 addi r6,r4,THREAD_VRSTATE
96 SAVE_32VRS(0,r5,r6)
94 mfvscr vr0 97 mfvscr vr0
95 li r10,THREAD_VSCR 98 li r10,VRSTATE_VSCR
96 stvx vr0,r10,r4 99 stvx vr0,r10,r6
97 /* Disable VMX for last_task_used_altivec */ 100 /* Disable VMX for last_task_used_altivec */
98 PPC_LL r5,PT_REGS(r4) 101 PPC_LL r5,PT_REGS(r4)
99 toreal(r5) 102 toreal(r5)
@@ -125,12 +128,13 @@ _GLOBAL(load_up_altivec)
125 oris r12,r12,MSR_VEC@h 128 oris r12,r12,MSR_VEC@h
126 std r12,_MSR(r1) 129 std r12,_MSR(r1)
127#endif 130#endif
131 addi r6,r5,THREAD_VRSTATE
128 li r4,1 132 li r4,1
129 li r10,THREAD_VSCR 133 li r10,VRSTATE_VSCR
130 stw r4,THREAD_USED_VR(r5) 134 stw r4,THREAD_USED_VR(r5)
131 lvx vr0,r10,r5 135 lvx vr0,r10,r6
132 mtvscr vr0 136 mtvscr vr0
133 REST_32VRS(0,r4,r5) 137 REST_32VRS(0,r4,r6)
134#ifndef CONFIG_SMP 138#ifndef CONFIG_SMP
135 /* Update last_task_used_altivec to 'current' */ 139 /* Update last_task_used_altivec to 'current' */
136 subi r4,r5,THREAD /* Back to 'current' */ 140 subi r4,r5,THREAD /* Back to 'current' */
@@ -165,12 +169,16 @@ _GLOBAL(giveup_altivec)
165 PPC_LCMPI 0,r3,0 169 PPC_LCMPI 0,r3,0
166 beqlr /* if no previous owner, done */ 170 beqlr /* if no previous owner, done */
167 addi r3,r3,THREAD /* want THREAD of task */ 171 addi r3,r3,THREAD /* want THREAD of task */
172 PPC_LL r7,THREAD_VRSAVEAREA(r3)
168 PPC_LL r5,PT_REGS(r3) 173 PPC_LL r5,PT_REGS(r3)
169 PPC_LCMPI 0,r5,0 174 PPC_LCMPI 0,r7,0
170 SAVE_32VRS(0,r4,r3) 175 bne 2f
176 addi r7,r3,THREAD_VRSTATE
1772: PPC_LCMPI 0,r5,0
178 SAVE_32VRS(0,r4,r7)
171 mfvscr vr0 179 mfvscr vr0
172 li r4,THREAD_VSCR 180 li r4,VRSTATE_VSCR
173 stvx vr0,r4,r3 181 stvx vr0,r4,r7
174 beq 1f 182 beq 1f
175 PPC_LL r4,_MSR-STACK_FRAME_OVERHEAD(r5) 183 PPC_LL r4,_MSR-STACK_FRAME_OVERHEAD(r5)
176#ifdef CONFIG_VSX 184#ifdef CONFIG_VSX
diff --git a/arch/powerpc/kernel/vio.c b/arch/powerpc/kernel/vio.c
index 408956fbf4f6..f99cefbd84e3 100644
--- a/arch/powerpc/kernel/vio.c
+++ b/arch/powerpc/kernel/vio.c
@@ -1537,12 +1537,12 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
1537 1537
1538 dn = dev->of_node; 1538 dn = dev->of_node;
1539 if (!dn) { 1539 if (!dn) {
1540 strcat(buf, "\n"); 1540 strcpy(buf, "\n");
1541 return strlen(buf); 1541 return strlen(buf);
1542 } 1542 }
1543 cp = of_get_property(dn, "compatible", NULL); 1543 cp = of_get_property(dn, "compatible", NULL);
1544 if (!cp) { 1544 if (!cp) {
1545 strcat(buf, "\n"); 1545 strcpy(buf, "\n");
1546 return strlen(buf); 1546 return strlen(buf);
1547 } 1547 }
1548 1548
diff --git a/arch/powerpc/kvm/Kconfig b/arch/powerpc/kvm/Kconfig
index ffaef2cb101a..e593ff257bd3 100644
--- a/arch/powerpc/kvm/Kconfig
+++ b/arch/powerpc/kvm/Kconfig
@@ -6,6 +6,7 @@ source "virt/kvm/Kconfig"
6 6
7menuconfig VIRTUALIZATION 7menuconfig VIRTUALIZATION
8 bool "Virtualization" 8 bool "Virtualization"
9 depends on !CPU_LITTLE_ENDIAN
9 ---help--- 10 ---help---
10 Say Y here to get to see options for using your Linux host to run 11 Say Y here to get to see options for using your Linux host to run
11 other operating systems inside virtual machines (guests). 12 other operating systems inside virtual machines (guests).
diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_pr.c
index 27db1e665959..c0b48f96a91c 100644
--- a/arch/powerpc/kvm/book3s_pr.c
+++ b/arch/powerpc/kvm/book3s_pr.c
@@ -444,7 +444,7 @@ void kvmppc_giveup_ext(struct kvm_vcpu *vcpu, ulong msr)
444#ifdef CONFIG_VSX 444#ifdef CONFIG_VSX
445 u64 *vcpu_vsx = vcpu->arch.vsr; 445 u64 *vcpu_vsx = vcpu->arch.vsr;
446#endif 446#endif
447 u64 *thread_fpr = (u64*)t->fpr; 447 u64 *thread_fpr = &t->fp_state.fpr[0][0];
448 int i; 448 int i;
449 449
450 /* 450 /*
@@ -466,14 +466,14 @@ void kvmppc_giveup_ext(struct kvm_vcpu *vcpu, ulong msr)
466 /* 466 /*
467 * Note that on CPUs with VSX, giveup_fpu stores 467 * Note that on CPUs with VSX, giveup_fpu stores
468 * both the traditional FP registers and the added VSX 468 * both the traditional FP registers and the added VSX
469 * registers into thread.fpr[]. 469 * registers into thread.fp_state.fpr[].
470 */ 470 */
471 if (current->thread.regs->msr & MSR_FP) 471 if (current->thread.regs->msr & MSR_FP)
472 giveup_fpu(current); 472 giveup_fpu(current);
473 for (i = 0; i < ARRAY_SIZE(vcpu->arch.fpr); i++) 473 for (i = 0; i < ARRAY_SIZE(vcpu->arch.fpr); i++)
474 vcpu_fpr[i] = thread_fpr[get_fpr_index(i)]; 474 vcpu_fpr[i] = thread_fpr[get_fpr_index(i)];
475 475
476 vcpu->arch.fpscr = t->fpscr.val; 476 vcpu->arch.fpscr = t->fp_state.fpscr;
477 477
478#ifdef CONFIG_VSX 478#ifdef CONFIG_VSX
479 if (cpu_has_feature(CPU_FTR_VSX)) 479 if (cpu_has_feature(CPU_FTR_VSX))
@@ -486,8 +486,8 @@ void kvmppc_giveup_ext(struct kvm_vcpu *vcpu, ulong msr)
486 if (msr & MSR_VEC) { 486 if (msr & MSR_VEC) {
487 if (current->thread.regs->msr & MSR_VEC) 487 if (current->thread.regs->msr & MSR_VEC)
488 giveup_altivec(current); 488 giveup_altivec(current);
489 memcpy(vcpu->arch.vr, t->vr, sizeof(vcpu->arch.vr)); 489 memcpy(vcpu->arch.vr, t->vr_state.vr, sizeof(vcpu->arch.vr));
490 vcpu->arch.vscr = t->vscr; 490 vcpu->arch.vscr = t->vr_state.vscr;
491 } 491 }
492#endif 492#endif
493 493
@@ -539,7 +539,7 @@ static int kvmppc_handle_ext(struct kvm_vcpu *vcpu, unsigned int exit_nr,
539#ifdef CONFIG_VSX 539#ifdef CONFIG_VSX
540 u64 *vcpu_vsx = vcpu->arch.vsr; 540 u64 *vcpu_vsx = vcpu->arch.vsr;
541#endif 541#endif
542 u64 *thread_fpr = (u64*)t->fpr; 542 u64 *thread_fpr = &t->fp_state.fpr[0][0];
543 int i; 543 int i;
544 544
545 /* When we have paired singles, we emulate in software */ 545 /* When we have paired singles, we emulate in software */
@@ -584,15 +584,15 @@ static int kvmppc_handle_ext(struct kvm_vcpu *vcpu, unsigned int exit_nr,
584 for (i = 0; i < ARRAY_SIZE(vcpu->arch.vsr) / 2; i++) 584 for (i = 0; i < ARRAY_SIZE(vcpu->arch.vsr) / 2; i++)
585 thread_fpr[get_fpr_index(i) + 1] = vcpu_vsx[i]; 585 thread_fpr[get_fpr_index(i) + 1] = vcpu_vsx[i];
586#endif 586#endif
587 t->fpscr.val = vcpu->arch.fpscr; 587 t->fp_state.fpscr = vcpu->arch.fpscr;
588 t->fpexc_mode = 0; 588 t->fpexc_mode = 0;
589 kvmppc_load_up_fpu(); 589 kvmppc_load_up_fpu();
590 } 590 }
591 591
592 if (msr & MSR_VEC) { 592 if (msr & MSR_VEC) {
593#ifdef CONFIG_ALTIVEC 593#ifdef CONFIG_ALTIVEC
594 memcpy(t->vr, vcpu->arch.vr, sizeof(vcpu->arch.vr)); 594 memcpy(t->vr_state.vr, vcpu->arch.vr, sizeof(vcpu->arch.vr));
595 t->vscr = vcpu->arch.vscr; 595 t->vr_state.vscr = vcpu->arch.vscr;
596 t->vrsave = -1; 596 t->vrsave = -1;
597 kvmppc_load_up_altivec(); 597 kvmppc_load_up_altivec();
598#endif 598#endif
@@ -1116,12 +1116,10 @@ void kvmppc_core_vcpu_free(struct kvm_vcpu *vcpu)
1116int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) 1116int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
1117{ 1117{
1118 int ret; 1118 int ret;
1119 double fpr[32][TS_FPRWIDTH]; 1119 struct thread_fp_state fp;
1120 unsigned int fpscr;
1121 int fpexc_mode; 1120 int fpexc_mode;
1122#ifdef CONFIG_ALTIVEC 1121#ifdef CONFIG_ALTIVEC
1123 vector128 vr[32]; 1122 struct thread_vr_state vr;
1124 vector128 vscr;
1125 unsigned long uninitialized_var(vrsave); 1123 unsigned long uninitialized_var(vrsave);
1126 int used_vr; 1124 int used_vr;
1127#endif 1125#endif
@@ -1153,8 +1151,7 @@ int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
1153 /* Save FPU state in stack */ 1151 /* Save FPU state in stack */
1154 if (current->thread.regs->msr & MSR_FP) 1152 if (current->thread.regs->msr & MSR_FP)
1155 giveup_fpu(current); 1153 giveup_fpu(current);
1156 memcpy(fpr, current->thread.fpr, sizeof(current->thread.fpr)); 1154 fp = current->thread.fp_state;
1157 fpscr = current->thread.fpscr.val;
1158 fpexc_mode = current->thread.fpexc_mode; 1155 fpexc_mode = current->thread.fpexc_mode;
1159 1156
1160#ifdef CONFIG_ALTIVEC 1157#ifdef CONFIG_ALTIVEC
@@ -1163,8 +1160,7 @@ int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
1163 if (used_vr) { 1160 if (used_vr) {
1164 if (current->thread.regs->msr & MSR_VEC) 1161 if (current->thread.regs->msr & MSR_VEC)
1165 giveup_altivec(current); 1162 giveup_altivec(current);
1166 memcpy(vr, current->thread.vr, sizeof(current->thread.vr)); 1163 vr = current->thread.vr_state;
1167 vscr = current->thread.vscr;
1168 vrsave = current->thread.vrsave; 1164 vrsave = current->thread.vrsave;
1169 } 1165 }
1170#endif 1166#endif
@@ -1196,15 +1192,13 @@ int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
1196 current->thread.regs->msr = ext_msr; 1192 current->thread.regs->msr = ext_msr;
1197 1193
1198 /* Restore FPU/VSX state from stack */ 1194 /* Restore FPU/VSX state from stack */
1199 memcpy(current->thread.fpr, fpr, sizeof(current->thread.fpr)); 1195 current->thread.fp_state = fp;
1200 current->thread.fpscr.val = fpscr;
1201 current->thread.fpexc_mode = fpexc_mode; 1196 current->thread.fpexc_mode = fpexc_mode;
1202 1197
1203#ifdef CONFIG_ALTIVEC 1198#ifdef CONFIG_ALTIVEC
1204 /* Restore Altivec state from stack */ 1199 /* Restore Altivec state from stack */
1205 if (used_vr && current->thread.used_vr) { 1200 if (used_vr && current->thread.used_vr) {
1206 memcpy(current->thread.vr, vr, sizeof(current->thread.vr)); 1201 current->thread.vr_state = vr;
1207 current->thread.vscr = vscr;
1208 current->thread.vrsave = vrsave; 1202 current->thread.vrsave = vrsave;
1209 } 1203 }
1210 current->thread.used_vr = used_vr; 1204 current->thread.used_vr = used_vr;
diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
index 17722d82f1d1..5133199f6cb7 100644
--- a/arch/powerpc/kvm/booke.c
+++ b/arch/powerpc/kvm/booke.c
@@ -656,9 +656,8 @@ int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
656{ 656{
657 int ret, s; 657 int ret, s;
658#ifdef CONFIG_PPC_FPU 658#ifdef CONFIG_PPC_FPU
659 unsigned int fpscr; 659 struct thread_fp_state fp;
660 int fpexc_mode; 660 int fpexc_mode;
661 u64 fpr[32];
662#endif 661#endif
663 662
664 if (!vcpu->arch.sane) { 663 if (!vcpu->arch.sane) {
@@ -677,13 +676,13 @@ int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
677#ifdef CONFIG_PPC_FPU 676#ifdef CONFIG_PPC_FPU
678 /* Save userspace FPU state in stack */ 677 /* Save userspace FPU state in stack */
679 enable_kernel_fp(); 678 enable_kernel_fp();
680 memcpy(fpr, current->thread.fpr, sizeof(current->thread.fpr)); 679 fp = current->thread.fp_state;
681 fpscr = current->thread.fpscr.val;
682 fpexc_mode = current->thread.fpexc_mode; 680 fpexc_mode = current->thread.fpexc_mode;
683 681
684 /* Restore guest FPU state to thread */ 682 /* Restore guest FPU state to thread */
685 memcpy(current->thread.fpr, vcpu->arch.fpr, sizeof(vcpu->arch.fpr)); 683 memcpy(current->thread.fp_state.fpr, vcpu->arch.fpr,
686 current->thread.fpscr.val = vcpu->arch.fpscr; 684 sizeof(vcpu->arch.fpr));
685 current->thread.fp_state.fpscr = vcpu->arch.fpscr;
687 686
688 /* 687 /*
689 * Since we can't trap on MSR_FP in GS-mode, we consider the guest 688 * Since we can't trap on MSR_FP in GS-mode, we consider the guest
@@ -709,12 +708,12 @@ int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
709 vcpu->fpu_active = 0; 708 vcpu->fpu_active = 0;
710 709
711 /* Save guest FPU state from thread */ 710 /* Save guest FPU state from thread */
712 memcpy(vcpu->arch.fpr, current->thread.fpr, sizeof(vcpu->arch.fpr)); 711 memcpy(vcpu->arch.fpr, current->thread.fp_state.fpr,
713 vcpu->arch.fpscr = current->thread.fpscr.val; 712 sizeof(vcpu->arch.fpr));
713 vcpu->arch.fpscr = current->thread.fp_state.fpscr;
714 714
715 /* Restore userspace FPU state from stack */ 715 /* Restore userspace FPU state from stack */
716 memcpy(current->thread.fpr, fpr, sizeof(current->thread.fpr)); 716 current->thread.fp_state = fp;
717 current->thread.fpscr.val = fpscr;
718 current->thread.fpexc_mode = fpexc_mode; 717 current->thread.fpexc_mode = fpexc_mode;
719#endif 718#endif
720 719
diff --git a/arch/powerpc/lib/Makefile b/arch/powerpc/lib/Makefile
index 450433276699..95a20e17dbff 100644
--- a/arch/powerpc/lib/Makefile
+++ b/arch/powerpc/lib/Makefile
@@ -10,15 +10,23 @@ CFLAGS_REMOVE_code-patching.o = -pg
10CFLAGS_REMOVE_feature-fixups.o = -pg 10CFLAGS_REMOVE_feature-fixups.o = -pg
11 11
12obj-y := string.o alloc.o \ 12obj-y := string.o alloc.o \
13 checksum_$(CONFIG_WORD_SIZE).o crtsavres.o 13 crtsavres.o
14obj-$(CONFIG_PPC32) += div64.o copy_32.o 14obj-$(CONFIG_PPC32) += div64.o copy_32.o
15obj-$(CONFIG_HAS_IOMEM) += devres.o 15obj-$(CONFIG_HAS_IOMEM) += devres.o
16 16
17obj-$(CONFIG_PPC64) += copypage_64.o copyuser_64.o \ 17obj-$(CONFIG_PPC64) += copypage_64.o copyuser_64.o \
18 memcpy_64.o usercopy_64.o mem_64.o string.o \ 18 usercopy_64.o mem_64.o string.o \
19 checksum_wrappers_64.o hweight_64.o \ 19 hweight_64.o \
20 copyuser_power7.o string_64.o copypage_power7.o \ 20 copyuser_power7.o string_64.o copypage_power7.o
21 memcpy_power7.o 21ifeq ($(CONFIG_GENERIC_CSUM),)
22obj-y += checksum_$(CONFIG_WORD_SIZE).o
23obj-$(CONFIG_PPC64) += checksum_wrappers_64.o
24endif
25
26ifeq ($(CONFIG_CPU_LITTLE_ENDIAN),)
27obj-$(CONFIG_PPC64) += memcpy_power7.o memcpy_64.o
28endif
29
22obj-$(CONFIG_PPC_EMULATE_SSTEP) += sstep.o ldstfp.o 30obj-$(CONFIG_PPC_EMULATE_SSTEP) += sstep.o ldstfp.o
23 31
24ifeq ($(CONFIG_PPC64),y) 32ifeq ($(CONFIG_PPC64),y)
@@ -31,3 +39,6 @@ obj-$(CONFIG_PPC_LIB_RHEAP) += rheap.o
31obj-y += code-patching.o 39obj-y += code-patching.o
32obj-y += feature-fixups.o 40obj-y += feature-fixups.o
33obj-$(CONFIG_FTR_FIXUP_SELFTEST) += feature-fixups-test.o 41obj-$(CONFIG_FTR_FIXUP_SELFTEST) += feature-fixups-test.o
42
43obj-$(CONFIG_ALTIVEC) += xor_vmx.o
44CFLAGS_xor_vmx.o += -maltivec -mabi=altivec
diff --git a/arch/powerpc/lib/copyuser_power7.S b/arch/powerpc/lib/copyuser_power7.S
index d1f11795a7ad..e8e9c36dc784 100644
--- a/arch/powerpc/lib/copyuser_power7.S
+++ b/arch/powerpc/lib/copyuser_power7.S
@@ -19,6 +19,14 @@
19 */ 19 */
20#include <asm/ppc_asm.h> 20#include <asm/ppc_asm.h>
21 21
22#ifdef __BIG_ENDIAN__
23#define LVS(VRT,RA,RB) lvsl VRT,RA,RB
24#define VPERM(VRT,VRA,VRB,VRC) vperm VRT,VRA,VRB,VRC
25#else
26#define LVS(VRT,RA,RB) lvsr VRT,RA,RB
27#define VPERM(VRT,VRA,VRB,VRC) vperm VRT,VRB,VRA,VRC
28#endif
29
22 .macro err1 30 .macro err1
23100: 31100:
24 .section __ex_table,"a" 32 .section __ex_table,"a"
@@ -552,13 +560,13 @@ err3; stw r7,4(r3)
552 li r10,32 560 li r10,32
553 li r11,48 561 li r11,48
554 562
555 lvsl vr16,0,r4 /* Setup permute control vector */ 563 LVS(vr16,0,r4) /* Setup permute control vector */
556err3; lvx vr0,0,r4 564err3; lvx vr0,0,r4
557 addi r4,r4,16 565 addi r4,r4,16
558 566
559 bf cr7*4+3,5f 567 bf cr7*4+3,5f
560err3; lvx vr1,r0,r4 568err3; lvx vr1,r0,r4
561 vperm vr8,vr0,vr1,vr16 569 VPERM(vr8,vr0,vr1,vr16)
562 addi r4,r4,16 570 addi r4,r4,16
563err3; stvx vr8,r0,r3 571err3; stvx vr8,r0,r3
564 addi r3,r3,16 572 addi r3,r3,16
@@ -566,9 +574,9 @@ err3; stvx vr8,r0,r3
566 574
5675: bf cr7*4+2,6f 5755: bf cr7*4+2,6f
568err3; lvx vr1,r0,r4 576err3; lvx vr1,r0,r4
569 vperm vr8,vr0,vr1,vr16 577 VPERM(vr8,vr0,vr1,vr16)
570err3; lvx vr0,r4,r9 578err3; lvx vr0,r4,r9
571 vperm vr9,vr1,vr0,vr16 579 VPERM(vr9,vr1,vr0,vr16)
572 addi r4,r4,32 580 addi r4,r4,32
573err3; stvx vr8,r0,r3 581err3; stvx vr8,r0,r3
574err3; stvx vr9,r3,r9 582err3; stvx vr9,r3,r9
@@ -576,13 +584,13 @@ err3; stvx vr9,r3,r9
576 584
5776: bf cr7*4+1,7f 5856: bf cr7*4+1,7f
578err3; lvx vr3,r0,r4 586err3; lvx vr3,r0,r4
579 vperm vr8,vr0,vr3,vr16 587 VPERM(vr8,vr0,vr3,vr16)
580err3; lvx vr2,r4,r9 588err3; lvx vr2,r4,r9
581 vperm vr9,vr3,vr2,vr16 589 VPERM(vr9,vr3,vr2,vr16)
582err3; lvx vr1,r4,r10 590err3; lvx vr1,r4,r10
583 vperm vr10,vr2,vr1,vr16 591 VPERM(vr10,vr2,vr1,vr16)
584err3; lvx vr0,r4,r11 592err3; lvx vr0,r4,r11
585 vperm vr11,vr1,vr0,vr16 593 VPERM(vr11,vr1,vr0,vr16)
586 addi r4,r4,64 594 addi r4,r4,64
587err3; stvx vr8,r0,r3 595err3; stvx vr8,r0,r3
588err3; stvx vr9,r3,r9 596err3; stvx vr9,r3,r9
@@ -611,21 +619,21 @@ err3; stvx vr11,r3,r11
611 .align 5 619 .align 5
6128: 6208:
613err4; lvx vr7,r0,r4 621err4; lvx vr7,r0,r4
614 vperm vr8,vr0,vr7,vr16 622 VPERM(vr8,vr0,vr7,vr16)
615err4; lvx vr6,r4,r9 623err4; lvx vr6,r4,r9
616 vperm vr9,vr7,vr6,vr16 624 VPERM(vr9,vr7,vr6,vr16)
617err4; lvx vr5,r4,r10 625err4; lvx vr5,r4,r10
618 vperm vr10,vr6,vr5,vr16 626 VPERM(vr10,vr6,vr5,vr16)
619err4; lvx vr4,r4,r11 627err4; lvx vr4,r4,r11
620 vperm vr11,vr5,vr4,vr16 628 VPERM(vr11,vr5,vr4,vr16)
621err4; lvx vr3,r4,r12 629err4; lvx vr3,r4,r12
622 vperm vr12,vr4,vr3,vr16 630 VPERM(vr12,vr4,vr3,vr16)
623err4; lvx vr2,r4,r14 631err4; lvx vr2,r4,r14
624 vperm vr13,vr3,vr2,vr16 632 VPERM(vr13,vr3,vr2,vr16)
625err4; lvx vr1,r4,r15 633err4; lvx vr1,r4,r15
626 vperm vr14,vr2,vr1,vr16 634 VPERM(vr14,vr2,vr1,vr16)
627err4; lvx vr0,r4,r16 635err4; lvx vr0,r4,r16
628 vperm vr15,vr1,vr0,vr16 636 VPERM(vr15,vr1,vr0,vr16)
629 addi r4,r4,128 637 addi r4,r4,128
630err4; stvx vr8,r0,r3 638err4; stvx vr8,r0,r3
631err4; stvx vr9,r3,r9 639err4; stvx vr9,r3,r9
@@ -649,13 +657,13 @@ err4; stvx vr15,r3,r16
649 657
650 bf cr7*4+1,9f 658 bf cr7*4+1,9f
651err3; lvx vr3,r0,r4 659err3; lvx vr3,r0,r4
652 vperm vr8,vr0,vr3,vr16 660 VPERM(vr8,vr0,vr3,vr16)
653err3; lvx vr2,r4,r9 661err3; lvx vr2,r4,r9
654 vperm vr9,vr3,vr2,vr16 662 VPERM(vr9,vr3,vr2,vr16)
655err3; lvx vr1,r4,r10 663err3; lvx vr1,r4,r10
656 vperm vr10,vr2,vr1,vr16 664 VPERM(vr10,vr2,vr1,vr16)
657err3; lvx vr0,r4,r11 665err3; lvx vr0,r4,r11
658 vperm vr11,vr1,vr0,vr16 666 VPERM(vr11,vr1,vr0,vr16)
659 addi r4,r4,64 667 addi r4,r4,64
660err3; stvx vr8,r0,r3 668err3; stvx vr8,r0,r3
661err3; stvx vr9,r3,r9 669err3; stvx vr9,r3,r9
@@ -665,9 +673,9 @@ err3; stvx vr11,r3,r11
665 673
6669: bf cr7*4+2,10f 6749: bf cr7*4+2,10f
667err3; lvx vr1,r0,r4 675err3; lvx vr1,r0,r4
668 vperm vr8,vr0,vr1,vr16 676 VPERM(vr8,vr0,vr1,vr16)
669err3; lvx vr0,r4,r9 677err3; lvx vr0,r4,r9
670 vperm vr9,vr1,vr0,vr16 678 VPERM(vr9,vr1,vr0,vr16)
671 addi r4,r4,32 679 addi r4,r4,32
672err3; stvx vr8,r0,r3 680err3; stvx vr8,r0,r3
673err3; stvx vr9,r3,r9 681err3; stvx vr9,r3,r9
@@ -675,7 +683,7 @@ err3; stvx vr9,r3,r9
675 683
67610: bf cr7*4+3,11f 68410: bf cr7*4+3,11f
677err3; lvx vr1,r0,r4 685err3; lvx vr1,r0,r4
678 vperm vr8,vr0,vr1,vr16 686 VPERM(vr8,vr0,vr1,vr16)
679 addi r4,r4,16 687 addi r4,r4,16
680err3; stvx vr8,r0,r3 688err3; stvx vr8,r0,r3
681 addi r3,r3,16 689 addi r3,r3,16
diff --git a/arch/powerpc/lib/memcpy_power7.S b/arch/powerpc/lib/memcpy_power7.S
index 0663630baf3b..e4177dbea6bd 100644
--- a/arch/powerpc/lib/memcpy_power7.S
+++ b/arch/powerpc/lib/memcpy_power7.S
@@ -20,6 +20,15 @@
20#include <asm/ppc_asm.h> 20#include <asm/ppc_asm.h>
21 21
22_GLOBAL(memcpy_power7) 22_GLOBAL(memcpy_power7)
23
24#ifdef __BIG_ENDIAN__
25#define LVS(VRT,RA,RB) lvsl VRT,RA,RB
26#define VPERM(VRT,VRA,VRB,VRC) vperm VRT,VRA,VRB,VRC
27#else
28#define LVS(VRT,RA,RB) lvsr VRT,RA,RB
29#define VPERM(VRT,VRA,VRB,VRC) vperm VRT,VRB,VRA,VRC
30#endif
31
23#ifdef CONFIG_ALTIVEC 32#ifdef CONFIG_ALTIVEC
24 cmpldi r5,16 33 cmpldi r5,16
25 cmpldi cr1,r5,4096 34 cmpldi cr1,r5,4096
@@ -485,13 +494,13 @@ _GLOBAL(memcpy_power7)
485 li r10,32 494 li r10,32
486 li r11,48 495 li r11,48
487 496
488 lvsl vr16,0,r4 /* Setup permute control vector */ 497 LVS(vr16,0,r4) /* Setup permute control vector */
489 lvx vr0,0,r4 498 lvx vr0,0,r4
490 addi r4,r4,16 499 addi r4,r4,16
491 500
492 bf cr7*4+3,5f 501 bf cr7*4+3,5f
493 lvx vr1,r0,r4 502 lvx vr1,r0,r4
494 vperm vr8,vr0,vr1,vr16 503 VPERM(vr8,vr0,vr1,vr16)
495 addi r4,r4,16 504 addi r4,r4,16
496 stvx vr8,r0,r3 505 stvx vr8,r0,r3
497 addi r3,r3,16 506 addi r3,r3,16
@@ -499,9 +508,9 @@ _GLOBAL(memcpy_power7)
499 508
5005: bf cr7*4+2,6f 5095: bf cr7*4+2,6f
501 lvx vr1,r0,r4 510 lvx vr1,r0,r4
502 vperm vr8,vr0,vr1,vr16 511 VPERM(vr8,vr0,vr1,vr16)
503 lvx vr0,r4,r9 512 lvx vr0,r4,r9
504 vperm vr9,vr1,vr0,vr16 513 VPERM(vr9,vr1,vr0,vr16)
505 addi r4,r4,32 514 addi r4,r4,32
506 stvx vr8,r0,r3 515 stvx vr8,r0,r3
507 stvx vr9,r3,r9 516 stvx vr9,r3,r9
@@ -509,13 +518,13 @@ _GLOBAL(memcpy_power7)
509 518
5106: bf cr7*4+1,7f 5196: bf cr7*4+1,7f
511 lvx vr3,r0,r4 520 lvx vr3,r0,r4
512 vperm vr8,vr0,vr3,vr16 521 VPERM(vr8,vr0,vr3,vr16)
513 lvx vr2,r4,r9 522 lvx vr2,r4,r9
514 vperm vr9,vr3,vr2,vr16 523 VPERM(vr9,vr3,vr2,vr16)
515 lvx vr1,r4,r10 524 lvx vr1,r4,r10
516 vperm vr10,vr2,vr1,vr16 525 VPERM(vr10,vr2,vr1,vr16)
517 lvx vr0,r4,r11 526 lvx vr0,r4,r11
518 vperm vr11,vr1,vr0,vr16 527 VPERM(vr11,vr1,vr0,vr16)
519 addi r4,r4,64 528 addi r4,r4,64
520 stvx vr8,r0,r3 529 stvx vr8,r0,r3
521 stvx vr9,r3,r9 530 stvx vr9,r3,r9
@@ -544,21 +553,21 @@ _GLOBAL(memcpy_power7)
544 .align 5 553 .align 5
5458: 5548:
546 lvx vr7,r0,r4 555 lvx vr7,r0,r4
547 vperm vr8,vr0,vr7,vr16 556 VPERM(vr8,vr0,vr7,vr16)
548 lvx vr6,r4,r9 557 lvx vr6,r4,r9
549 vperm vr9,vr7,vr6,vr16 558 VPERM(vr9,vr7,vr6,vr16)
550 lvx vr5,r4,r10 559 lvx vr5,r4,r10
551 vperm vr10,vr6,vr5,vr16 560 VPERM(vr10,vr6,vr5,vr16)
552 lvx vr4,r4,r11 561 lvx vr4,r4,r11
553 vperm vr11,vr5,vr4,vr16 562 VPERM(vr11,vr5,vr4,vr16)
554 lvx vr3,r4,r12 563 lvx vr3,r4,r12
555 vperm vr12,vr4,vr3,vr16 564 VPERM(vr12,vr4,vr3,vr16)
556 lvx vr2,r4,r14 565 lvx vr2,r4,r14
557 vperm vr13,vr3,vr2,vr16 566 VPERM(vr13,vr3,vr2,vr16)
558 lvx vr1,r4,r15 567 lvx vr1,r4,r15
559 vperm vr14,vr2,vr1,vr16 568 VPERM(vr14,vr2,vr1,vr16)
560 lvx vr0,r4,r16 569 lvx vr0,r4,r16
561 vperm vr15,vr1,vr0,vr16 570 VPERM(vr15,vr1,vr0,vr16)
562 addi r4,r4,128 571 addi r4,r4,128
563 stvx vr8,r0,r3 572 stvx vr8,r0,r3
564 stvx vr9,r3,r9 573 stvx vr9,r3,r9
@@ -582,13 +591,13 @@ _GLOBAL(memcpy_power7)
582 591
583 bf cr7*4+1,9f 592 bf cr7*4+1,9f
584 lvx vr3,r0,r4 593 lvx vr3,r0,r4
585 vperm vr8,vr0,vr3,vr16 594 VPERM(vr8,vr0,vr3,vr16)
586 lvx vr2,r4,r9 595 lvx vr2,r4,r9
587 vperm vr9,vr3,vr2,vr16 596 VPERM(vr9,vr3,vr2,vr16)
588 lvx vr1,r4,r10 597 lvx vr1,r4,r10
589 vperm vr10,vr2,vr1,vr16 598 VPERM(vr10,vr2,vr1,vr16)
590 lvx vr0,r4,r11 599 lvx vr0,r4,r11
591 vperm vr11,vr1,vr0,vr16 600 VPERM(vr11,vr1,vr0,vr16)
592 addi r4,r4,64 601 addi r4,r4,64
593 stvx vr8,r0,r3 602 stvx vr8,r0,r3
594 stvx vr9,r3,r9 603 stvx vr9,r3,r9
@@ -598,9 +607,9 @@ _GLOBAL(memcpy_power7)
598 607
5999: bf cr7*4+2,10f 6089: bf cr7*4+2,10f
600 lvx vr1,r0,r4 609 lvx vr1,r0,r4
601 vperm vr8,vr0,vr1,vr16 610 VPERM(vr8,vr0,vr1,vr16)
602 lvx vr0,r4,r9 611 lvx vr0,r4,r9
603 vperm vr9,vr1,vr0,vr16 612 VPERM(vr9,vr1,vr0,vr16)
604 addi r4,r4,32 613 addi r4,r4,32
605 stvx vr8,r0,r3 614 stvx vr8,r0,r3
606 stvx vr9,r3,r9 615 stvx vr9,r3,r9
@@ -608,7 +617,7 @@ _GLOBAL(memcpy_power7)
608 617
60910: bf cr7*4+3,11f 61810: bf cr7*4+3,11f
610 lvx vr1,r0,r4 619 lvx vr1,r0,r4
611 vperm vr8,vr0,vr1,vr16 620 VPERM(vr8,vr0,vr1,vr16)
612 addi r4,r4,16 621 addi r4,r4,16
613 stvx vr8,r0,r3 622 stvx vr8,r0,r3
614 addi r3,r3,16 623 addi r3,r3,16
diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
index b1faa1593c90..c0511c27a733 100644
--- a/arch/powerpc/lib/sstep.c
+++ b/arch/powerpc/lib/sstep.c
@@ -212,11 +212,19 @@ static int __kprobes read_mem_unaligned(unsigned long *dest, unsigned long ea,
212{ 212{
213 int err; 213 int err;
214 unsigned long x, b, c; 214 unsigned long x, b, c;
215#ifdef __LITTLE_ENDIAN__
216 int len = nb; /* save a copy of the length for byte reversal */
217#endif
215 218
216 /* unaligned, do this in pieces */ 219 /* unaligned, do this in pieces */
217 x = 0; 220 x = 0;
218 for (; nb > 0; nb -= c) { 221 for (; nb > 0; nb -= c) {
222#ifdef __LITTLE_ENDIAN__
223 c = 1;
224#endif
225#ifdef __BIG_ENDIAN__
219 c = max_align(ea); 226 c = max_align(ea);
227#endif
220 if (c > nb) 228 if (c > nb)
221 c = max_align(nb); 229 c = max_align(nb);
222 err = read_mem_aligned(&b, ea, c); 230 err = read_mem_aligned(&b, ea, c);
@@ -225,7 +233,24 @@ static int __kprobes read_mem_unaligned(unsigned long *dest, unsigned long ea,
225 x = (x << (8 * c)) + b; 233 x = (x << (8 * c)) + b;
226 ea += c; 234 ea += c;
227 } 235 }
236#ifdef __LITTLE_ENDIAN__
237 switch (len) {
238 case 2:
239 *dest = byterev_2(x);
240 break;
241 case 4:
242 *dest = byterev_4(x);
243 break;
244#ifdef __powerpc64__
245 case 8:
246 *dest = byterev_8(x);
247 break;
248#endif
249 }
250#endif
251#ifdef __BIG_ENDIAN__
228 *dest = x; 252 *dest = x;
253#endif
229 return 0; 254 return 0;
230} 255}
231 256
@@ -273,9 +298,29 @@ static int __kprobes write_mem_unaligned(unsigned long val, unsigned long ea,
273 int err; 298 int err;
274 unsigned long c; 299 unsigned long c;
275 300
301#ifdef __LITTLE_ENDIAN__
302 switch (nb) {
303 case 2:
304 val = byterev_2(val);
305 break;
306 case 4:
307 val = byterev_4(val);
308 break;
309#ifdef __powerpc64__
310 case 8:
311 val = byterev_8(val);
312 break;
313#endif
314 }
315#endif
276 /* unaligned or little-endian, do this in pieces */ 316 /* unaligned or little-endian, do this in pieces */
277 for (; nb > 0; nb -= c) { 317 for (; nb > 0; nb -= c) {
318#ifdef __LITTLE_ENDIAN__
319 c = 1;
320#endif
321#ifdef __BIG_ENDIAN__
278 c = max_align(ea); 322 c = max_align(ea);
323#endif
279 if (c > nb) 324 if (c > nb)
280 c = max_align(nb); 325 c = max_align(nb);
281 err = write_mem_aligned(val >> (nb - c) * 8, ea, c); 326 err = write_mem_aligned(val >> (nb - c) * 8, ea, c);
@@ -310,22 +355,36 @@ static int __kprobes do_fp_load(int rn, int (*func)(int, unsigned long),
310 struct pt_regs *regs) 355 struct pt_regs *regs)
311{ 356{
312 int err; 357 int err;
313 unsigned long val[sizeof(double) / sizeof(long)]; 358 union {
359 double dbl;
360 unsigned long ul[2];
361 struct {
362#ifdef __BIG_ENDIAN__
363 unsigned _pad_;
364 unsigned word;
365#endif
366#ifdef __LITTLE_ENDIAN__
367 unsigned word;
368 unsigned _pad_;
369#endif
370 } single;
371 } data;
314 unsigned long ptr; 372 unsigned long ptr;
315 373
316 if (!address_ok(regs, ea, nb)) 374 if (!address_ok(regs, ea, nb))
317 return -EFAULT; 375 return -EFAULT;
318 if ((ea & 3) == 0) 376 if ((ea & 3) == 0)
319 return (*func)(rn, ea); 377 return (*func)(rn, ea);
320 ptr = (unsigned long) &val[0]; 378 ptr = (unsigned long) &data.ul;
321 if (sizeof(unsigned long) == 8 || nb == 4) { 379 if (sizeof(unsigned long) == 8 || nb == 4) {
322 err = read_mem_unaligned(&val[0], ea, nb, regs); 380 err = read_mem_unaligned(&data.ul[0], ea, nb, regs);
323 ptr += sizeof(unsigned long) - nb; 381 if (nb == 4)
382 ptr = (unsigned long)&(data.single.word);
324 } else { 383 } else {
325 /* reading a double on 32-bit */ 384 /* reading a double on 32-bit */
326 err = read_mem_unaligned(&val[0], ea, 4, regs); 385 err = read_mem_unaligned(&data.ul[0], ea, 4, regs);
327 if (!err) 386 if (!err)
328 err = read_mem_unaligned(&val[1], ea + 4, 4, regs); 387 err = read_mem_unaligned(&data.ul[1], ea + 4, 4, regs);
329 } 388 }
330 if (err) 389 if (err)
331 return err; 390 return err;
@@ -337,28 +396,42 @@ static int __kprobes do_fp_store(int rn, int (*func)(int, unsigned long),
337 struct pt_regs *regs) 396 struct pt_regs *regs)
338{ 397{
339 int err; 398 int err;
340 unsigned long val[sizeof(double) / sizeof(long)]; 399 union {
400 double dbl;
401 unsigned long ul[2];
402 struct {
403#ifdef __BIG_ENDIAN__
404 unsigned _pad_;
405 unsigned word;
406#endif
407#ifdef __LITTLE_ENDIAN__
408 unsigned word;
409 unsigned _pad_;
410#endif
411 } single;
412 } data;
341 unsigned long ptr; 413 unsigned long ptr;
342 414
343 if (!address_ok(regs, ea, nb)) 415 if (!address_ok(regs, ea, nb))
344 return -EFAULT; 416 return -EFAULT;
345 if ((ea & 3) == 0) 417 if ((ea & 3) == 0)
346 return (*func)(rn, ea); 418 return (*func)(rn, ea);
347 ptr = (unsigned long) &val[0]; 419 ptr = (unsigned long) &data.ul[0];
348 if (sizeof(unsigned long) == 8 || nb == 4) { 420 if (sizeof(unsigned long) == 8 || nb == 4) {
349 ptr += sizeof(unsigned long) - nb; 421 if (nb == 4)
422 ptr = (unsigned long)&(data.single.word);
350 err = (*func)(rn, ptr); 423 err = (*func)(rn, ptr);
351 if (err) 424 if (err)
352 return err; 425 return err;
353 err = write_mem_unaligned(val[0], ea, nb, regs); 426 err = write_mem_unaligned(data.ul[0], ea, nb, regs);
354 } else { 427 } else {
355 /* writing a double on 32-bit */ 428 /* writing a double on 32-bit */
356 err = (*func)(rn, ptr); 429 err = (*func)(rn, ptr);
357 if (err) 430 if (err)
358 return err; 431 return err;
359 err = write_mem_unaligned(val[0], ea, 4, regs); 432 err = write_mem_unaligned(data.ul[0], ea, 4, regs);
360 if (!err) 433 if (!err)
361 err = write_mem_unaligned(val[1], ea + 4, 4, regs); 434 err = write_mem_unaligned(data.ul[1], ea + 4, 4, regs);
362 } 435 }
363 return err; 436 return err;
364} 437}
diff --git a/arch/powerpc/lib/xor_vmx.c b/arch/powerpc/lib/xor_vmx.c
new file mode 100644
index 000000000000..e905f7c2ea7b
--- /dev/null
+++ b/arch/powerpc/lib/xor_vmx.c
@@ -0,0 +1,177 @@
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15 *
16 * Copyright (C) IBM Corporation, 2012
17 *
18 * Author: Anton Blanchard <anton@au.ibm.com>
19 */
20#include <altivec.h>
21
22#include <linux/preempt.h>
23#include <linux/export.h>
24#include <linux/sched.h>
25#include <asm/switch_to.h>
26
27typedef vector signed char unative_t;
28
29#define DEFINE(V) \
30 unative_t *V = (unative_t *)V##_in; \
31 unative_t V##_0, V##_1, V##_2, V##_3
32
33#define LOAD(V) \
34 do { \
35 V##_0 = V[0]; \
36 V##_1 = V[1]; \
37 V##_2 = V[2]; \
38 V##_3 = V[3]; \
39 } while (0)
40
41#define STORE(V) \
42 do { \
43 V[0] = V##_0; \
44 V[1] = V##_1; \
45 V[2] = V##_2; \
46 V[3] = V##_3; \
47 } while (0)
48
49#define XOR(V1, V2) \
50 do { \
51 V1##_0 = vec_xor(V1##_0, V2##_0); \
52 V1##_1 = vec_xor(V1##_1, V2##_1); \
53 V1##_2 = vec_xor(V1##_2, V2##_2); \
54 V1##_3 = vec_xor(V1##_3, V2##_3); \
55 } while (0)
56
57void xor_altivec_2(unsigned long bytes, unsigned long *v1_in,
58 unsigned long *v2_in)
59{
60 DEFINE(v1);
61 DEFINE(v2);
62 unsigned long lines = bytes / (sizeof(unative_t)) / 4;
63
64 preempt_disable();
65 enable_kernel_altivec();
66
67 do {
68 LOAD(v1);
69 LOAD(v2);
70 XOR(v1, v2);
71 STORE(v1);
72
73 v1 += 4;
74 v2 += 4;
75 } while (--lines > 0);
76
77 preempt_enable();
78}
79EXPORT_SYMBOL(xor_altivec_2);
80
81void xor_altivec_3(unsigned long bytes, unsigned long *v1_in,
82 unsigned long *v2_in, unsigned long *v3_in)
83{
84 DEFINE(v1);
85 DEFINE(v2);
86 DEFINE(v3);
87 unsigned long lines = bytes / (sizeof(unative_t)) / 4;
88
89 preempt_disable();
90 enable_kernel_altivec();
91
92 do {
93 LOAD(v1);
94 LOAD(v2);
95 LOAD(v3);
96 XOR(v1, v2);
97 XOR(v1, v3);
98 STORE(v1);
99
100 v1 += 4;
101 v2 += 4;
102 v3 += 4;
103 } while (--lines > 0);
104
105 preempt_enable();
106}
107EXPORT_SYMBOL(xor_altivec_3);
108
109void xor_altivec_4(unsigned long bytes, unsigned long *v1_in,
110 unsigned long *v2_in, unsigned long *v3_in,
111 unsigned long *v4_in)
112{
113 DEFINE(v1);
114 DEFINE(v2);
115 DEFINE(v3);
116 DEFINE(v4);
117 unsigned long lines = bytes / (sizeof(unative_t)) / 4;
118
119 preempt_disable();
120 enable_kernel_altivec();
121
122 do {
123 LOAD(v1);
124 LOAD(v2);
125 LOAD(v3);
126 LOAD(v4);
127 XOR(v1, v2);
128 XOR(v3, v4);
129 XOR(v1, v3);
130 STORE(v1);
131
132 v1 += 4;
133 v2 += 4;
134 v3 += 4;
135 v4 += 4;
136 } while (--lines > 0);
137
138 preempt_enable();
139}
140EXPORT_SYMBOL(xor_altivec_4);
141
142void xor_altivec_5(unsigned long bytes, unsigned long *v1_in,
143 unsigned long *v2_in, unsigned long *v3_in,
144 unsigned long *v4_in, unsigned long *v5_in)
145{
146 DEFINE(v1);
147 DEFINE(v2);
148 DEFINE(v3);
149 DEFINE(v4);
150 DEFINE(v5);
151 unsigned long lines = bytes / (sizeof(unative_t)) / 4;
152
153 preempt_disable();
154 enable_kernel_altivec();
155
156 do {
157 LOAD(v1);
158 LOAD(v2);
159 LOAD(v3);
160 LOAD(v4);
161 LOAD(v5);
162 XOR(v1, v2);
163 XOR(v3, v4);
164 XOR(v1, v5);
165 XOR(v1, v3);
166 STORE(v1);
167
168 v1 += 4;
169 v2 += 4;
170 v3 += 4;
171 v4 += 4;
172 v5 += 4;
173 } while (--lines > 0);
174
175 preempt_enable();
176}
177EXPORT_SYMBOL(xor_altivec_5);
diff --git a/arch/powerpc/mm/hash_native_64.c b/arch/powerpc/mm/hash_native_64.c
index c33d939120c9..3ea26c25590b 100644
--- a/arch/powerpc/mm/hash_native_64.c
+++ b/arch/powerpc/mm/hash_native_64.c
@@ -35,7 +35,11 @@
35#define DBG_LOW(fmt...) 35#define DBG_LOW(fmt...)
36#endif 36#endif
37 37
38#ifdef __BIG_ENDIAN__
38#define HPTE_LOCK_BIT 3 39#define HPTE_LOCK_BIT 3
40#else
41#define HPTE_LOCK_BIT (56+3)
42#endif
39 43
40DEFINE_RAW_SPINLOCK(native_tlbie_lock); 44DEFINE_RAW_SPINLOCK(native_tlbie_lock);
41 45
@@ -172,7 +176,7 @@ static inline void tlbie(unsigned long vpn, int psize, int apsize,
172 176
173static inline void native_lock_hpte(struct hash_pte *hptep) 177static inline void native_lock_hpte(struct hash_pte *hptep)
174{ 178{
175 unsigned long *word = &hptep->v; 179 unsigned long *word = (unsigned long *)&hptep->v;
176 180
177 while (1) { 181 while (1) {
178 if (!test_and_set_bit_lock(HPTE_LOCK_BIT, word)) 182 if (!test_and_set_bit_lock(HPTE_LOCK_BIT, word))
@@ -184,7 +188,7 @@ static inline void native_lock_hpte(struct hash_pte *hptep)
184 188
185static inline void native_unlock_hpte(struct hash_pte *hptep) 189static inline void native_unlock_hpte(struct hash_pte *hptep)
186{ 190{
187 unsigned long *word = &hptep->v; 191 unsigned long *word = (unsigned long *)&hptep->v;
188 192
189 clear_bit_unlock(HPTE_LOCK_BIT, word); 193 clear_bit_unlock(HPTE_LOCK_BIT, word);
190} 194}
@@ -204,10 +208,10 @@ static long native_hpte_insert(unsigned long hpte_group, unsigned long vpn,
204 } 208 }
205 209
206 for (i = 0; i < HPTES_PER_GROUP; i++) { 210 for (i = 0; i < HPTES_PER_GROUP; i++) {
207 if (! (hptep->v & HPTE_V_VALID)) { 211 if (! (be64_to_cpu(hptep->v) & HPTE_V_VALID)) {
208 /* retry with lock held */ 212 /* retry with lock held */
209 native_lock_hpte(hptep); 213 native_lock_hpte(hptep);
210 if (! (hptep->v & HPTE_V_VALID)) 214 if (! (be64_to_cpu(hptep->v) & HPTE_V_VALID))
211 break; 215 break;
212 native_unlock_hpte(hptep); 216 native_unlock_hpte(hptep);
213 } 217 }
@@ -226,14 +230,14 @@ static long native_hpte_insert(unsigned long hpte_group, unsigned long vpn,
226 i, hpte_v, hpte_r); 230 i, hpte_v, hpte_r);
227 } 231 }
228 232
229 hptep->r = hpte_r; 233 hptep->r = cpu_to_be64(hpte_r);
230 /* Guarantee the second dword is visible before the valid bit */ 234 /* Guarantee the second dword is visible before the valid bit */
231 eieio(); 235 eieio();
232 /* 236 /*
233 * Now set the first dword including the valid bit 237 * Now set the first dword including the valid bit
234 * NOTE: this also unlocks the hpte 238 * NOTE: this also unlocks the hpte
235 */ 239 */
236 hptep->v = hpte_v; 240 hptep->v = cpu_to_be64(hpte_v);
237 241
238 __asm__ __volatile__ ("ptesync" : : : "memory"); 242 __asm__ __volatile__ ("ptesync" : : : "memory");
239 243
@@ -254,12 +258,12 @@ static long native_hpte_remove(unsigned long hpte_group)
254 258
255 for (i = 0; i < HPTES_PER_GROUP; i++) { 259 for (i = 0; i < HPTES_PER_GROUP; i++) {
256 hptep = htab_address + hpte_group + slot_offset; 260 hptep = htab_address + hpte_group + slot_offset;
257 hpte_v = hptep->v; 261 hpte_v = be64_to_cpu(hptep->v);
258 262
259 if ((hpte_v & HPTE_V_VALID) && !(hpte_v & HPTE_V_BOLTED)) { 263 if ((hpte_v & HPTE_V_VALID) && !(hpte_v & HPTE_V_BOLTED)) {
260 /* retry with lock held */ 264 /* retry with lock held */
261 native_lock_hpte(hptep); 265 native_lock_hpte(hptep);
262 hpte_v = hptep->v; 266 hpte_v = be64_to_cpu(hptep->v);
263 if ((hpte_v & HPTE_V_VALID) 267 if ((hpte_v & HPTE_V_VALID)
264 && !(hpte_v & HPTE_V_BOLTED)) 268 && !(hpte_v & HPTE_V_BOLTED))
265 break; 269 break;
@@ -294,7 +298,7 @@ static long native_hpte_updatepp(unsigned long slot, unsigned long newpp,
294 298
295 native_lock_hpte(hptep); 299 native_lock_hpte(hptep);
296 300
297 hpte_v = hptep->v; 301 hpte_v = be64_to_cpu(hptep->v);
298 /* 302 /*
299 * We need to invalidate the TLB always because hpte_remove doesn't do 303 * We need to invalidate the TLB always because hpte_remove doesn't do
300 * a tlb invalidate. If a hash bucket gets full, we "evict" a more/less 304 * a tlb invalidate. If a hash bucket gets full, we "evict" a more/less
@@ -308,8 +312,8 @@ static long native_hpte_updatepp(unsigned long slot, unsigned long newpp,
308 } else { 312 } else {
309 DBG_LOW(" -> hit\n"); 313 DBG_LOW(" -> hit\n");
310 /* Update the HPTE */ 314 /* Update the HPTE */
311 hptep->r = (hptep->r & ~(HPTE_R_PP | HPTE_R_N)) | 315 hptep->r = cpu_to_be64((be64_to_cpu(hptep->r) & ~(HPTE_R_PP | HPTE_R_N)) |
312 (newpp & (HPTE_R_PP | HPTE_R_N | HPTE_R_C)); 316 (newpp & (HPTE_R_PP | HPTE_R_N | HPTE_R_C)));
313 } 317 }
314 native_unlock_hpte(hptep); 318 native_unlock_hpte(hptep);
315 319
@@ -334,7 +338,7 @@ static long native_hpte_find(unsigned long vpn, int psize, int ssize)
334 slot = (hash & htab_hash_mask) * HPTES_PER_GROUP; 338 slot = (hash & htab_hash_mask) * HPTES_PER_GROUP;
335 for (i = 0; i < HPTES_PER_GROUP; i++) { 339 for (i = 0; i < HPTES_PER_GROUP; i++) {
336 hptep = htab_address + slot; 340 hptep = htab_address + slot;
337 hpte_v = hptep->v; 341 hpte_v = be64_to_cpu(hptep->v);
338 342
339 if (HPTE_V_COMPARE(hpte_v, want_v) && (hpte_v & HPTE_V_VALID)) 343 if (HPTE_V_COMPARE(hpte_v, want_v) && (hpte_v & HPTE_V_VALID))
340 /* HPTE matches */ 344 /* HPTE matches */
@@ -369,8 +373,9 @@ static void native_hpte_updateboltedpp(unsigned long newpp, unsigned long ea,
369 hptep = htab_address + slot; 373 hptep = htab_address + slot;
370 374
371 /* Update the HPTE */ 375 /* Update the HPTE */
372 hptep->r = (hptep->r & ~(HPTE_R_PP | HPTE_R_N)) | 376 hptep->r = cpu_to_be64((be64_to_cpu(hptep->r) &
373 (newpp & (HPTE_R_PP | HPTE_R_N)); 377 ~(HPTE_R_PP | HPTE_R_N)) |
378 (newpp & (HPTE_R_PP | HPTE_R_N)));
374 /* 379 /*
375 * Ensure it is out of the tlb too. Bolted entries base and 380 * Ensure it is out of the tlb too. Bolted entries base and
376 * actual page size will be same. 381 * actual page size will be same.
@@ -392,7 +397,7 @@ static void native_hpte_invalidate(unsigned long slot, unsigned long vpn,
392 397
393 want_v = hpte_encode_avpn(vpn, bpsize, ssize); 398 want_v = hpte_encode_avpn(vpn, bpsize, ssize);
394 native_lock_hpte(hptep); 399 native_lock_hpte(hptep);
395 hpte_v = hptep->v; 400 hpte_v = be64_to_cpu(hptep->v);
396 401
397 /* 402 /*
398 * We need to invalidate the TLB always because hpte_remove doesn't do 403 * We need to invalidate the TLB always because hpte_remove doesn't do
@@ -458,7 +463,7 @@ static void native_hugepage_invalidate(struct mm_struct *mm,
458 hptep = htab_address + slot; 463 hptep = htab_address + slot;
459 want_v = hpte_encode_avpn(vpn, psize, ssize); 464 want_v = hpte_encode_avpn(vpn, psize, ssize);
460 native_lock_hpte(hptep); 465 native_lock_hpte(hptep);
461 hpte_v = hptep->v; 466 hpte_v = be64_to_cpu(hptep->v);
462 467
463 /* Even if we miss, we need to invalidate the TLB */ 468 /* Even if we miss, we need to invalidate the TLB */
464 if (!HPTE_V_COMPARE(hpte_v, want_v) || !(hpte_v & HPTE_V_VALID)) 469 if (!HPTE_V_COMPARE(hpte_v, want_v) || !(hpte_v & HPTE_V_VALID))
@@ -519,11 +524,12 @@ static void hpte_decode(struct hash_pte *hpte, unsigned long slot,
519 int *psize, int *apsize, int *ssize, unsigned long *vpn) 524 int *psize, int *apsize, int *ssize, unsigned long *vpn)
520{ 525{
521 unsigned long avpn, pteg, vpi; 526 unsigned long avpn, pteg, vpi;
522 unsigned long hpte_v = hpte->v; 527 unsigned long hpte_v = be64_to_cpu(hpte->v);
528 unsigned long hpte_r = be64_to_cpu(hpte->r);
523 unsigned long vsid, seg_off; 529 unsigned long vsid, seg_off;
524 int size, a_size, shift; 530 int size, a_size, shift;
525 /* Look at the 8 bit LP value */ 531 /* Look at the 8 bit LP value */
526 unsigned int lp = (hpte->r >> LP_SHIFT) & ((1 << LP_BITS) - 1); 532 unsigned int lp = (hpte_r >> LP_SHIFT) & ((1 << LP_BITS) - 1);
527 533
528 if (!(hpte_v & HPTE_V_LARGE)) { 534 if (!(hpte_v & HPTE_V_LARGE)) {
529 size = MMU_PAGE_4K; 535 size = MMU_PAGE_4K;
@@ -612,7 +618,7 @@ static void native_hpte_clear(void)
612 * running, right? and for crash dump, we probably 618 * running, right? and for crash dump, we probably
613 * don't want to wait for a maybe bad cpu. 619 * don't want to wait for a maybe bad cpu.
614 */ 620 */
615 hpte_v = hptep->v; 621 hpte_v = be64_to_cpu(hptep->v);
616 622
617 /* 623 /*
618 * Call __tlbie() here rather than tlbie() since we 624 * Call __tlbie() here rather than tlbie() since we
@@ -664,7 +670,7 @@ static void native_flush_hash_range(unsigned long number, int local)
664 hptep = htab_address + slot; 670 hptep = htab_address + slot;
665 want_v = hpte_encode_avpn(vpn, psize, ssize); 671 want_v = hpte_encode_avpn(vpn, psize, ssize);
666 native_lock_hpte(hptep); 672 native_lock_hpte(hptep);
667 hpte_v = hptep->v; 673 hpte_v = be64_to_cpu(hptep->v);
668 if (!HPTE_V_COMPARE(hpte_v, want_v) || 674 if (!HPTE_V_COMPARE(hpte_v, want_v) ||
669 !(hpte_v & HPTE_V_VALID)) 675 !(hpte_v & HPTE_V_VALID))
670 native_unlock_hpte(hptep); 676 native_unlock_hpte(hptep);
diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c
index bde8b5589755..6176b3cdf579 100644
--- a/arch/powerpc/mm/hash_utils_64.c
+++ b/arch/powerpc/mm/hash_utils_64.c
@@ -251,19 +251,18 @@ static int __init htab_dt_scan_seg_sizes(unsigned long node,
251 void *data) 251 void *data)
252{ 252{
253 char *type = of_get_flat_dt_prop(node, "device_type", NULL); 253 char *type = of_get_flat_dt_prop(node, "device_type", NULL);
254 u32 *prop; 254 __be32 *prop;
255 unsigned long size = 0; 255 unsigned long size = 0;
256 256
257 /* We are scanning "cpu" nodes only */ 257 /* We are scanning "cpu" nodes only */
258 if (type == NULL || strcmp(type, "cpu") != 0) 258 if (type == NULL || strcmp(type, "cpu") != 0)
259 return 0; 259 return 0;
260 260
261 prop = (u32 *)of_get_flat_dt_prop(node, "ibm,processor-segment-sizes", 261 prop = of_get_flat_dt_prop(node, "ibm,processor-segment-sizes", &size);
262 &size);
263 if (prop == NULL) 262 if (prop == NULL)
264 return 0; 263 return 0;
265 for (; size >= 4; size -= 4, ++prop) { 264 for (; size >= 4; size -= 4, ++prop) {
266 if (prop[0] == 40) { 265 if (be32_to_cpu(prop[0]) == 40) {
267 DBG("1T segment support detected\n"); 266 DBG("1T segment support detected\n");
268 cur_cpu_spec->mmu_features |= MMU_FTR_1T_SEGMENT; 267 cur_cpu_spec->mmu_features |= MMU_FTR_1T_SEGMENT;
269 return 1; 268 return 1;
@@ -307,23 +306,22 @@ static int __init htab_dt_scan_page_sizes(unsigned long node,
307 void *data) 306 void *data)
308{ 307{
309 char *type = of_get_flat_dt_prop(node, "device_type", NULL); 308 char *type = of_get_flat_dt_prop(node, "device_type", NULL);
310 u32 *prop; 309 __be32 *prop;
311 unsigned long size = 0; 310 unsigned long size = 0;
312 311
313 /* We are scanning "cpu" nodes only */ 312 /* We are scanning "cpu" nodes only */
314 if (type == NULL || strcmp(type, "cpu") != 0) 313 if (type == NULL || strcmp(type, "cpu") != 0)
315 return 0; 314 return 0;
316 315
317 prop = (u32 *)of_get_flat_dt_prop(node, 316 prop = of_get_flat_dt_prop(node, "ibm,segment-page-sizes", &size);
318 "ibm,segment-page-sizes", &size);
319 if (prop != NULL) { 317 if (prop != NULL) {
320 pr_info("Page sizes from device-tree:\n"); 318 pr_info("Page sizes from device-tree:\n");
321 size /= 4; 319 size /= 4;
322 cur_cpu_spec->mmu_features &= ~(MMU_FTR_16M_PAGE); 320 cur_cpu_spec->mmu_features &= ~(MMU_FTR_16M_PAGE);
323 while(size > 0) { 321 while(size > 0) {
324 unsigned int base_shift = prop[0]; 322 unsigned int base_shift = be32_to_cpu(prop[0]);
325 unsigned int slbenc = prop[1]; 323 unsigned int slbenc = be32_to_cpu(prop[1]);
326 unsigned int lpnum = prop[2]; 324 unsigned int lpnum = be32_to_cpu(prop[2]);
327 struct mmu_psize_def *def; 325 struct mmu_psize_def *def;
328 int idx, base_idx; 326 int idx, base_idx;
329 327
@@ -356,8 +354,8 @@ static int __init htab_dt_scan_page_sizes(unsigned long node,
356 def->tlbiel = 0; 354 def->tlbiel = 0;
357 355
358 while (size > 0 && lpnum) { 356 while (size > 0 && lpnum) {
359 unsigned int shift = prop[0]; 357 unsigned int shift = be32_to_cpu(prop[0]);
360 int penc = prop[1]; 358 int penc = be32_to_cpu(prop[1]);
361 359
362 prop += 2; size -= 2; 360 prop += 2; size -= 2;
363 lpnum--; 361 lpnum--;
@@ -390,8 +388,8 @@ static int __init htab_dt_scan_hugepage_blocks(unsigned long node,
390 const char *uname, int depth, 388 const char *uname, int depth,
391 void *data) { 389 void *data) {
392 char *type = of_get_flat_dt_prop(node, "device_type", NULL); 390 char *type = of_get_flat_dt_prop(node, "device_type", NULL);
393 unsigned long *addr_prop; 391 __be64 *addr_prop;
394 u32 *page_count_prop; 392 __be32 *page_count_prop;
395 unsigned int expected_pages; 393 unsigned int expected_pages;
396 long unsigned int phys_addr; 394 long unsigned int phys_addr;
397 long unsigned int block_size; 395 long unsigned int block_size;
@@ -405,12 +403,12 @@ static int __init htab_dt_scan_hugepage_blocks(unsigned long node,
405 page_count_prop = of_get_flat_dt_prop(node, "ibm,expected#pages", NULL); 403 page_count_prop = of_get_flat_dt_prop(node, "ibm,expected#pages", NULL);
406 if (page_count_prop == NULL) 404 if (page_count_prop == NULL)
407 return 0; 405 return 0;
408 expected_pages = (1 << page_count_prop[0]); 406 expected_pages = (1 << be32_to_cpu(page_count_prop[0]));
409 addr_prop = of_get_flat_dt_prop(node, "reg", NULL); 407 addr_prop = of_get_flat_dt_prop(node, "reg", NULL);
410 if (addr_prop == NULL) 408 if (addr_prop == NULL)
411 return 0; 409 return 0;
412 phys_addr = addr_prop[0]; 410 phys_addr = be64_to_cpu(addr_prop[0]);
413 block_size = addr_prop[1]; 411 block_size = be64_to_cpu(addr_prop[1]);
414 if (block_size != (16 * GB)) 412 if (block_size != (16 * GB))
415 return 0; 413 return 0;
416 printk(KERN_INFO "Huge page(16GB) memory: " 414 printk(KERN_INFO "Huge page(16GB) memory: "
@@ -534,16 +532,16 @@ static int __init htab_dt_scan_pftsize(unsigned long node,
534 void *data) 532 void *data)
535{ 533{
536 char *type = of_get_flat_dt_prop(node, "device_type", NULL); 534 char *type = of_get_flat_dt_prop(node, "device_type", NULL);
537 u32 *prop; 535 __be32 *prop;
538 536
539 /* We are scanning "cpu" nodes only */ 537 /* We are scanning "cpu" nodes only */
540 if (type == NULL || strcmp(type, "cpu") != 0) 538 if (type == NULL || strcmp(type, "cpu") != 0)
541 return 0; 539 return 0;
542 540
543 prop = (u32 *)of_get_flat_dt_prop(node, "ibm,pft-size", NULL); 541 prop = of_get_flat_dt_prop(node, "ibm,pft-size", NULL);
544 if (prop != NULL) { 542 if (prop != NULL) {
545 /* pft_size[0] is the NUMA CEC cookie */ 543 /* pft_size[0] is the NUMA CEC cookie */
546 ppc64_pft_size = prop[1]; 544 ppc64_pft_size = be32_to_cpu(prop[1]);
547 return 1; 545 return 1;
548 } 546 }
549 return 0; 547 return 0;
diff --git a/arch/powerpc/mm/init_32.c b/arch/powerpc/mm/init_32.c
index d47d3dab4870..cff59f1bec23 100644
--- a/arch/powerpc/mm/init_32.c
+++ b/arch/powerpc/mm/init_32.c
@@ -213,7 +213,12 @@ void setup_initial_memory_limit(phys_addr_t first_memblock_base,
213 */ 213 */
214 BUG_ON(first_memblock_base != 0); 214 BUG_ON(first_memblock_base != 0);
215 215
216#ifdef CONFIG_PIN_TLB
217 /* 8xx can only access 24MB at the moment */
218 memblock_set_current_limit(min_t(u64, first_memblock_size, 0x01800000));
219#else
216 /* 8xx can only access 8MB at the moment */ 220 /* 8xx can only access 8MB at the moment */
217 memblock_set_current_limit(min_t(u64, first_memblock_size, 0x00800000)); 221 memblock_set_current_limit(min_t(u64, first_memblock_size, 0x00800000));
222#endif
218} 223}
219#endif /* CONFIG_8xx */ 224#endif /* CONFIG_8xx */
diff --git a/arch/powerpc/mm/init_64.c b/arch/powerpc/mm/init_64.c
index 8ed035d2edb5..e3734edffa69 100644
--- a/arch/powerpc/mm/init_64.c
+++ b/arch/powerpc/mm/init_64.c
@@ -304,5 +304,54 @@ void register_page_bootmem_memmap(unsigned long section_nr,
304 struct page *start_page, unsigned long size) 304 struct page *start_page, unsigned long size)
305{ 305{
306} 306}
307#endif /* CONFIG_SPARSEMEM_VMEMMAP */
308 307
308/*
309 * We do not have access to the sparsemem vmemmap, so we fallback to
310 * walking the list of sparsemem blocks which we already maintain for
311 * the sake of crashdump. In the long run, we might want to maintain
312 * a tree if performance of that linear walk becomes a problem.
313 *
314 * realmode_pfn_to_page functions can fail due to:
315 * 1) As real sparsemem blocks do not lay in RAM continously (they
316 * are in virtual address space which is not available in the real mode),
317 * the requested page struct can be split between blocks so get_page/put_page
318 * may fail.
319 * 2) When huge pages are used, the get_page/put_page API will fail
320 * in real mode as the linked addresses in the page struct are virtual
321 * too.
322 */
323struct page *realmode_pfn_to_page(unsigned long pfn)
324{
325 struct vmemmap_backing *vmem_back;
326 struct page *page;
327 unsigned long page_size = 1 << mmu_psize_defs[mmu_vmemmap_psize].shift;
328 unsigned long pg_va = (unsigned long) pfn_to_page(pfn);
329
330 for (vmem_back = vmemmap_list; vmem_back; vmem_back = vmem_back->list) {
331 if (pg_va < vmem_back->virt_addr)
332 continue;
333
334 /* Check that page struct is not split between real pages */
335 if ((pg_va + sizeof(struct page)) >
336 (vmem_back->virt_addr + page_size))
337 return NULL;
338
339 page = (struct page *) (vmem_back->phys + pg_va -
340 vmem_back->virt_addr);
341 return page;
342 }
343
344 return NULL;
345}
346EXPORT_SYMBOL_GPL(realmode_pfn_to_page);
347
348#elif defined(CONFIG_FLATMEM)
349
350struct page *realmode_pfn_to_page(unsigned long pfn)
351{
352 struct page *page = pfn_to_page(pfn);
353 return page;
354}
355EXPORT_SYMBOL_GPL(realmode_pfn_to_page);
356
357#endif /* CONFIG_SPARSEMEM_VMEMMAP/CONFIG_FLATMEM */
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index c916127f10c3..33d67844062c 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -195,7 +195,7 @@ static const __be32 *of_get_usable_memory(struct device_node *memory)
195 u32 len; 195 u32 len;
196 prop = of_get_property(memory, "linux,drconf-usable-memory", &len); 196 prop = of_get_property(memory, "linux,drconf-usable-memory", &len);
197 if (!prop || len < sizeof(unsigned int)) 197 if (!prop || len < sizeof(unsigned int))
198 return 0; 198 return NULL;
199 return prop; 199 return prop;
200} 200}
201 201
@@ -1154,7 +1154,7 @@ static int hot_add_drconf_scn_to_nid(struct device_node *memory,
1154 * represented in the device tree as a node (i.e. memory@XXXX) for 1154 * represented in the device tree as a node (i.e. memory@XXXX) for
1155 * each memblock. 1155 * each memblock.
1156 */ 1156 */
1157int hot_add_node_scn_to_nid(unsigned long scn_addr) 1157static int hot_add_node_scn_to_nid(unsigned long scn_addr)
1158{ 1158{
1159 struct device_node *memory; 1159 struct device_node *memory;
1160 int nid = -1; 1160 int nid = -1;
@@ -1235,7 +1235,7 @@ static u64 hot_add_drconf_memory_max(void)
1235 struct device_node *memory = NULL; 1235 struct device_node *memory = NULL;
1236 unsigned int drconf_cell_cnt = 0; 1236 unsigned int drconf_cell_cnt = 0;
1237 u64 lmb_size = 0; 1237 u64 lmb_size = 0;
1238 const __be32 *dm = 0; 1238 const __be32 *dm = NULL;
1239 1239
1240 memory = of_find_node_by_path("/ibm,dynamic-reconfiguration-memory"); 1240 memory = of_find_node_by_path("/ibm,dynamic-reconfiguration-memory");
1241 if (memory) { 1241 if (memory) {
@@ -1535,7 +1535,7 @@ static void topology_work_fn(struct work_struct *work)
1535} 1535}
1536static DECLARE_WORK(topology_work, topology_work_fn); 1536static DECLARE_WORK(topology_work, topology_work_fn);
1537 1537
1538void topology_schedule_update(void) 1538static void topology_schedule_update(void)
1539{ 1539{
1540 schedule_work(&topology_work); 1540 schedule_work(&topology_work);
1541} 1541}
diff --git a/arch/powerpc/mm/pgtable.c b/arch/powerpc/mm/pgtable.c
index edda589795c3..841e0d00863c 100644
--- a/arch/powerpc/mm/pgtable.c
+++ b/arch/powerpc/mm/pgtable.c
@@ -32,8 +32,6 @@
32#include <asm/tlbflush.h> 32#include <asm/tlbflush.h>
33#include <asm/tlb.h> 33#include <asm/tlb.h>
34 34
35#include "mmu_decl.h"
36
37static inline int is_exec_fault(void) 35static inline int is_exec_fault(void)
38{ 36{
39 return current->thread.regs && TRAP(current->thread.regs) == 0x400; 37 return current->thread.regs && TRAP(current->thread.regs) == 0x400;
@@ -72,7 +70,7 @@ struct page * maybe_pte_to_page(pte_t pte)
72 * support falls into the same category. 70 * support falls into the same category.
73 */ 71 */
74 72
75static pte_t set_pte_filter(pte_t pte, unsigned long addr) 73static pte_t set_pte_filter(pte_t pte)
76{ 74{
77 pte = __pte(pte_val(pte) & ~_PAGE_HPTEFLAGS); 75 pte = __pte(pte_val(pte) & ~_PAGE_HPTEFLAGS);
78 if (pte_looks_normal(pte) && !(cpu_has_feature(CPU_FTR_COHERENT_ICACHE) || 76 if (pte_looks_normal(pte) && !(cpu_has_feature(CPU_FTR_COHERENT_ICACHE) ||
@@ -81,17 +79,6 @@ static pte_t set_pte_filter(pte_t pte, unsigned long addr)
81 if (!pg) 79 if (!pg)
82 return pte; 80 return pte;
83 if (!test_bit(PG_arch_1, &pg->flags)) { 81 if (!test_bit(PG_arch_1, &pg->flags)) {
84#ifdef CONFIG_8xx
85 /* On 8xx, cache control instructions (particularly
86 * "dcbst" from flush_dcache_icache) fault as write
87 * operation if there is an unpopulated TLB entry
88 * for the address in question. To workaround that,
89 * we invalidate the TLB here, thus avoiding dcbst
90 * misbehaviour.
91 */
92 /* 8xx doesn't care about PID, size or ind args */
93 _tlbil_va(addr, 0, 0, 0);
94#endif /* CONFIG_8xx */
95 flush_dcache_icache_page(pg); 82 flush_dcache_icache_page(pg);
96 set_bit(PG_arch_1, &pg->flags); 83 set_bit(PG_arch_1, &pg->flags);
97 } 84 }
@@ -111,7 +98,7 @@ static pte_t set_access_flags_filter(pte_t pte, struct vm_area_struct *vma,
111 * as we don't have two bits to spare for _PAGE_EXEC and _PAGE_HWEXEC so 98 * as we don't have two bits to spare for _PAGE_EXEC and _PAGE_HWEXEC so
112 * instead we "filter out" the exec permission for non clean pages. 99 * instead we "filter out" the exec permission for non clean pages.
113 */ 100 */
114static pte_t set_pte_filter(pte_t pte, unsigned long addr) 101static pte_t set_pte_filter(pte_t pte)
115{ 102{
116 struct page *pg; 103 struct page *pg;
117 104
@@ -193,7 +180,7 @@ void set_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep,
193 * this context might not have been activated yet when this 180 * this context might not have been activated yet when this
194 * is called. 181 * is called.
195 */ 182 */
196 pte = set_pte_filter(pte, addr); 183 pte = set_pte_filter(pte);
197 184
198 /* Perform the setting of the PTE */ 185 /* Perform the setting of the PTE */
199 __set_pte_at(mm, addr, ptep, pte, 0); 186 __set_pte_at(mm, addr, ptep, pte, 0);
diff --git a/arch/powerpc/net/bpf_jit.h b/arch/powerpc/net/bpf_jit.h
index 8a5dfaf5c6b7..9aee27c582dc 100644
--- a/arch/powerpc/net/bpf_jit.h
+++ b/arch/powerpc/net/bpf_jit.h
@@ -39,6 +39,7 @@
39#define r_X 5 39#define r_X 5
40#define r_addr 6 40#define r_addr 6
41#define r_scratch1 7 41#define r_scratch1 7
42#define r_scratch2 8
42#define r_D 14 43#define r_D 14
43#define r_HL 15 44#define r_HL 15
44#define r_M 16 45#define r_M 16
@@ -92,6 +93,8 @@ DECLARE_LOAD_FUNC(sk_load_byte_msh);
92 ___PPC_RA(base) | IMM_L(i)) 93 ___PPC_RA(base) | IMM_L(i))
93#define PPC_LHZ(r, base, i) EMIT(PPC_INST_LHZ | ___PPC_RT(r) | \ 94#define PPC_LHZ(r, base, i) EMIT(PPC_INST_LHZ | ___PPC_RT(r) | \
94 ___PPC_RA(base) | IMM_L(i)) 95 ___PPC_RA(base) | IMM_L(i))
96#define PPC_LHBRX(r, base, b) EMIT(PPC_INST_LHBRX | ___PPC_RT(r) | \
97 ___PPC_RA(base) | ___PPC_RB(b))
95/* Convenience helpers for the above with 'far' offsets: */ 98/* Convenience helpers for the above with 'far' offsets: */
96#define PPC_LD_OFFS(r, base, i) do { if ((i) < 32768) PPC_LD(r, base, i); \ 99#define PPC_LD_OFFS(r, base, i) do { if ((i) < 32768) PPC_LD(r, base, i); \
97 else { PPC_ADDIS(r, base, IMM_HA(i)); \ 100 else { PPC_ADDIS(r, base, IMM_HA(i)); \
@@ -186,6 +189,14 @@ DECLARE_LOAD_FUNC(sk_load_byte_msh);
186 PPC_ORI(d, d, (uintptr_t)(i) & 0xffff); \ 189 PPC_ORI(d, d, (uintptr_t)(i) & 0xffff); \
187 } } while (0); 190 } } while (0);
188 191
192#define PPC_LHBRX_OFFS(r, base, i) \
193 do { PPC_LI32(r, i); PPC_LHBRX(r, r, base); } while(0)
194#ifdef __LITTLE_ENDIAN__
195#define PPC_NTOHS_OFFS(r, base, i) PPC_LHBRX_OFFS(r, base, i)
196#else
197#define PPC_NTOHS_OFFS(r, base, i) PPC_LHZ_OFFS(r, base, i)
198#endif
199
189static inline bool is_nearbranch(int offset) 200static inline bool is_nearbranch(int offset)
190{ 201{
191 return (offset < 32768) && (offset >= -32768); 202 return (offset < 32768) && (offset >= -32768);
diff --git a/arch/powerpc/net/bpf_jit_64.S b/arch/powerpc/net/bpf_jit_64.S
index 7d3a3b5619a2..e76eba74d9da 100644
--- a/arch/powerpc/net/bpf_jit_64.S
+++ b/arch/powerpc/net/bpf_jit_64.S
@@ -43,8 +43,11 @@ sk_load_word_positive_offset:
43 cmpd r_scratch1, r_addr 43 cmpd r_scratch1, r_addr
44 blt bpf_slow_path_word 44 blt bpf_slow_path_word
45 /* Nope, just hitting the header. cr0 here is eq or gt! */ 45 /* Nope, just hitting the header. cr0 here is eq or gt! */
46#ifdef __LITTLE_ENDIAN__
47 lwbrx r_A, r_D, r_addr
48#else
46 lwzx r_A, r_D, r_addr 49 lwzx r_A, r_D, r_addr
47 /* When big endian we don't need to byteswap. */ 50#endif
48 blr /* Return success, cr0 != LT */ 51 blr /* Return success, cr0 != LT */
49 52
50 .globl sk_load_half 53 .globl sk_load_half
@@ -56,7 +59,11 @@ sk_load_half_positive_offset:
56 subi r_scratch1, r_HL, 2 59 subi r_scratch1, r_HL, 2
57 cmpd r_scratch1, r_addr 60 cmpd r_scratch1, r_addr
58 blt bpf_slow_path_half 61 blt bpf_slow_path_half
62#ifdef __LITTLE_ENDIAN__
63 lhbrx r_A, r_D, r_addr
64#else
59 lhzx r_A, r_D, r_addr 65 lhzx r_A, r_D, r_addr
66#endif
60 blr 67 blr
61 68
62 .globl sk_load_byte 69 .globl sk_load_byte
diff --git a/arch/powerpc/net/bpf_jit_comp.c b/arch/powerpc/net/bpf_jit_comp.c
index 2345bdb4d917..ac3c2a10dafd 100644
--- a/arch/powerpc/net/bpf_jit_comp.c
+++ b/arch/powerpc/net/bpf_jit_comp.c
@@ -17,14 +17,8 @@
17 17
18#include "bpf_jit.h" 18#include "bpf_jit.h"
19 19
20#ifndef __BIG_ENDIAN
21/* There are endianness assumptions herein. */
22#error "Little-endian PPC not supported in BPF compiler"
23#endif
24
25int bpf_jit_enable __read_mostly; 20int bpf_jit_enable __read_mostly;
26 21
27
28static inline void bpf_flush_icache(void *start, void *end) 22static inline void bpf_flush_icache(void *start, void *end)
29{ 23{
30 smp_wmb(); 24 smp_wmb();
@@ -193,6 +187,26 @@ static int bpf_jit_build_body(struct sk_filter *fp, u32 *image,
193 PPC_MUL(r_A, r_A, r_scratch1); 187 PPC_MUL(r_A, r_A, r_scratch1);
194 } 188 }
195 break; 189 break;
190 case BPF_S_ALU_MOD_X: /* A %= X; */
191 ctx->seen |= SEEN_XREG;
192 PPC_CMPWI(r_X, 0);
193 if (ctx->pc_ret0 != -1) {
194 PPC_BCC(COND_EQ, addrs[ctx->pc_ret0]);
195 } else {
196 PPC_BCC_SHORT(COND_NE, (ctx->idx*4)+12);
197 PPC_LI(r_ret, 0);
198 PPC_JMP(exit_addr);
199 }
200 PPC_DIVWU(r_scratch1, r_A, r_X);
201 PPC_MUL(r_scratch1, r_X, r_scratch1);
202 PPC_SUB(r_A, r_A, r_scratch1);
203 break;
204 case BPF_S_ALU_MOD_K: /* A %= K; */
205 PPC_LI32(r_scratch2, K);
206 PPC_DIVWU(r_scratch1, r_A, r_scratch2);
207 PPC_MUL(r_scratch1, r_scratch2, r_scratch1);
208 PPC_SUB(r_A, r_A, r_scratch1);
209 break;
196 case BPF_S_ALU_DIV_X: /* A /= X; */ 210 case BPF_S_ALU_DIV_X: /* A /= X; */
197 ctx->seen |= SEEN_XREG; 211 ctx->seen |= SEEN_XREG;
198 PPC_CMPWI(r_X, 0); 212 PPC_CMPWI(r_X, 0);
@@ -346,18 +360,11 @@ static int bpf_jit_build_body(struct sk_filter *fp, u32 *image,
346 break; 360 break;
347 361
348 /*** Ancillary info loads ***/ 362 /*** Ancillary info loads ***/
349
350 /* None of the BPF_S_ANC* codes appear to be passed by
351 * sk_chk_filter(). The interpreter and the x86 BPF
352 * compiler implement them so we do too -- they may be
353 * planted in future.
354 */
355 case BPF_S_ANC_PROTOCOL: /* A = ntohs(skb->protocol); */ 363 case BPF_S_ANC_PROTOCOL: /* A = ntohs(skb->protocol); */
356 BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, 364 BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff,
357 protocol) != 2); 365 protocol) != 2);
358 PPC_LHZ_OFFS(r_A, r_skb, offsetof(struct sk_buff, 366 PPC_NTOHS_OFFS(r_A, r_skb, offsetof(struct sk_buff,
359 protocol)); 367 protocol));
360 /* ntohs is a NOP with BE loads. */
361 break; 368 break;
362 case BPF_S_ANC_IFINDEX: 369 case BPF_S_ANC_IFINDEX:
363 PPC_LD_OFFS(r_scratch1, r_skb, offsetof(struct sk_buff, 370 PPC_LD_OFFS(r_scratch1, r_skb, offsetof(struct sk_buff,
diff --git a/arch/powerpc/platforms/512x/mpc512x_shared.c b/arch/powerpc/platforms/512x/mpc512x_shared.c
index a82a41b4fd91..36b5652aada2 100644
--- a/arch/powerpc/platforms/512x/mpc512x_shared.c
+++ b/arch/powerpc/platforms/512x/mpc512x_shared.c
@@ -60,8 +60,6 @@ void mpc512x_restart(char *cmd)
60 ; 60 ;
61} 61}
62 62
63#if IS_ENABLED(CONFIG_FB_FSL_DIU)
64
65struct fsl_diu_shared_fb { 63struct fsl_diu_shared_fb {
66 u8 gamma[0x300]; /* 32-bit aligned! */ 64 u8 gamma[0x300]; /* 32-bit aligned! */
67 struct diu_ad ad0; /* 32-bit aligned! */ 65 struct diu_ad ad0; /* 32-bit aligned! */
@@ -71,7 +69,7 @@ struct fsl_diu_shared_fb {
71}; 69};
72 70
73#define DIU_DIV_MASK 0x000000ff 71#define DIU_DIV_MASK 0x000000ff
74void mpc512x_set_pixel_clock(unsigned int pixclock) 72static void mpc512x_set_pixel_clock(unsigned int pixclock)
75{ 73{
76 unsigned long bestval, bestfreq, speed, busfreq; 74 unsigned long bestval, bestfreq, speed, busfreq;
77 unsigned long minpixclock, maxpixclock, pixval; 75 unsigned long minpixclock, maxpixclock, pixval;
@@ -164,7 +162,7 @@ void mpc512x_set_pixel_clock(unsigned int pixclock)
164 iounmap(ccm); 162 iounmap(ccm);
165} 163}
166 164
167enum fsl_diu_monitor_port 165static enum fsl_diu_monitor_port
168mpc512x_valid_monitor_port(enum fsl_diu_monitor_port port) 166mpc512x_valid_monitor_port(enum fsl_diu_monitor_port port)
169{ 167{
170 return FSL_DIU_PORT_DVI; 168 return FSL_DIU_PORT_DVI;
@@ -179,7 +177,7 @@ static inline void mpc512x_free_bootmem(struct page *page)
179 free_reserved_page(page); 177 free_reserved_page(page);
180} 178}
181 179
182void mpc512x_release_bootmem(void) 180static void mpc512x_release_bootmem(void)
183{ 181{
184 unsigned long addr = diu_shared_fb.fb_phys & PAGE_MASK; 182 unsigned long addr = diu_shared_fb.fb_phys & PAGE_MASK;
185 unsigned long size = diu_shared_fb.fb_len; 183 unsigned long size = diu_shared_fb.fb_len;
@@ -205,7 +203,7 @@ void mpc512x_release_bootmem(void)
205 * address range will be reserved in setup_arch() after bootmem 203 * address range will be reserved in setup_arch() after bootmem
206 * allocator is up. 204 * allocator is up.
207 */ 205 */
208void __init mpc512x_init_diu(void) 206static void __init mpc512x_init_diu(void)
209{ 207{
210 struct device_node *np; 208 struct device_node *np;
211 struct diu __iomem *diu_reg; 209 struct diu __iomem *diu_reg;
@@ -274,7 +272,7 @@ out:
274 iounmap(diu_reg); 272 iounmap(diu_reg);
275} 273}
276 274
277void __init mpc512x_setup_diu(void) 275static void __init mpc512x_setup_diu(void)
278{ 276{
279 int ret; 277 int ret;
280 278
@@ -303,8 +301,6 @@ void __init mpc512x_setup_diu(void)
303 diu_ops.release_bootmem = mpc512x_release_bootmem; 301 diu_ops.release_bootmem = mpc512x_release_bootmem;
304} 302}
305 303
306#endif
307
308void __init mpc512x_init_IRQ(void) 304void __init mpc512x_init_IRQ(void)
309{ 305{
310 struct device_node *np; 306 struct device_node *np;
@@ -337,7 +333,7 @@ static struct of_device_id __initdata of_bus_ids[] = {
337 {}, 333 {},
338}; 334};
339 335
340void __init mpc512x_declare_of_platform_devices(void) 336static void __init mpc512x_declare_of_platform_devices(void)
341{ 337{
342 if (of_platform_bus_probe(NULL, of_bus_ids, NULL)) 338 if (of_platform_bus_probe(NULL, of_bus_ids, NULL))
343 printk(KERN_ERR __FILE__ ": " 339 printk(KERN_ERR __FILE__ ": "
@@ -387,7 +383,7 @@ static unsigned int __init get_fifo_size(struct device_node *np,
387 ((u32)(_base) + sizeof(struct mpc52xx_psc))) 383 ((u32)(_base) + sizeof(struct mpc52xx_psc)))
388 384
389/* Init PSC FIFO space for TX and RX slices */ 385/* Init PSC FIFO space for TX and RX slices */
390void __init mpc512x_psc_fifo_init(void) 386static void __init mpc512x_psc_fifo_init(void)
391{ 387{
392 struct device_node *np; 388 struct device_node *np;
393 void __iomem *psc; 389 void __iomem *psc;
diff --git a/arch/powerpc/platforms/52xx/Kconfig b/arch/powerpc/platforms/52xx/Kconfig
index 90f4496017e4..af54174801f7 100644
--- a/arch/powerpc/platforms/52xx/Kconfig
+++ b/arch/powerpc/platforms/52xx/Kconfig
@@ -57,5 +57,5 @@ config PPC_MPC5200_BUGFIX
57 57
58config PPC_MPC5200_LPBFIFO 58config PPC_MPC5200_LPBFIFO
59 tristate "MPC5200 LocalPlus bus FIFO driver" 59 tristate "MPC5200 LocalPlus bus FIFO driver"
60 depends on PPC_MPC52xx 60 depends on PPC_MPC52xx && PPC_BESTCOMM
61 select PPC_BESTCOMM_GEN_BD 61 select PPC_BESTCOMM_GEN_BD
diff --git a/arch/powerpc/platforms/52xx/mpc52xx_pic.c b/arch/powerpc/platforms/52xx/mpc52xx_pic.c
index b69221ba07fd..2898b737deb7 100644
--- a/arch/powerpc/platforms/52xx/mpc52xx_pic.c
+++ b/arch/powerpc/platforms/52xx/mpc52xx_pic.c
@@ -340,7 +340,7 @@ static int mpc52xx_irqhost_map(struct irq_domain *h, unsigned int virq,
340{ 340{
341 int l1irq; 341 int l1irq;
342 int l2irq; 342 int l2irq;
343 struct irq_chip *irqchip; 343 struct irq_chip *uninitialized_var(irqchip);
344 void *hndlr; 344 void *hndlr;
345 int type; 345 int type;
346 u32 reg; 346 u32 reg;
@@ -373,9 +373,8 @@ static int mpc52xx_irqhost_map(struct irq_domain *h, unsigned int virq,
373 case MPC52xx_IRQ_L1_PERP: irqchip = &mpc52xx_periph_irqchip; break; 373 case MPC52xx_IRQ_L1_PERP: irqchip = &mpc52xx_periph_irqchip; break;
374 case MPC52xx_IRQ_L1_SDMA: irqchip = &mpc52xx_sdma_irqchip; break; 374 case MPC52xx_IRQ_L1_SDMA: irqchip = &mpc52xx_sdma_irqchip; break;
375 case MPC52xx_IRQ_L1_CRIT: 375 case MPC52xx_IRQ_L1_CRIT:
376 default:
377 pr_warn("%s: Critical IRQ #%d is unsupported! Nopping it.\n", 376 pr_warn("%s: Critical IRQ #%d is unsupported! Nopping it.\n",
378 __func__, l1irq); 377 __func__, l2irq);
379 irq_set_chip(virq, &no_irq_chip); 378 irq_set_chip(virq, &no_irq_chip);
380 return 0; 379 return 0;
381 } 380 }
diff --git a/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c b/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c
index 7bc315822935..fd71cfdf2380 100644
--- a/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c
+++ b/arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c
@@ -204,7 +204,6 @@ static int mcu_remove(struct i2c_client *client)
204 ret = mcu_gpiochip_remove(mcu); 204 ret = mcu_gpiochip_remove(mcu);
205 if (ret) 205 if (ret)
206 return ret; 206 return ret;
207 i2c_set_clientdata(client, NULL);
208 kfree(mcu); 207 kfree(mcu);
209 return 0; 208 return 0;
210} 209}
diff --git a/arch/powerpc/platforms/85xx/Kconfig b/arch/powerpc/platforms/85xx/Kconfig
index de2eb9320993..4d4634958cfb 100644
--- a/arch/powerpc/platforms/85xx/Kconfig
+++ b/arch/powerpc/platforms/85xx/Kconfig
@@ -218,83 +218,16 @@ config GE_IMP3A
218 This board is a 3U CompactPCI Single Board Computer with a Freescale 218 This board is a 3U CompactPCI Single Board Computer with a Freescale
219 P2020 processor. 219 P2020 processor.
220 220
221config P2041_RDB
222 bool "Freescale P2041 RDB"
223 select DEFAULT_UIMAGE
224 select PPC_E500MC
225 select PHYS_64BIT
226 select SWIOTLB
227 select ARCH_REQUIRE_GPIOLIB
228 select GPIO_MPC8XXX
229 select HAS_RAPIDIO
230 select PPC_EPAPR_HV_PIC
231 help
232 This option enables support for the P2041 RDB board
233
234config P3041_DS
235 bool "Freescale P3041 DS"
236 select DEFAULT_UIMAGE
237 select PPC_E500MC
238 select PHYS_64BIT
239 select SWIOTLB
240 select ARCH_REQUIRE_GPIOLIB
241 select GPIO_MPC8XXX
242 select HAS_RAPIDIO
243 select PPC_EPAPR_HV_PIC
244 help
245 This option enables support for the P3041 DS board
246
247config P4080_DS
248 bool "Freescale P4080 DS"
249 select DEFAULT_UIMAGE
250 select PPC_E500MC
251 select PHYS_64BIT
252 select SWIOTLB
253 select ARCH_REQUIRE_GPIOLIB
254 select GPIO_MPC8XXX
255 select HAS_RAPIDIO
256 select PPC_EPAPR_HV_PIC
257 help
258 This option enables support for the P4080 DS board
259
260config SGY_CTS1000 221config SGY_CTS1000
261 tristate "Servergy CTS-1000 support" 222 tristate "Servergy CTS-1000 support"
262 select GPIOLIB 223 select GPIOLIB
263 select OF_GPIO 224 select OF_GPIO
264 depends on P4080_DS 225 depends on CORENET_GENERIC
265 help 226 help
266 Enable this to support functionality in Servergy's CTS-1000 systems. 227 Enable this to support functionality in Servergy's CTS-1000 systems.
267 228
268endif # PPC32 229endif # PPC32
269 230
270config P5020_DS
271 bool "Freescale P5020 DS"
272 select DEFAULT_UIMAGE
273 select E500
274 select PPC_E500MC
275 select PHYS_64BIT
276 select SWIOTLB
277 select ARCH_REQUIRE_GPIOLIB
278 select GPIO_MPC8XXX
279 select HAS_RAPIDIO
280 select PPC_EPAPR_HV_PIC
281 help
282 This option enables support for the P5020 DS board
283
284config P5040_DS
285 bool "Freescale P5040 DS"
286 select DEFAULT_UIMAGE
287 select E500
288 select PPC_E500MC
289 select PHYS_64BIT
290 select SWIOTLB
291 select ARCH_REQUIRE_GPIOLIB
292 select GPIO_MPC8XXX
293 select HAS_RAPIDIO
294 select PPC_EPAPR_HV_PIC
295 help
296 This option enables support for the P5040 DS board
297
298config PPC_QEMU_E500 231config PPC_QEMU_E500
299 bool "QEMU generic e500 platform" 232 bool "QEMU generic e500 platform"
300 select DEFAULT_UIMAGE 233 select DEFAULT_UIMAGE
@@ -310,10 +243,8 @@ config PPC_QEMU_E500
310 unset based on the emulated CPU (or actual host CPU in the case 243 unset based on the emulated CPU (or actual host CPU in the case
311 of KVM). 244 of KVM).
312 245
313if PPC64 246config CORENET_GENERIC
314 247 bool "Freescale CoreNet Generic"
315config T4240_QDS
316 bool "Freescale T4240 QDS"
317 select DEFAULT_UIMAGE 248 select DEFAULT_UIMAGE
318 select E500 249 select E500
319 select PPC_E500MC 250 select PPC_E500MC
@@ -324,26 +255,14 @@ config T4240_QDS
324 select HAS_RAPIDIO 255 select HAS_RAPIDIO
325 select PPC_EPAPR_HV_PIC 256 select PPC_EPAPR_HV_PIC
326 help 257 help
327 This option enables support for the T4240 QDS board 258 This option enables support for the FSL CoreNet based boards.
328 259 For 32bit kernel, the following boards are supported:
329config B4_QDS 260 P2041 RDB, P3041 DS and P4080 DS
330 bool "Freescale B4 QDS" 261 For 64bit kernel, the following boards are supported:
331 select DEFAULT_UIMAGE 262 T4240 QDS and B4 QDS
332 select E500 263 The following boards are supported for both 32bit and 64bit kernel:
333 select PPC_E500MC 264 P5020 DS and P5040 DS
334 select PHYS_64BIT
335 select SWIOTLB
336 select GPIOLIB
337 select ARCH_REQUIRE_GPIOLIB
338 select HAS_RAPIDIO
339 select PPC_EPAPR_HV_PIC
340 help
341 This option enables support for the B4 QDS board
342 The B4 application development system B4 QDS is a complete
343 debugging environment intended for engineers developing
344 applications for the B4.
345 265
346endif
347endif # FSL_SOC_BOOKE 266endif # FSL_SOC_BOOKE
348 267
349config TQM85xx 268config TQM85xx
diff --git a/arch/powerpc/platforms/85xx/Makefile b/arch/powerpc/platforms/85xx/Makefile
index 53c9f75a6907..dd4c0b59577b 100644
--- a/arch/powerpc/platforms/85xx/Makefile
+++ b/arch/powerpc/platforms/85xx/Makefile
@@ -18,13 +18,7 @@ obj-$(CONFIG_P1010_RDB) += p1010rdb.o
18obj-$(CONFIG_P1022_DS) += p1022_ds.o 18obj-$(CONFIG_P1022_DS) += p1022_ds.o
19obj-$(CONFIG_P1022_RDK) += p1022_rdk.o 19obj-$(CONFIG_P1022_RDK) += p1022_rdk.o
20obj-$(CONFIG_P1023_RDS) += p1023_rds.o 20obj-$(CONFIG_P1023_RDS) += p1023_rds.o
21obj-$(CONFIG_P2041_RDB) += p2041_rdb.o corenet_ds.o 21obj-$(CONFIG_CORENET_GENERIC) += corenet_generic.o
22obj-$(CONFIG_P3041_DS) += p3041_ds.o corenet_ds.o
23obj-$(CONFIG_P4080_DS) += p4080_ds.o corenet_ds.o
24obj-$(CONFIG_P5020_DS) += p5020_ds.o corenet_ds.o
25obj-$(CONFIG_P5040_DS) += p5040_ds.o corenet_ds.o
26obj-$(CONFIG_T4240_QDS) += t4240_qds.o corenet_ds.o
27obj-$(CONFIG_B4_QDS) += b4_qds.o corenet_ds.o
28obj-$(CONFIG_STX_GP3) += stx_gp3.o 22obj-$(CONFIG_STX_GP3) += stx_gp3.o
29obj-$(CONFIG_TQM85xx) += tqm85xx.o 23obj-$(CONFIG_TQM85xx) += tqm85xx.o
30obj-$(CONFIG_SBC8548) += sbc8548.o 24obj-$(CONFIG_SBC8548) += sbc8548.o
diff --git a/arch/powerpc/platforms/85xx/b4_qds.c b/arch/powerpc/platforms/85xx/b4_qds.c
deleted file mode 100644
index 0c6702f8b88e..000000000000
--- a/arch/powerpc/platforms/85xx/b4_qds.c
+++ /dev/null
@@ -1,102 +0,0 @@
1/*
2 * B4 QDS Setup
3 * Should apply for QDS platform of B4860 and it's personalities.
4 * viz B4860/B4420/B4220QDS
5 *
6 * Copyright 2012 Freescale Semiconductor Inc.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 */
13
14#include <linux/kernel.h>
15#include <linux/pci.h>
16#include <linux/kdev_t.h>
17#include <linux/delay.h>
18#include <linux/interrupt.h>
19#include <linux/phy.h>
20
21#include <asm/time.h>
22#include <asm/machdep.h>
23#include <asm/pci-bridge.h>
24#include <mm/mmu_decl.h>
25#include <asm/prom.h>
26#include <asm/udbg.h>
27#include <asm/mpic.h>
28
29#include <linux/of_platform.h>
30#include <sysdev/fsl_soc.h>
31#include <sysdev/fsl_pci.h>
32#include <asm/ehv_pic.h>
33
34#include "corenet_ds.h"
35
36/*
37 * Called very early, device-tree isn't unflattened
38 */
39static int __init b4_qds_probe(void)
40{
41 unsigned long root = of_get_flat_dt_root();
42#ifdef CONFIG_SMP
43 extern struct smp_ops_t smp_85xx_ops;
44#endif
45
46 if ((of_flat_dt_is_compatible(root, "fsl,B4860QDS")) ||
47 (of_flat_dt_is_compatible(root, "fsl,B4420QDS")) ||
48 (of_flat_dt_is_compatible(root, "fsl,B4220QDS")))
49 return 1;
50
51 /* Check if we're running under the Freescale hypervisor */
52 if ((of_flat_dt_is_compatible(root, "fsl,B4860QDS-hv")) ||
53 (of_flat_dt_is_compatible(root, "fsl,B4420QDS-hv")) ||
54 (of_flat_dt_is_compatible(root, "fsl,B4220QDS-hv"))) {
55 ppc_md.init_IRQ = ehv_pic_init;
56 ppc_md.get_irq = ehv_pic_get_irq;
57 ppc_md.restart = fsl_hv_restart;
58 ppc_md.power_off = fsl_hv_halt;
59 ppc_md.halt = fsl_hv_halt;
60#ifdef CONFIG_SMP
61 /*
62 * Disable the timebase sync operations because we can't write
63 * to the timebase registers under the hypervisor.
64 */
65 smp_85xx_ops.give_timebase = NULL;
66 smp_85xx_ops.take_timebase = NULL;
67#endif
68 return 1;
69 }
70
71 return 0;
72}
73
74define_machine(b4_qds) {
75 .name = "B4 QDS",
76 .probe = b4_qds_probe,
77 .setup_arch = corenet_ds_setup_arch,
78 .init_IRQ = corenet_ds_pic_init,
79#ifdef CONFIG_PCI
80 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
81#endif
82/* coreint doesn't play nice with lazy EE, use legacy mpic for now */
83#ifdef CONFIG_PPC64
84 .get_irq = mpic_get_irq,
85#else
86 .get_irq = mpic_get_coreint_irq,
87#endif
88 .restart = fsl_rstcr_restart,
89 .calibrate_decr = generic_calibrate_decr,
90 .progress = udbg_progress,
91#ifdef CONFIG_PPC64
92 .power_save = book3e_idle,
93#else
94 .power_save = e500_idle,
95#endif
96};
97
98machine_arch_initcall(b4_qds, corenet_ds_publish_devices);
99
100#ifdef CONFIG_SWIOTLB
101machine_arch_initcall(b4_qds, swiotlb_setup_bus_notifier);
102#endif
diff --git a/arch/powerpc/platforms/85xx/corenet_ds.c b/arch/powerpc/platforms/85xx/corenet_ds.c
deleted file mode 100644
index aa3690bae415..000000000000
--- a/arch/powerpc/platforms/85xx/corenet_ds.c
+++ /dev/null
@@ -1,96 +0,0 @@
1/*
2 * Corenet based SoC DS Setup
3 *
4 * Maintained by Kumar Gala (see MAINTAINERS for contact information)
5 *
6 * Copyright 2009-2011 Freescale Semiconductor Inc.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 */
13
14#include <linux/kernel.h>
15#include <linux/pci.h>
16#include <linux/kdev_t.h>
17#include <linux/delay.h>
18#include <linux/interrupt.h>
19
20#include <asm/time.h>
21#include <asm/machdep.h>
22#include <asm/pci-bridge.h>
23#include <asm/ppc-pci.h>
24#include <mm/mmu_decl.h>
25#include <asm/prom.h>
26#include <asm/udbg.h>
27#include <asm/mpic.h>
28
29#include <linux/of_platform.h>
30#include <sysdev/fsl_soc.h>
31#include <sysdev/fsl_pci.h>
32#include "smp.h"
33
34void __init corenet_ds_pic_init(void)
35{
36 struct mpic *mpic;
37 unsigned int flags = MPIC_BIG_ENDIAN | MPIC_SINGLE_DEST_CPU |
38 MPIC_NO_RESET;
39
40 if (ppc_md.get_irq == mpic_get_coreint_irq)
41 flags |= MPIC_ENABLE_COREINT;
42
43 mpic = mpic_alloc(NULL, 0, flags, 0, 512, " OpenPIC ");
44 BUG_ON(mpic == NULL);
45
46 mpic_init(mpic);
47}
48
49/*
50 * Setup the architecture
51 */
52void __init corenet_ds_setup_arch(void)
53{
54 mpc85xx_smp_init();
55
56 swiotlb_detect_4g();
57
58 pr_info("%s board from Freescale Semiconductor\n", ppc_md.name);
59}
60
61static const struct of_device_id of_device_ids[] = {
62 {
63 .compatible = "simple-bus"
64 },
65 {
66 .compatible = "fsl,srio",
67 },
68 {
69 .compatible = "fsl,p4080-pcie",
70 },
71 {
72 .compatible = "fsl,qoriq-pcie-v2.2",
73 },
74 {
75 .compatible = "fsl,qoriq-pcie-v2.3",
76 },
77 {
78 .compatible = "fsl,qoriq-pcie-v2.4",
79 },
80 {
81 .compatible = "fsl,qoriq-pcie-v3.0",
82 },
83 /* The following two are for the Freescale hypervisor */
84 {
85 .name = "hypervisor",
86 },
87 {
88 .name = "handles",
89 },
90 {}
91};
92
93int __init corenet_ds_publish_devices(void)
94{
95 return of_platform_bus_probe(NULL, of_device_ids, NULL);
96}
diff --git a/arch/powerpc/platforms/85xx/corenet_ds.h b/arch/powerpc/platforms/85xx/corenet_ds.h
deleted file mode 100644
index ddd700b23031..000000000000
--- a/arch/powerpc/platforms/85xx/corenet_ds.h
+++ /dev/null
@@ -1,19 +0,0 @@
1/*
2 * Corenet based SoC DS Setup
3 *
4 * Copyright 2009 Freescale Semiconductor Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 */
11
12#ifndef CORENET_DS_H
13#define CORENET_DS_H
14
15extern void __init corenet_ds_pic_init(void);
16extern void __init corenet_ds_setup_arch(void);
17extern int __init corenet_ds_publish_devices(void);
18
19#endif
diff --git a/arch/powerpc/platforms/85xx/corenet_generic.c b/arch/powerpc/platforms/85xx/corenet_generic.c
new file mode 100644
index 000000000000..fbd871e69754
--- /dev/null
+++ b/arch/powerpc/platforms/85xx/corenet_generic.c
@@ -0,0 +1,182 @@
1/*
2 * Corenet based SoC DS Setup
3 *
4 * Maintained by Kumar Gala (see MAINTAINERS for contact information)
5 *
6 * Copyright 2009-2011 Freescale Semiconductor Inc.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 */
13
14#include <linux/kernel.h>
15#include <linux/pci.h>
16#include <linux/kdev_t.h>
17#include <linux/delay.h>
18#include <linux/interrupt.h>
19
20#include <asm/time.h>
21#include <asm/machdep.h>
22#include <asm/pci-bridge.h>
23#include <asm/ppc-pci.h>
24#include <mm/mmu_decl.h>
25#include <asm/prom.h>
26#include <asm/udbg.h>
27#include <asm/mpic.h>
28#include <asm/ehv_pic.h>
29
30#include <linux/of_platform.h>
31#include <sysdev/fsl_soc.h>
32#include <sysdev/fsl_pci.h>
33#include "smp.h"
34
35void __init corenet_gen_pic_init(void)
36{
37 struct mpic *mpic;
38 unsigned int flags = MPIC_BIG_ENDIAN | MPIC_SINGLE_DEST_CPU |
39 MPIC_NO_RESET;
40
41 if (ppc_md.get_irq == mpic_get_coreint_irq)
42 flags |= MPIC_ENABLE_COREINT;
43
44 mpic = mpic_alloc(NULL, 0, flags, 0, 512, " OpenPIC ");
45 BUG_ON(mpic == NULL);
46
47 mpic_init(mpic);
48}
49
50/*
51 * Setup the architecture
52 */
53void __init corenet_gen_setup_arch(void)
54{
55 mpc85xx_smp_init();
56
57 swiotlb_detect_4g();
58
59 pr_info("%s board from Freescale Semiconductor\n", ppc_md.name);
60}
61
62static const struct of_device_id of_device_ids[] = {
63 {
64 .compatible = "simple-bus"
65 },
66 {
67 .compatible = "fsl,srio",
68 },
69 {
70 .compatible = "fsl,p4080-pcie",
71 },
72 {
73 .compatible = "fsl,qoriq-pcie-v2.2",
74 },
75 {
76 .compatible = "fsl,qoriq-pcie-v2.3",
77 },
78 {
79 .compatible = "fsl,qoriq-pcie-v2.4",
80 },
81 {
82 .compatible = "fsl,qoriq-pcie-v3.0",
83 },
84 /* The following two are for the Freescale hypervisor */
85 {
86 .name = "hypervisor",
87 },
88 {
89 .name = "handles",
90 },
91 {}
92};
93
94int __init corenet_gen_publish_devices(void)
95{
96 return of_platform_bus_probe(NULL, of_device_ids, NULL);
97}
98
99static const char * const boards[] __initconst = {
100 "fsl,P2041RDB",
101 "fsl,P3041DS",
102 "fsl,P4080DS",
103 "fsl,P5020DS",
104 "fsl,P5040DS",
105 "fsl,T4240QDS",
106 "fsl,B4860QDS",
107 "fsl,B4420QDS",
108 "fsl,B4220QDS",
109 NULL
110};
111
112static const char * const hv_boards[] __initconst = {
113 "fsl,P2041RDB-hv",
114 "fsl,P3041DS-hv",
115 "fsl,P4080DS-hv",
116 "fsl,P5020DS-hv",
117 "fsl,P5040DS-hv",
118 "fsl,T4240QDS-hv",
119 "fsl,B4860QDS-hv",
120 "fsl,B4420QDS-hv",
121 "fsl,B4220QDS-hv",
122 NULL
123};
124
125/*
126 * Called very early, device-tree isn't unflattened
127 */
128static int __init corenet_generic_probe(void)
129{
130 unsigned long root = of_get_flat_dt_root();
131#ifdef CONFIG_SMP
132 extern struct smp_ops_t smp_85xx_ops;
133#endif
134
135 if (of_flat_dt_match(root, boards))
136 return 1;
137
138 /* Check if we're running under the Freescale hypervisor */
139 if (of_flat_dt_match(root, hv_boards)) {
140 ppc_md.init_IRQ = ehv_pic_init;
141 ppc_md.get_irq = ehv_pic_get_irq;
142 ppc_md.restart = fsl_hv_restart;
143 ppc_md.power_off = fsl_hv_halt;
144 ppc_md.halt = fsl_hv_halt;
145#ifdef CONFIG_SMP
146 /*
147 * Disable the timebase sync operations because we can't write
148 * to the timebase registers under the hypervisor.
149 */
150 smp_85xx_ops.give_timebase = NULL;
151 smp_85xx_ops.take_timebase = NULL;
152#endif
153 return 1;
154 }
155
156 return 0;
157}
158
159define_machine(corenet_generic) {
160 .name = "CoreNet Generic",
161 .probe = corenet_generic_probe,
162 .setup_arch = corenet_gen_setup_arch,
163 .init_IRQ = corenet_gen_pic_init,
164#ifdef CONFIG_PCI
165 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
166#endif
167 .get_irq = mpic_get_coreint_irq,
168 .restart = fsl_rstcr_restart,
169 .calibrate_decr = generic_calibrate_decr,
170 .progress = udbg_progress,
171#ifdef CONFIG_PPC64
172 .power_save = book3e_idle,
173#else
174 .power_save = e500_idle,
175#endif
176};
177
178machine_arch_initcall(corenet_generic, corenet_gen_publish_devices);
179
180#ifdef CONFIG_SWIOTLB
181machine_arch_initcall(corenet_generic, swiotlb_setup_bus_notifier);
182#endif
diff --git a/arch/powerpc/platforms/85xx/p1010rdb.c b/arch/powerpc/platforms/85xx/p1010rdb.c
index 0252961392d5..d6a3dd311494 100644
--- a/arch/powerpc/platforms/85xx/p1010rdb.c
+++ b/arch/powerpc/platforms/85xx/p1010rdb.c
@@ -66,6 +66,8 @@ static int __init p1010_rdb_probe(void)
66 66
67 if (of_flat_dt_is_compatible(root, "fsl,P1010RDB")) 67 if (of_flat_dt_is_compatible(root, "fsl,P1010RDB"))
68 return 1; 68 return 1;
69 if (of_flat_dt_is_compatible(root, "fsl,P1010RDB-PB"))
70 return 1;
69 return 0; 71 return 0;
70} 72}
71 73
diff --git a/arch/powerpc/platforms/85xx/p2041_rdb.c b/arch/powerpc/platforms/85xx/p2041_rdb.c
deleted file mode 100644
index 000c0892fc40..000000000000
--- a/arch/powerpc/platforms/85xx/p2041_rdb.c
+++ /dev/null
@@ -1,87 +0,0 @@
1/*
2 * P2041 RDB Setup
3 *
4 * Copyright 2011 Freescale Semiconductor Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 */
11
12#include <linux/kernel.h>
13#include <linux/pci.h>
14#include <linux/kdev_t.h>
15#include <linux/delay.h>
16#include <linux/interrupt.h>
17#include <linux/phy.h>
18
19#include <asm/time.h>
20#include <asm/machdep.h>
21#include <asm/pci-bridge.h>
22#include <mm/mmu_decl.h>
23#include <asm/prom.h>
24#include <asm/udbg.h>
25#include <asm/mpic.h>
26
27#include <linux/of_platform.h>
28#include <sysdev/fsl_soc.h>
29#include <sysdev/fsl_pci.h>
30#include <asm/ehv_pic.h>
31
32#include "corenet_ds.h"
33
34/*
35 * Called very early, device-tree isn't unflattened
36 */
37static int __init p2041_rdb_probe(void)
38{
39 unsigned long root = of_get_flat_dt_root();
40#ifdef CONFIG_SMP
41 extern struct smp_ops_t smp_85xx_ops;
42#endif
43
44 if (of_flat_dt_is_compatible(root, "fsl,P2041RDB"))
45 return 1;
46
47 /* Check if we're running under the Freescale hypervisor */
48 if (of_flat_dt_is_compatible(root, "fsl,P2041RDB-hv")) {
49 ppc_md.init_IRQ = ehv_pic_init;
50 ppc_md.get_irq = ehv_pic_get_irq;
51 ppc_md.restart = fsl_hv_restart;
52 ppc_md.power_off = fsl_hv_halt;
53 ppc_md.halt = fsl_hv_halt;
54#ifdef CONFIG_SMP
55 /*
56 * Disable the timebase sync operations because we can't write
57 * to the timebase registers under the hypervisor.
58 */
59 smp_85xx_ops.give_timebase = NULL;
60 smp_85xx_ops.take_timebase = NULL;
61#endif
62 return 1;
63 }
64
65 return 0;
66}
67
68define_machine(p2041_rdb) {
69 .name = "P2041 RDB",
70 .probe = p2041_rdb_probe,
71 .setup_arch = corenet_ds_setup_arch,
72 .init_IRQ = corenet_ds_pic_init,
73#ifdef CONFIG_PCI
74 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
75#endif
76 .get_irq = mpic_get_coreint_irq,
77 .restart = fsl_rstcr_restart,
78 .calibrate_decr = generic_calibrate_decr,
79 .progress = udbg_progress,
80 .power_save = e500_idle,
81};
82
83machine_arch_initcall(p2041_rdb, corenet_ds_publish_devices);
84
85#ifdef CONFIG_SWIOTLB
86machine_arch_initcall(p2041_rdb, swiotlb_setup_bus_notifier);
87#endif
diff --git a/arch/powerpc/platforms/85xx/p3041_ds.c b/arch/powerpc/platforms/85xx/p3041_ds.c
deleted file mode 100644
index b3edc205daa9..000000000000
--- a/arch/powerpc/platforms/85xx/p3041_ds.c
+++ /dev/null
@@ -1,89 +0,0 @@
1/*
2 * P3041 DS Setup
3 *
4 * Maintained by Kumar Gala (see MAINTAINERS for contact information)
5 *
6 * Copyright 2009-2010 Freescale Semiconductor Inc.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 */
13
14#include <linux/kernel.h>
15#include <linux/pci.h>
16#include <linux/kdev_t.h>
17#include <linux/delay.h>
18#include <linux/interrupt.h>
19#include <linux/phy.h>
20
21#include <asm/time.h>
22#include <asm/machdep.h>
23#include <asm/pci-bridge.h>
24#include <mm/mmu_decl.h>
25#include <asm/prom.h>
26#include <asm/udbg.h>
27#include <asm/mpic.h>
28
29#include <linux/of_platform.h>
30#include <sysdev/fsl_soc.h>
31#include <sysdev/fsl_pci.h>
32#include <asm/ehv_pic.h>
33
34#include "corenet_ds.h"
35
36/*
37 * Called very early, device-tree isn't unflattened
38 */
39static int __init p3041_ds_probe(void)
40{
41 unsigned long root = of_get_flat_dt_root();
42#ifdef CONFIG_SMP
43 extern struct smp_ops_t smp_85xx_ops;
44#endif
45
46 if (of_flat_dt_is_compatible(root, "fsl,P3041DS"))
47 return 1;
48
49 /* Check if we're running under the Freescale hypervisor */
50 if (of_flat_dt_is_compatible(root, "fsl,P3041DS-hv")) {
51 ppc_md.init_IRQ = ehv_pic_init;
52 ppc_md.get_irq = ehv_pic_get_irq;
53 ppc_md.restart = fsl_hv_restart;
54 ppc_md.power_off = fsl_hv_halt;
55 ppc_md.halt = fsl_hv_halt;
56#ifdef CONFIG_SMP
57 /*
58 * Disable the timebase sync operations because we can't write
59 * to the timebase registers under the hypervisor.
60 */
61 smp_85xx_ops.give_timebase = NULL;
62 smp_85xx_ops.take_timebase = NULL;
63#endif
64 return 1;
65 }
66
67 return 0;
68}
69
70define_machine(p3041_ds) {
71 .name = "P3041 DS",
72 .probe = p3041_ds_probe,
73 .setup_arch = corenet_ds_setup_arch,
74 .init_IRQ = corenet_ds_pic_init,
75#ifdef CONFIG_PCI
76 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
77#endif
78 .get_irq = mpic_get_coreint_irq,
79 .restart = fsl_rstcr_restart,
80 .calibrate_decr = generic_calibrate_decr,
81 .progress = udbg_progress,
82 .power_save = e500_idle,
83};
84
85machine_arch_initcall(p3041_ds, corenet_ds_publish_devices);
86
87#ifdef CONFIG_SWIOTLB
88machine_arch_initcall(p3041_ds, swiotlb_setup_bus_notifier);
89#endif
diff --git a/arch/powerpc/platforms/85xx/p4080_ds.c b/arch/powerpc/platforms/85xx/p4080_ds.c
deleted file mode 100644
index 54df10632aea..000000000000
--- a/arch/powerpc/platforms/85xx/p4080_ds.c
+++ /dev/null
@@ -1,87 +0,0 @@
1/*
2 * P4080 DS Setup
3 *
4 * Maintained by Kumar Gala (see MAINTAINERS for contact information)
5 *
6 * Copyright 2009 Freescale Semiconductor Inc.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 */
13
14#include <linux/kernel.h>
15#include <linux/pci.h>
16#include <linux/kdev_t.h>
17#include <linux/delay.h>
18#include <linux/interrupt.h>
19
20#include <asm/time.h>
21#include <asm/machdep.h>
22#include <asm/pci-bridge.h>
23#include <mm/mmu_decl.h>
24#include <asm/prom.h>
25#include <asm/udbg.h>
26#include <asm/mpic.h>
27
28#include <linux/of_platform.h>
29#include <sysdev/fsl_soc.h>
30#include <sysdev/fsl_pci.h>
31#include <asm/ehv_pic.h>
32
33#include "corenet_ds.h"
34
35/*
36 * Called very early, device-tree isn't unflattened
37 */
38static int __init p4080_ds_probe(void)
39{
40 unsigned long root = of_get_flat_dt_root();
41#ifdef CONFIG_SMP
42 extern struct smp_ops_t smp_85xx_ops;
43#endif
44
45 if (of_flat_dt_is_compatible(root, "fsl,P4080DS"))
46 return 1;
47
48 /* Check if we're running under the Freescale hypervisor */
49 if (of_flat_dt_is_compatible(root, "fsl,P4080DS-hv")) {
50 ppc_md.init_IRQ = ehv_pic_init;
51 ppc_md.get_irq = ehv_pic_get_irq;
52 ppc_md.restart = fsl_hv_restart;
53 ppc_md.power_off = fsl_hv_halt;
54 ppc_md.halt = fsl_hv_halt;
55#ifdef CONFIG_SMP
56 /*
57 * Disable the timebase sync operations because we can't write
58 * to the timebase registers under the hypervisor.
59 */
60 smp_85xx_ops.give_timebase = NULL;
61 smp_85xx_ops.take_timebase = NULL;
62#endif
63 return 1;
64 }
65
66 return 0;
67}
68
69define_machine(p4080_ds) {
70 .name = "P4080 DS",
71 .probe = p4080_ds_probe,
72 .setup_arch = corenet_ds_setup_arch,
73 .init_IRQ = corenet_ds_pic_init,
74#ifdef CONFIG_PCI
75 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
76#endif
77 .get_irq = mpic_get_coreint_irq,
78 .restart = fsl_rstcr_restart,
79 .calibrate_decr = generic_calibrate_decr,
80 .progress = udbg_progress,
81 .power_save = e500_idle,
82};
83
84machine_arch_initcall(p4080_ds, corenet_ds_publish_devices);
85#ifdef CONFIG_SWIOTLB
86machine_arch_initcall(p4080_ds, swiotlb_setup_bus_notifier);
87#endif
diff --git a/arch/powerpc/platforms/85xx/p5020_ds.c b/arch/powerpc/platforms/85xx/p5020_ds.c
deleted file mode 100644
index 39cfa4044e6c..000000000000
--- a/arch/powerpc/platforms/85xx/p5020_ds.c
+++ /dev/null
@@ -1,93 +0,0 @@
1/*
2 * P5020 DS Setup
3 *
4 * Maintained by Kumar Gala (see MAINTAINERS for contact information)
5 *
6 * Copyright 2009-2010 Freescale Semiconductor Inc.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 */
13
14#include <linux/kernel.h>
15#include <linux/pci.h>
16#include <linux/kdev_t.h>
17#include <linux/delay.h>
18#include <linux/interrupt.h>
19#include <linux/phy.h>
20
21#include <asm/time.h>
22#include <asm/machdep.h>
23#include <asm/pci-bridge.h>
24#include <mm/mmu_decl.h>
25#include <asm/prom.h>
26#include <asm/udbg.h>
27#include <asm/mpic.h>
28
29#include <linux/of_platform.h>
30#include <sysdev/fsl_soc.h>
31#include <sysdev/fsl_pci.h>
32#include <asm/ehv_pic.h>
33
34#include "corenet_ds.h"
35
36/*
37 * Called very early, device-tree isn't unflattened
38 */
39static int __init p5020_ds_probe(void)
40{
41 unsigned long root = of_get_flat_dt_root();
42#ifdef CONFIG_SMP
43 extern struct smp_ops_t smp_85xx_ops;
44#endif
45
46 if (of_flat_dt_is_compatible(root, "fsl,P5020DS"))
47 return 1;
48
49 /* Check if we're running under the Freescale hypervisor */
50 if (of_flat_dt_is_compatible(root, "fsl,P5020DS-hv")) {
51 ppc_md.init_IRQ = ehv_pic_init;
52 ppc_md.get_irq = ehv_pic_get_irq;
53 ppc_md.restart = fsl_hv_restart;
54 ppc_md.power_off = fsl_hv_halt;
55 ppc_md.halt = fsl_hv_halt;
56#ifdef CONFIG_SMP
57 /*
58 * Disable the timebase sync operations because we can't write
59 * to the timebase registers under the hypervisor.
60 */
61 smp_85xx_ops.give_timebase = NULL;
62 smp_85xx_ops.take_timebase = NULL;
63#endif
64 return 1;
65 }
66
67 return 0;
68}
69
70define_machine(p5020_ds) {
71 .name = "P5020 DS",
72 .probe = p5020_ds_probe,
73 .setup_arch = corenet_ds_setup_arch,
74 .init_IRQ = corenet_ds_pic_init,
75#ifdef CONFIG_PCI
76 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
77#endif
78 .get_irq = mpic_get_coreint_irq,
79 .restart = fsl_rstcr_restart,
80 .calibrate_decr = generic_calibrate_decr,
81 .progress = udbg_progress,
82#ifdef CONFIG_PPC64
83 .power_save = book3e_idle,
84#else
85 .power_save = e500_idle,
86#endif
87};
88
89machine_arch_initcall(p5020_ds, corenet_ds_publish_devices);
90
91#ifdef CONFIG_SWIOTLB
92machine_arch_initcall(p5020_ds, swiotlb_setup_bus_notifier);
93#endif
diff --git a/arch/powerpc/platforms/85xx/p5040_ds.c b/arch/powerpc/platforms/85xx/p5040_ds.c
deleted file mode 100644
index f70e74cddf97..000000000000
--- a/arch/powerpc/platforms/85xx/p5040_ds.c
+++ /dev/null
@@ -1,84 +0,0 @@
1/*
2 * P5040 DS Setup
3 *
4 * Copyright 2009-2010 Freescale Semiconductor Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 */
11
12#include <linux/kernel.h>
13#include <linux/pci.h>
14
15#include <asm/machdep.h>
16#include <asm/udbg.h>
17#include <asm/mpic.h>
18
19#include <linux/of_fdt.h>
20
21#include <sysdev/fsl_soc.h>
22#include <sysdev/fsl_pci.h>
23#include <asm/ehv_pic.h>
24
25#include "corenet_ds.h"
26
27/*
28 * Called very early, device-tree isn't unflattened
29 */
30static int __init p5040_ds_probe(void)
31{
32 unsigned long root = of_get_flat_dt_root();
33#ifdef CONFIG_SMP
34 extern struct smp_ops_t smp_85xx_ops;
35#endif
36
37 if (of_flat_dt_is_compatible(root, "fsl,P5040DS"))
38 return 1;
39
40 /* Check if we're running under the Freescale hypervisor */
41 if (of_flat_dt_is_compatible(root, "fsl,P5040DS-hv")) {
42 ppc_md.init_IRQ = ehv_pic_init;
43 ppc_md.get_irq = ehv_pic_get_irq;
44 ppc_md.restart = fsl_hv_restart;
45 ppc_md.power_off = fsl_hv_halt;
46 ppc_md.halt = fsl_hv_halt;
47#ifdef CONFIG_SMP
48 /*
49 * Disable the timebase sync operations because we can't write
50 * to the timebase registers under the hypervisor.
51 */
52 smp_85xx_ops.give_timebase = NULL;
53 smp_85xx_ops.take_timebase = NULL;
54#endif
55 return 1;
56 }
57
58 return 0;
59}
60
61define_machine(p5040_ds) {
62 .name = "P5040 DS",
63 .probe = p5040_ds_probe,
64 .setup_arch = corenet_ds_setup_arch,
65 .init_IRQ = corenet_ds_pic_init,
66#ifdef CONFIG_PCI
67 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
68#endif
69 .get_irq = mpic_get_coreint_irq,
70 .restart = fsl_rstcr_restart,
71 .calibrate_decr = generic_calibrate_decr,
72 .progress = udbg_progress,
73#ifdef CONFIG_PPC64
74 .power_save = book3e_idle,
75#else
76 .power_save = e500_idle,
77#endif
78};
79
80machine_arch_initcall(p5040_ds, corenet_ds_publish_devices);
81
82#ifdef CONFIG_SWIOTLB
83machine_arch_initcall(p5040_ds, swiotlb_setup_bus_notifier);
84#endif
diff --git a/arch/powerpc/platforms/85xx/t4240_qds.c b/arch/powerpc/platforms/85xx/t4240_qds.c
deleted file mode 100644
index 91ead6b1b8af..000000000000
--- a/arch/powerpc/platforms/85xx/t4240_qds.c
+++ /dev/null
@@ -1,93 +0,0 @@
1/*
2 * T4240 QDS Setup
3 *
4 * Maintained by Kumar Gala (see MAINTAINERS for contact information)
5 *
6 * Copyright 2012 Freescale Semiconductor Inc.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 */
13
14#include <linux/kernel.h>
15#include <linux/pci.h>
16#include <linux/kdev_t.h>
17#include <linux/delay.h>
18#include <linux/interrupt.h>
19#include <linux/phy.h>
20
21#include <asm/time.h>
22#include <asm/machdep.h>
23#include <asm/pci-bridge.h>
24#include <mm/mmu_decl.h>
25#include <asm/prom.h>
26#include <asm/udbg.h>
27#include <asm/mpic.h>
28
29#include <linux/of_platform.h>
30#include <sysdev/fsl_soc.h>
31#include <sysdev/fsl_pci.h>
32#include <asm/ehv_pic.h>
33
34#include "corenet_ds.h"
35
36/*
37 * Called very early, device-tree isn't unflattened
38 */
39static int __init t4240_qds_probe(void)
40{
41 unsigned long root = of_get_flat_dt_root();
42#ifdef CONFIG_SMP
43 extern struct smp_ops_t smp_85xx_ops;
44#endif
45
46 if (of_flat_dt_is_compatible(root, "fsl,T4240QDS"))
47 return 1;
48
49 /* Check if we're running under the Freescale hypervisor */
50 if (of_flat_dt_is_compatible(root, "fsl,T4240QDS-hv")) {
51 ppc_md.init_IRQ = ehv_pic_init;
52 ppc_md.get_irq = ehv_pic_get_irq;
53 ppc_md.restart = fsl_hv_restart;
54 ppc_md.power_off = fsl_hv_halt;
55 ppc_md.halt = fsl_hv_halt;
56#ifdef CONFIG_SMP
57 /*
58 * Disable the timebase sync operations because we can't write
59 * to the timebase registers under the hypervisor.
60 */
61 smp_85xx_ops.give_timebase = NULL;
62 smp_85xx_ops.take_timebase = NULL;
63#endif
64 return 1;
65 }
66
67 return 0;
68}
69
70define_machine(t4240_qds) {
71 .name = "T4240 QDS",
72 .probe = t4240_qds_probe,
73 .setup_arch = corenet_ds_setup_arch,
74 .init_IRQ = corenet_ds_pic_init,
75#ifdef CONFIG_PCI
76 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
77#endif
78 .get_irq = mpic_get_coreint_irq,
79 .restart = fsl_rstcr_restart,
80 .calibrate_decr = generic_calibrate_decr,
81 .progress = udbg_progress,
82#ifdef CONFIG_PPC64
83 .power_save = book3e_idle,
84#else
85 .power_save = e500_idle,
86#endif
87};
88
89machine_arch_initcall(t4240_qds, corenet_ds_publish_devices);
90
91#ifdef CONFIG_SWIOTLB
92machine_arch_initcall(t4240_qds, swiotlb_setup_bus_notifier);
93#endif
diff --git a/arch/powerpc/platforms/8xx/tqm8xx_setup.c b/arch/powerpc/platforms/8xx/tqm8xx_setup.c
index 8d21ab70e06c..ef0778a0ca8f 100644
--- a/arch/powerpc/platforms/8xx/tqm8xx_setup.c
+++ b/arch/powerpc/platforms/8xx/tqm8xx_setup.c
@@ -48,7 +48,7 @@ struct cpm_pin {
48 int port, pin, flags; 48 int port, pin, flags;
49}; 49};
50 50
51static struct __initdata cpm_pin tqm8xx_pins[] = { 51static struct cpm_pin tqm8xx_pins[] __initdata = {
52 /* SMC1 */ 52 /* SMC1 */
53 {CPM_PORTB, 24, CPM_PIN_INPUT}, /* RX */ 53 {CPM_PORTB, 24, CPM_PIN_INPUT}, /* RX */
54 {CPM_PORTB, 25, CPM_PIN_INPUT | CPM_PIN_SECONDARY}, /* TX */ 54 {CPM_PORTB, 25, CPM_PIN_INPUT | CPM_PIN_SECONDARY}, /* TX */
@@ -63,7 +63,7 @@ static struct __initdata cpm_pin tqm8xx_pins[] = {
63 {CPM_PORTC, 11, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_GPIO}, 63 {CPM_PORTC, 11, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_GPIO},
64}; 64};
65 65
66static struct __initdata cpm_pin tqm8xx_fec_pins[] = { 66static struct cpm_pin tqm8xx_fec_pins[] __initdata = {
67 /* MII */ 67 /* MII */
68 {CPM_PORTD, 3, CPM_PIN_OUTPUT}, 68 {CPM_PORTD, 3, CPM_PIN_OUTPUT},
69 {CPM_PORTD, 4, CPM_PIN_OUTPUT}, 69 {CPM_PORTD, 4, CPM_PIN_OUTPUT},
diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platforms/Kconfig.cputype
index 6704e2e20e6b..c2a566fb8bb8 100644
--- a/arch/powerpc/platforms/Kconfig.cputype
+++ b/arch/powerpc/platforms/Kconfig.cputype
@@ -93,22 +93,23 @@ choice
93 93
94config GENERIC_CPU 94config GENERIC_CPU
95 bool "Generic" 95 bool "Generic"
96 depends on !CPU_LITTLE_ENDIAN
96 97
97config CELL_CPU 98config CELL_CPU
98 bool "Cell Broadband Engine" 99 bool "Cell Broadband Engine"
99 depends on PPC_BOOK3S_64 100 depends on PPC_BOOK3S_64 && !CPU_LITTLE_ENDIAN
100 101
101config POWER4_CPU 102config POWER4_CPU
102 bool "POWER4" 103 bool "POWER4"
103 depends on PPC_BOOK3S_64 104 depends on PPC_BOOK3S_64 && !CPU_LITTLE_ENDIAN
104 105
105config POWER5_CPU 106config POWER5_CPU
106 bool "POWER5" 107 bool "POWER5"
107 depends on PPC_BOOK3S_64 108 depends on PPC_BOOK3S_64 && !CPU_LITTLE_ENDIAN
108 109
109config POWER6_CPU 110config POWER6_CPU
110 bool "POWER6" 111 bool "POWER6"
111 depends on PPC_BOOK3S_64 112 depends on PPC_BOOK3S_64 && !CPU_LITTLE_ENDIAN
112 113
113config POWER7_CPU 114config POWER7_CPU
114 bool "POWER7" 115 bool "POWER7"
diff --git a/arch/powerpc/platforms/chrp/nvram.c b/arch/powerpc/platforms/chrp/nvram.c
index d3ceff04ffc7..9ef8cc3378d0 100644
--- a/arch/powerpc/platforms/chrp/nvram.c
+++ b/arch/powerpc/platforms/chrp/nvram.c
@@ -66,7 +66,7 @@ static void chrp_nvram_write(int addr, unsigned char val)
66void __init chrp_nvram_init(void) 66void __init chrp_nvram_init(void)
67{ 67{
68 struct device_node *nvram; 68 struct device_node *nvram;
69 const unsigned int *nbytes_p; 69 const __be32 *nbytes_p;
70 unsigned int proplen; 70 unsigned int proplen;
71 71
72 nvram = of_find_node_by_type(NULL, "nvram"); 72 nvram = of_find_node_by_type(NULL, "nvram");
@@ -79,7 +79,7 @@ void __init chrp_nvram_init(void)
79 return; 79 return;
80 } 80 }
81 81
82 nvram_size = *nbytes_p; 82 nvram_size = be32_to_cpup(nbytes_p);
83 83
84 printk(KERN_INFO "CHRP nvram contains %u bytes\n", nvram_size); 84 printk(KERN_INFO "CHRP nvram contains %u bytes\n", nvram_size);
85 of_node_put(nvram); 85 of_node_put(nvram);
diff --git a/arch/powerpc/platforms/embedded6xx/hlwd-pic.c b/arch/powerpc/platforms/embedded6xx/hlwd-pic.c
index 3006b5117ec6..6f61e21b3617 100644
--- a/arch/powerpc/platforms/embedded6xx/hlwd-pic.c
+++ b/arch/powerpc/platforms/embedded6xx/hlwd-pic.c
@@ -181,6 +181,7 @@ struct irq_domain *hlwd_pic_init(struct device_node *np)
181 &hlwd_irq_domain_ops, io_base); 181 &hlwd_irq_domain_ops, io_base);
182 if (!irq_domain) { 182 if (!irq_domain) {
183 pr_err("failed to allocate irq_domain\n"); 183 pr_err("failed to allocate irq_domain\n");
184 iounmap(io_base);
184 return NULL; 185 return NULL;
185 } 186 }
186 187
diff --git a/arch/powerpc/platforms/powernv/Kconfig b/arch/powerpc/platforms/powernv/Kconfig
index 6fae5eb99ea6..9fced3f6d2dc 100644
--- a/arch/powerpc/platforms/powernv/Kconfig
+++ b/arch/powerpc/platforms/powernv/Kconfig
@@ -9,6 +9,8 @@ config PPC_POWERNV
9 select EPAPR_BOOT 9 select EPAPR_BOOT
10 select PPC_INDIRECT_PIO 10 select PPC_INDIRECT_PIO
11 select PPC_UDBG_16550 11 select PPC_UDBG_16550
12 select PPC_SCOM
13 select ARCH_RANDOM
12 default y 14 default y
13 15
14config POWERNV_MSI 16config POWERNV_MSI
diff --git a/arch/powerpc/platforms/powernv/Makefile b/arch/powerpc/platforms/powernv/Makefile
index 300c437d713c..873fa1370dc4 100644
--- a/arch/powerpc/platforms/powernv/Makefile
+++ b/arch/powerpc/platforms/powernv/Makefile
@@ -1,6 +1,8 @@
1obj-y += setup.o opal-takeover.o opal-wrappers.o opal.o 1obj-y += setup.o opal-takeover.o opal-wrappers.o opal.o
2obj-y += opal-rtc.o opal-nvram.o opal-lpc.o 2obj-y += opal-rtc.o opal-nvram.o opal-lpc.o opal-flash.o
3obj-y += rng.o
3 4
4obj-$(CONFIG_SMP) += smp.o 5obj-$(CONFIG_SMP) += smp.o
5obj-$(CONFIG_PCI) += pci.o pci-p5ioc2.o pci-ioda.o 6obj-$(CONFIG_PCI) += pci.o pci-p5ioc2.o pci-ioda.o
6obj-$(CONFIG_EEH) += eeh-ioda.o eeh-powernv.o 7obj-$(CONFIG_EEH) += eeh-ioda.o eeh-powernv.o
8obj-$(CONFIG_PPC_SCOM) += opal-xscom.o
diff --git a/arch/powerpc/platforms/powernv/eeh-ioda.c b/arch/powerpc/platforms/powernv/eeh-ioda.c
index cf42e74514fa..02245cee7818 100644
--- a/arch/powerpc/platforms/powernv/eeh-ioda.c
+++ b/arch/powerpc/platforms/powernv/eeh-ioda.c
@@ -59,26 +59,60 @@ static struct notifier_block ioda_eeh_nb = {
59}; 59};
60 60
61#ifdef CONFIG_DEBUG_FS 61#ifdef CONFIG_DEBUG_FS
62static int ioda_eeh_dbgfs_set(void *data, u64 val) 62static int ioda_eeh_dbgfs_set(void *data, int offset, u64 val)
63{ 63{
64 struct pci_controller *hose = data; 64 struct pci_controller *hose = data;
65 struct pnv_phb *phb = hose->private_data; 65 struct pnv_phb *phb = hose->private_data;
66 66
67 out_be64(phb->regs + 0xD10, val); 67 out_be64(phb->regs + offset, val);
68 return 0; 68 return 0;
69} 69}
70 70
71static int ioda_eeh_dbgfs_get(void *data, u64 *val) 71static int ioda_eeh_dbgfs_get(void *data, int offset, u64 *val)
72{ 72{
73 struct pci_controller *hose = data; 73 struct pci_controller *hose = data;
74 struct pnv_phb *phb = hose->private_data; 74 struct pnv_phb *phb = hose->private_data;
75 75
76 *val = in_be64(phb->regs + 0xD10); 76 *val = in_be64(phb->regs + offset);
77 return 0; 77 return 0;
78} 78}
79 79
80DEFINE_SIMPLE_ATTRIBUTE(ioda_eeh_dbgfs_ops, ioda_eeh_dbgfs_get, 80static int ioda_eeh_outb_dbgfs_set(void *data, u64 val)
81 ioda_eeh_dbgfs_set, "0x%llx\n"); 81{
82 return ioda_eeh_dbgfs_set(data, 0xD10, val);
83}
84
85static int ioda_eeh_outb_dbgfs_get(void *data, u64 *val)
86{
87 return ioda_eeh_dbgfs_get(data, 0xD10, val);
88}
89
90static int ioda_eeh_inbA_dbgfs_set(void *data, u64 val)
91{
92 return ioda_eeh_dbgfs_set(data, 0xD90, val);
93}
94
95static int ioda_eeh_inbA_dbgfs_get(void *data, u64 *val)
96{
97 return ioda_eeh_dbgfs_get(data, 0xD90, val);
98}
99
100static int ioda_eeh_inbB_dbgfs_set(void *data, u64 val)
101{
102 return ioda_eeh_dbgfs_set(data, 0xE10, val);
103}
104
105static int ioda_eeh_inbB_dbgfs_get(void *data, u64 *val)
106{
107 return ioda_eeh_dbgfs_get(data, 0xE10, val);
108}
109
110DEFINE_SIMPLE_ATTRIBUTE(ioda_eeh_outb_dbgfs_ops, ioda_eeh_outb_dbgfs_get,
111 ioda_eeh_outb_dbgfs_set, "0x%llx\n");
112DEFINE_SIMPLE_ATTRIBUTE(ioda_eeh_inbA_dbgfs_ops, ioda_eeh_inbA_dbgfs_get,
113 ioda_eeh_inbA_dbgfs_set, "0x%llx\n");
114DEFINE_SIMPLE_ATTRIBUTE(ioda_eeh_inbB_dbgfs_ops, ioda_eeh_inbB_dbgfs_get,
115 ioda_eeh_inbB_dbgfs_set, "0x%llx\n");
82#endif /* CONFIG_DEBUG_FS */ 116#endif /* CONFIG_DEBUG_FS */
83 117
84/** 118/**
@@ -106,27 +140,30 @@ static int ioda_eeh_post_init(struct pci_controller *hose)
106 ioda_eeh_nb_init = 1; 140 ioda_eeh_nb_init = 1;
107 } 141 }
108 142
109 /* FIXME: Enable it for PHB3 later */ 143 /* We needn't HUB diag-data on PHB3 */
110 if (phb->type == PNV_PHB_IODA1) { 144 if (phb->type == PNV_PHB_IODA1 && !hub_diag) {
145 hub_diag = (char *)__get_free_page(GFP_KERNEL | __GFP_ZERO);
111 if (!hub_diag) { 146 if (!hub_diag) {
112 hub_diag = (char *)__get_free_page(GFP_KERNEL | 147 pr_err("%s: Out of memory !\n", __func__);
113 __GFP_ZERO); 148 return -ENOMEM;
114 if (!hub_diag) {
115 pr_err("%s: Out of memory !\n",
116 __func__);
117 return -ENOMEM;
118 }
119 } 149 }
150 }
120 151
121#ifdef CONFIG_DEBUG_FS 152#ifdef CONFIG_DEBUG_FS
122 if (phb->dbgfs) 153 if (phb->dbgfs) {
123 debugfs_create_file("err_injct", 0600, 154 debugfs_create_file("err_injct_outbound", 0600,
124 phb->dbgfs, hose, 155 phb->dbgfs, hose,
125 &ioda_eeh_dbgfs_ops); 156 &ioda_eeh_outb_dbgfs_ops);
157 debugfs_create_file("err_injct_inboundA", 0600,
158 phb->dbgfs, hose,
159 &ioda_eeh_inbA_dbgfs_ops);
160 debugfs_create_file("err_injct_inboundB", 0600,
161 phb->dbgfs, hose,
162 &ioda_eeh_inbB_dbgfs_ops);
163 }
126#endif 164#endif
127 165
128 phb->eeh_state |= PNV_EEH_STATE_ENABLED; 166 phb->eeh_state |= PNV_EEH_STATE_ENABLED;
129 }
130 167
131 return 0; 168 return 0;
132} 169}
@@ -546,8 +583,8 @@ static int ioda_eeh_get_log(struct eeh_pe *pe, int severity,
546 phb->diag.blob, PNV_PCI_DIAG_BUF_SIZE); 583 phb->diag.blob, PNV_PCI_DIAG_BUF_SIZE);
547 if (ret) { 584 if (ret) {
548 spin_unlock_irqrestore(&phb->lock, flags); 585 spin_unlock_irqrestore(&phb->lock, flags);
549 pr_warning("%s: Failed to get log for PHB#%x-PE#%x\n", 586 pr_warning("%s: Can't get log for PHB#%x-PE#%x (%lld)\n",
550 __func__, hose->global_number, pe->addr); 587 __func__, hose->global_number, pe->addr, ret);
551 return -EIO; 588 return -EIO;
552 } 589 }
553 590
@@ -710,6 +747,73 @@ static void ioda_eeh_p7ioc_phb_diag(struct pci_controller *hose,
710 } 747 }
711} 748}
712 749
750static void ioda_eeh_phb3_phb_diag(struct pci_controller *hose,
751 struct OpalIoPhbErrorCommon *common)
752{
753 struct OpalIoPhb3ErrorData *data;
754 int i;
755
756 data = (struct OpalIoPhb3ErrorData*)common;
757 pr_info("PHB3 PHB#%x Diag-data (Version: %d)\n\n",
758 hose->global_number, common->version);
759
760 pr_info(" brdgCtl: %08x\n", data->brdgCtl);
761
762 pr_info(" portStatusReg: %08x\n", data->portStatusReg);
763 pr_info(" rootCmplxStatus: %08x\n", data->rootCmplxStatus);
764 pr_info(" busAgentStatus: %08x\n", data->busAgentStatus);
765
766 pr_info(" deviceStatus: %08x\n", data->deviceStatus);
767 pr_info(" slotStatus: %08x\n", data->slotStatus);
768 pr_info(" linkStatus: %08x\n", data->linkStatus);
769 pr_info(" devCmdStatus: %08x\n", data->devCmdStatus);
770 pr_info(" devSecStatus: %08x\n", data->devSecStatus);
771
772 pr_info(" rootErrorStatus: %08x\n", data->rootErrorStatus);
773 pr_info(" uncorrErrorStatus: %08x\n", data->uncorrErrorStatus);
774 pr_info(" corrErrorStatus: %08x\n", data->corrErrorStatus);
775 pr_info(" tlpHdr1: %08x\n", data->tlpHdr1);
776 pr_info(" tlpHdr2: %08x\n", data->tlpHdr2);
777 pr_info(" tlpHdr3: %08x\n", data->tlpHdr3);
778 pr_info(" tlpHdr4: %08x\n", data->tlpHdr4);
779 pr_info(" sourceId: %08x\n", data->sourceId);
780 pr_info(" errorClass: %016llx\n", data->errorClass);
781 pr_info(" correlator: %016llx\n", data->correlator);
782 pr_info(" nFir: %016llx\n", data->nFir);
783 pr_info(" nFirMask: %016llx\n", data->nFirMask);
784 pr_info(" nFirWOF: %016llx\n", data->nFirWOF);
785 pr_info(" PhbPlssr: %016llx\n", data->phbPlssr);
786 pr_info(" PhbCsr: %016llx\n", data->phbCsr);
787 pr_info(" lemFir: %016llx\n", data->lemFir);
788 pr_info(" lemErrorMask: %016llx\n", data->lemErrorMask);
789 pr_info(" lemWOF: %016llx\n", data->lemWOF);
790 pr_info(" phbErrorStatus: %016llx\n", data->phbErrorStatus);
791 pr_info(" phbFirstErrorStatus: %016llx\n", data->phbFirstErrorStatus);
792 pr_info(" phbErrorLog0: %016llx\n", data->phbErrorLog0);
793 pr_info(" phbErrorLog1: %016llx\n", data->phbErrorLog1);
794 pr_info(" mmioErrorStatus: %016llx\n", data->mmioErrorStatus);
795 pr_info(" mmioFirstErrorStatus: %016llx\n", data->mmioFirstErrorStatus);
796 pr_info(" mmioErrorLog0: %016llx\n", data->mmioErrorLog0);
797 pr_info(" mmioErrorLog1: %016llx\n", data->mmioErrorLog1);
798 pr_info(" dma0ErrorStatus: %016llx\n", data->dma0ErrorStatus);
799 pr_info(" dma0FirstErrorStatus: %016llx\n", data->dma0FirstErrorStatus);
800 pr_info(" dma0ErrorLog0: %016llx\n", data->dma0ErrorLog0);
801 pr_info(" dma0ErrorLog1: %016llx\n", data->dma0ErrorLog1);
802 pr_info(" dma1ErrorStatus: %016llx\n", data->dma1ErrorStatus);
803 pr_info(" dma1FirstErrorStatus: %016llx\n", data->dma1FirstErrorStatus);
804 pr_info(" dma1ErrorLog0: %016llx\n", data->dma1ErrorLog0);
805 pr_info(" dma1ErrorLog1: %016llx\n", data->dma1ErrorLog1);
806
807 for (i = 0; i < OPAL_PHB3_NUM_PEST_REGS; i++) {
808 if ((data->pestA[i] >> 63) == 0 &&
809 (data->pestB[i] >> 63) == 0)
810 continue;
811
812 pr_info(" PE[%3d] PESTA: %016llx\n", i, data->pestA[i]);
813 pr_info(" PESTB: %016llx\n", data->pestB[i]);
814 }
815}
816
713static void ioda_eeh_phb_diag(struct pci_controller *hose) 817static void ioda_eeh_phb_diag(struct pci_controller *hose)
714{ 818{
715 struct pnv_phb *phb = hose->private_data; 819 struct pnv_phb *phb = hose->private_data;
@@ -728,6 +832,9 @@ static void ioda_eeh_phb_diag(struct pci_controller *hose)
728 case OPAL_PHB_ERROR_DATA_TYPE_P7IOC: 832 case OPAL_PHB_ERROR_DATA_TYPE_P7IOC:
729 ioda_eeh_p7ioc_phb_diag(hose, common); 833 ioda_eeh_p7ioc_phb_diag(hose, common);
730 break; 834 break;
835 case OPAL_PHB_ERROR_DATA_TYPE_PHB3:
836 ioda_eeh_phb3_phb_diag(hose, common);
837 break;
731 default: 838 default:
732 pr_warning("%s: Unrecognized I/O chip %d\n", 839 pr_warning("%s: Unrecognized I/O chip %d\n",
733 __func__, common->ioType); 840 __func__, common->ioType);
diff --git a/arch/powerpc/platforms/powernv/eeh-powernv.c b/arch/powerpc/platforms/powernv/eeh-powernv.c
index 79663d26e6ea..73b981438cc5 100644
--- a/arch/powerpc/platforms/powernv/eeh-powernv.c
+++ b/arch/powerpc/platforms/powernv/eeh-powernv.c
@@ -144,11 +144,8 @@ static int powernv_eeh_dev_probe(struct pci_dev *dev, void *flag)
144 /* 144 /*
145 * Enable EEH explicitly so that we will do EEH check 145 * Enable EEH explicitly so that we will do EEH check
146 * while accessing I/O stuff 146 * while accessing I/O stuff
147 *
148 * FIXME: Enable that for PHB3 later
149 */ 147 */
150 if (phb->type == PNV_PHB_IODA1) 148 eeh_subsystem_enabled = 1;
151 eeh_subsystem_enabled = 1;
152 149
153 /* Save memory bars */ 150 /* Save memory bars */
154 eeh_save_bars(edev); 151 eeh_save_bars(edev);
diff --git a/arch/powerpc/platforms/powernv/opal-flash.c b/arch/powerpc/platforms/powernv/opal-flash.c
new file mode 100644
index 000000000000..6ffa6b1ec5b7
--- /dev/null
+++ b/arch/powerpc/platforms/powernv/opal-flash.c
@@ -0,0 +1,667 @@
1/*
2 * PowerNV OPAL Firmware Update Interface
3 *
4 * Copyright 2013 IBM Corp.
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#define DEBUG
13
14#include <linux/kernel.h>
15#include <linux/reboot.h>
16#include <linux/init.h>
17#include <linux/kobject.h>
18#include <linux/sysfs.h>
19#include <linux/slab.h>
20#include <linux/mm.h>
21#include <linux/vmalloc.h>
22#include <linux/pagemap.h>
23
24#include <asm/opal.h>
25
26/* FLASH status codes */
27#define FLASH_NO_OP -1099 /* No operation initiated by user */
28#define FLASH_NO_AUTH -9002 /* Not a service authority partition */
29
30/* Validate image status values */
31#define VALIDATE_IMG_READY -1001 /* Image ready for validation */
32#define VALIDATE_IMG_INCOMPLETE -1002 /* User copied < VALIDATE_BUF_SIZE */
33
34/* Manage image status values */
35#define MANAGE_ACTIVE_ERR -9001 /* Cannot overwrite active img */
36
37/* Flash image status values */
38#define FLASH_IMG_READY 0 /* Img ready for flash on reboot */
39#define FLASH_INVALID_IMG -1003 /* Flash image shorter than expected */
40#define FLASH_IMG_NULL_DATA -1004 /* Bad data in sg list entry */
41#define FLASH_IMG_BAD_LEN -1005 /* Bad length in sg list entry */
42
43/* Manage operation tokens */
44#define FLASH_REJECT_TMP_SIDE 0 /* Reject temporary fw image */
45#define FLASH_COMMIT_TMP_SIDE 1 /* Commit temporary fw image */
46
47/* Update tokens */
48#define FLASH_UPDATE_CANCEL 0 /* Cancel update request */
49#define FLASH_UPDATE_INIT 1 /* Initiate update */
50
51/* Validate image update result tokens */
52#define VALIDATE_TMP_UPDATE 0 /* T side will be updated */
53#define VALIDATE_FLASH_AUTH 1 /* Partition does not have authority */
54#define VALIDATE_INVALID_IMG 2 /* Candidate image is not valid */
55#define VALIDATE_CUR_UNKNOWN 3 /* Current fixpack level is unknown */
56/*
57 * Current T side will be committed to P side before being replace with new
58 * image, and the new image is downlevel from current image
59 */
60#define VALIDATE_TMP_COMMIT_DL 4
61/*
62 * Current T side will be committed to P side before being replaced with new
63 * image
64 */
65#define VALIDATE_TMP_COMMIT 5
66/*
67 * T side will be updated with a downlevel image
68 */
69#define VALIDATE_TMP_UPDATE_DL 6
70/*
71 * The candidate image's release date is later than the system's firmware
72 * service entitlement date - service warranty period has expired
73 */
74#define VALIDATE_OUT_OF_WRNTY 7
75
76/* Validate buffer size */
77#define VALIDATE_BUF_SIZE 4096
78
79/* XXX: Assume candidate image size is <= 256MB */
80#define MAX_IMAGE_SIZE 0x10000000
81
82/* Flash sg list version */
83#define SG_LIST_VERSION (1UL)
84
85/* Image status */
86enum {
87 IMAGE_INVALID,
88 IMAGE_LOADING,
89 IMAGE_READY,
90};
91
92/* Candidate image data */
93struct image_data_t {
94 int status;
95 void *data;
96 uint32_t size;
97};
98
99/* Candidate image header */
100struct image_header_t {
101 uint16_t magic;
102 uint16_t version;
103 uint32_t size;
104};
105
106/* Scatter/gather entry */
107struct opal_sg_entry {
108 void *data;
109 long length;
110};
111
112/* We calculate number of entries based on PAGE_SIZE */
113#define SG_ENTRIES_PER_NODE ((PAGE_SIZE - 16) / sizeof(struct opal_sg_entry))
114
115/*
116 * This struct is very similar but not identical to that
117 * needed by the opal flash update. All we need to do for
118 * opal is rewrite num_entries into a version/length and
119 * translate the pointers to absolute.
120 */
121struct opal_sg_list {
122 unsigned long num_entries;
123 struct opal_sg_list *next;
124 struct opal_sg_entry entry[SG_ENTRIES_PER_NODE];
125};
126
127struct validate_flash_t {
128 int status; /* Return status */
129 void *buf; /* Candiate image buffer */
130 uint32_t buf_size; /* Image size */
131 uint32_t result; /* Update results token */
132};
133
134struct manage_flash_t {
135 int status; /* Return status */
136};
137
138struct update_flash_t {
139 int status; /* Return status */
140};
141
142static struct image_header_t image_header;
143static struct image_data_t image_data;
144static struct validate_flash_t validate_flash_data;
145static struct manage_flash_t manage_flash_data;
146static struct update_flash_t update_flash_data;
147
148static DEFINE_MUTEX(image_data_mutex);
149
150/*
151 * Validate candidate image
152 */
153static inline void opal_flash_validate(void)
154{
155 struct validate_flash_t *args_buf = &validate_flash_data;
156
157 args_buf->status = opal_validate_flash(__pa(args_buf->buf),
158 &(args_buf->buf_size),
159 &(args_buf->result));
160}
161
162/*
163 * Validate output format:
164 * validate result token
165 * current image version details
166 * new image version details
167 */
168static ssize_t validate_show(struct kobject *kobj,
169 struct kobj_attribute *attr, char *buf)
170{
171 struct validate_flash_t *args_buf = &validate_flash_data;
172 int len;
173
174 /* Candidate image is not validated */
175 if (args_buf->status < VALIDATE_TMP_UPDATE) {
176 len = sprintf(buf, "%d\n", args_buf->status);
177 goto out;
178 }
179
180 /* Result token */
181 len = sprintf(buf, "%d\n", args_buf->result);
182
183 /* Current and candidate image version details */
184 if ((args_buf->result != VALIDATE_TMP_UPDATE) &&
185 (args_buf->result < VALIDATE_CUR_UNKNOWN))
186 goto out;
187
188 if (args_buf->buf_size > (VALIDATE_BUF_SIZE - len)) {
189 memcpy(buf + len, args_buf->buf, VALIDATE_BUF_SIZE - len);
190 len = VALIDATE_BUF_SIZE;
191 } else {
192 memcpy(buf + len, args_buf->buf, args_buf->buf_size);
193 len += args_buf->buf_size;
194 }
195out:
196 /* Set status to default */
197 args_buf->status = FLASH_NO_OP;
198 return len;
199}
200
201/*
202 * Validate candidate firmware image
203 *
204 * Note:
205 * We are only interested in first 4K bytes of the
206 * candidate image.
207 */
208static ssize_t validate_store(struct kobject *kobj,
209 struct kobj_attribute *attr,
210 const char *buf, size_t count)
211{
212 struct validate_flash_t *args_buf = &validate_flash_data;
213
214 if (buf[0] != '1')
215 return -EINVAL;
216
217 mutex_lock(&image_data_mutex);
218
219 if (image_data.status != IMAGE_READY ||
220 image_data.size < VALIDATE_BUF_SIZE) {
221 args_buf->result = VALIDATE_INVALID_IMG;
222 args_buf->status = VALIDATE_IMG_INCOMPLETE;
223 goto out;
224 }
225
226 /* Copy first 4k bytes of candidate image */
227 memcpy(args_buf->buf, image_data.data, VALIDATE_BUF_SIZE);
228
229 args_buf->status = VALIDATE_IMG_READY;
230 args_buf->buf_size = VALIDATE_BUF_SIZE;
231
232 /* Validate candidate image */
233 opal_flash_validate();
234
235out:
236 mutex_unlock(&image_data_mutex);
237 return count;
238}
239
240/*
241 * Manage flash routine
242 */
243static inline void opal_flash_manage(uint8_t op)
244{
245 struct manage_flash_t *const args_buf = &manage_flash_data;
246
247 args_buf->status = opal_manage_flash(op);
248}
249
250/*
251 * Show manage flash status
252 */
253static ssize_t manage_show(struct kobject *kobj,
254 struct kobj_attribute *attr, char *buf)
255{
256 struct manage_flash_t *const args_buf = &manage_flash_data;
257 int rc;
258
259 rc = sprintf(buf, "%d\n", args_buf->status);
260 /* Set status to default*/
261 args_buf->status = FLASH_NO_OP;
262 return rc;
263}
264
265/*
266 * Manage operations:
267 * 0 - Reject
268 * 1 - Commit
269 */
270static ssize_t manage_store(struct kobject *kobj,
271 struct kobj_attribute *attr,
272 const char *buf, size_t count)
273{
274 uint8_t op;
275 switch (buf[0]) {
276 case '0':
277 op = FLASH_REJECT_TMP_SIDE;
278 break;
279 case '1':
280 op = FLASH_COMMIT_TMP_SIDE;
281 break;
282 default:
283 return -EINVAL;
284 }
285
286 /* commit/reject temporary image */
287 opal_flash_manage(op);
288 return count;
289}
290
291/*
292 * Free sg list
293 */
294static void free_sg_list(struct opal_sg_list *list)
295{
296 struct opal_sg_list *sg1;
297 while (list) {
298 sg1 = list->next;
299 kfree(list);
300 list = sg1;
301 }
302 list = NULL;
303}
304
305/*
306 * Build candidate image scatter gather list
307 *
308 * list format:
309 * -----------------------------------
310 * | VER (8) | Entry length in bytes |
311 * -----------------------------------
312 * | Pointer to next entry |
313 * -----------------------------------
314 * | Address of memory area 1 |
315 * -----------------------------------
316 * | Length of memory area 1 |
317 * -----------------------------------
318 * | ......... |
319 * -----------------------------------
320 * | ......... |
321 * -----------------------------------
322 * | Address of memory area N |
323 * -----------------------------------
324 * | Length of memory area N |
325 * -----------------------------------
326 */
327static struct opal_sg_list *image_data_to_sglist(void)
328{
329 struct opal_sg_list *sg1, *list = NULL;
330 void *addr;
331 int size;
332
333 addr = image_data.data;
334 size = image_data.size;
335
336 sg1 = kzalloc((sizeof(struct opal_sg_list)), GFP_KERNEL);
337 if (!sg1)
338 return NULL;
339
340 list = sg1;
341 sg1->num_entries = 0;
342 while (size > 0) {
343 /* Translate virtual address to physical address */
344 sg1->entry[sg1->num_entries].data =
345 (void *)(vmalloc_to_pfn(addr) << PAGE_SHIFT);
346
347 if (size > PAGE_SIZE)
348 sg1->entry[sg1->num_entries].length = PAGE_SIZE;
349 else
350 sg1->entry[sg1->num_entries].length = size;
351
352 sg1->num_entries++;
353 if (sg1->num_entries >= SG_ENTRIES_PER_NODE) {
354 sg1->next = kzalloc((sizeof(struct opal_sg_list)),
355 GFP_KERNEL);
356 if (!sg1->next) {
357 pr_err("%s : Failed to allocate memory\n",
358 __func__);
359 goto nomem;
360 }
361
362 sg1 = sg1->next;
363 sg1->num_entries = 0;
364 }
365 addr += PAGE_SIZE;
366 size -= PAGE_SIZE;
367 }
368 return list;
369nomem:
370 free_sg_list(list);
371 return NULL;
372}
373
374/*
375 * OPAL update flash
376 */
377static int opal_flash_update(int op)
378{
379 struct opal_sg_list *sg, *list, *next;
380 unsigned long addr;
381 int64_t rc = OPAL_PARAMETER;
382
383 if (op == FLASH_UPDATE_CANCEL) {
384 pr_alert("FLASH: Image update cancelled\n");
385 addr = '\0';
386 goto flash;
387 }
388
389 list = image_data_to_sglist();
390 if (!list)
391 goto invalid_img;
392
393 /* First entry address */
394 addr = __pa(list);
395
396 /* Translate sg list address to absolute */
397 for (sg = list; sg; sg = next) {
398 next = sg->next;
399 /* Don't translate NULL pointer for last entry */
400 if (sg->next)
401 sg->next = (struct opal_sg_list *)__pa(sg->next);
402 else
403 sg->next = NULL;
404
405 /* Make num_entries into the version/length field */
406 sg->num_entries = (SG_LIST_VERSION << 56) |
407 (sg->num_entries * sizeof(struct opal_sg_entry) + 16);
408 }
409
410 pr_alert("FLASH: Image is %u bytes\n", image_data.size);
411 pr_alert("FLASH: Image update requested\n");
412 pr_alert("FLASH: Image will be updated during system reboot\n");
413 pr_alert("FLASH: This will take several minutes. Do not power off!\n");
414
415flash:
416 rc = opal_update_flash(addr);
417
418invalid_img:
419 return rc;
420}
421
422/*
423 * Show candidate image status
424 */
425static ssize_t update_show(struct kobject *kobj,
426 struct kobj_attribute *attr, char *buf)
427{
428 struct update_flash_t *const args_buf = &update_flash_data;
429 return sprintf(buf, "%d\n", args_buf->status);
430}
431
432/*
433 * Set update image flag
434 * 1 - Flash new image
435 * 0 - Cancel flash request
436 */
437static ssize_t update_store(struct kobject *kobj,
438 struct kobj_attribute *attr,
439 const char *buf, size_t count)
440{
441 struct update_flash_t *const args_buf = &update_flash_data;
442 int rc = count;
443
444 mutex_lock(&image_data_mutex);
445
446 switch (buf[0]) {
447 case '0':
448 if (args_buf->status == FLASH_IMG_READY)
449 opal_flash_update(FLASH_UPDATE_CANCEL);
450 args_buf->status = FLASH_NO_OP;
451 break;
452 case '1':
453 /* Image is loaded? */
454 if (image_data.status == IMAGE_READY)
455 args_buf->status =
456 opal_flash_update(FLASH_UPDATE_INIT);
457 else
458 args_buf->status = FLASH_INVALID_IMG;
459 break;
460 default:
461 rc = -EINVAL;
462 }
463
464 mutex_unlock(&image_data_mutex);
465 return rc;
466}
467
468/*
469 * Free image buffer
470 */
471static void free_image_buf(void)
472{
473 void *addr;
474 int size;
475
476 addr = image_data.data;
477 size = PAGE_ALIGN(image_data.size);
478 while (size > 0) {
479 ClearPageReserved(vmalloc_to_page(addr));
480 addr += PAGE_SIZE;
481 size -= PAGE_SIZE;
482 }
483 vfree(image_data.data);
484 image_data.data = NULL;
485 image_data.status = IMAGE_INVALID;
486}
487
488/*
489 * Allocate image buffer.
490 */
491static int alloc_image_buf(char *buffer, size_t count)
492{
493 void *addr;
494 int size;
495
496 if (count < sizeof(struct image_header_t)) {
497 pr_warn("FLASH: Invalid candidate image\n");
498 return -EINVAL;
499 }
500
501 memcpy(&image_header, (void *)buffer, sizeof(struct image_header_t));
502 image_data.size = be32_to_cpu(image_header.size);
503 pr_debug("FLASH: Candiate image size = %u\n", image_data.size);
504
505 if (image_data.size > MAX_IMAGE_SIZE) {
506 pr_warn("FLASH: Too large image\n");
507 return -EINVAL;
508 }
509 if (image_data.size < VALIDATE_BUF_SIZE) {
510 pr_warn("FLASH: Image is shorter than expected\n");
511 return -EINVAL;
512 }
513
514 image_data.data = vzalloc(PAGE_ALIGN(image_data.size));
515 if (!image_data.data) {
516 pr_err("%s : Failed to allocate memory\n", __func__);
517 return -ENOMEM;
518 }
519
520 /* Pin memory */
521 addr = image_data.data;
522 size = PAGE_ALIGN(image_data.size);
523 while (size > 0) {
524 SetPageReserved(vmalloc_to_page(addr));
525 addr += PAGE_SIZE;
526 size -= PAGE_SIZE;
527 }
528
529 image_data.status = IMAGE_LOADING;
530 return 0;
531}
532
533/*
534 * Copy candidate image
535 *
536 * Parse candidate image header to get total image size
537 * and pre-allocate required memory.
538 */
539static ssize_t image_data_write(struct file *filp, struct kobject *kobj,
540 struct bin_attribute *bin_attr,
541 char *buffer, loff_t pos, size_t count)
542{
543 int rc;
544
545 mutex_lock(&image_data_mutex);
546
547 /* New image ? */
548 if (pos == 0) {
549 /* Free memory, if already allocated */
550 if (image_data.data)
551 free_image_buf();
552
553 /* Cancel outstanding image update request */
554 if (update_flash_data.status == FLASH_IMG_READY)
555 opal_flash_update(FLASH_UPDATE_CANCEL);
556
557 /* Allocate memory */
558 rc = alloc_image_buf(buffer, count);
559 if (rc)
560 goto out;
561 }
562
563 if (image_data.status != IMAGE_LOADING) {
564 rc = -ENOMEM;
565 goto out;
566 }
567
568 if ((pos + count) > image_data.size) {
569 rc = -EINVAL;
570 goto out;
571 }
572
573 memcpy(image_data.data + pos, (void *)buffer, count);
574 rc = count;
575
576 /* Set image status */
577 if ((pos + count) == image_data.size) {
578 pr_debug("FLASH: Candidate image loaded....\n");
579 image_data.status = IMAGE_READY;
580 }
581
582out:
583 mutex_unlock(&image_data_mutex);
584 return rc;
585}
586
587/*
588 * sysfs interface :
589 * OPAL uses below sysfs files for code update.
590 * We create these files under /sys/firmware/opal.
591 *
592 * image : Interface to load candidate firmware image
593 * validate_flash : Validate firmware image
594 * manage_flash : Commit/Reject firmware image
595 * update_flash : Flash new firmware image
596 *
597 */
598static struct bin_attribute image_data_attr = {
599 .attr = {.name = "image", .mode = 0200},
600 .size = MAX_IMAGE_SIZE, /* Limit image size */
601 .write = image_data_write,
602};
603
604static struct kobj_attribute validate_attribute =
605 __ATTR(validate_flash, 0600, validate_show, validate_store);
606
607static struct kobj_attribute manage_attribute =
608 __ATTR(manage_flash, 0600, manage_show, manage_store);
609
610static struct kobj_attribute update_attribute =
611 __ATTR(update_flash, 0600, update_show, update_store);
612
613static struct attribute *image_op_attrs[] = {
614 &validate_attribute.attr,
615 &manage_attribute.attr,
616 &update_attribute.attr,
617 NULL /* need to NULL terminate the list of attributes */
618};
619
620static struct attribute_group image_op_attr_group = {
621 .attrs = image_op_attrs,
622};
623
624void __init opal_flash_init(void)
625{
626 int ret;
627
628 /* Allocate validate image buffer */
629 validate_flash_data.buf = kzalloc(VALIDATE_BUF_SIZE, GFP_KERNEL);
630 if (!validate_flash_data.buf) {
631 pr_err("%s : Failed to allocate memory\n", __func__);
632 return;
633 }
634
635 /* Make sure /sys/firmware/opal directory is created */
636 if (!opal_kobj) {
637 pr_warn("FLASH: opal kobject is not available\n");
638 goto nokobj;
639 }
640
641 /* Create the sysfs files */
642 ret = sysfs_create_group(opal_kobj, &image_op_attr_group);
643 if (ret) {
644 pr_warn("FLASH: Failed to create sysfs files\n");
645 goto nokobj;
646 }
647
648 ret = sysfs_create_bin_file(opal_kobj, &image_data_attr);
649 if (ret) {
650 pr_warn("FLASH: Failed to create sysfs files\n");
651 goto nosysfs_file;
652 }
653
654 /* Set default status */
655 validate_flash_data.status = FLASH_NO_OP;
656 manage_flash_data.status = FLASH_NO_OP;
657 update_flash_data.status = FLASH_NO_OP;
658 image_data.status = IMAGE_INVALID;
659 return;
660
661nosysfs_file:
662 sysfs_remove_group(opal_kobj, &image_op_attr_group);
663
664nokobj:
665 kfree(validate_flash_data.buf);
666 return;
667}
diff --git a/arch/powerpc/platforms/powernv/opal-nvram.c b/arch/powerpc/platforms/powernv/opal-nvram.c
index 3f83e1ae26ac..acd9f7e96678 100644
--- a/arch/powerpc/platforms/powernv/opal-nvram.c
+++ b/arch/powerpc/platforms/powernv/opal-nvram.c
@@ -65,7 +65,7 @@ static ssize_t opal_nvram_write(char *buf, size_t count, loff_t *index)
65void __init opal_nvram_init(void) 65void __init opal_nvram_init(void)
66{ 66{
67 struct device_node *np; 67 struct device_node *np;
68 const u32 *nbytes_p; 68 const __be32 *nbytes_p;
69 69
70 np = of_find_compatible_node(NULL, NULL, "ibm,opal-nvram"); 70 np = of_find_compatible_node(NULL, NULL, "ibm,opal-nvram");
71 if (np == NULL) 71 if (np == NULL)
@@ -76,7 +76,7 @@ void __init opal_nvram_init(void)
76 of_node_put(np); 76 of_node_put(np);
77 return; 77 return;
78 } 78 }
79 nvram_size = *nbytes_p; 79 nvram_size = be32_to_cpup(nbytes_p);
80 80
81 printk(KERN_INFO "OPAL nvram setup, %u bytes\n", nvram_size); 81 printk(KERN_INFO "OPAL nvram setup, %u bytes\n", nvram_size);
82 of_node_put(np); 82 of_node_put(np);
diff --git a/arch/powerpc/platforms/powernv/opal-rtc.c b/arch/powerpc/platforms/powernv/opal-rtc.c
index 2aa7641aac9b..7d07c7e80ec0 100644
--- a/arch/powerpc/platforms/powernv/opal-rtc.c
+++ b/arch/powerpc/platforms/powernv/opal-rtc.c
@@ -37,10 +37,12 @@ unsigned long __init opal_get_boot_time(void)
37 struct rtc_time tm; 37 struct rtc_time tm;
38 u32 y_m_d; 38 u32 y_m_d;
39 u64 h_m_s_ms; 39 u64 h_m_s_ms;
40 __be32 __y_m_d;
41 __be64 __h_m_s_ms;
40 long rc = OPAL_BUSY; 42 long rc = OPAL_BUSY;
41 43
42 while (rc == OPAL_BUSY || rc == OPAL_BUSY_EVENT) { 44 while (rc == OPAL_BUSY || rc == OPAL_BUSY_EVENT) {
43 rc = opal_rtc_read(&y_m_d, &h_m_s_ms); 45 rc = opal_rtc_read(&__y_m_d, &__h_m_s_ms);
44 if (rc == OPAL_BUSY_EVENT) 46 if (rc == OPAL_BUSY_EVENT)
45 opal_poll_events(NULL); 47 opal_poll_events(NULL);
46 else 48 else
@@ -48,6 +50,8 @@ unsigned long __init opal_get_boot_time(void)
48 } 50 }
49 if (rc != OPAL_SUCCESS) 51 if (rc != OPAL_SUCCESS)
50 return 0; 52 return 0;
53 y_m_d = be32_to_cpu(__y_m_d);
54 h_m_s_ms = be64_to_cpu(__h_m_s_ms);
51 opal_to_tm(y_m_d, h_m_s_ms, &tm); 55 opal_to_tm(y_m_d, h_m_s_ms, &tm);
52 return mktime(tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, 56 return mktime(tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
53 tm.tm_hour, tm.tm_min, tm.tm_sec); 57 tm.tm_hour, tm.tm_min, tm.tm_sec);
@@ -58,9 +62,11 @@ void opal_get_rtc_time(struct rtc_time *tm)
58 long rc = OPAL_BUSY; 62 long rc = OPAL_BUSY;
59 u32 y_m_d; 63 u32 y_m_d;
60 u64 h_m_s_ms; 64 u64 h_m_s_ms;
65 __be32 __y_m_d;
66 __be64 __h_m_s_ms;
61 67
62 while (rc == OPAL_BUSY || rc == OPAL_BUSY_EVENT) { 68 while (rc == OPAL_BUSY || rc == OPAL_BUSY_EVENT) {
63 rc = opal_rtc_read(&y_m_d, &h_m_s_ms); 69 rc = opal_rtc_read(&__y_m_d, &__h_m_s_ms);
64 if (rc == OPAL_BUSY_EVENT) 70 if (rc == OPAL_BUSY_EVENT)
65 opal_poll_events(NULL); 71 opal_poll_events(NULL);
66 else 72 else
@@ -68,6 +74,8 @@ void opal_get_rtc_time(struct rtc_time *tm)
68 } 74 }
69 if (rc != OPAL_SUCCESS) 75 if (rc != OPAL_SUCCESS)
70 return; 76 return;
77 y_m_d = be32_to_cpu(__y_m_d);
78 h_m_s_ms = be64_to_cpu(__h_m_s_ms);
71 opal_to_tm(y_m_d, h_m_s_ms, tm); 79 opal_to_tm(y_m_d, h_m_s_ms, tm);
72} 80}
73 81
diff --git a/arch/powerpc/platforms/powernv/opal-wrappers.S b/arch/powerpc/platforms/powernv/opal-wrappers.S
index 8f3844535fbb..e7806504e976 100644
--- a/arch/powerpc/platforms/powernv/opal-wrappers.S
+++ b/arch/powerpc/platforms/powernv/opal-wrappers.S
@@ -24,7 +24,7 @@
24 mflr r0; \ 24 mflr r0; \
25 mfcr r12; \ 25 mfcr r12; \
26 std r0,16(r1); \ 26 std r0,16(r1); \
27 std r12,8(r1); \ 27 stw r12,8(r1); \
28 std r1,PACAR1(r13); \ 28 std r1,PACAR1(r13); \
29 li r0,0; \ 29 li r0,0; \
30 mfmsr r12; \ 30 mfmsr r12; \
@@ -34,7 +34,7 @@
34 mtmsrd r12,1; \ 34 mtmsrd r12,1; \
35 LOAD_REG_ADDR(r0,.opal_return); \ 35 LOAD_REG_ADDR(r0,.opal_return); \
36 mtlr r0; \ 36 mtlr r0; \
37 li r0,MSR_DR|MSR_IR; \ 37 li r0,MSR_DR|MSR_IR|MSR_LE;\
38 andc r12,r12,r0; \ 38 andc r12,r12,r0; \
39 li r0,token; \ 39 li r0,token; \
40 mtspr SPRN_HSRR1,r12; \ 40 mtspr SPRN_HSRR1,r12; \
@@ -45,8 +45,15 @@
45 hrfid 45 hrfid
46 46
47_STATIC(opal_return) 47_STATIC(opal_return)
48 /*
49 * Fixup endian on OPAL return... we should be able to simplify
50 * this by instead converting the below trampoline to a set of
51 * bytes (always BE) since MSR:LE will end up fixed up as a side
52 * effect of the rfid.
53 */
54 FIXUP_ENDIAN
48 ld r2,PACATOC(r13); 55 ld r2,PACATOC(r13);
49 ld r4,8(r1); 56 lwz r4,8(r1);
50 ld r5,16(r1); 57 ld r5,16(r1);
51 ld r6,PACASAVEDMSR(r13); 58 ld r6,PACASAVEDMSR(r13);
52 mtspr SPRN_SRR0,r5; 59 mtspr SPRN_SRR0,r5;
@@ -116,3 +123,6 @@ OPAL_CALL(opal_xscom_write, OPAL_XSCOM_WRITE);
116OPAL_CALL(opal_lpc_read, OPAL_LPC_READ); 123OPAL_CALL(opal_lpc_read, OPAL_LPC_READ);
117OPAL_CALL(opal_lpc_write, OPAL_LPC_WRITE); 124OPAL_CALL(opal_lpc_write, OPAL_LPC_WRITE);
118OPAL_CALL(opal_return_cpu, OPAL_RETURN_CPU); 125OPAL_CALL(opal_return_cpu, OPAL_RETURN_CPU);
126OPAL_CALL(opal_validate_flash, OPAL_FLASH_VALIDATE);
127OPAL_CALL(opal_manage_flash, OPAL_FLASH_MANAGE);
128OPAL_CALL(opal_update_flash, OPAL_FLASH_UPDATE);
diff --git a/arch/powerpc/platforms/powernv/opal-xscom.c b/arch/powerpc/platforms/powernv/opal-xscom.c
new file mode 100644
index 000000000000..4d99a8fd55ac
--- /dev/null
+++ b/arch/powerpc/platforms/powernv/opal-xscom.c
@@ -0,0 +1,128 @@
1/*
2 * PowerNV LPC bus handling.
3 *
4 * Copyright 2013 IBM Corp.
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 <linux/kernel.h>
13#include <linux/of.h>
14#include <linux/bug.h>
15#include <linux/gfp.h>
16#include <linux/slab.h>
17
18#include <asm/machdep.h>
19#include <asm/firmware.h>
20#include <asm/opal.h>
21#include <asm/scom.h>
22
23/*
24 * We could probably fit that inside the scom_map_t
25 * which is a void* after all but it's really too ugly
26 * so let's kmalloc it for now
27 */
28struct opal_scom_map {
29 uint32_t chip;
30 uint64_t addr;
31};
32
33static scom_map_t opal_scom_map(struct device_node *dev, u64 reg, u64 count)
34{
35 struct opal_scom_map *m;
36 const __be32 *gcid;
37
38 if (!of_get_property(dev, "scom-controller", NULL)) {
39 pr_err("%s: device %s is not a SCOM controller\n",
40 __func__, dev->full_name);
41 return SCOM_MAP_INVALID;
42 }
43 gcid = of_get_property(dev, "ibm,chip-id", NULL);
44 if (!gcid) {
45 pr_err("%s: device %s has no ibm,chip-id\n",
46 __func__, dev->full_name);
47 return SCOM_MAP_INVALID;
48 }
49 m = kmalloc(sizeof(struct opal_scom_map), GFP_KERNEL);
50 if (!m)
51 return NULL;
52 m->chip = be32_to_cpup(gcid);
53 m->addr = reg;
54
55 return (scom_map_t)m;
56}
57
58static void opal_scom_unmap(scom_map_t map)
59{
60 kfree(map);
61}
62
63static int opal_xscom_err_xlate(int64_t rc)
64{
65 switch(rc) {
66 case 0:
67 return 0;
68 /* Add more translations if necessary */
69 default:
70 return -EIO;
71 }
72}
73
74static u64 opal_scom_unmangle(u64 reg)
75{
76 /*
77 * XSCOM indirect addresses have the top bit set. Additionally
78 * the reset of the top 3 nibbles is always 0.
79 *
80 * Because the debugfs interface uses signed offsets and shifts
81 * the address left by 3, we basically cannot use the top 4 bits
82 * of the 64-bit address, and thus cannot use the indirect bit.
83 *
84 * To deal with that, we support the indirect bit being in bit
85 * 4 (IBM notation) instead of bit 0 in this API, we do the
86 * conversion here. To leave room for further xscom address
87 * expansion, we only clear out the top byte
88 *
89 */
90 if (reg & (1ull << 59))
91 reg = (reg & ~(0xffull << 56)) | (1ull << 63);
92 return reg;
93}
94
95static int opal_scom_read(scom_map_t map, u64 reg, u64 *value)
96{
97 struct opal_scom_map *m = map;
98 int64_t rc;
99
100 reg = opal_scom_unmangle(reg);
101 rc = opal_xscom_read(m->chip, m->addr + reg, (uint64_t *)__pa(value));
102 return opal_xscom_err_xlate(rc);
103}
104
105static int opal_scom_write(scom_map_t map, u64 reg, u64 value)
106{
107 struct opal_scom_map *m = map;
108 int64_t rc;
109
110 reg = opal_scom_unmangle(reg);
111 rc = opal_xscom_write(m->chip, m->addr + reg, value);
112 return opal_xscom_err_xlate(rc);
113}
114
115static const struct scom_controller opal_scom_controller = {
116 .map = opal_scom_map,
117 .unmap = opal_scom_unmap,
118 .read = opal_scom_read,
119 .write = opal_scom_write
120};
121
122static int opal_xscom_init(void)
123{
124 if (firmware_has_feature(FW_FEATURE_OPALv3))
125 scom_init(&opal_scom_controller);
126 return 0;
127}
128arch_initcall(opal_xscom_init);
diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c
index 2911abe550f1..b56c243aaee9 100644
--- a/arch/powerpc/platforms/powernv/opal.c
+++ b/arch/powerpc/platforms/powernv/opal.c
@@ -17,11 +17,15 @@
17#include <linux/interrupt.h> 17#include <linux/interrupt.h>
18#include <linux/notifier.h> 18#include <linux/notifier.h>
19#include <linux/slab.h> 19#include <linux/slab.h>
20#include <linux/kobject.h>
20#include <asm/opal.h> 21#include <asm/opal.h>
21#include <asm/firmware.h> 22#include <asm/firmware.h>
22 23
23#include "powernv.h" 24#include "powernv.h"
24 25
26/* /sys/firmware/opal */
27struct kobject *opal_kobj;
28
25struct opal { 29struct opal {
26 u64 base; 30 u64 base;
27 u64 entry; 31 u64 entry;
@@ -77,6 +81,7 @@ int __init early_init_dt_scan_opal(unsigned long node,
77 81
78static int __init opal_register_exception_handlers(void) 82static int __init opal_register_exception_handlers(void)
79{ 83{
84#ifdef __BIG_ENDIAN__
80 u64 glue; 85 u64 glue;
81 86
82 if (!(powerpc_firmware_features & FW_FEATURE_OPAL)) 87 if (!(powerpc_firmware_features & FW_FEATURE_OPAL))
@@ -94,6 +99,7 @@ static int __init opal_register_exception_handlers(void)
94 0, glue); 99 0, glue);
95 glue += 128; 100 glue += 128;
96 opal_register_exception_handler(OPAL_SOFTPATCH_HANDLER, 0, glue); 101 opal_register_exception_handler(OPAL_SOFTPATCH_HANDLER, 0, glue);
102#endif
97 103
98 return 0; 104 return 0;
99} 105}
@@ -164,27 +170,28 @@ void opal_notifier_disable(void)
164 170
165int opal_get_chars(uint32_t vtermno, char *buf, int count) 171int opal_get_chars(uint32_t vtermno, char *buf, int count)
166{ 172{
167 s64 len, rc; 173 s64 rc;
168 u64 evt; 174 __be64 evt, len;
169 175
170 if (!opal.entry) 176 if (!opal.entry)
171 return -ENODEV; 177 return -ENODEV;
172 opal_poll_events(&evt); 178 opal_poll_events(&evt);
173 if ((evt & OPAL_EVENT_CONSOLE_INPUT) == 0) 179 if ((be64_to_cpu(evt) & OPAL_EVENT_CONSOLE_INPUT) == 0)
174 return 0; 180 return 0;
175 len = count; 181 len = cpu_to_be64(count);
176 rc = opal_console_read(vtermno, &len, buf); 182 rc = opal_console_read(vtermno, &len, buf);
177 if (rc == OPAL_SUCCESS) 183 if (rc == OPAL_SUCCESS)
178 return len; 184 return be64_to_cpu(len);
179 return 0; 185 return 0;
180} 186}
181 187
182int opal_put_chars(uint32_t vtermno, const char *data, int total_len) 188int opal_put_chars(uint32_t vtermno, const char *data, int total_len)
183{ 189{
184 int written = 0; 190 int written = 0;
191 __be64 olen;
185 s64 len, rc; 192 s64 len, rc;
186 unsigned long flags; 193 unsigned long flags;
187 u64 evt; 194 __be64 evt;
188 195
189 if (!opal.entry) 196 if (!opal.entry)
190 return -ENODEV; 197 return -ENODEV;
@@ -199,13 +206,14 @@ int opal_put_chars(uint32_t vtermno, const char *data, int total_len)
199 */ 206 */
200 spin_lock_irqsave(&opal_write_lock, flags); 207 spin_lock_irqsave(&opal_write_lock, flags);
201 if (firmware_has_feature(FW_FEATURE_OPALv2)) { 208 if (firmware_has_feature(FW_FEATURE_OPALv2)) {
202 rc = opal_console_write_buffer_space(vtermno, &len); 209 rc = opal_console_write_buffer_space(vtermno, &olen);
210 len = be64_to_cpu(olen);
203 if (rc || len < total_len) { 211 if (rc || len < total_len) {
204 spin_unlock_irqrestore(&opal_write_lock, flags); 212 spin_unlock_irqrestore(&opal_write_lock, flags);
205 /* Closed -> drop characters */ 213 /* Closed -> drop characters */
206 if (rc) 214 if (rc)
207 return total_len; 215 return total_len;
208 opal_poll_events(&evt); 216 opal_poll_events(NULL);
209 return -EAGAIN; 217 return -EAGAIN;
210 } 218 }
211 } 219 }
@@ -216,8 +224,9 @@ int opal_put_chars(uint32_t vtermno, const char *data, int total_len)
216 rc = OPAL_BUSY; 224 rc = OPAL_BUSY;
217 while(total_len > 0 && (rc == OPAL_BUSY || 225 while(total_len > 0 && (rc == OPAL_BUSY ||
218 rc == OPAL_BUSY_EVENT || rc == OPAL_SUCCESS)) { 226 rc == OPAL_BUSY_EVENT || rc == OPAL_SUCCESS)) {
219 len = total_len; 227 olen = cpu_to_be64(total_len);
220 rc = opal_console_write(vtermno, &len, data); 228 rc = opal_console_write(vtermno, &olen, data);
229 len = be64_to_cpu(olen);
221 230
222 /* Closed or other error drop */ 231 /* Closed or other error drop */
223 if (rc != OPAL_SUCCESS && rc != OPAL_BUSY && 232 if (rc != OPAL_SUCCESS && rc != OPAL_BUSY &&
@@ -237,7 +246,8 @@ int opal_put_chars(uint32_t vtermno, const char *data, int total_len)
237 */ 246 */
238 do 247 do
239 opal_poll_events(&evt); 248 opal_poll_events(&evt);
240 while(rc == OPAL_SUCCESS && (evt & OPAL_EVENT_CONSOLE_OUTPUT)); 249 while(rc == OPAL_SUCCESS &&
250 (be64_to_cpu(evt) & OPAL_EVENT_CONSOLE_OUTPUT));
241 } 251 }
242 spin_unlock_irqrestore(&opal_write_lock, flags); 252 spin_unlock_irqrestore(&opal_write_lock, flags);
243 return written; 253 return written;
@@ -360,7 +370,7 @@ int opal_machine_check(struct pt_regs *regs)
360 370
361static irqreturn_t opal_interrupt(int irq, void *data) 371static irqreturn_t opal_interrupt(int irq, void *data)
362{ 372{
363 uint64_t events; 373 __be64 events;
364 374
365 opal_handle_interrupt(virq_to_hw(irq), &events); 375 opal_handle_interrupt(virq_to_hw(irq), &events);
366 376
@@ -369,10 +379,21 @@ static irqreturn_t opal_interrupt(int irq, void *data)
369 return IRQ_HANDLED; 379 return IRQ_HANDLED;
370} 380}
371 381
382static int opal_sysfs_init(void)
383{
384 opal_kobj = kobject_create_and_add("opal", firmware_kobj);
385 if (!opal_kobj) {
386 pr_warn("kobject_create_and_add opal failed\n");
387 return -ENOMEM;
388 }
389
390 return 0;
391}
392
372static int __init opal_init(void) 393static int __init opal_init(void)
373{ 394{
374 struct device_node *np, *consoles; 395 struct device_node *np, *consoles;
375 const u32 *irqs; 396 const __be32 *irqs;
376 int rc, i, irqlen; 397 int rc, i, irqlen;
377 398
378 opal_node = of_find_node_by_path("/ibm,opal"); 399 opal_node = of_find_node_by_path("/ibm,opal");
@@ -414,6 +435,14 @@ static int __init opal_init(void)
414 " (0x%x)\n", rc, irq, hwirq); 435 " (0x%x)\n", rc, irq, hwirq);
415 opal_irqs[i] = irq; 436 opal_irqs[i] = irq;
416 } 437 }
438
439 /* Create "opal" kobject under /sys/firmware */
440 rc = opal_sysfs_init();
441 if (rc == 0) {
442 /* Setup code update interface */
443 opal_flash_init();
444 }
445
417 return 0; 446 return 0;
418} 447}
419subsys_initcall(opal_init); 448subsys_initcall(opal_init);
diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
index 74a5a5773b1f..084cdfa40682 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -70,6 +70,16 @@ define_pe_printk_level(pe_err, KERN_ERR);
70define_pe_printk_level(pe_warn, KERN_WARNING); 70define_pe_printk_level(pe_warn, KERN_WARNING);
71define_pe_printk_level(pe_info, KERN_INFO); 71define_pe_printk_level(pe_info, KERN_INFO);
72 72
73/*
74 * stdcix is only supposed to be used in hypervisor real mode as per
75 * the architecture spec
76 */
77static inline void __raw_rm_writeq(u64 val, volatile void __iomem *paddr)
78{
79 __asm__ __volatile__("stdcix %0,0,%1"
80 : : "r" (val), "r" (paddr) : "memory");
81}
82
73static int pnv_ioda_alloc_pe(struct pnv_phb *phb) 83static int pnv_ioda_alloc_pe(struct pnv_phb *phb)
74{ 84{
75 unsigned long pe; 85 unsigned long pe;
@@ -153,13 +163,23 @@ static int pnv_ioda_configure_pe(struct pnv_phb *phb, struct pnv_ioda_pe *pe)
153 rid_end = pe->rid + 1; 163 rid_end = pe->rid + 1;
154 } 164 }
155 165
156 /* Associate PE in PELT */ 166 /*
167 * Associate PE in PELT. We need add the PE into the
168 * corresponding PELT-V as well. Otherwise, the error
169 * originated from the PE might contribute to other
170 * PEs.
171 */
157 rc = opal_pci_set_pe(phb->opal_id, pe->pe_number, pe->rid, 172 rc = opal_pci_set_pe(phb->opal_id, pe->pe_number, pe->rid,
158 bcomp, dcomp, fcomp, OPAL_MAP_PE); 173 bcomp, dcomp, fcomp, OPAL_MAP_PE);
159 if (rc) { 174 if (rc) {
160 pe_err(pe, "OPAL error %ld trying to setup PELT table\n", rc); 175 pe_err(pe, "OPAL error %ld trying to setup PELT table\n", rc);
161 return -ENXIO; 176 return -ENXIO;
162 } 177 }
178
179 rc = opal_pci_set_peltv(phb->opal_id, pe->pe_number,
180 pe->pe_number, OPAL_ADD_PE_TO_DOMAIN);
181 if (rc)
182 pe_warn(pe, "OPAL error %d adding self to PELTV\n", rc);
163 opal_pci_eeh_freeze_clear(phb->opal_id, pe->pe_number, 183 opal_pci_eeh_freeze_clear(phb->opal_id, pe->pe_number,
164 OPAL_EEH_ACTION_CLEAR_FREEZE_ALL); 184 OPAL_EEH_ACTION_CLEAR_FREEZE_ALL);
165 185
@@ -454,10 +474,13 @@ static void pnv_ioda_setup_bus_dma(struct pnv_ioda_pe *pe, struct pci_bus *bus)
454 } 474 }
455} 475}
456 476
457static void pnv_pci_ioda1_tce_invalidate(struct iommu_table *tbl, 477static void pnv_pci_ioda1_tce_invalidate(struct pnv_ioda_pe *pe,
458 u64 *startp, u64 *endp) 478 struct iommu_table *tbl,
479 __be64 *startp, __be64 *endp, bool rm)
459{ 480{
460 u64 __iomem *invalidate = (u64 __iomem *)tbl->it_index; 481 __be64 __iomem *invalidate = rm ?
482 (__be64 __iomem *)pe->tce_inval_reg_phys :
483 (__be64 __iomem *)tbl->it_index;
461 unsigned long start, end, inc; 484 unsigned long start, end, inc;
462 485
463 start = __pa(startp); 486 start = __pa(startp);
@@ -484,7 +507,10 @@ static void pnv_pci_ioda1_tce_invalidate(struct iommu_table *tbl,
484 507
485 mb(); /* Ensure above stores are visible */ 508 mb(); /* Ensure above stores are visible */
486 while (start <= end) { 509 while (start <= end) {
487 __raw_writeq(start, invalidate); 510 if (rm)
511 __raw_rm_writeq(cpu_to_be64(start), invalidate);
512 else
513 __raw_writeq(cpu_to_be64(start), invalidate);
488 start += inc; 514 start += inc;
489 } 515 }
490 516
@@ -496,10 +522,12 @@ static void pnv_pci_ioda1_tce_invalidate(struct iommu_table *tbl,
496 522
497static void pnv_pci_ioda2_tce_invalidate(struct pnv_ioda_pe *pe, 523static void pnv_pci_ioda2_tce_invalidate(struct pnv_ioda_pe *pe,
498 struct iommu_table *tbl, 524 struct iommu_table *tbl,
499 u64 *startp, u64 *endp) 525 __be64 *startp, __be64 *endp, bool rm)
500{ 526{
501 unsigned long start, end, inc; 527 unsigned long start, end, inc;
502 u64 __iomem *invalidate = (u64 __iomem *)tbl->it_index; 528 __be64 __iomem *invalidate = rm ?
529 (__be64 __iomem *)pe->tce_inval_reg_phys :
530 (__be64 __iomem *)tbl->it_index;
503 531
504 /* We'll invalidate DMA address in PE scope */ 532 /* We'll invalidate DMA address in PE scope */
505 start = 0x2ul << 60; 533 start = 0x2ul << 60;
@@ -515,22 +543,25 @@ static void pnv_pci_ioda2_tce_invalidate(struct pnv_ioda_pe *pe,
515 mb(); 543 mb();
516 544
517 while (start <= end) { 545 while (start <= end) {
518 __raw_writeq(start, invalidate); 546 if (rm)
547 __raw_rm_writeq(cpu_to_be64(start), invalidate);
548 else
549 __raw_writeq(cpu_to_be64(start), invalidate);
519 start += inc; 550 start += inc;
520 } 551 }
521} 552}
522 553
523void pnv_pci_ioda_tce_invalidate(struct iommu_table *tbl, 554void pnv_pci_ioda_tce_invalidate(struct iommu_table *tbl,
524 u64 *startp, u64 *endp) 555 __be64 *startp, __be64 *endp, bool rm)
525{ 556{
526 struct pnv_ioda_pe *pe = container_of(tbl, struct pnv_ioda_pe, 557 struct pnv_ioda_pe *pe = container_of(tbl, struct pnv_ioda_pe,
527 tce32_table); 558 tce32_table);
528 struct pnv_phb *phb = pe->phb; 559 struct pnv_phb *phb = pe->phb;
529 560
530 if (phb->type == PNV_PHB_IODA1) 561 if (phb->type == PNV_PHB_IODA1)
531 pnv_pci_ioda1_tce_invalidate(tbl, startp, endp); 562 pnv_pci_ioda1_tce_invalidate(pe, tbl, startp, endp, rm);
532 else 563 else
533 pnv_pci_ioda2_tce_invalidate(pe, tbl, startp, endp); 564 pnv_pci_ioda2_tce_invalidate(pe, tbl, startp, endp, rm);
534} 565}
535 566
536static void pnv_pci_ioda_setup_dma_pe(struct pnv_phb *phb, 567static void pnv_pci_ioda_setup_dma_pe(struct pnv_phb *phb,
@@ -603,7 +634,9 @@ static void pnv_pci_ioda_setup_dma_pe(struct pnv_phb *phb,
603 * bus number, print that out instead. 634 * bus number, print that out instead.
604 */ 635 */
605 tbl->it_busno = 0; 636 tbl->it_busno = 0;
606 tbl->it_index = (unsigned long)ioremap(be64_to_cpup(swinvp), 8); 637 pe->tce_inval_reg_phys = be64_to_cpup(swinvp);
638 tbl->it_index = (unsigned long)ioremap(pe->tce_inval_reg_phys,
639 8);
607 tbl->it_type = TCE_PCI_SWINV_CREATE | TCE_PCI_SWINV_FREE | 640 tbl->it_type = TCE_PCI_SWINV_CREATE | TCE_PCI_SWINV_FREE |
608 TCE_PCI_SWINV_PAIR; 641 TCE_PCI_SWINV_PAIR;
609 } 642 }
@@ -681,7 +714,9 @@ static void pnv_pci_ioda2_setup_dma_pe(struct pnv_phb *phb,
681 * bus number, print that out instead. 714 * bus number, print that out instead.
682 */ 715 */
683 tbl->it_busno = 0; 716 tbl->it_busno = 0;
684 tbl->it_index = (unsigned long)ioremap(be64_to_cpup(swinvp), 8); 717 pe->tce_inval_reg_phys = be64_to_cpup(swinvp);
718 tbl->it_index = (unsigned long)ioremap(pe->tce_inval_reg_phys,
719 8);
685 tbl->it_type = TCE_PCI_SWINV_CREATE | TCE_PCI_SWINV_FREE; 720 tbl->it_type = TCE_PCI_SWINV_CREATE | TCE_PCI_SWINV_FREE;
686 } 721 }
687 iommu_init_table(tbl, phb->hose->node); 722 iommu_init_table(tbl, phb->hose->node);
@@ -786,8 +821,7 @@ static int pnv_pci_ioda_msi_setup(struct pnv_phb *phb, struct pci_dev *dev,
786 struct irq_data *idata; 821 struct irq_data *idata;
787 struct irq_chip *ichip; 822 struct irq_chip *ichip;
788 unsigned int xive_num = hwirq - phb->msi_base; 823 unsigned int xive_num = hwirq - phb->msi_base;
789 uint64_t addr64; 824 __be32 data;
790 uint32_t addr32, data;
791 int rc; 825 int rc;
792 826
793 /* No PE assigned ? bail out ... no MSI for you ! */ 827 /* No PE assigned ? bail out ... no MSI for you ! */
@@ -811,6 +845,8 @@ static int pnv_pci_ioda_msi_setup(struct pnv_phb *phb, struct pci_dev *dev,
811 } 845 }
812 846
813 if (is_64) { 847 if (is_64) {
848 __be64 addr64;
849
814 rc = opal_get_msi_64(phb->opal_id, pe->mve_number, xive_num, 1, 850 rc = opal_get_msi_64(phb->opal_id, pe->mve_number, xive_num, 1,
815 &addr64, &data); 851 &addr64, &data);
816 if (rc) { 852 if (rc) {
@@ -818,9 +854,11 @@ static int pnv_pci_ioda_msi_setup(struct pnv_phb *phb, struct pci_dev *dev,
818 pci_name(dev), rc); 854 pci_name(dev), rc);
819 return -EIO; 855 return -EIO;
820 } 856 }
821 msg->address_hi = addr64 >> 32; 857 msg->address_hi = be64_to_cpu(addr64) >> 32;
822 msg->address_lo = addr64 & 0xfffffffful; 858 msg->address_lo = be64_to_cpu(addr64) & 0xfffffffful;
823 } else { 859 } else {
860 __be32 addr32;
861
824 rc = opal_get_msi_32(phb->opal_id, pe->mve_number, xive_num, 1, 862 rc = opal_get_msi_32(phb->opal_id, pe->mve_number, xive_num, 1,
825 &addr32, &data); 863 &addr32, &data);
826 if (rc) { 864 if (rc) {
@@ -829,9 +867,9 @@ static int pnv_pci_ioda_msi_setup(struct pnv_phb *phb, struct pci_dev *dev,
829 return -EIO; 867 return -EIO;
830 } 868 }
831 msg->address_hi = 0; 869 msg->address_hi = 0;
832 msg->address_lo = addr32; 870 msg->address_lo = be32_to_cpu(addr32);
833 } 871 }
834 msg->data = data; 872 msg->data = be32_to_cpu(data);
835 873
836 /* 874 /*
837 * Change the IRQ chip for the MSI interrupts on PHB3. 875 * Change the IRQ chip for the MSI interrupts on PHB3.
@@ -1106,8 +1144,8 @@ void __init pnv_pci_init_ioda_phb(struct device_node *np,
1106 struct pci_controller *hose; 1144 struct pci_controller *hose;
1107 struct pnv_phb *phb; 1145 struct pnv_phb *phb;
1108 unsigned long size, m32map_off, iomap_off, pemap_off; 1146 unsigned long size, m32map_off, iomap_off, pemap_off;
1109 const u64 *prop64; 1147 const __be64 *prop64;
1110 const u32 *prop32; 1148 const __be32 *prop32;
1111 int len; 1149 int len;
1112 u64 phb_id; 1150 u64 phb_id;
1113 void *aux; 1151 void *aux;
@@ -1142,8 +1180,8 @@ void __init pnv_pci_init_ioda_phb(struct device_node *np,
1142 spin_lock_init(&phb->lock); 1180 spin_lock_init(&phb->lock);
1143 prop32 = of_get_property(np, "bus-range", &len); 1181 prop32 = of_get_property(np, "bus-range", &len);
1144 if (prop32 && len == 8) { 1182 if (prop32 && len == 8) {
1145 hose->first_busno = prop32[0]; 1183 hose->first_busno = be32_to_cpu(prop32[0]);
1146 hose->last_busno = prop32[1]; 1184 hose->last_busno = be32_to_cpu(prop32[1]);
1147 } else { 1185 } else {
1148 pr_warn(" Broken <bus-range> on %s\n", np->full_name); 1186 pr_warn(" Broken <bus-range> on %s\n", np->full_name);
1149 hose->first_busno = 0; 1187 hose->first_busno = 0;
@@ -1171,12 +1209,13 @@ void __init pnv_pci_init_ioda_phb(struct device_node *np,
1171 pr_err(" Failed to map registers !\n"); 1209 pr_err(" Failed to map registers !\n");
1172 1210
1173 /* Initialize more IODA stuff */ 1211 /* Initialize more IODA stuff */
1212 phb->ioda.total_pe = 1;
1174 prop32 = of_get_property(np, "ibm,opal-num-pes", NULL); 1213 prop32 = of_get_property(np, "ibm,opal-num-pes", NULL);
1175 if (!prop32) 1214 if (prop32)
1176 phb->ioda.total_pe = 1; 1215 phb->ioda.total_pe = be32_to_cpup(prop32);
1177 else 1216 prop32 = of_get_property(np, "ibm,opal-reserved-pe", NULL);
1178 phb->ioda.total_pe = *prop32; 1217 if (prop32)
1179 1218 phb->ioda.reserved_pe = be32_to_cpup(prop32);
1180 phb->ioda.m32_size = resource_size(&hose->mem_resources[0]); 1219 phb->ioda.m32_size = resource_size(&hose->mem_resources[0]);
1181 /* FW Has already off top 64k of M32 space (MSI space) */ 1220 /* FW Has already off top 64k of M32 space (MSI space) */
1182 phb->ioda.m32_size += 0x10000; 1221 phb->ioda.m32_size += 0x10000;
@@ -1205,7 +1244,7 @@ void __init pnv_pci_init_ioda_phb(struct device_node *np,
1205 if (phb->type == PNV_PHB_IODA1) 1244 if (phb->type == PNV_PHB_IODA1)
1206 phb->ioda.io_segmap = aux + iomap_off; 1245 phb->ioda.io_segmap = aux + iomap_off;
1207 phb->ioda.pe_array = aux + pemap_off; 1246 phb->ioda.pe_array = aux + pemap_off;
1208 set_bit(0, phb->ioda.pe_alloc); 1247 set_bit(phb->ioda.reserved_pe, phb->ioda.pe_alloc);
1209 1248
1210 INIT_LIST_HEAD(&phb->ioda.pe_dma_list); 1249 INIT_LIST_HEAD(&phb->ioda.pe_dma_list);
1211 INIT_LIST_HEAD(&phb->ioda.pe_list); 1250 INIT_LIST_HEAD(&phb->ioda.pe_list);
@@ -1230,8 +1269,10 @@ void __init pnv_pci_init_ioda_phb(struct device_node *np,
1230 segment_size); 1269 segment_size);
1231#endif 1270#endif
1232 1271
1233 pr_info(" %d PE's M32: 0x%x [segment=0x%x] IO: 0x%x [segment=0x%x]\n", 1272 pr_info(" %d (%d) PE's M32: 0x%x [segment=0x%x]"
1273 " IO: 0x%x [segment=0x%x]\n",
1234 phb->ioda.total_pe, 1274 phb->ioda.total_pe,
1275 phb->ioda.reserved_pe,
1235 phb->ioda.m32_size, phb->ioda.m32_segsize, 1276 phb->ioda.m32_size, phb->ioda.m32_segsize,
1236 phb->ioda.io_size, phb->ioda.io_segsize); 1277 phb->ioda.io_size, phb->ioda.io_segsize);
1237 1278
@@ -1268,13 +1309,6 @@ void __init pnv_pci_init_ioda_phb(struct device_node *np,
1268 rc = opal_pci_reset(phb_id, OPAL_PCI_IODA_TABLE_RESET, OPAL_ASSERT_RESET); 1309 rc = opal_pci_reset(phb_id, OPAL_PCI_IODA_TABLE_RESET, OPAL_ASSERT_RESET);
1269 if (rc) 1310 if (rc)
1270 pr_warning(" OPAL Error %ld performing IODA table reset !\n", rc); 1311 pr_warning(" OPAL Error %ld performing IODA table reset !\n", rc);
1271
1272 /*
1273 * On IODA1 map everything to PE#0, on IODA2 we assume the IODA reset
1274 * has cleared the RTT which has the same effect
1275 */
1276 if (ioda_type == PNV_PHB_IODA1)
1277 opal_pci_set_pe(phb_id, 0, 0, 7, 1, 1 , OPAL_MAP_PE);
1278} 1312}
1279 1313
1280void __init pnv_pci_init_ioda2_phb(struct device_node *np) 1314void __init pnv_pci_init_ioda2_phb(struct device_node *np)
@@ -1285,7 +1319,7 @@ void __init pnv_pci_init_ioda2_phb(struct device_node *np)
1285void __init pnv_pci_init_ioda_hub(struct device_node *np) 1319void __init pnv_pci_init_ioda_hub(struct device_node *np)
1286{ 1320{
1287 struct device_node *phbn; 1321 struct device_node *phbn;
1288 const u64 *prop64; 1322 const __be64 *prop64;
1289 u64 hub_id; 1323 u64 hub_id;
1290 1324
1291 pr_info("Probing IODA IO-Hub %s\n", np->full_name); 1325 pr_info("Probing IODA IO-Hub %s\n", np->full_name);
diff --git a/arch/powerpc/platforms/powernv/pci-p5ioc2.c b/arch/powerpc/platforms/powernv/pci-p5ioc2.c
index b68db6325c1b..f8b4bd8afb2e 100644
--- a/arch/powerpc/platforms/powernv/pci-p5ioc2.c
+++ b/arch/powerpc/platforms/powernv/pci-p5ioc2.c
@@ -99,7 +99,7 @@ static void __init pnv_pci_init_p5ioc2_phb(struct device_node *np, u64 hub_id,
99 void *tce_mem, u64 tce_size) 99 void *tce_mem, u64 tce_size)
100{ 100{
101 struct pnv_phb *phb; 101 struct pnv_phb *phb;
102 const u64 *prop64; 102 const __be64 *prop64;
103 u64 phb_id; 103 u64 phb_id;
104 int64_t rc; 104 int64_t rc;
105 static int primary = 1; 105 static int primary = 1;
@@ -178,7 +178,7 @@ static void __init pnv_pci_init_p5ioc2_phb(struct device_node *np, u64 hub_id,
178void __init pnv_pci_init_p5ioc2_hub(struct device_node *np) 178void __init pnv_pci_init_p5ioc2_hub(struct device_node *np)
179{ 179{
180 struct device_node *phbn; 180 struct device_node *phbn;
181 const u64 *prop64; 181 const __be64 *prop64;
182 u64 hub_id; 182 u64 hub_id;
183 void *tce_mem; 183 void *tce_mem;
184 uint64_t tce_per_phb; 184 uint64_t tce_per_phb;
diff --git a/arch/powerpc/platforms/powernv/pci.c b/arch/powerpc/platforms/powernv/pci.c
index a28d3b5e6393..4eb33a9ed532 100644
--- a/arch/powerpc/platforms/powernv/pci.c
+++ b/arch/powerpc/platforms/powernv/pci.c
@@ -236,17 +236,21 @@ static void pnv_pci_config_check_eeh(struct pnv_phb *phb,
236{ 236{
237 s64 rc; 237 s64 rc;
238 u8 fstate; 238 u8 fstate;
239 u16 pcierr; 239 __be16 pcierr;
240 u32 pe_no; 240 u32 pe_no;
241 241
242 /* 242 /*
243 * Get the PE#. During the PCI probe stage, we might not 243 * Get the PE#. During the PCI probe stage, we might not
244 * setup that yet. So all ER errors should be mapped to 244 * setup that yet. So all ER errors should be mapped to
245 * PE#0 245 * reserved PE.
246 */ 246 */
247 pe_no = PCI_DN(dn)->pe_number; 247 pe_no = PCI_DN(dn)->pe_number;
248 if (pe_no == IODA_INVALID_PE) 248 if (pe_no == IODA_INVALID_PE) {
249 pe_no = 0; 249 if (phb->type == PNV_PHB_P5IOC2)
250 pe_no = 0;
251 else
252 pe_no = phb->ioda.reserved_pe;
253 }
250 254
251 /* Read freeze status */ 255 /* Read freeze status */
252 rc = opal_pci_eeh_freeze_status(phb->opal_id, pe_no, &fstate, &pcierr, 256 rc = opal_pci_eeh_freeze_status(phb->opal_id, pe_no, &fstate, &pcierr,
@@ -283,16 +287,16 @@ int pnv_pci_cfg_read(struct device_node *dn,
283 break; 287 break;
284 } 288 }
285 case 2: { 289 case 2: {
286 u16 v16; 290 __be16 v16;
287 rc = opal_pci_config_read_half_word(phb->opal_id, bdfn, where, 291 rc = opal_pci_config_read_half_word(phb->opal_id, bdfn, where,
288 &v16); 292 &v16);
289 *val = (rc == OPAL_SUCCESS) ? v16 : 0xffff; 293 *val = (rc == OPAL_SUCCESS) ? be16_to_cpu(v16) : 0xffff;
290 break; 294 break;
291 } 295 }
292 case 4: { 296 case 4: {
293 u32 v32; 297 __be32 v32;
294 rc = opal_pci_config_read_word(phb->opal_id, bdfn, where, &v32); 298 rc = opal_pci_config_read_word(phb->opal_id, bdfn, where, &v32);
295 *val = (rc == OPAL_SUCCESS) ? v32 : 0xffffffff; 299 *val = (rc == OPAL_SUCCESS) ? be32_to_cpu(v32) : 0xffffffff;
296 break; 300 break;
297 } 301 }
298 default: 302 default:
@@ -401,10 +405,10 @@ struct pci_ops pnv_pci_ops = {
401 405
402static int pnv_tce_build(struct iommu_table *tbl, long index, long npages, 406static int pnv_tce_build(struct iommu_table *tbl, long index, long npages,
403 unsigned long uaddr, enum dma_data_direction direction, 407 unsigned long uaddr, enum dma_data_direction direction,
404 struct dma_attrs *attrs) 408 struct dma_attrs *attrs, bool rm)
405{ 409{
406 u64 proto_tce; 410 u64 proto_tce;
407 u64 *tcep, *tces; 411 __be64 *tcep, *tces;
408 u64 rpn; 412 u64 rpn;
409 413
410 proto_tce = TCE_PCI_READ; // Read allowed 414 proto_tce = TCE_PCI_READ; // Read allowed
@@ -412,33 +416,48 @@ static int pnv_tce_build(struct iommu_table *tbl, long index, long npages,
412 if (direction != DMA_TO_DEVICE) 416 if (direction != DMA_TO_DEVICE)
413 proto_tce |= TCE_PCI_WRITE; 417 proto_tce |= TCE_PCI_WRITE;
414 418
415 tces = tcep = ((u64 *)tbl->it_base) + index - tbl->it_offset; 419 tces = tcep = ((__be64 *)tbl->it_base) + index - tbl->it_offset;
416 rpn = __pa(uaddr) >> TCE_SHIFT; 420 rpn = __pa(uaddr) >> TCE_SHIFT;
417 421
418 while (npages--) 422 while (npages--)
419 *(tcep++) = proto_tce | (rpn++ << TCE_RPN_SHIFT); 423 *(tcep++) = cpu_to_be64(proto_tce | (rpn++ << TCE_RPN_SHIFT));
420 424
421 /* Some implementations won't cache invalid TCEs and thus may not 425 /* Some implementations won't cache invalid TCEs and thus may not
422 * need that flush. We'll probably turn it_type into a bit mask 426 * need that flush. We'll probably turn it_type into a bit mask
423 * of flags if that becomes the case 427 * of flags if that becomes the case
424 */ 428 */
425 if (tbl->it_type & TCE_PCI_SWINV_CREATE) 429 if (tbl->it_type & TCE_PCI_SWINV_CREATE)
426 pnv_pci_ioda_tce_invalidate(tbl, tces, tcep - 1); 430 pnv_pci_ioda_tce_invalidate(tbl, tces, tcep - 1, rm);
427 431
428 return 0; 432 return 0;
429} 433}
430 434
431static void pnv_tce_free(struct iommu_table *tbl, long index, long npages) 435static int pnv_tce_build_vm(struct iommu_table *tbl, long index, long npages,
436 unsigned long uaddr,
437 enum dma_data_direction direction,
438 struct dma_attrs *attrs)
432{ 439{
433 u64 *tcep, *tces; 440 return pnv_tce_build(tbl, index, npages, uaddr, direction, attrs,
441 false);
442}
434 443
435 tces = tcep = ((u64 *)tbl->it_base) + index - tbl->it_offset; 444static void pnv_tce_free(struct iommu_table *tbl, long index, long npages,
445 bool rm)
446{
447 __be64 *tcep, *tces;
448
449 tces = tcep = ((__be64 *)tbl->it_base) + index - tbl->it_offset;
436 450
437 while (npages--) 451 while (npages--)
438 *(tcep++) = 0; 452 *(tcep++) = cpu_to_be64(0);
439 453
440 if (tbl->it_type & TCE_PCI_SWINV_FREE) 454 if (tbl->it_type & TCE_PCI_SWINV_FREE)
441 pnv_pci_ioda_tce_invalidate(tbl, tces, tcep - 1); 455 pnv_pci_ioda_tce_invalidate(tbl, tces, tcep - 1, rm);
456}
457
458static void pnv_tce_free_vm(struct iommu_table *tbl, long index, long npages)
459{
460 pnv_tce_free(tbl, index, npages, false);
442} 461}
443 462
444static unsigned long pnv_tce_get(struct iommu_table *tbl, long index) 463static unsigned long pnv_tce_get(struct iommu_table *tbl, long index)
@@ -446,6 +465,19 @@ static unsigned long pnv_tce_get(struct iommu_table *tbl, long index)
446 return ((u64 *)tbl->it_base)[index - tbl->it_offset]; 465 return ((u64 *)tbl->it_base)[index - tbl->it_offset];
447} 466}
448 467
468static int pnv_tce_build_rm(struct iommu_table *tbl, long index, long npages,
469 unsigned long uaddr,
470 enum dma_data_direction direction,
471 struct dma_attrs *attrs)
472{
473 return pnv_tce_build(tbl, index, npages, uaddr, direction, attrs, true);
474}
475
476static void pnv_tce_free_rm(struct iommu_table *tbl, long index, long npages)
477{
478 pnv_tce_free(tbl, index, npages, true);
479}
480
449void pnv_pci_setup_iommu_table(struct iommu_table *tbl, 481void pnv_pci_setup_iommu_table(struct iommu_table *tbl,
450 void *tce_mem, u64 tce_size, 482 void *tce_mem, u64 tce_size,
451 u64 dma_offset) 483 u64 dma_offset)
@@ -484,8 +516,8 @@ static struct iommu_table *pnv_pci_setup_bml_iommu(struct pci_controller *hose)
484 swinvp = of_get_property(hose->dn, "linux,tce-sw-invalidate-info", 516 swinvp = of_get_property(hose->dn, "linux,tce-sw-invalidate-info",
485 NULL); 517 NULL);
486 if (swinvp) { 518 if (swinvp) {
487 tbl->it_busno = swinvp[1]; 519 tbl->it_busno = be64_to_cpu(swinvp[1]);
488 tbl->it_index = (unsigned long)ioremap(swinvp[0], 8); 520 tbl->it_index = (unsigned long)ioremap(be64_to_cpup(swinvp), 8);
489 tbl->it_type = TCE_PCI_SWINV_CREATE | TCE_PCI_SWINV_FREE; 521 tbl->it_type = TCE_PCI_SWINV_CREATE | TCE_PCI_SWINV_FREE;
490 } 522 }
491 return tbl; 523 return tbl;
@@ -610,8 +642,10 @@ void __init pnv_pci_init(void)
610 642
611 /* Configure IOMMU DMA hooks */ 643 /* Configure IOMMU DMA hooks */
612 ppc_md.pci_dma_dev_setup = pnv_pci_dma_dev_setup; 644 ppc_md.pci_dma_dev_setup = pnv_pci_dma_dev_setup;
613 ppc_md.tce_build = pnv_tce_build; 645 ppc_md.tce_build = pnv_tce_build_vm;
614 ppc_md.tce_free = pnv_tce_free; 646 ppc_md.tce_free = pnv_tce_free_vm;
647 ppc_md.tce_build_rm = pnv_tce_build_rm;
648 ppc_md.tce_free_rm = pnv_tce_free_rm;
615 ppc_md.tce_get = pnv_tce_get; 649 ppc_md.tce_get = pnv_tce_get;
616 ppc_md.pci_probe_mode = pnv_pci_probe_mode; 650 ppc_md.pci_probe_mode = pnv_pci_probe_mode;
617 set_pci_dma_ops(&dma_iommu_ops); 651 set_pci_dma_ops(&dma_iommu_ops);
diff --git a/arch/powerpc/platforms/powernv/pci.h b/arch/powerpc/platforms/powernv/pci.h
index d633c64e05a1..911c24ef033e 100644
--- a/arch/powerpc/platforms/powernv/pci.h
+++ b/arch/powerpc/platforms/powernv/pci.h
@@ -17,7 +17,7 @@ enum pnv_phb_model {
17 PNV_PHB_MODEL_PHB3, 17 PNV_PHB_MODEL_PHB3,
18}; 18};
19 19
20#define PNV_PCI_DIAG_BUF_SIZE 4096 20#define PNV_PCI_DIAG_BUF_SIZE 8192
21#define PNV_IODA_PE_DEV (1 << 0) /* PE has single PCI device */ 21#define PNV_IODA_PE_DEV (1 << 0) /* PE has single PCI device */
22#define PNV_IODA_PE_BUS (1 << 1) /* PE has primary PCI bus */ 22#define PNV_IODA_PE_BUS (1 << 1) /* PE has primary PCI bus */
23#define PNV_IODA_PE_BUS_ALL (1 << 2) /* PE has subordinate buses */ 23#define PNV_IODA_PE_BUS_ALL (1 << 2) /* PE has subordinate buses */
@@ -52,6 +52,7 @@ struct pnv_ioda_pe {
52 int tce32_seg; 52 int tce32_seg;
53 int tce32_segcount; 53 int tce32_segcount;
54 struct iommu_table tce32_table; 54 struct iommu_table tce32_table;
55 phys_addr_t tce_inval_reg_phys;
55 56
56 /* XXX TODO: Add support for additional 64-bit iommus */ 57 /* XXX TODO: Add support for additional 64-bit iommus */
57 58
@@ -124,6 +125,7 @@ struct pnv_phb {
124 struct { 125 struct {
125 /* Global bridge info */ 126 /* Global bridge info */
126 unsigned int total_pe; 127 unsigned int total_pe;
128 unsigned int reserved_pe;
127 unsigned int m32_size; 129 unsigned int m32_size;
128 unsigned int m32_segsize; 130 unsigned int m32_segsize;
129 unsigned int m32_pci_base; 131 unsigned int m32_pci_base;
@@ -193,6 +195,6 @@ extern void pnv_pci_init_p5ioc2_hub(struct device_node *np);
193extern void pnv_pci_init_ioda_hub(struct device_node *np); 195extern void pnv_pci_init_ioda_hub(struct device_node *np);
194extern void pnv_pci_init_ioda2_phb(struct device_node *np); 196extern void pnv_pci_init_ioda2_phb(struct device_node *np);
195extern void pnv_pci_ioda_tce_invalidate(struct iommu_table *tbl, 197extern void pnv_pci_ioda_tce_invalidate(struct iommu_table *tbl,
196 u64 *startp, u64 *endp); 198 __be64 *startp, __be64 *endp, bool rm);
197 199
198#endif /* __POWERNV_PCI_H */ 200#endif /* __POWERNV_PCI_H */
diff --git a/arch/powerpc/platforms/powernv/rng.c b/arch/powerpc/platforms/powernv/rng.c
new file mode 100644
index 000000000000..8844628915dc
--- /dev/null
+++ b/arch/powerpc/platforms/powernv/rng.c
@@ -0,0 +1,125 @@
1/*
2 * Copyright 2013, Michael Ellerman, IBM Corporation.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 */
9
10#define pr_fmt(fmt) "powernv-rng: " fmt
11
12#include <linux/kernel.h>
13#include <linux/of.h>
14#include <linux/of_address.h>
15#include <linux/of_platform.h>
16#include <linux/slab.h>
17#include <linux/smp.h>
18#include <asm/archrandom.h>
19#include <asm/io.h>
20#include <asm/prom.h>
21#include <asm/machdep.h>
22
23
24struct powernv_rng {
25 void __iomem *regs;
26 unsigned long mask;
27};
28
29static DEFINE_PER_CPU(struct powernv_rng *, powernv_rng);
30
31
32static unsigned long rng_whiten(struct powernv_rng *rng, unsigned long val)
33{
34 unsigned long parity;
35
36 /* Calculate the parity of the value */
37 asm ("popcntd %0,%1" : "=r" (parity) : "r" (val));
38
39 /* xor our value with the previous mask */
40 val ^= rng->mask;
41
42 /* update the mask based on the parity of this value */
43 rng->mask = (rng->mask << 1) | (parity & 1);
44
45 return val;
46}
47
48int powernv_get_random_long(unsigned long *v)
49{
50 struct powernv_rng *rng;
51
52 rng = get_cpu_var(powernv_rng);
53
54 *v = rng_whiten(rng, in_be64(rng->regs));
55
56 put_cpu_var(rng);
57
58 return 1;
59}
60EXPORT_SYMBOL_GPL(powernv_get_random_long);
61
62static __init void rng_init_per_cpu(struct powernv_rng *rng,
63 struct device_node *dn)
64{
65 int chip_id, cpu;
66
67 chip_id = of_get_ibm_chip_id(dn);
68 if (chip_id == -1)
69 pr_warn("No ibm,chip-id found for %s.\n", dn->full_name);
70
71 for_each_possible_cpu(cpu) {
72 if (per_cpu(powernv_rng, cpu) == NULL ||
73 cpu_to_chip_id(cpu) == chip_id) {
74 per_cpu(powernv_rng, cpu) = rng;
75 }
76 }
77}
78
79static __init int rng_create(struct device_node *dn)
80{
81 struct powernv_rng *rng;
82 unsigned long val;
83
84 rng = kzalloc(sizeof(*rng), GFP_KERNEL);
85 if (!rng)
86 return -ENOMEM;
87
88 rng->regs = of_iomap(dn, 0);
89 if (!rng->regs) {
90 kfree(rng);
91 return -ENXIO;
92 }
93
94 val = in_be64(rng->regs);
95 rng->mask = val;
96
97 rng_init_per_cpu(rng, dn);
98
99 pr_info_once("Registering arch random hook.\n");
100
101 ppc_md.get_random_long = powernv_get_random_long;
102
103 return 0;
104}
105
106static __init int rng_init(void)
107{
108 struct device_node *dn;
109 int rc;
110
111 for_each_compatible_node(dn, NULL, "ibm,power-rng") {
112 rc = rng_create(dn);
113 if (rc) {
114 pr_err("Failed creating rng for %s (%d).\n",
115 dn->full_name, rc);
116 continue;
117 }
118
119 /* Create devices for hwrng driver */
120 of_platform_device_create(dn, NULL, NULL);
121 }
122
123 return 0;
124}
125subsys_initcall(rng_init);
diff --git a/arch/powerpc/platforms/pseries/Makefile b/arch/powerpc/platforms/pseries/Makefile
index 6c61ec5ee914..fbccac9cd2dc 100644
--- a/arch/powerpc/platforms/pseries/Makefile
+++ b/arch/powerpc/platforms/pseries/Makefile
@@ -3,7 +3,7 @@ ccflags-$(CONFIG_PPC_PSERIES_DEBUG) += -DDEBUG
3 3
4obj-y := lpar.o hvCall.o nvram.o reconfig.o \ 4obj-y := lpar.o hvCall.o nvram.o reconfig.o \
5 setup.o iommu.o event_sources.o ras.o \ 5 setup.o iommu.o event_sources.o ras.o \
6 firmware.o power.o dlpar.o mobility.o 6 firmware.o power.o dlpar.o mobility.o rng.o
7obj-$(CONFIG_SMP) += smp.o 7obj-$(CONFIG_SMP) += smp.o
8obj-$(CONFIG_SCANLOG) += scanlog.o 8obj-$(CONFIG_SCANLOG) += scanlog.o
9obj-$(CONFIG_EEH) += eeh_pseries.o 9obj-$(CONFIG_EEH) += eeh_pseries.o
diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c
index 0307901e4132..f253361552ae 100644
--- a/arch/powerpc/platforms/pseries/iommu.c
+++ b/arch/powerpc/platforms/pseries/iommu.c
@@ -52,7 +52,7 @@
52 52
53 53
54static void tce_invalidate_pSeries_sw(struct iommu_table *tbl, 54static void tce_invalidate_pSeries_sw(struct iommu_table *tbl,
55 u64 *startp, u64 *endp) 55 __be64 *startp, __be64 *endp)
56{ 56{
57 u64 __iomem *invalidate = (u64 __iomem *)tbl->it_index; 57 u64 __iomem *invalidate = (u64 __iomem *)tbl->it_index;
58 unsigned long start, end, inc; 58 unsigned long start, end, inc;
@@ -86,7 +86,7 @@ static int tce_build_pSeries(struct iommu_table *tbl, long index,
86 struct dma_attrs *attrs) 86 struct dma_attrs *attrs)
87{ 87{
88 u64 proto_tce; 88 u64 proto_tce;
89 u64 *tcep, *tces; 89 __be64 *tcep, *tces;
90 u64 rpn; 90 u64 rpn;
91 91
92 proto_tce = TCE_PCI_READ; // Read allowed 92 proto_tce = TCE_PCI_READ; // Read allowed
@@ -94,12 +94,12 @@ static int tce_build_pSeries(struct iommu_table *tbl, long index,
94 if (direction != DMA_TO_DEVICE) 94 if (direction != DMA_TO_DEVICE)
95 proto_tce |= TCE_PCI_WRITE; 95 proto_tce |= TCE_PCI_WRITE;
96 96
97 tces = tcep = ((u64 *)tbl->it_base) + index; 97 tces = tcep = ((__be64 *)tbl->it_base) + index;
98 98
99 while (npages--) { 99 while (npages--) {
100 /* can't move this out since we might cross MEMBLOCK boundary */ 100 /* can't move this out since we might cross MEMBLOCK boundary */
101 rpn = __pa(uaddr) >> TCE_SHIFT; 101 rpn = __pa(uaddr) >> TCE_SHIFT;
102 *tcep = proto_tce | (rpn & TCE_RPN_MASK) << TCE_RPN_SHIFT; 102 *tcep = cpu_to_be64(proto_tce | (rpn & TCE_RPN_MASK) << TCE_RPN_SHIFT);
103 103
104 uaddr += TCE_PAGE_SIZE; 104 uaddr += TCE_PAGE_SIZE;
105 tcep++; 105 tcep++;
@@ -113,9 +113,9 @@ static int tce_build_pSeries(struct iommu_table *tbl, long index,
113 113
114static void tce_free_pSeries(struct iommu_table *tbl, long index, long npages) 114static void tce_free_pSeries(struct iommu_table *tbl, long index, long npages)
115{ 115{
116 u64 *tcep, *tces; 116 __be64 *tcep, *tces;
117 117
118 tces = tcep = ((u64 *)tbl->it_base) + index; 118 tces = tcep = ((__be64 *)tbl->it_base) + index;
119 119
120 while (npages--) 120 while (npages--)
121 *(tcep++) = 0; 121 *(tcep++) = 0;
@@ -126,11 +126,11 @@ static void tce_free_pSeries(struct iommu_table *tbl, long index, long npages)
126 126
127static unsigned long tce_get_pseries(struct iommu_table *tbl, long index) 127static unsigned long tce_get_pseries(struct iommu_table *tbl, long index)
128{ 128{
129 u64 *tcep; 129 __be64 *tcep;
130 130
131 tcep = ((u64 *)tbl->it_base) + index; 131 tcep = ((__be64 *)tbl->it_base) + index;
132 132
133 return *tcep; 133 return be64_to_cpu(*tcep);
134} 134}
135 135
136static void tce_free_pSeriesLP(struct iommu_table*, long, long); 136static void tce_free_pSeriesLP(struct iommu_table*, long, long);
@@ -177,7 +177,7 @@ static int tce_build_pSeriesLP(struct iommu_table *tbl, long tcenum,
177 return ret; 177 return ret;
178} 178}
179 179
180static DEFINE_PER_CPU(u64 *, tce_page); 180static DEFINE_PER_CPU(__be64 *, tce_page);
181 181
182static int tce_buildmulti_pSeriesLP(struct iommu_table *tbl, long tcenum, 182static int tce_buildmulti_pSeriesLP(struct iommu_table *tbl, long tcenum,
183 long npages, unsigned long uaddr, 183 long npages, unsigned long uaddr,
@@ -186,7 +186,7 @@ static int tce_buildmulti_pSeriesLP(struct iommu_table *tbl, long tcenum,
186{ 186{
187 u64 rc = 0; 187 u64 rc = 0;
188 u64 proto_tce; 188 u64 proto_tce;
189 u64 *tcep; 189 __be64 *tcep;
190 u64 rpn; 190 u64 rpn;
191 long l, limit; 191 long l, limit;
192 long tcenum_start = tcenum, npages_start = npages; 192 long tcenum_start = tcenum, npages_start = npages;
@@ -206,7 +206,7 @@ static int tce_buildmulti_pSeriesLP(struct iommu_table *tbl, long tcenum,
206 * from iommu_alloc{,_sg}() 206 * from iommu_alloc{,_sg}()
207 */ 207 */
208 if (!tcep) { 208 if (!tcep) {
209 tcep = (u64 *)__get_free_page(GFP_ATOMIC); 209 tcep = (__be64 *)__get_free_page(GFP_ATOMIC);
210 /* If allocation fails, fall back to the loop implementation */ 210 /* If allocation fails, fall back to the loop implementation */
211 if (!tcep) { 211 if (!tcep) {
212 local_irq_restore(flags); 212 local_irq_restore(flags);
@@ -230,7 +230,7 @@ static int tce_buildmulti_pSeriesLP(struct iommu_table *tbl, long tcenum,
230 limit = min_t(long, npages, 4096/TCE_ENTRY_SIZE); 230 limit = min_t(long, npages, 4096/TCE_ENTRY_SIZE);
231 231
232 for (l = 0; l < limit; l++) { 232 for (l = 0; l < limit; l++) {
233 tcep[l] = proto_tce | (rpn & TCE_RPN_MASK) << TCE_RPN_SHIFT; 233 tcep[l] = cpu_to_be64(proto_tce | (rpn & TCE_RPN_MASK) << TCE_RPN_SHIFT);
234 rpn++; 234 rpn++;
235 } 235 }
236 236
@@ -329,16 +329,16 @@ struct direct_window {
329 329
330/* Dynamic DMA Window support */ 330/* Dynamic DMA Window support */
331struct ddw_query_response { 331struct ddw_query_response {
332 u32 windows_available; 332 __be32 windows_available;
333 u32 largest_available_block; 333 __be32 largest_available_block;
334 u32 page_size; 334 __be32 page_size;
335 u32 migration_capable; 335 __be32 migration_capable;
336}; 336};
337 337
338struct ddw_create_response { 338struct ddw_create_response {
339 u32 liobn; 339 __be32 liobn;
340 u32 addr_hi; 340 __be32 addr_hi;
341 u32 addr_lo; 341 __be32 addr_lo;
342}; 342};
343 343
344static LIST_HEAD(direct_window_list); 344static LIST_HEAD(direct_window_list);
@@ -392,7 +392,8 @@ static int tce_setrange_multi_pSeriesLP(unsigned long start_pfn,
392 unsigned long num_pfn, const void *arg) 392 unsigned long num_pfn, const void *arg)
393{ 393{
394 const struct dynamic_dma_window_prop *maprange = arg; 394 const struct dynamic_dma_window_prop *maprange = arg;
395 u64 *tcep, tce_size, num_tce, dma_offset, next, proto_tce, liobn; 395 u64 tce_size, num_tce, dma_offset, next, proto_tce, liobn;
396 __be64 *tcep;
396 u32 tce_shift; 397 u32 tce_shift;
397 u64 rc = 0; 398 u64 rc = 0;
398 long l, limit; 399 long l, limit;
@@ -401,7 +402,7 @@ static int tce_setrange_multi_pSeriesLP(unsigned long start_pfn,
401 tcep = __get_cpu_var(tce_page); 402 tcep = __get_cpu_var(tce_page);
402 403
403 if (!tcep) { 404 if (!tcep) {
404 tcep = (u64 *)__get_free_page(GFP_ATOMIC); 405 tcep = (__be64 *)__get_free_page(GFP_ATOMIC);
405 if (!tcep) { 406 if (!tcep) {
406 local_irq_enable(); 407 local_irq_enable();
407 return -ENOMEM; 408 return -ENOMEM;
@@ -435,7 +436,7 @@ static int tce_setrange_multi_pSeriesLP(unsigned long start_pfn,
435 dma_offset = next + be64_to_cpu(maprange->dma_base); 436 dma_offset = next + be64_to_cpu(maprange->dma_base);
436 437
437 for (l = 0; l < limit; l++) { 438 for (l = 0; l < limit; l++) {
438 tcep[l] = proto_tce | next; 439 tcep[l] = cpu_to_be64(proto_tce | next);
439 next += tce_size; 440 next += tce_size;
440 } 441 }
441 442
@@ -780,7 +781,7 @@ static u64 find_existing_ddw(struct device_node *pdn)
780 list_for_each_entry(window, &direct_window_list, list) { 781 list_for_each_entry(window, &direct_window_list, list) {
781 if (window->device == pdn) { 782 if (window->device == pdn) {
782 direct64 = window->prop; 783 direct64 = window->prop;
783 dma_addr = direct64->dma_base; 784 dma_addr = be64_to_cpu(direct64->dma_base);
784 break; 785 break;
785 } 786 }
786 } 787 }
@@ -1045,11 +1046,11 @@ static u64 enable_ddw(struct pci_dev *dev, struct device_node *pdn)
1045 dev_dbg(&dev->dev, "no free dynamic windows"); 1046 dev_dbg(&dev->dev, "no free dynamic windows");
1046 goto out_restore_window; 1047 goto out_restore_window;
1047 } 1048 }
1048 if (query.page_size & 4) { 1049 if (be32_to_cpu(query.page_size) & 4) {
1049 page_shift = 24; /* 16MB */ 1050 page_shift = 24; /* 16MB */
1050 } else if (query.page_size & 2) { 1051 } else if (be32_to_cpu(query.page_size) & 2) {
1051 page_shift = 16; /* 64kB */ 1052 page_shift = 16; /* 64kB */
1052 } else if (query.page_size & 1) { 1053 } else if (be32_to_cpu(query.page_size) & 1) {
1053 page_shift = 12; /* 4kB */ 1054 page_shift = 12; /* 4kB */
1054 } else { 1055 } else {
1055 dev_dbg(&dev->dev, "no supported direct page size in mask %x", 1056 dev_dbg(&dev->dev, "no supported direct page size in mask %x",
@@ -1059,7 +1060,7 @@ static u64 enable_ddw(struct pci_dev *dev, struct device_node *pdn)
1059 /* verify the window * number of ptes will map the partition */ 1060 /* verify the window * number of ptes will map the partition */
1060 /* check largest block * page size > max memory hotplug addr */ 1061 /* check largest block * page size > max memory hotplug addr */
1061 max_addr = memory_hotplug_max(); 1062 max_addr = memory_hotplug_max();
1062 if (query.largest_available_block < (max_addr >> page_shift)) { 1063 if (be32_to_cpu(query.largest_available_block) < (max_addr >> page_shift)) {
1063 dev_dbg(&dev->dev, "can't map partiton max 0x%llx with %u " 1064 dev_dbg(&dev->dev, "can't map partiton max 0x%llx with %u "
1064 "%llu-sized pages\n", max_addr, query.largest_available_block, 1065 "%llu-sized pages\n", max_addr, query.largest_available_block,
1065 1ULL << page_shift); 1066 1ULL << page_shift);
@@ -1085,7 +1086,7 @@ static u64 enable_ddw(struct pci_dev *dev, struct device_node *pdn)
1085 if (ret != 0) 1086 if (ret != 0)
1086 goto out_free_prop; 1087 goto out_free_prop;
1087 1088
1088 ddwprop->liobn = cpu_to_be32(create.liobn); 1089 ddwprop->liobn = create.liobn;
1089 ddwprop->dma_base = cpu_to_be64(of_read_number(&create.addr_hi, 2)); 1090 ddwprop->dma_base = cpu_to_be64(of_read_number(&create.addr_hi, 2));
1090 ddwprop->tce_shift = cpu_to_be32(page_shift); 1091 ddwprop->tce_shift = cpu_to_be32(page_shift);
1091 ddwprop->window_shift = cpu_to_be32(len); 1092 ddwprop->window_shift = cpu_to_be32(len);
diff --git a/arch/powerpc/platforms/pseries/nvram.c b/arch/powerpc/platforms/pseries/nvram.c
index d276cd3edd8f..057fc894be51 100644
--- a/arch/powerpc/platforms/pseries/nvram.c
+++ b/arch/powerpc/platforms/pseries/nvram.c
@@ -429,9 +429,6 @@ static int __init pseries_nvram_init_os_partition(struct nvram_os_partition
429 loff_t p; 429 loff_t p;
430 int size; 430 int size;
431 431
432 /* Scan nvram for partitions */
433 nvram_scan_partitions();
434
435 /* Look for ours */ 432 /* Look for ours */
436 p = nvram_find_partition(part->name, NVRAM_SIG_OS, &size); 433 p = nvram_find_partition(part->name, NVRAM_SIG_OS, &size);
437 434
@@ -795,6 +792,9 @@ static int __init pseries_nvram_init_log_partitions(void)
795{ 792{
796 int rc; 793 int rc;
797 794
795 /* Scan nvram for partitions */
796 nvram_scan_partitions();
797
798 rc = pseries_nvram_init_os_partition(&rtas_log_partition); 798 rc = pseries_nvram_init_os_partition(&rtas_log_partition);
799 nvram_init_oops_partition(rc == 0); 799 nvram_init_oops_partition(rc == 0);
800 return 0; 800 return 0;
@@ -804,7 +804,7 @@ machine_arch_initcall(pseries, pseries_nvram_init_log_partitions);
804int __init pSeries_nvram_init(void) 804int __init pSeries_nvram_init(void)
805{ 805{
806 struct device_node *nvram; 806 struct device_node *nvram;
807 const unsigned int *nbytes_p; 807 const __be32 *nbytes_p;
808 unsigned int proplen; 808 unsigned int proplen;
809 809
810 nvram = of_find_node_by_type(NULL, "nvram"); 810 nvram = of_find_node_by_type(NULL, "nvram");
@@ -817,7 +817,7 @@ int __init pSeries_nvram_init(void)
817 return -EIO; 817 return -EIO;
818 } 818 }
819 819
820 nvram_size = *nbytes_p; 820 nvram_size = be32_to_cpup(nbytes_p);
821 821
822 nvram_fetch = rtas_token("nvram-fetch"); 822 nvram_fetch = rtas_token("nvram-fetch");
823 nvram_store = rtas_token("nvram-store"); 823 nvram_store = rtas_token("nvram-store");
diff --git a/arch/powerpc/platforms/pseries/rng.c b/arch/powerpc/platforms/pseries/rng.c
new file mode 100644
index 000000000000..a702f1c08242
--- /dev/null
+++ b/arch/powerpc/platforms/pseries/rng.c
@@ -0,0 +1,44 @@
1/*
2 * Copyright 2013, Michael Ellerman, IBM Corporation.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 */
9
10#define pr_fmt(fmt) "pseries-rng: " fmt
11
12#include <linux/kernel.h>
13#include <linux/of.h>
14#include <asm/archrandom.h>
15#include <asm/machdep.h>
16
17
18static int pseries_get_random_long(unsigned long *v)
19{
20 unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
21
22 if (plpar_hcall(H_RANDOM, retbuf) == H_SUCCESS) {
23 *v = retbuf[0];
24 return 1;
25 }
26
27 return 0;
28}
29
30static __init int rng_init(void)
31{
32 struct device_node *dn;
33
34 dn = of_find_compatible_node(NULL, NULL, "ibm,random");
35 if (!dn)
36 return -ENODEV;
37
38 pr_info("Registering arch random hook.\n");
39
40 ppc_md.get_random_long = pseries_get_random_long;
41
42 return 0;
43}
44subsys_initcall(rng_init);
diff --git a/arch/powerpc/platforms/wsp/scom_smp.c b/arch/powerpc/platforms/wsp/scom_smp.c
index b56b70aeb497..268bc899c1f7 100644
--- a/arch/powerpc/platforms/wsp/scom_smp.c
+++ b/arch/powerpc/platforms/wsp/scom_smp.c
@@ -116,7 +116,14 @@ static int a2_scom_ram(scom_map_t scom, int thread, u32 insn, int extmask)
116 116
117 scom_write(scom, SCOM_RAMIC, cmd); 117 scom_write(scom, SCOM_RAMIC, cmd);
118 118
119 while (!((val = scom_read(scom, SCOM_RAMC)) & mask)) { 119 for (;;) {
120 if (scom_read(scom, SCOM_RAMC, &val) != 0) {
121 pr_err("SCOM error on instruction 0x%08x, thread %d\n",
122 insn, thread);
123 return -1;
124 }
125 if (val & mask)
126 break;
120 pr_devel("Waiting on RAMC = 0x%llx\n", val); 127 pr_devel("Waiting on RAMC = 0x%llx\n", val);
121 if (++n == 3) { 128 if (++n == 3) {
122 pr_err("RAMC timeout on instruction 0x%08x, thread %d\n", 129 pr_err("RAMC timeout on instruction 0x%08x, thread %d\n",
@@ -151,9 +158,7 @@ static int a2_scom_getgpr(scom_map_t scom, int thread, int gpr, int alt,
151 if (rc) 158 if (rc)
152 return rc; 159 return rc;
153 160
154 *out_gpr = scom_read(scom, SCOM_RAMD); 161 return scom_read(scom, SCOM_RAMD, out_gpr);
155
156 return 0;
157} 162}
158 163
159static int a2_scom_getspr(scom_map_t scom, int thread, int spr, u64 *out_spr) 164static int a2_scom_getspr(scom_map_t scom, int thread, int spr, u64 *out_spr)
@@ -353,7 +358,10 @@ int a2_scom_startup_cpu(unsigned int lcpu, int thr_idx, struct device_node *np)
353 358
354 pr_devel("Bringing up CPU%d using SCOM...\n", lcpu); 359 pr_devel("Bringing up CPU%d using SCOM...\n", lcpu);
355 360
356 pccr0 = scom_read(scom, SCOM_PCCR0); 361 if (scom_read(scom, SCOM_PCCR0, &pccr0) != 0) {
362 printk(KERN_ERR "XSCOM failure readng PCCR0 on CPU%d\n", lcpu);
363 return -1;
364 }
357 scom_write(scom, SCOM_PCCR0, pccr0 | SCOM_PCCR0_ENABLE_DEBUG | 365 scom_write(scom, SCOM_PCCR0, pccr0 | SCOM_PCCR0_ENABLE_DEBUG |
358 SCOM_PCCR0_ENABLE_RAM); 366 SCOM_PCCR0_ENABLE_RAM);
359 367
diff --git a/arch/powerpc/platforms/wsp/scom_wsp.c b/arch/powerpc/platforms/wsp/scom_wsp.c
index 4052e2259f30..8928507affea 100644
--- a/arch/powerpc/platforms/wsp/scom_wsp.c
+++ b/arch/powerpc/platforms/wsp/scom_wsp.c
@@ -50,18 +50,22 @@ static void wsp_scom_unmap(scom_map_t map)
50 iounmap((void *)map); 50 iounmap((void *)map);
51} 51}
52 52
53static u64 wsp_scom_read(scom_map_t map, u32 reg) 53static int wsp_scom_read(scom_map_t map, u64 reg, u64 *value)
54{ 54{
55 u64 __iomem *addr = (u64 __iomem *)map; 55 u64 __iomem *addr = (u64 __iomem *)map;
56 56
57 return in_be64(addr + reg); 57 *value = in_be64(addr + reg);
58
59 return 0;
58} 60}
59 61
60static void wsp_scom_write(scom_map_t map, u32 reg, u64 value) 62static int wsp_scom_write(scom_map_t map, u64 reg, u64 value)
61{ 63{
62 u64 __iomem *addr = (u64 __iomem *)map; 64 u64 __iomem *addr = (u64 __iomem *)map;
63 65
64 return out_be64(addr + reg, value); 66 out_be64(addr + reg, value);
67
68 return 0;
65} 69}
66 70
67static const struct scom_controller wsp_scom_controller = { 71static const struct scom_controller wsp_scom_controller = {
diff --git a/arch/powerpc/platforms/wsp/wsp.c b/arch/powerpc/platforms/wsp/wsp.c
index d25cc96c21b8..ddb6efe88914 100644
--- a/arch/powerpc/platforms/wsp/wsp.c
+++ b/arch/powerpc/platforms/wsp/wsp.c
@@ -89,6 +89,7 @@ void wsp_halt(void)
89 struct device_node *dn; 89 struct device_node *dn;
90 struct device_node *mine; 90 struct device_node *mine;
91 struct device_node *me; 91 struct device_node *me;
92 int rc;
92 93
93 me = of_get_cpu_node(smp_processor_id(), NULL); 94 me = of_get_cpu_node(smp_processor_id(), NULL);
94 mine = scom_find_parent(me); 95 mine = scom_find_parent(me);
@@ -101,15 +102,15 @@ void wsp_halt(void)
101 102
102 /* read-modify-write it so the HW probe does not get 103 /* read-modify-write it so the HW probe does not get
103 * confused */ 104 * confused */
104 val = scom_read(m, 0); 105 rc = scom_read(m, 0, &val);
105 val |= 1; 106 if (rc == 0)
106 scom_write(m, 0, val); 107 scom_write(m, 0, val | 1);
107 scom_unmap(m); 108 scom_unmap(m);
108 } 109 }
109 m = scom_map(mine, 0, 1); 110 m = scom_map(mine, 0, 1);
110 val = scom_read(m, 0); 111 rc = scom_read(m, 0, &val);
111 val |= 1; 112 if (rc == 0)
112 scom_write(m, 0, val); 113 scom_write(m, 0, val | 1);
113 /* should never return */ 114 /* should never return */
114 scom_unmap(m); 115 scom_unmap(m);
115} 116}
diff --git a/arch/powerpc/sysdev/Kconfig b/arch/powerpc/sysdev/Kconfig
index ab4cb5476472..13ec968be4c7 100644
--- a/arch/powerpc/sysdev/Kconfig
+++ b/arch/powerpc/sysdev/Kconfig
@@ -28,7 +28,7 @@ config PPC_SCOM
28 28
29config SCOM_DEBUGFS 29config SCOM_DEBUGFS
30 bool "Expose SCOM controllers via debugfs" 30 bool "Expose SCOM controllers via debugfs"
31 depends on PPC_SCOM 31 depends on PPC_SCOM && DEBUG_FS
32 default n 32 default n
33 33
34config GE_FPGA 34config GE_FPGA
diff --git a/arch/powerpc/sysdev/fsl_pci.c b/arch/powerpc/sysdev/fsl_pci.c
index ccfb50ddfe38..21039634d1d0 100644
--- a/arch/powerpc/sysdev/fsl_pci.c
+++ b/arch/powerpc/sysdev/fsl_pci.c
@@ -40,7 +40,7 @@
40 40
41static int fsl_pcie_bus_fixup, is_mpc83xx_pci; 41static int fsl_pcie_bus_fixup, is_mpc83xx_pci;
42 42
43static void quirk_fsl_pcie_header(struct pci_dev *dev) 43static void quirk_fsl_pcie_early(struct pci_dev *dev)
44{ 44{
45 u8 hdr_type; 45 u8 hdr_type;
46 46
@@ -562,7 +562,8 @@ no_bridge:
562} 562}
563#endif /* CONFIG_FSL_SOC_BOOKE || CONFIG_PPC_86xx */ 563#endif /* CONFIG_FSL_SOC_BOOKE || CONFIG_PPC_86xx */
564 564
565DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_FREESCALE, PCI_ANY_ID, quirk_fsl_pcie_header); 565DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_FREESCALE, PCI_ANY_ID,
566 quirk_fsl_pcie_early);
566 567
567#if defined(CONFIG_PPC_83xx) || defined(CONFIG_PPC_MPC512x) 568#if defined(CONFIG_PPC_83xx) || defined(CONFIG_PPC_MPC512x)
568struct mpc83xx_pcie_priv { 569struct mpc83xx_pcie_priv {
diff --git a/arch/powerpc/sysdev/fsl_soc.h b/arch/powerpc/sysdev/fsl_soc.h
index c6d00736f07f..4c5a19ef4f0b 100644
--- a/arch/powerpc/sysdev/fsl_soc.h
+++ b/arch/powerpc/sysdev/fsl_soc.h
@@ -21,8 +21,6 @@ struct device_node;
21 21
22extern void fsl_rstcr_restart(char *cmd); 22extern void fsl_rstcr_restart(char *cmd);
23 23
24#if defined(CONFIG_FB_FSL_DIU) || defined(CONFIG_FB_FSL_DIU_MODULE)
25
26/* The different ports that the DIU can be connected to */ 24/* The different ports that the DIU can be connected to */
27enum fsl_diu_monitor_port { 25enum fsl_diu_monitor_port {
28 FSL_DIU_PORT_DVI, /* DVI */ 26 FSL_DIU_PORT_DVI, /* DVI */
@@ -43,7 +41,6 @@ struct platform_diu_data_ops {
43}; 41};
44 42
45extern struct platform_diu_data_ops diu_ops; 43extern struct platform_diu_data_ops diu_ops;
46#endif
47 44
48void fsl_hv_restart(char *cmd); 45void fsl_hv_restart(char *cmd);
49void fsl_hv_halt(void); 46void fsl_hv_halt(void);
diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
index 1be54faf60dd..bdcb8588e492 100644
--- a/arch/powerpc/sysdev/mpic.c
+++ b/arch/powerpc/sysdev/mpic.c
@@ -1088,8 +1088,14 @@ static int mpic_host_map(struct irq_domain *h, unsigned int virq,
1088 * is done here. 1088 * is done here.
1089 */ 1089 */
1090 if (!mpic_is_ipi(mpic, hw) && (mpic->flags & MPIC_NO_RESET)) { 1090 if (!mpic_is_ipi(mpic, hw) && (mpic->flags & MPIC_NO_RESET)) {
1091 int cpu;
1092
1093 preempt_disable();
1094 cpu = mpic_processor_id(mpic);
1095 preempt_enable();
1096
1091 mpic_set_vector(virq, hw); 1097 mpic_set_vector(virq, hw);
1092 mpic_set_destination(virq, mpic_processor_id(mpic)); 1098 mpic_set_destination(virq, cpu);
1093 mpic_irq_set_priority(virq, 8); 1099 mpic_irq_set_priority(virq, 8);
1094 } 1100 }
1095 1101
diff --git a/arch/powerpc/sysdev/mv64x60_dev.c b/arch/powerpc/sysdev/mv64x60_dev.c
index 4a25c26f0bf4..a3a8fad8537d 100644
--- a/arch/powerpc/sysdev/mv64x60_dev.c
+++ b/arch/powerpc/sysdev/mv64x60_dev.c
@@ -228,7 +228,7 @@ static struct platform_device * __init mv64x60_eth_register_shared_pdev(
228 228
229 if (id == 0) { 229 if (id == 0) {
230 pdev = platform_device_register_simple("orion-mdio", -1, &r[1], 1); 230 pdev = platform_device_register_simple("orion-mdio", -1, &r[1], 1);
231 if (!pdev) 231 if (IS_ERR(pdev))
232 return pdev; 232 return pdev;
233 } 233 }
234 234
diff --git a/arch/powerpc/sysdev/scom.c b/arch/powerpc/sysdev/scom.c
index 9193e12df695..6f5a8d177c42 100644
--- a/arch/powerpc/sysdev/scom.c
+++ b/arch/powerpc/sysdev/scom.c
@@ -25,6 +25,7 @@
25#include <asm/debug.h> 25#include <asm/debug.h>
26#include <asm/prom.h> 26#include <asm/prom.h>
27#include <asm/scom.h> 27#include <asm/scom.h>
28#include <asm/uaccess.h>
28 29
29const struct scom_controller *scom_controller; 30const struct scom_controller *scom_controller;
30EXPORT_SYMBOL_GPL(scom_controller); 31EXPORT_SYMBOL_GPL(scom_controller);
@@ -53,7 +54,7 @@ scom_map_t scom_map_device(struct device_node *dev, int index)
53{ 54{
54 struct device_node *parent; 55 struct device_node *parent;
55 unsigned int cells, size; 56 unsigned int cells, size;
56 const u32 *prop; 57 const __be32 *prop, *sprop;
57 u64 reg, cnt; 58 u64 reg, cnt;
58 scom_map_t ret; 59 scom_map_t ret;
59 60
@@ -62,12 +63,24 @@ scom_map_t scom_map_device(struct device_node *dev, int index)
62 if (parent == NULL) 63 if (parent == NULL)
63 return 0; 64 return 0;
64 65
65 prop = of_get_property(parent, "#scom-cells", NULL); 66 /*
66 cells = prop ? *prop : 1; 67 * We support "scom-reg" properties for adding scom registers
67 68 * to a random device-tree node with an explicit scom-parent
69 *
70 * We also support the simple "reg" property if the device is
71 * a direct child of a scom controller.
72 *
73 * In case both exist, "scom-reg" takes precedence.
74 */
68 prop = of_get_property(dev, "scom-reg", &size); 75 prop = of_get_property(dev, "scom-reg", &size);
76 sprop = of_get_property(parent, "#scom-cells", NULL);
77 if (!prop && parent == dev->parent) {
78 prop = of_get_property(dev, "reg", &size);
79 sprop = of_get_property(parent, "#address-cells", NULL);
80 }
69 if (!prop) 81 if (!prop)
70 return 0; 82 return NULL;
83 cells = sprop ? be32_to_cpup(sprop) : 1;
71 size >>= 2; 84 size >>= 2;
72 85
73 if (index >= (size / (2*cells))) 86 if (index >= (size / (2*cells)))
@@ -86,62 +99,89 @@ EXPORT_SYMBOL_GPL(scom_map_device);
86#ifdef CONFIG_SCOM_DEBUGFS 99#ifdef CONFIG_SCOM_DEBUGFS
87struct scom_debug_entry { 100struct scom_debug_entry {
88 struct device_node *dn; 101 struct device_node *dn;
89 unsigned long addr; 102 struct debugfs_blob_wrapper path;
90 scom_map_t map; 103 char name[16];
91 spinlock_t lock;
92 char name[8];
93 struct debugfs_blob_wrapper blob;
94}; 104};
95 105
96static int scom_addr_set(void *data, u64 val) 106static ssize_t scom_debug_read(struct file *filp, char __user *ubuf,
107 size_t count, loff_t *ppos)
97{ 108{
98 struct scom_debug_entry *ent = data; 109 struct scom_debug_entry *ent = filp->private_data;
99 110 u64 __user *ubuf64 = (u64 __user *)ubuf;
100 ent->addr = 0; 111 loff_t off = *ppos;
101 scom_unmap(ent->map); 112 ssize_t done = 0;
102 113 u64 reg, reg_cnt, val;
103 ent->map = scom_map(ent->dn, val, 1); 114 scom_map_t map;
104 if (scom_map_ok(ent->map)) 115 int rc;
105 ent->addr = val; 116
106 else 117 if (off < 0 || (off & 7) || (count & 7))
107 return -EFAULT; 118 return -EINVAL;
108 119 reg = off >> 3;
109 return 0; 120 reg_cnt = count >> 3;
110} 121
111 122 map = scom_map(ent->dn, reg, reg_cnt);
112static int scom_addr_get(void *data, u64 *val) 123 if (!scom_map_ok(map))
113{ 124 return -ENXIO;
114 struct scom_debug_entry *ent = data; 125
115 *val = ent->addr; 126 for (reg = 0; reg < reg_cnt; reg++) {
116 return 0; 127 rc = scom_read(map, reg, &val);
128 if (!rc)
129 rc = put_user(val, ubuf64);
130 if (rc) {
131 if (!done)
132 done = rc;
133 break;
134 }
135 ubuf64++;
136 *ppos += 8;
137 done += 8;
138 }
139 scom_unmap(map);
140 return done;
117} 141}
118DEFINE_SIMPLE_ATTRIBUTE(scom_addr_fops, scom_addr_get, scom_addr_set,
119 "0x%llx\n");
120 142
121static int scom_val_set(void *data, u64 val) 143static ssize_t scom_debug_write(struct file* filp, const char __user *ubuf,
144 size_t count, loff_t *ppos)
122{ 145{
123 struct scom_debug_entry *ent = data; 146 struct scom_debug_entry *ent = filp->private_data;
124 147 u64 __user *ubuf64 = (u64 __user *)ubuf;
125 if (!scom_map_ok(ent->map)) 148 loff_t off = *ppos;
126 return -EFAULT; 149 ssize_t done = 0;
127 150 u64 reg, reg_cnt, val;
128 scom_write(ent->map, 0, val); 151 scom_map_t map;
129 152 int rc;
130 return 0; 153
154 if (off < 0 || (off & 7) || (count & 7))
155 return -EINVAL;
156 reg = off >> 3;
157 reg_cnt = count >> 3;
158
159 map = scom_map(ent->dn, reg, reg_cnt);
160 if (!scom_map_ok(map))
161 return -ENXIO;
162
163 for (reg = 0; reg < reg_cnt; reg++) {
164 rc = get_user(val, ubuf64);
165 if (!rc)
166 rc = scom_write(map, reg, val);
167 if (rc) {
168 if (!done)
169 done = rc;
170 break;
171 }
172 ubuf64++;
173 done += 8;
174 }
175 scom_unmap(map);
176 return done;
131} 177}
132 178
133static int scom_val_get(void *data, u64 *val) 179static const struct file_operations scom_debug_fops = {
134{ 180 .read = scom_debug_read,
135 struct scom_debug_entry *ent = data; 181 .write = scom_debug_write,
136 182 .open = simple_open,
137 if (!scom_map_ok(ent->map)) 183 .llseek = default_llseek,
138 return -EFAULT; 184};
139
140 *val = scom_read(ent->map, 0);
141 return 0;
142}
143DEFINE_SIMPLE_ATTRIBUTE(scom_val_fops, scom_val_get, scom_val_set,
144 "0x%llx\n");
145 185
146static int scom_debug_init_one(struct dentry *root, struct device_node *dn, 186static int scom_debug_init_one(struct dentry *root, struct device_node *dn,
147 int i) 187 int i)
@@ -154,11 +194,9 @@ static int scom_debug_init_one(struct dentry *root, struct device_node *dn,
154 return -ENOMEM; 194 return -ENOMEM;
155 195
156 ent->dn = of_node_get(dn); 196 ent->dn = of_node_get(dn);
157 ent->map = SCOM_MAP_INVALID; 197 snprintf(ent->name, 16, "%08x", i);
158 spin_lock_init(&ent->lock); 198 ent->path.data = (void*) dn->full_name;
159 snprintf(ent->name, 8, "scom%d", i); 199 ent->path.size = strlen(dn->full_name);
160 ent->blob.data = (void*) dn->full_name;
161 ent->blob.size = strlen(dn->full_name);
162 200
163 dir = debugfs_create_dir(ent->name, root); 201 dir = debugfs_create_dir(ent->name, root);
164 if (!dir) { 202 if (!dir) {
@@ -167,9 +205,8 @@ static int scom_debug_init_one(struct dentry *root, struct device_node *dn,
167 return -1; 205 return -1;
168 } 206 }
169 207
170 debugfs_create_file("addr", 0600, dir, ent, &scom_addr_fops); 208 debugfs_create_blob("devspec", 0400, dir, &ent->path);
171 debugfs_create_file("value", 0600, dir, ent, &scom_val_fops); 209 debugfs_create_file("access", 0600, dir, ent, &scom_debug_fops);
172 debugfs_create_blob("path", 0400, dir, &ent->blob);
173 210
174 return 0; 211 return 0;
175} 212}
@@ -185,8 +222,13 @@ static int scom_debug_init(void)
185 return -1; 222 return -1;
186 223
187 i = rc = 0; 224 i = rc = 0;
188 for_each_node_with_property(dn, "scom-controller") 225 for_each_node_with_property(dn, "scom-controller") {
189 rc |= scom_debug_init_one(root, dn, i++); 226 int id = of_get_ibm_chip_id(dn);
227 if (id == -1)
228 id = i;
229 rc |= scom_debug_init_one(root, dn, id);
230 i++;
231 }
190 232
191 return rc; 233 return rc;
192} 234}
diff --git a/arch/powerpc/sysdev/xics/ics-opal.c b/arch/powerpc/sysdev/xics/ics-opal.c
index 39d72212655e..3c6ee1b64e5d 100644
--- a/arch/powerpc/sysdev/xics/ics-opal.c
+++ b/arch/powerpc/sysdev/xics/ics-opal.c
@@ -112,6 +112,7 @@ static int ics_opal_set_affinity(struct irq_data *d,
112 bool force) 112 bool force)
113{ 113{
114 unsigned int hw_irq = (unsigned int)irqd_to_hwirq(d); 114 unsigned int hw_irq = (unsigned int)irqd_to_hwirq(d);
115 __be16 oserver;
115 int16_t server; 116 int16_t server;
116 int8_t priority; 117 int8_t priority;
117 int64_t rc; 118 int64_t rc;
@@ -120,13 +121,13 @@ static int ics_opal_set_affinity(struct irq_data *d,
120 if (hw_irq == XICS_IPI || hw_irq == XICS_IRQ_SPURIOUS) 121 if (hw_irq == XICS_IPI || hw_irq == XICS_IRQ_SPURIOUS)
121 return -1; 122 return -1;
122 123
123 rc = opal_get_xive(hw_irq, &server, &priority); 124 rc = opal_get_xive(hw_irq, &oserver, &priority);
124 if (rc != OPAL_SUCCESS) { 125 if (rc != OPAL_SUCCESS) {
125 pr_err("%s: opal_set_xive(irq=%d [hw 0x%x] server=%x)" 126 pr_err("%s: opal_get_xive(irq=%d [hw 0x%x]) error %lld\n",
126 " error %lld\n", 127 __func__, d->irq, hw_irq, rc);
127 __func__, d->irq, hw_irq, server, rc);
128 return -1; 128 return -1;
129 } 129 }
130 server = be16_to_cpu(oserver);
130 131
131 wanted_server = xics_get_irq_server(d->irq, cpumask, 1); 132 wanted_server = xics_get_irq_server(d->irq, cpumask, 1);
132 if (wanted_server < 0) { 133 if (wanted_server < 0) {
@@ -181,7 +182,7 @@ static int ics_opal_map(struct ics *ics, unsigned int virq)
181{ 182{
182 unsigned int hw_irq = (unsigned int)virq_to_hw(virq); 183 unsigned int hw_irq = (unsigned int)virq_to_hw(virq);
183 int64_t rc; 184 int64_t rc;
184 int16_t server; 185 __be16 server;
185 int8_t priority; 186 int8_t priority;
186 187
187 if (WARN_ON(hw_irq == XICS_IPI || hw_irq == XICS_IRQ_SPURIOUS)) 188 if (WARN_ON(hw_irq == XICS_IPI || hw_irq == XICS_IRQ_SPURIOUS))
@@ -201,7 +202,7 @@ static int ics_opal_map(struct ics *ics, unsigned int virq)
201static void ics_opal_mask_unknown(struct ics *ics, unsigned long vec) 202static void ics_opal_mask_unknown(struct ics *ics, unsigned long vec)
202{ 203{
203 int64_t rc; 204 int64_t rc;
204 int16_t server; 205 __be16 server;
205 int8_t priority; 206 int8_t priority;
206 207
207 /* Check if HAL knows about this interrupt */ 208 /* Check if HAL knows about this interrupt */
@@ -215,14 +216,14 @@ static void ics_opal_mask_unknown(struct ics *ics, unsigned long vec)
215static long ics_opal_get_server(struct ics *ics, unsigned long vec) 216static long ics_opal_get_server(struct ics *ics, unsigned long vec)
216{ 217{
217 int64_t rc; 218 int64_t rc;
218 int16_t server; 219 __be16 server;
219 int8_t priority; 220 int8_t priority;
220 221
221 /* Check if HAL knows about this interrupt */ 222 /* Check if HAL knows about this interrupt */
222 rc = opal_get_xive(vec, &server, &priority); 223 rc = opal_get_xive(vec, &server, &priority);
223 if (rc != OPAL_SUCCESS) 224 if (rc != OPAL_SUCCESS)
224 return -1; 225 return -1;
225 return ics_opal_unmangle_server(server); 226 return ics_opal_unmangle_server(be16_to_cpu(server));
226} 227}
227 228
228int __init ics_opal_init(void) 229int __init ics_opal_init(void)
diff --git a/drivers/char/hw_random/Kconfig b/drivers/char/hw_random/Kconfig
index 0aa9d91daef5..c206de2951f2 100644
--- a/drivers/char/hw_random/Kconfig
+++ b/drivers/char/hw_random/Kconfig
@@ -290,6 +290,19 @@ config HW_RANDOM_PSERIES
290 290
291 If unsure, say Y. 291 If unsure, say Y.
292 292
293config HW_RANDOM_POWERNV
294 tristate "PowerNV Random Number Generator support"
295 depends on HW_RANDOM && PPC_POWERNV
296 default HW_RANDOM
297 ---help---
298 This is the driver for Random Number Generator hardware found
299 in POWER7+ and above machines for PowerNV platform.
300
301 To compile this driver as a module, choose M here: the
302 module will be called powernv-rng.
303
304 If unsure, say Y.
305
293config HW_RANDOM_EXYNOS 306config HW_RANDOM_EXYNOS
294 tristate "EXYNOS HW random number generator support" 307 tristate "EXYNOS HW random number generator support"
295 depends on HW_RANDOM && HAS_IOMEM && HAVE_CLK 308 depends on HW_RANDOM && HAS_IOMEM && HAVE_CLK
diff --git a/drivers/char/hw_random/Makefile b/drivers/char/hw_random/Makefile
index bed467c9300e..d7d2435ff7fa 100644
--- a/drivers/char/hw_random/Makefile
+++ b/drivers/char/hw_random/Makefile
@@ -24,6 +24,7 @@ obj-$(CONFIG_HW_RANDOM_NOMADIK) += nomadik-rng.o
24obj-$(CONFIG_HW_RANDOM_PICOXCELL) += picoxcell-rng.o 24obj-$(CONFIG_HW_RANDOM_PICOXCELL) += picoxcell-rng.o
25obj-$(CONFIG_HW_RANDOM_PPC4XX) += ppc4xx-rng.o 25obj-$(CONFIG_HW_RANDOM_PPC4XX) += ppc4xx-rng.o
26obj-$(CONFIG_HW_RANDOM_PSERIES) += pseries-rng.o 26obj-$(CONFIG_HW_RANDOM_PSERIES) += pseries-rng.o
27obj-$(CONFIG_HW_RANDOM_POWERNV) += powernv-rng.o
27obj-$(CONFIG_HW_RANDOM_EXYNOS) += exynos-rng.o 28obj-$(CONFIG_HW_RANDOM_EXYNOS) += exynos-rng.o
28obj-$(CONFIG_HW_RANDOM_TPM) += tpm-rng.o 29obj-$(CONFIG_HW_RANDOM_TPM) += tpm-rng.o
29obj-$(CONFIG_HW_RANDOM_BCM2835) += bcm2835-rng.o 30obj-$(CONFIG_HW_RANDOM_BCM2835) += bcm2835-rng.o
diff --git a/drivers/char/hw_random/powernv-rng.c b/drivers/char/hw_random/powernv-rng.c
new file mode 100644
index 000000000000..3f4f63204560
--- /dev/null
+++ b/drivers/char/hw_random/powernv-rng.c
@@ -0,0 +1,81 @@
1/*
2 * Copyright 2013 Michael Ellerman, Guo Chao, IBM Corp.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 */
9
10#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
11
12#include <linux/module.h>
13#include <linux/kernel.h>
14#include <linux/platform_device.h>
15#include <linux/random.h>
16#include <linux/hw_random.h>
17
18static int powernv_rng_read(struct hwrng *rng, void *data, size_t max, bool wait)
19{
20 unsigned long *buf;
21 int i, len;
22
23 /* We rely on rng_buffer_size() being >= sizeof(unsigned long) */
24 len = max / sizeof(unsigned long);
25
26 buf = (unsigned long *)data;
27
28 for (i = 0; i < len; i++)
29 powernv_get_random_long(buf++);
30
31 return len * sizeof(unsigned long);
32}
33
34static struct hwrng powernv_hwrng = {
35 .name = "powernv-rng",
36 .read = powernv_rng_read,
37};
38
39static int powernv_rng_remove(struct platform_device *pdev)
40{
41 hwrng_unregister(&powernv_hwrng);
42
43 return 0;
44}
45
46static int powernv_rng_probe(struct platform_device *pdev)
47{
48 int rc;
49
50 rc = hwrng_register(&powernv_hwrng);
51 if (rc) {
52 /* We only register one device, ignore any others */
53 if (rc == -EEXIST)
54 rc = -ENODEV;
55
56 return rc;
57 }
58
59 pr_info("Registered powernv hwrng.\n");
60
61 return 0;
62}
63
64static struct of_device_id powernv_rng_match[] = {
65 { .compatible = "ibm,power-rng",},
66 {},
67};
68MODULE_DEVICE_TABLE(of, powernv_rng_match);
69
70static struct platform_driver powernv_rng_driver = {
71 .driver = {
72 .name = "powernv_rng",
73 .of_match_table = powernv_rng_match,
74 },
75 .probe = powernv_rng_probe,
76 .remove = powernv_rng_remove,
77};
78module_platform_driver(powernv_rng_driver);
79
80MODULE_LICENSE("GPL");
81MODULE_DESCRIPTION("Bare metal HWRNG driver for POWER7+ and above");
diff --git a/drivers/char/hw_random/pseries-rng.c b/drivers/char/hw_random/pseries-rng.c
index 5f1197929f0c..b761459a3436 100644
--- a/drivers/char/hw_random/pseries-rng.c
+++ b/drivers/char/hw_random/pseries-rng.c
@@ -17,6 +17,9 @@
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */ 18 */
19 19
20#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
21
22#include <linux/kernel.h>
20#include <linux/module.h> 23#include <linux/module.h>
21#include <linux/hw_random.h> 24#include <linux/hw_random.h>
22#include <asm/vio.h> 25#include <asm/vio.h>
@@ -25,10 +28,15 @@
25 28
26static int pseries_rng_data_read(struct hwrng *rng, u32 *data) 29static int pseries_rng_data_read(struct hwrng *rng, u32 *data)
27{ 30{
28 if (plpar_hcall(H_RANDOM, (unsigned long *)data) != H_SUCCESS) { 31 int rc;
29 printk(KERN_ERR "pseries rng hcall error\n"); 32
30 return 0; 33 rc = plpar_hcall(H_RANDOM, (unsigned long *)data);
34 if (rc != H_SUCCESS) {
35 pr_err_ratelimited("H_RANDOM call failed %d\n", rc);
36 return -EIO;
31 } 37 }
38
39 /* The hypervisor interface returns 64 bits */
32 return 8; 40 return 8;
33} 41}
34 42
diff --git a/drivers/macintosh/Kconfig b/drivers/macintosh/Kconfig
index 696238b9f0f7..d26a312f117a 100644
--- a/drivers/macintosh/Kconfig
+++ b/drivers/macintosh/Kconfig
@@ -103,6 +103,7 @@ config ADB_PMU_LED_IDE
103 bool "Use front LED as IDE LED by default" 103 bool "Use front LED as IDE LED by default"
104 depends on ADB_PMU_LED 104 depends on ADB_PMU_LED
105 depends on LEDS_CLASS 105 depends on LEDS_CLASS
106 depends on IDE_GD_ATA
106 select LEDS_TRIGGERS 107 select LEDS_TRIGGERS
107 select LEDS_TRIGGER_IDE_DISK 108 select LEDS_TRIGGER_IDE_DISK
108 help 109 help
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 7d4c70f859e3..aace017fc452 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -1882,3 +1882,34 @@ int of_device_is_stdout_path(struct device_node *dn)
1882 return of_stdout == dn; 1882 return of_stdout == dn;
1883} 1883}
1884EXPORT_SYMBOL_GPL(of_device_is_stdout_path); 1884EXPORT_SYMBOL_GPL(of_device_is_stdout_path);
1885
1886/**
1887 * of_find_next_cache_node - Find a node's subsidiary cache
1888 * @np: node of type "cpu" or "cache"
1889 *
1890 * Returns a node pointer with refcount incremented, use
1891 * of_node_put() on it when done. Caller should hold a reference
1892 * to np.
1893 */
1894struct device_node *of_find_next_cache_node(const struct device_node *np)
1895{
1896 struct device_node *child;
1897 const phandle *handle;
1898
1899 handle = of_get_property(np, "l2-cache", NULL);
1900 if (!handle)
1901 handle = of_get_property(np, "next-level-cache", NULL);
1902
1903 if (handle)
1904 return of_find_node_by_phandle(be32_to_cpup(handle));
1905
1906 /* OF on pmac has nodes instead of properties named "l2-cache"
1907 * beneath CPU nodes.
1908 */
1909 if (!strcmp(np->type, "cpu"))
1910 for_each_child_of_node(np, child)
1911 if (!strcmp(child->type, "cache"))
1912 return child;
1913
1914 return NULL;
1915}
diff --git a/drivers/tty/hvc/hvc_opal.c b/drivers/tty/hvc/hvc_opal.c
index cd69b48f6dfd..6496872e2e47 100644
--- a/drivers/tty/hvc/hvc_opal.c
+++ b/drivers/tty/hvc/hvc_opal.c
@@ -329,7 +329,7 @@ static void udbg_init_opal_common(void)
329void __init hvc_opal_init_early(void) 329void __init hvc_opal_init_early(void)
330{ 330{
331 struct device_node *stdout_node = NULL; 331 struct device_node *stdout_node = NULL;
332 const u32 *termno; 332 const __be32 *termno;
333 const char *name = NULL; 333 const char *name = NULL;
334 const struct hv_ops *ops; 334 const struct hv_ops *ops;
335 u32 index; 335 u32 index;
@@ -371,7 +371,7 @@ void __init hvc_opal_init_early(void)
371 if (!stdout_node) 371 if (!stdout_node)
372 return; 372 return;
373 termno = of_get_property(stdout_node, "reg", NULL); 373 termno = of_get_property(stdout_node, "reg", NULL);
374 index = termno ? *termno : 0; 374 index = termno ? be32_to_cpup(termno) : 0;
375 if (index >= MAX_NR_HVC_CONSOLES) 375 if (index >= MAX_NR_HVC_CONSOLES)
376 return; 376 return;
377 hvc_opal_privs[index] = &hvc_opal_boot_priv; 377 hvc_opal_privs[index] = &hvc_opal_boot_priv;
diff --git a/drivers/tty/hvc/hvsi_lib.c b/drivers/tty/hvc/hvsi_lib.c
index ac2767100df5..347050ea414a 100644
--- a/drivers/tty/hvc/hvsi_lib.c
+++ b/drivers/tty/hvc/hvsi_lib.c
@@ -9,7 +9,7 @@
9 9
10static int hvsi_send_packet(struct hvsi_priv *pv, struct hvsi_header *packet) 10static int hvsi_send_packet(struct hvsi_priv *pv, struct hvsi_header *packet)
11{ 11{
12 packet->seqno = atomic_inc_return(&pv->seqno); 12 packet->seqno = cpu_to_be16(atomic_inc_return(&pv->seqno));
13 13
14 /* Assumes that always succeeds, works in practice */ 14 /* Assumes that always succeeds, works in practice */
15 return pv->put_chars(pv->termno, (char *)packet, packet->len); 15 return pv->put_chars(pv->termno, (char *)packet, packet->len);
@@ -28,7 +28,7 @@ static void hvsi_start_handshake(struct hvsi_priv *pv)
28 /* Send version query */ 28 /* Send version query */
29 q.hdr.type = VS_QUERY_PACKET_HEADER; 29 q.hdr.type = VS_QUERY_PACKET_HEADER;
30 q.hdr.len = sizeof(struct hvsi_query); 30 q.hdr.len = sizeof(struct hvsi_query);
31 q.verb = VSV_SEND_VERSION_NUMBER; 31 q.verb = cpu_to_be16(VSV_SEND_VERSION_NUMBER);
32 hvsi_send_packet(pv, &q.hdr); 32 hvsi_send_packet(pv, &q.hdr);
33} 33}
34 34
@@ -40,7 +40,7 @@ static int hvsi_send_close(struct hvsi_priv *pv)
40 40
41 ctrl.hdr.type = VS_CONTROL_PACKET_HEADER; 41 ctrl.hdr.type = VS_CONTROL_PACKET_HEADER;
42 ctrl.hdr.len = sizeof(struct hvsi_control); 42 ctrl.hdr.len = sizeof(struct hvsi_control);
43 ctrl.verb = VSV_CLOSE_PROTOCOL; 43 ctrl.verb = cpu_to_be16(VSV_CLOSE_PROTOCOL);
44 return hvsi_send_packet(pv, &ctrl.hdr); 44 return hvsi_send_packet(pv, &ctrl.hdr);
45} 45}
46 46
@@ -69,14 +69,14 @@ static void hvsi_got_control(struct hvsi_priv *pv)
69{ 69{
70 struct hvsi_control *pkt = (struct hvsi_control *)pv->inbuf; 70 struct hvsi_control *pkt = (struct hvsi_control *)pv->inbuf;
71 71
72 switch (pkt->verb) { 72 switch (be16_to_cpu(pkt->verb)) {
73 case VSV_CLOSE_PROTOCOL: 73 case VSV_CLOSE_PROTOCOL:
74 /* We restart the handshaking */ 74 /* We restart the handshaking */
75 hvsi_start_handshake(pv); 75 hvsi_start_handshake(pv);
76 break; 76 break;
77 case VSV_MODEM_CTL_UPDATE: 77 case VSV_MODEM_CTL_UPDATE:
78 /* Transition of carrier detect */ 78 /* Transition of carrier detect */
79 hvsi_cd_change(pv, pkt->word & HVSI_TSCD); 79 hvsi_cd_change(pv, be32_to_cpu(pkt->word) & HVSI_TSCD);
80 break; 80 break;
81 } 81 }
82} 82}
@@ -87,7 +87,7 @@ static void hvsi_got_query(struct hvsi_priv *pv)
87 struct hvsi_query_response r; 87 struct hvsi_query_response r;
88 88
89 /* We only handle version queries */ 89 /* We only handle version queries */
90 if (pkt->verb != VSV_SEND_VERSION_NUMBER) 90 if (be16_to_cpu(pkt->verb) != VSV_SEND_VERSION_NUMBER)
91 return; 91 return;
92 92
93 pr_devel("HVSI@%x: Got version query, sending response...\n", 93 pr_devel("HVSI@%x: Got version query, sending response...\n",
@@ -96,7 +96,7 @@ static void hvsi_got_query(struct hvsi_priv *pv)
96 /* Send version response */ 96 /* Send version response */
97 r.hdr.type = VS_QUERY_RESPONSE_PACKET_HEADER; 97 r.hdr.type = VS_QUERY_RESPONSE_PACKET_HEADER;
98 r.hdr.len = sizeof(struct hvsi_query_response); 98 r.hdr.len = sizeof(struct hvsi_query_response);
99 r.verb = VSV_SEND_VERSION_NUMBER; 99 r.verb = cpu_to_be16(VSV_SEND_VERSION_NUMBER);
100 r.u.version = HVSI_VERSION; 100 r.u.version = HVSI_VERSION;
101 r.query_seqno = pkt->hdr.seqno; 101 r.query_seqno = pkt->hdr.seqno;
102 hvsi_send_packet(pv, &r.hdr); 102 hvsi_send_packet(pv, &r.hdr);
@@ -112,7 +112,7 @@ static void hvsi_got_response(struct hvsi_priv *pv)
112 112
113 switch(r->verb) { 113 switch(r->verb) {
114 case VSV_SEND_MODEM_CTL_STATUS: 114 case VSV_SEND_MODEM_CTL_STATUS:
115 hvsi_cd_change(pv, r->u.mctrl_word & HVSI_TSCD); 115 hvsi_cd_change(pv, be32_to_cpu(r->u.mctrl_word) & HVSI_TSCD);
116 pv->mctrl_update = 1; 116 pv->mctrl_update = 1;
117 break; 117 break;
118 } 118 }
@@ -265,8 +265,7 @@ int hvsilib_read_mctrl(struct hvsi_priv *pv)
265 pv->mctrl_update = 0; 265 pv->mctrl_update = 0;
266 q.hdr.type = VS_QUERY_PACKET_HEADER; 266 q.hdr.type = VS_QUERY_PACKET_HEADER;
267 q.hdr.len = sizeof(struct hvsi_query); 267 q.hdr.len = sizeof(struct hvsi_query);
268 q.hdr.seqno = atomic_inc_return(&pv->seqno); 268 q.verb = cpu_to_be16(VSV_SEND_MODEM_CTL_STATUS);
269 q.verb = VSV_SEND_MODEM_CTL_STATUS;
270 rc = hvsi_send_packet(pv, &q.hdr); 269 rc = hvsi_send_packet(pv, &q.hdr);
271 if (rc <= 0) { 270 if (rc <= 0) {
272 pr_devel("HVSI@%x: Error %d...\n", pv->termno, rc); 271 pr_devel("HVSI@%x: Error %d...\n", pv->termno, rc);
@@ -304,9 +303,9 @@ int hvsilib_write_mctrl(struct hvsi_priv *pv, int dtr)
304 303
305 ctrl.hdr.type = VS_CONTROL_PACKET_HEADER, 304 ctrl.hdr.type = VS_CONTROL_PACKET_HEADER,
306 ctrl.hdr.len = sizeof(struct hvsi_control); 305 ctrl.hdr.len = sizeof(struct hvsi_control);
307 ctrl.verb = VSV_SET_MODEM_CTL; 306 ctrl.verb = cpu_to_be16(VSV_SET_MODEM_CTL);
308 ctrl.mask = HVSI_TSDTR; 307 ctrl.mask = cpu_to_be32(HVSI_TSDTR);
309 ctrl.word = dtr ? HVSI_TSDTR : 0; 308 ctrl.word = cpu_to_be32(dtr ? HVSI_TSDTR : 0);
310 return hvsi_send_packet(pv, &ctrl.hdr); 309 return hvsi_send_packet(pv, &ctrl.hdr);
311} 310}
312 311
diff --git a/include/linux/hashtable.h b/include/linux/hashtable.h
index a9df51f5d54c..519b6e2d769e 100644
--- a/include/linux/hashtable.h
+++ b/include/linux/hashtable.h
@@ -174,6 +174,21 @@ static inline void hash_del_rcu(struct hlist_node *node)
174 member) 174 member)
175 175
176/** 176/**
177 * hash_for_each_possible_rcu_notrace - iterate over all possible objects hashing
178 * to the same bucket in an rcu enabled hashtable in a rcu enabled hashtable
179 * @name: hashtable to iterate
180 * @obj: the type * to use as a loop cursor for each entry
181 * @member: the name of the hlist_node within the struct
182 * @key: the key of the objects to iterate over
183 *
184 * This is the same as hash_for_each_possible_rcu() except that it does
185 * not do any RCU debugging or tracing.
186 */
187#define hash_for_each_possible_rcu_notrace(name, obj, member, key) \
188 hlist_for_each_entry_rcu_notrace(obj, \
189 &name[hash_min(key, HASH_BITS(name))], member)
190
191/**
177 * hash_for_each_possible_safe - iterate over all possible objects hashing to the 192 * hash_for_each_possible_safe - iterate over all possible objects hashing to the
178 * same bucket safe against removals 193 * same bucket safe against removals
179 * @name: hashtable to iterate 194 * @name: hashtable to iterate
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 81443d557a2e..8aa4006b9636 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -297,12 +297,26 @@ static inline int put_page_testzero(struct page *page)
297/* 297/*
298 * Try to grab a ref unless the page has a refcount of zero, return false if 298 * Try to grab a ref unless the page has a refcount of zero, return false if
299 * that is the case. 299 * that is the case.
300 * This can be called when MMU is off so it must not access
301 * any of the virtual mappings.
300 */ 302 */
301static inline int get_page_unless_zero(struct page *page) 303static inline int get_page_unless_zero(struct page *page)
302{ 304{
303 return atomic_inc_not_zero(&page->_count); 305 return atomic_inc_not_zero(&page->_count);
304} 306}
305 307
308/*
309 * Try to drop a ref unless the page has a refcount of one, return false if
310 * that is the case.
311 * This is to make sure that the refcount won't become zero after this drop.
312 * This can be called when MMU is off so it must not access
313 * any of the virtual mappings.
314 */
315static inline int put_page_unless_one(struct page *page)
316{
317 return atomic_add_unless(&page->_count, -1, 1);
318}
319
306extern int page_is_ram(unsigned long pfn); 320extern int page_is_ram(unsigned long pfn);
307 321
308/* Support for virtually mapped pages */ 322/* Support for virtually mapped pages */
diff --git a/include/linux/of.h b/include/linux/of.h
index f95aee391e30..c08c07e249b3 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -226,6 +226,8 @@ static inline int of_get_child_count(const struct device_node *np)
226 return num; 226 return num;
227} 227}
228 228
229/* cache lookup */
230extern struct device_node *of_find_next_cache_node(const struct device_node *);
229extern struct device_node *of_find_node_with_property( 231extern struct device_node *of_find_node_with_property(
230 struct device_node *from, const char *prop_name); 232 struct device_node *from, const char *prop_name);
231#define for_each_node_with_property(dn, prop_name) \ 233#define for_each_node_with_property(dn, prop_name) \
diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index 6d53675c2b54..98ada58f9942 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -329,7 +329,9 @@ static inline void set_page_writeback(struct page *page)
329 * System with lots of page flags available. This allows separate 329 * System with lots of page flags available. This allows separate
330 * flags for PageHead() and PageTail() checks of compound pages so that bit 330 * flags for PageHead() and PageTail() checks of compound pages so that bit
331 * tests can be used in performance sensitive paths. PageCompound is 331 * tests can be used in performance sensitive paths. PageCompound is
332 * generally not used in hot code paths. 332 * generally not used in hot code paths except arch/powerpc/mm/init_64.c
333 * and arch/powerpc/kvm/book3s_64_vio_hv.c which use it to detect huge pages
334 * and avoid handling those in real mode.
333 */ 335 */
334__PAGEFLAG(Head, head) CLEARPAGEFLAG(Head, head) 336__PAGEFLAG(Head, head) CLEARPAGEFLAG(Head, head)
335__PAGEFLAG(Tail, tail) 337__PAGEFLAG(Tail, tail)