aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore6
-rw-r--r--CREDITS5
-rw-r--r--Documentation/00-INDEX4
-rw-r--r--Documentation/DocBook/media/Makefile76
-rw-r--r--Documentation/DocBook/networking.tmpl4
-rw-r--r--Documentation/IPMI.txt65
-rw-r--r--Documentation/arm64/memory.txt12
-rw-r--r--Documentation/cgroups/memory.txt4
-rw-r--r--Documentation/devicetree/bindings/arm/atmel-at91.txt2
-rw-r--r--Documentation/devicetree/bindings/input/touchscreen/egalax-ts.txt19
-rw-r--r--Documentation/devicetree/bindings/net/mdio-gpio.txt9
-rw-r--r--Documentation/devicetree/bindings/pinctrl/nvidia,tegra20-pinmux.txt2
-rw-r--r--Documentation/devicetree/bindings/pinctrl/nvidia,tegra30-pinmux.txt2
-rw-r--r--Documentation/filesystems/proc.txt16
-rw-r--r--Documentation/firmware_class/README26
-rw-r--r--Documentation/hwmon/coretemp1
-rw-r--r--Documentation/hwmon/fam15h_power2
-rw-r--r--Documentation/hwmon/submitting-patches3
-rw-r--r--Documentation/networking/netdev-features.txt2
-rw-r--r--Documentation/networking/vxlan.txt4
-rw-r--r--Documentation/sysrq.txt1
-rw-r--r--Documentation/zh_CN/IRQ.txt39
-rw-r--r--Documentation/zh_CN/arm64/booting.txt156
-rw-r--r--Documentation/zh_CN/arm64/memory.txt93
-rw-r--r--MAINTAINERS141
-rw-r--r--Makefile17
-rw-r--r--arch/Kconfig14
-rw-r--r--arch/alpha/include/asm/thread_info.h80
-rw-r--r--arch/alpha/kernel/entry.S21
-rw-r--r--arch/alpha/kernel/osf_sys.c31
-rw-r--r--arch/alpha/kernel/process.c51
-rw-r--r--arch/alpha/kernel/signal.c16
-rw-r--r--arch/alpha/kernel/traps.c6
-rw-r--r--arch/arm/Kconfig9
-rw-r--r--arch/arm/Makefile13
-rw-r--r--arch/arm/boot/Makefile10
-rw-r--r--arch/arm/boot/dts/Makefile2
-rw-r--r--arch/arm/boot/dts/at91sam9g20ek_common.dtsi4
-rw-r--r--arch/arm/boot/dts/dbx5x0.dtsi17
-rw-r--r--arch/arm/boot/dts/dove.dtsi49
-rw-r--r--arch/arm/boot/dts/exynos4210-trats.dts6
-rw-r--r--arch/arm/boot/dts/imx23.dtsi1
-rw-r--r--arch/arm/boot/dts/imx28.dtsi1
-rw-r--r--arch/arm/boot/dts/imx6q-arm2.dts10
-rw-r--r--arch/arm/boot/dts/kirkwood-lsxl.dtsi18
-rw-r--r--arch/arm/boot/dts/omap3.dtsi4
-rw-r--r--arch/arm/boot/dts/tegra30.dtsi4
-rw-r--r--arch/arm/boot/dts/wm8505.dtsi4
-rw-r--r--arch/arm/configs/imx_v6_v7_defconfig2
-rw-r--r--arch/arm/configs/mvebu_defconfig10
-rw-r--r--arch/arm/configs/versatile_defconfig1
-rw-r--r--arch/arm/include/asm/flat.h2
-rw-r--r--arch/arm/include/asm/io.h4
-rw-r--r--arch/arm/include/asm/sched_clock.h2
-rw-r--r--arch/arm/include/asm/uaccess.h4
-rw-r--r--arch/arm/include/asm/vfpmacros.h12
-rw-r--r--arch/arm/include/asm/xen/interface.h12
-rw-r--r--arch/arm/include/asm/xen/page.h13
-rw-r--r--arch/arm/include/debug/8250_32.S27
-rw-r--r--arch/arm/include/debug/picoxcell.S18
-rw-r--r--arch/arm/include/debug/socfpga.S5
-rw-r--r--arch/arm/include/uapi/asm/hwcap.h3
-rw-r--r--arch/arm/kernel/entry-common.S4
-rw-r--r--arch/arm/kernel/irq.c2
-rw-r--r--arch/arm/kernel/kprobes-test-arm.c4
-rw-r--r--arch/arm/kernel/machine_kexec.c7
-rw-r--r--arch/arm/kernel/perf_event.c4
-rw-r--r--arch/arm/kernel/sched_clock.c18
-rw-r--r--arch/arm/kernel/smp.c14
-rw-r--r--arch/arm/kernel/smp_twd.c4
-rw-r--r--arch/arm/lib/delay.c1
-rw-r--r--arch/arm/mach-at91/Kconfig10
-rw-r--r--arch/arm/mach-at91/at91rm9200.c2
-rw-r--r--arch/arm/mach-at91/at91rm9200_devices.c6
-rw-r--r--arch/arm/mach-at91/at91sam9260.c4
-rw-r--r--arch/arm/mach-at91/at91sam9260_devices.c6
-rw-r--r--arch/arm/mach-at91/at91sam9261.c4
-rw-r--r--arch/arm/mach-at91/at91sam9261_devices.c6
-rw-r--r--arch/arm/mach-at91/at91sam9263.c2
-rw-r--r--arch/arm/mach-at91/at91sam9263_devices.c6
-rw-r--r--arch/arm/mach-at91/at91sam9g45_devices.c12
-rw-r--r--arch/arm/mach-at91/at91sam9rl_devices.c4
-rw-r--r--arch/arm/mach-at91/at91x40.c2
-rw-r--r--arch/arm/mach-at91/board-neocore926.c2
-rw-r--r--arch/arm/mach-at91/board-sam9261ek.c2
-rw-r--r--arch/arm/mach-at91/board-sam9263ek.c2
-rw-r--r--arch/arm/mach-at91/generic.h3
-rw-r--r--arch/arm/mach-at91/irq.c9
-rw-r--r--arch/arm/mach-at91/setup.c4
-rw-r--r--arch/arm/mach-davinci/dm644x.c3
-rw-r--r--arch/arm/mach-dove/common.c8
-rw-r--r--arch/arm/mach-dove/pcie.c5
-rw-r--r--arch/arm/mach-exynos/common.c5
-rw-r--r--arch/arm/mach-exynos/dma.c3
-rw-r--r--arch/arm/mach-exynos/include/mach/map.h1
-rw-r--r--arch/arm/mach-exynos/mach-exynos4-dt.c1
-rw-r--r--arch/arm/mach-highbank/system.c3
-rw-r--r--arch/arm/mach-imx/clk-busy.c2
-rw-r--r--arch/arm/mach-imx/clk-gate2.c2
-rw-r--r--arch/arm/mach-imx/clk-imx25.c4
-rw-r--r--arch/arm/mach-imx/clk-imx27.c4
-rw-r--r--arch/arm/mach-imx/ehci-imx25.c2
-rw-r--r--arch/arm/mach-imx/ehci-imx35.c2
-rw-r--r--arch/arm/mach-imx/mm-imx3.c5
-rw-r--r--arch/arm/mach-kirkwood/board-dt.c2
-rw-r--r--arch/arm/mach-kirkwood/common.c4
-rw-r--r--arch/arm/mach-omap1/board-ams-delta.c12
-rw-r--r--arch/arm/mach-omap2/Kconfig1
-rw-r--r--arch/arm/mach-omap2/board-igep0020.c5
-rw-r--r--arch/arm/mach-omap2/board-omap3beagle.c22
-rw-r--r--arch/arm/mach-omap2/clock33xx_data.c2
-rw-r--r--arch/arm/mach-omap2/clock44xx_data.c2
-rw-r--r--arch/arm/mach-omap2/clockdomain.c15
-rw-r--r--arch/arm/mach-omap2/clockdomains44xx_data.c2
-rw-r--r--arch/arm/mach-omap2/common-board-devices.c34
-rw-r--r--arch/arm/mach-omap2/devices.c81
-rw-r--r--arch/arm/mach-omap2/gpmc.c24
-rw-r--r--arch/arm/mach-omap2/mux34xx.c8
-rw-r--r--arch/arm/mach-omap2/omap_hwmod.c63
-rw-r--r--arch/arm/mach-omap2/omap_hwmod_44xx_data.c36
-rw-r--r--arch/arm/mach-omap2/pm.h1
-rw-r--r--arch/arm/mach-omap2/pm34xx.c30
-rw-r--r--arch/arm/mach-omap2/serial.c5
-rw-r--r--arch/arm/mach-omap2/timer.c2
-rw-r--r--arch/arm/mach-omap2/twl-common.c3
-rw-r--r--arch/arm/mach-omap2/vc.c2
-rw-r--r--arch/arm/mach-prima2/include/mach/gpio.h13
-rw-r--r--arch/arm/mach-pxa/hx4700.c8
-rw-r--r--arch/arm/mach-pxa/spitz_pm.c8
-rw-r--r--arch/arm/mach-s3c24xx/clock-s3c2440.c2
-rw-r--r--arch/arm/mach-s3c24xx/s3c2416.c2
-rw-r--r--arch/arm/mach-s3c24xx/s3c2443.c4
-rw-r--r--arch/arm/mach-s5p64x0/common.c3
-rw-r--r--arch/arm/mach-s5pc100/common.c3
-rw-r--r--arch/arm/mach-s5pv210/common.c3
-rw-r--r--arch/arm/mach-shmobile/board-armadillo800eva.c2
-rw-r--r--arch/arm/mach-shmobile/clock-r8a7779.c22
-rw-r--r--arch/arm/mach-shmobile/setup-r8a7779.c2
-rw-r--r--arch/arm/mach-spear13xx/include/mach/spear1310_misc_regs.h0
-rw-r--r--arch/arm/mach-spear13xx/include/mach/spear1340_misc_regs.h0
-rw-r--r--arch/arm/mach-tegra/board-dt-tegra20.c2
-rw-r--r--arch/arm/mach-tegra/board-dt-tegra30.c2
-rw-r--r--arch/arm/mach-tegra/board.h2
-rw-r--r--arch/arm/mach-tegra/tegra20_clocks_data.c1
-rw-r--r--arch/arm/mach-tegra/tegra30_clocks.c2
-rw-r--r--arch/arm/mach-tegra/tegra30_clocks_data.c1
-rw-r--r--arch/arm/mach-tegra/timer.c2
-rw-r--r--arch/arm/mach-ux500/cpu.c1
-rw-r--r--arch/arm/mm/alignment.c6
-rw-r--r--arch/arm/mm/dma-mapping.c2
-rw-r--r--arch/arm/mm/vmregion.h1
-rw-r--r--arch/arm/plat-mxc/devices/platform-mxc-mmc.c2
-rw-r--r--arch/arm/plat-omap/Kconfig1
-rw-r--r--arch/arm/plat-omap/debug-devices.c1
-rw-r--r--arch/arm/plat-omap/i2c.c21
-rw-r--r--arch/arm/plat-omap/include/plat/omap-serial.h4
-rw-r--r--arch/arm/plat-omap/include/plat/omap_hwmod.h6
-rw-r--r--arch/arm/plat-samsung/include/plat/spi-core.h30
-rw-r--r--arch/arm/tools/Makefile2
-rw-r--r--arch/arm/vfp/vfpmodule.c9
-rw-r--r--arch/arm/xen/enlighten.c11
-rw-r--r--arch/arm/xen/grant-table.c2
-rw-r--r--arch/arm/xen/hypercall.S14
-rw-r--r--arch/arm64/Kconfig4
-rw-r--r--arch/arm64/include/asm/Kbuild1
-rw-r--r--arch/arm64/include/asm/elf.h5
-rw-r--r--arch/arm64/include/asm/fpsimd.h5
-rw-r--r--arch/arm64/include/asm/io.h10
-rw-r--r--arch/arm64/include/asm/linkage.h7
-rw-r--r--arch/arm64/include/asm/pgtable-hwdef.h6
-rw-r--r--arch/arm64/include/asm/pgtable.h40
-rw-r--r--arch/arm64/include/asm/processor.h17
-rw-r--r--arch/arm64/include/asm/syscalls.h14
-rw-r--r--arch/arm64/include/asm/unistd.h2
-rw-r--r--arch/arm64/include/asm/unistd32.h8
-rw-r--r--arch/arm64/include/uapi/asm/ptrace.h3
-rw-r--r--arch/arm64/kernel/entry.S17
-rw-r--r--arch/arm64/kernel/perf_event.c10
-rw-r--r--arch/arm64/kernel/process.c101
-rw-r--r--arch/arm64/kernel/ptrace.c73
-rw-r--r--arch/arm64/kernel/setup.c12
-rw-r--r--arch/arm64/kernel/smp.c4
-rw-r--r--arch/arm64/kernel/sys.c76
-rw-r--r--arch/arm64/kernel/sys32.S19
-rw-r--r--arch/arm64/kernel/sys_compat.c38
-rw-r--r--arch/arm64/kernel/vdso.c20
-rw-r--r--arch/arm64/mm/init.c2
-rw-r--r--arch/avr32/Kconfig2
-rw-r--r--arch/avr32/include/asm/processor.h3
-rw-r--r--arch/avr32/include/asm/unistd.h1
-rw-r--r--arch/avr32/kernel/Makefile2
-rw-r--r--arch/avr32/kernel/entry-avr32b.S14
-rw-r--r--arch/avr32/kernel/process.c88
-rw-r--r--arch/avr32/kernel/sys_avr32.c24
-rw-r--r--arch/avr32/kernel/syscall-stubs.S6
-rw-r--r--arch/avr32/kernel/syscall_table.S2
-rw-r--r--arch/c6x/Kconfig1
-rw-r--r--arch/c6x/include/uapi/asm/unistd.h1
-rw-r--r--arch/c6x/kernel/entry.S12
-rw-r--r--arch/cris/Kconfig2
-rw-r--r--arch/cris/arch-v10/kernel/entry.S17
-rw-r--r--arch/cris/arch-v10/kernel/process.c106
-rw-r--r--arch/cris/arch-v32/kernel/entry.S22
-rw-r--r--arch/cris/arch-v32/kernel/process.c96
-rw-r--r--arch/cris/include/asm/processor.h2
-rw-r--r--arch/cris/include/asm/unistd.h1
-rw-r--r--arch/cris/kernel/crisksyms.c1
-rw-r--r--arch/frv/Kconfig1
-rw-r--r--arch/frv/boot/Makefile10
-rw-r--r--arch/frv/include/asm/unistd.h1
-rw-r--r--arch/frv/kernel/entry.S32
-rw-r--r--arch/frv/kernel/process.c5
-rw-r--r--arch/frv/kernel/setup.c2
-rw-r--r--arch/frv/mb93090-mb00/pci-dma-nommu.c1
-rw-r--r--arch/h8300/Kconfig2
-rw-r--r--arch/h8300/include/asm/cache.h3
-rw-r--r--arch/h8300/include/asm/processor.h2
-rw-r--r--arch/h8300/include/asm/ptrace.h2
-rw-r--r--arch/h8300/include/asm/unistd.h1
-rw-r--r--arch/h8300/kernel/entry.S9
-rw-r--r--arch/h8300/kernel/h8300_ksyms.c1
-rw-r--r--arch/h8300/kernel/process.c62
-rw-r--r--arch/h8300/kernel/sys_h8300.c26
-rw-r--r--arch/hexagon/Kconfig2
-rw-r--r--arch/hexagon/include/asm/Kbuild3
-rw-r--r--arch/hexagon/include/asm/atomic.h2
-rw-r--r--arch/hexagon/include/asm/barrier.h2
-rw-r--r--arch/hexagon/include/asm/bitops.h2
-rw-r--r--arch/hexagon/include/asm/cache.h2
-rw-r--r--arch/hexagon/include/asm/cacheflush.h2
-rw-r--r--arch/hexagon/include/asm/checksum.h2
-rw-r--r--arch/hexagon/include/asm/cmpxchg.h2
-rw-r--r--arch/hexagon/include/asm/delay.h2
-rw-r--r--arch/hexagon/include/asm/dma-mapping.h2
-rw-r--r--arch/hexagon/include/asm/dma.h2
-rw-r--r--arch/hexagon/include/asm/elf.h2
-rw-r--r--arch/hexagon/include/asm/exec.h2
-rw-r--r--arch/hexagon/include/asm/fixmap.h2
-rw-r--r--arch/hexagon/include/asm/hexagon_vm.h2
-rw-r--r--arch/hexagon/include/asm/intrinsics.h2
-rw-r--r--arch/hexagon/include/asm/io.h2
-rw-r--r--arch/hexagon/include/asm/irq.h2
-rw-r--r--arch/hexagon/include/asm/irqflags.h2
-rw-r--r--arch/hexagon/include/asm/kgdb.h2
-rw-r--r--arch/hexagon/include/asm/linkage.h2
-rw-r--r--arch/hexagon/include/asm/mem-layout.h2
-rw-r--r--arch/hexagon/include/asm/mmu.h2
-rw-r--r--arch/hexagon/include/asm/mmu_context.h2
-rw-r--r--arch/hexagon/include/asm/module.h2
-rw-r--r--arch/hexagon/include/asm/page.h2
-rw-r--r--arch/hexagon/include/asm/perf_event.h2
-rw-r--r--arch/hexagon/include/asm/pgalloc.h2
-rw-r--r--arch/hexagon/include/asm/pgtable.h2
-rw-r--r--arch/hexagon/include/asm/processor.h3
-rw-r--r--arch/hexagon/include/asm/smp.h2
-rw-r--r--arch/hexagon/include/asm/spinlock.h2
-rw-r--r--arch/hexagon/include/asm/spinlock_types.h2
-rw-r--r--arch/hexagon/include/asm/string.h2
-rw-r--r--arch/hexagon/include/asm/suspend.h2
-rw-r--r--arch/hexagon/include/asm/switch_to.h2
-rw-r--r--arch/hexagon/include/asm/syscall.h2
-rw-r--r--arch/hexagon/include/asm/thread_info.h2
-rw-r--r--arch/hexagon/include/asm/time.h2
-rw-r--r--arch/hexagon/include/asm/timer-regs.h2
-rw-r--r--arch/hexagon/include/asm/timex.h2
-rw-r--r--arch/hexagon/include/asm/tlb.h2
-rw-r--r--arch/hexagon/include/asm/tlbflush.h2
-rw-r--r--arch/hexagon/include/asm/traps.h2
-rw-r--r--arch/hexagon/include/asm/uaccess.h2
-rw-r--r--arch/hexagon/include/asm/vdso.h2
-rw-r--r--arch/hexagon/include/asm/vm_fault.h2
-rw-r--r--arch/hexagon/include/asm/vm_mmu.h2
-rw-r--r--arch/hexagon/include/uapi/asm/Kbuild12
-rw-r--r--arch/hexagon/include/uapi/asm/bitsperlong.h (renamed from arch/hexagon/include/asm/bitsperlong.h)2
-rw-r--r--arch/hexagon/include/uapi/asm/byteorder.h (renamed from arch/hexagon/include/asm/byteorder.h)2
-rw-r--r--arch/hexagon/include/uapi/asm/kvm_para.h (renamed from arch/hexagon/include/asm/kvm_para.h)0
-rw-r--r--arch/hexagon/include/uapi/asm/param.h (renamed from arch/hexagon/include/asm/param.h)2
-rw-r--r--arch/hexagon/include/uapi/asm/ptrace.h (renamed from arch/hexagon/include/asm/ptrace.h)6
-rw-r--r--arch/hexagon/include/uapi/asm/registers.h (renamed from arch/hexagon/include/asm/registers.h)17
-rw-r--r--arch/hexagon/include/uapi/asm/setup.h (renamed from arch/hexagon/include/asm/setup.h)2
-rw-r--r--arch/hexagon/include/uapi/asm/sigcontext.h (renamed from arch/hexagon/include/asm/sigcontext.h)2
-rw-r--r--arch/hexagon/include/uapi/asm/signal.h (renamed from arch/hexagon/include/asm/signal.h)2
-rw-r--r--arch/hexagon/include/uapi/asm/swab.h (renamed from arch/hexagon/include/asm/swab.h)2
-rw-r--r--arch/hexagon/include/uapi/asm/unistd.h (renamed from arch/hexagon/include/asm/unistd.h)3
-rw-r--r--arch/hexagon/include/uapi/asm/user.h (renamed from arch/hexagon/include/asm/user.h)18
-rw-r--r--arch/hexagon/kernel/asm-offsets.c2
-rw-r--r--arch/hexagon/kernel/dma.c2
-rw-r--r--arch/hexagon/kernel/head.S2
-rw-r--r--arch/hexagon/kernel/hexagon_ksyms.c2
-rw-r--r--arch/hexagon/kernel/irq_cpu.c2
-rw-r--r--arch/hexagon/kernel/kgdb.c2
-rw-r--r--arch/hexagon/kernel/module.c2
-rw-r--r--arch/hexagon/kernel/process.c104
-rw-r--r--arch/hexagon/kernel/ptrace.c2
-rw-r--r--arch/hexagon/kernel/reset.c2
-rw-r--r--arch/hexagon/kernel/setup.c2
-rw-r--r--arch/hexagon/kernel/signal.c6
-rw-r--r--arch/hexagon/kernel/smp.c2
-rw-r--r--arch/hexagon/kernel/stacktrace.c2
-rw-r--r--arch/hexagon/kernel/syscall.c46
-rw-r--r--arch/hexagon/kernel/syscalltab.c2
-rw-r--r--arch/hexagon/kernel/time.c2
-rw-r--r--arch/hexagon/kernel/topology.c2
-rw-r--r--arch/hexagon/kernel/trampoline.S2
-rw-r--r--arch/hexagon/kernel/traps.c2
-rw-r--r--arch/hexagon/kernel/vdso.c2
-rw-r--r--arch/hexagon/kernel/vm_entry.S6
-rw-r--r--arch/hexagon/kernel/vm_events.c2
-rw-r--r--arch/hexagon/kernel/vm_init_segtable.S2
-rw-r--r--arch/hexagon/kernel/vm_ops.S2
-rw-r--r--arch/hexagon/kernel/vm_switch.S2
-rw-r--r--arch/hexagon/kernel/vm_vectors.S2
-rw-r--r--arch/hexagon/kernel/vmlinux.lds.S2
-rw-r--r--arch/hexagon/lib/checksum.c2
-rw-r--r--arch/hexagon/lib/io.c2
-rw-r--r--arch/hexagon/lib/memcpy.S2
-rw-r--r--arch/hexagon/lib/memset.S2
-rw-r--r--arch/hexagon/mm/cache.c2
-rw-r--r--arch/hexagon/mm/copy_from_user.S2
-rw-r--r--arch/hexagon/mm/copy_to_user.S2
-rw-r--r--arch/hexagon/mm/copy_user_template.S2
-rw-r--r--arch/hexagon/mm/init.c2
-rw-r--r--arch/hexagon/mm/ioremap.c2
-rw-r--r--arch/hexagon/mm/pgalloc.c2
-rw-r--r--arch/hexagon/mm/strnlen_user.S2
-rw-r--r--arch/hexagon/mm/uaccess.c2
-rw-r--r--arch/hexagon/mm/vm_fault.c2
-rw-r--r--arch/hexagon/mm/vm_tlb.c2
-rw-r--r--arch/ia64/Kconfig2
-rw-r--r--arch/ia64/include/asm/Kbuild1
-rw-r--r--arch/ia64/include/asm/kvm_para.h34
-rw-r--r--arch/ia64/include/asm/processor.h16
-rw-r--r--arch/ia64/include/asm/unistd.h1
-rw-r--r--arch/ia64/include/uapi/asm/Kbuild2
-rw-r--r--arch/ia64/include/uapi/asm/kvm_para.h0
-rw-r--r--arch/ia64/kernel/entry.S39
-rw-r--r--arch/ia64/kernel/head.S13
-rw-r--r--arch/ia64/kernel/process.c158
-rw-r--r--arch/ia64/mm/init.c1
-rw-r--r--arch/m32r/Kconfig2
-rw-r--r--arch/m32r/include/asm/processor.h5
-rw-r--r--arch/m32r/include/asm/ptrace.h2
-rw-r--r--arch/m32r/include/asm/unistd.h1
-rw-r--r--arch/m32r/kernel/entry.S9
-rw-r--r--arch/m32r/kernel/process.c106
-rw-r--r--arch/m32r/kernel/sys_m32r.c21
-rw-r--r--arch/m68k/Kconfig1
-rw-r--r--arch/m68k/include/asm/Kbuild2
-rw-r--r--arch/m68k/include/asm/ptrace.h75
-rw-r--r--arch/m68k/include/asm/setup.h82
-rw-r--r--arch/m68k/include/asm/signal.h124
-rw-r--r--arch/m68k/include/asm/termios.h44
-rw-r--r--arch/m68k/include/asm/unistd.h357
-rw-r--r--arch/m68k/include/uapi/asm/Kbuild23
-rw-r--r--arch/m68k/include/uapi/asm/a.out.h (renamed from arch/m68k/include/asm/a.out.h)0
-rw-r--r--arch/m68k/include/uapi/asm/auxvec.h (renamed from arch/m68k/include/asm/auxvec.h)0
-rw-r--r--arch/m68k/include/uapi/asm/byteorder.h (renamed from arch/m68k/include/asm/byteorder.h)0
-rw-r--r--arch/m68k/include/uapi/asm/cachectl.h (renamed from arch/m68k/include/asm/cachectl.h)0
-rw-r--r--arch/m68k/include/uapi/asm/fcntl.h (renamed from arch/m68k/include/asm/fcntl.h)0
-rw-r--r--arch/m68k/include/uapi/asm/ioctls.h (renamed from arch/m68k/include/asm/ioctls.h)0
-rw-r--r--arch/m68k/include/uapi/asm/msgbuf.h (renamed from arch/m68k/include/asm/msgbuf.h)0
-rw-r--r--arch/m68k/include/uapi/asm/param.h (renamed from arch/m68k/include/asm/param.h)0
-rw-r--r--arch/m68k/include/uapi/asm/poll.h (renamed from arch/m68k/include/asm/poll.h)0
-rw-r--r--arch/m68k/include/uapi/asm/posix_types.h (renamed from arch/m68k/include/asm/posix_types.h)0
-rw-r--r--arch/m68k/include/uapi/asm/ptrace.h79
-rw-r--r--arch/m68k/include/uapi/asm/sembuf.h (renamed from arch/m68k/include/asm/sembuf.h)0
-rw-r--r--arch/m68k/include/uapi/asm/setup.h103
-rw-r--r--arch/m68k/include/uapi/asm/shmbuf.h (renamed from arch/m68k/include/asm/shmbuf.h)0
-rw-r--r--arch/m68k/include/uapi/asm/sigcontext.h (renamed from arch/m68k/include/asm/sigcontext.h)0
-rw-r--r--arch/m68k/include/uapi/asm/signal.h118
-rw-r--r--arch/m68k/include/uapi/asm/socket.h (renamed from arch/m68k/include/asm/socket.h)0
-rw-r--r--arch/m68k/include/uapi/asm/sockios.h (renamed from arch/m68k/include/asm/sockios.h)0
-rw-r--r--arch/m68k/include/uapi/asm/stat.h (renamed from arch/m68k/include/asm/stat.h)0
-rw-r--r--arch/m68k/include/uapi/asm/swab.h (renamed from arch/m68k/include/asm/swab.h)0
-rw-r--r--arch/m68k/include/uapi/asm/termbits.h (renamed from arch/m68k/include/asm/termbits.h)0
-rw-r--r--arch/m68k/include/uapi/asm/termios.h44
-rw-r--r--arch/m68k/include/uapi/asm/unistd.h357
-rw-r--r--arch/m68k/kernel/entry.S7
-rw-r--r--arch/m68k/kernel/syscalltable.S1
-rw-r--r--arch/microblaze/Kconfig2
-rw-r--r--arch/microblaze/include/asm/processor.h8
-rw-r--r--arch/microblaze/include/asm/unistd.h1
-rw-r--r--arch/microblaze/kernel/entry-nommu.S12
-rw-r--r--arch/microblaze/kernel/entry.S33
-rw-r--r--arch/microblaze/kernel/process.c72
-rw-r--r--arch/microblaze/kernel/signal.c2
-rw-r--r--arch/microblaze/kernel/sys_microblaze.c39
-rw-r--r--arch/mips/Kconfig2
-rw-r--r--arch/mips/cavium-octeon/executive/cvmx-l2c.c1
-rw-r--r--arch/mips/fw/arc/misc.c1
-rw-r--r--arch/mips/include/asm/Kbuild1
-rw-r--r--arch/mips/include/asm/bitops.h128
-rw-r--r--arch/mips/include/asm/compat.h2
-rw-r--r--arch/mips/include/asm/delay.h6
-rw-r--r--arch/mips/include/asm/io.h1
-rw-r--r--arch/mips/include/asm/irqflags.h207
-rw-r--r--arch/mips/include/asm/pgtable-64.h15
-rw-r--r--arch/mips/include/asm/processor.h2
-rw-r--r--arch/mips/include/asm/ptrace.h6
-rw-r--r--arch/mips/include/asm/thread_info.h6
-rw-r--r--arch/mips/include/asm/unistd.h1
-rw-r--r--arch/mips/jz4740/serial.h3
-rw-r--r--arch/mips/kernel/entry.S6
-rw-r--r--arch/mips/kernel/linux32.c21
-rw-r--r--arch/mips/kernel/mips_ksyms.c2
-rw-r--r--arch/mips/kernel/process.c62
-rw-r--r--arch/mips/kernel/scall64-n32.S2
-rw-r--r--arch/mips/kernel/scall64-o32.S2
-rw-r--r--arch/mips/kernel/setup.c26
-rw-r--r--arch/mips/kernel/smp-cmp.c2
-rw-r--r--arch/mips/kernel/syscall.c53
-rw-r--r--arch/mips/lib/Makefile5
-rw-r--r--arch/mips/lib/bitops.c179
-rw-r--r--arch/mips/lib/delay.c6
-rw-r--r--arch/mips/lib/dump_tlb.c4
-rw-r--r--arch/mips/lib/mips-atomic.c176
-rw-r--r--arch/mips/mm/tlb-r4k.c1
-rw-r--r--arch/mips/mm/tlbex.c56
-rw-r--r--arch/mips/mti-malta/malta-platform.c3
-rw-r--r--arch/mn10300/Kconfig1
-rw-r--r--arch/mn10300/include/asm/unistd.h1
-rw-r--r--arch/mn10300/include/uapi/asm/setup.h4
-rw-r--r--arch/mn10300/kernel/entry.S7
-rw-r--r--arch/openrisc/Kconfig2
-rw-r--r--arch/openrisc/include/uapi/asm/unistd.h2
-rw-r--r--arch/openrisc/kernel/entry.S43
-rw-r--r--arch/openrisc/kernel/process.c163
-rw-r--r--arch/openrisc/kernel/signal.c6
-rw-r--r--arch/parisc/Kconfig2
-rw-r--r--arch/parisc/include/asm/Kbuild9
-rw-r--r--arch/parisc/include/asm/auxvec.h4
-rw-r--r--arch/parisc/include/asm/compat_signal.h2
-rw-r--r--arch/parisc/include/asm/cputime.h6
-rw-r--r--arch/parisc/include/asm/device.h7
-rw-r--r--arch/parisc/include/asm/div64.h1
-rw-r--r--arch/parisc/include/asm/emergency-restart.h6
-rw-r--r--arch/parisc/include/asm/hw_irq.h8
-rw-r--r--arch/parisc/include/asm/irq_regs.h1
-rw-r--r--arch/parisc/include/asm/kdebug.h1
-rw-r--r--arch/parisc/include/asm/kvm_para.h1
-rw-r--r--arch/parisc/include/asm/local.h1
-rw-r--r--arch/parisc/include/asm/local64.h1
-rw-r--r--arch/parisc/include/asm/mutex.h9
-rw-r--r--arch/parisc/include/asm/param.h1
-rw-r--r--arch/parisc/include/asm/pdc.h423
-rw-r--r--arch/parisc/include/asm/percpu.h7
-rw-r--r--arch/parisc/include/asm/poll.h1
-rw-r--r--arch/parisc/include/asm/ptrace.h46
-rw-r--r--arch/parisc/include/asm/real.h5
-rw-r--r--arch/parisc/include/asm/segment.h6
-rw-r--r--arch/parisc/include/asm/signal.h113
-rw-r--r--arch/parisc/include/asm/termios.h41
-rw-r--r--arch/parisc/include/asm/topology.h6
-rw-r--r--arch/parisc/include/asm/unistd.h836
-rw-r--r--arch/parisc/include/asm/user.h5
-rw-r--r--arch/parisc/include/asm/vga.h6
-rw-r--r--arch/parisc/include/asm/xor.h1
-rw-r--r--arch/parisc/include/uapi/asm/Kbuild28
-rw-r--r--arch/parisc/include/uapi/asm/bitsperlong.h (renamed from arch/parisc/include/asm/bitsperlong.h)0
-rw-r--r--arch/parisc/include/uapi/asm/byteorder.h (renamed from arch/parisc/include/asm/byteorder.h)0
-rw-r--r--arch/parisc/include/uapi/asm/errno.h (renamed from arch/parisc/include/asm/errno.h)0
-rw-r--r--arch/parisc/include/uapi/asm/fcntl.h (renamed from arch/parisc/include/asm/fcntl.h)0
-rw-r--r--arch/parisc/include/uapi/asm/ioctl.h (renamed from arch/parisc/include/asm/ioctl.h)0
-rw-r--r--arch/parisc/include/uapi/asm/ioctls.h (renamed from arch/parisc/include/asm/ioctls.h)0
-rw-r--r--arch/parisc/include/uapi/asm/ipcbuf.h (renamed from arch/parisc/include/asm/ipcbuf.h)0
-rw-r--r--arch/parisc/include/uapi/asm/mman.h (renamed from arch/parisc/include/asm/mman.h)0
-rw-r--r--arch/parisc/include/uapi/asm/msgbuf.h (renamed from arch/parisc/include/asm/msgbuf.h)0
-rw-r--r--arch/parisc/include/uapi/asm/pdc.h427
-rw-r--r--arch/parisc/include/uapi/asm/posix_types.h (renamed from arch/parisc/include/asm/posix_types.h)0
-rw-r--r--arch/parisc/include/uapi/asm/ptrace.h47
-rw-r--r--arch/parisc/include/uapi/asm/resource.h (renamed from arch/parisc/include/asm/resource.h)0
-rw-r--r--arch/parisc/include/uapi/asm/sembuf.h (renamed from arch/parisc/include/asm/sembuf.h)0
-rw-r--r--arch/parisc/include/uapi/asm/setup.h (renamed from arch/parisc/include/asm/setup.h)0
-rw-r--r--arch/parisc/include/uapi/asm/shmbuf.h (renamed from arch/parisc/include/asm/shmbuf.h)0
-rw-r--r--arch/parisc/include/uapi/asm/sigcontext.h (renamed from arch/parisc/include/asm/sigcontext.h)0
-rw-r--r--arch/parisc/include/uapi/asm/siginfo.h (renamed from arch/parisc/include/asm/siginfo.h)0
-rw-r--r--arch/parisc/include/uapi/asm/signal.h118
-rw-r--r--arch/parisc/include/uapi/asm/socket.h (renamed from arch/parisc/include/asm/socket.h)0
-rw-r--r--arch/parisc/include/uapi/asm/sockios.h (renamed from arch/parisc/include/asm/sockios.h)0
-rw-r--r--arch/parisc/include/uapi/asm/stat.h (renamed from arch/parisc/include/asm/stat.h)0
-rw-r--r--arch/parisc/include/uapi/asm/statfs.h (renamed from arch/parisc/include/asm/statfs.h)0
-rw-r--r--arch/parisc/include/uapi/asm/swab.h (renamed from arch/parisc/include/asm/swab.h)0
-rw-r--r--arch/parisc/include/uapi/asm/termbits.h (renamed from arch/parisc/include/asm/termbits.h)0
-rw-r--r--arch/parisc/include/uapi/asm/termios.h43
-rw-r--r--arch/parisc/include/uapi/asm/types.h (renamed from arch/parisc/include/asm/types.h)0
-rw-r--r--arch/parisc/include/uapi/asm/unistd.h837
-rw-r--r--arch/parisc/kernel/entry.S217
-rw-r--r--arch/parisc/kernel/process.c96
-rw-r--r--arch/parisc/kernel/signal32.c6
-rw-r--r--arch/parisc/kernel/sys_parisc.c2
-rw-r--r--arch/parisc/kernel/sys_parisc32.c22
-rw-r--r--arch/parisc/kernel/syscall_table.S2
-rw-r--r--arch/powerpc/Kconfig1
-rw-r--r--arch/powerpc/boot/dts/mpc5200b.dtsi6
-rw-r--r--arch/powerpc/boot/dts/o2d.dtsi6
-rw-r--r--arch/powerpc/boot/dts/pcm030.dts7
-rw-r--r--arch/powerpc/include/asm/kvm_book3s_32.h1
-rw-r--r--arch/powerpc/include/asm/processor.h4
-rw-r--r--arch/powerpc/include/asm/unistd.h1
-rw-r--r--arch/powerpc/kernel/entry_32.S5
-rw-r--r--arch/powerpc/kernel/entry_64.S8
-rw-r--r--arch/powerpc/kernel/process.c41
-rw-r--r--arch/powerpc/kernel/sysfs.c2
-rw-r--r--arch/powerpc/kvm/book3s_32_mmu_host.c4
-rw-r--r--arch/powerpc/perf/core-book3s.c2
-rw-r--r--arch/powerpc/platforms/52xx/mpc52xx_pic.c9
-rw-r--r--arch/powerpc/platforms/pseries/eeh_pe.c2
-rw-r--r--arch/powerpc/platforms/pseries/msi.c3
-rw-r--r--arch/powerpc/platforms/pseries/processor_idle.c62
-rw-r--r--arch/s390/Kconfig3
-rw-r--r--arch/s390/boot/compressed/vmlinux.lds.S2
-rw-r--r--arch/s390/include/asm/cio.h2
-rw-r--r--arch/s390/include/asm/compat.h2
-rw-r--r--arch/s390/include/asm/perf_event.h2
-rw-r--r--arch/s390/include/asm/pgtable.h35
-rw-r--r--arch/s390/include/asm/topology.h3
-rw-r--r--arch/s390/include/asm/unistd.h1
-rw-r--r--arch/s390/include/uapi/asm/chpid.h10
-rw-r--r--arch/s390/include/uapi/asm/kvm_para.h11
-rw-r--r--arch/s390/include/uapi/asm/ptrace.h4
-rw-r--r--arch/s390/kernel/cache.c9
-rw-r--r--arch/s390/kernel/compat_signal.c14
-rw-r--r--arch/s390/kernel/entry.S32
-rw-r--r--arch/s390/kernel/entry64.S26
-rw-r--r--arch/s390/kernel/head_kdump.S10
-rw-r--r--arch/s390/kernel/perf_cpum_cf.c6
-rw-r--r--arch/s390/kernel/sclp.S8
-rw-r--r--arch/s390/kernel/signal.c14
-rw-r--r--arch/s390/kernel/topology.c6
-rw-r--r--arch/s390/kernel/vmlinux.lds.S2
-rw-r--r--arch/s390/lib/uaccess_pt.c2
-rw-r--r--arch/s390/mm/gup.c7
-rw-r--r--arch/score/Kconfig2
-rw-r--r--arch/score/include/asm/processor.h1
-rw-r--r--arch/score/include/asm/syscalls.h1
-rw-r--r--arch/score/include/asm/unistd.h1
-rw-r--r--arch/score/kernel/entry.S12
-rw-r--r--arch/score/kernel/process.c55
-rw-r--r--arch/score/kernel/signal.c7
-rw-r--r--arch/score/kernel/sys_score.c54
-rw-r--r--arch/sh/Kconfig2
-rw-r--r--arch/sh/include/asm/Kbuild11
-rw-r--r--arch/sh/include/asm/hw_breakpoint.h4
-rw-r--r--arch/sh/include/asm/posix_types.h8
-rw-r--r--arch/sh/include/asm/processor_32.h5
-rw-r--r--arch/sh/include/asm/processor_64.h5
-rw-r--r--arch/sh/include/asm/ptrace.h34
-rw-r--r--arch/sh/include/asm/ptrace_32.h75
-rw-r--r--arch/sh/include/asm/ptrace_64.h12
-rw-r--r--arch/sh/include/asm/setup.h5
-rw-r--r--arch/sh/include/asm/syscalls_32.h4
-rw-r--r--arch/sh/include/asm/syscalls_64.h4
-rw-r--r--arch/sh/include/asm/types.h5
-rw-r--r--arch/sh/include/asm/unistd.h10
-rw-r--r--arch/sh/include/uapi/asm/Kbuild22
-rw-r--r--arch/sh/include/uapi/asm/auxvec.h (renamed from arch/sh/include/asm/auxvec.h)0
-rw-r--r--arch/sh/include/uapi/asm/byteorder.h (renamed from arch/sh/include/asm/byteorder.h)0
-rw-r--r--arch/sh/include/uapi/asm/cachectl.h (renamed from arch/sh/include/asm/cachectl.h)0
-rw-r--r--arch/sh/include/uapi/asm/cpu-features.h (renamed from arch/sh/include/asm/cpu-features.h)0
-rw-r--r--arch/sh/include/uapi/asm/hw_breakpoint.h4
-rw-r--r--arch/sh/include/uapi/asm/ioctls.h (renamed from arch/sh/include/asm/ioctls.h)0
-rw-r--r--arch/sh/include/uapi/asm/posix_types.h7
-rw-r--r--arch/sh/include/uapi/asm/posix_types_32.h (renamed from arch/sh/include/asm/posix_types_32.h)0
-rw-r--r--arch/sh/include/uapi/asm/posix_types_64.h (renamed from arch/sh/include/asm/posix_types_64.h)0
-rw-r--r--arch/sh/include/uapi/asm/ptrace.h34
-rw-r--r--arch/sh/include/uapi/asm/ptrace_32.h77
-rw-r--r--arch/sh/include/uapi/asm/ptrace_64.h14
-rw-r--r--arch/sh/include/uapi/asm/setup.h1
-rw-r--r--arch/sh/include/uapi/asm/sigcontext.h (renamed from arch/sh/include/asm/sigcontext.h)0
-rw-r--r--arch/sh/include/uapi/asm/signal.h (renamed from arch/sh/include/asm/signal.h)0
-rw-r--r--arch/sh/include/uapi/asm/sockios.h (renamed from arch/sh/include/asm/sockios.h)0
-rw-r--r--arch/sh/include/uapi/asm/stat.h (renamed from arch/sh/include/asm/stat.h)0
-rw-r--r--arch/sh/include/uapi/asm/swab.h (renamed from arch/sh/include/asm/swab.h)0
-rw-r--r--arch/sh/include/uapi/asm/types.h1
-rw-r--r--arch/sh/include/uapi/asm/unistd.h7
-rw-r--r--arch/sh/include/uapi/asm/unistd_32.h (renamed from arch/sh/include/asm/unistd_32.h)3
-rw-r--r--arch/sh/include/uapi/asm/unistd_64.h (renamed from arch/sh/include/asm/unistd_64.h)3
-rw-r--r--arch/sh/kernel/Makefile3
-rw-r--r--arch/sh/kernel/cpu/sh5/entry.S19
-rw-r--r--arch/sh/kernel/entry-common.S13
-rw-r--r--arch/sh/kernel/process_32.c87
-rw-r--r--arch/sh/kernel/process_64.c85
-rw-r--r--arch/sh/kernel/signal_64.c6
-rw-r--r--arch/sh/kernel/sys_sh32.c24
-rw-r--r--arch/sh/kernel/sys_sh64.c50
-rw-r--r--arch/sh/kernel/syscalls_32.S1
-rw-r--r--arch/sh/kernel/syscalls_64.S1
-rw-r--r--arch/sparc/Kconfig3
-rw-r--r--arch/sparc/crypto/Makefile16
-rw-r--r--arch/sparc/crypto/aes_glue.c2
-rw-r--r--arch/sparc/crypto/camellia_glue.c2
-rw-r--r--arch/sparc/crypto/crc32c_glue.c2
-rw-r--r--arch/sparc/crypto/des_glue.c2
-rw-r--r--arch/sparc/crypto/md5_glue.c2
-rw-r--r--arch/sparc/crypto/sha1_glue.c2
-rw-r--r--arch/sparc/crypto/sha256_glue.c2
-rw-r--r--arch/sparc/crypto/sha512_glue.c2
-rw-r--r--arch/sparc/include/asm/atomic_64.h4
-rw-r--r--arch/sparc/include/asm/backoff.h69
-rw-r--r--arch/sparc/include/asm/compat.h5
-rw-r--r--arch/sparc/include/asm/processor_32.h1
-rw-r--r--arch/sparc/include/asm/processor_64.h28
-rw-r--r--arch/sparc/include/asm/prom.h8
-rw-r--r--arch/sparc/include/asm/ptrace.h23
-rw-r--r--arch/sparc/include/asm/smp_64.h2
-rw-r--r--arch/sparc/include/asm/switch_to_64.h2
-rw-r--r--arch/sparc/include/asm/syscalls.h2
-rw-r--r--arch/sparc/include/asm/thread_info_64.h30
-rw-r--r--arch/sparc/include/asm/ttable.h24
-rw-r--r--arch/sparc/include/asm/uaccess_64.h4
-rw-r--r--arch/sparc/include/asm/unistd.h1
-rw-r--r--arch/sparc/include/uapi/asm/sigcontext.h4
-rw-r--r--arch/sparc/include/uapi/asm/unistd.h7
-rw-r--r--arch/sparc/kernel/entry.S51
-rw-r--r--arch/sparc/kernel/entry.h7
-rw-r--r--arch/sparc/kernel/etrap_64.S8
-rw-r--r--arch/sparc/kernel/leon_kernel.c6
-rw-r--r--arch/sparc/kernel/perf_event.c37
-rw-r--r--arch/sparc/kernel/process_32.c152
-rw-r--r--arch/sparc/kernel/process_64.c305
-rw-r--r--arch/sparc/kernel/ptrace_64.c4
-rw-r--r--arch/sparc/kernel/setup_64.c21
-rw-r--r--arch/sparc/kernel/signal_64.c4
-rw-r--r--arch/sparc/kernel/smp_64.c11
-rw-r--r--arch/sparc/kernel/sys_sparc32.c36
-rw-r--r--arch/sparc/kernel/sys_sparc_32.c24
-rw-r--r--arch/sparc/kernel/sys_sparc_64.c21
-rw-r--r--arch/sparc/kernel/syscalls.S30
-rw-r--r--arch/sparc/kernel/systbls_32.S1
-rw-r--r--arch/sparc/kernel/systbls_64.S4
-rw-r--r--arch/sparc/kernel/traps_64.c4
-rw-r--r--arch/sparc/kernel/unaligned_64.c36
-rw-r--r--arch/sparc/kernel/visemul.c23
-rw-r--r--arch/sparc/kernel/vmlinux.lds.S5
-rw-r--r--arch/sparc/kernel/winfixup.S2
-rw-r--r--arch/sparc/lib/atomic_64.S16
-rw-r--r--arch/sparc/lib/ksyms.c1
-rw-r--r--arch/sparc/math-emu/math_64.c2
-rw-r--r--arch/sparc/mm/init_64.c2
-rw-r--r--arch/sparc/mm/ultra.S64
-rw-r--r--arch/tile/Kconfig2
-rw-r--r--arch/tile/Makefile4
-rw-r--r--arch/tile/include/arch/Kbuild1
-rw-r--r--arch/tile/include/asm/Kbuild3
-rw-r--r--arch/tile/include/asm/compat.h15
-rw-r--r--arch/tile/include/asm/elf.h1
-rw-r--r--arch/tile/include/asm/processor.h4
-rw-r--r--arch/tile/include/asm/switch_to.h5
-rw-r--r--arch/tile/include/asm/syscalls.h20
-rw-r--r--arch/tile/include/asm/unistd.h1
-rw-r--r--arch/tile/include/uapi/asm/Kbuild3
-rw-r--r--arch/tile/kernel/compat.c5
-rw-r--r--arch/tile/kernel/compat_signal.c10
-rw-r--r--arch/tile/kernel/entry.S11
-rw-r--r--arch/tile/kernel/intvec_32.S29
-rw-r--r--arch/tile/kernel/intvec_64.S30
-rw-r--r--arch/tile/kernel/module.c10
-rw-r--r--arch/tile/kernel/process.c170
-rw-r--r--arch/tile/kernel/signal.c9
-rw-r--r--arch/tile/kernel/sys.c9
-rw-r--r--arch/tile/mm/fault.c5
-rw-r--r--arch/um/kernel/exec.c3
-rw-r--r--arch/um/kernel/process.c2
-rw-r--r--arch/um/kernel/syscall.c8
-rw-r--r--arch/unicore32/Kconfig7
-rw-r--r--arch/unicore32/include/asm/Kbuild1
-rw-r--r--arch/unicore32/include/asm/bug.h5
-rw-r--r--arch/unicore32/include/asm/cmpxchg.h2
-rw-r--r--arch/unicore32/include/asm/kvm_para.h1
-rw-r--r--arch/unicore32/include/asm/processor.h5
-rw-r--r--arch/unicore32/include/asm/ptrace.h76
-rw-r--r--arch/unicore32/include/uapi/asm/Kbuild7
-rw-r--r--arch/unicore32/include/uapi/asm/byteorder.h (renamed from arch/unicore32/include/asm/byteorder.h)0
-rw-r--r--arch/unicore32/include/uapi/asm/ptrace.h90
-rw-r--r--arch/unicore32/include/uapi/asm/sigcontext.h (renamed from arch/unicore32/include/asm/sigcontext.h)0
-rw-r--r--arch/unicore32/include/uapi/asm/unistd.h (renamed from arch/unicore32/include/asm/unistd.h)1
-rw-r--r--arch/unicore32/kernel/entry.S20
-rw-r--r--arch/unicore32/kernel/process.c58
-rw-r--r--arch/unicore32/kernel/setup.h6
-rw-r--r--arch/unicore32/kernel/sys.c63
-rw-r--r--arch/unicore32/mm/fault.c37
-rw-r--r--arch/x86/Makefile2
-rw-r--r--arch/x86/boot/compressed/eboot.c2
-rw-r--r--arch/x86/boot/header.S3
-rw-r--r--arch/x86/crypto/aesni-intel_glue.c9
-rw-r--r--arch/x86/include/asm/efi.h6
-rw-r--r--arch/x86/include/asm/ptrace.h15
-rw-r--r--arch/x86/include/asm/xen/hypercall.h21
-rw-r--r--arch/x86/include/asm/xen/hypervisor.h1
-rw-r--r--arch/x86/include/asm/xen/interface.h4
-rw-r--r--arch/x86/kernel/apic/io_apic.c3
-rw-r--r--arch/x86/kernel/cpu/amd.c14
-rw-r--r--arch/x86/kernel/cpu/intel_cacheinfo.c2
-rw-r--r--arch/x86/kernel/cpu/mcheck/mce.c6
-rw-r--r--arch/x86/kernel/cpu/mcheck/mce_amd.c12
-rw-r--r--arch/x86/kernel/cpu/mcheck/mce_intel.c31
-rw-r--r--arch/x86/kernel/cpu/perf_event.c16
-rw-r--r--arch/x86/kernel/cpu/perf_event_intel_uncore.c48
-rw-r--r--arch/x86/kernel/cpu/perf_event_knc.c93
-rw-r--r--arch/x86/kernel/cpu/perf_event_p6.c127
-rw-r--r--arch/x86/kernel/e820.c3
-rw-r--r--arch/x86/kernel/entry_32.S8
-rw-r--r--arch/x86/kernel/entry_64.S16
-rw-r--r--arch/x86/kernel/kvm.c3
-rw-r--r--arch/x86/kernel/microcode_amd.c8
-rw-r--r--arch/x86/kernel/ptrace.c30
-rw-r--r--arch/x86/kernel/reboot.c8
-rw-r--r--arch/x86/kernel/setup.c30
-rw-r--r--arch/x86/kernel/signal.c4
-rw-r--r--arch/x86/kernel/uprobes.c16
-rw-r--r--arch/x86/kvm/cpuid.h3
-rw-r--r--arch/x86/kvm/lapic.c2
-rw-r--r--arch/x86/kvm/mmu.c3
-rw-r--r--arch/x86/kvm/vmx.c11
-rw-r--r--arch/x86/kvm/x86.c63
-rw-r--r--arch/x86/mm/init.c58
-rw-r--r--arch/x86/mm/init_64.c7
-rw-r--r--arch/x86/mm/tlb.c2
-rw-r--r--arch/x86/oprofile/nmi_int.c2
-rw-r--r--arch/x86/pci/ce4100.c13
-rw-r--r--arch/x86/platform/ce4100/ce4100.c24
-rw-r--r--arch/x86/platform/efi/efi.c47
-rw-r--r--arch/x86/platform/efi/efi_64.c7
-rw-r--r--arch/x86/realmode/rm/wakeup_asm.S15
-rw-r--r--arch/x86/xen/enlighten.c2
-rw-r--r--arch/x86/xen/mmu.c21
-rw-r--r--arch/xtensa/Kconfig2
-rw-r--r--arch/xtensa/boot/boot-redboot/bootstrap.S8
-rw-r--r--arch/xtensa/include/asm/Kbuild28
-rw-r--r--arch/xtensa/include/asm/atomic.h12
-rw-r--r--arch/xtensa/include/asm/bitsperlong.h1
-rw-r--r--arch/xtensa/include/asm/bug.h18
-rw-r--r--arch/xtensa/include/asm/cacheflush.h2
-rw-r--r--arch/xtensa/include/asm/cmpxchg.h4
-rw-r--r--arch/xtensa/include/asm/coprocessor.h5
-rw-r--r--arch/xtensa/include/asm/cputime.h6
-rw-r--r--arch/xtensa/include/asm/delay.h2
-rw-r--r--arch/xtensa/include/asm/device.h7
-rw-r--r--arch/xtensa/include/asm/div64.h16
-rw-r--r--arch/xtensa/include/asm/emergency-restart.h6
-rw-r--r--arch/xtensa/include/asm/errno.h16
-rw-r--r--arch/xtensa/include/asm/fcntl.h1
-rw-r--r--arch/xtensa/include/asm/futex.h1
-rw-r--r--arch/xtensa/include/asm/hardirq.h16
-rw-r--r--arch/xtensa/include/asm/io.h4
-rw-r--r--arch/xtensa/include/asm/ioctl.h1
-rw-r--r--arch/xtensa/include/asm/irq_regs.h1
-rw-r--r--arch/xtensa/include/asm/irqflags.h4
-rw-r--r--arch/xtensa/include/asm/kdebug.h1
-rw-r--r--arch/xtensa/include/asm/kmap_types.h6
-rw-r--r--arch/xtensa/include/asm/kvm_para.h1
-rw-r--r--arch/xtensa/include/asm/local.h16
-rw-r--r--arch/xtensa/include/asm/local64.h1
-rw-r--r--arch/xtensa/include/asm/mmu_context.h4
-rw-r--r--arch/xtensa/include/asm/param.h20
-rw-r--r--arch/xtensa/include/asm/percpu.h16
-rw-r--r--arch/xtensa/include/asm/processor.h4
-rw-r--r--arch/xtensa/include/asm/ptrace.h66
-rw-r--r--arch/xtensa/include/asm/regs.h55
-rw-r--r--arch/xtensa/include/asm/resource.h16
-rw-r--r--arch/xtensa/include/asm/scatterlist.h16
-rw-r--r--arch/xtensa/include/asm/sections.h16
-rw-r--r--arch/xtensa/include/asm/siginfo.h16
-rw-r--r--arch/xtensa/include/asm/signal.h134
-rw-r--r--arch/xtensa/include/asm/statfs.h17
-rw-r--r--arch/xtensa/include/asm/syscall.h2
-rw-r--r--arch/xtensa/include/asm/termios.h105
-rw-r--r--arch/xtensa/include/asm/timex.h8
-rw-r--r--arch/xtensa/include/asm/tlbflush.h8
-rw-r--r--arch/xtensa/include/asm/topology.h16
-rw-r--r--arch/xtensa/include/asm/types.h15
-rw-r--r--arch/xtensa/include/asm/unistd.h711
-rw-r--r--arch/xtensa/include/asm/xor.h16
-rw-r--r--arch/xtensa/include/uapi/asm/Kbuild22
-rw-r--r--arch/xtensa/include/uapi/asm/auxvec.h (renamed from arch/xtensa/include/asm/auxvec.h)0
-rw-r--r--arch/xtensa/include/uapi/asm/byteorder.h (renamed from arch/xtensa/include/asm/byteorder.h)0
-rw-r--r--arch/xtensa/include/uapi/asm/ioctls.h (renamed from arch/xtensa/include/asm/ioctls.h)0
-rw-r--r--arch/xtensa/include/uapi/asm/ipcbuf.h (renamed from arch/xtensa/include/asm/ipcbuf.h)0
-rw-r--r--arch/xtensa/include/uapi/asm/mman.h (renamed from arch/xtensa/include/asm/mman.h)0
-rw-r--r--arch/xtensa/include/uapi/asm/msgbuf.h (renamed from arch/xtensa/include/asm/msgbuf.h)0
-rw-r--r--arch/xtensa/include/uapi/asm/param.h30
-rw-r--r--arch/xtensa/include/uapi/asm/poll.h (renamed from arch/xtensa/include/asm/poll.h)0
-rw-r--r--arch/xtensa/include/uapi/asm/posix_types.h (renamed from arch/xtensa/include/asm/posix_types.h)0
-rw-r--r--arch/xtensa/include/uapi/asm/ptrace.h77
-rw-r--r--arch/xtensa/include/uapi/asm/sembuf.h (renamed from arch/xtensa/include/asm/sembuf.h)0
-rw-r--r--arch/xtensa/include/uapi/asm/setup.h (renamed from arch/xtensa/include/asm/setup.h)0
-rw-r--r--arch/xtensa/include/uapi/asm/shmbuf.h (renamed from arch/xtensa/include/asm/shmbuf.h)0
-rw-r--r--arch/xtensa/include/uapi/asm/sigcontext.h (renamed from arch/xtensa/include/asm/sigcontext.h)0
-rw-r--r--arch/xtensa/include/uapi/asm/signal.h148
-rw-r--r--arch/xtensa/include/uapi/asm/socket.h (renamed from arch/xtensa/include/asm/socket.h)0
-rw-r--r--arch/xtensa/include/uapi/asm/sockios.h (renamed from arch/xtensa/include/asm/sockios.h)0
-rw-r--r--arch/xtensa/include/uapi/asm/stat.h (renamed from arch/xtensa/include/asm/stat.h)0
-rw-r--r--arch/xtensa/include/uapi/asm/swab.h (renamed from arch/xtensa/include/asm/swab.h)0
-rw-r--r--arch/xtensa/include/uapi/asm/termbits.h (renamed from arch/xtensa/include/asm/termbits.h)0
-rw-r--r--arch/xtensa/include/uapi/asm/types.h28
-rw-r--r--arch/xtensa/include/uapi/asm/unistd.h754
-rw-r--r--arch/xtensa/kernel/align.S38
-rw-r--r--arch/xtensa/kernel/coprocessor.S20
-rw-r--r--arch/xtensa/kernel/entry.S311
-rw-r--r--arch/xtensa/kernel/head.S36
-rw-r--r--arch/xtensa/kernel/irq.c6
-rw-r--r--arch/xtensa/kernel/process.c147
-rw-r--r--arch/xtensa/kernel/setup.c4
-rw-r--r--arch/xtensa/kernel/syscall.c8
-rw-r--r--arch/xtensa/kernel/traps.c22
-rw-r--r--arch/xtensa/kernel/vectors.S44
-rw-r--r--arch/xtensa/kernel/xtensa_ksyms.c1
-rw-r--r--arch/xtensa/lib/memcopy.S309
-rw-r--r--arch/xtensa/mm/fault.c3
-rw-r--r--arch/xtensa/platforms/iss/console.c9
-rw-r--r--arch/xtensa/platforms/iss/include/platform/simcall.h9
-rw-r--r--arch/xtensa/platforms/iss/setup.c10
-rw-r--r--arch/xtensa/platforms/xt2000/setup.c10
-rw-r--r--block/Kconfig2
-rw-r--r--block/blk-cgroup.c10
-rw-r--r--block/blk-core.c3
-rw-r--r--block/blk-exec.c8
-rw-r--r--crypto/cryptd.c11
-rw-r--r--drivers/Makefile4
-rw-r--r--drivers/acpi/Makefile5
-rw-r--r--drivers/acpi/glue.c1
-rw-r--r--drivers/acpi/processor_driver.c1
-rw-r--r--drivers/acpi/video.c11
-rw-r--r--drivers/ata/ahci_platform.c2
-rw-r--r--drivers/ata/libata-acpi.c11
-rw-r--r--drivers/ata/libata-core.c4
-rw-r--r--drivers/ata/libata-scsi.c2
-rw-r--r--drivers/ata/pata_arasan_cf.c8
-rw-r--r--drivers/ata/sata_highbank.c4
-rw-r--r--drivers/ata/sata_svw.c35
-rw-r--r--drivers/base/Kconfig2
-rw-r--r--drivers/base/dma-coherent.c5
-rw-r--r--drivers/base/dma-contiguous.c5
-rw-r--r--drivers/base/firmware_class.c266
-rw-r--r--drivers/base/platform.c7
-rw-r--r--drivers/base/power/domain.c5
-rw-r--r--drivers/base/power/qos.c2
-rw-r--r--drivers/base/regmap/Kconfig2
-rw-r--r--drivers/bcma/main.c5
-rw-r--r--drivers/block/Kconfig15
-rw-r--r--drivers/block/aoe/aoecmd.c2
-rw-r--r--drivers/block/cciss.c1
-rw-r--r--drivers/block/floppy.c93
-rw-r--r--drivers/block/loop.c17
-rw-r--r--drivers/block/mtip32xx/mtip32xx.c33
-rw-r--r--drivers/block/mtip32xx/mtip32xx.h7
-rw-r--r--drivers/block/xen-blkback/common.h4
-rw-r--r--drivers/block/xen-blkback/xenbus.c9
-rw-r--r--drivers/bluetooth/ath3k.c1
-rw-r--r--drivers/bluetooth/btusb.c1
-rw-r--r--drivers/bus/omap-ocp2scp.c68
-rw-r--r--drivers/char/Makefile1
-rw-r--r--drivers/char/agp/intel-gtt.c2
-rw-r--r--drivers/char/ipmi/ipmi_msghandler.c2
-rw-r--r--drivers/char/ipmi/ipmi_si_intf.c36
-rw-r--r--drivers/char/sonypi.c2
-rw-r--r--drivers/clk/ux500/u8500_clk.c50
-rw-r--r--drivers/cpufreq/cpufreq_stats.c1
-rw-r--r--drivers/cpufreq/powernow-k8.c11
-rw-r--r--drivers/dma/Kconfig11
-rw-r--r--drivers/dma/dw_dmac_regs.h18
-rw-r--r--drivers/dma/imx-dma.c4
-rw-r--r--drivers/dma/sirf-dma.c4
-rw-r--r--drivers/edac/amd64_edac.c11
-rw-r--r--drivers/edac/amd64_edac.h2
-rw-r--r--drivers/edac/edac_stub.c2
-rw-r--r--drivers/edac/mce_amd_inj.c4
-rw-r--r--drivers/extcon/extcon-adc-jack.c10
-rw-r--r--drivers/extcon/extcon-class.c142
-rw-r--r--drivers/extcon/extcon-gpio.c1
-rw-r--r--drivers/extcon/extcon-max77693.c46
-rw-r--r--drivers/extcon/extcon-max8997.c6
-rw-r--r--drivers/firewire/sbp2.c2
-rw-r--r--drivers/firmware/memmap.c4
-rw-r--r--drivers/gpio/Kconfig4
-rw-r--r--drivers/gpio/gpio-74x164.c2
-rw-r--r--drivers/gpio/gpio-mcp23s08.c6
-rw-r--r--drivers/gpio/gpio-mvebu.c30
-rw-r--r--drivers/gpio/gpio-omap.c35
-rw-r--r--drivers/gpio/gpio-timberdale.c4
-rw-r--r--drivers/gpio/gpiolib.c10
-rw-r--r--drivers/gpu/drm/drm_fb_cma_helper.c4
-rw-r--r--drivers/gpu/drm/drm_fops.c44
-rw-r--r--drivers/gpu/drm/drm_info.c4
-rw-r--r--drivers/gpu/drm/drm_platform.c1
-rw-r--r--drivers/gpu/drm/exynos/Kconfig2
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_connector.c1
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_encoder.c33
-rw-r--r--drivers/gpu/drm/exynos/exynos_mixer.c2
-rw-r--r--drivers/gpu/drm/i915/dvo_ch7xxx.c6
-rw-r--r--drivers/gpu/drm/i915/i915_dma.c3
-rw-r--r--drivers/gpu/drm/i915/i915_drv.c13
-rw-r--r--drivers/gpu/drm/i915/i915_drv.h10
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c26
-rw-r--r--drivers/gpu/drm/i915/i915_reg.h2
-rw-r--r--drivers/gpu/drm/i915/intel_crt.c19
-rw-r--r--drivers/gpu/drm/i915/intel_display.c90
-rw-r--r--drivers/gpu/drm/i915/intel_dp.c18
-rw-r--r--drivers/gpu/drm/i915/intel_lvds.c8
-rw-r--r--drivers/gpu/drm/i915/intel_overlay.c86
-rw-r--r--drivers/gpu/drm/i915/intel_panel.c2
-rw-r--r--drivers/gpu/drm/i915/intel_pm.c4
-rw-r--r--drivers/gpu/drm/i915/intel_sdvo.c98
-rw-r--r--drivers/gpu/drm/i915/intel_sdvo_regs.h2
-rw-r--r--drivers/gpu/drm/nouveau/core/core/gpuobj.c5
-rw-r--r--drivers/gpu/drm/nouveau/core/core/mm.c11
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/disp/nv50.c31
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/graph/ctxnv40.c12
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/graph/nv40.c8
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/graph/nv40.h2
-rw-r--r--drivers/gpu/drm/nouveau/core/engine/mpeg/nv40.c2
-rw-r--r--drivers/gpu/drm/nouveau/core/include/core/mm.h1
-rw-r--r--drivers/gpu/drm/nouveau/core/include/core/object.h14
-rw-r--r--drivers/gpu/drm/nouveau/core/include/subdev/clock.h3
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/bios/base.c30
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/bios/dcb.c4
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/bios/pll.c10
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/clock/nva3.c19
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/clock/nvc0.c1
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/fb/nv50.c12
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/i2c/base.c2
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/therm/fan.c2
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/vm/nv41.c5
-rw-r--r--drivers/gpu/drm/nouveau/core/subdev/vm/nv44.c3
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_abi16.c4
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_bo.c2
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_connector.c2
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_display.c50
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_drm.c39
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_drm.h2
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_irq.c16
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_pm.c6
-rw-r--r--drivers/gpu/drm/nouveau/nv04_dac.c16
-rw-r--r--drivers/gpu/drm/nouveau/nv04_dfp.c14
-rw-r--r--drivers/gpu/drm/nouveau/nv04_tv.c9
-rw-r--r--drivers/gpu/drm/radeon/atombios_crtc.c60
-rw-r--r--drivers/gpu/drm/radeon/atombios_encoders.c7
-rw-r--r--drivers/gpu/drm/radeon/evergreen.c11
-rw-r--r--drivers/gpu/drm/radeon/evergreen_cs.c6
-rw-r--r--drivers/gpu/drm/radeon/evergreend.h4
-rw-r--r--drivers/gpu/drm/radeon/ni.c57
-rw-r--r--drivers/gpu/drm/radeon/nid.h1
-rw-r--r--drivers/gpu/drm/radeon/r600.c6
-rw-r--r--drivers/gpu/drm/radeon/radeon.h14
-rw-r--r--drivers/gpu/drm/radeon/radeon_acpi.c6
-rw-r--r--drivers/gpu/drm/radeon/radeon_agp.c5
-rw-r--r--drivers/gpu/drm/radeon/radeon_atpx_handler.c12
-rw-r--r--drivers/gpu/drm/radeon/radeon_connectors.c28
-rw-r--r--drivers/gpu/drm/radeon/radeon_cs.c1
-rw-r--r--drivers/gpu/drm/radeon/radeon_device.c64
-rw-r--r--drivers/gpu/drm/radeon/radeon_gart.c386
-rw-r--r--drivers/gpu/drm/radeon/radeon_gem.c18
-rw-r--r--drivers/gpu/drm/radeon/radeon_kms.c22
-rw-r--r--drivers/gpu/drm/radeon/radeon_legacy_crtc.c15
-rw-r--r--drivers/gpu/drm/radeon/radeon_legacy_encoders.c228
-rw-r--r--drivers/gpu/drm/radeon/radeon_object.c19
-rw-r--r--drivers/gpu/drm/radeon/radeon_ring.c2
-rw-r--r--drivers/gpu/drm/radeon/si.c55
-rw-r--r--drivers/gpu/drm/radeon/sid.h1
-rw-r--r--drivers/gpu/drm/shmobile/shmob_drm_drv.c12
-rw-r--r--drivers/gpu/drm/ttm/ttm_bo.c24
-rw-r--r--drivers/gpu/drm/ttm/ttm_page_alloc.c5
-rw-r--r--drivers/gpu/drm/ttm/ttm_tt.c4
-rw-r--r--drivers/gpu/drm/udl/udl_drv.h2
-rw-r--r--drivers/gpu/drm/udl/udl_fb.c12
-rw-r--r--drivers/gpu/drm/udl/udl_transfer.c5
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_dmabuf.c2
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_drv.c5
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c2
-rw-r--r--drivers/hid/hid-apple.c6
-rw-r--r--drivers/hid/hid-core.c6
-rw-r--r--drivers/hid/hid-ids.h3
-rw-r--r--drivers/hid/hid-microsoft.c18
-rw-r--r--drivers/hid/hid-multitouch.c5
-rw-r--r--drivers/hid/hidraw.c69
-rw-r--r--drivers/hv/channel.c24
-rw-r--r--drivers/hwmon/asb100.c2
-rw-r--r--drivers/hwmon/coretemp.c7
-rw-r--r--drivers/hwmon/fam15h_power.c4
-rw-r--r--drivers/hwmon/gpio-fan.c2
-rw-r--r--drivers/hwmon/pmbus/Kconfig2
-rw-r--r--drivers/hwmon/w83627ehf.c1
-rw-r--r--drivers/hwmon/w83627hf.c2
-rw-r--r--drivers/hwmon/w83781d.c2
-rw-r--r--drivers/hwmon/w83791d.c2
-rw-r--r--drivers/hwmon/w83792d.c2
-rw-r--r--drivers/hwmon/w83l786ng.c2
-rw-r--r--drivers/i2c/Makefile1
-rw-r--r--drivers/i2c/busses/Kconfig1
-rw-r--r--drivers/i2c/busses/Makefile1
-rw-r--r--drivers/i2c/busses/i2c-at91.c7
-rw-r--r--drivers/i2c/busses/i2c-i801.c11
-rw-r--r--drivers/i2c/busses/i2c-mxs.c188
-rw-r--r--drivers/i2c/busses/i2c-nomadik.c9
-rw-r--r--drivers/i2c/busses/i2c-omap.c36
-rw-r--r--drivers/i2c/busses/i2c-s3c2410.c1
-rw-r--r--drivers/i2c/busses/i2c-tegra.c2
-rw-r--r--drivers/i2c/i2c-stub.c (renamed from drivers/i2c/busses/i2c-stub.c)66
-rw-r--r--drivers/i2c/muxes/i2c-mux-pinctrl.c2
-rw-r--r--drivers/iio/Kconfig1
-rw-r--r--drivers/iio/Makefile1
-rw-r--r--drivers/infiniband/hw/cxgb4/mem.c2
-rw-r--r--drivers/infiniband/hw/mlx4/alias_GUID.c2
-rw-r--r--drivers/infiniband/hw/mlx4/mad.c85
-rw-r--r--drivers/infiniband/hw/mlx4/mcg.c18
-rw-r--r--drivers/input/evdev.c3
-rw-r--r--drivers/input/input-mt.c4
-rw-r--r--drivers/input/joydev.c3
-rw-r--r--drivers/input/keyboard/Kconfig1
-rw-r--r--drivers/input/keyboard/pxa27x_keypad.c3
-rw-r--r--drivers/input/misc/xen-kbdfront.c5
-rw-r--r--drivers/input/mouse/bcm5974.c21
-rw-r--r--drivers/input/mousedev.c7
-rw-r--r--drivers/input/tablet/wacom_sys.c51
-rw-r--r--drivers/input/tablet/wacom_wac.c91
-rw-r--r--drivers/input/tablet/wacom_wac.h5
-rw-r--r--drivers/input/touchscreen/Kconfig2
-rw-r--r--drivers/input/touchscreen/ads7846.c6
-rw-r--r--drivers/input/touchscreen/egalax_ts.c23
-rw-r--r--drivers/input/touchscreen/tsc40.c1
-rw-r--r--drivers/iommu/amd_iommu_init.c39
-rw-r--r--drivers/iommu/intel-iommu.c4
-rw-r--r--drivers/iommu/tegra-smmu.c3
-rw-r--r--drivers/irqchip/irq-bcm2835.c3
-rw-r--r--drivers/isdn/Kconfig2
-rw-r--r--drivers/isdn/gigaset/bas-gigaset.c19
-rw-r--r--drivers/isdn/i4l/Kconfig2
-rw-r--r--drivers/isdn/i4l/isdn_common.c4
-rw-r--r--drivers/leds/ledtrig-cpu.c21
-rw-r--r--drivers/md/dm.c8
-rw-r--r--drivers/md/faulty.c5
-rw-r--r--drivers/md/md.c27
-rw-r--r--drivers/md/raid1.c2
-rw-r--r--drivers/md/raid10.c146
-rw-r--r--drivers/md/raid5.c79
-rw-r--r--drivers/media/Kconfig18
-rw-r--r--drivers/mmc/host/dw_mmc-exynos.c8
-rw-r--r--drivers/mmc/host/dw_mmc-pltfm.c6
-rw-r--r--drivers/mmc/host/dw_mmc-pltfm.h2
-rw-r--r--drivers/mmc/host/dw_mmc.c62
-rw-r--r--drivers/mmc/host/mxcmmc.c2
-rw-r--r--drivers/mmc/host/omap_hsmmc.c19
-rw-r--r--drivers/mmc/host/sdhci-dove.c38
-rw-r--r--drivers/mmc/host/sdhci-of-esdhc.c11
-rw-r--r--drivers/mmc/host/sdhci-pci.c2
-rw-r--r--drivers/mmc/host/sdhci-pltfm.c7
-rw-r--r--drivers/mmc/host/sdhci-s3c.c30
-rw-r--r--drivers/mmc/host/sdhci.c44
-rw-r--r--drivers/mmc/host/sdhci.h1
-rw-r--r--drivers/mmc/host/sh_mmcif.c2
-rw-r--r--drivers/mtd/devices/slram.c2
-rw-r--r--drivers/mtd/nand/nand_base.c10
-rw-r--r--drivers/mtd/ofpart.c2
-rw-r--r--drivers/mtd/onenand/onenand_base.c2
-rw-r--r--drivers/net/bonding/bond_main.c9
-rw-r--r--drivers/net/bonding/bond_sysfs.c4
-rw-r--r--drivers/net/can/flexcan.c19
-rw-r--r--drivers/net/can/sja1000/peak_pci.c13
-rw-r--r--drivers/net/ethernet/8390/ne.c1
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c10
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c2
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c162
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c24
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c2
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/cxgb4.h19
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c39
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h3
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/t4_hw.c6
-rw-r--r--drivers/net/ethernet/freescale/gianfar.c5
-rw-r--r--drivers/net/ethernet/freescale/gianfar_ptp.c2
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c3
-rw-r--r--drivers/net/ethernet/jme.c36
-rw-r--r--drivers/net/ethernet/marvell/skge.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_tx.c3
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/eq.c24
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/main.c5
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/resource_tracker.c6
-rw-r--r--drivers/net/ethernet/micrel/ksz884x.c20
-rw-r--r--drivers/net/ethernet/nxp/lpc_eth.c1
-rw-r--r--drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c116
-rw-r--r--drivers/net/ethernet/qlogic/qla3xxx.c9
-rw-r--r--drivers/net/ethernet/realtek/8139cp.c22
-rw-r--r--drivers/net/ethernet/realtek/r8169.c5
-rw-r--r--drivers/net/ethernet/sis/sis900.c2
-rw-r--r--drivers/net/ethernet/smsc/smsc911x.c17
-rw-r--r--drivers/net/ethernet/ti/Kconfig2
-rw-r--r--drivers/net/ethernet/tile/tilegx.c37
-rw-r--r--drivers/net/ethernet/xilinx/xilinx_axienet_main.c16
-rw-r--r--drivers/net/ethernet/xscale/ixp4xx_eth.c8
-rw-r--r--drivers/net/irda/sir_dev.c2
-rw-r--r--drivers/net/phy/Kconfig5
-rw-r--r--drivers/net/phy/Makefile1
-rw-r--r--drivers/net/phy/at803x.c176
-rw-r--r--drivers/net/phy/mdio-gpio.c11
-rw-r--r--drivers/net/team/team_mode_broadcast.c6
-rw-r--r--drivers/net/usb/cdc_eem.c3
-rw-r--r--drivers/net/usb/cdc_ether.c41
-rw-r--r--drivers/net/usb/cdc_ncm.c22
-rw-r--r--drivers/net/usb/ipheth.c5
-rw-r--r--drivers/net/usb/qmi_wwan.c55
-rw-r--r--drivers/net/usb/smsc95xx.c5
-rw-r--r--drivers/net/usb/usbnet.c11
-rw-r--r--drivers/net/vmxnet3/vmxnet3_drv.c65
-rw-r--r--drivers/net/vxlan.c12
-rw-r--r--drivers/net/wan/ixp4xx_hss.c8
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h164
-rw-r--r--drivers/net/wireless/ath/ath9k/hif_usb.c1
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.c2
-rw-r--r--drivers/net/wireless/ath/ath9k/xmit.c10
-rw-r--r--drivers/net/wireless/b43/main.c4
-rw-r--r--drivers/net/wireless/b43legacy/pio.c2
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/usb.c2
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c72
-rw-r--r--drivers/net/wireless/ipw2x00/ipw2200.c2
-rw-r--r--drivers/net/wireless/iwlwifi/dvm/devices.c39
-rw-r--r--drivers/net/wireless/iwlwifi/dvm/mac80211.c16
-rw-r--r--drivers/net/wireless/iwlwifi/dvm/main.c2
-rw-r--r--drivers/net/wireless/iwlwifi/pcie/rx.c23
-rw-r--r--drivers/net/wireless/iwlwifi/pcie/tx.c8
-rw-r--r--drivers/net/wireless/mwifiex/cfg80211.c7
-rw-r--r--drivers/net/wireless/mwifiex/cmdevt.c11
-rw-r--r--drivers/net/wireless/mwifiex/scan.c13
-rw-r--r--drivers/net/wireless/mwifiex/sdio.c11
-rw-r--r--drivers/net/wireless/rt2x00/rt2500usb.c1
-rw-r--r--drivers/net/wireless/rt2x00/rt2800lib.c2
-rw-r--r--drivers/net/wireless/rt2x00/rt2800usb.c1
-rw-r--r--drivers/net/wireless/rt2x00/rt73usb.c1
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192cu/sw.c1
-rw-r--r--drivers/net/wireless/rtlwifi/usb.c2
-rw-r--r--drivers/net/xen-netfront.c98
-rw-r--r--drivers/nfc/pn533.c25
-rw-r--r--drivers/of/address.c24
-rw-r--r--drivers/of/irq.c8
-rw-r--r--drivers/of/platform.c2
-rw-r--r--drivers/pci/bus.c3
-rw-r--r--drivers/pci/pci-driver.c12
-rw-r--r--drivers/pci/pci-sysfs.c34
-rw-r--r--drivers/pci/pci.c32
-rw-r--r--drivers/pci/pci.h2
-rw-r--r--drivers/pci/pcie/aer/aerdrv_core.c20
-rw-r--r--drivers/pci/pcie/portdrv_core.c3
-rw-r--r--drivers/pci/proc.c8
-rw-r--r--drivers/pcmcia/pxa2xx_sharpsl.c2
-rw-r--r--drivers/pinctrl/Kconfig4
-rw-r--r--drivers/pinctrl/core.c4
-rw-r--r--drivers/pinctrl/pinconf.c4
-rw-r--r--drivers/pinctrl/pinctrl-bcm2835.c5
-rw-r--r--drivers/pinctrl/pinctrl-nomadik.c28
-rw-r--r--drivers/pinctrl/pinctrl-samsung.c10
-rw-r--r--drivers/pinctrl/pinctrl-sirf.c35
-rw-r--r--drivers/pinctrl/pinctrl-tegra.c2
-rw-r--r--drivers/pinctrl/pinctrl-tegra30.c24
-rw-r--r--drivers/pinctrl/pinctrl-xway.c2
-rw-r--r--drivers/pinctrl/spear/pinctrl-spear.c2
-rw-r--r--drivers/pinctrl/spear/pinctrl-spear1310.c365
-rw-r--r--drivers/pinctrl/spear/pinctrl-spear1340.c41
-rw-r--r--drivers/pinctrl/spear/pinctrl-spear320.c8
-rw-r--r--drivers/pinctrl/spear/pinctrl-spear3xx.h1
-rw-r--r--drivers/rapidio/rio.c2
-rw-r--r--drivers/regulator/core.c33
-rw-r--r--drivers/rtc/rtc-imxdi.c2
-rw-r--r--drivers/s390/char/con3215.c12
-rw-r--r--drivers/s390/cio/css.c7
-rw-r--r--drivers/s390/cio/css.h3
-rw-r--r--drivers/s390/cio/device.c8
-rw-r--r--drivers/s390/cio/idset.c25
-rw-r--r--drivers/s390/cio/idset.h3
-rw-r--r--drivers/s390/net/qeth_core_main.c24
-rw-r--r--drivers/s390/net/qeth_l2_main.c24
-rw-r--r--drivers/s390/net/qeth_l3_main.c11
-rw-r--r--drivers/s390/net/smsgiucv.c2
-rw-r--r--drivers/scsi/arm/fas216.c2
-rw-r--r--drivers/scsi/arm/oak.c1
-rw-r--r--drivers/scsi/isci/request.c2
-rw-r--r--drivers/scsi/qla2xxx/qla_mid.c3
-rw-r--r--drivers/scsi/qla2xxx/qla_target.c25
-rw-r--r--drivers/scsi/qla2xxx/qla_target.h1
-rw-r--r--drivers/scsi/qla2xxx/tcm_qla2xxx.c77
-rw-r--r--drivers/scsi/qla2xxx/tcm_qla2xxx.h2
-rw-r--r--drivers/scsi/qlogicpti.c13
-rw-r--r--drivers/scsi/scsi.c45
-rw-r--r--drivers/scsi/scsi_lib.c22
-rw-r--r--drivers/scsi/sd.c202
-rw-r--r--drivers/scsi/sd.h7
-rw-r--r--drivers/sh/intc/access.c45
-rw-r--r--drivers/sh/intc/chip.c4
-rw-r--r--drivers/spi/spi-mxs.c3
-rw-r--r--drivers/spi/spi-pl022.c3
-rw-r--r--drivers/spi/spi-rspi.c56
-rw-r--r--drivers/spi/spi-s3c64xx.c6
-rw-r--r--drivers/staging/android/android_alarm.h4
-rw-r--r--drivers/staging/android/binder.c30
-rw-r--r--drivers/staging/comedi/drivers/8255_pci.c2
-rw-r--r--drivers/staging/comedi/drivers/amplc_dio200.c2
-rw-r--r--drivers/staging/comedi/drivers/amplc_pc236.c5
-rw-r--r--drivers/staging/comedi/drivers/amplc_pc263.c2
-rw-r--r--drivers/staging/comedi/drivers/das08.c2
-rw-r--r--drivers/staging/comedi/drivers/ni_daq_700.c2
-rw-r--r--drivers/staging/comedi/drivers/ni_labpc.c2
-rw-r--r--drivers/staging/dgrp/dgrp_mon_ops.c1
-rw-r--r--drivers/staging/dgrp/dgrp_specproc.c7
-rw-r--r--drivers/staging/dgrp/dgrp_tty.c10
-rw-r--r--drivers/staging/gdm72xx/gdm_usb.c4
-rw-r--r--drivers/staging/iio/accel/adis16201_core.c24
-rw-r--r--drivers/staging/iio/accel/adis16203_core.c20
-rw-r--r--drivers/staging/iio/accel/adis16204_core.c22
-rw-r--r--drivers/staging/iio/accel/adis16209_core.c18
-rw-r--r--drivers/staging/iio/accel/adis16220_core.c19
-rw-r--r--drivers/staging/iio/accel/adis16240_core.c23
-rw-r--r--drivers/staging/iio/gyro/adis16260_core.c29
-rw-r--r--drivers/staging/iio/imu/adis16400.h2
-rw-r--r--drivers/staging/iio/imu/adis16400_core.c70
-rw-r--r--drivers/staging/ipack/bridges/tpci200.c1
-rw-r--r--drivers/staging/omapdrm/omap_gem.c4
-rw-r--r--drivers/staging/ramster/Kconfig1
-rw-r--r--drivers/staging/tidspbridge/core/tiomap3430.c37
-rw-r--r--drivers/staging/tidspbridge/hw/hw_mmu.c115
-rw-r--r--drivers/staging/tidspbridge/hw/hw_mmu.h31
-rw-r--r--drivers/staging/tidspbridge/include/dspbridge/cfgdefs.h4
-rw-r--r--drivers/staging/tidspbridge/include/dspbridge/host_os.h4
-rw-r--r--drivers/staging/tidspbridge/rmgr/drv.c8
-rw-r--r--drivers/staging/tidspbridge/rmgr/node.c21
-rw-r--r--drivers/staging/zram/zram_drv.c12
-rw-r--r--drivers/target/iscsi/iscsi_target.c4
-rw-r--r--drivers/target/iscsi/iscsi_target_core.h1
-rw-r--r--drivers/target/iscsi/iscsi_target_login.c1
-rw-r--r--drivers/target/iscsi/iscsi_target_util.c22
-rw-r--r--drivers/target/iscsi/iscsi_target_util.h1
-rw-r--r--drivers/target/target_core_configfs.c3
-rw-r--r--drivers/target/target_core_device.c18
-rw-r--r--drivers/target/target_core_sbc.c18
-rw-r--r--drivers/target/target_core_spc.c2
-rw-r--r--drivers/target/target_core_tmr.c6
-rw-r--r--drivers/target/target_core_transport.c1
-rw-r--r--drivers/thermal/Kconfig2
-rw-r--r--drivers/thermal/exynos_thermal.c2
-rw-r--r--drivers/thermal/rcar_thermal.c2
-rw-r--r--drivers/tty/hvc/hvc_console.c7
-rw-r--r--drivers/tty/serial/8250/8250_hp300.c20
-rw-r--r--drivers/tty/serial/Kconfig4
-rw-r--r--drivers/tty/serial/max310x.c1
-rw-r--r--drivers/tty/serial/omap-serial.c12
-rw-r--r--drivers/tty/serial/sccnxp.c1
-rw-r--r--drivers/tty/serial/sh-sci.c3
-rw-r--r--drivers/tty/sysrq.c1
-rw-r--r--drivers/usb/class/cdc-acm.c22
-rw-r--r--drivers/usb/core/devio.c1
-rw-r--r--drivers/usb/core/driver.c4
-rw-r--r--drivers/usb/core/hcd.c16
-rw-r--r--drivers/usb/core/hub.c43
-rw-r--r--drivers/usb/dwc3/core.c4
-rw-r--r--drivers/usb/dwc3/gadget.c2
-rw-r--r--drivers/usb/early/ehci-dbgp.c15
-rw-r--r--drivers/usb/gadget/Kconfig1
-rw-r--r--drivers/usb/gadget/lpc32xx_udc.c4
-rw-r--r--drivers/usb/gadget/net2272.c4
-rw-r--r--drivers/usb/gadget/u_ether.c3
-rw-r--r--drivers/usb/host/ehci-fsl.c2
-rw-r--r--drivers/usb/host/ehci-ls1x.c2
-rw-r--r--drivers/usb/host/ehci-orion.c2
-rw-r--r--drivers/usb/host/ehci-vt8500.c10
-rw-r--r--drivers/usb/host/ohci-xls.c2
-rw-r--r--drivers/usb/host/pci-quirks.c9
-rw-r--r--drivers/usb/host/uhci-platform.c9
-rw-r--r--drivers/usb/host/xhci-dbg.c2
-rw-r--r--drivers/usb/host/xhci-hub.c9
-rw-r--r--drivers/usb/host/xhci-ring.c11
-rw-r--r--drivers/usb/host/xhci.c11
-rw-r--r--drivers/usb/misc/ezusb.c1
-rw-r--r--drivers/usb/musb/am35x.c6
-rw-r--r--drivers/usb/musb/musb_dsps.c8
-rw-r--r--drivers/usb/musb/musb_gadget.c30
-rw-r--r--drivers/usb/musb/ux500.c2
-rw-r--r--drivers/usb/otg/Kconfig4
-rw-r--r--drivers/usb/renesas_usbhs/fifo.c1
-rw-r--r--drivers/usb/renesas_usbhs/mod.c6
-rw-r--r--drivers/usb/renesas_usbhs/mod_host.c5
-rw-r--r--drivers/usb/renesas_usbhs/pipe.h2
-rw-r--r--drivers/usb/serial/ark3116.c26
-rw-r--r--drivers/usb/serial/belkin_sa.c31
-rw-r--r--drivers/usb/serial/ch341.c23
-rw-r--r--drivers/usb/serial/cp210x.c40
-rw-r--r--drivers/usb/serial/cyberjack.c49
-rw-r--r--drivers/usb/serial/cypress_m8.c75
-rw-r--r--drivers/usb/serial/digi_acceleport.c117
-rw-r--r--drivers/usb/serial/f81232.c43
-rw-r--r--drivers/usb/serial/garmin_gps.c24
-rw-r--r--drivers/usb/serial/io_edgeport.c54
-rw-r--r--drivers/usb/serial/io_tables.h8
-rw-r--r--drivers/usb/serial/io_ti.c91
-rw-r--r--drivers/usb/serial/ipw.c7
-rw-r--r--drivers/usb/serial/iuu_phoenix.c76
-rw-r--r--drivers/usb/serial/keyspan.c180
-rw-r--r--drivers/usb/serial/keyspan.h8
-rw-r--r--drivers/usb/serial/keyspan_pda.c30
-rw-r--r--drivers/usb/serial/kl5kusb105.c68
-rw-r--r--drivers/usb/serial/kobil_sct.c23
-rw-r--r--drivers/usb/serial/mct_u232.c59
-rw-r--r--drivers/usb/serial/metro-usb.c65
-rw-r--r--drivers/usb/serial/mos7720.c62
-rw-r--r--drivers/usb/serial/mos7840.c495
-rw-r--r--drivers/usb/serial/omninet.c36
-rw-r--r--drivers/usb/serial/opticon.c11
-rw-r--r--drivers/usb/serial/option.c116
-rw-r--r--drivers/usb/serial/oti6858.c68
-rw-r--r--drivers/usb/serial/pl2303.c90
-rw-r--r--drivers/usb/serial/qcserial.c33
-rw-r--r--drivers/usb/serial/quatech2.c135
-rw-r--r--drivers/usb/serial/sierra.c133
-rw-r--r--drivers/usb/serial/spcp8x5.c46
-rw-r--r--drivers/usb/serial/ssu100.c34
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.c88
-rw-r--r--drivers/usb/serial/usb-wwan.h2
-rw-r--r--drivers/usb/serial/usb_wwan.c130
-rw-r--r--drivers/usb/serial/whiteheat.c60
-rw-r--r--drivers/usb/storage/scsiglue.c6
-rw-r--r--drivers/usb/storage/unusual_devs.h6
-rw-r--r--drivers/vhost/net.c3
-rw-r--r--drivers/video/backlight/Kconfig3
-rw-r--r--drivers/video/backlight/lm3639_bl.c4
-rw-r--r--drivers/video/omap2/dss/dsi.c13
-rw-r--r--drivers/video/omap2/dss/dss.c18
-rw-r--r--drivers/video/omap2/dss/hdmi.c4
-rw-r--r--drivers/video/omap2/omapfb/omapfb-ioctl.c2
-rw-r--r--drivers/video/xen-fbfront.c5
-rw-r--r--drivers/virtio/virtio.c4
-rw-r--r--drivers/xen/Kconfig2
-rw-r--r--drivers/xen/Makefile1
-rw-r--r--drivers/xen/balloon.c3
-rw-r--r--drivers/xen/dbgp.c2
-rw-r--r--drivers/xen/events.c6
-rw-r--r--drivers/xen/fallback.c80
-rw-r--r--drivers/xen/gntdev.c36
-rw-r--r--drivers/xen/grant-table.c8
-rw-r--r--drivers/xen/privcmd.c18
-rw-r--r--drivers/xen/sys-hypervisor.c4
-rw-r--r--drivers/xen/xen-pciback/vpci.c14
-rw-r--r--drivers/xen/xenbus/xenbus_dev_frontend.c2
-rw-r--r--drivers/xen/xenbus/xenbus_xs.c4
-rw-r--r--fs/bio.c6
-rw-r--r--fs/block_dev.c37
-rw-r--r--fs/btrfs/backref.c28
-rw-r--r--fs/btrfs/backref.h4
-rw-r--r--fs/btrfs/ctree.c70
-rw-r--r--fs/btrfs/ctree.h3
-rw-r--r--fs/btrfs/extent_io.c4
-rw-r--r--fs/btrfs/inode.c7
-rw-r--r--fs/btrfs/ioctl.c6
-rw-r--r--fs/btrfs/qgroup.c17
-rw-r--r--fs/btrfs/send.c156
-rw-r--r--fs/btrfs/transaction.c2
-rw-r--r--fs/btrfs/volumes.c7
-rw-r--r--fs/ceph/export.c2
-rw-r--r--fs/char_dev.c18
-rw-r--r--fs/cifs/cifsacl.c49
-rw-r--r--fs/cifs/dir.c11
-rw-r--r--fs/compat_ioctl.c2
-rw-r--r--fs/coredump.c5
-rw-r--r--fs/eventpoll.c38
-rw-r--r--fs/exec.c3
-rw-r--r--fs/ext2/super.c4
-rw-r--r--fs/ext3/balloc.c5
-rw-r--r--fs/ext3/namei.c40
-rw-r--r--fs/ext3/namei.h19
-rw-r--r--fs/ext3/super.c4
-rw-r--r--fs/ext4/balloc.c8
-rw-r--r--fs/ext4/bitmap.c6
-rw-r--r--fs/ext4/ext4.h7
-rw-r--r--fs/ext4/ext4_jbd2.c8
-rw-r--r--fs/ext4/extents.c60
-rw-r--r--fs/ext4/ialloc.c23
-rw-r--r--fs/ext4/mballoc.c14
-rw-r--r--fs/ext4/resize.c3
-rw-r--r--fs/ext4/super.c9
-rw-r--r--fs/file.c11
-rw-r--r--fs/fs_struct.c24
-rw-r--r--fs/gfs2/file.c14
-rw-r--r--fs/gfs2/lops.c16
-rw-r--r--fs/gfs2/quota.c7
-rw-r--r--fs/gfs2/rgrp.c33
-rw-r--r--fs/gfs2/super.c3
-rw-r--r--fs/gfs2/trans.c8
-rw-r--r--fs/jffs2/file.c39
-rw-r--r--fs/jfs/jfs_discard.c16
-rw-r--r--fs/lockd/clntxdr.c2
-rw-r--r--fs/lockd/mon.c57
-rw-r--r--fs/lockd/svcproc.c3
-rw-r--r--fs/namei.c4
-rw-r--r--fs/nfs/callback.c2
-rw-r--r--fs/nfs/dns_resolve.c5
-rw-r--r--fs/nfs/inode.c5
-rw-r--r--fs/nfs/internal.h6
-rw-r--r--fs/nfs/mount_clnt.c2
-rw-r--r--fs/nfs/namespace.c19
-rw-r--r--fs/nfs/nfs4filelayout.c21
-rw-r--r--fs/nfs/nfs4filelayout.h1
-rw-r--r--fs/nfs/nfs4filelayoutdev.c22
-rw-r--r--fs/nfs/nfs4getroot.c1
-rw-r--r--fs/nfs/nfs4namespace.c3
-rw-r--r--fs/nfs/nfs4proc.c46
-rw-r--r--fs/nfs/objlayout/objio_osd.c6
-rw-r--r--fs/nfs/pnfs.c4
-rw-r--r--fs/nfs/pnfs.h1
-rw-r--r--fs/nfs/super.c51
-rw-r--r--fs/nfs/unlink.c2
-rw-r--r--fs/notify/fanotify/fanotify.c1
-rw-r--r--fs/notify/fanotify/fanotify_user.c3
-rw-r--r--fs/proc/base.c109
-rw-r--r--fs/proc/internal.h4
-rw-r--r--fs/proc/stat.c14
-rw-r--r--fs/proc/task_mmu.c53
-rw-r--r--fs/pstore/platform.c3
-rw-r--r--fs/quota/dquot.c2
-rw-r--r--fs/reiserfs/inode.c10
-rw-r--r--fs/reiserfs/stree.c4
-rw-r--r--fs/reiserfs/super.c60
-rw-r--r--fs/sysfs/dir.c16
-rw-r--r--fs/ubifs/find.c12
-rw-r--r--fs/ubifs/lprops.c6
-rw-r--r--fs/ubifs/ubifs.h3
-rw-r--r--fs/xattr.c2
-rw-r--r--fs/xfs/xfs_alloc.c43
-rw-r--r--fs/xfs/xfs_alloc.h3
-rw-r--r--fs/xfs/xfs_alloc_btree.c2
-rw-r--r--fs/xfs/xfs_aops.c54
-rw-r--r--fs/xfs/xfs_attr_leaf.c20
-rw-r--r--fs/xfs/xfs_bmap.c63
-rw-r--r--fs/xfs/xfs_bmap.h9
-rw-r--r--fs/xfs/xfs_buf.c14
-rw-r--r--fs/xfs/xfs_buf_item.c18
-rw-r--r--fs/xfs/xfs_fsops.c21
-rw-r--r--fs/xfs/xfs_ialloc.c1
-rw-r--r--fs/xfs/xfs_inode.c3
-rw-r--r--fs/xfs/xfs_ioctl.c2
-rw-r--r--fs/xfs/xfs_iomap.c4
-rw-r--r--fs/xfs/xfs_log.c19
-rw-r--r--fs/xfs/xfs_log_recover.c2
-rw-r--r--include/Kbuild4
-rw-r--r--include/asm-generic/Kbuild0
-rw-r--r--include/asm-generic/syscalls.h7
-rw-r--r--include/drm/Kbuild0
-rw-r--r--include/drm/drm_pciids.h4
-rw-r--r--include/linux/Kbuild26
-rw-r--r--include/linux/byteorder/Kbuild0
-rw-r--r--include/linux/caif/Kbuild0
-rw-r--r--include/linux/can/Kbuild0
-rw-r--r--include/linux/clk-provider.h4
-rw-r--r--include/linux/compat.h2
-rw-r--r--include/linux/coredump.h1
-rw-r--r--include/linux/dvb/Kbuild8
-rw-r--r--include/linux/dvb/dmx.h130
-rw-r--r--include/linux/dvb/video.h249
-rw-r--r--include/linux/dynamic_debug.h2
-rw-r--r--include/linux/elf-fdpic.h51
-rw-r--r--include/linux/extcon.h2
-rw-r--r--include/linux/fdtable.h1
-rw-r--r--include/linux/fs.h126
-rw-r--r--include/linux/fs_struct.h1
-rw-r--r--include/linux/hashtable.h192
-rw-r--r--include/linux/hsi/Kbuild1
-rw-r--r--include/linux/i2c-omap.h1
-rw-r--r--include/linux/iio/iio.h16
-rw-r--r--include/linux/isdn/Kbuild0
-rw-r--r--include/linux/kvm_host.h15
-rw-r--r--include/linux/memblock.h1
-rw-r--r--include/linux/mfd/max77693.h13
-rw-r--r--include/linux/mm.h4
-rw-r--r--include/linux/mmc/Kbuild0
-rw-r--r--include/linux/mmc/dw_mmc.h6
-rw-r--r--include/linux/mmc/sdhci.h1
-rw-r--r--include/linux/mmzone.h2
-rw-r--r--include/linux/netfilter/Kbuild1
-rw-r--r--include/linux/netfilter/ipset/Kbuild0
-rw-r--r--include/linux/netfilter_arp/Kbuild0
-rw-r--r--include/linux/netfilter_bridge/Kbuild0
-rw-r--r--include/linux/netfilter_ipv4/Kbuild0
-rw-r--r--include/linux/netfilter_ipv6/Kbuild0
-rw-r--r--include/linux/nfsd/Kbuild0
-rw-r--r--include/linux/of.h7
-rw-r--r--include/linux/of_address.h8
-rw-r--r--include/linux/of_irq.h4
-rw-r--r--include/linux/percpu-rwsem.h28
-rw-r--r--include/linux/perf_event.h10
-rw-r--r--include/linux/pid_namespace.h8
-rw-r--r--include/linux/platform_data/omap_ocp2scp.h31
-rw-r--r--include/linux/ptp_clock_kernel.h3
-rw-r--r--include/linux/raid/Kbuild2
-rw-r--r--include/linux/raid/md_u.h141
-rw-r--r--include/linux/ratelimit.h27
-rw-r--r--include/linux/rbtree_augmented.h1
-rw-r--r--include/linux/rio.h2
-rw-r--r--include/linux/sched.h1
-rw-r--r--include/linux/spi/Kbuild0
-rw-r--r--include/linux/spi/ads7846.h5
-rw-r--r--include/linux/spi/tsc2005.h2
-rw-r--r--include/linux/sunrpc/Kbuild0
-rw-r--r--include/linux/tc_act/Kbuild0
-rw-r--r--include/linux/tc_ematch/Kbuild0
-rw-r--r--include/linux/tcp.h3
-rw-r--r--include/linux/uprobes.h11
-rw-r--r--include/linux/usb.h11
-rw-r--r--include/linux/usb/Kbuild10
-rw-r--r--include/linux/usb/audio.h524
-rw-r--r--include/linux/usb/ch9.h960
-rw-r--r--include/linux/usb/functionfs.h167
-rw-r--r--include/linux/wimax/Kbuild0
-rw-r--r--include/mtd/Kbuild0
-rw-r--r--include/net/cfg80211.h10
-rw-r--r--include/net/xfrm.h2
-rw-r--r--include/scsi/scsi_device.h4
-rw-r--r--include/sound/core.h3
-rw-r--r--include/trace/events/xen.h8
-rw-r--r--include/uapi/asm-generic/kvm_para.h4
-rw-r--r--include/uapi/linux/dvb/Kbuild8
-rw-r--r--include/uapi/linux/dvb/audio.h (renamed from include/linux/dvb/audio.h)0
-rw-r--r--include/uapi/linux/dvb/ca.h (renamed from include/linux/dvb/ca.h)0
-rw-r--r--include/uapi/linux/dvb/dmx.h155
-rw-r--r--include/uapi/linux/dvb/frontend.h (renamed from include/linux/dvb/frontend.h)0
-rw-r--r--include/uapi/linux/dvb/net.h (renamed from include/linux/dvb/net.h)0
-rw-r--r--include/uapi/linux/dvb/osd.h (renamed from include/linux/dvb/osd.h)0
-rw-r--r--include/uapi/linux/dvb/version.h (renamed from include/linux/dvb/version.h)0
-rw-r--r--include/uapi/linux/dvb/video.h274
-rw-r--r--include/uapi/linux/elf-fdpic.h42
-rw-r--r--include/uapi/linux/eventpoll.h1
-rw-r--r--include/uapi/linux/fs.h132
-rw-r--r--include/uapi/linux/hsi/Kbuild1
-rw-r--r--include/uapi/linux/hsi/hsi_char.h (renamed from include/linux/hsi/hsi_char.h)0
-rw-r--r--include/uapi/linux/irqnr.h4
-rw-r--r--include/uapi/linux/oom.h9
-rw-r--r--include/uapi/linux/raid/Kbuild2
-rw-r--r--include/uapi/linux/raid/md_p.h (renamed from include/linux/raid/md_p.h)0
-rw-r--r--include/uapi/linux/raid/md_u.h155
-rw-r--r--include/uapi/linux/tcp.h1
-rw-r--r--include/uapi/linux/usb/Kbuild10
-rw-r--r--include/uapi/linux/usb/audio.h545
-rw-r--r--include/uapi/linux/usb/cdc.h (renamed from include/linux/usb/cdc.h)0
-rw-r--r--include/uapi/linux/usb/ch11.h (renamed from include/linux/usb/ch11.h)0
-rw-r--r--include/uapi/linux/usb/ch9.h993
-rw-r--r--include/uapi/linux/usb/functionfs.h169
-rw-r--r--include/uapi/linux/usb/g_printer.h (renamed from include/linux/usb/g_printer.h)0
-rw-r--r--include/uapi/linux/usb/gadgetfs.h (renamed from include/linux/usb/gadgetfs.h)0
-rw-r--r--include/uapi/linux/usb/midi.h (renamed from include/linux/usb/midi.h)0
-rw-r--r--include/uapi/linux/usb/tmc.h (renamed from include/linux/usb/tmc.h)0
-rw-r--r--include/uapi/linux/usb/video.h (renamed from include/linux/usb/video.h)0
-rw-r--r--include/xen/Kbuild0
-rw-r--r--include/xen/grant_table.h2
-rw-r--r--include/xen/hvm.h34
-rw-r--r--include/xen/interface/grant_table.h2
-rw-r--r--include/xen/interface/memory.h24
-rw-r--r--init/main.c2
-rw-r--r--kernel/Makefile6
-rw-r--r--kernel/cgroup.c41
-rw-r--r--kernel/events/uprobes.c345
-rw-r--r--kernel/exit.c92
-rw-r--r--kernel/fork.c43
-rw-r--r--kernel/futex.c41
-rw-r--r--kernel/module-internal.h3
-rw-r--r--kernel/module.c53
-rw-r--r--kernel/module_signing.c24
-rw-r--r--kernel/pid_namespace.c33
-rw-r--r--kernel/printk.c1
-rw-r--r--kernel/sys.c12
-rw-r--r--kernel/trace/ring_buffer.c4
-rw-r--r--kernel/workqueue.c2
-rw-r--r--lib/dma-debug.c4
-rw-r--r--lib/genalloc.c2
-rw-r--r--lib/mpi/longlong.h19
-rw-r--r--mm/bootmem.c10
-rw-r--r--mm/compaction.c2
-rw-r--r--mm/fremap.c2
-rw-r--r--mm/highmem.c2
-rw-r--r--mm/huge_memory.c1
-rw-r--r--mm/memblock.c24
-rw-r--r--mm/memcontrol.c67
-rw-r--r--mm/memory.c10
-rw-r--r--mm/memory_hotplug.c7
-rw-r--r--mm/mempolicy.c5
-rw-r--r--mm/mmap.c2
-rw-r--r--mm/mmu_notifier.c26
-rw-r--r--mm/mmzone.c6
-rw-r--r--mm/nobootmem.c3
-rw-r--r--mm/page_alloc.c44
-rw-r--r--mm/rmap.c20
-rw-r--r--mm/shmem.c18
-rw-r--r--mm/slob.c6
-rw-r--r--mm/swapfile.c4
-rw-r--r--mm/vmscan.c27
-rw-r--r--net/8021q/vlan.c4
-rw-r--r--net/8021q/vlan_core.c9
-rw-r--r--net/batman-adv/bridge_loop_avoidance.c27
-rw-r--r--net/batman-adv/routing.c8
-rw-r--r--net/batman-adv/soft-interface.c12
-rw-r--r--net/batman-adv/translation-table.c15
-rw-r--r--net/batman-adv/types.h2
-rw-r--r--net/bluetooth/hci_core.c4
-rw-r--r--net/bluetooth/mgmt.c12
-rw-r--r--net/bluetooth/smp.c8
-rw-r--r--net/ceph/messenger.c6
-rw-r--r--net/core/dev.c6
-rw-r--r--net/core/dev_addr_lists.c3
-rw-r--r--net/core/net-sysfs.c20
-rw-r--r--net/core/rtnetlink.c3
-rw-r--r--net/core/skbuff.c6
-rw-r--r--net/ipv4/inet_diag.c5
-rw-r--r--net/ipv4/ip_sockglue.c35
-rw-r--r--net/ipv4/ip_vti.c5
-rw-r--r--net/ipv4/netfilter/iptable_nat.c4
-rw-r--r--net/ipv4/route.c18
-rw-r--r--net/ipv4/tcp.c14
-rw-r--r--net/ipv4/tcp_illinois.c8
-rw-r--r--net/ipv4/tcp_input.c31
-rw-r--r--net/ipv4/tcp_ipv4.c1
-rw-r--r--net/ipv4/tcp_metrics.c14
-rw-r--r--net/ipv4/tcp_minisocks.c1
-rw-r--r--net/ipv4/tcp_output.c4
-rw-r--r--net/ipv4/tcp_timer.c4
-rw-r--r--net/ipv4/xfrm4_policy.c13
-rw-r--r--net/ipv6/addrconf.c15
-rw-r--r--net/ipv6/inet6_connection_sock.c3
-rw-r--r--net/ipv6/ip6_gre.c8
-rw-r--r--net/ipv6/ipv6_sockglue.c1
-rw-r--r--net/ipv6/ndisc.c3
-rw-r--r--net/ipv6/netfilter/ip6table_nat.c4
-rw-r--r--net/ipv6/netfilter/nf_conntrack_reasm.c4
-rw-r--r--net/ipv6/route.c4
-rw-r--r--net/irda/ircomm/ircomm_tty.c2
-rw-r--r--net/l2tp/l2tp_eth.c1
-rw-r--r--net/mac80211/cfg.c3
-rw-r--r--net/mac80211/ibss.c10
-rw-r--r--net/mac80211/ieee80211_i.h2
-rw-r--r--net/mac80211/iface.c2
-rw-r--r--net/mac80211/main.c6
-rw-r--r--net/mac80211/mlme.c35
-rw-r--r--net/mac80211/rx.c74
-rw-r--r--net/mac80211/scan.c2
-rw-r--r--net/mac80211/sta_info.c15
-rw-r--r--net/mac80211/status.c9
-rw-r--r--net/mac80211/tx.c9
-rw-r--r--net/mac80211/util.c48
-rw-r--r--net/mac80211/wpa.c14
-rw-r--r--net/netfilter/ipset/ip_set_hash_ip.c4
-rw-r--r--net/netfilter/ipset/ip_set_hash_ipport.c7
-rw-r--r--net/netfilter/ipset/ip_set_hash_ipportip.c7
-rw-r--r--net/netfilter/ipset/ip_set_hash_ipportnet.c7
-rw-r--r--net/netfilter/ipvs/ip_vs_ctl.c3
-rw-r--r--net/netfilter/nf_conntrack_h323_main.c3
-rw-r--r--net/netfilter/nfnetlink_cttimeout.c3
-rw-r--r--net/netfilter/xt_CT.c10
-rw-r--r--net/netfilter/xt_TEE.c1
-rw-r--r--net/netfilter/xt_nat.c8
-rw-r--r--net/netlink/af_netlink.c19
-rw-r--r--net/nfc/llcp/llcp.c2
-rw-r--r--net/sched/sch_qfq.c109
-rw-r--r--net/sctp/proc.c8
-rw-r--r--net/sctp/sm_sideeffect.c3
-rw-r--r--net/sctp/socket.c2
-rw-r--r--net/sunrpc/backchannel_rqst.c2
-rw-r--r--net/sunrpc/cache.c4
-rw-r--r--net/sunrpc/xprtsock.c41
-rw-r--r--net/tipc/handler.c1
-rw-r--r--net/wireless/core.c3
-rw-r--r--net/wireless/mlme.c12
-rw-r--r--net/wireless/reg.c10
-rw-r--r--net/wireless/util.c14
-rw-r--r--scripts/Makefile.asm-generic2
-rw-r--r--scripts/Makefile.fwinst4
-rw-r--r--scripts/Makefile.modinst3
-rw-r--r--scripts/Makefile.modpost77
-rwxr-xr-xscripts/checkpatch.pl6
-rw-r--r--scripts/dtc/dtc.h44
-rw-r--r--scripts/kconfig/expr.h5
-rw-r--r--scripts/kconfig/list.h91
-rw-r--r--scripts/kconfig/lkc_proto.h4
-rw-r--r--scripts/kconfig/mconf.c6
-rw-r--r--scripts/kconfig/menu.c14
-rwxr-xr-x[-rw-r--r--]scripts/sign-file498
-rwxr-xr-xscripts/x509keyid268
-rw-r--r--security/apparmor/Makefile2
-rw-r--r--security/apparmor/policy.c24
-rw-r--r--security/device_cgroup.c101
-rw-r--r--security/selinux/hooks.c18
-rw-r--r--security/selinux/netnode.c3
-rw-r--r--sound/core/compress_offload.c9
-rw-r--r--sound/core/control.c5
-rw-r--r--sound/core/hwdep.c12
-rw-r--r--sound/core/init.c50
-rw-r--r--sound/core/oss/mixer_oss.c11
-rw-r--r--sound/core/oss/pcm_oss.c7
-rw-r--r--sound/core/pcm.c13
-rw-r--r--sound/core/pcm_native.c35
-rw-r--r--sound/core/rawmidi.c26
-rw-r--r--sound/core/sound.c11
-rw-r--r--sound/core/sound_oss.c10
-rw-r--r--sound/i2c/other/ak4113.c2
-rw-r--r--sound/i2c/other/ak4114.c2
-rw-r--r--sound/i2c/other/ak4117.c2
-rw-r--r--sound/isa/opti9xx/miro.c1
-rw-r--r--sound/pci/ac97/ac97_codec.c2
-rw-r--r--sound/pci/als300.c4
-rw-r--r--sound/pci/emu10k1/emu10k1_main.c9
-rw-r--r--sound/pci/es1968.c11
-rw-r--r--sound/pci/fm801.c11
-rw-r--r--sound/pci/hda/hda_codec.c13
-rw-r--r--sound/pci/hda/hda_codec.h1
-rw-r--r--sound/pci/hda/hda_intel.c83
-rw-r--r--sound/pci/hda/patch_analog.c1
-rw-r--r--sound/pci/hda/patch_cirrus.c22
-rw-r--r--sound/pci/hda/patch_realtek.c52
-rw-r--r--sound/pci/hda/patch_sigmatel.c2
-rw-r--r--sound/pci/hda/patch_via.c36
-rw-r--r--sound/pci/ice1712/ice1724.c7
-rw-r--r--sound/pci/rme9652/hdspm.c239
-rw-r--r--sound/soc/Makefile5
-rw-r--r--sound/soc/codecs/arizona.c4
-rw-r--r--sound/soc/codecs/cs4271.c11
-rw-r--r--sound/soc/codecs/cs42l52.c5
-rw-r--r--sound/soc/codecs/da9055.c22
-rw-r--r--sound/soc/codecs/twl6040.c8
-rw-r--r--sound/soc/codecs/wm2200.c3
-rw-r--r--sound/soc/codecs/wm5102.c552
-rw-r--r--sound/soc/codecs/wm8978.c2
-rw-r--r--sound/soc/codecs/wm8994.c20
-rw-r--r--sound/soc/codecs/wm8994.h1
-rw-r--r--sound/soc/kirkwood/kirkwood-dma.c3
-rw-r--r--sound/soc/kirkwood/kirkwood-i2s.c74
-rw-r--r--sound/soc/mxs/mxs-saif.c17
-rw-r--r--sound/soc/omap/ams-delta.c63
-rw-r--r--sound/soc/omap/omap-abe-twl6040.c2
-rw-r--r--sound/soc/omap/omap-dmic.c4
-rw-r--r--sound/soc/omap/omap-mcpdm.c9
-rw-r--r--sound/soc/omap/zoom2.c5
-rw-r--r--sound/soc/pxa/mmp-pcm.c2
-rw-r--r--sound/soc/samsung/Kconfig2
-rw-r--r--sound/soc/samsung/bells.c2
-rw-r--r--sound/soc/sh/fsi.c15
-rw-r--r--sound/soc/soc-core.c5
-rw-r--r--sound/soc/soc-dapm.c2
-rw-r--r--sound/soc/soc-jack.c7
-rw-r--r--sound/soc/ux500/mop500.c17
-rw-r--r--sound/soc/ux500/ux500_msp_i2s.c8
-rw-r--r--sound/usb/card.c14
-rw-r--r--sound/usb/card.h1
-rw-r--r--sound/usb/endpoint.c13
-rw-r--r--sound/usb/endpoint.h1
-rw-r--r--sound/usb/midi.c8
-rw-r--r--sound/usb/mixer.c65
-rw-r--r--sound/usb/mixer_quirks.c58
-rw-r--r--sound/usb/pcm.c58
-rw-r--r--sound/usb/proc.c4
-rw-r--r--sound/usb/stream.c1
-rw-r--r--sound/usb/usbaudio.h2
-rw-r--r--tools/lib/traceevent/event-parse.c9
-rw-r--r--tools/lib/traceevent/parse-filter.c15
-rw-r--r--tools/perf/Makefile24
-rw-r--r--tools/perf/builtin-help.c2
-rw-r--r--tools/perf/builtin-trace.c18
-rw-r--r--tools/perf/perf.h2
-rw-r--r--tools/perf/ui/browsers/hists.c6
-rw-r--r--tools/perf/util/parse-events-test.c12
-rw-r--r--tools/perf/util/parse-events.c3
-rw-r--r--tools/perf/util/setup.py2
-rw-r--r--tools/perf/util/sort.c6
-rw-r--r--tools/perf/util/thread.c1
-rw-r--r--tools/power/x86/turbostat/turbostat.c28
-rwxr-xr-xtools/testing/ktest/ktest.pl6
-rw-r--r--tools/testing/selftests/Makefile2
-rw-r--r--tools/testing/selftests/epoll/Makefile11
-rw-r--r--tools/testing/selftests/epoll/test_epoll.c344
-rw-r--r--tools/vm/page-types.c2
-rw-r--r--usr/gen_init_cpio.c43
-rw-r--r--virt/kvm/kvm_main.c4
1771 files changed, 22910 insertions, 18218 deletions
diff --git a/.gitignore b/.gitignore
index 0f2f40f7191..92bd0e45dfa 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,10 +14,6 @@
14*.o.* 14*.o.*
15*.a 15*.a
16*.s 16*.s
17*.ko.unsigned
18*.ko.stripped
19*.ko.stripped.dig
20*.ko.stripped.sig
21*.ko 17*.ko
22*.so 18*.so
23*.so.dbg 19*.so.dbg
@@ -95,6 +91,4 @@ GTAGS
95extra_certificates 91extra_certificates
96signing_key.priv 92signing_key.priv
97signing_key.x509 93signing_key.x509
98signing_key.x509.keyid
99signing_key.x509.signer
100x509.genkey 94x509.genkey
diff --git a/CREDITS b/CREDITS
index d8fe12a9421..2346b09ca8b 100644
--- a/CREDITS
+++ b/CREDITS
@@ -1823,6 +1823,11 @@ S: Kattreinstr 38
1823S: D-64295 1823S: D-64295
1824S: Germany 1824S: Germany
1825 1825
1826N: Avi Kivity
1827E: avi.kivity@gmail.com
1828D: Kernel-based Virtual Machine (KVM)
1829S: Ra'annana, Israel
1830
1826N: Andi Kleen 1831N: Andi Kleen
1827E: andi@firstfloor.org 1832E: andi@firstfloor.org
1828U: http://www.halobates.de 1833U: http://www.halobates.de
diff --git a/Documentation/00-INDEX b/Documentation/00-INDEX
index f54273e2ac9..ceb1ff73546 100644
--- a/Documentation/00-INDEX
+++ b/Documentation/00-INDEX
@@ -210,6 +210,8 @@ local_ops.txt
210 - semantics and behavior of local atomic operations. 210 - semantics and behavior of local atomic operations.
211lockdep-design.txt 211lockdep-design.txt
212 - documentation on the runtime locking correctness validator. 212 - documentation on the runtime locking correctness validator.
213lockup-watchdogs.txt
214 - info on soft and hard lockup detectors (aka nmi_watchdog).
213logo.gif 215logo.gif
214 - full colour GIF image of Linux logo (penguin - Tux). 216 - full colour GIF image of Linux logo (penguin - Tux).
215logo.txt 217logo.txt
@@ -240,8 +242,6 @@ netlabel/
240 - directory with information on the NetLabel subsystem. 242 - directory with information on the NetLabel subsystem.
241networking/ 243networking/
242 - directory with info on various aspects of networking with Linux. 244 - directory with info on various aspects of networking with Linux.
243nmi_watchdog.txt
244 - info on NMI watchdog for SMP systems.
245nommu-mmap.txt 245nommu-mmap.txt
246 - documentation about no-mmu memory mapping support. 246 - documentation about no-mmu memory mapping support.
247numastat.txt 247numastat.txt
diff --git a/Documentation/DocBook/media/Makefile b/Documentation/DocBook/media/Makefile
index 9b7e4c55792..f9fd615427f 100644
--- a/Documentation/DocBook/media/Makefile
+++ b/Documentation/DocBook/media/Makefile
@@ -56,15 +56,15 @@ FUNCS = \
56 write \ 56 write \
57 57
58IOCTLS = \ 58IOCTLS = \
59 $(shell perl -ne 'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree)/include/linux/videodev2.h) \ 59 $(shell perl -ne 'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree)/include/uapi/linux/videodev2.h) \
60 $(shell perl -ne 'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree)/include/linux/dvb/audio.h) \ 60 $(shell perl -ne 'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree)/include/uapi/linux/dvb/audio.h) \
61 $(shell perl -ne 'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree)/include/linux/dvb/ca.h) \ 61 $(shell perl -ne 'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree)/include/uapi/linux/dvb/ca.h) \
62 $(shell perl -ne 'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree)/include/linux/dvb/dmx.h) \ 62 $(shell perl -ne 'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree)/include/uapi/linux/dvb/dmx.h) \
63 $(shell perl -ne 'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree)/include/linux/dvb/frontend.h) \ 63 $(shell perl -ne 'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree)/include/uapi/linux/dvb/frontend.h) \
64 $(shell perl -ne 'print "$$1 " if /\#define\s+([A-Z][^\s]+)\s+_IO/' $(srctree)/include/linux/dvb/net.h) \ 64 $(shell perl -ne 'print "$$1 " if /\#define\s+([A-Z][^\s]+)\s+_IO/' $(srctree)/include/uapi/linux/dvb/net.h) \
65 $(shell perl -ne 'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree)/include/linux/dvb/video.h) \ 65 $(shell perl -ne 'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree)/include/uapi/linux/dvb/video.h) \
66 $(shell perl -ne 'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree)/include/linux/media.h) \ 66 $(shell perl -ne 'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree)/include/uapi/linux/media.h) \
67 $(shell perl -ne 'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree)/include/linux/v4l2-subdev.h) \ 67 $(shell perl -ne 'print "$$1 " if /\#define\s+([^\s]+)\s+_IO/' $(srctree)/include/uapi/linux/v4l2-subdev.h) \
68 VIDIOC_SUBDEV_G_FRAME_INTERVAL \ 68 VIDIOC_SUBDEV_G_FRAME_INTERVAL \
69 VIDIOC_SUBDEV_S_FRAME_INTERVAL \ 69 VIDIOC_SUBDEV_S_FRAME_INTERVAL \
70 VIDIOC_SUBDEV_ENUM_MBUS_CODE \ 70 VIDIOC_SUBDEV_ENUM_MBUS_CODE \
@@ -74,32 +74,32 @@ IOCTLS = \
74 VIDIOC_SUBDEV_S_SELECTION \ 74 VIDIOC_SUBDEV_S_SELECTION \
75 75
76TYPES = \ 76TYPES = \
77 $(shell perl -ne 'print "$$1 " if /^typedef\s+[^\s]+\s+([^\s]+)\;/' $(srctree)/include/linux/videodev2.h) \ 77 $(shell perl -ne 'print "$$1 " if /^typedef\s+[^\s]+\s+([^\s]+)\;/' $(srctree)/include/uapi/linux/videodev2.h) \
78 $(shell perl -ne 'print "$$1 " if /^}\s+([a-z0-9_]+_t)/' $(srctree)/include/linux/dvb/frontend.h) 78 $(shell perl -ne 'print "$$1 " if /^}\s+([a-z0-9_]+_t)/' $(srctree)/include/uapi/linux/dvb/frontend.h)
79 79
80ENUMS = \ 80ENUMS = \
81 $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/linux/videodev2.h) \ 81 $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/uapi/linux/videodev2.h) \
82 $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/linux/dvb/audio.h) \ 82 $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/uapi/linux/dvb/audio.h) \
83 $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/linux/dvb/ca.h) \ 83 $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/uapi/linux/dvb/ca.h) \
84 $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/linux/dvb/dmx.h) \ 84 $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/uapi/linux/dvb/dmx.h) \
85 $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/linux/dvb/frontend.h) \ 85 $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/uapi/linux/dvb/frontend.h) \
86 $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/linux/dvb/net.h) \ 86 $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/uapi/linux/dvb/net.h) \
87 $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/linux/dvb/video.h) \ 87 $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/uapi/linux/dvb/video.h) \
88 $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/linux/media.h) \ 88 $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/uapi/linux/media.h) \
89 $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/linux/v4l2-mediabus.h) \ 89 $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/uapi/linux/v4l2-mediabus.h) \
90 $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/linux/v4l2-subdev.h) 90 $(shell perl -ne 'print "$$1 " if /^enum\s+([^\s]+)\s+/' $(srctree)/include/uapi/linux/v4l2-subdev.h)
91 91
92STRUCTS = \ 92STRUCTS = \
93 $(shell perl -ne 'print "$$1 " if /^struct\s+([^\s]+)\s+/' $(srctree)/include/linux/videodev2.h) \ 93 $(shell perl -ne 'print "$$1 " if /^struct\s+([^\s]+)\s+/' $(srctree)/include/uapi/linux/videodev2.h) \
94 $(shell perl -ne 'print "$$1 " if (/^struct\s+([^\s\{]+)\s*/)' $(srctree)/include/linux/dvb/audio.h) \ 94 $(shell perl -ne 'print "$$1 " if (/^struct\s+([^\s\{]+)\s*/)' $(srctree)/include/uapi/linux/dvb/audio.h) \
95 $(shell perl -ne 'print "$$1 " if (/^struct\s+([^\s]+)\s+/)' $(srctree)/include/linux/dvb/ca.h) \ 95 $(shell perl -ne 'print "$$1 " if (/^struct\s+([^\s]+)\s+/)' $(srctree)/include/uapi/linux/dvb/ca.h) \
96 $(shell perl -ne 'print "$$1 " if (/^struct\s+([^\s]+)\s+/)' $(srctree)/include/linux/dvb/dmx.h) \ 96 $(shell perl -ne 'print "$$1 " if (/^struct\s+([^\s]+)\s+/)' $(srctree)/include/uapi/linux/dvb/dmx.h) \
97 $(shell perl -ne 'print "$$1 " if (!/dtv\_cmds\_h/ && /^struct\s+([^\s]+)\s+/)' $(srctree)/include/linux/dvb/frontend.h) \ 97 $(shell perl -ne 'print "$$1 " if (!/dtv\_cmds\_h/ && /^struct\s+([^\s]+)\s+/)' $(srctree)/include/uapi/linux/dvb/frontend.h) \
98 $(shell perl -ne 'print "$$1 " if (/^struct\s+([A-Z][^\s]+)\s+/)' $(srctree)/include/linux/dvb/net.h) \ 98 $(shell perl -ne 'print "$$1 " if (/^struct\s+([A-Z][^\s]+)\s+/)' $(srctree)/include/uapi/linux/dvb/net.h) \
99 $(shell perl -ne 'print "$$1 " if (/^struct\s+([^\s]+)\s+/)' $(srctree)/include/linux/dvb/video.h) \ 99 $(shell perl -ne 'print "$$1 " if (/^struct\s+([^\s]+)\s+/)' $(srctree)/include/uapi/linux/dvb/video.h) \
100 $(shell perl -ne 'print "$$1 " if /^struct\s+([^\s]+)\s+/' $(srctree)/include/linux/media.h) \ 100 $(shell perl -ne 'print "$$1 " if /^struct\s+([^\s]+)\s+/' $(srctree)/include/uapi/linux/media.h) \
101 $(shell perl -ne 'print "$$1 " if /^struct\s+([^\s]+)\s+/' $(srctree)/include/linux/v4l2-subdev.h) \ 101 $(shell perl -ne 'print "$$1 " if /^struct\s+([^\s]+)\s+/' $(srctree)/include/uapi/linux/v4l2-subdev.h) \
102 $(shell perl -ne 'print "$$1 " if /^struct\s+([^\s]+)\s+/' $(srctree)/include/linux/v4l2-mediabus.h) 102 $(shell perl -ne 'print "$$1 " if /^struct\s+([^\s]+)\s+/' $(srctree)/include/uapi/linux/v4l2-mediabus.h)
103 103
104ERRORS = \ 104ERRORS = \
105 E2BIG \ 105 E2BIG \
@@ -205,7 +205,7 @@ $(MEDIA_OBJ_DIR)/v4l2.xml: $(OBJIMGFILES)
205 @(ln -sf $(MEDIA_SRC_DIR)/v4l/*xml $(MEDIA_OBJ_DIR)/) 205 @(ln -sf $(MEDIA_SRC_DIR)/v4l/*xml $(MEDIA_OBJ_DIR)/)
206 @(ln -sf $(MEDIA_SRC_DIR)/dvb/*xml $(MEDIA_OBJ_DIR)/) 206 @(ln -sf $(MEDIA_SRC_DIR)/dvb/*xml $(MEDIA_OBJ_DIR)/)
207 207
208$(MEDIA_OBJ_DIR)/videodev2.h.xml: $(srctree)/include/linux/videodev2.h $(MEDIA_OBJ_DIR)/v4l2.xml 208$(MEDIA_OBJ_DIR)/videodev2.h.xml: $(srctree)/include/uapi/linux/videodev2.h $(MEDIA_OBJ_DIR)/v4l2.xml
209 @$($(quiet)gen_xml) 209 @$($(quiet)gen_xml)
210 @( \ 210 @( \
211 echo "<programlisting>") > $@ 211 echo "<programlisting>") > $@
@@ -216,7 +216,7 @@ $(MEDIA_OBJ_DIR)/videodev2.h.xml: $(srctree)/include/linux/videodev2.h $(MEDIA_O
216 @( \ 216 @( \
217 echo "</programlisting>") >> $@ 217 echo "</programlisting>") >> $@
218 218
219$(MEDIA_OBJ_DIR)/audio.h.xml: $(srctree)/include/linux/dvb/audio.h $(MEDIA_OBJ_DIR)/v4l2.xml 219$(MEDIA_OBJ_DIR)/audio.h.xml: $(srctree)/include/uapi/linux/dvb/audio.h $(MEDIA_OBJ_DIR)/v4l2.xml
220 @$($(quiet)gen_xml) 220 @$($(quiet)gen_xml)
221 @( \ 221 @( \
222 echo "<programlisting>") > $@ 222 echo "<programlisting>") > $@
@@ -227,7 +227,7 @@ $(MEDIA_OBJ_DIR)/audio.h.xml: $(srctree)/include/linux/dvb/audio.h $(MEDIA_OBJ_D
227 @( \ 227 @( \
228 echo "</programlisting>") >> $@ 228 echo "</programlisting>") >> $@
229 229
230$(MEDIA_OBJ_DIR)/ca.h.xml: $(srctree)/include/linux/dvb/ca.h $(MEDIA_OBJ_DIR)/v4l2.xml 230$(MEDIA_OBJ_DIR)/ca.h.xml: $(srctree)/include/uapi/linux/dvb/ca.h $(MEDIA_OBJ_DIR)/v4l2.xml
231 @$($(quiet)gen_xml) 231 @$($(quiet)gen_xml)
232 @( \ 232 @( \
233 echo "<programlisting>") > $@ 233 echo "<programlisting>") > $@
@@ -238,7 +238,7 @@ $(MEDIA_OBJ_DIR)/ca.h.xml: $(srctree)/include/linux/dvb/ca.h $(MEDIA_OBJ_DIR)/v4
238 @( \ 238 @( \
239 echo "</programlisting>") >> $@ 239 echo "</programlisting>") >> $@
240 240
241$(MEDIA_OBJ_DIR)/dmx.h.xml: $(srctree)/include/linux/dvb/dmx.h $(MEDIA_OBJ_DIR)/v4l2.xml 241$(MEDIA_OBJ_DIR)/dmx.h.xml: $(srctree)/include/uapi/linux/dvb/dmx.h $(MEDIA_OBJ_DIR)/v4l2.xml
242 @$($(quiet)gen_xml) 242 @$($(quiet)gen_xml)
243 @( \ 243 @( \
244 echo "<programlisting>") > $@ 244 echo "<programlisting>") > $@
@@ -249,7 +249,7 @@ $(MEDIA_OBJ_DIR)/dmx.h.xml: $(srctree)/include/linux/dvb/dmx.h $(MEDIA_OBJ_DIR)/
249 @( \ 249 @( \
250 echo "</programlisting>") >> $@ 250 echo "</programlisting>") >> $@
251 251
252$(MEDIA_OBJ_DIR)/frontend.h.xml: $(srctree)/include/linux/dvb/frontend.h $(MEDIA_OBJ_DIR)/v4l2.xml 252$(MEDIA_OBJ_DIR)/frontend.h.xml: $(srctree)/include/uapi/linux/dvb/frontend.h $(MEDIA_OBJ_DIR)/v4l2.xml
253 @$($(quiet)gen_xml) 253 @$($(quiet)gen_xml)
254 @( \ 254 @( \
255 echo "<programlisting>") > $@ 255 echo "<programlisting>") > $@
@@ -260,7 +260,7 @@ $(MEDIA_OBJ_DIR)/frontend.h.xml: $(srctree)/include/linux/dvb/frontend.h $(MEDIA
260 @( \ 260 @( \
261 echo "</programlisting>") >> $@ 261 echo "</programlisting>") >> $@
262 262
263$(MEDIA_OBJ_DIR)/net.h.xml: $(srctree)/include/linux/dvb/net.h $(MEDIA_OBJ_DIR)/v4l2.xml 263$(MEDIA_OBJ_DIR)/net.h.xml: $(srctree)/include/uapi/linux/dvb/net.h $(MEDIA_OBJ_DIR)/v4l2.xml
264 @$($(quiet)gen_xml) 264 @$($(quiet)gen_xml)
265 @( \ 265 @( \
266 echo "<programlisting>") > $@ 266 echo "<programlisting>") > $@
@@ -271,7 +271,7 @@ $(MEDIA_OBJ_DIR)/net.h.xml: $(srctree)/include/linux/dvb/net.h $(MEDIA_OBJ_DIR)/
271 @( \ 271 @( \
272 echo "</programlisting>") >> $@ 272 echo "</programlisting>") >> $@
273 273
274$(MEDIA_OBJ_DIR)/video.h.xml: $(srctree)/include/linux/dvb/video.h $(MEDIA_OBJ_DIR)/v4l2.xml 274$(MEDIA_OBJ_DIR)/video.h.xml: $(srctree)/include/uapi/linux/dvb/video.h $(MEDIA_OBJ_DIR)/v4l2.xml
275 @$($(quiet)gen_xml) 275 @$($(quiet)gen_xml)
276 @( \ 276 @( \
277 echo "<programlisting>") > $@ 277 echo "<programlisting>") > $@
diff --git a/Documentation/DocBook/networking.tmpl b/Documentation/DocBook/networking.tmpl
index 59ad69a9d77..29df25016c7 100644
--- a/Documentation/DocBook/networking.tmpl
+++ b/Documentation/DocBook/networking.tmpl
@@ -56,7 +56,7 @@
56!Enet/core/filter.c 56!Enet/core/filter.c
57 </sect1> 57 </sect1>
58 <sect1><title>Generic Network Statistics</title> 58 <sect1><title>Generic Network Statistics</title>
59!Iinclude/linux/gen_stats.h 59!Iinclude/uapi/linux/gen_stats.h
60!Enet/core/gen_stats.c 60!Enet/core/gen_stats.c
61!Enet/core/gen_estimator.c 61!Enet/core/gen_estimator.c
62 </sect1> 62 </sect1>
@@ -80,7 +80,7 @@
80!Enet/wimax/op-rfkill.c 80!Enet/wimax/op-rfkill.c
81!Enet/wimax/stack.c 81!Enet/wimax/stack.c
82!Iinclude/net/wimax.h 82!Iinclude/net/wimax.h
83!Iinclude/linux/wimax.h 83!Iinclude/uapi/linux/wimax.h
84 </sect1> 84 </sect1>
85 </chapter> 85 </chapter>
86 86
diff --git a/Documentation/IPMI.txt b/Documentation/IPMI.txt
index b2bea15137d..16eb4c9e923 100644
--- a/Documentation/IPMI.txt
+++ b/Documentation/IPMI.txt
@@ -42,13 +42,7 @@ The driver interface depends on your hardware. If your system
42properly provides the SMBIOS info for IPMI, the driver will detect it 42properly provides the SMBIOS info for IPMI, the driver will detect it
43and just work. If you have a board with a standard interface (These 43and just work. If you have a board with a standard interface (These
44will generally be either "KCS", "SMIC", or "BT", consult your hardware 44will generally be either "KCS", "SMIC", or "BT", consult your hardware
45manual), choose the 'IPMI SI handler' option. A driver also exists 45manual), choose the 'IPMI SI handler' option.
46for direct I2C access to the IPMI management controller. Some boards
47support this, but it is unknown if it will work on every board. For
48this, choose 'IPMI SMBus handler', but be ready to try to do some
49figuring to see if it will work on your system if the SMBIOS/APCI
50information is wrong or not present. It is fairly safe to have both
51these enabled and let the drivers auto-detect what is present.
52 46
53You should generally enable ACPI on your system, as systems with IPMI 47You should generally enable ACPI on your system, as systems with IPMI
54can have ACPI tables describing them. 48can have ACPI tables describing them.
@@ -58,8 +52,7 @@ their job correctly, the IPMI controller should be automatically
58detected (via ACPI or SMBIOS tables) and should just work. Sadly, 52detected (via ACPI or SMBIOS tables) and should just work. Sadly,
59many boards do not have this information. The driver attempts 53many boards do not have this information. The driver attempts
60standard defaults, but they may not work. If you fall into this 54standard defaults, but they may not work. If you fall into this
61situation, you need to read the section below named 'The SI Driver' or 55situation, you need to read the section below named 'The SI Driver'.
62"The SMBus Driver" on how to hand-configure your system.
63 56
64IPMI defines a standard watchdog timer. You can enable this with the 57IPMI defines a standard watchdog timer. You can enable this with the
65'IPMI Watchdog Timer' config option. If you compile the driver into 58'IPMI Watchdog Timer' config option. If you compile the driver into
@@ -104,12 +97,7 @@ driver, each open file for this device ties in to the message handler
104as an IPMI user. 97as an IPMI user.
105 98
106ipmi_si - A driver for various system interfaces. This supports KCS, 99ipmi_si - A driver for various system interfaces. This supports KCS,
107SMIC, and BT interfaces. Unless you have an SMBus interface or your 100SMIC, and BT interfaces.
108own custom interface, you probably need to use this.
109
110ipmi_smb - A driver for accessing BMCs on the SMBus. It uses the
111I2C kernel driver's SMBus interfaces to send and receive IPMI messages
112over the SMBus.
113 101
114ipmi_watchdog - IPMI requires systems to have a very capable watchdog 102ipmi_watchdog - IPMI requires systems to have a very capable watchdog
115timer. This driver implements the standard Linux watchdog timer 103timer. This driver implements the standard Linux watchdog timer
@@ -482,53 +470,6 @@ for specifying an interface. Note that when removing an interface,
482only the first three parameters (si type, address type, and address) 470only the first three parameters (si type, address type, and address)
483are used for the comparison. Any options are ignored for removing. 471are used for the comparison. Any options are ignored for removing.
484 472
485The SMBus Driver
486----------------
487
488The SMBus driver allows up to 4 SMBus devices to be configured in the
489system. By default, the driver will register any SMBus interfaces it finds
490in the I2C address range of 0x20 to 0x4f on any adapter. You can change this
491at module load time (for a module) with:
492
493 modprobe ipmi_smb.o
494 addr=<adapter1>,<i2caddr1>[,<adapter2>,<i2caddr2>[,...]]
495 dbg=<flags1>,<flags2>...
496 [defaultprobe=1] [dbg_probe=1]
497
498The addresses are specified in pairs, the first is the adapter ID and the
499second is the I2C address on that adapter.
500
501The debug flags are bit flags for each BMC found, they are:
502IPMI messages: 1, driver state: 2, timing: 4, I2C probe: 8
503
504Setting smb_defaultprobe to zero disabled the default probing of SMBus
505interfaces at address range 0x20 to 0x4f. This means that only the
506BMCs specified on the smb_addr line will be detected.
507
508Setting smb_dbg_probe to 1 will enable debugging of the probing and
509detection process for BMCs on the SMBusses.
510
511Discovering the IPMI compliant BMC on the SMBus can cause devices
512on the I2C bus to fail. The SMBus driver writes a "Get Device ID" IPMI
513message as a block write to the I2C bus and waits for a response.
514This action can be detrimental to some I2C devices. It is highly recommended
515that the known I2c address be given to the SMBus driver in the smb_addr
516parameter. The default address range will not be used when a smb_addr
517parameter is provided.
518
519When compiled into the kernel, the addresses can be specified on the
520kernel command line as:
521
522 ipmb_smb.addr=<adapter1>,<i2caddr1>[,<adapter2>,<i2caddr2>[,...]]
523 ipmi_smb.dbg=<flags1>,<flags2>...
524 ipmi_smb.defaultprobe=0 ipmi_smb.dbg_probe=1
525
526These are the same options as on the module command line.
527
528Note that you might need some I2C changes if CONFIG_IPMI_PANIC_EVENT
529is enabled along with this, so the I2C driver knows to run to
530completion during sending a panic event.
531
532 473
533Other Pieces 474Other Pieces
534------------ 475------------
diff --git a/Documentation/arm64/memory.txt b/Documentation/arm64/memory.txt
index dbbdcbba75a..4110cca96bd 100644
--- a/Documentation/arm64/memory.txt
+++ b/Documentation/arm64/memory.txt
@@ -27,17 +27,17 @@ Start End Size Use
27----------------------------------------------------------------------- 27-----------------------------------------------------------------------
280000000000000000 0000007fffffffff 512GB user 280000000000000000 0000007fffffffff 512GB user
29 29
30ffffff8000000000 ffffffbbfffcffff ~240GB vmalloc 30ffffff8000000000 ffffffbbfffeffff ~240GB vmalloc
31 31
32ffffffbbfffd0000 ffffffbcfffdffff 64KB [guard page] 32ffffffbbffff0000 ffffffbbffffffff 64KB [guard page]
33 33
34ffffffbbfffe0000 ffffffbcfffeffff 64KB PCI I/O space 34ffffffbc00000000 ffffffbdffffffff 8GB vmemmap
35 35
36ffffffbbffff0000 ffffffbcffffffff 64KB [guard page] 36ffffffbe00000000 ffffffbffbbfffff ~8GB [guard, future vmmemap]
37 37
38ffffffbc00000000 ffffffbdffffffff 8GB vmemmap 38ffffffbffbe00000 ffffffbffbe0ffff 64KB PCI I/O space
39 39
40ffffffbe00000000 ffffffbffbffffff ~8GB [guard, future vmmemap] 40ffffffbbffff0000 ffffffbcffffffff ~2MB [guard]
41 41
42ffffffbffc000000 ffffffbfffffffff 64MB modules 42ffffffbffc000000 ffffffbfffffffff 64MB modules
43 43
diff --git a/Documentation/cgroups/memory.txt b/Documentation/cgroups/memory.txt
index c07f7b4fb88..71c4da41344 100644
--- a/Documentation/cgroups/memory.txt
+++ b/Documentation/cgroups/memory.txt
@@ -466,6 +466,10 @@ Note:
4665.3 swappiness 4665.3 swappiness
467 467
468Similar to /proc/sys/vm/swappiness, but affecting a hierarchy of groups only. 468Similar to /proc/sys/vm/swappiness, but affecting a hierarchy of groups only.
469Please note that unlike the global swappiness, memcg knob set to 0
470really prevents from any swapping even if there is a swap storage
471available. This might lead to memcg OOM killer if there are no file
472pages to reclaim.
469 473
470Following cgroups' swappiness can't be changed. 474Following cgroups' swappiness can't be changed.
471- root cgroup (uses /proc/sys/vm/swappiness). 475- root cgroup (uses /proc/sys/vm/swappiness).
diff --git a/Documentation/devicetree/bindings/arm/atmel-at91.txt b/Documentation/devicetree/bindings/arm/atmel-at91.txt
index ecc81e36871..d187e9f7cf1 100644
--- a/Documentation/devicetree/bindings/arm/atmel-at91.txt
+++ b/Documentation/devicetree/bindings/arm/atmel-at91.txt
@@ -8,7 +8,7 @@ PIT Timer required properties:
8 shared across all System Controller members. 8 shared across all System Controller members.
9 9
10TC/TCLIB Timer required properties: 10TC/TCLIB Timer required properties:
11- compatible: Should be "atmel,<chip>-pit". 11- compatible: Should be "atmel,<chip>-tcb".
12 <chip> can be "at91rm9200" or "at91sam9x5" 12 <chip> can be "at91rm9200" or "at91sam9x5"
13- reg: Should contain registers location and length 13- reg: Should contain registers location and length
14- interrupts: Should contain all interrupts for the TC block 14- interrupts: Should contain all interrupts for the TC block
diff --git a/Documentation/devicetree/bindings/input/touchscreen/egalax-ts.txt b/Documentation/devicetree/bindings/input/touchscreen/egalax-ts.txt
new file mode 100644
index 00000000000..df70318a617
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/touchscreen/egalax-ts.txt
@@ -0,0 +1,19 @@
1* EETI eGalax Multiple Touch Controller
2
3Required properties:
4- compatible: must be "eeti,egalax_ts"
5- reg: i2c slave address
6- interrupt-parent: the phandle for the interrupt controller
7- interrupts: touch controller interrupt
8- wakeup-gpios: the gpio pin to be used for waking up the controller
9 as well as uased as irq pin
10
11Example:
12
13 egalax_ts@04 {
14 compatible = "eeti,egalax_ts";
15 reg = <0x04>;
16 interrupt-parent = <&gpio1>;
17 interrupts = <9 2>;
18 wakeup-gpios = <&gpio1 9 0>;
19 };
diff --git a/Documentation/devicetree/bindings/net/mdio-gpio.txt b/Documentation/devicetree/bindings/net/mdio-gpio.txt
index bc954952901..c79bab02536 100644
--- a/Documentation/devicetree/bindings/net/mdio-gpio.txt
+++ b/Documentation/devicetree/bindings/net/mdio-gpio.txt
@@ -8,9 +8,16 @@ gpios property as described in section VIII.1 in the following order:
8 8
9MDC, MDIO. 9MDC, MDIO.
10 10
11Note: Each gpio-mdio bus should have an alias correctly numbered in "aliases"
12node.
13
11Example: 14Example:
12 15
13mdio { 16aliases {
17 mdio-gpio0 = <&mdio0>;
18};
19
20mdio0: mdio {
14 compatible = "virtual,mdio-gpio"; 21 compatible = "virtual,mdio-gpio";
15 #address-cells = <1>; 22 #address-cells = <1>;
16 #size-cells = <0>; 23 #size-cells = <0>;
diff --git a/Documentation/devicetree/bindings/pinctrl/nvidia,tegra20-pinmux.txt b/Documentation/devicetree/bindings/pinctrl/nvidia,tegra20-pinmux.txt
index c8e578263ce..683fde93c4f 100644
--- a/Documentation/devicetree/bindings/pinctrl/nvidia,tegra20-pinmux.txt
+++ b/Documentation/devicetree/bindings/pinctrl/nvidia,tegra20-pinmux.txt
@@ -93,7 +93,7 @@ Valid values for pin and group names are:
93 93
94 With some exceptions, these support nvidia,high-speed-mode, 94 With some exceptions, these support nvidia,high-speed-mode,
95 nvidia,schmitt, nvidia,low-power-mode, nvidia,pull-down-strength, 95 nvidia,schmitt, nvidia,low-power-mode, nvidia,pull-down-strength,
96 nvidia,pull-up-strength, nvidia,slew_rate-rising, nvidia,slew_rate-falling. 96 nvidia,pull-up-strength, nvidia,slew-rate-rising, nvidia,slew-rate-falling.
97 97
98 drive_ao1, drive_ao2, drive_at1, drive_at2, drive_cdev1, drive_cdev2, 98 drive_ao1, drive_ao2, drive_at1, drive_at2, drive_cdev1, drive_cdev2,
99 drive_csus, drive_dap1, drive_dap2, drive_dap3, drive_dap4, drive_dbg, 99 drive_csus, drive_dap1, drive_dap2, drive_dap3, drive_dap4, drive_dbg,
diff --git a/Documentation/devicetree/bindings/pinctrl/nvidia,tegra30-pinmux.txt b/Documentation/devicetree/bindings/pinctrl/nvidia,tegra30-pinmux.txt
index c275b70349c..6f426ed7009 100644
--- a/Documentation/devicetree/bindings/pinctrl/nvidia,tegra30-pinmux.txt
+++ b/Documentation/devicetree/bindings/pinctrl/nvidia,tegra30-pinmux.txt
@@ -83,7 +83,7 @@ Valid values for pin and group names are:
83 drive groups: 83 drive groups:
84 84
85 These all support nvidia,pull-down-strength, nvidia,pull-up-strength, 85 These all support nvidia,pull-down-strength, nvidia,pull-up-strength,
86 nvidia,slew_rate-rising, nvidia,slew_rate-falling. Most but not all 86 nvidia,slew-rate-rising, nvidia,slew-rate-falling. Most but not all
87 support nvidia,high-speed-mode, nvidia,schmitt, nvidia,low-power-mode. 87 support nvidia,high-speed-mode, nvidia,schmitt, nvidia,low-power-mode.
88 88
89 ao1, ao2, at1, at2, at3, at4, at5, cdev1, cdev2, cec, crt, csus, dap1, 89 ao1, ao2, at1, at2, at3, at4, at5, cdev1, cdev2, cec, crt, csus, dap1,
diff --git a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt
index a1793d670cd..3844d21d6ca 100644
--- a/Documentation/filesystems/proc.txt
+++ b/Documentation/filesystems/proc.txt
@@ -33,7 +33,7 @@ Table of Contents
33 2 Modifying System Parameters 33 2 Modifying System Parameters
34 34
35 3 Per-Process Parameters 35 3 Per-Process Parameters
36 3.1 /proc/<pid>/oom_score_adj - Adjust the oom-killer 36 3.1 /proc/<pid>/oom_adj & /proc/<pid>/oom_score_adj - Adjust the oom-killer
37 score 37 score
38 3.2 /proc/<pid>/oom_score - Display current oom-killer score 38 3.2 /proc/<pid>/oom_score - Display current oom-killer score
39 3.3 /proc/<pid>/io - Display the IO accounting fields 39 3.3 /proc/<pid>/io - Display the IO accounting fields
@@ -1320,10 +1320,10 @@ of the kernel.
1320CHAPTER 3: PER-PROCESS PARAMETERS 1320CHAPTER 3: PER-PROCESS PARAMETERS
1321------------------------------------------------------------------------------ 1321------------------------------------------------------------------------------
1322 1322
13233.1 /proc/<pid>/oom_score_adj- Adjust the oom-killer score 13233.1 /proc/<pid>/oom_adj & /proc/<pid>/oom_score_adj- Adjust the oom-killer score
1324-------------------------------------------------------------------------------- 1324--------------------------------------------------------------------------------
1325 1325
1326This file can be used to adjust the badness heuristic used to select which 1326These file can be used to adjust the badness heuristic used to select which
1327process gets killed in out of memory conditions. 1327process gets killed in out of memory conditions.
1328 1328
1329The badness heuristic assigns a value to each candidate task ranging from 0 1329The badness heuristic assigns a value to each candidate task ranging from 0
@@ -1361,6 +1361,12 @@ same system, cpuset, mempolicy, or memory controller resources to use at least
1361equivalent to discounting 50% of the task's allowed memory from being considered 1361equivalent to discounting 50% of the task's allowed memory from being considered
1362as scoring against the task. 1362as scoring against the task.
1363 1363
1364For backwards compatibility with previous kernels, /proc/<pid>/oom_adj may also
1365be used to tune the badness score. Its acceptable values range from -16
1366(OOM_ADJUST_MIN) to +15 (OOM_ADJUST_MAX) and a special value of -17
1367(OOM_DISABLE) to disable oom killing entirely for that task. Its value is
1368scaled linearly with /proc/<pid>/oom_score_adj.
1369
1364The value of /proc/<pid>/oom_score_adj may be reduced no lower than the last 1370The value of /proc/<pid>/oom_score_adj may be reduced no lower than the last
1365value set by a CAP_SYS_RESOURCE process. To reduce the value any lower 1371value set by a CAP_SYS_RESOURCE process. To reduce the value any lower
1366requires CAP_SYS_RESOURCE. 1372requires CAP_SYS_RESOURCE.
@@ -1375,7 +1381,9 @@ minimal amount of work.
1375------------------------------------------------------------- 1381-------------------------------------------------------------
1376 1382
1377This file can be used to check the current score used by the oom-killer is for 1383This file can be used to check the current score used by the oom-killer is for
1378any given <pid>. 1384any given <pid>. Use it together with /proc/<pid>/oom_score_adj to tune which
1385process should be killed in an out-of-memory situation.
1386
1379 1387
13803.3 /proc/<pid>/io - Display the IO accounting fields 13883.3 /proc/<pid>/io - Display the IO accounting fields
1381------------------------------------------------------- 1389-------------------------------------------------------
diff --git a/Documentation/firmware_class/README b/Documentation/firmware_class/README
index 7eceaff63f5..815b711bcd8 100644
--- a/Documentation/firmware_class/README
+++ b/Documentation/firmware_class/README
@@ -18,32 +18,40 @@
18 High level behavior (mixed): 18 High level behavior (mixed):
19 ============================ 19 ============================
20 20
21 kernel(driver): calls request_firmware(&fw_entry, $FIRMWARE, device) 21 1), kernel(driver):
22 22 - calls request_firmware(&fw_entry, $FIRMWARE, device)
23 userspace: 23 - kernel searchs the fimware image with name $FIRMWARE directly
24 in the below search path of root filesystem:
25 "/lib/firmware/updates/" UTS_RELEASE,
26 "/lib/firmware/updates",
27 "/lib/firmware/" UTS_RELEASE,
28 "/lib/firmware"
29 - If found, goto 7), else goto 2)
30
31 2), userspace:
24 - /sys/class/firmware/xxx/{loading,data} appear. 32 - /sys/class/firmware/xxx/{loading,data} appear.
25 - hotplug gets called with a firmware identifier in $FIRMWARE 33 - hotplug gets called with a firmware identifier in $FIRMWARE
26 and the usual hotplug environment. 34 and the usual hotplug environment.
27 - hotplug: echo 1 > /sys/class/firmware/xxx/loading 35 - hotplug: echo 1 > /sys/class/firmware/xxx/loading
28 36
29 kernel: Discard any previous partial load. 37 3), kernel: Discard any previous partial load.
30 38
31 userspace: 39 4), userspace:
32 - hotplug: cat appropriate_firmware_image > \ 40 - hotplug: cat appropriate_firmware_image > \
33 /sys/class/firmware/xxx/data 41 /sys/class/firmware/xxx/data
34 42
35 kernel: grows a buffer in PAGE_SIZE increments to hold the image as it 43 5), kernel: grows a buffer in PAGE_SIZE increments to hold the image as it
36 comes in. 44 comes in.
37 45
38 userspace: 46 6), userspace:
39 - hotplug: echo 0 > /sys/class/firmware/xxx/loading 47 - hotplug: echo 0 > /sys/class/firmware/xxx/loading
40 48
41 kernel: request_firmware() returns and the driver has the firmware 49 7), kernel: request_firmware() returns and the driver has the firmware
42 image in fw_entry->{data,size}. If something went wrong 50 image in fw_entry->{data,size}. If something went wrong
43 request_firmware() returns non-zero and fw_entry is set to 51 request_firmware() returns non-zero and fw_entry is set to
44 NULL. 52 NULL.
45 53
46 kernel(driver): Driver code calls release_firmware(fw_entry) releasing 54 8), kernel(driver): Driver code calls release_firmware(fw_entry) releasing
47 the firmware image and any related resource. 55 the firmware image and any related resource.
48 56
49 High level behavior (driver code): 57 High level behavior (driver code):
diff --git a/Documentation/hwmon/coretemp b/Documentation/hwmon/coretemp
index c86b50c03ea..f17256f069b 100644
--- a/Documentation/hwmon/coretemp
+++ b/Documentation/hwmon/coretemp
@@ -105,6 +105,7 @@ Process Processor TjMax(C)
105 330/230 125 105 330/230 125
106 E680/660/640/620 90 106 E680/660/640/620 90
107 E680T/660T/640T/620T 110 107 E680T/660T/640T/620T 110
108 CE4170/4150/4110 110
108 109
10945nm Core2 Processors 11045nm Core2 Processors
110 Solo ULV SU3500/3300 100 111 Solo ULV SU3500/3300 100
diff --git a/Documentation/hwmon/fam15h_power b/Documentation/hwmon/fam15h_power
index a92918e0bd6..80654813d04 100644
--- a/Documentation/hwmon/fam15h_power
+++ b/Documentation/hwmon/fam15h_power
@@ -10,7 +10,7 @@ Supported chips:
10 BIOS and Kernel Developer's Guide (BKDG) For AMD Family 15h Processors 10 BIOS and Kernel Developer's Guide (BKDG) For AMD Family 15h Processors
11 (not yet published) 11 (not yet published)
12 12
13Author: Andreas Herrmann <andreas.herrmann3@amd.com> 13Author: Andreas Herrmann <herrmann.der.user@googlemail.com>
14 14
15Description 15Description
16----------- 16-----------
diff --git a/Documentation/hwmon/submitting-patches b/Documentation/hwmon/submitting-patches
index 790f774a303..843751c41fe 100644
--- a/Documentation/hwmon/submitting-patches
+++ b/Documentation/hwmon/submitting-patches
@@ -60,8 +60,7 @@ increase the chances of your change being accepted.
60 60
61* Add the driver to Kconfig and Makefile in alphabetical order. 61* Add the driver to Kconfig and Makefile in alphabetical order.
62 62
63* Make sure that all dependencies are listed in Kconfig. For new drivers, it 63* Make sure that all dependencies are listed in Kconfig.
64 is most likely prudent to add a dependency on EXPERIMENTAL.
65 64
66* Avoid forward declarations if you can. Rearrange the code if necessary. 65* Avoid forward declarations if you can. Rearrange the code if necessary.
67 66
diff --git a/Documentation/networking/netdev-features.txt b/Documentation/networking/netdev-features.txt
index 4164f5c02e4..f310edec8a7 100644
--- a/Documentation/networking/netdev-features.txt
+++ b/Documentation/networking/netdev-features.txt
@@ -164,4 +164,4 @@ read the CRC recorded by the NIC on receipt of the packet.
164This requests that the NIC receive all possible frames, including errored 164This requests that the NIC receive all possible frames, including errored
165frames (such as bad FCS, etc). This can be helpful when sniffing a link with 165frames (such as bad FCS, etc). This can be helpful when sniffing a link with
166bad packets on it. Some NICs may receive more packets if also put into normal 166bad packets on it. Some NICs may receive more packets if also put into normal
167PROMISC mdoe. 167PROMISC mode.
diff --git a/Documentation/networking/vxlan.txt b/Documentation/networking/vxlan.txt
index 5b34b762d7d..6d993510f09 100644
--- a/Documentation/networking/vxlan.txt
+++ b/Documentation/networking/vxlan.txt
@@ -32,7 +32,7 @@ no entry is in the forwarding table.
32 # ip link delete vxlan0 32 # ip link delete vxlan0
33 33
343. Show vxlan info 343. Show vxlan info
35 # ip -d show vxlan0 35 # ip -d link show vxlan0
36 36
37It is possible to create, destroy and display the vxlan 37It is possible to create, destroy and display the vxlan
38forwarding table using the new bridge command. 38forwarding table using the new bridge command.
@@ -41,7 +41,7 @@ forwarding table using the new bridge command.
41 # bridge fdb add to 00:17:42:8a:b4:05 dst 192.19.0.2 dev vxlan0 41 # bridge fdb add to 00:17:42:8a:b4:05 dst 192.19.0.2 dev vxlan0
42 42
432. Delete forwarding table entry 432. Delete forwarding table entry
44 # bridge fdb delete 00:17:42:8a:b4:05 44 # bridge fdb delete 00:17:42:8a:b4:05 dev vxlan0
45 45
463. Show forwarding table 463. Show forwarding table
47 # bridge fdb show dev vxlan0 47 # bridge fdb show dev vxlan0
diff --git a/Documentation/sysrq.txt b/Documentation/sysrq.txt
index 642f84495b2..2a4cdda4828 100644
--- a/Documentation/sysrq.txt
+++ b/Documentation/sysrq.txt
@@ -116,6 +116,7 @@ On all - write a character to /proc/sysrq-trigger. e.g.:
116'w' - Dumps tasks that are in uninterruptable (blocked) state. 116'w' - Dumps tasks that are in uninterruptable (blocked) state.
117 117
118'x' - Used by xmon interface on ppc/powerpc platforms. 118'x' - Used by xmon interface on ppc/powerpc platforms.
119 Show global PMU Registers on sparc64.
119 120
120'y' - Show global CPU Registers [SPARC-64 specific] 121'y' - Show global CPU Registers [SPARC-64 specific]
121 122
diff --git a/Documentation/zh_CN/IRQ.txt b/Documentation/zh_CN/IRQ.txt
new file mode 100644
index 00000000000..956026d5cf8
--- /dev/null
+++ b/Documentation/zh_CN/IRQ.txt
@@ -0,0 +1,39 @@
1Chinese translated version of Documentation/IRQ.txt
2
3If you have any comment or update to the content, please contact the
4original document maintainer directly. However, if you have a problem
5communicating in English you can also ask the Chinese maintainer for
6help. Contact the Chinese maintainer if this translation is outdated
7or if there is a problem with the translation.
8
9Maintainer: Eric W. Biederman <ebiederman@xmission.com>
10Chinese maintainer: Fu Wei <tekkamanninja@gmail.com>
11---------------------------------------------------------------------
12Documentation/IRQ.txt 的中文翻译
13
14如果想评论或更新本文的内容,请直接联系原文档的维护者。如果你使用英文
15交流有困难的话,也可以向中文版维护者求助。如果本翻译更新不及时或者翻
16译存在问题,请联系中文版维护者。
17英文版维护者: Eric W. Biederman <ebiederman@xmission.com>
18中文版维护者: 傅炜 Fu Wei <tekkamanninja@gmail.com>
19中文版翻译者: 傅炜 Fu Wei <tekkamanninja@gmail.com>
20中文版校译者: 傅炜 Fu Wei <tekkamanninja@gmail.com>
21
22
23以下为正文
24---------------------------------------------------------------------
25何为 IRQ?
26
27一个 IRQ 是来自某个设备的一个中断请求。目前,它们可以来自一个硬件引脚,
28或来自一个数据包。多个设备可能连接到同个硬件引脚,从而共享一个 IRQ。
29
30一个 IRQ 编号是用于告知硬件中断源的内核标识。通常情况下,这是一个
31全局 irq_desc 数组的索引,但是除了在 linux/interrupt.h 中的实现,
32具体的细节是体系结构特定的。
33
34一个 IRQ 编号是设备上某个可能的中断源的枚举。通常情况下,枚举的编号是
35该引脚在系统内中断控制器的所有输入引脚中的编号。对于 ISA 总线中的情况,
36枚举的是在两个 i8259 中断控制器中 16 个输入引脚。
37
38架构可以对 IRQ 编号指定额外的含义,在硬件涉及任何手工配置的情况下,
39是被提倡的。ISA 的 IRQ 是一个分配这类额外含义的典型例子。
diff --git a/Documentation/zh_CN/arm64/booting.txt b/Documentation/zh_CN/arm64/booting.txt
new file mode 100644
index 00000000000..28fa325b746
--- /dev/null
+++ b/Documentation/zh_CN/arm64/booting.txt
@@ -0,0 +1,156 @@
1Chinese translated version of Documentation/arm64/booting.txt
2
3If you have any comment or update to the content, please contact the
4original document maintainer directly. However, if you have a problem
5communicating in English you can also ask the Chinese maintainer for
6help. Contact the Chinese maintainer if this translation is outdated
7or if there is a problem with the translation.
8
9Maintainer: Will Deacon <will.deacon@arm.com>
10Chinese maintainer: Fu Wei <tekkamanninja@gmail.com>
11---------------------------------------------------------------------
12Documentation/arm64/booting.txt 的中文翻译
13
14如果想评论或更新本文的内容,请直接联系原文档的维护者。如果你使用英文
15交流有困难的话,也可以向中文版维护者求助。如果本翻译更新不及时或者翻
16译存在问题,请联系中文版维护者。
17
18英文版维护者: Will Deacon <will.deacon@arm.com>
19中文版维护者: 傅炜 Fu Wei <tekkamanninja@gmail.com>
20中文版翻译者: 傅炜 Fu Wei <tekkamanninja@gmail.com>
21中文版校译者: 傅炜 Fu Wei <tekkamanninja@gmail.com>
22
23以下为正文
24---------------------------------------------------------------------
25 启动 AArch64 Linux
26 ==================
27
28作者: Will Deacon <will.deacon@arm.com>
29日期: 2012 年 09 月 07 日
30
31本文档基于 Russell King 的 ARM 启动文档,且适用于所有公开发布的
32AArch64 Linux 内核代码。
33
34AArch64 异常模型由多个异常级别(EL0 - EL3)组成,对于 EL0 和 EL1
35异常级有对应的安全和非安全模式。EL2 是系统管理级,且仅存在于
36非安全模式下。EL3 是最高特权级,且仅存在于安全模式下。
37
38基于本文档的目的,我们将简单地使用‘引导装载程序’(‘boot loader’)
39这个术语来定义在将控制权交给 Linux 内核前 CPU 上执行的所有软件。
40这可能包含安全监控和系统管理代码,或者它可能只是一些用于准备最小启动
41环境的指令。
42
43基本上,引导装载程序(至少)应实现以下操作:
44
451、设置和初始化 RAM
462、设置设备树数据
473、解压内核映像
484、调用内核映像
49
50
511、设置和初始化 RAM
52-----------------
53
54必要性: 强制
55
56引导装载程序应该找到并初始化系统中所有内核用于保持系统变量数据的 RAM。
57这个操作的执行是设备依赖的。(它可能使用内部算法来自动定位和计算所有
58RAM,或可能使用对这个设备已知的 RAM 信息,还可能使用任何引导装载程序
59设计者想到的匹配方法。)
60
61
622、设置设备树数据
63---------------
64
65必要性: 强制
66
67设备树数据块(dtb)大小必须不大于 2 MB,且位于从内核映像起始算起第一个
68512MB 内的 2MB 边界上。这使得内核可以通过初始页表中的单个节描述符来
69映射此数据块。
70
71
723、解压内核映像
73-------------
74
75必要性: 可选
76
77AArch64 内核当前没有提供自解压代码,因此如果使用了压缩内核映像文件
78(比如 Image.gz),则需要通过引导装载程序(使用 gzip 等)来进行解压。
79若引导装载程序没有实现这个需求,就要使用非压缩内核映像文件。
80
81
824、调用内核映像
83-------------
84
85必要性: 强制
86
87已解压的内核映像包含一个 32 字节的头,内容如下:
88
89 u32 magic = 0x14000008; /* 跳转到 stext, 小端 */
90 u32 res0 = 0; /* 保留 */
91 u64 text_offset; /* 映像装载偏移 */
92 u64 res1 = 0; /* 保留 */
93 u64 res2 = 0; /* 保留 */
94
95映像必须位于系统 RAM 起始处的特定偏移(当前是 0x80000)。系统 RAM
96的起始地址必须是以 2MB 对齐的。
97
98在跳转入内核前,必须符合以下状态:
99
100- 停止所有 DMA 设备,这样内存数据就不会因为虚假网络包或磁盘数据而
101 被破坏。这可能可以节省你许多的调试时间。
102
103- 主 CPU 通用寄存器设置
104 x0 = 系统 RAM 中设备树数据块(dtb)的物理地址。
105 x1 = 0 (保留,将来可能使用)
106 x2 = 0 (保留,将来可能使用)
107 x3 = 0 (保留,将来可能使用)
108
109- CPU 模式
110 所有形式的中断必须在 PSTATE.DAIF 中被屏蔽(Debug、SError、IRQ
111 和 FIQ)。
112 CPU 必须处于 EL2(推荐,可访问虚拟化扩展)或非安全 EL1 模式下。
113
114- 高速缓存、MMU
115 MMU 必须关闭。
116 指令缓存开启或关闭都可以。
117 数据缓存必须关闭且无效。
118 外部高速缓存(如果存在)必须配置并禁用。
119
120- 架构计时器
121 CNTFRQ 必须设定为计时器的频率。
122 如果在 EL1 模式下进入内核,则 CNTHCTL_EL2 中的 EL1PCTEN (bit 0)
123 必须置位。
124
125- 一致性
126 通过内核启动的所有 CPU 在内核入口地址上必须处于相同的一致性域中。
127 这可能要根据具体实现来定义初始化过程,以使能每个CPU上对维护操作的
128 接收。
129
130- 系统寄存器
131 在进入内核映像的异常级中,所有构架中可写的系统寄存器必须通过软件
132 在一个更高的异常级别下初始化,以防止在 未知 状态下运行。
133
134引导装载程序必须在每个 CPU 处于以下状态时跳入内核入口:
135
136- 主 CPU 必须直接跳入内核映像的第一条指令。通过此 CPU 传递的设备树
137 数据块必须在每个 CPU 节点中包含以下内容:
138
139 1、‘enable-method’属性。目前,此字段支持的值仅为字符串“spin-table”。
140
141 2、‘cpu-release-addr’标识一个 64-bit、初始化为零的内存位置。
142
143 引导装载程序必须生成这些设备树属性,并在跳入内核入口之前将其插入
144 数据块。
145
146- 任何辅助 CPU 必须在内存保留区(通过设备树中的 /memreserve/ 域传递
147 给内核)中自旋于内核之外,轮询它们的 cpu-release-addr 位置(必须
148 包含在保留区中)。可通过插入 wfe 指令来降低忙循环开销,而主 CPU 将
149 发出 sev 指令。当对 cpu-release-addr 所指位置的读取操作返回非零值
150 时,CPU 必须直接跳入此值所指向的地址。
151
152- 辅助 CPU 通用寄存器设置
153 x0 = 0 (保留,将来可能使用)
154 x1 = 0 (保留,将来可能使用)
155 x2 = 0 (保留,将来可能使用)
156 x3 = 0 (保留,将来可能使用)
diff --git a/Documentation/zh_CN/arm64/memory.txt b/Documentation/zh_CN/arm64/memory.txt
new file mode 100644
index 00000000000..83b51931470
--- /dev/null
+++ b/Documentation/zh_CN/arm64/memory.txt
@@ -0,0 +1,93 @@
1Chinese translated version of Documentation/arm64/memory.txt
2
3If you have any comment or update to the content, please contact the
4original document maintainer directly. However, if you have a problem
5communicating in English you can also ask the Chinese maintainer for
6help. Contact the Chinese maintainer if this translation is outdated
7or if there is a problem with the translation.
8
9Maintainer: Catalin Marinas <catalin.marinas@arm.com>
10Chinese maintainer: Fu Wei <tekkamanninja@gmail.com>
11---------------------------------------------------------------------
12Documentation/arm64/memory.txt 的中文翻译
13
14如果想评论或更新本文的内容,请直接联系原文档的维护者。如果你使用英文
15交流有困难的话,也可以向中文版维护者求助。如果本翻译更新不及时或者翻
16译存在问题,请联系中文版维护者。
17
18英文版维护者: Catalin Marinas <catalin.marinas@arm.com>
19中文版维护者: 傅炜 Fu Wei <tekkamanninja@gmail.com>
20中文版翻译者: 傅炜 Fu Wei <tekkamanninja@gmail.com>
21中文版校译者: 傅炜 Fu Wei <tekkamanninja@gmail.com>
22
23以下为正文
24---------------------------------------------------------------------
25 Linux 在 AArch64 中的内存布局
26 ===========================
27
28作者: Catalin Marinas <catalin.marinas@arm.com>
29日期: 2012 年 02 月 20 日
30
31本文档描述 AArch64 Linux 内核所使用的虚拟内存布局。此构架可以实现
32页大小为 4KB 的 4 级转换表和页大小为 64KB 的 3 级转换表。
33
34AArch64 Linux 使用页大小为 4KB 的 3 级转换表配置,对于用户和内核
35都有 39-bit (512GB) 的虚拟地址空间。对于页大小为 64KB的配置,仅
36使用 2 级转换表,但内存布局相同。
37
38用户地址空间的 63:39 位为 0,而内核地址空间的相应位为 1。TTBRx 的
39选择由虚拟地址的 63 位给出。swapper_pg_dir 仅包含内核(全局)映射,
40而用户 pgd 仅包含用户(非全局)映射。swapper_pgd_dir 地址被写入
41TTBR1 中,且从不写入 TTBR0。
42
43
44AArch64 Linux 内存布局:
45
46起始地址 结束地址 大小 用途
47-----------------------------------------------------------------------
480000000000000000 0000007fffffffff 512GB 用户空间
49
50ffffff8000000000 ffffffbbfffcffff ~240GB vmalloc
51
52ffffffbbfffd0000 ffffffbcfffdffff 64KB [防护页]
53
54ffffffbbfffe0000 ffffffbcfffeffff 64KB PCI I/O 空间
55
56ffffffbbffff0000 ffffffbcffffffff 64KB [防护页]
57
58ffffffbc00000000 ffffffbdffffffff 8GB vmemmap
59
60ffffffbe00000000 ffffffbffbffffff ~8GB [防护页,未来用于 vmmemap]
61
62ffffffbffc000000 ffffffbfffffffff 64MB 模块
63
64ffffffc000000000 ffffffffffffffff 256GB 内存空间
65
66
674KB 页大小的转换表查找:
68
69+--------+--------+--------+--------+--------+--------+--------+--------+
70|63 56|55 48|47 40|39 32|31 24|23 16|15 8|7 0|
71+--------+--------+--------+--------+--------+--------+--------+--------+
72 | | | | | |
73 | | | | | v
74 | | | | | [11:0] 页内偏移
75 | | | | +-> [20:12] L3 索引
76 | | | +-----------> [29:21] L2 索引
77 | | +---------------------> [38:30] L1 索引
78 | +-------------------------------> [47:39] L0 索引 (未使用)
79 +-------------------------------------------------> [63] TTBR0/1
80
81
8264KB 页大小的转换表查找:
83
84+--------+--------+--------+--------+--------+--------+--------+--------+
85|63 56|55 48|47 40|39 32|31 24|23 16|15 8|7 0|
86+--------+--------+--------+--------+--------+--------+--------+--------+
87 | | | | |
88 | | | | v
89 | | | | [15:0] 页内偏移
90 | | | +----------> [28:16] L3 索引
91 | | +--------------------------> [41:29] L2 索引 (仅使用 38:29 )
92 | +-------------------------------> [47:42] L1 索引 (未使用)
93 +-------------------------------------------------> [63] TTBR0/1
diff --git a/MAINTAINERS b/MAINTAINERS
index e73060fe078..9386a63ea8f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -235,6 +235,7 @@ F: drivers/platform/x86/acer-wmi.c
235 235
236ACPI 236ACPI
237M: Len Brown <lenb@kernel.org> 237M: Len Brown <lenb@kernel.org>
238M: Rafael J. Wysocki <rjw@sisk.pl>
238L: linux-acpi@vger.kernel.org 239L: linux-acpi@vger.kernel.org
239W: http://www.lesswatts.org/projects/acpi/ 240W: http://www.lesswatts.org/projects/acpi/
240Q: http://patchwork.kernel.org/project/linux-acpi/list/ 241Q: http://patchwork.kernel.org/project/linux-acpi/list/
@@ -502,7 +503,7 @@ F: include/linux/altera_uart.h
502F: include/linux/altera_jtaguart.h 503F: include/linux/altera_jtaguart.h
503 504
504AMD FAM15H PROCESSOR POWER MONITORING DRIVER 505AMD FAM15H PROCESSOR POWER MONITORING DRIVER
505M: Andreas Herrmann <andreas.herrmann3@amd.com> 506M: Andreas Herrmann <herrmann.der.user@googlemail.com>
506L: lm-sensors@lm-sensors.org 507L: lm-sensors@lm-sensors.org
507S: Maintained 508S: Maintained
508F: Documentation/hwmon/fam15h_power 509F: Documentation/hwmon/fam15h_power
@@ -525,17 +526,17 @@ F: drivers/video/geode/
525F: arch/x86/include/asm/geode.h 526F: arch/x86/include/asm/geode.h
526 527
527AMD IOMMU (AMD-VI) 528AMD IOMMU (AMD-VI)
528M: Joerg Roedel <joerg.roedel@amd.com> 529M: Joerg Roedel <joro@8bytes.org>
529L: iommu@lists.linux-foundation.org 530L: iommu@lists.linux-foundation.org
530T: git git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu.git 531T: git git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu.git
531S: Supported 532S: Maintained
532F: drivers/iommu/amd_iommu*.[ch] 533F: drivers/iommu/amd_iommu*.[ch]
533F: include/linux/amd-iommu.h 534F: include/linux/amd-iommu.h
534 535
535AMD MICROCODE UPDATE SUPPORT 536AMD MICROCODE UPDATE SUPPORT
536M: Andreas Herrmann <andreas.herrmann3@amd.com> 537M: Andreas Herrmann <herrmann.der.user@googlemail.com>
537L: amd64-microcode@amd64.org 538L: amd64-microcode@amd64.org
538S: Supported 539S: Maintained
539F: arch/x86/kernel/microcode_amd.c 540F: arch/x86/kernel/microcode_amd.c
540 541
541AMS (Apple Motion Sensor) DRIVER 542AMS (Apple Motion Sensor) DRIVER
@@ -636,6 +637,13 @@ W: http://www.arm.linux.org.uk/
636S: Maintained 637S: Maintained
637F: arch/arm/ 638F: arch/arm/
638 639
640ARM SUB-ARCHITECTURES
641L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
642S: MAINTAINED
643F: arch/arm/mach-*/
644F: arch/arm/plat-*/
645T: git git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc.git
646
639ARM PRIMECELL AACI PL041 DRIVER 647ARM PRIMECELL AACI PL041 DRIVER
640M: Russell King <linux@arm.linux.org.uk> 648M: Russell King <linux@arm.linux.org.uk>
641S: Maintained 649S: Maintained
@@ -833,6 +841,14 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/kristoffer/linux-hpc.git
833F: arch/arm/mach-sa1100/jornada720.c 841F: arch/arm/mach-sa1100/jornada720.c
834F: arch/arm/mach-sa1100/include/mach/jornada720.h 842F: arch/arm/mach-sa1100/include/mach/jornada720.h
835 843
844ARM/IGEP MACHINE SUPPORT
845M: Enric Balletbo i Serra <eballetbo@gmail.com>
846M: Javier Martinez Canillas <javier@dowhile0.org>
847L: linux-omap@vger.kernel.org
848L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
849S: Maintained
850F: arch/arm/mach-omap2/board-igep0020.c
851
836ARM/INCOME PXA270 SUPPORT 852ARM/INCOME PXA270 SUPPORT
837M: Marek Vasut <marek.vasut@gmail.com> 853M: Marek Vasut <marek.vasut@gmail.com>
838L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) 854L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
@@ -2499,6 +2515,7 @@ M: Joonyoung Shim <jy0922.shim@samsung.com>
2499M: Seung-Woo Kim <sw0312.kim@samsung.com> 2515M: Seung-Woo Kim <sw0312.kim@samsung.com>
2500M: Kyungmin Park <kyungmin.park@samsung.com> 2516M: Kyungmin Park <kyungmin.park@samsung.com>
2501L: dri-devel@lists.freedesktop.org 2517L: dri-devel@lists.freedesktop.org
2518T: git git://git.kernel.org/pub/scm/linux/kernel/git/daeinki/drm-exynos.git
2502S: Supported 2519S: Supported
2503F: drivers/gpu/drm/exynos 2520F: drivers/gpu/drm/exynos
2504F: include/drm/exynos* 2521F: include/drm/exynos*
@@ -2699,10 +2716,10 @@ F: include/linux/edac.h
2699 2716
2700EDAC-AMD64 2717EDAC-AMD64
2701M: Doug Thompson <dougthompson@xmission.com> 2718M: Doug Thompson <dougthompson@xmission.com>
2702M: Borislav Petkov <borislav.petkov@amd.com> 2719M: Borislav Petkov <bp@alien8.de>
2703L: linux-edac@vger.kernel.org 2720L: linux-edac@vger.kernel.org
2704W: bluesmoke.sourceforge.net 2721W: bluesmoke.sourceforge.net
2705S: Supported 2722S: Maintained
2706F: drivers/edac/amd64_edac* 2723F: drivers/edac/amd64_edac*
2707 2724
2708EDAC-E752X 2725EDAC-E752X
@@ -2801,6 +2818,7 @@ F: sound/usb/misc/ua101.c
2801EXTENSIBLE FIRMWARE INTERFACE (EFI) 2818EXTENSIBLE FIRMWARE INTERFACE (EFI)
2802M: Matt Fleming <matt.fleming@intel.com> 2819M: Matt Fleming <matt.fleming@intel.com>
2803L: linux-efi@vger.kernel.org 2820L: linux-efi@vger.kernel.org
2821T: git git://git.kernel.org/pub/scm/linux/kernel/git/mfleming/efi.git
2804S: Maintained 2822S: Maintained
2805F: Documentation/x86/efi-stub.txt 2823F: Documentation/x86/efi-stub.txt
2806F: arch/ia64/kernel/efi.c 2824F: arch/ia64/kernel/efi.c
@@ -3588,6 +3606,49 @@ F: drivers/hid/hid-hyperv.c
3588F: drivers/net/hyperv/ 3606F: drivers/net/hyperv/
3589F: drivers/staging/hv/ 3607F: drivers/staging/hv/
3590 3608
3609I2C OVER PARALLEL PORT
3610M: Jean Delvare <khali@linux-fr.org>
3611L: linux-i2c@vger.kernel.org
3612S: Maintained
3613F: Documentation/i2c/busses/i2c-parport
3614F: Documentation/i2c/busses/i2c-parport-light
3615F: drivers/i2c/busses/i2c-parport.c
3616F: drivers/i2c/busses/i2c-parport-light.c
3617
3618I2C/SMBUS CONTROLLER DRIVERS FOR PC
3619M: Jean Delvare <khali@linux-fr.org>
3620L: linux-i2c@vger.kernel.org
3621S: Maintained
3622F: Documentation/i2c/busses/i2c-ali1535
3623F: Documentation/i2c/busses/i2c-ali1563
3624F: Documentation/i2c/busses/i2c-ali15x3
3625F: Documentation/i2c/busses/i2c-amd756
3626F: Documentation/i2c/busses/i2c-amd8111
3627F: Documentation/i2c/busses/i2c-i801
3628F: Documentation/i2c/busses/i2c-nforce2
3629F: Documentation/i2c/busses/i2c-piix4
3630F: Documentation/i2c/busses/i2c-sis5595
3631F: Documentation/i2c/busses/i2c-sis630
3632F: Documentation/i2c/busses/i2c-sis96x
3633F: Documentation/i2c/busses/i2c-via
3634F: Documentation/i2c/busses/i2c-viapro
3635F: drivers/i2c/busses/i2c-ali1535.c
3636F: drivers/i2c/busses/i2c-ali1563.c
3637F: drivers/i2c/busses/i2c-ali15x3.c
3638F: drivers/i2c/busses/i2c-amd756.c
3639F: drivers/i2c/busses/i2c-amd756-s4882.c
3640F: drivers/i2c/busses/i2c-amd8111.c
3641F: drivers/i2c/busses/i2c-i801.c
3642F: drivers/i2c/busses/i2c-isch.c
3643F: drivers/i2c/busses/i2c-nforce2.c
3644F: drivers/i2c/busses/i2c-nforce2-s4985.c
3645F: drivers/i2c/busses/i2c-piix4.c
3646F: drivers/i2c/busses/i2c-sis5595.c
3647F: drivers/i2c/busses/i2c-sis630.c
3648F: drivers/i2c/busses/i2c-sis96x.c
3649F: drivers/i2c/busses/i2c-via.c
3650F: drivers/i2c/busses/i2c-viapro.c
3651
3591I2C/SMBUS STUB DRIVER 3652I2C/SMBUS STUB DRIVER
3592M: "Mark M. Hoffman" <mhoffman@lightlink.com> 3653M: "Mark M. Hoffman" <mhoffman@lightlink.com>
3593L: linux-i2c@vger.kernel.org 3654L: linux-i2c@vger.kernel.org
@@ -3595,9 +3656,8 @@ S: Maintained
3595F: drivers/i2c/busses/i2c-stub.c 3656F: drivers/i2c/busses/i2c-stub.c
3596 3657
3597I2C SUBSYSTEM 3658I2C SUBSYSTEM
3598M: "Jean Delvare (PC drivers, core)" <khali@linux-fr.org> 3659M: Wolfram Sang <w.sang@pengutronix.de>
3599M: "Ben Dooks (embedded platforms)" <ben-linux@fluff.org> 3660M: "Ben Dooks (embedded platforms)" <ben-linux@fluff.org>
3600M: "Wolfram Sang (embedded platforms)" <w.sang@pengutronix.de>
3601L: linux-i2c@vger.kernel.org 3661L: linux-i2c@vger.kernel.org
3602W: http://i2c.wiki.kernel.org/ 3662W: http://i2c.wiki.kernel.org/
3603T: quilt kernel.org/pub/linux/kernel/people/jdelvare/linux-2.6/jdelvare-i2c/ 3663T: quilt kernel.org/pub/linux/kernel/people/jdelvare/linux-2.6/jdelvare-i2c/
@@ -3608,6 +3668,13 @@ F: drivers/i2c/
3608F: include/linux/i2c.h 3668F: include/linux/i2c.h
3609F: include/linux/i2c-*.h 3669F: include/linux/i2c-*.h
3610 3670
3671I2C-TAOS-EVM DRIVER
3672M: Jean Delvare <khali@linux-fr.org>
3673L: linux-i2c@vger.kernel.org
3674S: Maintained
3675F: Documentation/i2c/busses/i2c-taos-evm
3676F: drivers/i2c/busses/i2c-taos-evm.c
3677
3611I2C-TINY-USB DRIVER 3678I2C-TINY-USB DRIVER
3612M: Till Harbaum <till@harbaum.org> 3679M: Till Harbaum <till@harbaum.org>
3613L: linux-i2c@vger.kernel.org 3680L: linux-i2c@vger.kernel.org
@@ -3694,7 +3761,7 @@ S: Maintained
3694F: drivers/platform/x86/ideapad-laptop.c 3761F: drivers/platform/x86/ideapad-laptop.c
3695 3762
3696IDE/ATAPI DRIVERS 3763IDE/ATAPI DRIVERS
3697M: Borislav Petkov <petkovbb@gmail.com> 3764M: Borislav Petkov <bp@alien8.de>
3698L: linux-ide@vger.kernel.org 3765L: linux-ide@vger.kernel.org
3699S: Maintained 3766S: Maintained
3700F: Documentation/cdrom/ide-cd 3767F: Documentation/cdrom/ide-cd
@@ -4221,8 +4288,8 @@ F: include/linux/lockd/
4221F: include/linux/sunrpc/ 4288F: include/linux/sunrpc/
4222 4289
4223KERNEL VIRTUAL MACHINE (KVM) 4290KERNEL VIRTUAL MACHINE (KVM)
4224M: Avi Kivity <avi@redhat.com>
4225M: Marcelo Tosatti <mtosatti@redhat.com> 4291M: Marcelo Tosatti <mtosatti@redhat.com>
4292M: Gleb Natapov <gleb@redhat.com>
4226L: kvm@vger.kernel.org 4293L: kvm@vger.kernel.org
4227W: http://kvm.qumranet.com 4294W: http://kvm.qumranet.com
4228S: Supported 4295S: Supported
@@ -4372,7 +4439,7 @@ F: Documentation/scsi/53c700.txt
4372F: drivers/scsi/53c700* 4439F: drivers/scsi/53c700*
4373 4440
4374LED SUBSYSTEM 4441LED SUBSYSTEM
4375M: Bryan Wu <bryan.wu@canonical.com> 4442M: Bryan Wu <cooloney@gmail.com>
4376M: Richard Purdie <rpurdie@rpsys.net> 4443M: Richard Purdie <rpurdie@rpsys.net>
4377L: linux-leds@vger.kernel.org 4444L: linux-leds@vger.kernel.org
4378T: git git://git.kernel.org/pub/scm/linux/kernel/git/cooloney/linux-leds.git 4445T: git git://git.kernel.org/pub/scm/linux/kernel/git/cooloney/linux-leds.git
@@ -5019,6 +5086,20 @@ F: net/ipv6/
5019F: include/net/ip* 5086F: include/net/ip*
5020F: arch/x86/net/* 5087F: arch/x86/net/*
5021 5088
5089NETWORKING [IPSEC]
5090M: Steffen Klassert <steffen.klassert@secunet.com>
5091M: Herbert Xu <herbert@gondor.apana.org.au>
5092M: "David S. Miller" <davem@davemloft.net>
5093L: netdev@vger.kernel.org
5094T: git git://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git
5095S: Maintained
5096F: net/xfrm/
5097F: net/key/
5098F: net/ipv4/xfrm*
5099F: net/ipv6/xfrm*
5100F: include/uapi/linux/xfrm.h
5101F: include/net/xfrm.h
5102
5022NETWORKING [LABELED] (NetLabel, CIPSO, Labeled IPsec, SECMARK) 5103NETWORKING [LABELED] (NetLabel, CIPSO, Labeled IPsec, SECMARK)
5023M: Paul Moore <paul@paul-moore.com> 5104M: Paul Moore <paul@paul-moore.com>
5024L: netdev@vger.kernel.org 5105L: netdev@vger.kernel.org
@@ -5046,7 +5127,13 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git
5046S: Odd Fixes 5127S: Odd Fixes
5047F: drivers/net/ 5128F: drivers/net/
5048F: include/linux/if_* 5129F: include/linux/if_*
5049F: include/linux/*device.h 5130F: include/linux/netdevice.h
5131F: include/linux/arcdevice.h
5132F: include/linux/etherdevice.h
5133F: include/linux/fcdevice.h
5134F: include/linux/fddidevice.h
5135F: include/linux/hippidevice.h
5136F: include/linux/inetdevice.h
5050 5137
5051NETXEN (1/10) GbE SUPPORT 5138NETXEN (1/10) GbE SUPPORT
5052M: Sony Chacko <sony.chacko@qlogic.com> 5139M: Sony Chacko <sony.chacko@qlogic.com>
@@ -5334,7 +5421,7 @@ S: Maintained
5334F: sound/drivers/opl4/ 5421F: sound/drivers/opl4/
5335 5422
5336OPROFILE 5423OPROFILE
5337M: Robert Richter <robert.richter@amd.com> 5424M: Robert Richter <rric@kernel.org>
5338L: oprofile-list@lists.sf.net 5425L: oprofile-list@lists.sf.net
5339S: Maintained 5426S: Maintained
5340F: arch/*/include/asm/oprofile*.h 5427F: arch/*/include/asm/oprofile*.h
@@ -5618,7 +5705,7 @@ S: Maintained
5618F: drivers/pinctrl/spear/ 5705F: drivers/pinctrl/spear/
5619 5706
5620PKTCDVD DRIVER 5707PKTCDVD DRIVER
5621M: Peter Osterlund <petero2@telia.com> 5708M: Jiri Kosina <jkosina@suse.cz>
5622S: Maintained 5709S: Maintained
5623F: drivers/block/pktcdvd.c 5710F: drivers/block/pktcdvd.c
5624F: include/linux/pktcdvd.h 5711F: include/linux/pktcdvd.h
@@ -7180,6 +7267,14 @@ L: linux-xtensa@linux-xtensa.org
7180S: Maintained 7267S: Maintained
7181F: arch/xtensa/ 7268F: arch/xtensa/
7182 7269
7270THERMAL
7271M: Zhang Rui <rui.zhang@intel.com>
7272L: linux-pm@vger.kernel.org
7273T: git git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux.git
7274S: Supported
7275F: drivers/thermal/
7276F: include/linux/thermal.h
7277
7183THINKPAD ACPI EXTRAS DRIVER 7278THINKPAD ACPI EXTRAS DRIVER
7184M: Henrique de Moraes Holschuh <ibm-acpi@hmh.eng.br> 7279M: Henrique de Moraes Holschuh <ibm-acpi@hmh.eng.br>
7185L: ibm-acpi-devel@lists.sourceforge.net 7280L: ibm-acpi-devel@lists.sourceforge.net
@@ -7731,6 +7826,13 @@ W: http://www.ideasonboard.org/uvc/
7731S: Maintained 7826S: Maintained
7732F: drivers/media/usb/uvc/ 7827F: drivers/media/usb/uvc/
7733 7828
7829USB WEBCAM GADGET
7830M: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
7831L: linux-usb@vger.kernel.org
7832S: Maintained
7833F: drivers/usb/gadget/*uvc*.c
7834F: drivers/usb/gadget/webcam.c
7835
7734USB WIRELESS RNDIS DRIVER (rndis_wlan) 7836USB WIRELESS RNDIS DRIVER (rndis_wlan)
7735M: Jussi Kivilinna <jussi.kivilinna@mbnet.fi> 7837M: Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
7736L: linux-wireless@vger.kernel.org 7838L: linux-wireless@vger.kernel.org
@@ -7850,13 +7952,6 @@ M: Roger Luethi <rl@hellgate.ch>
7850S: Maintained 7952S: Maintained
7851F: drivers/net/ethernet/via/via-rhine.c 7953F: drivers/net/ethernet/via/via-rhine.c
7852 7954
7853VIAPRO SMBUS DRIVER
7854M: Jean Delvare <khali@linux-fr.org>
7855L: linux-i2c@vger.kernel.org
7856S: Maintained
7857F: Documentation/i2c/busses/i2c-viapro
7858F: drivers/i2c/busses/i2c-viapro.c
7859
7860VIA SD/MMC CARD CONTROLLER DRIVER 7955VIA SD/MMC CARD CONTROLLER DRIVER
7861M: Bruce Chang <brucechang@via.com.tw> 7956M: Bruce Chang <brucechang@via.com.tw>
7862M: Harald Welte <HaraldWelte@viatech.com> 7957M: Harald Welte <HaraldWelte@viatech.com>
@@ -8111,7 +8206,7 @@ F: drivers/platform/x86
8111 8206
8112X86 MCE INFRASTRUCTURE 8207X86 MCE INFRASTRUCTURE
8113M: Tony Luck <tony.luck@intel.com> 8208M: Tony Luck <tony.luck@intel.com>
8114M: Borislav Petkov <bp@amd64.org> 8209M: Borislav Petkov <bp@alien8.de>
8115L: linux-edac@vger.kernel.org 8210L: linux-edac@vger.kernel.org
8116S: Maintained 8211S: Maintained
8117F: arch/x86/kernel/cpu/mcheck/* 8212F: arch/x86/kernel/cpu/mcheck/*
diff --git a/Makefile b/Makefile
index 5be2ee8c90e..3d2fc460b22 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 3 1VERSION = 3
2PATCHLEVEL = 7 2PATCHLEVEL = 7
3SUBLEVEL = 0 3SUBLEVEL = 0
4EXTRAVERSION = -rc1 4EXTRAVERSION = -rc7
5NAME = Terrified Chipmunk 5NAME = Terrified Chipmunk
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
@@ -437,7 +437,9 @@ endif
437PHONY += asm-generic 437PHONY += asm-generic
438asm-generic: 438asm-generic:
439 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.asm-generic \ 439 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.asm-generic \
440 obj=arch/$(SRCARCH)/include/generated/asm 440 src=asm obj=arch/$(SRCARCH)/include/generated/asm
441 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.asm-generic \
442 src=uapi/asm obj=arch/$(SRCARCH)/include/generated/uapi/asm
441 443
442# To make sure we do not include .config for any of the *config targets 444# To make sure we do not include .config for any of the *config targets
443# catch them early, and hand them over to scripts/kconfig/Makefile 445# catch them early, and hand them over to scripts/kconfig/Makefile
@@ -717,6 +719,17 @@ endif # INSTALL_MOD_STRIP
717export mod_strip_cmd 719export mod_strip_cmd
718 720
719 721
722ifeq ($(CONFIG_MODULE_SIG),y)
723MODSECKEY = ./signing_key.priv
724MODPUBKEY = ./signing_key.x509
725export MODPUBKEY
726mod_sign_cmd = perl $(srctree)/scripts/sign-file $(MODSECKEY) $(MODPUBKEY)
727else
728mod_sign_cmd = true
729endif
730export mod_sign_cmd
731
732
720ifeq ($(KBUILD_EXTMOD),) 733ifeq ($(KBUILD_EXTMOD),)
721core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ 734core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/
722 735
diff --git a/arch/Kconfig b/arch/Kconfig
index 366ec06a518..8d698fb5ccc 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -341,4 +341,18 @@ config MODULES_USE_ELF_REL
341 Modules only use ELF REL relocations. Modules with ELF RELA 341 Modules only use ELF REL relocations. Modules with ELF RELA
342 relocations will give an error. 342 relocations will give an error.
343 343
344#
345# ABI hall of shame
346#
347config CLONE_BACKWARDS
348 bool
349 help
350 Architecture has tls passed as the 4th argument of clone(2),
351 not the 5th one.
352
353config CLONE_BACKWARDS2
354 bool
355 help
356 Architecture has the first two arguments of clone(2) swapped.
357
344source "kernel/gcov/Kconfig" 358source "kernel/gcov/Kconfig"
diff --git a/arch/alpha/include/asm/thread_info.h b/arch/alpha/include/asm/thread_info.h
index 4554ecbff7c..1f8c72959fb 100644
--- a/arch/alpha/include/asm/thread_info.h
+++ b/arch/alpha/include/asm/thread_info.h
@@ -7,6 +7,7 @@
7#include <asm/processor.h> 7#include <asm/processor.h>
8#include <asm/types.h> 8#include <asm/types.h>
9#include <asm/hwrpb.h> 9#include <asm/hwrpb.h>
10#include <asm/sysinfo.h>
10#endif 11#endif
11 12
12#ifndef __ASSEMBLY__ 13#ifndef __ASSEMBLY__
@@ -21,6 +22,7 @@ struct thread_info {
21 mm_segment_t addr_limit; /* thread address space */ 22 mm_segment_t addr_limit; /* thread address space */
22 unsigned cpu; /* current CPU */ 23 unsigned cpu; /* current CPU */
23 int preempt_count; /* 0 => preemptable, <0 => BUG */ 24 int preempt_count; /* 0 => preemptable, <0 => BUG */
25 unsigned int status; /* thread-synchronous flags */
24 26
25 int bpt_nsaved; 27 int bpt_nsaved;
26 unsigned long bpt_addr[2]; /* breakpoint handling */ 28 unsigned long bpt_addr[2]; /* breakpoint handling */
@@ -63,8 +65,6 @@ register struct thread_info *__current_thread_info __asm__("$8");
63 * - these are process state flags and used from assembly 65 * - these are process state flags and used from assembly
64 * - pending work-to-be-done flags come first and must be assigned to be 66 * - pending work-to-be-done flags come first and must be assigned to be
65 * within bits 0 to 7 to fit in and immediate operand. 67 * within bits 0 to 7 to fit in and immediate operand.
66 * - ALPHA_UAC_SHIFT below must be kept consistent with the unaligned
67 * control flags.
68 * 68 *
69 * TIF_SYSCALL_TRACE is known to be 0 via blbs. 69 * TIF_SYSCALL_TRACE is known to be 0 via blbs.
70 */ 70 */
@@ -72,18 +72,12 @@ register struct thread_info *__current_thread_info __asm__("$8");
72#define TIF_NOTIFY_RESUME 1 /* callback before returning to user */ 72#define TIF_NOTIFY_RESUME 1 /* callback before returning to user */
73#define TIF_SIGPENDING 2 /* signal pending */ 73#define TIF_SIGPENDING 2 /* signal pending */
74#define TIF_NEED_RESCHED 3 /* rescheduling necessary */ 74#define TIF_NEED_RESCHED 3 /* rescheduling necessary */
75#define TIF_POLLING_NRFLAG 8 /* poll_idle is polling NEED_RESCHED */
76#define TIF_DIE_IF_KERNEL 9 /* dik recursion lock */ 75#define TIF_DIE_IF_KERNEL 9 /* dik recursion lock */
77#define TIF_UAC_NOPRINT 10 /* ! Preserve sequence of following */
78#define TIF_UAC_NOFIX 11 /* ! flags as they match */
79#define TIF_UAC_SIGBUS 12 /* ! userspace part of 'osf_sysinfo' */
80#define TIF_MEMDIE 13 /* is terminating due to OOM killer */ 76#define TIF_MEMDIE 13 /* is terminating due to OOM killer */
81#define TIF_RESTORE_SIGMASK 14 /* restore signal mask in do_signal */
82 77
83#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) 78#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
84#define _TIF_SIGPENDING (1<<TIF_SIGPENDING) 79#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
85#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) 80#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
86#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
87#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME) 81#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
88 82
89/* Work to do on interrupt/exception return. */ 83/* Work to do on interrupt/exception return. */
@@ -94,29 +88,63 @@ register struct thread_info *__current_thread_info __asm__("$8");
94#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK \ 88#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK \
95 | _TIF_SYSCALL_TRACE) 89 | _TIF_SYSCALL_TRACE)
96 90
97#define ALPHA_UAC_SHIFT TIF_UAC_NOPRINT 91#define TS_UAC_NOPRINT 0x0001 /* ! Preserve the following three */
98#define ALPHA_UAC_MASK (1 << TIF_UAC_NOPRINT | 1 << TIF_UAC_NOFIX | \ 92#define TS_UAC_NOFIX 0x0002 /* ! flags as they match */
99 1 << TIF_UAC_SIGBUS) 93#define TS_UAC_SIGBUS 0x0004 /* ! userspace part of 'osf_sysinfo' */
94#define TS_RESTORE_SIGMASK 0x0008 /* restore signal mask in do_signal() */
95#define TS_POLLING 0x0010 /* idle task polling need_resched,
96 skip sending interrupt */
100 97
101#define SET_UNALIGN_CTL(task,value) ({ \ 98#define tsk_is_polling(t) (task_thread_info(t)->status & TS_POLLING)
102 task_thread_info(task)->flags = ((task_thread_info(task)->flags & \ 99
103 ~ALPHA_UAC_MASK) \ 100#ifndef __ASSEMBLY__
104 | (((value) << ALPHA_UAC_SHIFT) & (1<<TIF_UAC_NOPRINT))\ 101#define HAVE_SET_RESTORE_SIGMASK 1
105 | (((value) << (ALPHA_UAC_SHIFT + 1)) & (1<<TIF_UAC_SIGBUS)) \ 102static inline void set_restore_sigmask(void)
106 | (((value) << (ALPHA_UAC_SHIFT - 1)) & (1<<TIF_UAC_NOFIX)));\ 103{
104 struct thread_info *ti = current_thread_info();
105 ti->status |= TS_RESTORE_SIGMASK;
106 WARN_ON(!test_bit(TIF_SIGPENDING, (unsigned long *)&ti->flags));
107}
108static inline void clear_restore_sigmask(void)
109{
110 current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
111}
112static inline bool test_restore_sigmask(void)
113{
114 return current_thread_info()->status & TS_RESTORE_SIGMASK;
115}
116static inline bool test_and_clear_restore_sigmask(void)
117{
118 struct thread_info *ti = current_thread_info();
119 if (!(ti->status & TS_RESTORE_SIGMASK))
120 return false;
121 ti->status &= ~TS_RESTORE_SIGMASK;
122 return true;
123}
124#endif
125
126#define SET_UNALIGN_CTL(task,value) ({ \
127 __u32 status = task_thread_info(task)->status & ~UAC_BITMASK; \
128 if (value & PR_UNALIGN_NOPRINT) \
129 status |= TS_UAC_NOPRINT; \
130 if (value & PR_UNALIGN_SIGBUS) \
131 status |= TS_UAC_SIGBUS; \
132 if (value & 4) /* alpha-specific */ \
133 status |= TS_UAC_NOFIX; \
134 task_thread_info(task)->status = status; \
107 0; }) 135 0; })
108 136
109#define GET_UNALIGN_CTL(task,value) ({ \ 137#define GET_UNALIGN_CTL(task,value) ({ \
110 put_user((task_thread_info(task)->flags & (1 << TIF_UAC_NOPRINT))\ 138 __u32 status = task_thread_info(task)->status & ~UAC_BITMASK; \
111 >> ALPHA_UAC_SHIFT \ 139 __u32 res = 0; \
112 | (task_thread_info(task)->flags & (1 << TIF_UAC_SIGBUS))\ 140 if (status & TS_UAC_NOPRINT) \
113 >> (ALPHA_UAC_SHIFT + 1) \ 141 res |= PR_UNALIGN_NOPRINT; \
114 | (task_thread_info(task)->flags & (1 << TIF_UAC_NOFIX))\ 142 if (status & TS_UAC_SIGBUS) \
115 >> (ALPHA_UAC_SHIFT - 1), \ 143 res |= PR_UNALIGN_SIGBUS; \
116 (int __user *)(value)); \ 144 if (status & TS_UAC_NOFIX) \
145 res |= 4; \
146 put_user(res, (int __user *)(value)); \
117 }) 147 })
118 148
119#define tsk_is_polling(t) test_tsk_thread_flag(t, TIF_POLLING_NRFLAG)
120
121#endif /* __KERNEL__ */ 149#endif /* __KERNEL__ */
122#endif /* _ALPHA_THREAD_INFO_H */ 150#endif /* _ALPHA_THREAD_INFO_H */
diff --git a/arch/alpha/kernel/entry.S b/arch/alpha/kernel/entry.S
index a7607832dd4..c245de65c61 100644
--- a/arch/alpha/kernel/entry.S
+++ b/arch/alpha/kernel/entry.S
@@ -617,7 +617,6 @@ ret_from_kernel_thread:
617 .ent sys_fork 617 .ent sys_fork
618sys_fork: 618sys_fork:
619 .prologue 0 619 .prologue 0
620 mov $sp, $21
621 bsr $1, do_switch_stack 620 bsr $1, do_switch_stack
622 bis $31, SIGCHLD, $16 621 bis $31, SIGCHLD, $16
623 mov $31, $17 622 mov $31, $17
@@ -625,7 +624,9 @@ sys_fork:
625 mov $31, $19 624 mov $31, $19
626 mov $31, $20 625 mov $31, $20
627 jsr $26, alpha_clone 626 jsr $26, alpha_clone
628 bsr $1, undo_switch_stack 627fork_out:
628 ldq $26, 56($sp)
629 lda $sp, SWITCH_STACK_SIZE($sp)
629 ret 630 ret
630.end sys_fork 631.end sys_fork
631 632
@@ -634,12 +635,10 @@ sys_fork:
634 .ent sys_clone 635 .ent sys_clone
635sys_clone: 636sys_clone:
636 .prologue 0 637 .prologue 0
637 mov $sp, $21
638 bsr $1, do_switch_stack 638 bsr $1, do_switch_stack
639 /* $16, $17, $18, $19, $20 come from the user. */ 639 /* $16, $17, $18, $19, $20 come from the user. */
640 jsr $26, alpha_clone 640 lda $26, fork_out
641 bsr $1, undo_switch_stack 641 jsr $31, alpha_clone
642 ret
643.end sys_clone 642.end sys_clone
644 643
645 .align 4 644 .align 4
@@ -647,11 +646,9 @@ sys_clone:
647 .ent sys_vfork 646 .ent sys_vfork
648sys_vfork: 647sys_vfork:
649 .prologue 0 648 .prologue 0
650 mov $sp, $16
651 bsr $1, do_switch_stack 649 bsr $1, do_switch_stack
652 jsr $26, alpha_vfork 650 lda $26, fork_out
653 bsr $1, undo_switch_stack 651 jsr $31, alpha_vfork
654 ret
655.end sys_vfork 652.end sys_vfork
656 653
657 .align 4 654 .align 4
@@ -661,8 +658,6 @@ sys_sigreturn:
661 .prologue 0 658 .prologue 0
662 lda $9, ret_from_straced 659 lda $9, ret_from_straced
663 cmpult $26, $9, $9 660 cmpult $26, $9, $9
664 mov $sp, $17
665 lda $18, -SWITCH_STACK_SIZE($sp)
666 lda $sp, -SWITCH_STACK_SIZE($sp) 661 lda $sp, -SWITCH_STACK_SIZE($sp)
667 jsr $26, do_sigreturn 662 jsr $26, do_sigreturn
668 bne $9, 1f 663 bne $9, 1f
@@ -678,8 +673,6 @@ sys_rt_sigreturn:
678 .prologue 0 673 .prologue 0
679 lda $9, ret_from_straced 674 lda $9, ret_from_straced
680 cmpult $26, $9, $9 675 cmpult $26, $9, $9
681 mov $sp, $17
682 lda $18, -SWITCH_STACK_SIZE($sp)
683 lda $sp, -SWITCH_STACK_SIZE($sp) 676 lda $sp, -SWITCH_STACK_SIZE($sp)
684 jsr $26, do_rt_sigreturn 677 jsr $26, do_rt_sigreturn
685 bne $9, 1f 678 bne $9, 1f
diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
index 9eb090582cf..14db93e4c8a 100644
--- a/arch/alpha/kernel/osf_sys.c
+++ b/arch/alpha/kernel/osf_sys.c
@@ -445,7 +445,7 @@ struct procfs_args {
445 * unhappy with OSF UFS. [CHECKME] 445 * unhappy with OSF UFS. [CHECKME]
446 */ 446 */
447static int 447static int
448osf_ufs_mount(char *dirname, struct ufs_args __user *args, int flags) 448osf_ufs_mount(const char *dirname, struct ufs_args __user *args, int flags)
449{ 449{
450 int retval; 450 int retval;
451 struct cdfs_args tmp; 451 struct cdfs_args tmp;
@@ -465,7 +465,7 @@ osf_ufs_mount(char *dirname, struct ufs_args __user *args, int flags)
465} 465}
466 466
467static int 467static int
468osf_cdfs_mount(char *dirname, struct cdfs_args __user *args, int flags) 468osf_cdfs_mount(const char *dirname, struct cdfs_args __user *args, int flags)
469{ 469{
470 int retval; 470 int retval;
471 struct cdfs_args tmp; 471 struct cdfs_args tmp;
@@ -485,7 +485,7 @@ osf_cdfs_mount(char *dirname, struct cdfs_args __user *args, int flags)
485} 485}
486 486
487static int 487static int
488osf_procfs_mount(char *dirname, struct procfs_args __user *args, int flags) 488osf_procfs_mount(const char *dirname, struct procfs_args __user *args, int flags)
489{ 489{
490 struct procfs_args tmp; 490 struct procfs_args tmp;
491 491
@@ -793,8 +793,7 @@ SYSCALL_DEFINE5(osf_getsysinfo, unsigned long, op, void __user *, buffer,
793 case GSI_UACPROC: 793 case GSI_UACPROC:
794 if (nbytes < sizeof(unsigned int)) 794 if (nbytes < sizeof(unsigned int))
795 return -EINVAL; 795 return -EINVAL;
796 w = (current_thread_info()->flags >> ALPHA_UAC_SHIFT) & 796 w = current_thread_info()->status & UAC_BITMASK;
797 UAC_BITMASK;
798 if (put_user(w, (unsigned int __user *)buffer)) 797 if (put_user(w, (unsigned int __user *)buffer))
799 return -EFAULT; 798 return -EFAULT;
800 return 1; 799 return 1;
@@ -904,24 +903,20 @@ SYSCALL_DEFINE5(osf_setsysinfo, unsigned long, op, void __user *, buffer,
904 break; 903 break;
905 904
906 case SSI_NVPAIRS: { 905 case SSI_NVPAIRS: {
907 unsigned long v, w, i; 906 unsigned __user *p = buffer;
908 unsigned int old, new; 907 unsigned i;
909 908
910 for (i = 0; i < nbytes; ++i) { 909 for (i = 0, p = buffer; i < nbytes; ++i, p += 2) {
910 unsigned v, w, status;
911 911
912 if (get_user(v, 2*i + (unsigned int __user *)buffer)) 912 if (get_user(v, p) || get_user(w, p + 1))
913 return -EFAULT;
914 if (get_user(w, 2*i + 1 + (unsigned int __user *)buffer))
915 return -EFAULT; 913 return -EFAULT;
916 switch (v) { 914 switch (v) {
917 case SSIN_UACPROC: 915 case SSIN_UACPROC:
918 again: 916 w &= UAC_BITMASK;
919 old = current_thread_info()->flags; 917 status = current_thread_info()->status;
920 new = old & ~(UAC_BITMASK << ALPHA_UAC_SHIFT); 918 status = (status & ~UAC_BITMASK) | w;
921 new = new | (w & UAC_BITMASK) << ALPHA_UAC_SHIFT; 919 current_thread_info()->status = status;
922 if (cmpxchg(&current_thread_info()->flags,
923 old, new) != old)
924 goto again;
925 break; 920 break;
926 921
927 default: 922 default:
diff --git a/arch/alpha/kernel/process.c b/arch/alpha/kernel/process.c
index 4054e0ffe2b..a4dc79ba030 100644
--- a/arch/alpha/kernel/process.c
+++ b/arch/alpha/kernel/process.c
@@ -49,7 +49,7 @@ EXPORT_SYMBOL(pm_power_off);
49void 49void
50cpu_idle(void) 50cpu_idle(void)
51{ 51{
52 set_thread_flag(TIF_POLLING_NRFLAG); 52 current_thread_info()->status |= TS_POLLING;
53 53
54 while (1) { 54 while (1) {
55 /* FIXME -- EV6 and LCA45 know how to power down 55 /* FIXME -- EV6 and LCA45 know how to power down
@@ -246,19 +246,17 @@ release_thread(struct task_struct *dead_task)
246int 246int
247alpha_clone(unsigned long clone_flags, unsigned long usp, 247alpha_clone(unsigned long clone_flags, unsigned long usp,
248 int __user *parent_tid, int __user *child_tid, 248 int __user *parent_tid, int __user *child_tid,
249 unsigned long tls_value, struct pt_regs *regs) 249 unsigned long tls_value)
250{ 250{
251 if (!usp) 251 return do_fork(clone_flags, usp, current_pt_regs(), 0,
252 usp = rdusp(); 252 parent_tid, child_tid);
253
254 return do_fork(clone_flags, usp, regs, 0, parent_tid, child_tid);
255} 253}
256 254
257int 255int
258alpha_vfork(struct pt_regs *regs) 256alpha_vfork(void)
259{ 257{
260 return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, rdusp(), 258 return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, 0,
261 regs, 0, NULL, NULL); 259 current_pt_regs(), 0, NULL, NULL);
262} 260}
263 261
264/* 262/*
@@ -268,18 +266,22 @@ alpha_vfork(struct pt_regs *regs)
268int 266int
269copy_thread(unsigned long clone_flags, unsigned long usp, 267copy_thread(unsigned long clone_flags, unsigned long usp,
270 unsigned long arg, 268 unsigned long arg,
271 struct task_struct * p, struct pt_regs * regs) 269 struct task_struct *p, struct pt_regs *wontuse)
272{ 270{
273 extern void ret_from_fork(void); 271 extern void ret_from_fork(void);
274 extern void ret_from_kernel_thread(void); 272 extern void ret_from_kernel_thread(void);
275 273
276 struct thread_info *childti = task_thread_info(p); 274 struct thread_info *childti = task_thread_info(p);
277 struct pt_regs *childregs = task_pt_regs(p); 275 struct pt_regs *childregs = task_pt_regs(p);
276 struct pt_regs *regs = current_pt_regs();
278 struct switch_stack *childstack, *stack; 277 struct switch_stack *childstack, *stack;
279 unsigned long settls; 278 unsigned long settls;
280 279
281 childstack = ((struct switch_stack *) childregs) - 1; 280 childstack = ((struct switch_stack *) childregs) - 1;
282 if (unlikely(!regs)) { 281 childti->pcb.ksp = (unsigned long) childstack;
282 childti->pcb.flags = 1; /* set FEN, clear everything else */
283
284 if (unlikely(p->flags & PF_KTHREAD)) {
283 /* kernel thread */ 285 /* kernel thread */
284 memset(childstack, 0, 286 memset(childstack, 0,
285 sizeof(struct switch_stack) + sizeof(struct pt_regs)); 287 sizeof(struct switch_stack) + sizeof(struct pt_regs));
@@ -288,12 +290,17 @@ copy_thread(unsigned long clone_flags, unsigned long usp,
288 childstack->r10 = arg; 290 childstack->r10 = arg;
289 childregs->hae = alpha_mv.hae_cache, 291 childregs->hae = alpha_mv.hae_cache,
290 childti->pcb.usp = 0; 292 childti->pcb.usp = 0;
291 childti->pcb.ksp = (unsigned long) childstack;
292 childti->pcb.flags = 1; /* set FEN, clear everything else */
293 return 0; 293 return 0;
294 } 294 }
295 /* Note: if CLONE_SETTLS is not set, then we must inherit the
296 value from the parent, which will have been set by the block
297 copy in dup_task_struct. This is non-intuitive, but is
298 required for proper operation in the case of a threaded
299 application calling fork. */
300 if (clone_flags & CLONE_SETTLS)
301 childti->pcb.unique = regs->r20;
302 childti->pcb.usp = usp ?: rdusp();
295 *childregs = *regs; 303 *childregs = *regs;
296 settls = regs->r20;
297 childregs->r0 = 0; 304 childregs->r0 = 0;
298 childregs->r19 = 0; 305 childregs->r19 = 0;
299 childregs->r20 = 1; /* OSF/1 has some strange fork() semantics. */ 306 childregs->r20 = 1; /* OSF/1 has some strange fork() semantics. */
@@ -301,22 +308,6 @@ copy_thread(unsigned long clone_flags, unsigned long usp,
301 stack = ((struct switch_stack *) regs) - 1; 308 stack = ((struct switch_stack *) regs) - 1;
302 *childstack = *stack; 309 *childstack = *stack;
303 childstack->r26 = (unsigned long) ret_from_fork; 310 childstack->r26 = (unsigned long) ret_from_fork;
304 childti->pcb.usp = usp;
305 childti->pcb.ksp = (unsigned long) childstack;
306 childti->pcb.flags = 1; /* set FEN, clear everything else */
307
308 /* Set a new TLS for the child thread? Peek back into the
309 syscall arguments that we saved on syscall entry. Oops,
310 except we'd have clobbered it with the parent/child set
311 of r20. Read the saved copy. */
312 /* Note: if CLONE_SETTLS is not set, then we must inherit the
313 value from the parent, which will have been set by the block
314 copy in dup_task_struct. This is non-intuitive, but is
315 required for proper operation in the case of a threaded
316 application calling fork. */
317 if (clone_flags & CLONE_SETTLS)
318 childti->pcb.unique = settls;
319
320 return 0; 311 return 0;
321} 312}
322 313
diff --git a/arch/alpha/kernel/signal.c b/arch/alpha/kernel/signal.c
index 32575f85507..336393c9c11 100644
--- a/arch/alpha/kernel/signal.c
+++ b/arch/alpha/kernel/signal.c
@@ -160,10 +160,10 @@ extern char compile_time_assert
160#define INSN_CALLSYS 0x00000083 160#define INSN_CALLSYS 0x00000083
161 161
162static long 162static long
163restore_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs, 163restore_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs)
164 struct switch_stack *sw)
165{ 164{
166 unsigned long usp; 165 unsigned long usp;
166 struct switch_stack *sw = (struct switch_stack *)regs - 1;
167 long i, err = __get_user(regs->pc, &sc->sc_pc); 167 long i, err = __get_user(regs->pc, &sc->sc_pc);
168 168
169 current_thread_info()->restart_block.fn = do_no_restart_syscall; 169 current_thread_info()->restart_block.fn = do_no_restart_syscall;
@@ -215,9 +215,9 @@ restore_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs,
215 registers and transfer control from userland. */ 215 registers and transfer control from userland. */
216 216
217asmlinkage void 217asmlinkage void
218do_sigreturn(struct sigcontext __user *sc, struct pt_regs *regs, 218do_sigreturn(struct sigcontext __user *sc)
219 struct switch_stack *sw)
220{ 219{
220 struct pt_regs *regs = current_pt_regs();
221 sigset_t set; 221 sigset_t set;
222 222
223 /* Verify that it's a good sigcontext before using it */ 223 /* Verify that it's a good sigcontext before using it */
@@ -228,7 +228,7 @@ do_sigreturn(struct sigcontext __user *sc, struct pt_regs *regs,
228 228
229 set_current_blocked(&set); 229 set_current_blocked(&set);
230 230
231 if (restore_sigcontext(sc, regs, sw)) 231 if (restore_sigcontext(sc, regs))
232 goto give_sigsegv; 232 goto give_sigsegv;
233 233
234 /* Send SIGTRAP if we're single-stepping: */ 234 /* Send SIGTRAP if we're single-stepping: */
@@ -249,9 +249,9 @@ give_sigsegv:
249} 249}
250 250
251asmlinkage void 251asmlinkage void
252do_rt_sigreturn(struct rt_sigframe __user *frame, struct pt_regs *regs, 252do_rt_sigreturn(struct rt_sigframe __user *frame)
253 struct switch_stack *sw)
254{ 253{
254 struct pt_regs *regs = current_pt_regs();
255 sigset_t set; 255 sigset_t set;
256 256
257 /* Verify that it's a good ucontext_t before using it */ 257 /* Verify that it's a good ucontext_t before using it */
@@ -262,7 +262,7 @@ do_rt_sigreturn(struct rt_sigframe __user *frame, struct pt_regs *regs,
262 262
263 set_current_blocked(&set); 263 set_current_blocked(&set);
264 264
265 if (restore_sigcontext(&frame->uc.uc_mcontext, regs, sw)) 265 if (restore_sigcontext(&frame->uc.uc_mcontext, regs))
266 goto give_sigsegv; 266 goto give_sigsegv;
267 267
268 /* Send SIGTRAP if we're single-stepping: */ 268 /* Send SIGTRAP if we're single-stepping: */
diff --git a/arch/alpha/kernel/traps.c b/arch/alpha/kernel/traps.c
index 80d987c0e9a..272666d006d 100644
--- a/arch/alpha/kernel/traps.c
+++ b/arch/alpha/kernel/traps.c
@@ -780,17 +780,17 @@ do_entUnaUser(void __user * va, unsigned long opcode,
780 /* Check the UAC bits to decide what the user wants us to do 780 /* Check the UAC bits to decide what the user wants us to do
781 with the unaliged access. */ 781 with the unaliged access. */
782 782
783 if (!test_thread_flag (TIF_UAC_NOPRINT)) { 783 if (!(current_thread_info()->status & TS_UAC_NOPRINT)) {
784 if (__ratelimit(&ratelimit)) { 784 if (__ratelimit(&ratelimit)) {
785 printk("%s(%d): unaligned trap at %016lx: %p %lx %ld\n", 785 printk("%s(%d): unaligned trap at %016lx: %p %lx %ld\n",
786 current->comm, task_pid_nr(current), 786 current->comm, task_pid_nr(current),
787 regs->pc - 4, va, opcode, reg); 787 regs->pc - 4, va, opcode, reg);
788 } 788 }
789 } 789 }
790 if (test_thread_flag (TIF_UAC_SIGBUS)) 790 if ((current_thread_info()->status & TS_UAC_SIGBUS))
791 goto give_sigbus; 791 goto give_sigbus;
792 /* Not sure why you'd want to use this, but... */ 792 /* Not sure why you'd want to use this, but... */
793 if (test_thread_flag (TIF_UAC_NOFIX)) 793 if ((current_thread_info()->status & TS_UAC_NOFIX))
794 return; 794 return;
795 795
796 /* Don't bother reading ds in the access check since we already 796 /* Don't bother reading ds in the access check since we already
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 73067efd484..ade7e924bef 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1603,8 +1603,8 @@ config NR_CPUS
1603 default "4" 1603 default "4"
1604 1604
1605config HOTPLUG_CPU 1605config HOTPLUG_CPU
1606 bool "Support for hot-pluggable CPUs (EXPERIMENTAL)" 1606 bool "Support for hot-pluggable CPUs"
1607 depends on SMP && HOTPLUG && EXPERIMENTAL 1607 depends on SMP && HOTPLUG
1608 help 1608 help
1609 Say Y here to experiment with turning CPUs off and on. CPUs 1609 Say Y here to experiment with turning CPUs off and on. CPUs
1610 can be controlled through /sys/devices/system/cpu. 1610 can be controlled through /sys/devices/system/cpu.
@@ -1645,8 +1645,8 @@ config HZ
1645 default 100 1645 default 100
1646 1646
1647config THUMB2_KERNEL 1647config THUMB2_KERNEL
1648 bool "Compile the kernel in Thumb-2 mode (EXPERIMENTAL)" 1648 bool "Compile the kernel in Thumb-2 mode"
1649 depends on CPU_V7 && !CPU_V6 && !CPU_V6K && EXPERIMENTAL 1649 depends on CPU_V7 && !CPU_V6 && !CPU_V6K
1650 select AEABI 1650 select AEABI
1651 select ARM_ASM_UNIFIED 1651 select ARM_ASM_UNIFIED
1652 select ARM_UNWIND 1652 select ARM_UNWIND
@@ -1850,6 +1850,7 @@ config XEN_DOM0
1850config XEN 1850config XEN
1851 bool "Xen guest support on ARM (EXPERIMENTAL)" 1851 bool "Xen guest support on ARM (EXPERIMENTAL)"
1852 depends on EXPERIMENTAL && ARM && OF 1852 depends on EXPERIMENTAL && ARM && OF
1853 depends on CPU_V7 && !CPU_V6
1853 help 1854 help
1854 Say Y if you want to run Linux in a Virtual Machine on Xen on ARM. 1855 Say Y if you want to run Linux in a Virtual Machine on Xen on ARM.
1855 1856
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index f023e3acdfb..5f914fca911 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -21,8 +21,6 @@ endif
21OBJCOPYFLAGS :=-O binary -R .comment -S 21OBJCOPYFLAGS :=-O binary -R .comment -S
22GZFLAGS :=-9 22GZFLAGS :=-9
23#KBUILD_CFLAGS +=-pipe 23#KBUILD_CFLAGS +=-pipe
24# Explicitly specifiy 32-bit ARM ISA since toolchain default can be -mthumb:
25KBUILD_CFLAGS +=$(call cc-option,-marm,)
26 24
27# Never generate .eh_frame 25# Never generate .eh_frame
28KBUILD_CFLAGS += $(call cc-option,-fno-dwarf2-cfi-asm) 26KBUILD_CFLAGS += $(call cc-option,-fno-dwarf2-cfi-asm)
@@ -105,17 +103,20 @@ endif
105ifeq ($(CONFIG_THUMB2_KERNEL),y) 103ifeq ($(CONFIG_THUMB2_KERNEL),y)
106AFLAGS_AUTOIT :=$(call as-option,-Wa$(comma)-mimplicit-it=always,-Wa$(comma)-mauto-it) 104AFLAGS_AUTOIT :=$(call as-option,-Wa$(comma)-mimplicit-it=always,-Wa$(comma)-mauto-it)
107AFLAGS_NOWARN :=$(call as-option,-Wa$(comma)-mno-warn-deprecated,-Wa$(comma)-W) 105AFLAGS_NOWARN :=$(call as-option,-Wa$(comma)-mno-warn-deprecated,-Wa$(comma)-W)
108CFLAGS_THUMB2 :=-mthumb $(AFLAGS_AUTOIT) $(AFLAGS_NOWARN) 106CFLAGS_ISA :=-mthumb $(AFLAGS_AUTOIT) $(AFLAGS_NOWARN)
109AFLAGS_THUMB2 :=$(CFLAGS_THUMB2) -Wa$(comma)-mthumb 107AFLAGS_ISA :=$(CFLAGS_ISA) -Wa$(comma)-mthumb
110# Work around buggy relocation from gas if requested: 108# Work around buggy relocation from gas if requested:
111ifeq ($(CONFIG_THUMB2_AVOID_R_ARM_THM_JUMP11),y) 109ifeq ($(CONFIG_THUMB2_AVOID_R_ARM_THM_JUMP11),y)
112CFLAGS_MODULE +=-fno-optimize-sibling-calls 110CFLAGS_MODULE +=-fno-optimize-sibling-calls
113endif 111endif
112else
113CFLAGS_ISA :=$(call cc-option,-marm,)
114AFLAGS_ISA :=$(CFLAGS_ISA)
114endif 115endif
115 116
116# Need -Uarm for gcc < 3.x 117# Need -Uarm for gcc < 3.x
117KBUILD_CFLAGS +=$(CFLAGS_ABI) $(CFLAGS_THUMB2) $(arch-y) $(tune-y) $(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,)) -msoft-float -Uarm 118KBUILD_CFLAGS +=$(CFLAGS_ABI) $(CFLAGS_ISA) $(arch-y) $(tune-y) $(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,)) -msoft-float -Uarm
118KBUILD_AFLAGS +=$(CFLAGS_ABI) $(AFLAGS_THUMB2) $(arch-y) $(tune-y) -include asm/unified.h -msoft-float 119KBUILD_AFLAGS +=$(CFLAGS_ABI) $(AFLAGS_ISA) $(arch-y) $(tune-y) -include asm/unified.h -msoft-float
119 120
120CHECKFLAGS += -D__arm__ 121CHECKFLAGS += -D__arm__
121 122
diff --git a/arch/arm/boot/Makefile b/arch/arm/boot/Makefile
index 3fdab016aa5..9137df539b6 100644
--- a/arch/arm/boot/Makefile
+++ b/arch/arm/boot/Makefile
@@ -33,7 +33,7 @@ ifeq ($(CONFIG_XIP_KERNEL),y)
33 33
34$(obj)/xipImage: vmlinux FORCE 34$(obj)/xipImage: vmlinux FORCE
35 $(call if_changed,objcopy) 35 $(call if_changed,objcopy)
36 @echo ' Kernel: $@ is ready (physical address: $(CONFIG_XIP_PHYS_ADDR))' 36 @$(kecho) ' Kernel: $@ is ready (physical address: $(CONFIG_XIP_PHYS_ADDR))'
37 37
38$(obj)/Image $(obj)/zImage: FORCE 38$(obj)/Image $(obj)/zImage: FORCE
39 @echo 'Kernel configured for XIP (CONFIG_XIP_KERNEL=y)' 39 @echo 'Kernel configured for XIP (CONFIG_XIP_KERNEL=y)'
@@ -48,14 +48,14 @@ $(obj)/xipImage: FORCE
48 48
49$(obj)/Image: vmlinux FORCE 49$(obj)/Image: vmlinux FORCE
50 $(call if_changed,objcopy) 50 $(call if_changed,objcopy)
51 @echo ' Kernel: $@ is ready' 51 @$(kecho) ' Kernel: $@ is ready'
52 52
53$(obj)/compressed/vmlinux: $(obj)/Image FORCE 53$(obj)/compressed/vmlinux: $(obj)/Image FORCE
54 $(Q)$(MAKE) $(build)=$(obj)/compressed $@ 54 $(Q)$(MAKE) $(build)=$(obj)/compressed $@
55 55
56$(obj)/zImage: $(obj)/compressed/vmlinux FORCE 56$(obj)/zImage: $(obj)/compressed/vmlinux FORCE
57 $(call if_changed,objcopy) 57 $(call if_changed,objcopy)
58 @echo ' Kernel: $@ is ready' 58 @$(kecho) ' Kernel: $@ is ready'
59 59
60endif 60endif
61 61
@@ -90,7 +90,7 @@ fi
90$(obj)/uImage: $(obj)/zImage FORCE 90$(obj)/uImage: $(obj)/zImage FORCE
91 @$(check_for_multiple_loadaddr) 91 @$(check_for_multiple_loadaddr)
92 $(call if_changed,uimage) 92 $(call if_changed,uimage)
93 @echo ' Image $@ is ready' 93 @$(kecho) ' Image $@ is ready'
94 94
95$(obj)/bootp/bootp: $(obj)/zImage initrd FORCE 95$(obj)/bootp/bootp: $(obj)/zImage initrd FORCE
96 $(Q)$(MAKE) $(build)=$(obj)/bootp $@ 96 $(Q)$(MAKE) $(build)=$(obj)/bootp $@
@@ -98,7 +98,7 @@ $(obj)/bootp/bootp: $(obj)/zImage initrd FORCE
98 98
99$(obj)/bootpImage: $(obj)/bootp/bootp FORCE 99$(obj)/bootpImage: $(obj)/bootp/bootp FORCE
100 $(call if_changed,objcopy) 100 $(call if_changed,objcopy)
101 @echo ' Kernel: $@ is ready' 101 @$(kecho) ' Kernel: $@ is ready'
102 102
103PHONY += initrd FORCE 103PHONY += initrd FORCE
104initrd: 104initrd:
diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index c1ce813fcc4..f37cf9fa5fa 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -25,6 +25,8 @@ dtb-$(CONFIG_ARCH_EXYNOS) += exynos4210-origen.dtb \
25 exynos4210-trats.dtb \ 25 exynos4210-trats.dtb \
26 exynos5250-smdk5250.dtb 26 exynos5250-smdk5250.dtb
27dtb-$(CONFIG_ARCH_HIGHBANK) += highbank.dtb 27dtb-$(CONFIG_ARCH_HIGHBANK) += highbank.dtb
28dtb-$(CONFIG_ARCH_INTEGRATOR) += integratorap.dtb \
29 integratorcp.dtb
28dtb-$(CONFIG_ARCH_LPC32XX) += ea3250.dtb phy3250.dtb 30dtb-$(CONFIG_ARCH_LPC32XX) += ea3250.dtb phy3250.dtb
29dtb-$(CONFIG_ARCH_KIRKWOOD) += kirkwood-dns320.dtb \ 31dtb-$(CONFIG_ARCH_KIRKWOOD) += kirkwood-dns320.dtb \
30 kirkwood-dns325.dtb \ 32 kirkwood-dns325.dtb \
diff --git a/arch/arm/boot/dts/at91sam9g20ek_common.dtsi b/arch/arm/boot/dts/at91sam9g20ek_common.dtsi
index b06c0db273b..e6391a4e664 100644
--- a/arch/arm/boot/dts/at91sam9g20ek_common.dtsi
+++ b/arch/arm/boot/dts/at91sam9g20ek_common.dtsi
@@ -126,14 +126,14 @@
126 #size-cells = <0>; 126 #size-cells = <0>;
127 127
128 btn3 { 128 btn3 {
129 label = "Buttin 3"; 129 label = "Button 3";
130 gpios = <&pioA 30 1>; 130 gpios = <&pioA 30 1>;
131 linux,code = <0x103>; 131 linux,code = <0x103>;
132 gpio-key,wakeup; 132 gpio-key,wakeup;
133 }; 133 };
134 134
135 btn4 { 135 btn4 {
136 label = "Buttin 4"; 136 label = "Button 4";
137 gpios = <&pioA 31 1>; 137 gpios = <&pioA 31 1>;
138 linux,code = <0x104>; 138 linux,code = <0x104>;
139 gpio-key,wakeup; 139 gpio-key,wakeup;
diff --git a/arch/arm/boot/dts/dbx5x0.dtsi b/arch/arm/boot/dts/dbx5x0.dtsi
index 748ba7aa746..4b0e0ca08f4 100644
--- a/arch/arm/boot/dts/dbx5x0.dtsi
+++ b/arch/arm/boot/dts/dbx5x0.dtsi
@@ -483,6 +483,8 @@
483 compatible = "stericsson,db8500-i2c", "st,nomadik-i2c", "arm,primecell"; 483 compatible = "stericsson,db8500-i2c", "st,nomadik-i2c", "arm,primecell";
484 reg = <0x80004000 0x1000>; 484 reg = <0x80004000 0x1000>;
485 interrupts = <0 21 0x4>; 485 interrupts = <0 21 0x4>;
486 arm,primecell-periphid = <0x180024>;
487
486 #address-cells = <1>; 488 #address-cells = <1>;
487 #size-cells = <0>; 489 #size-cells = <0>;
488 v-i2c-supply = <&db8500_vape_reg>; 490 v-i2c-supply = <&db8500_vape_reg>;
@@ -494,6 +496,8 @@
494 compatible = "stericsson,db8500-i2c", "st,nomadik-i2c", "arm,primecell"; 496 compatible = "stericsson,db8500-i2c", "st,nomadik-i2c", "arm,primecell";
495 reg = <0x80122000 0x1000>; 497 reg = <0x80122000 0x1000>;
496 interrupts = <0 22 0x4>; 498 interrupts = <0 22 0x4>;
499 arm,primecell-periphid = <0x180024>;
500
497 #address-cells = <1>; 501 #address-cells = <1>;
498 #size-cells = <0>; 502 #size-cells = <0>;
499 v-i2c-supply = <&db8500_vape_reg>; 503 v-i2c-supply = <&db8500_vape_reg>;
@@ -505,6 +509,8 @@
505 compatible = "stericsson,db8500-i2c", "st,nomadik-i2c", "arm,primecell"; 509 compatible = "stericsson,db8500-i2c", "st,nomadik-i2c", "arm,primecell";
506 reg = <0x80128000 0x1000>; 510 reg = <0x80128000 0x1000>;
507 interrupts = <0 55 0x4>; 511 interrupts = <0 55 0x4>;
512 arm,primecell-periphid = <0x180024>;
513
508 #address-cells = <1>; 514 #address-cells = <1>;
509 #size-cells = <0>; 515 #size-cells = <0>;
510 v-i2c-supply = <&db8500_vape_reg>; 516 v-i2c-supply = <&db8500_vape_reg>;
@@ -516,6 +522,8 @@
516 compatible = "stericsson,db8500-i2c", "st,nomadik-i2c", "arm,primecell"; 522 compatible = "stericsson,db8500-i2c", "st,nomadik-i2c", "arm,primecell";
517 reg = <0x80110000 0x1000>; 523 reg = <0x80110000 0x1000>;
518 interrupts = <0 12 0x4>; 524 interrupts = <0 12 0x4>;
525 arm,primecell-periphid = <0x180024>;
526
519 #address-cells = <1>; 527 #address-cells = <1>;
520 #size-cells = <0>; 528 #size-cells = <0>;
521 v-i2c-supply = <&db8500_vape_reg>; 529 v-i2c-supply = <&db8500_vape_reg>;
@@ -527,6 +535,8 @@
527 compatible = "stericsson,db8500-i2c", "st,nomadik-i2c", "arm,primecell"; 535 compatible = "stericsson,db8500-i2c", "st,nomadik-i2c", "arm,primecell";
528 reg = <0x8012a000 0x1000>; 536 reg = <0x8012a000 0x1000>;
529 interrupts = <0 51 0x4>; 537 interrupts = <0 51 0x4>;
538 arm,primecell-periphid = <0x180024>;
539
530 #address-cells = <1>; 540 #address-cells = <1>;
531 #size-cells = <0>; 541 #size-cells = <0>;
532 v-i2c-supply = <&db8500_vape_reg>; 542 v-i2c-supply = <&db8500_vape_reg>;
@@ -573,33 +583,38 @@
573 interrupts = <0 60 0x4>; 583 interrupts = <0 60 0x4>;
574 status = "disabled"; 584 status = "disabled";
575 }; 585 };
586
576 sdi@80118000 { 587 sdi@80118000 {
577 compatible = "arm,pl18x", "arm,primecell"; 588 compatible = "arm,pl18x", "arm,primecell";
578 reg = <0x80118000 0x1000>; 589 reg = <0x80118000 0x1000>;
579 interrupts = <0 50 0x4>; 590 interrupts = <0 50 0x4>;
580 status = "disabled"; 591 status = "disabled";
581 }; 592 };
593
582 sdi@80005000 { 594 sdi@80005000 {
583 compatible = "arm,pl18x", "arm,primecell"; 595 compatible = "arm,pl18x", "arm,primecell";
584 reg = <0x80005000 0x1000>; 596 reg = <0x80005000 0x1000>;
585 interrupts = <0 41 0x4>; 597 interrupts = <0 41 0x4>;
586 status = "disabled"; 598 status = "disabled";
587 }; 599 };
600
588 sdi@80119000 { 601 sdi@80119000 {
589 compatible = "arm,pl18x", "arm,primecell"; 602 compatible = "arm,pl18x", "arm,primecell";
590 reg = <0x80119000 0x1000>; 603 reg = <0x80119000 0x1000>;
591 interrupts = <0 59 0x4>; 604 interrupts = <0 59 0x4>;
592 status = "disabled"; 605 status = "disabled";
593 }; 606 };
607
594 sdi@80114000 { 608 sdi@80114000 {
595 compatible = "arm,pl18x", "arm,primecell"; 609 compatible = "arm,pl18x", "arm,primecell";
596 reg = <0x80114000 0x1000>; 610 reg = <0x80114000 0x1000>;
597 interrupts = <0 99 0x4>; 611 interrupts = <0 99 0x4>;
598 status = "disabled"; 612 status = "disabled";
599 }; 613 };
614
600 sdi@80008000 { 615 sdi@80008000 {
601 compatible = "arm,pl18x", "arm,primecell"; 616 compatible = "arm,pl18x", "arm,primecell";
602 reg = <0x80114000 0x1000>; 617 reg = <0x80008000 0x1000>;
603 interrupts = <0 100 0x4>; 618 interrupts = <0 100 0x4>;
604 status = "disabled"; 619 status = "disabled";
605 }; 620 };
diff --git a/arch/arm/boot/dts/dove.dtsi b/arch/arm/boot/dts/dove.dtsi
index 96fb824b5e6..5a00022383e 100644
--- a/arch/arm/boot/dts/dove.dtsi
+++ b/arch/arm/boot/dts/dove.dtsi
@@ -4,21 +4,32 @@
4 compatible = "marvell,dove"; 4 compatible = "marvell,dove";
5 model = "Marvell Armada 88AP510 SoC"; 5 model = "Marvell Armada 88AP510 SoC";
6 6
7 interrupt-parent = <&intc>; 7 soc@f1000000 {
8
9 intc: interrupt-controller {
10 compatible = "marvell,orion-intc";
11 interrupt-controller;
12 #interrupt-cells = <1>;
13 reg = <0xf1020204 0x04>,
14 <0xf1020214 0x04>;
15 };
16
17 mbus@f1000000 {
18 compatible = "simple-bus"; 8 compatible = "simple-bus";
19 ranges = <0 0xf1000000 0x4000000>;
20 #address-cells = <1>; 9 #address-cells = <1>;
21 #size-cells = <1>; 10 #size-cells = <1>;
11 interrupt-parent = <&intc>;
12
13 ranges = <0xc8000000 0xc8000000 0x0100000 /* CESA SRAM 1M */
14 0xe0000000 0xe0000000 0x8000000 /* PCIe0 Mem 128M */
15 0xe8000000 0xe8000000 0x8000000 /* PCIe1 Mem 128M */
16 0xf0000000 0xf0000000 0x0100000 /* ScratchPad 1M */
17 0x00000000 0xf1000000 0x1000000 /* SB/NB regs 16M */
18 0xf2000000 0xf2000000 0x0100000 /* PCIe0 I/O 1M */
19 0xf2100000 0xf2100000 0x0100000 /* PCIe0 I/O 1M */
20 0xf8000000 0xf8000000 0x8000000>; /* BootROM 128M */
21
22 l2: l2-cache {
23 compatible = "marvell,tauros2-cache";
24 marvell,tauros2-cache-features = <0>;
25 };
26
27 intc: interrupt-controller {
28 compatible = "marvell,orion-intc";
29 interrupt-controller;
30 #interrupt-cells = <1>;
31 reg = <0x20204 0x04>, <0x20214 0x04>;
32 };
22 33
23 uart0: serial@12000 { 34 uart0: serial@12000 {
24 compatible = "ns16550a"; 35 compatible = "ns16550a";
@@ -56,11 +67,6 @@
56 status = "disabled"; 67 status = "disabled";
57 }; 68 };
58 69
59 wdt: wdt@20300 {
60 compatible = "marvell,orion-wdt";
61 reg = <0x20300 0x28>;
62 };
63
64 gpio0: gpio@d0400 { 70 gpio0: gpio@d0400 {
65 compatible = "marvell,orion-gpio"; 71 compatible = "marvell,orion-gpio";
66 #gpio-cells = <2>; 72 #gpio-cells = <2>;
@@ -139,5 +145,14 @@
139 nr-ports = <1>; 145 nr-ports = <1>;
140 status = "disabled"; 146 status = "disabled";
141 }; 147 };
148
149 crypto: crypto@30000 {
150 compatible = "marvell,orion-crypto";
151 reg = <0x30000 0x10000>,
152 <0xc8000000 0x800>;
153 reg-names = "regs", "sram";
154 interrupts = <31>;
155 status = "okay";
156 };
142 }; 157 };
143}; 158};
diff --git a/arch/arm/boot/dts/exynos4210-trats.dts b/arch/arm/boot/dts/exynos4210-trats.dts
index 73567b843e7..a21511c1407 100644
--- a/arch/arm/boot/dts/exynos4210-trats.dts
+++ b/arch/arm/boot/dts/exynos4210-trats.dts
@@ -20,8 +20,10 @@
20 compatible = "samsung,trats", "samsung,exynos4210"; 20 compatible = "samsung,trats", "samsung,exynos4210";
21 21
22 memory { 22 memory {
23 reg = <0x40000000 0x20000000 23 reg = <0x40000000 0x10000000
24 0x60000000 0x20000000>; 24 0x50000000 0x10000000
25 0x60000000 0x10000000
26 0x70000000 0x10000000>;
25 }; 27 };
26 28
27 chosen { 29 chosen {
diff --git a/arch/arm/boot/dts/imx23.dtsi b/arch/arm/boot/dts/imx23.dtsi
index 9ca4ca70c1b..6d31aa38346 100644
--- a/arch/arm/boot/dts/imx23.dtsi
+++ b/arch/arm/boot/dts/imx23.dtsi
@@ -69,6 +69,7 @@
69 interrupts = <13>, <56>; 69 interrupts = <13>, <56>;
70 interrupt-names = "gpmi-dma", "bch"; 70 interrupt-names = "gpmi-dma", "bch";
71 clocks = <&clks 34>; 71 clocks = <&clks 34>;
72 clock-names = "gpmi_io";
72 fsl,gpmi-dma-channel = <4>; 73 fsl,gpmi-dma-channel = <4>;
73 status = "disabled"; 74 status = "disabled";
74 }; 75 };
diff --git a/arch/arm/boot/dts/imx28.dtsi b/arch/arm/boot/dts/imx28.dtsi
index e16d6315548..55c57ea6169 100644
--- a/arch/arm/boot/dts/imx28.dtsi
+++ b/arch/arm/boot/dts/imx28.dtsi
@@ -85,6 +85,7 @@
85 interrupts = <88>, <41>; 85 interrupts = <88>, <41>;
86 interrupt-names = "gpmi-dma", "bch"; 86 interrupt-names = "gpmi-dma", "bch";
87 clocks = <&clks 50>; 87 clocks = <&clks 50>;
88 clock-names = "gpmi_io";
88 fsl,gpmi-dma-channel = <4>; 89 fsl,gpmi-dma-channel = <4>;
89 status = "disabled"; 90 status = "disabled";
90 }; 91 };
diff --git a/arch/arm/boot/dts/imx6q-arm2.dts b/arch/arm/boot/dts/imx6q-arm2.dts
index 15df4c105e8..5bfa02a3f85 100644
--- a/arch/arm/boot/dts/imx6q-arm2.dts
+++ b/arch/arm/boot/dts/imx6q-arm2.dts
@@ -37,6 +37,13 @@
37 pinctrl_hog: hoggrp { 37 pinctrl_hog: hoggrp {
38 fsl,pins = < 38 fsl,pins = <
39 176 0x80000000 /* MX6Q_PAD_EIM_D25__GPIO_3_25 */ 39 176 0x80000000 /* MX6Q_PAD_EIM_D25__GPIO_3_25 */
40 >;
41 };
42 };
43
44 arm2 {
45 pinctrl_usdhc3_arm2: usdhc3grp-arm2 {
46 fsl,pins = <
40 1363 0x80000000 /* MX6Q_PAD_NANDF_CS0__GPIO_6_11 */ 47 1363 0x80000000 /* MX6Q_PAD_NANDF_CS0__GPIO_6_11 */
41 1369 0x80000000 /* MX6Q_PAD_NANDF_CS1__GPIO_6_14 */ 48 1369 0x80000000 /* MX6Q_PAD_NANDF_CS1__GPIO_6_14 */
42 >; 49 >;
@@ -58,7 +65,8 @@
58 wp-gpios = <&gpio6 14 0>; 65 wp-gpios = <&gpio6 14 0>;
59 vmmc-supply = <&reg_3p3v>; 66 vmmc-supply = <&reg_3p3v>;
60 pinctrl-names = "default"; 67 pinctrl-names = "default";
61 pinctrl-0 = <&pinctrl_usdhc3_1>; 68 pinctrl-0 = <&pinctrl_usdhc3_1
69 &pinctrl_usdhc3_arm2>;
62 status = "okay"; 70 status = "okay";
63 }; 71 };
64 72
diff --git a/arch/arm/boot/dts/kirkwood-lsxl.dtsi b/arch/arm/boot/dts/kirkwood-lsxl.dtsi
index 8ac51c08269..8fea375c734 100644
--- a/arch/arm/boot/dts/kirkwood-lsxl.dtsi
+++ b/arch/arm/boot/dts/kirkwood-lsxl.dtsi
@@ -48,17 +48,19 @@
48 #size-cells = <0>; 48 #size-cells = <0>;
49 button@1 { 49 button@1 {
50 label = "Function Button"; 50 label = "Function Button";
51 linux,code = <132>; 51 linux,code = <357>;
52 gpios = <&gpio1 9 1>; 52 gpios = <&gpio1 9 1>;
53 }; 53 };
54 button@2 { 54 button@2 {
55 label = "Power-on Switch"; 55 label = "Power-on Switch";
56 linux,code = <116>; 56 linux,code = <0>;
57 linux,input-type = <5>;
57 gpios = <&gpio1 10 1>; 58 gpios = <&gpio1 10 1>;
58 }; 59 };
59 button@3 { 60 button@3 {
60 label = "Power-auto Switch"; 61 label = "Power-auto Switch";
61 linux,code = <142>; 62 linux,code = <1>;
63 linux,input-type = <5>;
62 gpios = <&gpio1 11 1>; 64 gpios = <&gpio1 11 1>;
63 }; 65 };
64 }; 66 };
@@ -67,28 +69,28 @@
67 compatible = "gpio-leds"; 69 compatible = "gpio-leds";
68 70
69 led@1 { 71 led@1 {
70 label = "lschlv2:blue:func"; 72 label = "lsxl:blue:func";
71 gpios = <&gpio1 4 1>; 73 gpios = <&gpio1 4 1>;
72 }; 74 };
73 75
74 led@2 { 76 led@2 {
75 label = "lschlv2:red:alarm"; 77 label = "lsxl:red:alarm";
76 gpios = <&gpio1 5 1>; 78 gpios = <&gpio1 5 1>;
77 }; 79 };
78 80
79 led@3 { 81 led@3 {
80 label = "lschlv2:amber:info"; 82 label = "lsxl:amber:info";
81 gpios = <&gpio1 6 1>; 83 gpios = <&gpio1 6 1>;
82 }; 84 };
83 85
84 led@4 { 86 led@4 {
85 label = "lschlv2:blue:power"; 87 label = "lsxl:blue:power";
86 gpios = <&gpio1 7 1>; 88 gpios = <&gpio1 7 1>;
87 linux,default-trigger = "default-on"; 89 linux,default-trigger = "default-on";
88 }; 90 };
89 91
90 led@5 { 92 led@5 {
91 label = "lschlv2:red:func"; 93 label = "lsxl:red:func";
92 gpios = <&gpio1 16 1>; 94 gpios = <&gpio1 16 1>;
93 }; 95 };
94 }; 96 };
diff --git a/arch/arm/boot/dts/omap3.dtsi b/arch/arm/boot/dts/omap3.dtsi
index f38ea8771b4..696e929d030 100644
--- a/arch/arm/boot/dts/omap3.dtsi
+++ b/arch/arm/boot/dts/omap3.dtsi
@@ -257,7 +257,7 @@
257 interrupt-names = "common", "tx", "rx", "sidetone"; 257 interrupt-names = "common", "tx", "rx", "sidetone";
258 interrupt-parent = <&intc>; 258 interrupt-parent = <&intc>;
259 ti,buffer-size = <1280>; 259 ti,buffer-size = <1280>;
260 ti,hwmods = "mcbsp2"; 260 ti,hwmods = "mcbsp2", "mcbsp2_sidetone";
261 }; 261 };
262 262
263 mcbsp3: mcbsp@49024000 { 263 mcbsp3: mcbsp@49024000 {
@@ -272,7 +272,7 @@
272 interrupt-names = "common", "tx", "rx", "sidetone"; 272 interrupt-names = "common", "tx", "rx", "sidetone";
273 interrupt-parent = <&intc>; 273 interrupt-parent = <&intc>;
274 ti,buffer-size = <128>; 274 ti,buffer-size = <128>;
275 ti,hwmods = "mcbsp3"; 275 ti,hwmods = "mcbsp3", "mcbsp3_sidetone";
276 }; 276 };
277 277
278 mcbsp4: mcbsp@49026000 { 278 mcbsp4: mcbsp@49026000 {
diff --git a/arch/arm/boot/dts/tegra30.dtsi b/arch/arm/boot/dts/tegra30.dtsi
index b1497c7d7d6..df7f2270fc9 100644
--- a/arch/arm/boot/dts/tegra30.dtsi
+++ b/arch/arm/boot/dts/tegra30.dtsi
@@ -73,8 +73,8 @@
73 73
74 pinmux: pinmux { 74 pinmux: pinmux {
75 compatible = "nvidia,tegra30-pinmux"; 75 compatible = "nvidia,tegra30-pinmux";
76 reg = <0x70000868 0xd0 /* Pad control registers */ 76 reg = <0x70000868 0xd4 /* Pad control registers */
77 0x70003000 0x3e0>; /* Mux registers */ 77 0x70003000 0x3e4>; /* Mux registers */
78 }; 78 };
79 79
80 serial@70006000 { 80 serial@70006000 {
diff --git a/arch/arm/boot/dts/wm8505.dtsi b/arch/arm/boot/dts/wm8505.dtsi
index b459691655a..330f833ac3b 100644
--- a/arch/arm/boot/dts/wm8505.dtsi
+++ b/arch/arm/boot/dts/wm8505.dtsi
@@ -71,13 +71,13 @@
71 ehci@d8007100 { 71 ehci@d8007100 {
72 compatible = "via,vt8500-ehci"; 72 compatible = "via,vt8500-ehci";
73 reg = <0xd8007100 0x200>; 73 reg = <0xd8007100 0x200>;
74 interrupts = <43>; 74 interrupts = <1>;
75 }; 75 };
76 76
77 uhci@d8007300 { 77 uhci@d8007300 {
78 compatible = "platform-uhci"; 78 compatible = "platform-uhci";
79 reg = <0xd8007300 0x200>; 79 reg = <0xd8007300 0x200>;
80 interrupts = <43>; 80 interrupts = <0>;
81 }; 81 };
82 82
83 fb@d8050800 { 83 fb@d8050800 {
diff --git a/arch/arm/configs/imx_v6_v7_defconfig b/arch/arm/configs/imx_v6_v7_defconfig
index 66aa7a6db88..394ded624e3 100644
--- a/arch/arm/configs/imx_v6_v7_defconfig
+++ b/arch/arm/configs/imx_v6_v7_defconfig
@@ -139,6 +139,7 @@ CONFIG_I2C_IMX=y
139CONFIG_SPI=y 139CONFIG_SPI=y
140CONFIG_SPI_IMX=y 140CONFIG_SPI_IMX=y
141CONFIG_GPIO_SYSFS=y 141CONFIG_GPIO_SYSFS=y
142CONFIG_GPIO_MC9S08DZ60=y
142# CONFIG_HWMON is not set 143# CONFIG_HWMON is not set
143CONFIG_WATCHDOG=y 144CONFIG_WATCHDOG=y
144CONFIG_IMX2_WDT=y 145CONFIG_IMX2_WDT=y
@@ -155,6 +156,7 @@ CONFIG_SOC_CAMERA=y
155CONFIG_SOC_CAMERA_OV2640=y 156CONFIG_SOC_CAMERA_OV2640=y
156CONFIG_VIDEO_MX3=y 157CONFIG_VIDEO_MX3=y
157CONFIG_FB=y 158CONFIG_FB=y
159CONFIG_LCD_PLATFORM=y
158CONFIG_BACKLIGHT_LCD_SUPPORT=y 160CONFIG_BACKLIGHT_LCD_SUPPORT=y
159CONFIG_LCD_CLASS_DEVICE=y 161CONFIG_LCD_CLASS_DEVICE=y
160CONFIG_LCD_L4F00242T03=y 162CONFIG_LCD_L4F00242T03=y
diff --git a/arch/arm/configs/mvebu_defconfig b/arch/arm/configs/mvebu_defconfig
index 7bcf850eddc..3458752c4bb 100644
--- a/arch/arm/configs/mvebu_defconfig
+++ b/arch/arm/configs/mvebu_defconfig
@@ -1,6 +1,6 @@
1CONFIG_EXPERIMENTAL=y 1CONFIG_EXPERIMENTAL=y
2CONFIG_SYSVIPC=y 2CONFIG_SYSVIPC=y
3CONFIG_NO_HZ=y 3CONFIG_IRQ_DOMAIN_DEBUG=y
4CONFIG_HIGH_RES_TIMERS=y 4CONFIG_HIGH_RES_TIMERS=y
5CONFIG_LOG_BUF_SHIFT=14 5CONFIG_LOG_BUF_SHIFT=14
6CONFIG_BLK_DEV_INITRD=y 6CONFIG_BLK_DEV_INITRD=y
@@ -9,10 +9,12 @@ CONFIG_SLAB=y
9CONFIG_MODULES=y 9CONFIG_MODULES=y
10CONFIG_MODULE_UNLOAD=y 10CONFIG_MODULE_UNLOAD=y
11CONFIG_ARCH_MVEBU=y 11CONFIG_ARCH_MVEBU=y
12CONFIG_MACH_ARMADA_370_XP=y 12CONFIG_MACH_ARMADA_370=y
13CONFIG_MACH_ARMADA_XP=y
14# CONFIG_CACHE_L2X0 is not set
13CONFIG_AEABI=y 15CONFIG_AEABI=y
14CONFIG_HIGHMEM=y 16CONFIG_HIGHMEM=y
15CONFIG_USE_OF=y 17# CONFIG_COMPACTION is not set
16CONFIG_ZBOOT_ROM_TEXT=0x0 18CONFIG_ZBOOT_ROM_TEXT=0x0
17CONFIG_ZBOOT_ROM_BSS=0x0 19CONFIG_ZBOOT_ROM_BSS=0x0
18CONFIG_ARM_APPENDED_DTB=y 20CONFIG_ARM_APPENDED_DTB=y
@@ -23,6 +25,8 @@ CONFIG_SERIAL_8250_CONSOLE=y
23CONFIG_SERIAL_OF_PLATFORM=y 25CONFIG_SERIAL_OF_PLATFORM=y
24CONFIG_GPIOLIB=y 26CONFIG_GPIOLIB=y
25CONFIG_GPIO_SYSFS=y 27CONFIG_GPIO_SYSFS=y
28# CONFIG_USB_SUPPORT is not set
29# CONFIG_IOMMU_SUPPORT is not set
26CONFIG_EXT2_FS=y 30CONFIG_EXT2_FS=y
27CONFIG_EXT3_FS=y 31CONFIG_EXT3_FS=y
28# CONFIG_EXT3_FS_XATTR is not set 32# CONFIG_EXT3_FS_XATTR is not set
diff --git a/arch/arm/configs/versatile_defconfig b/arch/arm/configs/versatile_defconfig
index cdd4d2bd396..2ba9e63d0f1 100644
--- a/arch/arm/configs/versatile_defconfig
+++ b/arch/arm/configs/versatile_defconfig
@@ -1,3 +1,4 @@
1CONFIG_ARCH_VERSATILE=y
1CONFIG_EXPERIMENTAL=y 2CONFIG_EXPERIMENTAL=y
2# CONFIG_LOCALVERSION_AUTO is not set 3# CONFIG_LOCALVERSION_AUTO is not set
3CONFIG_SYSVIPC=y 4CONFIG_SYSVIPC=y
diff --git a/arch/arm/include/asm/flat.h b/arch/arm/include/asm/flat.h
index 59426a4595c..e847d23351e 100644
--- a/arch/arm/include/asm/flat.h
+++ b/arch/arm/include/asm/flat.h
@@ -8,7 +8,7 @@
8#define flat_argvp_envp_on_stack() 1 8#define flat_argvp_envp_on_stack() 1
9#define flat_old_ram_flag(flags) (flags) 9#define flat_old_ram_flag(flags) (flags)
10#define flat_reloc_valid(reloc, size) ((reloc) <= (size)) 10#define flat_reloc_valid(reloc, size) ((reloc) <= (size))
11#define flat_get_addr_from_rp(rp, relval, flags, persistent) get_unaligned(rp) 11#define flat_get_addr_from_rp(rp, relval, flags, persistent) ((void)persistent,get_unaligned(rp))
12#define flat_put_addr_at_rp(rp, val, relval) put_unaligned(val,rp) 12#define flat_put_addr_at_rp(rp, val, relval) put_unaligned(val,rp)
13#define flat_get_relocate_addr(rel) (rel) 13#define flat_get_relocate_addr(rel) (rel)
14#define flat_set_persistent(relval, p) 0 14#define flat_set_persistent(relval, p) 0
diff --git a/arch/arm/include/asm/io.h b/arch/arm/include/asm/io.h
index 35c1ed89b93..42f042ee4ad 100644
--- a/arch/arm/include/asm/io.h
+++ b/arch/arm/include/asm/io.h
@@ -64,7 +64,7 @@ extern void __raw_readsl(const void __iomem *addr, void *data, int longlen);
64static inline void __raw_writew(u16 val, volatile void __iomem *addr) 64static inline void __raw_writew(u16 val, volatile void __iomem *addr)
65{ 65{
66 asm volatile("strh %1, %0" 66 asm volatile("strh %1, %0"
67 : "+Qo" (*(volatile u16 __force *)addr) 67 : "+Q" (*(volatile u16 __force *)addr)
68 : "r" (val)); 68 : "r" (val));
69} 69}
70 70
@@ -72,7 +72,7 @@ static inline u16 __raw_readw(const volatile void __iomem *addr)
72{ 72{
73 u16 val; 73 u16 val;
74 asm volatile("ldrh %1, %0" 74 asm volatile("ldrh %1, %0"
75 : "+Qo" (*(volatile u16 __force *)addr), 75 : "+Q" (*(volatile u16 __force *)addr),
76 "=r" (val)); 76 "=r" (val));
77 return val; 77 return val;
78} 78}
diff --git a/arch/arm/include/asm/sched_clock.h b/arch/arm/include/asm/sched_clock.h
index 05b8e82ec9f..e3f75726343 100644
--- a/arch/arm/include/asm/sched_clock.h
+++ b/arch/arm/include/asm/sched_clock.h
@@ -10,7 +10,5 @@
10 10
11extern void sched_clock_postinit(void); 11extern void sched_clock_postinit(void);
12extern void setup_sched_clock(u32 (*read)(void), int bits, unsigned long rate); 12extern void setup_sched_clock(u32 (*read)(void), int bits, unsigned long rate);
13extern void setup_sched_clock_needs_suspend(u32 (*read)(void), int bits,
14 unsigned long rate);
15 13
16#endif 14#endif
diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
index 77bd79f2ffd..7e1f76027f6 100644
--- a/arch/arm/include/asm/uaccess.h
+++ b/arch/arm/include/asm/uaccess.h
@@ -200,8 +200,8 @@ extern int __put_user_8(void *, unsigned long long);
200#define USER_DS KERNEL_DS 200#define USER_DS KERNEL_DS
201 201
202#define segment_eq(a,b) (1) 202#define segment_eq(a,b) (1)
203#define __addr_ok(addr) (1) 203#define __addr_ok(addr) ((void)(addr),1)
204#define __range_ok(addr,size) (0) 204#define __range_ok(addr,size) ((void)(addr),0)
205#define get_fs() (KERNEL_DS) 205#define get_fs() (KERNEL_DS)
206 206
207static inline void set_fs(mm_segment_t fs) 207static inline void set_fs(mm_segment_t fs)
diff --git a/arch/arm/include/asm/vfpmacros.h b/arch/arm/include/asm/vfpmacros.h
index 6a6f1e485f4..301c1db3e99 100644
--- a/arch/arm/include/asm/vfpmacros.h
+++ b/arch/arm/include/asm/vfpmacros.h
@@ -27,9 +27,9 @@
27#if __LINUX_ARM_ARCH__ <= 6 27#if __LINUX_ARM_ARCH__ <= 6
28 ldr \tmp, =elf_hwcap @ may not have MVFR regs 28 ldr \tmp, =elf_hwcap @ may not have MVFR regs
29 ldr \tmp, [\tmp, #0] 29 ldr \tmp, [\tmp, #0]
30 tst \tmp, #HWCAP_VFPv3D16 30 tst \tmp, #HWCAP_VFPD32
31 ldceql p11, cr0, [\base],#32*4 @ FLDMIAD \base!, {d16-d31} 31 ldcnel p11, cr0, [\base],#32*4 @ FLDMIAD \base!, {d16-d31}
32 addne \base, \base, #32*4 @ step over unused register space 32 addeq \base, \base, #32*4 @ step over unused register space
33#else 33#else
34 VFPFMRX \tmp, MVFR0 @ Media and VFP Feature Register 0 34 VFPFMRX \tmp, MVFR0 @ Media and VFP Feature Register 0
35 and \tmp, \tmp, #MVFR0_A_SIMD_MASK @ A_SIMD field 35 and \tmp, \tmp, #MVFR0_A_SIMD_MASK @ A_SIMD field
@@ -51,9 +51,9 @@
51#if __LINUX_ARM_ARCH__ <= 6 51#if __LINUX_ARM_ARCH__ <= 6
52 ldr \tmp, =elf_hwcap @ may not have MVFR regs 52 ldr \tmp, =elf_hwcap @ may not have MVFR regs
53 ldr \tmp, [\tmp, #0] 53 ldr \tmp, [\tmp, #0]
54 tst \tmp, #HWCAP_VFPv3D16 54 tst \tmp, #HWCAP_VFPD32
55 stceql p11, cr0, [\base],#32*4 @ FSTMIAD \base!, {d16-d31} 55 stcnel p11, cr0, [\base],#32*4 @ FSTMIAD \base!, {d16-d31}
56 addne \base, \base, #32*4 @ step over unused register space 56 addeq \base, \base, #32*4 @ step over unused register space
57#else 57#else
58 VFPFMRX \tmp, MVFR0 @ Media and VFP Feature Register 0 58 VFPFMRX \tmp, MVFR0 @ Media and VFP Feature Register 0
59 and \tmp, \tmp, #MVFR0_A_SIMD_MASK @ A_SIMD field 59 and \tmp, \tmp, #MVFR0_A_SIMD_MASK @ A_SIMD field
diff --git a/arch/arm/include/asm/xen/interface.h b/arch/arm/include/asm/xen/interface.h
index ae05e56dd17..5000397134b 100644
--- a/arch/arm/include/asm/xen/interface.h
+++ b/arch/arm/include/asm/xen/interface.h
@@ -29,16 +29,22 @@
29 29
30#ifndef __ASSEMBLY__ 30#ifndef __ASSEMBLY__
31/* Explicitly size integers that represent pfns in the interface with 31/* Explicitly size integers that represent pfns in the interface with
32 * Xen so that we can have one ABI that works for 32 and 64 bit guests. */ 32 * Xen so that we can have one ABI that works for 32 and 64 bit guests.
33 * Note that this means that the xen_pfn_t type may be capable of
34 * representing pfn's which the guest cannot represent in its own pfn
35 * type. However since pfn space is controlled by the guest this is
36 * fine since it simply wouldn't be able to create any sure pfns in
37 * the first place.
38 */
33typedef uint64_t xen_pfn_t; 39typedef uint64_t xen_pfn_t;
40#define PRI_xen_pfn "llx"
34typedef uint64_t xen_ulong_t; 41typedef uint64_t xen_ulong_t;
42#define PRI_xen_ulong "llx"
35/* Guest handles for primitive C types. */ 43/* Guest handles for primitive C types. */
36__DEFINE_GUEST_HANDLE(uchar, unsigned char); 44__DEFINE_GUEST_HANDLE(uchar, unsigned char);
37__DEFINE_GUEST_HANDLE(uint, unsigned int); 45__DEFINE_GUEST_HANDLE(uint, unsigned int);
38__DEFINE_GUEST_HANDLE(ulong, unsigned long);
39DEFINE_GUEST_HANDLE(char); 46DEFINE_GUEST_HANDLE(char);
40DEFINE_GUEST_HANDLE(int); 47DEFINE_GUEST_HANDLE(int);
41DEFINE_GUEST_HANDLE(long);
42DEFINE_GUEST_HANDLE(void); 48DEFINE_GUEST_HANDLE(void);
43DEFINE_GUEST_HANDLE(uint64_t); 49DEFINE_GUEST_HANDLE(uint64_t);
44DEFINE_GUEST_HANDLE(uint32_t); 50DEFINE_GUEST_HANDLE(uint32_t);
diff --git a/arch/arm/include/asm/xen/page.h b/arch/arm/include/asm/xen/page.h
index 174202318df..c6b9096cef9 100644
--- a/arch/arm/include/asm/xen/page.h
+++ b/arch/arm/include/asm/xen/page.h
@@ -10,7 +10,7 @@
10#include <xen/interface/grant_table.h> 10#include <xen/interface/grant_table.h>
11 11
12#define pfn_to_mfn(pfn) (pfn) 12#define pfn_to_mfn(pfn) (pfn)
13#define phys_to_machine_mapping_valid (1) 13#define phys_to_machine_mapping_valid(pfn) (1)
14#define mfn_to_pfn(mfn) (mfn) 14#define mfn_to_pfn(mfn) (mfn)
15#define mfn_to_virt(m) (__va(mfn_to_pfn(m) << PAGE_SHIFT)) 15#define mfn_to_virt(m) (__va(mfn_to_pfn(m) << PAGE_SHIFT))
16 16
@@ -30,6 +30,8 @@ typedef struct xpaddr {
30#define XMADDR(x) ((xmaddr_t) { .maddr = (x) }) 30#define XMADDR(x) ((xmaddr_t) { .maddr = (x) })
31#define XPADDR(x) ((xpaddr_t) { .paddr = (x) }) 31#define XPADDR(x) ((xpaddr_t) { .paddr = (x) })
32 32
33#define INVALID_P2M_ENTRY (~0UL)
34
33static inline xmaddr_t phys_to_machine(xpaddr_t phys) 35static inline xmaddr_t phys_to_machine(xpaddr_t phys)
34{ 36{
35 unsigned offset = phys.paddr & ~PAGE_MASK; 37 unsigned offset = phys.paddr & ~PAGE_MASK;
@@ -74,9 +76,14 @@ static inline int m2p_remove_override(struct page *page, bool clear_pte)
74 return 0; 76 return 0;
75} 77}
76 78
79static inline bool __set_phys_to_machine(unsigned long pfn, unsigned long mfn)
80{
81 BUG_ON(pfn != mfn && mfn != INVALID_P2M_ENTRY);
82 return true;
83}
84
77static inline bool set_phys_to_machine(unsigned long pfn, unsigned long mfn) 85static inline bool set_phys_to_machine(unsigned long pfn, unsigned long mfn)
78{ 86{
79 BUG(); 87 return __set_phys_to_machine(pfn, mfn);
80 return false;
81} 88}
82#endif /* _ASM_ARM_XEN_PAGE_H */ 89#endif /* _ASM_ARM_XEN_PAGE_H */
diff --git a/arch/arm/include/debug/8250_32.S b/arch/arm/include/debug/8250_32.S
new file mode 100644
index 00000000000..8db01eeabbb
--- /dev/null
+++ b/arch/arm/include/debug/8250_32.S
@@ -0,0 +1,27 @@
1/*
2 * Copyright (c) 2011 Picochip Ltd., Jamie Iles
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * Derived from arch/arm/mach-davinci/include/mach/debug-macro.S to use 32-bit
9 * accesses to the 8250.
10 */
11
12#include <linux/serial_reg.h>
13
14 .macro senduart,rd,rx
15 str \rd, [\rx, #UART_TX << UART_SHIFT]
16 .endm
17
18 .macro busyuart,rd,rx
191002: ldr \rd, [\rx, #UART_LSR << UART_SHIFT]
20 and \rd, \rd, #UART_LSR_TEMT | UART_LSR_THRE
21 teq \rd, #UART_LSR_TEMT | UART_LSR_THRE
22 bne 1002b
23 .endm
24
25 /* The UART's don't have any flow control IO's wired up. */
26 .macro waituart,rd,rx
27 .endm
diff --git a/arch/arm/include/debug/picoxcell.S b/arch/arm/include/debug/picoxcell.S
index 7419deb1b94..bc1f07c49cd 100644
--- a/arch/arm/include/debug/picoxcell.S
+++ b/arch/arm/include/debug/picoxcell.S
@@ -5,10 +5,7 @@
5 * it under the terms of the GNU General Public License version 2 as 5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation. 6 * published by the Free Software Foundation.
7 * 7 *
8 * Derived from arch/arm/mach-davinci/include/mach/debug-macro.S to use 32-bit
9 * accesses to the 8250.
10 */ 8 */
11#include <linux/serial_reg.h>
12 9
13#define UART_SHIFT 2 10#define UART_SHIFT 2
14#define PICOXCELL_UART1_BASE 0x80230000 11#define PICOXCELL_UART1_BASE 0x80230000
@@ -19,17 +16,4 @@
19 ldr \rp, =PICOXCELL_UART1_BASE 16 ldr \rp, =PICOXCELL_UART1_BASE
20 .endm 17 .endm
21 18
22 .macro senduart,rd,rx 19#include "8250_32.S"
23 str \rd, [\rx, #UART_TX << UART_SHIFT]
24 .endm
25
26 .macro busyuart,rd,rx
271002: ldr \rd, [\rx, #UART_LSR << UART_SHIFT]
28 and \rd, \rd, #UART_LSR_TEMT | UART_LSR_THRE
29 teq \rd, #UART_LSR_TEMT | UART_LSR_THRE
30 bne 1002b
31 .endm
32
33 /* The UART's don't have any flow control IO's wired up. */
34 .macro waituart,rd,rx
35 .endm
diff --git a/arch/arm/include/debug/socfpga.S b/arch/arm/include/debug/socfpga.S
index d6f26d23374..966b2f99494 100644
--- a/arch/arm/include/debug/socfpga.S
+++ b/arch/arm/include/debug/socfpga.S
@@ -7,6 +7,9 @@
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 */ 8 */
9 9
10#define UART_SHIFT 2
11#define DEBUG_LL_UART_OFFSET 0x00002000
12
10 .macro addruart, rp, rv, tmp 13 .macro addruart, rp, rv, tmp
11 mov \rp, #DEBUG_LL_UART_OFFSET 14 mov \rp, #DEBUG_LL_UART_OFFSET
12 orr \rp, \rp, #0x00c00000 15 orr \rp, \rp, #0x00c00000
@@ -14,3 +17,5 @@
14 orr \rp, \rp, #0xff000000 @ physical base 17 orr \rp, \rp, #0xff000000 @ physical base
15 .endm 18 .endm
16 19
20#include "8250_32.S"
21
diff --git a/arch/arm/include/uapi/asm/hwcap.h b/arch/arm/include/uapi/asm/hwcap.h
index f254f6503cc..3688fd15a32 100644
--- a/arch/arm/include/uapi/asm/hwcap.h
+++ b/arch/arm/include/uapi/asm/hwcap.h
@@ -18,11 +18,12 @@
18#define HWCAP_THUMBEE (1 << 11) 18#define HWCAP_THUMBEE (1 << 11)
19#define HWCAP_NEON (1 << 12) 19#define HWCAP_NEON (1 << 12)
20#define HWCAP_VFPv3 (1 << 13) 20#define HWCAP_VFPv3 (1 << 13)
21#define HWCAP_VFPv3D16 (1 << 14) 21#define HWCAP_VFPv3D16 (1 << 14) /* also set for VFPv4-D16 */
22#define HWCAP_TLS (1 << 15) 22#define HWCAP_TLS (1 << 15)
23#define HWCAP_VFPv4 (1 << 16) 23#define HWCAP_VFPv4 (1 << 16)
24#define HWCAP_IDIVA (1 << 17) 24#define HWCAP_IDIVA (1 << 17)
25#define HWCAP_IDIVT (1 << 18) 25#define HWCAP_IDIVT (1 << 18)
26#define HWCAP_VFPD32 (1 << 19) /* set if VFP has 32 regs (not 16) */
26#define HWCAP_IDIV (HWCAP_IDIVA | HWCAP_IDIVT) 27#define HWCAP_IDIV (HWCAP_IDIVA | HWCAP_IDIVT)
27 28
28 29
diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
index 417bac1846b..34711757ba5 100644
--- a/arch/arm/kernel/entry-common.S
+++ b/arch/arm/kernel/entry-common.S
@@ -88,9 +88,9 @@ ENTRY(ret_from_fork)
88 bl schedule_tail 88 bl schedule_tail
89 cmp r5, #0 89 cmp r5, #0
90 movne r0, r4 90 movne r0, r4
91 movne lr, pc 91 adrne lr, BSYM(1f)
92 movne pc, r5 92 movne pc, r5
93 get_thread_info tsk 931: get_thread_info tsk
94 b ret_slow_syscall 94 b ret_slow_syscall
95ENDPROC(ret_from_fork) 95ENDPROC(ret_from_fork)
96 96
diff --git a/arch/arm/kernel/irq.c b/arch/arm/kernel/irq.c
index 16cedb42c0c..896165096d6 100644
--- a/arch/arm/kernel/irq.c
+++ b/arch/arm/kernel/irq.c
@@ -34,6 +34,7 @@
34#include <linux/list.h> 34#include <linux/list.h>
35#include <linux/kallsyms.h> 35#include <linux/kallsyms.h>
36#include <linux/proc_fs.h> 36#include <linux/proc_fs.h>
37#include <linux/export.h>
37 38
38#include <asm/exception.h> 39#include <asm/exception.h>
39#include <asm/mach/arch.h> 40#include <asm/mach/arch.h>
@@ -109,6 +110,7 @@ void set_irq_flags(unsigned int irq, unsigned int iflags)
109 /* Order is clear bits in "clr" then set bits in "set" */ 110 /* Order is clear bits in "clr" then set bits in "set" */
110 irq_modify_status(irq, clr, set & ~clr); 111 irq_modify_status(irq, clr, set & ~clr);
111} 112}
113EXPORT_SYMBOL_GPL(set_irq_flags);
112 114
113void __init init_IRQ(void) 115void __init init_IRQ(void)
114{ 116{
diff --git a/arch/arm/kernel/kprobes-test-arm.c b/arch/arm/kernel/kprobes-test-arm.c
index 38c1a3b103a..83931290506 100644
--- a/arch/arm/kernel/kprobes-test-arm.c
+++ b/arch/arm/kernel/kprobes-test-arm.c
@@ -366,7 +366,9 @@ void kprobe_arm_test_cases(void)
366 TEST_UNSUPPORTED(".word 0xe04f0392 @ umaal r0, pc, r2, r3") 366 TEST_UNSUPPORTED(".word 0xe04f0392 @ umaal r0, pc, r2, r3")
367 TEST_UNSUPPORTED(".word 0xe0500090 @ undef") 367 TEST_UNSUPPORTED(".word 0xe0500090 @ undef")
368 TEST_UNSUPPORTED(".word 0xe05fff9f @ undef") 368 TEST_UNSUPPORTED(".word 0xe05fff9f @ undef")
369#endif
369 370
371#if __LINUX_ARM_ARCH__ >= 7
370 TEST_RRR( "mls r0, r",1, VAL1,", r",2, VAL2,", r",3, VAL3,"") 372 TEST_RRR( "mls r0, r",1, VAL1,", r",2, VAL2,", r",3, VAL3,"")
371 TEST_RRR( "mlshi r7, r",8, VAL3,", r",9, VAL1,", r",10, VAL2,"") 373 TEST_RRR( "mlshi r7, r",8, VAL3,", r",9, VAL1,", r",10, VAL2,"")
372 TEST_RR( "mls lr, r",1, VAL2,", r",2, VAL3,", r13") 374 TEST_RR( "mls lr, r",1, VAL2,", r",2, VAL3,", r13")
@@ -456,6 +458,8 @@ void kprobe_arm_test_cases(void)
456 TEST_UNSUPPORTED(".word 0xe1700090") /* Unallocated space */ 458 TEST_UNSUPPORTED(".word 0xe1700090") /* Unallocated space */
457#if __LINUX_ARM_ARCH__ >= 6 459#if __LINUX_ARM_ARCH__ >= 6
458 TEST_UNSUPPORTED("ldrex r2, [sp]") 460 TEST_UNSUPPORTED("ldrex r2, [sp]")
461#endif
462#if (__LINUX_ARM_ARCH__ >= 7) || defined(CONFIG_CPU_32v6K)
459 TEST_UNSUPPORTED("strexd r0, r2, r3, [sp]") 463 TEST_UNSUPPORTED("strexd r0, r2, r3, [sp]")
460 TEST_UNSUPPORTED("ldrexd r2, r3, [sp]") 464 TEST_UNSUPPORTED("ldrexd r2, r3, [sp]")
461 TEST_UNSUPPORTED("strexb r0, r2, [sp]") 465 TEST_UNSUPPORTED("strexb r0, r2, [sp]")
diff --git a/arch/arm/kernel/machine_kexec.c b/arch/arm/kernel/machine_kexec.c
index e29c3337ca8..8ef8c933780 100644
--- a/arch/arm/kernel/machine_kexec.c
+++ b/arch/arm/kernel/machine_kexec.c
@@ -45,10 +45,9 @@ int machine_kexec_prepare(struct kimage *image)
45 for (i = 0; i < image->nr_segments; i++) { 45 for (i = 0; i < image->nr_segments; i++) {
46 current_segment = &image->segment[i]; 46 current_segment = &image->segment[i];
47 47
48 err = memblock_is_region_memory(current_segment->mem, 48 if (!memblock_is_region_memory(current_segment->mem,
49 current_segment->memsz); 49 current_segment->memsz))
50 if (err) 50 return -EINVAL;
51 return - EINVAL;
52 51
53 err = get_user(header, (__be32*)current_segment->buf); 52 err = get_user(header, (__be32*)current_segment->buf);
54 if (err) 53 if (err)
diff --git a/arch/arm/kernel/perf_event.c b/arch/arm/kernel/perf_event.c
index 93971b1a4f0..53c0304b734 100644
--- a/arch/arm/kernel/perf_event.c
+++ b/arch/arm/kernel/perf_event.c
@@ -96,6 +96,10 @@ armpmu_event_set_period(struct perf_event *event,
96 s64 period = hwc->sample_period; 96 s64 period = hwc->sample_period;
97 int ret = 0; 97 int ret = 0;
98 98
99 /* The period may have been changed by PERF_EVENT_IOC_PERIOD */
100 if (unlikely(period != hwc->last_period))
101 left = period - (hwc->last_period - left);
102
99 if (unlikely(left <= -period)) { 103 if (unlikely(left <= -period)) {
100 left = period; 104 left = period;
101 local64_set(&hwc->period_left, left); 105 local64_set(&hwc->period_left, left);
diff --git a/arch/arm/kernel/sched_clock.c b/arch/arm/kernel/sched_clock.c
index e21bac20d90..fc6692e2b60 100644
--- a/arch/arm/kernel/sched_clock.c
+++ b/arch/arm/kernel/sched_clock.c
@@ -107,13 +107,6 @@ static void sched_clock_poll(unsigned long wrap_ticks)
107 update_sched_clock(); 107 update_sched_clock();
108} 108}
109 109
110void __init setup_sched_clock_needs_suspend(u32 (*read)(void), int bits,
111 unsigned long rate)
112{
113 setup_sched_clock(read, bits, rate);
114 cd.needs_suspend = true;
115}
116
117void __init setup_sched_clock(u32 (*read)(void), int bits, unsigned long rate) 110void __init setup_sched_clock(u32 (*read)(void), int bits, unsigned long rate)
118{ 111{
119 unsigned long r, w; 112 unsigned long r, w;
@@ -189,18 +182,15 @@ void __init sched_clock_postinit(void)
189static int sched_clock_suspend(void) 182static int sched_clock_suspend(void)
190{ 183{
191 sched_clock_poll(sched_clock_timer.data); 184 sched_clock_poll(sched_clock_timer.data);
192 if (cd.needs_suspend) 185 cd.suspended = true;
193 cd.suspended = true;
194 return 0; 186 return 0;
195} 187}
196 188
197static void sched_clock_resume(void) 189static void sched_clock_resume(void)
198{ 190{
199 if (cd.needs_suspend) { 191 cd.epoch_cyc = read_sched_clock();
200 cd.epoch_cyc = read_sched_clock(); 192 cd.epoch_cyc_copy = cd.epoch_cyc;
201 cd.epoch_cyc_copy = cd.epoch_cyc; 193 cd.suspended = false;
202 cd.suspended = false;
203 }
204} 194}
205 195
206static struct syscore_ops sched_clock_ops = { 196static struct syscore_ops sched_clock_ops = {
diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index 8e20754dd31..fbc8b2623d8 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -294,18 +294,24 @@ static void percpu_timer_setup(void);
294asmlinkage void __cpuinit secondary_start_kernel(void) 294asmlinkage void __cpuinit secondary_start_kernel(void)
295{ 295{
296 struct mm_struct *mm = &init_mm; 296 struct mm_struct *mm = &init_mm;
297 unsigned int cpu = smp_processor_id(); 297 unsigned int cpu;
298
299 /*
300 * The identity mapping is uncached (strongly ordered), so
301 * switch away from it before attempting any exclusive accesses.
302 */
303 cpu_switch_mm(mm->pgd, mm);
304 enter_lazy_tlb(mm, current);
305 local_flush_tlb_all();
298 306
299 /* 307 /*
300 * All kernel threads share the same mm context; grab a 308 * All kernel threads share the same mm context; grab a
301 * reference and switch to it. 309 * reference and switch to it.
302 */ 310 */
311 cpu = smp_processor_id();
303 atomic_inc(&mm->mm_count); 312 atomic_inc(&mm->mm_count);
304 current->active_mm = mm; 313 current->active_mm = mm;
305 cpumask_set_cpu(cpu, mm_cpumask(mm)); 314 cpumask_set_cpu(cpu, mm_cpumask(mm));
306 cpu_switch_mm(mm->pgd, mm);
307 enter_lazy_tlb(mm, current);
308 local_flush_tlb_all();
309 315
310 printk("CPU%u: Booted secondary processor\n", cpu); 316 printk("CPU%u: Booted secondary processor\n", cpu);
311 317
diff --git a/arch/arm/kernel/smp_twd.c b/arch/arm/kernel/smp_twd.c
index e1f906989bb..b22d700fea2 100644
--- a/arch/arm/kernel/smp_twd.c
+++ b/arch/arm/kernel/smp_twd.c
@@ -42,10 +42,10 @@ static void twd_set_mode(enum clock_event_mode mode,
42 42
43 switch (mode) { 43 switch (mode) {
44 case CLOCK_EVT_MODE_PERIODIC: 44 case CLOCK_EVT_MODE_PERIODIC:
45 /* timer load already set up */
46 ctrl = TWD_TIMER_CONTROL_ENABLE | TWD_TIMER_CONTROL_IT_ENABLE 45 ctrl = TWD_TIMER_CONTROL_ENABLE | TWD_TIMER_CONTROL_IT_ENABLE
47 | TWD_TIMER_CONTROL_PERIODIC; 46 | TWD_TIMER_CONTROL_PERIODIC;
48 __raw_writel(twd_timer_rate / HZ, twd_base + TWD_TIMER_LOAD); 47 __raw_writel(DIV_ROUND_CLOSEST(twd_timer_rate, HZ),
48 twd_base + TWD_TIMER_LOAD);
49 break; 49 break;
50 case CLOCK_EVT_MODE_ONESHOT: 50 case CLOCK_EVT_MODE_ONESHOT:
51 /* period set, and timer enabled in 'next_event' hook */ 51 /* period set, and timer enabled in 'next_event' hook */
diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c
index 9d0a30032d7..0dc53854a5d 100644
--- a/arch/arm/lib/delay.c
+++ b/arch/arm/lib/delay.c
@@ -45,6 +45,7 @@ int read_current_timer(unsigned long *timer_val)
45 *timer_val = delay_timer->read_current_timer(); 45 *timer_val = delay_timer->read_current_timer();
46 return 0; 46 return 0;
47} 47}
48EXPORT_SYMBOL_GPL(read_current_timer);
48 49
49static void __timer_delay(unsigned long cycles) 50static void __timer_delay(unsigned long cycles)
50{ 51{
diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index b1420710193..043624219b5 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -21,19 +21,13 @@ config SOC_AT91SAM9
21 bool 21 bool
22 select CPU_ARM926T 22 select CPU_ARM926T
23 select GENERIC_CLOCKEVENTS 23 select GENERIC_CLOCKEVENTS
24 select MULTI_IRQ_HANDLER
25 select SPARSE_IRQ
24 26
25menu "Atmel AT91 System-on-Chip" 27menu "Atmel AT91 System-on-Chip"
26 28
27comment "Atmel AT91 Processor" 29comment "Atmel AT91 Processor"
28 30
29config SOC_AT91SAM9
30 bool
31 select AT91_SAM9_SMC
32 select AT91_SAM9_TIME
33 select CPU_ARM926T
34 select MULTI_IRQ_HANDLER
35 select SPARSE_IRQ
36
37config SOC_AT91RM9200 31config SOC_AT91RM9200
38 bool "AT91RM9200" 32 bool "AT91RM9200"
39 select CPU_ARM920T 33 select CPU_ARM920T
diff --git a/arch/arm/mach-at91/at91rm9200.c b/arch/arm/mach-at91/at91rm9200.c
index b4f0565aff6..5269825194a 100644
--- a/arch/arm/mach-at91/at91rm9200.c
+++ b/arch/arm/mach-at91/at91rm9200.c
@@ -187,7 +187,7 @@ static struct clk_lookup periph_clocks_lookups[] = {
187 CLKDEV_CON_DEV_ID("pclk", "ssc.0", &ssc0_clk), 187 CLKDEV_CON_DEV_ID("pclk", "ssc.0", &ssc0_clk),
188 CLKDEV_CON_DEV_ID("pclk", "ssc.1", &ssc1_clk), 188 CLKDEV_CON_DEV_ID("pclk", "ssc.1", &ssc1_clk),
189 CLKDEV_CON_DEV_ID("pclk", "ssc.2", &ssc2_clk), 189 CLKDEV_CON_DEV_ID("pclk", "ssc.2", &ssc2_clk),
190 CLKDEV_CON_DEV_ID(NULL, "i2c-at91rm9200", &twi_clk), 190 CLKDEV_CON_DEV_ID(NULL, "i2c-at91rm9200.0", &twi_clk),
191 /* fake hclk clock */ 191 /* fake hclk clock */
192 CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &ohci_clk), 192 CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &ohci_clk),
193 CLKDEV_CON_ID("pioA", &pioA_clk), 193 CLKDEV_CON_ID("pioA", &pioA_clk),
diff --git a/arch/arm/mach-at91/at91rm9200_devices.c b/arch/arm/mach-at91/at91rm9200_devices.c
index a563189cdfc..3cee0e6ea7c 100644
--- a/arch/arm/mach-at91/at91rm9200_devices.c
+++ b/arch/arm/mach-at91/at91rm9200_devices.c
@@ -68,7 +68,7 @@ void __init at91_add_device_usbh(struct at91_usbh_data *data)
68 68
69 /* Enable overcurrent notification */ 69 /* Enable overcurrent notification */
70 for (i = 0; i < data->ports; i++) { 70 for (i = 0; i < data->ports; i++) {
71 if (data->overcurrent_pin[i]) 71 if (gpio_is_valid(data->overcurrent_pin[i]))
72 at91_set_gpio_input(data->overcurrent_pin[i], 1); 72 at91_set_gpio_input(data->overcurrent_pin[i], 1);
73 } 73 }
74 74
@@ -479,7 +479,7 @@ static struct i2c_gpio_platform_data pdata = {
479 479
480static struct platform_device at91rm9200_twi_device = { 480static struct platform_device at91rm9200_twi_device = {
481 .name = "i2c-gpio", 481 .name = "i2c-gpio",
482 .id = -1, 482 .id = 0,
483 .dev.platform_data = &pdata, 483 .dev.platform_data = &pdata,
484}; 484};
485 485
@@ -512,7 +512,7 @@ static struct resource twi_resources[] = {
512 512
513static struct platform_device at91rm9200_twi_device = { 513static struct platform_device at91rm9200_twi_device = {
514 .name = "i2c-at91rm9200", 514 .name = "i2c-at91rm9200",
515 .id = -1, 515 .id = 0,
516 .resource = twi_resources, 516 .resource = twi_resources,
517 .num_resources = ARRAY_SIZE(twi_resources), 517 .num_resources = ARRAY_SIZE(twi_resources),
518}; 518};
diff --git a/arch/arm/mach-at91/at91sam9260.c b/arch/arm/mach-at91/at91sam9260.c
index ad29f93f20c..f8202615f4a 100644
--- a/arch/arm/mach-at91/at91sam9260.c
+++ b/arch/arm/mach-at91/at91sam9260.c
@@ -211,8 +211,8 @@ static struct clk_lookup periph_clocks_lookups[] = {
211 CLKDEV_CON_DEV_ID("t1_clk", "atmel_tcb.1", &tc4_clk), 211 CLKDEV_CON_DEV_ID("t1_clk", "atmel_tcb.1", &tc4_clk),
212 CLKDEV_CON_DEV_ID("t2_clk", "atmel_tcb.1", &tc5_clk), 212 CLKDEV_CON_DEV_ID("t2_clk", "atmel_tcb.1", &tc5_clk),
213 CLKDEV_CON_DEV_ID("pclk", "ssc.0", &ssc_clk), 213 CLKDEV_CON_DEV_ID("pclk", "ssc.0", &ssc_clk),
214 CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9260", &twi_clk), 214 CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9260.0", &twi_clk),
215 CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9g20", &twi_clk), 215 CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9g20.0", &twi_clk),
216 /* more usart lookup table for DT entries */ 216 /* more usart lookup table for DT entries */
217 CLKDEV_CON_DEV_ID("usart", "fffff200.serial", &mck), 217 CLKDEV_CON_DEV_ID("usart", "fffff200.serial", &mck),
218 CLKDEV_CON_DEV_ID("usart", "fffb0000.serial", &usart0_clk), 218 CLKDEV_CON_DEV_ID("usart", "fffb0000.serial", &usart0_clk),
diff --git a/arch/arm/mach-at91/at91sam9260_devices.c b/arch/arm/mach-at91/at91sam9260_devices.c
index a76b8684f52..414bd855fb0 100644
--- a/arch/arm/mach-at91/at91sam9260_devices.c
+++ b/arch/arm/mach-at91/at91sam9260_devices.c
@@ -72,7 +72,7 @@ void __init at91_add_device_usbh(struct at91_usbh_data *data)
72 72
73 /* Enable overcurrent notification */ 73 /* Enable overcurrent notification */
74 for (i = 0; i < data->ports; i++) { 74 for (i = 0; i < data->ports; i++) {
75 if (data->overcurrent_pin[i]) 75 if (gpio_is_valid(data->overcurrent_pin[i]))
76 at91_set_gpio_input(data->overcurrent_pin[i], 1); 76 at91_set_gpio_input(data->overcurrent_pin[i], 1);
77 } 77 }
78 78
@@ -389,7 +389,7 @@ static struct i2c_gpio_platform_data pdata = {
389 389
390static struct platform_device at91sam9260_twi_device = { 390static struct platform_device at91sam9260_twi_device = {
391 .name = "i2c-gpio", 391 .name = "i2c-gpio",
392 .id = -1, 392 .id = 0,
393 .dev.platform_data = &pdata, 393 .dev.platform_data = &pdata,
394}; 394};
395 395
@@ -421,7 +421,7 @@ static struct resource twi_resources[] = {
421}; 421};
422 422
423static struct platform_device at91sam9260_twi_device = { 423static struct platform_device at91sam9260_twi_device = {
424 .id = -1, 424 .id = 0,
425 .resource = twi_resources, 425 .resource = twi_resources,
426 .num_resources = ARRAY_SIZE(twi_resources), 426 .num_resources = ARRAY_SIZE(twi_resources),
427}; 427};
diff --git a/arch/arm/mach-at91/at91sam9261.c b/arch/arm/mach-at91/at91sam9261.c
index 8d999eb1a13..04295c04b3e 100644
--- a/arch/arm/mach-at91/at91sam9261.c
+++ b/arch/arm/mach-at91/at91sam9261.c
@@ -178,8 +178,8 @@ static struct clk_lookup periph_clocks_lookups[] = {
178 CLKDEV_CON_DEV_ID("pclk", "ssc.1", &ssc1_clk), 178 CLKDEV_CON_DEV_ID("pclk", "ssc.1", &ssc1_clk),
179 CLKDEV_CON_DEV_ID("pclk", "ssc.2", &ssc2_clk), 179 CLKDEV_CON_DEV_ID("pclk", "ssc.2", &ssc2_clk),
180 CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &hck0), 180 CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &hck0),
181 CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9261", &twi_clk), 181 CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9261.0", &twi_clk),
182 CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9g10", &twi_clk), 182 CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9g10.0", &twi_clk),
183 CLKDEV_CON_ID("pioA", &pioA_clk), 183 CLKDEV_CON_ID("pioA", &pioA_clk),
184 CLKDEV_CON_ID("pioB", &pioB_clk), 184 CLKDEV_CON_ID("pioB", &pioB_clk),
185 CLKDEV_CON_ID("pioC", &pioC_clk), 185 CLKDEV_CON_ID("pioC", &pioC_clk),
diff --git a/arch/arm/mach-at91/at91sam9261_devices.c b/arch/arm/mach-at91/at91sam9261_devices.c
index 9752f17efba..cd604aad8e9 100644
--- a/arch/arm/mach-at91/at91sam9261_devices.c
+++ b/arch/arm/mach-at91/at91sam9261_devices.c
@@ -72,7 +72,7 @@ void __init at91_add_device_usbh(struct at91_usbh_data *data)
72 72
73 /* Enable overcurrent notification */ 73 /* Enable overcurrent notification */
74 for (i = 0; i < data->ports; i++) { 74 for (i = 0; i < data->ports; i++) {
75 if (data->overcurrent_pin[i]) 75 if (gpio_is_valid(data->overcurrent_pin[i]))
76 at91_set_gpio_input(data->overcurrent_pin[i], 1); 76 at91_set_gpio_input(data->overcurrent_pin[i], 1);
77 } 77 }
78 78
@@ -285,7 +285,7 @@ static struct i2c_gpio_platform_data pdata = {
285 285
286static struct platform_device at91sam9261_twi_device = { 286static struct platform_device at91sam9261_twi_device = {
287 .name = "i2c-gpio", 287 .name = "i2c-gpio",
288 .id = -1, 288 .id = 0,
289 .dev.platform_data = &pdata, 289 .dev.platform_data = &pdata,
290}; 290};
291 291
@@ -317,7 +317,7 @@ static struct resource twi_resources[] = {
317}; 317};
318 318
319static struct platform_device at91sam9261_twi_device = { 319static struct platform_device at91sam9261_twi_device = {
320 .id = -1, 320 .id = 0,
321 .resource = twi_resources, 321 .resource = twi_resources,
322 .num_resources = ARRAY_SIZE(twi_resources), 322 .num_resources = ARRAY_SIZE(twi_resources),
323}; 323};
diff --git a/arch/arm/mach-at91/at91sam9263.c b/arch/arm/mach-at91/at91sam9263.c
index 6a01d0360df..d6f9c23927c 100644
--- a/arch/arm/mach-at91/at91sam9263.c
+++ b/arch/arm/mach-at91/at91sam9263.c
@@ -193,7 +193,7 @@ static struct clk_lookup periph_clocks_lookups[] = {
193 CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.0", &spi0_clk), 193 CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.0", &spi0_clk),
194 CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.1", &spi1_clk), 194 CLKDEV_CON_DEV_ID("spi_clk", "atmel_spi.1", &spi1_clk),
195 CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.0", &tcb_clk), 195 CLKDEV_CON_DEV_ID("t0_clk", "atmel_tcb.0", &tcb_clk),
196 CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9260", &twi_clk), 196 CLKDEV_CON_DEV_ID(NULL, "i2c-at91sam9260.0", &twi_clk),
197 /* fake hclk clock */ 197 /* fake hclk clock */
198 CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &ohci_clk), 198 CLKDEV_CON_DEV_ID("hclk", "at91_ohci", &ohci_clk),
199 CLKDEV_CON_ID("pioA", &pioA_clk), 199 CLKDEV_CON_ID("pioA", &pioA_clk),
diff --git a/arch/arm/mach-at91/at91sam9263_devices.c b/arch/arm/mach-at91/at91sam9263_devices.c
index 8dde220b42b..9c61e59a210 100644
--- a/arch/arm/mach-at91/at91sam9263_devices.c
+++ b/arch/arm/mach-at91/at91sam9263_devices.c
@@ -78,7 +78,7 @@ void __init at91_add_device_usbh(struct at91_usbh_data *data)
78 78
79 /* Enable overcurrent notification */ 79 /* Enable overcurrent notification */
80 for (i = 0; i < data->ports; i++) { 80 for (i = 0; i < data->ports; i++) {
81 if (data->overcurrent_pin[i]) 81 if (gpio_is_valid(data->overcurrent_pin[i]))
82 at91_set_gpio_input(data->overcurrent_pin[i], 1); 82 at91_set_gpio_input(data->overcurrent_pin[i], 1);
83 } 83 }
84 84
@@ -567,7 +567,7 @@ static struct i2c_gpio_platform_data pdata = {
567 567
568static struct platform_device at91sam9263_twi_device = { 568static struct platform_device at91sam9263_twi_device = {
569 .name = "i2c-gpio", 569 .name = "i2c-gpio",
570 .id = -1, 570 .id = 0,
571 .dev.platform_data = &pdata, 571 .dev.platform_data = &pdata,
572}; 572};
573 573
@@ -600,7 +600,7 @@ static struct resource twi_resources[] = {
600 600
601static struct platform_device at91sam9263_twi_device = { 601static struct platform_device at91sam9263_twi_device = {
602 .name = "i2c-at91sam9260", 602 .name = "i2c-at91sam9260",
603 .id = -1, 603 .id = 0,
604 .resource = twi_resources, 604 .resource = twi_resources,
605 .num_resources = ARRAY_SIZE(twi_resources), 605 .num_resources = ARRAY_SIZE(twi_resources),
606}; 606};
diff --git a/arch/arm/mach-at91/at91sam9g45_devices.c b/arch/arm/mach-at91/at91sam9g45_devices.c
index b1596072dcc..fcd233cb33d 100644
--- a/arch/arm/mach-at91/at91sam9g45_devices.c
+++ b/arch/arm/mach-at91/at91sam9g45_devices.c
@@ -1841,8 +1841,8 @@ static struct resource sha_resources[] = {
1841 .flags = IORESOURCE_MEM, 1841 .flags = IORESOURCE_MEM,
1842 }, 1842 },
1843 [1] = { 1843 [1] = {
1844 .start = AT91SAM9G45_ID_AESTDESSHA, 1844 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_AESTDESSHA,
1845 .end = AT91SAM9G45_ID_AESTDESSHA, 1845 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_AESTDESSHA,
1846 .flags = IORESOURCE_IRQ, 1846 .flags = IORESOURCE_IRQ,
1847 }, 1847 },
1848}; 1848};
@@ -1874,8 +1874,8 @@ static struct resource tdes_resources[] = {
1874 .flags = IORESOURCE_MEM, 1874 .flags = IORESOURCE_MEM,
1875 }, 1875 },
1876 [1] = { 1876 [1] = {
1877 .start = AT91SAM9G45_ID_AESTDESSHA, 1877 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_AESTDESSHA,
1878 .end = AT91SAM9G45_ID_AESTDESSHA, 1878 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_AESTDESSHA,
1879 .flags = IORESOURCE_IRQ, 1879 .flags = IORESOURCE_IRQ,
1880 }, 1880 },
1881}; 1881};
@@ -1910,8 +1910,8 @@ static struct resource aes_resources[] = {
1910 .flags = IORESOURCE_MEM, 1910 .flags = IORESOURCE_MEM,
1911 }, 1911 },
1912 [1] = { 1912 [1] = {
1913 .start = AT91SAM9G45_ID_AESTDESSHA, 1913 .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_AESTDESSHA,
1914 .end = AT91SAM9G45_ID_AESTDESSHA, 1914 .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_AESTDESSHA,
1915 .flags = IORESOURCE_IRQ, 1915 .flags = IORESOURCE_IRQ,
1916 }, 1916 },
1917}; 1917};
diff --git a/arch/arm/mach-at91/at91sam9rl_devices.c b/arch/arm/mach-at91/at91sam9rl_devices.c
index d6ca0543ce8..5047bdc92ad 100644
--- a/arch/arm/mach-at91/at91sam9rl_devices.c
+++ b/arch/arm/mach-at91/at91sam9rl_devices.c
@@ -314,7 +314,7 @@ static struct i2c_gpio_platform_data pdata = {
314 314
315static struct platform_device at91sam9rl_twi_device = { 315static struct platform_device at91sam9rl_twi_device = {
316 .name = "i2c-gpio", 316 .name = "i2c-gpio",
317 .id = -1, 317 .id = 0,
318 .dev.platform_data = &pdata, 318 .dev.platform_data = &pdata,
319}; 319};
320 320
@@ -347,7 +347,7 @@ static struct resource twi_resources[] = {
347 347
348static struct platform_device at91sam9rl_twi_device = { 348static struct platform_device at91sam9rl_twi_device = {
349 .name = "i2c-at91sam9g20", 349 .name = "i2c-at91sam9g20",
350 .id = -1, 350 .id = 0,
351 .resource = twi_resources, 351 .resource = twi_resources,
352 .num_resources = ARRAY_SIZE(twi_resources), 352 .num_resources = ARRAY_SIZE(twi_resources),
353}; 353};
diff --git a/arch/arm/mach-at91/at91x40.c b/arch/arm/mach-at91/at91x40.c
index 6bd7300a2bc..bb7f54474b9 100644
--- a/arch/arm/mach-at91/at91x40.c
+++ b/arch/arm/mach-at91/at91x40.c
@@ -88,6 +88,6 @@ void __init at91x40_init_interrupts(unsigned int priority[NR_AIC_IRQS])
88 if (!priority) 88 if (!priority)
89 priority = at91x40_default_irq_priority; 89 priority = at91x40_default_irq_priority;
90 90
91 at91_aic_init(priority); 91 at91_aic_init(priority, at91_extern_irq);
92} 92}
93 93
diff --git a/arch/arm/mach-at91/board-neocore926.c b/arch/arm/mach-at91/board-neocore926.c
index 9cda3fd346a..6960778af4c 100644
--- a/arch/arm/mach-at91/board-neocore926.c
+++ b/arch/arm/mach-at91/board-neocore926.c
@@ -129,7 +129,7 @@ static struct spi_board_info neocore926_spi_devices[] = {
129 .max_speed_hz = 125000 * 16, 129 .max_speed_hz = 125000 * 16,
130 .bus_num = 0, 130 .bus_num = 0,
131 .platform_data = &ads_info, 131 .platform_data = &ads_info,
132 .irq = AT91SAM9263_ID_IRQ1, 132 .irq = NR_IRQS_LEGACY + AT91SAM9263_ID_IRQ1,
133 }, 133 },
134#endif 134#endif
135}; 135};
diff --git a/arch/arm/mach-at91/board-sam9261ek.c b/arch/arm/mach-at91/board-sam9261ek.c
index 27b3af1a304..a9167dd45f9 100644
--- a/arch/arm/mach-at91/board-sam9261ek.c
+++ b/arch/arm/mach-at91/board-sam9261ek.c
@@ -309,7 +309,7 @@ static struct spi_board_info ek_spi_devices[] = {
309 .max_speed_hz = 125000 * 26, /* (max sample rate @ 3V) * (cmd + data + overhead) */ 309 .max_speed_hz = 125000 * 26, /* (max sample rate @ 3V) * (cmd + data + overhead) */
310 .bus_num = 0, 310 .bus_num = 0,
311 .platform_data = &ads_info, 311 .platform_data = &ads_info,
312 .irq = AT91SAM9261_ID_IRQ0, 312 .irq = NR_IRQS_LEGACY + AT91SAM9261_ID_IRQ0,
313 .controller_data = (void *) AT91_PIN_PA28, /* CS pin */ 313 .controller_data = (void *) AT91_PIN_PA28, /* CS pin */
314 }, 314 },
315#endif 315#endif
diff --git a/arch/arm/mach-at91/board-sam9263ek.c b/arch/arm/mach-at91/board-sam9263ek.c
index 073e17403d9..b87dbe2be0d 100644
--- a/arch/arm/mach-at91/board-sam9263ek.c
+++ b/arch/arm/mach-at91/board-sam9263ek.c
@@ -132,7 +132,7 @@ static struct spi_board_info ek_spi_devices[] = {
132 .max_speed_hz = 125000 * 26, /* (max sample rate @ 3V) * (cmd + data + overhead) */ 132 .max_speed_hz = 125000 * 26, /* (max sample rate @ 3V) * (cmd + data + overhead) */
133 .bus_num = 0, 133 .bus_num = 0,
134 .platform_data = &ads_info, 134 .platform_data = &ads_info,
135 .irq = AT91SAM9263_ID_IRQ1, 135 .irq = NR_IRQS_LEGACY + AT91SAM9263_ID_IRQ1,
136 }, 136 },
137#endif 137#endif
138}; 138};
diff --git a/arch/arm/mach-at91/generic.h b/arch/arm/mach-at91/generic.h
index f4965067765..b62f560e6c7 100644
--- a/arch/arm/mach-at91/generic.h
+++ b/arch/arm/mach-at91/generic.h
@@ -26,7 +26,8 @@ extern void __init at91_dt_initialize(void);
26extern void __init at91_init_irq_default(void); 26extern void __init at91_init_irq_default(void);
27extern void __init at91_init_interrupts(unsigned int priority[]); 27extern void __init at91_init_interrupts(unsigned int priority[]);
28extern void __init at91x40_init_interrupts(unsigned int priority[]); 28extern void __init at91x40_init_interrupts(unsigned int priority[]);
29extern void __init at91_aic_init(unsigned int priority[]); 29extern void __init at91_aic_init(unsigned int priority[],
30 unsigned int ext_irq_mask);
30extern int __init at91_aic_of_init(struct device_node *node, 31extern int __init at91_aic_of_init(struct device_node *node,
31 struct device_node *parent); 32 struct device_node *parent);
32extern int __init at91_aic5_of_init(struct device_node *node, 33extern int __init at91_aic5_of_init(struct device_node *node,
diff --git a/arch/arm/mach-at91/irq.c b/arch/arm/mach-at91/irq.c
index 1e02c0e49dc..febc2ee901a 100644
--- a/arch/arm/mach-at91/irq.c
+++ b/arch/arm/mach-at91/irq.c
@@ -502,14 +502,19 @@ int __init at91_aic5_of_init(struct device_node *node,
502/* 502/*
503 * Initialize the AIC interrupt controller. 503 * Initialize the AIC interrupt controller.
504 */ 504 */
505void __init at91_aic_init(unsigned int *priority) 505void __init at91_aic_init(unsigned int *priority, unsigned int ext_irq_mask)
506{ 506{
507 unsigned int i; 507 unsigned int i;
508 int irq_base; 508 int irq_base;
509 509
510 if (at91_aic_pm_init()) 510 at91_extern_irq = kzalloc(BITS_TO_LONGS(n_irqs)
511 * sizeof(*at91_extern_irq), GFP_KERNEL);
512
513 if (at91_aic_pm_init() || at91_extern_irq == NULL)
511 panic("Unable to allocate bit maps\n"); 514 panic("Unable to allocate bit maps\n");
512 515
516 *at91_extern_irq = ext_irq_mask;
517
513 at91_aic_base = ioremap(AT91_AIC, 512); 518 at91_aic_base = ioremap(AT91_AIC, 512);
514 if (!at91_aic_base) 519 if (!at91_aic_base)
515 panic("Unable to ioremap AIC registers\n"); 520 panic("Unable to ioremap AIC registers\n");
diff --git a/arch/arm/mach-at91/setup.c b/arch/arm/mach-at91/setup.c
index da9881b161e..0b32c81730a 100644
--- a/arch/arm/mach-at91/setup.c
+++ b/arch/arm/mach-at91/setup.c
@@ -47,7 +47,7 @@ void __init at91_init_irq_default(void)
47void __init at91_init_interrupts(unsigned int *priority) 47void __init at91_init_interrupts(unsigned int *priority)
48{ 48{
49 /* Initialize the AIC interrupt controller */ 49 /* Initialize the AIC interrupt controller */
50 at91_aic_init(priority); 50 at91_aic_init(priority, at91_extern_irq);
51 51
52 /* Enable GPIO interrupts */ 52 /* Enable GPIO interrupts */
53 at91_gpio_irq_setup(); 53 at91_gpio_irq_setup();
@@ -151,7 +151,7 @@ static void __init soc_detect(u32 dbgu_base)
151 } 151 }
152 152
153 /* at91sam9g10 */ 153 /* at91sam9g10 */
154 if ((cidr & ~AT91_CIDR_EXT) == ARCH_ID_AT91SAM9G10) { 154 if ((socid & ~AT91_CIDR_EXT) == ARCH_ID_AT91SAM9G10) {
155 at91_soc_initdata.type = AT91_SOC_SAM9G10; 155 at91_soc_initdata.type = AT91_SOC_SAM9G10;
156 at91_boot_soc = at91sam9261_soc; 156 at91_boot_soc = at91sam9261_soc;
157 } 157 }
diff --git a/arch/arm/mach-davinci/dm644x.c b/arch/arm/mach-davinci/dm644x.c
index cd0c8b1e1ec..14e9947bad6 100644
--- a/arch/arm/mach-davinci/dm644x.c
+++ b/arch/arm/mach-davinci/dm644x.c
@@ -713,8 +713,7 @@ static int dm644x_venc_setup_clock(enum vpbe_enc_timings_type type,
713 break; 713 break;
714 case VPBE_ENC_CUSTOM_TIMINGS: 714 case VPBE_ENC_CUSTOM_TIMINGS:
715 if (pclock <= 27000000) { 715 if (pclock <= 27000000) {
716 v |= DM644X_VPSS_MUXSEL_PLL2_MODE | 716 v |= DM644X_VPSS_DACCLKEN;
717 DM644X_VPSS_DACCLKEN;
718 writel(v, DAVINCI_SYSMOD_VIRT(SYSMOD_VPSS_CLKCTL)); 717 writel(v, DAVINCI_SYSMOD_VIRT(SYSMOD_VPSS_CLKCTL));
719 } else { 718 } else {
720 /* 719 /*
diff --git a/arch/arm/mach-dove/common.c b/arch/arm/mach-dove/common.c
index b37bef1d5ff..f723fe13d0f 100644
--- a/arch/arm/mach-dove/common.c
+++ b/arch/arm/mach-dove/common.c
@@ -32,6 +32,7 @@
32#include <linux/irq.h> 32#include <linux/irq.h>
33#include <plat/time.h> 33#include <plat/time.h>
34#include <linux/platform_data/usb-ehci-orion.h> 34#include <linux/platform_data/usb-ehci-orion.h>
35#include <plat/irq.h>
35#include <plat/common.h> 36#include <plat/common.h>
36#include <plat/addr-map.h> 37#include <plat/addr-map.h>
37#include "common.h" 38#include "common.h"
@@ -109,8 +110,8 @@ static void __init dove_clk_init(void)
109 110
110 orion_clkdev_add(NULL, "orion-ehci.0", usb0); 111 orion_clkdev_add(NULL, "orion-ehci.0", usb0);
111 orion_clkdev_add(NULL, "orion-ehci.1", usb1); 112 orion_clkdev_add(NULL, "orion-ehci.1", usb1);
112 orion_clkdev_add(NULL, "mv643xx_eth.0", ge); 113 orion_clkdev_add(NULL, "mv643xx_eth_port.0", ge);
113 orion_clkdev_add("0", "sata_mv.0", sata); 114 orion_clkdev_add(NULL, "sata_mv.0", sata);
114 orion_clkdev_add("0", "pcie", pex0); 115 orion_clkdev_add("0", "pcie", pex0);
115 orion_clkdev_add("1", "pcie", pex1); 116 orion_clkdev_add("1", "pcie", pex1);
116 orion_clkdev_add(NULL, "sdhci-dove.0", sdio0); 117 orion_clkdev_add(NULL, "sdhci-dove.0", sdio0);
@@ -399,7 +400,7 @@ static void __init dove_dt_init(void)
399 (dove_tclk + 499999) / 1000000); 400 (dove_tclk + 499999) / 1000000);
400 401
401#ifdef CONFIG_CACHE_TAUROS2 402#ifdef CONFIG_CACHE_TAUROS2
402 tauros2_init(); 403 tauros2_init(0);
403#endif 404#endif
404 dove_setup_cpu_mbus(); 405 dove_setup_cpu_mbus();
405 406
@@ -415,7 +416,6 @@ static void __init dove_dt_init(void)
415 dove_ehci0_init(); 416 dove_ehci0_init();
416 dove_ehci1_init(); 417 dove_ehci1_init();
417 dove_pcie_init(1, 1); 418 dove_pcie_init(1, 1);
418 dove_crypto_init();
419 419
420 of_platform_populate(NULL, of_default_bus_match_table, 420 of_platform_populate(NULL, of_default_bus_match_table,
421 dove_auxdata_lookup, NULL); 421 dove_auxdata_lookup, NULL);
diff --git a/arch/arm/mach-dove/pcie.c b/arch/arm/mach-dove/pcie.c
index bb15b26041c..0ef4435b165 100644
--- a/arch/arm/mach-dove/pcie.c
+++ b/arch/arm/mach-dove/pcie.c
@@ -10,6 +10,7 @@
10 10
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/pci.h> 12#include <linux/pci.h>
13#include <linux/clk.h>
13#include <video/vga.h> 14#include <video/vga.h>
14#include <asm/mach/pci.h> 15#include <asm/mach/pci.h>
15#include <asm/mach/arch.h> 16#include <asm/mach/arch.h>
@@ -188,6 +189,10 @@ static void __init add_pcie_port(int index, void __iomem *base)
188 189
189 if (orion_pcie_link_up(base)) { 190 if (orion_pcie_link_up(base)) {
190 struct pcie_port *pp = &pcie_port[num_pcie_ports++]; 191 struct pcie_port *pp = &pcie_port[num_pcie_ports++];
192 struct clk *clk = clk_get_sys("pcie", (index ? "1" : "0"));
193
194 if (!IS_ERR(clk))
195 clk_prepare_enable(clk);
191 196
192 printk(KERN_INFO "link up\n"); 197 printk(KERN_INFO "link up\n");
193 198
diff --git a/arch/arm/mach-exynos/common.c b/arch/arm/mach-exynos/common.c
index 715b690e500..1947be8e5f5 100644
--- a/arch/arm/mach-exynos/common.c
+++ b/arch/arm/mach-exynos/common.c
@@ -47,6 +47,7 @@
47#include <plat/fimc-core.h> 47#include <plat/fimc-core.h>
48#include <plat/iic-core.h> 48#include <plat/iic-core.h>
49#include <plat/tv-core.h> 49#include <plat/tv-core.h>
50#include <plat/spi-core.h>
50#include <plat/regs-serial.h> 51#include <plat/regs-serial.h>
51 52
52#include "common.h" 53#include "common.h"
@@ -346,6 +347,8 @@ static void __init exynos4_map_io(void)
346 347
347 s5p_fb_setname(0, "exynos4-fb"); 348 s5p_fb_setname(0, "exynos4-fb");
348 s5p_hdmi_setname("exynos4-hdmi"); 349 s5p_hdmi_setname("exynos4-hdmi");
350
351 s3c64xx_spi_setname("exynos4210-spi");
349} 352}
350 353
351static void __init exynos5_map_io(void) 354static void __init exynos5_map_io(void)
@@ -366,6 +369,8 @@ static void __init exynos5_map_io(void)
366 s3c_i2c0_setname("s3c2440-i2c"); 369 s3c_i2c0_setname("s3c2440-i2c");
367 s3c_i2c1_setname("s3c2440-i2c"); 370 s3c_i2c1_setname("s3c2440-i2c");
368 s3c_i2c2_setname("s3c2440-i2c"); 371 s3c_i2c2_setname("s3c2440-i2c");
372
373 s3c64xx_spi_setname("exynos4210-spi");
369} 374}
370 375
371static void __init exynos4_init_clocks(int xtal) 376static void __init exynos4_init_clocks(int xtal)
diff --git a/arch/arm/mach-exynos/dma.c b/arch/arm/mach-exynos/dma.c
index 21d568b3b14..87e07d6fc61 100644
--- a/arch/arm/mach-exynos/dma.c
+++ b/arch/arm/mach-exynos/dma.c
@@ -275,6 +275,9 @@ static int __init exynos_dma_init(void)
275 exynos_pdma1_pdata.nr_valid_peri = 275 exynos_pdma1_pdata.nr_valid_peri =
276 ARRAY_SIZE(exynos4210_pdma1_peri); 276 ARRAY_SIZE(exynos4210_pdma1_peri);
277 exynos_pdma1_pdata.peri_id = exynos4210_pdma1_peri; 277 exynos_pdma1_pdata.peri_id = exynos4210_pdma1_peri;
278
279 if (samsung_rev() == EXYNOS4210_REV_0)
280 exynos_mdma1_device.res.start = EXYNOS4_PA_S_MDMA1;
278 } else if (soc_is_exynos4212() || soc_is_exynos4412()) { 281 } else if (soc_is_exynos4212() || soc_is_exynos4412()) {
279 exynos_pdma0_pdata.nr_valid_peri = 282 exynos_pdma0_pdata.nr_valid_peri =
280 ARRAY_SIZE(exynos4212_pdma0_peri); 283 ARRAY_SIZE(exynos4212_pdma0_peri);
diff --git a/arch/arm/mach-exynos/include/mach/map.h b/arch/arm/mach-exynos/include/mach/map.h
index 8480849affb..ed4da4544cd 100644
--- a/arch/arm/mach-exynos/include/mach/map.h
+++ b/arch/arm/mach-exynos/include/mach/map.h
@@ -90,6 +90,7 @@
90 90
91#define EXYNOS4_PA_MDMA0 0x10810000 91#define EXYNOS4_PA_MDMA0 0x10810000
92#define EXYNOS4_PA_MDMA1 0x12850000 92#define EXYNOS4_PA_MDMA1 0x12850000
93#define EXYNOS4_PA_S_MDMA1 0x12840000
93#define EXYNOS4_PA_PDMA0 0x12680000 94#define EXYNOS4_PA_PDMA0 0x12680000
94#define EXYNOS4_PA_PDMA1 0x12690000 95#define EXYNOS4_PA_PDMA1 0x12690000
95#define EXYNOS5_PA_MDMA0 0x10800000 96#define EXYNOS5_PA_MDMA0 0x10800000
diff --git a/arch/arm/mach-exynos/mach-exynos4-dt.c b/arch/arm/mach-exynos/mach-exynos4-dt.c
index e58d786faf7..eadf4b59e7d 100644
--- a/arch/arm/mach-exynos/mach-exynos4-dt.c
+++ b/arch/arm/mach-exynos/mach-exynos4-dt.c
@@ -99,6 +99,7 @@ static char const *exynos4_dt_compat[] __initdata = {
99 99
100DT_MACHINE_START(EXYNOS4210_DT, "Samsung Exynos4 (Flattened Device Tree)") 100DT_MACHINE_START(EXYNOS4210_DT, "Samsung Exynos4 (Flattened Device Tree)")
101 /* Maintainer: Thomas Abraham <thomas.abraham@linaro.org> */ 101 /* Maintainer: Thomas Abraham <thomas.abraham@linaro.org> */
102 .smp = smp_ops(exynos_smp_ops),
102 .init_irq = exynos4_init_irq, 103 .init_irq = exynos4_init_irq,
103 .map_io = exynos4_dt_map_io, 104 .map_io = exynos4_dt_map_io,
104 .handle_irq = gic_handle_irq, 105 .handle_irq = gic_handle_irq,
diff --git a/arch/arm/mach-highbank/system.c b/arch/arm/mach-highbank/system.c
index 82c27230d4a..86e37cd9376 100644
--- a/arch/arm/mach-highbank/system.c
+++ b/arch/arm/mach-highbank/system.c
@@ -28,6 +28,7 @@ void highbank_restart(char mode, const char *cmd)
28 hignbank_set_pwr_soft_reset(); 28 hignbank_set_pwr_soft_reset();
29 29
30 scu_power_mode(scu_base_addr, SCU_PM_POWEROFF); 30 scu_power_mode(scu_base_addr, SCU_PM_POWEROFF);
31 cpu_do_idle(); 31 while (1)
32 cpu_do_idle();
32} 33}
33 34
diff --git a/arch/arm/mach-imx/clk-busy.c b/arch/arm/mach-imx/clk-busy.c
index 1a7a8dd045a..1ab91b5209e 100644
--- a/arch/arm/mach-imx/clk-busy.c
+++ b/arch/arm/mach-imx/clk-busy.c
@@ -108,7 +108,7 @@ struct clk *imx_clk_busy_divider(const char *name, const char *parent_name,
108 busy->div.hw.init = &init; 108 busy->div.hw.init = &init;
109 109
110 clk = clk_register(NULL, &busy->div.hw); 110 clk = clk_register(NULL, &busy->div.hw);
111 if (!clk) 111 if (IS_ERR(clk))
112 kfree(busy); 112 kfree(busy);
113 113
114 return clk; 114 return clk;
diff --git a/arch/arm/mach-imx/clk-gate2.c b/arch/arm/mach-imx/clk-gate2.c
index 3c1b8ff9a0a..cc49c7ae186 100644
--- a/arch/arm/mach-imx/clk-gate2.c
+++ b/arch/arm/mach-imx/clk-gate2.c
@@ -112,7 +112,7 @@ struct clk *clk_register_gate2(struct device *dev, const char *name,
112 112
113 clk = clk_register(dev, &gate->hw); 113 clk = clk_register(dev, &gate->hw);
114 if (IS_ERR(clk)) 114 if (IS_ERR(clk))
115 kfree(clk); 115 kfree(gate);
116 116
117 return clk; 117 return clk;
118} 118}
diff --git a/arch/arm/mach-imx/clk-imx25.c b/arch/arm/mach-imx/clk-imx25.c
index d20d4795f4e..01e2f843bf2 100644
--- a/arch/arm/mach-imx/clk-imx25.c
+++ b/arch/arm/mach-imx/clk-imx25.c
@@ -127,8 +127,8 @@ int __init mx25_clocks_init(void)
127 clk[esdhc2_ipg_per] = imx_clk_gate("esdhc2_ipg_per", "per4", ccm(CCM_CGCR0), 4); 127 clk[esdhc2_ipg_per] = imx_clk_gate("esdhc2_ipg_per", "per4", ccm(CCM_CGCR0), 4);
128 clk[gpt_ipg_per] = imx_clk_gate("gpt_ipg_per", "per5", ccm(CCM_CGCR0), 5); 128 clk[gpt_ipg_per] = imx_clk_gate("gpt_ipg_per", "per5", ccm(CCM_CGCR0), 5);
129 clk[i2c_ipg_per] = imx_clk_gate("i2c_ipg_per", "per6", ccm(CCM_CGCR0), 6); 129 clk[i2c_ipg_per] = imx_clk_gate("i2c_ipg_per", "per6", ccm(CCM_CGCR0), 6);
130 clk[lcdc_ipg_per] = imx_clk_gate("lcdc_ipg_per", "per8", ccm(CCM_CGCR0), 7); 130 clk[lcdc_ipg_per] = imx_clk_gate("lcdc_ipg_per", "per7", ccm(CCM_CGCR0), 7);
131 clk[nfc_ipg_per] = imx_clk_gate("nfc_ipg_per", "ipg_per", ccm(CCM_CGCR0), 8); 131 clk[nfc_ipg_per] = imx_clk_gate("nfc_ipg_per", "per8", ccm(CCM_CGCR0), 8);
132 clk[ssi1_ipg_per] = imx_clk_gate("ssi1_ipg_per", "per13", ccm(CCM_CGCR0), 13); 132 clk[ssi1_ipg_per] = imx_clk_gate("ssi1_ipg_per", "per13", ccm(CCM_CGCR0), 13);
133 clk[ssi2_ipg_per] = imx_clk_gate("ssi2_ipg_per", "per14", ccm(CCM_CGCR0), 14); 133 clk[ssi2_ipg_per] = imx_clk_gate("ssi2_ipg_per", "per14", ccm(CCM_CGCR0), 14);
134 clk[uart_ipg_per] = imx_clk_gate("uart_ipg_per", "per15", ccm(CCM_CGCR0), 15); 134 clk[uart_ipg_per] = imx_clk_gate("uart_ipg_per", "per15", ccm(CCM_CGCR0), 15);
diff --git a/arch/arm/mach-imx/clk-imx27.c b/arch/arm/mach-imx/clk-imx27.c
index 3b6b640eed2..366e5d59d88 100644
--- a/arch/arm/mach-imx/clk-imx27.c
+++ b/arch/arm/mach-imx/clk-imx27.c
@@ -109,7 +109,7 @@ int __init mx27_clocks_init(unsigned long fref)
109 clk[per3_div] = imx_clk_divider("per3_div", "mpll_main2", CCM_PCDR1, 16, 6); 109 clk[per3_div] = imx_clk_divider("per3_div", "mpll_main2", CCM_PCDR1, 16, 6);
110 clk[per4_div] = imx_clk_divider("per4_div", "mpll_main2", CCM_PCDR1, 24, 6); 110 clk[per4_div] = imx_clk_divider("per4_div", "mpll_main2", CCM_PCDR1, 24, 6);
111 clk[vpu_sel] = imx_clk_mux("vpu_sel", CCM_CSCR, 21, 1, vpu_sel_clks, ARRAY_SIZE(vpu_sel_clks)); 111 clk[vpu_sel] = imx_clk_mux("vpu_sel", CCM_CSCR, 21, 1, vpu_sel_clks, ARRAY_SIZE(vpu_sel_clks));
112 clk[vpu_div] = imx_clk_divider("vpu_div", "vpu_sel", CCM_PCDR0, 10, 3); 112 clk[vpu_div] = imx_clk_divider("vpu_div", "vpu_sel", CCM_PCDR0, 10, 6);
113 clk[usb_div] = imx_clk_divider("usb_div", "spll", CCM_CSCR, 28, 3); 113 clk[usb_div] = imx_clk_divider("usb_div", "spll", CCM_CSCR, 28, 3);
114 clk[cpu_sel] = imx_clk_mux("cpu_sel", CCM_CSCR, 15, 1, cpu_sel_clks, ARRAY_SIZE(cpu_sel_clks)); 114 clk[cpu_sel] = imx_clk_mux("cpu_sel", CCM_CSCR, 15, 1, cpu_sel_clks, ARRAY_SIZE(cpu_sel_clks));
115 clk[clko_sel] = imx_clk_mux("clko_sel", CCM_CCSR, 0, 5, clko_sel_clks, ARRAY_SIZE(clko_sel_clks)); 115 clk[clko_sel] = imx_clk_mux("clko_sel", CCM_CCSR, 0, 5, clko_sel_clks, ARRAY_SIZE(clko_sel_clks));
@@ -121,7 +121,7 @@ int __init mx27_clocks_init(unsigned long fref)
121 clk[ssi1_sel] = imx_clk_mux("ssi1_sel", CCM_CSCR, 22, 1, ssi_sel_clks, ARRAY_SIZE(ssi_sel_clks)); 121 clk[ssi1_sel] = imx_clk_mux("ssi1_sel", CCM_CSCR, 22, 1, ssi_sel_clks, ARRAY_SIZE(ssi_sel_clks));
122 clk[ssi2_sel] = imx_clk_mux("ssi2_sel", CCM_CSCR, 23, 1, ssi_sel_clks, ARRAY_SIZE(ssi_sel_clks)); 122 clk[ssi2_sel] = imx_clk_mux("ssi2_sel", CCM_CSCR, 23, 1, ssi_sel_clks, ARRAY_SIZE(ssi_sel_clks));
123 clk[ssi1_div] = imx_clk_divider("ssi1_div", "ssi1_sel", CCM_PCDR0, 16, 6); 123 clk[ssi1_div] = imx_clk_divider("ssi1_div", "ssi1_sel", CCM_PCDR0, 16, 6);
124 clk[ssi2_div] = imx_clk_divider("ssi2_div", "ssi2_sel", CCM_PCDR0, 26, 3); 124 clk[ssi2_div] = imx_clk_divider("ssi2_div", "ssi2_sel", CCM_PCDR0, 26, 6);
125 clk[clko_en] = imx_clk_gate("clko_en", "clko_div", CCM_PCCR0, 0); 125 clk[clko_en] = imx_clk_gate("clko_en", "clko_div", CCM_PCCR0, 0);
126 clk[ssi2_ipg_gate] = imx_clk_gate("ssi2_ipg_gate", "ipg", CCM_PCCR0, 0); 126 clk[ssi2_ipg_gate] = imx_clk_gate("ssi2_ipg_gate", "ipg", CCM_PCCR0, 0);
127 clk[ssi1_ipg_gate] = imx_clk_gate("ssi1_ipg_gate", "ipg", CCM_PCCR0, 1); 127 clk[ssi1_ipg_gate] = imx_clk_gate("ssi1_ipg_gate", "ipg", CCM_PCCR0, 1);
diff --git a/arch/arm/mach-imx/ehci-imx25.c b/arch/arm/mach-imx/ehci-imx25.c
index 412c583a24b..576af744695 100644
--- a/arch/arm/mach-imx/ehci-imx25.c
+++ b/arch/arm/mach-imx/ehci-imx25.c
@@ -30,7 +30,7 @@
30#define MX25_H1_SIC_SHIFT 21 30#define MX25_H1_SIC_SHIFT 21
31#define MX25_H1_SIC_MASK (0x3 << MX25_H1_SIC_SHIFT) 31#define MX25_H1_SIC_MASK (0x3 << MX25_H1_SIC_SHIFT)
32#define MX25_H1_PP_BIT (1 << 18) 32#define MX25_H1_PP_BIT (1 << 18)
33#define MX25_H1_PM_BIT (1 << 8) 33#define MX25_H1_PM_BIT (1 << 16)
34#define MX25_H1_IPPUE_UP_BIT (1 << 7) 34#define MX25_H1_IPPUE_UP_BIT (1 << 7)
35#define MX25_H1_IPPUE_DOWN_BIT (1 << 6) 35#define MX25_H1_IPPUE_DOWN_BIT (1 << 6)
36#define MX25_H1_TLL_BIT (1 << 5) 36#define MX25_H1_TLL_BIT (1 << 5)
diff --git a/arch/arm/mach-imx/ehci-imx35.c b/arch/arm/mach-imx/ehci-imx35.c
index 779e16eb65c..293397852e4 100644
--- a/arch/arm/mach-imx/ehci-imx35.c
+++ b/arch/arm/mach-imx/ehci-imx35.c
@@ -30,7 +30,7 @@
30#define MX35_H1_SIC_SHIFT 21 30#define MX35_H1_SIC_SHIFT 21
31#define MX35_H1_SIC_MASK (0x3 << MX35_H1_SIC_SHIFT) 31#define MX35_H1_SIC_MASK (0x3 << MX35_H1_SIC_SHIFT)
32#define MX35_H1_PP_BIT (1 << 18) 32#define MX35_H1_PP_BIT (1 << 18)
33#define MX35_H1_PM_BIT (1 << 8) 33#define MX35_H1_PM_BIT (1 << 16)
34#define MX35_H1_IPPUE_UP_BIT (1 << 7) 34#define MX35_H1_IPPUE_UP_BIT (1 << 7)
35#define MX35_H1_IPPUE_DOWN_BIT (1 << 6) 35#define MX35_H1_IPPUE_DOWN_BIT (1 << 6)
36#define MX35_H1_TLL_BIT (1 << 5) 36#define MX35_H1_TLL_BIT (1 << 5)
diff --git a/arch/arm/mach-imx/mm-imx3.c b/arch/arm/mach-imx/mm-imx3.c
index 9d2c843bde0..b5deb055455 100644
--- a/arch/arm/mach-imx/mm-imx3.c
+++ b/arch/arm/mach-imx/mm-imx3.c
@@ -108,9 +108,8 @@ void __init imx3_init_l2x0(void)
108 } 108 }
109 109
110 l2x0_base = ioremap(MX3x_L2CC_BASE_ADDR, 4096); 110 l2x0_base = ioremap(MX3x_L2CC_BASE_ADDR, 4096);
111 if (IS_ERR(l2x0_base)) { 111 if (!l2x0_base) {
112 printk(KERN_ERR "remapping L2 cache area failed with %ld\n", 112 printk(KERN_ERR "remapping L2 cache area failed\n");
113 PTR_ERR(l2x0_base));
114 return; 113 return;
115 } 114 }
116 115
diff --git a/arch/arm/mach-kirkwood/board-dt.c b/arch/arm/mach-kirkwood/board-dt.c
index 70c5a288240..d94872fed8c 100644
--- a/arch/arm/mach-kirkwood/board-dt.c
+++ b/arch/arm/mach-kirkwood/board-dt.c
@@ -51,9 +51,7 @@ static void __init kirkwood_dt_init(void)
51 51
52 kirkwood_setup_cpu_mbus(); 52 kirkwood_setup_cpu_mbus();
53 53
54#ifdef CONFIG_CACHE_FEROCEON_L2
55 kirkwood_l2_init(); 54 kirkwood_l2_init();
56#endif
57 55
58 /* Setup root of clk tree */ 56 /* Setup root of clk tree */
59 kirkwood_clk_init(); 57 kirkwood_clk_init();
diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
index 3991077f58a..2c6c218fb79 100644
--- a/arch/arm/mach-kirkwood/common.c
+++ b/arch/arm/mach-kirkwood/common.c
@@ -633,6 +633,7 @@ char * __init kirkwood_id(void)
633 633
634void __init kirkwood_l2_init(void) 634void __init kirkwood_l2_init(void)
635{ 635{
636#ifdef CONFIG_CACHE_FEROCEON_L2
636#ifdef CONFIG_CACHE_FEROCEON_L2_WRITETHROUGH 637#ifdef CONFIG_CACHE_FEROCEON_L2_WRITETHROUGH
637 writel(readl(L2_CONFIG_REG) | L2_WRITETHROUGH, L2_CONFIG_REG); 638 writel(readl(L2_CONFIG_REG) | L2_WRITETHROUGH, L2_CONFIG_REG);
638 feroceon_l2_init(1); 639 feroceon_l2_init(1);
@@ -640,6 +641,7 @@ void __init kirkwood_l2_init(void)
640 writel(readl(L2_CONFIG_REG) & ~L2_WRITETHROUGH, L2_CONFIG_REG); 641 writel(readl(L2_CONFIG_REG) & ~L2_WRITETHROUGH, L2_CONFIG_REG);
641 feroceon_l2_init(0); 642 feroceon_l2_init(0);
642#endif 643#endif
644#endif
643} 645}
644 646
645void __init kirkwood_init(void) 647void __init kirkwood_init(void)
@@ -657,9 +659,7 @@ void __init kirkwood_init(void)
657 659
658 kirkwood_setup_cpu_mbus(); 660 kirkwood_setup_cpu_mbus();
659 661
660#ifdef CONFIG_CACHE_FEROCEON_L2
661 kirkwood_l2_init(); 662 kirkwood_l2_init();
662#endif
663 663
664 /* Setup root of clk tree */ 664 /* Setup root of clk tree */
665 kirkwood_clk_init(); 665 kirkwood_clk_init();
diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c
index 9518bf5996d..e255164ff08 100644
--- a/arch/arm/mach-omap1/board-ams-delta.c
+++ b/arch/arm/mach-omap1/board-ams-delta.c
@@ -444,16 +444,28 @@ static struct omap1_cam_platform_data ams_delta_camera_platform_data = {
444 .lclk_khz_max = 1334, /* results in 5fps CIF, 10fps QCIF */ 444 .lclk_khz_max = 1334, /* results in 5fps CIF, 10fps QCIF */
445}; 445};
446 446
447static struct platform_device ams_delta_audio_device = {
448 .name = "ams-delta-audio",
449 .id = -1,
450};
451
452static struct platform_device cx20442_codec_device = {
453 .name = "cx20442-codec",
454 .id = -1,
455};
456
447static struct platform_device *ams_delta_devices[] __initdata = { 457static struct platform_device *ams_delta_devices[] __initdata = {
448 &latch1_gpio_device, 458 &latch1_gpio_device,
449 &latch2_gpio_device, 459 &latch2_gpio_device,
450 &ams_delta_kp_device, 460 &ams_delta_kp_device,
451 &ams_delta_camera_device, 461 &ams_delta_camera_device,
462 &ams_delta_audio_device,
452}; 463};
453 464
454static struct platform_device *late_devices[] __initdata = { 465static struct platform_device *late_devices[] __initdata = {
455 &ams_delta_nand_device, 466 &ams_delta_nand_device,
456 &ams_delta_lcd_device, 467 &ams_delta_lcd_device,
468 &cx20442_codec_device,
457}; 469};
458 470
459static void __init ams_delta_init(void) 471static void __init ams_delta_init(void)
diff --git a/arch/arm/mach-omap2/Kconfig b/arch/arm/mach-omap2/Kconfig
index 2a1a898c7f9..d669e227e00 100644
--- a/arch/arm/mach-omap2/Kconfig
+++ b/arch/arm/mach-omap2/Kconfig
@@ -11,7 +11,6 @@ config ARCH_OMAP2PLUS_TYPICAL
11 select I2C_OMAP 11 select I2C_OMAP
12 select MENELAUS if ARCH_OMAP2 12 select MENELAUS if ARCH_OMAP2
13 select NEON if ARCH_OMAP3 || ARCH_OMAP4 || SOC_OMAP5 13 select NEON if ARCH_OMAP3 || ARCH_OMAP4 || SOC_OMAP5
14 select PINCTRL
15 select PM_RUNTIME 14 select PM_RUNTIME
16 select REGULATOR 15 select REGULATOR
17 select SERIAL_OMAP 16 select SERIAL_OMAP
diff --git a/arch/arm/mach-omap2/board-igep0020.c b/arch/arm/mach-omap2/board-igep0020.c
index 48d5e41dfbf..37859069444 100644
--- a/arch/arm/mach-omap2/board-igep0020.c
+++ b/arch/arm/mach-omap2/board-igep0020.c
@@ -580,6 +580,11 @@ static void __init igep_wlan_bt_init(void)
580 } else 580 } else
581 return; 581 return;
582 582
583 /* Make sure that the GPIO pins are muxed correctly */
584 omap_mux_init_gpio(igep_wlan_bt_gpios[0].gpio, OMAP_PIN_OUTPUT);
585 omap_mux_init_gpio(igep_wlan_bt_gpios[1].gpio, OMAP_PIN_OUTPUT);
586 omap_mux_init_gpio(igep_wlan_bt_gpios[2].gpio, OMAP_PIN_OUTPUT);
587
583 err = gpio_request_array(igep_wlan_bt_gpios, 588 err = gpio_request_array(igep_wlan_bt_gpios,
584 ARRAY_SIZE(igep_wlan_bt_gpios)); 589 ARRAY_SIZE(igep_wlan_bt_gpios));
585 if (err) { 590 if (err) {
diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
index 388c431c745..d41ab98890f 100644
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -24,6 +24,7 @@
24#include <linux/input.h> 24#include <linux/input.h>
25#include <linux/gpio_keys.h> 25#include <linux/gpio_keys.h>
26#include <linux/opp.h> 26#include <linux/opp.h>
27#include <linux/cpu.h>
27 28
28#include <linux/mtd/mtd.h> 29#include <linux/mtd/mtd.h>
29#include <linux/mtd/partitions.h> 30#include <linux/mtd/partitions.h>
@@ -444,27 +445,31 @@ static struct omap_board_mux board_mux[] __initdata = {
444}; 445};
445#endif 446#endif
446 447
447static void __init beagle_opp_init(void) 448static int __init beagle_opp_init(void)
448{ 449{
449 int r = 0; 450 int r = 0;
450 451
451 /* Initialize the omap3 opp table */ 452 if (!machine_is_omap3_beagle())
452 if (omap3_opp_init()) { 453 return 0;
454
455 /* Initialize the omap3 opp table if not already created. */
456 r = omap3_opp_init();
457 if (IS_ERR_VALUE(r) && (r != -EEXIST)) {
453 pr_err("%s: opp default init failed\n", __func__); 458 pr_err("%s: opp default init failed\n", __func__);
454 return; 459 return r;
455 } 460 }
456 461
457 /* Custom OPP enabled for all xM versions */ 462 /* Custom OPP enabled for all xM versions */
458 if (cpu_is_omap3630()) { 463 if (cpu_is_omap3630()) {
459 struct device *mpu_dev, *iva_dev; 464 struct device *mpu_dev, *iva_dev;
460 465
461 mpu_dev = omap_device_get_by_hwmod_name("mpu"); 466 mpu_dev = get_cpu_device(0);
462 iva_dev = omap_device_get_by_hwmod_name("iva"); 467 iva_dev = omap_device_get_by_hwmod_name("iva");
463 468
464 if (IS_ERR(mpu_dev) || IS_ERR(iva_dev)) { 469 if (IS_ERR(mpu_dev) || IS_ERR(iva_dev)) {
465 pr_err("%s: Aiee.. no mpu/dsp devices? %p %p\n", 470 pr_err("%s: Aiee.. no mpu/dsp devices? %p %p\n",
466 __func__, mpu_dev, iva_dev); 471 __func__, mpu_dev, iva_dev);
467 return; 472 return -ENODEV;
468 } 473 }
469 /* Enable MPU 1GHz and lower opps */ 474 /* Enable MPU 1GHz and lower opps */
470 r = opp_enable(mpu_dev, 800000000); 475 r = opp_enable(mpu_dev, 800000000);
@@ -484,8 +489,9 @@ static void __init beagle_opp_init(void)
484 opp_disable(iva_dev, 660000000); 489 opp_disable(iva_dev, 660000000);
485 } 490 }
486 } 491 }
487 return; 492 return 0;
488} 493}
494device_initcall(beagle_opp_init);
489 495
490static void __init omap3_beagle_init(void) 496static void __init omap3_beagle_init(void)
491{ 497{
@@ -522,8 +528,6 @@ static void __init omap3_beagle_init(void)
522 /* Ensure SDRC pins are mux'd for self-refresh */ 528 /* Ensure SDRC pins are mux'd for self-refresh */
523 omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT); 529 omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT);
524 omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT); 530 omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT);
525
526 beagle_opp_init();
527} 531}
528 532
529MACHINE_START(OMAP3_BEAGLE, "OMAP3 Beagle Board") 533MACHINE_START(OMAP3_BEAGLE, "OMAP3 Beagle Board")
diff --git a/arch/arm/mach-omap2/clock33xx_data.c b/arch/arm/mach-omap2/clock33xx_data.c
index 114ab4b8e0e..1a45d6bd253 100644
--- a/arch/arm/mach-omap2/clock33xx_data.c
+++ b/arch/arm/mach-omap2/clock33xx_data.c
@@ -1073,6 +1073,8 @@ static struct omap_clk am33xx_clks[] = {
1073 CLK(NULL, "gfx_fck_div_ck", &gfx_fck_div_ck, CK_AM33XX), 1073 CLK(NULL, "gfx_fck_div_ck", &gfx_fck_div_ck, CK_AM33XX),
1074 CLK(NULL, "sysclkout_pre_ck", &sysclkout_pre_ck, CK_AM33XX), 1074 CLK(NULL, "sysclkout_pre_ck", &sysclkout_pre_ck, CK_AM33XX),
1075 CLK(NULL, "clkout2_ck", &clkout2_ck, CK_AM33XX), 1075 CLK(NULL, "clkout2_ck", &clkout2_ck, CK_AM33XX),
1076 CLK(NULL, "timer_32k_ck", &clkdiv32k_ick, CK_AM33XX),
1077 CLK(NULL, "timer_sys_ck", &sys_clkin_ck, CK_AM33XX),
1076}; 1078};
1077 1079
1078int __init am33xx_clk_init(void) 1080int __init am33xx_clk_init(void)
diff --git a/arch/arm/mach-omap2/clock44xx_data.c b/arch/arm/mach-omap2/clock44xx_data.c
index d661d138f27..6efc30c961a 100644
--- a/arch/arm/mach-omap2/clock44xx_data.c
+++ b/arch/arm/mach-omap2/clock44xx_data.c
@@ -3294,7 +3294,7 @@ static struct omap_clk omap44xx_clks[] = {
3294 CLK(NULL, "auxclk5_src_ck", &auxclk5_src_ck, CK_443X), 3294 CLK(NULL, "auxclk5_src_ck", &auxclk5_src_ck, CK_443X),
3295 CLK(NULL, "auxclk5_ck", &auxclk5_ck, CK_443X), 3295 CLK(NULL, "auxclk5_ck", &auxclk5_ck, CK_443X),
3296 CLK(NULL, "auxclkreq5_ck", &auxclkreq5_ck, CK_443X), 3296 CLK(NULL, "auxclkreq5_ck", &auxclkreq5_ck, CK_443X),
3297 CLK(NULL, "gpmc_ck", &dummy_ck, CK_443X), 3297 CLK("omap-gpmc", "fck", &dummy_ck, CK_443X),
3298 CLK("omap_i2c.1", "ick", &dummy_ck, CK_443X), 3298 CLK("omap_i2c.1", "ick", &dummy_ck, CK_443X),
3299 CLK("omap_i2c.2", "ick", &dummy_ck, CK_443X), 3299 CLK("omap_i2c.2", "ick", &dummy_ck, CK_443X),
3300 CLK("omap_i2c.3", "ick", &dummy_ck, CK_443X), 3300 CLK("omap_i2c.3", "ick", &dummy_ck, CK_443X),
diff --git a/arch/arm/mach-omap2/clockdomain.c b/arch/arm/mach-omap2/clockdomain.c
index cbb879139c5..512e79a842c 100644
--- a/arch/arm/mach-omap2/clockdomain.c
+++ b/arch/arm/mach-omap2/clockdomain.c
@@ -925,15 +925,18 @@ static int _clkdm_clk_hwmod_enable(struct clockdomain *clkdm)
925 if (!clkdm || !arch_clkdm || !arch_clkdm->clkdm_clk_enable) 925 if (!clkdm || !arch_clkdm || !arch_clkdm->clkdm_clk_enable)
926 return -EINVAL; 926 return -EINVAL;
927 927
928 spin_lock_irqsave(&clkdm->lock, flags);
929
928 /* 930 /*
929 * For arch's with no autodeps, clkcm_clk_enable 931 * For arch's with no autodeps, clkcm_clk_enable
930 * should be called for every clock instance or hwmod that is 932 * should be called for every clock instance or hwmod that is
931 * enabled, so the clkdm can be force woken up. 933 * enabled, so the clkdm can be force woken up.
932 */ 934 */
933 if ((atomic_inc_return(&clkdm->usecount) > 1) && autodeps) 935 if ((atomic_inc_return(&clkdm->usecount) > 1) && autodeps) {
936 spin_unlock_irqrestore(&clkdm->lock, flags);
934 return 0; 937 return 0;
938 }
935 939
936 spin_lock_irqsave(&clkdm->lock, flags);
937 arch_clkdm->clkdm_clk_enable(clkdm); 940 arch_clkdm->clkdm_clk_enable(clkdm);
938 pwrdm_state_switch(clkdm->pwrdm.ptr); 941 pwrdm_state_switch(clkdm->pwrdm.ptr);
939 spin_unlock_irqrestore(&clkdm->lock, flags); 942 spin_unlock_irqrestore(&clkdm->lock, flags);
@@ -950,15 +953,19 @@ static int _clkdm_clk_hwmod_disable(struct clockdomain *clkdm)
950 if (!clkdm || !arch_clkdm || !arch_clkdm->clkdm_clk_disable) 953 if (!clkdm || !arch_clkdm || !arch_clkdm->clkdm_clk_disable)
951 return -EINVAL; 954 return -EINVAL;
952 955
956 spin_lock_irqsave(&clkdm->lock, flags);
957
953 if (atomic_read(&clkdm->usecount) == 0) { 958 if (atomic_read(&clkdm->usecount) == 0) {
959 spin_unlock_irqrestore(&clkdm->lock, flags);
954 WARN_ON(1); /* underflow */ 960 WARN_ON(1); /* underflow */
955 return -ERANGE; 961 return -ERANGE;
956 } 962 }
957 963
958 if (atomic_dec_return(&clkdm->usecount) > 0) 964 if (atomic_dec_return(&clkdm->usecount) > 0) {
965 spin_unlock_irqrestore(&clkdm->lock, flags);
959 return 0; 966 return 0;
967 }
960 968
961 spin_lock_irqsave(&clkdm->lock, flags);
962 arch_clkdm->clkdm_clk_disable(clkdm); 969 arch_clkdm->clkdm_clk_disable(clkdm);
963 pwrdm_state_switch(clkdm->pwrdm.ptr); 970 pwrdm_state_switch(clkdm->pwrdm.ptr);
964 spin_unlock_irqrestore(&clkdm->lock, flags); 971 spin_unlock_irqrestore(&clkdm->lock, flags);
diff --git a/arch/arm/mach-omap2/clockdomains44xx_data.c b/arch/arm/mach-omap2/clockdomains44xx_data.c
index b56d06b4878..95192a062d5 100644
--- a/arch/arm/mach-omap2/clockdomains44xx_data.c
+++ b/arch/arm/mach-omap2/clockdomains44xx_data.c
@@ -359,7 +359,7 @@ static struct clockdomain iss_44xx_clkdm = {
359 .clkdm_offs = OMAP4430_CM2_CAM_CAM_CDOFFS, 359 .clkdm_offs = OMAP4430_CM2_CAM_CAM_CDOFFS,
360 .wkdep_srcs = iss_wkup_sleep_deps, 360 .wkdep_srcs = iss_wkup_sleep_deps,
361 .sleepdep_srcs = iss_wkup_sleep_deps, 361 .sleepdep_srcs = iss_wkup_sleep_deps,
362 .flags = CLKDM_CAN_HWSUP_SWSUP, 362 .flags = CLKDM_CAN_SWSUP,
363}; 363};
364 364
365static struct clockdomain l3_dss_44xx_clkdm = { 365static struct clockdomain l3_dss_44xx_clkdm = {
diff --git a/arch/arm/mach-omap2/common-board-devices.c b/arch/arm/mach-omap2/common-board-devices.c
index 48daac2581b..84551f205e4 100644
--- a/arch/arm/mach-omap2/common-board-devices.c
+++ b/arch/arm/mach-omap2/common-board-devices.c
@@ -64,30 +64,36 @@ void __init omap_ads7846_init(int bus_num, int gpio_pendown, int gpio_debounce,
64 struct spi_board_info *spi_bi = &ads7846_spi_board_info; 64 struct spi_board_info *spi_bi = &ads7846_spi_board_info;
65 int err; 65 int err;
66 66
67 err = gpio_request_one(gpio_pendown, GPIOF_IN, "TSPenDown"); 67 /*
68 if (err) { 68 * If a board defines get_pendown_state() function, request the pendown
69 pr_err("Couldn't obtain gpio for TSPenDown: %d\n", err); 69 * GPIO and set the GPIO debounce time.
70 return; 70 * If a board does not define the get_pendown_state() function, then
71 } 71 * the ads7846 driver will setup the pendown GPIO itself.
72 */
73 if (board_pdata && board_pdata->get_pendown_state) {
74 err = gpio_request_one(gpio_pendown, GPIOF_IN, "TSPenDown");
75 if (err) {
76 pr_err("Couldn't obtain gpio for TSPenDown: %d\n", err);
77 return;
78 }
72 79
73 if (gpio_debounce) 80 if (gpio_debounce)
74 gpio_set_debounce(gpio_pendown, gpio_debounce); 81 gpio_set_debounce(gpio_pendown, gpio_debounce);
82
83 gpio_export(gpio_pendown, 0);
84 }
75 85
76 spi_bi->bus_num = bus_num; 86 spi_bi->bus_num = bus_num;
77 spi_bi->irq = gpio_to_irq(gpio_pendown); 87 spi_bi->irq = gpio_to_irq(gpio_pendown);
78 88
89 ads7846_config.gpio_pendown = gpio_pendown;
90
79 if (board_pdata) { 91 if (board_pdata) {
80 board_pdata->gpio_pendown = gpio_pendown; 92 board_pdata->gpio_pendown = gpio_pendown;
93 board_pdata->gpio_pendown_debounce = gpio_debounce;
81 spi_bi->platform_data = board_pdata; 94 spi_bi->platform_data = board_pdata;
82 if (board_pdata->get_pendown_state)
83 gpio_export(gpio_pendown, 0);
84 } else {
85 ads7846_config.gpio_pendown = gpio_pendown;
86 } 95 }
87 96
88 if (!board_pdata || (board_pdata && !board_pdata->get_pendown_state))
89 gpio_free(gpio_pendown);
90
91 spi_register_board_info(&ads7846_spi_board_info, 1); 97 spi_register_board_info(&ads7846_spi_board_info, 1);
92} 98}
93#else 99#else
diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
index c8c211731d2..c72b5a72772 100644
--- a/arch/arm/mach-omap2/devices.c
+++ b/arch/arm/mach-omap2/devices.c
@@ -19,6 +19,7 @@
19#include <linux/of.h> 19#include <linux/of.h>
20#include <linux/pinctrl/machine.h> 20#include <linux/pinctrl/machine.h>
21#include <linux/platform_data/omap4-keypad.h> 21#include <linux/platform_data/omap4-keypad.h>
22#include <linux/platform_data/omap_ocp2scp.h>
22 23
23#include <asm/mach-types.h> 24#include <asm/mach-types.h>
24#include <asm/mach/map.h> 25#include <asm/mach/map.h>
@@ -341,7 +342,7 @@ static void __init omap_init_dmic(void)
341 342
342 oh = omap_hwmod_lookup("dmic"); 343 oh = omap_hwmod_lookup("dmic");
343 if (!oh) { 344 if (!oh) {
344 printk(KERN_ERR "Could not look up mcpdm hw_mod\n"); 345 pr_err("Could not look up dmic hw_mod\n");
345 return; 346 return;
346 } 347 }
347 348
@@ -613,6 +614,83 @@ static void omap_init_vout(void)
613static inline void omap_init_vout(void) {} 614static inline void omap_init_vout(void) {}
614#endif 615#endif
615 616
617#if defined(CONFIG_OMAP_OCP2SCP) || defined(CONFIG_OMAP_OCP2SCP_MODULE)
618static int count_ocp2scp_devices(struct omap_ocp2scp_dev *ocp2scp_dev)
619{
620 int cnt = 0;
621
622 while (ocp2scp_dev->drv_name != NULL) {
623 cnt++;
624 ocp2scp_dev++;
625 }
626
627 return cnt;
628}
629
630static void omap_init_ocp2scp(void)
631{
632 struct omap_hwmod *oh;
633 struct platform_device *pdev;
634 int bus_id = -1, dev_cnt = 0, i;
635 struct omap_ocp2scp_dev *ocp2scp_dev;
636 const char *oh_name, *name;
637 struct omap_ocp2scp_platform_data *pdata;
638
639 if (!cpu_is_omap44xx())
640 return;
641
642 oh_name = "ocp2scp_usb_phy";
643 name = "omap-ocp2scp";
644
645 oh = omap_hwmod_lookup(oh_name);
646 if (!oh) {
647 pr_err("%s: could not find omap_hwmod for %s\n", __func__,
648 oh_name);
649 return;
650 }
651
652 pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
653 if (!pdata) {
654 pr_err("%s: No memory for ocp2scp pdata\n", __func__);
655 return;
656 }
657
658 ocp2scp_dev = oh->dev_attr;
659 dev_cnt = count_ocp2scp_devices(ocp2scp_dev);
660
661 if (!dev_cnt) {
662 pr_err("%s: No devices connected to ocp2scp\n", __func__);
663 kfree(pdata);
664 return;
665 }
666
667 pdata->devices = kzalloc(sizeof(struct omap_ocp2scp_dev *)
668 * dev_cnt, GFP_KERNEL);
669 if (!pdata->devices) {
670 pr_err("%s: No memory for ocp2scp pdata devices\n", __func__);
671 kfree(pdata);
672 return;
673 }
674
675 for (i = 0; i < dev_cnt; i++, ocp2scp_dev++)
676 pdata->devices[i] = ocp2scp_dev;
677
678 pdata->dev_cnt = dev_cnt;
679
680 pdev = omap_device_build(name, bus_id, oh, pdata, sizeof(*pdata), NULL,
681 0, false);
682 if (IS_ERR(pdev)) {
683 pr_err("Could not build omap_device for %s %s\n",
684 name, oh_name);
685 kfree(pdata->devices);
686 kfree(pdata);
687 return;
688 }
689}
690#else
691static inline void omap_init_ocp2scp(void) { }
692#endif
693
616/*-------------------------------------------------------------------------*/ 694/*-------------------------------------------------------------------------*/
617 695
618static int __init omap2_init_devices(void) 696static int __init omap2_init_devices(void)
@@ -640,6 +718,7 @@ static int __init omap2_init_devices(void)
640 omap_init_sham(); 718 omap_init_sham();
641 omap_init_aes(); 719 omap_init_aes();
642 omap_init_vout(); 720 omap_init_vout();
721 omap_init_ocp2scp();
643 722
644 return 0; 723 return 0;
645} 724}
diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
index 5ac5cf30406..92b5718fa72 100644
--- a/arch/arm/mach-omap2/gpmc.c
+++ b/arch/arm/mach-omap2/gpmc.c
@@ -868,9 +868,9 @@ static void __devexit gpmc_mem_exit(void)
868 868
869} 869}
870 870
871static void __devinit gpmc_mem_init(void) 871static int __devinit gpmc_mem_init(void)
872{ 872{
873 int cs; 873 int cs, rc;
874 unsigned long boot_rom_space = 0; 874 unsigned long boot_rom_space = 0;
875 875
876 /* never allocate the first page, to facilitate bug detection; 876 /* never allocate the first page, to facilitate bug detection;
@@ -890,13 +890,21 @@ static void __devinit gpmc_mem_init(void)
890 if (!gpmc_cs_mem_enabled(cs)) 890 if (!gpmc_cs_mem_enabled(cs))
891 continue; 891 continue;
892 gpmc_cs_get_memconf(cs, &base, &size); 892 gpmc_cs_get_memconf(cs, &base, &size);
893 if (gpmc_cs_insert_mem(cs, base, size) < 0) 893 rc = gpmc_cs_insert_mem(cs, base, size);
894 BUG(); 894 if (IS_ERR_VALUE(rc)) {
895 while (--cs >= 0)
896 if (gpmc_cs_mem_enabled(cs))
897 gpmc_cs_delete_mem(cs);
898 return rc;
899 }
895 } 900 }
901
902 return 0;
896} 903}
897 904
898static __devinit int gpmc_probe(struct platform_device *pdev) 905static __devinit int gpmc_probe(struct platform_device *pdev)
899{ 906{
907 int rc;
900 u32 l; 908 u32 l;
901 struct resource *res; 909 struct resource *res;
902 910
@@ -936,7 +944,13 @@ static __devinit int gpmc_probe(struct platform_device *pdev)
936 dev_info(gpmc_dev, "GPMC revision %d.%d\n", GPMC_REVISION_MAJOR(l), 944 dev_info(gpmc_dev, "GPMC revision %d.%d\n", GPMC_REVISION_MAJOR(l),
937 GPMC_REVISION_MINOR(l)); 945 GPMC_REVISION_MINOR(l));
938 946
939 gpmc_mem_init(); 947 rc = gpmc_mem_init();
948 if (IS_ERR_VALUE(rc)) {
949 clk_disable_unprepare(gpmc_l3_clk);
950 clk_put(gpmc_l3_clk);
951 dev_err(gpmc_dev, "failed to reserve memory\n");
952 return rc;
953 }
940 954
941 if (IS_ERR_VALUE(gpmc_setup_irq())) 955 if (IS_ERR_VALUE(gpmc_setup_irq()))
942 dev_warn(gpmc_dev, "gpmc_setup_irq failed\n"); 956 dev_warn(gpmc_dev, "gpmc_setup_irq failed\n");
diff --git a/arch/arm/mach-omap2/mux34xx.c b/arch/arm/mach-omap2/mux34xx.c
index 17f80e4ab16..c47140bbbec 100644
--- a/arch/arm/mach-omap2/mux34xx.c
+++ b/arch/arm/mach-omap2/mux34xx.c
@@ -614,16 +614,16 @@ static struct omap_mux __initdata omap3_muxmodes[] = {
614 "sys_off_mode", NULL, NULL, NULL, 614 "sys_off_mode", NULL, NULL, NULL,
615 "gpio_9", NULL, NULL, "safe_mode"), 615 "gpio_9", NULL, NULL, "safe_mode"),
616 _OMAP3_MUXENTRY(UART1_CTS, 150, 616 _OMAP3_MUXENTRY(UART1_CTS, 150,
617 "uart1_cts", NULL, NULL, NULL, 617 "uart1_cts", "ssi1_rdy_tx", NULL, NULL,
618 "gpio_150", "hsusb3_tll_clk", NULL, "safe_mode"), 618 "gpio_150", "hsusb3_tll_clk", NULL, "safe_mode"),
619 _OMAP3_MUXENTRY(UART1_RTS, 149, 619 _OMAP3_MUXENTRY(UART1_RTS, 149,
620 "uart1_rts", NULL, NULL, NULL, 620 "uart1_rts", "ssi1_flag_tx", NULL, NULL,
621 "gpio_149", NULL, NULL, "safe_mode"), 621 "gpio_149", NULL, NULL, "safe_mode"),
622 _OMAP3_MUXENTRY(UART1_RX, 151, 622 _OMAP3_MUXENTRY(UART1_RX, 151,
623 "uart1_rx", NULL, "mcbsp1_clkr", "mcspi4_clk", 623 "uart1_rx", "ss1_wake_tx", "mcbsp1_clkr", "mcspi4_clk",
624 "gpio_151", NULL, NULL, "safe_mode"), 624 "gpio_151", NULL, NULL, "safe_mode"),
625 _OMAP3_MUXENTRY(UART1_TX, 148, 625 _OMAP3_MUXENTRY(UART1_TX, 148,
626 "uart1_tx", NULL, NULL, NULL, 626 "uart1_tx", "ssi1_dat_tx", NULL, NULL,
627 "gpio_148", NULL, NULL, "safe_mode"), 627 "gpio_148", NULL, NULL, "safe_mode"),
628 _OMAP3_MUXENTRY(UART2_CTS, 144, 628 _OMAP3_MUXENTRY(UART2_CTS, 144,
629 "uart2_cts", "mcbsp3_dx", "gpt9_pwm_evt", NULL, 629 "uart2_cts", "mcbsp3_dx", "gpt9_pwm_evt", NULL,
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index b969ab1d258..87cc6d058de 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -422,6 +422,38 @@ static int _set_softreset(struct omap_hwmod *oh, u32 *v)
422} 422}
423 423
424/** 424/**
425 * _wait_softreset_complete - wait for an OCP softreset to complete
426 * @oh: struct omap_hwmod * to wait on
427 *
428 * Wait until the IP block represented by @oh reports that its OCP
429 * softreset is complete. This can be triggered by software (see
430 * _ocp_softreset()) or by hardware upon returning from off-mode (one
431 * example is HSMMC). Waits for up to MAX_MODULE_SOFTRESET_WAIT
432 * microseconds. Returns the number of microseconds waited.
433 */
434static int _wait_softreset_complete(struct omap_hwmod *oh)
435{
436 struct omap_hwmod_class_sysconfig *sysc;
437 u32 softrst_mask;
438 int c = 0;
439
440 sysc = oh->class->sysc;
441
442 if (sysc->sysc_flags & SYSS_HAS_RESET_STATUS)
443 omap_test_timeout((omap_hwmod_read(oh, sysc->syss_offs)
444 & SYSS_RESETDONE_MASK),
445 MAX_MODULE_SOFTRESET_WAIT, c);
446 else if (sysc->sysc_flags & SYSC_HAS_RESET_STATUS) {
447 softrst_mask = (0x1 << sysc->sysc_fields->srst_shift);
448 omap_test_timeout(!(omap_hwmod_read(oh, sysc->sysc_offs)
449 & softrst_mask),
450 MAX_MODULE_SOFTRESET_WAIT, c);
451 }
452
453 return c;
454}
455
456/**
425 * _set_dmadisable: set OCP_SYSCONFIG.DMADISABLE bit in @v 457 * _set_dmadisable: set OCP_SYSCONFIG.DMADISABLE bit in @v
426 * @oh: struct omap_hwmod * 458 * @oh: struct omap_hwmod *
427 * 459 *
@@ -1282,6 +1314,18 @@ static void _enable_sysc(struct omap_hwmod *oh)
1282 if (!oh->class->sysc) 1314 if (!oh->class->sysc)
1283 return; 1315 return;
1284 1316
1317 /*
1318 * Wait until reset has completed, this is needed as the IP
1319 * block is reset automatically by hardware in some cases
1320 * (off-mode for example), and the drivers require the
1321 * IP to be ready when they access it
1322 */
1323 if (oh->flags & HWMOD_CONTROL_OPT_CLKS_IN_RESET)
1324 _enable_optional_clocks(oh);
1325 _wait_softreset_complete(oh);
1326 if (oh->flags & HWMOD_CONTROL_OPT_CLKS_IN_RESET)
1327 _disable_optional_clocks(oh);
1328
1285 v = oh->_sysc_cache; 1329 v = oh->_sysc_cache;
1286 sf = oh->class->sysc->sysc_flags; 1330 sf = oh->class->sysc->sysc_flags;
1287 1331
@@ -1804,7 +1848,7 @@ static int _am33xx_disable_module(struct omap_hwmod *oh)
1804 */ 1848 */
1805static int _ocp_softreset(struct omap_hwmod *oh) 1849static int _ocp_softreset(struct omap_hwmod *oh)
1806{ 1850{
1807 u32 v, softrst_mask; 1851 u32 v;
1808 int c = 0; 1852 int c = 0;
1809 int ret = 0; 1853 int ret = 0;
1810 1854
@@ -1834,19 +1878,7 @@ static int _ocp_softreset(struct omap_hwmod *oh)
1834 if (oh->class->sysc->srst_udelay) 1878 if (oh->class->sysc->srst_udelay)
1835 udelay(oh->class->sysc->srst_udelay); 1879 udelay(oh->class->sysc->srst_udelay);
1836 1880
1837 if (oh->class->sysc->sysc_flags & SYSS_HAS_RESET_STATUS) 1881 c = _wait_softreset_complete(oh);
1838 omap_test_timeout((omap_hwmod_read(oh,
1839 oh->class->sysc->syss_offs)
1840 & SYSS_RESETDONE_MASK),
1841 MAX_MODULE_SOFTRESET_WAIT, c);
1842 else if (oh->class->sysc->sysc_flags & SYSC_HAS_RESET_STATUS) {
1843 softrst_mask = (0x1 << oh->class->sysc->sysc_fields->srst_shift);
1844 omap_test_timeout(!(omap_hwmod_read(oh,
1845 oh->class->sysc->sysc_offs)
1846 & softrst_mask),
1847 MAX_MODULE_SOFTRESET_WAIT, c);
1848 }
1849
1850 if (c == MAX_MODULE_SOFTRESET_WAIT) 1882 if (c == MAX_MODULE_SOFTRESET_WAIT)
1851 pr_warning("omap_hwmod: %s: softreset failed (waited %d usec)\n", 1883 pr_warning("omap_hwmod: %s: softreset failed (waited %d usec)\n",
1852 oh->name, MAX_MODULE_SOFTRESET_WAIT); 1884 oh->name, MAX_MODULE_SOFTRESET_WAIT);
@@ -2352,6 +2384,9 @@ static int __init _setup_reset(struct omap_hwmod *oh)
2352 if (oh->_state != _HWMOD_STATE_INITIALIZED) 2384 if (oh->_state != _HWMOD_STATE_INITIALIZED)
2353 return -EINVAL; 2385 return -EINVAL;
2354 2386
2387 if (oh->flags & HWMOD_EXT_OPT_MAIN_CLK)
2388 return -EPERM;
2389
2355 if (oh->rst_lines_cnt == 0) { 2390 if (oh->rst_lines_cnt == 0) {
2356 r = _enable(oh); 2391 r = _enable(oh);
2357 if (r) { 2392 if (r) {
diff --git a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
index 652d0285bd6..0b1249e0039 100644
--- a/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_44xx_data.c
@@ -21,6 +21,7 @@
21#include <linux/io.h> 21#include <linux/io.h>
22#include <linux/platform_data/gpio-omap.h> 22#include <linux/platform_data/gpio-omap.h>
23#include <linux/power/smartreflex.h> 23#include <linux/power/smartreflex.h>
24#include <linux/platform_data/omap_ocp2scp.h>
24 25
25#include <plat/omap_hwmod.h> 26#include <plat/omap_hwmod.h>
26#include <plat/i2c.h> 27#include <plat/i2c.h>
@@ -2125,6 +2126,14 @@ static struct omap_hwmod omap44xx_mcpdm_hwmod = {
2125 .name = "mcpdm", 2126 .name = "mcpdm",
2126 .class = &omap44xx_mcpdm_hwmod_class, 2127 .class = &omap44xx_mcpdm_hwmod_class,
2127 .clkdm_name = "abe_clkdm", 2128 .clkdm_name = "abe_clkdm",
2129 /*
2130 * It's suspected that the McPDM requires an off-chip main
2131 * functional clock, controlled via I2C. This IP block is
2132 * currently reset very early during boot, before I2C is
2133 * available, so it doesn't seem that we have any choice in
2134 * the kernel other than to avoid resetting it.
2135 */
2136 .flags = HWMOD_EXT_OPT_MAIN_CLK,
2128 .mpu_irqs = omap44xx_mcpdm_irqs, 2137 .mpu_irqs = omap44xx_mcpdm_irqs,
2129 .sdma_reqs = omap44xx_mcpdm_sdma_reqs, 2138 .sdma_reqs = omap44xx_mcpdm_sdma_reqs,
2130 .main_clk = "mcpdm_fck", 2139 .main_clk = "mcpdm_fck",
@@ -2681,6 +2690,32 @@ static struct omap_hwmod_class omap44xx_ocp2scp_hwmod_class = {
2681 .sysc = &omap44xx_ocp2scp_sysc, 2690 .sysc = &omap44xx_ocp2scp_sysc,
2682}; 2691};
2683 2692
2693/* ocp2scp dev_attr */
2694static struct resource omap44xx_usb_phy_and_pll_addrs[] = {
2695 {
2696 .name = "usb_phy",
2697 .start = 0x4a0ad080,
2698 .end = 0x4a0ae000,
2699 .flags = IORESOURCE_MEM,
2700 },
2701 {
2702 /* XXX: Remove this once control module driver is in place */
2703 .name = "ctrl_dev",
2704 .start = 0x4a002300,
2705 .end = 0x4a002303,
2706 .flags = IORESOURCE_MEM,
2707 },
2708 { }
2709};
2710
2711static struct omap_ocp2scp_dev ocp2scp_dev_attr[] = {
2712 {
2713 .drv_name = "omap-usb2",
2714 .res = omap44xx_usb_phy_and_pll_addrs,
2715 },
2716 { }
2717};
2718
2684/* ocp2scp_usb_phy */ 2719/* ocp2scp_usb_phy */
2685static struct omap_hwmod omap44xx_ocp2scp_usb_phy_hwmod = { 2720static struct omap_hwmod omap44xx_ocp2scp_usb_phy_hwmod = {
2686 .name = "ocp2scp_usb_phy", 2721 .name = "ocp2scp_usb_phy",
@@ -2694,6 +2729,7 @@ static struct omap_hwmod omap44xx_ocp2scp_usb_phy_hwmod = {
2694 .modulemode = MODULEMODE_HWCTRL, 2729 .modulemode = MODULEMODE_HWCTRL,
2695 }, 2730 },
2696 }, 2731 },
2732 .dev_attr = ocp2scp_dev_attr,
2697}; 2733};
2698 2734
2699/* 2735/*
diff --git a/arch/arm/mach-omap2/pm.h b/arch/arm/mach-omap2/pm.h
index 686137d164d..67d66131cfa 100644
--- a/arch/arm/mach-omap2/pm.h
+++ b/arch/arm/mach-omap2/pm.h
@@ -91,6 +91,7 @@ extern void omap3_save_scratchpad_contents(void);
91 91
92#define PM_RTA_ERRATUM_i608 (1 << 0) 92#define PM_RTA_ERRATUM_i608 (1 << 0)
93#define PM_SDRC_WAKEUP_ERRATUM_i583 (1 << 1) 93#define PM_SDRC_WAKEUP_ERRATUM_i583 (1 << 1)
94#define PM_PER_MEMORIES_ERRATUM_i582 (1 << 2)
94 95
95#if defined(CONFIG_PM) && defined(CONFIG_ARCH_OMAP3) 96#if defined(CONFIG_PM) && defined(CONFIG_ARCH_OMAP3)
96extern u16 pm34xx_errata; 97extern u16 pm34xx_errata;
diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
index ba670db1fd3..3a904de4313 100644
--- a/arch/arm/mach-omap2/pm34xx.c
+++ b/arch/arm/mach-omap2/pm34xx.c
@@ -652,14 +652,17 @@ static void __init pm_errata_configure(void)
652 /* Enable the l2 cache toggling in sleep logic */ 652 /* Enable the l2 cache toggling in sleep logic */
653 enable_omap3630_toggle_l2_on_restore(); 653 enable_omap3630_toggle_l2_on_restore();
654 if (omap_rev() < OMAP3630_REV_ES1_2) 654 if (omap_rev() < OMAP3630_REV_ES1_2)
655 pm34xx_errata |= PM_SDRC_WAKEUP_ERRATUM_i583; 655 pm34xx_errata |= (PM_SDRC_WAKEUP_ERRATUM_i583 |
656 PM_PER_MEMORIES_ERRATUM_i582);
657 } else if (cpu_is_omap34xx()) {
658 pm34xx_errata |= PM_PER_MEMORIES_ERRATUM_i582;
656 } 659 }
657} 660}
658 661
659int __init omap3_pm_init(void) 662int __init omap3_pm_init(void)
660{ 663{
661 struct power_state *pwrst, *tmp; 664 struct power_state *pwrst, *tmp;
662 struct clockdomain *neon_clkdm, *mpu_clkdm; 665 struct clockdomain *neon_clkdm, *mpu_clkdm, *per_clkdm, *wkup_clkdm;
663 int ret; 666 int ret;
664 667
665 if (!omap3_has_io_chain_ctrl()) 668 if (!omap3_has_io_chain_ctrl())
@@ -711,6 +714,8 @@ int __init omap3_pm_init(void)
711 714
712 neon_clkdm = clkdm_lookup("neon_clkdm"); 715 neon_clkdm = clkdm_lookup("neon_clkdm");
713 mpu_clkdm = clkdm_lookup("mpu_clkdm"); 716 mpu_clkdm = clkdm_lookup("mpu_clkdm");
717 per_clkdm = clkdm_lookup("per_clkdm");
718 wkup_clkdm = clkdm_lookup("wkup_clkdm");
714 719
715#ifdef CONFIG_SUSPEND 720#ifdef CONFIG_SUSPEND
716 omap_pm_suspend = omap3_pm_suspend; 721 omap_pm_suspend = omap3_pm_suspend;
@@ -727,6 +732,27 @@ int __init omap3_pm_init(void)
727 if (IS_PM34XX_ERRATUM(PM_RTA_ERRATUM_i608)) 732 if (IS_PM34XX_ERRATUM(PM_RTA_ERRATUM_i608))
728 omap3630_ctrl_disable_rta(); 733 omap3630_ctrl_disable_rta();
729 734
735 /*
736 * The UART3/4 FIFO and the sidetone memory in McBSP2/3 are
737 * not correctly reset when the PER powerdomain comes back
738 * from OFF or OSWR when the CORE powerdomain is kept active.
739 * See OMAP36xx Erratum i582 "PER Domain reset issue after
740 * Domain-OFF/OSWR Wakeup". This wakeup dependency is not a
741 * complete workaround. The kernel must also prevent the PER
742 * powerdomain from going to OSWR/OFF while the CORE
743 * powerdomain is not going to OSWR/OFF. And if PER last
744 * power state was off while CORE last power state was ON, the
745 * UART3/4 and McBSP2/3 SIDETONE devices need to run a
746 * self-test using their loopback tests; if that fails, those
747 * devices are unusable until the PER/CORE can complete a transition
748 * from ON to OSWR/OFF and then back to ON.
749 *
750 * XXX Technically this workaround is only needed if off-mode
751 * or OSWR is enabled.
752 */
753 if (IS_PM34XX_ERRATUM(PM_PER_MEMORIES_ERRATUM_i582))
754 clkdm_add_wkdep(per_clkdm, wkup_clkdm);
755
730 clkdm_add_wkdep(neon_clkdm, mpu_clkdm); 756 clkdm_add_wkdep(neon_clkdm, mpu_clkdm);
731 if (omap_type() != OMAP2_DEVICE_TYPE_GP) { 757 if (omap_type() != OMAP2_DEVICE_TYPE_GP) {
732 omap3_secure_ram_storage = 758 omap3_secure_ram_storage =
diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 0405c819080..a507cd6cf4f 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -329,6 +329,11 @@ void __init omap_serial_init_port(struct omap_board_data *bdata,
329 329
330 oh->mux = omap_hwmod_mux_init(bdata->pads, bdata->pads_cnt); 330 oh->mux = omap_hwmod_mux_init(bdata->pads, bdata->pads_cnt);
331 331
332 if (console_uart_id == bdata->id) {
333 omap_device_enable(pdev);
334 pm_runtime_set_active(&pdev->dev);
335 }
336
332 oh->dev_attr = uart; 337 oh->dev_attr = uart;
333 338
334 if (((cpu_is_omap34xx() || cpu_is_omap44xx()) && bdata->pads) 339 if (((cpu_is_omap34xx() || cpu_is_omap44xx()) && bdata->pads)
diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c
index 44f9aa7ec0c..69e46631a7c 100644
--- a/arch/arm/mach-omap2/timer.c
+++ b/arch/arm/mach-omap2/timer.c
@@ -467,7 +467,7 @@ OMAP_SYS_TIMER(3_am33xx)
467#ifdef CONFIG_ARCH_OMAP4 467#ifdef CONFIG_ARCH_OMAP4
468#ifdef CONFIG_LOCAL_TIMERS 468#ifdef CONFIG_LOCAL_TIMERS
469static DEFINE_TWD_LOCAL_TIMER(twd_local_timer, 469static DEFINE_TWD_LOCAL_TIMER(twd_local_timer,
470 OMAP44XX_LOCAL_TWD_BASE, 29 + OMAP_INTC_START); 470 OMAP44XX_LOCAL_TWD_BASE, 29);
471#endif 471#endif
472 472
473static void __init omap4_timer_init(void) 473static void __init omap4_timer_init(void)
diff --git a/arch/arm/mach-omap2/twl-common.c b/arch/arm/mach-omap2/twl-common.c
index 635e109f5ad..a256135d8e4 100644
--- a/arch/arm/mach-omap2/twl-common.c
+++ b/arch/arm/mach-omap2/twl-common.c
@@ -73,6 +73,7 @@ void __init omap4_pmic_init(const char *pmic_type,
73{ 73{
74 /* PMIC part*/ 74 /* PMIC part*/
75 omap_mux_init_signal("sys_nirq1", OMAP_PIN_INPUT_PULLUP | OMAP_PIN_OFF_WAKEUPENABLE); 75 omap_mux_init_signal("sys_nirq1", OMAP_PIN_INPUT_PULLUP | OMAP_PIN_OFF_WAKEUPENABLE);
76 omap_mux_init_signal("fref_clk0_out.sys_drm_msecure", OMAP_PIN_OUTPUT);
76 omap_pmic_init(1, 400, pmic_type, 7 + OMAP44XX_IRQ_GIC_START, pmic_data); 77 omap_pmic_init(1, 400, pmic_type, 7 + OMAP44XX_IRQ_GIC_START, pmic_data);
77 78
78 /* Register additional devices on i2c1 bus if needed */ 79 /* Register additional devices on i2c1 bus if needed */
@@ -366,7 +367,7 @@ static struct regulator_init_data omap4_clk32kg_idata = {
366}; 367};
367 368
368static struct regulator_consumer_supply omap4_vdd1_supply[] = { 369static struct regulator_consumer_supply omap4_vdd1_supply[] = {
369 REGULATOR_SUPPLY("vcc", "mpu.0"), 370 REGULATOR_SUPPLY("vcc", "cpu0"),
370}; 371};
371 372
372static struct regulator_consumer_supply omap4_vdd2_supply[] = { 373static struct regulator_consumer_supply omap4_vdd2_supply[] = {
diff --git a/arch/arm/mach-omap2/vc.c b/arch/arm/mach-omap2/vc.c
index 880249b1701..75878c37959 100644
--- a/arch/arm/mach-omap2/vc.c
+++ b/arch/arm/mach-omap2/vc.c
@@ -264,7 +264,7 @@ static void __init omap_vc_i2c_init(struct voltagedomain *voltdm)
264 264
265 if (initialized) { 265 if (initialized) {
266 if (voltdm->pmic->i2c_high_speed != i2c_high_speed) 266 if (voltdm->pmic->i2c_high_speed != i2c_high_speed)
267 pr_warn("%s: I2C config for vdd_%s does not match other channels (%u).", 267 pr_warn("%s: I2C config for vdd_%s does not match other channels (%u).\n",
268 __func__, voltdm->name, i2c_high_speed); 268 __func__, voltdm->name, i2c_high_speed);
269 return; 269 return;
270 } 270 }
diff --git a/arch/arm/mach-prima2/include/mach/gpio.h b/arch/arm/mach-prima2/include/mach/gpio.h
deleted file mode 100644
index 1904bb03876..00000000000
--- a/arch/arm/mach-prima2/include/mach/gpio.h
+++ /dev/null
@@ -1,13 +0,0 @@
1#ifndef __MACH_GPIO_H
2#define __MACH_GPIO_H
3
4/* Pull up/down values */
5enum sirfsoc_gpio_pull {
6 SIRFSOC_GPIO_PULL_NONE,
7 SIRFSOC_GPIO_PULL_UP,
8 SIRFSOC_GPIO_PULL_DOWN,
9};
10
11void sirfsoc_gpio_set_pull(unsigned gpio, unsigned mode);
12
13#endif
diff --git a/arch/arm/mach-pxa/hx4700.c b/arch/arm/mach-pxa/hx4700.c
index 5ecbd17b564..e2c6391863f 100644
--- a/arch/arm/mach-pxa/hx4700.c
+++ b/arch/arm/mach-pxa/hx4700.c
@@ -28,6 +28,7 @@
28#include <linux/mfd/asic3.h> 28#include <linux/mfd/asic3.h>
29#include <linux/mtd/physmap.h> 29#include <linux/mtd/physmap.h>
30#include <linux/pda_power.h> 30#include <linux/pda_power.h>
31#include <linux/pwm.h>
31#include <linux/pwm_backlight.h> 32#include <linux/pwm_backlight.h>
32#include <linux/regulator/driver.h> 33#include <linux/regulator/driver.h>
33#include <linux/regulator/gpio-regulator.h> 34#include <linux/regulator/gpio-regulator.h>
@@ -556,7 +557,7 @@ static struct platform_device hx4700_lcd = {
556 */ 557 */
557 558
558static struct platform_pwm_backlight_data backlight_data = { 559static struct platform_pwm_backlight_data backlight_data = {
559 .pwm_id = 1, 560 .pwm_id = -1, /* Superseded by pwm_lookup */
560 .max_brightness = 200, 561 .max_brightness = 200,
561 .dft_brightness = 100, 562 .dft_brightness = 100,
562 .pwm_period_ns = 30923, 563 .pwm_period_ns = 30923,
@@ -571,6 +572,10 @@ static struct platform_device backlight = {
571 }, 572 },
572}; 573};
573 574
575static struct pwm_lookup hx4700_pwm_lookup[] = {
576 PWM_LOOKUP("pxa27x-pwm.1", 0, "pwm-backlight", NULL),
577};
578
574/* 579/*
575 * USB "Transceiver" 580 * USB "Transceiver"
576 */ 581 */
@@ -872,6 +877,7 @@ static void __init hx4700_init(void)
872 pxa_set_stuart_info(NULL); 877 pxa_set_stuart_info(NULL);
873 878
874 platform_add_devices(devices, ARRAY_SIZE(devices)); 879 platform_add_devices(devices, ARRAY_SIZE(devices));
880 pwm_add_table(hx4700_pwm_lookup, ARRAY_SIZE(hx4700_pwm_lookup));
875 881
876 pxa_set_ficp_info(&ficp_info); 882 pxa_set_ficp_info(&ficp_info);
877 pxa27x_set_i2c_power_info(NULL); 883 pxa27x_set_i2c_power_info(NULL);
diff --git a/arch/arm/mach-pxa/spitz_pm.c b/arch/arm/mach-pxa/spitz_pm.c
index 438f02fe122..842596d4d31 100644
--- a/arch/arm/mach-pxa/spitz_pm.c
+++ b/arch/arm/mach-pxa/spitz_pm.c
@@ -86,10 +86,7 @@ static void spitz_discharge1(int on)
86 gpio_set_value(SPITZ_GPIO_LED_GREEN, on); 86 gpio_set_value(SPITZ_GPIO_LED_GREEN, on);
87} 87}
88 88
89static unsigned long gpio18_config[] = { 89static unsigned long gpio18_config = GPIO18_GPIO;
90 GPIO18_RDY,
91 GPIO18_GPIO,
92};
93 90
94static void spitz_presuspend(void) 91static void spitz_presuspend(void)
95{ 92{
@@ -112,7 +109,7 @@ static void spitz_presuspend(void)
112 PGSR3 &= ~SPITZ_GPIO_G3_STROBE_BIT; 109 PGSR3 &= ~SPITZ_GPIO_G3_STROBE_BIT;
113 PGSR2 |= GPIO_bit(SPITZ_GPIO_KEY_STROBE0); 110 PGSR2 |= GPIO_bit(SPITZ_GPIO_KEY_STROBE0);
114 111
115 pxa2xx_mfp_config(&gpio18_config[0], 1); 112 pxa2xx_mfp_config(&gpio18_config, 1);
116 gpio_request_one(18, GPIOF_OUT_INIT_HIGH, "Unknown"); 113 gpio_request_one(18, GPIOF_OUT_INIT_HIGH, "Unknown");
117 gpio_free(18); 114 gpio_free(18);
118 115
@@ -131,7 +128,6 @@ static void spitz_presuspend(void)
131 128
132static void spitz_postsuspend(void) 129static void spitz_postsuspend(void)
133{ 130{
134 pxa2xx_mfp_config(&gpio18_config[1], 1);
135} 131}
136 132
137static int spitz_should_wakeup(unsigned int resume_on_alarm) 133static int spitz_should_wakeup(unsigned int resume_on_alarm)
diff --git a/arch/arm/mach-s3c24xx/clock-s3c2440.c b/arch/arm/mach-s3c24xx/clock-s3c2440.c
index 749220f91a7..4407b173053 100644
--- a/arch/arm/mach-s3c24xx/clock-s3c2440.c
+++ b/arch/arm/mach-s3c24xx/clock-s3c2440.c
@@ -163,7 +163,7 @@ static struct clk_lookup s3c2440_clk_lookup[] = {
163 CLKDEV_INIT(NULL, "clk_uart_baud3", &s3c2440_clk_fclk_n), 163 CLKDEV_INIT(NULL, "clk_uart_baud3", &s3c2440_clk_fclk_n),
164}; 164};
165 165
166static int s3c2440_clk_add(struct device *dev, struct subsys_interface *sif) 166static int __init_refok s3c2440_clk_add(struct device *dev, struct subsys_interface *sif)
167{ 167{
168 struct clk *clock_upll; 168 struct clk *clock_upll;
169 struct clk *clock_h; 169 struct clk *clock_h;
diff --git a/arch/arm/mach-s3c24xx/s3c2416.c b/arch/arm/mach-s3c24xx/s3c2416.c
index ed5a95ece9e..77ee0b73223 100644
--- a/arch/arm/mach-s3c24xx/s3c2416.c
+++ b/arch/arm/mach-s3c24xx/s3c2416.c
@@ -61,6 +61,7 @@
61#include <plat/nand-core.h> 61#include <plat/nand-core.h>
62#include <plat/adc-core.h> 62#include <plat/adc-core.h>
63#include <plat/rtc-core.h> 63#include <plat/rtc-core.h>
64#include <plat/spi-core.h>
64 65
65static struct map_desc s3c2416_iodesc[] __initdata = { 66static struct map_desc s3c2416_iodesc[] __initdata = {
66 IODESC_ENT(WATCHDOG), 67 IODESC_ENT(WATCHDOG),
@@ -132,6 +133,7 @@ void __init s3c2416_map_io(void)
132 /* initialize device information early */ 133 /* initialize device information early */
133 s3c2416_default_sdhci0(); 134 s3c2416_default_sdhci0();
134 s3c2416_default_sdhci1(); 135 s3c2416_default_sdhci1();
136 s3c64xx_spi_setname("s3c2443-spi");
135 137
136 iotable_init(s3c2416_iodesc, ARRAY_SIZE(s3c2416_iodesc)); 138 iotable_init(s3c2416_iodesc, ARRAY_SIZE(s3c2416_iodesc));
137} 139}
diff --git a/arch/arm/mach-s3c24xx/s3c2443.c b/arch/arm/mach-s3c24xx/s3c2443.c
index ab648ad8fa5..165b6a6b3da 100644
--- a/arch/arm/mach-s3c24xx/s3c2443.c
+++ b/arch/arm/mach-s3c24xx/s3c2443.c
@@ -43,6 +43,7 @@
43#include <plat/nand-core.h> 43#include <plat/nand-core.h>
44#include <plat/adc-core.h> 44#include <plat/adc-core.h>
45#include <plat/rtc-core.h> 45#include <plat/rtc-core.h>
46#include <plat/spi-core.h>
46 47
47static struct map_desc s3c2443_iodesc[] __initdata = { 48static struct map_desc s3c2443_iodesc[] __initdata = {
48 IODESC_ENT(WATCHDOG), 49 IODESC_ENT(WATCHDOG),
@@ -100,6 +101,9 @@ void __init s3c2443_map_io(void)
100 s3c24xx_gpiocfg_default.set_pull = s3c2443_gpio_setpull; 101 s3c24xx_gpiocfg_default.set_pull = s3c2443_gpio_setpull;
101 s3c24xx_gpiocfg_default.get_pull = s3c2443_gpio_getpull; 102 s3c24xx_gpiocfg_default.get_pull = s3c2443_gpio_getpull;
102 103
104 /* initialize device information early */
105 s3c64xx_spi_setname("s3c2443-spi");
106
103 iotable_init(s3c2443_iodesc, ARRAY_SIZE(s3c2443_iodesc)); 107 iotable_init(s3c2443_iodesc, ARRAY_SIZE(s3c2443_iodesc));
104} 108}
105 109
diff --git a/arch/arm/mach-s5p64x0/common.c b/arch/arm/mach-s5p64x0/common.c
index 6e6a0a9d677..111e404a81f 100644
--- a/arch/arm/mach-s5p64x0/common.c
+++ b/arch/arm/mach-s5p64x0/common.c
@@ -44,6 +44,7 @@
44#include <plat/sdhci.h> 44#include <plat/sdhci.h>
45#include <plat/adc-core.h> 45#include <plat/adc-core.h>
46#include <plat/fb-core.h> 46#include <plat/fb-core.h>
47#include <plat/spi-core.h>
47#include <plat/gpio-cfg.h> 48#include <plat/gpio-cfg.h>
48#include <plat/regs-irqtype.h> 49#include <plat/regs-irqtype.h>
49#include <plat/regs-serial.h> 50#include <plat/regs-serial.h>
@@ -179,6 +180,7 @@ void __init s5p6440_map_io(void)
179 /* initialize any device information early */ 180 /* initialize any device information early */
180 s3c_adc_setname("s3c64xx-adc"); 181 s3c_adc_setname("s3c64xx-adc");
181 s3c_fb_setname("s5p64x0-fb"); 182 s3c_fb_setname("s5p64x0-fb");
183 s3c64xx_spi_setname("s5p64x0-spi");
182 184
183 s5p64x0_default_sdhci0(); 185 s5p64x0_default_sdhci0();
184 s5p64x0_default_sdhci1(); 186 s5p64x0_default_sdhci1();
@@ -193,6 +195,7 @@ void __init s5p6450_map_io(void)
193 /* initialize any device information early */ 195 /* initialize any device information early */
194 s3c_adc_setname("s3c64xx-adc"); 196 s3c_adc_setname("s3c64xx-adc");
195 s3c_fb_setname("s5p64x0-fb"); 197 s3c_fb_setname("s5p64x0-fb");
198 s3c64xx_spi_setname("s5p64x0-spi");
196 199
197 s5p64x0_default_sdhci0(); 200 s5p64x0_default_sdhci0();
198 s5p64x0_default_sdhci1(); 201 s5p64x0_default_sdhci1();
diff --git a/arch/arm/mach-s5pc100/common.c b/arch/arm/mach-s5pc100/common.c
index 62190865886..cc6e561c995 100644
--- a/arch/arm/mach-s5pc100/common.c
+++ b/arch/arm/mach-s5pc100/common.c
@@ -45,6 +45,7 @@
45#include <plat/fb-core.h> 45#include <plat/fb-core.h>
46#include <plat/iic-core.h> 46#include <plat/iic-core.h>
47#include <plat/onenand-core.h> 47#include <plat/onenand-core.h>
48#include <plat/spi-core.h>
48#include <plat/regs-serial.h> 49#include <plat/regs-serial.h>
49#include <plat/watchdog-reset.h> 50#include <plat/watchdog-reset.h>
50 51
@@ -165,6 +166,8 @@ void __init s5pc100_map_io(void)
165 s3c_onenand_setname("s5pc100-onenand"); 166 s3c_onenand_setname("s5pc100-onenand");
166 s3c_fb_setname("s5pc100-fb"); 167 s3c_fb_setname("s5pc100-fb");
167 s3c_cfcon_setname("s5pc100-pata"); 168 s3c_cfcon_setname("s5pc100-pata");
169
170 s3c64xx_spi_setname("s5pc100-spi");
168} 171}
169 172
170void __init s5pc100_init_clocks(int xtal) 173void __init s5pc100_init_clocks(int xtal)
diff --git a/arch/arm/mach-s5pv210/common.c b/arch/arm/mach-s5pv210/common.c
index 4c9e9027df9..a0c50efe814 100644
--- a/arch/arm/mach-s5pv210/common.c
+++ b/arch/arm/mach-s5pv210/common.c
@@ -43,6 +43,7 @@
43#include <plat/iic-core.h> 43#include <plat/iic-core.h>
44#include <plat/keypad-core.h> 44#include <plat/keypad-core.h>
45#include <plat/tv-core.h> 45#include <plat/tv-core.h>
46#include <plat/spi-core.h>
46#include <plat/regs-serial.h> 47#include <plat/regs-serial.h>
47 48
48#include "common.h" 49#include "common.h"
@@ -196,6 +197,8 @@ void __init s5pv210_map_io(void)
196 197
197 /* setup TV devices */ 198 /* setup TV devices */
198 s5p_hdmi_setname("s5pv210-hdmi"); 199 s5p_hdmi_setname("s5pv210-hdmi");
200
201 s3c64xx_spi_setname("s5pv210-spi");
199} 202}
200 203
201void __init s5pv210_init_clocks(int xtal) 204void __init s5pv210_init_clocks(int xtal)
diff --git a/arch/arm/mach-shmobile/board-armadillo800eva.c b/arch/arm/mach-shmobile/board-armadillo800eva.c
index 2912eab3b96..3cc8b1c21da 100644
--- a/arch/arm/mach-shmobile/board-armadillo800eva.c
+++ b/arch/arm/mach-shmobile/board-armadillo800eva.c
@@ -1196,7 +1196,7 @@ static void __init eva_init(void)
1196 1196
1197#ifdef CONFIG_CACHE_L2X0 1197#ifdef CONFIG_CACHE_L2X0
1198 /* Early BRESP enable, Shared attribute override enable, 32K*8way */ 1198 /* Early BRESP enable, Shared attribute override enable, 32K*8way */
1199 l2x0_init(__io(0xf0002000), 0x40440000, 0x82000fff); 1199 l2x0_init(IOMEM(0xf0002000), 0x40440000, 0x82000fff);
1200#endif 1200#endif
1201 1201
1202 i2c_register_board_info(0, i2c0_devices, ARRAY_SIZE(i2c0_devices)); 1202 i2c_register_board_info(0, i2c0_devices, ARRAY_SIZE(i2c0_devices));
diff --git a/arch/arm/mach-shmobile/clock-r8a7779.c b/arch/arm/mach-shmobile/clock-r8a7779.c
index 3cafb6ab5e9..37b2a3133b3 100644
--- a/arch/arm/mach-shmobile/clock-r8a7779.c
+++ b/arch/arm/mach-shmobile/clock-r8a7779.c
@@ -24,17 +24,17 @@
24#include <linux/clkdev.h> 24#include <linux/clkdev.h>
25#include <mach/common.h> 25#include <mach/common.h>
26 26
27#define FRQMR 0xffc80014 27#define FRQMR IOMEM(0xffc80014)
28#define MSTPCR0 0xffc80030 28#define MSTPCR0 IOMEM(0xffc80030)
29#define MSTPCR1 0xffc80034 29#define MSTPCR1 IOMEM(0xffc80034)
30#define MSTPCR3 0xffc8003c 30#define MSTPCR3 IOMEM(0xffc8003c)
31#define MSTPSR1 0xffc80044 31#define MSTPSR1 IOMEM(0xffc80044)
32#define MSTPSR4 0xffc80048 32#define MSTPSR4 IOMEM(0xffc80048)
33#define MSTPSR6 0xffc8004c 33#define MSTPSR6 IOMEM(0xffc8004c)
34#define MSTPCR4 0xffc80050 34#define MSTPCR4 IOMEM(0xffc80050)
35#define MSTPCR5 0xffc80054 35#define MSTPCR5 IOMEM(0xffc80054)
36#define MSTPCR6 0xffc80058 36#define MSTPCR6 IOMEM(0xffc80058)
37#define MSTPCR7 0xffc80040 37#define MSTPCR7 IOMEM(0xffc80040)
38 38
39/* ioremap() through clock mapping mandatory to avoid 39/* ioremap() through clock mapping mandatory to avoid
40 * collision with ARM coherent DMA virtual memory range. 40 * collision with ARM coherent DMA virtual memory range.
diff --git a/arch/arm/mach-shmobile/setup-r8a7779.c b/arch/arm/mach-shmobile/setup-r8a7779.c
index 2917668f009..ebbffc25f24 100644
--- a/arch/arm/mach-shmobile/setup-r8a7779.c
+++ b/arch/arm/mach-shmobile/setup-r8a7779.c
@@ -247,7 +247,7 @@ void __init r8a7779_add_standard_devices(void)
247{ 247{
248#ifdef CONFIG_CACHE_L2X0 248#ifdef CONFIG_CACHE_L2X0
249 /* Early BRESP enable, Shared attribute override enable, 64K*16way */ 249 /* Early BRESP enable, Shared attribute override enable, 64K*16way */
250 l2x0_init((void __iomem __force *)(0xf0100000), 0x40470000, 0x82000fff); 250 l2x0_init(IOMEM(0xf0100000), 0x40470000, 0x82000fff);
251#endif 251#endif
252 r8a7779_pm_init(); 252 r8a7779_pm_init();
253 253
diff --git a/arch/arm/mach-spear13xx/include/mach/spear1310_misc_regs.h b/arch/arm/mach-spear13xx/include/mach/spear1310_misc_regs.h
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/arch/arm/mach-spear13xx/include/mach/spear1310_misc_regs.h
+++ /dev/null
diff --git a/arch/arm/mach-spear13xx/include/mach/spear1340_misc_regs.h b/arch/arm/mach-spear13xx/include/mach/spear1340_misc_regs.h
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/arch/arm/mach-spear13xx/include/mach/spear1340_misc_regs.h
+++ /dev/null
diff --git a/arch/arm/mach-tegra/board-dt-tegra20.c b/arch/arm/mach-tegra/board-dt-tegra20.c
index 57e235f4ac7..aa5325cd1c4 100644
--- a/arch/arm/mach-tegra/board-dt-tegra20.c
+++ b/arch/arm/mach-tegra/board-dt-tegra20.c
@@ -182,7 +182,7 @@ DT_MACHINE_START(TEGRA_DT, "nVidia Tegra20 (Flattened Device Tree)")
182 .init_early = tegra20_init_early, 182 .init_early = tegra20_init_early,
183 .init_irq = tegra_dt_init_irq, 183 .init_irq = tegra_dt_init_irq,
184 .handle_irq = gic_handle_irq, 184 .handle_irq = gic_handle_irq,
185 .timer = &tegra_timer, 185 .timer = &tegra_sys_timer,
186 .init_machine = tegra_dt_init, 186 .init_machine = tegra_dt_init,
187 .init_late = tegra_dt_init_late, 187 .init_late = tegra_dt_init_late,
188 .restart = tegra_assert_system_reset, 188 .restart = tegra_assert_system_reset,
diff --git a/arch/arm/mach-tegra/board-dt-tegra30.c b/arch/arm/mach-tegra/board-dt-tegra30.c
index e4a676d4ddf..5e92a81f9a2 100644
--- a/arch/arm/mach-tegra/board-dt-tegra30.c
+++ b/arch/arm/mach-tegra/board-dt-tegra30.c
@@ -89,7 +89,7 @@ DT_MACHINE_START(TEGRA30_DT, "NVIDIA Tegra30 (Flattened Device Tree)")
89 .init_early = tegra30_init_early, 89 .init_early = tegra30_init_early,
90 .init_irq = tegra_dt_init_irq, 90 .init_irq = tegra_dt_init_irq,
91 .handle_irq = gic_handle_irq, 91 .handle_irq = gic_handle_irq,
92 .timer = &tegra_timer, 92 .timer = &tegra_sys_timer,
93 .init_machine = tegra30_dt_init, 93 .init_machine = tegra30_dt_init,
94 .init_late = tegra_init_late, 94 .init_late = tegra_init_late,
95 .restart = tegra_assert_system_reset, 95 .restart = tegra_assert_system_reset,
diff --git a/arch/arm/mach-tegra/board.h b/arch/arm/mach-tegra/board.h
index f88e5143c76..91fbe733a21 100644
--- a/arch/arm/mach-tegra/board.h
+++ b/arch/arm/mach-tegra/board.h
@@ -55,5 +55,5 @@ static inline int harmony_pcie_init(void) { return 0; }
55 55
56void __init tegra_paz00_wifikill_init(void); 56void __init tegra_paz00_wifikill_init(void);
57 57
58extern struct sys_timer tegra_timer; 58extern struct sys_timer tegra_sys_timer;
59#endif 59#endif
diff --git a/arch/arm/mach-tegra/tegra20_clocks_data.c b/arch/arm/mach-tegra/tegra20_clocks_data.c
index cc9b5fd8c3d..8d398a33adf 100644
--- a/arch/arm/mach-tegra/tegra20_clocks_data.c
+++ b/arch/arm/mach-tegra/tegra20_clocks_data.c
@@ -953,6 +953,7 @@ PERIPH_CLK(pcie_xclk, NULL, "pcie_xclk", 74, 0, 26000000, mux_clk_m,
953static struct clk *tegra_list_clks[] = { 953static struct clk *tegra_list_clks[] = {
954 &tegra_apbdma, 954 &tegra_apbdma,
955 &tegra_rtc, 955 &tegra_rtc,
956 &tegra_timer,
956 &tegra_i2s1, 957 &tegra_i2s1,
957 &tegra_i2s2, 958 &tegra_i2s2,
958 &tegra_spdif_out, 959 &tegra_spdif_out,
diff --git a/arch/arm/mach-tegra/tegra30_clocks.c b/arch/arm/mach-tegra/tegra30_clocks.c
index 5cd502c2716..e9de5dfd94e 100644
--- a/arch/arm/mach-tegra/tegra30_clocks.c
+++ b/arch/arm/mach-tegra/tegra30_clocks.c
@@ -1199,7 +1199,7 @@ static long tegra30_pll_round_rate(struct clk_hw *hw, unsigned long rate,
1199{ 1199{
1200 struct clk_tegra *c = to_clk_tegra(hw); 1200 struct clk_tegra *c = to_clk_tegra(hw);
1201 unsigned long input_rate = *prate; 1201 unsigned long input_rate = *prate;
1202 unsigned long output_rate = *prate; 1202 u64 output_rate = *prate;
1203 const struct clk_pll_freq_table *sel; 1203 const struct clk_pll_freq_table *sel;
1204 struct clk_pll_freq_table cfg; 1204 struct clk_pll_freq_table cfg;
1205 int mul; 1205 int mul;
diff --git a/arch/arm/mach-tegra/tegra30_clocks_data.c b/arch/arm/mach-tegra/tegra30_clocks_data.c
index d92cb556ae3..3d2e5532a9e 100644
--- a/arch/arm/mach-tegra/tegra30_clocks_data.c
+++ b/arch/arm/mach-tegra/tegra30_clocks_data.c
@@ -1143,6 +1143,7 @@ struct clk *tegra_list_clks[] = {
1143 &tegra_apbdma, 1143 &tegra_apbdma,
1144 &tegra_rtc, 1144 &tegra_rtc,
1145 &tegra_kbc, 1145 &tegra_kbc,
1146 &tegra_timer,
1146 &tegra_kfuse, 1147 &tegra_kfuse,
1147 &tegra_fuse, 1148 &tegra_fuse,
1148 &tegra_fuse_burn, 1149 &tegra_fuse_burn,
diff --git a/arch/arm/mach-tegra/timer.c b/arch/arm/mach-tegra/timer.c
index eccdce98304..d3b8c8e7368 100644
--- a/arch/arm/mach-tegra/timer.c
+++ b/arch/arm/mach-tegra/timer.c
@@ -245,7 +245,7 @@ static void __init tegra_init_timer(void)
245 register_persistent_clock(NULL, tegra_read_persistent_clock); 245 register_persistent_clock(NULL, tegra_read_persistent_clock);
246} 246}
247 247
248struct sys_timer tegra_timer = { 248struct sys_timer tegra_sys_timer = {
249 .init = tegra_init_timer, 249 .init = tegra_init_timer,
250}; 250};
251 251
diff --git a/arch/arm/mach-ux500/cpu.c b/arch/arm/mach-ux500/cpu.c
index 2236cbd03cd..1f3fbc2bb77 100644
--- a/arch/arm/mach-ux500/cpu.c
+++ b/arch/arm/mach-ux500/cpu.c
@@ -16,6 +16,7 @@
16#include <linux/stat.h> 16#include <linux/stat.h>
17#include <linux/of.h> 17#include <linux/of.h>
18#include <linux/of_irq.h> 18#include <linux/of_irq.h>
19#include <linux/irq.h>
19#include <linux/platform_data/clk-ux500.h> 20#include <linux/platform_data/clk-ux500.h>
20 21
21#include <asm/hardware/gic.h> 22#include <asm/hardware/gic.h>
diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
index b9f60ebe3bc..b820edaf318 100644
--- a/arch/arm/mm/alignment.c
+++ b/arch/arm/mm/alignment.c
@@ -745,7 +745,7 @@ do_alignment_t32_to_handler(unsigned long *pinstr, struct pt_regs *regs,
745static int 745static int
746do_alignment(unsigned long addr, unsigned int fsr, struct pt_regs *regs) 746do_alignment(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
747{ 747{
748 union offset_union offset; 748 union offset_union uninitialized_var(offset);
749 unsigned long instr = 0, instrptr; 749 unsigned long instr = 0, instrptr;
750 int (*handler)(unsigned long addr, unsigned long instr, struct pt_regs *regs); 750 int (*handler)(unsigned long addr, unsigned long instr, struct pt_regs *regs);
751 unsigned int type; 751 unsigned int type;
@@ -856,8 +856,10 @@ do_alignment(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
856 if (thumb2_32b) { 856 if (thumb2_32b) {
857 offset.un = 0; 857 offset.un = 0;
858 handler = do_alignment_t32_to_handler(&instr, regs, &offset); 858 handler = do_alignment_t32_to_handler(&instr, regs, &offset);
859 } else 859 } else {
860 offset.un = 0;
860 handler = do_alignment_ldmstm; 861 handler = do_alignment_ldmstm;
862 }
861 break; 863 break;
862 864
863 default: 865 default:
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index 477a2d23ddf..58bc3e4d3bd 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -610,7 +610,7 @@ static void *__dma_alloc(struct device *dev, size_t size, dma_addr_t *handle,
610 gfp_t gfp, pgprot_t prot, bool is_coherent, const void *caller) 610 gfp_t gfp, pgprot_t prot, bool is_coherent, const void *caller)
611{ 611{
612 u64 mask = get_coherent_dma_mask(dev); 612 u64 mask = get_coherent_dma_mask(dev);
613 struct page *page; 613 struct page *page = NULL;
614 void *addr; 614 void *addr;
615 615
616#ifdef CONFIG_DMA_API_DEBUG 616#ifdef CONFIG_DMA_API_DEBUG
diff --git a/arch/arm/mm/vmregion.h b/arch/arm/mm/vmregion.h
index bf312c354a2..0f5a5f2a2c7 100644
--- a/arch/arm/mm/vmregion.h
+++ b/arch/arm/mm/vmregion.h
@@ -17,7 +17,6 @@ struct arm_vmregion {
17 struct list_head vm_list; 17 struct list_head vm_list;
18 unsigned long vm_start; 18 unsigned long vm_start;
19 unsigned long vm_end; 19 unsigned long vm_end;
20 void *priv;
21 int vm_active; 20 int vm_active;
22 const void *caller; 21 const void *caller;
23}; 22};
diff --git a/arch/arm/plat-mxc/devices/platform-mxc-mmc.c b/arch/arm/plat-mxc/devices/platform-mxc-mmc.c
index 540d3a7d92d..e7b920b5867 100644
--- a/arch/arm/plat-mxc/devices/platform-mxc-mmc.c
+++ b/arch/arm/plat-mxc/devices/platform-mxc-mmc.c
@@ -55,7 +55,7 @@ struct platform_device *__init imx_add_mxc_mmc(
55 struct resource res[] = { 55 struct resource res[] = {
56 { 56 {
57 .start = data->iobase, 57 .start = data->iobase,
58 .end = data->iobase + SZ_4K - 1, 58 .end = data->iobase + data->iosize - 1,
59 .flags = IORESOURCE_MEM, 59 .flags = IORESOURCE_MEM,
60 }, { 60 }, {
61 .start = data->irq, 61 .start = data->irq,
diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig
index 7cd56ed5cd9..82fcb206b5b 100644
--- a/arch/arm/plat-omap/Kconfig
+++ b/arch/arm/plat-omap/Kconfig
@@ -26,6 +26,7 @@ config ARCH_OMAP2PLUS
26 select CLKDEV_LOOKUP 26 select CLKDEV_LOOKUP
27 select GENERIC_IRQ_CHIP 27 select GENERIC_IRQ_CHIP
28 select OMAP_DM_TIMER 28 select OMAP_DM_TIMER
29 select PINCTRL
29 select PROC_DEVICETREE if PROC_FS 30 select PROC_DEVICETREE if PROC_FS
30 select SPARSE_IRQ 31 select SPARSE_IRQ
31 select USE_OF 32 select USE_OF
diff --git a/arch/arm/plat-omap/debug-devices.c b/arch/arm/plat-omap/debug-devices.c
index c7a4c0902b3..5a4678edd65 100644
--- a/arch/arm/plat-omap/debug-devices.c
+++ b/arch/arm/plat-omap/debug-devices.c
@@ -16,6 +16,7 @@
16#include <linux/smc91x.h> 16#include <linux/smc91x.h>
17 17
18#include <mach/hardware.h> 18#include <mach/hardware.h>
19#include "../mach-omap2/debug-devices.h"
19 20
20/* Many OMAP development platforms reuse the same "debug board"; these 21/* Many OMAP development platforms reuse the same "debug board"; these
21 * platforms include H2, H3, H4, and Perseus2. 22 * platforms include H2, H3, H4, and Perseus2.
diff --git a/arch/arm/plat-omap/i2c.c b/arch/arm/plat-omap/i2c.c
index a5683a84c6e..6013831a043 100644
--- a/arch/arm/plat-omap/i2c.c
+++ b/arch/arm/plat-omap/i2c.c
@@ -26,12 +26,14 @@
26#include <linux/kernel.h> 26#include <linux/kernel.h>
27#include <linux/platform_device.h> 27#include <linux/platform_device.h>
28#include <linux/i2c.h> 28#include <linux/i2c.h>
29#include <linux/i2c-omap.h>
29#include <linux/slab.h> 30#include <linux/slab.h>
30#include <linux/err.h> 31#include <linux/err.h>
31#include <linux/clk.h> 32#include <linux/clk.h>
32 33
33#include <mach/irqs.h> 34#include <mach/irqs.h>
34#include <plat/i2c.h> 35#include <plat/i2c.h>
36#include <plat/omap-pm.h>
35#include <plat/omap_device.h> 37#include <plat/omap_device.h>
36 38
37#define OMAP_I2C_SIZE 0x3f 39#define OMAP_I2C_SIZE 0x3f
@@ -127,6 +129,16 @@ static inline int omap1_i2c_add_bus(int bus_id)
127 129
128 130
129#ifdef CONFIG_ARCH_OMAP2PLUS 131#ifdef CONFIG_ARCH_OMAP2PLUS
132/*
133 * XXX This function is a temporary compatibility wrapper - only
134 * needed until the I2C driver can be converted to call
135 * omap_pm_set_max_dev_wakeup_lat() and handle a return code.
136 */
137static void omap_pm_set_max_mpu_wakeup_lat_compat(struct device *dev, long t)
138{
139 omap_pm_set_max_mpu_wakeup_lat(dev, t);
140}
141
130static inline int omap2_i2c_add_bus(int bus_id) 142static inline int omap2_i2c_add_bus(int bus_id)
131{ 143{
132 int l; 144 int l;
@@ -158,6 +170,15 @@ static inline int omap2_i2c_add_bus(int bus_id)
158 dev_attr = (struct omap_i2c_dev_attr *)oh->dev_attr; 170 dev_attr = (struct omap_i2c_dev_attr *)oh->dev_attr;
159 pdata->flags = dev_attr->flags; 171 pdata->flags = dev_attr->flags;
160 172
173 /*
174 * When waiting for completion of a i2c transfer, we need to
175 * set a wake up latency constraint for the MPU. This is to
176 * ensure quick enough wakeup from idle, when transfer
177 * completes.
178 * Only omap3 has support for constraints
179 */
180 if (cpu_is_omap34xx())
181 pdata->set_mpu_wkup_lat = omap_pm_set_max_mpu_wakeup_lat_compat;
161 pdev = omap_device_build(name, bus_id, oh, pdata, 182 pdev = omap_device_build(name, bus_id, oh, pdata,
162 sizeof(struct omap_i2c_bus_platform_data), 183 sizeof(struct omap_i2c_bus_platform_data),
163 NULL, 0, 0); 184 NULL, 0, 0);
diff --git a/arch/arm/plat-omap/include/plat/omap-serial.h b/arch/arm/plat-omap/include/plat/omap-serial.h
index f4a4cd01479..1957a8516e9 100644
--- a/arch/arm/plat-omap/include/plat/omap-serial.h
+++ b/arch/arm/plat-omap/include/plat/omap-serial.h
@@ -40,10 +40,10 @@
40#define OMAP_UART_WER_MOD_WKUP 0X7F 40#define OMAP_UART_WER_MOD_WKUP 0X7F
41 41
42/* Enable XON/XOFF flow control on output */ 42/* Enable XON/XOFF flow control on output */
43#define OMAP_UART_SW_TX 0x8 43#define OMAP_UART_SW_TX 0x04
44 44
45/* Enable XON/XOFF flow control on input */ 45/* Enable XON/XOFF flow control on input */
46#define OMAP_UART_SW_RX 0x2 46#define OMAP_UART_SW_RX 0x04
47 47
48#define OMAP_UART_SYSC_RESET 0X07 48#define OMAP_UART_SYSC_RESET 0X07
49#define OMAP_UART_TCR_TRIG 0X0F 49#define OMAP_UART_TCR_TRIG 0X0F
diff --git a/arch/arm/plat-omap/include/plat/omap_hwmod.h b/arch/arm/plat-omap/include/plat/omap_hwmod.h
index b3349f7b1a2..1db02943802 100644
--- a/arch/arm/plat-omap/include/plat/omap_hwmod.h
+++ b/arch/arm/plat-omap/include/plat/omap_hwmod.h
@@ -443,6 +443,11 @@ struct omap_hwmod_omap4_prcm {
443 * in order to complete the reset. Optional clocks will be disabled 443 * in order to complete the reset. Optional clocks will be disabled
444 * again after the reset. 444 * again after the reset.
445 * HWMOD_16BIT_REG: Module has 16bit registers 445 * HWMOD_16BIT_REG: Module has 16bit registers
446 * HWMOD_EXT_OPT_MAIN_CLK: The only main functional clock source for
447 * this IP block comes from an off-chip source and is not always
448 * enabled. This prevents the hwmod code from being able to
449 * enable and reset the IP block early. XXX Eventually it should
450 * be possible to query the clock framework for this information.
446 */ 451 */
447#define HWMOD_SWSUP_SIDLE (1 << 0) 452#define HWMOD_SWSUP_SIDLE (1 << 0)
448#define HWMOD_SWSUP_MSTANDBY (1 << 1) 453#define HWMOD_SWSUP_MSTANDBY (1 << 1)
@@ -453,6 +458,7 @@ struct omap_hwmod_omap4_prcm {
453#define HWMOD_NO_IDLEST (1 << 6) 458#define HWMOD_NO_IDLEST (1 << 6)
454#define HWMOD_CONTROL_OPT_CLKS_IN_RESET (1 << 7) 459#define HWMOD_CONTROL_OPT_CLKS_IN_RESET (1 << 7)
455#define HWMOD_16BIT_REG (1 << 8) 460#define HWMOD_16BIT_REG (1 << 8)
461#define HWMOD_EXT_OPT_MAIN_CLK (1 << 9)
456 462
457/* 463/*
458 * omap_hwmod._int_flags definitions 464 * omap_hwmod._int_flags definitions
diff --git a/arch/arm/plat-samsung/include/plat/spi-core.h b/arch/arm/plat-samsung/include/plat/spi-core.h
new file mode 100644
index 00000000000..0b9428ab3fc
--- /dev/null
+++ b/arch/arm/plat-samsung/include/plat/spi-core.h
@@ -0,0 +1,30 @@
1/*
2 * Copyright (C) 2012 Heiko Stuebner <heiko@sntech.de>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8
9#ifndef __PLAT_S3C_SPI_CORE_H
10#define __PLAT_S3C_SPI_CORE_H
11
12/* These functions are only for use with the core support code, such as
13 * the cpu specific initialisation code
14 */
15
16/* re-define device name depending on support. */
17static inline void s3c64xx_spi_setname(char *name)
18{
19#ifdef CONFIG_S3C64XX_DEV_SPI0
20 s3c64xx_device_spi0.name = name;
21#endif
22#ifdef CONFIG_S3C64XX_DEV_SPI1
23 s3c64xx_device_spi1.name = name;
24#endif
25#ifdef CONFIG_S3C64XX_DEV_SPI2
26 s3c64xx_device_spi2.name = name;
27#endif
28}
29
30#endif /* __PLAT_S3C_SPI_CORE_H */
diff --git a/arch/arm/tools/Makefile b/arch/arm/tools/Makefile
index 635cb1865e4..32d05c8219d 100644
--- a/arch/arm/tools/Makefile
+++ b/arch/arm/tools/Makefile
@@ -5,6 +5,6 @@
5# 5#
6 6
7include/generated/mach-types.h: $(src)/gen-mach-types $(src)/mach-types 7include/generated/mach-types.h: $(src)/gen-mach-types $(src)/mach-types
8 @echo ' Generating $@' 8 @$(kecho) ' Generating $@'
9 @mkdir -p $(dir $@) 9 @mkdir -p $(dir $@)
10 $(Q)$(AWK) -f $^ > $@ || { rm -f $@; /bin/false; } 10 $(Q)$(AWK) -f $^ > $@ || { rm -f $@; /bin/false; }
diff --git a/arch/arm/vfp/vfpmodule.c b/arch/arm/vfp/vfpmodule.c
index c834b32af27..3b44e0dd0a9 100644
--- a/arch/arm/vfp/vfpmodule.c
+++ b/arch/arm/vfp/vfpmodule.c
@@ -701,11 +701,14 @@ static int __init vfp_init(void)
701 elf_hwcap |= HWCAP_VFPv3; 701 elf_hwcap |= HWCAP_VFPv3;
702 702
703 /* 703 /*
704 * Check for VFPv3 D16. CPUs in this configuration 704 * Check for VFPv3 D16 and VFPv4 D16. CPUs in
705 * only have 16 x 64bit registers. 705 * this configuration only have 16 x 64bit
706 * registers.
706 */ 707 */
707 if (((fmrx(MVFR0) & MVFR0_A_SIMD_MASK)) == 1) 708 if (((fmrx(MVFR0) & MVFR0_A_SIMD_MASK)) == 1)
708 elf_hwcap |= HWCAP_VFPv3D16; 709 elf_hwcap |= HWCAP_VFPv3D16; /* also v4-D16 */
710 else
711 elf_hwcap |= HWCAP_VFPD32;
709 } 712 }
710#endif 713#endif
711 /* 714 /*
diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
index 59bcb96ac36..f5760927544 100644
--- a/arch/arm/xen/enlighten.c
+++ b/arch/arm/xen/enlighten.c
@@ -166,3 +166,14 @@ void free_xenballooned_pages(int nr_pages, struct page **pages)
166 *pages = NULL; 166 *pages = NULL;
167} 167}
168EXPORT_SYMBOL_GPL(free_xenballooned_pages); 168EXPORT_SYMBOL_GPL(free_xenballooned_pages);
169
170/* In the hypervisor.S file. */
171EXPORT_SYMBOL_GPL(HYPERVISOR_event_channel_op);
172EXPORT_SYMBOL_GPL(HYPERVISOR_grant_table_op);
173EXPORT_SYMBOL_GPL(HYPERVISOR_xen_version);
174EXPORT_SYMBOL_GPL(HYPERVISOR_console_io);
175EXPORT_SYMBOL_GPL(HYPERVISOR_sched_op);
176EXPORT_SYMBOL_GPL(HYPERVISOR_hvm_op);
177EXPORT_SYMBOL_GPL(HYPERVISOR_memory_op);
178EXPORT_SYMBOL_GPL(HYPERVISOR_physdev_op);
179EXPORT_SYMBOL_GPL(privcmd_call);
diff --git a/arch/arm/xen/grant-table.c b/arch/arm/xen/grant-table.c
index dbd1330c019..859a9bb002d 100644
--- a/arch/arm/xen/grant-table.c
+++ b/arch/arm/xen/grant-table.c
@@ -33,7 +33,7 @@
33#include <xen/page.h> 33#include <xen/page.h>
34#include <xen/grant_table.h> 34#include <xen/grant_table.h>
35 35
36int arch_gnttab_map_shared(unsigned long *frames, unsigned long nr_gframes, 36int arch_gnttab_map_shared(xen_pfn_t *frames, unsigned long nr_gframes,
37 unsigned long max_nr_gframes, 37 unsigned long max_nr_gframes,
38 void **__shared) 38 void **__shared)
39{ 39{
diff --git a/arch/arm/xen/hypercall.S b/arch/arm/xen/hypercall.S
index 074f5ed101b..71f723984cb 100644
--- a/arch/arm/xen/hypercall.S
+++ b/arch/arm/xen/hypercall.S
@@ -48,20 +48,16 @@
48 48
49#include <linux/linkage.h> 49#include <linux/linkage.h>
50#include <asm/assembler.h> 50#include <asm/assembler.h>
51#include <asm/opcodes-virt.h>
51#include <xen/interface/xen.h> 52#include <xen/interface/xen.h>
52 53
53 54
54/* HVC 0xEA1 */ 55#define XEN_IMM 0xEA1
55#ifdef CONFIG_THUMB2_KERNEL
56#define xen_hvc .word 0xf7e08ea1
57#else
58#define xen_hvc .word 0xe140ea71
59#endif
60 56
61#define HYPERCALL_SIMPLE(hypercall) \ 57#define HYPERCALL_SIMPLE(hypercall) \
62ENTRY(HYPERVISOR_##hypercall) \ 58ENTRY(HYPERVISOR_##hypercall) \
63 mov r12, #__HYPERVISOR_##hypercall; \ 59 mov r12, #__HYPERVISOR_##hypercall; \
64 xen_hvc; \ 60 __HVC(XEN_IMM); \
65 mov pc, lr; \ 61 mov pc, lr; \
66ENDPROC(HYPERVISOR_##hypercall) 62ENDPROC(HYPERVISOR_##hypercall)
67 63
@@ -76,7 +72,7 @@ ENTRY(HYPERVISOR_##hypercall) \
76 stmdb sp!, {r4} \ 72 stmdb sp!, {r4} \
77 ldr r4, [sp, #4] \ 73 ldr r4, [sp, #4] \
78 mov r12, #__HYPERVISOR_##hypercall; \ 74 mov r12, #__HYPERVISOR_##hypercall; \
79 xen_hvc \ 75 __HVC(XEN_IMM); \
80 ldm sp!, {r4} \ 76 ldm sp!, {r4} \
81 mov pc, lr \ 77 mov pc, lr \
82ENDPROC(HYPERVISOR_##hypercall) 78ENDPROC(HYPERVISOR_##hypercall)
@@ -100,7 +96,7 @@ ENTRY(privcmd_call)
100 mov r2, r3 96 mov r2, r3
101 ldr r3, [sp, #8] 97 ldr r3, [sp, #8]
102 ldr r4, [sp, #4] 98 ldr r4, [sp, #4]
103 xen_hvc 99 __HVC(XEN_IMM)
104 ldm sp!, {r4} 100 ldm sp!, {r4}
105 mov pc, lr 101 mov pc, lr
106ENDPROC(privcmd_call); 102ENDPROC(privcmd_call);
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 7ff68c94607..20b688c8195 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -1,11 +1,14 @@
1config ARM64 1config ARM64
2 def_bool y 2 def_bool y
3 select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE 3 select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
4 select ARCH_WANT_COMPAT_IPC_PARSE_VERSION
4 select GENERIC_CLOCKEVENTS 5 select GENERIC_CLOCKEVENTS
5 select GENERIC_HARDIRQS_NO_DEPRECATED 6 select GENERIC_HARDIRQS_NO_DEPRECATED
6 select GENERIC_IOMAP 7 select GENERIC_IOMAP
7 select GENERIC_IRQ_PROBE 8 select GENERIC_IRQ_PROBE
8 select GENERIC_IRQ_SHOW 9 select GENERIC_IRQ_SHOW
10 select GENERIC_KERNEL_EXECVE
11 select GENERIC_KERNEL_THREAD
9 select GENERIC_SMP_IDLE_THREAD 12 select GENERIC_SMP_IDLE_THREAD
10 select GENERIC_TIME_VSYSCALL 13 select GENERIC_TIME_VSYSCALL
11 select HARDIRQS_SW_RESEND 14 select HARDIRQS_SW_RESEND
@@ -22,6 +25,7 @@ config ARM64
22 select HAVE_PERF_EVENTS 25 select HAVE_PERF_EVENTS
23 select HAVE_SPARSE_IRQ 26 select HAVE_SPARSE_IRQ
24 select IRQ_DOMAIN 27 select IRQ_DOMAIN
28 select MODULES_USE_ELF_RELA
25 select NO_BOOTMEM 29 select NO_BOOTMEM
26 select OF 30 select OF
27 select OF_EARLY_FLATTREE 31 select OF_EARLY_FLATTREE
diff --git a/arch/arm64/include/asm/Kbuild b/arch/arm64/include/asm/Kbuild
index fe77e51a784..a581a220593 100644
--- a/arch/arm64/include/asm/Kbuild
+++ b/arch/arm64/include/asm/Kbuild
@@ -18,7 +18,6 @@ generic-y += ipcbuf.h
18generic-y += irq_regs.h 18generic-y += irq_regs.h
19generic-y += kdebug.h 19generic-y += kdebug.h
20generic-y += kmap_types.h 20generic-y += kmap_types.h
21generic-y += linkage.h
22generic-y += local.h 21generic-y += local.h
23generic-y += local64.h 22generic-y += local64.h
24generic-y += mman.h 23generic-y += mman.h
diff --git a/arch/arm64/include/asm/elf.h b/arch/arm64/include/asm/elf.h
index cf284649dfc..07fea290d7c 100644
--- a/arch/arm64/include/asm/elf.h
+++ b/arch/arm64/include/asm/elf.h
@@ -25,12 +25,10 @@
25#include <asm/user.h> 25#include <asm/user.h>
26 26
27typedef unsigned long elf_greg_t; 27typedef unsigned long elf_greg_t;
28typedef unsigned long elf_freg_t[3];
29 28
30#define ELF_NGREG (sizeof (struct pt_regs) / sizeof(elf_greg_t)) 29#define ELF_NGREG (sizeof (struct pt_regs) / sizeof(elf_greg_t))
31typedef elf_greg_t elf_gregset_t[ELF_NGREG]; 30typedef elf_greg_t elf_gregset_t[ELF_NGREG];
32 31typedef struct user_fpsimd_state elf_fpregset_t;
33typedef struct user_fp elf_fpregset_t;
34 32
35#define EM_AARCH64 183 33#define EM_AARCH64 183
36 34
@@ -87,7 +85,6 @@ typedef struct user_fp elf_fpregset_t;
87#define R_AARCH64_MOVW_PREL_G2_NC 292 85#define R_AARCH64_MOVW_PREL_G2_NC 292
88#define R_AARCH64_MOVW_PREL_G3 293 86#define R_AARCH64_MOVW_PREL_G3 293
89 87
90
91/* 88/*
92 * These are used to set parameters in the core dumps. 89 * These are used to set parameters in the core dumps.
93 */ 90 */
diff --git a/arch/arm64/include/asm/fpsimd.h b/arch/arm64/include/asm/fpsimd.h
index b42fab9f62a..c43b4ac1300 100644
--- a/arch/arm64/include/asm/fpsimd.h
+++ b/arch/arm64/include/asm/fpsimd.h
@@ -25,9 +25,8 @@
25 * - FPSR and FPCR 25 * - FPSR and FPCR
26 * - 32 128-bit data registers 26 * - 32 128-bit data registers
27 * 27 *
28 * Note that user_fp forms a prefix of this structure, which is relied 28 * Note that user_fpsimd forms a prefix of this structure, which is
29 * upon in the ptrace FP/SIMD accessors. struct user_fpsimd_state must 29 * relied upon in the ptrace FP/SIMD accessors.
30 * form a prefix of struct fpsimd_state.
31 */ 30 */
32struct fpsimd_state { 31struct fpsimd_state {
33 union { 32 union {
diff --git a/arch/arm64/include/asm/io.h b/arch/arm64/include/asm/io.h
index 74a2a7d304a..d2f05a60827 100644
--- a/arch/arm64/include/asm/io.h
+++ b/arch/arm64/include/asm/io.h
@@ -114,7 +114,7 @@ static inline u64 __raw_readq(const volatile void __iomem *addr)
114 * I/O port access primitives. 114 * I/O port access primitives.
115 */ 115 */
116#define IO_SPACE_LIMIT 0xffff 116#define IO_SPACE_LIMIT 0xffff
117#define PCI_IOBASE ((void __iomem *)0xffffffbbfffe0000UL) 117#define PCI_IOBASE ((void __iomem *)(MODULES_VADDR - SZ_2M))
118 118
119static inline u8 inb(unsigned long addr) 119static inline u8 inb(unsigned long addr)
120{ 120{
@@ -222,12 +222,12 @@ extern void __iomem *__ioremap(phys_addr_t phys_addr, size_t size, pgprot_t prot
222extern void __iounmap(volatile void __iomem *addr); 222extern void __iounmap(volatile void __iomem *addr);
223 223
224#define PROT_DEFAULT (PTE_TYPE_PAGE | PTE_AF | PTE_DIRTY) 224#define PROT_DEFAULT (PTE_TYPE_PAGE | PTE_AF | PTE_DIRTY)
225#define PROT_DEVICE_nGnRE (PROT_DEFAULT | PTE_XN | PTE_ATTRINDX(MT_DEVICE_nGnRE)) 225#define PROT_DEVICE_nGnRE (PROT_DEFAULT | PTE_PXN | PTE_UXN | PTE_ATTRINDX(MT_DEVICE_nGnRE))
226#define PROT_NORMAL_NC (PROT_DEFAULT | PTE_ATTRINDX(MT_NORMAL_NC)) 226#define PROT_NORMAL_NC (PROT_DEFAULT | PTE_ATTRINDX(MT_NORMAL_NC))
227 227
228#define ioremap(addr, size) __ioremap((addr), (size), PROT_DEVICE_nGnRE) 228#define ioremap(addr, size) __ioremap((addr), (size), __pgprot(PROT_DEVICE_nGnRE))
229#define ioremap_nocache(addr, size) __ioremap((addr), (size), PROT_DEVICE_nGnRE) 229#define ioremap_nocache(addr, size) __ioremap((addr), (size), __pgprot(PROT_DEVICE_nGnRE))
230#define ioremap_wc(addr, size) __ioremap((addr), (size), PROT_NORMAL_NC) 230#define ioremap_wc(addr, size) __ioremap((addr), (size), __pgprot(PROT_NORMAL_NC))
231#define iounmap __iounmap 231#define iounmap __iounmap
232 232
233#define ARCH_HAS_IOREMAP_WC 233#define ARCH_HAS_IOREMAP_WC
diff --git a/arch/arm64/include/asm/linkage.h b/arch/arm64/include/asm/linkage.h
new file mode 100644
index 00000000000..636c1bced7d
--- /dev/null
+++ b/arch/arm64/include/asm/linkage.h
@@ -0,0 +1,7 @@
1#ifndef __ASM_LINKAGE_H
2#define __ASM_LINKAGE_H
3
4#define __ALIGN .align 4
5#define __ALIGN_STR ".align 4"
6
7#endif
diff --git a/arch/arm64/include/asm/pgtable-hwdef.h b/arch/arm64/include/asm/pgtable-hwdef.h
index 0f3b4581d92..75fd13d289b 100644
--- a/arch/arm64/include/asm/pgtable-hwdef.h
+++ b/arch/arm64/include/asm/pgtable-hwdef.h
@@ -38,7 +38,8 @@
38#define PMD_SECT_S (_AT(pmdval_t, 3) << 8) 38#define PMD_SECT_S (_AT(pmdval_t, 3) << 8)
39#define PMD_SECT_AF (_AT(pmdval_t, 1) << 10) 39#define PMD_SECT_AF (_AT(pmdval_t, 1) << 10)
40#define PMD_SECT_NG (_AT(pmdval_t, 1) << 11) 40#define PMD_SECT_NG (_AT(pmdval_t, 1) << 11)
41#define PMD_SECT_XN (_AT(pmdval_t, 1) << 54) 41#define PMD_SECT_PXN (_AT(pmdval_t, 1) << 53)
42#define PMD_SECT_UXN (_AT(pmdval_t, 1) << 54)
42 43
43/* 44/*
44 * AttrIndx[2:0] encoding (mapping attributes defined in the MAIR* registers). 45 * AttrIndx[2:0] encoding (mapping attributes defined in the MAIR* registers).
@@ -57,7 +58,8 @@
57#define PTE_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */ 58#define PTE_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
58#define PTE_AF (_AT(pteval_t, 1) << 10) /* Access Flag */ 59#define PTE_AF (_AT(pteval_t, 1) << 10) /* Access Flag */
59#define PTE_NG (_AT(pteval_t, 1) << 11) /* nG */ 60#define PTE_NG (_AT(pteval_t, 1) << 11) /* nG */
60#define PTE_XN (_AT(pteval_t, 1) << 54) /* XN */ 61#define PTE_PXN (_AT(pteval_t, 1) << 53) /* Privileged XN */
62#define PTE_UXN (_AT(pteval_t, 1) << 54) /* User XN */
61 63
62/* 64/*
63 * AttrIndx[2:0] encoding (mapping attributes defined in the MAIR* registers). 65 * AttrIndx[2:0] encoding (mapping attributes defined in the MAIR* registers).
diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
index 8960239be72..14aba2db677 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -62,23 +62,23 @@ extern pgprot_t pgprot_default;
62 62
63#define _MOD_PROT(p, b) __pgprot(pgprot_val(p) | (b)) 63#define _MOD_PROT(p, b) __pgprot(pgprot_val(p) | (b))
64 64
65#define PAGE_NONE _MOD_PROT(pgprot_default, PTE_NG | PTE_XN | PTE_RDONLY) 65#define PAGE_NONE _MOD_PROT(pgprot_default, PTE_NG | PTE_PXN | PTE_UXN | PTE_RDONLY)
66#define PAGE_SHARED _MOD_PROT(pgprot_default, PTE_USER | PTE_NG | PTE_XN) 66#define PAGE_SHARED _MOD_PROT(pgprot_default, PTE_USER | PTE_NG | PTE_PXN | PTE_UXN)
67#define PAGE_SHARED_EXEC _MOD_PROT(pgprot_default, PTE_USER | PTE_NG) 67#define PAGE_SHARED_EXEC _MOD_PROT(pgprot_default, PTE_USER | PTE_NG | PTE_PXN)
68#define PAGE_COPY _MOD_PROT(pgprot_default, PTE_USER | PTE_NG | PTE_XN | PTE_RDONLY) 68#define PAGE_COPY _MOD_PROT(pgprot_default, PTE_USER | PTE_NG | PTE_PXN | PTE_UXN | PTE_RDONLY)
69#define PAGE_COPY_EXEC _MOD_PROT(pgprot_default, PTE_USER | PTE_NG | PTE_RDONLY) 69#define PAGE_COPY_EXEC _MOD_PROT(pgprot_default, PTE_USER | PTE_NG | PTE_PXN | PTE_RDONLY)
70#define PAGE_READONLY _MOD_PROT(pgprot_default, PTE_USER | PTE_NG | PTE_XN | PTE_RDONLY) 70#define PAGE_READONLY _MOD_PROT(pgprot_default, PTE_USER | PTE_NG | PTE_PXN | PTE_UXN | PTE_RDONLY)
71#define PAGE_READONLY_EXEC _MOD_PROT(pgprot_default, PTE_USER | PTE_NG | PTE_RDONLY) 71#define PAGE_READONLY_EXEC _MOD_PROT(pgprot_default, PTE_USER | PTE_NG | PTE_PXN | PTE_RDONLY)
72#define PAGE_KERNEL _MOD_PROT(pgprot_default, PTE_XN | PTE_DIRTY) 72#define PAGE_KERNEL _MOD_PROT(pgprot_default, PTE_PXN | PTE_UXN | PTE_DIRTY)
73#define PAGE_KERNEL_EXEC _MOD_PROT(pgprot_default, PTE_DIRTY) 73#define PAGE_KERNEL_EXEC _MOD_PROT(pgprot_default, PTE_UXN | PTE_DIRTY)
74 74
75#define __PAGE_NONE __pgprot(_PAGE_DEFAULT | PTE_NG | PTE_XN | PTE_RDONLY) 75#define __PAGE_NONE __pgprot(_PAGE_DEFAULT | PTE_NG | PTE_PXN | PTE_UXN | PTE_RDONLY)
76#define __PAGE_SHARED __pgprot(_PAGE_DEFAULT | PTE_USER | PTE_NG | PTE_XN) 76#define __PAGE_SHARED __pgprot(_PAGE_DEFAULT | PTE_USER | PTE_NG | PTE_PXN | PTE_UXN)
77#define __PAGE_SHARED_EXEC __pgprot(_PAGE_DEFAULT | PTE_USER | PTE_NG) 77#define __PAGE_SHARED_EXEC __pgprot(_PAGE_DEFAULT | PTE_USER | PTE_NG | PTE_PXN)
78#define __PAGE_COPY __pgprot(_PAGE_DEFAULT | PTE_USER | PTE_NG | PTE_XN | PTE_RDONLY) 78#define __PAGE_COPY __pgprot(_PAGE_DEFAULT | PTE_USER | PTE_NG | PTE_PXN | PTE_UXN | PTE_RDONLY)
79#define __PAGE_COPY_EXEC __pgprot(_PAGE_DEFAULT | PTE_USER | PTE_NG | PTE_RDONLY) 79#define __PAGE_COPY_EXEC __pgprot(_PAGE_DEFAULT | PTE_USER | PTE_NG | PTE_PXN | PTE_RDONLY)
80#define __PAGE_READONLY __pgprot(_PAGE_DEFAULT | PTE_USER | PTE_NG | PTE_XN | PTE_RDONLY) 80#define __PAGE_READONLY __pgprot(_PAGE_DEFAULT | PTE_USER | PTE_NG | PTE_PXN | PTE_UXN | PTE_RDONLY)
81#define __PAGE_READONLY_EXEC __pgprot(_PAGE_DEFAULT | PTE_USER | PTE_NG | PTE_RDONLY) 81#define __PAGE_READONLY_EXEC __pgprot(_PAGE_DEFAULT | PTE_USER | PTE_NG | PTE_PXN | PTE_RDONLY)
82 82
83#endif /* __ASSEMBLY__ */ 83#endif /* __ASSEMBLY__ */
84 84
@@ -130,10 +130,10 @@ extern struct page *empty_zero_page;
130#define pte_young(pte) (pte_val(pte) & PTE_AF) 130#define pte_young(pte) (pte_val(pte) & PTE_AF)
131#define pte_special(pte) (pte_val(pte) & PTE_SPECIAL) 131#define pte_special(pte) (pte_val(pte) & PTE_SPECIAL)
132#define pte_write(pte) (!(pte_val(pte) & PTE_RDONLY)) 132#define pte_write(pte) (!(pte_val(pte) & PTE_RDONLY))
133#define pte_exec(pte) (!(pte_val(pte) & PTE_XN)) 133#define pte_exec(pte) (!(pte_val(pte) & PTE_UXN))
134 134
135#define pte_present_exec_user(pte) \ 135#define pte_present_exec_user(pte) \
136 ((pte_val(pte) & (PTE_VALID | PTE_USER | PTE_XN)) == \ 136 ((pte_val(pte) & (PTE_VALID | PTE_USER | PTE_UXN)) == \
137 (PTE_VALID | PTE_USER)) 137 (PTE_VALID | PTE_USER))
138 138
139#define PTE_BIT_FUNC(fn,op) \ 139#define PTE_BIT_FUNC(fn,op) \
@@ -262,7 +262,7 @@ static inline pmd_t *pmd_offset(pud_t *pud, unsigned long addr)
262 262
263static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) 263static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
264{ 264{
265 const pteval_t mask = PTE_USER | PTE_XN | PTE_RDONLY; 265 const pteval_t mask = PTE_USER | PTE_PXN | PTE_UXN | PTE_RDONLY;
266 pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask); 266 pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask);
267 return pte; 267 return pte;
268} 268}
diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h
index 39a208a392f..ab239b2c456 100644
--- a/arch/arm64/include/asm/processor.h
+++ b/arch/arm64/include/asm/processor.h
@@ -43,6 +43,8 @@
43#else 43#else
44#define STACK_TOP STACK_TOP_MAX 44#define STACK_TOP STACK_TOP_MAX
45#endif /* CONFIG_COMPAT */ 45#endif /* CONFIG_COMPAT */
46
47#define ARCH_LOW_ADDRESS_LIMIT PHYS_MASK
46#endif /* __KERNEL__ */ 48#endif /* __KERNEL__ */
47 49
48struct debug_info { 50struct debug_info {
@@ -92,30 +94,20 @@ static inline void start_thread_common(struct pt_regs *regs, unsigned long pc)
92static inline void start_thread(struct pt_regs *regs, unsigned long pc, 94static inline void start_thread(struct pt_regs *regs, unsigned long pc,
93 unsigned long sp) 95 unsigned long sp)
94{ 96{
95 unsigned long *stack = (unsigned long *)sp;
96
97 start_thread_common(regs, pc); 97 start_thread_common(regs, pc);
98 regs->pstate = PSR_MODE_EL0t; 98 regs->pstate = PSR_MODE_EL0t;
99 regs->sp = sp; 99 regs->sp = sp;
100 regs->regs[2] = stack[2]; /* x2 (envp) */
101 regs->regs[1] = stack[1]; /* x1 (argv) */
102 regs->regs[0] = stack[0]; /* x0 (argc) */
103} 100}
104 101
105#ifdef CONFIG_COMPAT 102#ifdef CONFIG_COMPAT
106static inline void compat_start_thread(struct pt_regs *regs, unsigned long pc, 103static inline void compat_start_thread(struct pt_regs *regs, unsigned long pc,
107 unsigned long sp) 104 unsigned long sp)
108{ 105{
109 unsigned int *stack = (unsigned int *)sp;
110
111 start_thread_common(regs, pc); 106 start_thread_common(regs, pc);
112 regs->pstate = COMPAT_PSR_MODE_USR; 107 regs->pstate = COMPAT_PSR_MODE_USR;
113 if (pc & 1) 108 if (pc & 1)
114 regs->pstate |= COMPAT_PSR_T_BIT; 109 regs->pstate |= COMPAT_PSR_T_BIT;
115 regs->compat_sp = sp; 110 regs->compat_sp = sp;
116 regs->regs[2] = stack[2]; /* x2 (envp) */
117 regs->regs[1] = stack[1]; /* x1 (argv) */
118 regs->regs[0] = stack[0]; /* x0 (argc) */
119} 111}
120#endif 112#endif
121 113
@@ -136,11 +128,6 @@ unsigned long get_wchan(struct task_struct *p);
136extern struct task_struct *cpu_switch_to(struct task_struct *prev, 128extern struct task_struct *cpu_switch_to(struct task_struct *prev,
137 struct task_struct *next); 129 struct task_struct *next);
138 130
139/*
140 * Create a new kernel thread
141 */
142extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
143
144#define task_pt_regs(p) \ 131#define task_pt_regs(p) \
145 ((struct pt_regs *)(THREAD_START_SP + task_stack_page(p)) - 1) 132 ((struct pt_regs *)(THREAD_START_SP + task_stack_page(p)) - 1)
146 133
diff --git a/arch/arm64/include/asm/syscalls.h b/arch/arm64/include/asm/syscalls.h
index 09ff33572aa..a1b00cd6f78 100644
--- a/arch/arm64/include/asm/syscalls.h
+++ b/arch/arm64/include/asm/syscalls.h
@@ -23,18 +23,16 @@
23/* 23/*
24 * System call wrappers implemented in kernel/entry.S. 24 * System call wrappers implemented in kernel/entry.S.
25 */ 25 */
26asmlinkage long sys_execve_wrapper(const char __user *filename,
27 const char __user *const __user *argv,
28 const char __user *const __user *envp);
29asmlinkage long sys_clone_wrapper(unsigned long clone_flags,
30 unsigned long newsp,
31 void __user *parent_tid,
32 unsigned long tls_val,
33 void __user *child_tid);
34asmlinkage long sys_rt_sigreturn_wrapper(void); 26asmlinkage long sys_rt_sigreturn_wrapper(void);
35asmlinkage long sys_sigaltstack_wrapper(const stack_t __user *uss, 27asmlinkage long sys_sigaltstack_wrapper(const stack_t __user *uss,
36 stack_t __user *uoss); 28 stack_t __user *uoss);
37 29
30/*
31 * AArch64 sys_clone implementation has a different prototype than the generic
32 * one (additional TLS value argument).
33 */
34#define sys_clone sys_clone
35
38#include <asm-generic/syscalls.h> 36#include <asm-generic/syscalls.h>
39 37
40#endif /* __ASM_SYSCALLS_H */ 38#endif /* __ASM_SYSCALLS_H */
diff --git a/arch/arm64/include/asm/unistd.h b/arch/arm64/include/asm/unistd.h
index 63f853f8b71..43064a8bd99 100644
--- a/arch/arm64/include/asm/unistd.h
+++ b/arch/arm64/include/asm/unistd.h
@@ -14,7 +14,6 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>. 14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */ 15 */
16#ifdef CONFIG_COMPAT 16#ifdef CONFIG_COMPAT
17#define __ARCH_WANT_COMPAT_IPC_PARSE_VERSION
18#define __ARCH_WANT_COMPAT_STAT64 17#define __ARCH_WANT_COMPAT_STAT64
19#define __ARCH_WANT_SYS_GETHOSTNAME 18#define __ARCH_WANT_SYS_GETHOSTNAME
20#define __ARCH_WANT_SYS_PAUSE 19#define __ARCH_WANT_SYS_PAUSE
@@ -26,4 +25,5 @@
26#define __ARCH_WANT_COMPAT_SYS_RT_SIGSUSPEND 25#define __ARCH_WANT_COMPAT_SYS_RT_SIGSUSPEND
27#define __ARCH_WANT_COMPAT_SYS_SENDFILE 26#define __ARCH_WANT_COMPAT_SYS_SENDFILE
28#endif 27#endif
28#define __ARCH_WANT_SYS_EXECVE
29#include <uapi/asm/unistd.h> 29#include <uapi/asm/unistd.h>
diff --git a/arch/arm64/include/asm/unistd32.h b/arch/arm64/include/asm/unistd32.h
index 6d909faebf2..d9850cf9870 100644
--- a/arch/arm64/include/asm/unistd32.h
+++ b/arch/arm64/include/asm/unistd32.h
@@ -23,7 +23,7 @@
23 23
24__SYSCALL(0, sys_restart_syscall) 24__SYSCALL(0, sys_restart_syscall)
25__SYSCALL(1, sys_exit) 25__SYSCALL(1, sys_exit)
26__SYSCALL(2, compat_sys_fork_wrapper) 26__SYSCALL(2, compat_sys_fork)
27__SYSCALL(3, sys_read) 27__SYSCALL(3, sys_read)
28__SYSCALL(4, sys_write) 28__SYSCALL(4, sys_write)
29__SYSCALL(5, compat_sys_open) 29__SYSCALL(5, compat_sys_open)
@@ -32,7 +32,7 @@ __SYSCALL(7, sys_ni_syscall) /* 7 was sys_waitpid */
32__SYSCALL(8, sys_creat) 32__SYSCALL(8, sys_creat)
33__SYSCALL(9, sys_link) 33__SYSCALL(9, sys_link)
34__SYSCALL(10, sys_unlink) 34__SYSCALL(10, sys_unlink)
35__SYSCALL(11, compat_sys_execve_wrapper) 35__SYSCALL(11, compat_sys_execve)
36__SYSCALL(12, sys_chdir) 36__SYSCALL(12, sys_chdir)
37__SYSCALL(13, sys_ni_syscall) /* 13 was sys_time */ 37__SYSCALL(13, sys_ni_syscall) /* 13 was sys_time */
38__SYSCALL(14, sys_mknod) 38__SYSCALL(14, sys_mknod)
@@ -141,7 +141,7 @@ __SYSCALL(116, compat_sys_sysinfo)
141__SYSCALL(117, sys_ni_syscall) /* 117 was sys_ipc */ 141__SYSCALL(117, sys_ni_syscall) /* 117 was sys_ipc */
142__SYSCALL(118, sys_fsync) 142__SYSCALL(118, sys_fsync)
143__SYSCALL(119, compat_sys_sigreturn_wrapper) 143__SYSCALL(119, compat_sys_sigreturn_wrapper)
144__SYSCALL(120, compat_sys_clone_wrapper) 144__SYSCALL(120, sys_clone)
145__SYSCALL(121, sys_setdomainname) 145__SYSCALL(121, sys_setdomainname)
146__SYSCALL(122, sys_newuname) 146__SYSCALL(122, sys_newuname)
147__SYSCALL(123, sys_ni_syscall) /* 123 was sys_modify_ldt */ 147__SYSCALL(123, sys_ni_syscall) /* 123 was sys_modify_ldt */
@@ -211,7 +211,7 @@ __SYSCALL(186, compat_sys_sigaltstack_wrapper)
211__SYSCALL(187, compat_sys_sendfile) 211__SYSCALL(187, compat_sys_sendfile)
212__SYSCALL(188, sys_ni_syscall) /* 188 reserved */ 212__SYSCALL(188, sys_ni_syscall) /* 188 reserved */
213__SYSCALL(189, sys_ni_syscall) /* 189 reserved */ 213__SYSCALL(189, sys_ni_syscall) /* 189 reserved */
214__SYSCALL(190, compat_sys_vfork_wrapper) 214__SYSCALL(190, compat_sys_vfork)
215__SYSCALL(191, compat_sys_getrlimit) /* SuS compliant getrlimit */ 215__SYSCALL(191, compat_sys_getrlimit) /* SuS compliant getrlimit */
216__SYSCALL(192, sys_mmap_pgoff) 216__SYSCALL(192, sys_mmap_pgoff)
217__SYSCALL(193, compat_sys_truncate64_wrapper) 217__SYSCALL(193, compat_sys_truncate64_wrapper)
diff --git a/arch/arm64/include/uapi/asm/ptrace.h b/arch/arm64/include/uapi/asm/ptrace.h
index 9b131b4efa0..6913643bbe5 100644
--- a/arch/arm64/include/uapi/asm/ptrace.h
+++ b/arch/arm64/include/uapi/asm/ptrace.h
@@ -79,13 +79,14 @@ struct user_fpsimd_state {
79 79
80struct user_hwdebug_state { 80struct user_hwdebug_state {
81 __u32 dbg_info; 81 __u32 dbg_info;
82 __u32 pad;
82 struct { 83 struct {
83 __u64 addr; 84 __u64 addr;
84 __u32 ctrl; 85 __u32 ctrl;
86 __u32 pad;
85 } dbg_regs[16]; 87 } dbg_regs[16];
86}; 88};
87 89
88
89#endif /* __ASSEMBLY__ */ 90#endif /* __ASSEMBLY__ */
90 91
91#endif /* _UAPI__ASM_PTRACE_H */ 92#endif /* _UAPI__ASM_PTRACE_H */
diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S
index a6f3f7da688..cbfa4d28100 100644
--- a/arch/arm64/kernel/entry.S
+++ b/arch/arm64/kernel/entry.S
@@ -594,7 +594,7 @@ work_resched:
594/* 594/*
595 * "slow" syscall return path. 595 * "slow" syscall return path.
596 */ 596 */
597ENTRY(ret_to_user) 597ret_to_user:
598 disable_irq // disable interrupts 598 disable_irq // disable interrupts
599 ldr x1, [tsk, #TI_FLAGS] 599 ldr x1, [tsk, #TI_FLAGS]
600 and x2, x1, #_TIF_WORK_MASK 600 and x2, x1, #_TIF_WORK_MASK
@@ -611,7 +611,10 @@ ENDPROC(ret_to_user)
611 */ 611 */
612ENTRY(ret_from_fork) 612ENTRY(ret_from_fork)
613 bl schedule_tail 613 bl schedule_tail
614 get_thread_info tsk 614 cbz x19, 1f // not a kernel thread
615 mov x0, x20
616 blr x19
6171: get_thread_info tsk
615 b ret_to_user 618 b ret_to_user
616ENDPROC(ret_from_fork) 619ENDPROC(ret_from_fork)
617 620
@@ -673,16 +676,6 @@ __sys_trace_return:
673/* 676/*
674 * Special system call wrappers. 677 * Special system call wrappers.
675 */ 678 */
676ENTRY(sys_execve_wrapper)
677 mov x3, sp
678 b sys_execve
679ENDPROC(sys_execve_wrapper)
680
681ENTRY(sys_clone_wrapper)
682 mov x5, sp
683 b sys_clone
684ENDPROC(sys_clone_wrapper)
685
686ENTRY(sys_rt_sigreturn_wrapper) 679ENTRY(sys_rt_sigreturn_wrapper)
687 mov x0, sp 680 mov x0, sp
688 b sys_rt_sigreturn 681 b sys_rt_sigreturn
diff --git a/arch/arm64/kernel/perf_event.c b/arch/arm64/kernel/perf_event.c
index ecbf2d81ec5..c76c7241125 100644
--- a/arch/arm64/kernel/perf_event.c
+++ b/arch/arm64/kernel/perf_event.c
@@ -613,17 +613,11 @@ enum armv8_pmuv3_perf_types {
613 ARMV8_PMUV3_PERFCTR_BUS_ACCESS = 0x19, 613 ARMV8_PMUV3_PERFCTR_BUS_ACCESS = 0x19,
614 ARMV8_PMUV3_PERFCTR_MEM_ERROR = 0x1A, 614 ARMV8_PMUV3_PERFCTR_MEM_ERROR = 0x1A,
615 ARMV8_PMUV3_PERFCTR_BUS_CYCLES = 0x1D, 615 ARMV8_PMUV3_PERFCTR_BUS_CYCLES = 0x1D,
616
617 /*
618 * This isn't an architected event.
619 * We detect this event number and use the cycle counter instead.
620 */
621 ARMV8_PMUV3_PERFCTR_CPU_CYCLES = 0xFF,
622}; 616};
623 617
624/* PMUv3 HW events mapping. */ 618/* PMUv3 HW events mapping. */
625static const unsigned armv8_pmuv3_perf_map[PERF_COUNT_HW_MAX] = { 619static const unsigned armv8_pmuv3_perf_map[PERF_COUNT_HW_MAX] = {
626 [PERF_COUNT_HW_CPU_CYCLES] = ARMV8_PMUV3_PERFCTR_CPU_CYCLES, 620 [PERF_COUNT_HW_CPU_CYCLES] = ARMV8_PMUV3_PERFCTR_CLOCK_CYCLES,
627 [PERF_COUNT_HW_INSTRUCTIONS] = ARMV8_PMUV3_PERFCTR_INSTR_EXECUTED, 621 [PERF_COUNT_HW_INSTRUCTIONS] = ARMV8_PMUV3_PERFCTR_INSTR_EXECUTED,
628 [PERF_COUNT_HW_CACHE_REFERENCES] = ARMV8_PMUV3_PERFCTR_L1_DCACHE_ACCESS, 622 [PERF_COUNT_HW_CACHE_REFERENCES] = ARMV8_PMUV3_PERFCTR_L1_DCACHE_ACCESS,
629 [PERF_COUNT_HW_CACHE_MISSES] = ARMV8_PMUV3_PERFCTR_L1_DCACHE_REFILL, 623 [PERF_COUNT_HW_CACHE_MISSES] = ARMV8_PMUV3_PERFCTR_L1_DCACHE_REFILL,
@@ -1106,7 +1100,7 @@ static int armv8pmu_get_event_idx(struct pmu_hw_events *cpuc,
1106 unsigned long evtype = event->config_base & ARMV8_EVTYPE_EVENT; 1100 unsigned long evtype = event->config_base & ARMV8_EVTYPE_EVENT;
1107 1101
1108 /* Always place a cycle counter into the cycle counter. */ 1102 /* Always place a cycle counter into the cycle counter. */
1109 if (evtype == ARMV8_PMUV3_PERFCTR_CPU_CYCLES) { 1103 if (evtype == ARMV8_PMUV3_PERFCTR_CLOCK_CYCLES) {
1110 if (test_and_set_bit(ARMV8_IDX_CYCLE_COUNTER, cpuc->used_mask)) 1104 if (test_and_set_bit(ARMV8_IDX_CYCLE_COUNTER, cpuc->used_mask))
1111 return -EAGAIN; 1105 return -EAGAIN;
1112 1106
diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c
index f22965ea1cf..8a5f3341861 100644
--- a/arch/arm64/kernel/process.c
+++ b/arch/arm64/kernel/process.c
@@ -240,27 +240,41 @@ int copy_thread(unsigned long clone_flags, unsigned long stack_start,
240 struct pt_regs *childregs = task_pt_regs(p); 240 struct pt_regs *childregs = task_pt_regs(p);
241 unsigned long tls = p->thread.tp_value; 241 unsigned long tls = p->thread.tp_value;
242 242
243 *childregs = *regs; 243 memset(&p->thread.cpu_context, 0, sizeof(struct cpu_context));
244 childregs->regs[0] = 0;
245 244
246 if (is_compat_thread(task_thread_info(p))) 245 if (likely(regs)) {
247 childregs->compat_sp = stack_start; 246 *childregs = *regs;
248 else { 247 childregs->regs[0] = 0;
248 if (is_compat_thread(task_thread_info(p))) {
249 if (stack_start)
250 childregs->compat_sp = stack_start;
251 } else {
252 /*
253 * Read the current TLS pointer from tpidr_el0 as it may be
254 * out-of-sync with the saved value.
255 */
256 asm("mrs %0, tpidr_el0" : "=r" (tls));
257 if (stack_start) {
258 /* 16-byte aligned stack mandatory on AArch64 */
259 if (stack_start & 15)
260 return -EINVAL;
261 childregs->sp = stack_start;
262 }
263 }
249 /* 264 /*
250 * Read the current TLS pointer from tpidr_el0 as it may be 265 * If a TLS pointer was passed to clone (4th argument), use it
251 * out-of-sync with the saved value. 266 * for the new thread.
252 */ 267 */
253 asm("mrs %0, tpidr_el0" : "=r" (tls)); 268 if (clone_flags & CLONE_SETTLS)
254 childregs->sp = stack_start; 269 tls = regs->regs[3];
270 } else {
271 memset(childregs, 0, sizeof(struct pt_regs));
272 childregs->pstate = PSR_MODE_EL1h;
273 p->thread.cpu_context.x19 = stack_start;
274 p->thread.cpu_context.x20 = stk_sz;
255 } 275 }
256
257 memset(&p->thread.cpu_context, 0, sizeof(struct cpu_context));
258 p->thread.cpu_context.sp = (unsigned long)childregs;
259 p->thread.cpu_context.pc = (unsigned long)ret_from_fork; 276 p->thread.cpu_context.pc = (unsigned long)ret_from_fork;
260 277 p->thread.cpu_context.sp = (unsigned long)childregs;
261 /* If a TLS pointer was passed to clone, use that for the new thread. */
262 if (clone_flags & CLONE_SETTLS)
263 tls = regs->regs[3];
264 p->thread.tp_value = tls; 278 p->thread.tp_value = tls;
265 279
266 ptrace_hw_copy_thread(p); 280 ptrace_hw_copy_thread(p);
@@ -309,61 +323,6 @@ struct task_struct *__switch_to(struct task_struct *prev,
309 return last; 323 return last;
310} 324}
311 325
312/*
313 * Fill in the task's elfregs structure for a core dump.
314 */
315int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs)
316{
317 elf_core_copy_regs(elfregs, task_pt_regs(t));
318 return 1;
319}
320
321/*
322 * fill in the fpe structure for a core dump...
323 */
324int dump_fpu (struct pt_regs *regs, struct user_fp *fp)
325{
326 return 0;
327}
328EXPORT_SYMBOL(dump_fpu);
329
330/*
331 * Shuffle the argument into the correct register before calling the
332 * thread function. x1 is the thread argument, x2 is the pointer to
333 * the thread function, and x3 points to the exit function.
334 */
335extern void kernel_thread_helper(void);
336asm( ".section .text\n"
337" .align\n"
338" .type kernel_thread_helper, #function\n"
339"kernel_thread_helper:\n"
340" mov x0, x1\n"
341" mov x30, x3\n"
342" br x2\n"
343" .size kernel_thread_helper, . - kernel_thread_helper\n"
344" .previous");
345
346#define kernel_thread_exit do_exit
347
348/*
349 * Create a kernel thread.
350 */
351pid_t kernel_thread(int (*fn)(void *), void *arg, unsigned long flags)
352{
353 struct pt_regs regs;
354
355 memset(&regs, 0, sizeof(regs));
356
357 regs.regs[1] = (unsigned long)arg;
358 regs.regs[2] = (unsigned long)fn;
359 regs.regs[3] = (unsigned long)kernel_thread_exit;
360 regs.pc = (unsigned long)kernel_thread_helper;
361 regs.pstate = PSR_MODE_EL1h;
362
363 return do_fork(flags|CLONE_VM|CLONE_UNTRACED, 0, &regs, 0, NULL, NULL);
364}
365EXPORT_SYMBOL(kernel_thread);
366
367unsigned long get_wchan(struct task_struct *p) 326unsigned long get_wchan(struct task_struct *p)
368{ 327{
369 struct stackframe frame; 328 struct stackframe frame;
diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c
index 2ea3968367c..6e1e77f1831 100644
--- a/arch/arm64/kernel/ptrace.c
+++ b/arch/arm64/kernel/ptrace.c
@@ -234,28 +234,33 @@ static int ptrace_hbp_fill_attr_ctrl(unsigned int note_type,
234 struct arch_hw_breakpoint_ctrl ctrl, 234 struct arch_hw_breakpoint_ctrl ctrl,
235 struct perf_event_attr *attr) 235 struct perf_event_attr *attr)
236{ 236{
237 int err, len, type; 237 int err, len, type, disabled = !ctrl.enabled;
238 238
239 err = arch_bp_generic_fields(ctrl, &len, &type); 239 if (disabled) {
240 if (err) 240 len = 0;
241 return err; 241 type = HW_BREAKPOINT_EMPTY;
242 242 } else {
243 switch (note_type) { 243 err = arch_bp_generic_fields(ctrl, &len, &type);
244 case NT_ARM_HW_BREAK: 244 if (err)
245 if ((type & HW_BREAKPOINT_X) != type) 245 return err;
246 return -EINVAL; 246
247 break; 247 switch (note_type) {
248 case NT_ARM_HW_WATCH: 248 case NT_ARM_HW_BREAK:
249 if ((type & HW_BREAKPOINT_RW) != type) 249 if ((type & HW_BREAKPOINT_X) != type)
250 return -EINVAL;
251 break;
252 case NT_ARM_HW_WATCH:
253 if ((type & HW_BREAKPOINT_RW) != type)
254 return -EINVAL;
255 break;
256 default:
250 return -EINVAL; 257 return -EINVAL;
251 break; 258 }
252 default:
253 return -EINVAL;
254 } 259 }
255 260
256 attr->bp_len = len; 261 attr->bp_len = len;
257 attr->bp_type = type; 262 attr->bp_type = type;
258 attr->disabled = !ctrl.enabled; 263 attr->disabled = disabled;
259 264
260 return 0; 265 return 0;
261} 266}
@@ -372,7 +377,7 @@ static int ptrace_hbp_set_addr(unsigned int note_type,
372 377
373#define PTRACE_HBP_ADDR_SZ sizeof(u64) 378#define PTRACE_HBP_ADDR_SZ sizeof(u64)
374#define PTRACE_HBP_CTRL_SZ sizeof(u32) 379#define PTRACE_HBP_CTRL_SZ sizeof(u32)
375#define PTRACE_HBP_REG_OFF sizeof(u32) 380#define PTRACE_HBP_PAD_SZ sizeof(u32)
376 381
377static int hw_break_get(struct task_struct *target, 382static int hw_break_get(struct task_struct *target,
378 const struct user_regset *regset, 383 const struct user_regset *regset,
@@ -380,7 +385,7 @@ static int hw_break_get(struct task_struct *target,
380 void *kbuf, void __user *ubuf) 385 void *kbuf, void __user *ubuf)
381{ 386{
382 unsigned int note_type = regset->core_note_type; 387 unsigned int note_type = regset->core_note_type;
383 int ret, idx = 0, offset = PTRACE_HBP_REG_OFF, limit; 388 int ret, idx = 0, offset, limit;
384 u32 info, ctrl; 389 u32 info, ctrl;
385 u64 addr; 390 u64 addr;
386 391
@@ -389,11 +394,20 @@ static int hw_break_get(struct task_struct *target,
389 if (ret) 394 if (ret)
390 return ret; 395 return ret;
391 396
392 ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, &info, 0, 4); 397 ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, &info, 0,
398 sizeof(info));
399 if (ret)
400 return ret;
401
402 /* Pad */
403 offset = offsetof(struct user_hwdebug_state, pad);
404 ret = user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf, offset,
405 offset + PTRACE_HBP_PAD_SZ);
393 if (ret) 406 if (ret)
394 return ret; 407 return ret;
395 408
396 /* (address, ctrl) registers */ 409 /* (address, ctrl) registers */
410 offset = offsetof(struct user_hwdebug_state, dbg_regs);
397 limit = regset->n * regset->size; 411 limit = regset->n * regset->size;
398 while (count && offset < limit) { 412 while (count && offset < limit) {
399 ret = ptrace_hbp_get_addr(note_type, target, idx, &addr); 413 ret = ptrace_hbp_get_addr(note_type, target, idx, &addr);
@@ -413,6 +427,13 @@ static int hw_break_get(struct task_struct *target,
413 if (ret) 427 if (ret)
414 return ret; 428 return ret;
415 offset += PTRACE_HBP_CTRL_SZ; 429 offset += PTRACE_HBP_CTRL_SZ;
430
431 ret = user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf,
432 offset,
433 offset + PTRACE_HBP_PAD_SZ);
434 if (ret)
435 return ret;
436 offset += PTRACE_HBP_PAD_SZ;
416 idx++; 437 idx++;
417 } 438 }
418 439
@@ -425,12 +446,13 @@ static int hw_break_set(struct task_struct *target,
425 const void *kbuf, const void __user *ubuf) 446 const void *kbuf, const void __user *ubuf)
426{ 447{
427 unsigned int note_type = regset->core_note_type; 448 unsigned int note_type = regset->core_note_type;
428 int ret, idx = 0, offset = PTRACE_HBP_REG_OFF, limit; 449 int ret, idx = 0, offset, limit;
429 u32 ctrl; 450 u32 ctrl;
430 u64 addr; 451 u64 addr;
431 452
432 /* Resource info */ 453 /* Resource info and pad */
433 ret = user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf, 0, 4); 454 offset = offsetof(struct user_hwdebug_state, dbg_regs);
455 ret = user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf, 0, offset);
434 if (ret) 456 if (ret)
435 return ret; 457 return ret;
436 458
@@ -454,6 +476,13 @@ static int hw_break_set(struct task_struct *target,
454 if (ret) 476 if (ret)
455 return ret; 477 return ret;
456 offset += PTRACE_HBP_CTRL_SZ; 478 offset += PTRACE_HBP_CTRL_SZ;
479
480 ret = user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf,
481 offset,
482 offset + PTRACE_HBP_PAD_SZ);
483 if (ret)
484 return ret;
485 offset += PTRACE_HBP_PAD_SZ;
457 idx++; 486 idx++;
458 } 487 }
459 488
diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
index 48ffb9fb3fe..7665a9bfdb1 100644
--- a/arch/arm64/kernel/setup.c
+++ b/arch/arm64/kernel/setup.c
@@ -170,7 +170,19 @@ static void __init setup_machine_fdt(phys_addr_t dt_phys)
170 170
171void __init early_init_dt_add_memory_arch(u64 base, u64 size) 171void __init early_init_dt_add_memory_arch(u64 base, u64 size)
172{ 172{
173 base &= PAGE_MASK;
173 size &= PAGE_MASK; 174 size &= PAGE_MASK;
175 if (base + size < PHYS_OFFSET) {
176 pr_warning("Ignoring memory block 0x%llx - 0x%llx\n",
177 base, base + size);
178 return;
179 }
180 if (base < PHYS_OFFSET) {
181 pr_warning("Ignoring memory range 0x%llx - 0x%llx\n",
182 base, PHYS_OFFSET);
183 size -= PHYS_OFFSET - base;
184 base = PHYS_OFFSET;
185 }
174 memblock_add(base, size); 186 memblock_add(base, size);
175} 187}
176 188
diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
index b711525be21..538300f2273 100644
--- a/arch/arm64/kernel/smp.c
+++ b/arch/arm64/kernel/smp.c
@@ -46,7 +46,6 @@
46#include <asm/sections.h> 46#include <asm/sections.h>
47#include <asm/tlbflush.h> 47#include <asm/tlbflush.h>
48#include <asm/ptrace.h> 48#include <asm/ptrace.h>
49#include <asm/mmu_context.h>
50 49
51/* 50/*
52 * as from 2.5, kernels no longer have an init_tasks structure 51 * as from 2.5, kernels no longer have an init_tasks structure
@@ -212,8 +211,7 @@ asmlinkage void __cpuinit secondary_start_kernel(void)
212 * before we continue. 211 * before we continue.
213 */ 212 */
214 set_cpu_online(cpu, true); 213 set_cpu_online(cpu, true);
215 while (!cpu_active(cpu)) 214 complete(&cpu_running);
216 cpu_relax();
217 215
218 /* 216 /*
219 * OK, it's off to the idle thread for us 217 * OK, it's off to the idle thread for us
diff --git a/arch/arm64/kernel/sys.c b/arch/arm64/kernel/sys.c
index b120df37de3..4364df85050 100644
--- a/arch/arm64/kernel/sys.c
+++ b/arch/arm64/kernel/sys.c
@@ -31,79 +31,11 @@
31 */ 31 */
32asmlinkage long sys_clone(unsigned long clone_flags, unsigned long newsp, 32asmlinkage long sys_clone(unsigned long clone_flags, unsigned long newsp,
33 int __user *parent_tidptr, unsigned long tls_val, 33 int __user *parent_tidptr, unsigned long tls_val,
34 int __user *child_tidptr, struct pt_regs *regs) 34 int __user *child_tidptr)
35{ 35{
36 if (!newsp) 36 return do_fork(clone_flags, newsp, current_pt_regs(), 0,
37 newsp = regs->sp; 37 parent_tidptr, child_tidptr);
38 /* 16-byte aligned stack mandatory on AArch64 */
39 if (newsp & 15)
40 return -EINVAL;
41 return do_fork(clone_flags, newsp, regs, 0, parent_tidptr, child_tidptr);
42}
43
44/*
45 * sys_execve() executes a new program.
46 */
47asmlinkage long sys_execve(const char __user *filenamei,
48 const char __user *const __user *argv,
49 const char __user *const __user *envp,
50 struct pt_regs *regs)
51{
52 long error;
53 struct filename *filename;
54
55 filename = getname(filenamei);
56 error = PTR_ERR(filename);
57 if (IS_ERR(filename))
58 goto out;
59 error = do_execve(filename->name, argv, envp, regs);
60 putname(filename);
61out:
62 return error;
63}
64
65int kernel_execve(const char *filename,
66 const char *const argv[],
67 const char *const envp[])
68{
69 struct pt_regs regs;
70 int ret;
71
72 memset(&regs, 0, sizeof(struct pt_regs));
73 ret = do_execve(filename,
74 (const char __user *const __user *)argv,
75 (const char __user *const __user *)envp, &regs);
76 if (ret < 0)
77 goto out;
78
79 /*
80 * Save argc to the register structure for userspace.
81 */
82 regs.regs[0] = ret;
83
84 /*
85 * We were successful. We won't be returning to our caller, but
86 * instead to user space by manipulating the kernel stack.
87 */
88 asm( "add x0, %0, %1\n\t"
89 "mov x1, %2\n\t"
90 "mov x2, %3\n\t"
91 "bl memmove\n\t" /* copy regs to top of stack */
92 "mov x27, #0\n\t" /* not a syscall */
93 "mov x28, %0\n\t" /* thread structure */
94 "mov sp, x0\n\t" /* reposition stack pointer */
95 "b ret_to_user"
96 :
97 : "r" (current_thread_info()),
98 "Ir" (THREAD_START_SP - sizeof(regs)),
99 "r" (&regs),
100 "Ir" (sizeof(regs))
101 : "x0", "x1", "x2", "x27", "x28", "x30", "memory");
102
103 out:
104 return ret;
105} 38}
106EXPORT_SYMBOL(kernel_execve);
107 39
108asmlinkage long sys_mmap(unsigned long addr, unsigned long len, 40asmlinkage long sys_mmap(unsigned long addr, unsigned long len,
109 unsigned long prot, unsigned long flags, 41 unsigned long prot, unsigned long flags,
@@ -118,8 +50,6 @@ asmlinkage long sys_mmap(unsigned long addr, unsigned long len,
118/* 50/*
119 * Wrappers to pass the pt_regs argument. 51 * Wrappers to pass the pt_regs argument.
120 */ 52 */
121#define sys_execve sys_execve_wrapper
122#define sys_clone sys_clone_wrapper
123#define sys_rt_sigreturn sys_rt_sigreturn_wrapper 53#define sys_rt_sigreturn sys_rt_sigreturn_wrapper
124#define sys_sigaltstack sys_sigaltstack_wrapper 54#define sys_sigaltstack sys_sigaltstack_wrapper
125 55
diff --git a/arch/arm64/kernel/sys32.S b/arch/arm64/kernel/sys32.S
index 54c4aec47a0..7ef59e9245e 100644
--- a/arch/arm64/kernel/sys32.S
+++ b/arch/arm64/kernel/sys32.S
@@ -26,25 +26,6 @@
26/* 26/*
27 * System call wrappers for the AArch32 compatibility layer. 27 * System call wrappers for the AArch32 compatibility layer.
28 */ 28 */
29compat_sys_fork_wrapper:
30 mov x0, sp
31 b compat_sys_fork
32ENDPROC(compat_sys_fork_wrapper)
33
34compat_sys_vfork_wrapper:
35 mov x0, sp
36 b compat_sys_vfork
37ENDPROC(compat_sys_vfork_wrapper)
38
39compat_sys_execve_wrapper:
40 mov x3, sp
41 b compat_sys_execve
42ENDPROC(compat_sys_execve_wrapper)
43
44compat_sys_clone_wrapper:
45 mov x5, sp
46 b compat_sys_clone
47ENDPROC(compat_sys_clone_wrapper)
48 29
49compat_sys_sigreturn_wrapper: 30compat_sys_sigreturn_wrapper:
50 mov x0, sp 31 mov x0, sp
diff --git a/arch/arm64/kernel/sys_compat.c b/arch/arm64/kernel/sys_compat.c
index 906e3bd270b..6fabc1912da 100644
--- a/arch/arm64/kernel/sys_compat.c
+++ b/arch/arm64/kernel/sys_compat.c
@@ -28,43 +28,15 @@
28#include <asm/cacheflush.h> 28#include <asm/cacheflush.h>
29#include <asm/unistd32.h> 29#include <asm/unistd32.h>
30 30
31asmlinkage int compat_sys_fork(struct pt_regs *regs) 31asmlinkage int compat_sys_fork(void)
32{ 32{
33 return do_fork(SIGCHLD, regs->compat_sp, regs, 0, NULL, NULL); 33 return do_fork(SIGCHLD, 0, current_pt_regs(), 0, NULL, NULL);
34} 34}
35 35
36asmlinkage int compat_sys_clone(unsigned long clone_flags, unsigned long newsp, 36asmlinkage int compat_sys_vfork(void)
37 int __user *parent_tidptr, int tls_val,
38 int __user *child_tidptr, struct pt_regs *regs)
39{ 37{
40 if (!newsp) 38 return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, 0,
41 newsp = regs->compat_sp; 39 current_pt_regs(), 0, NULL, NULL);
42
43 return do_fork(clone_flags, newsp, regs, 0, parent_tidptr, child_tidptr);
44}
45
46asmlinkage int compat_sys_vfork(struct pt_regs *regs)
47{
48 return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, regs->compat_sp,
49 regs, 0, NULL, NULL);
50}
51
52asmlinkage int compat_sys_execve(const char __user *filenamei,
53 compat_uptr_t argv, compat_uptr_t envp,
54 struct pt_regs *regs)
55{
56 int error;
57 struct filename *filename;
58
59 filename = getname(filenamei);
60 error = PTR_ERR(filename);
61 if (IS_ERR(filename))
62 goto out;
63 error = compat_do_execve(filename->name, compat_ptr(argv),
64 compat_ptr(envp), regs);
65 putname(filename);
66out:
67 return error;
68} 40}
69 41
70asmlinkage int compat_sys_sched_rr_get_interval(compat_pid_t pid, 42asmlinkage int compat_sys_sched_rr_get_interval(compat_pid_t pid,
diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c
index 17948fc7d66..ba457943a16 100644
--- a/arch/arm64/kernel/vdso.c
+++ b/arch/arm64/kernel/vdso.c
@@ -28,6 +28,7 @@
28#include <linux/sched.h> 28#include <linux/sched.h>
29#include <linux/signal.h> 29#include <linux/signal.h>
30#include <linux/slab.h> 30#include <linux/slab.h>
31#include <linux/timekeeper_internal.h>
31#include <linux/vmalloc.h> 32#include <linux/vmalloc.h>
32 33
33#include <asm/cacheflush.h> 34#include <asm/cacheflush.h>
@@ -222,11 +223,10 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
222/* 223/*
223 * Update the vDSO data page to keep in sync with kernel timekeeping. 224 * Update the vDSO data page to keep in sync with kernel timekeeping.
224 */ 225 */
225void update_vsyscall(struct timespec *ts, struct timespec *wtm, 226void update_vsyscall(struct timekeeper *tk)
226 struct clocksource *clock, u32 mult)
227{ 227{
228 struct timespec xtime_coarse; 228 struct timespec xtime_coarse;
229 u32 use_syscall = strcmp(clock->name, "arch_sys_counter"); 229 u32 use_syscall = strcmp(tk->clock->name, "arch_sys_counter");
230 230
231 ++vdso_data->tb_seq_count; 231 ++vdso_data->tb_seq_count;
232 smp_wmb(); 232 smp_wmb();
@@ -237,13 +237,13 @@ void update_vsyscall(struct timespec *ts, struct timespec *wtm,
237 vdso_data->xtime_coarse_nsec = xtime_coarse.tv_nsec; 237 vdso_data->xtime_coarse_nsec = xtime_coarse.tv_nsec;
238 238
239 if (!use_syscall) { 239 if (!use_syscall) {
240 vdso_data->cs_cycle_last = clock->cycle_last; 240 vdso_data->cs_cycle_last = tk->clock->cycle_last;
241 vdso_data->xtime_clock_sec = ts->tv_sec; 241 vdso_data->xtime_clock_sec = tk->xtime_sec;
242 vdso_data->xtime_clock_nsec = ts->tv_nsec; 242 vdso_data->xtime_clock_nsec = tk->xtime_nsec >> tk->shift;
243 vdso_data->cs_mult = mult; 243 vdso_data->cs_mult = tk->mult;
244 vdso_data->cs_shift = clock->shift; 244 vdso_data->cs_shift = tk->shift;
245 vdso_data->wtm_clock_sec = wtm->tv_sec; 245 vdso_data->wtm_clock_sec = tk->wall_to_monotonic.tv_sec;
246 vdso_data->wtm_clock_nsec = wtm->tv_nsec; 246 vdso_data->wtm_clock_nsec = tk->wall_to_monotonic.tv_nsec;
247 } 247 }
248 248
249 smp_wmb(); 249 smp_wmb();
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index efbf7df05d3..4cd28931dba 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -80,7 +80,7 @@ static void __init zone_sizes_init(unsigned long min, unsigned long max)
80#ifdef CONFIG_ZONE_DMA32 80#ifdef CONFIG_ZONE_DMA32
81 /* 4GB maximum for 32-bit only capable devices */ 81 /* 4GB maximum for 32-bit only capable devices */
82 max_dma32 = min(max, MAX_DMA32_PFN); 82 max_dma32 = min(max, MAX_DMA32_PFN);
83 zone_size[ZONE_DMA32] = max_dma32 - min; 83 zone_size[ZONE_DMA32] = max(min, max_dma32) - min;
84#endif 84#endif
85 zone_size[ZONE_NORMAL] = max - max_dma32; 85 zone_size[ZONE_NORMAL] = max - max_dma32;
86 86
diff --git a/arch/avr32/Kconfig b/arch/avr32/Kconfig
index 06e73bf665e..649aeb9acec 100644
--- a/arch/avr32/Kconfig
+++ b/arch/avr32/Kconfig
@@ -17,6 +17,8 @@ config AVR32
17 select GENERIC_CLOCKEVENTS 17 select GENERIC_CLOCKEVENTS
18 select HAVE_MOD_ARCH_SPECIFIC 18 select HAVE_MOD_ARCH_SPECIFIC
19 select MODULES_USE_ELF_RELA 19 select MODULES_USE_ELF_RELA
20 select GENERIC_KERNEL_THREAD
21 select GENERIC_KERNEL_EXECVE
20 help 22 help
21 AVR32 is a high-performance 32-bit RISC microprocessor core, 23 AVR32 is a high-performance 32-bit RISC microprocessor core,
22 designed for cost-sensitive embedded applications, with particular 24 designed for cost-sensitive embedded applications, with particular
diff --git a/arch/avr32/include/asm/processor.h b/arch/avr32/include/asm/processor.h
index 87d8baccc60..48d71c5c898 100644
--- a/arch/avr32/include/asm/processor.h
+++ b/arch/avr32/include/asm/processor.h
@@ -142,9 +142,6 @@ struct task_struct;
142/* Free all resources held by a thread */ 142/* Free all resources held by a thread */
143extern void release_thread(struct task_struct *); 143extern void release_thread(struct task_struct *);
144 144
145/* Create a kernel thread without removing it from tasklists */
146extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
147
148/* Return saved PC of a blocked thread */ 145/* Return saved PC of a blocked thread */
149#define thread_saved_pc(tsk) ((tsk)->thread.cpu_context.pc) 146#define thread_saved_pc(tsk) ((tsk)->thread.cpu_context.pc)
150 147
diff --git a/arch/avr32/include/asm/unistd.h b/arch/avr32/include/asm/unistd.h
index 157b4bd3d5e..641023d1bcb 100644
--- a/arch/avr32/include/asm/unistd.h
+++ b/arch/avr32/include/asm/unistd.h
@@ -39,6 +39,7 @@
39#define __ARCH_WANT_SYS_GETPGRP 39#define __ARCH_WANT_SYS_GETPGRP
40#define __ARCH_WANT_SYS_RT_SIGACTION 40#define __ARCH_WANT_SYS_RT_SIGACTION
41#define __ARCH_WANT_SYS_RT_SIGSUSPEND 41#define __ARCH_WANT_SYS_RT_SIGSUSPEND
42#define __ARCH_WANT_SYS_EXECVE
42 43
43/* 44/*
44 * "Conditional" syscalls 45 * "Conditional" syscalls
diff --git a/arch/avr32/kernel/Makefile b/arch/avr32/kernel/Makefile
index 9e2c465ef3a..119a2e41def 100644
--- a/arch/avr32/kernel/Makefile
+++ b/arch/avr32/kernel/Makefile
@@ -7,7 +7,7 @@ extra-y := head.o vmlinux.lds
7obj-$(CONFIG_SUBARCH_AVR32B) += entry-avr32b.o 7obj-$(CONFIG_SUBARCH_AVR32B) += entry-avr32b.o
8obj-y += syscall_table.o syscall-stubs.o irq.o 8obj-y += syscall_table.o syscall-stubs.o irq.o
9obj-y += setup.o traps.o ocd.o ptrace.o 9obj-y += setup.o traps.o ocd.o ptrace.o
10obj-y += signal.o sys_avr32.o process.o time.o 10obj-y += signal.o process.o time.o
11obj-y += switch_to.o cpu.o 11obj-y += switch_to.o cpu.o
12obj-$(CONFIG_MODULES) += module.o avr32_ksyms.o 12obj-$(CONFIG_MODULES) += module.o avr32_ksyms.o
13obj-$(CONFIG_KPROBES) += kprobes.o 13obj-$(CONFIG_KPROBES) += kprobes.o
diff --git a/arch/avr32/kernel/entry-avr32b.S b/arch/avr32/kernel/entry-avr32b.S
index df288418131..9899d3cc6f0 100644
--- a/arch/avr32/kernel/entry-avr32b.S
+++ b/arch/avr32/kernel/entry-avr32b.S
@@ -251,13 +251,15 @@ syscall_badsys:
251 .global ret_from_fork 251 .global ret_from_fork
252ret_from_fork: 252ret_from_fork:
253 call schedule_tail 253 call schedule_tail
254 mov r12, 0
255 rjmp syscall_return
254 256
255 /* check for syscall tracing */ 257 .global ret_from_kernel_thread
256 get_thread_info r0 258ret_from_kernel_thread:
257 ld.w r1, r0[TI_flags] 259 call schedule_tail
258 andl r1, _TIF_ALLWORK_MASK, COH 260 mov r12, r0
259 brne syscall_exit_work 261 mov lr, r2 /* syscall_return */
260 rjmp syscall_exit_cont 262 mov pc, r1
261 263
262syscall_trace_enter: 264syscall_trace_enter:
263 pushm r8-r12 265 pushm r8-r12
diff --git a/arch/avr32/kernel/process.c b/arch/avr32/kernel/process.c
index 1bb0a8abd79..09b894d96d6 100644
--- a/arch/avr32/kernel/process.c
+++ b/arch/avr32/kernel/process.c
@@ -69,44 +69,6 @@ void machine_restart(char *cmd)
69} 69}
70 70
71/* 71/*
72 * PC is actually discarded when returning from a system call -- the
73 * return address must be stored in LR. This function will make sure
74 * LR points to do_exit before starting the thread.
75 *
76 * Also, when returning from fork(), r12 is 0, so we must copy the
77 * argument as well.
78 *
79 * r0 : The argument to the main thread function
80 * r1 : The address of do_exit
81 * r2 : The address of the main thread function
82 */
83asmlinkage extern void kernel_thread_helper(void);
84__asm__(" .type kernel_thread_helper, @function\n"
85 "kernel_thread_helper:\n"
86 " mov r12, r0\n"
87 " mov lr, r2\n"
88 " mov pc, r1\n"
89 " .size kernel_thread_helper, . - kernel_thread_helper");
90
91int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags)
92{
93 struct pt_regs regs;
94
95 memset(&regs, 0, sizeof(regs));
96
97 regs.r0 = (unsigned long)arg;
98 regs.r1 = (unsigned long)fn;
99 regs.r2 = (unsigned long)do_exit;
100 regs.lr = (unsigned long)kernel_thread_helper;
101 regs.pc = (unsigned long)kernel_thread_helper;
102 regs.sr = MODE_SUPERVISOR;
103
104 return do_fork(flags | CLONE_VM | CLONE_UNTRACED,
105 0, &regs, 0, NULL, NULL);
106}
107EXPORT_SYMBOL(kernel_thread);
108
109/*
110 * Free current thread data structures etc 72 * Free current thread data structures etc
111 */ 73 */
112void exit_thread(void) 74void exit_thread(void)
@@ -332,26 +294,31 @@ int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu)
332} 294}
333 295
334asmlinkage void ret_from_fork(void); 296asmlinkage void ret_from_fork(void);
297asmlinkage void ret_from_kernel_thread(void);
298asmlinkage void syscall_return(void);
335 299
336int copy_thread(unsigned long clone_flags, unsigned long usp, 300int copy_thread(unsigned long clone_flags, unsigned long usp,
337 unsigned long unused, 301 unsigned long arg,
338 struct task_struct *p, struct pt_regs *regs) 302 struct task_struct *p, struct pt_regs *regs)
339{ 303{
340 struct pt_regs *childregs; 304 struct pt_regs *childregs = task_pt_regs(p);
341 305
342 childregs = ((struct pt_regs *)(THREAD_SIZE + (unsigned long)task_stack_page(p))) - 1; 306 if (unlikely(!regs)) {
343 *childregs = *regs; 307 memset(childregs, 0, sizeof(struct pt_regs));
344 308 p->thread.cpu_context.r0 = arg;
345 if (user_mode(regs)) 309 p->thread.cpu_context.r1 = usp; /* fn */
310 p->thread.cpu_context.r2 = syscall_return;
311 p->thread.cpu_context.pc = (unsigned long)ret_from_kernel_thread;
312 childregs->sr = MODE_SUPERVISOR;
313 } else {
314 *childregs = *regs;
346 childregs->sp = usp; 315 childregs->sp = usp;
347 else 316 childregs->r12 = 0; /* Set return value for child */
348 childregs->sp = (unsigned long)task_stack_page(p) + THREAD_SIZE; 317 p->thread.cpu_context.pc = (unsigned long)ret_from_fork;
349 318 }
350 childregs->r12 = 0; /* Set return value for child */
351 319
352 p->thread.cpu_context.sr = MODE_SUPERVISOR | SR_GM; 320 p->thread.cpu_context.sr = MODE_SUPERVISOR | SR_GM;
353 p->thread.cpu_context.ksp = (unsigned long)childregs; 321 p->thread.cpu_context.ksp = (unsigned long)childregs;
354 p->thread.cpu_context.pc = (unsigned long)ret_from_fork;
355 322
356 clear_tsk_thread_flag(p, TIF_DEBUG); 323 clear_tsk_thread_flag(p, TIF_DEBUG);
357 if ((clone_flags & CLONE_PTRACE) && test_thread_flag(TIF_DEBUG)) 324 if ((clone_flags & CLONE_PTRACE) && test_thread_flag(TIF_DEBUG))
@@ -382,27 +349,6 @@ asmlinkage int sys_vfork(struct pt_regs *regs)
382 0, NULL, NULL); 349 0, NULL, NULL);
383} 350}
384 351
385asmlinkage int sys_execve(const char __user *ufilename,
386 const char __user *const __user *uargv,
387 const char __user *const __user *uenvp,
388 struct pt_regs *regs)
389{
390 int error;
391 struct filename *filename;
392
393 filename = getname(ufilename);
394 error = PTR_ERR(filename);
395 if (IS_ERR(filename))
396 goto out;
397
398 error = do_execve(filename->name, uargv, uenvp, regs);
399 putname(filename);
400
401out:
402 return error;
403}
404
405
406/* 352/*
407 * This function is supposed to answer the question "who called 353 * This function is supposed to answer the question "who called
408 * schedule()?" 354 * schedule()?"
diff --git a/arch/avr32/kernel/sys_avr32.c b/arch/avr32/kernel/sys_avr32.c
deleted file mode 100644
index 62635a09ae3..00000000000
--- a/arch/avr32/kernel/sys_avr32.c
+++ /dev/null
@@ -1,24 +0,0 @@
1/*
2 * Copyright (C) 2004-2006 Atmel Corporation
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
8#include <linux/unistd.h>
9
10int kernel_execve(const char *file,
11 const char *const *argv,
12 const char *const *envp)
13{
14 register long scno asm("r8") = __NR_execve;
15 register long sc1 asm("r12") = (long)file;
16 register long sc2 asm("r11") = (long)argv;
17 register long sc3 asm("r10") = (long)envp;
18
19 asm volatile("scall"
20 : "=r"(sc1)
21 : "r"(scno), "0"(sc1), "r"(sc2), "r"(sc3)
22 : "cc", "memory");
23 return sc1;
24}
diff --git a/arch/avr32/kernel/syscall-stubs.S b/arch/avr32/kernel/syscall-stubs.S
index 0447a3e2ba6..285a61b9194 100644
--- a/arch/avr32/kernel/syscall-stubs.S
+++ b/arch/avr32/kernel/syscall-stubs.S
@@ -50,12 +50,6 @@ __sys_vfork:
50 mov r12, sp 50 mov r12, sp
51 rjmp sys_vfork 51 rjmp sys_vfork
52 52
53 .global __sys_execve
54 .type __sys_execve,@function
55__sys_execve:
56 mov r9, sp
57 rjmp sys_execve
58
59 .global __sys_mmap2 53 .global __sys_mmap2
60 .type __sys_mmap2,@function 54 .type __sys_mmap2,@function
61__sys_mmap2: 55__sys_mmap2:
diff --git a/arch/avr32/kernel/syscall_table.S b/arch/avr32/kernel/syscall_table.S
index 6eba53530d1..fc649770681 100644
--- a/arch/avr32/kernel/syscall_table.S
+++ b/arch/avr32/kernel/syscall_table.S
@@ -24,7 +24,7 @@ sys_call_table:
24 .long sys_creat 24 .long sys_creat
25 .long sys_link 25 .long sys_link
26 .long sys_unlink /* 10 */ 26 .long sys_unlink /* 10 */
27 .long __sys_execve 27 .long sys_execve
28 .long sys_chdir 28 .long sys_chdir
29 .long sys_time 29 .long sys_time
30 .long sys_mknod 30 .long sys_mknod
diff --git a/arch/c6x/Kconfig b/arch/c6x/Kconfig
index aee1b569ee6..66eab3703c7 100644
--- a/arch/c6x/Kconfig
+++ b/arch/c6x/Kconfig
@@ -18,6 +18,7 @@ config C6X
18 select OF_EARLY_FLATTREE 18 select OF_EARLY_FLATTREE
19 select GENERIC_CLOCKEVENTS 19 select GENERIC_CLOCKEVENTS
20 select GENERIC_KERNEL_THREAD 20 select GENERIC_KERNEL_THREAD
21 select GENERIC_KERNEL_EXECVE
21 select MODULES_USE_ELF_RELA 22 select MODULES_USE_ELF_RELA
22 23
23config MMU 24config MMU
diff --git a/arch/c6x/include/uapi/asm/unistd.h b/arch/c6x/include/uapi/asm/unistd.h
index 4ff747d12da..625beafb9cd 100644
--- a/arch/c6x/include/uapi/asm/unistd.h
+++ b/arch/c6x/include/uapi/asm/unistd.h
@@ -14,7 +14,6 @@
14 * more details. 14 * more details.
15 */ 15 */
16 16
17#define __ARCH_WANT_KERNEL_EXECVE
18#define __ARCH_WANT_SYS_EXECVE 17#define __ARCH_WANT_SYS_EXECVE
19 18
20/* Use the standard ABI for syscalls. */ 19/* Use the standard ABI for syscalls. */
diff --git a/arch/c6x/kernel/entry.S b/arch/c6x/kernel/entry.S
index 5449c36018f..75f6f36472c 100644
--- a/arch/c6x/kernel/entry.S
+++ b/arch/c6x/kernel/entry.S
@@ -413,19 +413,9 @@ ENTRY(ret_from_kernel_thread)
4130: 4130:
414 B .S2 B10 /* call fn */ 414 B .S2 B10 /* call fn */
415 LDW .D2T1 *+SP(REGS_A1+8),A4 /* get arg */ 415 LDW .D2T1 *+SP(REGS_A1+8),A4 /* get arg */
416 MVKL .S2 sys_exit,B11 416 ADDKPC .S2 ret_from_fork_2,B3,3
417 MVKH .S2 sys_exit,B11
418 ADDKPC .S2 0f,B3,1
4190:
420 BNOP .S2 B11,5 /* jump to sys_exit */
421ENDPROC(ret_from_kernel_thread) 417ENDPROC(ret_from_kernel_thread)
422 418
423ENTRY(ret_from_kernel_execve)
424 GET_THREAD_INFO A12
425 BNOP .S2 syscall_exit,4
426 ADD .D2X A4,-8,SP
427ENDPROC(ret_from_kernel_execve)
428
429 ;; 419 ;;
430 ;; These are the interrupt handlers, responsible for calling __do_IRQ() 420 ;; These are the interrupt handlers, responsible for calling __do_IRQ()
431 ;; int6 is used for syscalls (see _system_call entry) 421 ;; int6 is used for syscalls (see _system_call entry)
diff --git a/arch/cris/Kconfig b/arch/cris/Kconfig
index a67244473a3..81b59d18867 100644
--- a/arch/cris/Kconfig
+++ b/arch/cris/Kconfig
@@ -49,6 +49,8 @@ config CRIS
49 select GENERIC_SMP_IDLE_THREAD if ETRAX_ARCH_V32 49 select GENERIC_SMP_IDLE_THREAD if ETRAX_ARCH_V32
50 select GENERIC_CMOS_UPDATE 50 select GENERIC_CMOS_UPDATE
51 select MODULES_USE_ELF_RELA 51 select MODULES_USE_ELF_RELA
52 select GENERIC_KERNEL_THREAD
53 select GENERIC_KERNEL_EXECVE
52 54
53config HZ 55config HZ
54 int 56 int
diff --git a/arch/cris/arch-v10/kernel/entry.S b/arch/cris/arch-v10/kernel/entry.S
index 592fbe9dfb6..897bba67bf7 100644
--- a/arch/cris/arch-v10/kernel/entry.S
+++ b/arch/cris/arch-v10/kernel/entry.S
@@ -35,6 +35,7 @@
35 .globl system_call 35 .globl system_call
36 .globl ret_from_intr 36 .globl ret_from_intr
37 .globl ret_from_fork 37 .globl ret_from_fork
38 .globl ret_from_kernel_thread
38 .globl resume 39 .globl resume
39 .globl multiple_interrupt 40 .globl multiple_interrupt
40 .globl hwbreakpoint 41 .globl hwbreakpoint
@@ -81,7 +82,14 @@ ret_from_fork:
81 jsr schedule_tail 82 jsr schedule_tail
82 ba ret_from_sys_call 83 ba ret_from_sys_call
83 nop 84 nop
84 85
86ret_from_kernel_thread:
87 jsr schedule_tail
88 move.d $r2, $r10 ; argument is here
89 jsr $r1 ; call the payload
90 moveq 0, $r9 ; no syscall restarts, TYVM...
91 ba ret_from_sys_call
92
85ret_from_intr: 93ret_from_intr:
86 ;; check for resched if preemptive kernel or if we're going back to user-mode 94 ;; check for resched if preemptive kernel or if we're going back to user-mode
87 ;; this test matches the user_regs(regs) macro 95 ;; this test matches the user_regs(regs) macro
@@ -586,13 +594,6 @@ _ugdb_handle_breakpoint:
586 ba do_sigtrap ; SIGTRAP the offending process. 594 ba do_sigtrap ; SIGTRAP the offending process.
587 pop $dccr ; Restore dccr in delay slot. 595 pop $dccr ; Restore dccr in delay slot.
588 596
589 .global kernel_execve
590kernel_execve:
591 move.d __NR_execve, $r9
592 break 13
593 ret
594 nop
595
596 .data 597 .data
597 598
598hw_bp_trigs: 599hw_bp_trigs:
diff --git a/arch/cris/arch-v10/kernel/process.c b/arch/cris/arch-v10/kernel/process.c
index 15ac7150371..1d6458287f3 100644
--- a/arch/cris/arch-v10/kernel/process.c
+++ b/arch/cris/arch-v10/kernel/process.c
@@ -17,6 +17,7 @@
17#include <arch/svinto.h> 17#include <arch/svinto.h>
18#include <linux/init.h> 18#include <linux/init.h>
19#include <arch/system.h> 19#include <arch/system.h>
20#include <asm/ptrace.h>
20 21
21#ifdef CONFIG_ETRAX_GPIO 22#ifdef CONFIG_ETRAX_GPIO
22void etrax_gpio_wake_up_check(void); /* drivers/gpio.c */ 23void etrax_gpio_wake_up_check(void); /* drivers/gpio.c */
@@ -81,31 +82,6 @@ unsigned long thread_saved_pc(struct task_struct *t)
81 return task_pt_regs(t)->irp; 82 return task_pt_regs(t)->irp;
82} 83}
83 84
84static void kernel_thread_helper(void* dummy, int (*fn)(void *), void * arg)
85{
86 fn(arg);
87 do_exit(-1); /* Should never be called, return bad exit value */
88}
89
90/*
91 * Create a kernel thread
92 */
93int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
94{
95 struct pt_regs regs;
96
97 memset(&regs, 0, sizeof(regs));
98
99 /* Don't use r10 since that is set to 0 in copy_thread */
100 regs.r11 = (unsigned long)fn;
101 regs.r12 = (unsigned long)arg;
102 regs.irp = (unsigned long)kernel_thread_helper;
103 regs.dccr = 1 << I_DCCR_BITNR;
104
105 /* Ok, create the new process.. */
106 return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, &regs, 0, NULL, NULL);
107}
108
109/* setup the child's kernel stack with a pt_regs and switch_stack on it. 85/* setup the child's kernel stack with a pt_regs and switch_stack on it.
110 * it will be un-nested during _resume and _ret_from_sys_call when the 86 * it will be un-nested during _resume and _ret_from_sys_call when the
111 * new thread is scheduled. 87 * new thread is scheduled.
@@ -115,29 +91,35 @@ int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
115 * 91 *
116 */ 92 */
117asmlinkage void ret_from_fork(void); 93asmlinkage void ret_from_fork(void);
94asmlinkage void ret_from_kernel_thread(void);
118 95
119int copy_thread(unsigned long clone_flags, unsigned long usp, 96int copy_thread(unsigned long clone_flags, unsigned long usp,
120 unsigned long unused, 97 unsigned long arg,
121 struct task_struct *p, struct pt_regs *regs) 98 struct task_struct *p, struct pt_regs *regs)
122{ 99{
123 struct pt_regs * childregs; 100 struct pt_regs *childregs = task_pt_regs(p);
124 struct switch_stack *swstack; 101 struct switch_stack *swstack = ((struct switch_stack *)childregs) - 1;
125 102
126 /* put the pt_regs structure at the end of the new kernel stack page and fix it up 103 /* put the pt_regs structure at the end of the new kernel stack page and fix it up
127 * remember that the task_struct doubles as the kernel stack for the task 104 * remember that the task_struct doubles as the kernel stack for the task
128 */ 105 */
129 106
130 childregs = task_pt_regs(p); 107 if (unlikely(p->flags & PF_KTHREAD)) {
131 108 memset(swstack, 0,
109 sizeof(struct switch_stack) + sizeof(struct pt_regs));
110 swstack->r1 = usp;
111 swstack->r2 = arg;
112 childregs->dccr = 1 << I_DCCR_BITNR;
113 swstack->return_ip = (unsigned long) ret_from_kernel_thread;
114 p->thread.ksp = (unsigned long) swstack;
115 p->thread.usp = 0;
116 return 0;
117 }
132 *childregs = *regs; /* struct copy of pt_regs */ 118 *childregs = *regs; /* struct copy of pt_regs */
133
134 p->set_child_tid = p->clear_child_tid = NULL;
135 119
136 childregs->r10 = 0; /* child returns 0 after a fork/clone */ 120 childregs->r10 = 0; /* child returns 0 after a fork/clone */
137
138 /* put the switch stack right below the pt_regs */
139 121
140 swstack = ((struct switch_stack *)childregs) - 1; 122 /* put the switch stack right below the pt_regs */
141 123
142 swstack->r9 = 0; /* parameter to ret_from_sys_call, 0 == dont restart the syscall */ 124 swstack->r9 = 0; /* parameter to ret_from_sys_call, 0 == dont restart the syscall */
143 125
@@ -147,7 +129,7 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
147 129
148 /* fix the user-mode stackpointer */ 130 /* fix the user-mode stackpointer */
149 131
150 p->thread.usp = usp; 132 p->thread.usp = usp;
151 133
152 /* and the kernel-mode one */ 134 /* and the kernel-mode one */
153 135
@@ -161,68 +143,28 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
161 return 0; 143 return 0;
162} 144}
163 145
164/* 146asmlinkage int sys_fork(void)
165 * Be aware of the "magic" 7th argument in the four system-calls below.
166 * They need the latest stackframe, which is put as the 7th argument by
167 * entry.S. The previous arguments are dummies or actually used, but need
168 * to be defined to reach the 7th argument.
169 *
170 * N.B.: Another method to get the stackframe is to use current_regs(). But
171 * it returns the latest stack-frame stacked when going from _user mode_ and
172 * some of these (at least sys_clone) are called from kernel-mode sometimes
173 * (for example during kernel_thread, above) and thus cannot use it. Thus,
174 * to be sure not to get any surprises, we use the method for the other calls
175 * as well.
176 */
177
178asmlinkage int sys_fork(long r10, long r11, long r12, long r13, long mof, long srp,
179 struct pt_regs *regs)
180{ 147{
181 return do_fork(SIGCHLD, rdusp(), regs, 0, NULL, NULL); 148 return do_fork(SIGCHLD, rdusp(), current_pt_regs(), 0, NULL, NULL);
182} 149}
183 150
184/* if newusp is 0, we just grab the old usp */ 151/* if newusp is 0, we just grab the old usp */
185/* FIXME: Is parent_tid/child_tid really third/fourth argument? Update lib? */ 152/* FIXME: Is parent_tid/child_tid really third/fourth argument? Update lib? */
186asmlinkage int sys_clone(unsigned long newusp, unsigned long flags, 153asmlinkage int sys_clone(unsigned long newusp, unsigned long flags,
187 int* parent_tid, int* child_tid, long mof, long srp, 154 int* parent_tid, int* child_tid)
188 struct pt_regs *regs)
189{ 155{
190 if (!newusp) 156 if (!newusp)
191 newusp = rdusp(); 157 newusp = rdusp();
192 return do_fork(flags, newusp, regs, 0, parent_tid, child_tid); 158 return do_fork(flags, newusp, current_pt_regs(), 0, parent_tid, child_tid);
193} 159}
194 160
195/* vfork is a system call in i386 because of register-pressure - maybe 161/* vfork is a system call in i386 because of register-pressure - maybe
196 * we can remove it and handle it in libc but we put it here until then. 162 * we can remove it and handle it in libc but we put it here until then.
197 */ 163 */
198 164
199asmlinkage int sys_vfork(long r10, long r11, long r12, long r13, long mof, long srp, 165asmlinkage int sys_vfork(void)
200 struct pt_regs *regs)
201{
202 return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, rdusp(), regs, 0, NULL, NULL);
203}
204
205/*
206 * sys_execve() executes a new program.
207 */
208asmlinkage int sys_execve(const char *fname,
209 const char *const *argv,
210 const char *const *envp,
211 long r13, long mof, long srp,
212 struct pt_regs *regs)
213{ 166{
214 int error; 167 return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, rdusp(), current_pt_regs(), 0, NULL, NULL);
215 struct filename *filename;
216
217 filename = getname(fname);
218 error = PTR_ERR(filename);
219
220 if (IS_ERR(filename))
221 goto out;
222 error = do_execve(filename->name, argv, envp, regs);
223 putname(filename);
224 out:
225 return error;
226} 168}
227 169
228unsigned long get_wchan(struct task_struct *p) 170unsigned long get_wchan(struct task_struct *p)
diff --git a/arch/cris/arch-v32/kernel/entry.S b/arch/cris/arch-v32/kernel/entry.S
index c3ea4694fba..faa644111fe 100644
--- a/arch/cris/arch-v32/kernel/entry.S
+++ b/arch/cris/arch-v32/kernel/entry.S
@@ -31,6 +31,7 @@
31 .globl system_call 31 .globl system_call
32 .globl ret_from_intr 32 .globl ret_from_intr
33 .globl ret_from_fork 33 .globl ret_from_fork
34 .globl ret_from_kernel_thread
34 .globl resume 35 .globl resume
35 .globl multiple_interrupt 36 .globl multiple_interrupt
36 .globl nmi_interrupt 37 .globl nmi_interrupt
@@ -84,6 +85,18 @@ ret_from_fork:
84 nop 85 nop
85 .size ret_from_fork, . - ret_from_fork 86 .size ret_from_fork, . - ret_from_fork
86 87
88 .type ret_from_kernel_thread,@function
89ret_from_kernel_thread:
90 jsr schedule_tail
91 nop
92 move.d $r2, $r10
93 jsr $r1
94 nop
95 moveq 0, $r9 ; no syscall restarts, TYVM...
96 ba ret_from_sys_call
97 nop
98 .size ret_from_kernel_thread, . - ret_from_kernel_thread
99
87 .type ret_from_intr,@function 100 .type ret_from_intr,@function
88ret_from_intr: 101ret_from_intr:
89 ;; Check for resched if preemptive kernel, or if we're going back to 102 ;; Check for resched if preemptive kernel, or if we're going back to
@@ -531,15 +544,6 @@ _ugdb_handle_exception:
531 ba do_sigtrap ; SIGTRAP the offending process. 544 ba do_sigtrap ; SIGTRAP the offending process.
532 move.d [$sp+], $r0 ; Restore R0 in delay slot. 545 move.d [$sp+], $r0 ; Restore R0 in delay slot.
533 546
534 .global kernel_execve
535 .type kernel_execve,@function
536kernel_execve:
537 move.d __NR_execve, $r9
538 break 13
539 ret
540 nop
541 .size kernel_execve, . - kernel_execve
542
543 .data 547 .data
544 548
545 .section .rodata,"a" 549 .section .rodata,"a"
diff --git a/arch/cris/arch-v32/kernel/process.c b/arch/cris/arch-v32/kernel/process.c
index 4e999224635..fe465401b6e 100644
--- a/arch/cris/arch-v32/kernel/process.c
+++ b/arch/cris/arch-v32/kernel/process.c
@@ -16,6 +16,7 @@
16#include <hwregs/reg_map.h> 16#include <hwregs/reg_map.h>
17#include <hwregs/timer_defs.h> 17#include <hwregs/timer_defs.h>
18#include <hwregs/intr_vect_defs.h> 18#include <hwregs/intr_vect_defs.h>
19#include <asm/ptrace.h>
19 20
20extern void stop_watchdog(void); 21extern void stop_watchdog(void);
21 22
@@ -94,31 +95,6 @@ unsigned long thread_saved_pc(struct task_struct *t)
94 return task_pt_regs(t)->erp; 95 return task_pt_regs(t)->erp;
95} 96}
96 97
97static void
98kernel_thread_helper(void* dummy, int (*fn)(void *), void * arg)
99{
100 fn(arg);
101 do_exit(-1); /* Should never be called, return bad exit value. */
102}
103
104/* Create a kernel thread. */
105int
106kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
107{
108 struct pt_regs regs;
109
110 memset(&regs, 0, sizeof(regs));
111
112 /* Don't use r10 since that is set to 0 in copy_thread. */
113 regs.r11 = (unsigned long) fn;
114 regs.r12 = (unsigned long) arg;
115 regs.erp = (unsigned long) kernel_thread_helper;
116 regs.ccs = 1 << (I_CCS_BITNR + CCS_SHIFT);
117
118 /* Create the new process. */
119 return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, &regs, 0, NULL, NULL);
120}
121
122/* 98/*
123 * Setup the child's kernel stack with a pt_regs and call switch_stack() on it. 99 * Setup the child's kernel stack with a pt_regs and call switch_stack() on it.
124 * It will be unnested during _resume and _ret_from_sys_call when the new thread 100 * It will be unnested during _resume and _ret_from_sys_call when the new thread
@@ -129,23 +105,33 @@ kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
129 */ 105 */
130 106
131extern asmlinkage void ret_from_fork(void); 107extern asmlinkage void ret_from_fork(void);
108extern asmlinkage void ret_from_kernel_thread(void);
132 109
133int 110int
134copy_thread(unsigned long clone_flags, unsigned long usp, 111copy_thread(unsigned long clone_flags, unsigned long usp,
135 unsigned long unused, 112 unsigned long arg,
136 struct task_struct *p, struct pt_regs *regs) 113 struct task_struct *p, struct pt_regs *regs)
137{ 114{
138 struct pt_regs *childregs; 115 struct pt_regs *childregs = task_pt_regs(p);
139 struct switch_stack *swstack; 116 struct switch_stack *swstack = ((struct switch_stack *) childregs) - 1;
140 117
141 /* 118 /*
142 * Put the pt_regs structure at the end of the new kernel stack page and 119 * Put the pt_regs structure at the end of the new kernel stack page and
143 * fix it up. Note: the task_struct doubles as the kernel stack for the 120 * fix it up. Note: the task_struct doubles as the kernel stack for the
144 * task. 121 * task.
145 */ 122 */
146 childregs = task_pt_regs(p); 123 if (unlikely(p->flags & PF_KTHREAD)) {
124 memset(swstack, 0,
125 sizeof(struct switch_stack) + sizeof(struct pt_regs));
126 swstack->r1 = usp;
127 swstack->r2 = arg;
128 childregs->ccs = 1 << (I_CCS_BITNR + CCS_SHIFT);
129 swstack->return_ip = (unsigned long) ret_from_kernel_thread;
130 p->thread.ksp = (unsigned long) swstack;
131 p->thread.usp = 0;
132 return 0;
133 }
147 *childregs = *regs; /* Struct copy of pt_regs. */ 134 *childregs = *regs; /* Struct copy of pt_regs. */
148 p->set_child_tid = p->clear_child_tid = NULL;
149 childregs->r10 = 0; /* Child returns 0 after a fork/clone. */ 135 childregs->r10 = 0; /* Child returns 0 after a fork/clone. */
150 136
151 /* Set a new TLS ? 137 /* Set a new TLS ?
@@ -156,7 +142,6 @@ copy_thread(unsigned long clone_flags, unsigned long usp,
156 } 142 }
157 143
158 /* Put the switch stack right below the pt_regs. */ 144 /* Put the switch stack right below the pt_regs. */
159 swstack = ((struct switch_stack *) childregs) - 1;
160 145
161 /* Parameter to ret_from_sys_call. 0 is don't restart the syscall. */ 146 /* Parameter to ret_from_sys_call. 0 is don't restart the syscall. */
162 swstack->r9 = 0; 147 swstack->r9 = 0;
@@ -174,35 +159,21 @@ copy_thread(unsigned long clone_flags, unsigned long usp,
174 return 0; 159 return 0;
175} 160}
176 161
177/*
178 * Be aware of the "magic" 7th argument in the four system-calls below.
179 * They need the latest stackframe, which is put as the 7th argument by
180 * entry.S. The previous arguments are dummies or actually used, but need
181 * to be defined to reach the 7th argument.
182 *
183 * N.B.: Another method to get the stackframe is to use current_regs(). But
184 * it returns the latest stack-frame stacked when going from _user mode_ and
185 * some of these (at least sys_clone) are called from kernel-mode sometimes
186 * (for example during kernel_thread, above) and thus cannot use it. Thus,
187 * to be sure not to get any surprises, we use the method for the other calls
188 * as well.
189 */
190asmlinkage int 162asmlinkage int
191sys_fork(long r10, long r11, long r12, long r13, long mof, long srp, 163sys_fork(void)
192 struct pt_regs *regs)
193{ 164{
194 return do_fork(SIGCHLD, rdusp(), regs, 0, NULL, NULL); 165 return do_fork(SIGCHLD, rdusp(), current_pt_regs(), 0, NULL, NULL);
195} 166}
196 167
197/* FIXME: Is parent_tid/child_tid really third/fourth argument? Update lib? */ 168/* FIXME: Is parent_tid/child_tid really third/fourth argument? Update lib? */
198asmlinkage int 169asmlinkage int
199sys_clone(unsigned long newusp, unsigned long flags, int *parent_tid, int *child_tid, 170sys_clone(unsigned long newusp, unsigned long flags, int *parent_tid, int *child_tid,
200 unsigned long tls, long srp, struct pt_regs *regs) 171 unsigned long tls)
201{ 172{
202 if (!newusp) 173 if (!newusp)
203 newusp = rdusp(); 174 newusp = rdusp();
204 175
205 return do_fork(flags, newusp, regs, 0, parent_tid, child_tid); 176 return do_fork(flags, newusp, current_pt_regs(), 0, parent_tid, child_tid);
206} 177}
207 178
208/* 179/*
@@ -210,32 +181,9 @@ sys_clone(unsigned long newusp, unsigned long flags, int *parent_tid, int *child
210 * we can remove it and handle it in libc but we put it here until then. 181 * we can remove it and handle it in libc but we put it here until then.
211 */ 182 */
212asmlinkage int 183asmlinkage int
213sys_vfork(long r10, long r11, long r12, long r13, long mof, long srp, 184sys_vfork(void)
214 struct pt_regs *regs)
215{
216 return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, rdusp(), regs, 0, NULL, NULL);
217}
218
219/* sys_execve() executes a new program. */
220asmlinkage int
221sys_execve(const char *fname,
222 const char *const *argv,
223 const char *const *envp, long r13, long mof, long srp,
224 struct pt_regs *regs)
225{ 185{
226 int error; 186 return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, rdusp(), current_pt_regs(), 0, NULL, NULL);
227 struct filename *filename;
228
229 filename = getname(fname);
230 error = PTR_ERR(filename);
231
232 if (IS_ERR(filename))
233 goto out;
234
235 error = do_execve(filename->name, argv, envp, regs);
236 putname(filename);
237 out:
238 return error;
239} 187}
240 188
241unsigned long 189unsigned long
diff --git a/arch/cris/include/asm/processor.h b/arch/cris/include/asm/processor.h
index ef4e1bc3efc..675823f70c0 100644
--- a/arch/cris/include/asm/processor.h
+++ b/arch/cris/include/asm/processor.h
@@ -49,8 +49,6 @@ struct task_struct;
49#define task_pt_regs(task) user_regs(task_thread_info(task)) 49#define task_pt_regs(task) user_regs(task_thread_info(task))
50#define current_regs() task_pt_regs(current) 50#define current_regs() task_pt_regs(current)
51 51
52extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
53
54unsigned long get_wchan(struct task_struct *p); 52unsigned long get_wchan(struct task_struct *p);
55 53
56#define KSTK_ESP(tsk) ((tsk) == current ? rdusp() : (tsk)->thread.usp) 54#define KSTK_ESP(tsk) ((tsk) == current ? rdusp() : (tsk)->thread.usp)
diff --git a/arch/cris/include/asm/unistd.h b/arch/cris/include/asm/unistd.h
index 51873a446f8..f181d1fc763 100644
--- a/arch/cris/include/asm/unistd.h
+++ b/arch/cris/include/asm/unistd.h
@@ -371,6 +371,7 @@
371#define __ARCH_WANT_SYS_SIGPROCMASK 371#define __ARCH_WANT_SYS_SIGPROCMASK
372#define __ARCH_WANT_SYS_RT_SIGACTION 372#define __ARCH_WANT_SYS_RT_SIGACTION
373#define __ARCH_WANT_SYS_RT_SIGSUSPEND 373#define __ARCH_WANT_SYS_RT_SIGSUSPEND
374#define __ARCH_WANT_SYS_EXECVE
374 375
375/* 376/*
376 * "Conditional" syscalls 377 * "Conditional" syscalls
diff --git a/arch/cris/kernel/crisksyms.c b/arch/cris/kernel/crisksyms.c
index 7ac000f6a88..5868cee20eb 100644
--- a/arch/cris/kernel/crisksyms.c
+++ b/arch/cris/kernel/crisksyms.c
@@ -30,7 +30,6 @@ extern void __negdi2(void);
30extern void iounmap(volatile void * __iomem); 30extern void iounmap(volatile void * __iomem);
31 31
32/* Platform dependent support */ 32/* Platform dependent support */
33EXPORT_SYMBOL(kernel_thread);
34EXPORT_SYMBOL(get_cmos_time); 33EXPORT_SYMBOL(get_cmos_time);
35EXPORT_SYMBOL(loops_per_usec); 34EXPORT_SYMBOL(loops_per_usec);
36 35
diff --git a/arch/frv/Kconfig b/arch/frv/Kconfig
index b7412504f08..df2eb4bd9fa 100644
--- a/arch/frv/Kconfig
+++ b/arch/frv/Kconfig
@@ -13,6 +13,7 @@ config FRV
13 select GENERIC_CPU_DEVICES 13 select GENERIC_CPU_DEVICES
14 select ARCH_WANT_IPC_PARSE_VERSION 14 select ARCH_WANT_IPC_PARSE_VERSION
15 select GENERIC_KERNEL_THREAD 15 select GENERIC_KERNEL_THREAD
16 select GENERIC_KERNEL_EXECVE
16 17
17config ZONE_DMA 18config ZONE_DMA
18 bool 19 bool
diff --git a/arch/frv/boot/Makefile b/arch/frv/boot/Makefile
index 6ae3254da01..636d5bbcd53 100644
--- a/arch/frv/boot/Makefile
+++ b/arch/frv/boot/Makefile
@@ -17,6 +17,8 @@ PARAMS_PHYS = 0x0207c000
17INITRD_PHYS = 0x02180000 17INITRD_PHYS = 0x02180000
18INITRD_VIRT = 0x02180000 18INITRD_VIRT = 0x02180000
19 19
20OBJCOPYFLAGS :=-O binary -R .note -R .note.gnu.build-id -R .comment
21
20# 22#
21# If you don't define ZRELADDR above, 23# If you don't define ZRELADDR above,
22# then it defaults to ZTEXTADDR 24# then it defaults to ZTEXTADDR
@@ -32,18 +34,18 @@ Image: $(obj)/Image
32targets: $(obj)/Image 34targets: $(obj)/Image
33 35
34$(obj)/Image: vmlinux FORCE 36$(obj)/Image: vmlinux FORCE
35 $(OBJCOPY) -O binary -R .note -R .comment -S vmlinux $@ 37 $(OBJCOPY) $(OBJCOPYFLAGS) -S vmlinux $@
36 38
37#$(obj)/Image: $(CONFIGURE) $(SYSTEM) 39#$(obj)/Image: $(CONFIGURE) $(SYSTEM)
38# $(OBJCOPY) -O binary -R .note -R .comment -g -S $(SYSTEM) $@ 40# $(OBJCOPY) $(OBJCOPYFLAGS) -g -S $(SYSTEM) $@
39 41
40bzImage: zImage 42bzImage: zImage
41 43
42zImage: $(CONFIGURE) compressed/$(LINUX) 44zImage: $(CONFIGURE) compressed/$(LINUX)
43 $(OBJCOPY) -O binary -R .note -R .comment -S compressed/$(LINUX) $@ 45 $(OBJCOPY) $(OBJCOPYFLAGS) -S compressed/$(LINUX) $@
44 46
45bootpImage: bootp/bootp 47bootpImage: bootp/bootp
46 $(OBJCOPY) -O binary -R .note -R .comment -S bootp/bootp $@ 48 $(OBJCOPY) $(OBJCOPYFLAGS) -S bootp/bootp $@
47 49
48compressed/$(LINUX): $(LINUX) dep 50compressed/$(LINUX): $(LINUX) dep
49 @$(MAKE) -C compressed $(LINUX) 51 @$(MAKE) -C compressed $(LINUX)
diff --git a/arch/frv/include/asm/unistd.h b/arch/frv/include/asm/unistd.h
index 266a5b25a0c..2358634cacc 100644
--- a/arch/frv/include/asm/unistd.h
+++ b/arch/frv/include/asm/unistd.h
@@ -30,7 +30,6 @@
30#define __ARCH_WANT_SYS_RT_SIGACTION 30#define __ARCH_WANT_SYS_RT_SIGACTION
31#define __ARCH_WANT_SYS_RT_SIGSUSPEND 31#define __ARCH_WANT_SYS_RT_SIGSUSPEND
32#define __ARCH_WANT_SYS_EXECVE 32#define __ARCH_WANT_SYS_EXECVE
33#define __ARCH_WANT_KERNEL_EXECVE
34 33
35/* 34/*
36 * "Conditional" syscalls 35 * "Conditional" syscalls
diff --git a/arch/frv/kernel/entry.S b/arch/frv/kernel/entry.S
index 00273296031..dfcd263c051 100644
--- a/arch/frv/kernel/entry.S
+++ b/arch/frv/kernel/entry.S
@@ -867,13 +867,8 @@ ret_from_fork:
867ret_from_kernel_thread: 867ret_from_kernel_thread:
868 lddi.p @(gr28,#REG_GR(8)),gr20 868 lddi.p @(gr28,#REG_GR(8)),gr20
869 call schedule_tail 869 call schedule_tail
870 or.p gr20,gr20,gr8 870 calll.p @(gr21,gr0)
871 calll @(gr21,gr0) 871 or gr20,gr20,gr8
872 bra sys_exit
873
874 .globl ret_from_kernel_execve
875ret_from_kernel_execve:
876 ori gr28,0,sp
877 bra __syscall_exit 872 bra __syscall_exit
878 873
879################################################################################################### 874###################################################################################################
@@ -1080,27 +1075,10 @@ __entry_return_from_kernel_interrupt:
1080 subicc gr5,#0,gr0,icc0 1075 subicc gr5,#0,gr0,icc0
1081 beq icc0,#0,__entry_return_direct 1076 beq icc0,#0,__entry_return_direct
1082 1077
1083__entry_preempt_need_resched: 1078 subcc gr0,gr0,gr0,icc2 /* set Z and clear C */
1084 ldi @(gr15,#TI_FLAGS),gr4 1079 call preempt_schedule_irq
1085 andicc gr4,#_TIF_NEED_RESCHED,gr0,icc0
1086 beq icc0,#1,__entry_return_direct
1087
1088 setlos #PREEMPT_ACTIVE,gr5
1089 sti gr5,@(gr15,#TI_FLAGS)
1090
1091 andi gr23,#~PSR_PIL,gr23
1092 movgs gr23,psr
1093
1094 call schedule
1095 sti gr0,@(gr15,#TI_PRE_COUNT)
1096
1097 movsg psr,gr23
1098 ori gr23,#PSR_PIL_14,gr23
1099 movgs gr23,psr
1100 bra __entry_preempt_need_resched
1101#else
1102 bra __entry_return_direct
1103#endif 1080#endif
1081 bra __entry_return_direct
1104 1082
1105 1083
1106############################################################################### 1084###############################################################################
diff --git a/arch/frv/kernel/process.c b/arch/frv/kernel/process.c
index 655d90d20bb..7e33215f1d8 100644
--- a/arch/frv/kernel/process.c
+++ b/arch/frv/kernel/process.c
@@ -181,6 +181,9 @@ int copy_thread(unsigned long clone_flags,
181 childregs = (struct pt_regs *) 181 childregs = (struct pt_regs *)
182 (task_stack_page(p) + THREAD_SIZE - FRV_FRAME0_SIZE); 182 (task_stack_page(p) + THREAD_SIZE - FRV_FRAME0_SIZE);
183 183
184 /* set up the userspace frame (the only place that the USP is stored) */
185 *childregs = *__kernel_frame0_ptr;
186
184 p->set_child_tid = p->clear_child_tid = NULL; 187 p->set_child_tid = p->clear_child_tid = NULL;
185 188
186 p->thread.frame = childregs; 189 p->thread.frame = childregs;
@@ -191,10 +194,8 @@ int copy_thread(unsigned long clone_flags,
191 p->thread.frame0 = childregs; 194 p->thread.frame0 = childregs;
192 195
193 if (unlikely(!regs)) { 196 if (unlikely(!regs)) {
194 memset(childregs, 0, sizeof(struct pt_regs));
195 childregs->gr9 = usp; /* function */ 197 childregs->gr9 = usp; /* function */
196 childregs->gr8 = arg; 198 childregs->gr8 = arg;
197 chilregs->psr = PSR_S;
198 p->thread.pc = (unsigned long) ret_from_kernel_thread; 199 p->thread.pc = (unsigned long) ret_from_kernel_thread;
199 save_user_regs(p->thread.user); 200 save_user_regs(p->thread.user);
200 return 0; 201 return 0;
diff --git a/arch/frv/kernel/setup.c b/arch/frv/kernel/setup.c
index 1f1e5efb338..b8993c87d3d 100644
--- a/arch/frv/kernel/setup.c
+++ b/arch/frv/kernel/setup.c
@@ -112,9 +112,11 @@ char __initdata redboot_command_line[COMMAND_LINE_SIZE];
112#ifdef CONFIG_PM 112#ifdef CONFIG_PM
113#define __pminit 113#define __pminit
114#define __pminitdata 114#define __pminitdata
115#define __pminitconst
115#else 116#else
116#define __pminit __init 117#define __pminit __init
117#define __pminitdata __initdata 118#define __pminitdata __initdata
119#define __pminitconst __initconst
118#endif 120#endif
119 121
120struct clock_cmode { 122struct clock_cmode {
diff --git a/arch/frv/mb93090-mb00/pci-dma-nommu.c b/arch/frv/mb93090-mb00/pci-dma-nommu.c
index e47857f889b..b99c2a7cc7a 100644
--- a/arch/frv/mb93090-mb00/pci-dma-nommu.c
+++ b/arch/frv/mb93090-mb00/pci-dma-nommu.c
@@ -11,6 +11,7 @@
11 11
12#include <linux/types.h> 12#include <linux/types.h>
13#include <linux/slab.h> 13#include <linux/slab.h>
14#include <linux/export.h>
14#include <linux/dma-mapping.h> 15#include <linux/dma-mapping.h>
15#include <linux/list.h> 16#include <linux/list.h>
16#include <linux/pci.h> 17#include <linux/pci.h>
diff --git a/arch/h8300/Kconfig b/arch/h8300/Kconfig
index 98fabd10e95..04bef4d25b4 100644
--- a/arch/h8300/Kconfig
+++ b/arch/h8300/Kconfig
@@ -8,6 +8,8 @@ config H8300
8 select GENERIC_IRQ_SHOW 8 select GENERIC_IRQ_SHOW
9 select GENERIC_CPU_DEVICES 9 select GENERIC_CPU_DEVICES
10 select MODULES_USE_ELF_RELA 10 select MODULES_USE_ELF_RELA
11 select GENERIC_KERNEL_THREAD
12 select GENERIC_KERNEL_EXECVE
11 13
12config SYMBOL_PREFIX 14config SYMBOL_PREFIX
13 string 15 string
diff --git a/arch/h8300/include/asm/cache.h b/arch/h8300/include/asm/cache.h
index c6350283649..05887a1d80e 100644
--- a/arch/h8300/include/asm/cache.h
+++ b/arch/h8300/include/asm/cache.h
@@ -2,7 +2,8 @@
2#define __ARCH_H8300_CACHE_H 2#define __ARCH_H8300_CACHE_H
3 3
4/* bytes per L1 cache line */ 4/* bytes per L1 cache line */
5#define L1_CACHE_BYTES 4 5#define L1_CACHE_SHIFT 2
6#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
6 7
7/* m68k-elf-gcc 2.95.2 doesn't like these */ 8/* m68k-elf-gcc 2.95.2 doesn't like these */
8 9
diff --git a/arch/h8300/include/asm/processor.h b/arch/h8300/include/asm/processor.h
index 4c9f6f87b61..4b0ca49bb46 100644
--- a/arch/h8300/include/asm/processor.h
+++ b/arch/h8300/include/asm/processor.h
@@ -107,8 +107,6 @@ static inline void release_thread(struct task_struct *dead_task)
107{ 107{
108} 108}
109 109
110extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
111
112/* 110/*
113 * Free current thread data structures etc.. 111 * Free current thread data structures etc..
114 */ 112 */
diff --git a/arch/h8300/include/asm/ptrace.h b/arch/h8300/include/asm/ptrace.h
index d09c440bdba..00502a61bf0 100644
--- a/arch/h8300/include/asm/ptrace.h
+++ b/arch/h8300/include/asm/ptrace.h
@@ -60,6 +60,8 @@ struct pt_regs {
60#define user_mode(regs) (!((regs)->ccr & PS_S)) 60#define user_mode(regs) (!((regs)->ccr & PS_S))
61#define instruction_pointer(regs) ((regs)->pc) 61#define instruction_pointer(regs) ((regs)->pc)
62#define profile_pc(regs) instruction_pointer(regs) 62#define profile_pc(regs) instruction_pointer(regs)
63#define current_pt_regs() ((struct pt_regs *) \
64 (THREAD_SIZE + (unsigned long)current_thread_info()) - 1)
63#endif /* __KERNEL__ */ 65#endif /* __KERNEL__ */
64#endif /* __ASSEMBLY__ */ 66#endif /* __ASSEMBLY__ */
65#endif /* _H8300_PTRACE_H */ 67#endif /* _H8300_PTRACE_H */
diff --git a/arch/h8300/include/asm/unistd.h b/arch/h8300/include/asm/unistd.h
index 5cd882801d7..07afcfaec99 100644
--- a/arch/h8300/include/asm/unistd.h
+++ b/arch/h8300/include/asm/unistd.h
@@ -356,6 +356,7 @@
356#define __ARCH_WANT_SYS_SIGPROCMASK 356#define __ARCH_WANT_SYS_SIGPROCMASK
357#define __ARCH_WANT_SYS_RT_SIGACTION 357#define __ARCH_WANT_SYS_RT_SIGACTION
358#define __ARCH_WANT_SYS_RT_SIGSUSPEND 358#define __ARCH_WANT_SYS_RT_SIGSUSPEND
359#define __ARCH_WANT_SYS_EXECVE
359 360
360/* 361/*
361 * "Conditional" syscalls 362 * "Conditional" syscalls
diff --git a/arch/h8300/kernel/entry.S b/arch/h8300/kernel/entry.S
index ca743169030..617a6878787 100644
--- a/arch/h8300/kernel/entry.S
+++ b/arch/h8300/kernel/entry.S
@@ -158,6 +158,7 @@ INTERRUPTS = 128
158.globl SYMBOL_NAME(system_call) 158.globl SYMBOL_NAME(system_call)
159.globl SYMBOL_NAME(ret_from_exception) 159.globl SYMBOL_NAME(ret_from_exception)
160.globl SYMBOL_NAME(ret_from_fork) 160.globl SYMBOL_NAME(ret_from_fork)
161.globl SYMBOL_NAME(ret_from_kernel_thread)
161.globl SYMBOL_NAME(ret_from_interrupt) 162.globl SYMBOL_NAME(ret_from_interrupt)
162.globl SYMBOL_NAME(interrupt_redirect_table) 163.globl SYMBOL_NAME(interrupt_redirect_table)
163.globl SYMBOL_NAME(sw_ksp),SYMBOL_NAME(sw_usp) 164.globl SYMBOL_NAME(sw_ksp),SYMBOL_NAME(sw_usp)
@@ -330,6 +331,14 @@ SYMBOL_NAME_LABEL(ret_from_fork)
330 jsr @SYMBOL_NAME(schedule_tail) 331 jsr @SYMBOL_NAME(schedule_tail)
331 jmp @SYMBOL_NAME(ret_from_exception) 332 jmp @SYMBOL_NAME(ret_from_exception)
332 333
334SYMBOL_NAME_LABEL(ret_from_kernel_thread)
335 mov.l er2,er0
336 jsr @SYMBOL_NAME(schedule_tail)
337 mov.l @(LER4:16,sp),er0
338 mov.l @(LER5:16,sp),er1
339 jsr @er1
340 jmp @SYMBOL_NAME(ret_from_exception)
341
333SYMBOL_NAME_LABEL(resume) 342SYMBOL_NAME_LABEL(resume)
334 /* 343 /*
335 * Beware - when entering resume, offset of tss is in d1, 344 * Beware - when entering resume, offset of tss is in d1,
diff --git a/arch/h8300/kernel/h8300_ksyms.c b/arch/h8300/kernel/h8300_ksyms.c
index 6866bd9c7fb..53d7c0e4bd8 100644
--- a/arch/h8300/kernel/h8300_ksyms.c
+++ b/arch/h8300/kernel/h8300_ksyms.c
@@ -33,7 +33,6 @@ EXPORT_SYMBOL(strncmp);
33 33
34EXPORT_SYMBOL(ip_fast_csum); 34EXPORT_SYMBOL(ip_fast_csum);
35 35
36EXPORT_SYMBOL(kernel_thread);
37EXPORT_SYMBOL(enable_irq); 36EXPORT_SYMBOL(enable_irq);
38EXPORT_SYMBOL(disable_irq); 37EXPORT_SYMBOL(disable_irq);
39 38
diff --git a/arch/h8300/kernel/process.c b/arch/h8300/kernel/process.c
index e8dc1393a13..2a45718cc5e 100644
--- a/arch/h8300/kernel/process.c
+++ b/arch/h8300/kernel/process.c
@@ -47,6 +47,7 @@ void (*pm_power_off)(void) = NULL;
47EXPORT_SYMBOL(pm_power_off); 47EXPORT_SYMBOL(pm_power_off);
48 48
49asmlinkage void ret_from_fork(void); 49asmlinkage void ret_from_fork(void);
50asmlinkage void ret_from_kernel_thread(void);
50 51
51/* 52/*
52 * The idle loop on an H8/300.. 53 * The idle loop on an H8/300..
@@ -122,39 +123,6 @@ void show_regs(struct pt_regs * regs)
122 printk("\n"); 123 printk("\n");
123} 124}
124 125
125/*
126 * Create a kernel thread
127 */
128int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
129{
130 long retval;
131 long clone_arg;
132 mm_segment_t fs;
133
134 fs = get_fs();
135 set_fs (KERNEL_DS);
136 clone_arg = flags | CLONE_VM;
137 __asm__("mov.l sp,er3\n\t"
138 "sub.l er2,er2\n\t"
139 "mov.l %2,er1\n\t"
140 "mov.l %1,er0\n\t"
141 "trapa #0\n\t"
142 "cmp.l sp,er3\n\t"
143 "beq 1f\n\t"
144 "mov.l %4,er0\n\t"
145 "mov.l %3,er1\n\t"
146 "jsr @er1\n\t"
147 "mov.l %5,er0\n\t"
148 "trapa #0\n"
149 "1:\n\t"
150 "mov.l er0,%0"
151 :"=r"(retval)
152 :"i"(__NR_clone),"g"(clone_arg),"g"(fn),"g"(arg),"i"(__NR_exit)
153 :"er0","er1","er2","er3");
154 set_fs (fs);
155 return retval;
156}
157
158void flush_thread(void) 126void flush_thread(void)
159{ 127{
160} 128}
@@ -198,6 +166,13 @@ int copy_thread(unsigned long clone_flags,
198 166
199 childregs = (struct pt_regs *) (THREAD_SIZE + task_stack_page(p)) - 1; 167 childregs = (struct pt_regs *) (THREAD_SIZE + task_stack_page(p)) - 1;
200 168
169 if (unlikely(p->flags & PF_KTHREAD)) {
170 memset(childregs, 0, sizeof(struct pt_regs));
171 childregs->retpc = (unsigned long) ret_from_kernel_thread;
172 childregs->er4 = topstk; /* arg */
173 childregs->er5 = usp; /* fn */
174 p->thread.ksp = (unsigned long)childregs;
175 }
201 *childregs = *regs; 176 *childregs = *regs;
202 childregs->retpc = (unsigned long) ret_from_fork; 177 childregs->retpc = (unsigned long) ret_from_fork;
203 childregs->er0 = 0; 178 childregs->er0 = 0;
@@ -208,27 +183,6 @@ int copy_thread(unsigned long clone_flags,
208 return 0; 183 return 0;
209} 184}
210 185
211/*
212 * sys_execve() executes a new program.
213 */
214asmlinkage int sys_execve(const char *name,
215 const char *const *argv,
216 const char *const *envp,
217 int dummy, ...)
218{
219 int error;
220 struct filename *filename;
221 struct pt_regs *regs = (struct pt_regs *) ((unsigned char *)&dummy-4);
222
223 filename = getname(name);
224 error = PTR_ERR(filename);
225 if (IS_ERR(filename))
226 return error;
227 error = do_execve(filename->name, argv, envp, regs);
228 putname(filename);
229 return error;
230}
231
232unsigned long thread_saved_pc(struct task_struct *tsk) 186unsigned long thread_saved_pc(struct task_struct *tsk)
233{ 187{
234 return ((struct pt_regs *)tsk->thread.esp0)->pc; 188 return ((struct pt_regs *)tsk->thread.esp0)->pc;
diff --git a/arch/h8300/kernel/sys_h8300.c b/arch/h8300/kernel/sys_h8300.c
index 4bdc7311784..bf350cb7f59 100644
--- a/arch/h8300/kernel/sys_h8300.c
+++ b/arch/h8300/kernel/sys_h8300.c
@@ -46,29 +46,3 @@ asmlinkage void syscall_print(void *dummy,...)
46 ((regs->pc)&0xffffff)-2,regs->orig_er0,regs->er1,regs->er2,regs->er3,regs->er0); 46 ((regs->pc)&0xffffff)-2,regs->orig_er0,regs->er1,regs->er2,regs->er3,regs->er0);
47} 47}
48#endif 48#endif
49
50/*
51 * Do a system call from kernel instead of calling sys_execve so we
52 * end up with proper pt_regs.
53 */
54asmlinkage
55int kernel_execve(const char *filename,
56 const char *const argv[],
57 const char *const envp[])
58{
59 register long res __asm__("er0");
60 register const char *const *_c __asm__("er3") = envp;
61 register const char *const *_b __asm__("er2") = argv;
62 register const char * _a __asm__("er1") = filename;
63 __asm__ __volatile__ ("mov.l %1,er0\n\t"
64 "trapa #0\n\t"
65 : "=r" (res)
66 : "g" (__NR_execve),
67 "g" (_a),
68 "g" (_b),
69 "g" (_c)
70 : "cc", "memory");
71 return res;
72}
73
74
diff --git a/arch/hexagon/Kconfig b/arch/hexagon/Kconfig
index 0744f7d7b1f..e418803b6c8 100644
--- a/arch/hexagon/Kconfig
+++ b/arch/hexagon/Kconfig
@@ -31,6 +31,8 @@ config HEXAGON
31 select GENERIC_CLOCKEVENTS 31 select GENERIC_CLOCKEVENTS
32 select GENERIC_CLOCKEVENTS_BROADCAST 32 select GENERIC_CLOCKEVENTS_BROADCAST
33 select MODULES_USE_ELF_RELA 33 select MODULES_USE_ELF_RELA
34 select GENERIC_KERNEL_THREAD
35 select GENERIC_KERNEL_EXECVE
34 ---help--- 36 ---help---
35 Qualcomm Hexagon is a processor architecture designed for high 37 Qualcomm Hexagon is a processor architecture designed for high
36 performance and low power across a wide variety of applications. 38 performance and low power across a wide variety of applications.
diff --git a/arch/hexagon/include/asm/Kbuild b/arch/hexagon/include/asm/Kbuild
index 3364b6966d2..3bfa9b30f44 100644
--- a/arch/hexagon/include/asm/Kbuild
+++ b/arch/hexagon/include/asm/Kbuild
@@ -1,8 +1,5 @@
1include include/asm-generic/Kbuild.asm
2 1
3header-y += registers.h
4header-y += ucontext.h 2header-y += ucontext.h
5header-y += user.h
6 3
7generic-y += auxvec.h 4generic-y += auxvec.h
8generic-y += bug.h 5generic-y += bug.h
diff --git a/arch/hexagon/include/asm/atomic.h b/arch/hexagon/include/asm/atomic.h
index 3e258043337..468fbb0781c 100644
--- a/arch/hexagon/include/asm/atomic.h
+++ b/arch/hexagon/include/asm/atomic.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Atomic operations for the Hexagon architecture 2 * Atomic operations for the Hexagon architecture
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
diff --git a/arch/hexagon/include/asm/barrier.h b/arch/hexagon/include/asm/barrier.h
index a4ed6e26cb1..1041a8e70ce 100644
--- a/arch/hexagon/include/asm/barrier.h
+++ b/arch/hexagon/include/asm/barrier.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Memory barrier definitions for the Hexagon architecture 2 * Memory barrier definitions for the Hexagon architecture
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/include/asm/bitops.h b/arch/hexagon/include/asm/bitops.h
index 4caa649ad78..9b1e4afbab3 100644
--- a/arch/hexagon/include/asm/bitops.h
+++ b/arch/hexagon/include/asm/bitops.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Bit operations for the Hexagon architecture 2 * Bit operations for the Hexagon architecture
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
diff --git a/arch/hexagon/include/asm/cache.h b/arch/hexagon/include/asm/cache.h
index 0f01de2eb4a..f4ca594fdf8 100644
--- a/arch/hexagon/include/asm/cache.h
+++ b/arch/hexagon/include/asm/cache.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Cache definitions for the Hexagon architecture 2 * Cache definitions for the Hexagon architecture
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/include/asm/cacheflush.h b/arch/hexagon/include/asm/cacheflush.h
index 6865c1be927..49e0896ec24 100644
--- a/arch/hexagon/include/asm/cacheflush.h
+++ b/arch/hexagon/include/asm/cacheflush.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Cache flush operations for the Hexagon architecture 2 * Cache flush operations for the Hexagon architecture
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/include/asm/checksum.h b/arch/hexagon/include/asm/checksum.h
index 3ce4ecd44f8..46ec8a7fd65 100644
--- a/arch/hexagon/include/asm/checksum.h
+++ b/arch/hexagon/include/asm/checksum.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 2 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and 5 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/include/asm/cmpxchg.h b/arch/hexagon/include/asm/cmpxchg.h
index c5f9527e1df..9e7802911a5 100644
--- a/arch/hexagon/include/asm/cmpxchg.h
+++ b/arch/hexagon/include/asm/cmpxchg.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * xchg/cmpxchg operations for the Hexagon architecture 2 * xchg/cmpxchg operations for the Hexagon architecture
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
diff --git a/arch/hexagon/include/asm/delay.h b/arch/hexagon/include/asm/delay.h
index 9ab12e9a872..53079719d66 100644
--- a/arch/hexagon/include/asm/delay.h
+++ b/arch/hexagon/include/asm/delay.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 2 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and 5 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/include/asm/dma-mapping.h b/arch/hexagon/include/asm/dma-mapping.h
index 233ed3d2d25..85e9935660c 100644
--- a/arch/hexagon/include/asm/dma-mapping.h
+++ b/arch/hexagon/include/asm/dma-mapping.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * DMA operations for the Hexagon architecture 2 * DMA operations for the Hexagon architecture
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/include/asm/dma.h b/arch/hexagon/include/asm/dma.h
index da6d2f61a93..9e34ff49f3b 100644
--- a/arch/hexagon/include/asm/dma.h
+++ b/arch/hexagon/include/asm/dma.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 2 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and 5 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/include/asm/elf.h b/arch/hexagon/include/asm/elf.h
index 82b499621e0..1ba4b3bff5e 100644
--- a/arch/hexagon/include/asm/elf.h
+++ b/arch/hexagon/include/asm/elf.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * ELF definitions for the Hexagon architecture 2 * ELF definitions for the Hexagon architecture
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/include/asm/exec.h b/arch/hexagon/include/asm/exec.h
index 350e6d497d4..c32b2132614 100644
--- a/arch/hexagon/include/asm/exec.h
+++ b/arch/hexagon/include/asm/exec.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Process execution related definitions for the Hexagon architecture 2 * Process execution related definitions for the Hexagon architecture
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/include/asm/fixmap.h b/arch/hexagon/include/asm/fixmap.h
index b27f4941645..b75b6bf4269 100644
--- a/arch/hexagon/include/asm/fixmap.h
+++ b/arch/hexagon/include/asm/fixmap.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Fixmap support for Hexagon - enough to support highmem features 2 * Fixmap support for Hexagon - enough to support highmem features
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/include/asm/hexagon_vm.h b/arch/hexagon/include/asm/hexagon_vm.h
index 182cb9d5476..c144bee6cab 100644
--- a/arch/hexagon/include/asm/hexagon_vm.h
+++ b/arch/hexagon/include/asm/hexagon_vm.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Declarations for to Hexagon Virtal Machine. 2 * Declarations for to Hexagon Virtal Machine.
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/include/asm/intrinsics.h b/arch/hexagon/include/asm/intrinsics.h
index 1c02186d2e9..ca587737fb2 100644
--- a/arch/hexagon/include/asm/intrinsics.h
+++ b/arch/hexagon/include/asm/intrinsics.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 2 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and 5 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/include/asm/io.h b/arch/hexagon/include/asm/io.h
index b3acc2cc71b..e527cfeff5b 100644
--- a/arch/hexagon/include/asm/io.h
+++ b/arch/hexagon/include/asm/io.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * IO definitions for the Hexagon architecture 2 * IO definitions for the Hexagon architecture
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/include/asm/irq.h b/arch/hexagon/include/asm/irq.h
index ded8c15cf3e..51661db389d 100644
--- a/arch/hexagon/include/asm/irq.h
+++ b/arch/hexagon/include/asm/irq.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 2 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and 5 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/include/asm/irqflags.h b/arch/hexagon/include/asm/irqflags.h
index ec152365541..e5fd9492d60 100644
--- a/arch/hexagon/include/asm/irqflags.h
+++ b/arch/hexagon/include/asm/irqflags.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * IRQ support for the Hexagon architecture 2 * IRQ support for the Hexagon architecture
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/include/asm/kgdb.h b/arch/hexagon/include/asm/kgdb.h
index 9e8779702f1..32a6fb66944 100644
--- a/arch/hexagon/include/asm/kgdb.h
+++ b/arch/hexagon/include/asm/kgdb.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * arch/hexagon/include/asm/kgdb.h - Hexagon KGDB Support 2 * arch/hexagon/include/asm/kgdb.h - Hexagon KGDB Support
3 * 3 *
4 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/include/asm/linkage.h b/arch/hexagon/include/asm/linkage.h
index a00b85f680b..31b4cbe7e58 100644
--- a/arch/hexagon/include/asm/linkage.h
+++ b/arch/hexagon/include/asm/linkage.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 2 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and 5 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/include/asm/mem-layout.h b/arch/hexagon/include/asm/mem-layout.h
index 72e5dcda79f..af16e977c55 100644
--- a/arch/hexagon/include/asm/mem-layout.h
+++ b/arch/hexagon/include/asm/mem-layout.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Memory layout definitions for the Hexagon architecture 2 * Memory layout definitions for the Hexagon architecture
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/include/asm/mmu.h b/arch/hexagon/include/asm/mmu.h
index 30a5d8d2659..2288b19fd0f 100644
--- a/arch/hexagon/include/asm/mmu.h
+++ b/arch/hexagon/include/asm/mmu.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 2 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and 5 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/include/asm/mmu_context.h b/arch/hexagon/include/asm/mmu_context.h
index b4fe5a5411b..d423d2e73c3 100644
--- a/arch/hexagon/include/asm/mmu_context.h
+++ b/arch/hexagon/include/asm/mmu_context.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * MM context support for the Hexagon architecture 2 * MM context support for the Hexagon architecture
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/include/asm/module.h b/arch/hexagon/include/asm/module.h
index 72ba494e6d7..6b4323acef4 100644
--- a/arch/hexagon/include/asm/module.h
+++ b/arch/hexagon/include/asm/module.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 2 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and 5 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/include/asm/page.h b/arch/hexagon/include/asm/page.h
index edd97626c48..692adc21342 100644
--- a/arch/hexagon/include/asm/page.h
+++ b/arch/hexagon/include/asm/page.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Page management definitions for the Hexagon architecture 2 * Page management definitions for the Hexagon architecture
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/include/asm/perf_event.h b/arch/hexagon/include/asm/perf_event.h
index 8b8526b491c..430978b1de3 100644
--- a/arch/hexagon/include/asm/perf_event.h
+++ b/arch/hexagon/include/asm/perf_event.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 2 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and 5 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/include/asm/pgalloc.h b/arch/hexagon/include/asm/pgalloc.h
index 13443c77513..679bf6d6648 100644
--- a/arch/hexagon/include/asm/pgalloc.h
+++ b/arch/hexagon/include/asm/pgalloc.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Page table support for the Hexagon architecture 2 * Page table support for the Hexagon architecture
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/include/asm/pgtable.h b/arch/hexagon/include/asm/pgtable.h
index ca619bf225e..20d55f69fe5 100644
--- a/arch/hexagon/include/asm/pgtable.h
+++ b/arch/hexagon/include/asm/pgtable.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Page table support for the Hexagon architecture 2 * Page table support for the Hexagon architecture
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/include/asm/processor.h b/arch/hexagon/include/asm/processor.h
index e8ea459002a..6dd5d370686 100644
--- a/arch/hexagon/include/asm/processor.h
+++ b/arch/hexagon/include/asm/processor.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Process/processor support for the Hexagon architecture 2 * Process/processor support for the Hexagon architecture
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
@@ -34,7 +34,6 @@
34struct task_struct; 34struct task_struct;
35 35
36/* this is defined in arch/process.c */ 36/* this is defined in arch/process.c */
37extern pid_t kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
38extern unsigned long thread_saved_pc(struct task_struct *tsk); 37extern unsigned long thread_saved_pc(struct task_struct *tsk);
39 38
40extern void start_thread(struct pt_regs *, unsigned long, unsigned long); 39extern void start_thread(struct pt_regs *, unsigned long, unsigned long);
diff --git a/arch/hexagon/include/asm/smp.h b/arch/hexagon/include/asm/smp.h
index 87c869a6a89..2b9b974e095 100644
--- a/arch/hexagon/include/asm/smp.h
+++ b/arch/hexagon/include/asm/smp.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * SMP definitions for the Hexagon architecture 2 * SMP definitions for the Hexagon architecture
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/include/asm/spinlock.h b/arch/hexagon/include/asm/spinlock.h
index 168a920485a..12ca4ebc033 100644
--- a/arch/hexagon/include/asm/spinlock.h
+++ b/arch/hexagon/include/asm/spinlock.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Spinlock support for the Hexagon architecture 2 * Spinlock support for the Hexagon architecture
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
diff --git a/arch/hexagon/include/asm/spinlock_types.h b/arch/hexagon/include/asm/spinlock_types.h
index 99b5a7575c2..7a906b5214a 100644
--- a/arch/hexagon/include/asm/spinlock_types.h
+++ b/arch/hexagon/include/asm/spinlock_types.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Spinlock support for the Hexagon architecture 2 * Spinlock support for the Hexagon architecture
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/include/asm/string.h b/arch/hexagon/include/asm/string.h
index f4489c15942..7d37f47a1d0 100644
--- a/arch/hexagon/include/asm/string.h
+++ b/arch/hexagon/include/asm/string.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 2 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and 5 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/include/asm/suspend.h b/arch/hexagon/include/asm/suspend.h
index 089dd826879..18b44b557fb 100644
--- a/arch/hexagon/include/asm/suspend.h
+++ b/arch/hexagon/include/asm/suspend.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 2 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and 5 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/include/asm/switch_to.h b/arch/hexagon/include/asm/switch_to.h
index 28ca0dfb606..96745e7b3e3 100644
--- a/arch/hexagon/include/asm/switch_to.h
+++ b/arch/hexagon/include/asm/switch_to.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Task switching definitions for the Hexagon architecture 2 * Task switching definitions for the Hexagon architecture
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/include/asm/syscall.h b/arch/hexagon/include/asm/syscall.h
index 3e7d61d38d9..fb0e9d48faa 100644
--- a/arch/hexagon/include/asm/syscall.h
+++ b/arch/hexagon/include/asm/syscall.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Syscall support for the Hexagon architecture 2 * Syscall support for the Hexagon architecture
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/include/asm/thread_info.h b/arch/hexagon/include/asm/thread_info.h
index e4a0aad69cb..f7c32406a71 100644
--- a/arch/hexagon/include/asm/thread_info.h
+++ b/arch/hexagon/include/asm/thread_info.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Thread support for the Hexagon architecture 2 * Thread support for the Hexagon architecture
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/include/asm/time.h b/arch/hexagon/include/asm/time.h
index 081b82cac9a..deda170c03b 100644
--- a/arch/hexagon/include/asm/time.h
+++ b/arch/hexagon/include/asm/time.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 2 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and 5 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/include/asm/timer-regs.h b/arch/hexagon/include/asm/timer-regs.h
index d80db239a7b..79912b8c1e5 100644
--- a/arch/hexagon/include/asm/timer-regs.h
+++ b/arch/hexagon/include/asm/timer-regs.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Timer support for Hexagon 2 * Timer support for Hexagon
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/include/asm/timex.h b/arch/hexagon/include/asm/timex.h
index b11c62b23f3..f63fe132f07 100644
--- a/arch/hexagon/include/asm/timex.h
+++ b/arch/hexagon/include/asm/timex.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 2 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and 5 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/include/asm/tlb.h b/arch/hexagon/include/asm/tlb.h
index 473abde01d6..2f00772cc08 100644
--- a/arch/hexagon/include/asm/tlb.h
+++ b/arch/hexagon/include/asm/tlb.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 2 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and 5 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/include/asm/tlbflush.h b/arch/hexagon/include/asm/tlbflush.h
index b89a9025122..62d95a9705c 100644
--- a/arch/hexagon/include/asm/tlbflush.h
+++ b/arch/hexagon/include/asm/tlbflush.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * TLB flush support for Hexagon 2 * TLB flush support for Hexagon
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/include/asm/traps.h b/arch/hexagon/include/asm/traps.h
index 6a407f6e5e2..ec11285012c 100644
--- a/arch/hexagon/include/asm/traps.h
+++ b/arch/hexagon/include/asm/traps.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Trap support for Hexagon 2 * Trap support for Hexagon
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/include/asm/uaccess.h b/arch/hexagon/include/asm/uaccess.h
index 7e706eadbf0..e4127e4d6a5 100644
--- a/arch/hexagon/include/asm/uaccess.h
+++ b/arch/hexagon/include/asm/uaccess.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * User memory access support for Hexagon 2 * User memory access support for Hexagon
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/include/asm/vdso.h b/arch/hexagon/include/asm/vdso.h
index 2d95cbba357..ed08e6c6886 100644
--- a/arch/hexagon/include/asm/vdso.h
+++ b/arch/hexagon/include/asm/vdso.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * vDSO implementation for Hexagon 2 * vDSO implementation for Hexagon
3 * 3 *
4 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/include/asm/vm_fault.h b/arch/hexagon/include/asm/vm_fault.h
index cacda36ef5d..9b0e9c50ced 100644
--- a/arch/hexagon/include/asm/vm_fault.h
+++ b/arch/hexagon/include/asm/vm_fault.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 2 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and 5 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/include/asm/vm_mmu.h b/arch/hexagon/include/asm/vm_mmu.h
index 580462de5cc..9a94de7969b 100644
--- a/arch/hexagon/include/asm/vm_mmu.h
+++ b/arch/hexagon/include/asm/vm_mmu.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Hexagon VM page table entry definitions 2 * Hexagon VM page table entry definitions
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/include/uapi/asm/Kbuild b/arch/hexagon/include/uapi/asm/Kbuild
index baebb3da1d4..c31706c3863 100644
--- a/arch/hexagon/include/uapi/asm/Kbuild
+++ b/arch/hexagon/include/uapi/asm/Kbuild
@@ -1,3 +1,15 @@
1# UAPI Header export list 1# UAPI Header export list
2include include/uapi/asm-generic/Kbuild.asm 2include include/uapi/asm-generic/Kbuild.asm
3 3
4header-y += bitsperlong.h
5header-y += byteorder.h
6header-y += kvm_para.h
7header-y += param.h
8header-y += ptrace.h
9header-y += registers.h
10header-y += setup.h
11header-y += sigcontext.h
12header-y += signal.h
13header-y += swab.h
14header-y += unistd.h
15header-y += user.h
diff --git a/arch/hexagon/include/asm/bitsperlong.h b/arch/hexagon/include/uapi/asm/bitsperlong.h
index 2701cae3426..4a658151383 100644
--- a/arch/hexagon/include/asm/bitsperlong.h
+++ b/arch/hexagon/include/uapi/asm/bitsperlong.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 2 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and 5 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/include/asm/byteorder.h b/arch/hexagon/include/uapi/asm/byteorder.h
index 0e19b9fe4ca..e31f3f7d9a4 100644
--- a/arch/hexagon/include/asm/byteorder.h
+++ b/arch/hexagon/include/uapi/asm/byteorder.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 2 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and 5 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/include/asm/kvm_para.h b/arch/hexagon/include/uapi/asm/kvm_para.h
index 14fab8f0b95..14fab8f0b95 100644
--- a/arch/hexagon/include/asm/kvm_para.h
+++ b/arch/hexagon/include/uapi/asm/kvm_para.h
diff --git a/arch/hexagon/include/asm/param.h b/arch/hexagon/include/uapi/asm/param.h
index 285344bbd03..5cec8c0417f 100644
--- a/arch/hexagon/include/asm/param.h
+++ b/arch/hexagon/include/uapi/asm/param.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 2 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and 5 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/include/asm/ptrace.h b/arch/hexagon/include/uapi/asm/ptrace.h
index 3d2f607cd63..1ffce0c6ee0 100644
--- a/arch/hexagon/include/asm/ptrace.h
+++ b/arch/hexagon/include/uapi/asm/ptrace.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Ptrace definitions for the Hexagon architecture 2 * Ptrace definitions for the Hexagon architecture
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
@@ -32,4 +32,8 @@
32extern int regs_query_register_offset(const char *name); 32extern int regs_query_register_offset(const char *name);
33extern const char *regs_query_register_name(unsigned int offset); 33extern const char *regs_query_register_name(unsigned int offset);
34 34
35#define current_pt_regs() \
36 ((struct pt_regs *) \
37 ((unsigned long)current_thread_info() + THREAD_SIZE) - 1)
38
35#endif 39#endif
diff --git a/arch/hexagon/include/asm/registers.h b/arch/hexagon/include/uapi/asm/registers.h
index 4dd741be855..c20406f63b5 100644
--- a/arch/hexagon/include/asm/registers.h
+++ b/arch/hexagon/include/uapi/asm/registers.h
@@ -1,23 +1,8 @@
1/* 1/*
2 * Register definitions for the Hexagon architecture 2 * Register definitions for the Hexagon architecture
3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.
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 and
8 * only version 2 as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 * 02110-1301, USA.
19 */ 3 */
20 4
5
21#ifndef _ASM_REGISTERS_H 6#ifndef _ASM_REGISTERS_H
22#define _ASM_REGISTERS_H 7#define _ASM_REGISTERS_H
23 8
diff --git a/arch/hexagon/include/asm/setup.h b/arch/hexagon/include/uapi/asm/setup.h
index 3b754c50bc0..e48285e4af9 100644
--- a/arch/hexagon/include/asm/setup.h
+++ b/arch/hexagon/include/uapi/asm/setup.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 2 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and 5 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/include/asm/sigcontext.h b/arch/hexagon/include/uapi/asm/sigcontext.h
index ce6dcd99522..b6ba5369ccc 100644
--- a/arch/hexagon/include/asm/sigcontext.h
+++ b/arch/hexagon/include/uapi/asm/sigcontext.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 2 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and 5 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/include/asm/signal.h b/arch/hexagon/include/uapi/asm/signal.h
index 471c0562e17..939556817d3 100644
--- a/arch/hexagon/include/asm/signal.h
+++ b/arch/hexagon/include/uapi/asm/signal.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 2 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and 5 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/include/asm/swab.h b/arch/hexagon/include/uapi/asm/swab.h
index 99cf0be3fb8..9069e9247a2 100644
--- a/arch/hexagon/include/asm/swab.h
+++ b/arch/hexagon/include/uapi/asm/swab.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 2 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and 5 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/include/asm/unistd.h b/arch/hexagon/include/uapi/asm/unistd.h
index c0d5565030a..26b2e0f909c 100644
--- a/arch/hexagon/include/asm/unistd.h
+++ b/arch/hexagon/include/uapi/asm/unistd.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Syscall support for Hexagon 2 * Syscall support for Hexagon
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
@@ -27,5 +27,6 @@
27 */ 27 */
28 28
29#define sys_mmap2 sys_mmap_pgoff 29#define sys_mmap2 sys_mmap_pgoff
30#define __ARCH_WANT_SYS_EXECVE
30 31
31#include <asm-generic/unistd.h> 32#include <asm-generic/unistd.h>
diff --git a/arch/hexagon/include/asm/user.h b/arch/hexagon/include/uapi/asm/user.h
index 3a55078543d..cef13ee1413 100644
--- a/arch/hexagon/include/asm/user.h
+++ b/arch/hexagon/include/uapi/asm/user.h
@@ -1,21 +1,3 @@
1/*
2 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and
6 * only version 2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16 * 02110-1301, USA.
17 */
18
19#ifndef HEXAGON_ASM_USER_H 1#ifndef HEXAGON_ASM_USER_H
20#define HEXAGON_ASM_USER_H 2#define HEXAGON_ASM_USER_H
21 3
diff --git a/arch/hexagon/kernel/asm-offsets.c b/arch/hexagon/kernel/asm-offsets.c
index 89ffa514611..2d5e84d3b00 100644
--- a/arch/hexagon/kernel/asm-offsets.c
+++ b/arch/hexagon/kernel/asm-offsets.c
@@ -5,7 +5,7 @@
5 * Kevin Kissell, kevink@mips.com and Carsten Langgaard, carstenl@mips.com 5 * Kevin Kissell, kevink@mips.com and Carsten Langgaard, carstenl@mips.com
6 * Copyright (C) 2000 MIPS Technologies, Inc. 6 * Copyright (C) 2000 MIPS Technologies, Inc.
7 * 7 *
8 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 8 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 and 11 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/kernel/dma.c b/arch/hexagon/kernel/dma.c
index 2b48751aa5f..65c7bdcf565 100644
--- a/arch/hexagon/kernel/dma.c
+++ b/arch/hexagon/kernel/dma.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * DMA implementation for Hexagon 2 * DMA implementation for Hexagon
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/kernel/head.S b/arch/hexagon/kernel/head.S
index 8e6b819125a..d859402c73b 100644
--- a/arch/hexagon/kernel/head.S
+++ b/arch/hexagon/kernel/head.S
@@ -1,7 +1,7 @@
1/* 1/*
2 * Early kernel startup code for Hexagon 2 * Early kernel startup code for Hexagon
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
diff --git a/arch/hexagon/kernel/hexagon_ksyms.c b/arch/hexagon/kernel/hexagon_ksyms.c
index 7f189247180..32b1379d687 100644
--- a/arch/hexagon/kernel/hexagon_ksyms.c
+++ b/arch/hexagon/kernel/hexagon_ksyms.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Export of symbols defined in assembly files and/or libgcc. 2 * Export of symbols defined in assembly files and/or libgcc.
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/kernel/irq_cpu.c b/arch/hexagon/kernel/irq_cpu.c
index d4416a1a431..85883e1fdc1 100644
--- a/arch/hexagon/kernel/irq_cpu.c
+++ b/arch/hexagon/kernel/irq_cpu.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * First-level interrupt controller model for Hexagon. 2 * First-level interrupt controller model for Hexagon.
3 * 3 *
4 * Copyright (c) 2010-2011 Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/kernel/kgdb.c b/arch/hexagon/kernel/kgdb.c
index fe4aa1bcca5..34464537064 100644
--- a/arch/hexagon/kernel/kgdb.c
+++ b/arch/hexagon/kernel/kgdb.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * arch/hexagon/kernel/kgdb.c - Hexagon KGDB Support 2 * arch/hexagon/kernel/kgdb.c - Hexagon KGDB Support
3 * 3 *
4 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/kernel/module.c b/arch/hexagon/kernel/module.c
index 61a76bae366..477d07a5646 100644
--- a/arch/hexagon/kernel/module.c
+++ b/arch/hexagon/kernel/module.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Kernel module loader for Hexagon 2 * Kernel module loader for Hexagon
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/kernel/process.c b/arch/hexagon/kernel/process.c
index af51de63b83..cfbc52bd522 100644
--- a/arch/hexagon/kernel/process.c
+++ b/arch/hexagon/kernel/process.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Process creation support for Hexagon 2 * Process creation support for Hexagon
3 * 3 *
4 * Copyright (c) 2010-2012, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2012, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
@@ -26,33 +26,6 @@
26#include <linux/slab.h> 26#include <linux/slab.h>
27 27
28/* 28/*
29 * Kernel thread creation. The desired kernel function is "wrapped"
30 * in the kernel_thread_helper function, which does cleanup
31 * afterwards.
32 */
33static void __noreturn kernel_thread_helper(void *arg, int (*fn)(void *))
34{
35 do_exit(fn(arg));
36}
37
38int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags)
39{
40 struct pt_regs regs;
41
42 memset(&regs, 0, sizeof(regs));
43 /*
44 * Yes, we're exploting illicit knowledge of the ABI here.
45 */
46 regs.r00 = (unsigned long) arg;
47 regs.r01 = (unsigned long) fn;
48 pt_set_elr(&regs, (unsigned long)kernel_thread_helper);
49 pt_set_kmode(&regs);
50
51 return do_fork(flags|CLONE_VM|CLONE_UNTRACED, 0, &regs, 0, NULL, NULL);
52}
53EXPORT_SYMBOL(kernel_thread);
54
55/*
56 * Program thread launch. Often defined as a macro in processor.h, 29 * Program thread launch. Often defined as a macro in processor.h,
57 * but we're shooting for a small footprint and it's not an inner-loop 30 * but we're shooting for a small footprint and it's not an inner-loop
58 * performance-critical operation. 31 * performance-critical operation.
@@ -114,7 +87,7 @@ unsigned long thread_saved_pc(struct task_struct *tsk)
114 * Copy architecture-specific thread state 87 * Copy architecture-specific thread state
115 */ 88 */
116int copy_thread(unsigned long clone_flags, unsigned long usp, 89int copy_thread(unsigned long clone_flags, unsigned long usp,
117 unsigned long unused, struct task_struct *p, 90 unsigned long arg, struct task_struct *p,
118 struct pt_regs *regs) 91 struct pt_regs *regs)
119{ 92{
120 struct thread_info *ti = task_thread_info(p); 93 struct thread_info *ti = task_thread_info(p);
@@ -125,61 +98,50 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
125 childregs = (struct pt_regs *) (((unsigned long) ti + THREAD_SIZE) - 98 childregs = (struct pt_regs *) (((unsigned long) ti + THREAD_SIZE) -
126 sizeof(*childregs)); 99 sizeof(*childregs));
127 100
128 memcpy(childregs, regs, sizeof(*childregs));
129 ti->regs = childregs; 101 ti->regs = childregs;
130 102
131 /* 103 /*
132 * Establish kernel stack pointer and initial PC for new thread 104 * Establish kernel stack pointer and initial PC for new thread
105 * Note that unlike the usual situation, we do not copy the
106 * parent's callee-saved here; those are in pt_regs and whatever
107 * we leave here will be overridden on return to userland.
133 */ 108 */
134 ss = (struct hexagon_switch_stack *) ((unsigned long) childregs - 109 ss = (struct hexagon_switch_stack *) ((unsigned long) childregs -
135 sizeof(*ss)); 110 sizeof(*ss));
136 ss->lr = (unsigned long)ret_from_fork; 111 ss->lr = (unsigned long)ret_from_fork;
137 p->thread.switch_sp = ss; 112 p->thread.switch_sp = ss;
138 113 if (unlikely(p->flags & PF_KTHREAD)) {
139 /* If User mode thread, set pt_reg stack pointer as per parameter */ 114 memset(childregs, 0, sizeof(struct pt_regs));
140 if (user_mode(childregs)) { 115 /* r24 <- fn, r25 <- arg */
141 pt_set_rte_sp(childregs, usp); 116 ss->r2524 = usp | ((u64)arg << 32);
142 117 pt_set_kmode(childregs);
143 /* Child sees zero return value */ 118 return 0;
144 childregs->r00 = 0;
145
146 /*
147 * The clone syscall has the C signature:
148 * int [r0] clone(int flags [r0],
149 * void *child_frame [r1],
150 * void *parent_tid [r2],
151 * void *child_tid [r3],
152 * void *thread_control_block [r4]);
153 * ugp is used to provide TLS support.
154 */
155 if (clone_flags & CLONE_SETTLS)
156 childregs->ugp = childregs->r04;
157
158 /*
159 * Parent sees new pid -- not necessary, not even possible at
160 * this point in the fork process
161 * Might also want to set things like ti->addr_limit
162 */
163 } else {
164 /*
165 * If kernel thread, resume stack is kernel stack base.
166 * Note that this is pointer arithmetic on pt_regs *
167 */
168 pt_set_rte_sp(childregs, (unsigned long)(childregs + 1));
169 /*
170 * We need the current thread_info fast path pointer
171 * set up in pt_regs. The register to be used is
172 * parametric for assembler code, but the mechanism
173 * doesn't drop neatly into C. Needs to be fixed.
174 */
175 childregs->THREADINFO_REG = (unsigned long) ti;
176 } 119 }
120 memcpy(childregs, regs, sizeof(*childregs));
121 ss->r2524 = 0;
122
123 pt_set_rte_sp(childregs, usp);
124
125 /* Child sees zero return value */
126 childregs->r00 = 0;
127
128 /*
129 * The clone syscall has the C signature:
130 * int [r0] clone(int flags [r0],
131 * void *child_frame [r1],
132 * void *parent_tid [r2],
133 * void *child_tid [r3],
134 * void *thread_control_block [r4]);
135 * ugp is used to provide TLS support.
136 */
137 if (clone_flags & CLONE_SETTLS)
138 childregs->ugp = childregs->r04;
177 139
178 /* 140 /*
179 * thread_info pointer is pulled out of task_struct "stack" 141 * Parent sees new pid -- not necessary, not even possible at
180 * field on switch_to. 142 * this point in the fork process
143 * Might also want to set things like ti->addr_limit
181 */ 144 */
182 p->stack = (void *)ti;
183 145
184 return 0; 146 return 0;
185} 147}
diff --git a/arch/hexagon/kernel/ptrace.c b/arch/hexagon/kernel/ptrace.c
index 96c3b2c4dba..670b1b0bee6 100644
--- a/arch/hexagon/kernel/ptrace.c
+++ b/arch/hexagon/kernel/ptrace.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Ptrace support for Hexagon 2 * Ptrace support for Hexagon
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/kernel/reset.c b/arch/hexagon/kernel/reset.c
index 4d72fc58e9b..6aeabc962b3 100644
--- a/arch/hexagon/kernel/reset.c
+++ b/arch/hexagon/kernel/reset.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 2 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and 5 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/kernel/setup.c b/arch/hexagon/kernel/setup.c
index 1202f78d25c..94a38783500 100644
--- a/arch/hexagon/kernel/setup.c
+++ b/arch/hexagon/kernel/setup.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Arch related setup for Hexagon 2 * Arch related setup for Hexagon
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/kernel/signal.c b/arch/hexagon/kernel/signal.c
index 1ea16bec7b9..fe0d1373165 100644
--- a/arch/hexagon/kernel/signal.c
+++ b/arch/hexagon/kernel/signal.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Signal support for Hexagon processor 2 * Signal support for Hexagon processor
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
@@ -249,14 +249,14 @@ void do_notify_resume(struct pt_regs *regs, unsigned long thread_info_flags)
249 */ 249 */
250asmlinkage int sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss) 250asmlinkage int sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss)
251{ 251{
252 struct pt_regs *regs = current_thread_info()->regs; 252 struct pt_regs *regs = current_pt_regs();
253 253
254 return do_sigaltstack(uss, uoss, regs->r29); 254 return do_sigaltstack(uss, uoss, regs->r29);
255} 255}
256 256
257asmlinkage int sys_rt_sigreturn(void) 257asmlinkage int sys_rt_sigreturn(void)
258{ 258{
259 struct pt_regs *regs = current_thread_info()->regs; 259 struct pt_regs *regs = current_pt_regs();
260 struct rt_sigframe __user *frame; 260 struct rt_sigframe __user *frame;
261 sigset_t blocked; 261 sigset_t blocked;
262 262
diff --git a/arch/hexagon/kernel/smp.c b/arch/hexagon/kernel/smp.c
index 149fbefc1a4..8e095dffd07 100644
--- a/arch/hexagon/kernel/smp.c
+++ b/arch/hexagon/kernel/smp.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * SMP support for Hexagon 2 * SMP support for Hexagon
3 * 3 *
4 * Copyright (c) 2010-2012, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2012, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/kernel/stacktrace.c b/arch/hexagon/kernel/stacktrace.c
index 11c597b2ac5..f94918b449a 100644
--- a/arch/hexagon/kernel/stacktrace.c
+++ b/arch/hexagon/kernel/stacktrace.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Stacktrace support for Hexagon 2 * Stacktrace support for Hexagon
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/kernel/syscall.c b/arch/hexagon/kernel/syscall.c
index 25a9bfe3445..d2cc3270af3 100644
--- a/arch/hexagon/kernel/syscall.c
+++ b/arch/hexagon/kernel/syscall.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Hexagon system calls 2 * Hexagon system calls
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
@@ -35,55 +35,13 @@
35 * See signal.c for signal-related system call wrappers. 35 * See signal.c for signal-related system call wrappers.
36 */ 36 */
37 37
38asmlinkage int sys_execve(char __user *ufilename,
39 const char __user *const __user *argv,
40 const char __user *const __user *envp)
41{
42 struct pt_regs *pregs = current_thread_info()->regs;
43 struct filename *filename;
44 int retval;
45
46 filename = getname(ufilename);
47 retval = PTR_ERR(filename);
48 if (IS_ERR(filename))
49 return retval;
50
51 retval = do_execve(filename->name, argv, envp, pregs);
52 putname(filename);
53
54 return retval;
55}
56
57asmlinkage int sys_clone(unsigned long clone_flags, unsigned long newsp, 38asmlinkage int sys_clone(unsigned long clone_flags, unsigned long newsp,
58 unsigned long parent_tidp, unsigned long child_tidp) 39 unsigned long parent_tidp, unsigned long child_tidp)
59{ 40{
60 struct pt_regs *pregs = current_thread_info()->regs; 41 struct pt_regs *pregs = current_pt_regs();
61 42
62 if (!newsp) 43 if (!newsp)
63 newsp = pregs->SP; 44 newsp = pregs->SP;
64 return do_fork(clone_flags, newsp, pregs, 0, (int __user *)parent_tidp, 45 return do_fork(clone_flags, newsp, pregs, 0, (int __user *)parent_tidp,
65 (int __user *)child_tidp); 46 (int __user *)child_tidp);
66} 47}
67
68/*
69 * Do a system call from the kernel, so as to have a proper pt_regs
70 * and recycle the sys_execvpe infrustructure.
71 */
72int kernel_execve(const char *filename,
73 const char *const argv[], const char *const envp[])
74{
75 register unsigned long __a0 asm("r0") = (unsigned long) filename;
76 register unsigned long __a1 asm("r1") = (unsigned long) argv;
77 register unsigned long __a2 asm("r2") = (unsigned long) envp;
78 int retval;
79
80 __asm__ volatile(
81 " R6 = #%4;\n"
82 " trap0(#1);\n"
83 " %0 = R0;\n"
84 : "=r" (retval)
85 : "r" (__a0), "r" (__a1), "r" (__a2), "i" (__NR_execve)
86 );
87
88 return retval;
89}
diff --git a/arch/hexagon/kernel/syscalltab.c b/arch/hexagon/kernel/syscalltab.c
index c550f4177ab..7024b1ddc08 100644
--- a/arch/hexagon/kernel/syscalltab.c
+++ b/arch/hexagon/kernel/syscalltab.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * System call table for Hexagon 2 * System call table for Hexagon
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/kernel/time.c b/arch/hexagon/kernel/time.c
index 36ba6418571..9903fad997f 100644
--- a/arch/hexagon/kernel/time.c
+++ b/arch/hexagon/kernel/time.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Time related functions for Hexagon architecture 2 * Time related functions for Hexagon architecture
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/kernel/topology.c b/arch/hexagon/kernel/topology.c
index ba447518443..352f27e809f 100644
--- a/arch/hexagon/kernel/topology.c
+++ b/arch/hexagon/kernel/topology.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * CPU topology for Hexagon 2 * CPU topology for Hexagon
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/kernel/trampoline.S b/arch/hexagon/kernel/trampoline.S
index 06c36c036b9..18110a9056b 100644
--- a/arch/hexagon/kernel/trampoline.S
+++ b/arch/hexagon/kernel/trampoline.S
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 2 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and 5 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/kernel/traps.c b/arch/hexagon/kernel/traps.c
index f08857d0715..a41eeb8eeaa 100644
--- a/arch/hexagon/kernel/traps.c
+++ b/arch/hexagon/kernel/traps.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Kernel traps/events for Hexagon processor 2 * Kernel traps/events for Hexagon processor
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/kernel/vdso.c b/arch/hexagon/kernel/vdso.c
index 5d39f42f708..0bf5a87e4d0 100644
--- a/arch/hexagon/kernel/vdso.c
+++ b/arch/hexagon/kernel/vdso.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * vDSO implementation for Hexagon 2 * vDSO implementation for Hexagon
3 * 3 *
4 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/kernel/vm_entry.S b/arch/hexagon/kernel/vm_entry.S
index 5b99066cbc8..425e50c694f 100644
--- a/arch/hexagon/kernel/vm_entry.S
+++ b/arch/hexagon/kernel/vm_entry.S
@@ -1,7 +1,7 @@
1/* 1/*
2 * Event entry/exit for Hexagon 2 * Event entry/exit for Hexagon
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
@@ -266,4 +266,8 @@ _K_enter_machcheck:
266 .globl ret_from_fork 266 .globl ret_from_fork
267ret_from_fork: 267ret_from_fork:
268 call schedule_tail 268 call schedule_tail
269 P0 = cmp.eq(R24, #0);
270 if P0 jump return_from_syscall
271 R0 = R25;
272 callr R24
269 jump return_from_syscall 273 jump return_from_syscall
diff --git a/arch/hexagon/kernel/vm_events.c b/arch/hexagon/kernel/vm_events.c
index 591fc1b6863..9b5a4a295a6 100644
--- a/arch/hexagon/kernel/vm_events.c
+++ b/arch/hexagon/kernel/vm_events.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Mostly IRQ support for Hexagon 2 * Mostly IRQ support for Hexagon
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/kernel/vm_init_segtable.S b/arch/hexagon/kernel/vm_init_segtable.S
index aebb35b6465..80967f2192b 100644
--- a/arch/hexagon/kernel/vm_init_segtable.S
+++ b/arch/hexagon/kernel/vm_init_segtable.S
@@ -1,7 +1,7 @@
1/* 1/*
2 * Initial page table for Linux kernel under Hexagon VM, 2 * Initial page table for Linux kernel under Hexagon VM,
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/kernel/vm_ops.S b/arch/hexagon/kernel/vm_ops.S
index 24d7fcac4ff..9fb77b3f6cf 100644
--- a/arch/hexagon/kernel/vm_ops.S
+++ b/arch/hexagon/kernel/vm_ops.S
@@ -1,7 +1,7 @@
1/* 1/*
2 * Hexagon VM instruction support 2 * Hexagon VM instruction support
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/kernel/vm_switch.S b/arch/hexagon/kernel/vm_switch.S
index 0decf2f58e3..62c6df91b3b 100644
--- a/arch/hexagon/kernel/vm_switch.S
+++ b/arch/hexagon/kernel/vm_switch.S
@@ -1,7 +1,7 @@
1/* 1/*
2 * Context switch support for Hexagon 2 * Context switch support for Hexagon
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/kernel/vm_vectors.S b/arch/hexagon/kernel/vm_vectors.S
index 97a4b50b00d..620f42cc582 100644
--- a/arch/hexagon/kernel/vm_vectors.S
+++ b/arch/hexagon/kernel/vm_vectors.S
@@ -1,7 +1,7 @@
1/* 1/*
2 * Event jump tables 2 * Event jump tables
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/kernel/vmlinux.lds.S b/arch/hexagon/kernel/vmlinux.lds.S
index 071d3c30edf..14e793f6abb 100644
--- a/arch/hexagon/kernel/vmlinux.lds.S
+++ b/arch/hexagon/kernel/vmlinux.lds.S
@@ -1,7 +1,7 @@
1/* 1/*
2 * Linker script for Hexagon kernel 2 * Linker script for Hexagon kernel
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/lib/checksum.c b/arch/hexagon/lib/checksum.c
index 93005522d52..8169f78a46a 100644
--- a/arch/hexagon/lib/checksum.c
+++ b/arch/hexagon/lib/checksum.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Checksum functions for Hexagon 2 * Checksum functions for Hexagon
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/lib/io.c b/arch/hexagon/lib/io.c
index 8ae47ba0e70..885c9626d5e 100644
--- a/arch/hexagon/lib/io.c
+++ b/arch/hexagon/lib/io.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * I/O access functions for Hexagon 2 * I/O access functions for Hexagon
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/lib/memcpy.S b/arch/hexagon/lib/memcpy.S
index 2101c339566..81c561c4b4d 100644
--- a/arch/hexagon/lib/memcpy.S
+++ b/arch/hexagon/lib/memcpy.S
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 2 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
3 * 3 *
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
diff --git a/arch/hexagon/lib/memset.S b/arch/hexagon/lib/memset.S
index 26d961439ab..9341889ea3f 100644
--- a/arch/hexagon/lib/memset.S
+++ b/arch/hexagon/lib/memset.S
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2011 Code Aurora Forum. All rights reserved. 2 * Copyright (c) 2011, The Linux Foundation. All rights reserved.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and 5 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/mm/cache.c b/arch/hexagon/mm/cache.c
index c5cf6ee2758..fe14ccf2856 100644
--- a/arch/hexagon/mm/cache.c
+++ b/arch/hexagon/mm/cache.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Cache management functions for Hexagon 2 * Cache management functions for Hexagon
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/mm/copy_from_user.S b/arch/hexagon/mm/copy_from_user.S
index 8eb1d4d61a3..7fc94f3e664 100644
--- a/arch/hexagon/mm/copy_from_user.S
+++ b/arch/hexagon/mm/copy_from_user.S
@@ -1,7 +1,7 @@
1/* 1/*
2 * User memory copy functions for kernel 2 * User memory copy functions for kernel
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/mm/copy_to_user.S b/arch/hexagon/mm/copy_to_user.S
index cb9740ed9e7..0cfbcc09d1d 100644
--- a/arch/hexagon/mm/copy_to_user.S
+++ b/arch/hexagon/mm/copy_to_user.S
@@ -1,7 +1,7 @@
1/* 1/*
2 * User memory copying routines for the Hexagon Kernel 2 * User memory copying routines for the Hexagon Kernel
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/mm/copy_user_template.S b/arch/hexagon/mm/copy_user_template.S
index 08d7d7b23da..254d8cc766b 100644
--- a/arch/hexagon/mm/copy_user_template.S
+++ b/arch/hexagon/mm/copy_user_template.S
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 2 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and 5 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/mm/init.c b/arch/hexagon/mm/init.c
index b57d741750b..69ffcfd2879 100644
--- a/arch/hexagon/mm/init.c
+++ b/arch/hexagon/mm/init.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Memory subsystem initialization for Hexagon 2 * Memory subsystem initialization for Hexagon
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/mm/ioremap.c b/arch/hexagon/mm/ioremap.c
index 3a37bc3b011..5905fd5f97f 100644
--- a/arch/hexagon/mm/ioremap.c
+++ b/arch/hexagon/mm/ioremap.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * I/O remap functions for Hexagon 2 * I/O remap functions for Hexagon
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/mm/pgalloc.c b/arch/hexagon/mm/pgalloc.c
index b175e2d42b8..19760a4611d 100644
--- a/arch/hexagon/mm/pgalloc.c
+++ b/arch/hexagon/mm/pgalloc.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 2 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and 5 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/mm/strnlen_user.S b/arch/hexagon/mm/strnlen_user.S
index 5c6a16c7c72..0eecb7a768f 100644
--- a/arch/hexagon/mm/strnlen_user.S
+++ b/arch/hexagon/mm/strnlen_user.S
@@ -1,7 +1,7 @@
1/* 1/*
2 * User string length functions for kernel 2 * User string length functions for kernel
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/mm/uaccess.c b/arch/hexagon/mm/uaccess.c
index e748108b47a..34127261c2b 100644
--- a/arch/hexagon/mm/uaccess.c
+++ b/arch/hexagon/mm/uaccess.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 2 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and 5 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/mm/vm_fault.c b/arch/hexagon/mm/vm_fault.c
index 513b74cb397..308ef0ce648 100644
--- a/arch/hexagon/mm/vm_fault.c
+++ b/arch/hexagon/mm/vm_fault.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Memory fault handling for Hexagon 2 * Memory fault handling for Hexagon
3 * 3 *
4 * Copyright (c) 2010-2011 Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/hexagon/mm/vm_tlb.c b/arch/hexagon/mm/vm_tlb.c
index c6ff4157546..9647d00cb76 100644
--- a/arch/hexagon/mm/vm_tlb.c
+++ b/arch/hexagon/mm/vm_tlb.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Hexagon Virtual Machine TLB functions 2 * Hexagon Virtual Machine TLB functions
3 * 3 *
4 * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. 4 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 and 7 * it under the terms of the GNU General Public License version 2 and
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index 3279646120e..67060046812 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -42,6 +42,8 @@ config IA64
42 select GENERIC_TIME_VSYSCALL_OLD 42 select GENERIC_TIME_VSYSCALL_OLD
43 select HAVE_MOD_ARCH_SPECIFIC 43 select HAVE_MOD_ARCH_SPECIFIC
44 select MODULES_USE_ELF_RELA 44 select MODULES_USE_ELF_RELA
45 select GENERIC_KERNEL_THREAD
46 select GENERIC_KERNEL_EXECVE
45 default y 47 default y
46 help 48 help
47 The Itanium Processor Family is Intel's 64-bit successor to 49 The Itanium Processor Family is Intel's 64-bit successor to
diff --git a/arch/ia64/include/asm/Kbuild b/arch/ia64/include/asm/Kbuild
index 4a159da2363..dd02f09b6ed 100644
--- a/arch/ia64/include/asm/Kbuild
+++ b/arch/ia64/include/asm/Kbuild
@@ -1,3 +1,4 @@
1 1
2generic-y += clkdev.h 2generic-y += clkdev.h
3generic-y += exec.h 3generic-y += exec.h
4generic-y += kvm_para.h
diff --git a/arch/ia64/include/asm/kvm_para.h b/arch/ia64/include/asm/kvm_para.h
deleted file mode 100644
index 47c00f91043..00000000000
--- a/arch/ia64/include/asm/kvm_para.h
+++ /dev/null
@@ -1,34 +0,0 @@
1/*
2 * Copyright (C) 2007 Xiantao Zhang <xiantao.zhang@intel.com>
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
15 * Place - Suite 330, Boston, MA 02111-1307 USA.
16 *
17 */
18#ifndef __IA64_KVM_PARA_H
19#define __IA64_KVM_PARA_H
20
21#include <uapi/asm/kvm_para.h>
22
23
24static inline unsigned int kvm_arch_para_features(void)
25{
26 return 0;
27}
28
29static inline bool kvm_check_and_clear_guest_paused(void)
30{
31 return false;
32}
33
34#endif
diff --git a/arch/ia64/include/asm/processor.h b/arch/ia64/include/asm/processor.h
index 944152a5091..e0a899a1a8a 100644
--- a/arch/ia64/include/asm/processor.h
+++ b/arch/ia64/include/asm/processor.h
@@ -340,22 +340,6 @@ struct task_struct;
340 */ 340 */
341#define release_thread(dead_task) 341#define release_thread(dead_task)
342 342
343/*
344 * This is the mechanism for creating a new kernel thread.
345 *
346 * NOTE 1: Only a kernel-only process (ie the swapper or direct
347 * descendants who haven't done an "execve()") should use this: it
348 * will work within a system call from a "real" process, but the
349 * process memory space will not be free'd until both the parent and
350 * the child have exited.
351 *
352 * NOTE 2: This MUST NOT be an inlined function. Otherwise, we get
353 * into trouble in init/main.c when the child thread returns to
354 * do_basic_setup() and the timing is such that free_initmem() has
355 * been called already.
356 */
357extern pid_t kernel_thread (int (*fn)(void *), void *arg, unsigned long flags);
358
359/* Get wait channel for task P. */ 343/* Get wait channel for task P. */
360extern unsigned long get_wchan (struct task_struct *p); 344extern unsigned long get_wchan (struct task_struct *p);
361 345
diff --git a/arch/ia64/include/asm/unistd.h b/arch/ia64/include/asm/unistd.h
index 8b3ff2f5b86..1574bca8613 100644
--- a/arch/ia64/include/asm/unistd.h
+++ b/arch/ia64/include/asm/unistd.h
@@ -29,6 +29,7 @@
29 29
30#define __ARCH_WANT_SYS_RT_SIGACTION 30#define __ARCH_WANT_SYS_RT_SIGACTION
31#define __ARCH_WANT_SYS_RT_SIGSUSPEND 31#define __ARCH_WANT_SYS_RT_SIGSUSPEND
32#define __ARCH_WANT_SYS_EXECVE
32 33
33#if !defined(__ASSEMBLY__) && !defined(ASSEMBLER) 34#if !defined(__ASSEMBLY__) && !defined(ASSEMBLER)
34 35
diff --git a/arch/ia64/include/uapi/asm/Kbuild b/arch/ia64/include/uapi/asm/Kbuild
index 30cafac9370..1b3f5eb5fcd 100644
--- a/arch/ia64/include/uapi/asm/Kbuild
+++ b/arch/ia64/include/uapi/asm/Kbuild
@@ -1,6 +1,8 @@
1# UAPI Header export list 1# UAPI Header export list
2include include/uapi/asm-generic/Kbuild.asm 2include include/uapi/asm-generic/Kbuild.asm
3 3
4generic-y += kvm_para.h
5
4header-y += auxvec.h 6header-y += auxvec.h
5header-y += bitsperlong.h 7header-y += bitsperlong.h
6header-y += break.h 8header-y += break.h
diff --git a/arch/ia64/include/uapi/asm/kvm_para.h b/arch/ia64/include/uapi/asm/kvm_para.h
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/arch/ia64/include/uapi/asm/kvm_para.h
+++ /dev/null
diff --git a/arch/ia64/kernel/entry.S b/arch/ia64/kernel/entry.S
index 1ccbe12a4d8..940a6726362 100644
--- a/arch/ia64/kernel/entry.S
+++ b/arch/ia64/kernel/entry.S
@@ -61,14 +61,13 @@ ENTRY(ia64_execve)
61 * Allocate 8 input registers since ptrace() may clobber them 61 * Allocate 8 input registers since ptrace() may clobber them
62 */ 62 */
63 .prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(8) 63 .prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(8)
64 alloc loc1=ar.pfs,8,2,4,0 64 alloc loc1=ar.pfs,8,2,3,0
65 mov loc0=rp 65 mov loc0=rp
66 .body 66 .body
67 mov out0=in0 // filename 67 mov out0=in0 // filename
68 ;; // stop bit between alloc and call 68 ;; // stop bit between alloc and call
69 mov out1=in1 // argv 69 mov out1=in1 // argv
70 mov out2=in2 // envp 70 mov out2=in2 // envp
71 add out3=16,sp // regs
72 br.call.sptk.many rp=sys_execve 71 br.call.sptk.many rp=sys_execve
73.ret0: 72.ret0:
74 cmp4.ge p6,p7=r8,r0 73 cmp4.ge p6,p7=r8,r0
@@ -76,7 +75,6 @@ ENTRY(ia64_execve)
76 sxt4 r8=r8 // return 64-bit result 75 sxt4 r8=r8 // return 64-bit result
77 ;; 76 ;;
78 stf.spill [sp]=f0 77 stf.spill [sp]=f0
79(p6) cmp.ne pKStk,pUStk=r0,r0 // a successful execve() lands us in user-mode...
80 mov rp=loc0 78 mov rp=loc0
81(p6) mov ar.pfs=r0 // clear ar.pfs on success 79(p6) mov ar.pfs=r0 // clear ar.pfs on success
82(p7) br.ret.sptk.many rp 80(p7) br.ret.sptk.many rp
@@ -484,19 +482,6 @@ GLOBAL_ENTRY(prefetch_stack)
484 br.ret.sptk.many rp 482 br.ret.sptk.many rp
485END(prefetch_stack) 483END(prefetch_stack)
486 484
487GLOBAL_ENTRY(kernel_execve)
488 rum psr.ac
489 mov r15=__NR_execve // put syscall number in place
490 break __BREAK_SYSCALL
491 br.ret.sptk.many rp
492END(kernel_execve)
493
494GLOBAL_ENTRY(clone)
495 mov r15=__NR_clone // put syscall number in place
496 break __BREAK_SYSCALL
497 br.ret.sptk.many rp
498END(clone)
499
500 /* 485 /*
501 * Invoke a system call, but do some tracing before and after the call. 486 * Invoke a system call, but do some tracing before and after the call.
502 * We MUST preserve the current register frame throughout this routine 487 * We MUST preserve the current register frame throughout this routine
@@ -600,6 +585,27 @@ GLOBAL_ENTRY(ia64_strace_leave_kernel)
600.ret4: br.cond.sptk ia64_leave_kernel 585.ret4: br.cond.sptk ia64_leave_kernel
601END(ia64_strace_leave_kernel) 586END(ia64_strace_leave_kernel)
602 587
588ENTRY(call_payload)
589 .prologue ASM_UNW_PRLG_RP|ASM_UNW_PRLG_PFS, ASM_UNW_PRLG_GRSAVE(0)
590 /* call the kernel_thread payload; fn is in r4, arg - in r5 */
591 alloc loc1=ar.pfs,0,3,1,0
592 mov loc0=rp
593 mov loc2=gp
594 mov out0=r5 // arg
595 ld8 r14 = [r4], 8 // fn.address
596 ;;
597 mov b6 = r14
598 ld8 gp = [r4] // fn.gp
599 ;;
600 br.call.sptk.many rp=b6 // fn(arg)
601.ret12: mov gp=loc2
602 mov rp=loc0
603 mov ar.pfs=loc1
604 /* ... and if it has returned, we are going to userland */
605 cmp.ne pKStk,pUStk=r0,r0
606 br.ret.sptk.many rp
607END(call_payload)
608
603GLOBAL_ENTRY(ia64_ret_from_clone) 609GLOBAL_ENTRY(ia64_ret_from_clone)
604 PT_REGS_UNWIND_INFO(0) 610 PT_REGS_UNWIND_INFO(0)
605{ /* 611{ /*
@@ -616,6 +622,7 @@ GLOBAL_ENTRY(ia64_ret_from_clone)
616 br.call.sptk.many rp=ia64_invoke_schedule_tail 622 br.call.sptk.many rp=ia64_invoke_schedule_tail
617} 623}
618.ret8: 624.ret8:
625(pKStk) br.call.sptk.many rp=call_payload
619 adds r2=TI_FLAGS+IA64_TASK_SIZE,r13 626 adds r2=TI_FLAGS+IA64_TASK_SIZE,r13
620 ;; 627 ;;
621 ld4 r2=[r2] 628 ld4 r2=[r2]
diff --git a/arch/ia64/kernel/head.S b/arch/ia64/kernel/head.S
index 629a250f7c1..4738ff7bd66 100644
--- a/arch/ia64/kernel/head.S
+++ b/arch/ia64/kernel/head.S
@@ -1093,19 +1093,6 @@ GLOBAL_ENTRY(cycle_to_cputime)
1093END(cycle_to_cputime) 1093END(cycle_to_cputime)
1094#endif /* CONFIG_VIRT_CPU_ACCOUNTING */ 1094#endif /* CONFIG_VIRT_CPU_ACCOUNTING */
1095 1095
1096GLOBAL_ENTRY(start_kernel_thread)
1097 .prologue
1098 .save rp, r0 // this is the end of the call-chain
1099 .body
1100 alloc r2 = ar.pfs, 0, 0, 2, 0
1101 mov out0 = r9
1102 mov out1 = r11;;
1103 br.call.sptk.many rp = kernel_thread_helper;;
1104 mov out0 = r8
1105 br.call.sptk.many rp = sys_exit;;
11061: br.sptk.few 1b // not reached
1107END(start_kernel_thread)
1108
1109#ifdef CONFIG_IA64_BRL_EMU 1096#ifdef CONFIG_IA64_BRL_EMU
1110 1097
1111/* 1098/*
diff --git a/arch/ia64/kernel/process.c b/arch/ia64/kernel/process.c
index 35e106f2ed1..25543a295ad 100644
--- a/arch/ia64/kernel/process.c
+++ b/arch/ia64/kernel/process.c
@@ -401,64 +401,15 @@ copy_thread(unsigned long clone_flags,
401 struct pt_regs *child_ptregs; 401 struct pt_regs *child_ptregs;
402 int retval = 0; 402 int retval = 0;
403 403
404#ifdef CONFIG_SMP
405 /*
406 * For SMP idle threads, fork_by_hand() calls do_fork with
407 * NULL regs.
408 */
409 if (!regs)
410 return 0;
411#endif
412
413 stack = ((struct switch_stack *) regs) - 1;
414
415 child_ptregs = (struct pt_regs *) ((unsigned long) p + IA64_STK_OFFSET) - 1; 404 child_ptregs = (struct pt_regs *) ((unsigned long) p + IA64_STK_OFFSET) - 1;
416 child_stack = (struct switch_stack *) child_ptregs - 1; 405 child_stack = (struct switch_stack *) child_ptregs - 1;
417 406
418 /* copy parent's switch_stack & pt_regs to child: */
419 memcpy(child_stack, stack, sizeof(*child_ptregs) + sizeof(*child_stack));
420
421 rbs = (unsigned long) current + IA64_RBS_OFFSET; 407 rbs = (unsigned long) current + IA64_RBS_OFFSET;
422 child_rbs = (unsigned long) p + IA64_RBS_OFFSET; 408 child_rbs = (unsigned long) p + IA64_RBS_OFFSET;
423 rbs_size = stack->ar_bspstore - rbs;
424
425 /* copy the parent's register backing store to the child: */
426 memcpy((void *) child_rbs, (void *) rbs, rbs_size);
427
428 if (likely(user_mode(child_ptregs))) {
429 if (clone_flags & CLONE_SETTLS)
430 child_ptregs->r13 = regs->r16; /* see sys_clone2() in entry.S */
431 if (user_stack_base) {
432 child_ptregs->r12 = user_stack_base + user_stack_size - 16;
433 child_ptregs->ar_bspstore = user_stack_base;
434 child_ptregs->ar_rnat = 0;
435 child_ptregs->loadrs = 0;
436 }
437 } else {
438 /*
439 * Note: we simply preserve the relative position of
440 * the stack pointer here. There is no need to
441 * allocate a scratch area here, since that will have
442 * been taken care of by the caller of sys_clone()
443 * already.
444 */
445 child_ptregs->r12 = (unsigned long) child_ptregs - 16; /* kernel sp */
446 child_ptregs->r13 = (unsigned long) p; /* set `current' pointer */
447 }
448 child_stack->ar_bspstore = child_rbs + rbs_size;
449 child_stack->b0 = (unsigned long) &ia64_ret_from_clone;
450 409
451 /* copy parts of thread_struct: */ 410 /* copy parts of thread_struct: */
452 p->thread.ksp = (unsigned long) child_stack - 16; 411 p->thread.ksp = (unsigned long) child_stack - 16;
453 412
454 /* stop some PSR bits from being inherited.
455 * the psr.up/psr.pp bits must be cleared on fork but inherited on execve()
456 * therefore we must specify them explicitly here and not include them in
457 * IA64_PSR_BITS_TO_CLEAR.
458 */
459 child_ptregs->cr_ipsr = ((child_ptregs->cr_ipsr | IA64_PSR_BITS_TO_SET)
460 & ~(IA64_PSR_BITS_TO_CLEAR | IA64_PSR_PP | IA64_PSR_UP));
461
462 /* 413 /*
463 * NOTE: The calling convention considers all floating point 414 * NOTE: The calling convention considers all floating point
464 * registers in the high partition (fph) to be scratch. Since 415 * registers in the high partition (fph) to be scratch. Since
@@ -480,8 +431,66 @@ copy_thread(unsigned long clone_flags,
480# define THREAD_FLAGS_TO_SET 0 431# define THREAD_FLAGS_TO_SET 0
481 p->thread.flags = ((current->thread.flags & ~THREAD_FLAGS_TO_CLEAR) 432 p->thread.flags = ((current->thread.flags & ~THREAD_FLAGS_TO_CLEAR)
482 | THREAD_FLAGS_TO_SET); 433 | THREAD_FLAGS_TO_SET);
434
483 ia64_drop_fpu(p); /* don't pick up stale state from a CPU's fph */ 435 ia64_drop_fpu(p); /* don't pick up stale state from a CPU's fph */
484 436
437 if (unlikely(p->flags & PF_KTHREAD)) {
438 if (unlikely(!user_stack_base)) {
439 /* fork_idle() called us */
440 return 0;
441 }
442 memset(child_stack, 0, sizeof(*child_ptregs) + sizeof(*child_stack));
443 child_stack->r4 = user_stack_base; /* payload */
444 child_stack->r5 = user_stack_size; /* argument */
445 /*
446 * Preserve PSR bits, except for bits 32-34 and 37-45,
447 * which we can't read.
448 */
449 child_ptregs->cr_ipsr = ia64_getreg(_IA64_REG_PSR) | IA64_PSR_BN;
450 /* mark as valid, empty frame */
451 child_ptregs->cr_ifs = 1UL << 63;
452 child_stack->ar_fpsr = child_ptregs->ar_fpsr
453 = ia64_getreg(_IA64_REG_AR_FPSR);
454 child_stack->pr = (1 << PRED_KERNEL_STACK);
455 child_stack->ar_bspstore = child_rbs;
456 child_stack->b0 = (unsigned long) &ia64_ret_from_clone;
457
458 /* stop some PSR bits from being inherited.
459 * the psr.up/psr.pp bits must be cleared on fork but inherited on execve()
460 * therefore we must specify them explicitly here and not include them in
461 * IA64_PSR_BITS_TO_CLEAR.
462 */
463 child_ptregs->cr_ipsr = ((child_ptregs->cr_ipsr | IA64_PSR_BITS_TO_SET)
464 & ~(IA64_PSR_BITS_TO_CLEAR | IA64_PSR_PP | IA64_PSR_UP));
465
466 return 0;
467 }
468 stack = ((struct switch_stack *) regs) - 1;
469 /* copy parent's switch_stack & pt_regs to child: */
470 memcpy(child_stack, stack, sizeof(*child_ptregs) + sizeof(*child_stack));
471
472 /* copy the parent's register backing store to the child: */
473 rbs_size = stack->ar_bspstore - rbs;
474 memcpy((void *) child_rbs, (void *) rbs, rbs_size);
475 if (clone_flags & CLONE_SETTLS)
476 child_ptregs->r13 = regs->r16; /* see sys_clone2() in entry.S */
477 if (user_stack_base) {
478 child_ptregs->r12 = user_stack_base + user_stack_size - 16;
479 child_ptregs->ar_bspstore = user_stack_base;
480 child_ptregs->ar_rnat = 0;
481 child_ptregs->loadrs = 0;
482 }
483 child_stack->ar_bspstore = child_rbs + rbs_size;
484 child_stack->b0 = (unsigned long) &ia64_ret_from_clone;
485
486 /* stop some PSR bits from being inherited.
487 * the psr.up/psr.pp bits must be cleared on fork but inherited on execve()
488 * therefore we must specify them explicitly here and not include them in
489 * IA64_PSR_BITS_TO_CLEAR.
490 */
491 child_ptregs->cr_ipsr = ((child_ptregs->cr_ipsr | IA64_PSR_BITS_TO_SET)
492 & ~(IA64_PSR_BITS_TO_CLEAR | IA64_PSR_PP | IA64_PSR_UP));
493
485#ifdef CONFIG_PERFMON 494#ifdef CONFIG_PERFMON
486 if (current->thread.pfm_context) 495 if (current->thread.pfm_context)
487 pfm_inherit(p, child_ptregs); 496 pfm_inherit(p, child_ptregs);
@@ -608,57 +617,6 @@ dump_fpu (struct pt_regs *pt, elf_fpregset_t dst)
608 return 1; /* f0-f31 are always valid so we always return 1 */ 617 return 1; /* f0-f31 are always valid so we always return 1 */
609} 618}
610 619
611long
612sys_execve (const char __user *filename,
613 const char __user *const __user *argv,
614 const char __user *const __user *envp,
615 struct pt_regs *regs)
616{
617 struct filename *fname;
618 int error;
619
620 fname = getname(filename);
621 error = PTR_ERR(fname);
622 if (IS_ERR(fname))
623 goto out;
624 error = do_execve(fname->name, argv, envp, regs);
625 putname(fname);
626out:
627 return error;
628}
629
630pid_t
631kernel_thread (int (*fn)(void *), void *arg, unsigned long flags)
632{
633 extern void start_kernel_thread (void);
634 unsigned long *helper_fptr = (unsigned long *) &start_kernel_thread;
635 struct {
636 struct switch_stack sw;
637 struct pt_regs pt;
638 } regs;
639
640 memset(&regs, 0, sizeof(regs));
641 regs.pt.cr_iip = helper_fptr[0]; /* set entry point (IP) */
642 regs.pt.r1 = helper_fptr[1]; /* set GP */
643 regs.pt.r9 = (unsigned long) fn; /* 1st argument */
644 regs.pt.r11 = (unsigned long) arg; /* 2nd argument */
645 /* Preserve PSR bits, except for bits 32-34 and 37-45, which we can't read. */
646 regs.pt.cr_ipsr = ia64_getreg(_IA64_REG_PSR) | IA64_PSR_BN;
647 regs.pt.cr_ifs = 1UL << 63; /* mark as valid, empty frame */
648 regs.sw.ar_fpsr = regs.pt.ar_fpsr = ia64_getreg(_IA64_REG_AR_FPSR);
649 regs.sw.ar_bspstore = (unsigned long) current + IA64_RBS_OFFSET;
650 regs.sw.pr = (1 << PRED_KERNEL_STACK);
651 return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, &regs.pt, 0, NULL, NULL);
652}
653EXPORT_SYMBOL(kernel_thread);
654
655/* This gets called from kernel_thread() via ia64_invoke_thread_helper(). */
656int
657kernel_thread_helper (int (*fn)(void *), void *arg)
658{
659 return (*fn)(arg);
660}
661
662/* 620/*
663 * Flush thread state. This is called when a thread does an execve(). 621 * Flush thread state. This is called when a thread does an execve().
664 */ 622 */
diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
index acd5b68e887..082e383c1b6 100644
--- a/arch/ia64/mm/init.c
+++ b/arch/ia64/mm/init.c
@@ -637,7 +637,6 @@ mem_init (void)
637 637
638 high_memory = __va(max_low_pfn * PAGE_SIZE); 638 high_memory = __va(max_low_pfn * PAGE_SIZE);
639 639
640 reset_zone_present_pages();
641 for_each_online_pgdat(pgdat) 640 for_each_online_pgdat(pgdat)
642 if (pgdat->bdata->node_bootmem_map) 641 if (pgdat->bdata->node_bootmem_map)
643 totalram_pages += free_all_bootmem_node(pgdat); 642 totalram_pages += free_all_bootmem_node(pgdat);
diff --git a/arch/m32r/Kconfig b/arch/m32r/Kconfig
index f807721e19a..5183f43a2cf 100644
--- a/arch/m32r/Kconfig
+++ b/arch/m32r/Kconfig
@@ -15,6 +15,8 @@ config M32R
15 select GENERIC_ATOMIC64 15 select GENERIC_ATOMIC64
16 select ARCH_USES_GETTIMEOFFSET 16 select ARCH_USES_GETTIMEOFFSET
17 select MODULES_USE_ELF_RELA 17 select MODULES_USE_ELF_RELA
18 select GENERIC_KERNEL_THREAD
19 select GENERIC_KERNEL_EXECVE
18 20
19config SBUS 21config SBUS
20 bool 22 bool
diff --git a/arch/m32r/include/asm/processor.h b/arch/m32r/include/asm/processor.h
index da17253b573..5767367550c 100644
--- a/arch/m32r/include/asm/processor.h
+++ b/arch/m32r/include/asm/processor.h
@@ -118,11 +118,6 @@ struct mm_struct;
118/* Free all resources held by a thread. */ 118/* Free all resources held by a thread. */
119extern void release_thread(struct task_struct *); 119extern void release_thread(struct task_struct *);
120 120
121/*
122 * create a kernel thread without removing it from tasklists
123 */
124extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
125
126/* Copy and release all segment info associated with a VM */ 121/* Copy and release all segment info associated with a VM */
127extern void copy_segments(struct task_struct *p, struct mm_struct * mm); 122extern void copy_segments(struct task_struct *p, struct mm_struct * mm);
128extern void release_segments(struct mm_struct * mm); 123extern void release_segments(struct mm_struct * mm);
diff --git a/arch/m32r/include/asm/ptrace.h b/arch/m32r/include/asm/ptrace.h
index 4313aa62b51..c4432f1fb2c 100644
--- a/arch/m32r/include/asm/ptrace.h
+++ b/arch/m32r/include/asm/ptrace.h
@@ -139,6 +139,8 @@ extern void withdraw_debug_trap(struct pt_regs *regs);
139 139
140#define task_pt_regs(task) \ 140#define task_pt_regs(task) \
141 ((struct pt_regs *)(task_stack_page(task) + THREAD_SIZE) - 1) 141 ((struct pt_regs *)(task_stack_page(task) + THREAD_SIZE) - 1)
142#define current_pt_regs() ((struct pt_regs *) \
143 ((unsigned long)current_thread_info() + THREAD_SIZE) - 1)
142 144
143#endif /* __KERNEL */ 145#endif /* __KERNEL */
144 146
diff --git a/arch/m32r/include/asm/unistd.h b/arch/m32r/include/asm/unistd.h
index d5e66a48078..b27bdcbc7c2 100644
--- a/arch/m32r/include/asm/unistd.h
+++ b/arch/m32r/include/asm/unistd.h
@@ -352,6 +352,7 @@
352#define __ARCH_WANT_SYS_OLDUMOUNT 352#define __ARCH_WANT_SYS_OLDUMOUNT
353#define __ARCH_WANT_SYS_RT_SIGACTION 353#define __ARCH_WANT_SYS_RT_SIGACTION
354#define __ARCH_WANT_SYS_RT_SIGSUSPEND 354#define __ARCH_WANT_SYS_RT_SIGSUSPEND
355#define __ARCH_WANT_SYS_EXECVE
355 356
356#define __IGNORE_lchown 357#define __IGNORE_lchown
357#define __IGNORE_setuid 358#define __IGNORE_setuid
diff --git a/arch/m32r/kernel/entry.S b/arch/m32r/kernel/entry.S
index 225412bc227..0c01543f10c 100644
--- a/arch/m32r/kernel/entry.S
+++ b/arch/m32r/kernel/entry.S
@@ -125,6 +125,15 @@
125 and \reg, sp 125 and \reg, sp
126 .endm 126 .endm
127 127
128ENTRY(ret_from_kernel_thread)
129 pop r0
130 bl schedule_tail
131 GET_THREAD_INFO(r8)
132 ld r0, R0(r8)
133 ld r1, R1(r8)
134 jl r1
135 bra syscall_exit
136
128ENTRY(ret_from_fork) 137ENTRY(ret_from_fork)
129 pop r0 138 pop r0
130 bl schedule_tail 139 bl schedule_tail
diff --git a/arch/m32r/kernel/process.c b/arch/m32r/kernel/process.c
index e7366276ef3..62c713f5694 100644
--- a/arch/m32r/kernel/process.c
+++ b/arch/m32r/kernel/process.c
@@ -165,41 +165,6 @@ void show_regs(struct pt_regs * regs)
165} 165}
166 166
167/* 167/*
168 * Create a kernel thread
169 */
170
171/*
172 * This is the mechanism for creating a new kernel thread.
173 *
174 * NOTE! Only a kernel-only process(ie the swapper or direct descendants
175 * who haven't done an "execve()") should use this: it will work within
176 * a system call from a "real" process, but the process memory space will
177 * not be free'd until both the parent and the child have exited.
178 */
179static void kernel_thread_helper(void *nouse, int (*fn)(void *), void *arg)
180{
181 fn(arg);
182 do_exit(-1);
183}
184
185int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags)
186{
187 struct pt_regs regs;
188
189 memset(&regs, 0, sizeof (regs));
190 regs.r1 = (unsigned long)fn;
191 regs.r2 = (unsigned long)arg;
192
193 regs.bpc = (unsigned long)kernel_thread_helper;
194
195 regs.psw = M32R_PSW_BIE;
196
197 /* Ok, create the new process. */
198 return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, &regs, 0, NULL,
199 NULL);
200}
201
202/*
203 * Free current thread data structures etc.. 168 * Free current thread data structures etc..
204 */ 169 */
205void exit_thread(void) 170void exit_thread(void)
@@ -227,29 +192,35 @@ int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu)
227} 192}
228 193
229int copy_thread(unsigned long clone_flags, unsigned long spu, 194int copy_thread(unsigned long clone_flags, unsigned long spu,
230 unsigned long unused, struct task_struct *tsk, struct pt_regs *regs) 195 unsigned long arg, struct task_struct *tsk, struct pt_regs *regs)
231{ 196{
232 struct pt_regs *childregs = task_pt_regs(tsk); 197 struct pt_regs *childregs = task_pt_regs(tsk);
233 extern void ret_from_fork(void); 198 extern void ret_from_fork(void);
234 199 extern void ret_from_kernel_thread(void);
235 /* Copy registers */ 200
236 *childregs = *regs; 201 if (unlikely(tsk->flags & PF_KTHREAD)) {
237 202 memset(childregs, 0, sizeof(struct pt_regs));
238 childregs->spu = spu; 203 childregs->psw = M32R_PSW_BIE;
239 childregs->r0 = 0; /* Child gets zero as return value */ 204 childregs->r1 = spu; /* fn */
240 regs->r0 = tsk->pid; 205 childregs->r0 = arg;
206 tsk->thread.lr = (unsigned long)ret_from_kernel_thread;
207 } else {
208 /* Copy registers */
209 *childregs = *regs;
210 childregs->spu = spu;
211 childregs->r0 = 0; /* Child gets zero as return value */
212 tsk->thread.lr = (unsigned long)ret_from_fork;
213 }
241 tsk->thread.sp = (unsigned long)childregs; 214 tsk->thread.sp = (unsigned long)childregs;
242 tsk->thread.lr = (unsigned long)ret_from_fork;
243 215
244 return 0; 216 return 0;
245} 217}
246 218
247asmlinkage int sys_fork(unsigned long r0, unsigned long r1, unsigned long r2, 219asmlinkage int sys_fork(void)
248 unsigned long r3, unsigned long r4, unsigned long r5, unsigned long r6,
249 struct pt_regs regs)
250{ 220{
251#ifdef CONFIG_MMU 221#ifdef CONFIG_MMU
252 return do_fork(SIGCHLD, regs.spu, &regs, 0, NULL, NULL); 222 struct pt_regs *regs = current_pt_regs();
223 return do_fork(SIGCHLD, regs->spu, regs, 0, NULL, NULL);
253#else 224#else
254 return -EINVAL; 225 return -EINVAL;
255#endif /* CONFIG_MMU */ 226#endif /* CONFIG_MMU */
@@ -257,14 +228,13 @@ asmlinkage int sys_fork(unsigned long r0, unsigned long r1, unsigned long r2,
257 228
258asmlinkage int sys_clone(unsigned long clone_flags, unsigned long newsp, 229asmlinkage int sys_clone(unsigned long clone_flags, unsigned long newsp,
259 unsigned long parent_tidptr, 230 unsigned long parent_tidptr,
260 unsigned long child_tidptr, 231 unsigned long child_tidptr)
261 unsigned long r4, unsigned long r5, unsigned long r6,
262 struct pt_regs regs)
263{ 232{
233 struct pt_regs *regs = current_pt_regs();
264 if (!newsp) 234 if (!newsp)
265 newsp = regs.spu; 235 newsp = regs->spu;
266 236
267 return do_fork(clone_flags, newsp, &regs, 0, 237 return do_fork(clone_flags, newsp, regs, 0,
268 (int __user *)parent_tidptr, (int __user *)child_tidptr); 238 (int __user *)parent_tidptr, (int __user *)child_tidptr);
269} 239}
270 240
@@ -278,38 +248,14 @@ asmlinkage int sys_clone(unsigned long clone_flags, unsigned long newsp,
278 * do not have enough call-clobbered registers to hold all 248 * do not have enough call-clobbered registers to hold all
279 * the information you need. 249 * the information you need.
280 */ 250 */
281asmlinkage int sys_vfork(unsigned long r0, unsigned long r1, unsigned long r2, 251asmlinkage int sys_vfork(void)
282 unsigned long r3, unsigned long r4, unsigned long r5, unsigned long r6,
283 struct pt_regs regs)
284{ 252{
285 return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, regs.spu, &regs, 0, 253 struct pt_regs *regs = current_pt_regs();
254 return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, regs->spu, regs, 0,
286 NULL, NULL); 255 NULL, NULL);
287} 256}
288 257
289/* 258/*
290 * sys_execve() executes a new program.
291 */
292asmlinkage int sys_execve(const char __user *ufilename,
293 const char __user *const __user *uargv,
294 const char __user *const __user *uenvp,
295 unsigned long r3, unsigned long r4, unsigned long r5,
296 unsigned long r6, struct pt_regs regs)
297{
298 int error;
299 struct filename *filename;
300
301 filename = getname(ufilename);
302 error = PTR_ERR(filename);
303 if (IS_ERR(filename))
304 goto out;
305
306 error = do_execve(filename->name, uargv, uenvp, &regs);
307 putname(filename);
308out:
309 return error;
310}
311
312/*
313 * These bracket the sleeping functions.. 259 * These bracket the sleeping functions..
314 */ 260 */
315#define first_sched ((unsigned long) scheduling_functions_start_here) 261#define first_sched ((unsigned long) scheduling_functions_start_here)
diff --git a/arch/m32r/kernel/sys_m32r.c b/arch/m32r/kernel/sys_m32r.c
index d841fb6cc70..c3fdd632fba 100644
--- a/arch/m32r/kernel/sys_m32r.c
+++ b/arch/m32r/kernel/sys_m32r.c
@@ -88,24 +88,3 @@ asmlinkage int sys_cachectl(char *addr, int nbytes, int op)
88 /* Not implemented yet. */ 88 /* Not implemented yet. */
89 return -ENOSYS; 89 return -ENOSYS;
90} 90}
91
92/*
93 * Do a system call from kernel instead of calling sys_execve so we
94 * end up with proper pt_regs.
95 */
96int kernel_execve(const char *filename,
97 const char *const argv[],
98 const char *const envp[])
99{
100 register long __scno __asm__ ("r7") = __NR_execve;
101 register long __arg3 __asm__ ("r2") = (long)(envp);
102 register long __arg2 __asm__ ("r1") = (long)(argv);
103 register long __res __asm__ ("r0") = (long)(filename);
104 __asm__ __volatile__ (
105 "trap #" SYSCALL_VECTOR "|| nop"
106 : "=r" (__res)
107 : "r" (__scno), "0" (__res), "r" (__arg2),
108 "r" (__arg3)
109 : "memory");
110 return __res;
111}
diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
index e7c161433ea..953a7ba5d05 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -16,6 +16,7 @@ config M68K
16 select ARCH_WANT_IPC_PARSE_VERSION 16 select ARCH_WANT_IPC_PARSE_VERSION
17 select ARCH_USES_GETTIMEOFFSET if MMU && !COLDFIRE 17 select ARCH_USES_GETTIMEOFFSET if MMU && !COLDFIRE
18 select GENERIC_KERNEL_THREAD 18 select GENERIC_KERNEL_THREAD
19 select GENERIC_KERNEL_EXECVE
19 select HAVE_MOD_ARCH_SPECIFIC 20 select HAVE_MOD_ARCH_SPECIFIC
20 select MODULES_USE_ELF_REL 21 select MODULES_USE_ELF_REL
21 select MODULES_USE_ELF_RELA 22 select MODULES_USE_ELF_RELA
diff --git a/arch/m68k/include/asm/Kbuild b/arch/m68k/include/asm/Kbuild
index ecb540810ab..88fa3ac86fa 100644
--- a/arch/m68k/include/asm/Kbuild
+++ b/arch/m68k/include/asm/Kbuild
@@ -1,5 +1,3 @@
1include include/asm-generic/Kbuild.asm
2header-y += cachectl.h
3 1
4generic-y += bitsperlong.h 2generic-y += bitsperlong.h
5generic-y += clkdev.h 3generic-y += clkdev.h
diff --git a/arch/m68k/include/asm/ptrace.h b/arch/m68k/include/asm/ptrace.h
index 5e08b597f01..0f717045bdd 100644
--- a/arch/m68k/include/asm/ptrace.h
+++ b/arch/m68k/include/asm/ptrace.h
@@ -1,82 +1,10 @@
1#ifndef _M68K_PTRACE_H 1#ifndef _M68K_PTRACE_H
2#define _M68K_PTRACE_H 2#define _M68K_PTRACE_H
3 3
4#define PT_D1 0 4#include <uapi/asm/ptrace.h>
5#define PT_D2 1
6#define PT_D3 2
7#define PT_D4 3
8#define PT_D5 4
9#define PT_D6 5
10#define PT_D7 6
11#define PT_A0 7
12#define PT_A1 8
13#define PT_A2 9
14#define PT_A3 10
15#define PT_A4 11
16#define PT_A5 12
17#define PT_A6 13
18#define PT_D0 14
19#define PT_USP 15
20#define PT_ORIG_D0 16
21#define PT_SR 17
22#define PT_PC 18
23 5
24#ifndef __ASSEMBLY__ 6#ifndef __ASSEMBLY__
25 7
26/* this struct defines the way the registers are stored on the
27 stack during a system call. */
28
29struct pt_regs {
30 long d1;
31 long d2;
32 long d3;
33 long d4;
34 long d5;
35 long a0;
36 long a1;
37 long a2;
38 long d0;
39 long orig_d0;
40 long stkadj;
41#ifdef CONFIG_COLDFIRE
42 unsigned format : 4; /* frame format specifier */
43 unsigned vector : 12; /* vector offset */
44 unsigned short sr;
45 unsigned long pc;
46#else
47 unsigned short sr;
48 unsigned long pc;
49 unsigned format : 4; /* frame format specifier */
50 unsigned vector : 12; /* vector offset */
51#endif
52};
53
54/*
55 * This is the extended stack used by signal handlers and the context
56 * switcher: it's pushed after the normal "struct pt_regs".
57 */
58struct switch_stack {
59 unsigned long d6;
60 unsigned long d7;
61 unsigned long a3;
62 unsigned long a4;
63 unsigned long a5;
64 unsigned long a6;
65 unsigned long retpc;
66};
67
68/* Arbitrarily choose the same ptrace numbers as used by the Sparc code. */
69#define PTRACE_GETREGS 12
70#define PTRACE_SETREGS 13
71#define PTRACE_GETFPREGS 14
72#define PTRACE_SETFPREGS 15
73
74#define PTRACE_GET_THREAD_AREA 25
75
76#define PTRACE_SINGLEBLOCK 33 /* resume execution until next branch */
77
78#ifdef __KERNEL__
79
80#ifndef PS_S 8#ifndef PS_S
81#define PS_S (0x2000) 9#define PS_S (0x2000)
82#define PS_M (0x1000) 10#define PS_M (0x1000)
@@ -94,6 +22,5 @@ struct switch_stack {
94#define arch_has_block_step() (1) 22#define arch_has_block_step() (1)
95#endif 23#endif
96 24
97#endif /* __KERNEL__ */
98#endif /* __ASSEMBLY__ */ 25#endif /* __ASSEMBLY__ */
99#endif /* _M68K_PTRACE_H */ 26#endif /* _M68K_PTRACE_H */
diff --git a/arch/m68k/include/asm/setup.h b/arch/m68k/include/asm/setup.h
index 00c2c5397d3..65e78a2dad6 100644
--- a/arch/m68k/include/asm/setup.h
+++ b/arch/m68k/include/asm/setup.h
@@ -19,33 +19,12 @@
19** Redesign of the boot information structure; moved boot information 19** Redesign of the boot information structure; moved boot information
20** structure to bootinfo.h 20** structure to bootinfo.h
21*/ 21*/
22
23#ifndef _M68K_SETUP_H 22#ifndef _M68K_SETUP_H
24#define _M68K_SETUP_H 23#define _M68K_SETUP_H
25 24
25#include <uapi/asm/setup.h>
26 26
27 27
28 /*
29 * Linux/m68k Architectures
30 */
31
32#define MACH_AMIGA 1
33#define MACH_ATARI 2
34#define MACH_MAC 3
35#define MACH_APOLLO 4
36#define MACH_SUN3 5
37#define MACH_MVME147 6
38#define MACH_MVME16x 7
39#define MACH_BVME6000 8
40#define MACH_HP300 9
41#define MACH_Q40 10
42#define MACH_SUN3X 11
43#define MACH_M54XX 12
44
45#define COMMAND_LINE_SIZE 256
46
47#ifdef __KERNEL__
48
49#define CL_SIZE COMMAND_LINE_SIZE 28#define CL_SIZE COMMAND_LINE_SIZE
50 29
51#ifndef __ASSEMBLY__ 30#ifndef __ASSEMBLY__
@@ -194,63 +173,6 @@ extern unsigned long m68k_machtype;
194# define MACH_TYPE (m68k_machtype) 173# define MACH_TYPE (m68k_machtype)
195#endif 174#endif
196 175
197#endif /* __KERNEL__ */
198
199
200 /*
201 * CPU, FPU and MMU types
202 *
203 * Note: we may rely on the following equalities:
204 *
205 * CPU_68020 == MMU_68851
206 * CPU_68030 == MMU_68030
207 * CPU_68040 == FPU_68040 == MMU_68040
208 * CPU_68060 == FPU_68060 == MMU_68060
209 */
210
211#define CPUB_68020 0
212#define CPUB_68030 1
213#define CPUB_68040 2
214#define CPUB_68060 3
215#define CPUB_COLDFIRE 4
216
217#define CPU_68020 (1<<CPUB_68020)
218#define CPU_68030 (1<<CPUB_68030)
219#define CPU_68040 (1<<CPUB_68040)
220#define CPU_68060 (1<<CPUB_68060)
221#define CPU_COLDFIRE (1<<CPUB_COLDFIRE)
222
223#define FPUB_68881 0
224#define FPUB_68882 1
225#define FPUB_68040 2 /* Internal FPU */
226#define FPUB_68060 3 /* Internal FPU */
227#define FPUB_SUNFPA 4 /* Sun-3 FPA */
228#define FPUB_COLDFIRE 5 /* ColdFire FPU */
229
230#define FPU_68881 (1<<FPUB_68881)
231#define FPU_68882 (1<<FPUB_68882)
232#define FPU_68040 (1<<FPUB_68040)
233#define FPU_68060 (1<<FPUB_68060)
234#define FPU_SUNFPA (1<<FPUB_SUNFPA)
235#define FPU_COLDFIRE (1<<FPUB_COLDFIRE)
236
237#define MMUB_68851 0
238#define MMUB_68030 1 /* Internal MMU */
239#define MMUB_68040 2 /* Internal MMU */
240#define MMUB_68060 3 /* Internal MMU */
241#define MMUB_APOLLO 4 /* Custom Apollo */
242#define MMUB_SUN3 5 /* Custom Sun-3 */
243#define MMUB_COLDFIRE 6 /* Internal MMU */
244
245#define MMU_68851 (1<<MMUB_68851)
246#define MMU_68030 (1<<MMUB_68030)
247#define MMU_68040 (1<<MMUB_68040)
248#define MMU_68060 (1<<MMUB_68060)
249#define MMU_SUN3 (1<<MMUB_SUN3)
250#define MMU_APOLLO (1<<MMUB_APOLLO)
251#define MMU_COLDFIRE (1<<MMUB_COLDFIRE)
252
253#ifdef __KERNEL__
254 176
255#ifndef __ASSEMBLY__ 177#ifndef __ASSEMBLY__
256extern unsigned long m68k_cputype; 178extern unsigned long m68k_cputype;
@@ -385,6 +307,4 @@ extern int m68k_realnum_memory; /* real # of memory blocks found */
385extern struct mem_info m68k_memory[NUM_MEMINFO];/* memory description */ 307extern struct mem_info m68k_memory[NUM_MEMINFO];/* memory description */
386#endif 308#endif
387 309
388#endif /* __KERNEL__ */
389
390#endif /* _M68K_SETUP_H */ 310#endif /* _M68K_SETUP_H */
diff --git a/arch/m68k/include/asm/signal.h b/arch/m68k/include/asm/signal.h
index 60e88660169..2df26b57c26 100644
--- a/arch/m68k/include/asm/signal.h
+++ b/arch/m68k/include/asm/signal.h
@@ -1,12 +1,8 @@
1#ifndef _M68K_SIGNAL_H 1#ifndef _M68K_SIGNAL_H
2#define _M68K_SIGNAL_H 2#define _M68K_SIGNAL_H
3 3
4#include <linux/types.h> 4#include <uapi/asm/signal.h>
5 5
6/* Avoid too many header ordering problems. */
7struct siginfo;
8
9#ifdef __KERNEL__
10/* Most things should be clean enough to redefine this at will, if care 6/* Most things should be clean enough to redefine this at will, if care
11 is taken to make libc match. */ 7 is taken to make libc match. */
12 8
@@ -20,92 +16,6 @@ typedef struct {
20 unsigned long sig[_NSIG_WORDS]; 16 unsigned long sig[_NSIG_WORDS];
21} sigset_t; 17} sigset_t;
22 18
23#else
24/* Here we must cater to libcs that poke about in kernel headers. */
25
26#define NSIG 32
27typedef unsigned long sigset_t;
28
29#endif /* __KERNEL__ */
30
31#define SIGHUP 1
32#define SIGINT 2
33#define SIGQUIT 3
34#define SIGILL 4
35#define SIGTRAP 5
36#define SIGABRT 6
37#define SIGIOT 6
38#define SIGBUS 7
39#define SIGFPE 8
40#define SIGKILL 9
41#define SIGUSR1 10
42#define SIGSEGV 11
43#define SIGUSR2 12
44#define SIGPIPE 13
45#define SIGALRM 14
46#define SIGTERM 15
47#define SIGSTKFLT 16
48#define SIGCHLD 17
49#define SIGCONT 18
50#define SIGSTOP 19
51#define SIGTSTP 20
52#define SIGTTIN 21
53#define SIGTTOU 22
54#define SIGURG 23
55#define SIGXCPU 24
56#define SIGXFSZ 25
57#define SIGVTALRM 26
58#define SIGPROF 27
59#define SIGWINCH 28
60#define SIGIO 29
61#define SIGPOLL SIGIO
62/*
63#define SIGLOST 29
64*/
65#define SIGPWR 30
66#define SIGSYS 31
67#define SIGUNUSED 31
68
69/* These should not be considered constants from userland. */
70#define SIGRTMIN 32
71#define SIGRTMAX _NSIG
72
73/*
74 * SA_FLAGS values:
75 *
76 * SA_ONSTACK indicates that a registered stack_t will be used.
77 * SA_RESTART flag to get restarting signals (which were the default long ago)
78 * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop.
79 * SA_RESETHAND clears the handler when the signal is delivered.
80 * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies.
81 * SA_NODEFER prevents the current signal from being masked in the handler.
82 *
83 * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single
84 * Unix names RESETHAND and NODEFER respectively.
85 */
86#define SA_NOCLDSTOP 0x00000001
87#define SA_NOCLDWAIT 0x00000002
88#define SA_SIGINFO 0x00000004
89#define SA_ONSTACK 0x08000000
90#define SA_RESTART 0x10000000
91#define SA_NODEFER 0x40000000
92#define SA_RESETHAND 0x80000000
93
94#define SA_NOMASK SA_NODEFER
95#define SA_ONESHOT SA_RESETHAND
96
97/*
98 * sigaltstack controls
99 */
100#define SS_ONSTACK 1
101#define SS_DISABLE 2
102
103#define MINSIGSTKSZ 2048
104#define SIGSTKSZ 8192
105
106#include <asm-generic/signal-defs.h>
107
108#ifdef __KERNEL__
109struct old_sigaction { 19struct old_sigaction {
110 __sighandler_t sa_handler; 20 __sighandler_t sa_handler;
111 old_sigset_t sa_mask; 21 old_sigset_t sa_mask;
@@ -123,31 +33,6 @@ struct sigaction {
123struct k_sigaction { 33struct k_sigaction {
124 struct sigaction sa; 34 struct sigaction sa;
125}; 35};
126#else
127/* Here we must cater to libcs that poke about in kernel headers. */
128
129struct sigaction {
130 union {
131 __sighandler_t _sa_handler;
132 void (*_sa_sigaction)(int, struct siginfo *, void *);
133 } _u;
134 sigset_t sa_mask;
135 unsigned long sa_flags;
136 void (*sa_restorer)(void);
137};
138
139#define sa_handler _u._sa_handler
140#define sa_sigaction _u._sa_sigaction
141
142#endif /* __KERNEL__ */
143
144typedef struct sigaltstack {
145 void __user *ss_sp;
146 int ss_flags;
147 size_t ss_size;
148} stack_t;
149
150#ifdef __KERNEL__
151#include <asm/sigcontext.h> 36#include <asm/sigcontext.h>
152 37
153#ifndef CONFIG_CPU_HAS_NO_BITFIELDS 38#ifndef CONFIG_CPU_HAS_NO_BITFIELDS
@@ -156,7 +41,7 @@ typedef struct sigaltstack {
156static inline void sigaddset(sigset_t *set, int _sig) 41static inline void sigaddset(sigset_t *set, int _sig)
157{ 42{
158 asm ("bfset %0{%1,#1}" 43 asm ("bfset %0{%1,#1}"
159 : "+od" (*set) 44 : "+o" (*set)
160 : "id" ((_sig - 1) ^ 31) 45 : "id" ((_sig - 1) ^ 31)
161 : "cc"); 46 : "cc");
162} 47}
@@ -164,7 +49,7 @@ static inline void sigaddset(sigset_t *set, int _sig)
164static inline void sigdelset(sigset_t *set, int _sig) 49static inline void sigdelset(sigset_t *set, int _sig)
165{ 50{
166 asm ("bfclr %0{%1,#1}" 51 asm ("bfclr %0{%1,#1}"
167 : "+od" (*set) 52 : "+o" (*set)
168 : "id" ((_sig - 1) ^ 31) 53 : "id" ((_sig - 1) ^ 31)
169 : "cc"); 54 : "cc");
170} 55}
@@ -180,7 +65,7 @@ static inline int __gen_sigismember(sigset_t *set, int _sig)
180 int ret; 65 int ret;
181 asm ("bfextu %1{%2,#1},%0" 66 asm ("bfextu %1{%2,#1},%0"
182 : "=d" (ret) 67 : "=d" (ret)
183 : "od" (*set), "id" ((_sig-1) ^ 31) 68 : "o" (*set), "id" ((_sig-1) ^ 31)
184 : "cc"); 69 : "cc");
185 return ret; 70 return ret;
186} 71}
@@ -208,5 +93,4 @@ struct pt_regs;
208extern void ptrace_signal_deliver(struct pt_regs *regs, void *cookie); 93extern void ptrace_signal_deliver(struct pt_regs *regs, void *cookie);
209#endif /* __uClinux__ */ 94#endif /* __uClinux__ */
210 95
211#endif /* __KERNEL__ */
212#endif /* _M68K_SIGNAL_H */ 96#endif /* _M68K_SIGNAL_H */
diff --git a/arch/m68k/include/asm/termios.h b/arch/m68k/include/asm/termios.h
index 0823032e404..ad8efb09866 100644
--- a/arch/m68k/include/asm/termios.h
+++ b/arch/m68k/include/asm/termios.h
@@ -1,27 +1,8 @@
1#ifndef _M68K_TERMIOS_H 1#ifndef _M68K_TERMIOS_H
2#define _M68K_TERMIOS_H 2#define _M68K_TERMIOS_H
3 3
4#include <asm/termbits.h> 4#include <uapi/asm/termios.h>
5#include <asm/ioctls.h>
6 5
7struct winsize {
8 unsigned short ws_row;
9 unsigned short ws_col;
10 unsigned short ws_xpixel;
11 unsigned short ws_ypixel;
12};
13
14#define NCC 8
15struct termio {
16 unsigned short c_iflag; /* input mode flags */
17 unsigned short c_oflag; /* output mode flags */
18 unsigned short c_cflag; /* control mode flags */
19 unsigned short c_lflag; /* local mode flags */
20 unsigned char c_line; /* line discipline */
21 unsigned char c_cc[NCC]; /* control characters */
22};
23
24#ifdef __KERNEL__
25/* intr=^C quit=^| erase=del kill=^U 6/* intr=^C quit=^| erase=del kill=^U
26 eof=^D vtime=\0 vmin=\1 sxtc=\0 7 eof=^D vtime=\0 vmin=\1 sxtc=\0
27 start=^Q stop=^S susp=^Z eol=\0 8 start=^Q stop=^S susp=^Z eol=\0
@@ -29,27 +10,6 @@ struct termio {
29 eol2=\0 10 eol2=\0
30*/ 11*/
31#define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0" 12#define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0"
32#endif
33
34/* modem lines */
35#define TIOCM_LE 0x001
36#define TIOCM_DTR 0x002
37#define TIOCM_RTS 0x004
38#define TIOCM_ST 0x008
39#define TIOCM_SR 0x010
40#define TIOCM_CTS 0x020
41#define TIOCM_CAR 0x040
42#define TIOCM_RNG 0x080
43#define TIOCM_DSR 0x100
44#define TIOCM_CD TIOCM_CAR
45#define TIOCM_RI TIOCM_RNG
46#define TIOCM_OUT1 0x2000
47#define TIOCM_OUT2 0x4000
48#define TIOCM_LOOP 0x8000
49
50/* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
51
52#ifdef __KERNEL__
53 13
54/* 14/*
55 * Translate a "termio" structure into a "termios". Ugh. 15 * Translate a "termio" structure into a "termios". Ugh.
@@ -87,6 +47,4 @@ struct termio {
87#define user_termios_to_kernel_termios_1(k, u) copy_from_user(k, u, sizeof(struct termios)) 47#define user_termios_to_kernel_termios_1(k, u) copy_from_user(k, u, sizeof(struct termios))
88#define kernel_termios_to_user_termios_1(u, k) copy_to_user(u, k, sizeof(struct termios)) 48#define kernel_termios_to_user_termios_1(u, k) copy_to_user(u, k, sizeof(struct termios))
89 49
90#endif /* __KERNEL__ */
91
92#endif /* _M68K_TERMIOS_H */ 50#endif /* _M68K_TERMIOS_H */
diff --git a/arch/m68k/include/asm/unistd.h b/arch/m68k/include/asm/unistd.h
index c702ad71679..0aa16540596 100644
--- a/arch/m68k/include/asm/unistd.h
+++ b/arch/m68k/include/asm/unistd.h
@@ -1,361 +1,10 @@
1#ifndef _ASM_M68K_UNISTD_H_ 1#ifndef _ASM_M68K_UNISTD_H_
2#define _ASM_M68K_UNISTD_H_ 2#define _ASM_M68K_UNISTD_H_
3 3
4/* 4#include <uapi/asm/unistd.h>
5 * This file contains the system call numbers.
6 */
7
8#define __NR_restart_syscall 0
9#define __NR_exit 1
10#define __NR_fork 2
11#define __NR_read 3
12#define __NR_write 4
13#define __NR_open 5
14#define __NR_close 6
15#define __NR_waitpid 7
16#define __NR_creat 8
17#define __NR_link 9
18#define __NR_unlink 10
19#define __NR_execve 11
20#define __NR_chdir 12
21#define __NR_time 13
22#define __NR_mknod 14
23#define __NR_chmod 15
24#define __NR_chown 16
25/*#define __NR_break 17*/
26#define __NR_oldstat 18
27#define __NR_lseek 19
28#define __NR_getpid 20
29#define __NR_mount 21
30#define __NR_umount 22
31#define __NR_setuid 23
32#define __NR_getuid 24
33#define __NR_stime 25
34#define __NR_ptrace 26
35#define __NR_alarm 27
36#define __NR_oldfstat 28
37#define __NR_pause 29
38#define __NR_utime 30
39/*#define __NR_stty 31*/
40/*#define __NR_gtty 32*/
41#define __NR_access 33
42#define __NR_nice 34
43/*#define __NR_ftime 35*/
44#define __NR_sync 36
45#define __NR_kill 37
46#define __NR_rename 38
47#define __NR_mkdir 39
48#define __NR_rmdir 40
49#define __NR_dup 41
50#define __NR_pipe 42
51#define __NR_times 43
52/*#define __NR_prof 44*/
53#define __NR_brk 45
54#define __NR_setgid 46
55#define __NR_getgid 47
56#define __NR_signal 48
57#define __NR_geteuid 49
58#define __NR_getegid 50
59#define __NR_acct 51
60#define __NR_umount2 52
61/*#define __NR_lock 53*/
62#define __NR_ioctl 54
63#define __NR_fcntl 55
64/*#define __NR_mpx 56*/
65#define __NR_setpgid 57
66/*#define __NR_ulimit 58*/
67/*#define __NR_oldolduname 59*/
68#define __NR_umask 60
69#define __NR_chroot 61
70#define __NR_ustat 62
71#define __NR_dup2 63
72#define __NR_getppid 64
73#define __NR_getpgrp 65
74#define __NR_setsid 66
75#define __NR_sigaction 67
76#define __NR_sgetmask 68
77#define __NR_ssetmask 69
78#define __NR_setreuid 70
79#define __NR_setregid 71
80#define __NR_sigsuspend 72
81#define __NR_sigpending 73
82#define __NR_sethostname 74
83#define __NR_setrlimit 75
84#define __NR_getrlimit 76
85#define __NR_getrusage 77
86#define __NR_gettimeofday 78
87#define __NR_settimeofday 79
88#define __NR_getgroups 80
89#define __NR_setgroups 81
90#define __NR_select 82
91#define __NR_symlink 83
92#define __NR_oldlstat 84
93#define __NR_readlink 85
94#define __NR_uselib 86
95#define __NR_swapon 87
96#define __NR_reboot 88
97#define __NR_readdir 89
98#define __NR_mmap 90
99#define __NR_munmap 91
100#define __NR_truncate 92
101#define __NR_ftruncate 93
102#define __NR_fchmod 94
103#define __NR_fchown 95
104#define __NR_getpriority 96
105#define __NR_setpriority 97
106/*#define __NR_profil 98*/
107#define __NR_statfs 99
108#define __NR_fstatfs 100
109/*#define __NR_ioperm 101*/
110#define __NR_socketcall 102
111#define __NR_syslog 103
112#define __NR_setitimer 104
113#define __NR_getitimer 105
114#define __NR_stat 106
115#define __NR_lstat 107
116#define __NR_fstat 108
117/*#define __NR_olduname 109*/
118/*#define __NR_iopl 110*/ /* not supported */
119#define __NR_vhangup 111
120/*#define __NR_idle 112*/ /* Obsolete */
121/*#define __NR_vm86 113*/ /* not supported */
122#define __NR_wait4 114
123#define __NR_swapoff 115
124#define __NR_sysinfo 116
125#define __NR_ipc 117
126#define __NR_fsync 118
127#define __NR_sigreturn 119
128#define __NR_clone 120
129#define __NR_setdomainname 121
130#define __NR_uname 122
131#define __NR_cacheflush 123
132#define __NR_adjtimex 124
133#define __NR_mprotect 125
134#define __NR_sigprocmask 126
135#define __NR_create_module 127
136#define __NR_init_module 128
137#define __NR_delete_module 129
138#define __NR_get_kernel_syms 130
139#define __NR_quotactl 131
140#define __NR_getpgid 132
141#define __NR_fchdir 133
142#define __NR_bdflush 134
143#define __NR_sysfs 135
144#define __NR_personality 136
145/*#define __NR_afs_syscall 137*/ /* Syscall for Andrew File System */
146#define __NR_setfsuid 138
147#define __NR_setfsgid 139
148#define __NR__llseek 140
149#define __NR_getdents 141
150#define __NR__newselect 142
151#define __NR_flock 143
152#define __NR_msync 144
153#define __NR_readv 145
154#define __NR_writev 146
155#define __NR_getsid 147
156#define __NR_fdatasync 148
157#define __NR__sysctl 149
158#define __NR_mlock 150
159#define __NR_munlock 151
160#define __NR_mlockall 152
161#define __NR_munlockall 153
162#define __NR_sched_setparam 154
163#define __NR_sched_getparam 155
164#define __NR_sched_setscheduler 156
165#define __NR_sched_getscheduler 157
166#define __NR_sched_yield 158
167#define __NR_sched_get_priority_max 159
168#define __NR_sched_get_priority_min 160
169#define __NR_sched_rr_get_interval 161
170#define __NR_nanosleep 162
171#define __NR_mremap 163
172#define __NR_setresuid 164
173#define __NR_getresuid 165
174#define __NR_getpagesize 166
175#define __NR_query_module 167
176#define __NR_poll 168
177#define __NR_nfsservctl 169
178#define __NR_setresgid 170
179#define __NR_getresgid 171
180#define __NR_prctl 172
181#define __NR_rt_sigreturn 173
182#define __NR_rt_sigaction 174
183#define __NR_rt_sigprocmask 175
184#define __NR_rt_sigpending 176
185#define __NR_rt_sigtimedwait 177
186#define __NR_rt_sigqueueinfo 178
187#define __NR_rt_sigsuspend 179
188#define __NR_pread64 180
189#define __NR_pwrite64 181
190#define __NR_lchown 182
191#define __NR_getcwd 183
192#define __NR_capget 184
193#define __NR_capset 185
194#define __NR_sigaltstack 186
195#define __NR_sendfile 187
196#define __NR_getpmsg 188 /* some people actually want streams */
197#define __NR_putpmsg 189 /* some people actually want streams */
198#define __NR_vfork 190
199#define __NR_ugetrlimit 191
200#define __NR_mmap2 192
201#define __NR_truncate64 193
202#define __NR_ftruncate64 194
203#define __NR_stat64 195
204#define __NR_lstat64 196
205#define __NR_fstat64 197
206#define __NR_chown32 198
207#define __NR_getuid32 199
208#define __NR_getgid32 200
209#define __NR_geteuid32 201
210#define __NR_getegid32 202
211#define __NR_setreuid32 203
212#define __NR_setregid32 204
213#define __NR_getgroups32 205
214#define __NR_setgroups32 206
215#define __NR_fchown32 207
216#define __NR_setresuid32 208
217#define __NR_getresuid32 209
218#define __NR_setresgid32 210
219#define __NR_getresgid32 211
220#define __NR_lchown32 212
221#define __NR_setuid32 213
222#define __NR_setgid32 214
223#define __NR_setfsuid32 215
224#define __NR_setfsgid32 216
225#define __NR_pivot_root 217
226/* 218*/
227/* 219*/
228#define __NR_getdents64 220
229#define __NR_gettid 221
230#define __NR_tkill 222
231#define __NR_setxattr 223
232#define __NR_lsetxattr 224
233#define __NR_fsetxattr 225
234#define __NR_getxattr 226
235#define __NR_lgetxattr 227
236#define __NR_fgetxattr 228
237#define __NR_listxattr 229
238#define __NR_llistxattr 230
239#define __NR_flistxattr 231
240#define __NR_removexattr 232
241#define __NR_lremovexattr 233
242#define __NR_fremovexattr 234
243#define __NR_futex 235
244#define __NR_sendfile64 236
245#define __NR_mincore 237
246#define __NR_madvise 238
247#define __NR_fcntl64 239
248#define __NR_readahead 240
249#define __NR_io_setup 241
250#define __NR_io_destroy 242
251#define __NR_io_getevents 243
252#define __NR_io_submit 244
253#define __NR_io_cancel 245
254#define __NR_fadvise64 246
255#define __NR_exit_group 247
256#define __NR_lookup_dcookie 248
257#define __NR_epoll_create 249
258#define __NR_epoll_ctl 250
259#define __NR_epoll_wait 251
260#define __NR_remap_file_pages 252
261#define __NR_set_tid_address 253
262#define __NR_timer_create 254
263#define __NR_timer_settime 255
264#define __NR_timer_gettime 256
265#define __NR_timer_getoverrun 257
266#define __NR_timer_delete 258
267#define __NR_clock_settime 259
268#define __NR_clock_gettime 260
269#define __NR_clock_getres 261
270#define __NR_clock_nanosleep 262
271#define __NR_statfs64 263
272#define __NR_fstatfs64 264
273#define __NR_tgkill 265
274#define __NR_utimes 266
275#define __NR_fadvise64_64 267
276#define __NR_mbind 268
277#define __NR_get_mempolicy 269
278#define __NR_set_mempolicy 270
279#define __NR_mq_open 271
280#define __NR_mq_unlink 272
281#define __NR_mq_timedsend 273
282#define __NR_mq_timedreceive 274
283#define __NR_mq_notify 275
284#define __NR_mq_getsetattr 276
285#define __NR_waitid 277
286/*#define __NR_vserver 278*/
287#define __NR_add_key 279
288#define __NR_request_key 280
289#define __NR_keyctl 281
290#define __NR_ioprio_set 282
291#define __NR_ioprio_get 283
292#define __NR_inotify_init 284
293#define __NR_inotify_add_watch 285
294#define __NR_inotify_rm_watch 286
295#define __NR_migrate_pages 287
296#define __NR_openat 288
297#define __NR_mkdirat 289
298#define __NR_mknodat 290
299#define __NR_fchownat 291
300#define __NR_futimesat 292
301#define __NR_fstatat64 293
302#define __NR_unlinkat 294
303#define __NR_renameat 295
304#define __NR_linkat 296
305#define __NR_symlinkat 297
306#define __NR_readlinkat 298
307#define __NR_fchmodat 299
308#define __NR_faccessat 300
309#define __NR_pselect6 301
310#define __NR_ppoll 302
311#define __NR_unshare 303
312#define __NR_set_robust_list 304
313#define __NR_get_robust_list 305
314#define __NR_splice 306
315#define __NR_sync_file_range 307
316#define __NR_tee 308
317#define __NR_vmsplice 309
318#define __NR_move_pages 310
319#define __NR_sched_setaffinity 311
320#define __NR_sched_getaffinity 312
321#define __NR_kexec_load 313
322#define __NR_getcpu 314
323#define __NR_epoll_pwait 315
324#define __NR_utimensat 316
325#define __NR_signalfd 317
326#define __NR_timerfd_create 318
327#define __NR_eventfd 319
328#define __NR_fallocate 320
329#define __NR_timerfd_settime 321
330#define __NR_timerfd_gettime 322
331#define __NR_signalfd4 323
332#define __NR_eventfd2 324
333#define __NR_epoll_create1 325
334#define __NR_dup3 326
335#define __NR_pipe2 327
336#define __NR_inotify_init1 328
337#define __NR_preadv 329
338#define __NR_pwritev 330
339#define __NR_rt_tgsigqueueinfo 331
340#define __NR_perf_event_open 332
341#define __NR_get_thread_area 333
342#define __NR_set_thread_area 334
343#define __NR_atomic_cmpxchg_32 335
344#define __NR_atomic_barrier 336
345#define __NR_fanotify_init 337
346#define __NR_fanotify_mark 338
347#define __NR_prlimit64 339
348#define __NR_name_to_handle_at 340
349#define __NR_open_by_handle_at 341
350#define __NR_clock_adjtime 342
351#define __NR_syncfs 343
352#define __NR_setns 344
353#define __NR_process_vm_readv 345
354#define __NR_process_vm_writev 346
355 5
356#ifdef __KERNEL__
357 6
358#define NR_syscalls 347 7#define NR_syscalls 348
359 8
360#define __ARCH_WANT_OLD_READDIR 9#define __ARCH_WANT_OLD_READDIR
361#define __ARCH_WANT_OLD_STAT 10#define __ARCH_WANT_OLD_STAT
@@ -383,7 +32,6 @@
383#define __ARCH_WANT_SYS_RT_SIGACTION 32#define __ARCH_WANT_SYS_RT_SIGACTION
384#define __ARCH_WANT_SYS_RT_SIGSUSPEND 33#define __ARCH_WANT_SYS_RT_SIGSUSPEND
385#define __ARCH_WANT_SYS_EXECVE 34#define __ARCH_WANT_SYS_EXECVE
386#define __ARCH_WANT_KERNEL_EXECVE
387 35
388/* 36/*
389 * "Conditional" syscalls 37 * "Conditional" syscalls
@@ -393,5 +41,4 @@
393 */ 41 */
394#define cond_syscall(x) asm(".weak\t" #x "\n\t.set\t" #x ",sys_ni_syscall") 42#define cond_syscall(x) asm(".weak\t" #x "\n\t.set\t" #x ",sys_ni_syscall")
395 43
396#endif /* __KERNEL__ */
397#endif /* _ASM_M68K_UNISTD_H_ */ 44#endif /* _ASM_M68K_UNISTD_H_ */
diff --git a/arch/m68k/include/uapi/asm/Kbuild b/arch/m68k/include/uapi/asm/Kbuild
index baebb3da1d4..972bce120e1 100644
--- a/arch/m68k/include/uapi/asm/Kbuild
+++ b/arch/m68k/include/uapi/asm/Kbuild
@@ -1,3 +1,26 @@
1# UAPI Header export list 1# UAPI Header export list
2include include/uapi/asm-generic/Kbuild.asm 2include include/uapi/asm-generic/Kbuild.asm
3 3
4header-y += a.out.h
5header-y += auxvec.h
6header-y += byteorder.h
7header-y += cachectl.h
8header-y += fcntl.h
9header-y += ioctls.h
10header-y += msgbuf.h
11header-y += param.h
12header-y += poll.h
13header-y += posix_types.h
14header-y += ptrace.h
15header-y += sembuf.h
16header-y += setup.h
17header-y += shmbuf.h
18header-y += sigcontext.h
19header-y += signal.h
20header-y += socket.h
21header-y += sockios.h
22header-y += stat.h
23header-y += swab.h
24header-y += termbits.h
25header-y += termios.h
26header-y += unistd.h
diff --git a/arch/m68k/include/asm/a.out.h b/arch/m68k/include/uapi/asm/a.out.h
index 3885fe43432..3885fe43432 100644
--- a/arch/m68k/include/asm/a.out.h
+++ b/arch/m68k/include/uapi/asm/a.out.h
diff --git a/arch/m68k/include/asm/auxvec.h b/arch/m68k/include/uapi/asm/auxvec.h
index 844d6d52204..844d6d52204 100644
--- a/arch/m68k/include/asm/auxvec.h
+++ b/arch/m68k/include/uapi/asm/auxvec.h
diff --git a/arch/m68k/include/asm/byteorder.h b/arch/m68k/include/uapi/asm/byteorder.h
index 31b260a8880..31b260a8880 100644
--- a/arch/m68k/include/asm/byteorder.h
+++ b/arch/m68k/include/uapi/asm/byteorder.h
diff --git a/arch/m68k/include/asm/cachectl.h b/arch/m68k/include/uapi/asm/cachectl.h
index 525978e959e..525978e959e 100644
--- a/arch/m68k/include/asm/cachectl.h
+++ b/arch/m68k/include/uapi/asm/cachectl.h
diff --git a/arch/m68k/include/asm/fcntl.h b/arch/m68k/include/uapi/asm/fcntl.h
index 1c369b20dc4..1c369b20dc4 100644
--- a/arch/m68k/include/asm/fcntl.h
+++ b/arch/m68k/include/uapi/asm/fcntl.h
diff --git a/arch/m68k/include/asm/ioctls.h b/arch/m68k/include/uapi/asm/ioctls.h
index 1332bb4ca5b..1332bb4ca5b 100644
--- a/arch/m68k/include/asm/ioctls.h
+++ b/arch/m68k/include/uapi/asm/ioctls.h
diff --git a/arch/m68k/include/asm/msgbuf.h b/arch/m68k/include/uapi/asm/msgbuf.h
index 243cb798de8..243cb798de8 100644
--- a/arch/m68k/include/asm/msgbuf.h
+++ b/arch/m68k/include/uapi/asm/msgbuf.h
diff --git a/arch/m68k/include/asm/param.h b/arch/m68k/include/uapi/asm/param.h
index 36265ccf5c7..36265ccf5c7 100644
--- a/arch/m68k/include/asm/param.h
+++ b/arch/m68k/include/uapi/asm/param.h
diff --git a/arch/m68k/include/asm/poll.h b/arch/m68k/include/uapi/asm/poll.h
index f080fcdb61b..f080fcdb61b 100644
--- a/arch/m68k/include/asm/poll.h
+++ b/arch/m68k/include/uapi/asm/poll.h
diff --git a/arch/m68k/include/asm/posix_types.h b/arch/m68k/include/uapi/asm/posix_types.h
index cf4dbf70fdc..cf4dbf70fdc 100644
--- a/arch/m68k/include/asm/posix_types.h
+++ b/arch/m68k/include/uapi/asm/posix_types.h
diff --git a/arch/m68k/include/uapi/asm/ptrace.h b/arch/m68k/include/uapi/asm/ptrace.h
new file mode 100644
index 00000000000..caf92fd3493
--- /dev/null
+++ b/arch/m68k/include/uapi/asm/ptrace.h
@@ -0,0 +1,79 @@
1#ifndef _UAPI_M68K_PTRACE_H
2#define _UAPI_M68K_PTRACE_H
3
4#define PT_D1 0
5#define PT_D2 1
6#define PT_D3 2
7#define PT_D4 3
8#define PT_D5 4
9#define PT_D6 5
10#define PT_D7 6
11#define PT_A0 7
12#define PT_A1 8
13#define PT_A2 9
14#define PT_A3 10
15#define PT_A4 11
16#define PT_A5 12
17#define PT_A6 13
18#define PT_D0 14
19#define PT_USP 15
20#define PT_ORIG_D0 16
21#define PT_SR 17
22#define PT_PC 18
23
24#ifndef __ASSEMBLY__
25
26/* this struct defines the way the registers are stored on the
27 stack during a system call. */
28
29struct pt_regs {
30 long d1;
31 long d2;
32 long d3;
33 long d4;
34 long d5;
35 long a0;
36 long a1;
37 long a2;
38 long d0;
39 long orig_d0;
40 long stkadj;
41#ifdef CONFIG_COLDFIRE
42 unsigned format : 4; /* frame format specifier */
43 unsigned vector : 12; /* vector offset */
44 unsigned short sr;
45 unsigned long pc;
46#else
47 unsigned short sr;
48 unsigned long pc;
49 unsigned format : 4; /* frame format specifier */
50 unsigned vector : 12; /* vector offset */
51#endif
52};
53
54/*
55 * This is the extended stack used by signal handlers and the context
56 * switcher: it's pushed after the normal "struct pt_regs".
57 */
58struct switch_stack {
59 unsigned long d6;
60 unsigned long d7;
61 unsigned long a3;
62 unsigned long a4;
63 unsigned long a5;
64 unsigned long a6;
65 unsigned long retpc;
66};
67
68/* Arbitrarily choose the same ptrace numbers as used by the Sparc code. */
69#define PTRACE_GETREGS 12
70#define PTRACE_SETREGS 13
71#define PTRACE_GETFPREGS 14
72#define PTRACE_SETFPREGS 15
73
74#define PTRACE_GET_THREAD_AREA 25
75
76#define PTRACE_SINGLEBLOCK 33 /* resume execution until next branch */
77
78#endif /* __ASSEMBLY__ */
79#endif /* _UAPI_M68K_PTRACE_H */
diff --git a/arch/m68k/include/asm/sembuf.h b/arch/m68k/include/uapi/asm/sembuf.h
index 2308052a8c2..2308052a8c2 100644
--- a/arch/m68k/include/asm/sembuf.h
+++ b/arch/m68k/include/uapi/asm/sembuf.h
diff --git a/arch/m68k/include/uapi/asm/setup.h b/arch/m68k/include/uapi/asm/setup.h
new file mode 100644
index 00000000000..85579bff455
--- /dev/null
+++ b/arch/m68k/include/uapi/asm/setup.h
@@ -0,0 +1,103 @@
1/*
2** asm/setup.h -- Definition of the Linux/m68k setup information
3**
4** Copyright 1992 by Greg Harp
5**
6** This file is subject to the terms and conditions of the GNU General Public
7** License. See the file COPYING in the main directory of this archive
8** for more details.
9**
10** Created 09/29/92 by Greg Harp
11**
12** 5/2/94 Roman Hodek:
13** Added bi_atari part of the machine dependent union bi_un; for now it
14** contains just a model field to distinguish between TT and Falcon.
15** 26/7/96 Roman Zippel:
16** Renamed to setup.h; added some useful macros to allow gcc some
17** optimizations if possible.
18** 5/10/96 Geert Uytterhoeven:
19** Redesign of the boot information structure; moved boot information
20** structure to bootinfo.h
21*/
22
23#ifndef _UAPI_M68K_SETUP_H
24#define _UAPI_M68K_SETUP_H
25
26
27
28 /*
29 * Linux/m68k Architectures
30 */
31
32#define MACH_AMIGA 1
33#define MACH_ATARI 2
34#define MACH_MAC 3
35#define MACH_APOLLO 4
36#define MACH_SUN3 5
37#define MACH_MVME147 6
38#define MACH_MVME16x 7
39#define MACH_BVME6000 8
40#define MACH_HP300 9
41#define MACH_Q40 10
42#define MACH_SUN3X 11
43#define MACH_M54XX 12
44
45#define COMMAND_LINE_SIZE 256
46
47
48
49 /*
50 * CPU, FPU and MMU types
51 *
52 * Note: we may rely on the following equalities:
53 *
54 * CPU_68020 == MMU_68851
55 * CPU_68030 == MMU_68030
56 * CPU_68040 == FPU_68040 == MMU_68040
57 * CPU_68060 == FPU_68060 == MMU_68060
58 */
59
60#define CPUB_68020 0
61#define CPUB_68030 1
62#define CPUB_68040 2
63#define CPUB_68060 3
64#define CPUB_COLDFIRE 4
65
66#define CPU_68020 (1<<CPUB_68020)
67#define CPU_68030 (1<<CPUB_68030)
68#define CPU_68040 (1<<CPUB_68040)
69#define CPU_68060 (1<<CPUB_68060)
70#define CPU_COLDFIRE (1<<CPUB_COLDFIRE)
71
72#define FPUB_68881 0
73#define FPUB_68882 1
74#define FPUB_68040 2 /* Internal FPU */
75#define FPUB_68060 3 /* Internal FPU */
76#define FPUB_SUNFPA 4 /* Sun-3 FPA */
77#define FPUB_COLDFIRE 5 /* ColdFire FPU */
78
79#define FPU_68881 (1<<FPUB_68881)
80#define FPU_68882 (1<<FPUB_68882)
81#define FPU_68040 (1<<FPUB_68040)
82#define FPU_68060 (1<<FPUB_68060)
83#define FPU_SUNFPA (1<<FPUB_SUNFPA)
84#define FPU_COLDFIRE (1<<FPUB_COLDFIRE)
85
86#define MMUB_68851 0
87#define MMUB_68030 1 /* Internal MMU */
88#define MMUB_68040 2 /* Internal MMU */
89#define MMUB_68060 3 /* Internal MMU */
90#define MMUB_APOLLO 4 /* Custom Apollo */
91#define MMUB_SUN3 5 /* Custom Sun-3 */
92#define MMUB_COLDFIRE 6 /* Internal MMU */
93
94#define MMU_68851 (1<<MMUB_68851)
95#define MMU_68030 (1<<MMUB_68030)
96#define MMU_68040 (1<<MMUB_68040)
97#define MMU_68060 (1<<MMUB_68060)
98#define MMU_SUN3 (1<<MMUB_SUN3)
99#define MMU_APOLLO (1<<MMUB_APOLLO)
100#define MMU_COLDFIRE (1<<MMUB_COLDFIRE)
101
102
103#endif /* _UAPI_M68K_SETUP_H */
diff --git a/arch/m68k/include/asm/shmbuf.h b/arch/m68k/include/uapi/asm/shmbuf.h
index f8928d62f1b..f8928d62f1b 100644
--- a/arch/m68k/include/asm/shmbuf.h
+++ b/arch/m68k/include/uapi/asm/shmbuf.h
diff --git a/arch/m68k/include/asm/sigcontext.h b/arch/m68k/include/uapi/asm/sigcontext.h
index 523db2a51cf..523db2a51cf 100644
--- a/arch/m68k/include/asm/sigcontext.h
+++ b/arch/m68k/include/uapi/asm/sigcontext.h
diff --git a/arch/m68k/include/uapi/asm/signal.h b/arch/m68k/include/uapi/asm/signal.h
new file mode 100644
index 00000000000..2b450f311bd
--- /dev/null
+++ b/arch/m68k/include/uapi/asm/signal.h
@@ -0,0 +1,118 @@
1#ifndef _UAPI_M68K_SIGNAL_H
2#define _UAPI_M68K_SIGNAL_H
3
4#include <linux/types.h>
5
6/* Avoid too many header ordering problems. */
7struct siginfo;
8
9#ifndef __KERNEL__
10/* Here we must cater to libcs that poke about in kernel headers. */
11
12#define NSIG 32
13typedef unsigned long sigset_t;
14
15#endif /* __KERNEL__ */
16
17#define SIGHUP 1
18#define SIGINT 2
19#define SIGQUIT 3
20#define SIGILL 4
21#define SIGTRAP 5
22#define SIGABRT 6
23#define SIGIOT 6
24#define SIGBUS 7
25#define SIGFPE 8
26#define SIGKILL 9
27#define SIGUSR1 10
28#define SIGSEGV 11
29#define SIGUSR2 12
30#define SIGPIPE 13
31#define SIGALRM 14
32#define SIGTERM 15
33#define SIGSTKFLT 16
34#define SIGCHLD 17
35#define SIGCONT 18
36#define SIGSTOP 19
37#define SIGTSTP 20
38#define SIGTTIN 21
39#define SIGTTOU 22
40#define SIGURG 23
41#define SIGXCPU 24
42#define SIGXFSZ 25
43#define SIGVTALRM 26
44#define SIGPROF 27
45#define SIGWINCH 28
46#define SIGIO 29
47#define SIGPOLL SIGIO
48/*
49#define SIGLOST 29
50*/
51#define SIGPWR 30
52#define SIGSYS 31
53#define SIGUNUSED 31
54
55/* These should not be considered constants from userland. */
56#define SIGRTMIN 32
57#define SIGRTMAX _NSIG
58
59/*
60 * SA_FLAGS values:
61 *
62 * SA_ONSTACK indicates that a registered stack_t will be used.
63 * SA_RESTART flag to get restarting signals (which were the default long ago)
64 * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop.
65 * SA_RESETHAND clears the handler when the signal is delivered.
66 * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies.
67 * SA_NODEFER prevents the current signal from being masked in the handler.
68 *
69 * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single
70 * Unix names RESETHAND and NODEFER respectively.
71 */
72#define SA_NOCLDSTOP 0x00000001
73#define SA_NOCLDWAIT 0x00000002
74#define SA_SIGINFO 0x00000004
75#define SA_ONSTACK 0x08000000
76#define SA_RESTART 0x10000000
77#define SA_NODEFER 0x40000000
78#define SA_RESETHAND 0x80000000
79
80#define SA_NOMASK SA_NODEFER
81#define SA_ONESHOT SA_RESETHAND
82
83/*
84 * sigaltstack controls
85 */
86#define SS_ONSTACK 1
87#define SS_DISABLE 2
88
89#define MINSIGSTKSZ 2048
90#define SIGSTKSZ 8192
91
92#include <asm-generic/signal-defs.h>
93
94#ifndef __KERNEL__
95/* Here we must cater to libcs that poke about in kernel headers. */
96
97struct sigaction {
98 union {
99 __sighandler_t _sa_handler;
100 void (*_sa_sigaction)(int, struct siginfo *, void *);
101 } _u;
102 sigset_t sa_mask;
103 unsigned long sa_flags;
104 void (*sa_restorer)(void);
105};
106
107#define sa_handler _u._sa_handler
108#define sa_sigaction _u._sa_sigaction
109
110#endif /* __KERNEL__ */
111
112typedef struct sigaltstack {
113 void __user *ss_sp;
114 int ss_flags;
115 size_t ss_size;
116} stack_t;
117
118#endif /* _UAPI_M68K_SIGNAL_H */
diff --git a/arch/m68k/include/asm/socket.h b/arch/m68k/include/uapi/asm/socket.h
index d1be684edf9..d1be684edf9 100644
--- a/arch/m68k/include/asm/socket.h
+++ b/arch/m68k/include/uapi/asm/socket.h
diff --git a/arch/m68k/include/asm/sockios.h b/arch/m68k/include/uapi/asm/sockios.h
index c04a23943cb..c04a23943cb 100644
--- a/arch/m68k/include/asm/sockios.h
+++ b/arch/m68k/include/uapi/asm/sockios.h
diff --git a/arch/m68k/include/asm/stat.h b/arch/m68k/include/uapi/asm/stat.h
index dd38bc2e9f9..dd38bc2e9f9 100644
--- a/arch/m68k/include/asm/stat.h
+++ b/arch/m68k/include/uapi/asm/stat.h
diff --git a/arch/m68k/include/asm/swab.h b/arch/m68k/include/uapi/asm/swab.h
index b7b37a40def..b7b37a40def 100644
--- a/arch/m68k/include/asm/swab.h
+++ b/arch/m68k/include/uapi/asm/swab.h
diff --git a/arch/m68k/include/asm/termbits.h b/arch/m68k/include/uapi/asm/termbits.h
index aea1e37b765..aea1e37b765 100644
--- a/arch/m68k/include/asm/termbits.h
+++ b/arch/m68k/include/uapi/asm/termbits.h
diff --git a/arch/m68k/include/uapi/asm/termios.h b/arch/m68k/include/uapi/asm/termios.h
new file mode 100644
index 00000000000..ce2142c9ac1
--- /dev/null
+++ b/arch/m68k/include/uapi/asm/termios.h
@@ -0,0 +1,44 @@
1#ifndef _UAPI_M68K_TERMIOS_H
2#define _UAPI_M68K_TERMIOS_H
3
4#include <asm/termbits.h>
5#include <asm/ioctls.h>
6
7struct winsize {
8 unsigned short ws_row;
9 unsigned short ws_col;
10 unsigned short ws_xpixel;
11 unsigned short ws_ypixel;
12};
13
14#define NCC 8
15struct termio {
16 unsigned short c_iflag; /* input mode flags */
17 unsigned short c_oflag; /* output mode flags */
18 unsigned short c_cflag; /* control mode flags */
19 unsigned short c_lflag; /* local mode flags */
20 unsigned char c_line; /* line discipline */
21 unsigned char c_cc[NCC]; /* control characters */
22};
23
24
25/* modem lines */
26#define TIOCM_LE 0x001
27#define TIOCM_DTR 0x002
28#define TIOCM_RTS 0x004
29#define TIOCM_ST 0x008
30#define TIOCM_SR 0x010
31#define TIOCM_CTS 0x020
32#define TIOCM_CAR 0x040
33#define TIOCM_RNG 0x080
34#define TIOCM_DSR 0x100
35#define TIOCM_CD TIOCM_CAR
36#define TIOCM_RI TIOCM_RNG
37#define TIOCM_OUT1 0x2000
38#define TIOCM_OUT2 0x4000
39#define TIOCM_LOOP 0x8000
40
41/* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
42
43
44#endif /* _UAPI_M68K_TERMIOS_H */
diff --git a/arch/m68k/include/uapi/asm/unistd.h b/arch/m68k/include/uapi/asm/unistd.h
new file mode 100644
index 00000000000..b94bfbf9070
--- /dev/null
+++ b/arch/m68k/include/uapi/asm/unistd.h
@@ -0,0 +1,357 @@
1#ifndef _UAPI_ASM_M68K_UNISTD_H_
2#define _UAPI_ASM_M68K_UNISTD_H_
3
4/*
5 * This file contains the system call numbers.
6 */
7
8#define __NR_restart_syscall 0
9#define __NR_exit 1
10#define __NR_fork 2
11#define __NR_read 3
12#define __NR_write 4
13#define __NR_open 5
14#define __NR_close 6
15#define __NR_waitpid 7
16#define __NR_creat 8
17#define __NR_link 9
18#define __NR_unlink 10
19#define __NR_execve 11
20#define __NR_chdir 12
21#define __NR_time 13
22#define __NR_mknod 14
23#define __NR_chmod 15
24#define __NR_chown 16
25/*#define __NR_break 17*/
26#define __NR_oldstat 18
27#define __NR_lseek 19
28#define __NR_getpid 20
29#define __NR_mount 21
30#define __NR_umount 22
31#define __NR_setuid 23
32#define __NR_getuid 24
33#define __NR_stime 25
34#define __NR_ptrace 26
35#define __NR_alarm 27
36#define __NR_oldfstat 28
37#define __NR_pause 29
38#define __NR_utime 30
39/*#define __NR_stty 31*/
40/*#define __NR_gtty 32*/
41#define __NR_access 33
42#define __NR_nice 34
43/*#define __NR_ftime 35*/
44#define __NR_sync 36
45#define __NR_kill 37
46#define __NR_rename 38
47#define __NR_mkdir 39
48#define __NR_rmdir 40
49#define __NR_dup 41
50#define __NR_pipe 42
51#define __NR_times 43
52/*#define __NR_prof 44*/
53#define __NR_brk 45
54#define __NR_setgid 46
55#define __NR_getgid 47
56#define __NR_signal 48
57#define __NR_geteuid 49
58#define __NR_getegid 50
59#define __NR_acct 51
60#define __NR_umount2 52
61/*#define __NR_lock 53*/
62#define __NR_ioctl 54
63#define __NR_fcntl 55
64/*#define __NR_mpx 56*/
65#define __NR_setpgid 57
66/*#define __NR_ulimit 58*/
67/*#define __NR_oldolduname 59*/
68#define __NR_umask 60
69#define __NR_chroot 61
70#define __NR_ustat 62
71#define __NR_dup2 63
72#define __NR_getppid 64
73#define __NR_getpgrp 65
74#define __NR_setsid 66
75#define __NR_sigaction 67
76#define __NR_sgetmask 68
77#define __NR_ssetmask 69
78#define __NR_setreuid 70
79#define __NR_setregid 71
80#define __NR_sigsuspend 72
81#define __NR_sigpending 73
82#define __NR_sethostname 74
83#define __NR_setrlimit 75
84#define __NR_getrlimit 76
85#define __NR_getrusage 77
86#define __NR_gettimeofday 78
87#define __NR_settimeofday 79
88#define __NR_getgroups 80
89#define __NR_setgroups 81
90#define __NR_select 82
91#define __NR_symlink 83
92#define __NR_oldlstat 84
93#define __NR_readlink 85
94#define __NR_uselib 86
95#define __NR_swapon 87
96#define __NR_reboot 88
97#define __NR_readdir 89
98#define __NR_mmap 90
99#define __NR_munmap 91
100#define __NR_truncate 92
101#define __NR_ftruncate 93
102#define __NR_fchmod 94
103#define __NR_fchown 95
104#define __NR_getpriority 96
105#define __NR_setpriority 97
106/*#define __NR_profil 98*/
107#define __NR_statfs 99
108#define __NR_fstatfs 100
109/*#define __NR_ioperm 101*/
110#define __NR_socketcall 102
111#define __NR_syslog 103
112#define __NR_setitimer 104
113#define __NR_getitimer 105
114#define __NR_stat 106
115#define __NR_lstat 107
116#define __NR_fstat 108
117/*#define __NR_olduname 109*/
118/*#define __NR_iopl 110*/ /* not supported */
119#define __NR_vhangup 111
120/*#define __NR_idle 112*/ /* Obsolete */
121/*#define __NR_vm86 113*/ /* not supported */
122#define __NR_wait4 114
123#define __NR_swapoff 115
124#define __NR_sysinfo 116
125#define __NR_ipc 117
126#define __NR_fsync 118
127#define __NR_sigreturn 119
128#define __NR_clone 120
129#define __NR_setdomainname 121
130#define __NR_uname 122
131#define __NR_cacheflush 123
132#define __NR_adjtimex 124
133#define __NR_mprotect 125
134#define __NR_sigprocmask 126
135#define __NR_create_module 127
136#define __NR_init_module 128
137#define __NR_delete_module 129
138#define __NR_get_kernel_syms 130
139#define __NR_quotactl 131
140#define __NR_getpgid 132
141#define __NR_fchdir 133
142#define __NR_bdflush 134
143#define __NR_sysfs 135
144#define __NR_personality 136
145/*#define __NR_afs_syscall 137*/ /* Syscall for Andrew File System */
146#define __NR_setfsuid 138
147#define __NR_setfsgid 139
148#define __NR__llseek 140
149#define __NR_getdents 141
150#define __NR__newselect 142
151#define __NR_flock 143
152#define __NR_msync 144
153#define __NR_readv 145
154#define __NR_writev 146
155#define __NR_getsid 147
156#define __NR_fdatasync 148
157#define __NR__sysctl 149
158#define __NR_mlock 150
159#define __NR_munlock 151
160#define __NR_mlockall 152
161#define __NR_munlockall 153
162#define __NR_sched_setparam 154
163#define __NR_sched_getparam 155
164#define __NR_sched_setscheduler 156
165#define __NR_sched_getscheduler 157
166#define __NR_sched_yield 158
167#define __NR_sched_get_priority_max 159
168#define __NR_sched_get_priority_min 160
169#define __NR_sched_rr_get_interval 161
170#define __NR_nanosleep 162
171#define __NR_mremap 163
172#define __NR_setresuid 164
173#define __NR_getresuid 165
174#define __NR_getpagesize 166
175#define __NR_query_module 167
176#define __NR_poll 168
177#define __NR_nfsservctl 169
178#define __NR_setresgid 170
179#define __NR_getresgid 171
180#define __NR_prctl 172
181#define __NR_rt_sigreturn 173
182#define __NR_rt_sigaction 174
183#define __NR_rt_sigprocmask 175
184#define __NR_rt_sigpending 176
185#define __NR_rt_sigtimedwait 177
186#define __NR_rt_sigqueueinfo 178
187#define __NR_rt_sigsuspend 179
188#define __NR_pread64 180
189#define __NR_pwrite64 181
190#define __NR_lchown 182
191#define __NR_getcwd 183
192#define __NR_capget 184
193#define __NR_capset 185
194#define __NR_sigaltstack 186
195#define __NR_sendfile 187
196#define __NR_getpmsg 188 /* some people actually want streams */
197#define __NR_putpmsg 189 /* some people actually want streams */
198#define __NR_vfork 190
199#define __NR_ugetrlimit 191
200#define __NR_mmap2 192
201#define __NR_truncate64 193
202#define __NR_ftruncate64 194
203#define __NR_stat64 195
204#define __NR_lstat64 196
205#define __NR_fstat64 197
206#define __NR_chown32 198
207#define __NR_getuid32 199
208#define __NR_getgid32 200
209#define __NR_geteuid32 201
210#define __NR_getegid32 202
211#define __NR_setreuid32 203
212#define __NR_setregid32 204
213#define __NR_getgroups32 205
214#define __NR_setgroups32 206
215#define __NR_fchown32 207
216#define __NR_setresuid32 208
217#define __NR_getresuid32 209
218#define __NR_setresgid32 210
219#define __NR_getresgid32 211
220#define __NR_lchown32 212
221#define __NR_setuid32 213
222#define __NR_setgid32 214
223#define __NR_setfsuid32 215
224#define __NR_setfsgid32 216
225#define __NR_pivot_root 217
226/* 218*/
227/* 219*/
228#define __NR_getdents64 220
229#define __NR_gettid 221
230#define __NR_tkill 222
231#define __NR_setxattr 223
232#define __NR_lsetxattr 224
233#define __NR_fsetxattr 225
234#define __NR_getxattr 226
235#define __NR_lgetxattr 227
236#define __NR_fgetxattr 228
237#define __NR_listxattr 229
238#define __NR_llistxattr 230
239#define __NR_flistxattr 231
240#define __NR_removexattr 232
241#define __NR_lremovexattr 233
242#define __NR_fremovexattr 234
243#define __NR_futex 235
244#define __NR_sendfile64 236
245#define __NR_mincore 237
246#define __NR_madvise 238
247#define __NR_fcntl64 239
248#define __NR_readahead 240
249#define __NR_io_setup 241
250#define __NR_io_destroy 242
251#define __NR_io_getevents 243
252#define __NR_io_submit 244
253#define __NR_io_cancel 245
254#define __NR_fadvise64 246
255#define __NR_exit_group 247
256#define __NR_lookup_dcookie 248
257#define __NR_epoll_create 249
258#define __NR_epoll_ctl 250
259#define __NR_epoll_wait 251
260#define __NR_remap_file_pages 252
261#define __NR_set_tid_address 253
262#define __NR_timer_create 254
263#define __NR_timer_settime 255
264#define __NR_timer_gettime 256
265#define __NR_timer_getoverrun 257
266#define __NR_timer_delete 258
267#define __NR_clock_settime 259
268#define __NR_clock_gettime 260
269#define __NR_clock_getres 261
270#define __NR_clock_nanosleep 262
271#define __NR_statfs64 263
272#define __NR_fstatfs64 264
273#define __NR_tgkill 265
274#define __NR_utimes 266
275#define __NR_fadvise64_64 267
276#define __NR_mbind 268
277#define __NR_get_mempolicy 269
278#define __NR_set_mempolicy 270
279#define __NR_mq_open 271
280#define __NR_mq_unlink 272
281#define __NR_mq_timedsend 273
282#define __NR_mq_timedreceive 274
283#define __NR_mq_notify 275
284#define __NR_mq_getsetattr 276
285#define __NR_waitid 277
286/*#define __NR_vserver 278*/
287#define __NR_add_key 279
288#define __NR_request_key 280
289#define __NR_keyctl 281
290#define __NR_ioprio_set 282
291#define __NR_ioprio_get 283
292#define __NR_inotify_init 284
293#define __NR_inotify_add_watch 285
294#define __NR_inotify_rm_watch 286
295#define __NR_migrate_pages 287
296#define __NR_openat 288
297#define __NR_mkdirat 289
298#define __NR_mknodat 290
299#define __NR_fchownat 291
300#define __NR_futimesat 292
301#define __NR_fstatat64 293
302#define __NR_unlinkat 294
303#define __NR_renameat 295
304#define __NR_linkat 296
305#define __NR_symlinkat 297
306#define __NR_readlinkat 298
307#define __NR_fchmodat 299
308#define __NR_faccessat 300
309#define __NR_pselect6 301
310#define __NR_ppoll 302
311#define __NR_unshare 303
312#define __NR_set_robust_list 304
313#define __NR_get_robust_list 305
314#define __NR_splice 306
315#define __NR_sync_file_range 307
316#define __NR_tee 308
317#define __NR_vmsplice 309
318#define __NR_move_pages 310
319#define __NR_sched_setaffinity 311
320#define __NR_sched_getaffinity 312
321#define __NR_kexec_load 313
322#define __NR_getcpu 314
323#define __NR_epoll_pwait 315
324#define __NR_utimensat 316
325#define __NR_signalfd 317
326#define __NR_timerfd_create 318
327#define __NR_eventfd 319
328#define __NR_fallocate 320
329#define __NR_timerfd_settime 321
330#define __NR_timerfd_gettime 322
331#define __NR_signalfd4 323
332#define __NR_eventfd2 324
333#define __NR_epoll_create1 325
334#define __NR_dup3 326
335#define __NR_pipe2 327
336#define __NR_inotify_init1 328
337#define __NR_preadv 329
338#define __NR_pwritev 330
339#define __NR_rt_tgsigqueueinfo 331
340#define __NR_perf_event_open 332
341#define __NR_get_thread_area 333
342#define __NR_set_thread_area 334
343#define __NR_atomic_cmpxchg_32 335
344#define __NR_atomic_barrier 336
345#define __NR_fanotify_init 337
346#define __NR_fanotify_mark 338
347#define __NR_prlimit64 339
348#define __NR_name_to_handle_at 340
349#define __NR_open_by_handle_at 341
350#define __NR_clock_adjtime 342
351#define __NR_syncfs 343
352#define __NR_setns 344
353#define __NR_process_vm_readv 345
354#define __NR_process_vm_writev 346
355#define __NR_kcmp 347
356
357#endif /* _UAPI_ASM_M68K_UNISTD_H_ */
diff --git a/arch/m68k/kernel/entry.S b/arch/m68k/kernel/entry.S
index 946cb018775..45b2f293f8c 100644
--- a/arch/m68k/kernel/entry.S
+++ b/arch/m68k/kernel/entry.S
@@ -115,16 +115,9 @@ ENTRY(ret_from_kernel_thread)
115 | a3 contains the kernel thread payload, d7 - its argument 115 | a3 contains the kernel thread payload, d7 - its argument
116 movel %d1,%sp@- 116 movel %d1,%sp@-
117 jsr schedule_tail 117 jsr schedule_tail
118 GET_CURRENT(%d0)
119 movel %d7,(%sp) 118 movel %d7,(%sp)
120 jsr %a3@ 119 jsr %a3@
121 addql #4,%sp 120 addql #4,%sp
122 movel %d0,(%sp)
123 jra sys_exit
124
125ENTRY(ret_from_kernel_execve)
126 movel 4(%sp), %sp
127 GET_CURRENT(%d0)
128 jra ret_from_exception 121 jra ret_from_exception
129 122
130#if defined(CONFIG_COLDFIRE) || !defined(CONFIG_MMU) 123#if defined(CONFIG_COLDFIRE) || !defined(CONFIG_MMU)
diff --git a/arch/m68k/kernel/syscalltable.S b/arch/m68k/kernel/syscalltable.S
index ce827b37611..4fc2e29b771 100644
--- a/arch/m68k/kernel/syscalltable.S
+++ b/arch/m68k/kernel/syscalltable.S
@@ -367,4 +367,5 @@ ENTRY(sys_call_table)
367 .long sys_setns 367 .long sys_setns
368 .long sys_process_vm_readv /* 345 */ 368 .long sys_process_vm_readv /* 345 */
369 .long sys_process_vm_writev 369 .long sys_process_vm_writev
370 .long sys_kcmp
370 371
diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
index 4cba7439f9d..198abf6d41c 100644
--- a/arch/microblaze/Kconfig
+++ b/arch/microblaze/Kconfig
@@ -26,6 +26,8 @@ config MICROBLAZE
26 select GENERIC_ATOMIC64 26 select GENERIC_ATOMIC64
27 select GENERIC_CLOCKEVENTS 27 select GENERIC_CLOCKEVENTS
28 select MODULES_USE_ELF_RELA 28 select MODULES_USE_ELF_RELA
29 select GENERIC_KERNEL_THREAD
30 select GENERIC_KERNEL_EXECVE
29 31
30config SWAP 32config SWAP
31 def_bool n 33 def_bool n
diff --git a/arch/microblaze/include/asm/processor.h b/arch/microblaze/include/asm/processor.h
index af2bb965239..0759153e811 100644
--- a/arch/microblaze/include/asm/processor.h
+++ b/arch/microblaze/include/asm/processor.h
@@ -31,6 +31,7 @@ extern const struct seq_operations cpuinfo_op;
31void start_thread(struct pt_regs *regs, unsigned long pc, unsigned long usp); 31void start_thread(struct pt_regs *regs, unsigned long pc, unsigned long usp);
32 32
33extern void ret_from_fork(void); 33extern void ret_from_fork(void);
34extern void ret_from_kernel_thread(void);
34 35
35# endif /* __ASSEMBLY__ */ 36# endif /* __ASSEMBLY__ */
36 37
@@ -78,11 +79,6 @@ extern unsigned long thread_saved_pc(struct task_struct *t);
78 79
79extern unsigned long get_wchan(struct task_struct *p); 80extern unsigned long get_wchan(struct task_struct *p);
80 81
81/*
82 * create a kernel thread without removing it from tasklists
83 */
84extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
85
86# define KSTK_EIP(tsk) (0) 82# define KSTK_EIP(tsk) (0)
87# define KSTK_ESP(tsk) (0) 83# define KSTK_ESP(tsk) (0)
88 84
@@ -131,8 +127,6 @@ extern inline void release_thread(struct task_struct *dead_task)
131{ 127{
132} 128}
133 129
134extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
135
136/* Free current thread data structures etc. */ 130/* Free current thread data structures etc. */
137static inline void exit_thread(void) 131static inline void exit_thread(void)
138{ 132{
diff --git a/arch/microblaze/include/asm/unistd.h b/arch/microblaze/include/asm/unistd.h
index 6985e6e9d82..ea744283429 100644
--- a/arch/microblaze/include/asm/unistd.h
+++ b/arch/microblaze/include/asm/unistd.h
@@ -422,6 +422,7 @@
422#define __ARCH_WANT_SYS_SIGPROCMASK 422#define __ARCH_WANT_SYS_SIGPROCMASK
423#define __ARCH_WANT_SYS_RT_SIGACTION 423#define __ARCH_WANT_SYS_RT_SIGACTION
424#define __ARCH_WANT_SYS_RT_SIGSUSPEND 424#define __ARCH_WANT_SYS_RT_SIGSUSPEND
425#define __ARCH_WANT_SYS_EXECVE
425 426
426/* 427/*
427 * "Conditional" syscalls 428 * "Conditional" syscalls
diff --git a/arch/microblaze/kernel/entry-nommu.S b/arch/microblaze/kernel/entry-nommu.S
index 75c3ea1f48a..673a49c04a0 100644
--- a/arch/microblaze/kernel/entry-nommu.S
+++ b/arch/microblaze/kernel/entry-nommu.S
@@ -474,6 +474,14 @@ ENTRY(ret_from_fork)
474 brid ret_to_user 474 brid ret_to_user
475 nop 475 nop
476 476
477ENTRY(ret_from_kernel_thread)
478 brlid r15, schedule_tail
479 addk r5, r0, r3
480 brald r15, r20
481 addk r5, r0, r19
482 brid ret_to_user
483 addk r3, r0, r0
484
477work_pending: 485work_pending:
478 enable_irq 486 enable_irq
479 487
@@ -559,10 +567,6 @@ sys_clone:
559 brid microblaze_clone 567 brid microblaze_clone
560 addk r7, r1, r0 568 addk r7, r1, r0
561 569
562sys_execve:
563 brid microblaze_execve
564 addk r8, r1, r0
565
566sys_rt_sigreturn_wrapper: 570sys_rt_sigreturn_wrapper:
567 brid sys_rt_sigreturn 571 brid sys_rt_sigreturn
568 addk r5, r1, r0 572 addk r5, r1, r0
diff --git a/arch/microblaze/kernel/entry.S b/arch/microblaze/kernel/entry.S
index 03f7b8ce6b6..10f360ed82b 100644
--- a/arch/microblaze/kernel/entry.S
+++ b/arch/microblaze/kernel/entry.S
@@ -293,24 +293,6 @@ C_ENTRY(_user_exception):
293 swi r1, r0, TOPHYS(PER_CPU(ENTRY_SP)) /* save stack */ 293 swi r1, r0, TOPHYS(PER_CPU(ENTRY_SP)) /* save stack */
294 addi r14, r14, 4 /* return address is 4 byte after call */ 294 addi r14, r14, 4 /* return address is 4 byte after call */
295 295
296 mfs r1, rmsr
297 nop
298 andi r1, r1, MSR_UMS
299 bnei r1, 1f
300
301/* Kernel-mode state save - kernel execve */
302 lwi r1, r0, TOPHYS(PER_CPU(ENTRY_SP)); /* Reload kernel stack-ptr*/
303 tophys(r1,r1);
304
305 addik r1, r1, -PT_SIZE; /* Make room on the stack. */
306 SAVE_REGS
307
308 swi r1, r1, PT_MODE; /* pt_regs -> kernel mode */
309 brid 2f;
310 nop; /* Fill delay slot */
311
312/* User-mode state save. */
3131:
314 lwi r1, r0, TOPHYS(PER_CPU(CURRENT_SAVE)); /* get saved current */ 296 lwi r1, r0, TOPHYS(PER_CPU(CURRENT_SAVE)); /* get saved current */
315 tophys(r1,r1); 297 tophys(r1,r1);
316 lwi r1, r1, TS_THREAD_INFO; /* get stack from task_struct */ 298 lwi r1, r1, TS_THREAD_INFO; /* get stack from task_struct */
@@ -479,11 +461,20 @@ C_ENTRY(sys_fork_wrapper):
479 saved context). */ 461 saved context). */
480C_ENTRY(ret_from_fork): 462C_ENTRY(ret_from_fork):
481 bralid r15, schedule_tail; /* ...which is schedule_tail's arg */ 463 bralid r15, schedule_tail; /* ...which is schedule_tail's arg */
482 add r3, r5, r0; /* switch_thread returns the prev task */ 464 add r5, r3, r0; /* switch_thread returns the prev task */
483 /* ( in the delay slot ) */ 465 /* ( in the delay slot ) */
484 brid ret_from_trap; /* Do normal trap return */ 466 brid ret_from_trap; /* Do normal trap return */
485 add r3, r0, r0; /* Child's fork call should return 0. */ 467 add r3, r0, r0; /* Child's fork call should return 0. */
486 468
469C_ENTRY(ret_from_kernel_thread):
470 bralid r15, schedule_tail; /* ...which is schedule_tail's arg */
471 add r5, r3, r0; /* switch_thread returns the prev task */
472 /* ( in the delay slot ) */
473 brald r15, r20 /* fn was left in r20 */
474 addk r5, r0, r19 /* ... and argument - in r19 */
475 brid ret_from_trap
476 add r3, r0, r0
477
487C_ENTRY(sys_vfork): 478C_ENTRY(sys_vfork):
488 brid microblaze_vfork /* Do real work (tail-call) */ 479 brid microblaze_vfork /* Do real work (tail-call) */
489 addik r5, r1, 0 480 addik r5, r1, 0
@@ -498,10 +489,6 @@ C_ENTRY(sys_clone):
498 brid do_fork /* Do real work (tail-call) */ 489 brid do_fork /* Do real work (tail-call) */
499 add r8, r0, r0; /* Arg 3: (unused) */ 490 add r8, r0, r0; /* Arg 3: (unused) */
500 491
501C_ENTRY(sys_execve):
502 brid microblaze_execve; /* Do real work (tail-call).*/
503 addik r8, r1, 0; /* add user context as 4th arg */
504
505C_ENTRY(sys_rt_sigreturn_wrapper): 492C_ENTRY(sys_rt_sigreturn_wrapper):
506 brid sys_rt_sigreturn /* Do real work */ 493 brid sys_rt_sigreturn /* Do real work */
507 addik r5, r1, 0; /* add user context as 1st arg */ 494 addik r5, r1, 0; /* add user context as 1st arg */
diff --git a/arch/microblaze/kernel/process.c b/arch/microblaze/kernel/process.c
index 1944e00f07e..29768c3dc35 100644
--- a/arch/microblaze/kernel/process.c
+++ b/arch/microblaze/kernel/process.c
@@ -119,46 +119,38 @@ void flush_thread(void)
119} 119}
120 120
121int copy_thread(unsigned long clone_flags, unsigned long usp, 121int copy_thread(unsigned long clone_flags, unsigned long usp,
122 unsigned long unused, 122 unsigned long arg,
123 struct task_struct *p, struct pt_regs *regs) 123 struct task_struct *p, struct pt_regs *regs)
124{ 124{
125 struct pt_regs *childregs = task_pt_regs(p); 125 struct pt_regs *childregs = task_pt_regs(p);
126 struct thread_info *ti = task_thread_info(p); 126 struct thread_info *ti = task_thread_info(p);
127 127
128 if (unlikely(p->flags & PF_KTHREAD)) {
129 /* if we're creating a new kernel thread then just zeroing all
130 * the registers. That's OK for a brand new thread.*/
131 memset(childregs, 0, sizeof(struct pt_regs));
132 memset(&ti->cpu_context, 0, sizeof(struct cpu_context));
133 ti->cpu_context.r1 = (unsigned long)childregs;
134 ti->cpu_context.r20 = (unsigned long)usp; /* fn */
135 ti->cpu_context.r19 = (unsigned long)arg;
136 childregs->pt_mode = 1;
137 local_save_flags(childregs->msr);
138#ifdef CONFIG_MMU
139 ti->cpu_context.msr = childregs->msr & ~MSR_IE;
140#endif
141 ti->cpu_context.r15 = (unsigned long)ret_from_kernel_thread - 8;
142 return 0;
143 }
128 *childregs = *regs; 144 *childregs = *regs;
129 if (user_mode(regs)) 145 childregs->r1 = usp;
130 childregs->r1 = usp;
131 else
132 childregs->r1 = ((unsigned long) ti) + THREAD_SIZE;
133 146
134#ifndef CONFIG_MMU
135 memset(&ti->cpu_context, 0, sizeof(struct cpu_context)); 147 memset(&ti->cpu_context, 0, sizeof(struct cpu_context));
136 ti->cpu_context.r1 = (unsigned long)childregs; 148 ti->cpu_context.r1 = (unsigned long)childregs;
149#ifndef CONFIG_MMU
137 ti->cpu_context.msr = (unsigned long)childregs->msr; 150 ti->cpu_context.msr = (unsigned long)childregs->msr;
138#else 151#else
152 childregs->msr |= MSR_UMS;
139 153
140 /* if creating a kernel thread then update the current reg (we don't
141 * want to use the parent's value when restoring by POP_STATE) */
142 if (kernel_mode(regs))
143 /* save new current on stack to use POP_STATE */
144 childregs->CURRENT_TASK = (unsigned long)p;
145 /* if returning to user then use the parent's value of this register */
146
147 /* if we're creating a new kernel thread then just zeroing all
148 * the registers. That's OK for a brand new thread.*/
149 /* Pls. note that some of them will be restored in POP_STATE */
150 if (kernel_mode(regs))
151 memset(&ti->cpu_context, 0, sizeof(struct cpu_context));
152 /* if this thread is created for fork/vfork/clone, then we want to
153 * restore all the parent's context */
154 /* in addition to the registers which will be restored by POP_STATE */
155 else {
156 ti->cpu_context = *(struct cpu_context *)regs;
157 childregs->msr |= MSR_UMS;
158 }
159
160 /* FIXME STATE_SAVE_PT_OFFSET; */
161 ti->cpu_context.r1 = (unsigned long)childregs;
162 /* we should consider the fact that childregs is a copy of the parent 154 /* we should consider the fact that childregs is a copy of the parent
163 * regs which were saved immediately after entering the kernel state 155 * regs which were saved immediately after entering the kernel state
164 * before enabling VM. This MSR will be restored in switch_to and 156 * before enabling VM. This MSR will be restored in switch_to and
@@ -209,29 +201,6 @@ unsigned long thread_saved_pc(struct task_struct *tsk)
209} 201}
210#endif 202#endif
211 203
212static void kernel_thread_helper(int (*fn)(void *), void *arg)
213{
214 fn(arg);
215 do_exit(-1);
216}
217
218int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags)
219{
220 struct pt_regs regs;
221
222 memset(&regs, 0, sizeof(regs));
223 /* store them in non-volatile registers */
224 regs.r5 = (unsigned long)fn;
225 regs.r6 = (unsigned long)arg;
226 local_save_flags(regs.msr);
227 regs.pc = (unsigned long)kernel_thread_helper;
228 regs.pt_mode = 1;
229
230 return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0,
231 &regs, 0, NULL, NULL);
232}
233EXPORT_SYMBOL_GPL(kernel_thread);
234
235unsigned long get_wchan(struct task_struct *p) 204unsigned long get_wchan(struct task_struct *p)
236{ 205{
237/* TBD (used by procfs) */ 206/* TBD (used by procfs) */
@@ -246,6 +215,7 @@ void start_thread(struct pt_regs *regs, unsigned long pc, unsigned long usp)
246 regs->pt_mode = 0; 215 regs->pt_mode = 0;
247#ifdef CONFIG_MMU 216#ifdef CONFIG_MMU
248 regs->msr |= MSR_UMS; 217 regs->msr |= MSR_UMS;
218 regs->msr &= ~MSR_VM;
249#endif 219#endif
250} 220}
251 221
diff --git a/arch/microblaze/kernel/signal.c b/arch/microblaze/kernel/signal.c
index 3847e5b9c60..3903e3d11f5 100644
--- a/arch/microblaze/kernel/signal.c
+++ b/arch/microblaze/kernel/signal.c
@@ -111,7 +111,7 @@ asmlinkage long sys_rt_sigreturn(struct pt_regs *regs)
111 111
112 /* It is more difficult to avoid calling this function than to 112 /* It is more difficult to avoid calling this function than to
113 call it and ignore errors. */ 113 call it and ignore errors. */
114 if (do_sigaltstack(&frame->uc.uc_stack, NULL, regs->r1)) 114 if (do_sigaltstack(&frame->uc.uc_stack, NULL, regs->r1) == -EFAULT)
115 goto badframe; 115 goto badframe;
116 116
117 return rval; 117 return rval;
diff --git a/arch/microblaze/kernel/sys_microblaze.c b/arch/microblaze/kernel/sys_microblaze.c
index 404c0f24bd4..a6a7bae9f5c 100644
--- a/arch/microblaze/kernel/sys_microblaze.c
+++ b/arch/microblaze/kernel/sys_microblaze.c
@@ -48,24 +48,6 @@ asmlinkage long microblaze_clone(int flags, unsigned long stack,
48 return do_fork(flags, stack, regs, 0, NULL, NULL); 48 return do_fork(flags, stack, regs, 0, NULL, NULL);
49} 49}
50 50
51asmlinkage long microblaze_execve(const char __user *filenamei,
52 const char __user *const __user *argv,
53 const char __user *const __user *envp,
54 struct pt_regs *regs)
55{
56 int error;
57 struct filename *filename;
58
59 filename = getname(filenamei);
60 error = PTR_ERR(filename);
61 if (IS_ERR(filename))
62 goto out;
63 error = do_execve(filename->name, argv, envp, regs);
64 putname(filename);
65out:
66 return error;
67}
68
69asmlinkage long sys_mmap(unsigned long addr, unsigned long len, 51asmlinkage long sys_mmap(unsigned long addr, unsigned long len,
70 unsigned long prot, unsigned long flags, 52 unsigned long prot, unsigned long flags,
71 unsigned long fd, off_t pgoff) 53 unsigned long fd, off_t pgoff)
@@ -75,24 +57,3 @@ asmlinkage long sys_mmap(unsigned long addr, unsigned long len,
75 57
76 return sys_mmap_pgoff(addr, len, prot, flags, fd, pgoff >> PAGE_SHIFT); 58 return sys_mmap_pgoff(addr, len, prot, flags, fd, pgoff >> PAGE_SHIFT);
77} 59}
78
79/*
80 * Do a system call from kernel instead of calling sys_execve so we
81 * end up with proper pt_regs.
82 */
83int kernel_execve(const char *filename,
84 const char *const argv[],
85 const char *const envp[])
86{
87 register const char *__a __asm__("r5") = filename;
88 register const void *__b __asm__("r6") = argv;
89 register const void *__c __asm__("r7") = envp;
90 register unsigned long __syscall __asm__("r12") = __NR_execve;
91 register unsigned long __ret __asm__("r3");
92 __asm__ __volatile__ ("brki r14, 0x8"
93 : "=r" (__ret), "=r" (__syscall)
94 : "1" (__syscall), "r" (__a), "r" (__b), "r" (__c)
95 : "r4", "r8", "r9",
96 "r10", "r11", "r14", "cc", "memory");
97 return __ret;
98}
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index dba9390d37c..4183e62f178 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -40,6 +40,8 @@ config MIPS
40 select HAVE_MOD_ARCH_SPECIFIC 40 select HAVE_MOD_ARCH_SPECIFIC
41 select MODULES_USE_ELF_REL 41 select MODULES_USE_ELF_REL
42 select MODULES_USE_ELF_RELA if 64BIT 42 select MODULES_USE_ELF_RELA if 64BIT
43 select GENERIC_KERNEL_THREAD
44 select GENERIC_KERNEL_EXECVE
43 45
44menu "Machine selection" 46menu "Machine selection"
45 47
diff --git a/arch/mips/cavium-octeon/executive/cvmx-l2c.c b/arch/mips/cavium-octeon/executive/cvmx-l2c.c
index d38246e33dd..9f883bf7695 100644
--- a/arch/mips/cavium-octeon/executive/cvmx-l2c.c
+++ b/arch/mips/cavium-octeon/executive/cvmx-l2c.c
@@ -30,6 +30,7 @@
30 * measurement, and debugging facilities. 30 * measurement, and debugging facilities.
31 */ 31 */
32 32
33#include <linux/irqflags.h>
33#include <asm/octeon/cvmx.h> 34#include <asm/octeon/cvmx.h>
34#include <asm/octeon/cvmx-l2c.h> 35#include <asm/octeon/cvmx-l2c.h>
35#include <asm/octeon/cvmx-spinlock.h> 36#include <asm/octeon/cvmx-spinlock.h>
diff --git a/arch/mips/fw/arc/misc.c b/arch/mips/fw/arc/misc.c
index 7cf80ca2c1d..f9f5307434c 100644
--- a/arch/mips/fw/arc/misc.c
+++ b/arch/mips/fw/arc/misc.c
@@ -11,6 +11,7 @@
11 */ 11 */
12#include <linux/init.h> 12#include <linux/init.h>
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/irqflags.h>
14 15
15#include <asm/bcache.h> 16#include <asm/bcache.h>
16 17
diff --git a/arch/mips/include/asm/Kbuild b/arch/mips/include/asm/Kbuild
index e69de29bb2d..533053d12ce 100644
--- a/arch/mips/include/asm/Kbuild
+++ b/arch/mips/include/asm/Kbuild
@@ -0,0 +1 @@
# MIPS headers
diff --git a/arch/mips/include/asm/bitops.h b/arch/mips/include/asm/bitops.h
index 82ad35ce2b4..46ac73abd5e 100644
--- a/arch/mips/include/asm/bitops.h
+++ b/arch/mips/include/asm/bitops.h
@@ -14,7 +14,6 @@
14#endif 14#endif
15 15
16#include <linux/compiler.h> 16#include <linux/compiler.h>
17#include <linux/irqflags.h>
18#include <linux/types.h> 17#include <linux/types.h>
19#include <asm/barrier.h> 18#include <asm/barrier.h>
20#include <asm/byteorder.h> /* sigh ... */ 19#include <asm/byteorder.h> /* sigh ... */
@@ -44,6 +43,24 @@
44#define smp_mb__before_clear_bit() smp_mb__before_llsc() 43#define smp_mb__before_clear_bit() smp_mb__before_llsc()
45#define smp_mb__after_clear_bit() smp_llsc_mb() 44#define smp_mb__after_clear_bit() smp_llsc_mb()
46 45
46
47/*
48 * These are the "slower" versions of the functions and are in bitops.c.
49 * These functions call raw_local_irq_{save,restore}().
50 */
51void __mips_set_bit(unsigned long nr, volatile unsigned long *addr);
52void __mips_clear_bit(unsigned long nr, volatile unsigned long *addr);
53void __mips_change_bit(unsigned long nr, volatile unsigned long *addr);
54int __mips_test_and_set_bit(unsigned long nr,
55 volatile unsigned long *addr);
56int __mips_test_and_set_bit_lock(unsigned long nr,
57 volatile unsigned long *addr);
58int __mips_test_and_clear_bit(unsigned long nr,
59 volatile unsigned long *addr);
60int __mips_test_and_change_bit(unsigned long nr,
61 volatile unsigned long *addr);
62
63
47/* 64/*
48 * set_bit - Atomically set a bit in memory 65 * set_bit - Atomically set a bit in memory
49 * @nr: the bit to set 66 * @nr: the bit to set
@@ -57,7 +74,7 @@
57static inline void set_bit(unsigned long nr, volatile unsigned long *addr) 74static inline void set_bit(unsigned long nr, volatile unsigned long *addr)
58{ 75{
59 unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG); 76 unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG);
60 unsigned short bit = nr & SZLONG_MASK; 77 int bit = nr & SZLONG_MASK;
61 unsigned long temp; 78 unsigned long temp;
62 79
63 if (kernel_uses_llsc && R10000_LLSC_WAR) { 80 if (kernel_uses_llsc && R10000_LLSC_WAR) {
@@ -92,17 +109,8 @@ static inline void set_bit(unsigned long nr, volatile unsigned long *addr)
92 : "=&r" (temp), "+m" (*m) 109 : "=&r" (temp), "+m" (*m)
93 : "ir" (1UL << bit)); 110 : "ir" (1UL << bit));
94 } while (unlikely(!temp)); 111 } while (unlikely(!temp));
95 } else { 112 } else
96 volatile unsigned long *a = addr; 113 __mips_set_bit(nr, addr);
97 unsigned long mask;
98 unsigned long flags;
99
100 a += nr >> SZLONG_LOG;
101 mask = 1UL << bit;
102 raw_local_irq_save(flags);
103 *a |= mask;
104 raw_local_irq_restore(flags);
105 }
106} 114}
107 115
108/* 116/*
@@ -118,7 +126,7 @@ static inline void set_bit(unsigned long nr, volatile unsigned long *addr)
118static inline void clear_bit(unsigned long nr, volatile unsigned long *addr) 126static inline void clear_bit(unsigned long nr, volatile unsigned long *addr)
119{ 127{
120 unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG); 128 unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG);
121 unsigned short bit = nr & SZLONG_MASK; 129 int bit = nr & SZLONG_MASK;
122 unsigned long temp; 130 unsigned long temp;
123 131
124 if (kernel_uses_llsc && R10000_LLSC_WAR) { 132 if (kernel_uses_llsc && R10000_LLSC_WAR) {
@@ -153,17 +161,8 @@ static inline void clear_bit(unsigned long nr, volatile unsigned long *addr)
153 : "=&r" (temp), "+m" (*m) 161 : "=&r" (temp), "+m" (*m)
154 : "ir" (~(1UL << bit))); 162 : "ir" (~(1UL << bit)));
155 } while (unlikely(!temp)); 163 } while (unlikely(!temp));
156 } else { 164 } else
157 volatile unsigned long *a = addr; 165 __mips_clear_bit(nr, addr);
158 unsigned long mask;
159 unsigned long flags;
160
161 a += nr >> SZLONG_LOG;
162 mask = 1UL << bit;
163 raw_local_irq_save(flags);
164 *a &= ~mask;
165 raw_local_irq_restore(flags);
166 }
167} 166}
168 167
169/* 168/*
@@ -191,7 +190,7 @@ static inline void clear_bit_unlock(unsigned long nr, volatile unsigned long *ad
191 */ 190 */
192static inline void change_bit(unsigned long nr, volatile unsigned long *addr) 191static inline void change_bit(unsigned long nr, volatile unsigned long *addr)
193{ 192{
194 unsigned short bit = nr & SZLONG_MASK; 193 int bit = nr & SZLONG_MASK;
195 194
196 if (kernel_uses_llsc && R10000_LLSC_WAR) { 195 if (kernel_uses_llsc && R10000_LLSC_WAR) {
197 unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG); 196 unsigned long *m = ((unsigned long *) addr) + (nr >> SZLONG_LOG);
@@ -220,17 +219,8 @@ static inline void change_bit(unsigned long nr, volatile unsigned long *addr)
220 : "=&r" (temp), "+m" (*m) 219 : "=&r" (temp), "+m" (*m)
221 : "ir" (1UL << bit)); 220 : "ir" (1UL << bit));
222 } while (unlikely(!temp)); 221 } while (unlikely(!temp));
223 } else { 222 } else
224 volatile unsigned long *a = addr; 223 __mips_change_bit(nr, addr);
225 unsigned long mask;
226 unsigned long flags;
227
228 a += nr >> SZLONG_LOG;
229 mask = 1UL << bit;
230 raw_local_irq_save(flags);
231 *a ^= mask;
232 raw_local_irq_restore(flags);
233 }
234} 224}
235 225
236/* 226/*
@@ -244,7 +234,7 @@ static inline void change_bit(unsigned long nr, volatile unsigned long *addr)
244static inline int test_and_set_bit(unsigned long nr, 234static inline int test_and_set_bit(unsigned long nr,
245 volatile unsigned long *addr) 235 volatile unsigned long *addr)
246{ 236{
247 unsigned short bit = nr & SZLONG_MASK; 237 int bit = nr & SZLONG_MASK;
248 unsigned long res; 238 unsigned long res;
249 239
250 smp_mb__before_llsc(); 240 smp_mb__before_llsc();
@@ -281,18 +271,8 @@ static inline int test_and_set_bit(unsigned long nr,
281 } while (unlikely(!res)); 271 } while (unlikely(!res));
282 272
283 res = temp & (1UL << bit); 273 res = temp & (1UL << bit);
284 } else { 274 } else
285 volatile unsigned long *a = addr; 275 res = __mips_test_and_set_bit(nr, addr);
286 unsigned long mask;
287 unsigned long flags;
288
289 a += nr >> SZLONG_LOG;
290 mask = 1UL << bit;
291 raw_local_irq_save(flags);
292 res = (mask & *a);
293 *a |= mask;
294 raw_local_irq_restore(flags);
295 }
296 276
297 smp_llsc_mb(); 277 smp_llsc_mb();
298 278
@@ -310,7 +290,7 @@ static inline int test_and_set_bit(unsigned long nr,
310static inline int test_and_set_bit_lock(unsigned long nr, 290static inline int test_and_set_bit_lock(unsigned long nr,
311 volatile unsigned long *addr) 291 volatile unsigned long *addr)
312{ 292{
313 unsigned short bit = nr & SZLONG_MASK; 293 int bit = nr & SZLONG_MASK;
314 unsigned long res; 294 unsigned long res;
315 295
316 if (kernel_uses_llsc && R10000_LLSC_WAR) { 296 if (kernel_uses_llsc && R10000_LLSC_WAR) {
@@ -345,18 +325,8 @@ static inline int test_and_set_bit_lock(unsigned long nr,
345 } while (unlikely(!res)); 325 } while (unlikely(!res));
346 326
347 res = temp & (1UL << bit); 327 res = temp & (1UL << bit);
348 } else { 328 } else
349 volatile unsigned long *a = addr; 329 res = __mips_test_and_set_bit_lock(nr, addr);
350 unsigned long mask;
351 unsigned long flags;
352
353 a += nr >> SZLONG_LOG;
354 mask = 1UL << bit;
355 raw_local_irq_save(flags);
356 res = (mask & *a);
357 *a |= mask;
358 raw_local_irq_restore(flags);
359 }
360 330
361 smp_llsc_mb(); 331 smp_llsc_mb();
362 332
@@ -373,7 +343,7 @@ static inline int test_and_set_bit_lock(unsigned long nr,
373static inline int test_and_clear_bit(unsigned long nr, 343static inline int test_and_clear_bit(unsigned long nr,
374 volatile unsigned long *addr) 344 volatile unsigned long *addr)
375{ 345{
376 unsigned short bit = nr & SZLONG_MASK; 346 int bit = nr & SZLONG_MASK;
377 unsigned long res; 347 unsigned long res;
378 348
379 smp_mb__before_llsc(); 349 smp_mb__before_llsc();
@@ -428,18 +398,8 @@ static inline int test_and_clear_bit(unsigned long nr,
428 } while (unlikely(!res)); 398 } while (unlikely(!res));
429 399
430 res = temp & (1UL << bit); 400 res = temp & (1UL << bit);
431 } else { 401 } else
432 volatile unsigned long *a = addr; 402 res = __mips_test_and_clear_bit(nr, addr);
433 unsigned long mask;
434 unsigned long flags;
435
436 a += nr >> SZLONG_LOG;
437 mask = 1UL << bit;
438 raw_local_irq_save(flags);
439 res = (mask & *a);
440 *a &= ~mask;
441 raw_local_irq_restore(flags);
442 }
443 403
444 smp_llsc_mb(); 404 smp_llsc_mb();
445 405
@@ -457,7 +417,7 @@ static inline int test_and_clear_bit(unsigned long nr,
457static inline int test_and_change_bit(unsigned long nr, 417static inline int test_and_change_bit(unsigned long nr,
458 volatile unsigned long *addr) 418 volatile unsigned long *addr)
459{ 419{
460 unsigned short bit = nr & SZLONG_MASK; 420 int bit = nr & SZLONG_MASK;
461 unsigned long res; 421 unsigned long res;
462 422
463 smp_mb__before_llsc(); 423 smp_mb__before_llsc();
@@ -494,18 +454,8 @@ static inline int test_and_change_bit(unsigned long nr,
494 } while (unlikely(!res)); 454 } while (unlikely(!res));
495 455
496 res = temp & (1UL << bit); 456 res = temp & (1UL << bit);
497 } else { 457 } else
498 volatile unsigned long *a = addr; 458 res = __mips_test_and_change_bit(nr, addr);
499 unsigned long mask;
500 unsigned long flags;
501
502 a += nr >> SZLONG_LOG;
503 mask = 1UL << bit;
504 raw_local_irq_save(flags);
505 res = (mask & *a);
506 *a ^= mask;
507 raw_local_irq_restore(flags);
508 }
509 459
510 smp_llsc_mb(); 460 smp_llsc_mb();
511 461
diff --git a/arch/mips/include/asm/compat.h b/arch/mips/include/asm/compat.h
index 58277e0e9cd..3c5d1464b7b 100644
--- a/arch/mips/include/asm/compat.h
+++ b/arch/mips/include/asm/compat.h
@@ -290,7 +290,7 @@ struct compat_shmid64_ds {
290 290
291static inline int is_compat_task(void) 291static inline int is_compat_task(void)
292{ 292{
293 return test_thread_flag(TIF_32BIT); 293 return test_thread_flag(TIF_32BIT_ADDR);
294} 294}
295 295
296#endif /* _ASM_COMPAT_H */ 296#endif /* _ASM_COMPAT_H */
diff --git a/arch/mips/include/asm/delay.h b/arch/mips/include/asm/delay.h
index e7cd78277c2..dc0a5f77a35 100644
--- a/arch/mips/include/asm/delay.h
+++ b/arch/mips/include/asm/delay.h
@@ -13,9 +13,9 @@
13 13
14#include <linux/param.h> 14#include <linux/param.h>
15 15
16extern void __delay(unsigned int loops); 16extern void __delay(unsigned long loops);
17extern void __ndelay(unsigned int ns); 17extern void __ndelay(unsigned long ns);
18extern void __udelay(unsigned int us); 18extern void __udelay(unsigned long us);
19 19
20#define ndelay(ns) __ndelay(ns) 20#define ndelay(ns) __ndelay(ns)
21#define udelay(us) __udelay(us) 21#define udelay(us) __udelay(us)
diff --git a/arch/mips/include/asm/io.h b/arch/mips/include/asm/io.h
index 29d9c23c20c..ff2e0345e01 100644
--- a/arch/mips/include/asm/io.h
+++ b/arch/mips/include/asm/io.h
@@ -15,6 +15,7 @@
15#include <linux/compiler.h> 15#include <linux/compiler.h>
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/types.h> 17#include <linux/types.h>
18#include <linux/irqflags.h>
18 19
19#include <asm/addrspace.h> 20#include <asm/addrspace.h>
20#include <asm/bug.h> 21#include <asm/bug.h>
diff --git a/arch/mips/include/asm/irqflags.h b/arch/mips/include/asm/irqflags.h
index 309cbcd6909..9f3384c789d 100644
--- a/arch/mips/include/asm/irqflags.h
+++ b/arch/mips/include/asm/irqflags.h
@@ -16,83 +16,13 @@
16#include <linux/compiler.h> 16#include <linux/compiler.h>
17#include <asm/hazards.h> 17#include <asm/hazards.h>
18 18
19__asm__( 19#if defined(CONFIG_CPU_MIPSR2) && !defined(CONFIG_MIPS_MT_SMTC)
20 " .macro arch_local_irq_enable \n"
21 " .set push \n"
22 " .set reorder \n"
23 " .set noat \n"
24#ifdef CONFIG_MIPS_MT_SMTC
25 " mfc0 $1, $2, 1 # SMTC - clear TCStatus.IXMT \n"
26 " ori $1, 0x400 \n"
27 " xori $1, 0x400 \n"
28 " mtc0 $1, $2, 1 \n"
29#elif defined(CONFIG_CPU_MIPSR2)
30 " ei \n"
31#else
32 " mfc0 $1,$12 \n"
33 " ori $1,0x1f \n"
34 " xori $1,0x1e \n"
35 " mtc0 $1,$12 \n"
36#endif
37 " irq_enable_hazard \n"
38 " .set pop \n"
39 " .endm");
40 20
41extern void smtc_ipi_replay(void);
42
43static inline void arch_local_irq_enable(void)
44{
45#ifdef CONFIG_MIPS_MT_SMTC
46 /*
47 * SMTC kernel needs to do a software replay of queued
48 * IPIs, at the cost of call overhead on each local_irq_enable()
49 */
50 smtc_ipi_replay();
51#endif
52 __asm__ __volatile__(
53 "arch_local_irq_enable"
54 : /* no outputs */
55 : /* no inputs */
56 : "memory");
57}
58
59
60/*
61 * For cli() we have to insert nops to make sure that the new value
62 * has actually arrived in the status register before the end of this
63 * macro.
64 * R4000/R4400 need three nops, the R4600 two nops and the R10000 needs
65 * no nops at all.
66 */
67/*
68 * For TX49, operating only IE bit is not enough.
69 *
70 * If mfc0 $12 follows store and the mfc0 is last instruction of a
71 * page and fetching the next instruction causes TLB miss, the result
72 * of the mfc0 might wrongly contain EXL bit.
73 *
74 * ERT-TX49H2-027, ERT-TX49H3-012, ERT-TX49HL3-006, ERT-TX49H4-008
75 *
76 * Workaround: mask EXL bit of the result or place a nop before mfc0.
77 */
78__asm__( 21__asm__(
79 " .macro arch_local_irq_disable\n" 22 " .macro arch_local_irq_disable\n"
80 " .set push \n" 23 " .set push \n"
81 " .set noat \n" 24 " .set noat \n"
82#ifdef CONFIG_MIPS_MT_SMTC
83 " mfc0 $1, $2, 1 \n"
84 " ori $1, 0x400 \n"
85 " .set noreorder \n"
86 " mtc0 $1, $2, 1 \n"
87#elif defined(CONFIG_CPU_MIPSR2)
88 " di \n" 25 " di \n"
89#else
90 " mfc0 $1,$12 \n"
91 " ori $1,0x1f \n"
92 " xori $1,0x1f \n"
93 " .set noreorder \n"
94 " mtc0 $1,$12 \n"
95#endif
96 " irq_disable_hazard \n" 26 " irq_disable_hazard \n"
97 " .set pop \n" 27 " .set pop \n"
98 " .endm \n"); 28 " .endm \n");
@@ -106,46 +36,14 @@ static inline void arch_local_irq_disable(void)
106 : "memory"); 36 : "memory");
107} 37}
108 38
109__asm__(
110 " .macro arch_local_save_flags flags \n"
111 " .set push \n"
112 " .set reorder \n"
113#ifdef CONFIG_MIPS_MT_SMTC
114 " mfc0 \\flags, $2, 1 \n"
115#else
116 " mfc0 \\flags, $12 \n"
117#endif
118 " .set pop \n"
119 " .endm \n");
120
121static inline unsigned long arch_local_save_flags(void)
122{
123 unsigned long flags;
124 asm volatile("arch_local_save_flags %0" : "=r" (flags));
125 return flags;
126}
127 39
128__asm__( 40__asm__(
129 " .macro arch_local_irq_save result \n" 41 " .macro arch_local_irq_save result \n"
130 " .set push \n" 42 " .set push \n"
131 " .set reorder \n" 43 " .set reorder \n"
132 " .set noat \n" 44 " .set noat \n"
133#ifdef CONFIG_MIPS_MT_SMTC
134 " mfc0 \\result, $2, 1 \n"
135 " ori $1, \\result, 0x400 \n"
136 " .set noreorder \n"
137 " mtc0 $1, $2, 1 \n"
138 " andi \\result, \\result, 0x400 \n"
139#elif defined(CONFIG_CPU_MIPSR2)
140 " di \\result \n" 45 " di \\result \n"
141 " andi \\result, 1 \n" 46 " andi \\result, 1 \n"
142#else
143 " mfc0 \\result, $12 \n"
144 " ori $1, \\result, 0x1f \n"
145 " xori $1, 0x1f \n"
146 " .set noreorder \n"
147 " mtc0 $1, $12 \n"
148#endif
149 " irq_disable_hazard \n" 47 " irq_disable_hazard \n"
150 " .set pop \n" 48 " .set pop \n"
151 " .endm \n"); 49 " .endm \n");
@@ -160,61 +58,37 @@ static inline unsigned long arch_local_irq_save(void)
160 return flags; 58 return flags;
161} 59}
162 60
61
163__asm__( 62__asm__(
164 " .macro arch_local_irq_restore flags \n" 63 " .macro arch_local_irq_restore flags \n"
165 " .set push \n" 64 " .set push \n"
166 " .set noreorder \n" 65 " .set noreorder \n"
167 " .set noat \n" 66 " .set noat \n"
168#ifdef CONFIG_MIPS_MT_SMTC 67#if defined(CONFIG_IRQ_CPU)
169 "mfc0 $1, $2, 1 \n"
170 "andi \\flags, 0x400 \n"
171 "ori $1, 0x400 \n"
172 "xori $1, 0x400 \n"
173 "or \\flags, $1 \n"
174 "mtc0 \\flags, $2, 1 \n"
175#elif defined(CONFIG_CPU_MIPSR2) && defined(CONFIG_IRQ_CPU)
176 /* 68 /*
177 * Slow, but doesn't suffer from a relatively unlikely race 69 * Slow, but doesn't suffer from a relatively unlikely race
178 * condition we're having since days 1. 70 * condition we're having since days 1.
179 */ 71 */
180 " beqz \\flags, 1f \n" 72 " beqz \\flags, 1f \n"
181 " di \n" 73 " di \n"
182 " ei \n" 74 " ei \n"
183 "1: \n" 75 "1: \n"
184#elif defined(CONFIG_CPU_MIPSR2) 76#else
185 /* 77 /*
186 * Fast, dangerous. Life is fun, life is good. 78 * Fast, dangerous. Life is fun, life is good.
187 */ 79 */
188 " mfc0 $1, $12 \n" 80 " mfc0 $1, $12 \n"
189 " ins $1, \\flags, 0, 1 \n" 81 " ins $1, \\flags, 0, 1 \n"
190 " mtc0 $1, $12 \n" 82 " mtc0 $1, $12 \n"
191#else
192 " mfc0 $1, $12 \n"
193 " andi \\flags, 1 \n"
194 " ori $1, 0x1f \n"
195 " xori $1, 0x1f \n"
196 " or \\flags, $1 \n"
197 " mtc0 \\flags, $12 \n"
198#endif 83#endif
199 " irq_disable_hazard \n" 84 " irq_disable_hazard \n"
200 " .set pop \n" 85 " .set pop \n"
201 " .endm \n"); 86 " .endm \n");
202 87
203
204static inline void arch_local_irq_restore(unsigned long flags) 88static inline void arch_local_irq_restore(unsigned long flags)
205{ 89{
206 unsigned long __tmp1; 90 unsigned long __tmp1;
207 91
208#ifdef CONFIG_MIPS_MT_SMTC
209 /*
210 * SMTC kernel needs to do a software replay of queued
211 * IPIs, at the cost of branch and call overhead on each
212 * local_irq_restore()
213 */
214 if (unlikely(!(flags & 0x0400)))
215 smtc_ipi_replay();
216#endif
217
218 __asm__ __volatile__( 92 __asm__ __volatile__(
219 "arch_local_irq_restore\t%0" 93 "arch_local_irq_restore\t%0"
220 : "=r" (__tmp1) 94 : "=r" (__tmp1)
@@ -232,6 +106,75 @@ static inline void __arch_local_irq_restore(unsigned long flags)
232 : "0" (flags) 106 : "0" (flags)
233 : "memory"); 107 : "memory");
234} 108}
109#else
110/* Functions that require preempt_{dis,en}able() are in mips-atomic.c */
111void arch_local_irq_disable(void);
112unsigned long arch_local_irq_save(void);
113void arch_local_irq_restore(unsigned long flags);
114void __arch_local_irq_restore(unsigned long flags);
115#endif /* if defined(CONFIG_CPU_MIPSR2) && !defined(CONFIG_MIPS_MT_SMTC) */
116
117
118__asm__(
119 " .macro arch_local_irq_enable \n"
120 " .set push \n"
121 " .set reorder \n"
122 " .set noat \n"
123#ifdef CONFIG_MIPS_MT_SMTC
124 " mfc0 $1, $2, 1 # SMTC - clear TCStatus.IXMT \n"
125 " ori $1, 0x400 \n"
126 " xori $1, 0x400 \n"
127 " mtc0 $1, $2, 1 \n"
128#elif defined(CONFIG_CPU_MIPSR2)
129 " ei \n"
130#else
131 " mfc0 $1,$12 \n"
132 " ori $1,0x1f \n"
133 " xori $1,0x1e \n"
134 " mtc0 $1,$12 \n"
135#endif
136 " irq_enable_hazard \n"
137 " .set pop \n"
138 " .endm");
139
140extern void smtc_ipi_replay(void);
141
142static inline void arch_local_irq_enable(void)
143{
144#ifdef CONFIG_MIPS_MT_SMTC
145 /*
146 * SMTC kernel needs to do a software replay of queued
147 * IPIs, at the cost of call overhead on each local_irq_enable()
148 */
149 smtc_ipi_replay();
150#endif
151 __asm__ __volatile__(
152 "arch_local_irq_enable"
153 : /* no outputs */
154 : /* no inputs */
155 : "memory");
156}
157
158
159__asm__(
160 " .macro arch_local_save_flags flags \n"
161 " .set push \n"
162 " .set reorder \n"
163#ifdef CONFIG_MIPS_MT_SMTC
164 " mfc0 \\flags, $2, 1 \n"
165#else
166 " mfc0 \\flags, $12 \n"
167#endif
168 " .set pop \n"
169 " .endm \n");
170
171static inline unsigned long arch_local_save_flags(void)
172{
173 unsigned long flags;
174 asm volatile("arch_local_save_flags %0" : "=r" (flags));
175 return flags;
176}
177
235 178
236static inline int arch_irqs_disabled_flags(unsigned long flags) 179static inline int arch_irqs_disabled_flags(unsigned long flags)
237{ 180{
@@ -245,7 +188,7 @@ static inline int arch_irqs_disabled_flags(unsigned long flags)
245#endif 188#endif
246} 189}
247 190
248#endif 191#endif /* #ifndef __ASSEMBLY__ */
249 192
250/* 193/*
251 * Do the CPU's IRQ-state tracing from assembly code. 194 * Do the CPU's IRQ-state tracing from assembly code.
diff --git a/arch/mips/include/asm/pgtable-64.h b/arch/mips/include/asm/pgtable-64.h
index c26e1825007..f5b521d5a67 100644
--- a/arch/mips/include/asm/pgtable-64.h
+++ b/arch/mips/include/asm/pgtable-64.h
@@ -9,6 +9,7 @@
9#ifndef _ASM_PGTABLE_64_H 9#ifndef _ASM_PGTABLE_64_H
10#define _ASM_PGTABLE_64_H 10#define _ASM_PGTABLE_64_H
11 11
12#include <linux/compiler.h>
12#include <linux/linkage.h> 13#include <linux/linkage.h>
13 14
14#include <asm/addrspace.h> 15#include <asm/addrspace.h>
@@ -172,7 +173,19 @@ static inline int pmd_none(pmd_t pmd)
172 return pmd_val(pmd) == (unsigned long) invalid_pte_table; 173 return pmd_val(pmd) == (unsigned long) invalid_pte_table;
173} 174}
174 175
175#define pmd_bad(pmd) (pmd_val(pmd) & ~PAGE_MASK) 176static inline int pmd_bad(pmd_t pmd)
177{
178#ifdef CONFIG_HUGETLB_PAGE
179 /* pmd_huge(pmd) but inline */
180 if (unlikely(pmd_val(pmd) & _PAGE_HUGE))
181 return 0;
182#endif
183
184 if (unlikely(pmd_val(pmd) & ~PAGE_MASK))
185 return 1;
186
187 return 0;
188}
176 189
177static inline int pmd_present(pmd_t pmd) 190static inline int pmd_present(pmd_t pmd)
178{ 191{
diff --git a/arch/mips/include/asm/processor.h b/arch/mips/include/asm/processor.h
index 5e33fabe354..d28c41e0887 100644
--- a/arch/mips/include/asm/processor.h
+++ b/arch/mips/include/asm/processor.h
@@ -310,8 +310,6 @@ struct task_struct;
310/* Free all resources held by a thread. */ 310/* Free all resources held by a thread. */
311#define release_thread(thread) do { } while(0) 311#define release_thread(thread) do { } while(0)
312 312
313extern long kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
314
315extern unsigned long thread_saved_pc(struct task_struct *tsk); 313extern unsigned long thread_saved_pc(struct task_struct *tsk);
316 314
317/* 315/*
diff --git a/arch/mips/include/asm/ptrace.h b/arch/mips/include/asm/ptrace.h
index 4f5da948a77..cec5e125f7e 100644
--- a/arch/mips/include/asm/ptrace.h
+++ b/arch/mips/include/asm/ptrace.h
@@ -61,4 +61,10 @@ static inline void die_if_kernel(const char *str, struct pt_regs *regs)
61 die(str, regs); 61 die(str, regs);
62} 62}
63 63
64#define current_pt_regs() \
65({ \
66 unsigned long sp = (unsigned long)__builtin_frame_address(0); \
67 (struct pt_regs *)((sp | (THREAD_SIZE - 1)) + 1 - 32) - 1; \
68})
69
64#endif /* _ASM_PTRACE_H */ 70#endif /* _ASM_PTRACE_H */
diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
index 8debe9e9175..18806a52061 100644
--- a/arch/mips/include/asm/thread_info.h
+++ b/arch/mips/include/asm/thread_info.h
@@ -112,12 +112,6 @@ register struct thread_info *__current_thread_info __asm__("$28");
112#define TIF_LOAD_WATCH 25 /* If set, load watch registers */ 112#define TIF_LOAD_WATCH 25 /* If set, load watch registers */
113#define TIF_SYSCALL_TRACE 31 /* syscall trace active */ 113#define TIF_SYSCALL_TRACE 31 /* syscall trace active */
114 114
115#ifdef CONFIG_MIPS32_O32
116#define TIF_32BIT TIF_32BIT_REGS
117#elif defined(CONFIG_MIPS32_N32)
118#define TIF_32BIT _TIF_32BIT_ADDR
119#endif /* CONFIG_MIPS32_O32 */
120
121#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) 115#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
122#define _TIF_SIGPENDING (1<<TIF_SIGPENDING) 116#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
123#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) 117#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
diff --git a/arch/mips/include/asm/unistd.h b/arch/mips/include/asm/unistd.h
index 9e47cc11aa2..b306e2081ca 100644
--- a/arch/mips/include/asm/unistd.h
+++ b/arch/mips/include/asm/unistd.h
@@ -20,6 +20,7 @@
20#define __ARCH_OMIT_COMPAT_SYS_GETDENTS64 20#define __ARCH_OMIT_COMPAT_SYS_GETDENTS64
21#define __ARCH_WANT_OLD_READDIR 21#define __ARCH_WANT_OLD_READDIR
22#define __ARCH_WANT_SYS_ALARM 22#define __ARCH_WANT_SYS_ALARM
23#define __ARCH_WANT_SYS_EXECVE
23#define __ARCH_WANT_SYS_GETHOSTNAME 24#define __ARCH_WANT_SYS_GETHOSTNAME
24#define __ARCH_WANT_SYS_IPC 25#define __ARCH_WANT_SYS_IPC
25#define __ARCH_WANT_SYS_PAUSE 26#define __ARCH_WANT_SYS_PAUSE
diff --git a/arch/mips/jz4740/serial.h b/arch/mips/jz4740/serial.h
index b9fe3ade028..8eb715bb1ea 100644
--- a/arch/mips/jz4740/serial.h
+++ b/arch/mips/jz4740/serial.h
@@ -14,6 +14,9 @@
14 */ 14 */
15 15
16#ifndef __MIPS_JZ4740_SERIAL_H__ 16#ifndef __MIPS_JZ4740_SERIAL_H__
17#define __MIPS_JZ4740_SERIAL_H__
18
19struct uart_port;
17 20
18void jz4740_serial_out(struct uart_port *p, int offset, int value); 21void jz4740_serial_out(struct uart_port *p, int offset, int value);
19 22
diff --git a/arch/mips/kernel/entry.S b/arch/mips/kernel/entry.S
index a6c13321200..3320cb4ac1d 100644
--- a/arch/mips/kernel/entry.S
+++ b/arch/mips/kernel/entry.S
@@ -65,6 +65,12 @@ need_resched:
65 b need_resched 65 b need_resched
66#endif 66#endif
67 67
68FEXPORT(ret_from_kernel_thread)
69 jal schedule_tail # a0 = struct task_struct *prev
70 move a0, s1
71 jal s0
72 j syscall_exit
73
68FEXPORT(ret_from_fork) 74FEXPORT(ret_from_fork)
69 jal schedule_tail # a0 = struct task_struct *prev 75 jal schedule_tail # a0 = struct task_struct *prev
70 76
diff --git a/arch/mips/kernel/linux32.c b/arch/mips/kernel/linux32.c
index 3a21acedf88..8796dbc7e35 100644
--- a/arch/mips/kernel/linux32.c
+++ b/arch/mips/kernel/linux32.c
@@ -3,7 +3,6 @@
3 * 3 *
4 * Copyright (C) 2000 Silicon Graphics, Inc. 4 * Copyright (C) 2000 Silicon Graphics, Inc.
5 * Written by Ulf Carlsson (ulfc@engr.sgi.com) 5 * Written by Ulf Carlsson (ulfc@engr.sgi.com)
6 * sys32_execve from ia64/ia32 code, Feb 2000, Kanoj Sarcar (kanoj@sgi.com)
7 */ 6 */
8#include <linux/compiler.h> 7#include <linux/compiler.h>
9#include <linux/mm.h> 8#include <linux/mm.h>
@@ -77,26 +76,6 @@ out:
77 return error; 76 return error;
78} 77}
79 78
80/*
81 * sys_execve() executes a new program.
82 */
83asmlinkage int sys32_execve(nabi_no_regargs struct pt_regs regs)
84{
85 int error;
86 struct filename *filename;
87
88 filename = getname(compat_ptr(regs.regs[4]));
89 error = PTR_ERR(filename);
90 if (IS_ERR(filename))
91 goto out;
92 error = compat_do_execve(filename->name, compat_ptr(regs.regs[5]),
93 compat_ptr(regs.regs[6]), &regs);
94 putname(filename);
95
96out:
97 return error;
98}
99
100#define RLIM_INFINITY32 0x7fffffff 79#define RLIM_INFINITY32 0x7fffffff
101#define RESOURCE32(x) ((x > RLIM_INFINITY32) ? RLIM_INFINITY32 : x) 80#define RESOURCE32(x) ((x > RLIM_INFINITY32) ? RLIM_INFINITY32 : x)
102 81
diff --git a/arch/mips/kernel/mips_ksyms.c b/arch/mips/kernel/mips_ksyms.c
index 3fc1691110d..2d9304c2b54 100644
--- a/arch/mips/kernel/mips_ksyms.c
+++ b/arch/mips/kernel/mips_ksyms.c
@@ -32,8 +32,6 @@ EXPORT_SYMBOL(memset);
32EXPORT_SYMBOL(memcpy); 32EXPORT_SYMBOL(memcpy);
33EXPORT_SYMBOL(memmove); 33EXPORT_SYMBOL(memmove);
34 34
35EXPORT_SYMBOL(kernel_thread);
36
37/* 35/*
38 * Functions that operate on entire pages. Mostly used by memory management. 36 * Functions that operate on entire pages. Mostly used by memory management.
39 */ 37 */
diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
index e9a5fd7277f..d13720ac656 100644
--- a/arch/mips/kernel/process.c
+++ b/arch/mips/kernel/process.c
@@ -84,6 +84,7 @@ void __noreturn cpu_idle(void)
84} 84}
85 85
86asmlinkage void ret_from_fork(void); 86asmlinkage void ret_from_fork(void);
87asmlinkage void ret_from_kernel_thread(void);
87 88
88void start_thread(struct pt_regs * regs, unsigned long pc, unsigned long sp) 89void start_thread(struct pt_regs * regs, unsigned long pc, unsigned long sp)
89{ 90{
@@ -113,7 +114,7 @@ void flush_thread(void)
113} 114}
114 115
115int copy_thread(unsigned long clone_flags, unsigned long usp, 116int copy_thread(unsigned long clone_flags, unsigned long usp,
116 unsigned long unused, struct task_struct *p, struct pt_regs *regs) 117 unsigned long arg, struct task_struct *p, struct pt_regs *regs)
117{ 118{
118 struct thread_info *ti = task_thread_info(p); 119 struct thread_info *ti = task_thread_info(p);
119 struct pt_regs *childregs; 120 struct pt_regs *childregs;
@@ -136,19 +137,30 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
136 childregs = (struct pt_regs *) childksp - 1; 137 childregs = (struct pt_regs *) childksp - 1;
137 /* Put the stack after the struct pt_regs. */ 138 /* Put the stack after the struct pt_regs. */
138 childksp = (unsigned long) childregs; 139 childksp = (unsigned long) childregs;
140 p->thread.cp0_status = read_c0_status() & ~(ST0_CU2|ST0_CU1);
141 if (unlikely(p->flags & PF_KTHREAD)) {
142 unsigned long status = p->thread.cp0_status;
143 memset(childregs, 0, sizeof(struct pt_regs));
144 ti->addr_limit = KERNEL_DS;
145 p->thread.reg16 = usp; /* fn */
146 p->thread.reg17 = arg;
147 p->thread.reg29 = childksp;
148 p->thread.reg31 = (unsigned long) ret_from_kernel_thread;
149#if defined(CONFIG_CPU_R3000) || defined(CONFIG_CPU_TX39XX)
150 status = (status & ~(ST0_KUP | ST0_IEP | ST0_IEC)) |
151 ((status & (ST0_KUC | ST0_IEC)) << 2);
152#else
153 status |= ST0_EXL;
154#endif
155 childregs->cp0_status = status;
156 return 0;
157 }
139 *childregs = *regs; 158 *childregs = *regs;
140 childregs->regs[7] = 0; /* Clear error flag */ 159 childregs->regs[7] = 0; /* Clear error flag */
141
142 childregs->regs[2] = 0; /* Child gets zero as return value */ 160 childregs->regs[2] = 0; /* Child gets zero as return value */
161 childregs->regs[29] = usp;
162 ti->addr_limit = USER_DS;
143 163
144 if (childregs->cp0_status & ST0_CU0) {
145 childregs->regs[28] = (unsigned long) ti;
146 childregs->regs[29] = childksp;
147 ti->addr_limit = KERNEL_DS;
148 } else {
149 childregs->regs[29] = usp;
150 ti->addr_limit = USER_DS;
151 }
152 p->thread.reg29 = (unsigned long) childregs; 164 p->thread.reg29 = (unsigned long) childregs;
153 p->thread.reg31 = (unsigned long) ret_from_fork; 165 p->thread.reg31 = (unsigned long) ret_from_fork;
154 166
@@ -156,7 +168,6 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
156 * New tasks lose permission to use the fpu. This accelerates context 168 * New tasks lose permission to use the fpu. This accelerates context
157 * switching for most programs since they don't use the fpu. 169 * switching for most programs since they don't use the fpu.
158 */ 170 */
159 p->thread.cp0_status = read_c0_status() & ~(ST0_CU2|ST0_CU1);
160 childregs->cp0_status &= ~(ST0_CU2|ST0_CU1); 171 childregs->cp0_status &= ~(ST0_CU2|ST0_CU1);
161 172
162#ifdef CONFIG_MIPS_MT_SMTC 173#ifdef CONFIG_MIPS_MT_SMTC
@@ -222,35 +233,6 @@ int dump_task_fpu(struct task_struct *t, elf_fpregset_t *fpr)
222} 233}
223 234
224/* 235/*
225 * Create a kernel thread
226 */
227static void __noreturn kernel_thread_helper(void *arg, int (*fn)(void *))
228{
229 do_exit(fn(arg));
230}
231
232long kernel_thread(int (*fn)(void *), void *arg, unsigned long flags)
233{
234 struct pt_regs regs;
235
236 memset(&regs, 0, sizeof(regs));
237
238 regs.regs[4] = (unsigned long) arg;
239 regs.regs[5] = (unsigned long) fn;
240 regs.cp0_epc = (unsigned long) kernel_thread_helper;
241 regs.cp0_status = read_c0_status();
242#if defined(CONFIG_CPU_R3000) || defined(CONFIG_CPU_TX39XX)
243 regs.cp0_status = (regs.cp0_status & ~(ST0_KUP | ST0_IEP | ST0_IEC)) |
244 ((regs.cp0_status & (ST0_KUC | ST0_IEC)) << 2);
245#else
246 regs.cp0_status |= ST0_EXL;
247#endif
248
249 /* Ok, create the new process.. */
250 return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, &regs, 0, NULL, NULL);
251}
252
253/*
254 * 236 *
255 */ 237 */
256struct mips_frame_info { 238struct mips_frame_info {
diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
index f6ba8381ee0..d27ca340d46 100644
--- a/arch/mips/kernel/scall64-n32.S
+++ b/arch/mips/kernel/scall64-n32.S
@@ -167,7 +167,7 @@ EXPORT(sysn32_call_table)
167 PTR sys_getsockopt 167 PTR sys_getsockopt
168 PTR sys_clone /* 6055 */ 168 PTR sys_clone /* 6055 */
169 PTR sys_fork 169 PTR sys_fork
170 PTR sys32_execve 170 PTR compat_sys_execve
171 PTR sys_exit 171 PTR sys_exit
172 PTR compat_sys_wait4 172 PTR compat_sys_wait4
173 PTR sys_kill /* 6060 */ 173 PTR sys_kill /* 6060 */
diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S
index 53c2d724576..9601be6afa3 100644
--- a/arch/mips/kernel/scall64-o32.S
+++ b/arch/mips/kernel/scall64-o32.S
@@ -203,7 +203,7 @@ sys_call_table:
203 PTR sys_creat 203 PTR sys_creat
204 PTR sys_link 204 PTR sys_link
205 PTR sys_unlink /* 4010 */ 205 PTR sys_unlink /* 4010 */
206 PTR sys32_execve 206 PTR compat_sys_execve
207 PTR sys_chdir 207 PTR sys_chdir
208 PTR compat_sys_time 208 PTR compat_sys_time
209 PTR sys_mknod 209 PTR sys_mknod
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index a53f8ec37aa..290dc6a1d7a 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -79,7 +79,7 @@ static struct resource data_resource = { .name = "Kernel data", };
79void __init add_memory_region(phys_t start, phys_t size, long type) 79void __init add_memory_region(phys_t start, phys_t size, long type)
80{ 80{
81 int x = boot_mem_map.nr_map; 81 int x = boot_mem_map.nr_map;
82 struct boot_mem_map_entry *prev = boot_mem_map.map + x - 1; 82 int i;
83 83
84 /* Sanity check */ 84 /* Sanity check */
85 if (start + size < start) { 85 if (start + size < start) {
@@ -88,15 +88,29 @@ void __init add_memory_region(phys_t start, phys_t size, long type)
88 } 88 }
89 89
90 /* 90 /*
91 * Try to merge with previous entry if any. This is far less than 91 * Try to merge with existing entry, if any.
92 * perfect but is sufficient for most real world cases.
93 */ 92 */
94 if (x && prev->addr + prev->size == start && prev->type == type) { 93 for (i = 0; i < boot_mem_map.nr_map; i++) {
95 prev->size += size; 94 struct boot_mem_map_entry *entry = boot_mem_map.map + i;
95 unsigned long top;
96
97 if (entry->type != type)
98 continue;
99
100 if (start + size < entry->addr)
101 continue; /* no overlap */
102
103 if (entry->addr + entry->size < start)
104 continue; /* no overlap */
105
106 top = max(entry->addr + entry->size, start + size);
107 entry->addr = min(entry->addr, start);
108 entry->size = top - entry->addr;
109
96 return; 110 return;
97 } 111 }
98 112
99 if (x == BOOT_MEM_MAP_MAX) { 113 if (boot_mem_map.nr_map == BOOT_MEM_MAP_MAX) {
100 pr_err("Ooops! Too many entries in the memory map!\n"); 114 pr_err("Ooops! Too many entries in the memory map!\n");
101 return; 115 return;
102 } 116 }
diff --git a/arch/mips/kernel/smp-cmp.c b/arch/mips/kernel/smp-cmp.c
index afc379ca375..06cd0c610f4 100644
--- a/arch/mips/kernel/smp-cmp.c
+++ b/arch/mips/kernel/smp-cmp.c
@@ -97,7 +97,7 @@ static void cmp_init_secondary(void)
97 97
98 /* Enable per-cpu interrupts: platform specific */ 98 /* Enable per-cpu interrupts: platform specific */
99 99
100 c->core = (read_c0_ebase() >> 1) & 0xff; 100 c->core = (read_c0_ebase() >> 1) & 0x1ff;
101#if defined(CONFIG_MIPS_MT_SMP) || defined(CONFIG_MIPS_MT_SMTC) 101#if defined(CONFIG_MIPS_MT_SMP) || defined(CONFIG_MIPS_MT_SMTC)
102 c->vpe_id = (read_c0_tcbind() >> TCBIND_CURVPE_SHIFT) & TCBIND_CURVPE; 102 c->vpe_id = (read_c0_tcbind() >> TCBIND_CURVPE_SHIFT) & TCBIND_CURVPE;
103#endif 103#endif
diff --git a/arch/mips/kernel/syscall.c b/arch/mips/kernel/syscall.c
index 2bd561bc05a..c611e2df776 100644
--- a/arch/mips/kernel/syscall.c
+++ b/arch/mips/kernel/syscall.c
@@ -127,28 +127,6 @@ _sys_clone(nabi_no_regargs struct pt_regs regs)
127 parent_tidptr, child_tidptr); 127 parent_tidptr, child_tidptr);
128} 128}
129 129
130/*
131 * sys_execve() executes a new program.
132 */
133asmlinkage int sys_execve(nabi_no_regargs struct pt_regs regs)
134{
135 int error;
136 struct filename *filename;
137
138 filename = getname((const char __user *) (long)regs.regs[4]);
139 error = PTR_ERR(filename);
140 if (IS_ERR(filename))
141 goto out;
142 error = do_execve(filename->name,
143 (const char __user *const __user *) (long)regs.regs[5],
144 (const char __user *const __user *) (long)regs.regs[6],
145 &regs);
146 putname(filename);
147
148out:
149 return error;
150}
151
152SYSCALL_DEFINE1(set_thread_area, unsigned long, addr) 130SYSCALL_DEFINE1(set_thread_area, unsigned long, addr)
153{ 131{
154 struct thread_info *ti = task_thread_info(current); 132 struct thread_info *ti = task_thread_info(current);
@@ -313,34 +291,3 @@ asmlinkage void bad_stack(void)
313{ 291{
314 do_exit(SIGSEGV); 292 do_exit(SIGSEGV);
315} 293}
316
317/*
318 * Do a system call from kernel instead of calling sys_execve so we
319 * end up with proper pt_regs.
320 */
321int kernel_execve(const char *filename,
322 const char *const argv[],
323 const char *const envp[])
324{
325 register unsigned long __a0 asm("$4") = (unsigned long) filename;
326 register unsigned long __a1 asm("$5") = (unsigned long) argv;
327 register unsigned long __a2 asm("$6") = (unsigned long) envp;
328 register unsigned long __a3 asm("$7");
329 unsigned long __v0;
330
331 __asm__ volatile (" \n"
332 " .set noreorder \n"
333 " li $2, %5 # __NR_execve \n"
334 " syscall \n"
335 " move %0, $2 \n"
336 " .set reorder \n"
337 : "=&r" (__v0), "=r" (__a3)
338 : "r" (__a0), "r" (__a1), "r" (__a2), "i" (__NR_execve)
339 : "$2", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15", "$24",
340 "memory");
341
342 if (__a3 == 0)
343 return __v0;
344
345 return -__v0;
346}
diff --git a/arch/mips/lib/Makefile b/arch/mips/lib/Makefile
index c4a82e841c7..eeddc58802e 100644
--- a/arch/mips/lib/Makefile
+++ b/arch/mips/lib/Makefile
@@ -2,8 +2,9 @@
2# Makefile for MIPS-specific library files.. 2# Makefile for MIPS-specific library files..
3# 3#
4 4
5lib-y += csum_partial.o delay.o memcpy.o memset.o \ 5lib-y += bitops.o csum_partial.o delay.o memcpy.o memset.o \
6 strlen_user.o strncpy_user.o strnlen_user.o uncached.o 6 mips-atomic.o strlen_user.o strncpy_user.o \
7 strnlen_user.o uncached.o
7 8
8obj-y += iomap.o 9obj-y += iomap.o
9obj-$(CONFIG_PCI) += iomap-pci.o 10obj-$(CONFIG_PCI) += iomap-pci.o
diff --git a/arch/mips/lib/bitops.c b/arch/mips/lib/bitops.c
new file mode 100644
index 00000000000..239a9c957b0
--- /dev/null
+++ b/arch/mips/lib/bitops.c
@@ -0,0 +1,179 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (c) 1994-1997, 99, 2000, 06, 07 Ralf Baechle (ralf@linux-mips.org)
7 * Copyright (c) 1999, 2000 Silicon Graphics, Inc.
8 */
9#include <linux/bitops.h>
10#include <linux/irqflags.h>
11#include <linux/export.h>
12
13
14/**
15 * __mips_set_bit - Atomically set a bit in memory. This is called by
16 * set_bit() if it cannot find a faster solution.
17 * @nr: the bit to set
18 * @addr: the address to start counting from
19 */
20void __mips_set_bit(unsigned long nr, volatile unsigned long *addr)
21{
22 volatile unsigned long *a = addr;
23 unsigned bit = nr & SZLONG_MASK;
24 unsigned long mask;
25 unsigned long flags;
26
27 a += nr >> SZLONG_LOG;
28 mask = 1UL << bit;
29 raw_local_irq_save(flags);
30 *a |= mask;
31 raw_local_irq_restore(flags);
32}
33EXPORT_SYMBOL(__mips_set_bit);
34
35
36/**
37 * __mips_clear_bit - Clears a bit in memory. This is called by clear_bit() if
38 * it cannot find a faster solution.
39 * @nr: Bit to clear
40 * @addr: Address to start counting from
41 */
42void __mips_clear_bit(unsigned long nr, volatile unsigned long *addr)
43{
44 volatile unsigned long *a = addr;
45 unsigned bit = nr & SZLONG_MASK;
46 unsigned long mask;
47 unsigned long flags;
48
49 a += nr >> SZLONG_LOG;
50 mask = 1UL << bit;
51 raw_local_irq_save(flags);
52 *a &= ~mask;
53 raw_local_irq_restore(flags);
54}
55EXPORT_SYMBOL(__mips_clear_bit);
56
57
58/**
59 * __mips_change_bit - Toggle a bit in memory. This is called by change_bit()
60 * if it cannot find a faster solution.
61 * @nr: Bit to change
62 * @addr: Address to start counting from
63 */
64void __mips_change_bit(unsigned long nr, volatile unsigned long *addr)
65{
66 volatile unsigned long *a = addr;
67 unsigned bit = nr & SZLONG_MASK;
68 unsigned long mask;
69 unsigned long flags;
70
71 a += nr >> SZLONG_LOG;
72 mask = 1UL << bit;
73 raw_local_irq_save(flags);
74 *a ^= mask;
75 raw_local_irq_restore(flags);
76}
77EXPORT_SYMBOL(__mips_change_bit);
78
79
80/**
81 * __mips_test_and_set_bit - Set a bit and return its old value. This is
82 * called by test_and_set_bit() if it cannot find a faster solution.
83 * @nr: Bit to set
84 * @addr: Address to count from
85 */
86int __mips_test_and_set_bit(unsigned long nr,
87 volatile unsigned long *addr)
88{
89 volatile unsigned long *a = addr;
90 unsigned bit = nr & SZLONG_MASK;
91 unsigned long mask;
92 unsigned long flags;
93 unsigned long res;
94
95 a += nr >> SZLONG_LOG;
96 mask = 1UL << bit;
97 raw_local_irq_save(flags);
98 res = (mask & *a);
99 *a |= mask;
100 raw_local_irq_restore(flags);
101 return res;
102}
103EXPORT_SYMBOL(__mips_test_and_set_bit);
104
105
106/**
107 * __mips_test_and_set_bit_lock - Set a bit and return its old value. This is
108 * called by test_and_set_bit_lock() if it cannot find a faster solution.
109 * @nr: Bit to set
110 * @addr: Address to count from
111 */
112int __mips_test_and_set_bit_lock(unsigned long nr,
113 volatile unsigned long *addr)
114{
115 volatile unsigned long *a = addr;
116 unsigned bit = nr & SZLONG_MASK;
117 unsigned long mask;
118 unsigned long flags;
119 unsigned long res;
120
121 a += nr >> SZLONG_LOG;
122 mask = 1UL << bit;
123 raw_local_irq_save(flags);
124 res = (mask & *a);
125 *a |= mask;
126 raw_local_irq_restore(flags);
127 return res;
128}
129EXPORT_SYMBOL(__mips_test_and_set_bit_lock);
130
131
132/**
133 * __mips_test_and_clear_bit - Clear a bit and return its old value. This is
134 * called by test_and_clear_bit() if it cannot find a faster solution.
135 * @nr: Bit to clear
136 * @addr: Address to count from
137 */
138int __mips_test_and_clear_bit(unsigned long nr, volatile unsigned long *addr)
139{
140 volatile unsigned long *a = addr;
141 unsigned bit = nr & SZLONG_MASK;
142 unsigned long mask;
143 unsigned long flags;
144 unsigned long res;
145
146 a += nr >> SZLONG_LOG;
147 mask = 1UL << bit;
148 raw_local_irq_save(flags);
149 res = (mask & *a);
150 *a &= ~mask;
151 raw_local_irq_restore(flags);
152 return res;
153}
154EXPORT_SYMBOL(__mips_test_and_clear_bit);
155
156
157/**
158 * __mips_test_and_change_bit - Change a bit and return its old value. This is
159 * called by test_and_change_bit() if it cannot find a faster solution.
160 * @nr: Bit to change
161 * @addr: Address to count from
162 */
163int __mips_test_and_change_bit(unsigned long nr, volatile unsigned long *addr)
164{
165 volatile unsigned long *a = addr;
166 unsigned bit = nr & SZLONG_MASK;
167 unsigned long mask;
168 unsigned long flags;
169 unsigned long res;
170
171 a += nr >> SZLONG_LOG;
172 mask = 1UL << bit;
173 raw_local_irq_save(flags);
174 res = (mask & *a);
175 *a ^= mask;
176 raw_local_irq_restore(flags);
177 return res;
178}
179EXPORT_SYMBOL(__mips_test_and_change_bit);
diff --git a/arch/mips/lib/delay.c b/arch/mips/lib/delay.c
index 5995969e8c4..dc81ca8dc0d 100644
--- a/arch/mips/lib/delay.c
+++ b/arch/mips/lib/delay.c
@@ -15,13 +15,17 @@
15#include <asm/compiler.h> 15#include <asm/compiler.h>
16#include <asm/war.h> 16#include <asm/war.h>
17 17
18inline void __delay(unsigned int loops) 18void __delay(unsigned long loops)
19{ 19{
20 __asm__ __volatile__ ( 20 __asm__ __volatile__ (
21 " .set noreorder \n" 21 " .set noreorder \n"
22 " .align 3 \n" 22 " .align 3 \n"
23 "1: bnez %0, 1b \n" 23 "1: bnez %0, 1b \n"
24#if __SIZEOF_LONG__ == 4
24 " subu %0, 1 \n" 25 " subu %0, 1 \n"
26#else
27 " dsubu %0, 1 \n"
28#endif
25 " .set reorder \n" 29 " .set reorder \n"
26 : "=r" (loops) 30 : "=r" (loops)
27 : "0" (loops)); 31 : "0" (loops));
diff --git a/arch/mips/lib/dump_tlb.c b/arch/mips/lib/dump_tlb.c
index 3f69725556a..a99c1d3fc56 100644
--- a/arch/mips/lib/dump_tlb.c
+++ b/arch/mips/lib/dump_tlb.c
@@ -50,8 +50,9 @@ static void dump_tlb(int first, int last)
50{ 50{
51 unsigned long s_entryhi, entryhi, asid; 51 unsigned long s_entryhi, entryhi, asid;
52 unsigned long long entrylo0, entrylo1; 52 unsigned long long entrylo0, entrylo1;
53 unsigned int s_index, pagemask, c0, c1, i; 53 unsigned int s_index, s_pagemask, pagemask, c0, c1, i;
54 54
55 s_pagemask = read_c0_pagemask();
55 s_entryhi = read_c0_entryhi(); 56 s_entryhi = read_c0_entryhi();
56 s_index = read_c0_index(); 57 s_index = read_c0_index();
57 asid = s_entryhi & 0xff; 58 asid = s_entryhi & 0xff;
@@ -103,6 +104,7 @@ static void dump_tlb(int first, int last)
103 104
104 write_c0_entryhi(s_entryhi); 105 write_c0_entryhi(s_entryhi);
105 write_c0_index(s_index); 106 write_c0_index(s_index);
107 write_c0_pagemask(s_pagemask);
106} 108}
107 109
108void dump_tlb_all(void) 110void dump_tlb_all(void)
diff --git a/arch/mips/lib/mips-atomic.c b/arch/mips/lib/mips-atomic.c
new file mode 100644
index 00000000000..cd160be3ce4
--- /dev/null
+++ b/arch/mips/lib/mips-atomic.c
@@ -0,0 +1,176 @@
1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1994, 95, 96, 97, 98, 99, 2003 by Ralf Baechle
7 * Copyright (C) 1996 by Paul M. Antoine
8 * Copyright (C) 1999 Silicon Graphics
9 * Copyright (C) 2000 MIPS Technologies, Inc.
10 */
11#include <asm/irqflags.h>
12#include <asm/hazards.h>
13#include <linux/compiler.h>
14#include <linux/preempt.h>
15#include <linux/export.h>
16
17#if !defined(CONFIG_CPU_MIPSR2) || defined(CONFIG_MIPS_MT_SMTC)
18
19/*
20 * For cli() we have to insert nops to make sure that the new value
21 * has actually arrived in the status register before the end of this
22 * macro.
23 * R4000/R4400 need three nops, the R4600 two nops and the R10000 needs
24 * no nops at all.
25 */
26/*
27 * For TX49, operating only IE bit is not enough.
28 *
29 * If mfc0 $12 follows store and the mfc0 is last instruction of a
30 * page and fetching the next instruction causes TLB miss, the result
31 * of the mfc0 might wrongly contain EXL bit.
32 *
33 * ERT-TX49H2-027, ERT-TX49H3-012, ERT-TX49HL3-006, ERT-TX49H4-008
34 *
35 * Workaround: mask EXL bit of the result or place a nop before mfc0.
36 */
37__asm__(
38 " .macro arch_local_irq_disable\n"
39 " .set push \n"
40 " .set noat \n"
41#ifdef CONFIG_MIPS_MT_SMTC
42 " mfc0 $1, $2, 1 \n"
43 " ori $1, 0x400 \n"
44 " .set noreorder \n"
45 " mtc0 $1, $2, 1 \n"
46#elif defined(CONFIG_CPU_MIPSR2)
47 /* see irqflags.h for inline function */
48#else
49 " mfc0 $1,$12 \n"
50 " ori $1,0x1f \n"
51 " xori $1,0x1f \n"
52 " .set noreorder \n"
53 " mtc0 $1,$12 \n"
54#endif
55 " irq_disable_hazard \n"
56 " .set pop \n"
57 " .endm \n");
58
59notrace void arch_local_irq_disable(void)
60{
61 preempt_disable();
62 __asm__ __volatile__(
63 "arch_local_irq_disable"
64 : /* no outputs */
65 : /* no inputs */
66 : "memory");
67 preempt_enable();
68}
69EXPORT_SYMBOL(arch_local_irq_disable);
70
71
72__asm__(
73 " .macro arch_local_irq_save result \n"
74 " .set push \n"
75 " .set reorder \n"
76 " .set noat \n"
77#ifdef CONFIG_MIPS_MT_SMTC
78 " mfc0 \\result, $2, 1 \n"
79 " ori $1, \\result, 0x400 \n"
80 " .set noreorder \n"
81 " mtc0 $1, $2, 1 \n"
82 " andi \\result, \\result, 0x400 \n"
83#elif defined(CONFIG_CPU_MIPSR2)
84 /* see irqflags.h for inline function */
85#else
86 " mfc0 \\result, $12 \n"
87 " ori $1, \\result, 0x1f \n"
88 " xori $1, 0x1f \n"
89 " .set noreorder \n"
90 " mtc0 $1, $12 \n"
91#endif
92 " irq_disable_hazard \n"
93 " .set pop \n"
94 " .endm \n");
95
96notrace unsigned long arch_local_irq_save(void)
97{
98 unsigned long flags;
99 preempt_disable();
100 asm volatile("arch_local_irq_save\t%0"
101 : "=r" (flags)
102 : /* no inputs */
103 : "memory");
104 preempt_enable();
105 return flags;
106}
107EXPORT_SYMBOL(arch_local_irq_save);
108
109
110__asm__(
111 " .macro arch_local_irq_restore flags \n"
112 " .set push \n"
113 " .set noreorder \n"
114 " .set noat \n"
115#ifdef CONFIG_MIPS_MT_SMTC
116 "mfc0 $1, $2, 1 \n"
117 "andi \\flags, 0x400 \n"
118 "ori $1, 0x400 \n"
119 "xori $1, 0x400 \n"
120 "or \\flags, $1 \n"
121 "mtc0 \\flags, $2, 1 \n"
122#elif defined(CONFIG_CPU_MIPSR2) && defined(CONFIG_IRQ_CPU)
123 /* see irqflags.h for inline function */
124#elif defined(CONFIG_CPU_MIPSR2)
125 /* see irqflags.h for inline function */
126#else
127 " mfc0 $1, $12 \n"
128 " andi \\flags, 1 \n"
129 " ori $1, 0x1f \n"
130 " xori $1, 0x1f \n"
131 " or \\flags, $1 \n"
132 " mtc0 \\flags, $12 \n"
133#endif
134 " irq_disable_hazard \n"
135 " .set pop \n"
136 " .endm \n");
137
138notrace void arch_local_irq_restore(unsigned long flags)
139{
140 unsigned long __tmp1;
141
142#ifdef CONFIG_MIPS_MT_SMTC
143 /*
144 * SMTC kernel needs to do a software replay of queued
145 * IPIs, at the cost of branch and call overhead on each
146 * local_irq_restore()
147 */
148 if (unlikely(!(flags & 0x0400)))
149 smtc_ipi_replay();
150#endif
151 preempt_disable();
152 __asm__ __volatile__(
153 "arch_local_irq_restore\t%0"
154 : "=r" (__tmp1)
155 : "0" (flags)
156 : "memory");
157 preempt_enable();
158}
159EXPORT_SYMBOL(arch_local_irq_restore);
160
161
162notrace void __arch_local_irq_restore(unsigned long flags)
163{
164 unsigned long __tmp1;
165
166 preempt_disable();
167 __asm__ __volatile__(
168 "arch_local_irq_restore\t%0"
169 : "=r" (__tmp1)
170 : "0" (flags)
171 : "memory");
172 preempt_enable();
173}
174EXPORT_SYMBOL(__arch_local_irq_restore);
175
176#endif /* !defined(CONFIG_CPU_MIPSR2) || defined(CONFIG_MIPS_MT_SMTC) */
diff --git a/arch/mips/mm/tlb-r4k.c b/arch/mips/mm/tlb-r4k.c
index 87b9cfcc30f..4b9b935a070 100644
--- a/arch/mips/mm/tlb-r4k.c
+++ b/arch/mips/mm/tlb-r4k.c
@@ -320,6 +320,7 @@ void __update_tlb(struct vm_area_struct * vma, unsigned long address, pte_t pte)
320 tlb_write_random(); 320 tlb_write_random();
321 else 321 else
322 tlb_write_indexed(); 322 tlb_write_indexed();
323 tlbw_use_hazard();
323 write_c0_pagemask(PM_DEFAULT_MASK); 324 write_c0_pagemask(PM_DEFAULT_MASK);
324 } else 325 } else
325#endif 326#endif
diff --git a/arch/mips/mm/tlbex.c b/arch/mips/mm/tlbex.c
index 658a520364c..2833dcb67b5 100644
--- a/arch/mips/mm/tlbex.c
+++ b/arch/mips/mm/tlbex.c
@@ -148,8 +148,8 @@ enum label_id {
148 label_leave, 148 label_leave,
149 label_vmalloc, 149 label_vmalloc,
150 label_vmalloc_done, 150 label_vmalloc_done,
151 label_tlbw_hazard, 151 label_tlbw_hazard_0,
152 label_split, 152 label_split = label_tlbw_hazard_0 + 8,
153 label_tlbl_goaround1, 153 label_tlbl_goaround1,
154 label_tlbl_goaround2, 154 label_tlbl_goaround2,
155 label_nopage_tlbl, 155 label_nopage_tlbl,
@@ -167,7 +167,7 @@ UASM_L_LA(_second_part)
167UASM_L_LA(_leave) 167UASM_L_LA(_leave)
168UASM_L_LA(_vmalloc) 168UASM_L_LA(_vmalloc)
169UASM_L_LA(_vmalloc_done) 169UASM_L_LA(_vmalloc_done)
170UASM_L_LA(_tlbw_hazard) 170/* _tlbw_hazard_x is handled differently. */
171UASM_L_LA(_split) 171UASM_L_LA(_split)
172UASM_L_LA(_tlbl_goaround1) 172UASM_L_LA(_tlbl_goaround1)
173UASM_L_LA(_tlbl_goaround2) 173UASM_L_LA(_tlbl_goaround2)
@@ -181,6 +181,30 @@ UASM_L_LA(_large_segbits_fault)
181UASM_L_LA(_tlb_huge_update) 181UASM_L_LA(_tlb_huge_update)
182#endif 182#endif
183 183
184static int __cpuinitdata hazard_instance;
185
186static void uasm_bgezl_hazard(u32 **p, struct uasm_reloc **r, int instance)
187{
188 switch (instance) {
189 case 0 ... 7:
190 uasm_il_bgezl(p, r, 0, label_tlbw_hazard_0 + instance);
191 return;
192 default:
193 BUG();
194 }
195}
196
197static void uasm_bgezl_label(struct uasm_label **l, u32 **p, int instance)
198{
199 switch (instance) {
200 case 0 ... 7:
201 uasm_build_label(l, *p, label_tlbw_hazard_0 + instance);
202 break;
203 default:
204 BUG();
205 }
206}
207
184/* 208/*
185 * For debug purposes. 209 * For debug purposes.
186 */ 210 */
@@ -478,21 +502,28 @@ static void __cpuinit build_tlb_write_entry(u32 **p, struct uasm_label **l,
478 * This branch uses up a mtc0 hazard nop slot and saves 502 * This branch uses up a mtc0 hazard nop slot and saves
479 * two nops after the tlbw instruction. 503 * two nops after the tlbw instruction.
480 */ 504 */
481 uasm_il_bgezl(p, r, 0, label_tlbw_hazard); 505 uasm_bgezl_hazard(p, r, hazard_instance);
482 tlbw(p); 506 tlbw(p);
483 uasm_l_tlbw_hazard(l, *p); 507 uasm_bgezl_label(l, p, hazard_instance);
508 hazard_instance++;
484 uasm_i_nop(p); 509 uasm_i_nop(p);
485 break; 510 break;
486 511
487 case CPU_R4600: 512 case CPU_R4600:
488 case CPU_R4700: 513 case CPU_R4700:
489 case CPU_R5000:
490 case CPU_R5000A:
491 uasm_i_nop(p); 514 uasm_i_nop(p);
492 tlbw(p); 515 tlbw(p);
493 uasm_i_nop(p); 516 uasm_i_nop(p);
494 break; 517 break;
495 518
519 case CPU_R5000:
520 case CPU_R5000A:
521 case CPU_NEVADA:
522 uasm_i_nop(p); /* QED specifies 2 nops hazard */
523 uasm_i_nop(p); /* QED specifies 2 nops hazard */
524 tlbw(p);
525 break;
526
496 case CPU_R4300: 527 case CPU_R4300:
497 case CPU_5KC: 528 case CPU_5KC:
498 case CPU_TX49XX: 529 case CPU_TX49XX:
@@ -526,17 +557,6 @@ static void __cpuinit build_tlb_write_entry(u32 **p, struct uasm_label **l,
526 tlbw(p); 557 tlbw(p);
527 break; 558 break;
528 559
529 case CPU_NEVADA:
530 uasm_i_nop(p); /* QED specifies 2 nops hazard */
531 /*
532 * This branch uses up a mtc0 hazard nop slot and saves
533 * a nop after the tlbw instruction.
534 */
535 uasm_il_bgezl(p, r, 0, label_tlbw_hazard);
536 tlbw(p);
537 uasm_l_tlbw_hazard(l, *p);
538 break;
539
540 case CPU_RM7000: 560 case CPU_RM7000:
541 uasm_i_nop(p); 561 uasm_i_nop(p);
542 uasm_i_nop(p); 562 uasm_i_nop(p);
diff --git a/arch/mips/mti-malta/malta-platform.c b/arch/mips/mti-malta/malta-platform.c
index 80562b81f0f..74732177851 100644
--- a/arch/mips/mti-malta/malta-platform.c
+++ b/arch/mips/mti-malta/malta-platform.c
@@ -29,6 +29,7 @@
29#include <linux/mtd/partitions.h> 29#include <linux/mtd/partitions.h>
30#include <linux/mtd/physmap.h> 30#include <linux/mtd/physmap.h>
31#include <linux/platform_device.h> 31#include <linux/platform_device.h>
32#include <asm/mips-boards/maltaint.h>
32#include <mtd/mtd-abi.h> 33#include <mtd/mtd-abi.h>
33 34
34#define SMC_PORT(base, int) \ 35#define SMC_PORT(base, int) \
@@ -48,7 +49,7 @@ static struct plat_serial8250_port uart8250_data[] = {
48 SMC_PORT(0x2F8, 3), 49 SMC_PORT(0x2F8, 3),
49 { 50 {
50 .mapbase = 0x1f000900, /* The CBUS UART */ 51 .mapbase = 0x1f000900, /* The CBUS UART */
51 .irq = MIPS_CPU_IRQ_BASE + 2, 52 .irq = MIPS_CPU_IRQ_BASE + MIPSCPU_INT_MB2,
52 .uartclk = 3686400, /* Twice the usual clk! */ 53 .uartclk = 3686400, /* Twice the usual clk! */
53 .iotype = UPIO_MEM32, 54 .iotype = UPIO_MEM32,
54 .flags = CBUS_UART_FLAGS, 55 .flags = CBUS_UART_FLAGS,
diff --git a/arch/mn10300/Kconfig b/arch/mn10300/Kconfig
index 04669fac117..72471744a91 100644
--- a/arch/mn10300/Kconfig
+++ b/arch/mn10300/Kconfig
@@ -9,6 +9,7 @@ config MN10300
9 select HAVE_NMI_WATCHDOG if MN10300_WD_TIMER 9 select HAVE_NMI_WATCHDOG if MN10300_WD_TIMER
10 select GENERIC_CLOCKEVENTS 10 select GENERIC_CLOCKEVENTS
11 select GENERIC_KERNEL_THREAD 11 select GENERIC_KERNEL_THREAD
12 select GENERIC_KERNEL_EXECVE
12 select MODULES_USE_ELF_RELA 13 select MODULES_USE_ELF_RELA
13 14
14config AM33_2 15config AM33_2
diff --git a/arch/mn10300/include/asm/unistd.h b/arch/mn10300/include/asm/unistd.h
index 55bbec1887e..9711d51b021 100644
--- a/arch/mn10300/include/asm/unistd.h
+++ b/arch/mn10300/include/asm/unistd.h
@@ -44,7 +44,6 @@
44#define __ARCH_WANT_SYS_RT_SIGACTION 44#define __ARCH_WANT_SYS_RT_SIGACTION
45#define __ARCH_WANT_SYS_RT_SIGSUSPEND 45#define __ARCH_WANT_SYS_RT_SIGSUSPEND
46#define __ARCH_WANT_SYS_EXECVE 46#define __ARCH_WANT_SYS_EXECVE
47#define __ARCH_WANT_KERNEL_EXECVE
48 47
49/* 48/*
50 * "Conditional" syscalls 49 * "Conditional" syscalls
diff --git a/arch/mn10300/include/uapi/asm/setup.h b/arch/mn10300/include/uapi/asm/setup.h
index e69de29bb2d..ae5704fa77a 100644
--- a/arch/mn10300/include/uapi/asm/setup.h
+++ b/arch/mn10300/include/uapi/asm/setup.h
@@ -0,0 +1,4 @@
1/*
2 * There isn't anything here anymore, but the file must not be empty or patch
3 * will delete it.
4 */
diff --git a/arch/mn10300/kernel/entry.S b/arch/mn10300/kernel/entry.S
index 0c631d34c8d..68fcab8f8f6 100644
--- a/arch/mn10300/kernel/entry.S
+++ b/arch/mn10300/kernel/entry.S
@@ -60,13 +60,8 @@ ENTRY(ret_from_kernel_thread)
60 mov (REG_D0,fp),d0 60 mov (REG_D0,fp),d0
61 mov (REG_A0,fp),a0 61 mov (REG_A0,fp),a0
62 calls (a0) 62 calls (a0)
63 jmp sys_exit
64
65ENTRY(ret_from_kernel_execve)
66 add -12,d0 /* pt_regs -> frame */
67 mov d0,sp
68 GET_THREAD_INFO a2
69 clr d0 63 clr d0
64 mov d0,(REG_D0,fp)
70 jmp syscall_exit 65 jmp syscall_exit
71 66
72############################################################################### 67###############################################################################
diff --git a/arch/openrisc/Kconfig b/arch/openrisc/Kconfig
index 05f2ba41ff1..e7f1a2993f7 100644
--- a/arch/openrisc/Kconfig
+++ b/arch/openrisc/Kconfig
@@ -22,6 +22,8 @@ config OPENRISC
22 select GENERIC_STRNCPY_FROM_USER 22 select GENERIC_STRNCPY_FROM_USER
23 select GENERIC_STRNLEN_USER 23 select GENERIC_STRNLEN_USER
24 select MODULES_USE_ELF_RELA 24 select MODULES_USE_ELF_RELA
25 select GENERIC_KERNEL_THREAD
26 select GENERIC_KERNEL_EXECVE
25 27
26config MMU 28config MMU
27 def_bool y 29 def_bool y
diff --git a/arch/openrisc/include/uapi/asm/unistd.h b/arch/openrisc/include/uapi/asm/unistd.h
index 437bdbb61b1..5db7bc0fa5a 100644
--- a/arch/openrisc/include/uapi/asm/unistd.h
+++ b/arch/openrisc/include/uapi/asm/unistd.h
@@ -20,6 +20,8 @@
20 20
21#define sys_mmap2 sys_mmap_pgoff 21#define sys_mmap2 sys_mmap_pgoff
22 22
23#define __ARCH_WANT_SYS_EXECVE
24
23#include <asm-generic/unistd.h> 25#include <asm-generic/unistd.h>
24 26
25#define __NR_or1k_atomic __NR_arch_specific_syscall 27#define __NR_or1k_atomic __NR_arch_specific_syscall
diff --git a/arch/openrisc/kernel/entry.S b/arch/openrisc/kernel/entry.S
index ddfcaa828b0..c60a09df323 100644
--- a/arch/openrisc/kernel/entry.S
+++ b/arch/openrisc/kernel/entry.S
@@ -894,6 +894,16 @@ ENTRY(ret_from_fork)
894 l.jal schedule_tail 894 l.jal schedule_tail
895 l.nop 895 l.nop
896 896
897 /* Check if we are a kernel thread */
898 l.sfeqi r20,0
899 l.bf 1f
900 l.nop
901
902 /* ...we are a kernel thread so invoke the requested callback */
903 l.jalr r20
904 l.or r3,r22,r0
905
9061:
897 /* _syscall_returns expect r11 to contain return value */ 907 /* _syscall_returns expect r11 to contain return value */
898 l.lwz r11,PT_GPR11(r1) 908 l.lwz r11,PT_GPR11(r1)
899 909
@@ -915,26 +925,6 @@ ENTRY(ret_from_fork)
915 l.j _syscall_return 925 l.j _syscall_return
916 l.nop 926 l.nop
917 927
918/* Since syscalls don't save call-clobbered registers, the args to
919 * kernel_thread_helper will need to be passed through callee-saved
920 * registers and copied to the parameter registers when the thread
921 * begins running.
922 *
923 * See arch/openrisc/kernel/process.c:
924 * The args are passed as follows:
925 * arg1 (r3) : passed in r20
926 * arg2 (r4) : passed in r22
927 */
928
929ENTRY(_kernel_thread_helper)
930 l.or r3,r20,r0
931 l.or r4,r22,r0
932 l.movhi r31,hi(kernel_thread_helper)
933 l.ori r31,r31,lo(kernel_thread_helper)
934 l.jr r31
935 l.nop
936
937
938/* ========================================================[ switch ] === */ 928/* ========================================================[ switch ] === */
939 929
940/* 930/*
@@ -1044,8 +1034,13 @@ ENTRY(_switch)
1044 /* Unwind stack to pre-switch state */ 1034 /* Unwind stack to pre-switch state */
1045 l.addi r1,r1,(INT_FRAME_SIZE) 1035 l.addi r1,r1,(INT_FRAME_SIZE)
1046 1036
1047 /* Return via the link-register back to where we 'came from', where that can be 1037 /* Return via the link-register back to where we 'came from', where
1048 * either schedule() or return_from_fork()... */ 1038 * that may be either schedule(), ret_from_fork(), or
1039 * ret_from_kernel_thread(). If we are returning to a new thread,
1040 * we are expected to have set up the arg to schedule_tail already,
1041 * hence we do so here unconditionally:
1042 */
1043 l.lwz r3,TI_STACK(r3) /* Load 'prev' as schedule_tail arg */
1049 l.jr r9 1044 l.jr r9
1050 l.nop 1045 l.nop
1051 1046
@@ -1088,10 +1083,6 @@ ENTRY(sys_fork)
1088 l.j _fork_save_extra_regs_and_call 1083 l.j _fork_save_extra_regs_and_call
1089 l.addi r3,r1,0 1084 l.addi r3,r1,0
1090 1085
1091ENTRY(sys_execve)
1092 l.j _sys_execve
1093 l.addi r6,r1,0
1094
1095ENTRY(sys_sigaltstack) 1086ENTRY(sys_sigaltstack)
1096 l.j _sys_sigaltstack 1087 l.j _sys_sigaltstack
1097 l.addi r5,r1,0 1088 l.addi r5,r1,0
diff --git a/arch/openrisc/kernel/process.c b/arch/openrisc/kernel/process.c
index c35f3ab1a8d..e0874b8e09e 100644
--- a/arch/openrisc/kernel/process.c
+++ b/arch/openrisc/kernel/process.c
@@ -109,66 +109,82 @@ void release_thread(struct task_struct *dead_task)
109 */ 109 */
110extern asmlinkage void ret_from_fork(void); 110extern asmlinkage void ret_from_fork(void);
111 111
112/*
113 * copy_thread
114 * @clone_flags: flags
115 * @usp: user stack pointer or fn for kernel thread
116 * @arg: arg to fn for kernel thread; always NULL for userspace thread
117 * @p: the newly created task
118 * @regs: CPU context to copy for userspace thread; always NULL for kthread
119 *
120 * At the top of a newly initialized kernel stack are two stacked pt_reg
121 * structures. The first (topmost) is the userspace context of the thread.
122 * The second is the kernelspace context of the thread.
123 *
124 * A kernel thread will not be returning to userspace, so the topmost pt_regs
125 * struct can be uninitialized; it _does_ need to exist, though, because
126 * a kernel thread can become a userspace thread by doing a kernel_execve, in
127 * which case the topmost context will be initialized and used for 'returning'
128 * to userspace.
129 *
130 * The second pt_reg struct needs to be initialized to 'return' to
131 * ret_from_fork. A kernel thread will need to set r20 to the address of
132 * a function to call into (with arg in r22); userspace threads need to set
133 * r20 to NULL in which case ret_from_fork will just continue a return to
134 * userspace.
135 *
136 * A kernel thread 'fn' may return; this is effectively what happens when
137 * kernel_execve is called. In that case, the userspace pt_regs must have
138 * been initialized (which kernel_execve takes care of, see start_thread
139 * below); ret_from_fork will then continue its execution causing the
140 * 'kernel thread' to return to userspace as a userspace thread.
141 */
142
112int 143int
113copy_thread(unsigned long clone_flags, unsigned long usp, 144copy_thread(unsigned long clone_flags, unsigned long usp,
114 unsigned long unused, struct task_struct *p, struct pt_regs *regs) 145 unsigned long arg, struct task_struct *p, struct pt_regs *regs)
115{ 146{
116 struct pt_regs *childregs; 147 struct pt_regs *userregs;
117 struct pt_regs *kregs; 148 struct pt_regs *kregs;
118 unsigned long sp = (unsigned long)task_stack_page(p) + THREAD_SIZE; 149 unsigned long sp = (unsigned long)task_stack_page(p) + THREAD_SIZE;
119 struct thread_info *ti;
120 unsigned long top_of_kernel_stack; 150 unsigned long top_of_kernel_stack;
121 151
122 top_of_kernel_stack = sp; 152 top_of_kernel_stack = sp;
123 153
124 p->set_child_tid = p->clear_child_tid = NULL; 154 p->set_child_tid = p->clear_child_tid = NULL;
125 155
126 /* Copy registers */ 156 /* Locate userspace context on stack... */
127 /* redzone */ 157 sp -= STACK_FRAME_OVERHEAD; /* redzone */
128 sp -= STACK_FRAME_OVERHEAD;
129 sp -= sizeof(struct pt_regs); 158 sp -= sizeof(struct pt_regs);
130 childregs = (struct pt_regs *)sp; 159 userregs = (struct pt_regs *) sp;
131 160
132 /* Copy parent registers */ 161 /* ...and kernel context */
133 *childregs = *regs; 162 sp -= STACK_FRAME_OVERHEAD; /* redzone */
163 sp -= sizeof(struct pt_regs);
164 kregs = (struct pt_regs *)sp;
134 165
135 if ((childregs->sr & SPR_SR_SM) == 1) { 166 if (unlikely(p->flags & PF_KTHREAD)) {
136 /* for kernel thread, set `current_thread_info' 167 memset(kregs, 0, sizeof(struct pt_regs));
137 * and stackptr in new task 168 kregs->gpr[20] = usp; /* fn, kernel thread */
138 */ 169 kregs->gpr[22] = arg;
139 childregs->sp = (unsigned long)task_stack_page(p) + THREAD_SIZE;
140 childregs->gpr[10] = (unsigned long)task_thread_info(p);
141 } else { 170 } else {
142 childregs->sp = usp; 171 *userregs = *regs;
143 }
144
145 childregs->gpr[11] = 0; /* Result from fork() */
146 172
147 /* 173 userregs->sp = usp;
148 * The way this works is that at some point in the future 174 userregs->gpr[11] = 0; /* Result from fork() */
149 * some task will call _switch to switch to the new task.
150 * That will pop off the stack frame created below and start
151 * the new task running at ret_from_fork. The new task will
152 * do some house keeping and then return from the fork or clone
153 * system call, using the stack frame created above.
154 */
155 /* redzone */
156 sp -= STACK_FRAME_OVERHEAD;
157 sp -= sizeof(struct pt_regs);
158 kregs = (struct pt_regs *)sp;
159 175
160 ti = task_thread_info(p); 176 kregs->gpr[20] = 0; /* Userspace thread */
161 ti->ksp = sp; 177 }
162 178
163 /* kregs->sp must store the location of the 'pre-switch' kernel stack 179 /*
164 * pointer... for a newly forked process, this is simply the top of 180 * _switch wants the kernel stack page in pt_regs->sp so that it
165 * the kernel stack. 181 * can restore it to thread_info->ksp... see _switch for details.
166 */ 182 */
167 kregs->sp = top_of_kernel_stack; 183 kregs->sp = top_of_kernel_stack;
168 kregs->gpr[3] = (unsigned long)current; /* arg to schedule_tail */
169 kregs->gpr[10] = (unsigned long)task_thread_info(p);
170 kregs->gpr[9] = (unsigned long)ret_from_fork; 184 kregs->gpr[9] = (unsigned long)ret_from_fork;
171 185
186 task_thread_info(p)->ksp = (unsigned long)kregs;
187
172 return 0; 188 return 0;
173} 189}
174 190
@@ -177,16 +193,14 @@ copy_thread(unsigned long clone_flags, unsigned long usp,
177 */ 193 */
178void start_thread(struct pt_regs *regs, unsigned long pc, unsigned long sp) 194void start_thread(struct pt_regs *regs, unsigned long pc, unsigned long sp)
179{ 195{
180 unsigned long sr = regs->sr & ~SPR_SR_SM; 196 unsigned long sr = mfspr(SPR_SR) & ~SPR_SR_SM;
181 197
182 set_fs(USER_DS); 198 set_fs(USER_DS);
183 memset(regs->gpr, 0, sizeof(regs->gpr)); 199 memset(regs, 0, sizeof(struct pt_regs));
184 200
185 regs->pc = pc; 201 regs->pc = pc;
186 regs->sr = sr; 202 regs->sr = sr;
187 regs->sp = sp; 203 regs->sp = sp;
188
189/* printk("start thread, ksp = %lx\n", current_thread_info()->ksp);*/
190} 204}
191 205
192/* Fill in the fpu structure for a core dump. */ 206/* Fill in the fpu structure for a core dump. */
@@ -237,74 +251,9 @@ void dump_elf_thread(elf_greg_t *dest, struct pt_regs* regs)
237 dest[35] = 0; 251 dest[35] = 0;
238} 252}
239 253
240extern void _kernel_thread_helper(void);
241
242void __noreturn kernel_thread_helper(int (*fn) (void *), void *arg)
243{
244 do_exit(fn(arg));
245}
246
247/*
248 * Create a kernel thread.
249 */
250int kernel_thread(int (*fn) (void *), void *arg, unsigned long flags)
251{
252 struct pt_regs regs;
253
254 memset(&regs, 0, sizeof(regs));
255
256 regs.gpr[20] = (unsigned long)fn;
257 regs.gpr[22] = (unsigned long)arg;
258 regs.sr = mfspr(SPR_SR);
259 regs.pc = (unsigned long)_kernel_thread_helper;
260
261 return do_fork(flags | CLONE_VM | CLONE_UNTRACED,
262 0, &regs, 0, NULL, NULL);
263}
264
265/*
266 * sys_execve() executes a new program.
267 */
268asmlinkage long _sys_execve(const char __user *name,
269 const char __user * const __user *argv,
270 const char __user * const __user *envp,
271 struct pt_regs *regs)
272{
273 int error;
274 struct filename *filename;
275
276 filename = getname(name);
277 error = PTR_ERR(filename);
278
279 if (IS_ERR(filename))
280 goto out;
281
282 error = do_execve(filename->name, argv, envp, regs);
283 putname(filename);
284
285out:
286 return error;
287}
288
289unsigned long get_wchan(struct task_struct *p) 254unsigned long get_wchan(struct task_struct *p)
290{ 255{
291 /* TODO */ 256 /* TODO */
292 257
293 return 0; 258 return 0;
294} 259}
295
296int kernel_execve(const char *filename, char *const argv[], char *const envp[])
297{
298 register long __res asm("r11") = __NR_execve;
299 register long __a asm("r3") = (long)(filename);
300 register long __b asm("r4") = (long)(argv);
301 register long __c asm("r5") = (long)(envp);
302 __asm__ volatile ("l.sys 1"
303 : "=r" (__res), "=r"(__a), "=r"(__b), "=r"(__c)
304 : "0"(__res), "1"(__a), "2"(__b), "3"(__c)
305 : "r6", "r7", "r8", "r12", "r13", "r15",
306 "r17", "r19", "r21", "r23", "r25", "r27",
307 "r29", "r31");
308 __asm__ volatile ("l.nop");
309 return __res;
310}
diff --git a/arch/openrisc/kernel/signal.c b/arch/openrisc/kernel/signal.c
index 30110297f4f..ddedc8a7786 100644
--- a/arch/openrisc/kernel/signal.c
+++ b/arch/openrisc/kernel/signal.c
@@ -84,7 +84,6 @@ asmlinkage long _sys_rt_sigreturn(struct pt_regs *regs)
84{ 84{
85 struct rt_sigframe *frame = (struct rt_sigframe __user *)regs->sp; 85 struct rt_sigframe *frame = (struct rt_sigframe __user *)regs->sp;
86 sigset_t set; 86 sigset_t set;
87 stack_t st;
88 87
89 /* 88 /*
90 * Since we stacked the signal on a dword boundary, 89 * Since we stacked the signal on a dword boundary,
@@ -104,11 +103,10 @@ asmlinkage long _sys_rt_sigreturn(struct pt_regs *regs)
104 if (restore_sigcontext(regs, &frame->uc.uc_mcontext)) 103 if (restore_sigcontext(regs, &frame->uc.uc_mcontext))
105 goto badframe; 104 goto badframe;
106 105
107 if (__copy_from_user(&st, &frame->uc.uc_stack, sizeof(st)))
108 goto badframe;
109 /* It is more difficult to avoid calling this function than to 106 /* It is more difficult to avoid calling this function than to
110 call it and ignore errors. */ 107 call it and ignore errors. */
111 do_sigaltstack(&st, NULL, regs->sp); 108 if (do_sigaltstack(&frame->uc.uc_stack, NULL, regs->sp) == -EFAULT)
109 goto badframe;
112 110
113 return regs->gpr[11]; 111 return regs->gpr[11];
114 112
diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig
index 11def45b98c..0aec70c3561 100644
--- a/arch/parisc/Kconfig
+++ b/arch/parisc/Kconfig
@@ -22,6 +22,8 @@ config PARISC
22 select GENERIC_STRNCPY_FROM_USER 22 select GENERIC_STRNCPY_FROM_USER
23 select HAVE_MOD_ARCH_SPECIFIC 23 select HAVE_MOD_ARCH_SPECIFIC
24 select MODULES_USE_ELF_RELA 24 select MODULES_USE_ELF_RELA
25 select GENERIC_KERNEL_THREAD
26 select GENERIC_KERNEL_EXECVE
25 27
26 help 28 help
27 The PA-RISC microprocessor is designed by Hewlett-Packard and used 29 The PA-RISC microprocessor is designed by Hewlett-Packard and used
diff --git a/arch/parisc/include/asm/Kbuild b/arch/parisc/include/asm/Kbuild
index 458371a1565..bac8debecff 100644
--- a/arch/parisc/include/asm/Kbuild
+++ b/arch/parisc/include/asm/Kbuild
@@ -1,6 +1,5 @@
1include include/asm-generic/Kbuild.asm
2 1
3header-y += pdc.h 2generic-y += word-at-a-time.h auxvec.h user.h cputime.h emergency-restart.h \
4generic-y += clkdev.h 3 segment.h topology.h vga.h device.h percpu.h hw_irq.h mutex.h \
5generic-y += word-at-a-time.h 4 div64.h irq_regs.h kdebug.h kvm_para.h local64.h local.h param.h \
6generic-y += exec.h 5 poll.h xor.h clkdev.h exec.h
diff --git a/arch/parisc/include/asm/auxvec.h b/arch/parisc/include/asm/auxvec.h
deleted file mode 100644
index 9c3ac4b89dc..00000000000
--- a/arch/parisc/include/asm/auxvec.h
+++ /dev/null
@@ -1,4 +0,0 @@
1#ifndef __ASMPARISC_AUXVEC_H
2#define __ASMPARISC_AUXVEC_H
3
4#endif
diff --git a/arch/parisc/include/asm/compat_signal.h b/arch/parisc/include/asm/compat_signal.h
deleted file mode 100644
index 6ad02c360b2..00000000000
--- a/arch/parisc/include/asm/compat_signal.h
+++ /dev/null
@@ -1,2 +0,0 @@
1/* Use generic */
2#include <asm-generic/compat_signal.h>
diff --git a/arch/parisc/include/asm/cputime.h b/arch/parisc/include/asm/cputime.h
deleted file mode 100644
index dcdf2fbd7e7..00000000000
--- a/arch/parisc/include/asm/cputime.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef __PARISC_CPUTIME_H
2#define __PARISC_CPUTIME_H
3
4#include <asm-generic/cputime.h>
5
6#endif /* __PARISC_CPUTIME_H */
diff --git a/arch/parisc/include/asm/device.h b/arch/parisc/include/asm/device.h
deleted file mode 100644
index d8f9872b0e2..00000000000
--- a/arch/parisc/include/asm/device.h
+++ /dev/null
@@ -1,7 +0,0 @@
1/*
2 * Arch specific extensions to struct device
3 *
4 * This file is released under the GPLv2
5 */
6#include <asm-generic/device.h>
7
diff --git a/arch/parisc/include/asm/div64.h b/arch/parisc/include/asm/div64.h
deleted file mode 100644
index 6cd978cefb2..00000000000
--- a/arch/parisc/include/asm/div64.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-generic/div64.h>
diff --git a/arch/parisc/include/asm/emergency-restart.h b/arch/parisc/include/asm/emergency-restart.h
deleted file mode 100644
index 108d8c48e42..00000000000
--- a/arch/parisc/include/asm/emergency-restart.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef _ASM_EMERGENCY_RESTART_H
2#define _ASM_EMERGENCY_RESTART_H
3
4#include <asm-generic/emergency-restart.h>
5
6#endif /* _ASM_EMERGENCY_RESTART_H */
diff --git a/arch/parisc/include/asm/hw_irq.h b/arch/parisc/include/asm/hw_irq.h
deleted file mode 100644
index 6707f7df392..00000000000
--- a/arch/parisc/include/asm/hw_irq.h
+++ /dev/null
@@ -1,8 +0,0 @@
1#ifndef _ASM_HW_IRQ_H
2#define _ASM_HW_IRQ_H
3
4/*
5 * linux/include/asm/hw_irq.h
6 */
7
8#endif
diff --git a/arch/parisc/include/asm/irq_regs.h b/arch/parisc/include/asm/irq_regs.h
deleted file mode 100644
index 3dd9c0b7027..00000000000
--- a/arch/parisc/include/asm/irq_regs.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-generic/irq_regs.h>
diff --git a/arch/parisc/include/asm/kdebug.h b/arch/parisc/include/asm/kdebug.h
deleted file mode 100644
index 6ece1b03766..00000000000
--- a/arch/parisc/include/asm/kdebug.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-generic/kdebug.h>
diff --git a/arch/parisc/include/asm/kvm_para.h b/arch/parisc/include/asm/kvm_para.h
deleted file mode 100644
index 14fab8f0b95..00000000000
--- a/arch/parisc/include/asm/kvm_para.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-generic/kvm_para.h>
diff --git a/arch/parisc/include/asm/local.h b/arch/parisc/include/asm/local.h
deleted file mode 100644
index c11c530f74d..00000000000
--- a/arch/parisc/include/asm/local.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-generic/local.h>
diff --git a/arch/parisc/include/asm/local64.h b/arch/parisc/include/asm/local64.h
deleted file mode 100644
index 36c93b5cc23..00000000000
--- a/arch/parisc/include/asm/local64.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-generic/local64.h>
diff --git a/arch/parisc/include/asm/mutex.h b/arch/parisc/include/asm/mutex.h
deleted file mode 100644
index 458c1f7fbc1..00000000000
--- a/arch/parisc/include/asm/mutex.h
+++ /dev/null
@@ -1,9 +0,0 @@
1/*
2 * Pull in the generic implementation for the mutex fastpath.
3 *
4 * TODO: implement optimized primitives instead, or leave the generic
5 * implementation in place, or pick the atomic_xchg() based generic
6 * implementation. (see asm-generic/mutex-xchg.h for details)
7 */
8
9#include <asm-generic/mutex-dec.h>
diff --git a/arch/parisc/include/asm/param.h b/arch/parisc/include/asm/param.h
deleted file mode 100644
index 965d4542797..00000000000
--- a/arch/parisc/include/asm/param.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-generic/param.h>
diff --git a/arch/parisc/include/asm/pdc.h b/arch/parisc/include/asm/pdc.h
index 7f0f2d23059..7eb616e4bf8 100644
--- a/arch/parisc/include/asm/pdc.h
+++ b/arch/parisc/include/asm/pdc.h
@@ -1,348 +1,10 @@
1#ifndef _PARISC_PDC_H 1#ifndef _PARISC_PDC_H
2#define _PARISC_PDC_H 2#define _PARISC_PDC_H
3 3
4/* 4#include <uapi/asm/pdc.h>
5 * PDC return values ...
6 * All PDC calls return a subset of these errors.
7 */
8
9#define PDC_WARN 3 /* Call completed with a warning */
10#define PDC_REQ_ERR_1 2 /* See above */
11#define PDC_REQ_ERR_0 1 /* Call would generate a requestor error */
12#define PDC_OK 0 /* Call completed successfully */
13#define PDC_BAD_PROC -1 /* Called non-existent procedure*/
14#define PDC_BAD_OPTION -2 /* Called with non-existent option */
15#define PDC_ERROR -3 /* Call could not complete without an error */
16#define PDC_NE_MOD -5 /* Module not found */
17#define PDC_NE_CELL_MOD -7 /* Cell module not found */
18#define PDC_INVALID_ARG -10 /* Called with an invalid argument */
19#define PDC_BUS_POW_WARN -12 /* Call could not complete in allowed power budget */
20#define PDC_NOT_NARROW -17 /* Narrow mode not supported */
21
22/*
23 * PDC entry points...
24 */
25
26#define PDC_POW_FAIL 1 /* perform a power-fail */
27#define PDC_POW_FAIL_PREPARE 0 /* prepare for powerfail */
28
29#define PDC_CHASSIS 2 /* PDC-chassis functions */
30#define PDC_CHASSIS_DISP 0 /* update chassis display */
31#define PDC_CHASSIS_WARN 1 /* return chassis warnings */
32#define PDC_CHASSIS_DISPWARN 2 /* update&return chassis status */
33#define PDC_RETURN_CHASSIS_INFO 128 /* HVERSION dependent: return chassis LED/LCD info */
34
35#define PDC_PIM 3 /* Get PIM data */
36#define PDC_PIM_HPMC 0 /* Transfer HPMC data */
37#define PDC_PIM_RETURN_SIZE 1 /* Get Max buffer needed for PIM*/
38#define PDC_PIM_LPMC 2 /* Transfer HPMC data */
39#define PDC_PIM_SOFT_BOOT 3 /* Transfer Soft Boot data */
40#define PDC_PIM_TOC 4 /* Transfer TOC data */
41
42#define PDC_MODEL 4 /* PDC model information call */
43#define PDC_MODEL_INFO 0 /* returns information */
44#define PDC_MODEL_BOOTID 1 /* set the BOOT_ID */
45#define PDC_MODEL_VERSIONS 2 /* returns cpu-internal versions*/
46#define PDC_MODEL_SYSMODEL 3 /* return system model info */
47#define PDC_MODEL_ENSPEC 4 /* enable specific option */
48#define PDC_MODEL_DISPEC 5 /* disable specific option */
49#define PDC_MODEL_CPU_ID 6 /* returns cpu-id (only newer machines!) */
50#define PDC_MODEL_CAPABILITIES 7 /* returns OS32/OS64-flags */
51/* Values for PDC_MODEL_CAPABILITIES non-equivalent virtual aliasing support */
52#define PDC_MODEL_OS64 (1 << 0)
53#define PDC_MODEL_OS32 (1 << 1)
54#define PDC_MODEL_IOPDIR_FDC (1 << 2)
55#define PDC_MODEL_NVA_MASK (3 << 4)
56#define PDC_MODEL_NVA_SUPPORTED (0 << 4)
57#define PDC_MODEL_NVA_SLOW (1 << 4)
58#define PDC_MODEL_NVA_UNSUPPORTED (3 << 4)
59#define PDC_MODEL_GET_BOOT__OP 8 /* returns boot test options */
60#define PDC_MODEL_SET_BOOT__OP 9 /* set boot test options */
61
62#define PA89_INSTRUCTION_SET 0x4 /* capatibilies returned */
63#define PA90_INSTRUCTION_SET 0x8
64
65#define PDC_CACHE 5 /* return/set cache (& TLB) info*/
66#define PDC_CACHE_INFO 0 /* returns information */
67#define PDC_CACHE_SET_COH 1 /* set coherence state */
68#define PDC_CACHE_RET_SPID 2 /* returns space-ID bits */
69
70#define PDC_HPA 6 /* return HPA of processor */
71#define PDC_HPA_PROCESSOR 0
72#define PDC_HPA_MODULES 1
73
74#define PDC_COPROC 7 /* Co-Processor (usually FP unit(s)) */
75#define PDC_COPROC_CFG 0 /* Co-Processor Cfg (FP unit(s) enabled?) */
76
77#define PDC_IODC 8 /* talk to IODC */
78#define PDC_IODC_READ 0 /* read IODC entry point */
79/* PDC_IODC_RI_ * INDEX parameter of PDC_IODC_READ */
80#define PDC_IODC_RI_DATA_BYTES 0 /* IODC Data Bytes */
81/* 1, 2 obsolete - HVERSION dependent*/
82#define PDC_IODC_RI_INIT 3 /* Initialize module */
83#define PDC_IODC_RI_IO 4 /* Module input/output */
84#define PDC_IODC_RI_SPA 5 /* Module input/output */
85#define PDC_IODC_RI_CONFIG 6 /* Module input/output */
86/* 7 obsolete - HVERSION dependent */
87#define PDC_IODC_RI_TEST 8 /* Module input/output */
88#define PDC_IODC_RI_TLB 9 /* Module input/output */
89#define PDC_IODC_NINIT 2 /* non-destructive init */
90#define PDC_IODC_DINIT 3 /* destructive init */
91#define PDC_IODC_MEMERR 4 /* check for memory errors */
92#define PDC_IODC_INDEX_DATA 0 /* get first 16 bytes from mod IODC */
93#define PDC_IODC_BUS_ERROR -4 /* bus error return value */
94#define PDC_IODC_INVALID_INDEX -5 /* invalid index return value */
95#define PDC_IODC_COUNT -6 /* count is too small */
96
97#define PDC_TOD 9 /* time-of-day clock (TOD) */
98#define PDC_TOD_READ 0 /* read TOD */
99#define PDC_TOD_WRITE 1 /* write TOD */
100
101
102#define PDC_STABLE 10 /* stable storage (sprockets) */
103#define PDC_STABLE_READ 0
104#define PDC_STABLE_WRITE 1
105#define PDC_STABLE_RETURN_SIZE 2
106#define PDC_STABLE_VERIFY_CONTENTS 3
107#define PDC_STABLE_INITIALIZE 4
108
109#define PDC_NVOLATILE 11 /* often not implemented */
110
111#define PDC_ADD_VALID 12 /* Memory validation PDC call */
112#define PDC_ADD_VALID_VERIFY 0 /* Make PDC_ADD_VALID verify region */
113
114#define PDC_INSTR 15 /* get instr to invoke PDCE_CHECK() */
115
116#define PDC_PROC 16 /* (sprockets) */
117
118#define PDC_CONFIG 16 /* (sprockets) */
119#define PDC_CONFIG_DECONFIG 0
120#define PDC_CONFIG_DRECONFIG 1
121#define PDC_CONFIG_DRETURN_CONFIG 2
122
123#define PDC_BLOCK_TLB 18 /* manage hardware block-TLB */
124#define PDC_BTLB_INFO 0 /* returns parameter */
125#define PDC_BTLB_INSERT 1 /* insert BTLB entry */
126#define PDC_BTLB_PURGE 2 /* purge BTLB entries */
127#define PDC_BTLB_PURGE_ALL 3 /* purge all BTLB entries */
128
129#define PDC_TLB 19 /* manage hardware TLB miss handling */
130#define PDC_TLB_INFO 0 /* returns parameter */
131#define PDC_TLB_SETUP 1 /* set up miss handling */
132
133#define PDC_MEM 20 /* Manage memory */
134#define PDC_MEM_MEMINFO 0
135#define PDC_MEM_ADD_PAGE 1
136#define PDC_MEM_CLEAR_PDT 2
137#define PDC_MEM_READ_PDT 3
138#define PDC_MEM_RESET_CLEAR 4
139#define PDC_MEM_GOODMEM 5
140#define PDC_MEM_TABLE 128 /* Non contig mem map (sprockets) */
141#define PDC_MEM_RETURN_ADDRESS_TABLE PDC_MEM_TABLE
142#define PDC_MEM_GET_MEMORY_SYSTEM_TABLES_SIZE 131
143#define PDC_MEM_GET_MEMORY_SYSTEM_TABLES 132
144#define PDC_MEM_GET_PHYSICAL_LOCATION_FROM_MEMORY_ADDRESS 133
145
146#define PDC_MEM_RET_SBE_REPLACED 5 /* PDC_MEM return values */
147#define PDC_MEM_RET_DUPLICATE_ENTRY 4
148#define PDC_MEM_RET_BUF_SIZE_SMALL 1
149#define PDC_MEM_RET_PDT_FULL -11
150#define PDC_MEM_RET_INVALID_PHYSICAL_LOCATION ~0ULL
151
152#define PDC_PSW 21 /* Get/Set default System Mask */
153#define PDC_PSW_MASK 0 /* Return mask */
154#define PDC_PSW_GET_DEFAULTS 1 /* Return defaults */
155#define PDC_PSW_SET_DEFAULTS 2 /* Set default */
156#define PDC_PSW_ENDIAN_BIT 1 /* set for big endian */
157#define PDC_PSW_WIDE_BIT 2 /* set for wide mode */
158
159#define PDC_SYSTEM_MAP 22 /* find system modules */
160#define PDC_FIND_MODULE 0
161#define PDC_FIND_ADDRESS 1
162#define PDC_TRANSLATE_PATH 2
163
164#define PDC_SOFT_POWER 23 /* soft power switch */
165#define PDC_SOFT_POWER_INFO 0 /* return info about the soft power switch */
166#define PDC_SOFT_POWER_ENABLE 1 /* enable/disable soft power switch */
167
168
169/* HVERSION dependent */
170
171/* The PDC_MEM_MAP calls */
172#define PDC_MEM_MAP 128 /* on s700: return page info */
173#define PDC_MEM_MAP_HPA 0 /* returns hpa of a module */
174
175#define PDC_EEPROM 129 /* EEPROM access */
176#define PDC_EEPROM_READ_WORD 0
177#define PDC_EEPROM_WRITE_WORD 1
178#define PDC_EEPROM_READ_BYTE 2
179#define PDC_EEPROM_WRITE_BYTE 3
180#define PDC_EEPROM_EEPROM_PASSWORD -1000
181
182#define PDC_NVM 130 /* NVM (non-volatile memory) access */
183#define PDC_NVM_READ_WORD 0
184#define PDC_NVM_WRITE_WORD 1
185#define PDC_NVM_READ_BYTE 2
186#define PDC_NVM_WRITE_BYTE 3
187
188#define PDC_SEED_ERROR 132 /* (sprockets) */
189
190#define PDC_IO 135 /* log error info, reset IO system */
191#define PDC_IO_READ_AND_CLEAR_ERRORS 0
192#define PDC_IO_RESET 1
193#define PDC_IO_RESET_DEVICES 2
194/* sets bits 6&7 (little endian) of the HcControl Register */
195#define PDC_IO_USB_SUSPEND 0xC000000000000000
196#define PDC_IO_EEPROM_IO_ERR_TABLE_FULL -5 /* return value */
197#define PDC_IO_NO_SUSPEND -6 /* return value */
198
199#define PDC_BROADCAST_RESET 136 /* reset all processors */
200#define PDC_DO_RESET 0 /* option: perform a broadcast reset */
201#define PDC_DO_FIRM_TEST_RESET 1 /* Do broadcast reset with bitmap */
202#define PDC_BR_RECONFIGURATION 2 /* reset w/reconfiguration */
203#define PDC_FIRM_TEST_MAGIC 0xab9ec36fUL /* for this reboot only */
204
205#define PDC_LAN_STATION_ID 138 /* Hversion dependent mechanism for */
206#define PDC_LAN_STATION_ID_READ 0 /* getting the lan station address */
207
208#define PDC_LAN_STATION_ID_SIZE 6
209
210#define PDC_CHECK_RANGES 139 /* (sprockets) */
211
212#define PDC_NV_SECTIONS 141 /* (sprockets) */
213
214#define PDC_PERFORMANCE 142 /* performance monitoring */
215
216#define PDC_SYSTEM_INFO 143 /* system information */
217#define PDC_SYSINFO_RETURN_INFO_SIZE 0
218#define PDC_SYSINFO_RRETURN_SYS_INFO 1
219#define PDC_SYSINFO_RRETURN_ERRORS 2
220#define PDC_SYSINFO_RRETURN_WARNINGS 3
221#define PDC_SYSINFO_RETURN_REVISIONS 4
222#define PDC_SYSINFO_RRETURN_DIAGNOSE 5
223#define PDC_SYSINFO_RRETURN_HV_DIAGNOSE 1005
224
225#define PDC_RDR 144 /* (sprockets) */
226#define PDC_RDR_READ_BUFFER 0
227#define PDC_RDR_READ_SINGLE 1
228#define PDC_RDR_WRITE_SINGLE 2
229
230#define PDC_INTRIGUE 145 /* (sprockets) */
231#define PDC_INTRIGUE_WRITE_BUFFER 0
232#define PDC_INTRIGUE_GET_SCRATCH_BUFSIZE 1
233#define PDC_INTRIGUE_START_CPU_COUNTERS 2
234#define PDC_INTRIGUE_STOP_CPU_COUNTERS 3
235
236#define PDC_STI 146 /* STI access */
237/* same as PDC_PCI_XXX values (see below) */
238
239/* Legacy PDC definitions for same stuff */
240#define PDC_PCI_INDEX 147
241#define PDC_PCI_INTERFACE_INFO 0
242#define PDC_PCI_SLOT_INFO 1
243#define PDC_PCI_INFLIGHT_BYTES 2
244#define PDC_PCI_READ_CONFIG 3
245#define PDC_PCI_WRITE_CONFIG 4
246#define PDC_PCI_READ_PCI_IO 5
247#define PDC_PCI_WRITE_PCI_IO 6
248#define PDC_PCI_READ_CONFIG_DELAY 7
249#define PDC_PCI_UPDATE_CONFIG_DELAY 8
250#define PDC_PCI_PCI_PATH_TO_PCI_HPA 9
251#define PDC_PCI_PCI_HPA_TO_PCI_PATH 10
252#define PDC_PCI_PCI_PATH_TO_PCI_BUS 11
253#define PDC_PCI_PCI_RESERVED 12
254#define PDC_PCI_PCI_INT_ROUTE_SIZE 13
255#define PDC_PCI_GET_INT_TBL_SIZE PDC_PCI_PCI_INT_ROUTE_SIZE
256#define PDC_PCI_PCI_INT_ROUTE 14
257#define PDC_PCI_GET_INT_TBL PDC_PCI_PCI_INT_ROUTE
258#define PDC_PCI_READ_MON_TYPE 15
259#define PDC_PCI_WRITE_MON_TYPE 16
260
261
262/* Get SCSI Interface Card info: SDTR, SCSI ID, mode (SE vs LVD) */
263#define PDC_INITIATOR 163
264#define PDC_GET_INITIATOR 0
265#define PDC_SET_INITIATOR 1
266#define PDC_DELETE_INITIATOR 2
267#define PDC_RETURN_TABLE_SIZE 3
268#define PDC_RETURN_TABLE 4
269
270#define PDC_LINK 165 /* (sprockets) */
271#define PDC_LINK_PCI_ENTRY_POINTS 0 /* list (Arg1) = 0 */
272#define PDC_LINK_USB_ENTRY_POINTS 1 /* list (Arg1) = 1 */
273
274/* cl_class
275 * page 3-33 of IO-Firmware ARS
276 * IODC ENTRY_INIT(Search first) RET[1]
277 */
278#define CL_NULL 0 /* invalid */
279#define CL_RANDOM 1 /* random access (as disk) */
280#define CL_SEQU 2 /* sequential access (as tape) */
281#define CL_DUPLEX 7 /* full-duplex point-to-point (RS-232, Net) */
282#define CL_KEYBD 8 /* half-duplex console (HIL Keyboard) */
283#define CL_DISPL 9 /* half-duplex console (display) */
284#define CL_FC 10 /* FiberChannel access media */
285
286/* IODC ENTRY_INIT() */
287#define ENTRY_INIT_SRCH_FRST 2
288#define ENTRY_INIT_SRCH_NEXT 3
289#define ENTRY_INIT_MOD_DEV 4
290#define ENTRY_INIT_DEV 5
291#define ENTRY_INIT_MOD 6
292#define ENTRY_INIT_MSG 9
293
294/* IODC ENTRY_IO() */
295#define ENTRY_IO_BOOTIN 0
296#define ENTRY_IO_BOOTOUT 1
297#define ENTRY_IO_CIN 2
298#define ENTRY_IO_COUT 3
299#define ENTRY_IO_CLOSE 4
300#define ENTRY_IO_GETMSG 9
301#define ENTRY_IO_BBLOCK_IN 16
302#define ENTRY_IO_BBLOCK_OUT 17
303
304/* IODC ENTRY_SPA() */
305
306/* IODC ENTRY_CONFIG() */
307
308/* IODC ENTRY_TEST() */
309
310/* IODC ENTRY_TLB() */
311
312/* constants for OS (NVM...) */
313#define OS_ID_NONE 0 /* Undefined OS ID */
314#define OS_ID_HPUX 1 /* HP-UX OS */
315#define OS_ID_MPEXL 2 /* MPE XL OS */
316#define OS_ID_OSF 3 /* OSF OS */
317#define OS_ID_HPRT 4 /* HP-RT OS */
318#define OS_ID_NOVEL 5 /* NOVELL OS */
319#define OS_ID_LINUX 6 /* Linux */
320
321
322/* constants for PDC_CHASSIS */
323#define OSTAT_OFF 0
324#define OSTAT_FLT 1
325#define OSTAT_TEST 2
326#define OSTAT_INIT 3
327#define OSTAT_SHUT 4
328#define OSTAT_WARN 5
329#define OSTAT_RUN 6
330#define OSTAT_ON 7
331
332/* Page Zero constant offsets used by the HPMC handler */
333#define BOOT_CONSOLE_HPA_OFFSET 0x3c0
334#define BOOT_CONSOLE_SPA_OFFSET 0x3c4
335#define BOOT_CONSOLE_PATH_OFFSET 0x3a8
336
337/* size of the pdc_result buffer for firmware.c */
338#define NUM_PDC_RESULT 32
339 5
340#if !defined(__ASSEMBLY__) 6#if !defined(__ASSEMBLY__)
341 7
342#include <linux/types.h>
343
344#ifdef __KERNEL__
345
346extern int pdc_type; 8extern int pdc_type;
347 9
348/* Values for pdc_type */ 10/* Values for pdc_type */
@@ -673,88 +335,5 @@ static inline char * os_id_to_string(u16 os_id) {
673 } 335 }
674} 336}
675 337
676#endif /* __KERNEL__ */
677
678/* flags of the device_path */
679#define PF_AUTOBOOT 0x80
680#define PF_AUTOSEARCH 0x40
681#define PF_TIMER 0x0F
682
683struct device_path { /* page 1-69 */
684 unsigned char flags; /* flags see above! */
685 unsigned char bc[6]; /* bus converter routing info */
686 unsigned char mod;
687 unsigned int layers[6];/* device-specific layer-info */
688} __attribute__((aligned(8))) ;
689
690struct pz_device {
691 struct device_path dp; /* see above */
692 /* struct iomod *hpa; */
693 unsigned int hpa; /* HPA base address */
694 /* char *spa; */
695 unsigned int spa; /* SPA base address */
696 /* int (*iodc_io)(struct iomod*, ...); */
697 unsigned int iodc_io; /* device entry point */
698 short pad; /* reserved */
699 unsigned short cl_class;/* see below */
700} __attribute__((aligned(8))) ;
701
702struct zeropage {
703 /* [0x000] initialize vectors (VEC) */
704 unsigned int vec_special; /* must be zero */
705 /* int (*vec_pow_fail)(void);*/
706 unsigned int vec_pow_fail; /* power failure handler */
707 /* int (*vec_toc)(void); */
708 unsigned int vec_toc;
709 unsigned int vec_toclen;
710 /* int (*vec_rendz)(void); */
711 unsigned int vec_rendz;
712 int vec_pow_fail_flen;
713 int vec_pad[10];
714
715 /* [0x040] reserved processor dependent */
716 int pad0[112];
717
718 /* [0x200] reserved */
719 int pad1[84];
720
721 /* [0x350] memory configuration (MC) */
722 int memc_cont; /* contiguous mem size (bytes) */
723 int memc_phsize; /* physical memory size */
724 int memc_adsize; /* additional mem size, bytes of SPA space used by PDC */
725 unsigned int mem_pdc_hi; /* used for 64-bit */
726
727 /* [0x360] various parameters for the boot-CPU */
728 /* unsigned int *mem_booterr[8]; */
729 unsigned int mem_booterr[8]; /* ptr to boot errors */
730 unsigned int mem_free; /* first location, where OS can be loaded */
731 /* struct iomod *mem_hpa; */
732 unsigned int mem_hpa; /* HPA of the boot-CPU */
733 /* int (*mem_pdc)(int, ...); */
734 unsigned int mem_pdc; /* PDC entry point */
735 unsigned int mem_10msec; /* number of clock ticks in 10msec */
736
737 /* [0x390] initial memory module (IMM) */
738 /* struct iomod *imm_hpa; */
739 unsigned int imm_hpa; /* HPA of the IMM */
740 int imm_soft_boot; /* 0 = was hard boot, 1 = was soft boot */
741 unsigned int imm_spa_size; /* SPA size of the IMM in bytes */
742 unsigned int imm_max_mem; /* bytes of mem in IMM */
743
744 /* [0x3A0] boot console, display device and keyboard */
745 struct pz_device mem_cons; /* description of console device */
746 struct pz_device mem_boot; /* description of boot device */
747 struct pz_device mem_kbd; /* description of keyboard device */
748
749 /* [0x430] reserved */
750 int pad430[116];
751
752 /* [0x600] processor dependent */
753 __u32 pad600[1];
754 __u32 proc_sti; /* pointer to STI ROM */
755 __u32 pad608[126];
756};
757
758#endif /* !defined(__ASSEMBLY__) */ 338#endif /* !defined(__ASSEMBLY__) */
759
760#endif /* _PARISC_PDC_H */ 339#endif /* _PARISC_PDC_H */
diff --git a/arch/parisc/include/asm/percpu.h b/arch/parisc/include/asm/percpu.h
deleted file mode 100644
index a0dcd197012..00000000000
--- a/arch/parisc/include/asm/percpu.h
+++ /dev/null
@@ -1,7 +0,0 @@
1#ifndef _PARISC_PERCPU_H
2#define _PARISC_PERCPU_H
3
4#include <asm-generic/percpu.h>
5
6#endif
7
diff --git a/arch/parisc/include/asm/poll.h b/arch/parisc/include/asm/poll.h
deleted file mode 100644
index c98509d3149..00000000000
--- a/arch/parisc/include/asm/poll.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-generic/poll.h>
diff --git a/arch/parisc/include/asm/ptrace.h b/arch/parisc/include/asm/ptrace.h
index 250ae35aa06..a2db278a5de 100644
--- a/arch/parisc/include/asm/ptrace.h
+++ b/arch/parisc/include/asm/ptrace.h
@@ -1,49 +1,11 @@
1#ifndef _PARISC_PTRACE_H
2#define _PARISC_PTRACE_H
3
4/* written by Philipp Rumpf, Copyright (C) 1999 SuSE GmbH Nuernberg 1/* written by Philipp Rumpf, Copyright (C) 1999 SuSE GmbH Nuernberg
5** Copyright (C) 2000 Grant Grundler, Hewlett-Packard 2** Copyright (C) 2000 Grant Grundler, Hewlett-Packard
6*/ 3*/
4#ifndef _PARISC_PTRACE_H
5#define _PARISC_PTRACE_H
7 6
8#include <linux/types.h> 7#include <uapi/asm/ptrace.h>
9
10/* This struct defines the way the registers are stored on the
11 * stack during a system call.
12 *
13 * N.B. gdb/strace care about the size and offsets within this
14 * structure. If you change things, you may break object compatibility
15 * for those applications.
16 */
17
18struct pt_regs {
19 unsigned long gr[32]; /* PSW is in gr[0] */
20 __u64 fr[32];
21 unsigned long sr[ 8];
22 unsigned long iasq[2];
23 unsigned long iaoq[2];
24 unsigned long cr27;
25 unsigned long pad0; /* available for other uses */
26 unsigned long orig_r28;
27 unsigned long ksp;
28 unsigned long kpc;
29 unsigned long sar; /* CR11 */
30 unsigned long iir; /* CR19 */
31 unsigned long isr; /* CR20 */
32 unsigned long ior; /* CR21 */
33 unsigned long ipsw; /* CR22 */
34};
35
36/*
37 * The numbers chosen here are somewhat arbitrary but absolutely MUST
38 * not overlap with any of the number assigned in <linux/ptrace.h>.
39 *
40 * These ones are taken from IA-64 on the assumption that theirs are
41 * the most correct (and we also want to support PTRACE_SINGLEBLOCK
42 * since we have taken branch traps too)
43 */
44#define PTRACE_SINGLEBLOCK 12 /* resume execution until next branch */
45 8
46#ifdef __KERNEL__
47 9
48#define task_regs(task) ((struct pt_regs *) ((char *)(task) + TASK_REGS)) 10#define task_regs(task) ((struct pt_regs *) ((char *)(task) + TASK_REGS))
49 11
@@ -58,6 +20,4 @@ struct pt_regs {
58unsigned long profile_pc(struct pt_regs *); 20unsigned long profile_pc(struct pt_regs *);
59 21
60 22
61#endif /* __KERNEL__ */
62
63#endif 23#endif
diff --git a/arch/parisc/include/asm/real.h b/arch/parisc/include/asm/real.h
deleted file mode 100644
index 82acb25db39..00000000000
--- a/arch/parisc/include/asm/real.h
+++ /dev/null
@@ -1,5 +0,0 @@
1#ifndef _PARISC_REAL_H
2#define _PARISC_REAL_H
3
4
5#endif
diff --git a/arch/parisc/include/asm/segment.h b/arch/parisc/include/asm/segment.h
deleted file mode 100644
index 26794ddb652..00000000000
--- a/arch/parisc/include/asm/segment.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef __PARISC_SEGMENT_H
2#define __PARISC_SEGMENT_H
3
4/* Only here because we have some old header files that expect it.. */
5
6#endif
diff --git a/arch/parisc/include/asm/signal.h b/arch/parisc/include/asm/signal.h
index c20356375d1..21abf4fc169 100644
--- a/arch/parisc/include/asm/signal.h
+++ b/arch/parisc/include/asm/signal.h
@@ -1,129 +1,19 @@
1#ifndef _ASM_PARISC_SIGNAL_H 1#ifndef _ASM_PARISC_SIGNAL_H
2#define _ASM_PARISC_SIGNAL_H 2#define _ASM_PARISC_SIGNAL_H
3 3
4#define SIGHUP 1 4#include <uapi/asm/signal.h>
5#define SIGINT 2
6#define SIGQUIT 3
7#define SIGILL 4
8#define SIGTRAP 5
9#define SIGABRT 6
10#define SIGIOT 6
11#define SIGEMT 7
12#define SIGFPE 8
13#define SIGKILL 9
14#define SIGBUS 10
15#define SIGSEGV 11
16#define SIGSYS 12 /* Linux doesn't use this */
17#define SIGPIPE 13
18#define SIGALRM 14
19#define SIGTERM 15
20#define SIGUSR1 16
21#define SIGUSR2 17
22#define SIGCHLD 18
23#define SIGPWR 19
24#define SIGVTALRM 20
25#define SIGPROF 21
26#define SIGIO 22
27#define SIGPOLL SIGIO
28#define SIGWINCH 23
29#define SIGSTOP 24
30#define SIGTSTP 25
31#define SIGCONT 26
32#define SIGTTIN 27
33#define SIGTTOU 28
34#define SIGURG 29
35#define SIGLOST 30 /* Linux doesn't use this either */
36#define SIGUNUSED 31
37#define SIGRESERVE SIGUNUSED
38 5
39#define SIGXCPU 33
40#define SIGXFSZ 34
41#define SIGSTKFLT 36
42
43/* These should not be considered constants from userland. */
44#define SIGRTMIN 37
45#define SIGRTMAX _NSIG /* it's 44 under HP/UX */
46
47/*
48 * SA_FLAGS values:
49 *
50 * SA_ONSTACK indicates that a registered stack_t will be used.
51 * SA_RESTART flag to get restarting signals (which were the default long ago)
52 * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop.
53 * SA_RESETHAND clears the handler when the signal is delivered.
54 * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies.
55 * SA_NODEFER prevents the current signal from being masked in the handler.
56 *
57 * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single
58 * Unix names RESETHAND and NODEFER respectively.
59 */
60#define SA_ONSTACK 0x00000001
61#define SA_RESETHAND 0x00000004
62#define SA_NOCLDSTOP 0x00000008
63#define SA_SIGINFO 0x00000010
64#define SA_NODEFER 0x00000020
65#define SA_RESTART 0x00000040
66#define SA_NOCLDWAIT 0x00000080
67#define _SA_SIGGFAULT 0x00000100 /* HPUX */
68
69#define SA_NOMASK SA_NODEFER
70#define SA_ONESHOT SA_RESETHAND
71
72#define SA_RESTORER 0x04000000 /* obsolete -- ignored */
73
74/*
75 * sigaltstack controls
76 */
77#define SS_ONSTACK 1
78#define SS_DISABLE 2
79
80#define MINSIGSTKSZ 2048
81#define SIGSTKSZ 8192
82
83#ifdef __KERNEL__
84 6
85#define _NSIG 64 7#define _NSIG 64
86/* bits-per-word, where word apparently means 'long' not 'int' */ 8/* bits-per-word, where word apparently means 'long' not 'int' */
87#define _NSIG_BPW BITS_PER_LONG 9#define _NSIG_BPW BITS_PER_LONG
88#define _NSIG_WORDS (_NSIG / _NSIG_BPW) 10#define _NSIG_WORDS (_NSIG / _NSIG_BPW)
89 11
90#endif /* __KERNEL__ */
91
92#define SIG_BLOCK 0 /* for blocking signals */
93#define SIG_UNBLOCK 1 /* for unblocking signals */
94#define SIG_SETMASK 2 /* for setting the signal mask */
95
96#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
97#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
98#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
99
100# ifndef __ASSEMBLY__ 12# ifndef __ASSEMBLY__
101
102# include <linux/types.h>
103
104/* Avoid too many header ordering problems. */
105struct siginfo;
106
107/* Type of a signal handler. */
108#ifdef CONFIG_64BIT 13#ifdef CONFIG_64BIT
109/* function pointers on 64-bit parisc are pointers to little structs and the
110 * compiler doesn't support code which changes or tests the address of
111 * the function in the little struct. This is really ugly -PB
112 */
113typedef char __user *__sighandler_t;
114#else 14#else
115typedef void __signalfn_t(int);
116typedef __signalfn_t __user *__sighandler_t;
117#endif 15#endif
118 16
119typedef struct sigaltstack {
120 void __user *ss_sp;
121 int ss_flags;
122 size_t ss_size;
123} stack_t;
124
125#ifdef __KERNEL__
126
127/* Most things should be clean enough to redefine this at will, if care 17/* Most things should be clean enough to redefine this at will, if care
128 is taken to make libc match. */ 18 is taken to make libc match. */
129 19
@@ -148,6 +38,5 @@ struct k_sigaction {
148 38
149#include <asm/sigcontext.h> 39#include <asm/sigcontext.h>
150 40
151#endif /* __KERNEL__ */
152#endif /* !__ASSEMBLY */ 41#endif /* !__ASSEMBLY */
153#endif /* _ASM_PARISC_SIGNAL_H */ 42#endif /* _ASM_PARISC_SIGNAL_H */
diff --git a/arch/parisc/include/asm/termios.h b/arch/parisc/include/asm/termios.h
index a2a57a4548a..9bbc0c8974e 100644
--- a/arch/parisc/include/asm/termios.h
+++ b/arch/parisc/include/asm/termios.h
@@ -1,45 +1,8 @@
1#ifndef _PARISC_TERMIOS_H 1#ifndef _PARISC_TERMIOS_H
2#define _PARISC_TERMIOS_H 2#define _PARISC_TERMIOS_H
3 3
4#include <asm/termbits.h> 4#include <uapi/asm/termios.h>
5#include <asm/ioctls.h>
6 5
7struct winsize {
8 unsigned short ws_row;
9 unsigned short ws_col;
10 unsigned short ws_xpixel;
11 unsigned short ws_ypixel;
12};
13
14#define NCC 8
15struct termio {
16 unsigned short c_iflag; /* input mode flags */
17 unsigned short c_oflag; /* output mode flags */
18 unsigned short c_cflag; /* control mode flags */
19 unsigned short c_lflag; /* local mode flags */
20 unsigned char c_line; /* line discipline */
21 unsigned char c_cc[NCC]; /* control characters */
22};
23
24/* modem lines */
25#define TIOCM_LE 0x001
26#define TIOCM_DTR 0x002
27#define TIOCM_RTS 0x004
28#define TIOCM_ST 0x008
29#define TIOCM_SR 0x010
30#define TIOCM_CTS 0x020
31#define TIOCM_CAR 0x040
32#define TIOCM_RNG 0x080
33#define TIOCM_DSR 0x100
34#define TIOCM_CD TIOCM_CAR
35#define TIOCM_RI TIOCM_RNG
36#define TIOCM_OUT1 0x2000
37#define TIOCM_OUT2 0x4000
38#define TIOCM_LOOP 0x8000
39
40/* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
41
42#ifdef __KERNEL__
43 6
44/* intr=^C quit=^\ erase=del kill=^U 7/* intr=^C quit=^\ erase=del kill=^U
45 eof=^D vtime=\0 vmin=\1 sxtc=\0 8 eof=^D vtime=\0 vmin=\1 sxtc=\0
@@ -85,6 +48,4 @@ struct termio {
85#define user_termios_to_kernel_termios_1(k, u) copy_from_user(k, u, sizeof(struct termios)) 48#define user_termios_to_kernel_termios_1(k, u) copy_from_user(k, u, sizeof(struct termios))
86#define kernel_termios_to_user_termios_1(u, k) copy_to_user(u, k, sizeof(struct termios)) 49#define kernel_termios_to_user_termios_1(u, k) copy_to_user(u, k, sizeof(struct termios))
87 50
88#endif /* __KERNEL__ */
89
90#endif /* _PARISC_TERMIOS_H */ 51#endif /* _PARISC_TERMIOS_H */
diff --git a/arch/parisc/include/asm/topology.h b/arch/parisc/include/asm/topology.h
deleted file mode 100644
index d8133eb0b1e..00000000000
--- a/arch/parisc/include/asm/topology.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef _ASM_PARISC_TOPOLOGY_H
2#define _ASM_PARISC_TOPOLOGY_H
3
4#include <asm-generic/topology.h>
5
6#endif /* _ASM_PARISC_TOPOLOGY_H */
diff --git a/arch/parisc/include/asm/unistd.h b/arch/parisc/include/asm/unistd.h
index d61de64f990..55512e26b0c 100644
--- a/arch/parisc/include/asm/unistd.h
+++ b/arch/parisc/include/asm/unistd.h
@@ -1,840 +1,8 @@
1#ifndef _ASM_PARISC_UNISTD_H_ 1#ifndef _ASM_PARISC_UNISTD_H_
2#define _ASM_PARISC_UNISTD_H_ 2#define _ASM_PARISC_UNISTD_H_
3 3
4/* 4#include <uapi/asm/unistd.h>
5 * This file contains the system call numbers.
6 */
7
8/*
9 * HP-UX system calls get their native numbers for binary compatibility.
10 */
11
12#define __NR_HPUX_exit 1
13#define __NR_HPUX_fork 2
14#define __NR_HPUX_read 3
15#define __NR_HPUX_write 4
16#define __NR_HPUX_open 5
17#define __NR_HPUX_close 6
18#define __NR_HPUX_wait 7
19#define __NR_HPUX_creat 8
20#define __NR_HPUX_link 9
21#define __NR_HPUX_unlink 10
22#define __NR_HPUX_execv 11
23#define __NR_HPUX_chdir 12
24#define __NR_HPUX_time 13
25#define __NR_HPUX_mknod 14
26#define __NR_HPUX_chmod 15
27#define __NR_HPUX_chown 16
28#define __NR_HPUX_break 17
29#define __NR_HPUX_lchmod 18
30#define __NR_HPUX_lseek 19
31#define __NR_HPUX_getpid 20
32#define __NR_HPUX_mount 21
33#define __NR_HPUX_umount 22
34#define __NR_HPUX_setuid 23
35#define __NR_HPUX_getuid 24
36#define __NR_HPUX_stime 25
37#define __NR_HPUX_ptrace 26
38#define __NR_HPUX_alarm 27
39#define __NR_HPUX_oldfstat 28
40#define __NR_HPUX_pause 29
41#define __NR_HPUX_utime 30
42#define __NR_HPUX_stty 31
43#define __NR_HPUX_gtty 32
44#define __NR_HPUX_access 33
45#define __NR_HPUX_nice 34
46#define __NR_HPUX_ftime 35
47#define __NR_HPUX_sync 36
48#define __NR_HPUX_kill 37
49#define __NR_HPUX_stat 38
50#define __NR_HPUX_setpgrp3 39
51#define __NR_HPUX_lstat 40
52#define __NR_HPUX_dup 41
53#define __NR_HPUX_pipe 42
54#define __NR_HPUX_times 43
55#define __NR_HPUX_profil 44
56#define __NR_HPUX_ki_call 45
57#define __NR_HPUX_setgid 46
58#define __NR_HPUX_getgid 47
59#define __NR_HPUX_sigsys 48
60#define __NR_HPUX_reserved1 49
61#define __NR_HPUX_reserved2 50
62#define __NR_HPUX_acct 51
63#define __NR_HPUX_set_userthreadid 52
64#define __NR_HPUX_oldlock 53
65#define __NR_HPUX_ioctl 54
66#define __NR_HPUX_reboot 55
67#define __NR_HPUX_symlink 56
68#define __NR_HPUX_utssys 57
69#define __NR_HPUX_readlink 58
70#define __NR_HPUX_execve 59
71#define __NR_HPUX_umask 60
72#define __NR_HPUX_chroot 61
73#define __NR_HPUX_fcntl 62
74#define __NR_HPUX_ulimit 63
75#define __NR_HPUX_getpagesize 64
76#define __NR_HPUX_mremap 65
77#define __NR_HPUX_vfork 66
78#define __NR_HPUX_vread 67
79#define __NR_HPUX_vwrite 68
80#define __NR_HPUX_sbrk 69
81#define __NR_HPUX_sstk 70
82#define __NR_HPUX_mmap 71
83#define __NR_HPUX_vadvise 72
84#define __NR_HPUX_munmap 73
85#define __NR_HPUX_mprotect 74
86#define __NR_HPUX_madvise 75
87#define __NR_HPUX_vhangup 76
88#define __NR_HPUX_swapoff 77
89#define __NR_HPUX_mincore 78
90#define __NR_HPUX_getgroups 79
91#define __NR_HPUX_setgroups 80
92#define __NR_HPUX_getpgrp2 81
93#define __NR_HPUX_setpgrp2 82
94#define __NR_HPUX_setitimer 83
95#define __NR_HPUX_wait3 84
96#define __NR_HPUX_swapon 85
97#define __NR_HPUX_getitimer 86
98#define __NR_HPUX_gethostname42 87
99#define __NR_HPUX_sethostname42 88
100#define __NR_HPUX_getdtablesize 89
101#define __NR_HPUX_dup2 90
102#define __NR_HPUX_getdopt 91
103#define __NR_HPUX_fstat 92
104#define __NR_HPUX_select 93
105#define __NR_HPUX_setdopt 94
106#define __NR_HPUX_fsync 95
107#define __NR_HPUX_setpriority 96
108#define __NR_HPUX_socket_old 97
109#define __NR_HPUX_connect_old 98
110#define __NR_HPUX_accept_old 99
111#define __NR_HPUX_getpriority 100
112#define __NR_HPUX_send_old 101
113#define __NR_HPUX_recv_old 102
114#define __NR_HPUX_socketaddr_old 103
115#define __NR_HPUX_bind_old 104
116#define __NR_HPUX_setsockopt_old 105
117#define __NR_HPUX_listen_old 106
118#define __NR_HPUX_vtimes_old 107
119#define __NR_HPUX_sigvector 108
120#define __NR_HPUX_sigblock 109
121#define __NR_HPUX_siggetmask 110
122#define __NR_HPUX_sigpause 111
123#define __NR_HPUX_sigstack 112
124#define __NR_HPUX_recvmsg_old 113
125#define __NR_HPUX_sendmsg_old 114
126#define __NR_HPUX_vtrace_old 115
127#define __NR_HPUX_gettimeofday 116
128#define __NR_HPUX_getrusage 117
129#define __NR_HPUX_getsockopt_old 118
130#define __NR_HPUX_resuba_old 119
131#define __NR_HPUX_readv 120
132#define __NR_HPUX_writev 121
133#define __NR_HPUX_settimeofday 122
134#define __NR_HPUX_fchown 123
135#define __NR_HPUX_fchmod 124
136#define __NR_HPUX_recvfrom_old 125
137#define __NR_HPUX_setresuid 126
138#define __NR_HPUX_setresgid 127
139#define __NR_HPUX_rename 128
140#define __NR_HPUX_truncate 129
141#define __NR_HPUX_ftruncate 130
142#define __NR_HPUX_flock_old 131
143#define __NR_HPUX_sysconf 132
144#define __NR_HPUX_sendto_old 133
145#define __NR_HPUX_shutdown_old 134
146#define __NR_HPUX_socketpair_old 135
147#define __NR_HPUX_mkdir 136
148#define __NR_HPUX_rmdir 137
149#define __NR_HPUX_utimes_old 138
150#define __NR_HPUX_sigcleanup_old 139
151#define __NR_HPUX_setcore 140
152#define __NR_HPUX_getpeername_old 141
153#define __NR_HPUX_gethostid 142
154#define __NR_HPUX_sethostid 143
155#define __NR_HPUX_getrlimit 144
156#define __NR_HPUX_setrlimit 145
157#define __NR_HPUX_killpg_old 146
158#define __NR_HPUX_cachectl 147
159#define __NR_HPUX_quotactl 148
160#define __NR_HPUX_get_sysinfo 149
161#define __NR_HPUX_getsockname_old 150
162#define __NR_HPUX_privgrp 151
163#define __NR_HPUX_rtprio 152
164#define __NR_HPUX_plock 153
165#define __NR_HPUX_reserved3 154
166#define __NR_HPUX_lockf 155
167#define __NR_HPUX_semget 156
168#define __NR_HPUX_osemctl 157
169#define __NR_HPUX_semop 158
170#define __NR_HPUX_msgget 159
171#define __NR_HPUX_omsgctl 160
172#define __NR_HPUX_msgsnd 161
173#define __NR_HPUX_msgrecv 162
174#define __NR_HPUX_shmget 163
175#define __NR_HPUX_oshmctl 164
176#define __NR_HPUX_shmat 165
177#define __NR_HPUX_shmdt 166
178#define __NR_HPUX_m68020_advise 167
179/* [168,189] are for Discless/DUX */
180#define __NR_HPUX_csp 168
181#define __NR_HPUX_cluster 169
182#define __NR_HPUX_mkrnod 170
183#define __NR_HPUX_test 171
184#define __NR_HPUX_unsp_open 172
185#define __NR_HPUX_reserved4 173
186#define __NR_HPUX_getcontext_old 174
187#define __NR_HPUX_osetcontext 175
188#define __NR_HPUX_bigio 176
189#define __NR_HPUX_pipenode 177
190#define __NR_HPUX_lsync 178
191#define __NR_HPUX_getmachineid 179
192#define __NR_HPUX_cnodeid 180
193#define __NR_HPUX_cnodes 181
194#define __NR_HPUX_swapclients 182
195#define __NR_HPUX_rmt_process 183
196#define __NR_HPUX_dskless_stats 184
197#define __NR_HPUX_sigprocmask 185
198#define __NR_HPUX_sigpending 186
199#define __NR_HPUX_sigsuspend 187
200#define __NR_HPUX_sigaction 188
201#define __NR_HPUX_reserved5 189
202#define __NR_HPUX_nfssvc 190
203#define __NR_HPUX_getfh 191
204#define __NR_HPUX_getdomainname 192
205#define __NR_HPUX_setdomainname 193
206#define __NR_HPUX_async_daemon 194
207#define __NR_HPUX_getdirentries 195
208#define __NR_HPUX_statfs 196
209#define __NR_HPUX_fstatfs 197
210#define __NR_HPUX_vfsmount 198
211#define __NR_HPUX_reserved6 199
212#define __NR_HPUX_waitpid 200
213/* 201 - 223 missing */
214#define __NR_HPUX_sigsetreturn 224
215#define __NR_HPUX_sigsetstatemask 225
216/* 226 missing */
217#define __NR_HPUX_cs 227
218#define __NR_HPUX_cds 228
219#define __NR_HPUX_set_no_trunc 229
220#define __NR_HPUX_pathconf 230
221#define __NR_HPUX_fpathconf 231
222/* 232, 233 missing */
223#define __NR_HPUX_nfs_fcntl 234
224#define __NR_HPUX_ogetacl 235
225#define __NR_HPUX_ofgetacl 236
226#define __NR_HPUX_osetacl 237
227#define __NR_HPUX_ofsetacl 238
228#define __NR_HPUX_pstat 239
229#define __NR_HPUX_getaudid 240
230#define __NR_HPUX_setaudid 241
231#define __NR_HPUX_getaudproc 242
232#define __NR_HPUX_setaudproc 243
233#define __NR_HPUX_getevent 244
234#define __NR_HPUX_setevent 245
235#define __NR_HPUX_audwrite 246
236#define __NR_HPUX_audswitch 247
237#define __NR_HPUX_audctl 248
238#define __NR_HPUX_ogetaccess 249
239#define __NR_HPUX_fsctl 250
240/* 251 - 258 missing */
241#define __NR_HPUX_swapfs 259
242#define __NR_HPUX_fss 260
243/* 261 - 266 missing */
244#define __NR_HPUX_tsync 267
245#define __NR_HPUX_getnumfds 268
246#define __NR_HPUX_poll 269
247#define __NR_HPUX_getmsg 270
248#define __NR_HPUX_putmsg 271
249#define __NR_HPUX_fchdir 272
250#define __NR_HPUX_getmount_cnt 273
251#define __NR_HPUX_getmount_entry 274
252#define __NR_HPUX_accept 275
253#define __NR_HPUX_bind 276
254#define __NR_HPUX_connect 277
255#define __NR_HPUX_getpeername 278
256#define __NR_HPUX_getsockname 279
257#define __NR_HPUX_getsockopt 280
258#define __NR_HPUX_listen 281
259#define __NR_HPUX_recv 282
260#define __NR_HPUX_recvfrom 283
261#define __NR_HPUX_recvmsg 284
262#define __NR_HPUX_send 285
263#define __NR_HPUX_sendmsg 286
264#define __NR_HPUX_sendto 287
265#define __NR_HPUX_setsockopt 288
266#define __NR_HPUX_shutdown 289
267#define __NR_HPUX_socket 290
268#define __NR_HPUX_socketpair 291
269#define __NR_HPUX_proc_open 292
270#define __NR_HPUX_proc_close 293
271#define __NR_HPUX_proc_send 294
272#define __NR_HPUX_proc_recv 295
273#define __NR_HPUX_proc_sendrecv 296
274#define __NR_HPUX_proc_syscall 297
275/* 298 - 311 missing */
276#define __NR_HPUX_semctl 312
277#define __NR_HPUX_msgctl 313
278#define __NR_HPUX_shmctl 314
279#define __NR_HPUX_mpctl 315
280#define __NR_HPUX_exportfs 316
281#define __NR_HPUX_getpmsg 317
282#define __NR_HPUX_putpmsg 318
283/* 319 missing */
284#define __NR_HPUX_msync 320
285#define __NR_HPUX_msleep 321
286#define __NR_HPUX_mwakeup 322
287#define __NR_HPUX_msem_init 323
288#define __NR_HPUX_msem_remove 324
289#define __NR_HPUX_adjtime 325
290#define __NR_HPUX_kload 326
291#define __NR_HPUX_fattach 327
292#define __NR_HPUX_fdetach 328
293#define __NR_HPUX_serialize 329
294#define __NR_HPUX_statvfs 330
295#define __NR_HPUX_fstatvfs 331
296#define __NR_HPUX_lchown 332
297#define __NR_HPUX_getsid 333
298#define __NR_HPUX_sysfs 334
299/* 335, 336 missing */
300#define __NR_HPUX_sched_setparam 337
301#define __NR_HPUX_sched_getparam 338
302#define __NR_HPUX_sched_setscheduler 339
303#define __NR_HPUX_sched_getscheduler 340
304#define __NR_HPUX_sched_yield 341
305#define __NR_HPUX_sched_get_priority_max 342
306#define __NR_HPUX_sched_get_priority_min 343
307#define __NR_HPUX_sched_rr_get_interval 344
308#define __NR_HPUX_clock_settime 345
309#define __NR_HPUX_clock_gettime 346
310#define __NR_HPUX_clock_getres 347
311#define __NR_HPUX_timer_create 348
312#define __NR_HPUX_timer_delete 349
313#define __NR_HPUX_timer_settime 350
314#define __NR_HPUX_timer_gettime 351
315#define __NR_HPUX_timer_getoverrun 352
316#define __NR_HPUX_nanosleep 353
317#define __NR_HPUX_toolbox 354
318/* 355 missing */
319#define __NR_HPUX_getdents 356
320#define __NR_HPUX_getcontext 357
321#define __NR_HPUX_sysinfo 358
322#define __NR_HPUX_fcntl64 359
323#define __NR_HPUX_ftruncate64 360
324#define __NR_HPUX_fstat64 361
325#define __NR_HPUX_getdirentries64 362
326#define __NR_HPUX_getrlimit64 363
327#define __NR_HPUX_lockf64 364
328#define __NR_HPUX_lseek64 365
329#define __NR_HPUX_lstat64 366
330#define __NR_HPUX_mmap64 367
331#define __NR_HPUX_setrlimit64 368
332#define __NR_HPUX_stat64 369
333#define __NR_HPUX_truncate64 370
334#define __NR_HPUX_ulimit64 371
335#define __NR_HPUX_pread 372
336#define __NR_HPUX_preadv 373
337#define __NR_HPUX_pwrite 374
338#define __NR_HPUX_pwritev 375
339#define __NR_HPUX_pread64 376
340#define __NR_HPUX_preadv64 377
341#define __NR_HPUX_pwrite64 378
342#define __NR_HPUX_pwritev64 379
343#define __NR_HPUX_setcontext 380
344#define __NR_HPUX_sigaltstack 381
345#define __NR_HPUX_waitid 382
346#define __NR_HPUX_setpgrp 383
347#define __NR_HPUX_recvmsg2 384
348#define __NR_HPUX_sendmsg2 385
349#define __NR_HPUX_socket2 386
350#define __NR_HPUX_socketpair2 387
351#define __NR_HPUX_setregid 388
352#define __NR_HPUX_lwp_create 389
353#define __NR_HPUX_lwp_terminate 390
354#define __NR_HPUX_lwp_wait 391
355#define __NR_HPUX_lwp_suspend 392
356#define __NR_HPUX_lwp_resume 393
357/* 394 missing */
358#define __NR_HPUX_lwp_abort_syscall 395
359#define __NR_HPUX_lwp_info 396
360#define __NR_HPUX_lwp_kill 397
361#define __NR_HPUX_ksleep 398
362#define __NR_HPUX_kwakeup 399
363/* 400 missing */
364#define __NR_HPUX_pstat_getlwp 401
365#define __NR_HPUX_lwp_exit 402
366#define __NR_HPUX_lwp_continue 403
367#define __NR_HPUX_getacl 404
368#define __NR_HPUX_fgetacl 405
369#define __NR_HPUX_setacl 406
370#define __NR_HPUX_fsetacl 407
371#define __NR_HPUX_getaccess 408
372#define __NR_HPUX_lwp_mutex_init 409
373#define __NR_HPUX_lwp_mutex_lock_sys 410
374#define __NR_HPUX_lwp_mutex_unlock 411
375#define __NR_HPUX_lwp_cond_init 412
376#define __NR_HPUX_lwp_cond_signal 413
377#define __NR_HPUX_lwp_cond_broadcast 414
378#define __NR_HPUX_lwp_cond_wait_sys 415
379#define __NR_HPUX_lwp_getscheduler 416
380#define __NR_HPUX_lwp_setscheduler 417
381#define __NR_HPUX_lwp_getstate 418
382#define __NR_HPUX_lwp_setstate 419
383#define __NR_HPUX_lwp_detach 420
384#define __NR_HPUX_mlock 421
385#define __NR_HPUX_munlock 422
386#define __NR_HPUX_mlockall 423
387#define __NR_HPUX_munlockall 424
388#define __NR_HPUX_shm_open 425
389#define __NR_HPUX_shm_unlink 426
390#define __NR_HPUX_sigqueue 427
391#define __NR_HPUX_sigwaitinfo 428
392#define __NR_HPUX_sigtimedwait 429
393#define __NR_HPUX_sigwait 430
394#define __NR_HPUX_aio_read 431
395#define __NR_HPUX_aio_write 432
396#define __NR_HPUX_lio_listio 433
397#define __NR_HPUX_aio_error 434
398#define __NR_HPUX_aio_return 435
399#define __NR_HPUX_aio_cancel 436
400#define __NR_HPUX_aio_suspend 437
401#define __NR_HPUX_aio_fsync 438
402#define __NR_HPUX_mq_open 439
403#define __NR_HPUX_mq_close 440
404#define __NR_HPUX_mq_unlink 441
405#define __NR_HPUX_mq_send 442
406#define __NR_HPUX_mq_receive 443
407#define __NR_HPUX_mq_notify 444
408#define __NR_HPUX_mq_setattr 445
409#define __NR_HPUX_mq_getattr 446
410#define __NR_HPUX_ksem_open 447
411#define __NR_HPUX_ksem_unlink 448
412#define __NR_HPUX_ksem_close 449
413#define __NR_HPUX_ksem_post 450
414#define __NR_HPUX_ksem_wait 451
415#define __NR_HPUX_ksem_read 452
416#define __NR_HPUX_ksem_trywait 453
417#define __NR_HPUX_lwp_rwlock_init 454
418#define __NR_HPUX_lwp_rwlock_destroy 455
419#define __NR_HPUX_lwp_rwlock_rdlock_sys 456
420#define __NR_HPUX_lwp_rwlock_wrlock_sys 457
421#define __NR_HPUX_lwp_rwlock_tryrdlock 458
422#define __NR_HPUX_lwp_rwlock_trywrlock 459
423#define __NR_HPUX_lwp_rwlock_unlock 460
424#define __NR_HPUX_ttrace 461
425#define __NR_HPUX_ttrace_wait 462
426#define __NR_HPUX_lf_wire_mem 463
427#define __NR_HPUX_lf_unwire_mem 464
428#define __NR_HPUX_lf_send_pin_map 465
429#define __NR_HPUX_lf_free_buf 466
430#define __NR_HPUX_lf_wait_nq 467
431#define __NR_HPUX_lf_wakeup_conn_q 468
432#define __NR_HPUX_lf_unused 469
433#define __NR_HPUX_lwp_sema_init 470
434#define __NR_HPUX_lwp_sema_post 471
435#define __NR_HPUX_lwp_sema_wait 472
436#define __NR_HPUX_lwp_sema_trywait 473
437#define __NR_HPUX_lwp_sema_destroy 474
438#define __NR_HPUX_statvfs64 475
439#define __NR_HPUX_fstatvfs64 476
440#define __NR_HPUX_msh_register 477
441#define __NR_HPUX_ptrace64 478
442#define __NR_HPUX_sendfile 479
443#define __NR_HPUX_sendpath 480
444#define __NR_HPUX_sendfile64 481
445#define __NR_HPUX_sendpath64 482
446#define __NR_HPUX_modload 483
447#define __NR_HPUX_moduload 484
448#define __NR_HPUX_modpath 485
449#define __NR_HPUX_getksym 486
450#define __NR_HPUX_modadm 487
451#define __NR_HPUX_modstat 488
452#define __NR_HPUX_lwp_detached_exit 489
453#define __NR_HPUX_crashconf 490
454#define __NR_HPUX_siginhibit 491
455#define __NR_HPUX_sigenable 492
456#define __NR_HPUX_spuctl 493
457#define __NR_HPUX_zerokernelsum 494
458#define __NR_HPUX_nfs_kstat 495
459#define __NR_HPUX_aio_read64 496
460#define __NR_HPUX_aio_write64 497
461#define __NR_HPUX_aio_error64 498
462#define __NR_HPUX_aio_return64 499
463#define __NR_HPUX_aio_cancel64 500
464#define __NR_HPUX_aio_suspend64 501
465#define __NR_HPUX_aio_fsync64 502
466#define __NR_HPUX_lio_listio64 503
467#define __NR_HPUX_recv2 504
468#define __NR_HPUX_recvfrom2 505
469#define __NR_HPUX_send2 506
470#define __NR_HPUX_sendto2 507
471#define __NR_HPUX_acl 508
472#define __NR_HPUX___cnx_p2p_ctl 509
473#define __NR_HPUX___cnx_gsched_ctl 510
474#define __NR_HPUX___cnx_pmon_ctl 511
475
476#define __NR_HPUX_syscalls 512
477
478/*
479 * Linux system call numbers.
480 *
481 * Cary Coutant says that we should just use another syscall gateway
482 * page to avoid clashing with the HPUX space, and I think he's right:
483 * it will would keep a branch out of our syscall entry path, at the
484 * very least. If we decide to change it later, we can ``just'' tweak
485 * the LINUX_GATEWAY_ADDR define at the bottom and make __NR_Linux be
486 * 1024 or something. Oh, and recompile libc. =)
487 *
488 * 64-bit HPUX binaries get the syscall gateway address passed in a register
489 * from the kernel at startup, which seems a sane strategy.
490 */
491
492#define __NR_Linux 0
493#define __NR_restart_syscall (__NR_Linux + 0)
494#define __NR_exit (__NR_Linux + 1)
495#define __NR_fork (__NR_Linux + 2)
496#define __NR_read (__NR_Linux + 3)
497#define __NR_write (__NR_Linux + 4)
498#define __NR_open (__NR_Linux + 5)
499#define __NR_close (__NR_Linux + 6)
500#define __NR_waitpid (__NR_Linux + 7)
501#define __NR_creat (__NR_Linux + 8)
502#define __NR_link (__NR_Linux + 9)
503#define __NR_unlink (__NR_Linux + 10)
504#define __NR_execve (__NR_Linux + 11)
505#define __NR_chdir (__NR_Linux + 12)
506#define __NR_time (__NR_Linux + 13)
507#define __NR_mknod (__NR_Linux + 14)
508#define __NR_chmod (__NR_Linux + 15)
509#define __NR_lchown (__NR_Linux + 16)
510#define __NR_socket (__NR_Linux + 17)
511#define __NR_stat (__NR_Linux + 18)
512#define __NR_lseek (__NR_Linux + 19)
513#define __NR_getpid (__NR_Linux + 20)
514#define __NR_mount (__NR_Linux + 21)
515#define __NR_bind (__NR_Linux + 22)
516#define __NR_setuid (__NR_Linux + 23)
517#define __NR_getuid (__NR_Linux + 24)
518#define __NR_stime (__NR_Linux + 25)
519#define __NR_ptrace (__NR_Linux + 26)
520#define __NR_alarm (__NR_Linux + 27)
521#define __NR_fstat (__NR_Linux + 28)
522#define __NR_pause (__NR_Linux + 29)
523#define __NR_utime (__NR_Linux + 30)
524#define __NR_connect (__NR_Linux + 31)
525#define __NR_listen (__NR_Linux + 32)
526#define __NR_access (__NR_Linux + 33)
527#define __NR_nice (__NR_Linux + 34)
528#define __NR_accept (__NR_Linux + 35)
529#define __NR_sync (__NR_Linux + 36)
530#define __NR_kill (__NR_Linux + 37)
531#define __NR_rename (__NR_Linux + 38)
532#define __NR_mkdir (__NR_Linux + 39)
533#define __NR_rmdir (__NR_Linux + 40)
534#define __NR_dup (__NR_Linux + 41)
535#define __NR_pipe (__NR_Linux + 42)
536#define __NR_times (__NR_Linux + 43)
537#define __NR_getsockname (__NR_Linux + 44)
538#define __NR_brk (__NR_Linux + 45)
539#define __NR_setgid (__NR_Linux + 46)
540#define __NR_getgid (__NR_Linux + 47)
541#define __NR_signal (__NR_Linux + 48)
542#define __NR_geteuid (__NR_Linux + 49)
543#define __NR_getegid (__NR_Linux + 50)
544#define __NR_acct (__NR_Linux + 51)
545#define __NR_umount2 (__NR_Linux + 52)
546#define __NR_getpeername (__NR_Linux + 53)
547#define __NR_ioctl (__NR_Linux + 54)
548#define __NR_fcntl (__NR_Linux + 55)
549#define __NR_socketpair (__NR_Linux + 56)
550#define __NR_setpgid (__NR_Linux + 57)
551#define __NR_send (__NR_Linux + 58)
552#define __NR_uname (__NR_Linux + 59)
553#define __NR_umask (__NR_Linux + 60)
554#define __NR_chroot (__NR_Linux + 61)
555#define __NR_ustat (__NR_Linux + 62)
556#define __NR_dup2 (__NR_Linux + 63)
557#define __NR_getppid (__NR_Linux + 64)
558#define __NR_getpgrp (__NR_Linux + 65)
559#define __NR_setsid (__NR_Linux + 66)
560#define __NR_pivot_root (__NR_Linux + 67)
561#define __NR_sgetmask (__NR_Linux + 68)
562#define __NR_ssetmask (__NR_Linux + 69)
563#define __NR_setreuid (__NR_Linux + 70)
564#define __NR_setregid (__NR_Linux + 71)
565#define __NR_mincore (__NR_Linux + 72)
566#define __NR_sigpending (__NR_Linux + 73)
567#define __NR_sethostname (__NR_Linux + 74)
568#define __NR_setrlimit (__NR_Linux + 75)
569#define __NR_getrlimit (__NR_Linux + 76)
570#define __NR_getrusage (__NR_Linux + 77)
571#define __NR_gettimeofday (__NR_Linux + 78)
572#define __NR_settimeofday (__NR_Linux + 79)
573#define __NR_getgroups (__NR_Linux + 80)
574#define __NR_setgroups (__NR_Linux + 81)
575#define __NR_sendto (__NR_Linux + 82)
576#define __NR_symlink (__NR_Linux + 83)
577#define __NR_lstat (__NR_Linux + 84)
578#define __NR_readlink (__NR_Linux + 85)
579#define __NR_uselib (__NR_Linux + 86)
580#define __NR_swapon (__NR_Linux + 87)
581#define __NR_reboot (__NR_Linux + 88)
582#define __NR_mmap2 (__NR_Linux + 89)
583#define __NR_mmap (__NR_Linux + 90)
584#define __NR_munmap (__NR_Linux + 91)
585#define __NR_truncate (__NR_Linux + 92)
586#define __NR_ftruncate (__NR_Linux + 93)
587#define __NR_fchmod (__NR_Linux + 94)
588#define __NR_fchown (__NR_Linux + 95)
589#define __NR_getpriority (__NR_Linux + 96)
590#define __NR_setpriority (__NR_Linux + 97)
591#define __NR_recv (__NR_Linux + 98)
592#define __NR_statfs (__NR_Linux + 99)
593#define __NR_fstatfs (__NR_Linux + 100)
594#define __NR_stat64 (__NR_Linux + 101)
595/* #define __NR_socketcall (__NR_Linux + 102) */
596#define __NR_syslog (__NR_Linux + 103)
597#define __NR_setitimer (__NR_Linux + 104)
598#define __NR_getitimer (__NR_Linux + 105)
599#define __NR_capget (__NR_Linux + 106)
600#define __NR_capset (__NR_Linux + 107)
601#define __NR_pread64 (__NR_Linux + 108)
602#define __NR_pwrite64 (__NR_Linux + 109)
603#define __NR_getcwd (__NR_Linux + 110)
604#define __NR_vhangup (__NR_Linux + 111)
605#define __NR_fstat64 (__NR_Linux + 112)
606#define __NR_vfork (__NR_Linux + 113)
607#define __NR_wait4 (__NR_Linux + 114)
608#define __NR_swapoff (__NR_Linux + 115)
609#define __NR_sysinfo (__NR_Linux + 116)
610#define __NR_shutdown (__NR_Linux + 117)
611#define __NR_fsync (__NR_Linux + 118)
612#define __NR_madvise (__NR_Linux + 119)
613#define __NR_clone (__NR_Linux + 120)
614#define __NR_setdomainname (__NR_Linux + 121)
615#define __NR_sendfile (__NR_Linux + 122)
616#define __NR_recvfrom (__NR_Linux + 123)
617#define __NR_adjtimex (__NR_Linux + 124)
618#define __NR_mprotect (__NR_Linux + 125)
619#define __NR_sigprocmask (__NR_Linux + 126)
620#define __NR_create_module (__NR_Linux + 127)
621#define __NR_init_module (__NR_Linux + 128)
622#define __NR_delete_module (__NR_Linux + 129)
623#define __NR_get_kernel_syms (__NR_Linux + 130)
624#define __NR_quotactl (__NR_Linux + 131)
625#define __NR_getpgid (__NR_Linux + 132)
626#define __NR_fchdir (__NR_Linux + 133)
627#define __NR_bdflush (__NR_Linux + 134)
628#define __NR_sysfs (__NR_Linux + 135)
629#define __NR_personality (__NR_Linux + 136)
630#define __NR_afs_syscall (__NR_Linux + 137) /* Syscall for Andrew File System */
631#define __NR_setfsuid (__NR_Linux + 138)
632#define __NR_setfsgid (__NR_Linux + 139)
633#define __NR__llseek (__NR_Linux + 140)
634#define __NR_getdents (__NR_Linux + 141)
635#define __NR__newselect (__NR_Linux + 142)
636#define __NR_flock (__NR_Linux + 143)
637#define __NR_msync (__NR_Linux + 144)
638#define __NR_readv (__NR_Linux + 145)
639#define __NR_writev (__NR_Linux + 146)
640#define __NR_getsid (__NR_Linux + 147)
641#define __NR_fdatasync (__NR_Linux + 148)
642#define __NR__sysctl (__NR_Linux + 149)
643#define __NR_mlock (__NR_Linux + 150)
644#define __NR_munlock (__NR_Linux + 151)
645#define __NR_mlockall (__NR_Linux + 152)
646#define __NR_munlockall (__NR_Linux + 153)
647#define __NR_sched_setparam (__NR_Linux + 154)
648#define __NR_sched_getparam (__NR_Linux + 155)
649#define __NR_sched_setscheduler (__NR_Linux + 156)
650#define __NR_sched_getscheduler (__NR_Linux + 157)
651#define __NR_sched_yield (__NR_Linux + 158)
652#define __NR_sched_get_priority_max (__NR_Linux + 159)
653#define __NR_sched_get_priority_min (__NR_Linux + 160)
654#define __NR_sched_rr_get_interval (__NR_Linux + 161)
655#define __NR_nanosleep (__NR_Linux + 162)
656#define __NR_mremap (__NR_Linux + 163)
657#define __NR_setresuid (__NR_Linux + 164)
658#define __NR_getresuid (__NR_Linux + 165)
659#define __NR_sigaltstack (__NR_Linux + 166)
660#define __NR_query_module (__NR_Linux + 167)
661#define __NR_poll (__NR_Linux + 168)
662#define __NR_nfsservctl (__NR_Linux + 169)
663#define __NR_setresgid (__NR_Linux + 170)
664#define __NR_getresgid (__NR_Linux + 171)
665#define __NR_prctl (__NR_Linux + 172)
666#define __NR_rt_sigreturn (__NR_Linux + 173)
667#define __NR_rt_sigaction (__NR_Linux + 174)
668#define __NR_rt_sigprocmask (__NR_Linux + 175)
669#define __NR_rt_sigpending (__NR_Linux + 176)
670#define __NR_rt_sigtimedwait (__NR_Linux + 177)
671#define __NR_rt_sigqueueinfo (__NR_Linux + 178)
672#define __NR_rt_sigsuspend (__NR_Linux + 179)
673#define __NR_chown (__NR_Linux + 180)
674#define __NR_setsockopt (__NR_Linux + 181)
675#define __NR_getsockopt (__NR_Linux + 182)
676#define __NR_sendmsg (__NR_Linux + 183)
677#define __NR_recvmsg (__NR_Linux + 184)
678#define __NR_semop (__NR_Linux + 185)
679#define __NR_semget (__NR_Linux + 186)
680#define __NR_semctl (__NR_Linux + 187)
681#define __NR_msgsnd (__NR_Linux + 188)
682#define __NR_msgrcv (__NR_Linux + 189)
683#define __NR_msgget (__NR_Linux + 190)
684#define __NR_msgctl (__NR_Linux + 191)
685#define __NR_shmat (__NR_Linux + 192)
686#define __NR_shmdt (__NR_Linux + 193)
687#define __NR_shmget (__NR_Linux + 194)
688#define __NR_shmctl (__NR_Linux + 195)
689
690#define __NR_getpmsg (__NR_Linux + 196) /* Somebody *wants* streams? */
691#define __NR_putpmsg (__NR_Linux + 197)
692
693#define __NR_lstat64 (__NR_Linux + 198)
694#define __NR_truncate64 (__NR_Linux + 199)
695#define __NR_ftruncate64 (__NR_Linux + 200)
696#define __NR_getdents64 (__NR_Linux + 201)
697#define __NR_fcntl64 (__NR_Linux + 202)
698#define __NR_attrctl (__NR_Linux + 203)
699#define __NR_acl_get (__NR_Linux + 204)
700#define __NR_acl_set (__NR_Linux + 205)
701#define __NR_gettid (__NR_Linux + 206)
702#define __NR_readahead (__NR_Linux + 207)
703#define __NR_tkill (__NR_Linux + 208)
704#define __NR_sendfile64 (__NR_Linux + 209)
705#define __NR_futex (__NR_Linux + 210)
706#define __NR_sched_setaffinity (__NR_Linux + 211)
707#define __NR_sched_getaffinity (__NR_Linux + 212)
708#define __NR_set_thread_area (__NR_Linux + 213)
709#define __NR_get_thread_area (__NR_Linux + 214)
710#define __NR_io_setup (__NR_Linux + 215)
711#define __NR_io_destroy (__NR_Linux + 216)
712#define __NR_io_getevents (__NR_Linux + 217)
713#define __NR_io_submit (__NR_Linux + 218)
714#define __NR_io_cancel (__NR_Linux + 219)
715#define __NR_alloc_hugepages (__NR_Linux + 220)
716#define __NR_free_hugepages (__NR_Linux + 221)
717#define __NR_exit_group (__NR_Linux + 222)
718#define __NR_lookup_dcookie (__NR_Linux + 223)
719#define __NR_epoll_create (__NR_Linux + 224)
720#define __NR_epoll_ctl (__NR_Linux + 225)
721#define __NR_epoll_wait (__NR_Linux + 226)
722#define __NR_remap_file_pages (__NR_Linux + 227)
723#define __NR_semtimedop (__NR_Linux + 228)
724#define __NR_mq_open (__NR_Linux + 229)
725#define __NR_mq_unlink (__NR_Linux + 230)
726#define __NR_mq_timedsend (__NR_Linux + 231)
727#define __NR_mq_timedreceive (__NR_Linux + 232)
728#define __NR_mq_notify (__NR_Linux + 233)
729#define __NR_mq_getsetattr (__NR_Linux + 234)
730#define __NR_waitid (__NR_Linux + 235)
731#define __NR_fadvise64_64 (__NR_Linux + 236)
732#define __NR_set_tid_address (__NR_Linux + 237)
733#define __NR_setxattr (__NR_Linux + 238)
734#define __NR_lsetxattr (__NR_Linux + 239)
735#define __NR_fsetxattr (__NR_Linux + 240)
736#define __NR_getxattr (__NR_Linux + 241)
737#define __NR_lgetxattr (__NR_Linux + 242)
738#define __NR_fgetxattr (__NR_Linux + 243)
739#define __NR_listxattr (__NR_Linux + 244)
740#define __NR_llistxattr (__NR_Linux + 245)
741#define __NR_flistxattr (__NR_Linux + 246)
742#define __NR_removexattr (__NR_Linux + 247)
743#define __NR_lremovexattr (__NR_Linux + 248)
744#define __NR_fremovexattr (__NR_Linux + 249)
745#define __NR_timer_create (__NR_Linux + 250)
746#define __NR_timer_settime (__NR_Linux + 251)
747#define __NR_timer_gettime (__NR_Linux + 252)
748#define __NR_timer_getoverrun (__NR_Linux + 253)
749#define __NR_timer_delete (__NR_Linux + 254)
750#define __NR_clock_settime (__NR_Linux + 255)
751#define __NR_clock_gettime (__NR_Linux + 256)
752#define __NR_clock_getres (__NR_Linux + 257)
753#define __NR_clock_nanosleep (__NR_Linux + 258)
754#define __NR_tgkill (__NR_Linux + 259)
755#define __NR_mbind (__NR_Linux + 260)
756#define __NR_get_mempolicy (__NR_Linux + 261)
757#define __NR_set_mempolicy (__NR_Linux + 262)
758#define __NR_vserver (__NR_Linux + 263)
759#define __NR_add_key (__NR_Linux + 264)
760#define __NR_request_key (__NR_Linux + 265)
761#define __NR_keyctl (__NR_Linux + 266)
762#define __NR_ioprio_set (__NR_Linux + 267)
763#define __NR_ioprio_get (__NR_Linux + 268)
764#define __NR_inotify_init (__NR_Linux + 269)
765#define __NR_inotify_add_watch (__NR_Linux + 270)
766#define __NR_inotify_rm_watch (__NR_Linux + 271)
767#define __NR_migrate_pages (__NR_Linux + 272)
768#define __NR_pselect6 (__NR_Linux + 273)
769#define __NR_ppoll (__NR_Linux + 274)
770#define __NR_openat (__NR_Linux + 275)
771#define __NR_mkdirat (__NR_Linux + 276)
772#define __NR_mknodat (__NR_Linux + 277)
773#define __NR_fchownat (__NR_Linux + 278)
774#define __NR_futimesat (__NR_Linux + 279)
775#define __NR_fstatat64 (__NR_Linux + 280)
776#define __NR_unlinkat (__NR_Linux + 281)
777#define __NR_renameat (__NR_Linux + 282)
778#define __NR_linkat (__NR_Linux + 283)
779#define __NR_symlinkat (__NR_Linux + 284)
780#define __NR_readlinkat (__NR_Linux + 285)
781#define __NR_fchmodat (__NR_Linux + 286)
782#define __NR_faccessat (__NR_Linux + 287)
783#define __NR_unshare (__NR_Linux + 288)
784#define __NR_set_robust_list (__NR_Linux + 289)
785#define __NR_get_robust_list (__NR_Linux + 290)
786#define __NR_splice (__NR_Linux + 291)
787#define __NR_sync_file_range (__NR_Linux + 292)
788#define __NR_tee (__NR_Linux + 293)
789#define __NR_vmsplice (__NR_Linux + 294)
790#define __NR_move_pages (__NR_Linux + 295)
791#define __NR_getcpu (__NR_Linux + 296)
792#define __NR_epoll_pwait (__NR_Linux + 297)
793#define __NR_statfs64 (__NR_Linux + 298)
794#define __NR_fstatfs64 (__NR_Linux + 299)
795#define __NR_kexec_load (__NR_Linux + 300)
796#define __NR_utimensat (__NR_Linux + 301)
797#define __NR_signalfd (__NR_Linux + 302)
798#define __NR_timerfd (__NR_Linux + 303)
799#define __NR_eventfd (__NR_Linux + 304)
800#define __NR_fallocate (__NR_Linux + 305)
801#define __NR_timerfd_create (__NR_Linux + 306)
802#define __NR_timerfd_settime (__NR_Linux + 307)
803#define __NR_timerfd_gettime (__NR_Linux + 308)
804#define __NR_signalfd4 (__NR_Linux + 309)
805#define __NR_eventfd2 (__NR_Linux + 310)
806#define __NR_epoll_create1 (__NR_Linux + 311)
807#define __NR_dup3 (__NR_Linux + 312)
808#define __NR_pipe2 (__NR_Linux + 313)
809#define __NR_inotify_init1 (__NR_Linux + 314)
810#define __NR_preadv (__NR_Linux + 315)
811#define __NR_pwritev (__NR_Linux + 316)
812#define __NR_rt_tgsigqueueinfo (__NR_Linux + 317)
813#define __NR_perf_event_open (__NR_Linux + 318)
814#define __NR_recvmmsg (__NR_Linux + 319)
815#define __NR_accept4 (__NR_Linux + 320)
816#define __NR_prlimit64 (__NR_Linux + 321)
817#define __NR_fanotify_init (__NR_Linux + 322)
818#define __NR_fanotify_mark (__NR_Linux + 323)
819#define __NR_clock_adjtime (__NR_Linux + 324)
820#define __NR_name_to_handle_at (__NR_Linux + 325)
821#define __NR_open_by_handle_at (__NR_Linux + 326)
822#define __NR_syncfs (__NR_Linux + 327)
823#define __NR_setns (__NR_Linux + 328)
824#define __NR_sendmmsg (__NR_Linux + 329)
825
826#define __NR_Linux_syscalls (__NR_sendmmsg + 1)
827
828
829#define __IGNORE_select /* newselect */
830#define __IGNORE_fadvise64 /* fadvise64_64 */
831#define __IGNORE_utimes /* utime */
832
833
834#define HPUX_GATEWAY_ADDR 0xC0000004
835#define LINUX_GATEWAY_ADDR 0x100
836 5
837#ifdef __KERNEL__
838#ifndef __ASSEMBLY__ 6#ifndef __ASSEMBLY__
839 7
840#define SYS_ify(syscall_name) __NR_##syscall_name 8#define SYS_ify(syscall_name) __NR_##syscall_name
@@ -995,6 +163,7 @@ type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \
995#define __ARCH_WANT_SYS_RT_SIGACTION 163#define __ARCH_WANT_SYS_RT_SIGACTION
996#define __ARCH_WANT_SYS_RT_SIGSUSPEND 164#define __ARCH_WANT_SYS_RT_SIGSUSPEND
997#define __ARCH_WANT_COMPAT_SYS_RT_SIGSUSPEND 165#define __ARCH_WANT_COMPAT_SYS_RT_SIGSUSPEND
166#define __ARCH_WANT_SYS_EXECVE
998 167
999#endif /* __ASSEMBLY__ */ 168#endif /* __ASSEMBLY__ */
1000 169
@@ -1008,5 +177,4 @@ type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \
1008 */ 177 */
1009#define cond_syscall(x) asm(".weak\t" #x "\n\t.set\t" #x ",sys_ni_syscall") 178#define cond_syscall(x) asm(".weak\t" #x "\n\t.set\t" #x ",sys_ni_syscall")
1010 179
1011#endif /* __KERNEL__ */
1012#endif /* _ASM_PARISC_UNISTD_H_ */ 180#endif /* _ASM_PARISC_UNISTD_H_ */
diff --git a/arch/parisc/include/asm/user.h b/arch/parisc/include/asm/user.h
deleted file mode 100644
index 80224753e50..00000000000
--- a/arch/parisc/include/asm/user.h
+++ /dev/null
@@ -1,5 +0,0 @@
1/* This file should not exist, but lots of generic code still includes
2 it. It's a hangover from old a.out days and the traditional core
3 dump format. We are ELF-only, and so are our core dumps. If we
4 need to support HP/UX core format then we'll do it here
5 eventually. */
diff --git a/arch/parisc/include/asm/vga.h b/arch/parisc/include/asm/vga.h
deleted file mode 100644
index 171399a88ca..00000000000
--- a/arch/parisc/include/asm/vga.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef __ASM_PARISC_VGA_H__
2#define __ASM_PARISC_VGA_H__
3
4/* nothing */
5
6#endif /* __ASM_PARISC_VGA_H__ */
diff --git a/arch/parisc/include/asm/xor.h b/arch/parisc/include/asm/xor.h
deleted file mode 100644
index c82eb12a5b1..00000000000
--- a/arch/parisc/include/asm/xor.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-generic/xor.h>
diff --git a/arch/parisc/include/uapi/asm/Kbuild b/arch/parisc/include/uapi/asm/Kbuild
index baebb3da1d4..a580642555b 100644
--- a/arch/parisc/include/uapi/asm/Kbuild
+++ b/arch/parisc/include/uapi/asm/Kbuild
@@ -1,3 +1,31 @@
1# UAPI Header export list 1# UAPI Header export list
2include include/uapi/asm-generic/Kbuild.asm 2include include/uapi/asm-generic/Kbuild.asm
3 3
4header-y += bitsperlong.h
5header-y += byteorder.h
6header-y += errno.h
7header-y += fcntl.h
8header-y += ioctl.h
9header-y += ioctls.h
10header-y += ipcbuf.h
11header-y += mman.h
12header-y += msgbuf.h
13header-y += pdc.h
14header-y += posix_types.h
15header-y += ptrace.h
16header-y += resource.h
17header-y += sembuf.h
18header-y += setup.h
19header-y += shmbuf.h
20header-y += sigcontext.h
21header-y += siginfo.h
22header-y += signal.h
23header-y += socket.h
24header-y += sockios.h
25header-y += stat.h
26header-y += statfs.h
27header-y += swab.h
28header-y += termbits.h
29header-y += termios.h
30header-y += types.h
31header-y += unistd.h
diff --git a/arch/parisc/include/asm/bitsperlong.h b/arch/parisc/include/uapi/asm/bitsperlong.h
index 75196b415d3..75196b415d3 100644
--- a/arch/parisc/include/asm/bitsperlong.h
+++ b/arch/parisc/include/uapi/asm/bitsperlong.h
diff --git a/arch/parisc/include/asm/byteorder.h b/arch/parisc/include/uapi/asm/byteorder.h
index 58af2c5f5d6..58af2c5f5d6 100644
--- a/arch/parisc/include/asm/byteorder.h
+++ b/arch/parisc/include/uapi/asm/byteorder.h
diff --git a/arch/parisc/include/asm/errno.h b/arch/parisc/include/uapi/asm/errno.h
index 135ad6047e5..135ad6047e5 100644
--- a/arch/parisc/include/asm/errno.h
+++ b/arch/parisc/include/uapi/asm/errno.h
diff --git a/arch/parisc/include/asm/fcntl.h b/arch/parisc/include/uapi/asm/fcntl.h
index 0304b92ccfe..0304b92ccfe 100644
--- a/arch/parisc/include/asm/fcntl.h
+++ b/arch/parisc/include/uapi/asm/fcntl.h
diff --git a/arch/parisc/include/asm/ioctl.h b/arch/parisc/include/uapi/asm/ioctl.h
index ec8efa02bed..ec8efa02bed 100644
--- a/arch/parisc/include/asm/ioctl.h
+++ b/arch/parisc/include/uapi/asm/ioctl.h
diff --git a/arch/parisc/include/asm/ioctls.h b/arch/parisc/include/uapi/asm/ioctls.h
index 054ec06f9e2..054ec06f9e2 100644
--- a/arch/parisc/include/asm/ioctls.h
+++ b/arch/parisc/include/uapi/asm/ioctls.h
diff --git a/arch/parisc/include/asm/ipcbuf.h b/arch/parisc/include/uapi/asm/ipcbuf.h
index bd956c42578..bd956c42578 100644
--- a/arch/parisc/include/asm/ipcbuf.h
+++ b/arch/parisc/include/uapi/asm/ipcbuf.h
diff --git a/arch/parisc/include/asm/mman.h b/arch/parisc/include/uapi/asm/mman.h
index 12219ebce86..12219ebce86 100644
--- a/arch/parisc/include/asm/mman.h
+++ b/arch/parisc/include/uapi/asm/mman.h
diff --git a/arch/parisc/include/asm/msgbuf.h b/arch/parisc/include/uapi/asm/msgbuf.h
index fe88f264941..fe88f264941 100644
--- a/arch/parisc/include/asm/msgbuf.h
+++ b/arch/parisc/include/uapi/asm/msgbuf.h
diff --git a/arch/parisc/include/uapi/asm/pdc.h b/arch/parisc/include/uapi/asm/pdc.h
new file mode 100644
index 00000000000..702498f7705
--- /dev/null
+++ b/arch/parisc/include/uapi/asm/pdc.h
@@ -0,0 +1,427 @@
1#ifndef _UAPI_PARISC_PDC_H
2#define _UAPI_PARISC_PDC_H
3
4/*
5 * PDC return values ...
6 * All PDC calls return a subset of these errors.
7 */
8
9#define PDC_WARN 3 /* Call completed with a warning */
10#define PDC_REQ_ERR_1 2 /* See above */
11#define PDC_REQ_ERR_0 1 /* Call would generate a requestor error */
12#define PDC_OK 0 /* Call completed successfully */
13#define PDC_BAD_PROC -1 /* Called non-existent procedure*/
14#define PDC_BAD_OPTION -2 /* Called with non-existent option */
15#define PDC_ERROR -3 /* Call could not complete without an error */
16#define PDC_NE_MOD -5 /* Module not found */
17#define PDC_NE_CELL_MOD -7 /* Cell module not found */
18#define PDC_INVALID_ARG -10 /* Called with an invalid argument */
19#define PDC_BUS_POW_WARN -12 /* Call could not complete in allowed power budget */
20#define PDC_NOT_NARROW -17 /* Narrow mode not supported */
21
22/*
23 * PDC entry points...
24 */
25
26#define PDC_POW_FAIL 1 /* perform a power-fail */
27#define PDC_POW_FAIL_PREPARE 0 /* prepare for powerfail */
28
29#define PDC_CHASSIS 2 /* PDC-chassis functions */
30#define PDC_CHASSIS_DISP 0 /* update chassis display */
31#define PDC_CHASSIS_WARN 1 /* return chassis warnings */
32#define PDC_CHASSIS_DISPWARN 2 /* update&return chassis status */
33#define PDC_RETURN_CHASSIS_INFO 128 /* HVERSION dependent: return chassis LED/LCD info */
34
35#define PDC_PIM 3 /* Get PIM data */
36#define PDC_PIM_HPMC 0 /* Transfer HPMC data */
37#define PDC_PIM_RETURN_SIZE 1 /* Get Max buffer needed for PIM*/
38#define PDC_PIM_LPMC 2 /* Transfer HPMC data */
39#define PDC_PIM_SOFT_BOOT 3 /* Transfer Soft Boot data */
40#define PDC_PIM_TOC 4 /* Transfer TOC data */
41
42#define PDC_MODEL 4 /* PDC model information call */
43#define PDC_MODEL_INFO 0 /* returns information */
44#define PDC_MODEL_BOOTID 1 /* set the BOOT_ID */
45#define PDC_MODEL_VERSIONS 2 /* returns cpu-internal versions*/
46#define PDC_MODEL_SYSMODEL 3 /* return system model info */
47#define PDC_MODEL_ENSPEC 4 /* enable specific option */
48#define PDC_MODEL_DISPEC 5 /* disable specific option */
49#define PDC_MODEL_CPU_ID 6 /* returns cpu-id (only newer machines!) */
50#define PDC_MODEL_CAPABILITIES 7 /* returns OS32/OS64-flags */
51/* Values for PDC_MODEL_CAPABILITIES non-equivalent virtual aliasing support */
52#define PDC_MODEL_OS64 (1 << 0)
53#define PDC_MODEL_OS32 (1 << 1)
54#define PDC_MODEL_IOPDIR_FDC (1 << 2)
55#define PDC_MODEL_NVA_MASK (3 << 4)
56#define PDC_MODEL_NVA_SUPPORTED (0 << 4)
57#define PDC_MODEL_NVA_SLOW (1 << 4)
58#define PDC_MODEL_NVA_UNSUPPORTED (3 << 4)
59#define PDC_MODEL_GET_BOOT__OP 8 /* returns boot test options */
60#define PDC_MODEL_SET_BOOT__OP 9 /* set boot test options */
61
62#define PA89_INSTRUCTION_SET 0x4 /* capatibilies returned */
63#define PA90_INSTRUCTION_SET 0x8
64
65#define PDC_CACHE 5 /* return/set cache (& TLB) info*/
66#define PDC_CACHE_INFO 0 /* returns information */
67#define PDC_CACHE_SET_COH 1 /* set coherence state */
68#define PDC_CACHE_RET_SPID 2 /* returns space-ID bits */
69
70#define PDC_HPA 6 /* return HPA of processor */
71#define PDC_HPA_PROCESSOR 0
72#define PDC_HPA_MODULES 1
73
74#define PDC_COPROC 7 /* Co-Processor (usually FP unit(s)) */
75#define PDC_COPROC_CFG 0 /* Co-Processor Cfg (FP unit(s) enabled?) */
76
77#define PDC_IODC 8 /* talk to IODC */
78#define PDC_IODC_READ 0 /* read IODC entry point */
79/* PDC_IODC_RI_ * INDEX parameter of PDC_IODC_READ */
80#define PDC_IODC_RI_DATA_BYTES 0 /* IODC Data Bytes */
81/* 1, 2 obsolete - HVERSION dependent*/
82#define PDC_IODC_RI_INIT 3 /* Initialize module */
83#define PDC_IODC_RI_IO 4 /* Module input/output */
84#define PDC_IODC_RI_SPA 5 /* Module input/output */
85#define PDC_IODC_RI_CONFIG 6 /* Module input/output */
86/* 7 obsolete - HVERSION dependent */
87#define PDC_IODC_RI_TEST 8 /* Module input/output */
88#define PDC_IODC_RI_TLB 9 /* Module input/output */
89#define PDC_IODC_NINIT 2 /* non-destructive init */
90#define PDC_IODC_DINIT 3 /* destructive init */
91#define PDC_IODC_MEMERR 4 /* check for memory errors */
92#define PDC_IODC_INDEX_DATA 0 /* get first 16 bytes from mod IODC */
93#define PDC_IODC_BUS_ERROR -4 /* bus error return value */
94#define PDC_IODC_INVALID_INDEX -5 /* invalid index return value */
95#define PDC_IODC_COUNT -6 /* count is too small */
96
97#define PDC_TOD 9 /* time-of-day clock (TOD) */
98#define PDC_TOD_READ 0 /* read TOD */
99#define PDC_TOD_WRITE 1 /* write TOD */
100
101
102#define PDC_STABLE 10 /* stable storage (sprockets) */
103#define PDC_STABLE_READ 0
104#define PDC_STABLE_WRITE 1
105#define PDC_STABLE_RETURN_SIZE 2
106#define PDC_STABLE_VERIFY_CONTENTS 3
107#define PDC_STABLE_INITIALIZE 4
108
109#define PDC_NVOLATILE 11 /* often not implemented */
110
111#define PDC_ADD_VALID 12 /* Memory validation PDC call */
112#define PDC_ADD_VALID_VERIFY 0 /* Make PDC_ADD_VALID verify region */
113
114#define PDC_INSTR 15 /* get instr to invoke PDCE_CHECK() */
115
116#define PDC_PROC 16 /* (sprockets) */
117
118#define PDC_CONFIG 16 /* (sprockets) */
119#define PDC_CONFIG_DECONFIG 0
120#define PDC_CONFIG_DRECONFIG 1
121#define PDC_CONFIG_DRETURN_CONFIG 2
122
123#define PDC_BLOCK_TLB 18 /* manage hardware block-TLB */
124#define PDC_BTLB_INFO 0 /* returns parameter */
125#define PDC_BTLB_INSERT 1 /* insert BTLB entry */
126#define PDC_BTLB_PURGE 2 /* purge BTLB entries */
127#define PDC_BTLB_PURGE_ALL 3 /* purge all BTLB entries */
128
129#define PDC_TLB 19 /* manage hardware TLB miss handling */
130#define PDC_TLB_INFO 0 /* returns parameter */
131#define PDC_TLB_SETUP 1 /* set up miss handling */
132
133#define PDC_MEM 20 /* Manage memory */
134#define PDC_MEM_MEMINFO 0
135#define PDC_MEM_ADD_PAGE 1
136#define PDC_MEM_CLEAR_PDT 2
137#define PDC_MEM_READ_PDT 3
138#define PDC_MEM_RESET_CLEAR 4
139#define PDC_MEM_GOODMEM 5
140#define PDC_MEM_TABLE 128 /* Non contig mem map (sprockets) */
141#define PDC_MEM_RETURN_ADDRESS_TABLE PDC_MEM_TABLE
142#define PDC_MEM_GET_MEMORY_SYSTEM_TABLES_SIZE 131
143#define PDC_MEM_GET_MEMORY_SYSTEM_TABLES 132
144#define PDC_MEM_GET_PHYSICAL_LOCATION_FROM_MEMORY_ADDRESS 133
145
146#define PDC_MEM_RET_SBE_REPLACED 5 /* PDC_MEM return values */
147#define PDC_MEM_RET_DUPLICATE_ENTRY 4
148#define PDC_MEM_RET_BUF_SIZE_SMALL 1
149#define PDC_MEM_RET_PDT_FULL -11
150#define PDC_MEM_RET_INVALID_PHYSICAL_LOCATION ~0ULL
151
152#define PDC_PSW 21 /* Get/Set default System Mask */
153#define PDC_PSW_MASK 0 /* Return mask */
154#define PDC_PSW_GET_DEFAULTS 1 /* Return defaults */
155#define PDC_PSW_SET_DEFAULTS 2 /* Set default */
156#define PDC_PSW_ENDIAN_BIT 1 /* set for big endian */
157#define PDC_PSW_WIDE_BIT 2 /* set for wide mode */
158
159#define PDC_SYSTEM_MAP 22 /* find system modules */
160#define PDC_FIND_MODULE 0
161#define PDC_FIND_ADDRESS 1
162#define PDC_TRANSLATE_PATH 2
163
164#define PDC_SOFT_POWER 23 /* soft power switch */
165#define PDC_SOFT_POWER_INFO 0 /* return info about the soft power switch */
166#define PDC_SOFT_POWER_ENABLE 1 /* enable/disable soft power switch */
167
168
169/* HVERSION dependent */
170
171/* The PDC_MEM_MAP calls */
172#define PDC_MEM_MAP 128 /* on s700: return page info */
173#define PDC_MEM_MAP_HPA 0 /* returns hpa of a module */
174
175#define PDC_EEPROM 129 /* EEPROM access */
176#define PDC_EEPROM_READ_WORD 0
177#define PDC_EEPROM_WRITE_WORD 1
178#define PDC_EEPROM_READ_BYTE 2
179#define PDC_EEPROM_WRITE_BYTE 3
180#define PDC_EEPROM_EEPROM_PASSWORD -1000
181
182#define PDC_NVM 130 /* NVM (non-volatile memory) access */
183#define PDC_NVM_READ_WORD 0
184#define PDC_NVM_WRITE_WORD 1
185#define PDC_NVM_READ_BYTE 2
186#define PDC_NVM_WRITE_BYTE 3
187
188#define PDC_SEED_ERROR 132 /* (sprockets) */
189
190#define PDC_IO 135 /* log error info, reset IO system */
191#define PDC_IO_READ_AND_CLEAR_ERRORS 0
192#define PDC_IO_RESET 1
193#define PDC_IO_RESET_DEVICES 2
194/* sets bits 6&7 (little endian) of the HcControl Register */
195#define PDC_IO_USB_SUSPEND 0xC000000000000000
196#define PDC_IO_EEPROM_IO_ERR_TABLE_FULL -5 /* return value */
197#define PDC_IO_NO_SUSPEND -6 /* return value */
198
199#define PDC_BROADCAST_RESET 136 /* reset all processors */
200#define PDC_DO_RESET 0 /* option: perform a broadcast reset */
201#define PDC_DO_FIRM_TEST_RESET 1 /* Do broadcast reset with bitmap */
202#define PDC_BR_RECONFIGURATION 2 /* reset w/reconfiguration */
203#define PDC_FIRM_TEST_MAGIC 0xab9ec36fUL /* for this reboot only */
204
205#define PDC_LAN_STATION_ID 138 /* Hversion dependent mechanism for */
206#define PDC_LAN_STATION_ID_READ 0 /* getting the lan station address */
207
208#define PDC_LAN_STATION_ID_SIZE 6
209
210#define PDC_CHECK_RANGES 139 /* (sprockets) */
211
212#define PDC_NV_SECTIONS 141 /* (sprockets) */
213
214#define PDC_PERFORMANCE 142 /* performance monitoring */
215
216#define PDC_SYSTEM_INFO 143 /* system information */
217#define PDC_SYSINFO_RETURN_INFO_SIZE 0
218#define PDC_SYSINFO_RRETURN_SYS_INFO 1
219#define PDC_SYSINFO_RRETURN_ERRORS 2
220#define PDC_SYSINFO_RRETURN_WARNINGS 3
221#define PDC_SYSINFO_RETURN_REVISIONS 4
222#define PDC_SYSINFO_RRETURN_DIAGNOSE 5
223#define PDC_SYSINFO_RRETURN_HV_DIAGNOSE 1005
224
225#define PDC_RDR 144 /* (sprockets) */
226#define PDC_RDR_READ_BUFFER 0
227#define PDC_RDR_READ_SINGLE 1
228#define PDC_RDR_WRITE_SINGLE 2
229
230#define PDC_INTRIGUE 145 /* (sprockets) */
231#define PDC_INTRIGUE_WRITE_BUFFER 0
232#define PDC_INTRIGUE_GET_SCRATCH_BUFSIZE 1
233#define PDC_INTRIGUE_START_CPU_COUNTERS 2
234#define PDC_INTRIGUE_STOP_CPU_COUNTERS 3
235
236#define PDC_STI 146 /* STI access */
237/* same as PDC_PCI_XXX values (see below) */
238
239/* Legacy PDC definitions for same stuff */
240#define PDC_PCI_INDEX 147
241#define PDC_PCI_INTERFACE_INFO 0
242#define PDC_PCI_SLOT_INFO 1
243#define PDC_PCI_INFLIGHT_BYTES 2
244#define PDC_PCI_READ_CONFIG 3
245#define PDC_PCI_WRITE_CONFIG 4
246#define PDC_PCI_READ_PCI_IO 5
247#define PDC_PCI_WRITE_PCI_IO 6
248#define PDC_PCI_READ_CONFIG_DELAY 7
249#define PDC_PCI_UPDATE_CONFIG_DELAY 8
250#define PDC_PCI_PCI_PATH_TO_PCI_HPA 9
251#define PDC_PCI_PCI_HPA_TO_PCI_PATH 10
252#define PDC_PCI_PCI_PATH_TO_PCI_BUS 11
253#define PDC_PCI_PCI_RESERVED 12
254#define PDC_PCI_PCI_INT_ROUTE_SIZE 13
255#define PDC_PCI_GET_INT_TBL_SIZE PDC_PCI_PCI_INT_ROUTE_SIZE
256#define PDC_PCI_PCI_INT_ROUTE 14
257#define PDC_PCI_GET_INT_TBL PDC_PCI_PCI_INT_ROUTE
258#define PDC_PCI_READ_MON_TYPE 15
259#define PDC_PCI_WRITE_MON_TYPE 16
260
261
262/* Get SCSI Interface Card info: SDTR, SCSI ID, mode (SE vs LVD) */
263#define PDC_INITIATOR 163
264#define PDC_GET_INITIATOR 0
265#define PDC_SET_INITIATOR 1
266#define PDC_DELETE_INITIATOR 2
267#define PDC_RETURN_TABLE_SIZE 3
268#define PDC_RETURN_TABLE 4
269
270#define PDC_LINK 165 /* (sprockets) */
271#define PDC_LINK_PCI_ENTRY_POINTS 0 /* list (Arg1) = 0 */
272#define PDC_LINK_USB_ENTRY_POINTS 1 /* list (Arg1) = 1 */
273
274/* cl_class
275 * page 3-33 of IO-Firmware ARS
276 * IODC ENTRY_INIT(Search first) RET[1]
277 */
278#define CL_NULL 0 /* invalid */
279#define CL_RANDOM 1 /* random access (as disk) */
280#define CL_SEQU 2 /* sequential access (as tape) */
281#define CL_DUPLEX 7 /* full-duplex point-to-point (RS-232, Net) */
282#define CL_KEYBD 8 /* half-duplex console (HIL Keyboard) */
283#define CL_DISPL 9 /* half-duplex console (display) */
284#define CL_FC 10 /* FiberChannel access media */
285
286/* IODC ENTRY_INIT() */
287#define ENTRY_INIT_SRCH_FRST 2
288#define ENTRY_INIT_SRCH_NEXT 3
289#define ENTRY_INIT_MOD_DEV 4
290#define ENTRY_INIT_DEV 5
291#define ENTRY_INIT_MOD 6
292#define ENTRY_INIT_MSG 9
293
294/* IODC ENTRY_IO() */
295#define ENTRY_IO_BOOTIN 0
296#define ENTRY_IO_BOOTOUT 1
297#define ENTRY_IO_CIN 2
298#define ENTRY_IO_COUT 3
299#define ENTRY_IO_CLOSE 4
300#define ENTRY_IO_GETMSG 9
301#define ENTRY_IO_BBLOCK_IN 16
302#define ENTRY_IO_BBLOCK_OUT 17
303
304/* IODC ENTRY_SPA() */
305
306/* IODC ENTRY_CONFIG() */
307
308/* IODC ENTRY_TEST() */
309
310/* IODC ENTRY_TLB() */
311
312/* constants for OS (NVM...) */
313#define OS_ID_NONE 0 /* Undefined OS ID */
314#define OS_ID_HPUX 1 /* HP-UX OS */
315#define OS_ID_MPEXL 2 /* MPE XL OS */
316#define OS_ID_OSF 3 /* OSF OS */
317#define OS_ID_HPRT 4 /* HP-RT OS */
318#define OS_ID_NOVEL 5 /* NOVELL OS */
319#define OS_ID_LINUX 6 /* Linux */
320
321
322/* constants for PDC_CHASSIS */
323#define OSTAT_OFF 0
324#define OSTAT_FLT 1
325#define OSTAT_TEST 2
326#define OSTAT_INIT 3
327#define OSTAT_SHUT 4
328#define OSTAT_WARN 5
329#define OSTAT_RUN 6
330#define OSTAT_ON 7
331
332/* Page Zero constant offsets used by the HPMC handler */
333#define BOOT_CONSOLE_HPA_OFFSET 0x3c0
334#define BOOT_CONSOLE_SPA_OFFSET 0x3c4
335#define BOOT_CONSOLE_PATH_OFFSET 0x3a8
336
337/* size of the pdc_result buffer for firmware.c */
338#define NUM_PDC_RESULT 32
339
340#if !defined(__ASSEMBLY__)
341
342#include <linux/types.h>
343
344
345/* flags of the device_path */
346#define PF_AUTOBOOT 0x80
347#define PF_AUTOSEARCH 0x40
348#define PF_TIMER 0x0F
349
350struct device_path { /* page 1-69 */
351 unsigned char flags; /* flags see above! */
352 unsigned char bc[6]; /* bus converter routing info */
353 unsigned char mod;
354 unsigned int layers[6];/* device-specific layer-info */
355} __attribute__((aligned(8))) ;
356
357struct pz_device {
358 struct device_path dp; /* see above */
359 /* struct iomod *hpa; */
360 unsigned int hpa; /* HPA base address */
361 /* char *spa; */
362 unsigned int spa; /* SPA base address */
363 /* int (*iodc_io)(struct iomod*, ...); */
364 unsigned int iodc_io; /* device entry point */
365 short pad; /* reserved */
366 unsigned short cl_class;/* see below */
367} __attribute__((aligned(8))) ;
368
369struct zeropage {
370 /* [0x000] initialize vectors (VEC) */
371 unsigned int vec_special; /* must be zero */
372 /* int (*vec_pow_fail)(void);*/
373 unsigned int vec_pow_fail; /* power failure handler */
374 /* int (*vec_toc)(void); */
375 unsigned int vec_toc;
376 unsigned int vec_toclen;
377 /* int (*vec_rendz)(void); */
378 unsigned int vec_rendz;
379 int vec_pow_fail_flen;
380 int vec_pad[10];
381
382 /* [0x040] reserved processor dependent */
383 int pad0[112];
384
385 /* [0x200] reserved */
386 int pad1[84];
387
388 /* [0x350] memory configuration (MC) */
389 int memc_cont; /* contiguous mem size (bytes) */
390 int memc_phsize; /* physical memory size */
391 int memc_adsize; /* additional mem size, bytes of SPA space used by PDC */
392 unsigned int mem_pdc_hi; /* used for 64-bit */
393
394 /* [0x360] various parameters for the boot-CPU */
395 /* unsigned int *mem_booterr[8]; */
396 unsigned int mem_booterr[8]; /* ptr to boot errors */
397 unsigned int mem_free; /* first location, where OS can be loaded */
398 /* struct iomod *mem_hpa; */
399 unsigned int mem_hpa; /* HPA of the boot-CPU */
400 /* int (*mem_pdc)(int, ...); */
401 unsigned int mem_pdc; /* PDC entry point */
402 unsigned int mem_10msec; /* number of clock ticks in 10msec */
403
404 /* [0x390] initial memory module (IMM) */
405 /* struct iomod *imm_hpa; */
406 unsigned int imm_hpa; /* HPA of the IMM */
407 int imm_soft_boot; /* 0 = was hard boot, 1 = was soft boot */
408 unsigned int imm_spa_size; /* SPA size of the IMM in bytes */
409 unsigned int imm_max_mem; /* bytes of mem in IMM */
410
411 /* [0x3A0] boot console, display device and keyboard */
412 struct pz_device mem_cons; /* description of console device */
413 struct pz_device mem_boot; /* description of boot device */
414 struct pz_device mem_kbd; /* description of keyboard device */
415
416 /* [0x430] reserved */
417 int pad430[116];
418
419 /* [0x600] processor dependent */
420 __u32 pad600[1];
421 __u32 proc_sti; /* pointer to STI ROM */
422 __u32 pad608[126];
423};
424
425#endif /* !defined(__ASSEMBLY__) */
426
427#endif /* _UAPI_PARISC_PDC_H */
diff --git a/arch/parisc/include/asm/posix_types.h b/arch/parisc/include/uapi/asm/posix_types.h
index b9344256f76..b9344256f76 100644
--- a/arch/parisc/include/asm/posix_types.h
+++ b/arch/parisc/include/uapi/asm/posix_types.h
diff --git a/arch/parisc/include/uapi/asm/ptrace.h b/arch/parisc/include/uapi/asm/ptrace.h
new file mode 100644
index 00000000000..c4fa6c8b9ad
--- /dev/null
+++ b/arch/parisc/include/uapi/asm/ptrace.h
@@ -0,0 +1,47 @@
1/* written by Philipp Rumpf, Copyright (C) 1999 SuSE GmbH Nuernberg
2** Copyright (C) 2000 Grant Grundler, Hewlett-Packard
3*/
4#ifndef _UAPI_PARISC_PTRACE_H
5#define _UAPI_PARISC_PTRACE_H
6
7
8#include <linux/types.h>
9
10/* This struct defines the way the registers are stored on the
11 * stack during a system call.
12 *
13 * N.B. gdb/strace care about the size and offsets within this
14 * structure. If you change things, you may break object compatibility
15 * for those applications.
16 */
17
18struct pt_regs {
19 unsigned long gr[32]; /* PSW is in gr[0] */
20 __u64 fr[32];
21 unsigned long sr[ 8];
22 unsigned long iasq[2];
23 unsigned long iaoq[2];
24 unsigned long cr27;
25 unsigned long pad0; /* available for other uses */
26 unsigned long orig_r28;
27 unsigned long ksp;
28 unsigned long kpc;
29 unsigned long sar; /* CR11 */
30 unsigned long iir; /* CR19 */
31 unsigned long isr; /* CR20 */
32 unsigned long ior; /* CR21 */
33 unsigned long ipsw; /* CR22 */
34};
35
36/*
37 * The numbers chosen here are somewhat arbitrary but absolutely MUST
38 * not overlap with any of the number assigned in <linux/ptrace.h>.
39 *
40 * These ones are taken from IA-64 on the assumption that theirs are
41 * the most correct (and we also want to support PTRACE_SINGLEBLOCK
42 * since we have taken branch traps too)
43 */
44#define PTRACE_SINGLEBLOCK 12 /* resume execution until next branch */
45
46
47#endif /* _UAPI_PARISC_PTRACE_H */
diff --git a/arch/parisc/include/asm/resource.h b/arch/parisc/include/uapi/asm/resource.h
index 8b06343b62e..8b06343b62e 100644
--- a/arch/parisc/include/asm/resource.h
+++ b/arch/parisc/include/uapi/asm/resource.h
diff --git a/arch/parisc/include/asm/sembuf.h b/arch/parisc/include/uapi/asm/sembuf.h
index 1e59ffd3bd1..1e59ffd3bd1 100644
--- a/arch/parisc/include/asm/sembuf.h
+++ b/arch/parisc/include/uapi/asm/sembuf.h
diff --git a/arch/parisc/include/asm/setup.h b/arch/parisc/include/uapi/asm/setup.h
index 7da2e5b8747..7da2e5b8747 100644
--- a/arch/parisc/include/asm/setup.h
+++ b/arch/parisc/include/uapi/asm/setup.h
diff --git a/arch/parisc/include/asm/shmbuf.h b/arch/parisc/include/uapi/asm/shmbuf.h
index 0a3eada1863..0a3eada1863 100644
--- a/arch/parisc/include/asm/shmbuf.h
+++ b/arch/parisc/include/uapi/asm/shmbuf.h
diff --git a/arch/parisc/include/asm/sigcontext.h b/arch/parisc/include/uapi/asm/sigcontext.h
index 27ef31bb3b6..27ef31bb3b6 100644
--- a/arch/parisc/include/asm/sigcontext.h
+++ b/arch/parisc/include/uapi/asm/sigcontext.h
diff --git a/arch/parisc/include/asm/siginfo.h b/arch/parisc/include/uapi/asm/siginfo.h
index d7034728f37..d7034728f37 100644
--- a/arch/parisc/include/asm/siginfo.h
+++ b/arch/parisc/include/uapi/asm/siginfo.h
diff --git a/arch/parisc/include/uapi/asm/signal.h b/arch/parisc/include/uapi/asm/signal.h
new file mode 100644
index 00000000000..b1ddaa24337
--- /dev/null
+++ b/arch/parisc/include/uapi/asm/signal.h
@@ -0,0 +1,118 @@
1#ifndef _UAPI_ASM_PARISC_SIGNAL_H
2#define _UAPI_ASM_PARISC_SIGNAL_H
3
4#define SIGHUP 1
5#define SIGINT 2
6#define SIGQUIT 3
7#define SIGILL 4
8#define SIGTRAP 5
9#define SIGABRT 6
10#define SIGIOT 6
11#define SIGEMT 7
12#define SIGFPE 8
13#define SIGKILL 9
14#define SIGBUS 10
15#define SIGSEGV 11
16#define SIGSYS 12 /* Linux doesn't use this */
17#define SIGPIPE 13
18#define SIGALRM 14
19#define SIGTERM 15
20#define SIGUSR1 16
21#define SIGUSR2 17
22#define SIGCHLD 18
23#define SIGPWR 19
24#define SIGVTALRM 20
25#define SIGPROF 21
26#define SIGIO 22
27#define SIGPOLL SIGIO
28#define SIGWINCH 23
29#define SIGSTOP 24
30#define SIGTSTP 25
31#define SIGCONT 26
32#define SIGTTIN 27
33#define SIGTTOU 28
34#define SIGURG 29
35#define SIGLOST 30 /* Linux doesn't use this either */
36#define SIGUNUSED 31
37#define SIGRESERVE SIGUNUSED
38
39#define SIGXCPU 33
40#define SIGXFSZ 34
41#define SIGSTKFLT 36
42
43/* These should not be considered constants from userland. */
44#define SIGRTMIN 37
45#define SIGRTMAX _NSIG /* it's 44 under HP/UX */
46
47/*
48 * SA_FLAGS values:
49 *
50 * SA_ONSTACK indicates that a registered stack_t will be used.
51 * SA_RESTART flag to get restarting signals (which were the default long ago)
52 * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop.
53 * SA_RESETHAND clears the handler when the signal is delivered.
54 * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies.
55 * SA_NODEFER prevents the current signal from being masked in the handler.
56 *
57 * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single
58 * Unix names RESETHAND and NODEFER respectively.
59 */
60#define SA_ONSTACK 0x00000001
61#define SA_RESETHAND 0x00000004
62#define SA_NOCLDSTOP 0x00000008
63#define SA_SIGINFO 0x00000010
64#define SA_NODEFER 0x00000020
65#define SA_RESTART 0x00000040
66#define SA_NOCLDWAIT 0x00000080
67#define _SA_SIGGFAULT 0x00000100 /* HPUX */
68
69#define SA_NOMASK SA_NODEFER
70#define SA_ONESHOT SA_RESETHAND
71
72#define SA_RESTORER 0x04000000 /* obsolete -- ignored */
73
74/*
75 * sigaltstack controls
76 */
77#define SS_ONSTACK 1
78#define SS_DISABLE 2
79
80#define MINSIGSTKSZ 2048
81#define SIGSTKSZ 8192
82
83
84#define SIG_BLOCK 0 /* for blocking signals */
85#define SIG_UNBLOCK 1 /* for unblocking signals */
86#define SIG_SETMASK 2 /* for setting the signal mask */
87
88#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
89#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
90#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
91
92# ifndef __ASSEMBLY__
93
94# include <linux/types.h>
95
96/* Avoid too many header ordering problems. */
97struct siginfo;
98
99/* Type of a signal handler. */
100#ifdef CONFIG_64BIT
101/* function pointers on 64-bit parisc are pointers to little structs and the
102 * compiler doesn't support code which changes or tests the address of
103 * the function in the little struct. This is really ugly -PB
104 */
105typedef char __user *__sighandler_t;
106#else
107typedef void __signalfn_t(int);
108typedef __signalfn_t __user *__sighandler_t;
109#endif
110
111typedef struct sigaltstack {
112 void __user *ss_sp;
113 int ss_flags;
114 size_t ss_size;
115} stack_t;
116
117#endif /* !__ASSEMBLY */
118#endif /* _UAPI_ASM_PARISC_SIGNAL_H */
diff --git a/arch/parisc/include/asm/socket.h b/arch/parisc/include/uapi/asm/socket.h
index 1b52c2c31a7..1b52c2c31a7 100644
--- a/arch/parisc/include/asm/socket.h
+++ b/arch/parisc/include/uapi/asm/socket.h
diff --git a/arch/parisc/include/asm/sockios.h b/arch/parisc/include/uapi/asm/sockios.h
index dabfbc7483f..dabfbc7483f 100644
--- a/arch/parisc/include/asm/sockios.h
+++ b/arch/parisc/include/uapi/asm/sockios.h
diff --git a/arch/parisc/include/asm/stat.h b/arch/parisc/include/uapi/asm/stat.h
index d76fbda5d62..d76fbda5d62 100644
--- a/arch/parisc/include/asm/stat.h
+++ b/arch/parisc/include/uapi/asm/stat.h
diff --git a/arch/parisc/include/asm/statfs.h b/arch/parisc/include/uapi/asm/statfs.h
index 324bea905dc..324bea905dc 100644
--- a/arch/parisc/include/asm/statfs.h
+++ b/arch/parisc/include/uapi/asm/statfs.h
diff --git a/arch/parisc/include/asm/swab.h b/arch/parisc/include/uapi/asm/swab.h
index e78403b129e..e78403b129e 100644
--- a/arch/parisc/include/asm/swab.h
+++ b/arch/parisc/include/uapi/asm/swab.h
diff --git a/arch/parisc/include/asm/termbits.h b/arch/parisc/include/uapi/asm/termbits.h
index d1ab92177a5..d1ab92177a5 100644
--- a/arch/parisc/include/asm/termbits.h
+++ b/arch/parisc/include/uapi/asm/termbits.h
diff --git a/arch/parisc/include/uapi/asm/termios.h b/arch/parisc/include/uapi/asm/termios.h
new file mode 100644
index 00000000000..f3377395070
--- /dev/null
+++ b/arch/parisc/include/uapi/asm/termios.h
@@ -0,0 +1,43 @@
1#ifndef _UAPI_PARISC_TERMIOS_H
2#define _UAPI_PARISC_TERMIOS_H
3
4#include <asm/termbits.h>
5#include <asm/ioctls.h>
6
7struct winsize {
8 unsigned short ws_row;
9 unsigned short ws_col;
10 unsigned short ws_xpixel;
11 unsigned short ws_ypixel;
12};
13
14#define NCC 8
15struct termio {
16 unsigned short c_iflag; /* input mode flags */
17 unsigned short c_oflag; /* output mode flags */
18 unsigned short c_cflag; /* control mode flags */
19 unsigned short c_lflag; /* local mode flags */
20 unsigned char c_line; /* line discipline */
21 unsigned char c_cc[NCC]; /* control characters */
22};
23
24/* modem lines */
25#define TIOCM_LE 0x001
26#define TIOCM_DTR 0x002
27#define TIOCM_RTS 0x004
28#define TIOCM_ST 0x008
29#define TIOCM_SR 0x010
30#define TIOCM_CTS 0x020
31#define TIOCM_CAR 0x040
32#define TIOCM_RNG 0x080
33#define TIOCM_DSR 0x100
34#define TIOCM_CD TIOCM_CAR
35#define TIOCM_RI TIOCM_RNG
36#define TIOCM_OUT1 0x2000
37#define TIOCM_OUT2 0x4000
38#define TIOCM_LOOP 0x8000
39
40/* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
41
42
43#endif /* _UAPI_PARISC_TERMIOS_H */
diff --git a/arch/parisc/include/asm/types.h b/arch/parisc/include/uapi/asm/types.h
index 8866f9bbdea..8866f9bbdea 100644
--- a/arch/parisc/include/asm/types.h
+++ b/arch/parisc/include/uapi/asm/types.h
diff --git a/arch/parisc/include/uapi/asm/unistd.h b/arch/parisc/include/uapi/asm/unistd.h
new file mode 100644
index 00000000000..e178f30f2cc
--- /dev/null
+++ b/arch/parisc/include/uapi/asm/unistd.h
@@ -0,0 +1,837 @@
1#ifndef _UAPI_ASM_PARISC_UNISTD_H_
2#define _UAPI_ASM_PARISC_UNISTD_H_
3
4/*
5 * This file contains the system call numbers.
6 */
7
8/*
9 * HP-UX system calls get their native numbers for binary compatibility.
10 */
11
12#define __NR_HPUX_exit 1
13#define __NR_HPUX_fork 2
14#define __NR_HPUX_read 3
15#define __NR_HPUX_write 4
16#define __NR_HPUX_open 5
17#define __NR_HPUX_close 6
18#define __NR_HPUX_wait 7
19#define __NR_HPUX_creat 8
20#define __NR_HPUX_link 9
21#define __NR_HPUX_unlink 10
22#define __NR_HPUX_execv 11
23#define __NR_HPUX_chdir 12
24#define __NR_HPUX_time 13
25#define __NR_HPUX_mknod 14
26#define __NR_HPUX_chmod 15
27#define __NR_HPUX_chown 16
28#define __NR_HPUX_break 17
29#define __NR_HPUX_lchmod 18
30#define __NR_HPUX_lseek 19
31#define __NR_HPUX_getpid 20
32#define __NR_HPUX_mount 21
33#define __NR_HPUX_umount 22
34#define __NR_HPUX_setuid 23
35#define __NR_HPUX_getuid 24
36#define __NR_HPUX_stime 25
37#define __NR_HPUX_ptrace 26
38#define __NR_HPUX_alarm 27
39#define __NR_HPUX_oldfstat 28
40#define __NR_HPUX_pause 29
41#define __NR_HPUX_utime 30
42#define __NR_HPUX_stty 31
43#define __NR_HPUX_gtty 32
44#define __NR_HPUX_access 33
45#define __NR_HPUX_nice 34
46#define __NR_HPUX_ftime 35
47#define __NR_HPUX_sync 36
48#define __NR_HPUX_kill 37
49#define __NR_HPUX_stat 38
50#define __NR_HPUX_setpgrp3 39
51#define __NR_HPUX_lstat 40
52#define __NR_HPUX_dup 41
53#define __NR_HPUX_pipe 42
54#define __NR_HPUX_times 43
55#define __NR_HPUX_profil 44
56#define __NR_HPUX_ki_call 45
57#define __NR_HPUX_setgid 46
58#define __NR_HPUX_getgid 47
59#define __NR_HPUX_sigsys 48
60#define __NR_HPUX_reserved1 49
61#define __NR_HPUX_reserved2 50
62#define __NR_HPUX_acct 51
63#define __NR_HPUX_set_userthreadid 52
64#define __NR_HPUX_oldlock 53
65#define __NR_HPUX_ioctl 54
66#define __NR_HPUX_reboot 55
67#define __NR_HPUX_symlink 56
68#define __NR_HPUX_utssys 57
69#define __NR_HPUX_readlink 58
70#define __NR_HPUX_execve 59
71#define __NR_HPUX_umask 60
72#define __NR_HPUX_chroot 61
73#define __NR_HPUX_fcntl 62
74#define __NR_HPUX_ulimit 63
75#define __NR_HPUX_getpagesize 64
76#define __NR_HPUX_mremap 65
77#define __NR_HPUX_vfork 66
78#define __NR_HPUX_vread 67
79#define __NR_HPUX_vwrite 68
80#define __NR_HPUX_sbrk 69
81#define __NR_HPUX_sstk 70
82#define __NR_HPUX_mmap 71
83#define __NR_HPUX_vadvise 72
84#define __NR_HPUX_munmap 73
85#define __NR_HPUX_mprotect 74
86#define __NR_HPUX_madvise 75
87#define __NR_HPUX_vhangup 76
88#define __NR_HPUX_swapoff 77
89#define __NR_HPUX_mincore 78
90#define __NR_HPUX_getgroups 79
91#define __NR_HPUX_setgroups 80
92#define __NR_HPUX_getpgrp2 81
93#define __NR_HPUX_setpgrp2 82
94#define __NR_HPUX_setitimer 83
95#define __NR_HPUX_wait3 84
96#define __NR_HPUX_swapon 85
97#define __NR_HPUX_getitimer 86
98#define __NR_HPUX_gethostname42 87
99#define __NR_HPUX_sethostname42 88
100#define __NR_HPUX_getdtablesize 89
101#define __NR_HPUX_dup2 90
102#define __NR_HPUX_getdopt 91
103#define __NR_HPUX_fstat 92
104#define __NR_HPUX_select 93
105#define __NR_HPUX_setdopt 94
106#define __NR_HPUX_fsync 95
107#define __NR_HPUX_setpriority 96
108#define __NR_HPUX_socket_old 97
109#define __NR_HPUX_connect_old 98
110#define __NR_HPUX_accept_old 99
111#define __NR_HPUX_getpriority 100
112#define __NR_HPUX_send_old 101
113#define __NR_HPUX_recv_old 102
114#define __NR_HPUX_socketaddr_old 103
115#define __NR_HPUX_bind_old 104
116#define __NR_HPUX_setsockopt_old 105
117#define __NR_HPUX_listen_old 106
118#define __NR_HPUX_vtimes_old 107
119#define __NR_HPUX_sigvector 108
120#define __NR_HPUX_sigblock 109
121#define __NR_HPUX_siggetmask 110
122#define __NR_HPUX_sigpause 111
123#define __NR_HPUX_sigstack 112
124#define __NR_HPUX_recvmsg_old 113
125#define __NR_HPUX_sendmsg_old 114
126#define __NR_HPUX_vtrace_old 115
127#define __NR_HPUX_gettimeofday 116
128#define __NR_HPUX_getrusage 117
129#define __NR_HPUX_getsockopt_old 118
130#define __NR_HPUX_resuba_old 119
131#define __NR_HPUX_readv 120
132#define __NR_HPUX_writev 121
133#define __NR_HPUX_settimeofday 122
134#define __NR_HPUX_fchown 123
135#define __NR_HPUX_fchmod 124
136#define __NR_HPUX_recvfrom_old 125
137#define __NR_HPUX_setresuid 126
138#define __NR_HPUX_setresgid 127
139#define __NR_HPUX_rename 128
140#define __NR_HPUX_truncate 129
141#define __NR_HPUX_ftruncate 130
142#define __NR_HPUX_flock_old 131
143#define __NR_HPUX_sysconf 132
144#define __NR_HPUX_sendto_old 133
145#define __NR_HPUX_shutdown_old 134
146#define __NR_HPUX_socketpair_old 135
147#define __NR_HPUX_mkdir 136
148#define __NR_HPUX_rmdir 137
149#define __NR_HPUX_utimes_old 138
150#define __NR_HPUX_sigcleanup_old 139
151#define __NR_HPUX_setcore 140
152#define __NR_HPUX_getpeername_old 141
153#define __NR_HPUX_gethostid 142
154#define __NR_HPUX_sethostid 143
155#define __NR_HPUX_getrlimit 144
156#define __NR_HPUX_setrlimit 145
157#define __NR_HPUX_killpg_old 146
158#define __NR_HPUX_cachectl 147
159#define __NR_HPUX_quotactl 148
160#define __NR_HPUX_get_sysinfo 149
161#define __NR_HPUX_getsockname_old 150
162#define __NR_HPUX_privgrp 151
163#define __NR_HPUX_rtprio 152
164#define __NR_HPUX_plock 153
165#define __NR_HPUX_reserved3 154
166#define __NR_HPUX_lockf 155
167#define __NR_HPUX_semget 156
168#define __NR_HPUX_osemctl 157
169#define __NR_HPUX_semop 158
170#define __NR_HPUX_msgget 159
171#define __NR_HPUX_omsgctl 160
172#define __NR_HPUX_msgsnd 161
173#define __NR_HPUX_msgrecv 162
174#define __NR_HPUX_shmget 163
175#define __NR_HPUX_oshmctl 164
176#define __NR_HPUX_shmat 165
177#define __NR_HPUX_shmdt 166
178#define __NR_HPUX_m68020_advise 167
179/* [168,189] are for Discless/DUX */
180#define __NR_HPUX_csp 168
181#define __NR_HPUX_cluster 169
182#define __NR_HPUX_mkrnod 170
183#define __NR_HPUX_test 171
184#define __NR_HPUX_unsp_open 172
185#define __NR_HPUX_reserved4 173
186#define __NR_HPUX_getcontext_old 174
187#define __NR_HPUX_osetcontext 175
188#define __NR_HPUX_bigio 176
189#define __NR_HPUX_pipenode 177
190#define __NR_HPUX_lsync 178
191#define __NR_HPUX_getmachineid 179
192#define __NR_HPUX_cnodeid 180
193#define __NR_HPUX_cnodes 181
194#define __NR_HPUX_swapclients 182
195#define __NR_HPUX_rmt_process 183
196#define __NR_HPUX_dskless_stats 184
197#define __NR_HPUX_sigprocmask 185
198#define __NR_HPUX_sigpending 186
199#define __NR_HPUX_sigsuspend 187
200#define __NR_HPUX_sigaction 188
201#define __NR_HPUX_reserved5 189
202#define __NR_HPUX_nfssvc 190
203#define __NR_HPUX_getfh 191
204#define __NR_HPUX_getdomainname 192
205#define __NR_HPUX_setdomainname 193
206#define __NR_HPUX_async_daemon 194
207#define __NR_HPUX_getdirentries 195
208#define __NR_HPUX_statfs 196
209#define __NR_HPUX_fstatfs 197
210#define __NR_HPUX_vfsmount 198
211#define __NR_HPUX_reserved6 199
212#define __NR_HPUX_waitpid 200
213/* 201 - 223 missing */
214#define __NR_HPUX_sigsetreturn 224
215#define __NR_HPUX_sigsetstatemask 225
216/* 226 missing */
217#define __NR_HPUX_cs 227
218#define __NR_HPUX_cds 228
219#define __NR_HPUX_set_no_trunc 229
220#define __NR_HPUX_pathconf 230
221#define __NR_HPUX_fpathconf 231
222/* 232, 233 missing */
223#define __NR_HPUX_nfs_fcntl 234
224#define __NR_HPUX_ogetacl 235
225#define __NR_HPUX_ofgetacl 236
226#define __NR_HPUX_osetacl 237
227#define __NR_HPUX_ofsetacl 238
228#define __NR_HPUX_pstat 239
229#define __NR_HPUX_getaudid 240
230#define __NR_HPUX_setaudid 241
231#define __NR_HPUX_getaudproc 242
232#define __NR_HPUX_setaudproc 243
233#define __NR_HPUX_getevent 244
234#define __NR_HPUX_setevent 245
235#define __NR_HPUX_audwrite 246
236#define __NR_HPUX_audswitch 247
237#define __NR_HPUX_audctl 248
238#define __NR_HPUX_ogetaccess 249
239#define __NR_HPUX_fsctl 250
240/* 251 - 258 missing */
241#define __NR_HPUX_swapfs 259
242#define __NR_HPUX_fss 260
243/* 261 - 266 missing */
244#define __NR_HPUX_tsync 267
245#define __NR_HPUX_getnumfds 268
246#define __NR_HPUX_poll 269
247#define __NR_HPUX_getmsg 270
248#define __NR_HPUX_putmsg 271
249#define __NR_HPUX_fchdir 272
250#define __NR_HPUX_getmount_cnt 273
251#define __NR_HPUX_getmount_entry 274
252#define __NR_HPUX_accept 275
253#define __NR_HPUX_bind 276
254#define __NR_HPUX_connect 277
255#define __NR_HPUX_getpeername 278
256#define __NR_HPUX_getsockname 279
257#define __NR_HPUX_getsockopt 280
258#define __NR_HPUX_listen 281
259#define __NR_HPUX_recv 282
260#define __NR_HPUX_recvfrom 283
261#define __NR_HPUX_recvmsg 284
262#define __NR_HPUX_send 285
263#define __NR_HPUX_sendmsg 286
264#define __NR_HPUX_sendto 287
265#define __NR_HPUX_setsockopt 288
266#define __NR_HPUX_shutdown 289
267#define __NR_HPUX_socket 290
268#define __NR_HPUX_socketpair 291
269#define __NR_HPUX_proc_open 292
270#define __NR_HPUX_proc_close 293
271#define __NR_HPUX_proc_send 294
272#define __NR_HPUX_proc_recv 295
273#define __NR_HPUX_proc_sendrecv 296
274#define __NR_HPUX_proc_syscall 297
275/* 298 - 311 missing */
276#define __NR_HPUX_semctl 312
277#define __NR_HPUX_msgctl 313
278#define __NR_HPUX_shmctl 314
279#define __NR_HPUX_mpctl 315
280#define __NR_HPUX_exportfs 316
281#define __NR_HPUX_getpmsg 317
282#define __NR_HPUX_putpmsg 318
283/* 319 missing */
284#define __NR_HPUX_msync 320
285#define __NR_HPUX_msleep 321
286#define __NR_HPUX_mwakeup 322
287#define __NR_HPUX_msem_init 323
288#define __NR_HPUX_msem_remove 324
289#define __NR_HPUX_adjtime 325
290#define __NR_HPUX_kload 326
291#define __NR_HPUX_fattach 327
292#define __NR_HPUX_fdetach 328
293#define __NR_HPUX_serialize 329
294#define __NR_HPUX_statvfs 330
295#define __NR_HPUX_fstatvfs 331
296#define __NR_HPUX_lchown 332
297#define __NR_HPUX_getsid 333
298#define __NR_HPUX_sysfs 334
299/* 335, 336 missing */
300#define __NR_HPUX_sched_setparam 337
301#define __NR_HPUX_sched_getparam 338
302#define __NR_HPUX_sched_setscheduler 339
303#define __NR_HPUX_sched_getscheduler 340
304#define __NR_HPUX_sched_yield 341
305#define __NR_HPUX_sched_get_priority_max 342
306#define __NR_HPUX_sched_get_priority_min 343
307#define __NR_HPUX_sched_rr_get_interval 344
308#define __NR_HPUX_clock_settime 345
309#define __NR_HPUX_clock_gettime 346
310#define __NR_HPUX_clock_getres 347
311#define __NR_HPUX_timer_create 348
312#define __NR_HPUX_timer_delete 349
313#define __NR_HPUX_timer_settime 350
314#define __NR_HPUX_timer_gettime 351
315#define __NR_HPUX_timer_getoverrun 352
316#define __NR_HPUX_nanosleep 353
317#define __NR_HPUX_toolbox 354
318/* 355 missing */
319#define __NR_HPUX_getdents 356
320#define __NR_HPUX_getcontext 357
321#define __NR_HPUX_sysinfo 358
322#define __NR_HPUX_fcntl64 359
323#define __NR_HPUX_ftruncate64 360
324#define __NR_HPUX_fstat64 361
325#define __NR_HPUX_getdirentries64 362
326#define __NR_HPUX_getrlimit64 363
327#define __NR_HPUX_lockf64 364
328#define __NR_HPUX_lseek64 365
329#define __NR_HPUX_lstat64 366
330#define __NR_HPUX_mmap64 367
331#define __NR_HPUX_setrlimit64 368
332#define __NR_HPUX_stat64 369
333#define __NR_HPUX_truncate64 370
334#define __NR_HPUX_ulimit64 371
335#define __NR_HPUX_pread 372
336#define __NR_HPUX_preadv 373
337#define __NR_HPUX_pwrite 374
338#define __NR_HPUX_pwritev 375
339#define __NR_HPUX_pread64 376
340#define __NR_HPUX_preadv64 377
341#define __NR_HPUX_pwrite64 378
342#define __NR_HPUX_pwritev64 379
343#define __NR_HPUX_setcontext 380
344#define __NR_HPUX_sigaltstack 381
345#define __NR_HPUX_waitid 382
346#define __NR_HPUX_setpgrp 383
347#define __NR_HPUX_recvmsg2 384
348#define __NR_HPUX_sendmsg2 385
349#define __NR_HPUX_socket2 386
350#define __NR_HPUX_socketpair2 387
351#define __NR_HPUX_setregid 388
352#define __NR_HPUX_lwp_create 389
353#define __NR_HPUX_lwp_terminate 390
354#define __NR_HPUX_lwp_wait 391
355#define __NR_HPUX_lwp_suspend 392
356#define __NR_HPUX_lwp_resume 393
357/* 394 missing */
358#define __NR_HPUX_lwp_abort_syscall 395
359#define __NR_HPUX_lwp_info 396
360#define __NR_HPUX_lwp_kill 397
361#define __NR_HPUX_ksleep 398
362#define __NR_HPUX_kwakeup 399
363/* 400 missing */
364#define __NR_HPUX_pstat_getlwp 401
365#define __NR_HPUX_lwp_exit 402
366#define __NR_HPUX_lwp_continue 403
367#define __NR_HPUX_getacl 404
368#define __NR_HPUX_fgetacl 405
369#define __NR_HPUX_setacl 406
370#define __NR_HPUX_fsetacl 407
371#define __NR_HPUX_getaccess 408
372#define __NR_HPUX_lwp_mutex_init 409
373#define __NR_HPUX_lwp_mutex_lock_sys 410
374#define __NR_HPUX_lwp_mutex_unlock 411
375#define __NR_HPUX_lwp_cond_init 412
376#define __NR_HPUX_lwp_cond_signal 413
377#define __NR_HPUX_lwp_cond_broadcast 414
378#define __NR_HPUX_lwp_cond_wait_sys 415
379#define __NR_HPUX_lwp_getscheduler 416
380#define __NR_HPUX_lwp_setscheduler 417
381#define __NR_HPUX_lwp_getstate 418
382#define __NR_HPUX_lwp_setstate 419
383#define __NR_HPUX_lwp_detach 420
384#define __NR_HPUX_mlock 421
385#define __NR_HPUX_munlock 422
386#define __NR_HPUX_mlockall 423
387#define __NR_HPUX_munlockall 424
388#define __NR_HPUX_shm_open 425
389#define __NR_HPUX_shm_unlink 426
390#define __NR_HPUX_sigqueue 427
391#define __NR_HPUX_sigwaitinfo 428
392#define __NR_HPUX_sigtimedwait 429
393#define __NR_HPUX_sigwait 430
394#define __NR_HPUX_aio_read 431
395#define __NR_HPUX_aio_write 432
396#define __NR_HPUX_lio_listio 433
397#define __NR_HPUX_aio_error 434
398#define __NR_HPUX_aio_return 435
399#define __NR_HPUX_aio_cancel 436
400#define __NR_HPUX_aio_suspend 437
401#define __NR_HPUX_aio_fsync 438
402#define __NR_HPUX_mq_open 439
403#define __NR_HPUX_mq_close 440
404#define __NR_HPUX_mq_unlink 441
405#define __NR_HPUX_mq_send 442
406#define __NR_HPUX_mq_receive 443
407#define __NR_HPUX_mq_notify 444
408#define __NR_HPUX_mq_setattr 445
409#define __NR_HPUX_mq_getattr 446
410#define __NR_HPUX_ksem_open 447
411#define __NR_HPUX_ksem_unlink 448
412#define __NR_HPUX_ksem_close 449
413#define __NR_HPUX_ksem_post 450
414#define __NR_HPUX_ksem_wait 451
415#define __NR_HPUX_ksem_read 452
416#define __NR_HPUX_ksem_trywait 453
417#define __NR_HPUX_lwp_rwlock_init 454
418#define __NR_HPUX_lwp_rwlock_destroy 455
419#define __NR_HPUX_lwp_rwlock_rdlock_sys 456
420#define __NR_HPUX_lwp_rwlock_wrlock_sys 457
421#define __NR_HPUX_lwp_rwlock_tryrdlock 458
422#define __NR_HPUX_lwp_rwlock_trywrlock 459
423#define __NR_HPUX_lwp_rwlock_unlock 460
424#define __NR_HPUX_ttrace 461
425#define __NR_HPUX_ttrace_wait 462
426#define __NR_HPUX_lf_wire_mem 463
427#define __NR_HPUX_lf_unwire_mem 464
428#define __NR_HPUX_lf_send_pin_map 465
429#define __NR_HPUX_lf_free_buf 466
430#define __NR_HPUX_lf_wait_nq 467
431#define __NR_HPUX_lf_wakeup_conn_q 468
432#define __NR_HPUX_lf_unused 469
433#define __NR_HPUX_lwp_sema_init 470
434#define __NR_HPUX_lwp_sema_post 471
435#define __NR_HPUX_lwp_sema_wait 472
436#define __NR_HPUX_lwp_sema_trywait 473
437#define __NR_HPUX_lwp_sema_destroy 474
438#define __NR_HPUX_statvfs64 475
439#define __NR_HPUX_fstatvfs64 476
440#define __NR_HPUX_msh_register 477
441#define __NR_HPUX_ptrace64 478
442#define __NR_HPUX_sendfile 479
443#define __NR_HPUX_sendpath 480
444#define __NR_HPUX_sendfile64 481
445#define __NR_HPUX_sendpath64 482
446#define __NR_HPUX_modload 483
447#define __NR_HPUX_moduload 484
448#define __NR_HPUX_modpath 485
449#define __NR_HPUX_getksym 486
450#define __NR_HPUX_modadm 487
451#define __NR_HPUX_modstat 488
452#define __NR_HPUX_lwp_detached_exit 489
453#define __NR_HPUX_crashconf 490
454#define __NR_HPUX_siginhibit 491
455#define __NR_HPUX_sigenable 492
456#define __NR_HPUX_spuctl 493
457#define __NR_HPUX_zerokernelsum 494
458#define __NR_HPUX_nfs_kstat 495
459#define __NR_HPUX_aio_read64 496
460#define __NR_HPUX_aio_write64 497
461#define __NR_HPUX_aio_error64 498
462#define __NR_HPUX_aio_return64 499
463#define __NR_HPUX_aio_cancel64 500
464#define __NR_HPUX_aio_suspend64 501
465#define __NR_HPUX_aio_fsync64 502
466#define __NR_HPUX_lio_listio64 503
467#define __NR_HPUX_recv2 504
468#define __NR_HPUX_recvfrom2 505
469#define __NR_HPUX_send2 506
470#define __NR_HPUX_sendto2 507
471#define __NR_HPUX_acl 508
472#define __NR_HPUX___cnx_p2p_ctl 509
473#define __NR_HPUX___cnx_gsched_ctl 510
474#define __NR_HPUX___cnx_pmon_ctl 511
475
476#define __NR_HPUX_syscalls 512
477
478/*
479 * Linux system call numbers.
480 *
481 * Cary Coutant says that we should just use another syscall gateway
482 * page to avoid clashing with the HPUX space, and I think he's right:
483 * it will would keep a branch out of our syscall entry path, at the
484 * very least. If we decide to change it later, we can ``just'' tweak
485 * the LINUX_GATEWAY_ADDR define at the bottom and make __NR_Linux be
486 * 1024 or something. Oh, and recompile libc. =)
487 *
488 * 64-bit HPUX binaries get the syscall gateway address passed in a register
489 * from the kernel at startup, which seems a sane strategy.
490 */
491
492#define __NR_Linux 0
493#define __NR_restart_syscall (__NR_Linux + 0)
494#define __NR_exit (__NR_Linux + 1)
495#define __NR_fork (__NR_Linux + 2)
496#define __NR_read (__NR_Linux + 3)
497#define __NR_write (__NR_Linux + 4)
498#define __NR_open (__NR_Linux + 5)
499#define __NR_close (__NR_Linux + 6)
500#define __NR_waitpid (__NR_Linux + 7)
501#define __NR_creat (__NR_Linux + 8)
502#define __NR_link (__NR_Linux + 9)
503#define __NR_unlink (__NR_Linux + 10)
504#define __NR_execve (__NR_Linux + 11)
505#define __NR_chdir (__NR_Linux + 12)
506#define __NR_time (__NR_Linux + 13)
507#define __NR_mknod (__NR_Linux + 14)
508#define __NR_chmod (__NR_Linux + 15)
509#define __NR_lchown (__NR_Linux + 16)
510#define __NR_socket (__NR_Linux + 17)
511#define __NR_stat (__NR_Linux + 18)
512#define __NR_lseek (__NR_Linux + 19)
513#define __NR_getpid (__NR_Linux + 20)
514#define __NR_mount (__NR_Linux + 21)
515#define __NR_bind (__NR_Linux + 22)
516#define __NR_setuid (__NR_Linux + 23)
517#define __NR_getuid (__NR_Linux + 24)
518#define __NR_stime (__NR_Linux + 25)
519#define __NR_ptrace (__NR_Linux + 26)
520#define __NR_alarm (__NR_Linux + 27)
521#define __NR_fstat (__NR_Linux + 28)
522#define __NR_pause (__NR_Linux + 29)
523#define __NR_utime (__NR_Linux + 30)
524#define __NR_connect (__NR_Linux + 31)
525#define __NR_listen (__NR_Linux + 32)
526#define __NR_access (__NR_Linux + 33)
527#define __NR_nice (__NR_Linux + 34)
528#define __NR_accept (__NR_Linux + 35)
529#define __NR_sync (__NR_Linux + 36)
530#define __NR_kill (__NR_Linux + 37)
531#define __NR_rename (__NR_Linux + 38)
532#define __NR_mkdir (__NR_Linux + 39)
533#define __NR_rmdir (__NR_Linux + 40)
534#define __NR_dup (__NR_Linux + 41)
535#define __NR_pipe (__NR_Linux + 42)
536#define __NR_times (__NR_Linux + 43)
537#define __NR_getsockname (__NR_Linux + 44)
538#define __NR_brk (__NR_Linux + 45)
539#define __NR_setgid (__NR_Linux + 46)
540#define __NR_getgid (__NR_Linux + 47)
541#define __NR_signal (__NR_Linux + 48)
542#define __NR_geteuid (__NR_Linux + 49)
543#define __NR_getegid (__NR_Linux + 50)
544#define __NR_acct (__NR_Linux + 51)
545#define __NR_umount2 (__NR_Linux + 52)
546#define __NR_getpeername (__NR_Linux + 53)
547#define __NR_ioctl (__NR_Linux + 54)
548#define __NR_fcntl (__NR_Linux + 55)
549#define __NR_socketpair (__NR_Linux + 56)
550#define __NR_setpgid (__NR_Linux + 57)
551#define __NR_send (__NR_Linux + 58)
552#define __NR_uname (__NR_Linux + 59)
553#define __NR_umask (__NR_Linux + 60)
554#define __NR_chroot (__NR_Linux + 61)
555#define __NR_ustat (__NR_Linux + 62)
556#define __NR_dup2 (__NR_Linux + 63)
557#define __NR_getppid (__NR_Linux + 64)
558#define __NR_getpgrp (__NR_Linux + 65)
559#define __NR_setsid (__NR_Linux + 66)
560#define __NR_pivot_root (__NR_Linux + 67)
561#define __NR_sgetmask (__NR_Linux + 68)
562#define __NR_ssetmask (__NR_Linux + 69)
563#define __NR_setreuid (__NR_Linux + 70)
564#define __NR_setregid (__NR_Linux + 71)
565#define __NR_mincore (__NR_Linux + 72)
566#define __NR_sigpending (__NR_Linux + 73)
567#define __NR_sethostname (__NR_Linux + 74)
568#define __NR_setrlimit (__NR_Linux + 75)
569#define __NR_getrlimit (__NR_Linux + 76)
570#define __NR_getrusage (__NR_Linux + 77)
571#define __NR_gettimeofday (__NR_Linux + 78)
572#define __NR_settimeofday (__NR_Linux + 79)
573#define __NR_getgroups (__NR_Linux + 80)
574#define __NR_setgroups (__NR_Linux + 81)
575#define __NR_sendto (__NR_Linux + 82)
576#define __NR_symlink (__NR_Linux + 83)
577#define __NR_lstat (__NR_Linux + 84)
578#define __NR_readlink (__NR_Linux + 85)
579#define __NR_uselib (__NR_Linux + 86)
580#define __NR_swapon (__NR_Linux + 87)
581#define __NR_reboot (__NR_Linux + 88)
582#define __NR_mmap2 (__NR_Linux + 89)
583#define __NR_mmap (__NR_Linux + 90)
584#define __NR_munmap (__NR_Linux + 91)
585#define __NR_truncate (__NR_Linux + 92)
586#define __NR_ftruncate (__NR_Linux + 93)
587#define __NR_fchmod (__NR_Linux + 94)
588#define __NR_fchown (__NR_Linux + 95)
589#define __NR_getpriority (__NR_Linux + 96)
590#define __NR_setpriority (__NR_Linux + 97)
591#define __NR_recv (__NR_Linux + 98)
592#define __NR_statfs (__NR_Linux + 99)
593#define __NR_fstatfs (__NR_Linux + 100)
594#define __NR_stat64 (__NR_Linux + 101)
595/* #define __NR_socketcall (__NR_Linux + 102) */
596#define __NR_syslog (__NR_Linux + 103)
597#define __NR_setitimer (__NR_Linux + 104)
598#define __NR_getitimer (__NR_Linux + 105)
599#define __NR_capget (__NR_Linux + 106)
600#define __NR_capset (__NR_Linux + 107)
601#define __NR_pread64 (__NR_Linux + 108)
602#define __NR_pwrite64 (__NR_Linux + 109)
603#define __NR_getcwd (__NR_Linux + 110)
604#define __NR_vhangup (__NR_Linux + 111)
605#define __NR_fstat64 (__NR_Linux + 112)
606#define __NR_vfork (__NR_Linux + 113)
607#define __NR_wait4 (__NR_Linux + 114)
608#define __NR_swapoff (__NR_Linux + 115)
609#define __NR_sysinfo (__NR_Linux + 116)
610#define __NR_shutdown (__NR_Linux + 117)
611#define __NR_fsync (__NR_Linux + 118)
612#define __NR_madvise (__NR_Linux + 119)
613#define __NR_clone (__NR_Linux + 120)
614#define __NR_setdomainname (__NR_Linux + 121)
615#define __NR_sendfile (__NR_Linux + 122)
616#define __NR_recvfrom (__NR_Linux + 123)
617#define __NR_adjtimex (__NR_Linux + 124)
618#define __NR_mprotect (__NR_Linux + 125)
619#define __NR_sigprocmask (__NR_Linux + 126)
620#define __NR_create_module (__NR_Linux + 127)
621#define __NR_init_module (__NR_Linux + 128)
622#define __NR_delete_module (__NR_Linux + 129)
623#define __NR_get_kernel_syms (__NR_Linux + 130)
624#define __NR_quotactl (__NR_Linux + 131)
625#define __NR_getpgid (__NR_Linux + 132)
626#define __NR_fchdir (__NR_Linux + 133)
627#define __NR_bdflush (__NR_Linux + 134)
628#define __NR_sysfs (__NR_Linux + 135)
629#define __NR_personality (__NR_Linux + 136)
630#define __NR_afs_syscall (__NR_Linux + 137) /* Syscall for Andrew File System */
631#define __NR_setfsuid (__NR_Linux + 138)
632#define __NR_setfsgid (__NR_Linux + 139)
633#define __NR__llseek (__NR_Linux + 140)
634#define __NR_getdents (__NR_Linux + 141)
635#define __NR__newselect (__NR_Linux + 142)
636#define __NR_flock (__NR_Linux + 143)
637#define __NR_msync (__NR_Linux + 144)
638#define __NR_readv (__NR_Linux + 145)
639#define __NR_writev (__NR_Linux + 146)
640#define __NR_getsid (__NR_Linux + 147)
641#define __NR_fdatasync (__NR_Linux + 148)
642#define __NR__sysctl (__NR_Linux + 149)
643#define __NR_mlock (__NR_Linux + 150)
644#define __NR_munlock (__NR_Linux + 151)
645#define __NR_mlockall (__NR_Linux + 152)
646#define __NR_munlockall (__NR_Linux + 153)
647#define __NR_sched_setparam (__NR_Linux + 154)
648#define __NR_sched_getparam (__NR_Linux + 155)
649#define __NR_sched_setscheduler (__NR_Linux + 156)
650#define __NR_sched_getscheduler (__NR_Linux + 157)
651#define __NR_sched_yield (__NR_Linux + 158)
652#define __NR_sched_get_priority_max (__NR_Linux + 159)
653#define __NR_sched_get_priority_min (__NR_Linux + 160)
654#define __NR_sched_rr_get_interval (__NR_Linux + 161)
655#define __NR_nanosleep (__NR_Linux + 162)
656#define __NR_mremap (__NR_Linux + 163)
657#define __NR_setresuid (__NR_Linux + 164)
658#define __NR_getresuid (__NR_Linux + 165)
659#define __NR_sigaltstack (__NR_Linux + 166)
660#define __NR_query_module (__NR_Linux + 167)
661#define __NR_poll (__NR_Linux + 168)
662#define __NR_nfsservctl (__NR_Linux + 169)
663#define __NR_setresgid (__NR_Linux + 170)
664#define __NR_getresgid (__NR_Linux + 171)
665#define __NR_prctl (__NR_Linux + 172)
666#define __NR_rt_sigreturn (__NR_Linux + 173)
667#define __NR_rt_sigaction (__NR_Linux + 174)
668#define __NR_rt_sigprocmask (__NR_Linux + 175)
669#define __NR_rt_sigpending (__NR_Linux + 176)
670#define __NR_rt_sigtimedwait (__NR_Linux + 177)
671#define __NR_rt_sigqueueinfo (__NR_Linux + 178)
672#define __NR_rt_sigsuspend (__NR_Linux + 179)
673#define __NR_chown (__NR_Linux + 180)
674#define __NR_setsockopt (__NR_Linux + 181)
675#define __NR_getsockopt (__NR_Linux + 182)
676#define __NR_sendmsg (__NR_Linux + 183)
677#define __NR_recvmsg (__NR_Linux + 184)
678#define __NR_semop (__NR_Linux + 185)
679#define __NR_semget (__NR_Linux + 186)
680#define __NR_semctl (__NR_Linux + 187)
681#define __NR_msgsnd (__NR_Linux + 188)
682#define __NR_msgrcv (__NR_Linux + 189)
683#define __NR_msgget (__NR_Linux + 190)
684#define __NR_msgctl (__NR_Linux + 191)
685#define __NR_shmat (__NR_Linux + 192)
686#define __NR_shmdt (__NR_Linux + 193)
687#define __NR_shmget (__NR_Linux + 194)
688#define __NR_shmctl (__NR_Linux + 195)
689
690#define __NR_getpmsg (__NR_Linux + 196) /* Somebody *wants* streams? */
691#define __NR_putpmsg (__NR_Linux + 197)
692
693#define __NR_lstat64 (__NR_Linux + 198)
694#define __NR_truncate64 (__NR_Linux + 199)
695#define __NR_ftruncate64 (__NR_Linux + 200)
696#define __NR_getdents64 (__NR_Linux + 201)
697#define __NR_fcntl64 (__NR_Linux + 202)
698#define __NR_attrctl (__NR_Linux + 203)
699#define __NR_acl_get (__NR_Linux + 204)
700#define __NR_acl_set (__NR_Linux + 205)
701#define __NR_gettid (__NR_Linux + 206)
702#define __NR_readahead (__NR_Linux + 207)
703#define __NR_tkill (__NR_Linux + 208)
704#define __NR_sendfile64 (__NR_Linux + 209)
705#define __NR_futex (__NR_Linux + 210)
706#define __NR_sched_setaffinity (__NR_Linux + 211)
707#define __NR_sched_getaffinity (__NR_Linux + 212)
708#define __NR_set_thread_area (__NR_Linux + 213)
709#define __NR_get_thread_area (__NR_Linux + 214)
710#define __NR_io_setup (__NR_Linux + 215)
711#define __NR_io_destroy (__NR_Linux + 216)
712#define __NR_io_getevents (__NR_Linux + 217)
713#define __NR_io_submit (__NR_Linux + 218)
714#define __NR_io_cancel (__NR_Linux + 219)
715#define __NR_alloc_hugepages (__NR_Linux + 220)
716#define __NR_free_hugepages (__NR_Linux + 221)
717#define __NR_exit_group (__NR_Linux + 222)
718#define __NR_lookup_dcookie (__NR_Linux + 223)
719#define __NR_epoll_create (__NR_Linux + 224)
720#define __NR_epoll_ctl (__NR_Linux + 225)
721#define __NR_epoll_wait (__NR_Linux + 226)
722#define __NR_remap_file_pages (__NR_Linux + 227)
723#define __NR_semtimedop (__NR_Linux + 228)
724#define __NR_mq_open (__NR_Linux + 229)
725#define __NR_mq_unlink (__NR_Linux + 230)
726#define __NR_mq_timedsend (__NR_Linux + 231)
727#define __NR_mq_timedreceive (__NR_Linux + 232)
728#define __NR_mq_notify (__NR_Linux + 233)
729#define __NR_mq_getsetattr (__NR_Linux + 234)
730#define __NR_waitid (__NR_Linux + 235)
731#define __NR_fadvise64_64 (__NR_Linux + 236)
732#define __NR_set_tid_address (__NR_Linux + 237)
733#define __NR_setxattr (__NR_Linux + 238)
734#define __NR_lsetxattr (__NR_Linux + 239)
735#define __NR_fsetxattr (__NR_Linux + 240)
736#define __NR_getxattr (__NR_Linux + 241)
737#define __NR_lgetxattr (__NR_Linux + 242)
738#define __NR_fgetxattr (__NR_Linux + 243)
739#define __NR_listxattr (__NR_Linux + 244)
740#define __NR_llistxattr (__NR_Linux + 245)
741#define __NR_flistxattr (__NR_Linux + 246)
742#define __NR_removexattr (__NR_Linux + 247)
743#define __NR_lremovexattr (__NR_Linux + 248)
744#define __NR_fremovexattr (__NR_Linux + 249)
745#define __NR_timer_create (__NR_Linux + 250)
746#define __NR_timer_settime (__NR_Linux + 251)
747#define __NR_timer_gettime (__NR_Linux + 252)
748#define __NR_timer_getoverrun (__NR_Linux + 253)
749#define __NR_timer_delete (__NR_Linux + 254)
750#define __NR_clock_settime (__NR_Linux + 255)
751#define __NR_clock_gettime (__NR_Linux + 256)
752#define __NR_clock_getres (__NR_Linux + 257)
753#define __NR_clock_nanosleep (__NR_Linux + 258)
754#define __NR_tgkill (__NR_Linux + 259)
755#define __NR_mbind (__NR_Linux + 260)
756#define __NR_get_mempolicy (__NR_Linux + 261)
757#define __NR_set_mempolicy (__NR_Linux + 262)
758#define __NR_vserver (__NR_Linux + 263)
759#define __NR_add_key (__NR_Linux + 264)
760#define __NR_request_key (__NR_Linux + 265)
761#define __NR_keyctl (__NR_Linux + 266)
762#define __NR_ioprio_set (__NR_Linux + 267)
763#define __NR_ioprio_get (__NR_Linux + 268)
764#define __NR_inotify_init (__NR_Linux + 269)
765#define __NR_inotify_add_watch (__NR_Linux + 270)
766#define __NR_inotify_rm_watch (__NR_Linux + 271)
767#define __NR_migrate_pages (__NR_Linux + 272)
768#define __NR_pselect6 (__NR_Linux + 273)
769#define __NR_ppoll (__NR_Linux + 274)
770#define __NR_openat (__NR_Linux + 275)
771#define __NR_mkdirat (__NR_Linux + 276)
772#define __NR_mknodat (__NR_Linux + 277)
773#define __NR_fchownat (__NR_Linux + 278)
774#define __NR_futimesat (__NR_Linux + 279)
775#define __NR_fstatat64 (__NR_Linux + 280)
776#define __NR_unlinkat (__NR_Linux + 281)
777#define __NR_renameat (__NR_Linux + 282)
778#define __NR_linkat (__NR_Linux + 283)
779#define __NR_symlinkat (__NR_Linux + 284)
780#define __NR_readlinkat (__NR_Linux + 285)
781#define __NR_fchmodat (__NR_Linux + 286)
782#define __NR_faccessat (__NR_Linux + 287)
783#define __NR_unshare (__NR_Linux + 288)
784#define __NR_set_robust_list (__NR_Linux + 289)
785#define __NR_get_robust_list (__NR_Linux + 290)
786#define __NR_splice (__NR_Linux + 291)
787#define __NR_sync_file_range (__NR_Linux + 292)
788#define __NR_tee (__NR_Linux + 293)
789#define __NR_vmsplice (__NR_Linux + 294)
790#define __NR_move_pages (__NR_Linux + 295)
791#define __NR_getcpu (__NR_Linux + 296)
792#define __NR_epoll_pwait (__NR_Linux + 297)
793#define __NR_statfs64 (__NR_Linux + 298)
794#define __NR_fstatfs64 (__NR_Linux + 299)
795#define __NR_kexec_load (__NR_Linux + 300)
796#define __NR_utimensat (__NR_Linux + 301)
797#define __NR_signalfd (__NR_Linux + 302)
798#define __NR_timerfd (__NR_Linux + 303)
799#define __NR_eventfd (__NR_Linux + 304)
800#define __NR_fallocate (__NR_Linux + 305)
801#define __NR_timerfd_create (__NR_Linux + 306)
802#define __NR_timerfd_settime (__NR_Linux + 307)
803#define __NR_timerfd_gettime (__NR_Linux + 308)
804#define __NR_signalfd4 (__NR_Linux + 309)
805#define __NR_eventfd2 (__NR_Linux + 310)
806#define __NR_epoll_create1 (__NR_Linux + 311)
807#define __NR_dup3 (__NR_Linux + 312)
808#define __NR_pipe2 (__NR_Linux + 313)
809#define __NR_inotify_init1 (__NR_Linux + 314)
810#define __NR_preadv (__NR_Linux + 315)
811#define __NR_pwritev (__NR_Linux + 316)
812#define __NR_rt_tgsigqueueinfo (__NR_Linux + 317)
813#define __NR_perf_event_open (__NR_Linux + 318)
814#define __NR_recvmmsg (__NR_Linux + 319)
815#define __NR_accept4 (__NR_Linux + 320)
816#define __NR_prlimit64 (__NR_Linux + 321)
817#define __NR_fanotify_init (__NR_Linux + 322)
818#define __NR_fanotify_mark (__NR_Linux + 323)
819#define __NR_clock_adjtime (__NR_Linux + 324)
820#define __NR_name_to_handle_at (__NR_Linux + 325)
821#define __NR_open_by_handle_at (__NR_Linux + 326)
822#define __NR_syncfs (__NR_Linux + 327)
823#define __NR_setns (__NR_Linux + 328)
824#define __NR_sendmmsg (__NR_Linux + 329)
825
826#define __NR_Linux_syscalls (__NR_sendmmsg + 1)
827
828
829#define __IGNORE_select /* newselect */
830#define __IGNORE_fadvise64 /* fadvise64_64 */
831#define __IGNORE_utimes /* utime */
832
833
834#define HPUX_GATEWAY_ADDR 0xC0000004
835#define LINUX_GATEWAY_ADDR 0x100
836
837#endif /* _UAPI_ASM_PARISC_UNISTD_H_ */
diff --git a/arch/parisc/kernel/entry.S b/arch/parisc/kernel/entry.S
index 18670a07884..c9a9abd4bc5 100644
--- a/arch/parisc/kernel/entry.S
+++ b/arch/parisc/kernel/entry.S
@@ -708,59 +708,9 @@ ENTRY(end_fault_vector)
708 .import do_cpu_irq_mask,code 708 .import do_cpu_irq_mask,code
709 709
710 /* 710 /*
711 * r26 = function to be called
712 * r25 = argument to pass in
713 * r24 = flags for do_fork()
714 *
715 * Kernel threads don't ever return, so they don't need
716 * a true register context. We just save away the arguments
717 * for copy_thread/ret_ to properly set up the child.
718 */
719
720#define CLONE_VM 0x100 /* Must agree with <linux/sched.h> */
721#define CLONE_UNTRACED 0x00800000
722
723 .import do_fork
724ENTRY(__kernel_thread)
725 STREG %r2, -RP_OFFSET(%r30)
726
727 copy %r30, %r1
728 ldo PT_SZ_ALGN(%r30),%r30
729#ifdef CONFIG_64BIT
730 /* Yo, function pointers in wide mode are little structs... -PB */
731 ldd 24(%r26), %r2
732 STREG %r2, PT_GR27(%r1) /* Store childs %dp */
733 ldd 16(%r26), %r26
734
735 STREG %r22, PT_GR22(%r1) /* save r22 (arg5) */
736 copy %r0, %r22 /* user_tid */
737#endif
738 STREG %r26, PT_GR26(%r1) /* Store function & argument for child */
739 STREG %r25, PT_GR25(%r1)
740 ldil L%CLONE_UNTRACED, %r26
741 ldo CLONE_VM(%r26), %r26 /* Force CLONE_VM since only init_mm */
742 or %r26, %r24, %r26 /* will have kernel mappings. */
743 ldi 1, %r25 /* stack_start, signals kernel thread */
744 stw %r0, -52(%r30) /* user_tid */
745#ifdef CONFIG_64BIT
746 ldo -16(%r30),%r29 /* Reference param save area */
747#endif
748 BL do_fork, %r2
749 copy %r1, %r24 /* pt_regs */
750
751 /* Parent Returns here */
752
753 LDREG -PT_SZ_ALGN-RP_OFFSET(%r30), %r2
754 ldo -PT_SZ_ALGN(%r30), %r30
755 bv %r0(%r2)
756 nop
757ENDPROC(__kernel_thread)
758
759 /*
760 * Child Returns here 711 * Child Returns here
761 * 712 *
762 * copy_thread moved args from temp save area set up above 713 * copy_thread moved args into task save area.
763 * into task save area.
764 */ 714 */
765 715
766ENTRY(ret_from_kernel_thread) 716ENTRY(ret_from_kernel_thread)
@@ -769,51 +719,17 @@ ENTRY(ret_from_kernel_thread)
769 BL schedule_tail, %r2 719 BL schedule_tail, %r2
770 nop 720 nop
771 721
772 LDREG TI_TASK-THREAD_SZ_ALGN(%r30), %r1 722 LDREG TI_TASK-THREAD_SZ_ALGN-FRAME_SIZE(%r30), %r1
773 LDREG TASK_PT_GR25(%r1), %r26 723 LDREG TASK_PT_GR25(%r1), %r26
774#ifdef CONFIG_64BIT 724#ifdef CONFIG_64BIT
775 LDREG TASK_PT_GR27(%r1), %r27 725 LDREG TASK_PT_GR27(%r1), %r27
776 LDREG TASK_PT_GR22(%r1), %r22
777#endif 726#endif
778 LDREG TASK_PT_GR26(%r1), %r1 727 LDREG TASK_PT_GR26(%r1), %r1
779 ble 0(%sr7, %r1) 728 ble 0(%sr7, %r1)
780 copy %r31, %r2 729 copy %r31, %r2
781 730 b finish_child_return
782#ifdef CONFIG_64BIT
783 ldo -16(%r30),%r29 /* Reference param save area */
784 loadgp /* Thread could have been in a module */
785#endif
786#ifndef CONFIG_64BIT
787 b sys_exit
788#else
789 load32 sys_exit, %r1
790 bv %r0(%r1)
791#endif
792 ldi 0, %r26
793ENDPROC(ret_from_kernel_thread)
794
795 .import sys_execve, code
796ENTRY(__execve)
797 copy %r2, %r15
798 copy %r30, %r16
799 ldo PT_SZ_ALGN(%r30), %r30
800 STREG %r26, PT_GR26(%r16)
801 STREG %r25, PT_GR25(%r16)
802 STREG %r24, PT_GR24(%r16)
803#ifdef CONFIG_64BIT
804 ldo -16(%r30),%r29 /* Reference param save area */
805#endif
806 BL sys_execve, %r2
807 copy %r16, %r26
808
809 cmpib,=,n 0,%r28,intr_return /* forward */
810
811 /* yes, this will trap and die. */
812 copy %r15, %r2
813 copy %r16, %r30
814 bv %r0(%r2)
815 nop 731 nop
816ENDPROC(__execve) 732ENDPROC(ret_from_kernel_thread)
817 733
818 734
819 /* 735 /*
@@ -1776,49 +1692,27 @@ ENTRY(sys_fork_wrapper)
1776 LDREG TI_TASK-THREAD_SZ_ALGN-FRAME_SIZE(%r30), %r1 1692 LDREG TI_TASK-THREAD_SZ_ALGN-FRAME_SIZE(%r30), %r1
1777 ldo TASK_REGS(%r1),%r1 1693 ldo TASK_REGS(%r1),%r1
1778 reg_save %r1 1694 reg_save %r1
1779 mfctl %cr27, %r3 1695 mfctl %cr27, %r28
1780 STREG %r3, PT_CR27(%r1) 1696 STREG %r28, PT_CR27(%r1)
1781
1782 STREG %r2,-RP_OFFSET(%r30)
1783 ldo FRAME_SIZE(%r30),%r30
1784#ifdef CONFIG_64BIT
1785 ldo -16(%r30),%r29 /* Reference param save area */
1786#endif
1787
1788 /* These are call-clobbered registers and therefore
1789 also syscall-clobbered (we hope). */
1790 STREG %r2,PT_GR19(%r1) /* save for child */
1791 STREG %r30,PT_GR21(%r1)
1792 1697
1793 LDREG PT_GR30(%r1),%r25 1698 LDREG PT_GR30(%r1),%r25
1794 copy %r1,%r24 1699 copy %r1,%r24
1795 BL sys_clone,%r2 1700 b sys_clone
1796 ldi SIGCHLD,%r26 1701 ldi SIGCHLD,%r26
1797
1798 LDREG -RP_OFFSET-FRAME_SIZE(%r30),%r2
1799wrapper_exit:
1800 ldo -FRAME_SIZE(%r30),%r30 /* get the stackframe */
1801 LDREG TI_TASK-THREAD_SZ_ALGN-FRAME_SIZE(%r30),%r1
1802 ldo TASK_REGS(%r1),%r1 /* get pt regs */
1803
1804 LDREG PT_CR27(%r1), %r3
1805 mtctl %r3, %cr27
1806 reg_restore %r1
1807
1808 /* strace expects syscall # to be preserved in r20 */
1809 ldi __NR_fork,%r20
1810 bv %r0(%r2)
1811 STREG %r20,PT_GR20(%r1)
1812ENDPROC(sys_fork_wrapper) 1702ENDPROC(sys_fork_wrapper)
1813 1703
1814 /* Set the return value for the child */ 1704 /* Set the return value for the child */
1815ENTRY(child_return) 1705ENTRY(child_return)
1816 BL schedule_tail, %r2 1706 BL schedule_tail, %r2
1817 nop 1707 nop
1708finish_child_return:
1709 LDREG TI_TASK-THREAD_SZ_ALGN-FRAME_SIZE(%r30), %r1
1710 ldo TASK_REGS(%r1),%r1 /* get pt regs */
1818 1711
1819 LDREG TI_TASK-THREAD_SZ_ALGN-FRAME_SIZE-FRAME_SIZE(%r30), %r1 1712 LDREG PT_CR27(%r1), %r3
1820 LDREG TASK_PT_GR19(%r1),%r2 1713 mtctl %r3, %cr27
1821 b wrapper_exit 1714 reg_restore %r1
1715 b syscall_exit
1822 copy %r0,%r28 1716 copy %r0,%r28
1823ENDPROC(child_return) 1717ENDPROC(child_return)
1824 1718
@@ -1827,23 +1721,10 @@ ENTRY(sys_clone_wrapper)
1827 LDREG TI_TASK-THREAD_SZ_ALGN-FRAME_SIZE(%r30),%r1 1721 LDREG TI_TASK-THREAD_SZ_ALGN-FRAME_SIZE(%r30),%r1
1828 ldo TASK_REGS(%r1),%r1 /* get pt regs */ 1722 ldo TASK_REGS(%r1),%r1 /* get pt regs */
1829 reg_save %r1 1723 reg_save %r1
1830 mfctl %cr27, %r3 1724 mfctl %cr27, %r28
1831 STREG %r3, PT_CR27(%r1) 1725 STREG %r28, PT_CR27(%r1)
1832 1726 b sys_clone
1833 STREG %r2,-RP_OFFSET(%r30)
1834 ldo FRAME_SIZE(%r30),%r30
1835#ifdef CONFIG_64BIT
1836 ldo -16(%r30),%r29 /* Reference param save area */
1837#endif
1838
1839 /* WARNING - Clobbers r19 and r21, userspace must save these! */
1840 STREG %r2,PT_GR19(%r1) /* save for child */
1841 STREG %r30,PT_GR21(%r1)
1842 BL sys_clone,%r2
1843 copy %r1,%r24 1727 copy %r1,%r24
1844
1845 b wrapper_exit
1846 LDREG -RP_OFFSET-FRAME_SIZE(%r30),%r2
1847ENDPROC(sys_clone_wrapper) 1728ENDPROC(sys_clone_wrapper)
1848 1729
1849 1730
@@ -1851,72 +1732,14 @@ ENTRY(sys_vfork_wrapper)
1851 LDREG TI_TASK-THREAD_SZ_ALGN-FRAME_SIZE(%r30),%r1 1732 LDREG TI_TASK-THREAD_SZ_ALGN-FRAME_SIZE(%r30),%r1
1852 ldo TASK_REGS(%r1),%r1 /* get pt regs */ 1733 ldo TASK_REGS(%r1),%r1 /* get pt regs */
1853 reg_save %r1 1734 reg_save %r1
1854 mfctl %cr27, %r3 1735 mfctl %cr27, %r28
1855 STREG %r3, PT_CR27(%r1) 1736 STREG %r28, PT_CR27(%r1)
1856 1737
1857 STREG %r2,-RP_OFFSET(%r30) 1738 b sys_vfork
1858 ldo FRAME_SIZE(%r30),%r30
1859#ifdef CONFIG_64BIT
1860 ldo -16(%r30),%r29 /* Reference param save area */
1861#endif
1862
1863 STREG %r2,PT_GR19(%r1) /* save for child */
1864 STREG %r30,PT_GR21(%r1)
1865
1866 BL sys_vfork,%r2
1867 copy %r1,%r26 1739 copy %r1,%r26
1868
1869 b wrapper_exit
1870 LDREG -RP_OFFSET-FRAME_SIZE(%r30),%r2
1871ENDPROC(sys_vfork_wrapper) 1740ENDPROC(sys_vfork_wrapper)
1872 1741
1873 1742
1874 .macro execve_wrapper execve
1875 LDREG TI_TASK-THREAD_SZ_ALGN-FRAME_SIZE(%r30),%r1
1876 ldo TASK_REGS(%r1),%r1 /* get pt regs */
1877
1878 /*
1879 * Do we need to save/restore r3-r18 here?
1880 * I don't think so. why would new thread need old
1881 * threads registers?
1882 */
1883
1884 /* %arg0 - %arg3 are already saved for us. */
1885
1886 STREG %r2,-RP_OFFSET(%r30)
1887 ldo FRAME_SIZE(%r30),%r30
1888#ifdef CONFIG_64BIT
1889 ldo -16(%r30),%r29 /* Reference param save area */
1890#endif
1891 BL \execve,%r2
1892 copy %r1,%arg0
1893
1894 ldo -FRAME_SIZE(%r30),%r30
1895 LDREG -RP_OFFSET(%r30),%r2
1896
1897 /* If exec succeeded we need to load the args */
1898
1899 ldo -1024(%r0),%r1
1900 cmpb,>>= %r28,%r1,error_\execve
1901 copy %r2,%r19
1902
1903error_\execve:
1904 bv %r0(%r19)
1905 nop
1906 .endm
1907
1908 .import sys_execve
1909ENTRY(sys_execve_wrapper)
1910 execve_wrapper sys_execve
1911ENDPROC(sys_execve_wrapper)
1912
1913#ifdef CONFIG_64BIT
1914 .import sys32_execve
1915ENTRY(sys32_execve_wrapper)
1916 execve_wrapper sys32_execve
1917ENDPROC(sys32_execve_wrapper)
1918#endif
1919
1920ENTRY(sys_rt_sigreturn_wrapper) 1743ENTRY(sys_rt_sigreturn_wrapper)
1921 LDREG TI_TASK-THREAD_SZ_ALGN-FRAME_SIZE(%r30),%r26 1744 LDREG TI_TASK-THREAD_SZ_ALGN-FRAME_SIZE(%r30),%r26
1922 ldo TASK_REGS(%r26),%r26 /* get pt regs */ 1745 ldo TASK_REGS(%r26),%r26 /* get pt regs */
diff --git a/arch/parisc/kernel/process.c b/arch/parisc/kernel/process.c
index cbc37216bf9..38db36f6430 100644
--- a/arch/parisc/kernel/process.c
+++ b/arch/parisc/kernel/process.c
@@ -52,6 +52,7 @@
52 52
53#include <asm/io.h> 53#include <asm/io.h>
54#include <asm/asm-offsets.h> 54#include <asm/asm-offsets.h>
55#include <asm/assembly.h>
55#include <asm/pdc.h> 56#include <asm/pdc.h>
56#include <asm/pdc_chassis.h> 57#include <asm/pdc_chassis.h>
57#include <asm/pgalloc.h> 58#include <asm/pgalloc.h>
@@ -165,23 +166,6 @@ void (*pm_power_off)(void) = machine_power_off;
165EXPORT_SYMBOL(pm_power_off); 166EXPORT_SYMBOL(pm_power_off);
166 167
167/* 168/*
168 * Create a kernel thread
169 */
170
171extern pid_t __kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
172pid_t kernel_thread(int (*fn)(void *), void *arg, unsigned long flags)
173{
174
175 /*
176 * FIXME: Once we are sure we don't need any debug here,
177 * kernel_thread can become a #define.
178 */
179
180 return __kernel_thread(fn, arg, flags);
181}
182EXPORT_SYMBOL(kernel_thread);
183
184/*
185 * Free current thread data structures etc.. 169 * Free current thread data structures etc..
186 */ 170 */
187void exit_thread(void) 171void exit_thread(void)
@@ -256,8 +240,8 @@ sys_vfork(struct pt_regs *regs)
256 240
257int 241int
258copy_thread(unsigned long clone_flags, unsigned long usp, 242copy_thread(unsigned long clone_flags, unsigned long usp,
259 unsigned long unused, /* in ia64 this is "user_stack_size" */ 243 unsigned long arg,
260 struct task_struct * p, struct pt_regs * pregs) 244 struct task_struct *p, struct pt_regs *pregs)
261{ 245{
262 struct pt_regs * cregs = &(p->thread.regs); 246 struct pt_regs * cregs = &(p->thread.regs);
263 void *stack = task_stack_page(p); 247 void *stack = task_stack_page(p);
@@ -270,48 +254,32 @@ copy_thread(unsigned long clone_flags, unsigned long usp,
270#ifdef CONFIG_HPUX 254#ifdef CONFIG_HPUX
271 extern void * const hpux_child_return; 255 extern void * const hpux_child_return;
272#endif 256#endif
257 if (unlikely(p->flags & PF_KTHREAD)) {
258 memset(cregs, 0, sizeof(struct pt_regs));
259 if (!usp) /* idle thread */
260 return 0;
273 261
274 *cregs = *pregs;
275
276 /* Set the return value for the child. Note that this is not
277 actually restored by the syscall exit path, but we put it
278 here for consistency in case of signals. */
279 cregs->gr[28] = 0; /* child */
280
281 /*
282 * We need to differentiate between a user fork and a
283 * kernel fork. We can't use user_mode, because the
284 * the syscall path doesn't save iaoq. Right now
285 * We rely on the fact that kernel_thread passes
286 * in zero for usp.
287 */
288 if (usp == 1) {
289 /* kernel thread */ 262 /* kernel thread */
290 cregs->ksp = (unsigned long)stack + THREAD_SZ_ALGN;
291 /* Must exit via ret_from_kernel_thread in order 263 /* Must exit via ret_from_kernel_thread in order
292 * to call schedule_tail() 264 * to call schedule_tail()
293 */ 265 */
266 cregs->ksp = (unsigned long)stack + THREAD_SZ_ALGN + FRAME_SIZE;
294 cregs->kpc = (unsigned long) &ret_from_kernel_thread; 267 cregs->kpc = (unsigned long) &ret_from_kernel_thread;
295 /* 268 /*
296 * Copy function and argument to be called from 269 * Copy function and argument to be called from
297 * ret_from_kernel_thread. 270 * ret_from_kernel_thread.
298 */ 271 */
299#ifdef CONFIG_64BIT 272#ifdef CONFIG_64BIT
300 cregs->gr[27] = pregs->gr[27]; 273 cregs->gr[27] = ((unsigned long *)usp)[3];
274 cregs->gr[26] = ((unsigned long *)usp)[2];
275#else
276 cregs->gr[26] = usp;
301#endif 277#endif
302 cregs->gr[26] = pregs->gr[26]; 278 cregs->gr[25] = arg;
303 cregs->gr[25] = pregs->gr[25];
304 } else { 279 } else {
305 /* user thread */ 280 /* user thread */
306 /*
307 * Note that the fork wrappers are responsible
308 * for setting gr[21].
309 */
310
311 /* Use same stack depth as parent */
312 cregs->ksp = (unsigned long)stack
313 + (pregs->gr[21] & (THREAD_SIZE - 1));
314 cregs->gr[30] = usp; 281 cregs->gr[30] = usp;
282 cregs->ksp = (unsigned long)stack + THREAD_SZ_ALGN + FRAME_SIZE;
315 if (personality(p->personality) == PER_HPUX) { 283 if (personality(p->personality) == PER_HPUX) {
316#ifdef CONFIG_HPUX 284#ifdef CONFIG_HPUX
317 cregs->kpc = (unsigned long) &hpux_child_return; 285 cregs->kpc = (unsigned long) &hpux_child_return;
@@ -323,8 +291,7 @@ copy_thread(unsigned long clone_flags, unsigned long usp,
323 } 291 }
324 /* Setup thread TLS area from the 4th parameter in clone */ 292 /* Setup thread TLS area from the 4th parameter in clone */
325 if (clone_flags & CLONE_SETTLS) 293 if (clone_flags & CLONE_SETTLS)
326 cregs->cr27 = pregs->gr[23]; 294 cregs->cr27 = pregs->gr[23];
327
328 } 295 }
329 296
330 return 0; 297 return 0;
@@ -335,39 +302,6 @@ unsigned long thread_saved_pc(struct task_struct *t)
335 return t->thread.regs.kpc; 302 return t->thread.regs.kpc;
336} 303}
337 304
338/*
339 * sys_execve() executes a new program.
340 */
341
342asmlinkage int sys_execve(struct pt_regs *regs)
343{
344 int error;
345 struct filename *filename;
346
347 filename = getname((const char __user *) regs->gr[26]);
348 error = PTR_ERR(filename);
349 if (IS_ERR(filename))
350 goto out;
351 error = do_execve(filename->name,
352 (const char __user *const __user *) regs->gr[25],
353 (const char __user *const __user *) regs->gr[24],
354 regs);
355 putname(filename);
356out:
357
358 return error;
359}
360
361extern int __execve(const char *filename,
362 const char *const argv[],
363 const char *const envp[], struct task_struct *task);
364int kernel_execve(const char *filename,
365 const char *const argv[],
366 const char *const envp[])
367{
368 return __execve(filename, argv, envp, current);
369}
370
371unsigned long 305unsigned long
372get_wchan(struct task_struct *p) 306get_wchan(struct task_struct *p)
373{ 307{
diff --git a/arch/parisc/kernel/signal32.c b/arch/parisc/kernel/signal32.c
index fd49aeda9eb..5dede04f2f3 100644
--- a/arch/parisc/kernel/signal32.c
+++ b/arch/parisc/kernel/signal32.c
@@ -65,7 +65,8 @@ put_sigset32(compat_sigset_t __user *up, sigset_t *set, size_t sz)
65{ 65{
66 compat_sigset_t s; 66 compat_sigset_t s;
67 67
68 if (sz != sizeof *set) panic("put_sigset32()"); 68 if (sz != sizeof *set)
69 return -EINVAL;
69 sigset_64to32(&s, set); 70 sigset_64to32(&s, set);
70 71
71 return copy_to_user(up, &s, sizeof s); 72 return copy_to_user(up, &s, sizeof s);
@@ -77,7 +78,8 @@ get_sigset32(compat_sigset_t __user *up, sigset_t *set, size_t sz)
77 compat_sigset_t s; 78 compat_sigset_t s;
78 int r; 79 int r;
79 80
80 if (sz != sizeof *set) panic("put_sigset32()"); 81 if (sz != sizeof *set)
82 return -EINVAL;
81 83
82 if ((r = copy_from_user(&s, up, sz)) == 0) { 84 if ((r = copy_from_user(&s, up, sz)) == 0) {
83 sigset_32to64(set, &s); 85 sigset_32to64(set, &s);
diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
index 7426e40699b..f76c10863c6 100644
--- a/arch/parisc/kernel/sys_parisc.c
+++ b/arch/parisc/kernel/sys_parisc.c
@@ -73,6 +73,8 @@ static unsigned long get_shared_area(struct address_space *mapping,
73 struct vm_area_struct *vma; 73 struct vm_area_struct *vma;
74 int offset = mapping ? get_offset(mapping) : 0; 74 int offset = mapping ? get_offset(mapping) : 0;
75 75
76 offset = (offset + (pgoff << PAGE_SHIFT)) & 0x3FF000;
77
76 addr = DCACHE_ALIGN(addr - offset) + offset; 78 addr = DCACHE_ALIGN(addr - offset) + offset;
77 79
78 for (vma = find_vma(current->mm, addr); ; vma = vma->vm_next) { 80 for (vma = find_vma(current->mm, addr); ; vma = vma->vm_next) {
diff --git a/arch/parisc/kernel/sys_parisc32.c b/arch/parisc/kernel/sys_parisc32.c
index bf5b93a885d..9cfdaa19ab6 100644
--- a/arch/parisc/kernel/sys_parisc32.c
+++ b/arch/parisc/kernel/sys_parisc32.c
@@ -53,28 +53,6 @@
53#define DBG(x) 53#define DBG(x)
54#endif 54#endif
55 55
56/*
57 * sys32_execve() executes a new program.
58 */
59
60asmlinkage int sys32_execve(struct pt_regs *regs)
61{
62 int error;
63 struct filename *filename;
64
65 DBG(("sys32_execve(%p) r26 = 0x%lx\n", regs, regs->gr[26]));
66 filename = getname((const char __user *) regs->gr[26]);
67 error = PTR_ERR(filename);
68 if (IS_ERR(filename))
69 goto out;
70 error = compat_do_execve(filename->name, compat_ptr(regs->gr[25]),
71 compat_ptr(regs->gr[24]), regs);
72 putname(filename);
73out:
74
75 return error;
76}
77
78asmlinkage long sys32_unimplemented(int r26, int r25, int r24, int r23, 56asmlinkage long sys32_unimplemented(int r26, int r25, int r24, int r23,
79 int r22, int r21, int r20) 57 int r22, int r21, int r20)
80{ 58{
diff --git a/arch/parisc/kernel/syscall_table.S b/arch/parisc/kernel/syscall_table.S
index 3735abd7f8f..cb2da96d6ab 100644
--- a/arch/parisc/kernel/syscall_table.S
+++ b/arch/parisc/kernel/syscall_table.S
@@ -66,7 +66,7 @@
66 ENTRY_SAME(creat) 66 ENTRY_SAME(creat)
67 ENTRY_SAME(link) 67 ENTRY_SAME(link)
68 ENTRY_SAME(unlink) /* 10 */ 68 ENTRY_SAME(unlink) /* 10 */
69 ENTRY_DIFF(execve_wrapper) 69 ENTRY_COMP(execve)
70 ENTRY_SAME(chdir) 70 ENTRY_SAME(chdir)
71 /* See comments in kernel/time.c!!! Maybe we don't need this? */ 71 /* See comments in kernel/time.c!!! Maybe we don't need this? */
72 ENTRY_COMP(time) 72 ENTRY_COMP(time)
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index a902a5c1c76..5af5aa70717 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -144,6 +144,7 @@ config PPC
144 select GENERIC_KERNEL_THREAD 144 select GENERIC_KERNEL_THREAD
145 select HAVE_MOD_ARCH_SPECIFIC 145 select HAVE_MOD_ARCH_SPECIFIC
146 select MODULES_USE_ELF_RELA 146 select MODULES_USE_ELF_RELA
147 select GENERIC_KERNEL_EXECVE
147 148
148config EARLY_PRINTK 149config EARLY_PRINTK
149 bool 150 bool
diff --git a/arch/powerpc/boot/dts/mpc5200b.dtsi b/arch/powerpc/boot/dts/mpc5200b.dtsi
index 7ab286ab530..39ed65a44c5 100644
--- a/arch/powerpc/boot/dts/mpc5200b.dtsi
+++ b/arch/powerpc/boot/dts/mpc5200b.dtsi
@@ -231,6 +231,12 @@
231 interrupts = <2 7 0>; 231 interrupts = <2 7 0>;
232 }; 232 };
233 233
234 sclpc@3c00 {
235 compatible = "fsl,mpc5200-lpbfifo";
236 reg = <0x3c00 0x60>;
237 interrupts = <2 23 0>;
238 };
239
234 i2c@3d00 { 240 i2c@3d00 {
235 #address-cells = <1>; 241 #address-cells = <1>;
236 #size-cells = <0>; 242 #size-cells = <0>;
diff --git a/arch/powerpc/boot/dts/o2d.dtsi b/arch/powerpc/boot/dts/o2d.dtsi
index 3444eb8f0ad..24f66803929 100644
--- a/arch/powerpc/boot/dts/o2d.dtsi
+++ b/arch/powerpc/boot/dts/o2d.dtsi
@@ -86,12 +86,6 @@
86 reg = <0>; 86 reg = <0>;
87 }; 87 };
88 }; 88 };
89
90 sclpc@3c00 {
91 compatible = "fsl,mpc5200-lpbfifo";
92 reg = <0x3c00 0x60>;
93 interrupts = <3 23 0>;
94 };
95 }; 89 };
96 90
97 localbus { 91 localbus {
diff --git a/arch/powerpc/boot/dts/pcm030.dts b/arch/powerpc/boot/dts/pcm030.dts
index 9e354997eb7..96512c05803 100644
--- a/arch/powerpc/boot/dts/pcm030.dts
+++ b/arch/powerpc/boot/dts/pcm030.dts
@@ -59,7 +59,7 @@
59 #gpio-cells = <2>; 59 #gpio-cells = <2>;
60 }; 60 };
61 61
62 psc@2000 { /* PSC1 in ac97 mode */ 62 audioplatform: psc@2000 { /* PSC1 in ac97 mode */
63 compatible = "mpc5200b-psc-ac97","fsl,mpc5200b-psc-ac97"; 63 compatible = "mpc5200b-psc-ac97","fsl,mpc5200b-psc-ac97";
64 cell-index = <0>; 64 cell-index = <0>;
65 }; 65 };
@@ -134,4 +134,9 @@
134 localbus { 134 localbus {
135 status = "disabled"; 135 status = "disabled";
136 }; 136 };
137
138 sound {
139 compatible = "phytec,pcm030-audio-fabric";
140 asoc-platform = <&audioplatform>;
141 };
137}; 142};
diff --git a/arch/powerpc/include/asm/kvm_book3s_32.h b/arch/powerpc/include/asm/kvm_book3s_32.h
index 38040ff8206..ce0ef6ce8f8 100644
--- a/arch/powerpc/include/asm/kvm_book3s_32.h
+++ b/arch/powerpc/include/asm/kvm_book3s_32.h
@@ -42,5 +42,6 @@ static inline void svcpu_put(struct kvmppc_book3s_shadow_vcpu *svcpu)
42#define SID_SHIFT 28 42#define SID_SHIFT 28
43#define ESID_MASK 0xf0000000 43#define ESID_MASK 0xf0000000
44#define VSID_MASK 0x00fffffff0000000ULL 44#define VSID_MASK 0x00fffffff0000000ULL
45#define VPN_SHIFT 12
45 46
46#endif /* __ASM_KVM_BOOK3S_32_H__ */ 47#endif /* __ASM_KVM_BOOK3S_32_H__ */
diff --git a/arch/powerpc/include/asm/processor.h b/arch/powerpc/include/asm/processor.h
index 8734b385527..87502046c0d 100644
--- a/arch/powerpc/include/asm/processor.h
+++ b/arch/powerpc/include/asm/processor.h
@@ -388,9 +388,9 @@ extern int powersave_nap; /* set if nap mode can be used in idle loop */
388extern void power7_nap(void); 388extern void power7_nap(void);
389 389
390#ifdef CONFIG_PSERIES_IDLE 390#ifdef CONFIG_PSERIES_IDLE
391extern void update_smt_snooze_delay(int snooze); 391extern void update_smt_snooze_delay(int cpu, int residency);
392#else 392#else
393static inline void update_smt_snooze_delay(int snooze) {} 393static inline void update_smt_snooze_delay(int cpu, int residency) {}
394#endif 394#endif
395 395
396extern void flush_instruction_cache(void); 396extern void flush_instruction_cache(void);
diff --git a/arch/powerpc/include/asm/unistd.h b/arch/powerpc/include/asm/unistd.h
index 921dce6d844..280068cfff2 100644
--- a/arch/powerpc/include/asm/unistd.h
+++ b/arch/powerpc/include/asm/unistd.h
@@ -56,7 +56,6 @@
56#define __ARCH_WANT_COMPAT_SYS_SENDFILE 56#define __ARCH_WANT_COMPAT_SYS_SENDFILE
57#endif 57#endif
58#define __ARCH_WANT_SYS_EXECVE 58#define __ARCH_WANT_SYS_EXECVE
59#define __ARCH_WANT_KERNEL_EXECVE
60 59
61/* 60/*
62 * "Conditional" syscalls 61 * "Conditional" syscalls
diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S
index 9499385676e..d22e73e4618 100644
--- a/arch/powerpc/kernel/entry_32.S
+++ b/arch/powerpc/kernel/entry_32.S
@@ -444,11 +444,6 @@ ret_from_kernel_thread:
444 PPC440EP_ERR42 444 PPC440EP_ERR42
445 blrl 445 blrl
446 li r3,0 446 li r3,0
447 b do_exit # no return
448
449 .globl __ret_from_kernel_execve
450__ret_from_kernel_execve:
451 addi r1,r3,-STACK_FRAME_OVERHEAD
452 b ret_from_syscall 447 b ret_from_syscall
453 448
454/* Traced system call support */ 449/* Traced system call support */
diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
index 56e0ff0878b..e9a906c2723 100644
--- a/arch/powerpc/kernel/entry_64.S
+++ b/arch/powerpc/kernel/entry_64.S
@@ -373,17 +373,11 @@ _GLOBAL(ret_from_fork)
373_GLOBAL(ret_from_kernel_thread) 373_GLOBAL(ret_from_kernel_thread)
374 bl .schedule_tail 374 bl .schedule_tail
375 REST_NVGPRS(r1) 375 REST_NVGPRS(r1)
376 REST_GPR(2,r1) 376 ld r14, 0(r14)
377 mtlr r14 377 mtlr r14
378 mr r3,r15 378 mr r3,r15
379 blrl 379 blrl
380 li r3,0 380 li r3,0
381 b .do_exit # no return
382
383_GLOBAL(__ret_from_kernel_execve)
384 addi r1,r3,-STACK_FRAME_OVERHEAD
385 li r10,1
386 std r10,SOFTE(r1)
387 b syscall_exit 381 b syscall_exit
388 382
389 .section ".toc","aw" 383 .section ".toc","aw"
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index ba48233500f..f6d244db920 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -745,25 +745,24 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
745 /* Copy registers */ 745 /* Copy registers */
746 sp -= sizeof(struct pt_regs); 746 sp -= sizeof(struct pt_regs);
747 childregs = (struct pt_regs *) sp; 747 childregs = (struct pt_regs *) sp;
748 if (!regs) { 748 if (unlikely(p->flags & PF_KTHREAD)) {
749 /* for kernel thread, set `current' and stackptr in new task */ 749 struct thread_info *ti = (void *)task_stack_page(p);
750 memset(childregs, 0, sizeof(struct pt_regs)); 750 memset(childregs, 0, sizeof(struct pt_regs));
751 childregs->gpr[1] = sp + sizeof(struct pt_regs); 751 childregs->gpr[1] = sp + sizeof(struct pt_regs);
752 childregs->gpr[14] = usp; /* function */
752#ifdef CONFIG_PPC64 753#ifdef CONFIG_PPC64
753 childregs->gpr[14] = *(unsigned long *)usp;
754 childregs->gpr[2] = ((unsigned long *)usp)[1],
755 clear_tsk_thread_flag(p, TIF_32BIT); 754 clear_tsk_thread_flag(p, TIF_32BIT);
756#else 755 childregs->softe = 1;
757 childregs->gpr[14] = usp; /* function */
758 childregs->gpr[2] = (unsigned long) p;
759#endif 756#endif
760 childregs->gpr[15] = arg; 757 childregs->gpr[15] = arg;
761 p->thread.regs = NULL; /* no user register state */ 758 p->thread.regs = NULL; /* no user register state */
759 ti->flags |= _TIF_RESTOREALL;
762 f = ret_from_kernel_thread; 760 f = ret_from_kernel_thread;
763 } else { 761 } else {
764 CHECK_FULL_REGS(regs); 762 CHECK_FULL_REGS(regs);
765 *childregs = *regs; 763 *childregs = *regs;
766 childregs->gpr[1] = usp; 764 if (usp)
765 childregs->gpr[1] = usp;
767 p->thread.regs = childregs; 766 p->thread.regs = childregs;
768 childregs->gpr[3] = 0; /* Result from fork() */ 767 childregs->gpr[3] = 0; /* Result from fork() */
769 if (clone_flags & CLONE_SETTLS) { 768 if (clone_flags & CLONE_SETTLS) {
@@ -1027,22 +1026,11 @@ int get_unalign_ctl(struct task_struct *tsk, unsigned long adr)
1027 return put_user(tsk->thread.align_ctl, (unsigned int __user *)adr); 1026 return put_user(tsk->thread.align_ctl, (unsigned int __user *)adr);
1028} 1027}
1029 1028
1030#define TRUNC_PTR(x) ((typeof(x))(((unsigned long)(x)) & 0xffffffff))
1031
1032int sys_clone(unsigned long clone_flags, unsigned long usp, 1029int sys_clone(unsigned long clone_flags, unsigned long usp,
1033 int __user *parent_tidp, void __user *child_threadptr, 1030 int __user *parent_tidp, void __user *child_threadptr,
1034 int __user *child_tidp, int p6, 1031 int __user *child_tidp, int p6,
1035 struct pt_regs *regs) 1032 struct pt_regs *regs)
1036{ 1033{
1037 CHECK_FULL_REGS(regs);
1038 if (usp == 0)
1039 usp = regs->gpr[1]; /* stack pointer for child */
1040#ifdef CONFIG_PPC64
1041 if (is_32bit_task()) {
1042 parent_tidp = TRUNC_PTR(parent_tidp);
1043 child_tidp = TRUNC_PTR(child_tidp);
1044 }
1045#endif
1046 return do_fork(clone_flags, usp, regs, 0, parent_tidp, child_tidp); 1034 return do_fork(clone_flags, usp, regs, 0, parent_tidp, child_tidp);
1047} 1035}
1048 1036
@@ -1050,28 +1038,17 @@ int sys_fork(unsigned long p1, unsigned long p2, unsigned long p3,
1050 unsigned long p4, unsigned long p5, unsigned long p6, 1038 unsigned long p4, unsigned long p5, unsigned long p6,
1051 struct pt_regs *regs) 1039 struct pt_regs *regs)
1052{ 1040{
1053 CHECK_FULL_REGS(regs); 1041 return do_fork(SIGCHLD, 0, regs, 0, NULL, NULL);
1054 return do_fork(SIGCHLD, regs->gpr[1], regs, 0, NULL, NULL);
1055} 1042}
1056 1043
1057int sys_vfork(unsigned long p1, unsigned long p2, unsigned long p3, 1044int sys_vfork(unsigned long p1, unsigned long p2, unsigned long p3,
1058 unsigned long p4, unsigned long p5, unsigned long p6, 1045 unsigned long p4, unsigned long p5, unsigned long p6,
1059 struct pt_regs *regs) 1046 struct pt_regs *regs)
1060{ 1047{
1061 CHECK_FULL_REGS(regs); 1048 return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, 0,
1062 return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, regs->gpr[1],
1063 regs, 0, NULL, NULL); 1049 regs, 0, NULL, NULL);
1064} 1050}
1065 1051
1066void __ret_from_kernel_execve(struct pt_regs *normal)
1067__noreturn;
1068
1069void ret_from_kernel_execve(struct pt_regs *normal)
1070{
1071 set_thread_flag(TIF_RESTOREALL);
1072 __ret_from_kernel_execve(normal);
1073}
1074
1075static inline int valid_irq_stack(unsigned long sp, struct task_struct *p, 1052static inline int valid_irq_stack(unsigned long sp, struct task_struct *p,
1076 unsigned long nbytes) 1053 unsigned long nbytes)
1077{ 1054{
diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
index 8302af64921..cf357a059dd 100644
--- a/arch/powerpc/kernel/sysfs.c
+++ b/arch/powerpc/kernel/sysfs.c
@@ -50,7 +50,7 @@ static ssize_t store_smt_snooze_delay(struct device *dev,
50 return -EINVAL; 50 return -EINVAL;
51 51
52 per_cpu(smt_snooze_delay, cpu->dev.id) = snooze; 52 per_cpu(smt_snooze_delay, cpu->dev.id) = snooze;
53 update_smt_snooze_delay(snooze); 53 update_smt_snooze_delay(cpu->dev.id, snooze);
54 54
55 return count; 55 return count;
56} 56}
diff --git a/arch/powerpc/kvm/book3s_32_mmu_host.c b/arch/powerpc/kvm/book3s_32_mmu_host.c
index 00aa61268e0..b0f625a3334 100644
--- a/arch/powerpc/kvm/book3s_32_mmu_host.c
+++ b/arch/powerpc/kvm/book3s_32_mmu_host.c
@@ -173,8 +173,8 @@ int kvmppc_mmu_map_page(struct kvm_vcpu *vcpu, struct kvmppc_pte *orig_pte)
173 BUG_ON(!map); 173 BUG_ON(!map);
174 174
175 vsid = map->host_vsid; 175 vsid = map->host_vsid;
176 vpn = (vsid << (SID_SHIFT - VPN_SHIFT)) | ((eaddr & ~ESID_MASK) >> VPN_SHIFT) 176 vpn = (vsid << (SID_SHIFT - VPN_SHIFT)) |
177 177 ((eaddr & ~ESID_MASK) >> VPN_SHIFT);
178next_pteg: 178next_pteg:
179 if (rr == 16) { 179 if (rr == 16) {
180 primary = !primary; 180 primary = !primary;
diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c
index 0db88f501f9..aa2465e21f1 100644
--- a/arch/powerpc/perf/core-book3s.c
+++ b/arch/powerpc/perf/core-book3s.c
@@ -1463,7 +1463,7 @@ static void perf_event_interrupt(struct pt_regs *regs)
1463 if (!event->hw.idx || is_limited_pmc(event->hw.idx)) 1463 if (!event->hw.idx || is_limited_pmc(event->hw.idx))
1464 continue; 1464 continue;
1465 val = read_pmc(event->hw.idx); 1465 val = read_pmc(event->hw.idx);
1466 if (pmc_overflow(val)) { 1466 if ((int)val < 0) {
1467 /* event has overflowed */ 1467 /* event has overflowed */
1468 found = 1; 1468 found = 1;
1469 record_and_restart(event, val, regs); 1469 record_and_restart(event, val, regs);
diff --git a/arch/powerpc/platforms/52xx/mpc52xx_pic.c b/arch/powerpc/platforms/52xx/mpc52xx_pic.c
index 8520b58a5e9..b89ef65392d 100644
--- a/arch/powerpc/platforms/52xx/mpc52xx_pic.c
+++ b/arch/powerpc/platforms/52xx/mpc52xx_pic.c
@@ -372,10 +372,11 @@ static int mpc52xx_irqhost_map(struct irq_domain *h, unsigned int virq,
372 case MPC52xx_IRQ_L1_MAIN: irqchip = &mpc52xx_main_irqchip; break; 372 case MPC52xx_IRQ_L1_MAIN: irqchip = &mpc52xx_main_irqchip; break;
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 default: 375 case MPC52xx_IRQ_L1_CRIT:
376 pr_err("%s: invalid irq: virq=%i, l1=%i, l2=%i\n", 376 pr_warn("%s: Critical IRQ #%d is unsupported! Nopping it.\n",
377 __func__, virq, l1irq, l2irq); 377 __func__, l2irq);
378 return -EINVAL; 378 irq_set_chip(virq, &no_irq_chip);
379 return 0;
379 } 380 }
380 381
381 irq_set_chip_and_handler(virq, irqchip, handle_level_irq); 382 irq_set_chip_and_handler(virq, irqchip, handle_level_irq);
diff --git a/arch/powerpc/platforms/pseries/eeh_pe.c b/arch/powerpc/platforms/pseries/eeh_pe.c
index 797cd181dc3..d16c8ded108 100644
--- a/arch/powerpc/platforms/pseries/eeh_pe.c
+++ b/arch/powerpc/platforms/pseries/eeh_pe.c
@@ -449,7 +449,7 @@ int eeh_rmv_from_parent_pe(struct eeh_dev *edev, int purge_pe)
449 if (list_empty(&pe->edevs)) { 449 if (list_empty(&pe->edevs)) {
450 cnt = 0; 450 cnt = 0;
451 list_for_each_entry(child, &pe->child_list, child) { 451 list_for_each_entry(child, &pe->child_list, child) {
452 if (!(pe->type & EEH_PE_INVALID)) { 452 if (!(child->type & EEH_PE_INVALID)) {
453 cnt++; 453 cnt++;
454 break; 454 break;
455 } 455 }
diff --git a/arch/powerpc/platforms/pseries/msi.c b/arch/powerpc/platforms/pseries/msi.c
index d19f4977c83..e5b08472313 100644
--- a/arch/powerpc/platforms/pseries/msi.c
+++ b/arch/powerpc/platforms/pseries/msi.c
@@ -220,7 +220,8 @@ static struct device_node *find_pe_dn(struct pci_dev *dev, int *total)
220 220
221 /* Get the top level device in the PE */ 221 /* Get the top level device in the PE */
222 edev = of_node_to_eeh_dev(dn); 222 edev = of_node_to_eeh_dev(dn);
223 edev = list_first_entry(&edev->pe->edevs, struct eeh_dev, list); 223 if (edev->pe)
224 edev = list_first_entry(&edev->pe->edevs, struct eeh_dev, list);
224 dn = eeh_dev_to_of_node(edev); 225 dn = eeh_dev_to_of_node(edev);
225 if (!dn) 226 if (!dn)
226 return NULL; 227 return NULL;
diff --git a/arch/powerpc/platforms/pseries/processor_idle.c b/arch/powerpc/platforms/pseries/processor_idle.c
index 455760b1fe6..45d00e5fe14 100644
--- a/arch/powerpc/platforms/pseries/processor_idle.c
+++ b/arch/powerpc/platforms/pseries/processor_idle.c
@@ -33,13 +33,6 @@ static int max_idle_state = MAX_IDLE_STATE_COUNT - 1;
33static struct cpuidle_device __percpu *pseries_cpuidle_devices; 33static struct cpuidle_device __percpu *pseries_cpuidle_devices;
34static struct cpuidle_state *cpuidle_state_table; 34static struct cpuidle_state *cpuidle_state_table;
35 35
36void update_smt_snooze_delay(int snooze)
37{
38 struct cpuidle_driver *drv = cpuidle_get_driver();
39 if (drv)
40 drv->states[0].target_residency = snooze;
41}
42
43static inline void idle_loop_prolog(unsigned long *in_purr, ktime_t *kt_before) 36static inline void idle_loop_prolog(unsigned long *in_purr, ktime_t *kt_before)
44{ 37{
45 38
@@ -66,32 +59,22 @@ static int snooze_loop(struct cpuidle_device *dev,
66{ 59{
67 unsigned long in_purr; 60 unsigned long in_purr;
68 ktime_t kt_before; 61 ktime_t kt_before;
69 unsigned long start_snooze; 62 int cpu = dev->cpu;
70 long snooze = drv->states[0].target_residency;
71 63
72 idle_loop_prolog(&in_purr, &kt_before); 64 idle_loop_prolog(&in_purr, &kt_before);
65 local_irq_enable();
66 set_thread_flag(TIF_POLLING_NRFLAG);
73 67
74 if (snooze) { 68 while ((!need_resched()) && cpu_online(cpu)) {
75 start_snooze = get_tb() + snooze * tb_ticks_per_usec; 69 ppc64_runlatch_off();
76 local_irq_enable(); 70 HMT_low();
77 set_thread_flag(TIF_POLLING_NRFLAG); 71 HMT_very_low();
78
79 while ((snooze < 0) || (get_tb() < start_snooze)) {
80 if (need_resched() || cpu_is_offline(dev->cpu))
81 goto out;
82 ppc64_runlatch_off();
83 HMT_low();
84 HMT_very_low();
85 }
86
87 HMT_medium();
88 clear_thread_flag(TIF_POLLING_NRFLAG);
89 smp_mb();
90 local_irq_disable();
91 } 72 }
92 73
93out:
94 HMT_medium(); 74 HMT_medium();
75 clear_thread_flag(TIF_POLLING_NRFLAG);
76 smp_mb();
77
95 dev->last_residency = 78 dev->last_residency =
96 (int)idle_loop_epilog(in_purr, kt_before); 79 (int)idle_loop_epilog(in_purr, kt_before);
97 return index; 80 return index;
@@ -172,8 +155,8 @@ static struct cpuidle_state dedicated_states[MAX_IDLE_STATE_COUNT] = {
172 .name = "CEDE", 155 .name = "CEDE",
173 .desc = "CEDE", 156 .desc = "CEDE",
174 .flags = CPUIDLE_FLAG_TIME_VALID, 157 .flags = CPUIDLE_FLAG_TIME_VALID,
175 .exit_latency = 1, 158 .exit_latency = 10,
176 .target_residency = 10, 159 .target_residency = 100,
177 .enter = &dedicated_cede_loop }, 160 .enter = &dedicated_cede_loop },
178}; 161};
179 162
@@ -190,6 +173,23 @@ static struct cpuidle_state shared_states[MAX_IDLE_STATE_COUNT] = {
190 .enter = &shared_cede_loop }, 173 .enter = &shared_cede_loop },
191}; 174};
192 175
176void update_smt_snooze_delay(int cpu, int residency)
177{
178 struct cpuidle_driver *drv = cpuidle_get_driver();
179 struct cpuidle_device *dev = per_cpu(cpuidle_devices, cpu);
180
181 if (cpuidle_state_table != dedicated_states)
182 return;
183
184 if (residency < 0) {
185 /* Disable the Nap state on that cpu */
186 if (dev)
187 dev->states_usage[1].disable = 1;
188 } else
189 if (drv)
190 drv->states[1].target_residency = residency;
191}
192
193static int pseries_cpuidle_add_cpu_notifier(struct notifier_block *n, 193static int pseries_cpuidle_add_cpu_notifier(struct notifier_block *n,
194 unsigned long action, void *hcpu) 194 unsigned long action, void *hcpu)
195{ 195{
@@ -246,10 +246,6 @@ static int pseries_cpuidle_driver_init(void)
246 drv->states[drv->state_count] = /* structure copy */ 246 drv->states[drv->state_count] = /* structure copy */
247 cpuidle_state_table[idle_state]; 247 cpuidle_state_table[idle_state];
248 248
249 if (cpuidle_state_table == dedicated_states)
250 drv->states[drv->state_count].target_residency =
251 __get_cpu_var(smt_snooze_delay);
252
253 drv->state_count += 1; 249 drv->state_count += 1;
254 } 250 }
255 251
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index 3f3d9ca7a5b..a163784e72c 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -96,6 +96,7 @@ config S390
96 select HAVE_MEMBLOCK_NODE_MAP 96 select HAVE_MEMBLOCK_NODE_MAP
97 select HAVE_CMPXCHG_LOCAL 97 select HAVE_CMPXCHG_LOCAL
98 select HAVE_CMPXCHG_DOUBLE 98 select HAVE_CMPXCHG_DOUBLE
99 select HAVE_ALIGNED_STRUCT_PAGE if SLUB
99 select HAVE_VIRT_CPU_ACCOUNTING 100 select HAVE_VIRT_CPU_ACCOUNTING
100 select VIRT_CPU_ACCOUNTING 101 select VIRT_CPU_ACCOUNTING
101 select ARCH_DISCARD_MEMBLOCK 102 select ARCH_DISCARD_MEMBLOCK
@@ -130,12 +131,14 @@ config S390
130 select ARCH_INLINE_WRITE_UNLOCK_IRQRESTORE 131 select ARCH_INLINE_WRITE_UNLOCK_IRQRESTORE
131 select HAVE_UID16 if 32BIT 132 select HAVE_UID16 if 32BIT
132 select ARCH_WANT_IPC_PARSE_VERSION 133 select ARCH_WANT_IPC_PARSE_VERSION
134 select HAVE_ARCH_TRANSPARENT_HUGEPAGE if 64BIT
133 select GENERIC_SMP_IDLE_THREAD 135 select GENERIC_SMP_IDLE_THREAD
134 select GENERIC_TIME_VSYSCALL_OLD 136 select GENERIC_TIME_VSYSCALL_OLD
135 select GENERIC_CLOCKEVENTS 137 select GENERIC_CLOCKEVENTS
136 select KTIME_SCALAR if 32BIT 138 select KTIME_SCALAR if 32BIT
137 select HAVE_ARCH_SECCOMP_FILTER 139 select HAVE_ARCH_SECCOMP_FILTER
138 select GENERIC_KERNEL_THREAD 140 select GENERIC_KERNEL_THREAD
141 select GENERIC_KERNEL_EXECVE
139 select HAVE_MOD_ARCH_SPECIFIC 142 select HAVE_MOD_ARCH_SPECIFIC
140 select MODULES_USE_ELF_RELA 143 select MODULES_USE_ELF_RELA
141 144
diff --git a/arch/s390/boot/compressed/vmlinux.lds.S b/arch/s390/boot/compressed/vmlinux.lds.S
index d80f79d8dd9..8e1fb823928 100644
--- a/arch/s390/boot/compressed/vmlinux.lds.S
+++ b/arch/s390/boot/compressed/vmlinux.lds.S
@@ -5,7 +5,7 @@ OUTPUT_FORMAT("elf64-s390", "elf64-s390", "elf64-s390")
5OUTPUT_ARCH(s390:64-bit) 5OUTPUT_ARCH(s390:64-bit)
6#else 6#else
7OUTPUT_FORMAT("elf32-s390", "elf32-s390", "elf32-s390") 7OUTPUT_FORMAT("elf32-s390", "elf32-s390", "elf32-s390")
8OUTPUT_ARCH(s390) 8OUTPUT_ARCH(s390:31-bit)
9#endif 9#endif
10 10
11ENTRY(startup) 11ENTRY(startup)
diff --git a/arch/s390/include/asm/cio.h b/arch/s390/include/asm/cio.h
index 55bde603521..ad2b924167d 100644
--- a/arch/s390/include/asm/cio.h
+++ b/arch/s390/include/asm/cio.h
@@ -9,6 +9,8 @@
9 9
10#define LPM_ANYPATH 0xff 10#define LPM_ANYPATH 0xff
11#define __MAX_CSSID 0 11#define __MAX_CSSID 0
12#define __MAX_SUBCHANNEL 65535
13#define __MAX_SSID 3
12 14
13#include <asm/scsw.h> 15#include <asm/scsw.h>
14 16
diff --git a/arch/s390/include/asm/compat.h b/arch/s390/include/asm/compat.h
index a34a9d612fc..18cd6b59265 100644
--- a/arch/s390/include/asm/compat.h
+++ b/arch/s390/include/asm/compat.h
@@ -20,7 +20,7 @@
20#define PSW32_MASK_CC 0x00003000UL 20#define PSW32_MASK_CC 0x00003000UL
21#define PSW32_MASK_PM 0x00000f00UL 21#define PSW32_MASK_PM 0x00000f00UL
22 22
23#define PSW32_MASK_USER 0x00003F00UL 23#define PSW32_MASK_USER 0x0000FF00UL
24 24
25#define PSW32_ADDR_AMODE 0x80000000UL 25#define PSW32_ADDR_AMODE 0x80000000UL
26#define PSW32_ADDR_INSN 0x7FFFFFFFUL 26#define PSW32_ADDR_INSN 0x7FFFFFFFUL
diff --git a/arch/s390/include/asm/perf_event.h b/arch/s390/include/asm/perf_event.h
index 7941968e12b..5f0173a3169 100644
--- a/arch/s390/include/asm/perf_event.h
+++ b/arch/s390/include/asm/perf_event.h
@@ -9,7 +9,7 @@
9#include <asm/cpu_mf.h> 9#include <asm/cpu_mf.h>
10 10
11/* CPU-measurement counter facility */ 11/* CPU-measurement counter facility */
12#define PERF_CPUM_CF_MAX_CTR 160 12#define PERF_CPUM_CF_MAX_CTR 256
13 13
14/* Per-CPU flags for PMU states */ 14/* Per-CPU flags for PMU states */
15#define PMU_F_RESERVED 0x1000 15#define PMU_F_RESERVED 0x1000
diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h
index dd647c919a6..2d3b7cb2600 100644
--- a/arch/s390/include/asm/pgtable.h
+++ b/arch/s390/include/asm/pgtable.h
@@ -506,12 +506,15 @@ static inline int pud_bad(pud_t pud)
506 506
507static inline int pmd_present(pmd_t pmd) 507static inline int pmd_present(pmd_t pmd)
508{ 508{
509 return (pmd_val(pmd) & _SEGMENT_ENTRY_ORIGIN) != 0UL; 509 unsigned long mask = _SEGMENT_ENTRY_INV | _SEGMENT_ENTRY_RO;
510 return (pmd_val(pmd) & mask) == _HPAGE_TYPE_NONE ||
511 !(pmd_val(pmd) & _SEGMENT_ENTRY_INV);
510} 512}
511 513
512static inline int pmd_none(pmd_t pmd) 514static inline int pmd_none(pmd_t pmd)
513{ 515{
514 return (pmd_val(pmd) & _SEGMENT_ENTRY_INV) != 0UL; 516 return (pmd_val(pmd) & _SEGMENT_ENTRY_INV) &&
517 !(pmd_val(pmd) & _SEGMENT_ENTRY_RO);
515} 518}
516 519
517static inline int pmd_large(pmd_t pmd) 520static inline int pmd_large(pmd_t pmd)
@@ -1223,6 +1226,11 @@ static inline void __pmd_idte(unsigned long address, pmd_t *pmdp)
1223} 1226}
1224 1227
1225#ifdef CONFIG_TRANSPARENT_HUGEPAGE 1228#ifdef CONFIG_TRANSPARENT_HUGEPAGE
1229
1230#define SEGMENT_NONE __pgprot(_HPAGE_TYPE_NONE)
1231#define SEGMENT_RO __pgprot(_HPAGE_TYPE_RO)
1232#define SEGMENT_RW __pgprot(_HPAGE_TYPE_RW)
1233
1226#define __HAVE_ARCH_PGTABLE_DEPOSIT 1234#define __HAVE_ARCH_PGTABLE_DEPOSIT
1227extern void pgtable_trans_huge_deposit(struct mm_struct *mm, pgtable_t pgtable); 1235extern void pgtable_trans_huge_deposit(struct mm_struct *mm, pgtable_t pgtable);
1228 1236
@@ -1242,16 +1250,15 @@ static inline void set_pmd_at(struct mm_struct *mm, unsigned long addr,
1242 1250
1243static inline unsigned long massage_pgprot_pmd(pgprot_t pgprot) 1251static inline unsigned long massage_pgprot_pmd(pgprot_t pgprot)
1244{ 1252{
1245 unsigned long pgprot_pmd = 0; 1253 /*
1246 1254 * pgprot is PAGE_NONE, PAGE_RO, or PAGE_RW (see __Pxxx / __Sxxx)
1247 if (pgprot_val(pgprot) & _PAGE_INVALID) { 1255 * Convert to segment table entry format.
1248 if (pgprot_val(pgprot) & _PAGE_SWT) 1256 */
1249 pgprot_pmd |= _HPAGE_TYPE_NONE; 1257 if (pgprot_val(pgprot) == pgprot_val(PAGE_NONE))
1250 pgprot_pmd |= _SEGMENT_ENTRY_INV; 1258 return pgprot_val(SEGMENT_NONE);
1251 } 1259 if (pgprot_val(pgprot) == pgprot_val(PAGE_RO))
1252 if (pgprot_val(pgprot) & _PAGE_RO) 1260 return pgprot_val(SEGMENT_RO);
1253 pgprot_pmd |= _SEGMENT_ENTRY_RO; 1261 return pgprot_val(SEGMENT_RW);
1254 return pgprot_pmd;
1255} 1262}
1256 1263
1257static inline pmd_t pmd_modify(pmd_t pmd, pgprot_t newprot) 1264static inline pmd_t pmd_modify(pmd_t pmd, pgprot_t newprot)
@@ -1269,7 +1276,9 @@ static inline pmd_t pmd_mkhuge(pmd_t pmd)
1269 1276
1270static inline pmd_t pmd_mkwrite(pmd_t pmd) 1277static inline pmd_t pmd_mkwrite(pmd_t pmd)
1271{ 1278{
1272 pmd_val(pmd) &= ~_SEGMENT_ENTRY_RO; 1279 /* Do not clobber _HPAGE_TYPE_NONE pages! */
1280 if (!(pmd_val(pmd) & _SEGMENT_ENTRY_INV))
1281 pmd_val(pmd) &= ~_SEGMENT_ENTRY_RO;
1273 return pmd; 1282 return pmd;
1274} 1283}
1275 1284
diff --git a/arch/s390/include/asm/topology.h b/arch/s390/include/asm/topology.h
index 9ca30538376..9935cbd6a46 100644
--- a/arch/s390/include/asm/topology.h
+++ b/arch/s390/include/asm/topology.h
@@ -8,6 +8,9 @@ struct cpu;
8 8
9#ifdef CONFIG_SCHED_BOOK 9#ifdef CONFIG_SCHED_BOOK
10 10
11extern unsigned char cpu_socket_id[NR_CPUS];
12#define topology_physical_package_id(cpu) (cpu_socket_id[cpu])
13
11extern unsigned char cpu_core_id[NR_CPUS]; 14extern unsigned char cpu_core_id[NR_CPUS];
12extern cpumask_t cpu_core_map[NR_CPUS]; 15extern cpumask_t cpu_core_map[NR_CPUS];
13 16
diff --git a/arch/s390/include/asm/unistd.h b/arch/s390/include/asm/unistd.h
index bbbae41fa9a..ccbcab7742c 100644
--- a/arch/s390/include/asm/unistd.h
+++ b/arch/s390/include/asm/unistd.h
@@ -54,7 +54,6 @@
54# define __ARCH_WANT_COMPAT_SYS_RT_SIGSUSPEND 54# define __ARCH_WANT_COMPAT_SYS_RT_SIGSUSPEND
55# endif 55# endif
56#define __ARCH_WANT_SYS_EXECVE 56#define __ARCH_WANT_SYS_EXECVE
57#define __ARCH_WANT_KERNEL_EXECVE
58 57
59/* 58/*
60 * "Conditional" syscalls 59 * "Conditional" syscalls
diff --git a/arch/s390/include/uapi/asm/chpid.h b/arch/s390/include/uapi/asm/chpid.h
index 581992dfae2..6b4fb29cc19 100644
--- a/arch/s390/include/uapi/asm/chpid.h
+++ b/arch/s390/include/uapi/asm/chpid.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright IBM Corp. 2007 2 * Copyright IBM Corp. 2007, 2012
3 * Author(s): Peter Oberparleiter <peter.oberparleiter@de.ibm.com> 3 * Author(s): Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
4 */ 4 */
5 5
@@ -12,10 +12,10 @@
12#define __MAX_CHPID 255 12#define __MAX_CHPID 255
13 13
14struct chp_id { 14struct chp_id {
15 u8 reserved1; 15 __u8 reserved1;
16 u8 cssid; 16 __u8 cssid;
17 u8 reserved2; 17 __u8 reserved2;
18 u8 id; 18 __u8 id;
19} __attribute__((packed)); 19} __attribute__((packed));
20 20
21 21
diff --git a/arch/s390/include/uapi/asm/kvm_para.h b/arch/s390/include/uapi/asm/kvm_para.h
index e69de29bb2d..ff1f4e7b301 100644
--- a/arch/s390/include/uapi/asm/kvm_para.h
+++ b/arch/s390/include/uapi/asm/kvm_para.h
@@ -0,0 +1,11 @@
1/*
2 * User API definitions for paravirtual devices on s390
3 *
4 * Copyright IBM Corp. 2008
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 only)
8 * as published by the Free Software Foundation.
9 *
10 * Author(s): Christian Borntraeger <borntraeger@de.ibm.com>
11 */
diff --git a/arch/s390/include/uapi/asm/ptrace.h b/arch/s390/include/uapi/asm/ptrace.h
index 705588a16d7..a5ca214b34f 100644
--- a/arch/s390/include/uapi/asm/ptrace.h
+++ b/arch/s390/include/uapi/asm/ptrace.h
@@ -239,7 +239,7 @@ typedef struct
239#define PSW_MASK_EA 0x00000000UL 239#define PSW_MASK_EA 0x00000000UL
240#define PSW_MASK_BA 0x00000000UL 240#define PSW_MASK_BA 0x00000000UL
241 241
242#define PSW_MASK_USER 0x00003F00UL 242#define PSW_MASK_USER 0x0000FF00UL
243 243
244#define PSW_ADDR_AMODE 0x80000000UL 244#define PSW_ADDR_AMODE 0x80000000UL
245#define PSW_ADDR_INSN 0x7FFFFFFFUL 245#define PSW_ADDR_INSN 0x7FFFFFFFUL
@@ -269,7 +269,7 @@ typedef struct
269#define PSW_MASK_EA 0x0000000100000000UL 269#define PSW_MASK_EA 0x0000000100000000UL
270#define PSW_MASK_BA 0x0000000080000000UL 270#define PSW_MASK_BA 0x0000000080000000UL
271 271
272#define PSW_MASK_USER 0x00003F8180000000UL 272#define PSW_MASK_USER 0x0000FF8180000000UL
273 273
274#define PSW_ADDR_AMODE 0x0000000000000000UL 274#define PSW_ADDR_AMODE 0x0000000000000000UL
275#define PSW_ADDR_INSN 0xFFFFFFFFFFFFFFFFUL 275#define PSW_ADDR_INSN 0xFFFFFFFFFFFFFFFFUL
diff --git a/arch/s390/kernel/cache.c b/arch/s390/kernel/cache.c
index 8df8d8a19c9..64b24650e4f 100644
--- a/arch/s390/kernel/cache.c
+++ b/arch/s390/kernel/cache.c
@@ -59,8 +59,8 @@ enum {
59 59
60enum { 60enum {
61 CACHE_TI_UNIFIED = 0, 61 CACHE_TI_UNIFIED = 0,
62 CACHE_TI_INSTRUCTION = 0, 62 CACHE_TI_DATA = 0,
63 CACHE_TI_DATA, 63 CACHE_TI_INSTRUCTION,
64}; 64};
65 65
66struct cache_info { 66struct cache_info {
@@ -121,7 +121,10 @@ static int __init cache_add(int level, int private, int type)
121 cache = kzalloc(sizeof(*cache), GFP_KERNEL); 121 cache = kzalloc(sizeof(*cache), GFP_KERNEL);
122 if (!cache) 122 if (!cache)
123 return -ENOMEM; 123 return -ENOMEM;
124 ti = type == CACHE_TYPE_DATA ? CACHE_TI_DATA : CACHE_TI_UNIFIED; 124 if (type == CACHE_TYPE_INSTRUCTION)
125 ti = CACHE_TI_INSTRUCTION;
126 else
127 ti = CACHE_TI_UNIFIED;
125 cache->size = ecag(EXTRACT_SIZE, level, ti); 128 cache->size = ecag(EXTRACT_SIZE, level, ti);
126 cache->line_size = ecag(EXTRACT_LINE_SIZE, level, ti); 129 cache->line_size = ecag(EXTRACT_LINE_SIZE, level, ti);
127 cache->associativity = ecag(EXTRACT_ASSOCIATIVITY, level, ti); 130 cache->associativity = ecag(EXTRACT_ASSOCIATIVITY, level, ti);
diff --git a/arch/s390/kernel/compat_signal.c b/arch/s390/kernel/compat_signal.c
index a1e8a8694bb..593fcc9253f 100644
--- a/arch/s390/kernel/compat_signal.c
+++ b/arch/s390/kernel/compat_signal.c
@@ -309,6 +309,10 @@ static int restore_sigregs32(struct pt_regs *regs,_sigregs32 __user *sregs)
309 regs->psw.mask = (regs->psw.mask & ~PSW_MASK_USER) | 309 regs->psw.mask = (regs->psw.mask & ~PSW_MASK_USER) |
310 (__u64)(regs32.psw.mask & PSW32_MASK_USER) << 32 | 310 (__u64)(regs32.psw.mask & PSW32_MASK_USER) << 32 |
311 (__u64)(regs32.psw.addr & PSW32_ADDR_AMODE); 311 (__u64)(regs32.psw.addr & PSW32_ADDR_AMODE);
312 /* Check for invalid user address space control. */
313 if ((regs->psw.mask & PSW_MASK_ASC) >= (psw_kernel_bits & PSW_MASK_ASC))
314 regs->psw.mask = (psw_user_bits & PSW_MASK_ASC) |
315 (regs->psw.mask & ~PSW_MASK_ASC);
312 regs->psw.addr = (__u64)(regs32.psw.addr & PSW32_ADDR_INSN); 316 regs->psw.addr = (__u64)(regs32.psw.addr & PSW32_ADDR_INSN);
313 for (i = 0; i < NUM_GPRS; i++) 317 for (i = 0; i < NUM_GPRS; i++)
314 regs->gprs[i] = (__u64) regs32.gprs[i]; 318 regs->gprs[i] = (__u64) regs32.gprs[i];
@@ -481,7 +485,10 @@ static int setup_frame32(int sig, struct k_sigaction *ka,
481 485
482 /* Set up registers for signal handler */ 486 /* Set up registers for signal handler */
483 regs->gprs[15] = (__force __u64) frame; 487 regs->gprs[15] = (__force __u64) frame;
484 regs->psw.mask |= PSW_MASK_BA; /* force amode 31 */ 488 /* Force 31 bit amode and default user address space control. */
489 regs->psw.mask = PSW_MASK_BA |
490 (psw_user_bits & PSW_MASK_ASC) |
491 (regs->psw.mask & ~PSW_MASK_ASC);
485 regs->psw.addr = (__force __u64) ka->sa.sa_handler; 492 regs->psw.addr = (__force __u64) ka->sa.sa_handler;
486 493
487 regs->gprs[2] = map_signal(sig); 494 regs->gprs[2] = map_signal(sig);
@@ -549,7 +556,10 @@ static int setup_rt_frame32(int sig, struct k_sigaction *ka, siginfo_t *info,
549 556
550 /* Set up registers for signal handler */ 557 /* Set up registers for signal handler */
551 regs->gprs[15] = (__force __u64) frame; 558 regs->gprs[15] = (__force __u64) frame;
552 regs->psw.mask |= PSW_MASK_BA; /* force amode 31 */ 559 /* Force 31 bit amode and default user address space control. */
560 regs->psw.mask = PSW_MASK_BA |
561 (psw_user_bits & PSW_MASK_ASC) |
562 (regs->psw.mask & ~PSW_MASK_ASC);
553 regs->psw.addr = (__u64) ka->sa.sa_handler; 563 regs->psw.addr = (__u64) ka->sa.sa_handler;
554 564
555 regs->gprs[2] = map_signal(sig); 565 regs->gprs[2] = map_signal(sig);
diff --git a/arch/s390/kernel/entry.S b/arch/s390/kernel/entry.S
index ef46f66bc0d..aa8f2ba6289 100644
--- a/arch/s390/kernel/entry.S
+++ b/arch/s390/kernel/entry.S
@@ -330,40 +330,18 @@ ENTRY(ret_from_fork)
330 la %r11,STACK_FRAME_OVERHEAD(%r15) 330 la %r11,STACK_FRAME_OVERHEAD(%r15)
331 l %r12,__LC_THREAD_INFO 331 l %r12,__LC_THREAD_INFO
332 l %r13,__LC_SVC_NEW_PSW+4 332 l %r13,__LC_SVC_NEW_PSW+4
333 tm __PT_PSW+1(%r11),0x01 # forking a kernel thread ?
334 je 1f
335 l %r1,BASED(.Lschedule_tail) 333 l %r1,BASED(.Lschedule_tail)
336 basr %r14,%r1 # call schedule_tail 334 basr %r14,%r1 # call schedule_tail
337 TRACE_IRQS_ON 335 TRACE_IRQS_ON
338 ssm __LC_SVC_NEW_PSW # reenable interrupts 336 ssm __LC_SVC_NEW_PSW # reenable interrupts
339 j sysc_tracenogo 337 tm __PT_PSW+1(%r11),0x01 # forking a kernel thread ?
340 338 jne sysc_tracenogo
3411: # it's a kernel thread 339 # it's a kernel thread
342 st %r15,__PT_R15(%r11) # store stack pointer for new kthread 340 lm %r9,%r10,__PT_R9(%r11) # load gprs
343 l %r1,BASED(.Lschedule_tail)
344 basr %r14,%r1 # call schedule_tail
345 TRACE_IRQS_ON
346 ssm __LC_SVC_NEW_PSW # reenable interrupts
347 lm %r9,%r11,__PT_R9(%r11) # load gprs
348ENTRY(kernel_thread_starter) 341ENTRY(kernel_thread_starter)
349 la %r2,0(%r10) 342 la %r2,0(%r10)
350 basr %r14,%r9 343 basr %r14,%r9
351 la %r2,0 344 j sysc_tracenogo
352 br %r11 # do_exit
353
354#
355# kernel_execve function needs to deal with pt_regs that is not
356# at the usual place
357#
358ENTRY(ret_from_kernel_execve)
359 ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
360 lr %r15,%r2
361 lr %r11,%r2
362 ahi %r15,-STACK_FRAME_OVERHEAD
363 xc __SF_BACKCHAIN(4,%r15),__SF_BACKCHAIN(%r15)
364 l %r12,__LC_THREAD_INFO
365 ssm __LC_SVC_NEW_PSW # reenable interrupts
366 j sysc_return
367 345
368/* 346/*
369 * Program check handler routine 347 * Program check handler routine
diff --git a/arch/s390/kernel/entry64.S b/arch/s390/kernel/entry64.S
index 07d8de35398..499e95e90f3 100644
--- a/arch/s390/kernel/entry64.S
+++ b/arch/s390/kernel/entry64.S
@@ -352,33 +352,17 @@ sysc_tracenogo:
352ENTRY(ret_from_fork) 352ENTRY(ret_from_fork)
353 la %r11,STACK_FRAME_OVERHEAD(%r15) 353 la %r11,STACK_FRAME_OVERHEAD(%r15)
354 lg %r12,__LC_THREAD_INFO 354 lg %r12,__LC_THREAD_INFO
355 tm __PT_PSW+1(%r11),0x01 # forking a kernel thread ?
356 je 1f
357 brasl %r14,schedule_tail 355 brasl %r14,schedule_tail
358 TRACE_IRQS_ON 356 TRACE_IRQS_ON
359 ssm __LC_SVC_NEW_PSW # reenable interrupts 357 ssm __LC_SVC_NEW_PSW # reenable interrupts
360 j sysc_tracenogo 358 tm __PT_PSW+1(%r11),0x01 # forking a kernel thread ?
3611: # it's a kernel thread 359 jne sysc_tracenogo
362 stg %r15,__PT_R15(%r11) # store stack pointer for new kthread 360 # it's a kernel thread
363 brasl %r14,schedule_tail 361 lmg %r9,%r10,__PT_R9(%r11) # load gprs
364 TRACE_IRQS_ON
365 ssm __LC_SVC_NEW_PSW # reenable interrupts
366 lmg %r9,%r11,__PT_R9(%r11) # load gprs
367ENTRY(kernel_thread_starter) 362ENTRY(kernel_thread_starter)
368 la %r2,0(%r10) 363 la %r2,0(%r10)
369 basr %r14,%r9 364 basr %r14,%r9
370 la %r2,0 365 j sysc_tracenogo
371 br %r11 # do_exit
372
373ENTRY(ret_from_kernel_execve)
374 ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts
375 lgr %r15,%r2
376 lgr %r11,%r2
377 aghi %r15,-STACK_FRAME_OVERHEAD
378 xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
379 lg %r12,__LC_THREAD_INFO
380 ssm __LC_SVC_NEW_PSW # reenable interrupts
381 j sysc_return
382 366
383/* 367/*
384 * Program check handler routine 368 * Program check handler routine
diff --git a/arch/s390/kernel/head_kdump.S b/arch/s390/kernel/head_kdump.S
index acaaaf4b705..085a95eb315 100644
--- a/arch/s390/kernel/head_kdump.S
+++ b/arch/s390/kernel/head_kdump.S
@@ -85,16 +85,10 @@
85.align 2 85.align 2
86startup_kdump_relocated: 86startup_kdump_relocated:
87 basr %r13,0 87 basr %r13,0
880: 880: lpswe .Lrestart_psw-0b(%r13) # Start new kernel...
89 mvc 0(8,%r0),.Lrestart_psw-0b(%r13) # Setup restart PSW
90 sam31 # Switch to 31 bit addr mode
91 sr %r1,%r1 # Erase register r1
92 sr %r2,%r2 # Erase register r2
93 sigp %r1,%r2,SIGP_SET_ARCHITECTURE # Switch to 31 bit arch mode
94 lpsw 0 # Start new kernel...
95.align 8 89.align 8
96.Lrestart_psw: 90.Lrestart_psw:
97 .long 0x00080000,0x80000000 + startup 91 .quad 0x0000000080000000,0x0000000000000000 + startup
98#else 92#else
99.align 2 93.align 2
100.Lep_startup_kdump: 94.Lep_startup_kdump:
diff --git a/arch/s390/kernel/perf_cpum_cf.c b/arch/s390/kernel/perf_cpum_cf.c
index 9871b1971ed..c4e7269d4a0 100644
--- a/arch/s390/kernel/perf_cpum_cf.c
+++ b/arch/s390/kernel/perf_cpum_cf.c
@@ -94,7 +94,7 @@ static int get_counter_set(u64 event)
94 set = CPUMF_CTR_SET_USER; 94 set = CPUMF_CTR_SET_USER;
95 else if (event < 128) 95 else if (event < 128)
96 set = CPUMF_CTR_SET_CRYPTO; 96 set = CPUMF_CTR_SET_CRYPTO;
97 else if (event < 160) 97 else if (event < 256)
98 set = CPUMF_CTR_SET_EXT; 98 set = CPUMF_CTR_SET_EXT;
99 99
100 return set; 100 return set;
@@ -138,6 +138,10 @@ static int validate_ctr_version(const struct hw_perf_event *hwc)
138 case CPUMF_CTR_SET_EXT: 138 case CPUMF_CTR_SET_EXT:
139 if (cpuhw->info.csvn < 1) 139 if (cpuhw->info.csvn < 1)
140 err = -EOPNOTSUPP; 140 err = -EOPNOTSUPP;
141 if ((cpuhw->info.csvn == 1 && hwc->config > 159) ||
142 (cpuhw->info.csvn == 2 && hwc->config > 175) ||
143 (cpuhw->info.csvn > 2 && hwc->config > 255))
144 err = -EOPNOTSUPP;
141 break; 145 break;
142 } 146 }
143 147
diff --git a/arch/s390/kernel/sclp.S b/arch/s390/kernel/sclp.S
index bf053898630..b6506ee32a3 100644
--- a/arch/s390/kernel/sclp.S
+++ b/arch/s390/kernel/sclp.S
@@ -44,6 +44,12 @@ _sclp_wait_int:
44#endif 44#endif
45 mvc .LoldpswS1-.LbaseS1(16,%r13),0(%r8) 45 mvc .LoldpswS1-.LbaseS1(16,%r13),0(%r8)
46 mvc 0(16,%r8),0(%r9) 46 mvc 0(16,%r8),0(%r9)
47#ifdef CONFIG_64BIT
48 epsw %r6,%r7 # set current addressing mode
49 nill %r6,0x1 # in new psw (31 or 64 bit mode)
50 nilh %r7,0x8000
51 stm %r6,%r7,0(%r8)
52#endif
47 lhi %r6,0x0200 # cr mask for ext int (cr0.54) 53 lhi %r6,0x0200 # cr mask for ext int (cr0.54)
48 ltr %r2,%r2 54 ltr %r2,%r2
49 jz .LsetctS1 55 jz .LsetctS1
@@ -87,7 +93,7 @@ _sclp_wait_int:
87 .long 0x00080000, 0x80000000+.LwaitS1 # PSW to handle ext int 93 .long 0x00080000, 0x80000000+.LwaitS1 # PSW to handle ext int
88#ifdef CONFIG_64BIT 94#ifdef CONFIG_64BIT
89.LextpswS1_64: 95.LextpswS1_64:
90 .quad 0x0000000180000000, .LwaitS1 # PSW to handle ext int, 64 bit 96 .quad 0, .LwaitS1 # PSW to handle ext int, 64 bit
91#endif 97#endif
92.LwaitpswS1: 98.LwaitpswS1:
93 .long 0x010a0000, 0x00000000+.LloopS1 # PSW to wait for ext int 99 .long 0x010a0000, 0x00000000+.LloopS1 # PSW to wait for ext int
diff --git a/arch/s390/kernel/signal.c b/arch/s390/kernel/signal.c
index c13a2a37ef0..d1259d87507 100644
--- a/arch/s390/kernel/signal.c
+++ b/arch/s390/kernel/signal.c
@@ -136,6 +136,10 @@ static int restore_sigregs(struct pt_regs *regs, _sigregs __user *sregs)
136 /* Use regs->psw.mask instead of psw_user_bits to preserve PER bit. */ 136 /* Use regs->psw.mask instead of psw_user_bits to preserve PER bit. */
137 regs->psw.mask = (regs->psw.mask & ~PSW_MASK_USER) | 137 regs->psw.mask = (regs->psw.mask & ~PSW_MASK_USER) |
138 (user_sregs.regs.psw.mask & PSW_MASK_USER); 138 (user_sregs.regs.psw.mask & PSW_MASK_USER);
139 /* Check for invalid user address space control. */
140 if ((regs->psw.mask & PSW_MASK_ASC) >= (psw_kernel_bits & PSW_MASK_ASC))
141 regs->psw.mask = (psw_user_bits & PSW_MASK_ASC) |
142 (regs->psw.mask & ~PSW_MASK_ASC);
139 /* Check for invalid amode */ 143 /* Check for invalid amode */
140 if (regs->psw.mask & PSW_MASK_EA) 144 if (regs->psw.mask & PSW_MASK_EA)
141 regs->psw.mask |= PSW_MASK_BA; 145 regs->psw.mask |= PSW_MASK_BA;
@@ -273,7 +277,10 @@ static int setup_frame(int sig, struct k_sigaction *ka,
273 277
274 /* Set up registers for signal handler */ 278 /* Set up registers for signal handler */
275 regs->gprs[15] = (unsigned long) frame; 279 regs->gprs[15] = (unsigned long) frame;
276 regs->psw.mask |= PSW_MASK_EA | PSW_MASK_BA; /* 64 bit amode */ 280 /* Force default amode and default user address space control. */
281 regs->psw.mask = PSW_MASK_EA | PSW_MASK_BA |
282 (psw_user_bits & PSW_MASK_ASC) |
283 (regs->psw.mask & ~PSW_MASK_ASC);
277 regs->psw.addr = (unsigned long) ka->sa.sa_handler | PSW_ADDR_AMODE; 284 regs->psw.addr = (unsigned long) ka->sa.sa_handler | PSW_ADDR_AMODE;
278 285
279 regs->gprs[2] = map_signal(sig); 286 regs->gprs[2] = map_signal(sig);
@@ -346,7 +353,10 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
346 353
347 /* Set up registers for signal handler */ 354 /* Set up registers for signal handler */
348 regs->gprs[15] = (unsigned long) frame; 355 regs->gprs[15] = (unsigned long) frame;
349 regs->psw.mask |= PSW_MASK_EA | PSW_MASK_BA; /* 64 bit amode */ 356 /* Force default amode and default user address space control. */
357 regs->psw.mask = PSW_MASK_EA | PSW_MASK_BA |
358 (psw_user_bits & PSW_MASK_ASC) |
359 (regs->psw.mask & ~PSW_MASK_ASC);
350 regs->psw.addr = (unsigned long) ka->sa.sa_handler | PSW_ADDR_AMODE; 360 regs->psw.addr = (unsigned long) ka->sa.sa_handler | PSW_ADDR_AMODE;
351 361
352 regs->gprs[2] = map_signal(sig); 362 regs->gprs[2] = map_signal(sig);
diff --git a/arch/s390/kernel/topology.c b/arch/s390/kernel/topology.c
index 54d93f4b681..dd55f7c2010 100644
--- a/arch/s390/kernel/topology.c
+++ b/arch/s390/kernel/topology.c
@@ -40,6 +40,7 @@ static DEFINE_SPINLOCK(topology_lock);
40static struct mask_info core_info; 40static struct mask_info core_info;
41cpumask_t cpu_core_map[NR_CPUS]; 41cpumask_t cpu_core_map[NR_CPUS];
42unsigned char cpu_core_id[NR_CPUS]; 42unsigned char cpu_core_id[NR_CPUS];
43unsigned char cpu_socket_id[NR_CPUS];
43 44
44static struct mask_info book_info; 45static struct mask_info book_info;
45cpumask_t cpu_book_map[NR_CPUS]; 46cpumask_t cpu_book_map[NR_CPUS];
@@ -83,11 +84,12 @@ static struct mask_info *add_cpus_to_mask(struct topology_cpu *tl_cpu,
83 cpumask_set_cpu(lcpu, &book->mask); 84 cpumask_set_cpu(lcpu, &book->mask);
84 cpu_book_id[lcpu] = book->id; 85 cpu_book_id[lcpu] = book->id;
85 cpumask_set_cpu(lcpu, &core->mask); 86 cpumask_set_cpu(lcpu, &core->mask);
87 cpu_core_id[lcpu] = rcpu;
86 if (one_core_per_cpu) { 88 if (one_core_per_cpu) {
87 cpu_core_id[lcpu] = rcpu; 89 cpu_socket_id[lcpu] = rcpu;
88 core = core->next; 90 core = core->next;
89 } else { 91 } else {
90 cpu_core_id[lcpu] = core->id; 92 cpu_socket_id[lcpu] = core->id;
91 } 93 }
92 smp_cpu_set_polarization(lcpu, tl_cpu->pp); 94 smp_cpu_set_polarization(lcpu, tl_cpu->pp);
93 } 95 }
diff --git a/arch/s390/kernel/vmlinux.lds.S b/arch/s390/kernel/vmlinux.lds.S
index de8fa9bbd35..79cb51adc74 100644
--- a/arch/s390/kernel/vmlinux.lds.S
+++ b/arch/s390/kernel/vmlinux.lds.S
@@ -8,7 +8,7 @@
8 8
9#ifndef CONFIG_64BIT 9#ifndef CONFIG_64BIT
10OUTPUT_FORMAT("elf32-s390", "elf32-s390", "elf32-s390") 10OUTPUT_FORMAT("elf32-s390", "elf32-s390", "elf32-s390")
11OUTPUT_ARCH(s390) 11OUTPUT_ARCH(s390:31-bit)
12ENTRY(startup) 12ENTRY(startup)
13jiffies = jiffies_64 + 4; 13jiffies = jiffies_64 + 4;
14#else 14#else
diff --git a/arch/s390/lib/uaccess_pt.c b/arch/s390/lib/uaccess_pt.c
index 2d37bb861fa..9017a63dda3 100644
--- a/arch/s390/lib/uaccess_pt.c
+++ b/arch/s390/lib/uaccess_pt.c
@@ -39,7 +39,7 @@ static __always_inline unsigned long follow_table(struct mm_struct *mm,
39 pmd = pmd_offset(pud, addr); 39 pmd = pmd_offset(pud, addr);
40 if (pmd_none(*pmd)) 40 if (pmd_none(*pmd))
41 return -0x10UL; 41 return -0x10UL;
42 if (pmd_huge(*pmd)) { 42 if (pmd_large(*pmd)) {
43 if (write && (pmd_val(*pmd) & _SEGMENT_ENTRY_RO)) 43 if (write && (pmd_val(*pmd) & _SEGMENT_ENTRY_RO))
44 return -0x04UL; 44 return -0x04UL;
45 return (pmd_val(*pmd) & HPAGE_MASK) + (addr & ~HPAGE_MASK); 45 return (pmd_val(*pmd) & HPAGE_MASK) + (addr & ~HPAGE_MASK);
diff --git a/arch/s390/mm/gup.c b/arch/s390/mm/gup.c
index 60acb93a468..1f5315d1215 100644
--- a/arch/s390/mm/gup.c
+++ b/arch/s390/mm/gup.c
@@ -126,7 +126,7 @@ static inline int gup_pmd_range(pud_t *pudp, pud_t pud, unsigned long addr,
126 */ 126 */
127 if (pmd_none(pmd) || pmd_trans_splitting(pmd)) 127 if (pmd_none(pmd) || pmd_trans_splitting(pmd))
128 return 0; 128 return 0;
129 if (unlikely(pmd_huge(pmd))) { 129 if (unlikely(pmd_large(pmd))) {
130 if (!gup_huge_pmd(pmdp, pmd, addr, next, 130 if (!gup_huge_pmd(pmdp, pmd, addr, next,
131 write, pages, nr)) 131 write, pages, nr))
132 return 0; 132 return 0;
@@ -180,8 +180,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
180 addr = start; 180 addr = start;
181 len = (unsigned long) nr_pages << PAGE_SHIFT; 181 len = (unsigned long) nr_pages << PAGE_SHIFT;
182 end = start + len; 182 end = start + len;
183 if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ, 183 if ((end < start) || (end > TASK_SIZE))
184 (void __user *)start, len)))
185 return 0; 184 return 0;
186 185
187 local_irq_save(flags); 186 local_irq_save(flags);
@@ -229,7 +228,7 @@ int get_user_pages_fast(unsigned long start, int nr_pages, int write,
229 addr = start; 228 addr = start;
230 len = (unsigned long) nr_pages << PAGE_SHIFT; 229 len = (unsigned long) nr_pages << PAGE_SHIFT;
231 end = start + len; 230 end = start + len;
232 if (end < start) 231 if ((end < start) || (end > TASK_SIZE))
233 goto slow_irqon; 232 goto slow_irqon;
234 233
235 /* 234 /*
diff --git a/arch/score/Kconfig b/arch/score/Kconfig
index 4f93a431a45..a285e78fb9c 100644
--- a/arch/score/Kconfig
+++ b/arch/score/Kconfig
@@ -13,6 +13,8 @@ config SCORE
13 select GENERIC_CLOCKEVENTS 13 select GENERIC_CLOCKEVENTS
14 select HAVE_MOD_ARCH_SPECIFIC 14 select HAVE_MOD_ARCH_SPECIFIC
15 select MODULES_USE_ELF_REL 15 select MODULES_USE_ELF_REL
16 select GENERIC_KERNEL_THREAD
17 select GENERIC_KERNEL_EXECVE
16 18
17choice 19choice
18 prompt "System type" 20 prompt "System type"
diff --git a/arch/score/include/asm/processor.h b/arch/score/include/asm/processor.h
index ab3aceb5420..d9a922d8711 100644
--- a/arch/score/include/asm/processor.h
+++ b/arch/score/include/asm/processor.h
@@ -13,7 +13,6 @@ struct task_struct;
13 */ 13 */
14extern void (*cpu_wait)(void); 14extern void (*cpu_wait)(void);
15 15
16extern long kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
17extern unsigned long thread_saved_pc(struct task_struct *tsk); 16extern unsigned long thread_saved_pc(struct task_struct *tsk);
18extern void start_thread(struct pt_regs *regs, 17extern void start_thread(struct pt_regs *regs,
19 unsigned long pc, unsigned long sp); 18 unsigned long pc, unsigned long sp);
diff --git a/arch/score/include/asm/syscalls.h b/arch/score/include/asm/syscalls.h
index 1dd5e0d6b0c..8d332534342 100644
--- a/arch/score/include/asm/syscalls.h
+++ b/arch/score/include/asm/syscalls.h
@@ -2,7 +2,6 @@
2#define _ASM_SCORE_SYSCALLS_H 2#define _ASM_SCORE_SYSCALLS_H
3 3
4asmlinkage long score_clone(struct pt_regs *regs); 4asmlinkage long score_clone(struct pt_regs *regs);
5asmlinkage long score_execve(struct pt_regs *regs);
6asmlinkage long score_sigaltstack(struct pt_regs *regs); 5asmlinkage long score_sigaltstack(struct pt_regs *regs);
7asmlinkage long score_rt_sigreturn(struct pt_regs *regs); 6asmlinkage long score_rt_sigreturn(struct pt_regs *regs);
8 7
diff --git a/arch/score/include/asm/unistd.h b/arch/score/include/asm/unistd.h
index a862384e9c1..b006ca43512 100644
--- a/arch/score/include/asm/unistd.h
+++ b/arch/score/include/asm/unistd.h
@@ -4,5 +4,6 @@
4#define __ARCH_WANT_SYSCALL_NO_FLAGS 4#define __ARCH_WANT_SYSCALL_NO_FLAGS
5#define __ARCH_WANT_SYSCALL_OFF_T 5#define __ARCH_WANT_SYSCALL_OFF_T
6#define __ARCH_WANT_SYSCALL_DEPRECATED 6#define __ARCH_WANT_SYSCALL_DEPRECATED
7#define __ARCH_WANT_SYS_EXECVE
7 8
8#include <asm-generic/unistd.h> 9#include <asm-generic/unistd.h>
diff --git a/arch/score/kernel/entry.S b/arch/score/kernel/entry.S
index 83bb96079c4..da9901088bb 100644
--- a/arch/score/kernel/entry.S
+++ b/arch/score/kernel/entry.S
@@ -278,6 +278,13 @@ need_resched:
278 nop 278 nop
279#endif 279#endif
280 280
281ENTRY(ret_from_kernel_thread)
282 bl schedule_tail # r4=struct task_struct *prev
283 nop
284 mv r4, r13
285 brl r12
286 j syscall_exit
287
281ENTRY(ret_from_fork) 288ENTRY(ret_from_fork)
282 bl schedule_tail # r4=struct task_struct *prev 289 bl schedule_tail # r4=struct task_struct *prev
283 290
@@ -480,11 +487,6 @@ illegal_syscall:
480 sw r9, [r0, PT_R7] 487 sw r9, [r0, PT_R7]
481 j syscall_return 488 j syscall_return
482 489
483ENTRY(sys_execve)
484 mv r4, r0
485 la r8, score_execve
486 br r8
487
488ENTRY(sys_clone) 490ENTRY(sys_clone)
489 mv r4, r0 491 mv r4, r0
490 la r8, score_clone 492 la r8, score_clone
diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
index 637970cfd3f..6f311cf64b9 100644
--- a/arch/score/kernel/process.c
+++ b/arch/score/kernel/process.c
@@ -60,6 +60,7 @@ void __noreturn cpu_idle(void)
60} 60}
61 61
62void ret_from_fork(void); 62void ret_from_fork(void);
63void ret_from_kernel_thread(void);
63 64
64void start_thread(struct pt_regs *regs, unsigned long pc, unsigned long sp) 65void start_thread(struct pt_regs *regs, unsigned long pc, unsigned long sp)
65{ 66{
@@ -86,29 +87,27 @@ void flush_thread(void) {}
86 * set up the kernel stack and exception frames for a new process 87 * set up the kernel stack and exception frames for a new process
87 */ 88 */
88int copy_thread(unsigned long clone_flags, unsigned long usp, 89int copy_thread(unsigned long clone_flags, unsigned long usp,
89 unsigned long unused, 90 unsigned long arg,
90 struct task_struct *p, struct pt_regs *regs) 91 struct task_struct *p, struct pt_regs *regs)
91{ 92{
92 struct thread_info *ti = task_thread_info(p); 93 struct thread_info *ti = task_thread_info(p);
93 struct pt_regs *childregs = task_pt_regs(p); 94 struct pt_regs *childregs = task_pt_regs(p);
94 95
95 p->set_child_tid = NULL; 96 p->thread.reg0 = (unsigned long) childregs;
96 p->clear_child_tid = NULL; 97 if (unlikely(!regs)) {
97 98 memset(childregs, 0, sizeof(struct pt_regs));
98 *childregs = *regs; 99 p->thread->reg12 = usp;
99 childregs->regs[7] = 0; /* Clear error flag */ 100 p->thread->reg13 = arg;
100 childregs->regs[4] = 0; /* Child gets zero as return value */ 101 p->thread.reg3 = (unsigned long) ret_from_kernel_thread;
101 regs->regs[4] = p->pid;
102
103 if (childregs->cp0_psr & 0x8) { /* test kernel fork or user fork */
104 childregs->regs[0] = usp; /* user fork */
105 } else { 102 } else {
106 childregs->regs[28] = (unsigned long) ti; /* kernel fork */ 103 *childregs = *regs;
107 childregs->regs[0] = (unsigned long) childregs; 104 childregs->regs[7] = 0; /* Clear error flag */
105 childregs->regs[4] = 0; /* Child gets zero as return value */
106 childregs->regs[0] = usp; /* user fork */
107 regs->regs[4] = p->pid; /* WTF? */
108 p->thread.reg3 = (unsigned long) ret_from_fork;
108 } 109 }
109 110
110 p->thread.reg0 = (unsigned long) childregs;
111 p->thread.reg3 = (unsigned long) ret_from_fork;
112 p->thread.cp0_psr = 0; 111 p->thread.cp0_psr = 0;
113 112
114 return 0; 113 return 0;
@@ -120,32 +119,6 @@ int dump_fpu(struct pt_regs *regs, elf_fpregset_t *r)
120 return 1; 119 return 1;
121} 120}
122 121
123static void __noreturn
124kernel_thread_helper(void *unused0, int (*fn)(void *),
125 void *arg, void *unused1)
126{
127 do_exit(fn(arg));
128}
129
130/*
131 * Create a kernel thread.
132 */
133long kernel_thread(int (*fn)(void *), void *arg, unsigned long flags)
134{
135 struct pt_regs regs;
136
137 memset(&regs, 0, sizeof(regs));
138
139 regs.regs[6] = (unsigned long) arg;
140 regs.regs[5] = (unsigned long) fn;
141 regs.cp0_epc = (unsigned long) kernel_thread_helper;
142 regs.cp0_psr = (regs.cp0_psr & ~(0x1|0x4|0x8)) | \
143 ((regs.cp0_psr & 0x3) << 2);
144
145 return do_fork(flags | CLONE_VM | CLONE_UNTRACED, \
146 0, &regs, 0, NULL, NULL);
147}
148
149unsigned long thread_saved_pc(struct task_struct *tsk) 122unsigned long thread_saved_pc(struct task_struct *tsk)
150{ 123{
151 return task_pt_regs(tsk)->cp0_epc; 124 return task_pt_regs(tsk)->cp0_epc;
diff --git a/arch/score/kernel/signal.c b/arch/score/kernel/signal.c
index c268bbf8b41..02353bde92d 100644
--- a/arch/score/kernel/signal.c
+++ b/arch/score/kernel/signal.c
@@ -148,7 +148,6 @@ score_rt_sigreturn(struct pt_regs *regs)
148{ 148{
149 struct rt_sigframe __user *frame; 149 struct rt_sigframe __user *frame;
150 sigset_t set; 150 sigset_t set;
151 stack_t st;
152 int sig; 151 int sig;
153 152
154 /* Always make any pending restarted system calls return -EINTR */ 153 /* Always make any pending restarted system calls return -EINTR */
@@ -168,12 +167,10 @@ score_rt_sigreturn(struct pt_regs *regs)
168 else if (sig) 167 else if (sig)
169 force_sig(sig, current); 168 force_sig(sig, current);
170 169
171 if (__copy_from_user(&st, &frame->rs_uc.uc_stack, sizeof(st)))
172 goto badframe;
173
174 /* It is more difficult to avoid calling this function than to 170 /* It is more difficult to avoid calling this function than to
175 call it and ignore errors. */ 171 call it and ignore errors. */
176 do_sigaltstack((stack_t __user *)&st, NULL, regs->regs[0]); 172 if (do_sigaltstack(&frame->rs_uc.uc_stack, NULL, regs->regs[0]) == -EFAULT)
173 goto badframe;
177 regs->is_syscall = 0; 174 regs->is_syscall = 0;
178 175
179 __asm__ __volatile__( 176 __asm__ __volatile__(
diff --git a/arch/score/kernel/sys_score.c b/arch/score/kernel/sys_score.c
index d45cf00a335..c54434c2fd9 100644
--- a/arch/score/kernel/sys_score.c
+++ b/arch/score/kernel/sys_score.c
@@ -83,57 +83,3 @@ score_vfork(struct pt_regs *regs)
83 return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, 83 return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD,
84 regs->regs[0], regs, 0, NULL, NULL); 84 regs->regs[0], regs, 0, NULL, NULL);
85} 85}
86
87/*
88 * sys_execve() executes a new program.
89 * This is called indirectly via a small wrapper
90 */
91asmlinkage long
92score_execve(struct pt_regs *regs)
93{
94 int error;
95 struct filename *filename;
96
97 filename = getname((char __user*)regs->regs[4]);
98 error = PTR_ERR(filename);
99 if (IS_ERR(filename))
100 return error;
101
102 error = do_execve(filename->name,
103 (const char __user *const __user *)regs->regs[5],
104 (const char __user *const __user *)regs->regs[6],
105 regs);
106
107 putname(filename);
108 return error;
109}
110
111/*
112 * Do a system call from kernel instead of calling sys_execve so we
113 * end up with proper pt_regs.
114 */
115asmlinkage
116int kernel_execve(const char *filename,
117 const char *const argv[],
118 const char *const envp[])
119{
120 register unsigned long __r4 asm("r4") = (unsigned long) filename;
121 register unsigned long __r5 asm("r5") = (unsigned long) argv;
122 register unsigned long __r6 asm("r6") = (unsigned long) envp;
123 register unsigned long __r7 asm("r7");
124
125 __asm__ __volatile__ (" \n"
126 "ldi r27, %5 \n"
127 "syscall \n"
128 "mv %0, r4 \n"
129 "mv %1, r7 \n"
130 : "=&r" (__r4), "=r" (__r7)
131 : "r" (__r4), "r" (__r5), "r" (__r6), "i" (__NR_execve)
132 : "r8", "r9", "r10", "r11", "r22", "r23", "r24", "r25",
133 "r26", "r27", "memory");
134
135 if (__r7 == 0)
136 return __r4;
137
138 return -__r4;
139}
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index babc2b826c5..8451317eed5 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -40,6 +40,8 @@ config SUPERH
40 select GENERIC_STRNLEN_USER 40 select GENERIC_STRNLEN_USER
41 select HAVE_MOD_ARCH_SPECIFIC if DWARF_UNWINDER 41 select HAVE_MOD_ARCH_SPECIFIC if DWARF_UNWINDER
42 select MODULES_USE_ELF_RELA 42 select MODULES_USE_ELF_RELA
43 select GENERIC_KERNEL_THREAD
44 select GENERIC_KERNEL_EXECVE
43 help 45 help
44 The SuperH is a RISC processor targeted for use in embedded systems 46 The SuperH is a RISC processor targeted for use in embedded systems
45 and consumer electronics; it was also used in the Sega Dreamcast 47 and consumer electronics; it was also used in the Sega Dreamcast
diff --git a/arch/sh/include/asm/Kbuild b/arch/sh/include/asm/Kbuild
index 86eadceff09..29f83beeef7 100644
--- a/arch/sh/include/asm/Kbuild
+++ b/arch/sh/include/asm/Kbuild
@@ -1,4 +1,3 @@
1include include/asm-generic/Kbuild.asm
2 1
3generic-y += bitsperlong.h 2generic-y += bitsperlong.h
4generic-y += cputime.h 3generic-y += cputime.h
@@ -34,13 +33,3 @@ generic-y += termbits.h
34generic-y += termios.h 33generic-y += termios.h
35generic-y += ucontext.h 34generic-y += ucontext.h
36generic-y += xor.h 35generic-y += xor.h
37
38header-y += cachectl.h
39header-y += cpu-features.h
40header-y += hw_breakpoint.h
41header-y += posix_types_32.h
42header-y += posix_types_64.h
43header-y += ptrace_32.h
44header-y += ptrace_64.h
45header-y += unistd_32.h
46header-y += unistd_64.h
diff --git a/arch/sh/include/asm/hw_breakpoint.h b/arch/sh/include/asm/hw_breakpoint.h
index 89890f61a7b..ec9ad593c3d 100644
--- a/arch/sh/include/asm/hw_breakpoint.h
+++ b/arch/sh/include/asm/hw_breakpoint.h
@@ -1,7 +1,8 @@
1#ifndef __ASM_SH_HW_BREAKPOINT_H 1#ifndef __ASM_SH_HW_BREAKPOINT_H
2#define __ASM_SH_HW_BREAKPOINT_H 2#define __ASM_SH_HW_BREAKPOINT_H
3 3
4#ifdef __KERNEL__ 4#include <uapi/asm/hw_breakpoint.h>
5
5#define __ARCH_HW_BREAKPOINT_H 6#define __ARCH_HW_BREAKPOINT_H
6 7
7#include <linux/kdebug.h> 8#include <linux/kdebug.h>
@@ -66,5 +67,4 @@ extern int register_sh_ubc(struct sh_ubc *);
66 67
67extern struct pmu perf_ops_bp; 68extern struct pmu perf_ops_bp;
68 69
69#endif /* __KERNEL__ */
70#endif /* __ASM_SH_HW_BREAKPOINT_H */ 70#endif /* __ASM_SH_HW_BREAKPOINT_H */
diff --git a/arch/sh/include/asm/posix_types.h b/arch/sh/include/asm/posix_types.h
index f08449bcbde..1aa781079b1 100644
--- a/arch/sh/include/asm/posix_types.h
+++ b/arch/sh/include/asm/posix_types.h
@@ -1,13 +1,5 @@
1#ifdef __KERNEL__
2# ifdef CONFIG_SUPERH32 1# ifdef CONFIG_SUPERH32
3# include <asm/posix_types_32.h> 2# include <asm/posix_types_32.h>
4# else 3# else
5# include <asm/posix_types_64.h> 4# include <asm/posix_types_64.h>
6# endif 5# endif
7#else
8# ifdef __SH5__
9# include <asm/posix_types_64.h>
10# else
11# include <asm/posix_types_32.h>
12# endif
13#endif /* __KERNEL__ */
diff --git a/arch/sh/include/asm/processor_32.h b/arch/sh/include/asm/processor_32.h
index b6311fd2d06..b1320d55ca3 100644
--- a/arch/sh/include/asm/processor_32.h
+++ b/arch/sh/include/asm/processor_32.h
@@ -126,11 +126,6 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_pc, unsigned lo
126/* Free all resources held by a thread. */ 126/* Free all resources held by a thread. */
127extern void release_thread(struct task_struct *); 127extern void release_thread(struct task_struct *);
128 128
129/*
130 * create a kernel thread without removing it from tasklists
131 */
132extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
133
134/* Copy and release all segment info associated with a VM */ 129/* Copy and release all segment info associated with a VM */
135#define copy_segments(p, mm) do { } while(0) 130#define copy_segments(p, mm) do { } while(0)
136#define release_segments(mm) do { } while(0) 131#define release_segments(mm) do { } while(0)
diff --git a/arch/sh/include/asm/processor_64.h b/arch/sh/include/asm/processor_64.h
index cd6029fb2c0..1ee8946f095 100644
--- a/arch/sh/include/asm/processor_64.h
+++ b/arch/sh/include/asm/processor_64.h
@@ -159,11 +159,6 @@ struct mm_struct;
159 159
160/* Free all resources held by a thread. */ 160/* Free all resources held by a thread. */
161extern void release_thread(struct task_struct *); 161extern void release_thread(struct task_struct *);
162/*
163 * create a kernel thread without removing it from tasklists
164 */
165extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
166
167 162
168/* Copy and release all segment info associated with a VM */ 163/* Copy and release all segment info associated with a VM */
169#define copy_segments(p, mm) do { } while (0) 164#define copy_segments(p, mm) do { } while (0)
diff --git a/arch/sh/include/asm/ptrace.h b/arch/sh/include/asm/ptrace.h
index a4a38dff997..2506c7db76b 100644
--- a/arch/sh/include/asm/ptrace.h
+++ b/arch/sh/include/asm/ptrace.h
@@ -1,42 +1,16 @@
1#ifndef __ASM_SH_PTRACE_H
2#define __ASM_SH_PTRACE_H
3
4/* 1/*
5 * Copyright (C) 1999, 2000 Niibe Yutaka 2 * Copyright (C) 1999, 2000 Niibe Yutaka
6 */ 3 */
4#ifndef __ASM_SH_PTRACE_H
5#define __ASM_SH_PTRACE_H
7 6
8#define PTRACE_GETREGS 12 /* General registers */
9#define PTRACE_SETREGS 13
10
11#define PTRACE_GETFPREGS 14 /* FPU registers */
12#define PTRACE_SETFPREGS 15
13
14#define PTRACE_GETFDPIC 31 /* get the ELF fdpic loadmap address */
15
16#define PTRACE_GETFDPIC_EXEC 0 /* [addr] request the executable loadmap */
17#define PTRACE_GETFDPIC_INTERP 1 /* [addr] request the interpreter loadmap */
18
19#define PTRACE_GETDSPREGS 55 /* DSP registers */
20#define PTRACE_SETDSPREGS 56
21
22#define PT_TEXT_END_ADDR 240
23#define PT_TEXT_ADDR 244 /* &(struct user)->start_code */
24#define PT_DATA_ADDR 248 /* &(struct user)->start_data */
25#define PT_TEXT_LEN 252
26
27#if defined(__SH5__) || defined(CONFIG_CPU_SH5)
28#include <asm/ptrace_64.h>
29#else
30#include <asm/ptrace_32.h>
31#endif
32
33#ifdef __KERNEL__
34 7
35#include <linux/stringify.h> 8#include <linux/stringify.h>
36#include <linux/stddef.h> 9#include <linux/stddef.h>
37#include <linux/thread_info.h> 10#include <linux/thread_info.h>
38#include <asm/addrspace.h> 11#include <asm/addrspace.h>
39#include <asm/page.h> 12#include <asm/page.h>
13#include <uapi/asm/ptrace.h>
40 14
41#define user_mode(regs) (((regs)->sr & 0x40000000)==0) 15#define user_mode(regs) (((regs)->sr & 0x40000000)==0)
42#define kernel_stack_pointer(_regs) ((unsigned long)(_regs)->regs[15]) 16#define kernel_stack_pointer(_regs) ((unsigned long)(_regs)->regs[15])
@@ -140,6 +114,4 @@ static inline unsigned long profile_pc(struct pt_regs *regs)
140#define profile_pc profile_pc 114#define profile_pc profile_pc
141 115
142#include <asm-generic/ptrace.h> 116#include <asm-generic/ptrace.h>
143#endif /* __KERNEL__ */
144
145#endif /* __ASM_SH_PTRACE_H */ 117#endif /* __ASM_SH_PTRACE_H */
diff --git a/arch/sh/include/asm/ptrace_32.h b/arch/sh/include/asm/ptrace_32.h
index 2d3e906aa72..1dd4480c536 100644
--- a/arch/sh/include/asm/ptrace_32.h
+++ b/arch/sh/include/asm/ptrace_32.h
@@ -1,79 +1,8 @@
1#ifndef __ASM_SH_PTRACE_32_H 1#ifndef __ASM_SH_PTRACE_32_H
2#define __ASM_SH_PTRACE_32_H 2#define __ASM_SH_PTRACE_32_H
3 3
4/* 4#include <uapi/asm/ptrace_32.h>
5 * GCC defines register number like this:
6 * -----------------------------
7 * 0 - 15 are integer registers
8 * 17 - 22 are control/special registers
9 * 24 - 39 fp registers
10 * 40 - 47 xd registers
11 * 48 - fpscr register
12 * -----------------------------
13 *
14 * We follows above, except:
15 * 16 --- program counter (PC)
16 * 22 --- syscall #
17 * 23 --- floating point communication register
18 */
19#define REG_REG0 0
20#define REG_REG15 15
21 5
22#define REG_PC 16
23
24#define REG_PR 17
25#define REG_SR 18
26#define REG_GBR 19
27#define REG_MACH 20
28#define REG_MACL 21
29
30#define REG_SYSCALL 22
31
32#define REG_FPREG0 23
33#define REG_FPREG15 38
34#define REG_XFREG0 39
35#define REG_XFREG15 54
36
37#define REG_FPSCR 55
38#define REG_FPUL 56
39
40/*
41 * This struct defines the way the registers are stored on the
42 * kernel stack during a system call or other kernel entry.
43 */
44struct pt_regs {
45 unsigned long regs[16];
46 unsigned long pc;
47 unsigned long pr;
48 unsigned long sr;
49 unsigned long gbr;
50 unsigned long mach;
51 unsigned long macl;
52 long tra;
53};
54
55/*
56 * This struct defines the way the DSP registers are stored on the
57 * kernel stack during a system call or other kernel entry.
58 */
59struct pt_dspregs {
60 unsigned long a1;
61 unsigned long a0g;
62 unsigned long a1g;
63 unsigned long m0;
64 unsigned long m1;
65 unsigned long a0;
66 unsigned long x0;
67 unsigned long x1;
68 unsigned long y0;
69 unsigned long y1;
70 unsigned long dsr;
71 unsigned long rs;
72 unsigned long re;
73 unsigned long mod;
74};
75
76#ifdef __KERNEL__
77 6
78#define MAX_REG_OFFSET offsetof(struct pt_regs, tra) 7#define MAX_REG_OFFSET offsetof(struct pt_regs, tra)
79static inline long regs_return_value(struct pt_regs *regs) 8static inline long regs_return_value(struct pt_regs *regs)
@@ -81,6 +10,4 @@ static inline long regs_return_value(struct pt_regs *regs)
81 return regs->regs[0]; 10 return regs->regs[0];
82} 11}
83 12
84#endif /* __KERNEL__ */
85
86#endif /* __ASM_SH_PTRACE_32_H */ 13#endif /* __ASM_SH_PTRACE_32_H */
diff --git a/arch/sh/include/asm/ptrace_64.h b/arch/sh/include/asm/ptrace_64.h
index eb3fcceaf64..97f4b5660f2 100644
--- a/arch/sh/include/asm/ptrace_64.h
+++ b/arch/sh/include/asm/ptrace_64.h
@@ -1,16 +1,8 @@
1#ifndef __ASM_SH_PTRACE_64_H 1#ifndef __ASM_SH_PTRACE_64_H
2#define __ASM_SH_PTRACE_64_H 2#define __ASM_SH_PTRACE_64_H
3 3
4struct pt_regs { 4#include <uapi/asm/ptrace_64.h>
5 unsigned long long pc;
6 unsigned long long sr;
7 long long syscall_nr;
8 unsigned long long regs[63];
9 unsigned long long tregs[8];
10 unsigned long long pad[2];
11};
12 5
13#ifdef __KERNEL__
14 6
15#define MAX_REG_OFFSET offsetof(struct pt_regs, tregs[7]) 7#define MAX_REG_OFFSET offsetof(struct pt_regs, tregs[7])
16static inline long regs_return_value(struct pt_regs *regs) 8static inline long regs_return_value(struct pt_regs *regs)
@@ -18,6 +10,4 @@ static inline long regs_return_value(struct pt_regs *regs)
18 return regs->regs[3]; 10 return regs->regs[3];
19} 11}
20 12
21#endif /* __KERNEL__ */
22
23#endif /* __ASM_SH_PTRACE_64_H */ 13#endif /* __ASM_SH_PTRACE_64_H */
diff --git a/arch/sh/include/asm/setup.h b/arch/sh/include/asm/setup.h
index 465a22df8fd..99238108e7a 100644
--- a/arch/sh/include/asm/setup.h
+++ b/arch/sh/include/asm/setup.h
@@ -1,9 +1,8 @@
1#ifndef _SH_SETUP_H 1#ifndef _SH_SETUP_H
2#define _SH_SETUP_H 2#define _SH_SETUP_H
3 3
4#include <asm-generic/setup.h> 4#include <uapi/asm/setup.h>
5 5
6#ifdef __KERNEL__
7/* 6/*
8 * This is set up by the setup-routine at boot-time 7 * This is set up by the setup-routine at boot-time
9 */ 8 */
@@ -22,6 +21,4 @@ void sh_mv_setup(void);
22void check_for_initrd(void); 21void check_for_initrd(void);
23void per_cpu_trap_init(void); 22void per_cpu_trap_init(void);
24 23
25#endif /* __KERNEL__ */
26
27#endif /* _SH_SETUP_H */ 24#endif /* _SH_SETUP_H */
diff --git a/arch/sh/include/asm/syscalls_32.h b/arch/sh/include/asm/syscalls_32.h
index 6c1fa559753..d2f89f1741f 100644
--- a/arch/sh/include/asm/syscalls_32.h
+++ b/arch/sh/include/asm/syscalls_32.h
@@ -19,10 +19,6 @@ asmlinkage int sys_clone(unsigned long clone_flags, unsigned long newsp,
19asmlinkage int sys_vfork(unsigned long r4, unsigned long r5, 19asmlinkage int sys_vfork(unsigned long r4, unsigned long r5,
20 unsigned long r6, unsigned long r7, 20 unsigned long r6, unsigned long r7,
21 struct pt_regs __regs); 21 struct pt_regs __regs);
22asmlinkage int sys_execve(const char __user *ufilename,
23 const char __user *const __user *uargv,
24 const char __user *const __user *uenvp,
25 unsigned long r7, struct pt_regs __regs);
26asmlinkage int sys_sigsuspend(old_sigset_t mask); 22asmlinkage int sys_sigsuspend(old_sigset_t mask);
27asmlinkage int sys_sigaction(int sig, const struct old_sigaction __user *act, 23asmlinkage int sys_sigaction(int sig, const struct old_sigaction __user *act,
28 struct old_sigaction __user *oact); 24 struct old_sigaction __user *oact);
diff --git a/arch/sh/include/asm/syscalls_64.h b/arch/sh/include/asm/syscalls_64.h
index ee519f41d95..3fedd9f1fab 100644
--- a/arch/sh/include/asm/syscalls_64.h
+++ b/arch/sh/include/asm/syscalls_64.h
@@ -21,10 +21,6 @@ asmlinkage int sys_vfork(unsigned long r2, unsigned long r3,
21 unsigned long r4, unsigned long r5, 21 unsigned long r4, unsigned long r5,
22 unsigned long r6, unsigned long r7, 22 unsigned long r6, unsigned long r7,
23 struct pt_regs *pregs); 23 struct pt_regs *pregs);
24asmlinkage int sys_execve(const char *ufilename, char **uargv,
25 char **uenvp, unsigned long r5,
26 unsigned long r6, unsigned long r7,
27 struct pt_regs *pregs);
28 24
29/* Misc syscall related bits */ 25/* Misc syscall related bits */
30asmlinkage long long do_syscall_trace_enter(struct pt_regs *regs); 26asmlinkage long long do_syscall_trace_enter(struct pt_regs *regs);
diff --git a/arch/sh/include/asm/types.h b/arch/sh/include/asm/types.h
index f8421f7ad63..6a31053fa5e 100644
--- a/arch/sh/include/asm/types.h
+++ b/arch/sh/include/asm/types.h
@@ -1,12 +1,11 @@
1#ifndef __ASM_SH_TYPES_H 1#ifndef __ASM_SH_TYPES_H
2#define __ASM_SH_TYPES_H 2#define __ASM_SH_TYPES_H
3 3
4#include <asm-generic/types.h> 4#include <uapi/asm/types.h>
5 5
6/* 6/*
7 * These aren't exported outside the kernel to avoid name space clashes 7 * These aren't exported outside the kernel to avoid name space clashes
8 */ 8 */
9#ifdef __KERNEL__
10#ifndef __ASSEMBLY__ 9#ifndef __ASSEMBLY__
11 10
12#ifdef CONFIG_SUPERH32 11#ifdef CONFIG_SUPERH32
@@ -18,6 +17,4 @@ typedef u64 reg_size_t;
18#endif 17#endif
19 18
20#endif /* __ASSEMBLY__ */ 19#endif /* __ASSEMBLY__ */
21#endif /* __KERNEL__ */
22
23#endif /* __ASM_SH_TYPES_H */ 20#endif /* __ASM_SH_TYPES_H */
diff --git a/arch/sh/include/asm/unistd.h b/arch/sh/include/asm/unistd.h
index 307201a854f..f1f4775766a 100644
--- a/arch/sh/include/asm/unistd.h
+++ b/arch/sh/include/asm/unistd.h
@@ -1,4 +1,3 @@
1#ifdef __KERNEL__
2# ifdef CONFIG_SUPERH32 1# ifdef CONFIG_SUPERH32
3# include <asm/unistd_32.h> 2# include <asm/unistd_32.h>
4# else 3# else
@@ -29,6 +28,7 @@
29# define __ARCH_WANT_SYS_SIGPENDING 28# define __ARCH_WANT_SYS_SIGPENDING
30# define __ARCH_WANT_SYS_SIGPROCMASK 29# define __ARCH_WANT_SYS_SIGPROCMASK
31# define __ARCH_WANT_SYS_RT_SIGACTION 30# define __ARCH_WANT_SYS_RT_SIGACTION
31# define __ARCH_WANT_SYS_EXECVE
32 32
33/* 33/*
34 * "Conditional" syscalls 34 * "Conditional" syscalls
@@ -38,10 +38,4 @@
38 */ 38 */
39# define cond_syscall(x) asm(".weak\t" #x "\n\t.set\t" #x ",sys_ni_syscall") 39# define cond_syscall(x) asm(".weak\t" #x "\n\t.set\t" #x ",sys_ni_syscall")
40 40
41#else 41#include <uapi/asm/unistd.h>
42# ifdef __SH5__
43# include <asm/unistd_64.h>
44# else
45# include <asm/unistd_32.h>
46# endif
47#endif
diff --git a/arch/sh/include/uapi/asm/Kbuild b/arch/sh/include/uapi/asm/Kbuild
index baebb3da1d4..60613ae7851 100644
--- a/arch/sh/include/uapi/asm/Kbuild
+++ b/arch/sh/include/uapi/asm/Kbuild
@@ -1,3 +1,25 @@
1# UAPI Header export list 1# UAPI Header export list
2include include/uapi/asm-generic/Kbuild.asm 2include include/uapi/asm-generic/Kbuild.asm
3 3
4header-y += auxvec.h
5header-y += byteorder.h
6header-y += cachectl.h
7header-y += cpu-features.h
8header-y += hw_breakpoint.h
9header-y += ioctls.h
10header-y += posix_types.h
11header-y += posix_types_32.h
12header-y += posix_types_64.h
13header-y += ptrace.h
14header-y += ptrace_32.h
15header-y += ptrace_64.h
16header-y += setup.h
17header-y += sigcontext.h
18header-y += signal.h
19header-y += sockios.h
20header-y += stat.h
21header-y += swab.h
22header-y += types.h
23header-y += unistd.h
24header-y += unistd_32.h
25header-y += unistd_64.h
diff --git a/arch/sh/include/asm/auxvec.h b/arch/sh/include/uapi/asm/auxvec.h
index 8bcc51af936..8bcc51af936 100644
--- a/arch/sh/include/asm/auxvec.h
+++ b/arch/sh/include/uapi/asm/auxvec.h
diff --git a/arch/sh/include/asm/byteorder.h b/arch/sh/include/uapi/asm/byteorder.h
index db2f5d7cb17..db2f5d7cb17 100644
--- a/arch/sh/include/asm/byteorder.h
+++ b/arch/sh/include/uapi/asm/byteorder.h
diff --git a/arch/sh/include/asm/cachectl.h b/arch/sh/include/uapi/asm/cachectl.h
index 6ffb4b7a212..6ffb4b7a212 100644
--- a/arch/sh/include/asm/cachectl.h
+++ b/arch/sh/include/uapi/asm/cachectl.h
diff --git a/arch/sh/include/asm/cpu-features.h b/arch/sh/include/uapi/asm/cpu-features.h
index 694abe490ed..694abe490ed 100644
--- a/arch/sh/include/asm/cpu-features.h
+++ b/arch/sh/include/uapi/asm/cpu-features.h
diff --git a/arch/sh/include/uapi/asm/hw_breakpoint.h b/arch/sh/include/uapi/asm/hw_breakpoint.h
new file mode 100644
index 00000000000..ae5704fa77a
--- /dev/null
+++ b/arch/sh/include/uapi/asm/hw_breakpoint.h
@@ -0,0 +1,4 @@
1/*
2 * There isn't anything here anymore, but the file must not be empty or patch
3 * will delete it.
4 */
diff --git a/arch/sh/include/asm/ioctls.h b/arch/sh/include/uapi/asm/ioctls.h
index a6769f352bf..a6769f352bf 100644
--- a/arch/sh/include/asm/ioctls.h
+++ b/arch/sh/include/uapi/asm/ioctls.h
diff --git a/arch/sh/include/uapi/asm/posix_types.h b/arch/sh/include/uapi/asm/posix_types.h
new file mode 100644
index 00000000000..dc55e5adfe1
--- /dev/null
+++ b/arch/sh/include/uapi/asm/posix_types.h
@@ -0,0 +1,7 @@
1#ifndef __KERNEL__
2# ifdef __SH5__
3# include <asm/posix_types_64.h>
4# else
5# include <asm/posix_types_32.h>
6# endif
7#endif /* __KERNEL__ */
diff --git a/arch/sh/include/asm/posix_types_32.h b/arch/sh/include/uapi/asm/posix_types_32.h
index ba0bdc423b0..ba0bdc423b0 100644
--- a/arch/sh/include/asm/posix_types_32.h
+++ b/arch/sh/include/uapi/asm/posix_types_32.h
diff --git a/arch/sh/include/asm/posix_types_64.h b/arch/sh/include/uapi/asm/posix_types_64.h
index 244f7e950e1..244f7e950e1 100644
--- a/arch/sh/include/asm/posix_types_64.h
+++ b/arch/sh/include/uapi/asm/posix_types_64.h
diff --git a/arch/sh/include/uapi/asm/ptrace.h b/arch/sh/include/uapi/asm/ptrace.h
new file mode 100644
index 00000000000..8b8c5aca9c2
--- /dev/null
+++ b/arch/sh/include/uapi/asm/ptrace.h
@@ -0,0 +1,34 @@
1/*
2 * Copyright (C) 1999, 2000 Niibe Yutaka
3 */
4#ifndef _UAPI__ASM_SH_PTRACE_H
5#define _UAPI__ASM_SH_PTRACE_H
6
7
8#define PTRACE_GETREGS 12 /* General registers */
9#define PTRACE_SETREGS 13
10
11#define PTRACE_GETFPREGS 14 /* FPU registers */
12#define PTRACE_SETFPREGS 15
13
14#define PTRACE_GETFDPIC 31 /* get the ELF fdpic loadmap address */
15
16#define PTRACE_GETFDPIC_EXEC 0 /* [addr] request the executable loadmap */
17#define PTRACE_GETFDPIC_INTERP 1 /* [addr] request the interpreter loadmap */
18
19#define PTRACE_GETDSPREGS 55 /* DSP registers */
20#define PTRACE_SETDSPREGS 56
21
22#define PT_TEXT_END_ADDR 240
23#define PT_TEXT_ADDR 244 /* &(struct user)->start_code */
24#define PT_DATA_ADDR 248 /* &(struct user)->start_data */
25#define PT_TEXT_LEN 252
26
27#if defined(__SH5__) || defined(CONFIG_CPU_SH5)
28#include <asm/ptrace_64.h>
29#else
30#include <asm/ptrace_32.h>
31#endif
32
33
34#endif /* _UAPI__ASM_SH_PTRACE_H */
diff --git a/arch/sh/include/uapi/asm/ptrace_32.h b/arch/sh/include/uapi/asm/ptrace_32.h
new file mode 100644
index 00000000000..926e0cefc2b
--- /dev/null
+++ b/arch/sh/include/uapi/asm/ptrace_32.h
@@ -0,0 +1,77 @@
1#ifndef _UAPI__ASM_SH_PTRACE_32_H
2#define _UAPI__ASM_SH_PTRACE_32_H
3
4/*
5 * GCC defines register number like this:
6 * -----------------------------
7 * 0 - 15 are integer registers
8 * 17 - 22 are control/special registers
9 * 24 - 39 fp registers
10 * 40 - 47 xd registers
11 * 48 - fpscr register
12 * -----------------------------
13 *
14 * We follows above, except:
15 * 16 --- program counter (PC)
16 * 22 --- syscall #
17 * 23 --- floating point communication register
18 */
19#define REG_REG0 0
20#define REG_REG15 15
21
22#define REG_PC 16
23
24#define REG_PR 17
25#define REG_SR 18
26#define REG_GBR 19
27#define REG_MACH 20
28#define REG_MACL 21
29
30#define REG_SYSCALL 22
31
32#define REG_FPREG0 23
33#define REG_FPREG15 38
34#define REG_XFREG0 39
35#define REG_XFREG15 54
36
37#define REG_FPSCR 55
38#define REG_FPUL 56
39
40/*
41 * This struct defines the way the registers are stored on the
42 * kernel stack during a system call or other kernel entry.
43 */
44struct pt_regs {
45 unsigned long regs[16];
46 unsigned long pc;
47 unsigned long pr;
48 unsigned long sr;
49 unsigned long gbr;
50 unsigned long mach;
51 unsigned long macl;
52 long tra;
53};
54
55/*
56 * This struct defines the way the DSP registers are stored on the
57 * kernel stack during a system call or other kernel entry.
58 */
59struct pt_dspregs {
60 unsigned long a1;
61 unsigned long a0g;
62 unsigned long a1g;
63 unsigned long m0;
64 unsigned long m1;
65 unsigned long a0;
66 unsigned long x0;
67 unsigned long x1;
68 unsigned long y0;
69 unsigned long y1;
70 unsigned long dsr;
71 unsigned long rs;
72 unsigned long re;
73 unsigned long mod;
74};
75
76
77#endif /* _UAPI__ASM_SH_PTRACE_32_H */
diff --git a/arch/sh/include/uapi/asm/ptrace_64.h b/arch/sh/include/uapi/asm/ptrace_64.h
new file mode 100644
index 00000000000..0e52ee83e94
--- /dev/null
+++ b/arch/sh/include/uapi/asm/ptrace_64.h
@@ -0,0 +1,14 @@
1#ifndef _UAPI__ASM_SH_PTRACE_64_H
2#define _UAPI__ASM_SH_PTRACE_64_H
3
4struct pt_regs {
5 unsigned long long pc;
6 unsigned long long sr;
7 long long syscall_nr;
8 unsigned long long regs[63];
9 unsigned long long tregs[8];
10 unsigned long long pad[2];
11};
12
13
14#endif /* _UAPI__ASM_SH_PTRACE_64_H */
diff --git a/arch/sh/include/uapi/asm/setup.h b/arch/sh/include/uapi/asm/setup.h
new file mode 100644
index 00000000000..552df83f1a4
--- /dev/null
+++ b/arch/sh/include/uapi/asm/setup.h
@@ -0,0 +1 @@
#include <asm-generic/setup.h>
diff --git a/arch/sh/include/asm/sigcontext.h b/arch/sh/include/uapi/asm/sigcontext.h
index 8ce1435bc0b..8ce1435bc0b 100644
--- a/arch/sh/include/asm/sigcontext.h
+++ b/arch/sh/include/uapi/asm/sigcontext.h
diff --git a/arch/sh/include/asm/signal.h b/arch/sh/include/uapi/asm/signal.h
index 9ac530a90bc..9ac530a90bc 100644
--- a/arch/sh/include/asm/signal.h
+++ b/arch/sh/include/uapi/asm/signal.h
diff --git a/arch/sh/include/asm/sockios.h b/arch/sh/include/uapi/asm/sockios.h
index cf8b96b1f9a..cf8b96b1f9a 100644
--- a/arch/sh/include/asm/sockios.h
+++ b/arch/sh/include/uapi/asm/sockios.h
diff --git a/arch/sh/include/asm/stat.h b/arch/sh/include/uapi/asm/stat.h
index e1810cc6e3d..e1810cc6e3d 100644
--- a/arch/sh/include/asm/stat.h
+++ b/arch/sh/include/uapi/asm/stat.h
diff --git a/arch/sh/include/asm/swab.h b/arch/sh/include/uapi/asm/swab.h
index 1cd09767a7a..1cd09767a7a 100644
--- a/arch/sh/include/asm/swab.h
+++ b/arch/sh/include/uapi/asm/swab.h
diff --git a/arch/sh/include/uapi/asm/types.h b/arch/sh/include/uapi/asm/types.h
new file mode 100644
index 00000000000..b9e79bc580d
--- /dev/null
+++ b/arch/sh/include/uapi/asm/types.h
@@ -0,0 +1 @@
#include <asm-generic/types.h>
diff --git a/arch/sh/include/uapi/asm/unistd.h b/arch/sh/include/uapi/asm/unistd.h
new file mode 100644
index 00000000000..eeef88dd53c
--- /dev/null
+++ b/arch/sh/include/uapi/asm/unistd.h
@@ -0,0 +1,7 @@
1#ifndef __KERNEL__
2# ifdef __SH5__
3# include <asm/unistd_64.h>
4# else
5# include <asm/unistd_32.h>
6# endif
7#endif
diff --git a/arch/sh/include/asm/unistd_32.h b/arch/sh/include/uapi/asm/unistd_32.h
index 72fd1e06100..9e465f246dc 100644
--- a/arch/sh/include/asm/unistd_32.h
+++ b/arch/sh/include/uapi/asm/unistd_32.h
@@ -378,7 +378,8 @@
378#define __NR_setns 364 378#define __NR_setns 364
379#define __NR_process_vm_readv 365 379#define __NR_process_vm_readv 365
380#define __NR_process_vm_writev 366 380#define __NR_process_vm_writev 366
381#define __NR_kcmp 367
381 382
382#define NR_syscalls 367 383#define NR_syscalls 368
383 384
384#endif /* __ASM_SH_UNISTD_32_H */ 385#endif /* __ASM_SH_UNISTD_32_H */
diff --git a/arch/sh/include/asm/unistd_64.h b/arch/sh/include/uapi/asm/unistd_64.h
index a28edc32969..8e3a2edd284 100644
--- a/arch/sh/include/asm/unistd_64.h
+++ b/arch/sh/include/uapi/asm/unistd_64.h
@@ -398,7 +398,8 @@
398#define __NR_setns 375 398#define __NR_setns 375
399#define __NR_process_vm_readv 376 399#define __NR_process_vm_readv 376
400#define __NR_process_vm_writev 377 400#define __NR_process_vm_writev 377
401#define __NR_kcmp 378
401 402
402#define NR_syscalls 378 403#define NR_syscalls 379
403 404
404#endif /* __ASM_SH_UNISTD_64_H */ 405#endif /* __ASM_SH_UNISTD_64_H */
diff --git a/arch/sh/kernel/Makefile b/arch/sh/kernel/Makefile
index 88571ff8eee..f259b37874e 100644
--- a/arch/sh/kernel/Makefile
+++ b/arch/sh/kernel/Makefile
@@ -16,7 +16,7 @@ obj-y := debugtraps.o dma-nommu.o dumpstack.o \
16 machvec.o nmi_debug.o process.o \ 16 machvec.o nmi_debug.o process.o \
17 process_$(BITS).o ptrace.o ptrace_$(BITS).o \ 17 process_$(BITS).o ptrace.o ptrace_$(BITS).o \
18 reboot.o return_address.o \ 18 reboot.o return_address.o \
19 setup.o signal_$(BITS).o sys_sh.o sys_sh$(BITS).o \ 19 setup.o signal_$(BITS).o sys_sh.o \
20 syscalls_$(BITS).o time.o topology.o traps.o \ 20 syscalls_$(BITS).o time.o topology.o traps.o \
21 traps_$(BITS).o unwinder.o 21 traps_$(BITS).o unwinder.o
22 22
@@ -25,6 +25,7 @@ obj-y += iomap.o
25obj-$(CONFIG_HAS_IOPORT) += ioport.o 25obj-$(CONFIG_HAS_IOPORT) += ioport.o
26endif 26endif
27 27
28obj-$(CONFIG_SUPERH32) += sys_sh32.o
28obj-y += cpu/ 29obj-y += cpu/
29obj-$(CONFIG_VSYSCALL) += vsyscall/ 30obj-$(CONFIG_VSYSCALL) += vsyscall/
30obj-$(CONFIG_SMP) += smp.o 31obj-$(CONFIG_SMP) += smp.o
diff --git a/arch/sh/kernel/cpu/sh5/entry.S b/arch/sh/kernel/cpu/sh5/entry.S
index 7e605b95592..0c8d0377d40 100644
--- a/arch/sh/kernel/cpu/sh5/entry.S
+++ b/arch/sh/kernel/cpu/sh5/entry.S
@@ -1228,6 +1228,25 @@ ret_from_fork:
1228 pta ret_from_syscall, tr0 1228 pta ret_from_syscall, tr0
1229 blink tr0, ZERO 1229 blink tr0, ZERO
1230 1230
1231.global ret_from_kernel_thread
1232ret_from_kernel_thread:
1233
1234 movi schedule_tail,r5
1235 ori r5, 1, r5
1236 ptabs r5, tr0
1237 blink tr0, LINK
1238
1239 ld.q SP, FRAME_R(2), r2
1240 ld.q SP, FRAME_R(3), r3
1241 ptabs r3, tr0
1242 blink tr0, LINK
1243
1244 ld.q SP, FRAME_S(FSPC), r2
1245 addi r2, 4, r2 /* Move PC, being pre-execution event */
1246 st.q SP, FRAME_S(FSPC), r2
1247 pta ret_from_syscall, tr0
1248 blink tr0, ZERO
1249
1231syscall_allowed: 1250syscall_allowed:
1232 /* Use LINK to deflect the exit point, default is syscall_ret */ 1251 /* Use LINK to deflect the exit point, default is syscall_ret */
1233 pta syscall_ret, tr0 1252 pta syscall_ret, tr0
diff --git a/arch/sh/kernel/entry-common.S b/arch/sh/kernel/entry-common.S
index b96489d8b27..9b6e4beeb29 100644
--- a/arch/sh/kernel/entry-common.S
+++ b/arch/sh/kernel/entry-common.S
@@ -297,6 +297,19 @@ ret_from_fork:
297 mov r0, r4 297 mov r0, r4
298 bra syscall_exit 298 bra syscall_exit
299 nop 299 nop
300
301 .align 2
302 .globl ret_from_kernel_thread
303ret_from_kernel_thread:
304 mov.l 1f, r8
305 jsr @r8
306 mov r0, r4
307 mov.l @(OFF_R5,r15), r5 ! fn
308 jsr @r5
309 mov.l @(OFF_R4,r15), r4 ! arg
310 bra syscall_exit
311 nop
312
300 .align 2 313 .align 2
3011: .long schedule_tail 3141: .long schedule_tail
302 315
diff --git a/arch/sh/kernel/process_32.c b/arch/sh/kernel/process_32.c
index ba7345f37bc..fce8029de92 100644
--- a/arch/sh/kernel/process_32.c
+++ b/arch/sh/kernel/process_32.c
@@ -68,38 +68,6 @@ void show_regs(struct pt_regs * regs)
68 show_code(regs); 68 show_code(regs);
69} 69}
70 70
71/*
72 * Create a kernel thread
73 */
74__noreturn void kernel_thread_helper(void *arg, int (*fn)(void *))
75{
76 do_exit(fn(arg));
77}
78
79/* Don't use this in BL=1(cli). Or else, CPU resets! */
80int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
81{
82 struct pt_regs regs;
83 int pid;
84
85 memset(&regs, 0, sizeof(regs));
86 regs.regs[4] = (unsigned long)arg;
87 regs.regs[5] = (unsigned long)fn;
88
89 regs.pc = (unsigned long)kernel_thread_helper;
90 regs.sr = SR_MD;
91#if defined(CONFIG_SH_FPU)
92 regs.sr |= SR_FD;
93#endif
94
95 /* Ok, create the new process.. */
96 pid = do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0,
97 &regs, 0, NULL, NULL);
98
99 return pid;
100}
101EXPORT_SYMBOL(kernel_thread);
102
103void start_thread(struct pt_regs *regs, unsigned long new_pc, 71void start_thread(struct pt_regs *regs, unsigned long new_pc,
104 unsigned long new_sp) 72 unsigned long new_sp)
105{ 73{
@@ -157,9 +125,10 @@ int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu)
157EXPORT_SYMBOL(dump_fpu); 125EXPORT_SYMBOL(dump_fpu);
158 126
159asmlinkage void ret_from_fork(void); 127asmlinkage void ret_from_fork(void);
128asmlinkage void ret_from_kernel_thread(void);
160 129
161int copy_thread(unsigned long clone_flags, unsigned long usp, 130int copy_thread(unsigned long clone_flags, unsigned long usp,
162 unsigned long unused, 131 unsigned long arg,
163 struct task_struct *p, struct pt_regs *regs) 132 struct task_struct *p, struct pt_regs *regs)
164{ 133{
165 struct thread_info *ti = task_thread_info(p); 134 struct thread_info *ti = task_thread_info(p);
@@ -177,29 +146,34 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
177 } 146 }
178#endif 147#endif
179 148
180 childregs = task_pt_regs(p); 149 memset(p->thread.ptrace_bps, 0, sizeof(p->thread.ptrace_bps));
181 *childregs = *regs;
182 150
183 if (user_mode(regs)) { 151 childregs = task_pt_regs(p);
184 childregs->regs[15] = usp; 152 p->thread.sp = (unsigned long) childregs;
185 ti->addr_limit = USER_DS; 153 if (unlikely(p->flags & PF_KTHREAD)) {
186 } else { 154 memset(childregs, 0, sizeof(struct pt_regs));
187 childregs->regs[15] = (unsigned long)childregs; 155 p->thread.pc = (unsigned long) ret_from_kernel_thread;
156 childregs->regs[4] = arg;
157 childregs->regs[5] = usp;
158 childregs->sr = SR_MD;
159#if defined(CONFIG_SH_FPU)
160 childregs->sr |= SR_FD;
161#endif
188 ti->addr_limit = KERNEL_DS; 162 ti->addr_limit = KERNEL_DS;
189 ti->status &= ~TS_USEDFPU; 163 ti->status &= ~TS_USEDFPU;
190 p->fpu_counter = 0; 164 p->fpu_counter = 0;
165 return 0;
191 } 166 }
167 *childregs = *regs;
168
169 childregs->regs[15] = usp;
170 ti->addr_limit = USER_DS;
192 171
193 if (clone_flags & CLONE_SETTLS) 172 if (clone_flags & CLONE_SETTLS)
194 childregs->gbr = childregs->regs[0]; 173 childregs->gbr = childregs->regs[0];
195 174
196 childregs->regs[0] = 0; /* Set return value for child */ 175 childregs->regs[0] = 0; /* Set return value for child */
197
198 p->thread.sp = (unsigned long) childregs;
199 p->thread.pc = (unsigned long) ret_from_fork; 176 p->thread.pc = (unsigned long) ret_from_fork;
200
201 memset(p->thread.ptrace_bps, 0, sizeof(p->thread.ptrace_bps));
202
203 return 0; 177 return 0;
204} 178}
205 179
@@ -288,29 +262,6 @@ asmlinkage int sys_vfork(unsigned long r4, unsigned long r5,
288 0, NULL, NULL); 262 0, NULL, NULL);
289} 263}
290 264
291/*
292 * sys_execve() executes a new program.
293 */
294asmlinkage int sys_execve(const char __user *ufilename,
295 const char __user *const __user *uargv,
296 const char __user *const __user *uenvp,
297 unsigned long r7, struct pt_regs __regs)
298{
299 struct pt_regs *regs = RELOC_HIDE(&__regs, 0);
300 int error;
301 struct filename *filename;
302
303 filename = getname(ufilename);
304 error = PTR_ERR(filename);
305 if (IS_ERR(filename))
306 goto out;
307
308 error = do_execve(filename->name, uargv, uenvp, regs);
309 putname(filename);
310out:
311 return error;
312}
313
314unsigned long get_wchan(struct task_struct *p) 265unsigned long get_wchan(struct task_struct *p)
315{ 266{
316 unsigned long pc; 267 unsigned long pc;
diff --git a/arch/sh/kernel/process_64.c b/arch/sh/kernel/process_64.c
index 98a709f0c3c..3a0f3fd3bb5 100644
--- a/arch/sh/kernel/process_64.c
+++ b/arch/sh/kernel/process_64.c
@@ -285,39 +285,6 @@ void show_regs(struct pt_regs *regs)
285} 285}
286 286
287/* 287/*
288 * Create a kernel thread
289 */
290__noreturn void kernel_thread_helper(void *arg, int (*fn)(void *))
291{
292 do_exit(fn(arg));
293}
294
295/*
296 * This is the mechanism for creating a new kernel thread.
297 *
298 * NOTE! Only a kernel-only process(ie the swapper or direct descendants
299 * who haven't done an "execve()") should use this: it will work within
300 * a system call from a "real" process, but the process memory space will
301 * not be freed until both the parent and the child have exited.
302 */
303int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
304{
305 struct pt_regs regs;
306
307 memset(&regs, 0, sizeof(regs));
308 regs.regs[2] = (unsigned long)arg;
309 regs.regs[3] = (unsigned long)fn;
310
311 regs.pc = (unsigned long)kernel_thread_helper;
312 regs.sr = (1 << 30);
313
314 /* Ok, create the new process.. */
315 return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0,
316 &regs, 0, NULL, NULL);
317}
318EXPORT_SYMBOL(kernel_thread);
319
320/*
321 * Free current thread data structures etc.. 288 * Free current thread data structures etc..
322 */ 289 */
323void exit_thread(void) 290void exit_thread(void)
@@ -401,15 +368,17 @@ int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu)
401EXPORT_SYMBOL(dump_fpu); 368EXPORT_SYMBOL(dump_fpu);
402 369
403asmlinkage void ret_from_fork(void); 370asmlinkage void ret_from_fork(void);
371asmlinkage void ret_from_kernel_thread(void);
404 372
405int copy_thread(unsigned long clone_flags, unsigned long usp, 373int copy_thread(unsigned long clone_flags, unsigned long usp,
406 unsigned long unused, 374 unsigned long arg,
407 struct task_struct *p, struct pt_regs *regs) 375 struct task_struct *p, struct pt_regs *regs)
408{ 376{
409 struct pt_regs *childregs; 377 struct pt_regs *childregs;
410 378
411#ifdef CONFIG_SH_FPU 379#ifdef CONFIG_SH_FPU
412 if(last_task_used_math == current) { 380 /* can't happen for a kernel thread */
381 if (last_task_used_math == current) {
413 enable_fpu(); 382 enable_fpu();
414 save_fpu(current); 383 save_fpu(current);
415 disable_fpu(); 384 disable_fpu();
@@ -419,7 +388,17 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
419#endif 388#endif
420 /* Copy from sh version */ 389 /* Copy from sh version */
421 childregs = (struct pt_regs *)(THREAD_SIZE + task_stack_page(p)) - 1; 390 childregs = (struct pt_regs *)(THREAD_SIZE + task_stack_page(p)) - 1;
391 p->thread.sp = (unsigned long) childregs;
422 392
393 if (unlikely(p->flags & PF_KTHREAD)) {
394 memset(childregs, 0, sizeof(struct pt_regs));
395 childregs->regs[2] = (unsigned long)arg;
396 childregs->regs[3] = (unsigned long)fn;
397 childregs->sr = (1 << 30); /* not user_mode */
398 childregs->sr |= SR_FD; /* Invalidate FPU flag */
399 p->thread.pc = (unsigned long) ret_from_kernel_thread;
400 return 0;
401 }
423 *childregs = *regs; 402 *childregs = *regs;
424 403
425 /* 404 /*
@@ -428,19 +407,12 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
428 * 32-bit wide and context switch must take care 407 * 32-bit wide and context switch must take care
429 * of NEFF sign extension. 408 * of NEFF sign extension.
430 */ 409 */
431 if (user_mode(regs)) { 410 childregs->regs[15] = neff_sign_extend(usp);
432 childregs->regs[15] = neff_sign_extend(usp); 411 p->thread.uregs = childregs;
433 p->thread.uregs = childregs;
434 } else {
435 childregs->regs[15] =
436 neff_sign_extend((unsigned long)task_stack_page(p) +
437 THREAD_SIZE);
438 }
439 412
440 childregs->regs[9] = 0; /* Set return value for child */ 413 childregs->regs[9] = 0; /* Set return value for child */
441 childregs->sr |= SR_FD; /* Invalidate FPU flag */ 414 childregs->sr |= SR_FD; /* Invalidate FPU flag */
442 415
443 p->thread.sp = (unsigned long) childregs;
444 p->thread.pc = (unsigned long) ret_from_fork; 416 p->thread.pc = (unsigned long) ret_from_fork;
445 417
446 return 0; 418 return 0;
@@ -482,31 +454,6 @@ asmlinkage int sys_vfork(unsigned long r2, unsigned long r3,
482 return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, pregs->regs[15], pregs, 0, 0, 0); 454 return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, pregs->regs[15], pregs, 0, 0, 0);
483} 455}
484 456
485/*
486 * sys_execve() executes a new program.
487 */
488asmlinkage int sys_execve(const char *ufilename, char **uargv,
489 char **uenvp, unsigned long r5,
490 unsigned long r6, unsigned long r7,
491 struct pt_regs *pregs)
492{
493 int error;
494 struct filename *filename;
495
496 filename = getname((char __user *)ufilename);
497 error = PTR_ERR(filename);
498 if (IS_ERR(filename))
499 goto out;
500
501 error = do_execve(filename->name,
502 (const char __user *const __user *)uargv,
503 (const char __user *const __user *)uenvp,
504 pregs);
505 putname(filename);
506out:
507 return error;
508}
509
510#ifdef CONFIG_FRAME_POINTER 457#ifdef CONFIG_FRAME_POINTER
511static int in_sh64_switch_to(unsigned long pc) 458static int in_sh64_switch_to(unsigned long pc)
512{ 459{
diff --git a/arch/sh/kernel/signal_64.c b/arch/sh/kernel/signal_64.c
index 23853814bd1..d867cd95a62 100644
--- a/arch/sh/kernel/signal_64.c
+++ b/arch/sh/kernel/signal_64.c
@@ -347,7 +347,6 @@ asmlinkage int sys_rt_sigreturn(unsigned long r2, unsigned long r3,
347{ 347{
348 struct rt_sigframe __user *frame = (struct rt_sigframe __user *) (long) REF_REG_SP; 348 struct rt_sigframe __user *frame = (struct rt_sigframe __user *) (long) REF_REG_SP;
349 sigset_t set; 349 sigset_t set;
350 stack_t __user st;
351 long long ret; 350 long long ret;
352 351
353 /* Always make any pending restarted system calls return -EINTR */ 352 /* Always make any pending restarted system calls return -EINTR */
@@ -365,11 +364,10 @@ asmlinkage int sys_rt_sigreturn(unsigned long r2, unsigned long r3,
365 goto badframe; 364 goto badframe;
366 regs->pc -= 4; 365 regs->pc -= 4;
367 366
368 if (__copy_from_user(&st, &frame->uc.uc_stack, sizeof(st)))
369 goto badframe;
370 /* It is more difficult to avoid calling this function than to 367 /* It is more difficult to avoid calling this function than to
371 call it and ignore errors. */ 368 call it and ignore errors. */
372 do_sigaltstack(&st, NULL, REF_REG_SP); 369 if (do_sigaltstack(&frame->uc.uc_stack, NULL, REF_REG_SP) == -EFAULT)
370 goto badframe;
373 371
374 return (int) ret; 372 return (int) ret;
375 373
diff --git a/arch/sh/kernel/sys_sh32.c b/arch/sh/kernel/sys_sh32.c
index f56b6fe5c5d..497bab3a040 100644
--- a/arch/sh/kernel/sys_sh32.c
+++ b/arch/sh/kernel/sys_sh32.c
@@ -60,27 +60,3 @@ asmlinkage int sys_fadvise64_64_wrapper(int fd, u32 offset0, u32 offset1,
60 (u64)len0 << 32 | len1, advice); 60 (u64)len0 << 32 | len1, advice);
61#endif 61#endif
62} 62}
63
64#if defined(CONFIG_CPU_SH2) || defined(CONFIG_CPU_SH2A)
65#define SYSCALL_ARG3 "trapa #0x23"
66#else
67#define SYSCALL_ARG3 "trapa #0x13"
68#endif
69
70/*
71 * Do a system call from kernel instead of calling sys_execve so we
72 * end up with proper pt_regs.
73 */
74int kernel_execve(const char *filename,
75 const char *const argv[],
76 const char *const envp[])
77{
78 register long __sc0 __asm__ ("r3") = __NR_execve;
79 register long __sc4 __asm__ ("r4") = (long) filename;
80 register long __sc5 __asm__ ("r5") = (long) argv;
81 register long __sc6 __asm__ ("r6") = (long) envp;
82 __asm__ __volatile__ (SYSCALL_ARG3 : "=z" (__sc0)
83 : "0" (__sc0), "r" (__sc4), "r" (__sc5), "r" (__sc6)
84 : "memory");
85 return __sc0;
86}
diff --git a/arch/sh/kernel/sys_sh64.c b/arch/sh/kernel/sys_sh64.c
deleted file mode 100644
index c5a38c4bf41..00000000000
--- a/arch/sh/kernel/sys_sh64.c
+++ /dev/null
@@ -1,50 +0,0 @@
1/*
2 * arch/sh/kernel/sys_sh64.c
3 *
4 * Copyright (C) 2000, 2001 Paolo Alberelli
5 *
6 * This file contains various random system calls that
7 * have a non-standard calling sequence on the Linux/SH5
8 * platform.
9 *
10 * This file is subject to the terms and conditions of the GNU General Public
11 * License. See the file "COPYING" in the main directory of this archive
12 * for more details.
13 */
14#include <linux/errno.h>
15#include <linux/rwsem.h>
16#include <linux/sched.h>
17#include <linux/mm.h>
18#include <linux/fs.h>
19#include <linux/smp.h>
20#include <linux/sem.h>
21#include <linux/msg.h>
22#include <linux/shm.h>
23#include <linux/stat.h>
24#include <linux/mman.h>
25#include <linux/file.h>
26#include <linux/syscalls.h>
27#include <linux/ipc.h>
28#include <asm/uaccess.h>
29#include <asm/ptrace.h>
30#include <asm/unistd.h>
31
32/*
33 * Do a system call from kernel instead of calling sys_execve so we
34 * end up with proper pt_regs.
35 */
36int kernel_execve(const char *filename,
37 const char *const argv[],
38 const char *const envp[])
39{
40 register unsigned long __sc0 __asm__ ("r9") = ((0x13 << 16) | __NR_execve);
41 register unsigned long __sc2 __asm__ ("r2") = (unsigned long) filename;
42 register unsigned long __sc3 __asm__ ("r3") = (unsigned long) argv;
43 register unsigned long __sc4 __asm__ ("r4") = (unsigned long) envp;
44 __asm__ __volatile__ ("trapa %1 !\t\t\t execve(%2,%3,%4)"
45 : "=r" (__sc0)
46 : "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4) );
47 __asm__ __volatile__ ("!dummy %0 %1 %2 %3"
48 : : "r" (__sc0), "r" (__sc2), "r" (__sc3), "r" (__sc4) : "memory");
49 return __sc0;
50}
diff --git a/arch/sh/kernel/syscalls_32.S b/arch/sh/kernel/syscalls_32.S
index 4b68f0f7976..fe97ae5e56f 100644
--- a/arch/sh/kernel/syscalls_32.S
+++ b/arch/sh/kernel/syscalls_32.S
@@ -384,3 +384,4 @@ ENTRY(sys_call_table)
384 .long sys_setns 384 .long sys_setns
385 .long sys_process_vm_readv /* 365 */ 385 .long sys_process_vm_readv /* 365 */
386 .long sys_process_vm_writev 386 .long sys_process_vm_writev
387 .long sys_kcmp
diff --git a/arch/sh/kernel/syscalls_64.S b/arch/sh/kernel/syscalls_64.S
index 0956345b36e..5c7b1c67bdc 100644
--- a/arch/sh/kernel/syscalls_64.S
+++ b/arch/sh/kernel/syscalls_64.S
@@ -404,3 +404,4 @@ sys_call_table:
404 .long sys_setns /* 375 */ 404 .long sys_setns /* 375 */
405 .long sys_process_vm_readv 405 .long sys_process_vm_readv
406 .long sys_process_vm_writev 406 .long sys_process_vm_writev
407 .long sys_kcmp
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index b6b442b0d79..0c7d365fa40 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -20,6 +20,7 @@ config SPARC
20 select HAVE_ARCH_TRACEHOOK 20 select HAVE_ARCH_TRACEHOOK
21 select SYSCTL_EXCEPTION_TRACE 21 select SYSCTL_EXCEPTION_TRACE
22 select ARCH_WANT_OPTIONAL_GPIOLIB 22 select ARCH_WANT_OPTIONAL_GPIOLIB
23 select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE
23 select RTC_CLASS 24 select RTC_CLASS
24 select RTC_DRV_M48T59 25 select RTC_DRV_M48T59
25 select HAVE_IRQ_WORK 26 select HAVE_IRQ_WORK
@@ -40,6 +41,8 @@ config SPARC
40 select GENERIC_STRNCPY_FROM_USER 41 select GENERIC_STRNCPY_FROM_USER
41 select GENERIC_STRNLEN_USER 42 select GENERIC_STRNLEN_USER
42 select MODULES_USE_ELF_RELA 43 select MODULES_USE_ELF_RELA
44 select GENERIC_KERNEL_THREAD
45 select GENERIC_KERNEL_EXECVE
43 46
44config SPARC32 47config SPARC32
45 def_bool !64BIT 48 def_bool !64BIT
diff --git a/arch/sparc/crypto/Makefile b/arch/sparc/crypto/Makefile
index 6ae1ad5e502..5d469d81761 100644
--- a/arch/sparc/crypto/Makefile
+++ b/arch/sparc/crypto/Makefile
@@ -13,13 +13,13 @@ obj-$(CONFIG_CRYPTO_DES_SPARC64) += camellia-sparc64.o
13 13
14obj-$(CONFIG_CRYPTO_CRC32C_SPARC64) += crc32c-sparc64.o 14obj-$(CONFIG_CRYPTO_CRC32C_SPARC64) += crc32c-sparc64.o
15 15
16sha1-sparc64-y := sha1_asm.o sha1_glue.o crop_devid.o 16sha1-sparc64-y := sha1_asm.o sha1_glue.o
17sha256-sparc64-y := sha256_asm.o sha256_glue.o crop_devid.o 17sha256-sparc64-y := sha256_asm.o sha256_glue.o
18sha512-sparc64-y := sha512_asm.o sha512_glue.o crop_devid.o 18sha512-sparc64-y := sha512_asm.o sha512_glue.o
19md5-sparc64-y := md5_asm.o md5_glue.o crop_devid.o 19md5-sparc64-y := md5_asm.o md5_glue.o
20 20
21aes-sparc64-y := aes_asm.o aes_glue.o crop_devid.o 21aes-sparc64-y := aes_asm.o aes_glue.o
22des-sparc64-y := des_asm.o des_glue.o crop_devid.o 22des-sparc64-y := des_asm.o des_glue.o
23camellia-sparc64-y := camellia_asm.o camellia_glue.o crop_devid.o 23camellia-sparc64-y := camellia_asm.o camellia_glue.o
24 24
25crc32c-sparc64-y := crc32c_asm.o crc32c_glue.o crop_devid.o 25crc32c-sparc64-y := crc32c_asm.o crc32c_glue.o
diff --git a/arch/sparc/crypto/aes_glue.c b/arch/sparc/crypto/aes_glue.c
index 8f1c9980f63..3965d1d36df 100644
--- a/arch/sparc/crypto/aes_glue.c
+++ b/arch/sparc/crypto/aes_glue.c
@@ -475,3 +475,5 @@ MODULE_LICENSE("GPL");
475MODULE_DESCRIPTION("AES Secure Hash Algorithm, sparc64 aes opcode accelerated"); 475MODULE_DESCRIPTION("AES Secure Hash Algorithm, sparc64 aes opcode accelerated");
476 476
477MODULE_ALIAS("aes"); 477MODULE_ALIAS("aes");
478
479#include "crop_devid.c"
diff --git a/arch/sparc/crypto/camellia_glue.c b/arch/sparc/crypto/camellia_glue.c
index 42905c08429..62c89af3fd3 100644
--- a/arch/sparc/crypto/camellia_glue.c
+++ b/arch/sparc/crypto/camellia_glue.c
@@ -320,3 +320,5 @@ MODULE_LICENSE("GPL");
320MODULE_DESCRIPTION("Camellia Cipher Algorithm, sparc64 camellia opcode accelerated"); 320MODULE_DESCRIPTION("Camellia Cipher Algorithm, sparc64 camellia opcode accelerated");
321 321
322MODULE_ALIAS("aes"); 322MODULE_ALIAS("aes");
323
324#include "crop_devid.c"
diff --git a/arch/sparc/crypto/crc32c_glue.c b/arch/sparc/crypto/crc32c_glue.c
index 0bd89cea8d8..5162fad912c 100644
--- a/arch/sparc/crypto/crc32c_glue.c
+++ b/arch/sparc/crypto/crc32c_glue.c
@@ -177,3 +177,5 @@ MODULE_LICENSE("GPL");
177MODULE_DESCRIPTION("CRC32c (Castagnoli), sparc64 crc32c opcode accelerated"); 177MODULE_DESCRIPTION("CRC32c (Castagnoli), sparc64 crc32c opcode accelerated");
178 178
179MODULE_ALIAS("crc32c"); 179MODULE_ALIAS("crc32c");
180
181#include "crop_devid.c"
diff --git a/arch/sparc/crypto/des_glue.c b/arch/sparc/crypto/des_glue.c
index c4940c2d307..41524cebcc4 100644
--- a/arch/sparc/crypto/des_glue.c
+++ b/arch/sparc/crypto/des_glue.c
@@ -527,3 +527,5 @@ MODULE_LICENSE("GPL");
527MODULE_DESCRIPTION("DES & Triple DES EDE Cipher Algorithms, sparc64 des opcode accelerated"); 527MODULE_DESCRIPTION("DES & Triple DES EDE Cipher Algorithms, sparc64 des opcode accelerated");
528 528
529MODULE_ALIAS("des"); 529MODULE_ALIAS("des");
530
531#include "crop_devid.c"
diff --git a/arch/sparc/crypto/md5_glue.c b/arch/sparc/crypto/md5_glue.c
index 603d723038c..09a9ea1dfb6 100644
--- a/arch/sparc/crypto/md5_glue.c
+++ b/arch/sparc/crypto/md5_glue.c
@@ -186,3 +186,5 @@ MODULE_LICENSE("GPL");
186MODULE_DESCRIPTION("MD5 Secure Hash Algorithm, sparc64 md5 opcode accelerated"); 186MODULE_DESCRIPTION("MD5 Secure Hash Algorithm, sparc64 md5 opcode accelerated");
187 187
188MODULE_ALIAS("md5"); 188MODULE_ALIAS("md5");
189
190#include "crop_devid.c"
diff --git a/arch/sparc/crypto/sha1_glue.c b/arch/sparc/crypto/sha1_glue.c
index 2bbb20bee9f..6cd5f29e1e0 100644
--- a/arch/sparc/crypto/sha1_glue.c
+++ b/arch/sparc/crypto/sha1_glue.c
@@ -181,3 +181,5 @@ MODULE_LICENSE("GPL");
181MODULE_DESCRIPTION("SHA1 Secure Hash Algorithm, sparc64 sha1 opcode accelerated"); 181MODULE_DESCRIPTION("SHA1 Secure Hash Algorithm, sparc64 sha1 opcode accelerated");
182 182
183MODULE_ALIAS("sha1"); 183MODULE_ALIAS("sha1");
184
185#include "crop_devid.c"
diff --git a/arch/sparc/crypto/sha256_glue.c b/arch/sparc/crypto/sha256_glue.c
index 591e656bd89..04f555ab268 100644
--- a/arch/sparc/crypto/sha256_glue.c
+++ b/arch/sparc/crypto/sha256_glue.c
@@ -239,3 +239,5 @@ MODULE_DESCRIPTION("SHA-224 and SHA-256 Secure Hash Algorithm, sparc64 sha256 op
239 239
240MODULE_ALIAS("sha224"); 240MODULE_ALIAS("sha224");
241MODULE_ALIAS("sha256"); 241MODULE_ALIAS("sha256");
242
243#include "crop_devid.c"
diff --git a/arch/sparc/crypto/sha512_glue.c b/arch/sparc/crypto/sha512_glue.c
index 486f0a2b700..f04d1994d19 100644
--- a/arch/sparc/crypto/sha512_glue.c
+++ b/arch/sparc/crypto/sha512_glue.c
@@ -224,3 +224,5 @@ MODULE_DESCRIPTION("SHA-384 and SHA-512 Secure Hash Algorithm, sparc64 sha512 op
224 224
225MODULE_ALIAS("sha384"); 225MODULE_ALIAS("sha384");
226MODULE_ALIAS("sha512"); 226MODULE_ALIAS("sha512");
227
228#include "crop_devid.c"
diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
index ce35a1cf1a2..be56a244c9c 100644
--- a/arch/sparc/include/asm/atomic_64.h
+++ b/arch/sparc/include/asm/atomic_64.h
@@ -1,7 +1,7 @@
1/* atomic.h: Thankfully the V9 is at least reasonable for this 1/* atomic.h: Thankfully the V9 is at least reasonable for this
2 * stuff. 2 * stuff.
3 * 3 *
4 * Copyright (C) 1996, 1997, 2000 David S. Miller (davem@redhat.com) 4 * Copyright (C) 1996, 1997, 2000, 2012 David S. Miller (davem@redhat.com)
5 */ 5 */
6 6
7#ifndef __ARCH_SPARC64_ATOMIC__ 7#ifndef __ARCH_SPARC64_ATOMIC__
@@ -106,6 +106,8 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
106 106
107#define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0) 107#define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
108 108
109extern long atomic64_dec_if_positive(atomic64_t *v);
110
109/* Atomic operations are already serializing */ 111/* Atomic operations are already serializing */
110#define smp_mb__before_atomic_dec() barrier() 112#define smp_mb__before_atomic_dec() barrier()
111#define smp_mb__after_atomic_dec() barrier() 113#define smp_mb__after_atomic_dec() barrier()
diff --git a/arch/sparc/include/asm/backoff.h b/arch/sparc/include/asm/backoff.h
index db3af0d30fb..4e02086b839 100644
--- a/arch/sparc/include/asm/backoff.h
+++ b/arch/sparc/include/asm/backoff.h
@@ -1,6 +1,46 @@
1#ifndef _SPARC64_BACKOFF_H 1#ifndef _SPARC64_BACKOFF_H
2#define _SPARC64_BACKOFF_H 2#define _SPARC64_BACKOFF_H
3 3
4/* The macros in this file implement an exponential backoff facility
5 * for atomic operations.
6 *
7 * When multiple threads compete on an atomic operation, it is
8 * possible for one thread to be continually denied a successful
9 * completion of the compare-and-swap instruction. Heavily
10 * threaded cpu implementations like Niagara can compound this
11 * problem even further.
12 *
13 * When an atomic operation fails and needs to be retried, we spin a
14 * certain number of times. At each subsequent failure of the same
15 * operation we double the spin count, realizing an exponential
16 * backoff.
17 *
18 * When we spin, we try to use an operation that will cause the
19 * current cpu strand to block, and therefore make the core fully
20 * available to any other other runnable strands. There are two
21 * options, based upon cpu capabilities.
22 *
23 * On all cpus prior to SPARC-T4 we do three dummy reads of the
24 * condition code register. Each read blocks the strand for something
25 * between 40 and 50 cpu cycles.
26 *
27 * For SPARC-T4 and later we have a special "pause" instruction
28 * available. This is implemented using writes to register %asr27.
29 * The cpu will block the number of cycles written into the register,
30 * unless a disrupting trap happens first. SPARC-T4 specifically
31 * implements pause with a granularity of 8 cycles. Each strand has
32 * an internal pause counter which decrements every 8 cycles. So the
33 * chip shifts the %asr27 value down by 3 bits, and writes the result
34 * into the pause counter. If a value smaller than 8 is written, the
35 * chip blocks for 1 cycle.
36 *
37 * To achieve the same amount of backoff as the three %ccr reads give
38 * on earlier chips, we shift the backoff value up by 7 bits. (Three
39 * %ccr reads block for about 128 cycles, 1 << 7 == 128) We write the
40 * whole amount we want to block into the pause register, rather than
41 * loop writing 128 each time.
42 */
43
4#define BACKOFF_LIMIT (4 * 1024) 44#define BACKOFF_LIMIT (4 * 1024)
5 45
6#ifdef CONFIG_SMP 46#ifdef CONFIG_SMP
@@ -11,16 +51,25 @@
11#define BACKOFF_LABEL(spin_label, continue_label) \ 51#define BACKOFF_LABEL(spin_label, continue_label) \
12 spin_label 52 spin_label
13 53
14#define BACKOFF_SPIN(reg, tmp, label) \ 54#define BACKOFF_SPIN(reg, tmp, label) \
15 mov reg, tmp; \ 55 mov reg, tmp; \
1688: brnz,pt tmp, 88b; \ 5688: rd %ccr, %g0; \
17 sub tmp, 1, tmp; \ 57 rd %ccr, %g0; \
18 set BACKOFF_LIMIT, tmp; \ 58 rd %ccr, %g0; \
19 cmp reg, tmp; \ 59 .section .pause_3insn_patch,"ax";\
20 bg,pn %xcc, label; \ 60 .word 88b; \
21 nop; \ 61 sllx tmp, 7, tmp; \
22 ba,pt %xcc, label; \ 62 wr tmp, 0, %asr27; \
23 sllx reg, 1, reg; 63 clr tmp; \
64 .previous; \
65 brnz,pt tmp, 88b; \
66 sub tmp, 1, tmp; \
67 set BACKOFF_LIMIT, tmp; \
68 cmp reg, tmp; \
69 bg,pn %xcc, label; \
70 nop; \
71 ba,pt %xcc, label; \
72 sllx reg, 1, reg;
24 73
25#else 74#else
26 75
diff --git a/arch/sparc/include/asm/compat.h b/arch/sparc/include/asm/compat.h
index cef99fbc0a2..830502fe62b 100644
--- a/arch/sparc/include/asm/compat.h
+++ b/arch/sparc/include/asm/compat.h
@@ -232,9 +232,10 @@ static inline void __user *arch_compat_alloc_user_space(long len)
232 struct pt_regs *regs = current_thread_info()->kregs; 232 struct pt_regs *regs = current_thread_info()->kregs;
233 unsigned long usp = regs->u_regs[UREG_I6]; 233 unsigned long usp = regs->u_regs[UREG_I6];
234 234
235 if (!(test_thread_flag(TIF_32BIT))) 235 if (test_thread_64bit_stack(usp))
236 usp += STACK_BIAS; 236 usp += STACK_BIAS;
237 else 237
238 if (test_thread_flag(TIF_32BIT))
238 usp &= 0xffffffffUL; 239 usp &= 0xffffffffUL;
239 240
240 usp -= len; 241 usp -= len;
diff --git a/arch/sparc/include/asm/processor_32.h b/arch/sparc/include/asm/processor_32.h
index f74ac9ee33a..c1e01914fd9 100644
--- a/arch/sparc/include/asm/processor_32.h
+++ b/arch/sparc/include/asm/processor_32.h
@@ -106,7 +106,6 @@ static inline void start_thread(struct pt_regs * regs, unsigned long pc,
106 106
107/* Free all resources held by a thread. */ 107/* Free all resources held by a thread. */
108#define release_thread(tsk) do { } while(0) 108#define release_thread(tsk) do { } while(0)
109extern pid_t kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
110 109
111extern unsigned long get_wchan(struct task_struct *); 110extern unsigned long get_wchan(struct task_struct *);
112 111
diff --git a/arch/sparc/include/asm/processor_64.h b/arch/sparc/include/asm/processor_64.h
index 4e5a483122a..cce72ce4c33 100644
--- a/arch/sparc/include/asm/processor_64.h
+++ b/arch/sparc/include/asm/processor_64.h
@@ -94,6 +94,7 @@ struct thread_struct {
94#ifndef __ASSEMBLY__ 94#ifndef __ASSEMBLY__
95 95
96#include <linux/types.h> 96#include <linux/types.h>
97#include <asm/fpumacro.h>
97 98
98/* Return saved PC of a blocked thread. */ 99/* Return saved PC of a blocked thread. */
99struct task_struct; 100struct task_struct;
@@ -143,6 +144,10 @@ do { \
143 : \ 144 : \
144 : "r" (regs), "r" (sp - sizeof(struct reg_window) - STACK_BIAS), \ 145 : "r" (regs), "r" (sp - sizeof(struct reg_window) - STACK_BIAS), \
145 "i" ((const unsigned long)(&((struct pt_regs *)0)->u_regs[0]))); \ 146 "i" ((const unsigned long)(&((struct pt_regs *)0)->u_regs[0]))); \
147 fprs_write(0); \
148 current_thread_info()->xfsr[0] = 0; \
149 current_thread_info()->fpsaved[0] = 0; \
150 regs->tstate &= ~TSTATE_PEF; \
146} while (0) 151} while (0)
147 152
148#define start_thread32(regs, pc, sp) \ 153#define start_thread32(regs, pc, sp) \
@@ -183,20 +188,37 @@ do { \
183 : \ 188 : \
184 : "r" (regs), "r" (sp - sizeof(struct reg_window32)), \ 189 : "r" (regs), "r" (sp - sizeof(struct reg_window32)), \
185 "i" ((const unsigned long)(&((struct pt_regs *)0)->u_regs[0]))); \ 190 "i" ((const unsigned long)(&((struct pt_regs *)0)->u_regs[0]))); \
191 fprs_write(0); \
192 current_thread_info()->xfsr[0] = 0; \
193 current_thread_info()->fpsaved[0] = 0; \
194 regs->tstate &= ~TSTATE_PEF; \
186} while (0) 195} while (0)
187 196
188/* Free all resources held by a thread. */ 197/* Free all resources held by a thread. */
189#define release_thread(tsk) do { } while (0) 198#define release_thread(tsk) do { } while (0)
190 199
191extern pid_t kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
192
193extern unsigned long get_wchan(struct task_struct *task); 200extern unsigned long get_wchan(struct task_struct *task);
194 201
195#define task_pt_regs(tsk) (task_thread_info(tsk)->kregs) 202#define task_pt_regs(tsk) (task_thread_info(tsk)->kregs)
196#define KSTK_EIP(tsk) (task_pt_regs(tsk)->tpc) 203#define KSTK_EIP(tsk) (task_pt_regs(tsk)->tpc)
197#define KSTK_ESP(tsk) (task_pt_regs(tsk)->u_regs[UREG_FP]) 204#define KSTK_ESP(tsk) (task_pt_regs(tsk)->u_regs[UREG_FP])
198 205
199#define cpu_relax() barrier() 206/* Please see the commentary in asm/backoff.h for a description of
207 * what these instructions are doing and how they have been choosen.
208 * To make a long story short, we are trying to yield the current cpu
209 * strand during busy loops.
210 */
211#define cpu_relax() asm volatile("\n99:\n\t" \
212 "rd %%ccr, %%g0\n\t" \
213 "rd %%ccr, %%g0\n\t" \
214 "rd %%ccr, %%g0\n\t" \
215 ".section .pause_3insn_patch,\"ax\"\n\t"\
216 ".word 99b\n\t" \
217 "wr %%g0, 128, %%asr27\n\t" \
218 "nop\n\t" \
219 "nop\n\t" \
220 ".previous" \
221 ::: "memory")
200 222
201/* Prefetch support. This is tuned for UltraSPARC-III and later. 223/* Prefetch support. This is tuned for UltraSPARC-III and later.
202 * UltraSPARC-I will treat these as nops, and UltraSPARC-II has 224 * UltraSPARC-I will treat these as nops, and UltraSPARC-II has
diff --git a/arch/sparc/include/asm/prom.h b/arch/sparc/include/asm/prom.h
index c2876511070..67c62578d17 100644
--- a/arch/sparc/include/asm/prom.h
+++ b/arch/sparc/include/asm/prom.h
@@ -63,5 +63,13 @@ extern char *of_console_options;
63extern void irq_trans_init(struct device_node *dp); 63extern void irq_trans_init(struct device_node *dp);
64extern char *build_path_component(struct device_node *dp); 64extern char *build_path_component(struct device_node *dp);
65 65
66/* SPARC has local implementations */
67extern int of_address_to_resource(struct device_node *dev, int index,
68 struct resource *r);
69#define of_address_to_resource of_address_to_resource
70
71void __iomem *of_iomap(struct device_node *node, int index);
72#define of_iomap of_iomap
73
66#endif /* __KERNEL__ */ 74#endif /* __KERNEL__ */
67#endif /* _SPARC_PROM_H */ 75#endif /* _SPARC_PROM_H */
diff --git a/arch/sparc/include/asm/ptrace.h b/arch/sparc/include/asm/ptrace.h
index 0c6f6b06828..bdfafd7af46 100644
--- a/arch/sparc/include/asm/ptrace.h
+++ b/arch/sparc/include/asm/ptrace.h
@@ -32,6 +32,9 @@ static inline bool pt_regs_clear_syscall(struct pt_regs *regs)
32#define arch_ptrace_stop(exit_code, info) \ 32#define arch_ptrace_stop(exit_code, info) \
33 synchronize_user_stack() 33 synchronize_user_stack()
34 34
35#define current_pt_regs() \
36 ((struct pt_regs *)((unsigned long)current_thread_info() + THREAD_SIZE) - 1)
37
35struct global_reg_snapshot { 38struct global_reg_snapshot {
36 unsigned long tstate; 39 unsigned long tstate;
37 unsigned long tpc; 40 unsigned long tpc;
@@ -42,11 +45,20 @@ struct global_reg_snapshot {
42 struct thread_info *thread; 45 struct thread_info *thread;
43 unsigned long pad1; 46 unsigned long pad1;
44}; 47};
45extern struct global_reg_snapshot global_reg_snapshot[NR_CPUS];
46 48
47#define force_successful_syscall_return() \ 49struct global_pmu_snapshot {
48do { current_thread_info()->syscall_noerror = 1; \ 50 unsigned long pcr[4];
49} while (0) 51 unsigned long pic[4];
52};
53
54union global_cpu_snapshot {
55 struct global_reg_snapshot reg;
56 struct global_pmu_snapshot pmu;
57};
58
59extern union global_cpu_snapshot global_cpu_snapshot[NR_CPUS];
60
61#define force_successful_syscall_return() set_thread_noerror(1)
50#define user_mode(regs) (!((regs)->tstate & TSTATE_PRIV)) 62#define user_mode(regs) (!((regs)->tstate & TSTATE_PRIV))
51#define instruction_pointer(regs) ((regs)->tpc) 63#define instruction_pointer(regs) ((regs)->tpc)
52#define instruction_pointer_set(regs, val) ((regs)->tpc = (val)) 64#define instruction_pointer_set(regs, val) ((regs)->tpc = (val))
@@ -89,6 +101,9 @@ static inline bool pt_regs_clear_syscall(struct pt_regs *regs)
89#define arch_ptrace_stop(exit_code, info) \ 101#define arch_ptrace_stop(exit_code, info) \
90 synchronize_user_stack() 102 synchronize_user_stack()
91 103
104#define current_pt_regs() \
105 ((struct pt_regs *)((unsigned long)current_thread_info() + THREAD_SIZE) - 1)
106
92#define user_mode(regs) (!((regs)->psr & PSR_PS)) 107#define user_mode(regs) (!((regs)->psr & PSR_PS))
93#define instruction_pointer(regs) ((regs)->pc) 108#define instruction_pointer(regs) ((regs)->pc)
94#define user_stack_pointer(regs) ((regs)->u_regs[UREG_FP]) 109#define user_stack_pointer(regs) ((regs)->u_regs[UREG_FP])
diff --git a/arch/sparc/include/asm/smp_64.h b/arch/sparc/include/asm/smp_64.h
index 29862a9e906..dd3bef4b989 100644
--- a/arch/sparc/include/asm/smp_64.h
+++ b/arch/sparc/include/asm/smp_64.h
@@ -48,6 +48,7 @@ extern void smp_fill_in_sib_core_maps(void);
48extern void cpu_play_dead(void); 48extern void cpu_play_dead(void);
49 49
50extern void smp_fetch_global_regs(void); 50extern void smp_fetch_global_regs(void);
51extern void smp_fetch_global_pmu(void);
51 52
52struct seq_file; 53struct seq_file;
53void smp_bogo(struct seq_file *); 54void smp_bogo(struct seq_file *);
@@ -65,6 +66,7 @@ extern void __cpu_die(unsigned int cpu);
65#define hard_smp_processor_id() 0 66#define hard_smp_processor_id() 0
66#define smp_fill_in_sib_core_maps() do { } while (0) 67#define smp_fill_in_sib_core_maps() do { } while (0)
67#define smp_fetch_global_regs() do { } while (0) 68#define smp_fetch_global_regs() do { } while (0)
69#define smp_fetch_global_pmu() do { } while (0)
68 70
69#endif /* !(CONFIG_SMP) */ 71#endif /* !(CONFIG_SMP) */
70 72
diff --git a/arch/sparc/include/asm/switch_to_64.h b/arch/sparc/include/asm/switch_to_64.h
index 7923c4a2be3..cad36f56fa0 100644
--- a/arch/sparc/include/asm/switch_to_64.h
+++ b/arch/sparc/include/asm/switch_to_64.h
@@ -23,7 +23,7 @@ do { flush_tlb_pending(); \
23 /* If you are tempted to conditionalize the following */ \ 23 /* If you are tempted to conditionalize the following */ \
24 /* so that ASI is only written if it changes, think again. */ \ 24 /* so that ASI is only written if it changes, think again. */ \
25 __asm__ __volatile__("wr %%g0, %0, %%asi" \ 25 __asm__ __volatile__("wr %%g0, %0, %%asi" \
26 : : "r" (__thread_flag_byte_ptr(task_thread_info(next))[TI_FLAG_BYTE_CURRENT_DS]));\ 26 : : "r" (task_thread_info(next)->current_ds));\
27 trap_block[current_thread_info()->cpu].thread = \ 27 trap_block[current_thread_info()->cpu].thread = \
28 task_thread_info(next); \ 28 task_thread_info(next); \
29 __asm__ __volatile__( \ 29 __asm__ __volatile__( \
diff --git a/arch/sparc/include/asm/syscalls.h b/arch/sparc/include/asm/syscalls.h
index 45a43f637a1..bf8972adea1 100644
--- a/arch/sparc/include/asm/syscalls.h
+++ b/arch/sparc/include/asm/syscalls.h
@@ -8,6 +8,4 @@ extern asmlinkage long sparc_do_fork(unsigned long clone_flags,
8 struct pt_regs *regs, 8 struct pt_regs *regs,
9 unsigned long stack_size); 9 unsigned long stack_size);
10 10
11extern asmlinkage int sparc_execve(struct pt_regs *regs);
12
13#endif /* _SPARC64_SYSCALLS_H */ 11#endif /* _SPARC64_SYSCALLS_H */
diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
index 4e227663108..269bd92313d 100644
--- a/arch/sparc/include/asm/thread_info_64.h
+++ b/arch/sparc/include/asm/thread_info_64.h
@@ -14,12 +14,12 @@
14#define TI_FLAG_FAULT_CODE_SHIFT 56 14#define TI_FLAG_FAULT_CODE_SHIFT 56
15#define TI_FLAG_BYTE_WSTATE 1 15#define TI_FLAG_BYTE_WSTATE 1
16#define TI_FLAG_WSTATE_SHIFT 48 16#define TI_FLAG_WSTATE_SHIFT 48
17#define TI_FLAG_BYTE_CWP 2 17#define TI_FLAG_BYTE_NOERROR 2
18#define TI_FLAG_CWP_SHIFT 40 18#define TI_FLAG_BYTE_NOERROR_SHIFT 40
19#define TI_FLAG_BYTE_CURRENT_DS 3 19#define TI_FLAG_BYTE_FPDEPTH 3
20#define TI_FLAG_CURRENT_DS_SHIFT 32 20#define TI_FLAG_FPDEPTH_SHIFT 32
21#define TI_FLAG_BYTE_FPDEPTH 4 21#define TI_FLAG_BYTE_CWP 4
22#define TI_FLAG_FPDEPTH_SHIFT 24 22#define TI_FLAG_CWP_SHIFT 24
23#define TI_FLAG_BYTE_WSAVED 5 23#define TI_FLAG_BYTE_WSAVED 5
24#define TI_FLAG_WSAVED_SHIFT 16 24#define TI_FLAG_WSAVED_SHIFT 16
25 25
@@ -47,7 +47,7 @@ struct thread_info {
47 struct exec_domain *exec_domain; 47 struct exec_domain *exec_domain;
48 int preempt_count; /* 0 => preemptable, <0 => BUG */ 48 int preempt_count; /* 0 => preemptable, <0 => BUG */
49 __u8 new_child; 49 __u8 new_child;
50 __u8 syscall_noerror; 50 __u8 current_ds;
51 __u16 cpu; 51 __u16 cpu;
52 52
53 unsigned long *utraps; 53 unsigned long *utraps;
@@ -74,9 +74,9 @@ struct thread_info {
74#define TI_FAULT_CODE (TI_FLAGS + TI_FLAG_BYTE_FAULT_CODE) 74#define TI_FAULT_CODE (TI_FLAGS + TI_FLAG_BYTE_FAULT_CODE)
75#define TI_WSTATE (TI_FLAGS + TI_FLAG_BYTE_WSTATE) 75#define TI_WSTATE (TI_FLAGS + TI_FLAG_BYTE_WSTATE)
76#define TI_CWP (TI_FLAGS + TI_FLAG_BYTE_CWP) 76#define TI_CWP (TI_FLAGS + TI_FLAG_BYTE_CWP)
77#define TI_CURRENT_DS (TI_FLAGS + TI_FLAG_BYTE_CURRENT_DS)
78#define TI_FPDEPTH (TI_FLAGS + TI_FLAG_BYTE_FPDEPTH) 77#define TI_FPDEPTH (TI_FLAGS + TI_FLAG_BYTE_FPDEPTH)
79#define TI_WSAVED (TI_FLAGS + TI_FLAG_BYTE_WSAVED) 78#define TI_WSAVED (TI_FLAGS + TI_FLAG_BYTE_WSAVED)
79#define TI_SYS_NOERROR (TI_FLAGS + TI_FLAG_BYTE_NOERROR)
80#define TI_FPSAVED 0x00000010 80#define TI_FPSAVED 0x00000010
81#define TI_KSP 0x00000018 81#define TI_KSP 0x00000018
82#define TI_FAULT_ADDR 0x00000020 82#define TI_FAULT_ADDR 0x00000020
@@ -84,7 +84,7 @@ struct thread_info {
84#define TI_EXEC_DOMAIN 0x00000030 84#define TI_EXEC_DOMAIN 0x00000030
85#define TI_PRE_COUNT 0x00000038 85#define TI_PRE_COUNT 0x00000038
86#define TI_NEW_CHILD 0x0000003c 86#define TI_NEW_CHILD 0x0000003c
87#define TI_SYS_NOERROR 0x0000003d 87#define TI_CURRENT_DS 0x0000003d
88#define TI_CPU 0x0000003e 88#define TI_CPU 0x0000003e
89#define TI_UTRAPS 0x00000040 89#define TI_UTRAPS 0x00000040
90#define TI_REG_WINDOW 0x00000048 90#define TI_REG_WINDOW 0x00000048
@@ -121,7 +121,7 @@ struct thread_info {
121#define INIT_THREAD_INFO(tsk) \ 121#define INIT_THREAD_INFO(tsk) \
122{ \ 122{ \
123 .task = &tsk, \ 123 .task = &tsk, \
124 .flags = ((unsigned long)ASI_P) << TI_FLAG_CURRENT_DS_SHIFT, \ 124 .current_ds = ASI_P, \
125 .exec_domain = &default_exec_domain, \ 125 .exec_domain = &default_exec_domain, \
126 .preempt_count = INIT_PREEMPT_COUNT, \ 126 .preempt_count = INIT_PREEMPT_COUNT, \
127 .restart_block = { \ 127 .restart_block = { \
@@ -153,13 +153,12 @@ register struct thread_info *current_thread_info_reg asm("g6");
153#define set_thread_wstate(val) (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_WSTATE] = (val)) 153#define set_thread_wstate(val) (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_WSTATE] = (val))
154#define get_thread_cwp() (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_CWP]) 154#define get_thread_cwp() (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_CWP])
155#define set_thread_cwp(val) (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_CWP] = (val)) 155#define set_thread_cwp(val) (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_CWP] = (val))
156#define get_thread_current_ds() (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_CURRENT_DS]) 156#define get_thread_noerror() (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_NOERROR])
157#define set_thread_current_ds(val) (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_CURRENT_DS] = (val)) 157#define set_thread_noerror(val) (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_NOERROR] = (val))
158#define get_thread_fpdepth() (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_FPDEPTH]) 158#define get_thread_fpdepth() (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_FPDEPTH])
159#define set_thread_fpdepth(val) (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_FPDEPTH] = (val)) 159#define set_thread_fpdepth(val) (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_FPDEPTH] = (val))
160#define get_thread_wsaved() (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_WSAVED]) 160#define get_thread_wsaved() (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_WSAVED])
161#define set_thread_wsaved(val) (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_WSAVED] = (val)) 161#define set_thread_wsaved(val) (__cur_thread_flag_byte_ptr[TI_FLAG_BYTE_WSAVED] = (val))
162
163#endif /* !(__ASSEMBLY__) */ 162#endif /* !(__ASSEMBLY__) */
164 163
165/* 164/*
@@ -259,6 +258,11 @@ static inline bool test_and_clear_restore_sigmask(void)
259 258
260#define tsk_is_polling(t) test_tsk_thread_flag(t, TIF_POLLING_NRFLAG) 259#define tsk_is_polling(t) test_tsk_thread_flag(t, TIF_POLLING_NRFLAG)
261 260
261#define thread32_stack_is_64bit(__SP) (((__SP) & 0x1) != 0)
262#define test_thread_64bit_stack(__SP) \
263 ((test_thread_flag(TIF_32BIT) && !thread32_stack_is_64bit(__SP)) ? \
264 false : true)
265
262#endif /* !__ASSEMBLY__ */ 266#endif /* !__ASSEMBLY__ */
263 267
264#endif /* __KERNEL__ */ 268#endif /* __KERNEL__ */
diff --git a/arch/sparc/include/asm/ttable.h b/arch/sparc/include/asm/ttable.h
index 48f2807d326..71b5a67522a 100644
--- a/arch/sparc/include/asm/ttable.h
+++ b/arch/sparc/include/asm/ttable.h
@@ -372,7 +372,9 @@ etrap_spill_fixup_64bit: \
372 372
373/* Normal 32bit spill */ 373/* Normal 32bit spill */
374#define SPILL_2_GENERIC(ASI) \ 374#define SPILL_2_GENERIC(ASI) \
375 srl %sp, 0, %sp; \ 375 and %sp, 1, %g3; \
376 brnz,pn %g3, (. - (128 + 4)); \
377 srl %sp, 0, %sp; \
376 stwa %l0, [%sp + %g0] ASI; \ 378 stwa %l0, [%sp + %g0] ASI; \
377 mov 0x04, %g3; \ 379 mov 0x04, %g3; \
378 stwa %l1, [%sp + %g3] ASI; \ 380 stwa %l1, [%sp + %g3] ASI; \
@@ -398,14 +400,16 @@ etrap_spill_fixup_64bit: \
398 stwa %i6, [%g1 + %g0] ASI; \ 400 stwa %i6, [%g1 + %g0] ASI; \
399 stwa %i7, [%g1 + %g3] ASI; \ 401 stwa %i7, [%g1 + %g3] ASI; \
400 saved; \ 402 saved; \
401 retry; nop; nop; \ 403 retry; \
402 b,a,pt %xcc, spill_fixup_dax; \ 404 b,a,pt %xcc, spill_fixup_dax; \
403 b,a,pt %xcc, spill_fixup_mna; \ 405 b,a,pt %xcc, spill_fixup_mna; \
404 b,a,pt %xcc, spill_fixup; 406 b,a,pt %xcc, spill_fixup;
405 407
406#define SPILL_2_GENERIC_ETRAP \ 408#define SPILL_2_GENERIC_ETRAP \
407etrap_user_spill_32bit: \ 409etrap_user_spill_32bit: \
408 srl %sp, 0, %sp; \ 410 and %sp, 1, %g3; \
411 brnz,pn %g3, etrap_user_spill_64bit; \
412 srl %sp, 0, %sp; \
409 stwa %l0, [%sp + 0x00] %asi; \ 413 stwa %l0, [%sp + 0x00] %asi; \
410 stwa %l1, [%sp + 0x04] %asi; \ 414 stwa %l1, [%sp + 0x04] %asi; \
411 stwa %l2, [%sp + 0x08] %asi; \ 415 stwa %l2, [%sp + 0x08] %asi; \
@@ -427,7 +431,7 @@ etrap_user_spill_32bit: \
427 ba,pt %xcc, etrap_save; \ 431 ba,pt %xcc, etrap_save; \
428 wrpr %g1, %cwp; \ 432 wrpr %g1, %cwp; \
429 nop; nop; nop; nop; \ 433 nop; nop; nop; nop; \
430 nop; nop; nop; nop; \ 434 nop; nop; \
431 ba,a,pt %xcc, etrap_spill_fixup_32bit; \ 435 ba,a,pt %xcc, etrap_spill_fixup_32bit; \
432 ba,a,pt %xcc, etrap_spill_fixup_32bit; \ 436 ba,a,pt %xcc, etrap_spill_fixup_32bit; \
433 ba,a,pt %xcc, etrap_spill_fixup_32bit; 437 ba,a,pt %xcc, etrap_spill_fixup_32bit;
@@ -592,7 +596,9 @@ user_rtt_fill_64bit: \
592 596
593/* Normal 32bit fill */ 597/* Normal 32bit fill */
594#define FILL_2_GENERIC(ASI) \ 598#define FILL_2_GENERIC(ASI) \
595 srl %sp, 0, %sp; \ 599 and %sp, 1, %g3; \
600 brnz,pn %g3, (. - (128 + 4)); \
601 srl %sp, 0, %sp; \
596 lduwa [%sp + %g0] ASI, %l0; \ 602 lduwa [%sp + %g0] ASI, %l0; \
597 mov 0x04, %g2; \ 603 mov 0x04, %g2; \
598 mov 0x08, %g3; \ 604 mov 0x08, %g3; \
@@ -616,14 +622,16 @@ user_rtt_fill_64bit: \
616 lduwa [%g1 + %g3] ASI, %i6; \ 622 lduwa [%g1 + %g3] ASI, %i6; \
617 lduwa [%g1 + %g5] ASI, %i7; \ 623 lduwa [%g1 + %g5] ASI, %i7; \
618 restored; \ 624 restored; \
619 retry; nop; nop; nop; nop; \ 625 retry; nop; nop; \
620 b,a,pt %xcc, fill_fixup_dax; \ 626 b,a,pt %xcc, fill_fixup_dax; \
621 b,a,pt %xcc, fill_fixup_mna; \ 627 b,a,pt %xcc, fill_fixup_mna; \
622 b,a,pt %xcc, fill_fixup; 628 b,a,pt %xcc, fill_fixup;
623 629
624#define FILL_2_GENERIC_RTRAP \ 630#define FILL_2_GENERIC_RTRAP \
625user_rtt_fill_32bit: \ 631user_rtt_fill_32bit: \
626 srl %sp, 0, %sp; \ 632 and %sp, 1, %g3; \
633 brnz,pn %g3, user_rtt_fill_64bit; \
634 srl %sp, 0, %sp; \
627 lduwa [%sp + 0x00] %asi, %l0; \ 635 lduwa [%sp + 0x00] %asi, %l0; \
628 lduwa [%sp + 0x04] %asi, %l1; \ 636 lduwa [%sp + 0x04] %asi, %l1; \
629 lduwa [%sp + 0x08] %asi, %l2; \ 637 lduwa [%sp + 0x08] %asi, %l2; \
@@ -643,7 +651,7 @@ user_rtt_fill_32bit: \
643 ba,pt %xcc, user_rtt_pre_restore; \ 651 ba,pt %xcc, user_rtt_pre_restore; \
644 restored; \ 652 restored; \
645 nop; nop; nop; nop; nop; \ 653 nop; nop; nop; nop; nop; \
646 nop; nop; nop; nop; nop; \ 654 nop; nop; nop; \
647 ba,a,pt %xcc, user_rtt_fill_fixup; \ 655 ba,a,pt %xcc, user_rtt_fill_fixup; \
648 ba,a,pt %xcc, user_rtt_fill_fixup; \ 656 ba,a,pt %xcc, user_rtt_fill_fixup; \
649 ba,a,pt %xcc, user_rtt_fill_fixup; 657 ba,a,pt %xcc, user_rtt_fill_fixup;
diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
index 73083e1d38d..e562d3caee5 100644
--- a/arch/sparc/include/asm/uaccess_64.h
+++ b/arch/sparc/include/asm/uaccess_64.h
@@ -38,14 +38,14 @@
38#define VERIFY_READ 0 38#define VERIFY_READ 0
39#define VERIFY_WRITE 1 39#define VERIFY_WRITE 1
40 40
41#define get_fs() ((mm_segment_t) { get_thread_current_ds() }) 41#define get_fs() ((mm_segment_t){(current_thread_info()->current_ds)})
42#define get_ds() (KERNEL_DS) 42#define get_ds() (KERNEL_DS)
43 43
44#define segment_eq(a,b) ((a).seg == (b).seg) 44#define segment_eq(a,b) ((a).seg == (b).seg)
45 45
46#define set_fs(val) \ 46#define set_fs(val) \
47do { \ 47do { \
48 set_thread_current_ds((val).seg); \ 48 current_thread_info()->current_ds =(val).seg; \
49 __asm__ __volatile__ ("wr %%g0, %0, %%asi" : : "r" ((val).seg)); \ 49 __asm__ __volatile__ ("wr %%g0, %0, %%asi" : : "r" ((val).seg)); \
50} while(0) 50} while(0)
51 51
diff --git a/arch/sparc/include/asm/unistd.h b/arch/sparc/include/asm/unistd.h
index 0ecea6ed943..c3e5d8b6417 100644
--- a/arch/sparc/include/asm/unistd.h
+++ b/arch/sparc/include/asm/unistd.h
@@ -46,6 +46,7 @@
46#define __ARCH_WANT_COMPAT_SYS_RT_SIGSUSPEND 46#define __ARCH_WANT_COMPAT_SYS_RT_SIGSUSPEND
47#define __ARCH_WANT_COMPAT_SYS_SENDFILE 47#define __ARCH_WANT_COMPAT_SYS_SENDFILE
48#endif 48#endif
49#define __ARCH_WANT_SYS_EXECVE
49 50
50/* 51/*
51 * "Conditional" syscalls 52 * "Conditional" syscalls
diff --git a/arch/sparc/include/uapi/asm/sigcontext.h b/arch/sparc/include/uapi/asm/sigcontext.h
index e69de29bb2d..ae5704fa77a 100644
--- a/arch/sparc/include/uapi/asm/sigcontext.h
+++ b/arch/sparc/include/uapi/asm/sigcontext.h
@@ -0,0 +1,4 @@
1/*
2 * There isn't anything here anymore, but the file must not be empty or patch
3 * will delete it.
4 */
diff --git a/arch/sparc/include/uapi/asm/unistd.h b/arch/sparc/include/uapi/asm/unistd.h
index 8974ef7ae92..cac719d1bc5 100644
--- a/arch/sparc/include/uapi/asm/unistd.h
+++ b/arch/sparc/include/uapi/asm/unistd.h
@@ -405,8 +405,13 @@
405#define __NR_setns 337 405#define __NR_setns 337
406#define __NR_process_vm_readv 338 406#define __NR_process_vm_readv 338
407#define __NR_process_vm_writev 339 407#define __NR_process_vm_writev 339
408#define __NR_kern_features 340
409#define __NR_kcmp 341
408 410
409#define NR_syscalls 340 411#define NR_syscalls 342
412
413/* Bitmask values returned from kern_features system call. */
414#define KERN_FEATURE_MIXED_MODE_STACK 0x00000001
410 415
411#ifdef __32bit_syscall_numbers__ 416#ifdef __32bit_syscall_numbers__
412/* Sparc 32-bit only has the "setresuid32", "getresuid32" variants, 417/* Sparc 32-bit only has the "setresuid32", "getresuid32" variants,
diff --git a/arch/sparc/kernel/entry.S b/arch/sparc/kernel/entry.S
index dcaa1cf0de4..21fd1a8f47d 100644
--- a/arch/sparc/kernel/entry.S
+++ b/arch/sparc/kernel/entry.S
@@ -806,23 +806,10 @@ sys_nis_syscall:
806 call c_sys_nis_syscall 806 call c_sys_nis_syscall
807 mov %l5, %o7 807 mov %l5, %o7
808 808
809 .align 4
810 .globl sys_execve
811sys_execve:
812 mov %o7, %l5
813 add %sp, STACKFRAME_SZ, %o0 ! pt_regs *regs arg
814 call sparc_execve
815 mov %l5, %o7
816
817 .globl sunos_execv
818sunos_execv: 809sunos_execv:
819 st %g0, [%sp + STACKFRAME_SZ + PT_I2] 810 .globl sunos_execv
820 811 b sys_execve
821 call sparc_execve 812 clr %i2
822 add %sp, STACKFRAME_SZ, %o0
823
824 b ret_sys_call
825 ld [%sp + STACKFRAME_SZ + PT_I0], %o0
826 813
827 .align 4 814 .align 4
828 .globl sys_sparc_pipe 815 .globl sys_sparc_pipe
@@ -959,17 +946,9 @@ flush_patch_four:
959 .align 4 946 .align 4
960linux_sparc_ni_syscall: 947linux_sparc_ni_syscall:
961 sethi %hi(sys_ni_syscall), %l7 948 sethi %hi(sys_ni_syscall), %l7
962 b syscall_is_too_hard 949 b do_syscall
963 or %l7, %lo(sys_ni_syscall), %l7 950 or %l7, %lo(sys_ni_syscall), %l7
964 951
965linux_fast_syscall:
966 andn %l7, 3, %l7
967 mov %i0, %o0
968 mov %i1, %o1
969 mov %i2, %o2
970 jmpl %l7 + %g0, %g0
971 mov %i3, %o3
972
973linux_syscall_trace: 952linux_syscall_trace:
974 add %sp, STACKFRAME_SZ, %o0 953 add %sp, STACKFRAME_SZ, %o0
975 call syscall_trace 954 call syscall_trace
@@ -991,6 +970,23 @@ ret_from_fork:
991 b ret_sys_call 970 b ret_sys_call
992 ld [%sp + STACKFRAME_SZ + PT_I0], %o0 971 ld [%sp + STACKFRAME_SZ + PT_I0], %o0
993 972
973 .globl ret_from_kernel_thread
974ret_from_kernel_thread:
975 call schedule_tail
976 ld [%g3 + TI_TASK], %o0
977 ld [%sp + STACKFRAME_SZ + PT_G1], %l0
978 call %l0
979 ld [%sp + STACKFRAME_SZ + PT_G2], %o0
980 rd %psr, %l1
981 ld [%sp + STACKFRAME_SZ + PT_PSR], %l0
982 andn %l0, PSR_CWP, %l0
983 nop
984 and %l1, PSR_CWP, %l1
985 or %l0, %l1, %l0
986 st %l0, [%sp + STACKFRAME_SZ + PT_PSR]
987 b ret_sys_call
988 mov 0, %o0
989
994 /* Linux native system calls enter here... */ 990 /* Linux native system calls enter here... */
995 .align 4 991 .align 4
996 .globl linux_sparc_syscall 992 .globl linux_sparc_syscall
@@ -1002,11 +998,8 @@ linux_sparc_syscall:
1002 bgeu linux_sparc_ni_syscall 998 bgeu linux_sparc_ni_syscall
1003 sll %g1, 2, %l4 999 sll %g1, 2, %l4
1004 ld [%l7 + %l4], %l7 1000 ld [%l7 + %l4], %l7
1005 andcc %l7, 1, %g0
1006 bne linux_fast_syscall
1007 /* Just do first insn from SAVE_ALL in the delay slot */
1008 1001
1009syscall_is_too_hard: 1002do_syscall:
1010 SAVE_ALL_HEAD 1003 SAVE_ALL_HEAD
1011 rd %wim, %l3 1004 rd %wim, %l3
1012 1005
diff --git a/arch/sparc/kernel/entry.h b/arch/sparc/kernel/entry.h
index 0c218e4c088..cc3c5cb47cd 100644
--- a/arch/sparc/kernel/entry.h
+++ b/arch/sparc/kernel/entry.h
@@ -59,6 +59,13 @@ struct popc_6insn_patch_entry {
59extern struct popc_6insn_patch_entry __popc_6insn_patch, 59extern struct popc_6insn_patch_entry __popc_6insn_patch,
60 __popc_6insn_patch_end; 60 __popc_6insn_patch_end;
61 61
62struct pause_patch_entry {
63 unsigned int addr;
64 unsigned int insns[3];
65};
66extern struct pause_patch_entry __pause_3insn_patch,
67 __pause_3insn_patch_end;
68
62extern void __init per_cpu_patch(void); 69extern void __init per_cpu_patch(void);
63extern void sun4v_patch_1insn_range(struct sun4v_1insn_patch_entry *, 70extern void sun4v_patch_1insn_range(struct sun4v_1insn_patch_entry *,
64 struct sun4v_1insn_patch_entry *); 71 struct sun4v_1insn_patch_entry *);
diff --git a/arch/sparc/kernel/etrap_64.S b/arch/sparc/kernel/etrap_64.S
index 786b185e6e3..1276ca2567b 100644
--- a/arch/sparc/kernel/etrap_64.S
+++ b/arch/sparc/kernel/etrap_64.S
@@ -92,8 +92,10 @@ etrap_save: save %g2, -STACK_BIAS, %sp
92 rdpr %wstate, %g2 92 rdpr %wstate, %g2
93 wrpr %g0, 0, %canrestore 93 wrpr %g0, 0, %canrestore
94 sll %g2, 3, %g2 94 sll %g2, 3, %g2
95
96 /* Set TI_SYS_FPDEPTH to 1 and clear TI_SYS_NOERROR. */
95 mov 1, %l5 97 mov 1, %l5
96 stb %l5, [%l6 + TI_FPDEPTH] 98 sth %l5, [%l6 + TI_SYS_NOERROR]
97 99
98 wrpr %g3, 0, %otherwin 100 wrpr %g3, 0, %otherwin
99 wrpr %g2, 0, %wstate 101 wrpr %g2, 0, %wstate
@@ -152,7 +154,9 @@ etrap_save: save %g2, -STACK_BIAS, %sp
152 add %l6, TI_FPSAVED + 1, %l4 154 add %l6, TI_FPSAVED + 1, %l4
153 srl %l5, 1, %l3 155 srl %l5, 1, %l3
154 add %l5, 2, %l5 156 add %l5, 2, %l5
155 stb %l5, [%l6 + TI_FPDEPTH] 157
158 /* Set TI_SYS_FPDEPTH to %l5 and clear TI_SYS_NOERROR. */
159 sth %l5, [%l6 + TI_SYS_NOERROR]
156 ba,pt %xcc, 2b 160 ba,pt %xcc, 2b
157 stb %g0, [%l4 + %l3] 161 stb %g0, [%l4 + %l3]
158 nop 162 nop
diff --git a/arch/sparc/kernel/leon_kernel.c b/arch/sparc/kernel/leon_kernel.c
index f8b6eee40bd..87f60ee6543 100644
--- a/arch/sparc/kernel/leon_kernel.c
+++ b/arch/sparc/kernel/leon_kernel.c
@@ -56,11 +56,13 @@ static inline unsigned int leon_eirq_get(int cpu)
56static void leon_handle_ext_irq(unsigned int irq, struct irq_desc *desc) 56static void leon_handle_ext_irq(unsigned int irq, struct irq_desc *desc)
57{ 57{
58 unsigned int eirq; 58 unsigned int eirq;
59 struct irq_bucket *p;
59 int cpu = sparc_leon3_cpuid(); 60 int cpu = sparc_leon3_cpuid();
60 61
61 eirq = leon_eirq_get(cpu); 62 eirq = leon_eirq_get(cpu);
62 if ((eirq & 0x10) && irq_map[eirq]->irq) /* bit4 tells if IRQ happened */ 63 p = irq_map[eirq];
63 generic_handle_irq(irq_map[eirq]->irq); 64 if ((eirq & 0x10) && p && p->irq) /* bit4 tells if IRQ happened */
65 generic_handle_irq(p->irq);
64} 66}
65 67
66/* The extended IRQ controller has been found, this function registers it */ 68/* The extended IRQ controller has been found, this function registers it */
diff --git a/arch/sparc/kernel/perf_event.c b/arch/sparc/kernel/perf_event.c
index e48651dace1..b5c38faa4ea 100644
--- a/arch/sparc/kernel/perf_event.c
+++ b/arch/sparc/kernel/perf_event.c
@@ -817,15 +817,17 @@ static u64 nop_for_index(int idx)
817 817
818static inline void sparc_pmu_enable_event(struct cpu_hw_events *cpuc, struct hw_perf_event *hwc, int idx) 818static inline void sparc_pmu_enable_event(struct cpu_hw_events *cpuc, struct hw_perf_event *hwc, int idx)
819{ 819{
820 u64 val, mask = mask_for_index(idx); 820 u64 enc, val, mask = mask_for_index(idx);
821 int pcr_index = 0; 821 int pcr_index = 0;
822 822
823 if (sparc_pmu->num_pcrs > 1) 823 if (sparc_pmu->num_pcrs > 1)
824 pcr_index = idx; 824 pcr_index = idx;
825 825
826 enc = perf_event_get_enc(cpuc->events[idx]);
827
826 val = cpuc->pcr[pcr_index]; 828 val = cpuc->pcr[pcr_index];
827 val &= ~mask; 829 val &= ~mask;
828 val |= hwc->config; 830 val |= event_encoding(enc, idx);
829 cpuc->pcr[pcr_index] = val; 831 cpuc->pcr[pcr_index] = val;
830 832
831 pcr_ops->write_pcr(pcr_index, cpuc->pcr[pcr_index]); 833 pcr_ops->write_pcr(pcr_index, cpuc->pcr[pcr_index]);
@@ -1738,8 +1740,6 @@ static void perf_callchain_user_64(struct perf_callchain_entry *entry,
1738{ 1740{
1739 unsigned long ufp; 1741 unsigned long ufp;
1740 1742
1741 perf_callchain_store(entry, regs->tpc);
1742
1743 ufp = regs->u_regs[UREG_I6] + STACK_BIAS; 1743 ufp = regs->u_regs[UREG_I6] + STACK_BIAS;
1744 do { 1744 do {
1745 struct sparc_stackf *usf, sf; 1745 struct sparc_stackf *usf, sf;
@@ -1760,19 +1760,27 @@ static void perf_callchain_user_32(struct perf_callchain_entry *entry,
1760{ 1760{
1761 unsigned long ufp; 1761 unsigned long ufp;
1762 1762
1763 perf_callchain_store(entry, regs->tpc);
1764
1765 ufp = regs->u_regs[UREG_I6] & 0xffffffffUL; 1763 ufp = regs->u_regs[UREG_I6] & 0xffffffffUL;
1766 do { 1764 do {
1767 struct sparc_stackf32 *usf, sf;
1768 unsigned long pc; 1765 unsigned long pc;
1769 1766
1770 usf = (struct sparc_stackf32 *) ufp; 1767 if (thread32_stack_is_64bit(ufp)) {
1771 if (__copy_from_user_inatomic(&sf, usf, sizeof(sf))) 1768 struct sparc_stackf *usf, sf;
1772 break;
1773 1769
1774 pc = sf.callers_pc; 1770 ufp += STACK_BIAS;
1775 ufp = (unsigned long)sf.fp; 1771 usf = (struct sparc_stackf *) ufp;
1772 if (__copy_from_user_inatomic(&sf, usf, sizeof(sf)))
1773 break;
1774 pc = sf.callers_pc & 0xffffffff;
1775 ufp = ((unsigned long) sf.fp) & 0xffffffff;
1776 } else {
1777 struct sparc_stackf32 *usf, sf;
1778 usf = (struct sparc_stackf32 *) ufp;
1779 if (__copy_from_user_inatomic(&sf, usf, sizeof(sf)))
1780 break;
1781 pc = sf.callers_pc;
1782 ufp = (unsigned long)sf.fp;
1783 }
1776 perf_callchain_store(entry, pc); 1784 perf_callchain_store(entry, pc);
1777 } while (entry->nr < PERF_MAX_STACK_DEPTH); 1785 } while (entry->nr < PERF_MAX_STACK_DEPTH);
1778} 1786}
@@ -1780,6 +1788,11 @@ static void perf_callchain_user_32(struct perf_callchain_entry *entry,
1780void 1788void
1781perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs) 1789perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
1782{ 1790{
1791 perf_callchain_store(entry, regs->tpc);
1792
1793 if (!current->mm)
1794 return;
1795
1783 flushw_user(); 1796 flushw_user();
1784 if (test_thread_flag(TIF_32BIT)) 1797 if (test_thread_flag(TIF_32BIT))
1785 perf_callchain_user_32(entry, regs); 1798 perf_callchain_user_32(entry, regs);
diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
index 487bffb36f5..bf4c6addce7 100644
--- a/arch/sparc/kernel/process_32.c
+++ b/arch/sparc/kernel/process_32.c
@@ -316,9 +316,10 @@ asmlinkage int sparc_do_fork(unsigned long clone_flags,
316 * XXX See comment above sys_vfork in sparc64. todo. 316 * XXX See comment above sys_vfork in sparc64. todo.
317 */ 317 */
318extern void ret_from_fork(void); 318extern void ret_from_fork(void);
319extern void ret_from_kernel_thread(void);
319 320
320int copy_thread(unsigned long clone_flags, unsigned long sp, 321int copy_thread(unsigned long clone_flags, unsigned long sp,
321 unsigned long unused, 322 unsigned long arg,
322 struct task_struct *p, struct pt_regs *regs) 323 struct task_struct *p, struct pt_regs *regs)
323{ 324{
324 struct thread_info *ti = task_thread_info(p); 325 struct thread_info *ti = task_thread_info(p);
@@ -336,16 +337,13 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
336 } 337 }
337 338
338 /* 339 /*
339 * p->thread_info new_stack childregs 340 * p->thread_info new_stack childregs stack bottom
340 * ! ! ! {if(PSR_PS) } 341 * ! ! ! !
341 * V V (stk.fr.) V (pt_regs) { (stk.fr.) } 342 * V V (stk.fr.) V (pt_regs) V
342 * +----- - - - - - ------+===========+============={+==========}+ 343 * +----- - - - - - ------+===========+=============+
343 */ 344 */
344 new_stack = task_stack_page(p) + THREAD_SIZE; 345 new_stack = task_stack_page(p) + THREAD_SIZE;
345 if (regs->psr & PSR_PS)
346 new_stack -= STACKFRAME_SZ;
347 new_stack -= STACKFRAME_SZ + TRACEREG_SZ; 346 new_stack -= STACKFRAME_SZ + TRACEREG_SZ;
348 memcpy(new_stack, (char *)regs - STACKFRAME_SZ, STACKFRAME_SZ + TRACEREG_SZ);
349 childregs = (struct pt_regs *) (new_stack + STACKFRAME_SZ); 347 childregs = (struct pt_regs *) (new_stack + STACKFRAME_SZ);
350 348
351 /* 349 /*
@@ -356,55 +354,58 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
356 * Thus, kpsr|=PSR_PIL. 354 * Thus, kpsr|=PSR_PIL.
357 */ 355 */
358 ti->ksp = (unsigned long) new_stack; 356 ti->ksp = (unsigned long) new_stack;
357 p->thread.kregs = childregs;
358
359 if (unlikely(p->flags & PF_KTHREAD)) {
360 extern int nwindows;
361 unsigned long psr;
362 memset(new_stack, 0, STACKFRAME_SZ + TRACEREG_SZ);
363 p->thread.flags |= SPARC_FLAG_KTHREAD;
364 p->thread.current_ds = KERNEL_DS;
365 ti->kpc = (((unsigned long) ret_from_kernel_thread) - 0x8);
366 childregs->u_regs[UREG_G1] = sp; /* function */
367 childregs->u_regs[UREG_G2] = arg;
368 psr = childregs->psr = get_psr();
369 ti->kpsr = psr | PSR_PIL;
370 ti->kwim = 1 << (((psr & PSR_CWP) + 1) % nwindows);
371 return 0;
372 }
373 memcpy(new_stack, (char *)regs - STACKFRAME_SZ, STACKFRAME_SZ + TRACEREG_SZ);
374 childregs->u_regs[UREG_FP] = sp;
375 p->thread.flags &= ~SPARC_FLAG_KTHREAD;
376 p->thread.current_ds = USER_DS;
359 ti->kpc = (((unsigned long) ret_from_fork) - 0x8); 377 ti->kpc = (((unsigned long) ret_from_fork) - 0x8);
360 ti->kpsr = current->thread.fork_kpsr | PSR_PIL; 378 ti->kpsr = current->thread.fork_kpsr | PSR_PIL;
361 ti->kwim = current->thread.fork_kwim; 379 ti->kwim = current->thread.fork_kwim;
362 380
363 if(regs->psr & PSR_PS) { 381 if (sp != regs->u_regs[UREG_FP]) {
364 extern struct pt_regs fake_swapper_regs; 382 struct sparc_stackf __user *childstack;
383 struct sparc_stackf __user *parentstack;
365 384
366 p->thread.kregs = &fake_swapper_regs; 385 /*
367 new_stack += STACKFRAME_SZ + TRACEREG_SZ; 386 * This is a clone() call with supplied user stack.
368 childregs->u_regs[UREG_FP] = (unsigned long) new_stack; 387 * Set some valid stack frames to give to the child.
369 p->thread.flags |= SPARC_FLAG_KTHREAD; 388 */
370 p->thread.current_ds = KERNEL_DS; 389 childstack = (struct sparc_stackf __user *)
371 memcpy(new_stack, (void *)regs->u_regs[UREG_FP], STACKFRAME_SZ); 390 (sp & ~0xfUL);
372 childregs->u_regs[UREG_G6] = (unsigned long) ti; 391 parentstack = (struct sparc_stackf __user *)
373 } else { 392 regs->u_regs[UREG_FP];
374 p->thread.kregs = childregs;
375 childregs->u_regs[UREG_FP] = sp;
376 p->thread.flags &= ~SPARC_FLAG_KTHREAD;
377 p->thread.current_ds = USER_DS;
378
379 if (sp != regs->u_regs[UREG_FP]) {
380 struct sparc_stackf __user *childstack;
381 struct sparc_stackf __user *parentstack;
382
383 /*
384 * This is a clone() call with supplied user stack.
385 * Set some valid stack frames to give to the child.
386 */
387 childstack = (struct sparc_stackf __user *)
388 (sp & ~0xfUL);
389 parentstack = (struct sparc_stackf __user *)
390 regs->u_regs[UREG_FP];
391 393
392#if 0 394#if 0
393 printk("clone: parent stack:\n"); 395 printk("clone: parent stack:\n");
394 show_stackframe(parentstack); 396 show_stackframe(parentstack);
395#endif 397#endif
396 398
397 childstack = clone_stackframe(childstack, parentstack); 399 childstack = clone_stackframe(childstack, parentstack);
398 if (!childstack) 400 if (!childstack)
399 return -EFAULT; 401 return -EFAULT;
400 402
401#if 0 403#if 0
402 printk("clone: child stack:\n"); 404 printk("clone: child stack:\n");
403 show_stackframe(childstack); 405 show_stackframe(childstack);
404#endif 406#endif
405 407
406 childregs->u_regs[UREG_FP] = (unsigned long)childstack; 408 childregs->u_regs[UREG_FP] = (unsigned long)childstack;
407 }
408 } 409 }
409 410
410#ifdef CONFIG_SMP 411#ifdef CONFIG_SMP
@@ -475,69 +476,6 @@ int dump_fpu (struct pt_regs * regs, elf_fpregset_t * fpregs)
475 return 1; 476 return 1;
476} 477}
477 478
478/*
479 * sparc_execve() executes a new program after the asm stub has set
480 * things up for us. This should basically do what I want it to.
481 */
482asmlinkage int sparc_execve(struct pt_regs *regs)
483{
484 int error, base = 0;
485 struct filename *filename;
486
487 /* Check for indirect call. */
488 if(regs->u_regs[UREG_G1] == 0)
489 base = 1;
490
491 filename = getname((char __user *)regs->u_regs[base + UREG_I0]);
492 error = PTR_ERR(filename);
493 if(IS_ERR(filename))
494 goto out;
495 error = do_execve(filename->name,
496 (const char __user *const __user *)
497 regs->u_regs[base + UREG_I1],
498 (const char __user *const __user *)
499 regs->u_regs[base + UREG_I2],
500 regs);
501 putname(filename);
502out:
503 return error;
504}
505
506/*
507 * This is the mechanism for creating a new kernel thread.
508 *
509 * NOTE! Only a kernel-only process(ie the swapper or direct descendants
510 * who haven't done an "execve()") should use this: it will work within
511 * a system call from a "real" process, but the process memory space will
512 * not be freed until both the parent and the child have exited.
513 */
514pid_t kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
515{
516 long retval;
517
518 __asm__ __volatile__("mov %4, %%g2\n\t" /* Set aside fn ptr... */
519 "mov %5, %%g3\n\t" /* and arg. */
520 "mov %1, %%g1\n\t"
521 "mov %2, %%o0\n\t" /* Clone flags. */
522 "mov 0, %%o1\n\t" /* usp arg == 0 */
523 "t 0x10\n\t" /* Linux/Sparc clone(). */
524 "cmp %%o1, 0\n\t"
525 "be 1f\n\t" /* The parent, just return. */
526 " nop\n\t" /* Delay slot. */
527 "jmpl %%g2, %%o7\n\t" /* Call the function. */
528 " mov %%g3, %%o0\n\t" /* Get back the arg in delay. */
529 "mov %3, %%g1\n\t"
530 "t 0x10\n\t" /* Linux/Sparc exit(). */
531 /* Notreached by child. */
532 "1: mov %%o0, %0\n\t" :
533 "=r" (retval) :
534 "i" (__NR_clone), "r" (flags | CLONE_VM | CLONE_UNTRACED),
535 "i" (__NR_exit), "r" (fn), "r" (arg) :
536 "g1", "g2", "g3", "o0", "o1", "memory", "cc");
537 return retval;
538}
539EXPORT_SYMBOL(kernel_thread);
540
541unsigned long get_wchan(struct task_struct *task) 479unsigned long get_wchan(struct task_struct *task)
542{ 480{
543 unsigned long pc, fp, bias = 0; 481 unsigned long pc, fp, bias = 0;
diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
index fcaa5942112..dff54f46728 100644
--- a/arch/sparc/kernel/process_64.c
+++ b/arch/sparc/kernel/process_64.c
@@ -27,6 +27,7 @@
27#include <linux/tick.h> 27#include <linux/tick.h>
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/cpu.h> 29#include <linux/cpu.h>
30#include <linux/perf_event.h>
30#include <linux/elfcore.h> 31#include <linux/elfcore.h>
31#include <linux/sysrq.h> 32#include <linux/sysrq.h>
32#include <linux/nmi.h> 33#include <linux/nmi.h>
@@ -47,6 +48,7 @@
47#include <asm/syscalls.h> 48#include <asm/syscalls.h>
48#include <asm/irq_regs.h> 49#include <asm/irq_regs.h>
49#include <asm/smp.h> 50#include <asm/smp.h>
51#include <asm/pcr.h>
50 52
51#include "kstack.h" 53#include "kstack.h"
52 54
@@ -204,18 +206,22 @@ void show_regs(struct pt_regs *regs)
204 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]); 206 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
205} 207}
206 208
207struct global_reg_snapshot global_reg_snapshot[NR_CPUS]; 209union global_cpu_snapshot global_cpu_snapshot[NR_CPUS];
208static DEFINE_SPINLOCK(global_reg_snapshot_lock); 210static DEFINE_SPINLOCK(global_cpu_snapshot_lock);
209 211
210static void __global_reg_self(struct thread_info *tp, struct pt_regs *regs, 212static void __global_reg_self(struct thread_info *tp, struct pt_regs *regs,
211 int this_cpu) 213 int this_cpu)
212{ 214{
215 struct global_reg_snapshot *rp;
216
213 flushw_all(); 217 flushw_all();
214 218
215 global_reg_snapshot[this_cpu].tstate = regs->tstate; 219 rp = &global_cpu_snapshot[this_cpu].reg;
216 global_reg_snapshot[this_cpu].tpc = regs->tpc; 220
217 global_reg_snapshot[this_cpu].tnpc = regs->tnpc; 221 rp->tstate = regs->tstate;
218 global_reg_snapshot[this_cpu].o7 = regs->u_regs[UREG_I7]; 222 rp->tpc = regs->tpc;
223 rp->tnpc = regs->tnpc;
224 rp->o7 = regs->u_regs[UREG_I7];
219 225
220 if (regs->tstate & TSTATE_PRIV) { 226 if (regs->tstate & TSTATE_PRIV) {
221 struct reg_window *rw; 227 struct reg_window *rw;
@@ -223,17 +229,17 @@ static void __global_reg_self(struct thread_info *tp, struct pt_regs *regs,
223 rw = (struct reg_window *) 229 rw = (struct reg_window *)
224 (regs->u_regs[UREG_FP] + STACK_BIAS); 230 (regs->u_regs[UREG_FP] + STACK_BIAS);
225 if (kstack_valid(tp, (unsigned long) rw)) { 231 if (kstack_valid(tp, (unsigned long) rw)) {
226 global_reg_snapshot[this_cpu].i7 = rw->ins[7]; 232 rp->i7 = rw->ins[7];
227 rw = (struct reg_window *) 233 rw = (struct reg_window *)
228 (rw->ins[6] + STACK_BIAS); 234 (rw->ins[6] + STACK_BIAS);
229 if (kstack_valid(tp, (unsigned long) rw)) 235 if (kstack_valid(tp, (unsigned long) rw))
230 global_reg_snapshot[this_cpu].rpc = rw->ins[7]; 236 rp->rpc = rw->ins[7];
231 } 237 }
232 } else { 238 } else {
233 global_reg_snapshot[this_cpu].i7 = 0; 239 rp->i7 = 0;
234 global_reg_snapshot[this_cpu].rpc = 0; 240 rp->rpc = 0;
235 } 241 }
236 global_reg_snapshot[this_cpu].thread = tp; 242 rp->thread = tp;
237} 243}
238 244
239/* In order to avoid hangs we do not try to synchronize with the 245/* In order to avoid hangs we do not try to synchronize with the
@@ -261,9 +267,9 @@ void arch_trigger_all_cpu_backtrace(void)
261 if (!regs) 267 if (!regs)
262 regs = tp->kregs; 268 regs = tp->kregs;
263 269
264 spin_lock_irqsave(&global_reg_snapshot_lock, flags); 270 spin_lock_irqsave(&global_cpu_snapshot_lock, flags);
265 271
266 memset(global_reg_snapshot, 0, sizeof(global_reg_snapshot)); 272 memset(global_cpu_snapshot, 0, sizeof(global_cpu_snapshot));
267 273
268 this_cpu = raw_smp_processor_id(); 274 this_cpu = raw_smp_processor_id();
269 275
@@ -272,7 +278,7 @@ void arch_trigger_all_cpu_backtrace(void)
272 smp_fetch_global_regs(); 278 smp_fetch_global_regs();
273 279
274 for_each_online_cpu(cpu) { 280 for_each_online_cpu(cpu) {
275 struct global_reg_snapshot *gp = &global_reg_snapshot[cpu]; 281 struct global_reg_snapshot *gp = &global_cpu_snapshot[cpu].reg;
276 282
277 __global_reg_poll(gp); 283 __global_reg_poll(gp);
278 284
@@ -295,9 +301,9 @@ void arch_trigger_all_cpu_backtrace(void)
295 } 301 }
296 } 302 }
297 303
298 memset(global_reg_snapshot, 0, sizeof(global_reg_snapshot)); 304 memset(global_cpu_snapshot, 0, sizeof(global_cpu_snapshot));
299 305
300 spin_unlock_irqrestore(&global_reg_snapshot_lock, flags); 306 spin_unlock_irqrestore(&global_cpu_snapshot_lock, flags);
301} 307}
302 308
303#ifdef CONFIG_MAGIC_SYSRQ 309#ifdef CONFIG_MAGIC_SYSRQ
@@ -309,16 +315,90 @@ static void sysrq_handle_globreg(int key)
309 315
310static struct sysrq_key_op sparc_globalreg_op = { 316static struct sysrq_key_op sparc_globalreg_op = {
311 .handler = sysrq_handle_globreg, 317 .handler = sysrq_handle_globreg,
312 .help_msg = "Globalregs", 318 .help_msg = "global-regs(Y)",
313 .action_msg = "Show Global CPU Regs", 319 .action_msg = "Show Global CPU Regs",
314}; 320};
315 321
316static int __init sparc_globreg_init(void) 322static void __global_pmu_self(int this_cpu)
323{
324 struct global_pmu_snapshot *pp;
325 int i, num;
326
327 pp = &global_cpu_snapshot[this_cpu].pmu;
328
329 num = 1;
330 if (tlb_type == hypervisor &&
331 sun4v_chip_type >= SUN4V_CHIP_NIAGARA4)
332 num = 4;
333
334 for (i = 0; i < num; i++) {
335 pp->pcr[i] = pcr_ops->read_pcr(i);
336 pp->pic[i] = pcr_ops->read_pic(i);
337 }
338}
339
340static void __global_pmu_poll(struct global_pmu_snapshot *pp)
341{
342 int limit = 0;
343
344 while (!pp->pcr[0] && ++limit < 100) {
345 barrier();
346 udelay(1);
347 }
348}
349
350static void pmu_snapshot_all_cpus(void)
351{
352 unsigned long flags;
353 int this_cpu, cpu;
354
355 spin_lock_irqsave(&global_cpu_snapshot_lock, flags);
356
357 memset(global_cpu_snapshot, 0, sizeof(global_cpu_snapshot));
358
359 this_cpu = raw_smp_processor_id();
360
361 __global_pmu_self(this_cpu);
362
363 smp_fetch_global_pmu();
364
365 for_each_online_cpu(cpu) {
366 struct global_pmu_snapshot *pp = &global_cpu_snapshot[cpu].pmu;
367
368 __global_pmu_poll(pp);
369
370 printk("%c CPU[%3d]: PCR[%08lx:%08lx:%08lx:%08lx] PIC[%08lx:%08lx:%08lx:%08lx]\n",
371 (cpu == this_cpu ? '*' : ' '), cpu,
372 pp->pcr[0], pp->pcr[1], pp->pcr[2], pp->pcr[3],
373 pp->pic[0], pp->pic[1], pp->pic[2], pp->pic[3]);
374 }
375
376 memset(global_cpu_snapshot, 0, sizeof(global_cpu_snapshot));
377
378 spin_unlock_irqrestore(&global_cpu_snapshot_lock, flags);
379}
380
381static void sysrq_handle_globpmu(int key)
317{ 382{
318 return register_sysrq_key('y', &sparc_globalreg_op); 383 pmu_snapshot_all_cpus();
319} 384}
320 385
321core_initcall(sparc_globreg_init); 386static struct sysrq_key_op sparc_globalpmu_op = {
387 .handler = sysrq_handle_globpmu,
388 .help_msg = "global-pmu(X)",
389 .action_msg = "Show Global PMU Regs",
390};
391
392static int __init sparc_sysrq_init(void)
393{
394 int ret = register_sysrq_key('y', &sparc_globalreg_op);
395
396 if (!ret)
397 ret = register_sysrq_key('x', &sparc_globalpmu_op);
398 return ret;
399}
400
401core_initcall(sparc_sysrq_init);
322 402
323#endif 403#endif
324 404
@@ -372,13 +452,16 @@ void flush_thread(void)
372/* It's a bit more tricky when 64-bit tasks are involved... */ 452/* It's a bit more tricky when 64-bit tasks are involved... */
373static unsigned long clone_stackframe(unsigned long csp, unsigned long psp) 453static unsigned long clone_stackframe(unsigned long csp, unsigned long psp)
374{ 454{
455 bool stack_64bit = test_thread_64bit_stack(psp);
375 unsigned long fp, distance, rval; 456 unsigned long fp, distance, rval;
376 457
377 if (!(test_thread_flag(TIF_32BIT))) { 458 if (stack_64bit) {
378 csp += STACK_BIAS; 459 csp += STACK_BIAS;
379 psp += STACK_BIAS; 460 psp += STACK_BIAS;
380 __get_user(fp, &(((struct reg_window __user *)psp)->ins[6])); 461 __get_user(fp, &(((struct reg_window __user *)psp)->ins[6]));
381 fp += STACK_BIAS; 462 fp += STACK_BIAS;
463 if (test_thread_flag(TIF_32BIT))
464 fp &= 0xffffffff;
382 } else 465 } else
383 __get_user(fp, &(((struct reg_window32 __user *)psp)->ins[6])); 466 __get_user(fp, &(((struct reg_window32 __user *)psp)->ins[6]));
384 467
@@ -392,7 +475,7 @@ static unsigned long clone_stackframe(unsigned long csp, unsigned long psp)
392 rval = (csp - distance); 475 rval = (csp - distance);
393 if (copy_in_user((void __user *) rval, (void __user *) psp, distance)) 476 if (copy_in_user((void __user *) rval, (void __user *) psp, distance))
394 rval = 0; 477 rval = 0;
395 else if (test_thread_flag(TIF_32BIT)) { 478 else if (!stack_64bit) {
396 if (put_user(((u32)csp), 479 if (put_user(((u32)csp),
397 &(((struct reg_window32 __user *)rval)->ins[6]))) 480 &(((struct reg_window32 __user *)rval)->ins[6])))
398 rval = 0; 481 rval = 0;
@@ -427,18 +510,18 @@ void synchronize_user_stack(void)
427 510
428 flush_user_windows(); 511 flush_user_windows();
429 if ((window = get_thread_wsaved()) != 0) { 512 if ((window = get_thread_wsaved()) != 0) {
430 int winsize = sizeof(struct reg_window);
431 int bias = 0;
432
433 if (test_thread_flag(TIF_32BIT))
434 winsize = sizeof(struct reg_window32);
435 else
436 bias = STACK_BIAS;
437
438 window -= 1; 513 window -= 1;
439 do { 514 do {
440 unsigned long sp = (t->rwbuf_stkptrs[window] + bias);
441 struct reg_window *rwin = &t->reg_window[window]; 515 struct reg_window *rwin = &t->reg_window[window];
516 int winsize = sizeof(struct reg_window);
517 unsigned long sp;
518
519 sp = t->rwbuf_stkptrs[window];
520
521 if (test_thread_64bit_stack(sp))
522 sp += STACK_BIAS;
523 else
524 winsize = sizeof(struct reg_window32);
442 525
443 if (!copy_to_user((char __user *)sp, rwin, winsize)) { 526 if (!copy_to_user((char __user *)sp, rwin, winsize)) {
444 shift_window_buffer(window, get_thread_wsaved() - 1, t); 527 shift_window_buffer(window, get_thread_wsaved() - 1, t);
@@ -464,13 +547,6 @@ void fault_in_user_windows(void)
464{ 547{
465 struct thread_info *t = current_thread_info(); 548 struct thread_info *t = current_thread_info();
466 unsigned long window; 549 unsigned long window;
467 int winsize = sizeof(struct reg_window);
468 int bias = 0;
469
470 if (test_thread_flag(TIF_32BIT))
471 winsize = sizeof(struct reg_window32);
472 else
473 bias = STACK_BIAS;
474 550
475 flush_user_windows(); 551 flush_user_windows();
476 window = get_thread_wsaved(); 552 window = get_thread_wsaved();
@@ -478,8 +554,16 @@ void fault_in_user_windows(void)
478 if (likely(window != 0)) { 554 if (likely(window != 0)) {
479 window -= 1; 555 window -= 1;
480 do { 556 do {
481 unsigned long sp = (t->rwbuf_stkptrs[window] + bias);
482 struct reg_window *rwin = &t->reg_window[window]; 557 struct reg_window *rwin = &t->reg_window[window];
558 int winsize = sizeof(struct reg_window);
559 unsigned long sp;
560
561 sp = t->rwbuf_stkptrs[window];
562
563 if (test_thread_64bit_stack(sp))
564 sp += STACK_BIAS;
565 else
566 winsize = sizeof(struct reg_window32);
483 567
484 if (unlikely(sp & 0x7UL)) 568 if (unlikely(sp & 0x7UL))
485 stack_unaligned(sp); 569 stack_unaligned(sp);
@@ -538,64 +622,55 @@ asmlinkage long sparc_do_fork(unsigned long clone_flags,
538 * Child --> %o0 == parents pid, %o1 == 1 622 * Child --> %o0 == parents pid, %o1 == 1
539 */ 623 */
540int copy_thread(unsigned long clone_flags, unsigned long sp, 624int copy_thread(unsigned long clone_flags, unsigned long sp,
541 unsigned long unused, 625 unsigned long arg,
542 struct task_struct *p, struct pt_regs *regs) 626 struct task_struct *p, struct pt_regs *regs)
543{ 627{
544 struct thread_info *t = task_thread_info(p); 628 struct thread_info *t = task_thread_info(p);
545 struct sparc_stackf *parent_sf; 629 struct sparc_stackf *parent_sf;
546 unsigned long child_stack_sz; 630 unsigned long child_stack_sz;
547 char *child_trap_frame; 631 char *child_trap_frame;
548 int kernel_thread;
549
550 kernel_thread = (regs->tstate & TSTATE_PRIV) ? 1 : 0;
551 parent_sf = ((struct sparc_stackf *) regs) - 1;
552 632
553 /* Calculate offset to stack_frame & pt_regs */ 633 /* Calculate offset to stack_frame & pt_regs */
554 child_stack_sz = ((STACKFRAME_SZ + TRACEREG_SZ) + 634 child_stack_sz = (STACKFRAME_SZ + TRACEREG_SZ);
555 (kernel_thread ? STACKFRAME_SZ : 0));
556 child_trap_frame = (task_stack_page(p) + 635 child_trap_frame = (task_stack_page(p) +
557 (THREAD_SIZE - child_stack_sz)); 636 (THREAD_SIZE - child_stack_sz));
558 memcpy(child_trap_frame, parent_sf, child_stack_sz);
559 637
560 t->flags = (t->flags & ~((0xffUL << TI_FLAG_CWP_SHIFT) |
561 (0xffUL << TI_FLAG_CURRENT_DS_SHIFT))) |
562 (((regs->tstate + 1) & TSTATE_CWP) << TI_FLAG_CWP_SHIFT);
563 t->new_child = 1; 638 t->new_child = 1;
564 t->ksp = ((unsigned long) child_trap_frame) - STACK_BIAS; 639 t->ksp = ((unsigned long) child_trap_frame) - STACK_BIAS;
565 t->kregs = (struct pt_regs *) (child_trap_frame + 640 t->kregs = (struct pt_regs *) (child_trap_frame +
566 sizeof(struct sparc_stackf)); 641 sizeof(struct sparc_stackf));
567 t->fpsaved[0] = 0; 642 t->fpsaved[0] = 0;
568 643
569 if (kernel_thread) { 644 if (unlikely(p->flags & PF_KTHREAD)) {
570 struct sparc_stackf *child_sf = (struct sparc_stackf *) 645 memset(child_trap_frame, 0, child_stack_sz);
571 (child_trap_frame + (STACKFRAME_SZ + TRACEREG_SZ)); 646 __thread_flag_byte_ptr(t)[TI_FLAG_BYTE_CWP] =
572 647 (current_pt_regs()->tstate + 1) & TSTATE_CWP;
573 /* Zero terminate the stack backtrace. */ 648 t->current_ds = ASI_P;
574 child_sf->fp = NULL; 649 t->kregs->u_regs[UREG_G1] = sp; /* function */
575 t->kregs->u_regs[UREG_FP] = 650 t->kregs->u_regs[UREG_G2] = arg;
576 ((unsigned long) child_sf) - STACK_BIAS; 651 return 0;
652 }
577 653
578 t->flags |= ((long)ASI_P << TI_FLAG_CURRENT_DS_SHIFT); 654 parent_sf = ((struct sparc_stackf *) regs) - 1;
579 t->kregs->u_regs[UREG_G6] = (unsigned long) t; 655 memcpy(child_trap_frame, parent_sf, child_stack_sz);
580 t->kregs->u_regs[UREG_G4] = (unsigned long) t->task; 656 if (t->flags & _TIF_32BIT) {
581 } else { 657 sp &= 0x00000000ffffffffUL;
582 if (t->flags & _TIF_32BIT) { 658 regs->u_regs[UREG_FP] &= 0x00000000ffffffffUL;
583 sp &= 0x00000000ffffffffUL;
584 regs->u_regs[UREG_FP] &= 0x00000000ffffffffUL;
585 }
586 t->kregs->u_regs[UREG_FP] = sp;
587 t->flags |= ((long)ASI_AIUS << TI_FLAG_CURRENT_DS_SHIFT);
588 if (sp != regs->u_regs[UREG_FP]) {
589 unsigned long csp;
590
591 csp = clone_stackframe(sp, regs->u_regs[UREG_FP]);
592 if (!csp)
593 return -EFAULT;
594 t->kregs->u_regs[UREG_FP] = csp;
595 }
596 if (t->utraps)
597 t->utraps[0]++;
598 } 659 }
660 t->kregs->u_regs[UREG_FP] = sp;
661 __thread_flag_byte_ptr(t)[TI_FLAG_BYTE_CWP] =
662 (regs->tstate + 1) & TSTATE_CWP;
663 t->current_ds = ASI_AIUS;
664 if (sp != regs->u_regs[UREG_FP]) {
665 unsigned long csp;
666
667 csp = clone_stackframe(sp, regs->u_regs[UREG_FP]);
668 if (!csp)
669 return -EFAULT;
670 t->kregs->u_regs[UREG_FP] = csp;
671 }
672 if (t->utraps)
673 t->utraps[0]++;
599 674
600 /* Set the return value for the child. */ 675 /* Set the return value for the child. */
601 t->kregs->u_regs[UREG_I0] = current->pid; 676 t->kregs->u_regs[UREG_I0] = current->pid;
@@ -610,45 +685,6 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
610 return 0; 685 return 0;
611} 686}
612 687
613/*
614 * This is the mechanism for creating a new kernel thread.
615 *
616 * NOTE! Only a kernel-only process(ie the swapper or direct descendants
617 * who haven't done an "execve()") should use this: it will work within
618 * a system call from a "real" process, but the process memory space will
619 * not be freed until both the parent and the child have exited.
620 */
621pid_t kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
622{
623 long retval;
624
625 /* If the parent runs before fn(arg) is called by the child,
626 * the input registers of this function can be clobbered.
627 * So we stash 'fn' and 'arg' into global registers which
628 * will not be modified by the parent.
629 */
630 __asm__ __volatile__("mov %4, %%g2\n\t" /* Save FN into global */
631 "mov %5, %%g3\n\t" /* Save ARG into global */
632 "mov %1, %%g1\n\t" /* Clone syscall nr. */
633 "mov %2, %%o0\n\t" /* Clone flags. */
634 "mov 0, %%o1\n\t" /* usp arg == 0 */
635 "t 0x6d\n\t" /* Linux/Sparc clone(). */
636 "brz,a,pn %%o1, 1f\n\t" /* Parent, just return. */
637 " mov %%o0, %0\n\t"
638 "jmpl %%g2, %%o7\n\t" /* Call the function. */
639 " mov %%g3, %%o0\n\t" /* Set arg in delay. */
640 "mov %3, %%g1\n\t"
641 "t 0x6d\n\t" /* Linux/Sparc exit(). */
642 /* Notreached by child. */
643 "1:" :
644 "=r" (retval) :
645 "i" (__NR_clone), "r" (flags | CLONE_VM | CLONE_UNTRACED),
646 "i" (__NR_exit), "r" (fn), "r" (arg) :
647 "g1", "g2", "g3", "o0", "o1", "memory", "cc");
648 return retval;
649}
650EXPORT_SYMBOL(kernel_thread);
651
652typedef struct { 688typedef struct {
653 union { 689 union {
654 unsigned int pr_regs[32]; 690 unsigned int pr_regs[32];
@@ -715,41 +751,6 @@ int dump_fpu (struct pt_regs * regs, elf_fpregset_t * fpregs)
715} 751}
716EXPORT_SYMBOL(dump_fpu); 752EXPORT_SYMBOL(dump_fpu);
717 753
718/*
719 * sparc_execve() executes a new program after the asm stub has set
720 * things up for us. This should basically do what I want it to.
721 */
722asmlinkage int sparc_execve(struct pt_regs *regs)
723{
724 int error, base = 0;
725 struct filename *filename;
726
727 /* User register window flush is done by entry.S */
728
729 /* Check for indirect call. */
730 if (regs->u_regs[UREG_G1] == 0)
731 base = 1;
732
733 filename = getname((char __user *)regs->u_regs[base + UREG_I0]);
734 error = PTR_ERR(filename);
735 if (IS_ERR(filename))
736 goto out;
737 error = do_execve(filename->name,
738 (const char __user *const __user *)
739 regs->u_regs[base + UREG_I1],
740 (const char __user *const __user *)
741 regs->u_regs[base + UREG_I2], regs);
742 putname(filename);
743 if (!error) {
744 fprs_write(0);
745 current_thread_info()->xfsr[0] = 0;
746 current_thread_info()->fpsaved[0] = 0;
747 regs->tstate &= ~TSTATE_PEF;
748 }
749out:
750 return error;
751}
752
753unsigned long get_wchan(struct task_struct *task) 754unsigned long get_wchan(struct task_struct *task)
754{ 755{
755 unsigned long pc, fp, bias = 0; 756 unsigned long pc, fp, bias = 0;
diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
index 484dabac704..7ff45e4ba68 100644
--- a/arch/sparc/kernel/ptrace_64.c
+++ b/arch/sparc/kernel/ptrace_64.c
@@ -151,7 +151,7 @@ static int regwindow64_get(struct task_struct *target,
151{ 151{
152 unsigned long rw_addr = regs->u_regs[UREG_I6]; 152 unsigned long rw_addr = regs->u_regs[UREG_I6];
153 153
154 if (test_tsk_thread_flag(current, TIF_32BIT)) { 154 if (!test_thread_64bit_stack(rw_addr)) {
155 struct reg_window32 win32; 155 struct reg_window32 win32;
156 int i; 156 int i;
157 157
@@ -176,7 +176,7 @@ static int regwindow64_set(struct task_struct *target,
176{ 176{
177 unsigned long rw_addr = regs->u_regs[UREG_I6]; 177 unsigned long rw_addr = regs->u_regs[UREG_I6];
178 178
179 if (test_tsk_thread_flag(current, TIF_32BIT)) { 179 if (!test_thread_64bit_stack(rw_addr)) {
180 struct reg_window32 win32; 180 struct reg_window32 win32;
181 int i; 181 int i;
182 182
diff --git a/arch/sparc/kernel/setup_64.c b/arch/sparc/kernel/setup_64.c
index 0800e71d8a8..0eaf0059aae 100644
--- a/arch/sparc/kernel/setup_64.c
+++ b/arch/sparc/kernel/setup_64.c
@@ -316,6 +316,25 @@ static void __init popc_patch(void)
316 } 316 }
317} 317}
318 318
319static void __init pause_patch(void)
320{
321 struct pause_patch_entry *p;
322
323 p = &__pause_3insn_patch;
324 while (p < &__pause_3insn_patch_end) {
325 unsigned long i, addr = p->addr;
326
327 for (i = 0; i < 3; i++) {
328 *(unsigned int *) (addr + (i * 4)) = p->insns[i];
329 wmb();
330 __asm__ __volatile__("flush %0"
331 : : "r" (addr + (i * 4)));
332 }
333
334 p++;
335 }
336}
337
319#ifdef CONFIG_SMP 338#ifdef CONFIG_SMP
320void __init boot_cpu_id_too_large(int cpu) 339void __init boot_cpu_id_too_large(int cpu)
321{ 340{
@@ -528,6 +547,8 @@ static void __init init_sparc64_elf_hwcap(void)
528 547
529 if (sparc64_elf_hwcap & AV_SPARC_POPC) 548 if (sparc64_elf_hwcap & AV_SPARC_POPC)
530 popc_patch(); 549 popc_patch();
550 if (sparc64_elf_hwcap & AV_SPARC_PAUSE)
551 pause_patch();
531} 552}
532 553
533void __init setup_arch(char **cmdline_p) 554void __init setup_arch(char **cmdline_p)
diff --git a/arch/sparc/kernel/signal_64.c b/arch/sparc/kernel/signal_64.c
index 867de2f8189..689e1ba6280 100644
--- a/arch/sparc/kernel/signal_64.c
+++ b/arch/sparc/kernel/signal_64.c
@@ -295,9 +295,7 @@ void do_rt_sigreturn(struct pt_regs *regs)
295 err |= restore_fpu_state(regs, fpu_save); 295 err |= restore_fpu_state(regs, fpu_save);
296 296
297 err |= __copy_from_user(&set, &sf->mask, sizeof(sigset_t)); 297 err |= __copy_from_user(&set, &sf->mask, sizeof(sigset_t));
298 err |= do_sigaltstack(&sf->stack, NULL, (unsigned long)sf); 298 if (err || do_sigaltstack(&sf->stack, NULL, (unsigned long)sf) == -EFAULT)
299
300 if (err)
301 goto segv; 299 goto segv;
302 300
303 err |= __get_user(rwin_save, &sf->rwin_save); 301 err |= __get_user(rwin_save, &sf->rwin_save);
diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
index 781bcb10b8b..d94b878577b 100644
--- a/arch/sparc/kernel/smp_64.c
+++ b/arch/sparc/kernel/smp_64.c
@@ -852,6 +852,8 @@ extern unsigned long xcall_flush_tlb_mm;
852extern unsigned long xcall_flush_tlb_pending; 852extern unsigned long xcall_flush_tlb_pending;
853extern unsigned long xcall_flush_tlb_kernel_range; 853extern unsigned long xcall_flush_tlb_kernel_range;
854extern unsigned long xcall_fetch_glob_regs; 854extern unsigned long xcall_fetch_glob_regs;
855extern unsigned long xcall_fetch_glob_pmu;
856extern unsigned long xcall_fetch_glob_pmu_n4;
855extern unsigned long xcall_receive_signal; 857extern unsigned long xcall_receive_signal;
856extern unsigned long xcall_new_mmu_context_version; 858extern unsigned long xcall_new_mmu_context_version;
857#ifdef CONFIG_KGDB 859#ifdef CONFIG_KGDB
@@ -1000,6 +1002,15 @@ void smp_fetch_global_regs(void)
1000 smp_cross_call(&xcall_fetch_glob_regs, 0, 0, 0); 1002 smp_cross_call(&xcall_fetch_glob_regs, 0, 0, 0);
1001} 1003}
1002 1004
1005void smp_fetch_global_pmu(void)
1006{
1007 if (tlb_type == hypervisor &&
1008 sun4v_chip_type >= SUN4V_CHIP_NIAGARA4)
1009 smp_cross_call(&xcall_fetch_glob_pmu_n4, 0, 0, 0);
1010 else
1011 smp_cross_call(&xcall_fetch_glob_pmu, 0, 0, 0);
1012}
1013
1003/* We know that the window frames of the user have been flushed 1014/* We know that the window frames of the user have been flushed
1004 * to the stack before we get here because all callers of us 1015 * to the stack before we get here because all callers of us
1005 * are flush_tlb_*() routines, and these run after flush_cache_*() 1016 * are flush_tlb_*() routines, and these run after flush_cache_*()
diff --git a/arch/sparc/kernel/sys_sparc32.c b/arch/sparc/kernel/sys_sparc32.c
index c3239811a1b..03c7e929ec3 100644
--- a/arch/sparc/kernel/sys_sparc32.c
+++ b/arch/sparc/kernel/sys_sparc32.c
@@ -396,42 +396,6 @@ asmlinkage long compat_sys_rt_sigaction(int sig,
396 return ret; 396 return ret;
397} 397}
398 398
399/*
400 * sparc32_execve() executes a new program after the asm stub has set
401 * things up for us. This should basically do what I want it to.
402 */
403asmlinkage long sparc32_execve(struct pt_regs *regs)
404{
405 int error, base = 0;
406 struct filename *filename;
407
408 /* User register window flush is done by entry.S */
409
410 /* Check for indirect call. */
411 if ((u32)regs->u_regs[UREG_G1] == 0)
412 base = 1;
413
414 filename = getname(compat_ptr(regs->u_regs[base + UREG_I0]));
415 error = PTR_ERR(filename);
416 if (IS_ERR(filename))
417 goto out;
418
419 error = compat_do_execve(filename->name,
420 compat_ptr(regs->u_regs[base + UREG_I1]),
421 compat_ptr(regs->u_regs[base + UREG_I2]), regs);
422
423 putname(filename);
424
425 if (!error) {
426 fprs_write(0);
427 current_thread_info()->xfsr[0] = 0;
428 current_thread_info()->fpsaved[0] = 0;
429 regs->tstate &= ~TSTATE_PEF;
430 }
431out:
432 return error;
433}
434
435#ifdef CONFIG_MODULES 399#ifdef CONFIG_MODULES
436 400
437asmlinkage long sys32_init_module(void __user *umod, u32 len, 401asmlinkage long sys32_init_module(void __user *umod, u32 len,
diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
index 0c9b31b22e0..a8e6eb0a11d 100644
--- a/arch/sparc/kernel/sys_sparc_32.c
+++ b/arch/sparc/kernel/sys_sparc_32.c
@@ -258,27 +258,3 @@ out:
258 up_read(&uts_sem); 258 up_read(&uts_sem);
259 return err; 259 return err;
260} 260}
261
262/*
263 * Do a system call from kernel instead of calling sys_execve so we
264 * end up with proper pt_regs.
265 */
266int kernel_execve(const char *filename,
267 const char *const argv[],
268 const char *const envp[])
269{
270 long __res;
271 register long __g1 __asm__ ("g1") = __NR_execve;
272 register long __o0 __asm__ ("o0") = (long)(filename);
273 register long __o1 __asm__ ("o1") = (long)(argv);
274 register long __o2 __asm__ ("o2") = (long)(envp);
275 asm volatile ("t 0x10\n\t"
276 "bcc 1f\n\t"
277 "mov %%o0, %0\n\t"
278 "sub %%g0, %%o0, %0\n\t"
279 "1:\n\t"
280 : "=r" (__res), "=&r" (__o0)
281 : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__g1)
282 : "cc");
283 return __res;
284}
diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
index 11c6c9603e7..51b85feb8b9 100644
--- a/arch/sparc/kernel/sys_sparc_64.c
+++ b/arch/sparc/kernel/sys_sparc_64.c
@@ -730,24 +730,7 @@ SYSCALL_DEFINE5(rt_sigaction, int, sig, const struct sigaction __user *, act,
730 return ret; 730 return ret;
731} 731}
732 732
733/* 733asmlinkage long sys_kern_features(void)
734 * Do a system call from kernel instead of calling sys_execve so we
735 * end up with proper pt_regs.
736 */
737int kernel_execve(const char *filename,
738 const char *const argv[],
739 const char *const envp[])
740{ 734{
741 long __res; 735 return KERN_FEATURE_MIXED_MODE_STACK;
742 register long __g1 __asm__ ("g1") = __NR_execve;
743 register long __o0 __asm__ ("o0") = (long)(filename);
744 register long __o1 __asm__ ("o1") = (long)(argv);
745 register long __o2 __asm__ ("o2") = (long)(envp);
746 asm volatile ("t 0x6d\n\t"
747 "sub %%g0, %%o0, %0\n\t"
748 "movcc %%xcc, %%o0, %0\n\t"
749 : "=r" (__res), "=&r" (__o0)
750 : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__g1)
751 : "cc");
752 return __res;
753} 736}
diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
index 7f5f65d0b3f..2ef41e67f0b 100644
--- a/arch/sparc/kernel/syscalls.S
+++ b/arch/sparc/kernel/syscalls.S
@@ -1,23 +1,19 @@
1 /* SunOS's execv() call only specifies the argv argument, the 1 /* SunOS's execv() call only specifies the argv argument, the
2 * environment settings are the same as the calling processes. 2 * environment settings are the same as the calling processes.
3 */ 3 */
4sys_execve: 4sys64_execve:
5 sethi %hi(sparc_execve), %g1 5 set sys_execve, %g1
6 ba,pt %xcc, execve_merge 6 jmpl %g1, %g0
7 or %g1, %lo(sparc_execve), %g1 7 flushw
8 8
9#ifdef CONFIG_COMPAT 9#ifdef CONFIG_COMPAT
10sunos_execv: 10sunos_execv:
11 stx %g0, [%sp + PTREGS_OFF + PT_V9_I2] 11 mov %g0, %o2
12sys32_execve: 12sys32_execve:
13 sethi %hi(sparc32_execve), %g1 13 set compat_sys_execve, %g1
14 or %g1, %lo(sparc32_execve), %g1
15#endif
16
17execve_merge:
18 flushw
19 jmpl %g1, %g0 14 jmpl %g1, %g0
20 add %sp, PTREGS_OFF, %o0 15 flushw
16#endif
21 17
22 .align 32 18 .align 32
23sys_sparc_pipe: 19sys_sparc_pipe:
@@ -112,11 +108,16 @@ sys_clone:
112ret_from_syscall: 108ret_from_syscall:
113 /* Clear current_thread_info()->new_child. */ 109 /* Clear current_thread_info()->new_child. */
114 stb %g0, [%g6 + TI_NEW_CHILD] 110 stb %g0, [%g6 + TI_NEW_CHILD]
115 ldx [%g6 + TI_FLAGS], %l0
116 call schedule_tail 111 call schedule_tail
117 mov %g7, %o0 112 mov %g7, %o0
113 ldx [%sp + PTREGS_OFF + PT_V9_I0], %o0
114 brnz,pt %o0, ret_sys_call
115 ldx [%g6 + TI_FLAGS], %l0
116 ldx [%sp + PTREGS_OFF + PT_V9_G1], %l1
117 call %l1
118 ldx [%sp + PTREGS_OFF + PT_V9_G2], %o0
118 ba,pt %xcc, ret_sys_call 119 ba,pt %xcc, ret_sys_call
119 ldx [%sp + PTREGS_OFF + PT_V9_I0], %o0 120 mov 0, %o0
120 121
121 .globl sparc_exit 122 .globl sparc_exit
122 .type sparc_exit,#function 123 .type sparc_exit,#function
@@ -222,7 +223,6 @@ ret_sys_call:
222 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc 223 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
223 224
2242: 2252:
225 stb %g0, [%g6 + TI_SYS_NOERROR]
226 /* System call success, clear Carry condition code. */ 226 /* System call success, clear Carry condition code. */
227 andn %g3, %g2, %g3 227 andn %g3, %g2, %g3
2283: 2283:
diff --git a/arch/sparc/kernel/systbls_32.S b/arch/sparc/kernel/systbls_32.S
index 63402f9e9f5..5147f574f12 100644
--- a/arch/sparc/kernel/systbls_32.S
+++ b/arch/sparc/kernel/systbls_32.S
@@ -85,3 +85,4 @@ sys_call_table:
85/*325*/ .long sys_pwritev, sys_rt_tgsigqueueinfo, sys_perf_event_open, sys_recvmmsg, sys_fanotify_init 85/*325*/ .long sys_pwritev, sys_rt_tgsigqueueinfo, sys_perf_event_open, sys_recvmmsg, sys_fanotify_init
86/*330*/ .long sys_fanotify_mark, sys_prlimit64, sys_name_to_handle_at, sys_open_by_handle_at, sys_clock_adjtime 86/*330*/ .long sys_fanotify_mark, sys_prlimit64, sys_name_to_handle_at, sys_open_by_handle_at, sys_clock_adjtime
87/*335*/ .long sys_syncfs, sys_sendmmsg, sys_setns, sys_process_vm_readv, sys_process_vm_writev 87/*335*/ .long sys_syncfs, sys_sendmmsg, sys_setns, sys_process_vm_readv, sys_process_vm_writev
88/*340*/ .long sys_ni_syscall, sys_kcmp
diff --git a/arch/sparc/kernel/systbls_64.S b/arch/sparc/kernel/systbls_64.S
index 3a58e0d66f5..ebb7f5fc58f 100644
--- a/arch/sparc/kernel/systbls_64.S
+++ b/arch/sparc/kernel/systbls_64.S
@@ -86,6 +86,7 @@ sys_call_table32:
86 .word compat_sys_pwritev, compat_sys_rt_tgsigqueueinfo, sys_perf_event_open, compat_sys_recvmmsg, sys_fanotify_init 86 .word compat_sys_pwritev, compat_sys_rt_tgsigqueueinfo, sys_perf_event_open, compat_sys_recvmmsg, sys_fanotify_init
87/*330*/ .word sys32_fanotify_mark, sys_prlimit64, sys_name_to_handle_at, compat_sys_open_by_handle_at, compat_sys_clock_adjtime 87/*330*/ .word sys32_fanotify_mark, sys_prlimit64, sys_name_to_handle_at, compat_sys_open_by_handle_at, compat_sys_clock_adjtime
88 .word sys_syncfs, compat_sys_sendmmsg, sys_setns, compat_sys_process_vm_readv, compat_sys_process_vm_writev 88 .word sys_syncfs, compat_sys_sendmmsg, sys_setns, compat_sys_process_vm_readv, compat_sys_process_vm_writev
89/*340*/ .word sys_kern_features, sys_kcmp
89 90
90#endif /* CONFIG_COMPAT */ 91#endif /* CONFIG_COMPAT */
91 92
@@ -106,7 +107,7 @@ sys_call_table:
106/*40*/ .word sys_newlstat, sys_dup, sys_sparc_pipe, sys_times, sys_nis_syscall 107/*40*/ .word sys_newlstat, sys_dup, sys_sparc_pipe, sys_times, sys_nis_syscall
107 .word sys_umount, sys_setgid, sys_getgid, sys_signal, sys_geteuid 108 .word sys_umount, sys_setgid, sys_getgid, sys_signal, sys_geteuid
108/*50*/ .word sys_getegid, sys_acct, sys_memory_ordering, sys_nis_syscall, sys_ioctl 109/*50*/ .word sys_getegid, sys_acct, sys_memory_ordering, sys_nis_syscall, sys_ioctl
109 .word sys_reboot, sys_nis_syscall, sys_symlink, sys_readlink, sys_execve 110 .word sys_reboot, sys_nis_syscall, sys_symlink, sys_readlink, sys64_execve
110/*60*/ .word sys_umask, sys_chroot, sys_newfstat, sys_fstat64, sys_getpagesize 111/*60*/ .word sys_umask, sys_chroot, sys_newfstat, sys_fstat64, sys_getpagesize
111 .word sys_msync, sys_vfork, sys_pread64, sys_pwrite64, sys_nis_syscall 112 .word sys_msync, sys_vfork, sys_pread64, sys_pwrite64, sys_nis_syscall
112/*70*/ .word sys_nis_syscall, sys_mmap, sys_nis_syscall, sys_64_munmap, sys_mprotect 113/*70*/ .word sys_nis_syscall, sys_mmap, sys_nis_syscall, sys_64_munmap, sys_mprotect
@@ -163,3 +164,4 @@ sys_call_table:
163 .word sys_pwritev, sys_rt_tgsigqueueinfo, sys_perf_event_open, sys_recvmmsg, sys_fanotify_init 164 .word sys_pwritev, sys_rt_tgsigqueueinfo, sys_perf_event_open, sys_recvmmsg, sys_fanotify_init
164/*330*/ .word sys_fanotify_mark, sys_prlimit64, sys_name_to_handle_at, sys_open_by_handle_at, sys_clock_adjtime 165/*330*/ .word sys_fanotify_mark, sys_prlimit64, sys_name_to_handle_at, sys_open_by_handle_at, sys_clock_adjtime
165 .word sys_syncfs, sys_sendmmsg, sys_setns, sys_process_vm_readv, sys_process_vm_writev 166 .word sys_syncfs, sys_sendmmsg, sys_setns, sys_process_vm_readv, sys_process_vm_writev
167/*340*/ .word sys_kern_features, sys_kcmp
diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
index b66a77968f3..e7ecf1507d9 100644
--- a/arch/sparc/kernel/traps_64.c
+++ b/arch/sparc/kernel/traps_64.c
@@ -2688,8 +2688,8 @@ void __init trap_init(void)
2688 TI_PRE_COUNT != offsetof(struct thread_info, 2688 TI_PRE_COUNT != offsetof(struct thread_info,
2689 preempt_count) || 2689 preempt_count) ||
2690 TI_NEW_CHILD != offsetof(struct thread_info, new_child) || 2690 TI_NEW_CHILD != offsetof(struct thread_info, new_child) ||
2691 TI_SYS_NOERROR != offsetof(struct thread_info, 2691 TI_CURRENT_DS != offsetof(struct thread_info,
2692 syscall_noerror) || 2692 current_ds) ||
2693 TI_RESTART_BLOCK != offsetof(struct thread_info, 2693 TI_RESTART_BLOCK != offsetof(struct thread_info,
2694 restart_block) || 2694 restart_block) ||
2695 TI_KUNA_REGS != offsetof(struct thread_info, 2695 TI_KUNA_REGS != offsetof(struct thread_info,
diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
index f81d038f734..8201c25e766 100644
--- a/arch/sparc/kernel/unaligned_64.c
+++ b/arch/sparc/kernel/unaligned_64.c
@@ -113,21 +113,24 @@ static inline long sign_extend_imm13(long imm)
113 113
114static unsigned long fetch_reg(unsigned int reg, struct pt_regs *regs) 114static unsigned long fetch_reg(unsigned int reg, struct pt_regs *regs)
115{ 115{
116 unsigned long value; 116 unsigned long value, fp;
117 117
118 if (reg < 16) 118 if (reg < 16)
119 return (!reg ? 0 : regs->u_regs[reg]); 119 return (!reg ? 0 : regs->u_regs[reg]);
120
121 fp = regs->u_regs[UREG_FP];
122
120 if (regs->tstate & TSTATE_PRIV) { 123 if (regs->tstate & TSTATE_PRIV) {
121 struct reg_window *win; 124 struct reg_window *win;
122 win = (struct reg_window *)(regs->u_regs[UREG_FP] + STACK_BIAS); 125 win = (struct reg_window *)(fp + STACK_BIAS);
123 value = win->locals[reg - 16]; 126 value = win->locals[reg - 16];
124 } else if (test_thread_flag(TIF_32BIT)) { 127 } else if (!test_thread_64bit_stack(fp)) {
125 struct reg_window32 __user *win32; 128 struct reg_window32 __user *win32;
126 win32 = (struct reg_window32 __user *)((unsigned long)((u32)regs->u_regs[UREG_FP])); 129 win32 = (struct reg_window32 __user *)((unsigned long)((u32)fp));
127 get_user(value, &win32->locals[reg - 16]); 130 get_user(value, &win32->locals[reg - 16]);
128 } else { 131 } else {
129 struct reg_window __user *win; 132 struct reg_window __user *win;
130 win = (struct reg_window __user *)(regs->u_regs[UREG_FP] + STACK_BIAS); 133 win = (struct reg_window __user *)(fp + STACK_BIAS);
131 get_user(value, &win->locals[reg - 16]); 134 get_user(value, &win->locals[reg - 16]);
132 } 135 }
133 return value; 136 return value;
@@ -135,19 +138,24 @@ static unsigned long fetch_reg(unsigned int reg, struct pt_regs *regs)
135 138
136static unsigned long *fetch_reg_addr(unsigned int reg, struct pt_regs *regs) 139static unsigned long *fetch_reg_addr(unsigned int reg, struct pt_regs *regs)
137{ 140{
141 unsigned long fp;
142
138 if (reg < 16) 143 if (reg < 16)
139 return &regs->u_regs[reg]; 144 return &regs->u_regs[reg];
145
146 fp = regs->u_regs[UREG_FP];
147
140 if (regs->tstate & TSTATE_PRIV) { 148 if (regs->tstate & TSTATE_PRIV) {
141 struct reg_window *win; 149 struct reg_window *win;
142 win = (struct reg_window *)(regs->u_regs[UREG_FP] + STACK_BIAS); 150 win = (struct reg_window *)(fp + STACK_BIAS);
143 return &win->locals[reg - 16]; 151 return &win->locals[reg - 16];
144 } else if (test_thread_flag(TIF_32BIT)) { 152 } else if (!test_thread_64bit_stack(fp)) {
145 struct reg_window32 *win32; 153 struct reg_window32 *win32;
146 win32 = (struct reg_window32 *)((unsigned long)((u32)regs->u_regs[UREG_FP])); 154 win32 = (struct reg_window32 *)((unsigned long)((u32)fp));
147 return (unsigned long *)&win32->locals[reg - 16]; 155 return (unsigned long *)&win32->locals[reg - 16];
148 } else { 156 } else {
149 struct reg_window *win; 157 struct reg_window *win;
150 win = (struct reg_window *)(regs->u_regs[UREG_FP] + STACK_BIAS); 158 win = (struct reg_window *)(fp + STACK_BIAS);
151 return &win->locals[reg - 16]; 159 return &win->locals[reg - 16];
152 } 160 }
153} 161}
@@ -392,13 +400,15 @@ int handle_popc(u32 insn, struct pt_regs *regs)
392 if (rd) 400 if (rd)
393 regs->u_regs[rd] = ret; 401 regs->u_regs[rd] = ret;
394 } else { 402 } else {
395 if (test_thread_flag(TIF_32BIT)) { 403 unsigned long fp = regs->u_regs[UREG_FP];
404
405 if (!test_thread_64bit_stack(fp)) {
396 struct reg_window32 __user *win32; 406 struct reg_window32 __user *win32;
397 win32 = (struct reg_window32 __user *)((unsigned long)((u32)regs->u_regs[UREG_FP])); 407 win32 = (struct reg_window32 __user *)((unsigned long)((u32)fp));
398 put_user(ret, &win32->locals[rd - 16]); 408 put_user(ret, &win32->locals[rd - 16]);
399 } else { 409 } else {
400 struct reg_window __user *win; 410 struct reg_window __user *win;
401 win = (struct reg_window __user *)(regs->u_regs[UREG_FP] + STACK_BIAS); 411 win = (struct reg_window __user *)(fp + STACK_BIAS);
402 put_user(ret, &win->locals[rd - 16]); 412 put_user(ret, &win->locals[rd - 16]);
403 } 413 }
404 } 414 }
@@ -554,7 +564,7 @@ void handle_ld_nf(u32 insn, struct pt_regs *regs)
554 reg[0] = 0; 564 reg[0] = 0;
555 if ((insn & 0x780000) == 0x180000) 565 if ((insn & 0x780000) == 0x180000)
556 reg[1] = 0; 566 reg[1] = 0;
557 } else if (test_thread_flag(TIF_32BIT)) { 567 } else if (!test_thread_64bit_stack(regs->u_regs[UREG_FP])) {
558 put_user(0, (int __user *) reg); 568 put_user(0, (int __user *) reg);
559 if ((insn & 0x780000) == 0x180000) 569 if ((insn & 0x780000) == 0x180000)
560 put_user(0, ((int __user *) reg) + 1); 570 put_user(0, ((int __user *) reg) + 1);
diff --git a/arch/sparc/kernel/visemul.c b/arch/sparc/kernel/visemul.c
index 08e074b7eb6..c096c624ac4 100644
--- a/arch/sparc/kernel/visemul.c
+++ b/arch/sparc/kernel/visemul.c
@@ -149,21 +149,24 @@ static inline void maybe_flush_windows(unsigned int rs1, unsigned int rs2,
149 149
150static unsigned long fetch_reg(unsigned int reg, struct pt_regs *regs) 150static unsigned long fetch_reg(unsigned int reg, struct pt_regs *regs)
151{ 151{
152 unsigned long value; 152 unsigned long value, fp;
153 153
154 if (reg < 16) 154 if (reg < 16)
155 return (!reg ? 0 : regs->u_regs[reg]); 155 return (!reg ? 0 : regs->u_regs[reg]);
156
157 fp = regs->u_regs[UREG_FP];
158
156 if (regs->tstate & TSTATE_PRIV) { 159 if (regs->tstate & TSTATE_PRIV) {
157 struct reg_window *win; 160 struct reg_window *win;
158 win = (struct reg_window *)(regs->u_regs[UREG_FP] + STACK_BIAS); 161 win = (struct reg_window *)(fp + STACK_BIAS);
159 value = win->locals[reg - 16]; 162 value = win->locals[reg - 16];
160 } else if (test_thread_flag(TIF_32BIT)) { 163 } else if (!test_thread_64bit_stack(fp)) {
161 struct reg_window32 __user *win32; 164 struct reg_window32 __user *win32;
162 win32 = (struct reg_window32 __user *)((unsigned long)((u32)regs->u_regs[UREG_FP])); 165 win32 = (struct reg_window32 __user *)((unsigned long)((u32)fp));
163 get_user(value, &win32->locals[reg - 16]); 166 get_user(value, &win32->locals[reg - 16]);
164 } else { 167 } else {
165 struct reg_window __user *win; 168 struct reg_window __user *win;
166 win = (struct reg_window __user *)(regs->u_regs[UREG_FP] + STACK_BIAS); 169 win = (struct reg_window __user *)(fp + STACK_BIAS);
167 get_user(value, &win->locals[reg - 16]); 170 get_user(value, &win->locals[reg - 16]);
168 } 171 }
169 return value; 172 return value;
@@ -172,16 +175,18 @@ static unsigned long fetch_reg(unsigned int reg, struct pt_regs *regs)
172static inline unsigned long __user *__fetch_reg_addr_user(unsigned int reg, 175static inline unsigned long __user *__fetch_reg_addr_user(unsigned int reg,
173 struct pt_regs *regs) 176 struct pt_regs *regs)
174{ 177{
178 unsigned long fp = regs->u_regs[UREG_FP];
179
175 BUG_ON(reg < 16); 180 BUG_ON(reg < 16);
176 BUG_ON(regs->tstate & TSTATE_PRIV); 181 BUG_ON(regs->tstate & TSTATE_PRIV);
177 182
178 if (test_thread_flag(TIF_32BIT)) { 183 if (!test_thread_64bit_stack(fp)) {
179 struct reg_window32 __user *win32; 184 struct reg_window32 __user *win32;
180 win32 = (struct reg_window32 __user *)((unsigned long)((u32)regs->u_regs[UREG_FP])); 185 win32 = (struct reg_window32 __user *)((unsigned long)((u32)fp));
181 return (unsigned long __user *)&win32->locals[reg - 16]; 186 return (unsigned long __user *)&win32->locals[reg - 16];
182 } else { 187 } else {
183 struct reg_window __user *win; 188 struct reg_window __user *win;
184 win = (struct reg_window __user *)(regs->u_regs[UREG_FP] + STACK_BIAS); 189 win = (struct reg_window __user *)(fp + STACK_BIAS);
185 return &win->locals[reg - 16]; 190 return &win->locals[reg - 16];
186 } 191 }
187} 192}
@@ -204,7 +209,7 @@ static void store_reg(struct pt_regs *regs, unsigned long val, unsigned long rd)
204 } else { 209 } else {
205 unsigned long __user *rd_user = __fetch_reg_addr_user(rd, regs); 210 unsigned long __user *rd_user = __fetch_reg_addr_user(rd, regs);
206 211
207 if (test_thread_flag(TIF_32BIT)) 212 if (!test_thread_64bit_stack(regs->u_regs[UREG_FP]))
208 __put_user((u32)val, (u32 __user *)rd_user); 213 __put_user((u32)val, (u32 __user *)rd_user);
209 else 214 else
210 __put_user(val, rd_user); 215 __put_user(val, rd_user);
diff --git a/arch/sparc/kernel/vmlinux.lds.S b/arch/sparc/kernel/vmlinux.lds.S
index 89c2c29f154..0bacceb1915 100644
--- a/arch/sparc/kernel/vmlinux.lds.S
+++ b/arch/sparc/kernel/vmlinux.lds.S
@@ -132,6 +132,11 @@ SECTIONS
132 *(.popc_6insn_patch) 132 *(.popc_6insn_patch)
133 __popc_6insn_patch_end = .; 133 __popc_6insn_patch_end = .;
134 } 134 }
135 .pause_3insn_patch : {
136 __pause_3insn_patch = .;
137 *(.pause_3insn_patch)
138 __pause_3insn_patch_end = .;
139 }
135 PERCPU_SECTION(SMP_CACHE_BYTES) 140 PERCPU_SECTION(SMP_CACHE_BYTES)
136 141
137 . = ALIGN(PAGE_SIZE); 142 . = ALIGN(PAGE_SIZE);
diff --git a/arch/sparc/kernel/winfixup.S b/arch/sparc/kernel/winfixup.S
index a6b0863c27d..1e67ce95836 100644
--- a/arch/sparc/kernel/winfixup.S
+++ b/arch/sparc/kernel/winfixup.S
@@ -43,6 +43,8 @@ spill_fixup_mna:
43spill_fixup_dax: 43spill_fixup_dax:
44 TRAP_LOAD_THREAD_REG(%g6, %g1) 44 TRAP_LOAD_THREAD_REG(%g6, %g1)
45 ldx [%g6 + TI_FLAGS], %g1 45 ldx [%g6 + TI_FLAGS], %g1
46 andcc %sp, 0x1, %g0
47 movne %icc, 0, %g1
46 andcc %g1, _TIF_32BIT, %g0 48 andcc %g1, _TIF_32BIT, %g0
47 ldub [%g6 + TI_WSAVED], %g1 49 ldub [%g6 + TI_WSAVED], %g1
48 sll %g1, 3, %g3 50 sll %g1, 3, %g3
diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S
index 4d502da3de7..85c233d0a34 100644
--- a/arch/sparc/lib/atomic_64.S
+++ b/arch/sparc/lib/atomic_64.S
@@ -1,6 +1,6 @@
1/* atomic.S: These things are too big to do inline. 1/* atomic.S: These things are too big to do inline.
2 * 2 *
3 * Copyright (C) 1999, 2007 David S. Miller (davem@davemloft.net) 3 * Copyright (C) 1999, 2007 2012 David S. Miller (davem@davemloft.net)
4 */ 4 */
5 5
6#include <linux/linkage.h> 6#include <linux/linkage.h>
@@ -117,3 +117,17 @@ ENTRY(atomic64_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
117 sub %g1, %o0, %o0 117 sub %g1, %o0, %o0
1182: BACKOFF_SPIN(%o2, %o3, 1b) 1182: BACKOFF_SPIN(%o2, %o3, 1b)
119ENDPROC(atomic64_sub_ret) 119ENDPROC(atomic64_sub_ret)
120
121ENTRY(atomic64_dec_if_positive) /* %o0 = atomic_ptr */
122 BACKOFF_SETUP(%o2)
1231: ldx [%o0], %g1
124 brlez,pn %g1, 3f
125 sub %g1, 1, %g7
126 casx [%o0], %g1, %g7
127 cmp %g1, %g7
128 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
129 nop
1303: retl
131 sub %g1, 1, %o0
1322: BACKOFF_SPIN(%o2, %o3, 1b)
133ENDPROC(atomic64_dec_if_positive)
diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
index ee31b884c61..0c4e35e522f 100644
--- a/arch/sparc/lib/ksyms.c
+++ b/arch/sparc/lib/ksyms.c
@@ -116,6 +116,7 @@ EXPORT_SYMBOL(atomic64_add);
116EXPORT_SYMBOL(atomic64_add_ret); 116EXPORT_SYMBOL(atomic64_add_ret);
117EXPORT_SYMBOL(atomic64_sub); 117EXPORT_SYMBOL(atomic64_sub);
118EXPORT_SYMBOL(atomic64_sub_ret); 118EXPORT_SYMBOL(atomic64_sub_ret);
119EXPORT_SYMBOL(atomic64_dec_if_positive);
119 120
120/* Atomic bit operations. */ 121/* Atomic bit operations. */
121EXPORT_SYMBOL(test_and_set_bit); 122EXPORT_SYMBOL(test_and_set_bit);
diff --git a/arch/sparc/math-emu/math_64.c b/arch/sparc/math-emu/math_64.c
index 1704068da92..034aadbff03 100644
--- a/arch/sparc/math-emu/math_64.c
+++ b/arch/sparc/math-emu/math_64.c
@@ -320,7 +320,7 @@ int do_mathemu(struct pt_regs *regs, struct fpustate *f, bool illegal_insn_trap)
320 XR = 0; 320 XR = 0;
321 else if (freg < 16) 321 else if (freg < 16)
322 XR = regs->u_regs[freg]; 322 XR = regs->u_regs[freg];
323 else if (test_thread_flag(TIF_32BIT)) { 323 else if (!test_thread_64bit_stack(regs->u_regs[UREG_FP])) {
324 struct reg_window32 __user *win32; 324 struct reg_window32 __user *win32;
325 flushw_user (); 325 flushw_user ();
326 win32 = (struct reg_window32 __user *)((unsigned long)((u32)regs->u_regs[UREG_FP])); 326 win32 = (struct reg_window32 __user *)((unsigned long)((u32)regs->u_regs[UREG_FP]));
diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
index 9e28a118e6a..85be1ca539b 100644
--- a/arch/sparc/mm/init_64.c
+++ b/arch/sparc/mm/init_64.c
@@ -624,7 +624,7 @@ static void __init inherit_prom_mappings(void)
624void prom_world(int enter) 624void prom_world(int enter)
625{ 625{
626 if (!enter) 626 if (!enter)
627 set_fs((mm_segment_t) { get_thread_current_ds() }); 627 set_fs(get_fs());
628 628
629 __asm__ __volatile__("flushw"); 629 __asm__ __volatile__("flushw");
630} 630}
diff --git a/arch/sparc/mm/ultra.S b/arch/sparc/mm/ultra.S
index 874162a11ce..f8e13d421fc 100644
--- a/arch/sparc/mm/ultra.S
+++ b/arch/sparc/mm/ultra.S
@@ -481,8 +481,8 @@ xcall_sync_tick:
481 481
482 .globl xcall_fetch_glob_regs 482 .globl xcall_fetch_glob_regs
483xcall_fetch_glob_regs: 483xcall_fetch_glob_regs:
484 sethi %hi(global_reg_snapshot), %g1 484 sethi %hi(global_cpu_snapshot), %g1
485 or %g1, %lo(global_reg_snapshot), %g1 485 or %g1, %lo(global_cpu_snapshot), %g1
486 __GET_CPUID(%g2) 486 __GET_CPUID(%g2)
487 sllx %g2, 6, %g3 487 sllx %g2, 6, %g3
488 add %g1, %g3, %g1 488 add %g1, %g3, %g1
@@ -509,6 +509,66 @@ xcall_fetch_glob_regs:
509 stx %g3, [%g1 + GR_SNAP_THREAD] 509 stx %g3, [%g1 + GR_SNAP_THREAD]
510 retry 510 retry
511 511
512 .globl xcall_fetch_glob_pmu
513xcall_fetch_glob_pmu:
514 sethi %hi(global_cpu_snapshot), %g1
515 or %g1, %lo(global_cpu_snapshot), %g1
516 __GET_CPUID(%g2)
517 sllx %g2, 6, %g3
518 add %g1, %g3, %g1
519 rd %pic, %g7
520 stx %g7, [%g1 + (4 * 8)]
521 rd %pcr, %g7
522 stx %g7, [%g1 + (0 * 8)]
523 retry
524
525 .globl xcall_fetch_glob_pmu_n4
526xcall_fetch_glob_pmu_n4:
527 sethi %hi(global_cpu_snapshot), %g1
528 or %g1, %lo(global_cpu_snapshot), %g1
529 __GET_CPUID(%g2)
530 sllx %g2, 6, %g3
531 add %g1, %g3, %g1
532
533 ldxa [%g0] ASI_PIC, %g7
534 stx %g7, [%g1 + (4 * 8)]
535 mov 0x08, %g3
536 ldxa [%g3] ASI_PIC, %g7
537 stx %g7, [%g1 + (5 * 8)]
538 mov 0x10, %g3
539 ldxa [%g3] ASI_PIC, %g7
540 stx %g7, [%g1 + (6 * 8)]
541 mov 0x18, %g3
542 ldxa [%g3] ASI_PIC, %g7
543 stx %g7, [%g1 + (7 * 8)]
544
545 mov %o0, %g2
546 mov %o1, %g3
547 mov %o5, %g7
548
549 mov HV_FAST_VT_GET_PERFREG, %o5
550 mov 3, %o0
551 ta HV_FAST_TRAP
552 stx %o1, [%g1 + (3 * 8)]
553 mov HV_FAST_VT_GET_PERFREG, %o5
554 mov 2, %o0
555 ta HV_FAST_TRAP
556 stx %o1, [%g1 + (2 * 8)]
557 mov HV_FAST_VT_GET_PERFREG, %o5
558 mov 1, %o0
559 ta HV_FAST_TRAP
560 stx %o1, [%g1 + (1 * 8)]
561 mov HV_FAST_VT_GET_PERFREG, %o5
562 mov 0, %o0
563 ta HV_FAST_TRAP
564 stx %o1, [%g1 + (0 * 8)]
565
566 mov %g2, %o0
567 mov %g3, %o1
568 mov %g7, %o5
569
570 retry
571
512#ifdef DCACHE_ALIASING_POSSIBLE 572#ifdef DCACHE_ALIASING_POSSIBLE
513 .align 32 573 .align 32
514 .globl xcall_flush_dcache_page_cheetah 574 .globl xcall_flush_dcache_page_cheetah
diff --git a/arch/tile/Kconfig b/arch/tile/Kconfig
index 875d008828b..ea7f61e8bc9 100644
--- a/arch/tile/Kconfig
+++ b/arch/tile/Kconfig
@@ -21,6 +21,8 @@ config TILE
21 select ARCH_HAVE_NMI_SAFE_CMPXCHG 21 select ARCH_HAVE_NMI_SAFE_CMPXCHG
22 select GENERIC_CLOCKEVENTS 22 select GENERIC_CLOCKEVENTS
23 select MODULES_USE_ELF_RELA 23 select MODULES_USE_ELF_RELA
24 select GENERIC_KERNEL_THREAD
25 select GENERIC_KERNEL_EXECVE
24 26
25# FIXME: investigate whether we need/want these options. 27# FIXME: investigate whether we need/want these options.
26# select HAVE_IOREMAP_PROT 28# select HAVE_IOREMAP_PROT
diff --git a/arch/tile/Makefile b/arch/tile/Makefile
index 55640cf9259..3d15364c607 100644
--- a/arch/tile/Makefile
+++ b/arch/tile/Makefile
@@ -26,6 +26,10 @@ $(error Set TILERA_ROOT or CROSS_COMPILE when building $(ARCH) on $(HOST_ARCH))
26 endif 26 endif
27endif 27endif
28 28
29# The tile compiler may emit .eh_frame information for backtracing.
30# In kernel modules, this causes load failures due to unsupported relocations.
31KBUILD_CFLAGS += -fno-asynchronous-unwind-tables
32
29ifneq ($(CONFIG_DEBUG_EXTRA_FLAGS),"") 33ifneq ($(CONFIG_DEBUG_EXTRA_FLAGS),"")
30KBUILD_CFLAGS += $(CONFIG_DEBUG_EXTRA_FLAGS) 34KBUILD_CFLAGS += $(CONFIG_DEBUG_EXTRA_FLAGS)
31endif 35endif
diff --git a/arch/tile/include/arch/Kbuild b/arch/tile/include/arch/Kbuild
index e69de29bb2d..3751c9fabcf 100644
--- a/arch/tile/include/arch/Kbuild
+++ b/arch/tile/include/arch/Kbuild
@@ -0,0 +1 @@
# Tile arch headers
diff --git a/arch/tile/include/asm/Kbuild b/arch/tile/include/asm/Kbuild
index c68808a09da..6948015e08a 100644
--- a/arch/tile/include/asm/Kbuild
+++ b/arch/tile/include/asm/Kbuild
@@ -1,8 +1,6 @@
1 1
2header-y += ../arch/ 2header-y += ../arch/
3 3
4header-y += ucontext.h
5
6generic-y += bug.h 4generic-y += bug.h
7generic-y += bugs.h 5generic-y += bugs.h
8generic-y += clkdev.h 6generic-y += clkdev.h
@@ -37,5 +35,4 @@ generic-y += statfs.h
37generic-y += termbits.h 35generic-y += termbits.h
38generic-y += termios.h 36generic-y += termios.h
39generic-y += types.h 37generic-y += types.h
40generic-y += ucontext.h
41generic-y += xor.h 38generic-y += xor.h
diff --git a/arch/tile/include/asm/compat.h b/arch/tile/include/asm/compat.h
index 3063e6fc8da..ca61fb4296b 100644
--- a/arch/tile/include/asm/compat.h
+++ b/arch/tile/include/asm/compat.h
@@ -275,18 +275,14 @@ extern int compat_setup_rt_frame(int sig, struct k_sigaction *ka,
275struct compat_sigaction; 275struct compat_sigaction;
276struct compat_siginfo; 276struct compat_siginfo;
277struct compat_sigaltstack; 277struct compat_sigaltstack;
278long compat_sys_execve(const char __user *path,
279 compat_uptr_t __user *argv,
280 compat_uptr_t __user *envp, struct pt_regs *);
281long compat_sys_rt_sigaction(int sig, struct compat_sigaction __user *act, 278long compat_sys_rt_sigaction(int sig, struct compat_sigaction __user *act,
282 struct compat_sigaction __user *oact, 279 struct compat_sigaction __user *oact,
283 size_t sigsetsize); 280 size_t sigsetsize);
284long compat_sys_rt_sigqueueinfo(int pid, int sig, 281long compat_sys_rt_sigqueueinfo(int pid, int sig,
285 struct compat_siginfo __user *uinfo); 282 struct compat_siginfo __user *uinfo);
286long compat_sys_rt_sigreturn(struct pt_regs *); 283long compat_sys_rt_sigreturn(void);
287long compat_sys_sigaltstack(const struct compat_sigaltstack __user *uss_ptr, 284long compat_sys_sigaltstack(const struct compat_sigaltstack __user *uss_ptr,
288 struct compat_sigaltstack __user *uoss_ptr, 285 struct compat_sigaltstack __user *uoss_ptr);
289 struct pt_regs *);
290long compat_sys_truncate64(char __user *filename, u32 dummy, u32 low, u32 high); 286long compat_sys_truncate64(char __user *filename, u32 dummy, u32 low, u32 high);
291long compat_sys_ftruncate64(unsigned int fd, u32 dummy, u32 low, u32 high); 287long compat_sys_ftruncate64(unsigned int fd, u32 dummy, u32 low, u32 high);
292long compat_sys_pread64(unsigned int fd, char __user *ubuf, size_t count, 288long compat_sys_pread64(unsigned int fd, char __user *ubuf, size_t count,
@@ -303,12 +299,7 @@ long compat_sys_fallocate(int fd, int mode,
303long compat_sys_sched_rr_get_interval(compat_pid_t pid, 299long compat_sys_sched_rr_get_interval(compat_pid_t pid,
304 struct compat_timespec __user *interval); 300 struct compat_timespec __user *interval);
305 301
306/* These are the intvec_64.S trampolines. */ 302/* Assembly trampoline to avoid clobbering r0. */
307long _compat_sys_execve(const char __user *path,
308 const compat_uptr_t __user *argv,
309 const compat_uptr_t __user *envp);
310long _compat_sys_sigaltstack(const struct compat_sigaltstack __user *uss_ptr,
311 struct compat_sigaltstack __user *uoss_ptr);
312long _compat_sys_rt_sigreturn(void); 303long _compat_sys_rt_sigreturn(void);
313 304
314#endif /* _ASM_TILE_COMPAT_H */ 305#endif /* _ASM_TILE_COMPAT_H */
diff --git a/arch/tile/include/asm/elf.h b/arch/tile/include/asm/elf.h
index f8ccf08f693..b73e1039c91 100644
--- a/arch/tile/include/asm/elf.h
+++ b/arch/tile/include/asm/elf.h
@@ -148,6 +148,7 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
148#define compat_start_thread(regs, ip, usp) do { \ 148#define compat_start_thread(regs, ip, usp) do { \
149 regs->pc = ptr_to_compat_reg((void *)(ip)); \ 149 regs->pc = ptr_to_compat_reg((void *)(ip)); \
150 regs->sp = ptr_to_compat_reg((void *)(usp)); \ 150 regs->sp = ptr_to_compat_reg((void *)(usp)); \
151 single_step_execve(); \
151 } while (0) 152 } while (0)
152 153
153/* 154/*
diff --git a/arch/tile/include/asm/processor.h b/arch/tile/include/asm/processor.h
index 8c4dd9ff91e..879073e7658 100644
--- a/arch/tile/include/asm/processor.h
+++ b/arch/tile/include/asm/processor.h
@@ -211,6 +211,7 @@ static inline void start_thread(struct pt_regs *regs,
211{ 211{
212 regs->pc = pc; 212 regs->pc = pc;
213 regs->sp = usp; 213 regs->sp = usp;
214 single_step_execve();
214} 215}
215 216
216/* Free all resources held by a thread. */ 217/* Free all resources held by a thread. */
@@ -239,6 +240,9 @@ unsigned long get_wchan(struct task_struct *p);
239#define KSTK_TOP(task) (task_ksp0(task) - STACK_TOP_DELTA) 240#define KSTK_TOP(task) (task_ksp0(task) - STACK_TOP_DELTA)
240#define task_pt_regs(task) \ 241#define task_pt_regs(task) \
241 ((struct pt_regs *)(task_ksp0(task) - KSTK_PTREGS_GAP) - 1) 242 ((struct pt_regs *)(task_ksp0(task) - KSTK_PTREGS_GAP) - 1)
243#define current_pt_regs() \
244 ((struct pt_regs *)((stack_pointer | (THREAD_SIZE - 1)) - \
245 (KSTK_PTREGS_GAP - 1)) - 1)
242#define task_sp(task) (task_pt_regs(task)->sp) 246#define task_sp(task) (task_pt_regs(task)->sp)
243#define task_pc(task) (task_pt_regs(task)->pc) 247#define task_pc(task) (task_pt_regs(task)->pc)
244/* Aliases for pc and sp (used in fs/proc/array.c) */ 248/* Aliases for pc and sp (used in fs/proc/array.c) */
diff --git a/arch/tile/include/asm/switch_to.h b/arch/tile/include/asm/switch_to.h
index 1d48c5fee8b..b8f888cbe6b 100644
--- a/arch/tile/include/asm/switch_to.h
+++ b/arch/tile/include/asm/switch_to.h
@@ -68,7 +68,10 @@ extern unsigned long get_switch_to_pc(void);
68/* Support function for forking a new task. */ 68/* Support function for forking a new task. */
69void ret_from_fork(void); 69void ret_from_fork(void);
70 70
71/* Called from ret_from_fork() when a new process starts up. */ 71/* Support function for forking a new kernel thread. */
72void ret_from_kernel_thread(void *fn, void *arg);
73
74/* Called from ret_from_xxx() when a new process starts up. */
72struct task_struct *sim_notify_fork(struct task_struct *prev); 75struct task_struct *sim_notify_fork(struct task_struct *prev);
73 76
74#endif /* !__ASSEMBLY__ */ 77#endif /* !__ASSEMBLY__ */
diff --git a/arch/tile/include/asm/syscalls.h b/arch/tile/include/asm/syscalls.h
index 06f0464cfed..369696d63e7 100644
--- a/arch/tile/include/asm/syscalls.h
+++ b/arch/tile/include/asm/syscalls.h
@@ -51,8 +51,7 @@ long sys_cacheflush(unsigned long addr, unsigned long len,
51 51
52#ifndef __tilegx__ 52#ifndef __tilegx__
53/* mm/fault.c */ 53/* mm/fault.c */
54long sys_cmpxchg_badaddr(unsigned long address, struct pt_regs *); 54long sys_cmpxchg_badaddr(unsigned long address);
55long _sys_cmpxchg_badaddr(unsigned long address);
56#endif 55#endif
57 56
58#ifdef CONFIG_COMPAT 57#ifdef CONFIG_COMPAT
@@ -63,14 +62,23 @@ long sys_truncate64(const char __user *path, loff_t length);
63long sys_ftruncate64(unsigned int fd, loff_t length); 62long sys_ftruncate64(unsigned int fd, loff_t length);
64#endif 63#endif
65 64
65/* Provide versions of standard syscalls that use current_pt_regs(). */
66long sys_clone(unsigned long clone_flags, unsigned long newsp,
67 void __user *parent_tid, void __user *child_tid);
68long sys_execve(const char __user *filename,
69 const char __user *const __user *argv,
70 const char __user *const __user *envp);
71long sys_rt_sigreturn(void);
72long sys_sigaltstack(const stack_t __user *, stack_t __user *);
73#define sys_clone sys_clone
74#define sys_execve sys_execve
75#define sys_rt_sigreturn sys_rt_sigreturn
76#define sys_sigaltstack sys_sigaltstack
77
66/* These are the intvec*.S trampolines. */ 78/* These are the intvec*.S trampolines. */
67long _sys_sigaltstack(const stack_t __user *, stack_t __user *);
68long _sys_rt_sigreturn(void); 79long _sys_rt_sigreturn(void);
69long _sys_clone(unsigned long clone_flags, unsigned long newsp, 80long _sys_clone(unsigned long clone_flags, unsigned long newsp,
70 void __user *parent_tid, void __user *child_tid); 81 void __user *parent_tid, void __user *child_tid);
71long _sys_execve(const char __user *filename,
72 const char __user *const __user *argv,
73 const char __user *const __user *envp);
74 82
75#include <asm-generic/syscalls.h> 83#include <asm-generic/syscalls.h>
76 84
diff --git a/arch/tile/include/asm/unistd.h b/arch/tile/include/asm/unistd.h
index 6e032a0a268..dab827dc8ac 100644
--- a/arch/tile/include/asm/unistd.h
+++ b/arch/tile/include/asm/unistd.h
@@ -16,4 +16,5 @@
16#define __ARCH_WANT_SYS_LLSEEK 16#define __ARCH_WANT_SYS_LLSEEK
17#endif 17#endif
18#define __ARCH_WANT_SYS_NEWFSTATAT 18#define __ARCH_WANT_SYS_NEWFSTATAT
19#define __ARCH_WANT_SYS_EXECVE
19#include <uapi/asm/unistd.h> 20#include <uapi/asm/unistd.h>
diff --git a/arch/tile/include/uapi/asm/Kbuild b/arch/tile/include/uapi/asm/Kbuild
index 5c6915fd30b..c20db8e428b 100644
--- a/arch/tile/include/uapi/asm/Kbuild
+++ b/arch/tile/include/uapi/asm/Kbuild
@@ -15,4 +15,7 @@ header-y += siginfo.h
15header-y += signal.h 15header-y += signal.h
16header-y += stat.h 16header-y += stat.h
17header-y += swab.h 17header-y += swab.h
18header-y += ucontext.h
18header-y += unistd.h 19header-y += unistd.h
20
21generic-y += ucontext.h
diff --git a/arch/tile/kernel/compat.c b/arch/tile/kernel/compat.c
index d67459b9ac2..a2e805569d5 100644
--- a/arch/tile/kernel/compat.c
+++ b/arch/tile/kernel/compat.c
@@ -102,10 +102,9 @@ long compat_sys_sched_rr_get_interval(compat_pid_t pid,
102#define compat_sys_fadvise64_64 sys32_fadvise64_64 102#define compat_sys_fadvise64_64 sys32_fadvise64_64
103#define compat_sys_readahead sys32_readahead 103#define compat_sys_readahead sys32_readahead
104 104
105/* Call the trampolines to manage pt_regs where necessary. */ 105/* Call the assembly trampolines where necessary. */
106#define compat_sys_execve _compat_sys_execve
107#define compat_sys_sigaltstack _compat_sys_sigaltstack
108#define compat_sys_rt_sigreturn _compat_sys_rt_sigreturn 106#define compat_sys_rt_sigreturn _compat_sys_rt_sigreturn
107#undef sys_clone
109#define sys_clone _sys_clone 108#define sys_clone _sys_clone
110 109
111/* 110/*
diff --git a/arch/tile/kernel/compat_signal.c b/arch/tile/kernel/compat_signal.c
index 08b4fe1717b..2e4cc69224a 100644
--- a/arch/tile/kernel/compat_signal.c
+++ b/arch/tile/kernel/compat_signal.c
@@ -197,8 +197,7 @@ int copy_siginfo_from_user32(siginfo_t *to, struct compat_siginfo __user *from)
197} 197}
198 198
199long compat_sys_sigaltstack(const struct compat_sigaltstack __user *uss_ptr, 199long compat_sys_sigaltstack(const struct compat_sigaltstack __user *uss_ptr,
200 struct compat_sigaltstack __user *uoss_ptr, 200 struct compat_sigaltstack __user *uoss_ptr)
201 struct pt_regs *regs)
202{ 201{
203 stack_t uss, uoss; 202 stack_t uss, uoss;
204 int ret; 203 int ret;
@@ -219,7 +218,7 @@ long compat_sys_sigaltstack(const struct compat_sigaltstack __user *uss_ptr,
219 set_fs(KERNEL_DS); 218 set_fs(KERNEL_DS);
220 ret = do_sigaltstack(uss_ptr ? (stack_t __user __force *)&uss : NULL, 219 ret = do_sigaltstack(uss_ptr ? (stack_t __user __force *)&uss : NULL,
221 (stack_t __user __force *)&uoss, 220 (stack_t __user __force *)&uoss,
222 (unsigned long)compat_ptr(regs->sp)); 221 (unsigned long)compat_ptr(current_pt_regs()->sp));
223 set_fs(seg); 222 set_fs(seg);
224 if (ret >= 0 && uoss_ptr) { 223 if (ret >= 0 && uoss_ptr) {
225 if (!access_ok(VERIFY_WRITE, uoss_ptr, sizeof(*uoss_ptr)) || 224 if (!access_ok(VERIFY_WRITE, uoss_ptr, sizeof(*uoss_ptr)) ||
@@ -232,8 +231,9 @@ long compat_sys_sigaltstack(const struct compat_sigaltstack __user *uss_ptr,
232} 231}
233 232
234/* The assembly shim for this function arranges to ignore the return value. */ 233/* The assembly shim for this function arranges to ignore the return value. */
235long compat_sys_rt_sigreturn(struct pt_regs *regs) 234long compat_sys_rt_sigreturn(void)
236{ 235{
236 struct pt_regs *regs = current_pt_regs();
237 struct compat_rt_sigframe __user *frame = 237 struct compat_rt_sigframe __user *frame =
238 (struct compat_rt_sigframe __user *) compat_ptr(regs->sp); 238 (struct compat_rt_sigframe __user *) compat_ptr(regs->sp);
239 sigset_t set; 239 sigset_t set;
@@ -248,7 +248,7 @@ long compat_sys_rt_sigreturn(struct pt_regs *regs)
248 if (restore_sigcontext(regs, &frame->uc.uc_mcontext)) 248 if (restore_sigcontext(regs, &frame->uc.uc_mcontext))
249 goto badframe; 249 goto badframe;
250 250
251 if (compat_sys_sigaltstack(&frame->uc.uc_stack, NULL, regs) != 0) 251 if (compat_sys_sigaltstack(&frame->uc.uc_stack, NULL) == -EFAULT)
252 goto badframe; 252 goto badframe;
253 253
254 return 0; 254 return 0;
diff --git a/arch/tile/kernel/entry.S b/arch/tile/kernel/entry.S
index c31637baff2..f116cb0bce2 100644
--- a/arch/tile/kernel/entry.S
+++ b/arch/tile/kernel/entry.S
@@ -28,17 +28,6 @@ STD_ENTRY(current_text_addr)
28 STD_ENDPROC(current_text_addr) 28 STD_ENDPROC(current_text_addr)
29 29
30/* 30/*
31 * Implement execve(). The i386 code has a note that forking from kernel
32 * space results in no copy on write until the execve, so we should be
33 * careful not to write to the stack here.
34 */
35STD_ENTRY(kernel_execve)
36 moveli TREG_SYSCALL_NR_NAME, __NR_execve
37 swint1
38 jrp lr
39 STD_ENDPROC(kernel_execve)
40
41/*
42 * We don't run this function directly, but instead copy it to a page 31 * We don't run this function directly, but instead copy it to a page
43 * we map into every user process. See vdso_setup(). 32 * we map into every user process. See vdso_setup().
44 * 33 *
diff --git a/arch/tile/kernel/intvec_32.S b/arch/tile/kernel/intvec_32.S
index 6943515100f..f212bf7cea8 100644
--- a/arch/tile/kernel/intvec_32.S
+++ b/arch/tile/kernel/intvec_32.S
@@ -1291,6 +1291,21 @@ STD_ENTRY(ret_from_fork)
1291 } 1291 }
1292 STD_ENDPROC(ret_from_fork) 1292 STD_ENDPROC(ret_from_fork)
1293 1293
1294STD_ENTRY(ret_from_kernel_thread)
1295 jal sim_notify_fork
1296 jal schedule_tail
1297 FEEDBACK_REENTER(ret_from_fork)
1298 {
1299 move r0, r31
1300 jalr r30
1301 }
1302 FEEDBACK_REENTER(ret_from_kernel_thread)
1303 {
1304 movei r30, 0 /* not an NMI */
1305 j .Lresume_userspace /* jump into middle of interrupt_return */
1306 }
1307 STD_ENDPROC(ret_from_kernel_thread)
1308
1294 /* 1309 /*
1295 * Code for ill interrupt. 1310 * Code for ill interrupt.
1296 */ 1311 */
@@ -1437,15 +1452,6 @@ STD_ENTRY_LOCAL(bad_intr)
1437 panic "Unhandled interrupt %#x: PC %#lx" 1452 panic "Unhandled interrupt %#x: PC %#lx"
1438 STD_ENDPROC(bad_intr) 1453 STD_ENDPROC(bad_intr)
1439 1454
1440/* Put address of pt_regs in reg and jump. */
1441#define PTREGS_SYSCALL(x, reg) \
1442 STD_ENTRY(_##x); \
1443 { \
1444 PTREGS_PTR(reg, PTREGS_OFFSET_BASE); \
1445 j x \
1446 }; \
1447 STD_ENDPROC(_##x)
1448
1449/* 1455/*
1450 * Special-case sigreturn to not write r0 to the stack on return. 1456 * Special-case sigreturn to not write r0 to the stack on return.
1451 * This is technically more efficient, but it also avoids difficulties 1457 * This is technically more efficient, but it also avoids difficulties
@@ -1461,12 +1467,9 @@ STD_ENTRY_LOCAL(bad_intr)
1461 }; \ 1467 }; \
1462 STD_ENDPROC(_##x) 1468 STD_ENDPROC(_##x)
1463 1469
1464PTREGS_SYSCALL(sys_execve, r3)
1465PTREGS_SYSCALL(sys_sigaltstack, r2)
1466PTREGS_SYSCALL_SIGRETURN(sys_rt_sigreturn, r0) 1470PTREGS_SYSCALL_SIGRETURN(sys_rt_sigreturn, r0)
1467PTREGS_SYSCALL(sys_cmpxchg_badaddr, r1)
1468 1471
1469/* Save additional callee-saves to pt_regs, put address in r4 and jump. */ 1472/* Save additional callee-saves to pt_regs and jump to standard function. */
1470STD_ENTRY(_sys_clone) 1473STD_ENTRY(_sys_clone)
1471 push_extra_callee_saves r4 1474 push_extra_callee_saves r4
1472 j sys_clone 1475 j sys_clone
diff --git a/arch/tile/kernel/intvec_64.S b/arch/tile/kernel/intvec_64.S
index 7c06d597ffd..54bc9a6678e 100644
--- a/arch/tile/kernel/intvec_64.S
+++ b/arch/tile/kernel/intvec_64.S
@@ -1150,6 +1150,21 @@ STD_ENTRY(ret_from_fork)
1150 } 1150 }
1151 STD_ENDPROC(ret_from_fork) 1151 STD_ENDPROC(ret_from_fork)
1152 1152
1153STD_ENTRY(ret_from_kernel_thread)
1154 jal sim_notify_fork
1155 jal schedule_tail
1156 FEEDBACK_REENTER(ret_from_fork)
1157 {
1158 move r0, r31
1159 jalr r30
1160 }
1161 FEEDBACK_REENTER(ret_from_kernel_thread)
1162 {
1163 movei r30, 0 /* not an NMI */
1164 j .Lresume_userspace /* jump into middle of interrupt_return */
1165 }
1166 STD_ENDPROC(ret_from_kernel_thread)
1167
1153/* Various stub interrupt handlers and syscall handlers */ 1168/* Various stub interrupt handlers and syscall handlers */
1154 1169
1155STD_ENTRY_LOCAL(_kernel_double_fault) 1170STD_ENTRY_LOCAL(_kernel_double_fault)
@@ -1166,15 +1181,6 @@ STD_ENTRY_LOCAL(bad_intr)
1166 panic "Unhandled interrupt %#x: PC %#lx" 1181 panic "Unhandled interrupt %#x: PC %#lx"
1167 STD_ENDPROC(bad_intr) 1182 STD_ENDPROC(bad_intr)
1168 1183
1169/* Put address of pt_regs in reg and jump. */
1170#define PTREGS_SYSCALL(x, reg) \
1171 STD_ENTRY(_##x); \
1172 { \
1173 PTREGS_PTR(reg, PTREGS_OFFSET_BASE); \
1174 j x \
1175 }; \
1176 STD_ENDPROC(_##x)
1177
1178/* 1184/*
1179 * Special-case sigreturn to not write r0 to the stack on return. 1185 * Special-case sigreturn to not write r0 to the stack on return.
1180 * This is technically more efficient, but it also avoids difficulties 1186 * This is technically more efficient, but it also avoids difficulties
@@ -1190,16 +1196,12 @@ STD_ENTRY_LOCAL(bad_intr)
1190 }; \ 1196 }; \
1191 STD_ENDPROC(_##x) 1197 STD_ENDPROC(_##x)
1192 1198
1193PTREGS_SYSCALL(sys_execve, r3)
1194PTREGS_SYSCALL(sys_sigaltstack, r2)
1195PTREGS_SYSCALL_SIGRETURN(sys_rt_sigreturn, r0) 1199PTREGS_SYSCALL_SIGRETURN(sys_rt_sigreturn, r0)
1196#ifdef CONFIG_COMPAT 1200#ifdef CONFIG_COMPAT
1197PTREGS_SYSCALL(compat_sys_execve, r3)
1198PTREGS_SYSCALL(compat_sys_sigaltstack, r2)
1199PTREGS_SYSCALL_SIGRETURN(compat_sys_rt_sigreturn, r0) 1201PTREGS_SYSCALL_SIGRETURN(compat_sys_rt_sigreturn, r0)
1200#endif 1202#endif
1201 1203
1202/* Save additional callee-saves to pt_regs, put address in r4 and jump. */ 1204/* Save additional callee-saves to pt_regs and jump to standard function. */
1203STD_ENTRY(_sys_clone) 1205STD_ENTRY(_sys_clone)
1204 push_extra_callee_saves r4 1206 push_extra_callee_saves r4
1205 j sys_clone 1207 j sys_clone
diff --git a/arch/tile/kernel/module.c b/arch/tile/kernel/module.c
index 001cbfa10ac..243ffebe38d 100644
--- a/arch/tile/kernel/module.c
+++ b/arch/tile/kernel/module.c
@@ -24,16 +24,6 @@
24#include <asm/homecache.h> 24#include <asm/homecache.h>
25#include <arch/opcode.h> 25#include <arch/opcode.h>
26 26
27#ifdef __tilegx__
28# define Elf_Rela Elf64_Rela
29# define ELF_R_SYM ELF64_R_SYM
30# define ELF_R_TYPE ELF64_R_TYPE
31#else
32# define Elf_Rela Elf32_Rela
33# define ELF_R_SYM ELF32_R_SYM
34# define ELF_R_TYPE ELF32_R_TYPE
35#endif
36
37#ifdef MODULE_DEBUG 27#ifdef MODULE_DEBUG
38#define DEBUGP printk 28#define DEBUGP printk
39#else 29#else
diff --git a/arch/tile/kernel/process.c b/arch/tile/kernel/process.c
index 307d010696c..1c20029d2f5 100644
--- a/arch/tile/kernel/process.c
+++ b/arch/tile/kernel/process.c
@@ -157,24 +157,44 @@ void arch_release_thread_info(struct thread_info *info)
157static void save_arch_state(struct thread_struct *t); 157static void save_arch_state(struct thread_struct *t);
158 158
159int copy_thread(unsigned long clone_flags, unsigned long sp, 159int copy_thread(unsigned long clone_flags, unsigned long sp,
160 unsigned long stack_size, 160 unsigned long arg,
161 struct task_struct *p, struct pt_regs *regs) 161 struct task_struct *p, struct pt_regs *unused)
162{ 162{
163 struct pt_regs *childregs; 163 struct pt_regs *childregs = task_pt_regs(p);
164 unsigned long ksp; 164 unsigned long ksp;
165 unsigned long *callee_regs;
165 166
166 /* 167 /*
167 * When creating a new kernel thread we pass sp as zero. 168 * Set up the stack and stack pointer appropriately for the
168 * Assign it to a reasonable value now that we have the stack. 169 * new child to find itself woken up in __switch_to().
170 * The callee-saved registers must be on the stack to be read;
171 * the new task will then jump to assembly support to handle
172 * calling schedule_tail(), etc., and (for userspace tasks)
173 * returning to the context set up in the pt_regs.
169 */ 174 */
170 if (sp == 0 && regs->ex1 == PL_ICS_EX1(KERNEL_PL, 0)) 175 ksp = (unsigned long) childregs;
171 sp = KSTK_TOP(p); 176 ksp -= C_ABI_SAVE_AREA_SIZE; /* interrupt-entry save area */
177 ((long *)ksp)[0] = ((long *)ksp)[1] = 0;
178 ksp -= CALLEE_SAVED_REGS_COUNT * sizeof(unsigned long);
179 callee_regs = (unsigned long *)ksp;
180 ksp -= C_ABI_SAVE_AREA_SIZE; /* __switch_to() save area */
181 ((long *)ksp)[0] = ((long *)ksp)[1] = 0;
182 p->thread.ksp = ksp;
172 183
173 /* 184 /* Record the pid of the task that created this one. */
174 * Do not clone step state from the parent; each thread 185 p->thread.creator_pid = current->pid;
175 * must make its own lazily. 186
176 */ 187 if (unlikely(p->flags & PF_KTHREAD)) {
177 task_thread_info(p)->step_state = NULL; 188 /* kernel thread */
189 memset(childregs, 0, sizeof(struct pt_regs));
190 memset(&callee_regs[2], 0,
191 (CALLEE_SAVED_REGS_COUNT - 2) * sizeof(unsigned long));
192 callee_regs[0] = sp; /* r30 = function */
193 callee_regs[1] = arg; /* r31 = arg */
194 childregs->ex1 = PL_ICS_EX1(KERNEL_PL, 0);
195 p->thread.pc = (unsigned long) ret_from_kernel_thread;
196 return 0;
197 }
178 198
179 /* 199 /*
180 * Start new thread in ret_from_fork so it schedules properly 200 * Start new thread in ret_from_fork so it schedules properly
@@ -182,46 +202,33 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
182 */ 202 */
183 p->thread.pc = (unsigned long) ret_from_fork; 203 p->thread.pc = (unsigned long) ret_from_fork;
184 204
185 /* Save user stack top pointer so we can ID the stack vm area later. */ 205 /*
186 p->thread.usp0 = sp; 206 * Do not clone step state from the parent; each thread
187 207 * must make its own lazily.
188 /* Record the pid of the process that created this one. */ 208 */
189 p->thread.creator_pid = current->pid; 209 task_thread_info(p)->step_state = NULL;
190 210
191 /* 211 /*
192 * Copy the registers onto the kernel stack so the 212 * Copy the registers onto the kernel stack so the
193 * return-from-interrupt code will reload it into registers. 213 * return-from-interrupt code will reload it into registers.
194 */ 214 */
195 childregs = task_pt_regs(p); 215 *childregs = *current_pt_regs();
196 *childregs = *regs;
197 childregs->regs[0] = 0; /* return value is zero */ 216 childregs->regs[0] = 0; /* return value is zero */
198 childregs->sp = sp; /* override with new user stack pointer */ 217 if (sp)
218 childregs->sp = sp; /* override with new user stack pointer */
219 memcpy(callee_regs, &childregs->regs[CALLEE_SAVED_FIRST_REG],
220 CALLEE_SAVED_REGS_COUNT * sizeof(unsigned long));
221
222 /* Save user stack top pointer so we can ID the stack vm area later. */
223 p->thread.usp0 = childregs->sp;
199 224
200 /* 225 /*
201 * If CLONE_SETTLS is set, set "tp" in the new task to "r4", 226 * If CLONE_SETTLS is set, set "tp" in the new task to "r4",
202 * which is passed in as arg #5 to sys_clone(). 227 * which is passed in as arg #5 to sys_clone().
203 */ 228 */
204 if (clone_flags & CLONE_SETTLS) 229 if (clone_flags & CLONE_SETTLS)
205 childregs->tp = regs->regs[4]; 230 childregs->tp = childregs->regs[4];
206 231
207 /*
208 * Copy the callee-saved registers from the passed pt_regs struct
209 * into the context-switch callee-saved registers area.
210 * This way when we start the interrupt-return sequence, the
211 * callee-save registers will be correctly in registers, which
212 * is how we assume the compiler leaves them as we start doing
213 * the normal return-from-interrupt path after calling C code.
214 * Zero out the C ABI save area to mark the top of the stack.
215 */
216 ksp = (unsigned long) childregs;
217 ksp -= C_ABI_SAVE_AREA_SIZE; /* interrupt-entry save area */
218 ((long *)ksp)[0] = ((long *)ksp)[1] = 0;
219 ksp -= CALLEE_SAVED_REGS_COUNT * sizeof(unsigned long);
220 memcpy((void *)ksp, &regs->regs[CALLEE_SAVED_FIRST_REG],
221 CALLEE_SAVED_REGS_COUNT * sizeof(unsigned long));
222 ksp -= C_ABI_SAVE_AREA_SIZE; /* __switch_to() save area */
223 ((long *)ksp)[0] = ((long *)ksp)[1] = 0;
224 p->thread.ksp = ksp;
225 232
226#if CHIP_HAS_TILE_DMA() 233#if CHIP_HAS_TILE_DMA()
227 /* 234 /*
@@ -578,61 +585,13 @@ int do_work_pending(struct pt_regs *regs, u32 thread_info_flags)
578} 585}
579 586
580/* Note there is an implicit fifth argument if (clone_flags & CLONE_SETTLS). */ 587/* Note there is an implicit fifth argument if (clone_flags & CLONE_SETTLS). */
581SYSCALL_DEFINE5(clone, unsigned long, clone_flags, unsigned long, newsp, 588SYSCALL_DEFINE4(clone, unsigned long, clone_flags, unsigned long, newsp,
582 void __user *, parent_tidptr, void __user *, child_tidptr, 589 void __user *, parent_tidptr, void __user *, child_tidptr)
583 struct pt_regs *, regs)
584{ 590{
585 if (!newsp) 591 return do_fork(clone_flags, newsp, current_pt_regs(), 0,
586 newsp = regs->sp;
587 return do_fork(clone_flags, newsp, regs, 0,
588 parent_tidptr, child_tidptr); 592 parent_tidptr, child_tidptr);
589} 593}
590 594
591/*
592 * sys_execve() executes a new program.
593 */
594SYSCALL_DEFINE4(execve, const char __user *, path,
595 const char __user *const __user *, argv,
596 const char __user *const __user *, envp,
597 struct pt_regs *, regs)
598{
599 long error;
600 struct filename *filename;
601
602 filename = getname(path);
603 error = PTR_ERR(filename);
604 if (IS_ERR(filename))
605 goto out;
606 error = do_execve(filename->name, argv, envp, regs);
607 putname(filename);
608 if (error == 0)
609 single_step_execve();
610out:
611 return error;
612}
613
614#ifdef CONFIG_COMPAT
615long compat_sys_execve(const char __user *path,
616 compat_uptr_t __user *argv,
617 compat_uptr_t __user *envp,
618 struct pt_regs *regs)
619{
620 long error;
621 struct filename *filename;
622
623 filename = getname(path);
624 error = PTR_ERR(filename);
625 if (IS_ERR(filename))
626 goto out;
627 error = compat_do_execve(filename->name, argv, envp, regs);
628 putname(filename);
629 if (error == 0)
630 single_step_execve();
631out:
632 return error;
633}
634#endif
635
636unsigned long get_wchan(struct task_struct *p) 595unsigned long get_wchan(struct task_struct *p)
637{ 596{
638 struct KBacktraceIterator kbt; 597 struct KBacktraceIterator kbt;
@@ -650,37 +609,6 @@ unsigned long get_wchan(struct task_struct *p)
650 return 0; 609 return 0;
651} 610}
652 611
653/*
654 * We pass in lr as zero (cleared in kernel_thread) and the caller
655 * part of the backtrace ABI on the stack also zeroed (in copy_thread)
656 * so that backtraces will stop with this function.
657 * Note that we don't use r0, since copy_thread() clears it.
658 */
659static void start_kernel_thread(int dummy, int (*fn)(int), int arg)
660{
661 do_exit(fn(arg));
662}
663
664/*
665 * Create a kernel thread
666 */
667int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
668{
669 struct pt_regs regs;
670
671 memset(&regs, 0, sizeof(regs));
672 regs.ex1 = PL_ICS_EX1(KERNEL_PL, 0); /* run at kernel PL, no ICS */
673 regs.pc = (long) start_kernel_thread;
674 regs.flags = PT_FLAGS_CALLER_SAVES; /* need to restore r1 and r2 */
675 regs.regs[1] = (long) fn; /* function pointer */
676 regs.regs[2] = (long) arg; /* parameter register */
677
678 /* Ok, create the new process.. */
679 return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, &regs,
680 0, NULL, NULL);
681}
682EXPORT_SYMBOL(kernel_thread);
683
684/* Flush thread state. */ 612/* Flush thread state. */
685void flush_thread(void) 613void flush_thread(void)
686{ 614{
diff --git a/arch/tile/kernel/signal.c b/arch/tile/kernel/signal.c
index 67efb656d10..657a7ace4ab 100644
--- a/arch/tile/kernel/signal.c
+++ b/arch/tile/kernel/signal.c
@@ -37,10 +37,10 @@
37 37
38#define DEBUG_SIG 0 38#define DEBUG_SIG 0
39 39
40SYSCALL_DEFINE3(sigaltstack, const stack_t __user *, uss, 40SYSCALL_DEFINE2(sigaltstack, const stack_t __user *, uss,
41 stack_t __user *, uoss, struct pt_regs *, regs) 41 stack_t __user *, uoss)
42{ 42{
43 return do_sigaltstack(uss, uoss, regs->sp); 43 return do_sigaltstack(uss, uoss, current_pt_regs()->sp);
44} 44}
45 45
46 46
@@ -83,8 +83,9 @@ void signal_fault(const char *type, struct pt_regs *regs,
83} 83}
84 84
85/* The assembly shim for this function arranges to ignore the return value. */ 85/* The assembly shim for this function arranges to ignore the return value. */
86SYSCALL_DEFINE1(rt_sigreturn, struct pt_regs *, regs) 86SYSCALL_DEFINE0(rt_sigreturn)
87{ 87{
88 struct pt_regs *regs = current_pt_regs();
88 struct rt_sigframe __user *frame = 89 struct rt_sigframe __user *frame =
89 (struct rt_sigframe __user *)(regs->sp); 90 (struct rt_sigframe __user *)(regs->sp);
90 sigset_t set; 91 sigset_t set;
diff --git a/arch/tile/kernel/sys.c b/arch/tile/kernel/sys.c
index b08095b402d..02ff5c0ef77 100644
--- a/arch/tile/kernel/sys.c
+++ b/arch/tile/kernel/sys.c
@@ -106,14 +106,11 @@ SYSCALL_DEFINE6(mmap, unsigned long, addr, unsigned long, len,
106#define sys_readahead sys32_readahead 106#define sys_readahead sys32_readahead
107#endif 107#endif
108 108
109/* Call the trampolines to manage pt_regs where necessary. */ 109/* Call the assembly trampolines where necessary. */
110#define sys_execve _sys_execve 110#undef sys_rt_sigreturn
111#define sys_sigaltstack _sys_sigaltstack
112#define sys_rt_sigreturn _sys_rt_sigreturn 111#define sys_rt_sigreturn _sys_rt_sigreturn
112#undef sys_clone
113#define sys_clone _sys_clone 113#define sys_clone _sys_clone
114#ifndef __tilegx__
115#define sys_cmpxchg_badaddr _sys_cmpxchg_badaddr
116#endif
117 114
118/* 115/*
119 * Note that we can't include <linux/unistd.h> here since the header 116 * Note that we can't include <linux/unistd.h> here since the header
diff --git a/arch/tile/mm/fault.c b/arch/tile/mm/fault.c
index fe811fa5f1b..3d2b81c163a 100644
--- a/arch/tile/mm/fault.c
+++ b/arch/tile/mm/fault.c
@@ -70,9 +70,10 @@ static noinline void force_sig_info_fault(const char *type, int si_signo,
70 * Synthesize the fault a PL0 process would get by doing a word-load of 70 * Synthesize the fault a PL0 process would get by doing a word-load of
71 * an unaligned address or a high kernel address. 71 * an unaligned address or a high kernel address.
72 */ 72 */
73SYSCALL_DEFINE2(cmpxchg_badaddr, unsigned long, address, 73SYSCALL_DEFINE1(cmpxchg_badaddr, unsigned long, address)
74 struct pt_regs *, regs)
75{ 74{
75 struct pt_regs *regs = current_pt_regs();
76
76 if (address >= PAGE_OFFSET) 77 if (address >= PAGE_OFFSET)
77 force_sig_info_fault("atomic segfault", SIGSEGV, SEGV_MAPERR, 78 force_sig_info_fault("atomic segfault", SIGSEGV, SEGV_MAPERR,
78 address, INT_DTLB_MISS, current, regs); 79 address, INT_DTLB_MISS, current, regs);
diff --git a/arch/um/kernel/exec.c b/arch/um/kernel/exec.c
index 3a8ece7d09c..0d7103c9eff 100644
--- a/arch/um/kernel/exec.c
+++ b/arch/um/kernel/exec.c
@@ -32,13 +32,14 @@ void flush_thread(void)
32 "err = %d\n", ret); 32 "err = %d\n", ret);
33 force_sig(SIGKILL, current); 33 force_sig(SIGKILL, current);
34 } 34 }
35 get_safe_registers(current_pt_regs()->regs.gp,
36 current_pt_regs()->regs.fp);
35 37
36 __switch_mm(&current->mm->context.id); 38 __switch_mm(&current->mm->context.id);
37} 39}
38 40
39void start_thread(struct pt_regs *regs, unsigned long eip, unsigned long esp) 41void start_thread(struct pt_regs *regs, unsigned long eip, unsigned long esp)
40{ 42{
41 get_safe_registers(regs->regs.gp, regs->regs.fp);
42 PT_REGS_IP(regs) = eip; 43 PT_REGS_IP(regs) = eip;
43 PT_REGS_SP(regs) = esp; 44 PT_REGS_SP(regs) = esp;
44 current->ptrace &= ~PT_DTRACE; 45 current->ptrace &= ~PT_DTRACE;
diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
index b6d699cdd55..c502c804e8b 100644
--- a/arch/um/kernel/process.c
+++ b/arch/um/kernel/process.c
@@ -171,7 +171,7 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
171 p->thread = (struct thread_struct) INIT_THREAD; 171 p->thread = (struct thread_struct) INIT_THREAD;
172 172
173 if (!kthread) { 173 if (!kthread) {
174 memcpy(&p->thread.regs.regs, &regs->regs, 174 memcpy(&p->thread.regs.regs, current_pt_regs(),
175 sizeof(p->thread.regs.regs)); 175 sizeof(p->thread.regs.regs));
176 PT_REGS_SET_SYSCALL_RETURN(&p->thread.regs, 0); 176 PT_REGS_SET_SYSCALL_RETURN(&p->thread.regs, 0);
177 if (sp != 0) 177 if (sp != 0)
diff --git a/arch/um/kernel/syscall.c b/arch/um/kernel/syscall.c
index a81f3705e90..3a875226c8e 100644
--- a/arch/um/kernel/syscall.c
+++ b/arch/um/kernel/syscall.c
@@ -16,23 +16,19 @@
16 16
17long sys_fork(void) 17long sys_fork(void)
18{ 18{
19 return do_fork(SIGCHLD, UPT_SP(&current->thread.regs.regs), 19 return do_fork(SIGCHLD, 0,
20 &current->thread.regs, 0, NULL, NULL); 20 &current->thread.regs, 0, NULL, NULL);
21} 21}
22 22
23long sys_vfork(void) 23long sys_vfork(void)
24{ 24{
25 return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, 25 return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, 0,
26 UPT_SP(&current->thread.regs.regs),
27 &current->thread.regs, 0, NULL, NULL); 26 &current->thread.regs, 0, NULL, NULL);
28} 27}
29 28
30long sys_clone(unsigned long clone_flags, unsigned long newsp, 29long sys_clone(unsigned long clone_flags, unsigned long newsp,
31 void __user *parent_tid, void __user *child_tid) 30 void __user *parent_tid, void __user *child_tid)
32{ 31{
33 if (!newsp)
34 newsp = UPT_SP(&current->thread.regs.regs);
35
36 return do_fork(clone_flags, newsp, &current->thread.regs, 0, parent_tid, 32 return do_fork(clone_flags, newsp, &current->thread.regs, 0, parent_tid,
37 child_tid); 33 child_tid);
38} 34}
diff --git a/arch/unicore32/Kconfig b/arch/unicore32/Kconfig
index e5c5473e69c..c4fbb21e802 100644
--- a/arch/unicore32/Kconfig
+++ b/arch/unicore32/Kconfig
@@ -16,6 +16,8 @@ config UNICORE32
16 select ARCH_WANT_FRAME_POINTERS 16 select ARCH_WANT_FRAME_POINTERS
17 select GENERIC_IOMAP 17 select GENERIC_IOMAP
18 select MODULES_USE_ELF_REL 18 select MODULES_USE_ELF_REL
19 select GENERIC_KERNEL_THREAD
20 select GENERIC_KERNEL_EXECVE
19 help 21 help
20 UniCore-32 is 32-bit Instruction Set Architecture, 22 UniCore-32 is 32-bit Instruction Set Architecture,
21 including a series of low-power-consumption RISC chip 23 including a series of low-power-consumption RISC chip
@@ -64,6 +66,9 @@ config GENERIC_CALIBRATE_DELAY
64config ARCH_MAY_HAVE_PC_FDC 66config ARCH_MAY_HAVE_PC_FDC
65 bool 67 bool
66 68
69config ZONE_DMA
70 def_bool y
71
67config NEED_DMA_MAP_STATE 72config NEED_DMA_MAP_STATE
68 def_bool y 73 def_bool y
69 74
@@ -216,7 +221,7 @@ config PUV3_GPIO
216 bool 221 bool
217 depends on !ARCH_FPGA 222 depends on !ARCH_FPGA
218 select GENERIC_GPIO 223 select GENERIC_GPIO
219 select GPIO_SYSFS if EXPERIMENTAL 224 select GPIO_SYSFS
220 default y 225 default y
221 226
222if PUV3_NB0916 227if PUV3_NB0916
diff --git a/arch/unicore32/include/asm/Kbuild b/arch/unicore32/include/asm/Kbuild
index c910c9857e1..601e92f18af 100644
--- a/arch/unicore32/include/asm/Kbuild
+++ b/arch/unicore32/include/asm/Kbuild
@@ -1,4 +1,3 @@
1include include/asm-generic/Kbuild.asm
2 1
3generic-y += atomic.h 2generic-y += atomic.h
4generic-y += auxvec.h 3generic-y += auxvec.h
diff --git a/arch/unicore32/include/asm/bug.h b/arch/unicore32/include/asm/bug.h
index b1ff8cadb08..93a56f3e234 100644
--- a/arch/unicore32/include/asm/bug.h
+++ b/arch/unicore32/include/asm/bug.h
@@ -19,9 +19,4 @@ extern void die(const char *msg, struct pt_regs *regs, int err);
19extern void uc32_notify_die(const char *str, struct pt_regs *regs, 19extern void uc32_notify_die(const char *str, struct pt_regs *regs,
20 struct siginfo *info, unsigned long err, unsigned long trap); 20 struct siginfo *info, unsigned long err, unsigned long trap);
21 21
22extern asmlinkage void __backtrace(void);
23extern asmlinkage void c_backtrace(unsigned long fp, int pmode);
24
25extern void __show_regs(struct pt_regs *);
26
27#endif /* __UNICORE_BUG_H__ */ 22#endif /* __UNICORE_BUG_H__ */
diff --git a/arch/unicore32/include/asm/cmpxchg.h b/arch/unicore32/include/asm/cmpxchg.h
index df4d5acfd19..8e797ad4fa2 100644
--- a/arch/unicore32/include/asm/cmpxchg.h
+++ b/arch/unicore32/include/asm/cmpxchg.h
@@ -35,7 +35,7 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr,
35 : "memory", "cc"); 35 : "memory", "cc");
36 break; 36 break;
37 default: 37 default:
38 ret = __xchg_bad_pointer(); 38 __xchg_bad_pointer();
39 } 39 }
40 40
41 return ret; 41 return ret;
diff --git a/arch/unicore32/include/asm/kvm_para.h b/arch/unicore32/include/asm/kvm_para.h
deleted file mode 100644
index 14fab8f0b95..00000000000
--- a/arch/unicore32/include/asm/kvm_para.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-generic/kvm_para.h>
diff --git a/arch/unicore32/include/asm/processor.h b/arch/unicore32/include/asm/processor.h
index 14382cb0965..4eaa4216766 100644
--- a/arch/unicore32/include/asm/processor.h
+++ b/arch/unicore32/include/asm/processor.h
@@ -72,11 +72,6 @@ unsigned long get_wchan(struct task_struct *p);
72 72
73#define cpu_relax() barrier() 73#define cpu_relax() barrier()
74 74
75/*
76 * Create a new kernel thread
77 */
78extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
79
80#define task_pt_regs(p) \ 75#define task_pt_regs(p) \
81 ((struct pt_regs *)(THREAD_START_SP + task_stack_page(p)) - 1) 76 ((struct pt_regs *)(THREAD_START_SP + task_stack_page(p)) - 1)
82 77
diff --git a/arch/unicore32/include/asm/ptrace.h b/arch/unicore32/include/asm/ptrace.h
index b9caf9b0997..726749dab52 100644
--- a/arch/unicore32/include/asm/ptrace.h
+++ b/arch/unicore32/include/asm/ptrace.h
@@ -12,80 +12,10 @@
12#ifndef __UNICORE_PTRACE_H__ 12#ifndef __UNICORE_PTRACE_H__
13#define __UNICORE_PTRACE_H__ 13#define __UNICORE_PTRACE_H__
14 14
15#define PTRACE_GET_THREAD_AREA 22 15#include <uapi/asm/ptrace.h>
16
17/*
18 * PSR bits
19 */
20#define USER_MODE 0x00000010
21#define REAL_MODE 0x00000011
22#define INTR_MODE 0x00000012
23#define PRIV_MODE 0x00000013
24#define ABRT_MODE 0x00000017
25#define EXTN_MODE 0x0000001b
26#define SUSR_MODE 0x0000001f
27#define MODE_MASK 0x0000001f
28#define PSR_R_BIT 0x00000040
29#define PSR_I_BIT 0x00000080
30#define PSR_V_BIT 0x10000000
31#define PSR_C_BIT 0x20000000
32#define PSR_Z_BIT 0x40000000
33#define PSR_S_BIT 0x80000000
34
35/*
36 * Groups of PSR bits
37 */
38#define PSR_f 0xff000000 /* Flags */
39#define PSR_c 0x000000ff /* Control */
40 16
41#ifndef __ASSEMBLY__ 17#ifndef __ASSEMBLY__
42 18
43/*
44 * This struct defines the way the registers are stored on the
45 * stack during a system call. Note that sizeof(struct pt_regs)
46 * has to be a multiple of 8.
47 */
48struct pt_regs {
49 unsigned long uregs[34];
50};
51
52#define UCreg_asr uregs[32]
53#define UCreg_pc uregs[31]
54#define UCreg_lr uregs[30]
55#define UCreg_sp uregs[29]
56#define UCreg_ip uregs[28]
57#define UCreg_fp uregs[27]
58#define UCreg_26 uregs[26]
59#define UCreg_25 uregs[25]
60#define UCreg_24 uregs[24]
61#define UCreg_23 uregs[23]
62#define UCreg_22 uregs[22]
63#define UCreg_21 uregs[21]
64#define UCreg_20 uregs[20]
65#define UCreg_19 uregs[19]
66#define UCreg_18 uregs[18]
67#define UCreg_17 uregs[17]
68#define UCreg_16 uregs[16]
69#define UCreg_15 uregs[15]
70#define UCreg_14 uregs[14]
71#define UCreg_13 uregs[13]
72#define UCreg_12 uregs[12]
73#define UCreg_11 uregs[11]
74#define UCreg_10 uregs[10]
75#define UCreg_09 uregs[9]
76#define UCreg_08 uregs[8]
77#define UCreg_07 uregs[7]
78#define UCreg_06 uregs[6]
79#define UCreg_05 uregs[5]
80#define UCreg_04 uregs[4]
81#define UCreg_03 uregs[3]
82#define UCreg_02 uregs[2]
83#define UCreg_01 uregs[1]
84#define UCreg_00 uregs[0]
85#define UCreg_ORIG_00 uregs[33]
86
87#ifdef __KERNEL__
88
89#define user_mode(regs) \ 19#define user_mode(regs) \
90 (processor_mode(regs) == USER_MODE) 20 (processor_mode(regs) == USER_MODE)
91 21
@@ -125,9 +55,5 @@ static inline int valid_user_regs(struct pt_regs *regs)
125 55
126#define instruction_pointer(regs) ((regs)->UCreg_pc) 56#define instruction_pointer(regs) ((regs)->UCreg_pc)
127 57
128#endif /* __KERNEL__ */
129
130#endif /* __ASSEMBLY__ */ 58#endif /* __ASSEMBLY__ */
131
132#endif 59#endif
133
diff --git a/arch/unicore32/include/uapi/asm/Kbuild b/arch/unicore32/include/uapi/asm/Kbuild
index baebb3da1d4..0514d7ad685 100644
--- a/arch/unicore32/include/uapi/asm/Kbuild
+++ b/arch/unicore32/include/uapi/asm/Kbuild
@@ -1,3 +1,10 @@
1# UAPI Header export list 1# UAPI Header export list
2include include/uapi/asm-generic/Kbuild.asm 2include include/uapi/asm-generic/Kbuild.asm
3 3
4header-y += byteorder.h
5header-y += kvm_para.h
6header-y += ptrace.h
7header-y += sigcontext.h
8header-y += unistd.h
9
10generic-y += kvm_para.h
diff --git a/arch/unicore32/include/asm/byteorder.h b/arch/unicore32/include/uapi/asm/byteorder.h
index ebe1b3fef3e..ebe1b3fef3e 100644
--- a/arch/unicore32/include/asm/byteorder.h
+++ b/arch/unicore32/include/uapi/asm/byteorder.h
diff --git a/arch/unicore32/include/uapi/asm/ptrace.h b/arch/unicore32/include/uapi/asm/ptrace.h
new file mode 100644
index 00000000000..187aa2e98a5
--- /dev/null
+++ b/arch/unicore32/include/uapi/asm/ptrace.h
@@ -0,0 +1,90 @@
1/*
2 * linux/arch/unicore32/include/asm/ptrace.h
3 *
4 * Code specific to PKUnity SoC and UniCore ISA
5 *
6 * Copyright (C) 2001-2010 GUAN Xue-tao
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12#ifndef _UAPI__UNICORE_PTRACE_H__
13#define _UAPI__UNICORE_PTRACE_H__
14
15#define PTRACE_GET_THREAD_AREA 22
16
17/*
18 * PSR bits
19 */
20#define USER_MODE 0x00000010
21#define REAL_MODE 0x00000011
22#define INTR_MODE 0x00000012
23#define PRIV_MODE 0x00000013
24#define ABRT_MODE 0x00000017
25#define EXTN_MODE 0x0000001b
26#define SUSR_MODE 0x0000001f
27#define MODE_MASK 0x0000001f
28#define PSR_R_BIT 0x00000040
29#define PSR_I_BIT 0x00000080
30#define PSR_V_BIT 0x10000000
31#define PSR_C_BIT 0x20000000
32#define PSR_Z_BIT 0x40000000
33#define PSR_S_BIT 0x80000000
34
35/*
36 * Groups of PSR bits
37 */
38#define PSR_f 0xff000000 /* Flags */
39#define PSR_c 0x000000ff /* Control */
40
41#ifndef __ASSEMBLY__
42
43/*
44 * This struct defines the way the registers are stored on the
45 * stack during a system call. Note that sizeof(struct pt_regs)
46 * has to be a multiple of 8.
47 */
48struct pt_regs {
49 unsigned long uregs[34];
50};
51
52#define UCreg_asr uregs[32]
53#define UCreg_pc uregs[31]
54#define UCreg_lr uregs[30]
55#define UCreg_sp uregs[29]
56#define UCreg_ip uregs[28]
57#define UCreg_fp uregs[27]
58#define UCreg_26 uregs[26]
59#define UCreg_25 uregs[25]
60#define UCreg_24 uregs[24]
61#define UCreg_23 uregs[23]
62#define UCreg_22 uregs[22]
63#define UCreg_21 uregs[21]
64#define UCreg_20 uregs[20]
65#define UCreg_19 uregs[19]
66#define UCreg_18 uregs[18]
67#define UCreg_17 uregs[17]
68#define UCreg_16 uregs[16]
69#define UCreg_15 uregs[15]
70#define UCreg_14 uregs[14]
71#define UCreg_13 uregs[13]
72#define UCreg_12 uregs[12]
73#define UCreg_11 uregs[11]
74#define UCreg_10 uregs[10]
75#define UCreg_09 uregs[9]
76#define UCreg_08 uregs[8]
77#define UCreg_07 uregs[7]
78#define UCreg_06 uregs[6]
79#define UCreg_05 uregs[5]
80#define UCreg_04 uregs[4]
81#define UCreg_03 uregs[3]
82#define UCreg_02 uregs[2]
83#define UCreg_01 uregs[1]
84#define UCreg_00 uregs[0]
85#define UCreg_ORIG_00 uregs[33]
86
87
88#endif /* __ASSEMBLY__ */
89
90#endif /* _UAPI__UNICORE_PTRACE_H__ */
diff --git a/arch/unicore32/include/asm/sigcontext.h b/arch/unicore32/include/uapi/asm/sigcontext.h
index 6a2d7671c05..6a2d7671c05 100644
--- a/arch/unicore32/include/asm/sigcontext.h
+++ b/arch/unicore32/include/uapi/asm/sigcontext.h
diff --git a/arch/unicore32/include/asm/unistd.h b/arch/unicore32/include/uapi/asm/unistd.h
index 2abcf61c615..d18a3be89b3 100644
--- a/arch/unicore32/include/asm/unistd.h
+++ b/arch/unicore32/include/uapi/asm/unistd.h
@@ -12,3 +12,4 @@
12 12
13/* Use the standard ABI for syscalls. */ 13/* Use the standard ABI for syscalls. */
14#include <asm-generic/unistd.h> 14#include <asm-generic/unistd.h>
15#define __ARCH_WANT_SYS_EXECVE
diff --git a/arch/unicore32/kernel/entry.S b/arch/unicore32/kernel/entry.S
index dcb87ab19dd..7049350c790 100644
--- a/arch/unicore32/kernel/entry.S
+++ b/arch/unicore32/kernel/entry.S
@@ -573,17 +573,16 @@ ENDPROC(ret_to_user)
573 */ 573 */
574ENTRY(ret_from_fork) 574ENTRY(ret_from_fork)
575 b.l schedule_tail 575 b.l schedule_tail
576 get_thread_info tsk
577 ldw r1, [tsk+], #TI_FLAGS @ check for syscall tracing
578 mov why, #1
579 cand.a r1, #_TIF_SYSCALL_TRACE @ are we tracing syscalls?
580 beq ret_slow_syscall
581 mov r1, sp
582 mov r0, #1 @ trace exit [IP = 1]
583 b.l syscall_trace
584 b ret_slow_syscall 576 b ret_slow_syscall
585ENDPROC(ret_from_fork) 577ENDPROC(ret_from_fork)
586 578
579ENTRY(ret_from_kernel_thread)
580 b.l schedule_tail
581 mov r0, r5
582 adr lr, ret_slow_syscall
583 mov pc, r4
584ENDPROC(ret_from_kernel_thread)
585
587/*============================================================================= 586/*=============================================================================
588 * SWI handler 587 * SWI handler
589 *----------------------------------------------------------------------------- 588 *-----------------------------------------------------------------------------
@@ -669,11 +668,6 @@ __cr_alignment:
669#endif 668#endif
670 .ltorg 669 .ltorg
671 670
672ENTRY(sys_execve)
673 add r3, sp, #S_OFF
674 b __sys_execve
675ENDPROC(sys_execve)
676
677ENTRY(sys_clone) 671ENTRY(sys_clone)
678 add ip, sp, #S_OFF 672 add ip, sp, #S_OFF
679 stw ip, [sp+], #4 673 stw ip, [sp+], #4
diff --git a/arch/unicore32/kernel/process.c b/arch/unicore32/kernel/process.c
index b008586dad7..a8fe265ce2c 100644
--- a/arch/unicore32/kernel/process.c
+++ b/arch/unicore32/kernel/process.c
@@ -258,6 +258,7 @@ void release_thread(struct task_struct *dead_task)
258} 258}
259 259
260asmlinkage void ret_from_fork(void) __asm__("ret_from_fork"); 260asmlinkage void ret_from_fork(void) __asm__("ret_from_fork");
261asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
261 262
262int 263int
263copy_thread(unsigned long clone_flags, unsigned long stack_start, 264copy_thread(unsigned long clone_flags, unsigned long stack_start,
@@ -266,17 +267,22 @@ copy_thread(unsigned long clone_flags, unsigned long stack_start,
266 struct thread_info *thread = task_thread_info(p); 267 struct thread_info *thread = task_thread_info(p);
267 struct pt_regs *childregs = task_pt_regs(p); 268 struct pt_regs *childregs = task_pt_regs(p);
268 269
269 *childregs = *regs;
270 childregs->UCreg_00 = 0;
271 childregs->UCreg_sp = stack_start;
272
273 memset(&thread->cpu_context, 0, sizeof(struct cpu_context_save)); 270 memset(&thread->cpu_context, 0, sizeof(struct cpu_context_save));
274 thread->cpu_context.sp = (unsigned long)childregs; 271 thread->cpu_context.sp = (unsigned long)childregs;
275 thread->cpu_context.pc = (unsigned long)ret_from_fork; 272 if (unlikely(!regs)) {
276 273 thread->cpu_context.pc = (unsigned long)ret_from_kernel_thread;
277 if (clone_flags & CLONE_SETTLS) 274 thread->cpu_context.r4 = stack_start;
278 childregs->UCreg_16 = regs->UCreg_03; 275 thread->cpu_context.r5 = stk_sz;
276 memset(childregs, 0, sizeof(struct pt_regs));
277 } else {
278 thread->cpu_context.pc = (unsigned long)ret_from_fork;
279 *childregs = *regs;
280 childregs->UCreg_00 = 0;
281 childregs->UCreg_sp = stack_start;
279 282
283 if (clone_flags & CLONE_SETTLS)
284 childregs->UCreg_16 = regs->UCreg_03;
285 }
280 return 0; 286 return 0;
281} 287}
282 288
@@ -305,42 +311,6 @@ int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fp)
305} 311}
306EXPORT_SYMBOL(dump_fpu); 312EXPORT_SYMBOL(dump_fpu);
307 313
308/*
309 * Shuffle the argument into the correct register before calling the
310 * thread function. r1 is the thread argument, r2 is the pointer to
311 * the thread function, and r3 points to the exit function.
312 */
313asm(".pushsection .text\n"
314" .align\n"
315" .type kernel_thread_helper, #function\n"
316"kernel_thread_helper:\n"
317" mov.a asr, r7\n"
318" mov r0, r4\n"
319" mov lr, r6\n"
320" mov pc, r5\n"
321" .size kernel_thread_helper, . - kernel_thread_helper\n"
322" .popsection");
323
324/*
325 * Create a kernel thread.
326 */
327pid_t kernel_thread(int (*fn)(void *), void *arg, unsigned long flags)
328{
329 struct pt_regs regs;
330
331 memset(&regs, 0, sizeof(regs));
332
333 regs.UCreg_04 = (unsigned long)arg;
334 regs.UCreg_05 = (unsigned long)fn;
335 regs.UCreg_06 = (unsigned long)do_exit;
336 regs.UCreg_07 = PRIV_MODE;
337 regs.UCreg_pc = (unsigned long)kernel_thread_helper;
338 regs.UCreg_asr = regs.UCreg_07 | PSR_I_BIT;
339
340 return do_fork(flags|CLONE_VM|CLONE_UNTRACED, 0, &regs, 0, NULL, NULL);
341}
342EXPORT_SYMBOL(kernel_thread);
343
344unsigned long get_wchan(struct task_struct *p) 314unsigned long get_wchan(struct task_struct *p)
345{ 315{
346 struct stackframe frame; 316 struct stackframe frame;
diff --git a/arch/unicore32/kernel/setup.h b/arch/unicore32/kernel/setup.h
index f23955028a1..30f749da8f7 100644
--- a/arch/unicore32/kernel/setup.h
+++ b/arch/unicore32/kernel/setup.h
@@ -30,4 +30,10 @@ extern char __vectors_start[], __vectors_end[];
30extern void kernel_thread_helper(void); 30extern void kernel_thread_helper(void);
31 31
32extern void __init early_signal_init(void); 32extern void __init early_signal_init(void);
33
34extern asmlinkage void __backtrace(void);
35extern asmlinkage void c_backtrace(unsigned long fp, int pmode);
36
37extern void __show_regs(struct pt_regs *);
38
33#endif 39#endif
diff --git a/arch/unicore32/kernel/sys.c b/arch/unicore32/kernel/sys.c
index fabdee96110..9680134b31f 100644
--- a/arch/unicore32/kernel/sys.c
+++ b/arch/unicore32/kernel/sys.c
@@ -42,69 +42,6 @@ asmlinkage long __sys_clone(unsigned long clone_flags, unsigned long newsp,
42 parent_tid, child_tid); 42 parent_tid, child_tid);
43} 43}
44 44
45/* sys_execve() executes a new program.
46 * This is called indirectly via a small wrapper
47 */
48asmlinkage long __sys_execve(const char __user *filename,
49 const char __user *const __user *argv,
50 const char __user *const __user *envp,
51 struct pt_regs *regs)
52{
53 int error;
54 struct filename *fn;
55
56 fn = getname(filename);
57 error = PTR_ERR(fn);
58 if (IS_ERR(fn))
59 goto out;
60 error = do_execve(fn->name, argv, envp, regs);
61 putname(fn);
62out:
63 return error;
64}
65
66int kernel_execve(const char *filename,
67 const char *const argv[],
68 const char *const envp[])
69{
70 struct pt_regs regs;
71 int ret;
72
73 memset(&regs, 0, sizeof(struct pt_regs));
74 ret = do_execve(filename,
75 (const char __user *const __user *)argv,
76 (const char __user *const __user *)envp, &regs);
77 if (ret < 0)
78 goto out;
79
80 /*
81 * Save argc to the register structure for userspace.
82 */
83 regs.UCreg_00 = ret;
84
85 /*
86 * We were successful. We won't be returning to our caller, but
87 * instead to user space by manipulating the kernel stack.
88 */
89 asm("add r0, %0, %1\n\t"
90 "mov r1, %2\n\t"
91 "mov r2, %3\n\t"
92 "mov r22, #0\n\t" /* not a syscall */
93 "mov r23, %0\n\t" /* thread structure */
94 "b.l memmove\n\t" /* copy regs to top of stack */
95 "mov sp, r0\n\t" /* reposition stack pointer */
96 "b ret_to_user"
97 :
98 : "r" (current_thread_info()),
99 "Ir" (THREAD_START_SP - sizeof(regs)),
100 "r" (&regs),
101 "Ir" (sizeof(regs))
102 : "r0", "r1", "r2", "r3", "ip", "lr", "memory");
103
104 out:
105 return ret;
106}
107
108/* Note: used by the compat code even in 64-bit Linux. */ 45/* Note: used by the compat code even in 64-bit Linux. */
109SYSCALL_DEFINE6(mmap2, unsigned long, addr, unsigned long, len, 46SYSCALL_DEFINE6(mmap2, unsigned long, addr, unsigned long, len,
110 unsigned long, prot, unsigned long, flags, 47 unsigned long, prot, unsigned long, flags,
diff --git a/arch/unicore32/mm/fault.c b/arch/unicore32/mm/fault.c
index 2eeb9c04cab..f9b5c10bcce 100644
--- a/arch/unicore32/mm/fault.c
+++ b/arch/unicore32/mm/fault.c
@@ -168,7 +168,7 @@ static inline bool access_error(unsigned int fsr, struct vm_area_struct *vma)
168} 168}
169 169
170static int __do_pf(struct mm_struct *mm, unsigned long addr, unsigned int fsr, 170static int __do_pf(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
171 struct task_struct *tsk) 171 unsigned int flags, struct task_struct *tsk)
172{ 172{
173 struct vm_area_struct *vma; 173 struct vm_area_struct *vma;
174 int fault; 174 int fault;
@@ -194,14 +194,7 @@ good_area:
194 * If for any reason at all we couldn't handle the fault, make 194 * If for any reason at all we couldn't handle the fault, make
195 * sure we exit gracefully rather than endlessly redo the fault. 195 * sure we exit gracefully rather than endlessly redo the fault.
196 */ 196 */
197 fault = handle_mm_fault(mm, vma, addr & PAGE_MASK, 197 fault = handle_mm_fault(mm, vma, addr & PAGE_MASK, flags);
198 (!(fsr ^ 0x12)) ? FAULT_FLAG_WRITE : 0);
199 if (unlikely(fault & VM_FAULT_ERROR))
200 return fault;
201 if (fault & VM_FAULT_MAJOR)
202 tsk->maj_flt++;
203 else
204 tsk->min_flt++;
205 return fault; 198 return fault;
206 199
207check_stack: 200check_stack:
@@ -216,6 +209,8 @@ static int do_pf(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
216 struct task_struct *tsk; 209 struct task_struct *tsk;
217 struct mm_struct *mm; 210 struct mm_struct *mm;
218 int fault, sig, code; 211 int fault, sig, code;
212 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
213 ((!(fsr ^ 0x12)) ? FAULT_FLAG_WRITE : 0);
219 214
220 tsk = current; 215 tsk = current;
221 mm = tsk->mm; 216 mm = tsk->mm;
@@ -236,6 +231,7 @@ static int do_pf(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
236 if (!user_mode(regs) 231 if (!user_mode(regs)
237 && !search_exception_tables(regs->UCreg_pc)) 232 && !search_exception_tables(regs->UCreg_pc))
238 goto no_context; 233 goto no_context;
234retry:
239 down_read(&mm->mmap_sem); 235 down_read(&mm->mmap_sem);
240 } else { 236 } else {
241 /* 237 /*
@@ -251,7 +247,28 @@ static int do_pf(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
251#endif 247#endif
252 } 248 }
253 249
254 fault = __do_pf(mm, addr, fsr, tsk); 250 fault = __do_pf(mm, addr, fsr, flags, tsk);
251
252 /* If we need to retry but a fatal signal is pending, handle the
253 * signal first. We do not need to release the mmap_sem because
254 * it would already be released in __lock_page_or_retry in
255 * mm/filemap.c. */
256 if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current))
257 return 0;
258
259 if (!(fault & VM_FAULT_ERROR) && (flags & FAULT_FLAG_ALLOW_RETRY)) {
260 if (fault & VM_FAULT_MAJOR)
261 tsk->maj_flt++;
262 else
263 tsk->min_flt++;
264 if (fault & VM_FAULT_RETRY) {
265 /* Clear FAULT_FLAG_ALLOW_RETRY to avoid any risk
266 * of starvation. */
267 flags &= ~FAULT_FLAG_ALLOW_RETRY;
268 goto retry;
269 }
270 }
271
255 up_read(&mm->mmap_sem); 272 up_read(&mm->mmap_sem);
256 273
257 /* 274 /*
diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 58790bd85c1..05afcca66de 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -142,7 +142,7 @@ KBUILD_CFLAGS += $(call cc-option,-mno-avx,)
142KBUILD_CFLAGS += $(mflags-y) 142KBUILD_CFLAGS += $(mflags-y)
143KBUILD_AFLAGS += $(mflags-y) 143KBUILD_AFLAGS += $(mflags-y)
144 144
145archscripts: 145archscripts: scripts_basic
146 $(Q)$(MAKE) $(build)=arch/x86/tools relocs 146 $(Q)$(MAKE) $(build)=arch/x86/tools relocs
147 147
148### 148###
diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
index c760e073963..e87b0cac14b 100644
--- a/arch/x86/boot/compressed/eboot.c
+++ b/arch/x86/boot/compressed/eboot.c
@@ -12,6 +12,8 @@
12#include <asm/setup.h> 12#include <asm/setup.h>
13#include <asm/desc.h> 13#include <asm/desc.h>
14 14
15#undef memcpy /* Use memcpy from misc.c */
16
15#include "eboot.h" 17#include "eboot.h"
16 18
17static efi_system_table_t *sys_table; 19static efi_system_table_t *sys_table;
diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
index 2a017441b8b..8c132a625b9 100644
--- a/arch/x86/boot/header.S
+++ b/arch/x86/boot/header.S
@@ -476,6 +476,3 @@ die:
476setup_corrupt: 476setup_corrupt:
477 .byte 7 477 .byte 7
478 .string "No setup signature found...\n" 478 .string "No setup signature found...\n"
479
480 .data
481dummy: .long 0
diff --git a/arch/x86/crypto/aesni-intel_glue.c b/arch/x86/crypto/aesni-intel_glue.c
index 7c04d0da709..1b9c22bea8a 100644
--- a/arch/x86/crypto/aesni-intel_glue.c
+++ b/arch/x86/crypto/aesni-intel_glue.c
@@ -515,6 +515,11 @@ static int xts_aesni_setkey(struct crypto_tfm *tfm, const u8 *key,
515} 515}
516 516
517 517
518static void aesni_xts_tweak(void *ctx, u8 *out, const u8 *in)
519{
520 aesni_enc(ctx, out, in);
521}
522
518static int xts_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, 523static int xts_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
519 struct scatterlist *src, unsigned int nbytes) 524 struct scatterlist *src, unsigned int nbytes)
520{ 525{
@@ -525,7 +530,7 @@ static int xts_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
525 .tbuflen = sizeof(buf), 530 .tbuflen = sizeof(buf),
526 531
527 .tweak_ctx = aes_ctx(ctx->raw_tweak_ctx), 532 .tweak_ctx = aes_ctx(ctx->raw_tweak_ctx),
528 .tweak_fn = XTS_TWEAK_CAST(aesni_enc), 533 .tweak_fn = aesni_xts_tweak,
529 .crypt_ctx = aes_ctx(ctx->raw_crypt_ctx), 534 .crypt_ctx = aes_ctx(ctx->raw_crypt_ctx),
530 .crypt_fn = lrw_xts_encrypt_callback, 535 .crypt_fn = lrw_xts_encrypt_callback,
531 }; 536 };
@@ -550,7 +555,7 @@ static int xts_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
550 .tbuflen = sizeof(buf), 555 .tbuflen = sizeof(buf),
551 556
552 .tweak_ctx = aes_ctx(ctx->raw_tweak_ctx), 557 .tweak_ctx = aes_ctx(ctx->raw_tweak_ctx),
553 .tweak_fn = XTS_TWEAK_CAST(aesni_enc), 558 .tweak_fn = aesni_xts_tweak,
554 .crypt_ctx = aes_ctx(ctx->raw_crypt_ctx), 559 .crypt_ctx = aes_ctx(ctx->raw_crypt_ctx),
555 .crypt_fn = lrw_xts_decrypt_callback, 560 .crypt_fn = lrw_xts_decrypt_callback,
556 }; 561 };
diff --git a/arch/x86/include/asm/efi.h b/arch/x86/include/asm/efi.h
index c9dcc181d4d..6e8fdf5ad11 100644
--- a/arch/x86/include/asm/efi.h
+++ b/arch/x86/include/asm/efi.h
@@ -35,7 +35,7 @@ extern unsigned long asmlinkage efi_call_phys(void *, ...);
35#define efi_call_virt6(f, a1, a2, a3, a4, a5, a6) \ 35#define efi_call_virt6(f, a1, a2, a3, a4, a5, a6) \
36 efi_call_virt(f, a1, a2, a3, a4, a5, a6) 36 efi_call_virt(f, a1, a2, a3, a4, a5, a6)
37 37
38#define efi_ioremap(addr, size, type) ioremap_cache(addr, size) 38#define efi_ioremap(addr, size, type, attr) ioremap_cache(addr, size)
39 39
40#else /* !CONFIG_X86_32 */ 40#else /* !CONFIG_X86_32 */
41 41
@@ -89,7 +89,7 @@ extern u64 efi_call6(void *fp, u64 arg1, u64 arg2, u64 arg3,
89 (u64)(a3), (u64)(a4), (u64)(a5), (u64)(a6)) 89 (u64)(a3), (u64)(a4), (u64)(a5), (u64)(a6))
90 90
91extern void __iomem *efi_ioremap(unsigned long addr, unsigned long size, 91extern void __iomem *efi_ioremap(unsigned long addr, unsigned long size,
92 u32 type); 92 u32 type, u64 attribute);
93 93
94#endif /* CONFIG_X86_32 */ 94#endif /* CONFIG_X86_32 */
95 95
@@ -98,6 +98,8 @@ extern void efi_set_executable(efi_memory_desc_t *md, bool executable);
98extern int efi_memblock_x86_reserve_range(void); 98extern int efi_memblock_x86_reserve_range(void);
99extern void efi_call_phys_prelog(void); 99extern void efi_call_phys_prelog(void);
100extern void efi_call_phys_epilog(void); 100extern void efi_call_phys_epilog(void);
101extern void efi_unmap_memmap(void);
102extern void efi_memory_uc(u64 addr, unsigned long size);
101 103
102#ifndef CONFIG_EFI 104#ifndef CONFIG_EFI
103/* 105/*
diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
index dcfde52979c..19f16ebaf4f 100644
--- a/arch/x86/include/asm/ptrace.h
+++ b/arch/x86/include/asm/ptrace.h
@@ -205,21 +205,14 @@ static inline bool user_64bit_mode(struct pt_regs *regs)
205} 205}
206#endif 206#endif
207 207
208/*
209 * X86_32 CPUs don't save ss and esp if the CPU is already in kernel mode
210 * when it traps. The previous stack will be directly underneath the saved
211 * registers, and 'sp/ss' won't even have been saved. Thus the '&regs->sp'.
212 *
213 * This is valid only for kernel mode traps.
214 */
215static inline unsigned long kernel_stack_pointer(struct pt_regs *regs)
216{
217#ifdef CONFIG_X86_32 208#ifdef CONFIG_X86_32
218 return (unsigned long)(&regs->sp); 209extern unsigned long kernel_stack_pointer(struct pt_regs *regs);
219#else 210#else
211static inline unsigned long kernel_stack_pointer(struct pt_regs *regs)
212{
220 return regs->sp; 213 return regs->sp;
221#endif
222} 214}
215#endif
223 216
224#define GET_IP(regs) ((regs)->ip) 217#define GET_IP(regs) ((regs)->ip)
225#define GET_FP(regs) ((regs)->bp) 218#define GET_FP(regs) ((regs)->bp)
diff --git a/arch/x86/include/asm/xen/hypercall.h b/arch/x86/include/asm/xen/hypercall.h
index 59c226d120c..c20d1ce62dc 100644
--- a/arch/x86/include/asm/xen/hypercall.h
+++ b/arch/x86/include/asm/xen/hypercall.h
@@ -359,18 +359,14 @@ HYPERVISOR_update_va_mapping(unsigned long va, pte_t new_val,
359 return _hypercall4(int, update_va_mapping, va, 359 return _hypercall4(int, update_va_mapping, va,
360 new_val.pte, new_val.pte >> 32, flags); 360 new_val.pte, new_val.pte >> 32, flags);
361} 361}
362extern int __must_check xen_event_channel_op_compat(int, void *);
362 363
363static inline int 364static inline int
364HYPERVISOR_event_channel_op(int cmd, void *arg) 365HYPERVISOR_event_channel_op(int cmd, void *arg)
365{ 366{
366 int rc = _hypercall2(int, event_channel_op, cmd, arg); 367 int rc = _hypercall2(int, event_channel_op, cmd, arg);
367 if (unlikely(rc == -ENOSYS)) { 368 if (unlikely(rc == -ENOSYS))
368 struct evtchn_op op; 369 rc = xen_event_channel_op_compat(cmd, arg);
369 op.cmd = cmd;
370 memcpy(&op.u, arg, sizeof(op.u));
371 rc = _hypercall1(int, event_channel_op_compat, &op);
372 memcpy(arg, &op.u, sizeof(op.u));
373 }
374 return rc; 370 return rc;
375} 371}
376 372
@@ -386,17 +382,14 @@ HYPERVISOR_console_io(int cmd, int count, char *str)
386 return _hypercall3(int, console_io, cmd, count, str); 382 return _hypercall3(int, console_io, cmd, count, str);
387} 383}
388 384
385extern int __must_check HYPERVISOR_physdev_op_compat(int, void *);
386
389static inline int 387static inline int
390HYPERVISOR_physdev_op(int cmd, void *arg) 388HYPERVISOR_physdev_op(int cmd, void *arg)
391{ 389{
392 int rc = _hypercall2(int, physdev_op, cmd, arg); 390 int rc = _hypercall2(int, physdev_op, cmd, arg);
393 if (unlikely(rc == -ENOSYS)) { 391 if (unlikely(rc == -ENOSYS))
394 struct physdev_op op; 392 rc = HYPERVISOR_physdev_op_compat(cmd, arg);
395 op.cmd = cmd;
396 memcpy(&op.u, arg, sizeof(op.u));
397 rc = _hypercall1(int, physdev_op_compat, &op);
398 memcpy(arg, &op.u, sizeof(op.u));
399 }
400 return rc; 393 return rc;
401} 394}
402 395
diff --git a/arch/x86/include/asm/xen/hypervisor.h b/arch/x86/include/asm/xen/hypervisor.h
index 66d0fff1ee8..125f344f06a 100644
--- a/arch/x86/include/asm/xen/hypervisor.h
+++ b/arch/x86/include/asm/xen/hypervisor.h
@@ -33,7 +33,6 @@
33#ifndef _ASM_X86_XEN_HYPERVISOR_H 33#ifndef _ASM_X86_XEN_HYPERVISOR_H
34#define _ASM_X86_XEN_HYPERVISOR_H 34#define _ASM_X86_XEN_HYPERVISOR_H
35 35
36/* arch/i386/kernel/setup.c */
37extern struct shared_info *HYPERVISOR_shared_info; 36extern struct shared_info *HYPERVISOR_shared_info;
38extern struct start_info *xen_start_info; 37extern struct start_info *xen_start_info;
39 38
diff --git a/arch/x86/include/asm/xen/interface.h b/arch/x86/include/asm/xen/interface.h
index 6d2f75a82a1..54d52ff1304 100644
--- a/arch/x86/include/asm/xen/interface.h
+++ b/arch/x86/include/asm/xen/interface.h
@@ -51,14 +51,14 @@
51 * with Xen so that on ARM we can have one ABI that works for 32 and 64 51 * with Xen so that on ARM we can have one ABI that works for 32 and 64
52 * bit guests. */ 52 * bit guests. */
53typedef unsigned long xen_pfn_t; 53typedef unsigned long xen_pfn_t;
54#define PRI_xen_pfn "lx"
54typedef unsigned long xen_ulong_t; 55typedef unsigned long xen_ulong_t;
56#define PRI_xen_ulong "lx"
55/* Guest handles for primitive C types. */ 57/* Guest handles for primitive C types. */
56__DEFINE_GUEST_HANDLE(uchar, unsigned char); 58__DEFINE_GUEST_HANDLE(uchar, unsigned char);
57__DEFINE_GUEST_HANDLE(uint, unsigned int); 59__DEFINE_GUEST_HANDLE(uint, unsigned int);
58__DEFINE_GUEST_HANDLE(ulong, unsigned long);
59DEFINE_GUEST_HANDLE(char); 60DEFINE_GUEST_HANDLE(char);
60DEFINE_GUEST_HANDLE(int); 61DEFINE_GUEST_HANDLE(int);
61DEFINE_GUEST_HANDLE(long);
62DEFINE_GUEST_HANDLE(void); 62DEFINE_GUEST_HANDLE(void);
63DEFINE_GUEST_HANDLE(uint64_t); 63DEFINE_GUEST_HANDLE(uint64_t);
64DEFINE_GUEST_HANDLE(uint32_t); 64DEFINE_GUEST_HANDLE(uint32_t);
diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
index c265593ec2c..1817fa91102 100644
--- a/arch/x86/kernel/apic/io_apic.c
+++ b/arch/x86/kernel/apic/io_apic.c
@@ -2257,6 +2257,9 @@ asmlinkage void smp_irq_move_cleanup_interrupt(void)
2257 continue; 2257 continue;
2258 2258
2259 cfg = irq_cfg(irq); 2259 cfg = irq_cfg(irq);
2260 if (!cfg)
2261 continue;
2262
2260 raw_spin_lock(&desc->lock); 2263 raw_spin_lock(&desc->lock);
2261 2264
2262 /* 2265 /*
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index f7e98a2c0d1..1b7d1656a04 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -631,6 +631,20 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)
631 } 631 }
632 } 632 }
633 633
634 /*
635 * The way access filter has a performance penalty on some workloads.
636 * Disable it on the affected CPUs.
637 */
638 if ((c->x86 == 0x15) &&
639 (c->x86_model >= 0x02) && (c->x86_model < 0x20)) {
640 u64 val;
641
642 if (!rdmsrl_safe(0xc0011021, &val) && !(val & 0x1E)) {
643 val |= 0x1E;
644 wrmsrl_safe(0xc0011021, val);
645 }
646 }
647
634 cpu_detect_cache_sizes(c); 648 cpu_detect_cache_sizes(c);
635 649
636 /* Multi core CPU? */ 650 /* Multi core CPU? */
diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
index 9a7c90d80bc..93c5451bdd5 100644
--- a/arch/x86/kernel/cpu/intel_cacheinfo.c
+++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
@@ -991,7 +991,7 @@ static struct attribute ** __cpuinit amd_l3_attrs(void)
991 if (attrs) 991 if (attrs)
992 return attrs; 992 return attrs;
993 993
994 n = sizeof (default_attrs) / sizeof (struct attribute *); 994 n = ARRAY_SIZE(default_attrs);
995 995
996 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) 996 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
997 n += 2; 997 n += 2;
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index 29e87d3b284..46cbf868969 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -2209,11 +2209,6 @@ static struct dev_ext_attribute dev_attr_cmci_disabled = {
2209 &mce_cmci_disabled 2209 &mce_cmci_disabled
2210}; 2210};
2211 2211
2212static struct dev_ext_attribute dev_attr_bios_cmci_threshold = {
2213 __ATTR(bios_cmci_threshold, 0444, device_show_int, NULL),
2214 &mce_bios_cmci_threshold
2215};
2216
2217static struct device_attribute *mce_device_attrs[] = { 2212static struct device_attribute *mce_device_attrs[] = {
2218 &dev_attr_tolerant.attr, 2213 &dev_attr_tolerant.attr,
2219 &dev_attr_check_interval.attr, 2214 &dev_attr_check_interval.attr,
@@ -2222,7 +2217,6 @@ static struct device_attribute *mce_device_attrs[] = {
2222 &dev_attr_dont_log_ce.attr, 2217 &dev_attr_dont_log_ce.attr,
2223 &dev_attr_ignore_ce.attr, 2218 &dev_attr_ignore_ce.attr,
2224 &dev_attr_cmci_disabled.attr, 2219 &dev_attr_cmci_disabled.attr,
2225 &dev_attr_bios_cmci_threshold.attr,
2226 NULL 2220 NULL
2227}; 2221};
2228 2222
diff --git a/arch/x86/kernel/cpu/mcheck/mce_amd.c b/arch/x86/kernel/cpu/mcheck/mce_amd.c
index c4e916d7737..1ac581f38df 100644
--- a/arch/x86/kernel/cpu/mcheck/mce_amd.c
+++ b/arch/x86/kernel/cpu/mcheck/mce_amd.c
@@ -6,7 +6,7 @@
6 * 6 *
7 * Written by Jacob Shin - AMD, Inc. 7 * Written by Jacob Shin - AMD, Inc.
8 * 8 *
9 * Support: borislav.petkov@amd.com 9 * Maintained by: Borislav Petkov <bp@alien8.de>
10 * 10 *
11 * April 2006 11 * April 2006
12 * - added support for AMD Family 0x10 processors 12 * - added support for AMD Family 0x10 processors
@@ -576,12 +576,10 @@ static __cpuinit int threshold_create_bank(unsigned int cpu, unsigned int bank)
576 int err = 0; 576 int err = 0;
577 577
578 if (shared_bank[bank]) { 578 if (shared_bank[bank]) {
579
580 nb = node_to_amd_nb(amd_get_nb_id(cpu)); 579 nb = node_to_amd_nb(amd_get_nb_id(cpu));
581 WARN_ON(!nb);
582 580
583 /* threshold descriptor already initialized on this node? */ 581 /* threshold descriptor already initialized on this node? */
584 if (nb->bank4) { 582 if (nb && nb->bank4) {
585 /* yes, use it */ 583 /* yes, use it */
586 b = nb->bank4; 584 b = nb->bank4;
587 err = kobject_add(b->kobj, &dev->kobj, name); 585 err = kobject_add(b->kobj, &dev->kobj, name);
@@ -615,8 +613,10 @@ static __cpuinit int threshold_create_bank(unsigned int cpu, unsigned int bank)
615 atomic_set(&b->cpus, 1); 613 atomic_set(&b->cpus, 1);
616 614
617 /* nb is already initialized, see above */ 615 /* nb is already initialized, see above */
618 WARN_ON(nb->bank4); 616 if (nb) {
619 nb->bank4 = b; 617 WARN_ON(nb->bank4);
618 nb->bank4 = b;
619 }
620 } 620 }
621 621
622 err = allocate_threshold_blocks(cpu, bank, 0, 622 err = allocate_threshold_blocks(cpu, bank, 0,
diff --git a/arch/x86/kernel/cpu/mcheck/mce_intel.c b/arch/x86/kernel/cpu/mcheck/mce_intel.c
index 5f88abf07e9..4f9a3cbfc4a 100644
--- a/arch/x86/kernel/cpu/mcheck/mce_intel.c
+++ b/arch/x86/kernel/cpu/mcheck/mce_intel.c
@@ -285,34 +285,39 @@ void cmci_clear(void)
285 raw_spin_unlock_irqrestore(&cmci_discover_lock, flags); 285 raw_spin_unlock_irqrestore(&cmci_discover_lock, flags);
286} 286}
287 287
288static long cmci_rediscover_work_func(void *arg)
289{
290 int banks;
291
292 /* Recheck banks in case CPUs don't all have the same */
293 if (cmci_supported(&banks))
294 cmci_discover(banks);
295
296 return 0;
297}
298
288/* 299/*
289 * After a CPU went down cycle through all the others and rediscover 300 * After a CPU went down cycle through all the others and rediscover
290 * Must run in process context. 301 * Must run in process context.
291 */ 302 */
292void cmci_rediscover(int dying) 303void cmci_rediscover(int dying)
293{ 304{
294 int banks; 305 int cpu, banks;
295 int cpu;
296 cpumask_var_t old;
297 306
298 if (!cmci_supported(&banks)) 307 if (!cmci_supported(&banks))
299 return; 308 return;
300 if (!alloc_cpumask_var(&old, GFP_KERNEL))
301 return;
302 cpumask_copy(old, &current->cpus_allowed);
303 309
304 for_each_online_cpu(cpu) { 310 for_each_online_cpu(cpu) {
305 if (cpu == dying) 311 if (cpu == dying)
306 continue; 312 continue;
307 if (set_cpus_allowed_ptr(current, cpumask_of(cpu))) 313
314 if (cpu == smp_processor_id()) {
315 cmci_rediscover_work_func(NULL);
308 continue; 316 continue;
309 /* Recheck banks in case CPUs don't all have the same */ 317 }
310 if (cmci_supported(&banks))
311 cmci_discover(banks);
312 }
313 318
314 set_cpus_allowed_ptr(current, old); 319 work_on_cpu(cpu, cmci_rediscover_work_func, NULL);
315 free_cpumask_var(old); 320 }
316} 321}
317 322
318/* 323/*
diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index 915b876edd1..4a3374e61a9 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -208,12 +208,14 @@ static bool check_hw_exists(void)
208 } 208 }
209 209
210 /* 210 /*
211 * Now write a value and read it back to see if it matches, 211 * Read the current value, change it and read it back to see if it
212 * this is needed to detect certain hardware emulators (qemu/kvm) 212 * matches, this is needed to detect certain hardware emulators
213 * that don't trap on the MSR access and always return 0s. 213 * (qemu/kvm) that don't trap on the MSR access and always return 0s.
214 */ 214 */
215 val = 0xabcdUL;
216 reg = x86_pmu_event_addr(0); 215 reg = x86_pmu_event_addr(0);
216 if (rdmsrl_safe(reg, &val))
217 goto msr_fail;
218 val ^= 0xffffUL;
217 ret = wrmsrl_safe(reg, val); 219 ret = wrmsrl_safe(reg, val);
218 ret |= rdmsrl_safe(reg, &val_new); 220 ret |= rdmsrl_safe(reg, &val_new);
219 if (ret || val != val_new) 221 if (ret || val != val_new)
@@ -338,6 +340,9 @@ int x86_setup_perfctr(struct perf_event *event)
338 /* BTS is currently only allowed for user-mode. */ 340 /* BTS is currently only allowed for user-mode. */
339 if (!attr->exclude_kernel) 341 if (!attr->exclude_kernel)
340 return -EOPNOTSUPP; 342 return -EOPNOTSUPP;
343
344 if (!attr->exclude_guest)
345 return -EOPNOTSUPP;
341 } 346 }
342 347
343 hwc->config |= config; 348 hwc->config |= config;
@@ -380,6 +385,9 @@ int x86_pmu_hw_config(struct perf_event *event)
380 if (event->attr.precise_ip) { 385 if (event->attr.precise_ip) {
381 int precise = 0; 386 int precise = 0;
382 387
388 if (!event->attr.exclude_guest)
389 return -EOPNOTSUPP;
390
383 /* Support for constant skid */ 391 /* Support for constant skid */
384 if (x86_pmu.pebs_active && !x86_pmu.pebs_broken) { 392 if (x86_pmu.pebs_active && !x86_pmu.pebs_broken) {
385 precise++; 393 precise++;
diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
index 99d96a4978b..3cf3d97cce3 100644
--- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
+++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
@@ -118,22 +118,24 @@ static void snbep_uncore_pci_disable_box(struct intel_uncore_box *box)
118{ 118{
119 struct pci_dev *pdev = box->pci_dev; 119 struct pci_dev *pdev = box->pci_dev;
120 int box_ctl = uncore_pci_box_ctl(box); 120 int box_ctl = uncore_pci_box_ctl(box);
121 u32 config; 121 u32 config = 0;
122 122
123 pci_read_config_dword(pdev, box_ctl, &config); 123 if (!pci_read_config_dword(pdev, box_ctl, &config)) {
124 config |= SNBEP_PMON_BOX_CTL_FRZ; 124 config |= SNBEP_PMON_BOX_CTL_FRZ;
125 pci_write_config_dword(pdev, box_ctl, config); 125 pci_write_config_dword(pdev, box_ctl, config);
126 }
126} 127}
127 128
128static void snbep_uncore_pci_enable_box(struct intel_uncore_box *box) 129static void snbep_uncore_pci_enable_box(struct intel_uncore_box *box)
129{ 130{
130 struct pci_dev *pdev = box->pci_dev; 131 struct pci_dev *pdev = box->pci_dev;
131 int box_ctl = uncore_pci_box_ctl(box); 132 int box_ctl = uncore_pci_box_ctl(box);
132 u32 config; 133 u32 config = 0;
133 134
134 pci_read_config_dword(pdev, box_ctl, &config); 135 if (!pci_read_config_dword(pdev, box_ctl, &config)) {
135 config &= ~SNBEP_PMON_BOX_CTL_FRZ; 136 config &= ~SNBEP_PMON_BOX_CTL_FRZ;
136 pci_write_config_dword(pdev, box_ctl, config); 137 pci_write_config_dword(pdev, box_ctl, config);
138 }
137} 139}
138 140
139static void snbep_uncore_pci_enable_event(struct intel_uncore_box *box, struct perf_event *event) 141static void snbep_uncore_pci_enable_event(struct intel_uncore_box *box, struct perf_event *event)
@@ -156,7 +158,7 @@ static u64 snbep_uncore_pci_read_counter(struct intel_uncore_box *box, struct pe
156{ 158{
157 struct pci_dev *pdev = box->pci_dev; 159 struct pci_dev *pdev = box->pci_dev;
158 struct hw_perf_event *hwc = &event->hw; 160 struct hw_perf_event *hwc = &event->hw;
159 u64 count; 161 u64 count = 0;
160 162
161 pci_read_config_dword(pdev, hwc->event_base, (u32 *)&count); 163 pci_read_config_dword(pdev, hwc->event_base, (u32 *)&count);
162 pci_read_config_dword(pdev, hwc->event_base + 4, (u32 *)&count + 1); 164 pci_read_config_dword(pdev, hwc->event_base + 4, (u32 *)&count + 1);
@@ -603,11 +605,12 @@ static struct pci_driver snbep_uncore_pci_driver = {
603/* 605/*
604 * build pci bus to socket mapping 606 * build pci bus to socket mapping
605 */ 607 */
606static void snbep_pci2phy_map_init(void) 608static int snbep_pci2phy_map_init(void)
607{ 609{
608 struct pci_dev *ubox_dev = NULL; 610 struct pci_dev *ubox_dev = NULL;
609 int i, bus, nodeid; 611 int i, bus, nodeid;
610 u32 config; 612 int err = 0;
613 u32 config = 0;
611 614
612 while (1) { 615 while (1) {
613 /* find the UBOX device */ 616 /* find the UBOX device */
@@ -618,10 +621,14 @@ static void snbep_pci2phy_map_init(void)
618 break; 621 break;
619 bus = ubox_dev->bus->number; 622 bus = ubox_dev->bus->number;
620 /* get the Node ID of the local register */ 623 /* get the Node ID of the local register */
621 pci_read_config_dword(ubox_dev, 0x40, &config); 624 err = pci_read_config_dword(ubox_dev, 0x40, &config);
625 if (err)
626 break;
622 nodeid = config; 627 nodeid = config;
623 /* get the Node ID mapping */ 628 /* get the Node ID mapping */
624 pci_read_config_dword(ubox_dev, 0x54, &config); 629 err = pci_read_config_dword(ubox_dev, 0x54, &config);
630 if (err)
631 break;
625 /* 632 /*
626 * every three bits in the Node ID mapping register maps 633 * every three bits in the Node ID mapping register maps
627 * to a particular node. 634 * to a particular node.
@@ -633,7 +640,11 @@ static void snbep_pci2phy_map_init(void)
633 } 640 }
634 } 641 }
635 }; 642 };
636 return; 643
644 if (ubox_dev)
645 pci_dev_put(ubox_dev);
646
647 return err ? pcibios_err_to_errno(err) : 0;
637} 648}
638/* end of Sandy Bridge-EP uncore support */ 649/* end of Sandy Bridge-EP uncore support */
639 650
@@ -1547,7 +1558,6 @@ void nhmex_rbox_alter_er(struct intel_uncore_box *box, struct perf_event *event)
1547{ 1558{
1548 struct hw_perf_event *hwc = &event->hw; 1559 struct hw_perf_event *hwc = &event->hw;
1549 struct hw_perf_event_extra *reg1 = &hwc->extra_reg; 1560 struct hw_perf_event_extra *reg1 = &hwc->extra_reg;
1550 int port;
1551 1561
1552 /* adjust the main event selector and extra register index */ 1562 /* adjust the main event selector and extra register index */
1553 if (reg1->idx % 2) { 1563 if (reg1->idx % 2) {
@@ -1559,7 +1569,6 @@ void nhmex_rbox_alter_er(struct intel_uncore_box *box, struct perf_event *event)
1559 } 1569 }
1560 1570
1561 /* adjust extra register config */ 1571 /* adjust extra register config */
1562 port = reg1->idx / 6 + box->pmu->pmu_idx * 4;
1563 switch (reg1->idx % 6) { 1572 switch (reg1->idx % 6) {
1564 case 2: 1573 case 2:
1565 /* shift the 8~15 bits to the 0~7 bits */ 1574 /* shift the 8~15 bits to the 0~7 bits */
@@ -2578,9 +2587,11 @@ static int __init uncore_pci_init(void)
2578 2587
2579 switch (boot_cpu_data.x86_model) { 2588 switch (boot_cpu_data.x86_model) {
2580 case 45: /* Sandy Bridge-EP */ 2589 case 45: /* Sandy Bridge-EP */
2590 ret = snbep_pci2phy_map_init();
2591 if (ret)
2592 return ret;
2581 pci_uncores = snbep_pci_uncores; 2593 pci_uncores = snbep_pci_uncores;
2582 uncore_pci_driver = &snbep_uncore_pci_driver; 2594 uncore_pci_driver = &snbep_uncore_pci_driver;
2583 snbep_pci2phy_map_init();
2584 break; 2595 break;
2585 default: 2596 default:
2586 return 0; 2597 return 0;
@@ -2926,6 +2937,9 @@ static int __init intel_uncore_init(void)
2926 if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL) 2937 if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL)
2927 return -ENODEV; 2938 return -ENODEV;
2928 2939
2940 if (cpu_has_hypervisor)
2941 return -ENODEV;
2942
2929 ret = uncore_pci_init(); 2943 ret = uncore_pci_init();
2930 if (ret) 2944 if (ret)
2931 goto fail; 2945 goto fail;
diff --git a/arch/x86/kernel/cpu/perf_event_knc.c b/arch/x86/kernel/cpu/perf_event_knc.c
index 7c46bfdbc37..4b7731bf23a 100644
--- a/arch/x86/kernel/cpu/perf_event_knc.c
+++ b/arch/x86/kernel/cpu/perf_event_knc.c
@@ -3,6 +3,8 @@
3#include <linux/perf_event.h> 3#include <linux/perf_event.h>
4#include <linux/types.h> 4#include <linux/types.h>
5 5
6#include <asm/hardirq.h>
7
6#include "perf_event.h" 8#include "perf_event.h"
7 9
8static const u64 knc_perfmon_event_map[] = 10static const u64 knc_perfmon_event_map[] =
@@ -173,30 +175,100 @@ static void knc_pmu_enable_all(int added)
173static inline void 175static inline void
174knc_pmu_disable_event(struct perf_event *event) 176knc_pmu_disable_event(struct perf_event *event)
175{ 177{
176 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
177 struct hw_perf_event *hwc = &event->hw; 178 struct hw_perf_event *hwc = &event->hw;
178 u64 val; 179 u64 val;
179 180
180 val = hwc->config; 181 val = hwc->config;
181 if (cpuc->enabled) 182 val &= ~ARCH_PERFMON_EVENTSEL_ENABLE;
182 val &= ~ARCH_PERFMON_EVENTSEL_ENABLE;
183 183
184 (void)wrmsrl_safe(hwc->config_base + hwc->idx, val); 184 (void)wrmsrl_safe(hwc->config_base + hwc->idx, val);
185} 185}
186 186
187static void knc_pmu_enable_event(struct perf_event *event) 187static void knc_pmu_enable_event(struct perf_event *event)
188{ 188{
189 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
190 struct hw_perf_event *hwc = &event->hw; 189 struct hw_perf_event *hwc = &event->hw;
191 u64 val; 190 u64 val;
192 191
193 val = hwc->config; 192 val = hwc->config;
194 if (cpuc->enabled) 193 val |= ARCH_PERFMON_EVENTSEL_ENABLE;
195 val |= ARCH_PERFMON_EVENTSEL_ENABLE;
196 194
197 (void)wrmsrl_safe(hwc->config_base + hwc->idx, val); 195 (void)wrmsrl_safe(hwc->config_base + hwc->idx, val);
198} 196}
199 197
198static inline u64 knc_pmu_get_status(void)
199{
200 u64 status;
201
202 rdmsrl(MSR_KNC_IA32_PERF_GLOBAL_STATUS, status);
203
204 return status;
205}
206
207static inline void knc_pmu_ack_status(u64 ack)
208{
209 wrmsrl(MSR_KNC_IA32_PERF_GLOBAL_OVF_CONTROL, ack);
210}
211
212static int knc_pmu_handle_irq(struct pt_regs *regs)
213{
214 struct perf_sample_data data;
215 struct cpu_hw_events *cpuc;
216 int handled = 0;
217 int bit, loops;
218 u64 status;
219
220 cpuc = &__get_cpu_var(cpu_hw_events);
221
222 knc_pmu_disable_all();
223
224 status = knc_pmu_get_status();
225 if (!status) {
226 knc_pmu_enable_all(0);
227 return handled;
228 }
229
230 loops = 0;
231again:
232 knc_pmu_ack_status(status);
233 if (++loops > 100) {
234 WARN_ONCE(1, "perf: irq loop stuck!\n");
235 perf_event_print_debug();
236 goto done;
237 }
238
239 inc_irq_stat(apic_perf_irqs);
240
241 for_each_set_bit(bit, (unsigned long *)&status, X86_PMC_IDX_MAX) {
242 struct perf_event *event = cpuc->events[bit];
243
244 handled++;
245
246 if (!test_bit(bit, cpuc->active_mask))
247 continue;
248
249 if (!intel_pmu_save_and_restart(event))
250 continue;
251
252 perf_sample_data_init(&data, 0, event->hw.last_period);
253
254 if (perf_event_overflow(event, &data, regs))
255 x86_pmu_stop(event, 0);
256 }
257
258 /*
259 * Repeat if there is more work to be done:
260 */
261 status = knc_pmu_get_status();
262 if (status)
263 goto again;
264
265done:
266 knc_pmu_enable_all(0);
267
268 return handled;
269}
270
271
200PMU_FORMAT_ATTR(event, "config:0-7" ); 272PMU_FORMAT_ATTR(event, "config:0-7" );
201PMU_FORMAT_ATTR(umask, "config:8-15" ); 273PMU_FORMAT_ATTR(umask, "config:8-15" );
202PMU_FORMAT_ATTR(edge, "config:18" ); 274PMU_FORMAT_ATTR(edge, "config:18" );
@@ -214,7 +286,7 @@ static struct attribute *intel_knc_formats_attr[] = {
214 286
215static __initconst struct x86_pmu knc_pmu = { 287static __initconst struct x86_pmu knc_pmu = {
216 .name = "knc", 288 .name = "knc",
217 .handle_irq = x86_pmu_handle_irq, 289 .handle_irq = knc_pmu_handle_irq,
218 .disable_all = knc_pmu_disable_all, 290 .disable_all = knc_pmu_disable_all,
219 .enable_all = knc_pmu_enable_all, 291 .enable_all = knc_pmu_enable_all,
220 .enable = knc_pmu_enable_event, 292 .enable = knc_pmu_enable_event,
@@ -226,12 +298,11 @@ static __initconst struct x86_pmu knc_pmu = {
226 .event_map = knc_pmu_event_map, 298 .event_map = knc_pmu_event_map,
227 .max_events = ARRAY_SIZE(knc_perfmon_event_map), 299 .max_events = ARRAY_SIZE(knc_perfmon_event_map),
228 .apic = 1, 300 .apic = 1,
229 .max_period = (1ULL << 31) - 1, 301 .max_period = (1ULL << 39) - 1,
230 .version = 0, 302 .version = 0,
231 .num_counters = 2, 303 .num_counters = 2,
232 /* in theory 40 bits, early silicon is buggy though */ 304 .cntval_bits = 40,
233 .cntval_bits = 32, 305 .cntval_mask = (1ULL << 40) - 1,
234 .cntval_mask = (1ULL << 32) - 1,
235 .get_event_constraints = x86_get_event_constraints, 306 .get_event_constraints = x86_get_event_constraints,
236 .event_constraints = knc_event_constraints, 307 .event_constraints = knc_event_constraints,
237 .format_attrs = intel_knc_formats_attr, 308 .format_attrs = intel_knc_formats_attr,
diff --git a/arch/x86/kernel/cpu/perf_event_p6.c b/arch/x86/kernel/cpu/perf_event_p6.c
index e4dd0f7a045..7d0270bd793 100644
--- a/arch/x86/kernel/cpu/perf_event_p6.c
+++ b/arch/x86/kernel/cpu/perf_event_p6.c
@@ -8,13 +8,106 @@
8 */ 8 */
9static const u64 p6_perfmon_event_map[] = 9static const u64 p6_perfmon_event_map[] =
10{ 10{
11 [PERF_COUNT_HW_CPU_CYCLES] = 0x0079, 11 [PERF_COUNT_HW_CPU_CYCLES] = 0x0079, /* CPU_CLK_UNHALTED */
12 [PERF_COUNT_HW_INSTRUCTIONS] = 0x00c0, 12 [PERF_COUNT_HW_INSTRUCTIONS] = 0x00c0, /* INST_RETIRED */
13 [PERF_COUNT_HW_CACHE_REFERENCES] = 0x0f2e, 13 [PERF_COUNT_HW_CACHE_REFERENCES] = 0x0f2e, /* L2_RQSTS:M:E:S:I */
14 [PERF_COUNT_HW_CACHE_MISSES] = 0x012e, 14 [PERF_COUNT_HW_CACHE_MISSES] = 0x012e, /* L2_RQSTS:I */
15 [PERF_COUNT_HW_BRANCH_INSTRUCTIONS] = 0x00c4, 15 [PERF_COUNT_HW_BRANCH_INSTRUCTIONS] = 0x00c4, /* BR_INST_RETIRED */
16 [PERF_COUNT_HW_BRANCH_MISSES] = 0x00c5, 16 [PERF_COUNT_HW_BRANCH_MISSES] = 0x00c5, /* BR_MISS_PRED_RETIRED */
17 [PERF_COUNT_HW_BUS_CYCLES] = 0x0062, 17 [PERF_COUNT_HW_BUS_CYCLES] = 0x0062, /* BUS_DRDY_CLOCKS */
18 [PERF_COUNT_HW_STALLED_CYCLES_FRONTEND] = 0x00a2, /* RESOURCE_STALLS */
19
20};
21
22static __initconst u64 p6_hw_cache_event_ids
23 [PERF_COUNT_HW_CACHE_MAX]
24 [PERF_COUNT_HW_CACHE_OP_MAX]
25 [PERF_COUNT_HW_CACHE_RESULT_MAX] =
26{
27 [ C(L1D) ] = {
28 [ C(OP_READ) ] = {
29 [ C(RESULT_ACCESS) ] = 0x0043, /* DATA_MEM_REFS */
30 [ C(RESULT_MISS) ] = 0x0045, /* DCU_LINES_IN */
31 },
32 [ C(OP_WRITE) ] = {
33 [ C(RESULT_ACCESS) ] = 0,
34 [ C(RESULT_MISS) ] = 0x0f29, /* L2_LD:M:E:S:I */
35 },
36 [ C(OP_PREFETCH) ] = {
37 [ C(RESULT_ACCESS) ] = 0,
38 [ C(RESULT_MISS) ] = 0,
39 },
40 },
41 [ C(L1I ) ] = {
42 [ C(OP_READ) ] = {
43 [ C(RESULT_ACCESS) ] = 0x0080, /* IFU_IFETCH */
44 [ C(RESULT_MISS) ] = 0x0f28, /* L2_IFETCH:M:E:S:I */
45 },
46 [ C(OP_WRITE) ] = {
47 [ C(RESULT_ACCESS) ] = -1,
48 [ C(RESULT_MISS) ] = -1,
49 },
50 [ C(OP_PREFETCH) ] = {
51 [ C(RESULT_ACCESS) ] = 0,
52 [ C(RESULT_MISS) ] = 0,
53 },
54 },
55 [ C(LL ) ] = {
56 [ C(OP_READ) ] = {
57 [ C(RESULT_ACCESS) ] = 0,
58 [ C(RESULT_MISS) ] = 0,
59 },
60 [ C(OP_WRITE) ] = {
61 [ C(RESULT_ACCESS) ] = 0,
62 [ C(RESULT_MISS) ] = 0x0025, /* L2_M_LINES_INM */
63 },
64 [ C(OP_PREFETCH) ] = {
65 [ C(RESULT_ACCESS) ] = 0,
66 [ C(RESULT_MISS) ] = 0,
67 },
68 },
69 [ C(DTLB) ] = {
70 [ C(OP_READ) ] = {
71 [ C(RESULT_ACCESS) ] = 0x0043, /* DATA_MEM_REFS */
72 [ C(RESULT_MISS) ] = 0,
73 },
74 [ C(OP_WRITE) ] = {
75 [ C(RESULT_ACCESS) ] = 0,
76 [ C(RESULT_MISS) ] = 0,
77 },
78 [ C(OP_PREFETCH) ] = {
79 [ C(RESULT_ACCESS) ] = 0,
80 [ C(RESULT_MISS) ] = 0,
81 },
82 },
83 [ C(ITLB) ] = {
84 [ C(OP_READ) ] = {
85 [ C(RESULT_ACCESS) ] = 0x0080, /* IFU_IFETCH */
86 [ C(RESULT_MISS) ] = 0x0085, /* ITLB_MISS */
87 },
88 [ C(OP_WRITE) ] = {
89 [ C(RESULT_ACCESS) ] = -1,
90 [ C(RESULT_MISS) ] = -1,
91 },
92 [ C(OP_PREFETCH) ] = {
93 [ C(RESULT_ACCESS) ] = -1,
94 [ C(RESULT_MISS) ] = -1,
95 },
96 },
97 [ C(BPU ) ] = {
98 [ C(OP_READ) ] = {
99 [ C(RESULT_ACCESS) ] = 0x00c4, /* BR_INST_RETIRED */
100 [ C(RESULT_MISS) ] = 0x00c5, /* BR_MISS_PRED_RETIRED */
101 },
102 [ C(OP_WRITE) ] = {
103 [ C(RESULT_ACCESS) ] = -1,
104 [ C(RESULT_MISS) ] = -1,
105 },
106 [ C(OP_PREFETCH) ] = {
107 [ C(RESULT_ACCESS) ] = -1,
108 [ C(RESULT_MISS) ] = -1,
109 },
110 },
18}; 111};
19 112
20static u64 p6_pmu_event_map(int hw_event) 113static u64 p6_pmu_event_map(int hw_event)
@@ -34,7 +127,7 @@ static struct event_constraint p6_event_constraints[] =
34{ 127{
35 INTEL_EVENT_CONSTRAINT(0xc1, 0x1), /* FLOPS */ 128 INTEL_EVENT_CONSTRAINT(0xc1, 0x1), /* FLOPS */
36 INTEL_EVENT_CONSTRAINT(0x10, 0x1), /* FP_COMP_OPS_EXE */ 129 INTEL_EVENT_CONSTRAINT(0x10, 0x1), /* FP_COMP_OPS_EXE */
37 INTEL_EVENT_CONSTRAINT(0x11, 0x1), /* FP_ASSIST */ 130 INTEL_EVENT_CONSTRAINT(0x11, 0x2), /* FP_ASSIST */
38 INTEL_EVENT_CONSTRAINT(0x12, 0x2), /* MUL */ 131 INTEL_EVENT_CONSTRAINT(0x12, 0x2), /* MUL */
39 INTEL_EVENT_CONSTRAINT(0x13, 0x2), /* DIV */ 132 INTEL_EVENT_CONSTRAINT(0x13, 0x2), /* DIV */
40 INTEL_EVENT_CONSTRAINT(0x14, 0x1), /* CYCLES_DIV_BUSY */ 133 INTEL_EVENT_CONSTRAINT(0x14, 0x1), /* CYCLES_DIV_BUSY */
@@ -64,25 +157,25 @@ static void p6_pmu_enable_all(int added)
64static inline void 157static inline void
65p6_pmu_disable_event(struct perf_event *event) 158p6_pmu_disable_event(struct perf_event *event)
66{ 159{
67 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
68 struct hw_perf_event *hwc = &event->hw; 160 struct hw_perf_event *hwc = &event->hw;
69 u64 val = P6_NOP_EVENT; 161 u64 val = P6_NOP_EVENT;
70 162
71 if (cpuc->enabled)
72 val |= ARCH_PERFMON_EVENTSEL_ENABLE;
73
74 (void)wrmsrl_safe(hwc->config_base, val); 163 (void)wrmsrl_safe(hwc->config_base, val);
75} 164}
76 165
77static void p6_pmu_enable_event(struct perf_event *event) 166static void p6_pmu_enable_event(struct perf_event *event)
78{ 167{
79 struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
80 struct hw_perf_event *hwc = &event->hw; 168 struct hw_perf_event *hwc = &event->hw;
81 u64 val; 169 u64 val;
82 170
83 val = hwc->config; 171 val = hwc->config;
84 if (cpuc->enabled) 172
85 val |= ARCH_PERFMON_EVENTSEL_ENABLE; 173 /*
174 * p6 only has a global event enable, set on PerfEvtSel0
175 * We "disable" events by programming P6_NOP_EVENT
176 * and we rely on p6_pmu_enable_all() being called
177 * to actually enable the events.
178 */
86 179
87 (void)wrmsrl_safe(hwc->config_base, val); 180 (void)wrmsrl_safe(hwc->config_base, val);
88} 181}
@@ -158,5 +251,9 @@ __init int p6_pmu_init(void)
158 251
159 x86_pmu = p6_pmu; 252 x86_pmu = p6_pmu;
160 253
254 memcpy(hw_cache_event_ids, p6_hw_cache_event_ids,
255 sizeof(hw_cache_event_ids));
256
257
161 return 0; 258 return 0;
162} 259}
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index ed858e9e9a7..df06ade26be 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -1077,6 +1077,9 @@ void __init memblock_x86_fill(void)
1077 memblock_add(ei->addr, ei->size); 1077 memblock_add(ei->addr, ei->size);
1078 } 1078 }
1079 1079
1080 /* throw away partial pages */
1081 memblock_trim_memory(PAGE_SIZE);
1082
1080 memblock_dump_all(); 1083 memblock_dump_all();
1081} 1084}
1082 1085
diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
index a1193aef6d7..88b725aa1d5 100644
--- a/arch/x86/kernel/entry_32.S
+++ b/arch/x86/kernel/entry_32.S
@@ -1035,7 +1035,7 @@ ENTRY(xen_sysenter_target)
1035 1035
1036ENTRY(xen_hypervisor_callback) 1036ENTRY(xen_hypervisor_callback)
1037 CFI_STARTPROC 1037 CFI_STARTPROC
1038 pushl_cfi $0 1038 pushl_cfi $-1 /* orig_ax = -1 => not a system call */
1039 SAVE_ALL 1039 SAVE_ALL
1040 TRACE_IRQS_OFF 1040 TRACE_IRQS_OFF
1041 1041
@@ -1077,14 +1077,16 @@ ENTRY(xen_failsafe_callback)
10772: mov 8(%esp),%es 10772: mov 8(%esp),%es
10783: mov 12(%esp),%fs 10783: mov 12(%esp),%fs
10794: mov 16(%esp),%gs 10794: mov 16(%esp),%gs
1080 /* EAX == 0 => Category 1 (Bad segment)
1081 EAX != 0 => Category 2 (Bad IRET) */
1080 testl %eax,%eax 1082 testl %eax,%eax
1081 popl_cfi %eax 1083 popl_cfi %eax
1082 lea 16(%esp),%esp 1084 lea 16(%esp),%esp
1083 CFI_ADJUST_CFA_OFFSET -16 1085 CFI_ADJUST_CFA_OFFSET -16
1084 jz 5f 1086 jz 5f
1085 addl $16,%esp 1087 addl $16,%esp
1086 jmp iret_exc # EAX != 0 => Category 2 (Bad IRET) 1088 jmp iret_exc
10875: pushl_cfi $0 # EAX == 0 => Category 1 (Bad segment) 10895: pushl_cfi $-1 /* orig_ax = -1 => not a system call */
1088 SAVE_ALL 1090 SAVE_ALL
1089 jmp ret_from_exception 1091 jmp ret_from_exception
1090 CFI_ENDPROC 1092 CFI_ENDPROC
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index 0c58952d64e..1328fe49a3f 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -995,8 +995,8 @@ END(interrupt)
995 */ 995 */
996 .p2align CONFIG_X86_L1_CACHE_SHIFT 996 .p2align CONFIG_X86_L1_CACHE_SHIFT
997common_interrupt: 997common_interrupt:
998 ASM_CLAC
999 XCPT_FRAME 998 XCPT_FRAME
999 ASM_CLAC
1000 addq $-0x80,(%rsp) /* Adjust vector to [-256,-1] range */ 1000 addq $-0x80,(%rsp) /* Adjust vector to [-256,-1] range */
1001 interrupt do_IRQ 1001 interrupt do_IRQ
1002 /* 0(%rsp): old_rsp-ARGOFFSET */ 1002 /* 0(%rsp): old_rsp-ARGOFFSET */
@@ -1135,8 +1135,8 @@ END(common_interrupt)
1135 */ 1135 */
1136.macro apicinterrupt num sym do_sym 1136.macro apicinterrupt num sym do_sym
1137ENTRY(\sym) 1137ENTRY(\sym)
1138 ASM_CLAC
1139 INTR_FRAME 1138 INTR_FRAME
1139 ASM_CLAC
1140 pushq_cfi $~(\num) 1140 pushq_cfi $~(\num)
1141.Lcommon_\sym: 1141.Lcommon_\sym:
1142 interrupt \do_sym 1142 interrupt \do_sym
@@ -1190,8 +1190,8 @@ apicinterrupt IRQ_WORK_VECTOR \
1190 */ 1190 */
1191.macro zeroentry sym do_sym 1191.macro zeroentry sym do_sym
1192ENTRY(\sym) 1192ENTRY(\sym)
1193 ASM_CLAC
1194 INTR_FRAME 1193 INTR_FRAME
1194 ASM_CLAC
1195 PARAVIRT_ADJUST_EXCEPTION_FRAME 1195 PARAVIRT_ADJUST_EXCEPTION_FRAME
1196 pushq_cfi $-1 /* ORIG_RAX: no syscall to restart */ 1196 pushq_cfi $-1 /* ORIG_RAX: no syscall to restart */
1197 subq $ORIG_RAX-R15, %rsp 1197 subq $ORIG_RAX-R15, %rsp
@@ -1208,8 +1208,8 @@ END(\sym)
1208 1208
1209.macro paranoidzeroentry sym do_sym 1209.macro paranoidzeroentry sym do_sym
1210ENTRY(\sym) 1210ENTRY(\sym)
1211 ASM_CLAC
1212 INTR_FRAME 1211 INTR_FRAME
1212 ASM_CLAC
1213 PARAVIRT_ADJUST_EXCEPTION_FRAME 1213 PARAVIRT_ADJUST_EXCEPTION_FRAME
1214 pushq_cfi $-1 /* ORIG_RAX: no syscall to restart */ 1214 pushq_cfi $-1 /* ORIG_RAX: no syscall to restart */
1215 subq $ORIG_RAX-R15, %rsp 1215 subq $ORIG_RAX-R15, %rsp
@@ -1227,8 +1227,8 @@ END(\sym)
1227#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8) 1227#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
1228.macro paranoidzeroentry_ist sym do_sym ist 1228.macro paranoidzeroentry_ist sym do_sym ist
1229ENTRY(\sym) 1229ENTRY(\sym)
1230 ASM_CLAC
1231 INTR_FRAME 1230 INTR_FRAME
1231 ASM_CLAC
1232 PARAVIRT_ADJUST_EXCEPTION_FRAME 1232 PARAVIRT_ADJUST_EXCEPTION_FRAME
1233 pushq_cfi $-1 /* ORIG_RAX: no syscall to restart */ 1233 pushq_cfi $-1 /* ORIG_RAX: no syscall to restart */
1234 subq $ORIG_RAX-R15, %rsp 1234 subq $ORIG_RAX-R15, %rsp
@@ -1247,8 +1247,8 @@ END(\sym)
1247 1247
1248.macro errorentry sym do_sym 1248.macro errorentry sym do_sym
1249ENTRY(\sym) 1249ENTRY(\sym)
1250 ASM_CLAC
1251 XCPT_FRAME 1250 XCPT_FRAME
1251 ASM_CLAC
1252 PARAVIRT_ADJUST_EXCEPTION_FRAME 1252 PARAVIRT_ADJUST_EXCEPTION_FRAME
1253 subq $ORIG_RAX-R15, %rsp 1253 subq $ORIG_RAX-R15, %rsp
1254 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15 1254 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
@@ -1266,8 +1266,8 @@ END(\sym)
1266 /* error code is on the stack already */ 1266 /* error code is on the stack already */
1267.macro paranoiderrorentry sym do_sym 1267.macro paranoiderrorentry sym do_sym
1268ENTRY(\sym) 1268ENTRY(\sym)
1269 ASM_CLAC
1270 XCPT_FRAME 1269 XCPT_FRAME
1270 ASM_CLAC
1271 PARAVIRT_ADJUST_EXCEPTION_FRAME 1271 PARAVIRT_ADJUST_EXCEPTION_FRAME
1272 subq $ORIG_RAX-R15, %rsp 1272 subq $ORIG_RAX-R15, %rsp
1273 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15 1273 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
@@ -1435,7 +1435,7 @@ ENTRY(xen_failsafe_callback)
1435 CFI_RESTORE r11 1435 CFI_RESTORE r11
1436 addq $0x30,%rsp 1436 addq $0x30,%rsp
1437 CFI_ADJUST_CFA_OFFSET -0x30 1437 CFI_ADJUST_CFA_OFFSET -0x30
1438 pushq_cfi $0 1438 pushq_cfi $-1 /* orig_ax = -1 => not a system call */
1439 SAVE_ALL 1439 SAVE_ALL
1440 jmp error_exit 1440 jmp error_exit
1441 CFI_ENDPROC 1441 CFI_ENDPROC
diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
index b3e5e51bc90..4180a874c76 100644
--- a/arch/x86/kernel/kvm.c
+++ b/arch/x86/kernel/kvm.c
@@ -247,7 +247,10 @@ do_async_page_fault(struct pt_regs *regs, unsigned long error_code)
247 break; 247 break;
248 case KVM_PV_REASON_PAGE_NOT_PRESENT: 248 case KVM_PV_REASON_PAGE_NOT_PRESENT:
249 /* page is swapped out by the host. */ 249 /* page is swapped out by the host. */
250 rcu_irq_enter();
251 exit_idle();
250 kvm_async_pf_task_wait((u32)read_cr2()); 252 kvm_async_pf_task_wait((u32)read_cr2());
253 rcu_irq_exit();
251 break; 254 break;
252 case KVM_PV_REASON_PAGE_READY: 255 case KVM_PV_REASON_PAGE_READY:
253 rcu_irq_enter(); 256 rcu_irq_enter();
diff --git a/arch/x86/kernel/microcode_amd.c b/arch/x86/kernel/microcode_amd.c
index 7720ff5a9ee..efdec7cd8e0 100644
--- a/arch/x86/kernel/microcode_amd.c
+++ b/arch/x86/kernel/microcode_amd.c
@@ -8,8 +8,8 @@
8 * Tigran Aivazian <tigran@aivazian.fsnet.co.uk> 8 * Tigran Aivazian <tigran@aivazian.fsnet.co.uk>
9 * 9 *
10 * Maintainers: 10 * Maintainers:
11 * Andreas Herrmann <andreas.herrmann3@amd.com> 11 * Andreas Herrmann <herrmann.der.user@googlemail.com>
12 * Borislav Petkov <borislav.petkov@amd.com> 12 * Borislav Petkov <bp@alien8.de>
13 * 13 *
14 * This driver allows to upgrade microcode on F10h AMD 14 * This driver allows to upgrade microcode on F10h AMD
15 * CPUs and later. 15 * CPUs and later.
@@ -190,6 +190,7 @@ static unsigned int verify_patch_size(int cpu, u32 patch_size,
190#define F1XH_MPB_MAX_SIZE 2048 190#define F1XH_MPB_MAX_SIZE 2048
191#define F14H_MPB_MAX_SIZE 1824 191#define F14H_MPB_MAX_SIZE 1824
192#define F15H_MPB_MAX_SIZE 4096 192#define F15H_MPB_MAX_SIZE 4096
193#define F16H_MPB_MAX_SIZE 3458
193 194
194 switch (c->x86) { 195 switch (c->x86) {
195 case 0x14: 196 case 0x14:
@@ -198,6 +199,9 @@ static unsigned int verify_patch_size(int cpu, u32 patch_size,
198 case 0x15: 199 case 0x15:
199 max_size = F15H_MPB_MAX_SIZE; 200 max_size = F15H_MPB_MAX_SIZE;
200 break; 201 break;
202 case 0x16:
203 max_size = F16H_MPB_MAX_SIZE;
204 break;
201 default: 205 default:
202 max_size = F1XH_MPB_MAX_SIZE; 206 max_size = F1XH_MPB_MAX_SIZE;
203 break; 207 break;
diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
index b00b33a1839..5e0596b0632 100644
--- a/arch/x86/kernel/ptrace.c
+++ b/arch/x86/kernel/ptrace.c
@@ -22,6 +22,7 @@
22#include <linux/perf_event.h> 22#include <linux/perf_event.h>
23#include <linux/hw_breakpoint.h> 23#include <linux/hw_breakpoint.h>
24#include <linux/rcupdate.h> 24#include <linux/rcupdate.h>
25#include <linux/module.h>
25 26
26#include <asm/uaccess.h> 27#include <asm/uaccess.h>
27#include <asm/pgtable.h> 28#include <asm/pgtable.h>
@@ -166,6 +167,35 @@ static inline bool invalid_selector(u16 value)
166 167
167#define FLAG_MASK FLAG_MASK_32 168#define FLAG_MASK FLAG_MASK_32
168 169
170/*
171 * X86_32 CPUs don't save ss and esp if the CPU is already in kernel mode
172 * when it traps. The previous stack will be directly underneath the saved
173 * registers, and 'sp/ss' won't even have been saved. Thus the '&regs->sp'.
174 *
175 * Now, if the stack is empty, '&regs->sp' is out of range. In this
176 * case we try to take the previous stack. To always return a non-null
177 * stack pointer we fall back to regs as stack if no previous stack
178 * exists.
179 *
180 * This is valid only for kernel mode traps.
181 */
182unsigned long kernel_stack_pointer(struct pt_regs *regs)
183{
184 unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1);
185 unsigned long sp = (unsigned long)&regs->sp;
186 struct thread_info *tinfo;
187
188 if (context == (sp & ~(THREAD_SIZE - 1)))
189 return sp;
190
191 tinfo = (struct thread_info *)context;
192 if (tinfo->previous_esp)
193 return tinfo->previous_esp;
194
195 return (unsigned long)regs;
196}
197EXPORT_SYMBOL_GPL(kernel_stack_pointer);
198
169static unsigned long *pt_regs_access(struct pt_regs *regs, unsigned long regno) 199static unsigned long *pt_regs_access(struct pt_regs *regs, unsigned long regno)
170{ 200{
171 BUILD_BUG_ON(offsetof(struct pt_regs, bx) != 0); 201 BUILD_BUG_ON(offsetof(struct pt_regs, bx) != 0);
diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
index 52190a938b4..4e8ba39eaf0 100644
--- a/arch/x86/kernel/reboot.c
+++ b/arch/x86/kernel/reboot.c
@@ -358,14 +358,6 @@ static struct dmi_system_id __initdata reboot_dmi_table[] = {
358 DMI_MATCH(DMI_PRODUCT_NAME, "VGN-Z540N"), 358 DMI_MATCH(DMI_PRODUCT_NAME, "VGN-Z540N"),
359 }, 359 },
360 }, 360 },
361 { /* Handle problems with rebooting on CompuLab SBC-FITPC2 */
362 .callback = set_bios_reboot,
363 .ident = "CompuLab SBC-FITPC2",
364 .matches = {
365 DMI_MATCH(DMI_SYS_VENDOR, "CompuLab"),
366 DMI_MATCH(DMI_PRODUCT_NAME, "SBC-FITPC2"),
367 },
368 },
369 { /* Handle problems with rebooting on ASUS P4S800 */ 361 { /* Handle problems with rebooting on ASUS P4S800 */
370 .callback = set_bios_reboot, 362 .callback = set_bios_reboot,
371 .ident = "ASUS P4S800", 363 .ident = "ASUS P4S800",
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index a2bb18e0283..ca45696f30f 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -920,8 +920,22 @@ void __init setup_arch(char **cmdline_p)
920 920
921#ifdef CONFIG_X86_64 921#ifdef CONFIG_X86_64
922 if (max_pfn > max_low_pfn) { 922 if (max_pfn > max_low_pfn) {
923 max_pfn_mapped = init_memory_mapping(1UL<<32, 923 int i;
924 max_pfn<<PAGE_SHIFT); 924 unsigned long start, end;
925 unsigned long start_pfn, end_pfn;
926
927 for_each_mem_pfn_range(i, MAX_NUMNODES, &start_pfn, &end_pfn,
928 NULL) {
929
930 end = PFN_PHYS(end_pfn);
931 if (end <= (1UL<<32))
932 continue;
933
934 start = PFN_PHYS(start_pfn);
935 max_pfn_mapped = init_memory_mapping(
936 max((1UL<<32), start), end);
937 }
938
925 /* can we preseve max_low_pfn ?*/ 939 /* can we preseve max_low_pfn ?*/
926 max_low_pfn = max_pfn; 940 max_low_pfn = max_pfn;
927 } 941 }
@@ -1035,6 +1049,18 @@ void __init setup_arch(char **cmdline_p)
1035 arch_init_ideal_nops(); 1049 arch_init_ideal_nops();
1036 1050
1037 register_refined_jiffies(CLOCK_TICK_RATE); 1051 register_refined_jiffies(CLOCK_TICK_RATE);
1052
1053#ifdef CONFIG_EFI
1054 /* Once setup is done above, disable efi_enabled on mismatched
1055 * firmware/kernel archtectures since there is no support for
1056 * runtime services.
1057 */
1058 if (efi_enabled && IS_ENABLED(CONFIG_X86_64) != efi_64bit) {
1059 pr_info("efi: Setup done, disabling due to 32/64-bit mismatch\n");
1060 efi_unmap_memmap();
1061 efi_enabled = 0;
1062 }
1063#endif
1038} 1064}
1039 1065
1040#ifdef CONFIG_X86_32 1066#ifdef CONFIG_X86_32
diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
index 29ad351804e..70b27ee6118 100644
--- a/arch/x86/kernel/signal.c
+++ b/arch/x86/kernel/signal.c
@@ -824,10 +824,8 @@ do_notify_resume(struct pt_regs *regs, void *unused, __u32 thread_info_flags)
824 mce_notify_process(); 824 mce_notify_process();
825#endif /* CONFIG_X86_64 && CONFIG_X86_MCE */ 825#endif /* CONFIG_X86_64 && CONFIG_X86_MCE */
826 826
827 if (thread_info_flags & _TIF_UPROBE) { 827 if (thread_info_flags & _TIF_UPROBE)
828 clear_thread_flag(TIF_UPROBE);
829 uprobe_notify_resume(regs); 828 uprobe_notify_resume(regs);
830 }
831 829
832 /* deal with pending signal delivery */ 830 /* deal with pending signal delivery */
833 if (thread_info_flags & _TIF_SIGPENDING) 831 if (thread_info_flags & _TIF_SIGPENDING)
diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
index 9538f00827a..aafa5557b39 100644
--- a/arch/x86/kernel/uprobes.c
+++ b/arch/x86/kernel/uprobes.c
@@ -651,31 +651,19 @@ void arch_uprobe_abort_xol(struct arch_uprobe *auprobe, struct pt_regs *regs)
651 651
652/* 652/*
653 * Skip these instructions as per the currently known x86 ISA. 653 * Skip these instructions as per the currently known x86 ISA.
654 * 0x66* { 0x90 | 0x0f 0x1f | 0x0f 0x19 | 0x87 0xc0 } 654 * rep=0x66*; nop=0x90
655 */ 655 */
656static bool __skip_sstep(struct arch_uprobe *auprobe, struct pt_regs *regs) 656static bool __skip_sstep(struct arch_uprobe *auprobe, struct pt_regs *regs)
657{ 657{
658 int i; 658 int i;
659 659
660 for (i = 0; i < MAX_UINSN_BYTES; i++) { 660 for (i = 0; i < MAX_UINSN_BYTES; i++) {
661 if ((auprobe->insn[i] == 0x66)) 661 if (auprobe->insn[i] == 0x66)
662 continue; 662 continue;
663 663
664 if (auprobe->insn[i] == 0x90) 664 if (auprobe->insn[i] == 0x90)
665 return true; 665 return true;
666 666
667 if (i == (MAX_UINSN_BYTES - 1))
668 break;
669
670 if ((auprobe->insn[i] == 0x0f) && (auprobe->insn[i+1] == 0x1f))
671 return true;
672
673 if ((auprobe->insn[i] == 0x0f) && (auprobe->insn[i+1] == 0x19))
674 return true;
675
676 if ((auprobe->insn[i] == 0x87) && (auprobe->insn[i+1] == 0xc0))
677 return true;
678
679 break; 667 break;
680 } 668 }
681 return false; 669 return false;
diff --git a/arch/x86/kvm/cpuid.h b/arch/x86/kvm/cpuid.h
index a10e4601685..58fc5148882 100644
--- a/arch/x86/kvm/cpuid.h
+++ b/arch/x86/kvm/cpuid.h
@@ -24,6 +24,9 @@ static inline bool guest_cpuid_has_xsave(struct kvm_vcpu *vcpu)
24{ 24{
25 struct kvm_cpuid_entry2 *best; 25 struct kvm_cpuid_entry2 *best;
26 26
27 if (!static_cpu_has(X86_FEATURE_XSAVE))
28 return 0;
29
27 best = kvm_find_cpuid_entry(vcpu, 1, 0); 30 best = kvm_find_cpuid_entry(vcpu, 1, 0);
28 return best && (best->ecx & bit(X86_FEATURE_XSAVE)); 31 return best && (best->ecx & bit(X86_FEATURE_XSAVE));
29} 32}
diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
index c6e6b721b6e..43e9fadca5d 100644
--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -1311,7 +1311,7 @@ void kvm_lapic_set_base(struct kvm_vcpu *vcpu, u64 value)
1311 vcpu->arch.apic_base = value; 1311 vcpu->arch.apic_base = value;
1312 if (apic_x2apic_mode(apic)) { 1312 if (apic_x2apic_mode(apic)) {
1313 u32 id = kvm_apic_id(apic); 1313 u32 id = kvm_apic_id(apic);
1314 u32 ldr = ((id & ~0xf) << 16) | (1 << (id & 0xf)); 1314 u32 ldr = ((id >> 4) << 16) | (1 << (id & 0xf));
1315 kvm_apic_set_ldr(apic, ldr); 1315 kvm_apic_set_ldr(apic, ldr);
1316 } 1316 }
1317 apic->base_address = apic->vcpu->arch.apic_base & 1317 apic->base_address = apic->vcpu->arch.apic_base &
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index d289fee1ffb..6f85fe0bf95 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -2497,8 +2497,7 @@ static void mmu_set_spte(struct kvm_vcpu *vcpu, u64 *sptep,
2497 } 2497 }
2498 } 2498 }
2499 2499
2500 if (!is_error_pfn(pfn)) 2500 kvm_release_pfn_clean(pfn);
2501 kvm_release_pfn_clean(pfn);
2502} 2501}
2503 2502
2504static void nonpaging_new_cr3(struct kvm_vcpu *vcpu) 2503static void nonpaging_new_cr3(struct kvm_vcpu *vcpu)
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index ad6b1dd06f8..f85815945fc 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -6549,19 +6549,22 @@ static void vmx_cpuid_update(struct kvm_vcpu *vcpu)
6549 } 6549 }
6550 } 6550 }
6551 6551
6552 exec_control = vmcs_read32(SECONDARY_VM_EXEC_CONTROL);
6553 /* Exposing INVPCID only when PCID is exposed */ 6552 /* Exposing INVPCID only when PCID is exposed */
6554 best = kvm_find_cpuid_entry(vcpu, 0x7, 0); 6553 best = kvm_find_cpuid_entry(vcpu, 0x7, 0);
6555 if (vmx_invpcid_supported() && 6554 if (vmx_invpcid_supported() &&
6556 best && (best->ebx & bit(X86_FEATURE_INVPCID)) && 6555 best && (best->ebx & bit(X86_FEATURE_INVPCID)) &&
6557 guest_cpuid_has_pcid(vcpu)) { 6556 guest_cpuid_has_pcid(vcpu)) {
6557 exec_control = vmcs_read32(SECONDARY_VM_EXEC_CONTROL);
6558 exec_control |= SECONDARY_EXEC_ENABLE_INVPCID; 6558 exec_control |= SECONDARY_EXEC_ENABLE_INVPCID;
6559 vmcs_write32(SECONDARY_VM_EXEC_CONTROL, 6559 vmcs_write32(SECONDARY_VM_EXEC_CONTROL,
6560 exec_control); 6560 exec_control);
6561 } else { 6561 } else {
6562 exec_control &= ~SECONDARY_EXEC_ENABLE_INVPCID; 6562 if (cpu_has_secondary_exec_ctrls()) {
6563 vmcs_write32(SECONDARY_VM_EXEC_CONTROL, 6563 exec_control = vmcs_read32(SECONDARY_VM_EXEC_CONTROL);
6564 exec_control); 6564 exec_control &= ~SECONDARY_EXEC_ENABLE_INVPCID;
6565 vmcs_write32(SECONDARY_VM_EXEC_CONTROL,
6566 exec_control);
6567 }
6565 if (best) 6568 if (best)
6566 best->ebx &= ~bit(X86_FEATURE_INVPCID); 6569 best->ebx &= ~bit(X86_FEATURE_INVPCID);
6567 } 6570 }
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 1eefebe5d72..4f7641756be 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -3779,7 +3779,7 @@ static int write_exit_mmio(struct kvm_vcpu *vcpu, gpa_t gpa,
3779{ 3779{
3780 struct kvm_mmio_fragment *frag = &vcpu->mmio_fragments[0]; 3780 struct kvm_mmio_fragment *frag = &vcpu->mmio_fragments[0];
3781 3781
3782 memcpy(vcpu->run->mmio.data, frag->data, frag->len); 3782 memcpy(vcpu->run->mmio.data, frag->data, min(8u, frag->len));
3783 return X86EMUL_CONTINUE; 3783 return X86EMUL_CONTINUE;
3784} 3784}
3785 3785
@@ -3832,18 +3832,11 @@ mmio:
3832 bytes -= handled; 3832 bytes -= handled;
3833 val += handled; 3833 val += handled;
3834 3834
3835 while (bytes) { 3835 WARN_ON(vcpu->mmio_nr_fragments >= KVM_MAX_MMIO_FRAGMENTS);
3836 unsigned now = min(bytes, 8U); 3836 frag = &vcpu->mmio_fragments[vcpu->mmio_nr_fragments++];
3837 3837 frag->gpa = gpa;
3838 frag = &vcpu->mmio_fragments[vcpu->mmio_nr_fragments++]; 3838 frag->data = val;
3839 frag->gpa = gpa; 3839 frag->len = bytes;
3840 frag->data = val;
3841 frag->len = now;
3842
3843 gpa += now;
3844 val += now;
3845 bytes -= now;
3846 }
3847 return X86EMUL_CONTINUE; 3840 return X86EMUL_CONTINUE;
3848} 3841}
3849 3842
@@ -3890,7 +3883,7 @@ int emulator_read_write(struct x86_emulate_ctxt *ctxt, unsigned long addr,
3890 vcpu->mmio_needed = 1; 3883 vcpu->mmio_needed = 1;
3891 vcpu->mmio_cur_fragment = 0; 3884 vcpu->mmio_cur_fragment = 0;
3892 3885
3893 vcpu->run->mmio.len = vcpu->mmio_fragments[0].len; 3886 vcpu->run->mmio.len = min(8u, vcpu->mmio_fragments[0].len);
3894 vcpu->run->mmio.is_write = vcpu->mmio_is_write = ops->write; 3887 vcpu->run->mmio.is_write = vcpu->mmio_is_write = ops->write;
3895 vcpu->run->exit_reason = KVM_EXIT_MMIO; 3888 vcpu->run->exit_reason = KVM_EXIT_MMIO;
3896 vcpu->run->mmio.phys_addr = gpa; 3889 vcpu->run->mmio.phys_addr = gpa;
@@ -5522,28 +5515,44 @@ static int complete_emulated_pio(struct kvm_vcpu *vcpu)
5522 * 5515 *
5523 * read: 5516 * read:
5524 * for each fragment 5517 * for each fragment
5525 * write gpa, len 5518 * for each mmio piece in the fragment
5526 * exit 5519 * write gpa, len
5527 * copy data 5520 * exit
5521 * copy data
5528 * execute insn 5522 * execute insn
5529 * 5523 *
5530 * write: 5524 * write:
5531 * for each fragment 5525 * for each fragment
5532 * write gpa, len 5526 * for each mmio piece in the fragment
5533 * copy data 5527 * write gpa, len
5534 * exit 5528 * copy data
5529 * exit
5535 */ 5530 */
5536static int complete_emulated_mmio(struct kvm_vcpu *vcpu) 5531static int complete_emulated_mmio(struct kvm_vcpu *vcpu)
5537{ 5532{
5538 struct kvm_run *run = vcpu->run; 5533 struct kvm_run *run = vcpu->run;
5539 struct kvm_mmio_fragment *frag; 5534 struct kvm_mmio_fragment *frag;
5535 unsigned len;
5540 5536
5541 BUG_ON(!vcpu->mmio_needed); 5537 BUG_ON(!vcpu->mmio_needed);
5542 5538
5543 /* Complete previous fragment */ 5539 /* Complete previous fragment */
5544 frag = &vcpu->mmio_fragments[vcpu->mmio_cur_fragment++]; 5540 frag = &vcpu->mmio_fragments[vcpu->mmio_cur_fragment];
5541 len = min(8u, frag->len);
5545 if (!vcpu->mmio_is_write) 5542 if (!vcpu->mmio_is_write)
5546 memcpy(frag->data, run->mmio.data, frag->len); 5543 memcpy(frag->data, run->mmio.data, len);
5544
5545 if (frag->len <= 8) {
5546 /* Switch to the next fragment. */
5547 frag++;
5548 vcpu->mmio_cur_fragment++;
5549 } else {
5550 /* Go forward to the next mmio piece. */
5551 frag->data += len;
5552 frag->gpa += len;
5553 frag->len -= len;
5554 }
5555
5547 if (vcpu->mmio_cur_fragment == vcpu->mmio_nr_fragments) { 5556 if (vcpu->mmio_cur_fragment == vcpu->mmio_nr_fragments) {
5548 vcpu->mmio_needed = 0; 5557 vcpu->mmio_needed = 0;
5549 if (vcpu->mmio_is_write) 5558 if (vcpu->mmio_is_write)
@@ -5551,13 +5560,12 @@ static int complete_emulated_mmio(struct kvm_vcpu *vcpu)
5551 vcpu->mmio_read_completed = 1; 5560 vcpu->mmio_read_completed = 1;
5552 return complete_emulated_io(vcpu); 5561 return complete_emulated_io(vcpu);
5553 } 5562 }
5554 /* Initiate next fragment */ 5563
5555 ++frag;
5556 run->exit_reason = KVM_EXIT_MMIO; 5564 run->exit_reason = KVM_EXIT_MMIO;
5557 run->mmio.phys_addr = frag->gpa; 5565 run->mmio.phys_addr = frag->gpa;
5558 if (vcpu->mmio_is_write) 5566 if (vcpu->mmio_is_write)
5559 memcpy(run->mmio.data, frag->data, frag->len); 5567 memcpy(run->mmio.data, frag->data, min(8u, frag->len));
5560 run->mmio.len = frag->len; 5568 run->mmio.len = min(8u, frag->len);
5561 run->mmio.is_write = vcpu->mmio_is_write; 5569 run->mmio.is_write = vcpu->mmio_is_write;
5562 vcpu->arch.complete_userspace_io = complete_emulated_mmio; 5570 vcpu->arch.complete_userspace_io = complete_emulated_mmio;
5563 return 0; 5571 return 0;
@@ -5773,6 +5781,9 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu,
5773 int pending_vec, max_bits, idx; 5781 int pending_vec, max_bits, idx;
5774 struct desc_ptr dt; 5782 struct desc_ptr dt;
5775 5783
5784 if (!guest_cpuid_has_xsave(vcpu) && (sregs->cr4 & X86_CR4_OSXSAVE))
5785 return -EINVAL;
5786
5776 dt.size = sregs->idt.limit; 5787 dt.size = sregs->idt.limit;
5777 dt.address = sregs->idt.base; 5788 dt.address = sregs->idt.base;
5778 kvm_x86_ops->set_idt(vcpu, &dt); 5789 kvm_x86_ops->set_idt(vcpu, &dt);
diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index ab1f6a93b52..d7aea41563b 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -35,40 +35,44 @@ struct map_range {
35 unsigned page_size_mask; 35 unsigned page_size_mask;
36}; 36};
37 37
38static void __init find_early_table_space(struct map_range *mr, unsigned long end, 38/*
39 int use_pse, int use_gbpages) 39 * First calculate space needed for kernel direct mapping page tables to cover
40 * mr[0].start to mr[nr_range - 1].end, while accounting for possible 2M and 1GB
41 * pages. Then find enough contiguous space for those page tables.
42 */
43static void __init find_early_table_space(struct map_range *mr, int nr_range)
40{ 44{
41 unsigned long puds, pmds, ptes, tables, start = 0, good_end = end; 45 int i;
46 unsigned long puds = 0, pmds = 0, ptes = 0, tables;
47 unsigned long start = 0, good_end;
42 phys_addr_t base; 48 phys_addr_t base;
43 49
44 puds = (end + PUD_SIZE - 1) >> PUD_SHIFT; 50 for (i = 0; i < nr_range; i++) {
45 tables = roundup(puds * sizeof(pud_t), PAGE_SIZE); 51 unsigned long range, extra;
46
47 if (use_gbpages) {
48 unsigned long extra;
49
50 extra = end - ((end>>PUD_SHIFT) << PUD_SHIFT);
51 pmds = (extra + PMD_SIZE - 1) >> PMD_SHIFT;
52 } else
53 pmds = (end + PMD_SIZE - 1) >> PMD_SHIFT;
54 52
55 tables += roundup(pmds * sizeof(pmd_t), PAGE_SIZE); 53 range = mr[i].end - mr[i].start;
54 puds += (range + PUD_SIZE - 1) >> PUD_SHIFT;
56 55
57 if (use_pse) { 56 if (mr[i].page_size_mask & (1 << PG_LEVEL_1G)) {
58 unsigned long extra; 57 extra = range - ((range >> PUD_SHIFT) << PUD_SHIFT);
58 pmds += (extra + PMD_SIZE - 1) >> PMD_SHIFT;
59 } else {
60 pmds += (range + PMD_SIZE - 1) >> PMD_SHIFT;
61 }
59 62
60 extra = end - ((end>>PMD_SHIFT) << PMD_SHIFT); 63 if (mr[i].page_size_mask & (1 << PG_LEVEL_2M)) {
64 extra = range - ((range >> PMD_SHIFT) << PMD_SHIFT);
61#ifdef CONFIG_X86_32 65#ifdef CONFIG_X86_32
62 extra += PMD_SIZE; 66 extra += PMD_SIZE;
63#endif 67#endif
64 /* The first 2/4M doesn't use large pages. */ 68 ptes += (extra + PAGE_SIZE - 1) >> PAGE_SHIFT;
65 if (mr->start < PMD_SIZE) 69 } else {
66 extra += mr->end - mr->start; 70 ptes += (range + PAGE_SIZE - 1) >> PAGE_SHIFT;
67 71 }
68 ptes = (extra + PAGE_SIZE - 1) >> PAGE_SHIFT; 72 }
69 } else
70 ptes = (end + PAGE_SIZE - 1) >> PAGE_SHIFT;
71 73
74 tables = roundup(puds * sizeof(pud_t), PAGE_SIZE);
75 tables += roundup(pmds * sizeof(pmd_t), PAGE_SIZE);
72 tables += roundup(ptes * sizeof(pte_t), PAGE_SIZE); 76 tables += roundup(ptes * sizeof(pte_t), PAGE_SIZE);
73 77
74#ifdef CONFIG_X86_32 78#ifdef CONFIG_X86_32
@@ -86,7 +90,7 @@ static void __init find_early_table_space(struct map_range *mr, unsigned long en
86 pgt_buf_top = pgt_buf_start + (tables >> PAGE_SHIFT); 90 pgt_buf_top = pgt_buf_start + (tables >> PAGE_SHIFT);
87 91
88 printk(KERN_DEBUG "kernel direct mapping tables up to %#lx @ [mem %#010lx-%#010lx]\n", 92 printk(KERN_DEBUG "kernel direct mapping tables up to %#lx @ [mem %#010lx-%#010lx]\n",
89 end - 1, pgt_buf_start << PAGE_SHIFT, 93 mr[nr_range - 1].end - 1, pgt_buf_start << PAGE_SHIFT,
90 (pgt_buf_top << PAGE_SHIFT) - 1); 94 (pgt_buf_top << PAGE_SHIFT) - 1);
91} 95}
92 96
@@ -267,7 +271,7 @@ unsigned long __init_refok init_memory_mapping(unsigned long start,
267 * nodes are discovered. 271 * nodes are discovered.
268 */ 272 */
269 if (!after_bootmem) 273 if (!after_bootmem)
270 find_early_table_space(&mr[0], end, use_pse, use_gbpages); 274 find_early_table_space(mr, nr_range);
271 275
272 for (i = 0; i < nr_range; i++) 276 for (i = 0; i < nr_range; i++)
273 ret = kernel_physical_mapping_init(mr[i].start, mr[i].end, 277 ret = kernel_physical_mapping_init(mr[i].start, mr[i].end,
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 2b6b4a3c8be..3baff255ada 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -386,7 +386,8 @@ phys_pte_init(pte_t *pte_page, unsigned long addr, unsigned long end,
386 * these mappings are more intelligent. 386 * these mappings are more intelligent.
387 */ 387 */
388 if (pte_val(*pte)) { 388 if (pte_val(*pte)) {
389 pages++; 389 if (!after_bootmem)
390 pages++;
390 continue; 391 continue;
391 } 392 }
392 393
@@ -451,6 +452,8 @@ phys_pmd_init(pmd_t *pmd_page, unsigned long address, unsigned long end,
451 * attributes. 452 * attributes.
452 */ 453 */
453 if (page_size_mask & (1 << PG_LEVEL_2M)) { 454 if (page_size_mask & (1 << PG_LEVEL_2M)) {
455 if (!after_bootmem)
456 pages++;
454 last_map_addr = next; 457 last_map_addr = next;
455 continue; 458 continue;
456 } 459 }
@@ -526,6 +529,8 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
526 * attributes. 529 * attributes.
527 */ 530 */
528 if (page_size_mask & (1 << PG_LEVEL_1G)) { 531 if (page_size_mask & (1 << PG_LEVEL_1G)) {
532 if (!after_bootmem)
533 pages++;
529 last_map_addr = next; 534 last_map_addr = next;
530 continue; 535 continue;
531 } 536 }
diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
index 0777f042e40..60f926cd8b0 100644
--- a/arch/x86/mm/tlb.c
+++ b/arch/x86/mm/tlb.c
@@ -197,7 +197,7 @@ void flush_tlb_mm_range(struct mm_struct *mm, unsigned long start,
197 } 197 }
198 198
199 if (end == TLB_FLUSH_ALL || tlb_flushall_shift == -1 199 if (end == TLB_FLUSH_ALL || tlb_flushall_shift == -1
200 || vmflag == VM_HUGETLB) { 200 || vmflag & VM_HUGETLB) {
201 local_flush_tlb(); 201 local_flush_tlb();
202 goto flush_all; 202 goto flush_all;
203 } 203 }
diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
index 26b8a8514ee..48768df2471 100644
--- a/arch/x86/oprofile/nmi_int.c
+++ b/arch/x86/oprofile/nmi_int.c
@@ -55,7 +55,7 @@ u64 op_x86_get_ctrl(struct op_x86_model_spec const *model,
55 val |= counter_config->extra; 55 val |= counter_config->extra;
56 event &= model->event_mask ? model->event_mask : 0xFF; 56 event &= model->event_mask ? model->event_mask : 0xFF;
57 val |= event & 0xFF; 57 val |= event & 0xFF;
58 val |= (event & 0x0F00) << 24; 58 val |= (u64)(event & 0x0F00) << 24;
59 59
60 return val; 60 return val;
61} 61}
diff --git a/arch/x86/pci/ce4100.c b/arch/x86/pci/ce4100.c
index 41bd2a2d2c5..b914e20b5a0 100644
--- a/arch/x86/pci/ce4100.c
+++ b/arch/x86/pci/ce4100.c
@@ -115,6 +115,16 @@ static void sata_revid_read(struct sim_dev_reg *reg, u32 *value)
115 reg_read(reg, value); 115 reg_read(reg, value);
116} 116}
117 117
118static void reg_noirq_read(struct sim_dev_reg *reg, u32 *value)
119{
120 unsigned long flags;
121
122 raw_spin_lock_irqsave(&pci_config_lock, flags);
123 /* force interrupt pin value to 0 */
124 *value = reg->sim_reg.value & 0xfff00ff;
125 raw_spin_unlock_irqrestore(&pci_config_lock, flags);
126}
127
118static struct sim_dev_reg bus1_fixups[] = { 128static struct sim_dev_reg bus1_fixups[] = {
119 DEFINE_REG(2, 0, 0x10, (16*MB), reg_init, reg_read, reg_write) 129 DEFINE_REG(2, 0, 0x10, (16*MB), reg_init, reg_read, reg_write)
120 DEFINE_REG(2, 0, 0x14, (256), reg_init, reg_read, reg_write) 130 DEFINE_REG(2, 0, 0x14, (256), reg_init, reg_read, reg_write)
@@ -144,6 +154,7 @@ static struct sim_dev_reg bus1_fixups[] = {
144 DEFINE_REG(11, 5, 0x10, (64*KB), reg_init, reg_read, reg_write) 154 DEFINE_REG(11, 5, 0x10, (64*KB), reg_init, reg_read, reg_write)
145 DEFINE_REG(11, 6, 0x10, (256), reg_init, reg_read, reg_write) 155 DEFINE_REG(11, 6, 0x10, (256), reg_init, reg_read, reg_write)
146 DEFINE_REG(11, 7, 0x10, (64*KB), reg_init, reg_read, reg_write) 156 DEFINE_REG(11, 7, 0x10, (64*KB), reg_init, reg_read, reg_write)
157 DEFINE_REG(11, 7, 0x3c, 256, reg_init, reg_noirq_read, reg_write)
147 DEFINE_REG(12, 0, 0x10, (128*KB), reg_init, reg_read, reg_write) 158 DEFINE_REG(12, 0, 0x10, (128*KB), reg_init, reg_read, reg_write)
148 DEFINE_REG(12, 0, 0x14, (256), reg_init, reg_read, reg_write) 159 DEFINE_REG(12, 0, 0x14, (256), reg_init, reg_read, reg_write)
149 DEFINE_REG(12, 1, 0x10, (1024), reg_init, reg_read, reg_write) 160 DEFINE_REG(12, 1, 0x10, (1024), reg_init, reg_read, reg_write)
@@ -161,8 +172,10 @@ static struct sim_dev_reg bus1_fixups[] = {
161 DEFINE_REG(16, 0, 0x10, (64*KB), reg_init, reg_read, reg_write) 172 DEFINE_REG(16, 0, 0x10, (64*KB), reg_init, reg_read, reg_write)
162 DEFINE_REG(16, 0, 0x14, (64*MB), reg_init, reg_read, reg_write) 173 DEFINE_REG(16, 0, 0x14, (64*MB), reg_init, reg_read, reg_write)
163 DEFINE_REG(16, 0, 0x18, (64*MB), reg_init, reg_read, reg_write) 174 DEFINE_REG(16, 0, 0x18, (64*MB), reg_init, reg_read, reg_write)
175 DEFINE_REG(16, 0, 0x3c, 256, reg_init, reg_noirq_read, reg_write)
164 DEFINE_REG(17, 0, 0x10, (128*KB), reg_init, reg_read, reg_write) 176 DEFINE_REG(17, 0, 0x10, (128*KB), reg_init, reg_read, reg_write)
165 DEFINE_REG(18, 0, 0x10, (1*KB), reg_init, reg_read, reg_write) 177 DEFINE_REG(18, 0, 0x10, (1*KB), reg_init, reg_read, reg_write)
178 DEFINE_REG(18, 0, 0x3c, 256, reg_init, reg_noirq_read, reg_write)
166}; 179};
167 180
168static void __init init_sim_regs(void) 181static void __init init_sim_regs(void)
diff --git a/arch/x86/platform/ce4100/ce4100.c b/arch/x86/platform/ce4100/ce4100.c
index 4c61b52191e..92525cb8e54 100644
--- a/arch/x86/platform/ce4100/ce4100.c
+++ b/arch/x86/platform/ce4100/ce4100.c
@@ -21,12 +21,25 @@
21#include <asm/i8259.h> 21#include <asm/i8259.h>
22#include <asm/io.h> 22#include <asm/io.h>
23#include <asm/io_apic.h> 23#include <asm/io_apic.h>
24#include <asm/emergency-restart.h>
24 25
25static int ce4100_i8042_detect(void) 26static int ce4100_i8042_detect(void)
26{ 27{
27 return 0; 28 return 0;
28} 29}
29 30
31/*
32 * The CE4100 platform has an internal 8051 Microcontroller which is
33 * responsible for signaling to the external Power Management Unit the
34 * intention to reset, reboot or power off the system. This 8051 device has
35 * its command register mapped at I/O port 0xcf9 and the value 0x4 is used
36 * to power off the system.
37 */
38static void ce4100_power_off(void)
39{
40 outb(0x4, 0xcf9);
41}
42
30#ifdef CONFIG_SERIAL_8250 43#ifdef CONFIG_SERIAL_8250
31 44
32static unsigned int mem_serial_in(struct uart_port *p, int offset) 45static unsigned int mem_serial_in(struct uart_port *p, int offset)
@@ -139,8 +152,19 @@ void __init x86_ce4100_early_setup(void)
139 x86_init.mpparse.find_smp_config = x86_init_noop; 152 x86_init.mpparse.find_smp_config = x86_init_noop;
140 x86_init.pci.init = ce4100_pci_init; 153 x86_init.pci.init = ce4100_pci_init;
141 154
155 /*
156 * By default, the reboot method is ACPI which is supported by the
157 * CE4100 bootloader CEFDK using FADT.ResetReg Address and ResetValue
158 * the bootloader will however issue a system power off instead of
159 * reboot. By using BOOT_KBD we ensure proper system reboot as
160 * expected.
161 */
162 reboot_type = BOOT_KBD;
163
142#ifdef CONFIG_X86_IO_APIC 164#ifdef CONFIG_X86_IO_APIC
143 x86_init.pci.init_irq = sdv_pci_init; 165 x86_init.pci.init_irq = sdv_pci_init;
144 x86_init.mpparse.setup_ioapic_ids = setup_ioapic_ids_from_mpc_nocheck; 166 x86_init.mpparse.setup_ioapic_ids = setup_ioapic_ids_from_mpc_nocheck;
145#endif 167#endif
168
169 pm_power_off = ce4100_power_off;
146} 170}
diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index aded2a91162..ad4439145f8 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -70,11 +70,15 @@ EXPORT_SYMBOL(efi);
70struct efi_memory_map memmap; 70struct efi_memory_map memmap;
71 71
72bool efi_64bit; 72bool efi_64bit;
73static bool efi_native;
74 73
75static struct efi efi_phys __initdata; 74static struct efi efi_phys __initdata;
76static efi_system_table_t efi_systab __initdata; 75static efi_system_table_t efi_systab __initdata;
77 76
77static inline bool efi_is_native(void)
78{
79 return IS_ENABLED(CONFIG_X86_64) == efi_64bit;
80}
81
78static int __init setup_noefi(char *arg) 82static int __init setup_noefi(char *arg)
79{ 83{
80 efi_enabled = 0; 84 efi_enabled = 0;
@@ -420,7 +424,7 @@ void __init efi_reserve_boot_services(void)
420 } 424 }
421} 425}
422 426
423static void __init efi_unmap_memmap(void) 427void __init efi_unmap_memmap(void)
424{ 428{
425 if (memmap.map) { 429 if (memmap.map) {
426 early_iounmap(memmap.map, memmap.nr_map * memmap.desc_size); 430 early_iounmap(memmap.map, memmap.nr_map * memmap.desc_size);
@@ -432,7 +436,7 @@ void __init efi_free_boot_services(void)
432{ 436{
433 void *p; 437 void *p;
434 438
435 if (!efi_native) 439 if (!efi_is_native())
436 return; 440 return;
437 441
438 for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) { 442 for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) {
@@ -684,12 +688,10 @@ void __init efi_init(void)
684 return; 688 return;
685 } 689 }
686 efi_phys.systab = (efi_system_table_t *)boot_params.efi_info.efi_systab; 690 efi_phys.systab = (efi_system_table_t *)boot_params.efi_info.efi_systab;
687 efi_native = !efi_64bit;
688#else 691#else
689 efi_phys.systab = (efi_system_table_t *) 692 efi_phys.systab = (efi_system_table_t *)
690 (boot_params.efi_info.efi_systab | 693 (boot_params.efi_info.efi_systab |
691 ((__u64)boot_params.efi_info.efi_systab_hi<<32)); 694 ((__u64)boot_params.efi_info.efi_systab_hi<<32));
692 efi_native = efi_64bit;
693#endif 695#endif
694 696
695 if (efi_systab_init(efi_phys.systab)) { 697 if (efi_systab_init(efi_phys.systab)) {
@@ -723,7 +725,7 @@ void __init efi_init(void)
723 * that doesn't match the kernel 32/64-bit mode. 725 * that doesn't match the kernel 32/64-bit mode.
724 */ 726 */
725 727
726 if (!efi_native) 728 if (!efi_is_native())
727 pr_info("No EFI runtime due to 32/64-bit mismatch with kernel\n"); 729 pr_info("No EFI runtime due to 32/64-bit mismatch with kernel\n");
728 else if (efi_runtime_init()) { 730 else if (efi_runtime_init()) {
729 efi_enabled = 0; 731 efi_enabled = 0;
@@ -735,7 +737,7 @@ void __init efi_init(void)
735 return; 737 return;
736 } 738 }
737#ifdef CONFIG_X86_32 739#ifdef CONFIG_X86_32
738 if (efi_native) { 740 if (efi_is_native()) {
739 x86_platform.get_wallclock = efi_get_time; 741 x86_platform.get_wallclock = efi_get_time;
740 x86_platform.set_wallclock = efi_set_rtc_mmss; 742 x86_platform.set_wallclock = efi_set_rtc_mmss;
741 } 743 }
@@ -810,6 +812,16 @@ void __iomem *efi_lookup_mapped_addr(u64 phys_addr)
810 return NULL; 812 return NULL;
811} 813}
812 814
815void efi_memory_uc(u64 addr, unsigned long size)
816{
817 unsigned long page_shift = 1UL << EFI_PAGE_SHIFT;
818 u64 npages;
819
820 npages = round_up(size, page_shift) / page_shift;
821 memrange_efi_to_native(&addr, &npages);
822 set_memory_uc(addr, npages);
823}
824
813/* 825/*
814 * This function will switch the EFI runtime services to virtual mode. 826 * This function will switch the EFI runtime services to virtual mode.
815 * Essentially, look through the EFI memmap and map every region that 827 * Essentially, look through the EFI memmap and map every region that
@@ -823,7 +835,7 @@ void __init efi_enter_virtual_mode(void)
823 efi_memory_desc_t *md, *prev_md = NULL; 835 efi_memory_desc_t *md, *prev_md = NULL;
824 efi_status_t status; 836 efi_status_t status;
825 unsigned long size; 837 unsigned long size;
826 u64 end, systab, addr, npages, end_pfn; 838 u64 end, systab, end_pfn;
827 void *p, *va, *new_memmap = NULL; 839 void *p, *va, *new_memmap = NULL;
828 int count = 0; 840 int count = 0;
829 841
@@ -834,7 +846,7 @@ void __init efi_enter_virtual_mode(void)
834 * non-native EFI 846 * non-native EFI
835 */ 847 */
836 848
837 if (!efi_native) { 849 if (!efi_is_native()) {
838 efi_unmap_memmap(); 850 efi_unmap_memmap();
839 return; 851 return;
840 } 852 }
@@ -879,10 +891,14 @@ void __init efi_enter_virtual_mode(void)
879 end_pfn = PFN_UP(end); 891 end_pfn = PFN_UP(end);
880 if (end_pfn <= max_low_pfn_mapped 892 if (end_pfn <= max_low_pfn_mapped
881 || (end_pfn > (1UL << (32 - PAGE_SHIFT)) 893 || (end_pfn > (1UL << (32 - PAGE_SHIFT))
882 && end_pfn <= max_pfn_mapped)) 894 && end_pfn <= max_pfn_mapped)) {
883 va = __va(md->phys_addr); 895 va = __va(md->phys_addr);
884 else 896
885 va = efi_ioremap(md->phys_addr, size, md->type); 897 if (!(md->attribute & EFI_MEMORY_WB))
898 efi_memory_uc((u64)(unsigned long)va, size);
899 } else
900 va = efi_ioremap(md->phys_addr, size,
901 md->type, md->attribute);
886 902
887 md->virt_addr = (u64) (unsigned long) va; 903 md->virt_addr = (u64) (unsigned long) va;
888 904
@@ -892,13 +908,6 @@ void __init efi_enter_virtual_mode(void)
892 continue; 908 continue;
893 } 909 }
894 910
895 if (!(md->attribute & EFI_MEMORY_WB)) {
896 addr = md->virt_addr;
897 npages = md->num_pages;
898 memrange_efi_to_native(&addr, &npages);
899 set_memory_uc(addr, npages);
900 }
901
902 systab = (u64) (unsigned long) efi_phys.systab; 911 systab = (u64) (unsigned long) efi_phys.systab;
903 if (md->phys_addr <= systab && systab < end) { 912 if (md->phys_addr <= systab && systab < end) {
904 systab += md->virt_addr - md->phys_addr; 913 systab += md->virt_addr - md->phys_addr;
diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
index ac3aa54e265..95fd505dfeb 100644
--- a/arch/x86/platform/efi/efi_64.c
+++ b/arch/x86/platform/efi/efi_64.c
@@ -82,7 +82,7 @@ void __init efi_call_phys_epilog(void)
82} 82}
83 83
84void __iomem *__init efi_ioremap(unsigned long phys_addr, unsigned long size, 84void __iomem *__init efi_ioremap(unsigned long phys_addr, unsigned long size,
85 u32 type) 85 u32 type, u64 attribute)
86{ 86{
87 unsigned long last_map_pfn; 87 unsigned long last_map_pfn;
88 88
@@ -92,8 +92,11 @@ void __iomem *__init efi_ioremap(unsigned long phys_addr, unsigned long size,
92 last_map_pfn = init_memory_mapping(phys_addr, phys_addr + size); 92 last_map_pfn = init_memory_mapping(phys_addr, phys_addr + size);
93 if ((last_map_pfn << PAGE_SHIFT) < phys_addr + size) { 93 if ((last_map_pfn << PAGE_SHIFT) < phys_addr + size) {
94 unsigned long top = last_map_pfn << PAGE_SHIFT; 94 unsigned long top = last_map_pfn << PAGE_SHIFT;
95 efi_ioremap(top, size - (top - phys_addr), type); 95 efi_ioremap(top, size - (top - phys_addr), type, attribute);
96 } 96 }
97 97
98 if (!(attribute & EFI_MEMORY_WB))
99 efi_memory_uc((u64)(unsigned long)__va(phys_addr), size);
100
98 return (void __iomem *)__va(phys_addr); 101 return (void __iomem *)__va(phys_addr);
99} 102}
diff --git a/arch/x86/realmode/rm/wakeup_asm.S b/arch/x86/realmode/rm/wakeup_asm.S
index e56479e5805..9e7e14797a7 100644
--- a/arch/x86/realmode/rm/wakeup_asm.S
+++ b/arch/x86/realmode/rm/wakeup_asm.S
@@ -74,18 +74,9 @@ ENTRY(wakeup_start)
74 74
75 lidtl wakeup_idt 75 lidtl wakeup_idt
76 76
77 /* Clear the EFLAGS but remember if we have EFLAGS.ID */ 77 /* Clear the EFLAGS */
78 movl $X86_EFLAGS_ID, %ecx
79 pushl %ecx
80 popfl
81 pushfl
82 popl %edi
83 pushl $0 78 pushl $0
84 popfl 79 popfl
85 pushfl
86 popl %edx
87 xorl %edx, %edi
88 andl %ecx, %edi /* %edi is zero iff CPUID & %cr4 are missing */
89 80
90 /* Check header signature... */ 81 /* Check header signature... */
91 movl signature, %eax 82 movl signature, %eax
@@ -120,12 +111,12 @@ ENTRY(wakeup_start)
120 movl %eax, %cr3 111 movl %eax, %cr3
121 112
122 btl $WAKEUP_BEHAVIOR_RESTORE_CR4, %edi 113 btl $WAKEUP_BEHAVIOR_RESTORE_CR4, %edi
123 jz 1f 114 jnc 1f
124 movl pmode_cr4, %eax 115 movl pmode_cr4, %eax
125 movl %eax, %cr4 116 movl %eax, %cr4
1261: 1171:
127 btl $WAKEUP_BEHAVIOR_RESTORE_EFER, %edi 118 btl $WAKEUP_BEHAVIOR_RESTORE_EFER, %edi
128 jz 1f 119 jnc 1f
129 movl pmode_efer, %eax 120 movl pmode_efer, %eax
130 movl pmode_efer + 4, %edx 121 movl pmode_efer + 4, %edx
131 movl $MSR_EFER, %ecx 122 movl $MSR_EFER, %ecx
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index e3497f240ea..586d83812b6 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -81,8 +81,6 @@
81#include "smp.h" 81#include "smp.h"
82#include "multicalls.h" 82#include "multicalls.h"
83 83
84#include <xen/events.h>
85
86EXPORT_SYMBOL_GPL(hypercall_page); 84EXPORT_SYMBOL_GPL(hypercall_page);
87 85
88DEFINE_PER_CPU(struct vcpu_info *, xen_vcpu); 86DEFINE_PER_CPU(struct vcpu_info *, xen_vcpu);
diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index 6226c99729b..dcf5f2dd91e 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -1288,6 +1288,25 @@ unsigned long xen_read_cr2_direct(void)
1288 return this_cpu_read(xen_vcpu_info.arch.cr2); 1288 return this_cpu_read(xen_vcpu_info.arch.cr2);
1289} 1289}
1290 1290
1291void xen_flush_tlb_all(void)
1292{
1293 struct mmuext_op *op;
1294 struct multicall_space mcs;
1295
1296 trace_xen_mmu_flush_tlb_all(0);
1297
1298 preempt_disable();
1299
1300 mcs = xen_mc_entry(sizeof(*op));
1301
1302 op = mcs.args;
1303 op->cmd = MMUEXT_TLB_FLUSH_ALL;
1304 MULTI_mmuext_op(mcs.mc, op, 1, NULL, DOMID_SELF);
1305
1306 xen_mc_issue(PARAVIRT_LAZY_MMU);
1307
1308 preempt_enable();
1309}
1291static void xen_flush_tlb(void) 1310static void xen_flush_tlb(void)
1292{ 1311{
1293 struct mmuext_op *op; 1312 struct mmuext_op *op;
@@ -2518,7 +2537,7 @@ int xen_remap_domain_mfn_range(struct vm_area_struct *vma,
2518 err = 0; 2537 err = 0;
2519out: 2538out:
2520 2539
2521 flush_tlb_all(); 2540 xen_flush_tlb_all();
2522 2541
2523 return err; 2542 return err;
2524} 2543}
diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig
index cdcb48adee4..0d1f36a22c9 100644
--- a/arch/xtensa/Kconfig
+++ b/arch/xtensa/Kconfig
@@ -13,6 +13,8 @@ config XTENSA
13 select GENERIC_CPU_DEVICES 13 select GENERIC_CPU_DEVICES
14 select MODULES_USE_ELF_RELA 14 select MODULES_USE_ELF_RELA
15 select GENERIC_PCI_IOMAP 15 select GENERIC_PCI_IOMAP
16 select GENERIC_KERNEL_THREAD
17 select GENERIC_KERNEL_EXECVE
16 select ARCH_WANT_OPTIONAL_GPIOLIB 18 select ARCH_WANT_OPTIONAL_GPIOLIB
17 help 19 help
18 Xtensa processors are 32-bit RISC machines designed by Tensilica 20 Xtensa processors are 32-bit RISC machines designed by Tensilica
diff --git a/arch/xtensa/boot/boot-redboot/bootstrap.S b/arch/xtensa/boot/boot-redboot/bootstrap.S
index 4c316cd28a5..86c34dbc9cd 100644
--- a/arch/xtensa/boot/boot-redboot/bootstrap.S
+++ b/arch/xtensa/boot/boot-redboot/bootstrap.S
@@ -51,17 +51,17 @@ _start:
51 /* 'reset' window registers */ 51 /* 'reset' window registers */
52 52
53 movi a4, 1 53 movi a4, 1
54 wsr a4, PS 54 wsr a4, ps
55 rsync 55 rsync
56 56
57 rsr a5, WINDOWBASE 57 rsr a5, windowbase
58 ssl a5 58 ssl a5
59 sll a4, a4 59 sll a4, a4
60 wsr a4, WINDOWSTART 60 wsr a4, windowstart
61 rsync 61 rsync
62 62
63 movi a4, 0x00040000 63 movi a4, 0x00040000
64 wsr a4, PS 64 wsr a4, ps
65 rsync 65 rsync
66 66
67 /* copy the loader to its address 67 /* copy the loader to its address
diff --git a/arch/xtensa/include/asm/Kbuild b/arch/xtensa/include/asm/Kbuild
index fccd81eddff..6d130278999 100644
--- a/arch/xtensa/include/asm/Kbuild
+++ b/arch/xtensa/include/asm/Kbuild
@@ -1,4 +1,28 @@
1include include/asm-generic/Kbuild.asm 1generic-y += bitsperlong.h
2 2generic-y += bug.h
3generic-y += clkdev.h 3generic-y += clkdev.h
4generic-y += cputime.h
5generic-y += device.h
6generic-y += div64.h
7generic-y += emergency-restart.h
8generic-y += errno.h
4generic-y += exec.h 9generic-y += exec.h
10generic-y += fcntl.h
11generic-y += futex.h
12generic-y += hardirq.h
13generic-y += ioctl.h
14generic-y += irq_regs.h
15generic-y += kdebug.h
16generic-y += kmap_types.h
17generic-y += kvm_para.h
18generic-y += local.h
19generic-y += local64.h
20generic-y += percpu.h
21generic-y += resource.h
22generic-y += scatterlist.h
23generic-y += sections.h
24generic-y += siginfo.h
25generic-y += statfs.h
26generic-y += termios.h
27generic-y += topology.h
28generic-y += xor.h
diff --git a/arch/xtensa/include/asm/atomic.h b/arch/xtensa/include/asm/atomic.h
index b4098930877..24f50cada70 100644
--- a/arch/xtensa/include/asm/atomic.h
+++ b/arch/xtensa/include/asm/atomic.h
@@ -73,7 +73,7 @@ static inline void atomic_add(int i, atomic_t * v)
73 "l32i %0, %2, 0 \n\t" 73 "l32i %0, %2, 0 \n\t"
74 "add %0, %0, %1 \n\t" 74 "add %0, %0, %1 \n\t"
75 "s32i %0, %2, 0 \n\t" 75 "s32i %0, %2, 0 \n\t"
76 "wsr a15, "__stringify(PS)" \n\t" 76 "wsr a15, ps \n\t"
77 "rsync \n" 77 "rsync \n"
78 : "=&a" (vval) 78 : "=&a" (vval)
79 : "a" (i), "a" (v) 79 : "a" (i), "a" (v)
@@ -97,7 +97,7 @@ static inline void atomic_sub(int i, atomic_t *v)
97 "l32i %0, %2, 0 \n\t" 97 "l32i %0, %2, 0 \n\t"
98 "sub %0, %0, %1 \n\t" 98 "sub %0, %0, %1 \n\t"
99 "s32i %0, %2, 0 \n\t" 99 "s32i %0, %2, 0 \n\t"
100 "wsr a15, "__stringify(PS)" \n\t" 100 "wsr a15, ps \n\t"
101 "rsync \n" 101 "rsync \n"
102 : "=&a" (vval) 102 : "=&a" (vval)
103 : "a" (i), "a" (v) 103 : "a" (i), "a" (v)
@@ -118,7 +118,7 @@ static inline int atomic_add_return(int i, atomic_t * v)
118 "l32i %0, %2, 0 \n\t" 118 "l32i %0, %2, 0 \n\t"
119 "add %0, %0, %1 \n\t" 119 "add %0, %0, %1 \n\t"
120 "s32i %0, %2, 0 \n\t" 120 "s32i %0, %2, 0 \n\t"
121 "wsr a15, "__stringify(PS)" \n\t" 121 "wsr a15, ps \n\t"
122 "rsync \n" 122 "rsync \n"
123 : "=&a" (vval) 123 : "=&a" (vval)
124 : "a" (i), "a" (v) 124 : "a" (i), "a" (v)
@@ -137,7 +137,7 @@ static inline int atomic_sub_return(int i, atomic_t * v)
137 "l32i %0, %2, 0 \n\t" 137 "l32i %0, %2, 0 \n\t"
138 "sub %0, %0, %1 \n\t" 138 "sub %0, %0, %1 \n\t"
139 "s32i %0, %2, 0 \n\t" 139 "s32i %0, %2, 0 \n\t"
140 "wsr a15, "__stringify(PS)" \n\t" 140 "wsr a15, ps \n\t"
141 "rsync \n" 141 "rsync \n"
142 : "=&a" (vval) 142 : "=&a" (vval)
143 : "a" (i), "a" (v) 143 : "a" (i), "a" (v)
@@ -260,7 +260,7 @@ static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
260 "xor %1, %4, %3 \n\t" 260 "xor %1, %4, %3 \n\t"
261 "and %0, %0, %4 \n\t" 261 "and %0, %0, %4 \n\t"
262 "s32i %0, %2, 0 \n\t" 262 "s32i %0, %2, 0 \n\t"
263 "wsr a15, "__stringify(PS)" \n\t" 263 "wsr a15, ps \n\t"
264 "rsync \n" 264 "rsync \n"
265 : "=&a" (vval), "=a" (mask) 265 : "=&a" (vval), "=a" (mask)
266 : "a" (v), "a" (all_f), "1" (mask) 266 : "a" (v), "a" (all_f), "1" (mask)
@@ -277,7 +277,7 @@ static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
277 "l32i %0, %2, 0 \n\t" 277 "l32i %0, %2, 0 \n\t"
278 "or %0, %0, %1 \n\t" 278 "or %0, %0, %1 \n\t"
279 "s32i %0, %2, 0 \n\t" 279 "s32i %0, %2, 0 \n\t"
280 "wsr a15, "__stringify(PS)" \n\t" 280 "wsr a15, ps \n\t"
281 "rsync \n" 281 "rsync \n"
282 : "=&a" (vval) 282 : "=&a" (vval)
283 : "a" (mask), "a" (v) 283 : "a" (mask), "a" (v)
diff --git a/arch/xtensa/include/asm/bitsperlong.h b/arch/xtensa/include/asm/bitsperlong.h
deleted file mode 100644
index 6dc0bb0c13b..00000000000
--- a/arch/xtensa/include/asm/bitsperlong.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-generic/bitsperlong.h>
diff --git a/arch/xtensa/include/asm/bug.h b/arch/xtensa/include/asm/bug.h
deleted file mode 100644
index 3e52d72712f..00000000000
--- a/arch/xtensa/include/asm/bug.h
+++ /dev/null
@@ -1,18 +0,0 @@
1/*
2 * include/asm-xtensa/bug.h
3 *
4 * Macros to cause a 'bug' message.
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 *
10 * Copyright (C) 2001 - 2005 Tensilica Inc.
11 */
12
13#ifndef _XTENSA_BUG_H
14#define _XTENSA_BUG_H
15
16#include <asm-generic/bug.h>
17
18#endif /* _XTENSA_BUG_H */
diff --git a/arch/xtensa/include/asm/cacheflush.h b/arch/xtensa/include/asm/cacheflush.h
index 376cd9d5f45..569fec4f9a2 100644
--- a/arch/xtensa/include/asm/cacheflush.h
+++ b/arch/xtensa/include/asm/cacheflush.h
@@ -165,7 +165,7 @@ extern void copy_from_user_page(struct vm_area_struct*, struct page*,
165static inline u32 xtensa_get_cacheattr(void) 165static inline u32 xtensa_get_cacheattr(void)
166{ 166{
167 u32 r; 167 u32 r;
168 asm volatile(" rsr %0, CACHEATTR" : "=a"(r)); 168 asm volatile(" rsr %0, cacheattr" : "=a"(r));
169 return r; 169 return r;
170} 170}
171 171
diff --git a/arch/xtensa/include/asm/cmpxchg.h b/arch/xtensa/include/asm/cmpxchg.h
index e32149063d8..64dad04a9d2 100644
--- a/arch/xtensa/include/asm/cmpxchg.h
+++ b/arch/xtensa/include/asm/cmpxchg.h
@@ -27,7 +27,7 @@ __cmpxchg_u32(volatile int *p, int old, int new)
27 "bne %0, %2, 1f \n\t" 27 "bne %0, %2, 1f \n\t"
28 "s32i %3, %1, 0 \n\t" 28 "s32i %3, %1, 0 \n\t"
29 "1: \n\t" 29 "1: \n\t"
30 "wsr a15, "__stringify(PS)" \n\t" 30 "wsr a15, ps \n\t"
31 "rsync \n\t" 31 "rsync \n\t"
32 : "=&a" (old) 32 : "=&a" (old)
33 : "a" (p), "a" (old), "r" (new) 33 : "a" (p), "a" (old), "r" (new)
@@ -97,7 +97,7 @@ static inline unsigned long xchg_u32(volatile int * m, unsigned long val)
97 __asm__ __volatile__("rsil a15, "__stringify(LOCKLEVEL)"\n\t" 97 __asm__ __volatile__("rsil a15, "__stringify(LOCKLEVEL)"\n\t"
98 "l32i %0, %1, 0 \n\t" 98 "l32i %0, %1, 0 \n\t"
99 "s32i %2, %1, 0 \n\t" 99 "s32i %2, %1, 0 \n\t"
100 "wsr a15, "__stringify(PS)" \n\t" 100 "wsr a15, ps \n\t"
101 "rsync \n\t" 101 "rsync \n\t"
102 : "=&a" (tmp) 102 : "=&a" (tmp)
103 : "a" (m), "a" (val) 103 : "a" (m), "a" (val)
diff --git a/arch/xtensa/include/asm/coprocessor.h b/arch/xtensa/include/asm/coprocessor.h
index 75c94a1658b..677501b32df 100644
--- a/arch/xtensa/include/asm/coprocessor.h
+++ b/arch/xtensa/include/asm/coprocessor.h
@@ -94,11 +94,10 @@
94#if XCHAL_HAVE_CP 94#if XCHAL_HAVE_CP
95 95
96#define RSR_CPENABLE(x) do { \ 96#define RSR_CPENABLE(x) do { \
97 __asm__ __volatile__("rsr %0," __stringify(CPENABLE) : "=a" (x)); \ 97 __asm__ __volatile__("rsr %0, cpenable" : "=a" (x)); \
98 } while(0); 98 } while(0);
99#define WSR_CPENABLE(x) do { \ 99#define WSR_CPENABLE(x) do { \
100 __asm__ __volatile__("wsr %0," __stringify(CPENABLE) "; rsync" \ 100 __asm__ __volatile__("wsr %0, cpenable; rsync" :: "a" (x)); \
101 :: "a" (x)); \
102 } while(0); 101 } while(0);
103 102
104#endif /* XCHAL_HAVE_CP */ 103#endif /* XCHAL_HAVE_CP */
diff --git a/arch/xtensa/include/asm/cputime.h b/arch/xtensa/include/asm/cputime.h
deleted file mode 100644
index a7fb864a50a..00000000000
--- a/arch/xtensa/include/asm/cputime.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef _XTENSA_CPUTIME_H
2#define _XTENSA_CPUTIME_H
3
4#include <asm-generic/cputime.h>
5
6#endif /* _XTENSA_CPUTIME_H */
diff --git a/arch/xtensa/include/asm/delay.h b/arch/xtensa/include/asm/delay.h
index e1d8c9e010c..58c0a4fd400 100644
--- a/arch/xtensa/include/asm/delay.h
+++ b/arch/xtensa/include/asm/delay.h
@@ -27,7 +27,7 @@ static inline void __delay(unsigned long loops)
27static __inline__ u32 xtensa_get_ccount(void) 27static __inline__ u32 xtensa_get_ccount(void)
28{ 28{
29 u32 ccount; 29 u32 ccount;
30 asm volatile ("rsr %0, 234; # CCOUNT\n" : "=r" (ccount)); 30 asm volatile ("rsr %0, ccount\n" : "=r" (ccount));
31 return ccount; 31 return ccount;
32} 32}
33 33
diff --git a/arch/xtensa/include/asm/device.h b/arch/xtensa/include/asm/device.h
deleted file mode 100644
index d8f9872b0e2..00000000000
--- a/arch/xtensa/include/asm/device.h
+++ /dev/null
@@ -1,7 +0,0 @@
1/*
2 * Arch specific extensions to struct device
3 *
4 * This file is released under the GPLv2
5 */
6#include <asm-generic/device.h>
7
diff --git a/arch/xtensa/include/asm/div64.h b/arch/xtensa/include/asm/div64.h
deleted file mode 100644
index f35678cb0a9..00000000000
--- a/arch/xtensa/include/asm/div64.h
+++ /dev/null
@@ -1,16 +0,0 @@
1/*
2 * include/asm-xtensa/div64.h
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (C) 2001 - 2007 Tensilica Inc.
9 */
10
11#ifndef _XTENSA_DIV64_H
12#define _XTENSA_DIV64_H
13
14#include <asm-generic/div64.h>
15
16#endif /* _XTENSA_DIV64_H */
diff --git a/arch/xtensa/include/asm/emergency-restart.h b/arch/xtensa/include/asm/emergency-restart.h
deleted file mode 100644
index 108d8c48e42..00000000000
--- a/arch/xtensa/include/asm/emergency-restart.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef _ASM_EMERGENCY_RESTART_H
2#define _ASM_EMERGENCY_RESTART_H
3
4#include <asm-generic/emergency-restart.h>
5
6#endif /* _ASM_EMERGENCY_RESTART_H */
diff --git a/arch/xtensa/include/asm/errno.h b/arch/xtensa/include/asm/errno.h
deleted file mode 100644
index a0f3b96b79b..00000000000
--- a/arch/xtensa/include/asm/errno.h
+++ /dev/null
@@ -1,16 +0,0 @@
1/*
2 * include/asm-xtensa/errno.h
3 *
4 * This file is subject to the terms and conditions of the GNU General
5 * Public License. See the file "COPYING" in the main directory of
6 * this archive for more details.
7 *
8 * Copyright (C) 2002 - 2005 Tensilica Inc.
9 */
10
11#ifndef _XTENSA_ERRNO_H
12#define _XTENSA_ERRNO_H
13
14#include <asm-generic/errno.h>
15
16#endif /* _XTENSA_ERRNO_H */
diff --git a/arch/xtensa/include/asm/fcntl.h b/arch/xtensa/include/asm/fcntl.h
deleted file mode 100644
index 46ab12db573..00000000000
--- a/arch/xtensa/include/asm/fcntl.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-generic/fcntl.h>
diff --git a/arch/xtensa/include/asm/futex.h b/arch/xtensa/include/asm/futex.h
deleted file mode 100644
index 0b745828f42..00000000000
--- a/arch/xtensa/include/asm/futex.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-generic/futex.h>
diff --git a/arch/xtensa/include/asm/hardirq.h b/arch/xtensa/include/asm/hardirq.h
deleted file mode 100644
index 91695a13549..00000000000
--- a/arch/xtensa/include/asm/hardirq.h
+++ /dev/null
@@ -1,16 +0,0 @@
1/*
2 * include/asm-xtensa/hardirq.h
3 *
4 * This file is subject to the terms and conditions of the GNU General
5 * Public License. See the file "COPYING" in the main directory of
6 * this archive for more details.
7 *
8 * Copyright (C) 2002 - 2005 Tensilica Inc.
9 */
10
11#ifndef _XTENSA_HARDIRQ_H
12#define _XTENSA_HARDIRQ_H
13
14#include <asm-generic/hardirq.h>
15
16#endif /* _XTENSA_HARDIRQ_H */
diff --git a/arch/xtensa/include/asm/io.h b/arch/xtensa/include/asm/io.h
index e6be5b9091c..700c2e6f2d2 100644
--- a/arch/xtensa/include/asm/io.h
+++ b/arch/xtensa/include/asm/io.h
@@ -62,6 +62,10 @@ static inline void __iomem *ioremap(unsigned long offset, unsigned long size)
62static inline void iounmap(volatile void __iomem *addr) 62static inline void iounmap(volatile void __iomem *addr)
63{ 63{
64} 64}
65
66#define virt_to_bus virt_to_phys
67#define bus_to_virt phys_to_virt
68
65#endif /* CONFIG_MMU */ 69#endif /* CONFIG_MMU */
66 70
67/* 71/*
diff --git a/arch/xtensa/include/asm/ioctl.h b/arch/xtensa/include/asm/ioctl.h
deleted file mode 100644
index b279fe06dfe..00000000000
--- a/arch/xtensa/include/asm/ioctl.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-generic/ioctl.h>
diff --git a/arch/xtensa/include/asm/irq_regs.h b/arch/xtensa/include/asm/irq_regs.h
deleted file mode 100644
index 3dd9c0b7027..00000000000
--- a/arch/xtensa/include/asm/irq_regs.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-generic/irq_regs.h>
diff --git a/arch/xtensa/include/asm/irqflags.h b/arch/xtensa/include/asm/irqflags.h
index dae9a8bdcb1..f865b1c1eae 100644
--- a/arch/xtensa/include/asm/irqflags.h
+++ b/arch/xtensa/include/asm/irqflags.h
@@ -16,7 +16,7 @@
16static inline unsigned long arch_local_save_flags(void) 16static inline unsigned long arch_local_save_flags(void)
17{ 17{
18 unsigned long flags; 18 unsigned long flags;
19 asm volatile("rsr %0,"__stringify(PS) : "=a" (flags)); 19 asm volatile("rsr %0, ps" : "=a" (flags));
20 return flags; 20 return flags;
21} 21}
22 22
@@ -41,7 +41,7 @@ static inline void arch_local_irq_enable(void)
41 41
42static inline void arch_local_irq_restore(unsigned long flags) 42static inline void arch_local_irq_restore(unsigned long flags)
43{ 43{
44 asm volatile("wsr %0, "__stringify(PS)" ; rsync" 44 asm volatile("wsr %0, ps; rsync"
45 :: "a" (flags) : "memory"); 45 :: "a" (flags) : "memory");
46} 46}
47 47
diff --git a/arch/xtensa/include/asm/kdebug.h b/arch/xtensa/include/asm/kdebug.h
deleted file mode 100644
index 6ece1b03766..00000000000
--- a/arch/xtensa/include/asm/kdebug.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-generic/kdebug.h>
diff --git a/arch/xtensa/include/asm/kmap_types.h b/arch/xtensa/include/asm/kmap_types.h
deleted file mode 100644
index 11c687e527f..00000000000
--- a/arch/xtensa/include/asm/kmap_types.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef _XTENSA_KMAP_TYPES_H
2#define _XTENSA_KMAP_TYPES_H
3
4#include <asm-generic/kmap_types.h>
5
6#endif /* _XTENSA_KMAP_TYPES_H */
diff --git a/arch/xtensa/include/asm/kvm_para.h b/arch/xtensa/include/asm/kvm_para.h
deleted file mode 100644
index 14fab8f0b95..00000000000
--- a/arch/xtensa/include/asm/kvm_para.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-generic/kvm_para.h>
diff --git a/arch/xtensa/include/asm/local.h b/arch/xtensa/include/asm/local.h
deleted file mode 100644
index 48723e550d1..00000000000
--- a/arch/xtensa/include/asm/local.h
+++ /dev/null
@@ -1,16 +0,0 @@
1/*
2 * include/asm-xtensa/local.h
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (C) 2001 - 2005 Tensilica Inc.
9 */
10
11#ifndef _XTENSA_LOCAL_H
12#define _XTENSA_LOCAL_H
13
14#include <asm-generic/local.h>
15
16#endif /* _XTENSA_LOCAL_H */
diff --git a/arch/xtensa/include/asm/local64.h b/arch/xtensa/include/asm/local64.h
deleted file mode 100644
index 36c93b5cc23..00000000000
--- a/arch/xtensa/include/asm/local64.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm-generic/local64.h>
diff --git a/arch/xtensa/include/asm/mmu_context.h b/arch/xtensa/include/asm/mmu_context.h
index dbd8731a876..feb10af9651 100644
--- a/arch/xtensa/include/asm/mmu_context.h
+++ b/arch/xtensa/include/asm/mmu_context.h
@@ -51,14 +51,14 @@ extern unsigned long asid_cache;
51 51
52static inline void set_rasid_register (unsigned long val) 52static inline void set_rasid_register (unsigned long val)
53{ 53{
54 __asm__ __volatile__ (" wsr %0, "__stringify(RASID)"\n\t" 54 __asm__ __volatile__ (" wsr %0, rasid\n\t"
55 " isync\n" : : "a" (val)); 55 " isync\n" : : "a" (val));
56} 56}
57 57
58static inline unsigned long get_rasid_register (void) 58static inline unsigned long get_rasid_register (void)
59{ 59{
60 unsigned long tmp; 60 unsigned long tmp;
61 __asm__ __volatile__ (" rsr %0,"__stringify(RASID)"\n\t" : "=a" (tmp)); 61 __asm__ __volatile__ (" rsr %0, rasid\n\t" : "=a" (tmp));
62 return tmp; 62 return tmp;
63} 63}
64 64
diff --git a/arch/xtensa/include/asm/param.h b/arch/xtensa/include/asm/param.h
index ba03d5aeab6..0a70e780ef2 100644
--- a/arch/xtensa/include/asm/param.h
+++ b/arch/xtensa/include/asm/param.h
@@ -7,28 +7,12 @@
7 * 7 *
8 * Copyright (C) 2001 - 2005 Tensilica Inc. 8 * Copyright (C) 2001 - 2005 Tensilica Inc.
9 */ 9 */
10
11#ifndef _XTENSA_PARAM_H 10#ifndef _XTENSA_PARAM_H
12#define _XTENSA_PARAM_H 11#define _XTENSA_PARAM_H
13 12
14#ifdef __KERNEL__ 13#include <uapi/asm/param.h>
14
15# define HZ CONFIG_HZ /* internal timer frequency */ 15# define HZ CONFIG_HZ /* internal timer frequency */
16# define USER_HZ 100 /* for user interfaces in "ticks" */ 16# define USER_HZ 100 /* for user interfaces in "ticks" */
17# define CLOCKS_PER_SEC (USER_HZ) /* frequnzy at which times() counts */ 17# define CLOCKS_PER_SEC (USER_HZ) /* frequnzy at which times() counts */
18#else
19# define HZ 100
20#endif
21
22#define EXEC_PAGESIZE 4096
23
24#ifndef NGROUPS
25#define NGROUPS 32
26#endif
27
28#ifndef NOGROUP
29#define NOGROUP (-1)
30#endif
31
32#define MAXHOSTNAMELEN 64 /* max length of hostname */
33
34#endif /* _XTENSA_PARAM_H */ 18#endif /* _XTENSA_PARAM_H */
diff --git a/arch/xtensa/include/asm/percpu.h b/arch/xtensa/include/asm/percpu.h
deleted file mode 100644
index 6d2bc2ada9d..00000000000
--- a/arch/xtensa/include/asm/percpu.h
+++ /dev/null
@@ -1,16 +0,0 @@
1/*
2 * linux/include/asm-xtensa/percpu.h
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (C) 2001 - 2005 Tensilica Inc.
9 */
10
11#ifndef _XTENSA_PERCPU__
12#define _XTENSA_PERCPU__
13
14#include <asm-generic/percpu.h>
15
16#endif /* _XTENSA_PERCPU__ */
diff --git a/arch/xtensa/include/asm/processor.h b/arch/xtensa/include/asm/processor.h
index 5c371d8d452..2d630e7399c 100644
--- a/arch/xtensa/include/asm/processor.h
+++ b/arch/xtensa/include/asm/processor.h
@@ -152,6 +152,7 @@ struct thread_struct {
152 152
153/* Clearing a0 terminates the backtrace. */ 153/* Clearing a0 terminates the backtrace. */
154#define start_thread(regs, new_pc, new_sp) \ 154#define start_thread(regs, new_pc, new_sp) \
155 memset(regs, 0, sizeof(*regs)); \
155 regs->pc = new_pc; \ 156 regs->pc = new_pc; \
156 regs->ps = USER_PS_VALUE; \ 157 regs->ps = USER_PS_VALUE; \
157 regs->areg[1] = new_sp; \ 158 regs->areg[1] = new_sp; \
@@ -168,9 +169,6 @@ struct mm_struct;
168/* Free all resources held by a thread. */ 169/* Free all resources held by a thread. */
169#define release_thread(thread) do { } while(0) 170#define release_thread(thread) do { } while(0)
170 171
171/* Create a kernel thread without removing it from tasklists */
172extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
173
174/* Copy and release all segment info associated with a VM */ 172/* Copy and release all segment info associated with a VM */
175#define copy_segments(p, mm) do { } while(0) 173#define copy_segments(p, mm) do { } while(0)
176#define release_segments(mm) do { } while(0) 174#define release_segments(mm) do { } while(0)
diff --git a/arch/xtensa/include/asm/ptrace.h b/arch/xtensa/include/asm/ptrace.h
index d85d38da8ee..da21c17f23a 100644
--- a/arch/xtensa/include/asm/ptrace.h
+++ b/arch/xtensa/include/asm/ptrace.h
@@ -7,73 +7,11 @@
7 * 7 *
8 * Copyright (C) 2001 - 2005 Tensilica Inc. 8 * Copyright (C) 2001 - 2005 Tensilica Inc.
9 */ 9 */
10
11#ifndef _XTENSA_PTRACE_H 10#ifndef _XTENSA_PTRACE_H
12#define _XTENSA_PTRACE_H 11#define _XTENSA_PTRACE_H
13 12
14/* 13#include <uapi/asm/ptrace.h>
15 * Kernel stack
16 *
17 * +-----------------------+ -------- STACK_SIZE
18 * | register file | |
19 * +-----------------------+ |
20 * | struct pt_regs | |
21 * +-----------------------+ | ------ PT_REGS_OFFSET
22 * double : 16 bytes spill area : | ^
23 * excetion :- - - - - - - - - - - -: | |
24 * frame : struct pt_regs : | |
25 * :- - - - - - - - - - - -: | |
26 * | | | |
27 * | memory stack | | |
28 * | | | |
29 * ~ ~ ~ ~
30 * ~ ~ ~ ~
31 * | | | |
32 * | | | |
33 * +-----------------------+ | | --- STACK_BIAS
34 * | struct task_struct | | | ^
35 * current --> +-----------------------+ | | |
36 * | struct thread_info | | | |
37 * +-----------------------+ --------
38 */
39
40#define KERNEL_STACK_SIZE (2 * PAGE_SIZE)
41
42/* Offsets for exception_handlers[] (3 x 64-entries x 4-byte tables). */
43
44#define EXC_TABLE_KSTK 0x004 /* Kernel Stack */
45#define EXC_TABLE_DOUBLE_SAVE 0x008 /* Double exception save area for a0 */
46#define EXC_TABLE_FIXUP 0x00c /* Fixup handler */
47#define EXC_TABLE_PARAM 0x010 /* For passing a parameter to fixup */
48#define EXC_TABLE_SYSCALL_SAVE 0x014 /* For fast syscall handler */
49#define EXC_TABLE_FAST_USER 0x100 /* Fast user exception handler */
50#define EXC_TABLE_FAST_KERNEL 0x200 /* Fast kernel exception handler */
51#define EXC_TABLE_DEFAULT 0x300 /* Default C-Handler */
52#define EXC_TABLE_SIZE 0x400
53 14
54/* Registers used by strace */
55
56#define REG_A_BASE 0x0000
57#define REG_AR_BASE 0x0100
58#define REG_PC 0x0020
59#define REG_PS 0x02e6
60#define REG_WB 0x0248
61#define REG_WS 0x0249
62#define REG_LBEG 0x0200
63#define REG_LEND 0x0201
64#define REG_LCOUNT 0x0202
65#define REG_SAR 0x0203
66
67#define SYSCALL_NR 0x00ff
68
69/* Other PTRACE_ values defined in <linux/ptrace.h> using values 0-9,16,17,24 */
70
71#define PTRACE_GETREGS 12
72#define PTRACE_SETREGS 13
73#define PTRACE_GETXTREGS 18
74#define PTRACE_SETXTREGS 19
75
76#ifdef __KERNEL__
77 15
78#ifndef __ASSEMBLY__ 16#ifndef __ASSEMBLY__
79 17
@@ -132,6 +70,4 @@ struct pt_regs {
132 70
133#endif /* !__ASSEMBLY__ */ 71#endif /* !__ASSEMBLY__ */
134 72
135#endif /* __KERNEL__ */
136
137#endif /* _XTENSA_PTRACE_H */ 73#endif /* _XTENSA_PTRACE_H */
diff --git a/arch/xtensa/include/asm/regs.h b/arch/xtensa/include/asm/regs.h
index a3075b12aff..8a8aa61ccc8 100644
--- a/arch/xtensa/include/asm/regs.h
+++ b/arch/xtensa/include/asm/regs.h
@@ -27,52 +27,15 @@
27 27
28/* Special registers. */ 28/* Special registers. */
29 29
30#define LBEG 0 30#define SREG_MR 32
31#define LEND 1 31#define SREG_IBREAKA 128
32#define LCOUNT 2 32#define SREG_DBREAKA 144
33#define SAR 3 33#define SREG_DBREAKC 160
34#define BR 4 34#define SREG_EPC 176
35#define SCOMPARE1 12 35#define SREG_EPS 192
36#define ACCHI 16 36#define SREG_EXCSAVE 208
37#define ACCLO 17 37#define SREG_CCOMPARE 240
38#define MR 32 38#define SREG_MISC 244
39#define WINDOWBASE 72
40#define WINDOWSTART 73
41#define PTEVADDR 83
42#define RASID 90
43#define ITLBCFG 91
44#define DTLBCFG 92
45#define IBREAKENABLE 96
46#define DDR 104
47#define IBREAKA 128
48#define DBREAKA 144
49#define DBREAKC 160
50#define EPC 176
51#define EPC_1 177
52#define DEPC 192
53#define EPS 192
54#define EPS_1 193
55#define EXCSAVE 208
56#define EXCSAVE_1 209
57#define INTERRUPT 226
58#define INTENABLE 228
59#define PS 230
60#define THREADPTR 231
61#define EXCCAUSE 232
62#define DEBUGCAUSE 233
63#define CCOUNT 234
64#define PRID 235
65#define ICOUNT 236
66#define ICOUNTLEVEL 237
67#define EXCVADDR 238
68#define CCOMPARE 240
69#define MISC_SR 244
70
71/* Special names for read-only and write-only interrupt registers. */
72
73#define INTREAD 226
74#define INTSET 226
75#define INTCLEAR 227
76 39
77/* EXCCAUSE register fields */ 40/* EXCCAUSE register fields */
78 41
diff --git a/arch/xtensa/include/asm/resource.h b/arch/xtensa/include/asm/resource.h
deleted file mode 100644
index 17b5ab31177..00000000000
--- a/arch/xtensa/include/asm/resource.h
+++ /dev/null
@@ -1,16 +0,0 @@
1/*
2 * include/asm-xtensa/resource.h
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (C) 2005 Tensilica Inc.
9 */
10
11#ifndef _XTENSA_RESOURCE_H
12#define _XTENSA_RESOURCE_H
13
14#include <asm-generic/resource.h>
15
16#endif /* _XTENSA_RESOURCE_H */
diff --git a/arch/xtensa/include/asm/scatterlist.h b/arch/xtensa/include/asm/scatterlist.h
deleted file mode 100644
index a0421a61d9e..00000000000
--- a/arch/xtensa/include/asm/scatterlist.h
+++ /dev/null
@@ -1,16 +0,0 @@
1/*
2 * include/asm-xtensa/scatterlist.h
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (C) 2001 - 2005 Tensilica Inc.
9 */
10
11#ifndef _XTENSA_SCATTERLIST_H
12#define _XTENSA_SCATTERLIST_H
13
14#include <asm-generic/scatterlist.h>
15
16#endif /* _XTENSA_SCATTERLIST_H */
diff --git a/arch/xtensa/include/asm/sections.h b/arch/xtensa/include/asm/sections.h
deleted file mode 100644
index 40b5191b55a..00000000000
--- a/arch/xtensa/include/asm/sections.h
+++ /dev/null
@@ -1,16 +0,0 @@
1/*
2 * include/asm-xtensa/sections.h
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (C) 2001 - 2005 Tensilica Inc.
9 */
10
11#ifndef _XTENSA_SECTIONS_H
12#define _XTENSA_SECTIONS_H
13
14#include <asm-generic/sections.h>
15
16#endif /* _XTENSA_SECTIONS_H */
diff --git a/arch/xtensa/include/asm/siginfo.h b/arch/xtensa/include/asm/siginfo.h
deleted file mode 100644
index 6916248295d..00000000000
--- a/arch/xtensa/include/asm/siginfo.h
+++ /dev/null
@@ -1,16 +0,0 @@
1/*
2 * include/asm-xtensa/siginfo.h
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (C) 2001 - 2005 Tensilica Inc.
9 */
10
11#ifndef _XTENSA_SIGINFO_H
12#define _XTENSA_SIGINFO_H
13
14#include <asm-generic/siginfo.h>
15
16#endif /* _XTENSA_SIGINFO_H */
diff --git a/arch/xtensa/include/asm/signal.h b/arch/xtensa/include/asm/signal.h
index 7f201b9d419..72fd44c85b7 100644
--- a/arch/xtensa/include/asm/signal.h
+++ b/arch/xtensa/include/asm/signal.h
@@ -9,117 +9,12 @@
9 * 9 *
10 * Copyright (C) 2001 - 2005 Tensilica Inc. 10 * Copyright (C) 2001 - 2005 Tensilica Inc.
11 */ 11 */
12
13#ifndef _XTENSA_SIGNAL_H 12#ifndef _XTENSA_SIGNAL_H
14#define _XTENSA_SIGNAL_H 13#define _XTENSA_SIGNAL_H
15 14
16 15#include <uapi/asm/signal.h>
17#define _NSIG 64
18#define _NSIG_BPW 32
19#define _NSIG_WORDS (_NSIG / _NSIG_BPW)
20
21#ifndef __ASSEMBLY__
22
23#include <linux/types.h>
24
25/* Avoid too many header ordering problems. */
26struct siginfo;
27typedef unsigned long old_sigset_t; /* at least 32 bits */
28typedef struct {
29 unsigned long sig[_NSIG_WORDS];
30} sigset_t;
31
32#endif
33
34#define SIGHUP 1
35#define SIGINT 2
36#define SIGQUIT 3
37#define SIGILL 4
38#define SIGTRAP 5
39#define SIGABRT 6
40#define SIGIOT 6
41#define SIGBUS 7
42#define SIGFPE 8
43#define SIGKILL 9
44#define SIGUSR1 10
45#define SIGSEGV 11
46#define SIGUSR2 12
47#define SIGPIPE 13
48#define SIGALRM 14
49#define SIGTERM 15
50#define SIGSTKFLT 16
51#define SIGCHLD 17
52#define SIGCONT 18
53#define SIGSTOP 19
54#define SIGTSTP 20
55#define SIGTTIN 21
56#define SIGTTOU 22
57#define SIGURG 23
58#define SIGXCPU 24
59#define SIGXFSZ 25
60#define SIGVTALRM 26
61#define SIGPROF 27
62#define SIGWINCH 28
63#define SIGIO 29
64#define SIGPOLL SIGIO
65/* #define SIGLOST 29 */
66#define SIGPWR 30
67#define SIGSYS 31
68#define SIGUNUSED 31
69
70/* These should not be considered constants from userland. */
71#define SIGRTMIN 32
72#define SIGRTMAX (_NSIG-1)
73
74/*
75 * SA_FLAGS values:
76 *
77 * SA_ONSTACK indicates that a registered stack_t will be used.
78 * SA_RESTART flag to get restarting signals (which were the default long ago)
79 * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop.
80 * SA_RESETHAND clears the handler when the signal is delivered.
81 * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies.
82 * SA_NODEFER prevents the current signal from being masked in the handler.
83 *
84 * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single
85 * Unix names RESETHAND and NODEFER respectively.
86 */
87#define SA_NOCLDSTOP 0x00000001
88#define SA_NOCLDWAIT 0x00000002 /* not supported yet */
89#define SA_SIGINFO 0x00000004
90#define SA_ONSTACK 0x08000000
91#define SA_RESTART 0x10000000
92#define SA_NODEFER 0x40000000
93#define SA_RESETHAND 0x80000000
94
95#define SA_NOMASK SA_NODEFER
96#define SA_ONESHOT SA_RESETHAND
97
98#define SA_RESTORER 0x04000000
99
100/*
101 * sigaltstack controls
102 */
103#define SS_ONSTACK 1
104#define SS_DISABLE 2
105
106#define MINSIGSTKSZ 2048
107#define SIGSTKSZ 8192
108 16
109#ifndef __ASSEMBLY__ 17#ifndef __ASSEMBLY__
110
111#define SIG_BLOCK 0 /* for blocking signals */
112#define SIG_UNBLOCK 1 /* for unblocking signals */
113#define SIG_SETMASK 2 /* for setting the signal mask */
114
115/* Type of a signal handler. */
116typedef void (*__sighandler_t)(int);
117
118#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
119#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
120#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
121
122#ifdef __KERNEL__
123struct sigaction { 18struct sigaction {
124 __sighandler_t sa_handler; 19 __sighandler_t sa_handler;
125 unsigned long sa_flags; 20 unsigned long sa_flags;
@@ -131,35 +26,8 @@ struct k_sigaction {
131 struct sigaction sa; 26 struct sigaction sa;
132}; 27};
133 28
134#else
135
136/* Here we must cater to libcs that poke about in kernel headers. */
137
138struct sigaction {
139 union {
140 __sighandler_t _sa_handler;
141 void (*_sa_sigaction)(int, struct siginfo *, void *);
142 } _u;
143 sigset_t sa_mask;
144 unsigned long sa_flags;
145 void (*sa_restorer)(void);
146};
147
148#define sa_handler _u._sa_handler
149#define sa_sigaction _u._sa_sigaction
150
151#endif /* __KERNEL__ */
152
153typedef struct sigaltstack {
154 void *ss_sp;
155 int ss_flags;
156 size_t ss_size;
157} stack_t;
158
159#ifdef __KERNEL__
160#include <asm/sigcontext.h> 29#include <asm/sigcontext.h>
161#define ptrace_signal_deliver(regs, cookie) do { } while (0) 30#define ptrace_signal_deliver(regs, cookie) do { } while (0)
162 31
163#endif /* __KERNEL__ */
164#endif /* __ASSEMBLY__ */ 32#endif /* __ASSEMBLY__ */
165#endif /* _XTENSA_SIGNAL_H */ 33#endif /* _XTENSA_SIGNAL_H */
diff --git a/arch/xtensa/include/asm/statfs.h b/arch/xtensa/include/asm/statfs.h
deleted file mode 100644
index 9c3d1a21313..00000000000
--- a/arch/xtensa/include/asm/statfs.h
+++ /dev/null
@@ -1,17 +0,0 @@
1/*
2 * include/asm-xtensa/statfs.h
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (C) 2005 Tensilica Inc.
9 */
10
11#ifndef _XTENSA_STATFS_H
12#define _XTENSA_STATFS_H
13
14#include <asm-generic/statfs.h>
15
16#endif /* _XTENSA_STATFS_H */
17
diff --git a/arch/xtensa/include/asm/syscall.h b/arch/xtensa/include/asm/syscall.h
index c1dacca312f..124aeee0d38 100644
--- a/arch/xtensa/include/asm/syscall.h
+++ b/arch/xtensa/include/asm/syscall.h
@@ -10,7 +10,7 @@
10 10
11struct pt_regs; 11struct pt_regs;
12struct sigaction; 12struct sigaction;
13asmlinkage long xtensa_execve(char*, char**, char**, struct pt_regs*); 13asmlinkage long sys_execve(char*, char**, char**, struct pt_regs*);
14asmlinkage long xtensa_clone(unsigned long, unsigned long, struct pt_regs*); 14asmlinkage long xtensa_clone(unsigned long, unsigned long, struct pt_regs*);
15asmlinkage long xtensa_ptrace(long, long, long, long); 15asmlinkage long xtensa_ptrace(long, long, long, long);
16asmlinkage long xtensa_sigreturn(struct pt_regs*); 16asmlinkage long xtensa_sigreturn(struct pt_regs*);
diff --git a/arch/xtensa/include/asm/termios.h b/arch/xtensa/include/asm/termios.h
deleted file mode 100644
index 4673f42f88a..00000000000
--- a/arch/xtensa/include/asm/termios.h
+++ /dev/null
@@ -1,105 +0,0 @@
1/*
2 * include/asm-xtensa/termios.h
3 *
4 * Copied from SH.
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 *
10 * Copyright (C) 2001 - 2005 Tensilica Inc.
11 */
12
13#ifndef _XTENSA_TERMIOS_H
14#define _XTENSA_TERMIOS_H
15
16#include <asm/termbits.h>
17#include <asm/ioctls.h>
18
19struct winsize {
20 unsigned short ws_row;
21 unsigned short ws_col;
22 unsigned short ws_xpixel;
23 unsigned short ws_ypixel;
24};
25
26#define NCC 8
27struct termio {
28 unsigned short c_iflag; /* input mode flags */
29 unsigned short c_oflag; /* output mode flags */
30 unsigned short c_cflag; /* control mode flags */
31 unsigned short c_lflag; /* local mode flags */
32 unsigned char c_line; /* line discipline */
33 unsigned char c_cc[NCC]; /* control characters */
34};
35
36/* Modem lines */
37
38#define TIOCM_LE 0x001
39#define TIOCM_DTR 0x002
40#define TIOCM_RTS 0x004
41#define TIOCM_ST 0x008
42#define TIOCM_SR 0x010
43#define TIOCM_CTS 0x020
44#define TIOCM_CAR 0x040
45#define TIOCM_RNG 0x080
46#define TIOCM_DSR 0x100
47#define TIOCM_CD TIOCM_CAR
48#define TIOCM_RI TIOCM_RNG
49#define TIOCM_OUT1 0x2000
50#define TIOCM_OUT2 0x4000
51#define TIOCM_LOOP 0x8000
52
53/* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
54
55#ifdef __KERNEL__
56
57/* intr=^C quit=^\ erase=del kill=^U
58 eof=^D vtime=\0 vmin=\1 sxtc=\0
59 start=^Q stop=^S susp=^Z eol=\0
60 reprint=^R discard=^U werase=^W lnext=^V
61 eol2=\0
62*/
63#define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0"
64
65/*
66 * Translate a "termio" structure into a "termios". Ugh.
67 */
68
69#define SET_LOW_TERMIOS_BITS(termios, termio, x) { \
70 unsigned short __tmp; \
71 get_user(__tmp,&(termio)->x); \
72 *(unsigned short *) &(termios)->x = __tmp; \
73}
74
75#define user_termio_to_kernel_termios(termios, termio) \
76({ \
77 SET_LOW_TERMIOS_BITS(termios, termio, c_iflag); \
78 SET_LOW_TERMIOS_BITS(termios, termio, c_oflag); \
79 SET_LOW_TERMIOS_BITS(termios, termio, c_cflag); \
80 SET_LOW_TERMIOS_BITS(termios, termio, c_lflag); \
81 copy_from_user((termios)->c_cc, (termio)->c_cc, NCC); \
82})
83
84/*
85 * Translate a "termios" structure into a "termio". Ugh.
86 */
87
88#define kernel_termios_to_user_termio(termio, termios) \
89({ \
90 put_user((termios)->c_iflag, &(termio)->c_iflag); \
91 put_user((termios)->c_oflag, &(termio)->c_oflag); \
92 put_user((termios)->c_cflag, &(termio)->c_cflag); \
93 put_user((termios)->c_lflag, &(termio)->c_lflag); \
94 put_user((termios)->c_line, &(termio)->c_line); \
95 copy_to_user((termio)->c_cc, (termios)->c_cc, NCC); \
96})
97
98#define user_termios_to_kernel_termios(k, u) copy_from_user(k, u, sizeof(struct termios2))
99#define kernel_termios_to_user_termios(u, k) copy_to_user(u, k, sizeof(struct termios2))
100#define user_termios_to_kernel_termios_1(k, u) copy_from_user(k, u, sizeof(struct termios))
101#define kernel_termios_to_user_termios_1(u, k) copy_to_user(u, k, sizeof(struct termios))
102
103#endif /* __KERNEL__ */
104
105#endif /* _XTENSA_TERMIOS_H */
diff --git a/arch/xtensa/include/asm/timex.h b/arch/xtensa/include/asm/timex.h
index 053bc427210..175b3d5e1b0 100644
--- a/arch/xtensa/include/asm/timex.h
+++ b/arch/xtensa/include/asm/timex.h
@@ -63,10 +63,10 @@ extern cycles_t cacheflush_time;
63 * Register access. 63 * Register access.
64 */ 64 */
65 65
66#define WSR_CCOUNT(r) asm volatile ("wsr %0,"__stringify(CCOUNT) :: "a" (r)) 66#define WSR_CCOUNT(r) asm volatile ("wsr %0, ccount" :: "a" (r))
67#define RSR_CCOUNT(r) asm volatile ("rsr %0,"__stringify(CCOUNT) : "=a" (r)) 67#define RSR_CCOUNT(r) asm volatile ("rsr %0, ccount" : "=a" (r))
68#define WSR_CCOMPARE(x,r) asm volatile ("wsr %0,"__stringify(CCOMPARE)"+"__stringify(x) :: "a"(r)) 68#define WSR_CCOMPARE(x,r) asm volatile ("wsr %0,"__stringify(SREG_CCOMPARE)"+"__stringify(x) :: "a"(r))
69#define RSR_CCOMPARE(x,r) asm volatile ("rsr %0,"__stringify(CCOMPARE)"+"__stringify(x) : "=a"(r)) 69#define RSR_CCOMPARE(x,r) asm volatile ("rsr %0,"__stringify(SREG_CCOMPARE)"+"__stringify(x) : "=a"(r))
70 70
71static inline unsigned long get_ccount (void) 71static inline unsigned long get_ccount (void)
72{ 72{
diff --git a/arch/xtensa/include/asm/tlbflush.h b/arch/xtensa/include/asm/tlbflush.h
index 46d240074f7..43dd348a5a4 100644
--- a/arch/xtensa/include/asm/tlbflush.h
+++ b/arch/xtensa/include/asm/tlbflush.h
@@ -86,26 +86,26 @@ static inline void invalidate_dtlb_entry_no_isync (unsigned entry)
86 86
87static inline void set_itlbcfg_register (unsigned long val) 87static inline void set_itlbcfg_register (unsigned long val)
88{ 88{
89 __asm__ __volatile__("wsr %0, "__stringify(ITLBCFG)"\n\t" "isync\n\t" 89 __asm__ __volatile__("wsr %0, itlbcfg\n\t" "isync\n\t"
90 : : "a" (val)); 90 : : "a" (val));
91} 91}
92 92
93static inline void set_dtlbcfg_register (unsigned long val) 93static inline void set_dtlbcfg_register (unsigned long val)
94{ 94{
95 __asm__ __volatile__("wsr %0, "__stringify(DTLBCFG)"; dsync\n\t" 95 __asm__ __volatile__("wsr %0, dtlbcfg; dsync\n\t"
96 : : "a" (val)); 96 : : "a" (val));
97} 97}
98 98
99static inline void set_ptevaddr_register (unsigned long val) 99static inline void set_ptevaddr_register (unsigned long val)
100{ 100{
101 __asm__ __volatile__(" wsr %0, "__stringify(PTEVADDR)"; isync\n" 101 __asm__ __volatile__(" wsr %0, ptevaddr; isync\n"
102 : : "a" (val)); 102 : : "a" (val));
103} 103}
104 104
105static inline unsigned long read_ptevaddr_register (void) 105static inline unsigned long read_ptevaddr_register (void)
106{ 106{
107 unsigned long tmp; 107 unsigned long tmp;
108 __asm__ __volatile__("rsr %0, "__stringify(PTEVADDR)"\n\t" : "=a" (tmp)); 108 __asm__ __volatile__("rsr %0, ptevaddr\n\t" : "=a" (tmp));
109 return tmp; 109 return tmp;
110} 110}
111 111
diff --git a/arch/xtensa/include/asm/topology.h b/arch/xtensa/include/asm/topology.h
deleted file mode 100644
index 7309e38a0cc..00000000000
--- a/arch/xtensa/include/asm/topology.h
+++ /dev/null
@@ -1,16 +0,0 @@
1/*
2 * include/asm-xtensa/topology.h
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (C) 2001 - 2005 Tensilica Inc.
9 */
10
11#ifndef _XTENSA_TOPOLOGY_H
12#define _XTENSA_TOPOLOGY_H
13
14#include <asm-generic/topology.h>
15
16#endif /* _XTENSA_TOPOLOGY_H */
diff --git a/arch/xtensa/include/asm/types.h b/arch/xtensa/include/asm/types.h
index 6d4db7e8ffa..2b410b8c7f7 100644
--- a/arch/xtensa/include/asm/types.h
+++ b/arch/xtensa/include/asm/types.h
@@ -7,30 +7,17 @@
7 * 7 *
8 * Copyright (C) 2001 - 2005 Tensilica Inc. 8 * Copyright (C) 2001 - 2005 Tensilica Inc.
9 */ 9 */
10
11#ifndef _XTENSA_TYPES_H 10#ifndef _XTENSA_TYPES_H
12#define _XTENSA_TYPES_H 11#define _XTENSA_TYPES_H
13 12
14#include <asm-generic/int-ll64.h> 13#include <uapi/asm/types.h>
15
16#ifdef __ASSEMBLY__
17# define __XTENSA_UL(x) (x)
18# define __XTENSA_UL_CONST(x) x
19#else
20# define __XTENSA_UL(x) ((unsigned long)(x))
21# define __XTENSA_UL_CONST(x) x##UL
22#endif
23 14
24#ifndef __ASSEMBLY__ 15#ifndef __ASSEMBLY__
25
26/* 16/*
27 * These aren't exported outside the kernel to avoid name space clashes 17 * These aren't exported outside the kernel to avoid name space clashes
28 */ 18 */
29#ifdef __KERNEL__
30 19
31#define BITS_PER_LONG 32 20#define BITS_PER_LONG 32
32 21
33#endif /* __KERNEL__ */
34#endif 22#endif
35
36#endif /* _XTENSA_TYPES_H */ 23#endif /* _XTENSA_TYPES_H */
diff --git a/arch/xtensa/include/asm/unistd.h b/arch/xtensa/include/asm/unistd.h
index bc7e005faa6..f4e6eaa40d1 100644
--- a/arch/xtensa/include/asm/unistd.h
+++ b/arch/xtensa/include/asm/unistd.h
@@ -1,712 +1,8 @@
1/*
2 * include/asm-xtensa/unistd.h
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (C) 2001 - 2005 Tensilica Inc.
9 */
10
11#ifndef _XTENSA_UNISTD_H 1#ifndef _XTENSA_UNISTD_H
12#define _XTENSA_UNISTD_H 2#define _XTENSA_UNISTD_H
13 3
14#ifndef __SYSCALL 4#define __ARCH_WANT_SYS_EXECVE
15# define __SYSCALL(nr,func,nargs) 5#include <uapi/asm/unistd.h>
16#endif
17
18#define __NR_spill 0
19__SYSCALL( 0, sys_ni_syscall, 0)
20#define __NR_xtensa 1
21__SYSCALL( 1, sys_ni_syscall, 0)
22#define __NR_available4 2
23__SYSCALL( 2, sys_ni_syscall, 0)
24#define __NR_available5 3
25__SYSCALL( 3, sys_ni_syscall, 0)
26#define __NR_available6 4
27__SYSCALL( 4, sys_ni_syscall, 0)
28#define __NR_available7 5
29__SYSCALL( 5, sys_ni_syscall, 0)
30#define __NR_available8 6
31__SYSCALL( 6, sys_ni_syscall, 0)
32#define __NR_available9 7
33__SYSCALL( 7, sys_ni_syscall, 0)
34
35/* File Operations */
36
37#define __NR_open 8
38__SYSCALL( 8, sys_open, 3)
39#define __NR_close 9
40__SYSCALL( 9, sys_close, 1)
41#define __NR_dup 10
42__SYSCALL( 10, sys_dup, 1)
43#define __NR_dup2 11
44__SYSCALL( 11, sys_dup2, 2)
45#define __NR_read 12
46__SYSCALL( 12, sys_read, 3)
47#define __NR_write 13
48__SYSCALL( 13, sys_write, 3)
49#define __NR_select 14
50__SYSCALL( 14, sys_select, 5)
51#define __NR_lseek 15
52__SYSCALL( 15, sys_lseek, 3)
53#define __NR_poll 16
54__SYSCALL( 16, sys_poll, 3)
55#define __NR__llseek 17
56__SYSCALL( 17, sys_llseek, 5)
57#define __NR_epoll_wait 18
58__SYSCALL( 18, sys_epoll_wait, 4)
59#define __NR_epoll_ctl 19
60__SYSCALL( 19, sys_epoll_ctl, 4)
61#define __NR_epoll_create 20
62__SYSCALL( 20, sys_epoll_create, 1)
63#define __NR_creat 21
64__SYSCALL( 21, sys_creat, 2)
65#define __NR_truncate 22
66__SYSCALL( 22, sys_truncate, 2)
67#define __NR_ftruncate 23
68__SYSCALL( 23, sys_ftruncate, 2)
69#define __NR_readv 24
70__SYSCALL( 24, sys_readv, 3)
71#define __NR_writev 25
72__SYSCALL( 25, sys_writev, 3)
73#define __NR_fsync 26
74__SYSCALL( 26, sys_fsync, 1)
75#define __NR_fdatasync 27
76__SYSCALL( 27, sys_fdatasync, 1)
77#define __NR_truncate64 28
78__SYSCALL( 28, sys_truncate64, 2)
79#define __NR_ftruncate64 29
80__SYSCALL( 29, sys_ftruncate64, 2)
81#define __NR_pread64 30
82__SYSCALL( 30, sys_pread64, 6)
83#define __NR_pwrite64 31
84__SYSCALL( 31, sys_pwrite64, 6)
85
86#define __NR_link 32
87__SYSCALL( 32, sys_link, 2)
88#define __NR_rename 33
89__SYSCALL( 33, sys_rename, 2)
90#define __NR_symlink 34
91__SYSCALL( 34, sys_symlink, 2)
92#define __NR_readlink 35
93__SYSCALL( 35, sys_readlink, 3)
94#define __NR_mknod 36
95__SYSCALL( 36, sys_mknod, 3)
96#define __NR_pipe 37
97__SYSCALL( 37, sys_pipe, 1)
98#define __NR_unlink 38
99__SYSCALL( 38, sys_unlink, 1)
100#define __NR_rmdir 39
101__SYSCALL( 39, sys_rmdir, 1)
102
103#define __NR_mkdir 40
104__SYSCALL( 40, sys_mkdir, 2)
105#define __NR_chdir 41
106__SYSCALL( 41, sys_chdir, 1)
107#define __NR_fchdir 42
108__SYSCALL( 42, sys_fchdir, 1)
109#define __NR_getcwd 43
110__SYSCALL( 43, sys_getcwd, 2)
111
112#define __NR_chmod 44
113__SYSCALL( 44, sys_chmod, 2)
114#define __NR_chown 45
115__SYSCALL( 45, sys_chown, 3)
116#define __NR_stat 46
117__SYSCALL( 46, sys_newstat, 2)
118#define __NR_stat64 47
119__SYSCALL( 47, sys_stat64, 2)
120
121#define __NR_lchown 48
122__SYSCALL( 48, sys_lchown, 3)
123#define __NR_lstat 49
124__SYSCALL( 49, sys_newlstat, 2)
125#define __NR_lstat64 50
126__SYSCALL( 50, sys_lstat64, 2)
127#define __NR_available51 51
128__SYSCALL( 51, sys_ni_syscall, 0)
129
130#define __NR_fchmod 52
131__SYSCALL( 52, sys_fchmod, 2)
132#define __NR_fchown 53
133__SYSCALL( 53, sys_fchown, 3)
134#define __NR_fstat 54
135__SYSCALL( 54, sys_newfstat, 2)
136#define __NR_fstat64 55
137__SYSCALL( 55, sys_fstat64, 2)
138
139#define __NR_flock 56
140__SYSCALL( 56, sys_flock, 2)
141#define __NR_access 57
142__SYSCALL( 57, sys_access, 2)
143#define __NR_umask 58
144__SYSCALL( 58, sys_umask, 1)
145#define __NR_getdents 59
146__SYSCALL( 59, sys_getdents, 3)
147#define __NR_getdents64 60
148__SYSCALL( 60, sys_getdents64, 3)
149#define __NR_fcntl64 61
150__SYSCALL( 61, sys_fcntl64, 3)
151#define __NR_available62 62
152__SYSCALL( 62, sys_ni_syscall, 0)
153#define __NR_fadvise64_64 63
154__SYSCALL( 63, xtensa_fadvise64_64, 6)
155#define __NR_utime 64 /* glibc 2.3.3 ?? */
156__SYSCALL( 64, sys_utime, 2)
157#define __NR_utimes 65
158__SYSCALL( 65, sys_utimes, 2)
159#define __NR_ioctl 66
160__SYSCALL( 66, sys_ioctl, 3)
161#define __NR_fcntl 67
162__SYSCALL( 67, sys_fcntl, 3)
163
164#define __NR_setxattr 68
165__SYSCALL( 68, sys_setxattr, 5)
166#define __NR_getxattr 69
167__SYSCALL( 69, sys_getxattr, 4)
168#define __NR_listxattr 70
169__SYSCALL( 70, sys_listxattr, 3)
170#define __NR_removexattr 71
171__SYSCALL( 71, sys_removexattr, 2)
172#define __NR_lsetxattr 72
173__SYSCALL( 72, sys_lsetxattr, 5)
174#define __NR_lgetxattr 73
175__SYSCALL( 73, sys_lgetxattr, 4)
176#define __NR_llistxattr 74
177__SYSCALL( 74, sys_llistxattr, 3)
178#define __NR_lremovexattr 75
179__SYSCALL( 75, sys_lremovexattr, 2)
180#define __NR_fsetxattr 76
181__SYSCALL( 76, sys_fsetxattr, 5)
182#define __NR_fgetxattr 77
183__SYSCALL( 77, sys_fgetxattr, 4)
184#define __NR_flistxattr 78
185__SYSCALL( 78, sys_flistxattr, 3)
186#define __NR_fremovexattr 79
187__SYSCALL( 79, sys_fremovexattr, 2)
188
189/* File Map / Shared Memory Operations */
190
191#define __NR_mmap2 80
192__SYSCALL( 80, sys_mmap_pgoff, 6)
193#define __NR_munmap 81
194__SYSCALL( 81, sys_munmap, 2)
195#define __NR_mprotect 82
196__SYSCALL( 82, sys_mprotect, 3)
197#define __NR_brk 83
198__SYSCALL( 83, sys_brk, 1)
199#define __NR_mlock 84
200__SYSCALL( 84, sys_mlock, 2)
201#define __NR_munlock 85
202__SYSCALL( 85, sys_munlock, 2)
203#define __NR_mlockall 86
204__SYSCALL( 86, sys_mlockall, 1)
205#define __NR_munlockall 87
206__SYSCALL( 87, sys_munlockall, 0)
207#define __NR_mremap 88
208__SYSCALL( 88, sys_mremap, 4)
209#define __NR_msync 89
210__SYSCALL( 89, sys_msync, 3)
211#define __NR_mincore 90
212__SYSCALL( 90, sys_mincore, 3)
213#define __NR_madvise 91
214__SYSCALL( 91, sys_madvise, 3)
215#define __NR_shmget 92
216__SYSCALL( 92, sys_shmget, 4)
217#define __NR_shmat 93
218__SYSCALL( 93, xtensa_shmat, 4)
219#define __NR_shmctl 94
220__SYSCALL( 94, sys_shmctl, 4)
221#define __NR_shmdt 95
222__SYSCALL( 95, sys_shmdt, 4)
223
224/* Socket Operations */
225
226#define __NR_socket 96
227__SYSCALL( 96, sys_socket, 3)
228#define __NR_setsockopt 97
229__SYSCALL( 97, sys_setsockopt, 5)
230#define __NR_getsockopt 98
231__SYSCALL( 98, sys_getsockopt, 5)
232#define __NR_shutdown 99
233__SYSCALL( 99, sys_shutdown, 2)
234
235#define __NR_bind 100
236__SYSCALL(100, sys_bind, 3)
237#define __NR_connect 101
238__SYSCALL(101, sys_connect, 3)
239#define __NR_listen 102
240__SYSCALL(102, sys_listen, 2)
241#define __NR_accept 103
242__SYSCALL(103, sys_accept, 3)
243
244#define __NR_getsockname 104
245__SYSCALL(104, sys_getsockname, 3)
246#define __NR_getpeername 105
247__SYSCALL(105, sys_getpeername, 3)
248#define __NR_sendmsg 106
249__SYSCALL(106, sys_sendmsg, 3)
250#define __NR_recvmsg 107
251__SYSCALL(107, sys_recvmsg, 3)
252#define __NR_send 108
253__SYSCALL(108, sys_send, 4)
254#define __NR_recv 109
255__SYSCALL(109, sys_recv, 4)
256#define __NR_sendto 110
257__SYSCALL(110, sys_sendto, 6)
258#define __NR_recvfrom 111
259__SYSCALL(111, sys_recvfrom, 6)
260
261#define __NR_socketpair 112
262__SYSCALL(112, sys_socketpair, 4)
263#define __NR_sendfile 113
264__SYSCALL(113, sys_sendfile, 4)
265#define __NR_sendfile64 114
266__SYSCALL(114, sys_sendfile64, 4)
267#define __NR_available115 115
268__SYSCALL(115, sys_ni_syscall, 0)
269
270/* Process Operations */
271
272#define __NR_clone 116
273__SYSCALL(116, xtensa_clone, 5)
274#define __NR_execve 117
275__SYSCALL(117, xtensa_execve, 3)
276#define __NR_exit 118
277__SYSCALL(118, sys_exit, 1)
278#define __NR_exit_group 119
279__SYSCALL(119, sys_exit_group, 1)
280#define __NR_getpid 120
281__SYSCALL(120, sys_getpid, 0)
282#define __NR_wait4 121
283__SYSCALL(121, sys_wait4, 4)
284#define __NR_waitid 122
285__SYSCALL(122, sys_waitid, 5)
286#define __NR_kill 123
287__SYSCALL(123, sys_kill, 2)
288#define __NR_tkill 124
289__SYSCALL(124, sys_tkill, 2)
290#define __NR_tgkill 125
291__SYSCALL(125, sys_tgkill, 3)
292#define __NR_set_tid_address 126
293__SYSCALL(126, sys_set_tid_address, 1)
294#define __NR_gettid 127
295__SYSCALL(127, sys_gettid, 0)
296#define __NR_setsid 128
297__SYSCALL(128, sys_setsid, 0)
298#define __NR_getsid 129
299__SYSCALL(129, sys_getsid, 1)
300#define __NR_prctl 130
301__SYSCALL(130, sys_prctl, 5)
302#define __NR_personality 131
303__SYSCALL(131, sys_personality, 1)
304#define __NR_getpriority 132
305__SYSCALL(132, sys_getpriority, 2)
306#define __NR_setpriority 133
307__SYSCALL(133, sys_setpriority, 3)
308#define __NR_setitimer 134
309__SYSCALL(134, sys_setitimer, 3)
310#define __NR_getitimer 135
311__SYSCALL(135, sys_getitimer, 2)
312#define __NR_setuid 136
313__SYSCALL(136, sys_setuid, 1)
314#define __NR_getuid 137
315__SYSCALL(137, sys_getuid, 0)
316#define __NR_setgid 138
317__SYSCALL(138, sys_setgid, 1)
318#define __NR_getgid 139
319__SYSCALL(139, sys_getgid, 0)
320#define __NR_geteuid 140
321__SYSCALL(140, sys_geteuid, 0)
322#define __NR_getegid 141
323__SYSCALL(141, sys_getegid, 0)
324#define __NR_setreuid 142
325__SYSCALL(142, sys_setreuid, 2)
326#define __NR_setregid 143
327__SYSCALL(143, sys_setregid, 2)
328#define __NR_setresuid 144
329__SYSCALL(144, sys_setresuid, 3)
330#define __NR_getresuid 145
331__SYSCALL(145, sys_getresuid, 3)
332#define __NR_setresgid 146
333__SYSCALL(146, sys_setresgid, 3)
334#define __NR_getresgid 147
335__SYSCALL(147, sys_getresgid, 3)
336#define __NR_setpgid 148
337__SYSCALL(148, sys_setpgid, 2)
338#define __NR_getpgid 149
339__SYSCALL(149, sys_getpgid, 1)
340#define __NR_getppid 150
341__SYSCALL(150, sys_getppid, 0)
342#define __NR_getpgrp 151
343__SYSCALL(151, sys_getpgrp, 0)
344
345#define __NR_reserved152 152 /* set_thread_area */
346__SYSCALL(152, sys_ni_syscall, 0)
347#define __NR_reserved153 153 /* get_thread_area */
348__SYSCALL(153, sys_ni_syscall, 0)
349#define __NR_times 154
350__SYSCALL(154, sys_times, 1)
351#define __NR_acct 155
352__SYSCALL(155, sys_acct, 1)
353#define __NR_sched_setaffinity 156
354__SYSCALL(156, sys_sched_setaffinity, 3)
355#define __NR_sched_getaffinity 157
356__SYSCALL(157, sys_sched_getaffinity, 3)
357#define __NR_capget 158
358__SYSCALL(158, sys_capget, 2)
359#define __NR_capset 159
360__SYSCALL(159, sys_capset, 2)
361#define __NR_ptrace 160
362__SYSCALL(160, sys_ptrace, 4)
363#define __NR_semtimedop 161
364__SYSCALL(161, sys_semtimedop, 5)
365#define __NR_semget 162
366__SYSCALL(162, sys_semget, 4)
367#define __NR_semop 163
368__SYSCALL(163, sys_semop, 4)
369#define __NR_semctl 164
370__SYSCALL(164, sys_semctl, 4)
371#define __NR_available165 165
372__SYSCALL(165, sys_ni_syscall, 0)
373#define __NR_msgget 166
374__SYSCALL(166, sys_msgget, 4)
375#define __NR_msgsnd 167
376__SYSCALL(167, sys_msgsnd, 4)
377#define __NR_msgrcv 168
378__SYSCALL(168, sys_msgrcv, 4)
379#define __NR_msgctl 169
380__SYSCALL(169, sys_msgctl, 4)
381#define __NR_available170 170
382__SYSCALL(170, sys_ni_syscall, 0)
383#define __NR_available171 171
384__SYSCALL(171, sys_ni_syscall, 0)
385
386/* File System */
387
388#define __NR_mount 172
389__SYSCALL(172, sys_mount, 5)
390#define __NR_swapon 173
391__SYSCALL(173, sys_swapon, 2)
392#define __NR_chroot 174
393__SYSCALL(174, sys_chroot, 1)
394#define __NR_pivot_root 175
395__SYSCALL(175, sys_pivot_root, 2)
396#define __NR_umount 176
397__SYSCALL(176, sys_umount, 2)
398#define __NR_swapoff 177
399__SYSCALL(177, sys_swapoff, 1)
400#define __NR_sync 178
401__SYSCALL(178, sys_sync, 0)
402#define __NR_available179 179
403__SYSCALL(179, sys_ni_syscall, 0)
404#define __NR_setfsuid 180
405__SYSCALL(180, sys_setfsuid, 1)
406#define __NR_setfsgid 181
407__SYSCALL(181, sys_setfsgid, 1)
408#define __NR_sysfs 182
409__SYSCALL(182, sys_sysfs, 3)
410#define __NR_ustat 183
411__SYSCALL(183, sys_ustat, 2)
412#define __NR_statfs 184
413__SYSCALL(184, sys_statfs, 2)
414#define __NR_fstatfs 185
415__SYSCALL(185, sys_fstatfs, 2)
416#define __NR_statfs64 186
417__SYSCALL(186, sys_statfs64, 3)
418#define __NR_fstatfs64 187
419__SYSCALL(187, sys_fstatfs64, 3)
420
421/* System */
422
423#define __NR_setrlimit 188
424__SYSCALL(188, sys_setrlimit, 2)
425#define __NR_getrlimit 189
426__SYSCALL(189, sys_getrlimit, 2)
427#define __NR_getrusage 190
428__SYSCALL(190, sys_getrusage, 2)
429#define __NR_futex 191
430__SYSCALL(191, sys_futex, 5)
431#define __NR_gettimeofday 192
432__SYSCALL(192, sys_gettimeofday, 2)
433#define __NR_settimeofday 193
434__SYSCALL(193, sys_settimeofday, 2)
435#define __NR_adjtimex 194
436__SYSCALL(194, sys_adjtimex, 1)
437#define __NR_nanosleep 195
438__SYSCALL(195, sys_nanosleep, 2)
439#define __NR_getgroups 196
440__SYSCALL(196, sys_getgroups, 2)
441#define __NR_setgroups 197
442__SYSCALL(197, sys_setgroups, 2)
443#define __NR_sethostname 198
444__SYSCALL(198, sys_sethostname, 2)
445#define __NR_setdomainname 199
446__SYSCALL(199, sys_setdomainname, 2)
447#define __NR_syslog 200
448__SYSCALL(200, sys_syslog, 3)
449#define __NR_vhangup 201
450__SYSCALL(201, sys_vhangup, 0)
451#define __NR_uselib 202
452__SYSCALL(202, sys_uselib, 1)
453#define __NR_reboot 203
454__SYSCALL(203, sys_reboot, 3)
455#define __NR_quotactl 204
456__SYSCALL(204, sys_quotactl, 4)
457#define __NR_nfsservctl 205
458__SYSCALL(205, sys_ni_syscall, 0)
459#define __NR__sysctl 206
460__SYSCALL(206, sys_sysctl, 1)
461#define __NR_bdflush 207
462__SYSCALL(207, sys_bdflush, 2)
463#define __NR_uname 208
464__SYSCALL(208, sys_newuname, 1)
465#define __NR_sysinfo 209
466__SYSCALL(209, sys_sysinfo, 1)
467#define __NR_init_module 210
468__SYSCALL(210, sys_init_module, 2)
469#define __NR_delete_module 211
470__SYSCALL(211, sys_delete_module, 1)
471
472#define __NR_sched_setparam 212
473__SYSCALL(212, sys_sched_setparam, 2)
474#define __NR_sched_getparam 213
475__SYSCALL(213, sys_sched_getparam, 2)
476#define __NR_sched_setscheduler 214
477__SYSCALL(214, sys_sched_setscheduler, 3)
478#define __NR_sched_getscheduler 215
479__SYSCALL(215, sys_sched_getscheduler, 1)
480#define __NR_sched_get_priority_max 216
481__SYSCALL(216, sys_sched_get_priority_max, 1)
482#define __NR_sched_get_priority_min 217
483__SYSCALL(217, sys_sched_get_priority_min, 1)
484#define __NR_sched_rr_get_interval 218
485__SYSCALL(218, sys_sched_rr_get_interval, 2)
486#define __NR_sched_yield 219
487__SYSCALL(219, sys_sched_yield, 0)
488#define __NR_available222 222
489__SYSCALL(222, sys_ni_syscall, 0)
490
491/* Signal Handling */
492
493#define __NR_restart_syscall 223
494__SYSCALL(223, sys_restart_syscall, 0)
495#define __NR_sigaltstack 224
496__SYSCALL(224, xtensa_sigaltstack, 2)
497#define __NR_rt_sigreturn 225
498__SYSCALL(225, xtensa_rt_sigreturn, 1)
499#define __NR_rt_sigaction 226
500__SYSCALL(226, sys_rt_sigaction, 4)
501#define __NR_rt_sigprocmask 227
502__SYSCALL(227, sys_rt_sigprocmask, 4)
503#define __NR_rt_sigpending 228
504__SYSCALL(228, sys_rt_sigpending, 2)
505#define __NR_rt_sigtimedwait 229
506__SYSCALL(229, sys_rt_sigtimedwait, 4)
507#define __NR_rt_sigqueueinfo 230
508__SYSCALL(230, sys_rt_sigqueueinfo, 3)
509#define __NR_rt_sigsuspend 231
510__SYSCALL(231, sys_rt_sigsuspend, 2)
511
512/* Message */
513
514#define __NR_mq_open 232
515__SYSCALL(232, sys_mq_open, 4)
516#define __NR_mq_unlink 233
517__SYSCALL(233, sys_mq_unlink, 1)
518#define __NR_mq_timedsend 234
519__SYSCALL(234, sys_mq_timedsend, 5)
520#define __NR_mq_timedreceive 235
521__SYSCALL(235, sys_mq_timedreceive, 5)
522#define __NR_mq_notify 236
523__SYSCALL(236, sys_mq_notify, 2)
524#define __NR_mq_getsetattr 237
525__SYSCALL(237, sys_mq_getsetattr, 3)
526#define __NR_available238 238
527__SYSCALL(238, sys_ni_syscall, 0)
528
529/* IO */
530
531#define __NR_io_setup 239
532__SYSCALL(239, sys_io_setup, 2)
533#define __NR_io_destroy 240
534__SYSCALL(240, sys_io_destroy, 1)
535#define __NR_io_submit 241
536__SYSCALL(241, sys_io_submit, 3)
537#define __NR_io_getevents 242
538__SYSCALL(242, sys_io_getevents, 5)
539#define __NR_io_cancel 243
540__SYSCALL(243, sys_io_cancel, 3)
541#define __NR_clock_settime 244
542__SYSCALL(244, sys_clock_settime, 2)
543#define __NR_clock_gettime 245
544__SYSCALL(245, sys_clock_gettime, 2)
545#define __NR_clock_getres 246
546__SYSCALL(246, sys_clock_getres, 2)
547#define __NR_clock_nanosleep 247
548__SYSCALL(247, sys_clock_nanosleep, 4)
549
550/* Timer */
551
552#define __NR_timer_create 248
553__SYSCALL(248, sys_timer_create, 3)
554#define __NR_timer_delete 249
555__SYSCALL(249, sys_timer_delete, 1)
556#define __NR_timer_settime 250
557__SYSCALL(250, sys_timer_settime, 4)
558#define __NR_timer_gettime 251
559__SYSCALL(251, sys_timer_gettime, 2)
560#define __NR_timer_getoverrun 252
561__SYSCALL(252, sys_timer_getoverrun, 1)
562
563/* System */
564
565#define __NR_reserved244 253
566__SYSCALL(253, sys_ni_syscall, 0)
567#define __NR_lookup_dcookie 254
568__SYSCALL(254, sys_lookup_dcookie, 4)
569#define __NR_available255 255
570__SYSCALL(255, sys_ni_syscall, 0)
571#define __NR_add_key 256
572__SYSCALL(256, sys_add_key, 5)
573#define __NR_request_key 257
574__SYSCALL(257, sys_request_key, 5)
575#define __NR_keyctl 258
576__SYSCALL(258, sys_keyctl, 5)
577#define __NR_available259 259
578__SYSCALL(259, sys_ni_syscall, 0)
579
580
581#define __NR_readahead 260
582__SYSCALL(260, sys_readahead, 5)
583#define __NR_remap_file_pages 261
584__SYSCALL(261, sys_remap_file_pages, 5)
585#define __NR_migrate_pages 262
586__SYSCALL(262, sys_migrate_pages, 0)
587#define __NR_mbind 263
588__SYSCALL(263, sys_mbind, 6)
589#define __NR_get_mempolicy 264
590__SYSCALL(264, sys_get_mempolicy, 5)
591#define __NR_set_mempolicy 265
592__SYSCALL(265, sys_set_mempolicy, 3)
593#define __NR_unshare 266
594__SYSCALL(266, sys_unshare, 1)
595#define __NR_move_pages 267
596__SYSCALL(267, sys_move_pages, 0)
597#define __NR_splice 268
598__SYSCALL(268, sys_splice, 0)
599#define __NR_tee 269
600__SYSCALL(269, sys_tee, 0)
601#define __NR_vmsplice 270
602__SYSCALL(270, sys_vmsplice, 0)
603#define __NR_available271 271
604__SYSCALL(271, sys_ni_syscall, 0)
605
606#define __NR_pselect6 272
607__SYSCALL(272, sys_pselect6, 0)
608#define __NR_ppoll 273
609__SYSCALL(273, sys_ppoll, 0)
610#define __NR_epoll_pwait 274
611__SYSCALL(274, sys_epoll_pwait, 0)
612#define __NR_available275 275
613__SYSCALL(275, sys_ni_syscall, 0)
614
615#define __NR_inotify_init 276
616__SYSCALL(276, sys_inotify_init, 0)
617#define __NR_inotify_add_watch 277
618__SYSCALL(277, sys_inotify_add_watch, 3)
619#define __NR_inotify_rm_watch 278
620__SYSCALL(278, sys_inotify_rm_watch, 2)
621#define __NR_available279 279
622__SYSCALL(279, sys_ni_syscall, 0)
623
624#define __NR_getcpu 280
625__SYSCALL(280, sys_getcpu, 0)
626#define __NR_kexec_load 281
627__SYSCALL(281, sys_ni_syscall, 0)
628
629#define __NR_ioprio_set 282
630__SYSCALL(282, sys_ioprio_set, 2)
631#define __NR_ioprio_get 283
632__SYSCALL(283, sys_ioprio_get, 3)
633
634#define __NR_set_robust_list 284
635__SYSCALL(284, sys_set_robust_list, 3)
636#define __NR_get_robust_list 285
637__SYSCALL(285, sys_get_robust_list, 3)
638#define __NR_reserved286 286 /* sync_file_rangeX */
639__SYSCALL(286, sys_ni_syscall, 3)
640#define __NR_available287 287
641__SYSCALL(287, sys_faccessat, 0)
642
643/* Relative File Operations */
644
645#define __NR_openat 288
646__SYSCALL(288, sys_openat, 4)
647#define __NR_mkdirat 289
648__SYSCALL(289, sys_mkdirat, 3)
649#define __NR_mknodat 290
650__SYSCALL(290, sys_mknodat, 4)
651#define __NR_unlinkat 291
652__SYSCALL(291, sys_unlinkat, 3)
653#define __NR_renameat 292
654__SYSCALL(292, sys_renameat, 4)
655#define __NR_linkat 293
656__SYSCALL(293, sys_linkat, 5)
657#define __NR_symlinkat 294
658__SYSCALL(294, sys_symlinkat, 3)
659#define __NR_readlinkat 295
660__SYSCALL(295, sys_readlinkat, 4)
661#define __NR_utimensat 296
662__SYSCALL(296, sys_utimensat, 0)
663#define __NR_fchownat 297
664__SYSCALL(297, sys_fchownat, 5)
665#define __NR_futimesat 298
666__SYSCALL(298, sys_futimesat, 4)
667#define __NR_fstatat64 299
668__SYSCALL(299, sys_fstatat64, 0)
669#define __NR_fchmodat 300
670__SYSCALL(300, sys_fchmodat, 4)
671#define __NR_faccessat 301
672__SYSCALL(301, sys_faccessat, 4)
673#define __NR_available302 302
674__SYSCALL(302, sys_ni_syscall, 0)
675#define __NR_available303 303
676__SYSCALL(303, sys_ni_syscall, 0)
677
678#define __NR_signalfd 304
679__SYSCALL(304, sys_signalfd, 3)
680/* 305 was __NR_timerfd */
681__SYSCALL(305, sys_ni_syscall, 0)
682#define __NR_eventfd 306
683__SYSCALL(306, sys_eventfd, 1)
684#define __NR_recvmmsg 307
685__SYSCALL(307, sys_recvmmsg, 5)
686#define __NR_setns 308
687__SYSCALL(308, sys_setns, 2)
688
689#define __NR_syscall_count 309
690
691/*
692 * sysxtensa syscall handler
693 *
694 * int sysxtensa (SYS_XTENSA_ATOMIC_SET, ptr, val, unused);
695 * int sysxtensa (SYS_XTENSA_ATOMIC_ADD, ptr, val, unused);
696 * int sysxtensa (SYS_XTENSA_ATOMIC_EXG_ADD, ptr, val, unused);
697 * int sysxtensa (SYS_XTENSA_ATOMIC_CMP_SWP, ptr, oldval, newval);
698 * a2 a6 a3 a4 a5
699 */
700
701#define SYS_XTENSA_RESERVED 0 /* don't use this */
702#define SYS_XTENSA_ATOMIC_SET 1 /* set variable */
703#define SYS_XTENSA_ATOMIC_EXG_ADD 2 /* exchange memory and add */
704#define SYS_XTENSA_ATOMIC_ADD 3 /* add to memory */
705#define SYS_XTENSA_ATOMIC_CMP_SWP 4 /* compare and swap */
706
707#define SYS_XTENSA_COUNT 5 /* count */
708
709#ifdef __KERNEL__
710 6
711/* 7/*
712 * "Conditional" syscalls 8 * "Conditional" syscalls
@@ -735,5 +31,4 @@ __SYSCALL(308, sys_setns, 2)
735#define __IGNORE_vfork /* use clone */ 31#define __IGNORE_vfork /* use clone */
736#define __IGNORE_fadvise64 /* use fadvise64_64 */ 32#define __IGNORE_fadvise64 /* use fadvise64_64 */
737 33
738#endif /* __KERNEL__ */ 34#endif /* _XTENSA_UNISTD_H */
739#endif /* _XTENSA_UNISTD_H */
diff --git a/arch/xtensa/include/asm/xor.h b/arch/xtensa/include/asm/xor.h
deleted file mode 100644
index e7b1f083991..00000000000
--- a/arch/xtensa/include/asm/xor.h
+++ /dev/null
@@ -1,16 +0,0 @@
1/*
2 * include/asm-xtensa/xor.h
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (C) 2001 - 2005 Tensilica Inc.
9 */
10
11#ifndef _XTENSA_XOR_H
12#define _XTENSA_XOR_H
13
14#include <asm-generic/xor.h>
15
16#endif
diff --git a/arch/xtensa/include/uapi/asm/Kbuild b/arch/xtensa/include/uapi/asm/Kbuild
index baebb3da1d4..56aad54e7fb 100644
--- a/arch/xtensa/include/uapi/asm/Kbuild
+++ b/arch/xtensa/include/uapi/asm/Kbuild
@@ -1,3 +1,25 @@
1# UAPI Header export list 1# UAPI Header export list
2include include/uapi/asm-generic/Kbuild.asm 2include include/uapi/asm-generic/Kbuild.asm
3 3
4header-y += auxvec.h
5header-y += byteorder.h
6header-y += ioctls.h
7header-y += ipcbuf.h
8header-y += mman.h
9header-y += msgbuf.h
10header-y += param.h
11header-y += poll.h
12header-y += posix_types.h
13header-y += ptrace.h
14header-y += sembuf.h
15header-y += setup.h
16header-y += shmbuf.h
17header-y += sigcontext.h
18header-y += signal.h
19header-y += socket.h
20header-y += sockios.h
21header-y += stat.h
22header-y += swab.h
23header-y += termbits.h
24header-y += types.h
25header-y += unistd.h
diff --git a/arch/xtensa/include/asm/auxvec.h b/arch/xtensa/include/uapi/asm/auxvec.h
index 257dec75c5a..257dec75c5a 100644
--- a/arch/xtensa/include/asm/auxvec.h
+++ b/arch/xtensa/include/uapi/asm/auxvec.h
diff --git a/arch/xtensa/include/asm/byteorder.h b/arch/xtensa/include/uapi/asm/byteorder.h
index 54eb6315349..54eb6315349 100644
--- a/arch/xtensa/include/asm/byteorder.h
+++ b/arch/xtensa/include/uapi/asm/byteorder.h
diff --git a/arch/xtensa/include/asm/ioctls.h b/arch/xtensa/include/uapi/asm/ioctls.h
index 2aa4cd9f0ce..2aa4cd9f0ce 100644
--- a/arch/xtensa/include/asm/ioctls.h
+++ b/arch/xtensa/include/uapi/asm/ioctls.h
diff --git a/arch/xtensa/include/asm/ipcbuf.h b/arch/xtensa/include/uapi/asm/ipcbuf.h
index c33aa6a4214..c33aa6a4214 100644
--- a/arch/xtensa/include/asm/ipcbuf.h
+++ b/arch/xtensa/include/uapi/asm/ipcbuf.h
diff --git a/arch/xtensa/include/asm/mman.h b/arch/xtensa/include/uapi/asm/mman.h
index 25bc6c1309c..25bc6c1309c 100644
--- a/arch/xtensa/include/asm/mman.h
+++ b/arch/xtensa/include/uapi/asm/mman.h
diff --git a/arch/xtensa/include/asm/msgbuf.h b/arch/xtensa/include/uapi/asm/msgbuf.h
index 693c9675528..693c9675528 100644
--- a/arch/xtensa/include/asm/msgbuf.h
+++ b/arch/xtensa/include/uapi/asm/msgbuf.h
diff --git a/arch/xtensa/include/uapi/asm/param.h b/arch/xtensa/include/uapi/asm/param.h
new file mode 100644
index 00000000000..87bc2eae630
--- /dev/null
+++ b/arch/xtensa/include/uapi/asm/param.h
@@ -0,0 +1,30 @@
1/*
2 * include/asm-xtensa/param.h
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (C) 2001 - 2005 Tensilica Inc.
9 */
10
11#ifndef _UAPI_XTENSA_PARAM_H
12#define _UAPI_XTENSA_PARAM_H
13
14#ifndef __KERNEL__
15# define HZ 100
16#endif
17
18#define EXEC_PAGESIZE 4096
19
20#ifndef NGROUPS
21#define NGROUPS 32
22#endif
23
24#ifndef NOGROUP
25#define NOGROUP (-1)
26#endif
27
28#define MAXHOSTNAMELEN 64 /* max length of hostname */
29
30#endif /* _UAPI_XTENSA_PARAM_H */
diff --git a/arch/xtensa/include/asm/poll.h b/arch/xtensa/include/uapi/asm/poll.h
index 9d2d5993f06..9d2d5993f06 100644
--- a/arch/xtensa/include/asm/poll.h
+++ b/arch/xtensa/include/uapi/asm/poll.h
diff --git a/arch/xtensa/include/asm/posix_types.h b/arch/xtensa/include/uapi/asm/posix_types.h
index 6e96be0d02d..6e96be0d02d 100644
--- a/arch/xtensa/include/asm/posix_types.h
+++ b/arch/xtensa/include/uapi/asm/posix_types.h
diff --git a/arch/xtensa/include/uapi/asm/ptrace.h b/arch/xtensa/include/uapi/asm/ptrace.h
new file mode 100644
index 00000000000..ee17aa842fd
--- /dev/null
+++ b/arch/xtensa/include/uapi/asm/ptrace.h
@@ -0,0 +1,77 @@
1/*
2 * include/asm-xtensa/ptrace.h
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (C) 2001 - 2005 Tensilica Inc.
9 */
10
11#ifndef _UAPI_XTENSA_PTRACE_H
12#define _UAPI_XTENSA_PTRACE_H
13
14/*
15 * Kernel stack
16 *
17 * +-----------------------+ -------- STACK_SIZE
18 * | register file | |
19 * +-----------------------+ |
20 * | struct pt_regs | |
21 * +-----------------------+ | ------ PT_REGS_OFFSET
22 * double : 16 bytes spill area : | ^
23 * excetion :- - - - - - - - - - - -: | |
24 * frame : struct pt_regs : | |
25 * :- - - - - - - - - - - -: | |
26 * | | | |
27 * | memory stack | | |
28 * | | | |
29 * ~ ~ ~ ~
30 * ~ ~ ~ ~
31 * | | | |
32 * | | | |
33 * +-----------------------+ | | --- STACK_BIAS
34 * | struct task_struct | | | ^
35 * current --> +-----------------------+ | | |
36 * | struct thread_info | | | |
37 * +-----------------------+ --------
38 */
39
40#define KERNEL_STACK_SIZE (2 * PAGE_SIZE)
41
42/* Offsets for exception_handlers[] (3 x 64-entries x 4-byte tables). */
43
44#define EXC_TABLE_KSTK 0x004 /* Kernel Stack */
45#define EXC_TABLE_DOUBLE_SAVE 0x008 /* Double exception save area for a0 */
46#define EXC_TABLE_FIXUP 0x00c /* Fixup handler */
47#define EXC_TABLE_PARAM 0x010 /* For passing a parameter to fixup */
48#define EXC_TABLE_SYSCALL_SAVE 0x014 /* For fast syscall handler */
49#define EXC_TABLE_FAST_USER 0x100 /* Fast user exception handler */
50#define EXC_TABLE_FAST_KERNEL 0x200 /* Fast kernel exception handler */
51#define EXC_TABLE_DEFAULT 0x300 /* Default C-Handler */
52#define EXC_TABLE_SIZE 0x400
53
54/* Registers used by strace */
55
56#define REG_A_BASE 0x0000
57#define REG_AR_BASE 0x0100
58#define REG_PC 0x0020
59#define REG_PS 0x02e6
60#define REG_WB 0x0248
61#define REG_WS 0x0249
62#define REG_LBEG 0x0200
63#define REG_LEND 0x0201
64#define REG_LCOUNT 0x0202
65#define REG_SAR 0x0203
66
67#define SYSCALL_NR 0x00ff
68
69/* Other PTRACE_ values defined in <linux/ptrace.h> using values 0-9,16,17,24 */
70
71#define PTRACE_GETREGS 12
72#define PTRACE_SETREGS 13
73#define PTRACE_GETXTREGS 18
74#define PTRACE_SETXTREGS 19
75
76
77#endif /* _UAPI_XTENSA_PTRACE_H */
diff --git a/arch/xtensa/include/asm/sembuf.h b/arch/xtensa/include/uapi/asm/sembuf.h
index c15870493b3..c15870493b3 100644
--- a/arch/xtensa/include/asm/sembuf.h
+++ b/arch/xtensa/include/uapi/asm/sembuf.h
diff --git a/arch/xtensa/include/asm/setup.h b/arch/xtensa/include/uapi/asm/setup.h
index 9fa8ad97936..9fa8ad97936 100644
--- a/arch/xtensa/include/asm/setup.h
+++ b/arch/xtensa/include/uapi/asm/setup.h
diff --git a/arch/xtensa/include/asm/shmbuf.h b/arch/xtensa/include/uapi/asm/shmbuf.h
index ad4b0121782..ad4b0121782 100644
--- a/arch/xtensa/include/asm/shmbuf.h
+++ b/arch/xtensa/include/uapi/asm/shmbuf.h
diff --git a/arch/xtensa/include/asm/sigcontext.h b/arch/xtensa/include/uapi/asm/sigcontext.h
index 03383af8c3b..03383af8c3b 100644
--- a/arch/xtensa/include/asm/sigcontext.h
+++ b/arch/xtensa/include/uapi/asm/sigcontext.h
diff --git a/arch/xtensa/include/uapi/asm/signal.h b/arch/xtensa/include/uapi/asm/signal.h
new file mode 100644
index 00000000000..b88ce96f2af
--- /dev/null
+++ b/arch/xtensa/include/uapi/asm/signal.h
@@ -0,0 +1,148 @@
1/*
2 * include/asm-xtensa/signal.h
3 *
4 * Swiped from SH.
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 *
10 * Copyright (C) 2001 - 2005 Tensilica Inc.
11 */
12
13#ifndef _UAPI_XTENSA_SIGNAL_H
14#define _UAPI_XTENSA_SIGNAL_H
15
16
17#define _NSIG 64
18#define _NSIG_BPW 32
19#define _NSIG_WORDS (_NSIG / _NSIG_BPW)
20
21#ifndef __ASSEMBLY__
22
23#include <linux/types.h>
24
25/* Avoid too many header ordering problems. */
26struct siginfo;
27typedef unsigned long old_sigset_t; /* at least 32 bits */
28typedef struct {
29 unsigned long sig[_NSIG_WORDS];
30} sigset_t;
31
32#endif
33
34#define SIGHUP 1
35#define SIGINT 2
36#define SIGQUIT 3
37#define SIGILL 4
38#define SIGTRAP 5
39#define SIGABRT 6
40#define SIGIOT 6
41#define SIGBUS 7
42#define SIGFPE 8
43#define SIGKILL 9
44#define SIGUSR1 10
45#define SIGSEGV 11
46#define SIGUSR2 12
47#define SIGPIPE 13
48#define SIGALRM 14
49#define SIGTERM 15
50#define SIGSTKFLT 16
51#define SIGCHLD 17
52#define SIGCONT 18
53#define SIGSTOP 19
54#define SIGTSTP 20
55#define SIGTTIN 21
56#define SIGTTOU 22
57#define SIGURG 23
58#define SIGXCPU 24
59#define SIGXFSZ 25
60#define SIGVTALRM 26
61#define SIGPROF 27
62#define SIGWINCH 28
63#define SIGIO 29
64#define SIGPOLL SIGIO
65/* #define SIGLOST 29 */
66#define SIGPWR 30
67#define SIGSYS 31
68#define SIGUNUSED 31
69
70/* These should not be considered constants from userland. */
71#define SIGRTMIN 32
72#define SIGRTMAX (_NSIG-1)
73
74/*
75 * SA_FLAGS values:
76 *
77 * SA_ONSTACK indicates that a registered stack_t will be used.
78 * SA_RESTART flag to get restarting signals (which were the default long ago)
79 * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop.
80 * SA_RESETHAND clears the handler when the signal is delivered.
81 * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies.
82 * SA_NODEFER prevents the current signal from being masked in the handler.
83 *
84 * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single
85 * Unix names RESETHAND and NODEFER respectively.
86 */
87#define SA_NOCLDSTOP 0x00000001
88#define SA_NOCLDWAIT 0x00000002 /* not supported yet */
89#define SA_SIGINFO 0x00000004
90#define SA_ONSTACK 0x08000000
91#define SA_RESTART 0x10000000
92#define SA_NODEFER 0x40000000
93#define SA_RESETHAND 0x80000000
94
95#define SA_NOMASK SA_NODEFER
96#define SA_ONESHOT SA_RESETHAND
97
98#define SA_RESTORER 0x04000000
99
100/*
101 * sigaltstack controls
102 */
103#define SS_ONSTACK 1
104#define SS_DISABLE 2
105
106#define MINSIGSTKSZ 2048
107#define SIGSTKSZ 8192
108
109#ifndef __ASSEMBLY__
110
111#define SIG_BLOCK 0 /* for blocking signals */
112#define SIG_UNBLOCK 1 /* for unblocking signals */
113#define SIG_SETMASK 2 /* for setting the signal mask */
114
115/* Type of a signal handler. */
116typedef void (*__sighandler_t)(int);
117
118#define SIG_DFL ((__sighandler_t)0) /* default signal handling */
119#define SIG_IGN ((__sighandler_t)1) /* ignore signal */
120#define SIG_ERR ((__sighandler_t)-1) /* error return from signal */
121
122#ifndef __KERNEL__
123
124/* Here we must cater to libcs that poke about in kernel headers. */
125
126struct sigaction {
127 union {
128 __sighandler_t _sa_handler;
129 void (*_sa_sigaction)(int, struct siginfo *, void *);
130 } _u;
131 sigset_t sa_mask;
132 unsigned long sa_flags;
133 void (*sa_restorer)(void);
134};
135
136#define sa_handler _u._sa_handler
137#define sa_sigaction _u._sa_sigaction
138
139#endif /* __KERNEL__ */
140
141typedef struct sigaltstack {
142 void *ss_sp;
143 int ss_flags;
144 size_t ss_size;
145} stack_t;
146
147#endif /* __ASSEMBLY__ */
148#endif /* _UAPI_XTENSA_SIGNAL_H */
diff --git a/arch/xtensa/include/asm/socket.h b/arch/xtensa/include/uapi/asm/socket.h
index e36c6818492..e36c6818492 100644
--- a/arch/xtensa/include/asm/socket.h
+++ b/arch/xtensa/include/uapi/asm/socket.h
diff --git a/arch/xtensa/include/asm/sockios.h b/arch/xtensa/include/uapi/asm/sockios.h
index efe0af379f0..efe0af379f0 100644
--- a/arch/xtensa/include/asm/sockios.h
+++ b/arch/xtensa/include/uapi/asm/sockios.h
diff --git a/arch/xtensa/include/asm/stat.h b/arch/xtensa/include/uapi/asm/stat.h
index c4992038cee..c4992038cee 100644
--- a/arch/xtensa/include/asm/stat.h
+++ b/arch/xtensa/include/uapi/asm/stat.h
diff --git a/arch/xtensa/include/asm/swab.h b/arch/xtensa/include/uapi/asm/swab.h
index 226a3916231..226a3916231 100644
--- a/arch/xtensa/include/asm/swab.h
+++ b/arch/xtensa/include/uapi/asm/swab.h
diff --git a/arch/xtensa/include/asm/termbits.h b/arch/xtensa/include/uapi/asm/termbits.h
index 0d6c8715b24..0d6c8715b24 100644
--- a/arch/xtensa/include/asm/termbits.h
+++ b/arch/xtensa/include/uapi/asm/termbits.h
diff --git a/arch/xtensa/include/uapi/asm/types.h b/arch/xtensa/include/uapi/asm/types.h
new file mode 100644
index 00000000000..87ec7ae73cb
--- /dev/null
+++ b/arch/xtensa/include/uapi/asm/types.h
@@ -0,0 +1,28 @@
1/*
2 * include/asm-xtensa/types.h
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (C) 2001 - 2005 Tensilica Inc.
9 */
10
11#ifndef _UAPI_XTENSA_TYPES_H
12#define _UAPI_XTENSA_TYPES_H
13
14#include <asm-generic/int-ll64.h>
15
16#ifdef __ASSEMBLY__
17# define __XTENSA_UL(x) (x)
18# define __XTENSA_UL_CONST(x) x
19#else
20# define __XTENSA_UL(x) ((unsigned long)(x))
21# define __XTENSA_UL_CONST(x) x##UL
22#endif
23
24#ifndef __ASSEMBLY__
25
26#endif
27
28#endif /* _UAPI_XTENSA_TYPES_H */
diff --git a/arch/xtensa/include/uapi/asm/unistd.h b/arch/xtensa/include/uapi/asm/unistd.h
new file mode 100644
index 00000000000..9f36d0e3e0a
--- /dev/null
+++ b/arch/xtensa/include/uapi/asm/unistd.h
@@ -0,0 +1,754 @@
1#if !defined(_UAPI_XTENSA_UNISTD_H) || defined(__SYSCALL)
2#define _UAPI_XTENSA_UNISTD_H
3
4#ifndef __SYSCALL
5# define __SYSCALL(nr,func,nargs)
6#endif
7
8#define __NR_spill 0
9__SYSCALL( 0, sys_ni_syscall, 0)
10#define __NR_xtensa 1
11__SYSCALL( 1, sys_ni_syscall, 0)
12#define __NR_available4 2
13__SYSCALL( 2, sys_ni_syscall, 0)
14#define __NR_available5 3
15__SYSCALL( 3, sys_ni_syscall, 0)
16#define __NR_available6 4
17__SYSCALL( 4, sys_ni_syscall, 0)
18#define __NR_available7 5
19__SYSCALL( 5, sys_ni_syscall, 0)
20#define __NR_available8 6
21__SYSCALL( 6, sys_ni_syscall, 0)
22#define __NR_available9 7
23__SYSCALL( 7, sys_ni_syscall, 0)
24
25/* File Operations */
26
27#define __NR_open 8
28__SYSCALL( 8, sys_open, 3)
29#define __NR_close 9
30__SYSCALL( 9, sys_close, 1)
31#define __NR_dup 10
32__SYSCALL( 10, sys_dup, 1)
33#define __NR_dup2 11
34__SYSCALL( 11, sys_dup2, 2)
35#define __NR_read 12
36__SYSCALL( 12, sys_read, 3)
37#define __NR_write 13
38__SYSCALL( 13, sys_write, 3)
39#define __NR_select 14
40__SYSCALL( 14, sys_select, 5)
41#define __NR_lseek 15
42__SYSCALL( 15, sys_lseek, 3)
43#define __NR_poll 16
44__SYSCALL( 16, sys_poll, 3)
45#define __NR__llseek 17
46__SYSCALL( 17, sys_llseek, 5)
47#define __NR_epoll_wait 18
48__SYSCALL( 18, sys_epoll_wait, 4)
49#define __NR_epoll_ctl 19
50__SYSCALL( 19, sys_epoll_ctl, 4)
51#define __NR_epoll_create 20
52__SYSCALL( 20, sys_epoll_create, 1)
53#define __NR_creat 21
54__SYSCALL( 21, sys_creat, 2)
55#define __NR_truncate 22
56__SYSCALL( 22, sys_truncate, 2)
57#define __NR_ftruncate 23
58__SYSCALL( 23, sys_ftruncate, 2)
59#define __NR_readv 24
60__SYSCALL( 24, sys_readv, 3)
61#define __NR_writev 25
62__SYSCALL( 25, sys_writev, 3)
63#define __NR_fsync 26
64__SYSCALL( 26, sys_fsync, 1)
65#define __NR_fdatasync 27
66__SYSCALL( 27, sys_fdatasync, 1)
67#define __NR_truncate64 28
68__SYSCALL( 28, sys_truncate64, 2)
69#define __NR_ftruncate64 29
70__SYSCALL( 29, sys_ftruncate64, 2)
71#define __NR_pread64 30
72__SYSCALL( 30, sys_pread64, 6)
73#define __NR_pwrite64 31
74__SYSCALL( 31, sys_pwrite64, 6)
75
76#define __NR_link 32
77__SYSCALL( 32, sys_link, 2)
78#define __NR_rename 33
79__SYSCALL( 33, sys_rename, 2)
80#define __NR_symlink 34
81__SYSCALL( 34, sys_symlink, 2)
82#define __NR_readlink 35
83__SYSCALL( 35, sys_readlink, 3)
84#define __NR_mknod 36
85__SYSCALL( 36, sys_mknod, 3)
86#define __NR_pipe 37
87__SYSCALL( 37, sys_pipe, 1)
88#define __NR_unlink 38
89__SYSCALL( 38, sys_unlink, 1)
90#define __NR_rmdir 39
91__SYSCALL( 39, sys_rmdir, 1)
92
93#define __NR_mkdir 40
94__SYSCALL( 40, sys_mkdir, 2)
95#define __NR_chdir 41
96__SYSCALL( 41, sys_chdir, 1)
97#define __NR_fchdir 42
98__SYSCALL( 42, sys_fchdir, 1)
99#define __NR_getcwd 43
100__SYSCALL( 43, sys_getcwd, 2)
101
102#define __NR_chmod 44
103__SYSCALL( 44, sys_chmod, 2)
104#define __NR_chown 45
105__SYSCALL( 45, sys_chown, 3)
106#define __NR_stat 46
107__SYSCALL( 46, sys_newstat, 2)
108#define __NR_stat64 47
109__SYSCALL( 47, sys_stat64, 2)
110
111#define __NR_lchown 48
112__SYSCALL( 48, sys_lchown, 3)
113#define __NR_lstat 49
114__SYSCALL( 49, sys_newlstat, 2)
115#define __NR_lstat64 50
116__SYSCALL( 50, sys_lstat64, 2)
117#define __NR_available51 51
118__SYSCALL( 51, sys_ni_syscall, 0)
119
120#define __NR_fchmod 52
121__SYSCALL( 52, sys_fchmod, 2)
122#define __NR_fchown 53
123__SYSCALL( 53, sys_fchown, 3)
124#define __NR_fstat 54
125__SYSCALL( 54, sys_newfstat, 2)
126#define __NR_fstat64 55
127__SYSCALL( 55, sys_fstat64, 2)
128
129#define __NR_flock 56
130__SYSCALL( 56, sys_flock, 2)
131#define __NR_access 57
132__SYSCALL( 57, sys_access, 2)
133#define __NR_umask 58
134__SYSCALL( 58, sys_umask, 1)
135#define __NR_getdents 59
136__SYSCALL( 59, sys_getdents, 3)
137#define __NR_getdents64 60
138__SYSCALL( 60, sys_getdents64, 3)
139#define __NR_fcntl64 61
140__SYSCALL( 61, sys_fcntl64, 3)
141#define __NR_fallocate 62
142__SYSCALL( 62, sys_fallocate, 6)
143#define __NR_fadvise64_64 63
144__SYSCALL( 63, xtensa_fadvise64_64, 6)
145#define __NR_utime 64 /* glibc 2.3.3 ?? */
146__SYSCALL( 64, sys_utime, 2)
147#define __NR_utimes 65
148__SYSCALL( 65, sys_utimes, 2)
149#define __NR_ioctl 66
150__SYSCALL( 66, sys_ioctl, 3)
151#define __NR_fcntl 67
152__SYSCALL( 67, sys_fcntl, 3)
153
154#define __NR_setxattr 68
155__SYSCALL( 68, sys_setxattr, 5)
156#define __NR_getxattr 69
157__SYSCALL( 69, sys_getxattr, 4)
158#define __NR_listxattr 70
159__SYSCALL( 70, sys_listxattr, 3)
160#define __NR_removexattr 71
161__SYSCALL( 71, sys_removexattr, 2)
162#define __NR_lsetxattr 72
163__SYSCALL( 72, sys_lsetxattr, 5)
164#define __NR_lgetxattr 73
165__SYSCALL( 73, sys_lgetxattr, 4)
166#define __NR_llistxattr 74
167__SYSCALL( 74, sys_llistxattr, 3)
168#define __NR_lremovexattr 75
169__SYSCALL( 75, sys_lremovexattr, 2)
170#define __NR_fsetxattr 76
171__SYSCALL( 76, sys_fsetxattr, 5)
172#define __NR_fgetxattr 77
173__SYSCALL( 77, sys_fgetxattr, 4)
174#define __NR_flistxattr 78
175__SYSCALL( 78, sys_flistxattr, 3)
176#define __NR_fremovexattr 79
177__SYSCALL( 79, sys_fremovexattr, 2)
178
179/* File Map / Shared Memory Operations */
180
181#define __NR_mmap2 80
182__SYSCALL( 80, sys_mmap_pgoff, 6)
183#define __NR_munmap 81
184__SYSCALL( 81, sys_munmap, 2)
185#define __NR_mprotect 82
186__SYSCALL( 82, sys_mprotect, 3)
187#define __NR_brk 83
188__SYSCALL( 83, sys_brk, 1)
189#define __NR_mlock 84
190__SYSCALL( 84, sys_mlock, 2)
191#define __NR_munlock 85
192__SYSCALL( 85, sys_munlock, 2)
193#define __NR_mlockall 86
194__SYSCALL( 86, sys_mlockall, 1)
195#define __NR_munlockall 87
196__SYSCALL( 87, sys_munlockall, 0)
197#define __NR_mremap 88
198__SYSCALL( 88, sys_mremap, 4)
199#define __NR_msync 89
200__SYSCALL( 89, sys_msync, 3)
201#define __NR_mincore 90
202__SYSCALL( 90, sys_mincore, 3)
203#define __NR_madvise 91
204__SYSCALL( 91, sys_madvise, 3)
205#define __NR_shmget 92
206__SYSCALL( 92, sys_shmget, 4)
207#define __NR_shmat 93
208__SYSCALL( 93, xtensa_shmat, 4)
209#define __NR_shmctl 94
210__SYSCALL( 94, sys_shmctl, 4)
211#define __NR_shmdt 95
212__SYSCALL( 95, sys_shmdt, 4)
213
214/* Socket Operations */
215
216#define __NR_socket 96
217__SYSCALL( 96, sys_socket, 3)
218#define __NR_setsockopt 97
219__SYSCALL( 97, sys_setsockopt, 5)
220#define __NR_getsockopt 98
221__SYSCALL( 98, sys_getsockopt, 5)
222#define __NR_shutdown 99
223__SYSCALL( 99, sys_shutdown, 2)
224
225#define __NR_bind 100
226__SYSCALL(100, sys_bind, 3)
227#define __NR_connect 101
228__SYSCALL(101, sys_connect, 3)
229#define __NR_listen 102
230__SYSCALL(102, sys_listen, 2)
231#define __NR_accept 103
232__SYSCALL(103, sys_accept, 3)
233
234#define __NR_getsockname 104
235__SYSCALL(104, sys_getsockname, 3)
236#define __NR_getpeername 105
237__SYSCALL(105, sys_getpeername, 3)
238#define __NR_sendmsg 106
239__SYSCALL(106, sys_sendmsg, 3)
240#define __NR_recvmsg 107
241__SYSCALL(107, sys_recvmsg, 3)
242#define __NR_send 108
243__SYSCALL(108, sys_send, 4)
244#define __NR_recv 109
245__SYSCALL(109, sys_recv, 4)
246#define __NR_sendto 110
247__SYSCALL(110, sys_sendto, 6)
248#define __NR_recvfrom 111
249__SYSCALL(111, sys_recvfrom, 6)
250
251#define __NR_socketpair 112
252__SYSCALL(112, sys_socketpair, 4)
253#define __NR_sendfile 113
254__SYSCALL(113, sys_sendfile, 4)
255#define __NR_sendfile64 114
256__SYSCALL(114, sys_sendfile64, 4)
257#define __NR_sendmmsg 115
258__SYSCALL(115, sys_sendmmsg, 4)
259
260/* Process Operations */
261
262#define __NR_clone 116
263__SYSCALL(116, xtensa_clone, 5)
264#define __NR_execve 117
265__SYSCALL(117, sys_execve, 3)
266#define __NR_exit 118
267__SYSCALL(118, sys_exit, 1)
268#define __NR_exit_group 119
269__SYSCALL(119, sys_exit_group, 1)
270#define __NR_getpid 120
271__SYSCALL(120, sys_getpid, 0)
272#define __NR_wait4 121
273__SYSCALL(121, sys_wait4, 4)
274#define __NR_waitid 122
275__SYSCALL(122, sys_waitid, 5)
276#define __NR_kill 123
277__SYSCALL(123, sys_kill, 2)
278#define __NR_tkill 124
279__SYSCALL(124, sys_tkill, 2)
280#define __NR_tgkill 125
281__SYSCALL(125, sys_tgkill, 3)
282#define __NR_set_tid_address 126
283__SYSCALL(126, sys_set_tid_address, 1)
284#define __NR_gettid 127
285__SYSCALL(127, sys_gettid, 0)
286#define __NR_setsid 128
287__SYSCALL(128, sys_setsid, 0)
288#define __NR_getsid 129
289__SYSCALL(129, sys_getsid, 1)
290#define __NR_prctl 130
291__SYSCALL(130, sys_prctl, 5)
292#define __NR_personality 131
293__SYSCALL(131, sys_personality, 1)
294#define __NR_getpriority 132
295__SYSCALL(132, sys_getpriority, 2)
296#define __NR_setpriority 133
297__SYSCALL(133, sys_setpriority, 3)
298#define __NR_setitimer 134
299__SYSCALL(134, sys_setitimer, 3)
300#define __NR_getitimer 135
301__SYSCALL(135, sys_getitimer, 2)
302#define __NR_setuid 136
303__SYSCALL(136, sys_setuid, 1)
304#define __NR_getuid 137
305__SYSCALL(137, sys_getuid, 0)
306#define __NR_setgid 138
307__SYSCALL(138, sys_setgid, 1)
308#define __NR_getgid 139
309__SYSCALL(139, sys_getgid, 0)
310#define __NR_geteuid 140
311__SYSCALL(140, sys_geteuid, 0)
312#define __NR_getegid 141
313__SYSCALL(141, sys_getegid, 0)
314#define __NR_setreuid 142
315__SYSCALL(142, sys_setreuid, 2)
316#define __NR_setregid 143
317__SYSCALL(143, sys_setregid, 2)
318#define __NR_setresuid 144
319__SYSCALL(144, sys_setresuid, 3)
320#define __NR_getresuid 145
321__SYSCALL(145, sys_getresuid, 3)
322#define __NR_setresgid 146
323__SYSCALL(146, sys_setresgid, 3)
324#define __NR_getresgid 147
325__SYSCALL(147, sys_getresgid, 3)
326#define __NR_setpgid 148
327__SYSCALL(148, sys_setpgid, 2)
328#define __NR_getpgid 149
329__SYSCALL(149, sys_getpgid, 1)
330#define __NR_getppid 150
331__SYSCALL(150, sys_getppid, 0)
332#define __NR_getpgrp 151
333__SYSCALL(151, sys_getpgrp, 0)
334
335#define __NR_reserved152 152 /* set_thread_area */
336__SYSCALL(152, sys_ni_syscall, 0)
337#define __NR_reserved153 153 /* get_thread_area */
338__SYSCALL(153, sys_ni_syscall, 0)
339#define __NR_times 154
340__SYSCALL(154, sys_times, 1)
341#define __NR_acct 155
342__SYSCALL(155, sys_acct, 1)
343#define __NR_sched_setaffinity 156
344__SYSCALL(156, sys_sched_setaffinity, 3)
345#define __NR_sched_getaffinity 157
346__SYSCALL(157, sys_sched_getaffinity, 3)
347#define __NR_capget 158
348__SYSCALL(158, sys_capget, 2)
349#define __NR_capset 159
350__SYSCALL(159, sys_capset, 2)
351#define __NR_ptrace 160
352__SYSCALL(160, sys_ptrace, 4)
353#define __NR_semtimedop 161
354__SYSCALL(161, sys_semtimedop, 5)
355#define __NR_semget 162
356__SYSCALL(162, sys_semget, 4)
357#define __NR_semop 163
358__SYSCALL(163, sys_semop, 4)
359#define __NR_semctl 164
360__SYSCALL(164, sys_semctl, 4)
361#define __NR_available165 165
362__SYSCALL(165, sys_ni_syscall, 0)
363#define __NR_msgget 166
364__SYSCALL(166, sys_msgget, 4)
365#define __NR_msgsnd 167
366__SYSCALL(167, sys_msgsnd, 4)
367#define __NR_msgrcv 168
368__SYSCALL(168, sys_msgrcv, 4)
369#define __NR_msgctl 169
370__SYSCALL(169, sys_msgctl, 4)
371#define __NR_available170 170
372__SYSCALL(170, sys_ni_syscall, 0)
373
374/* File System */
375
376#define __NR_umount2 171
377__SYSCALL(171, sys_umount, 2)
378#define __NR_mount 172
379__SYSCALL(172, sys_mount, 5)
380#define __NR_swapon 173
381__SYSCALL(173, sys_swapon, 2)
382#define __NR_chroot 174
383__SYSCALL(174, sys_chroot, 1)
384#define __NR_pivot_root 175
385__SYSCALL(175, sys_pivot_root, 2)
386#define __NR_umount 176
387__SYSCALL(176, sys_umount, 2)
388#define __NR_swapoff 177
389__SYSCALL(177, sys_swapoff, 1)
390#define __NR_sync 178
391__SYSCALL(178, sys_sync, 0)
392#define __NR_syncfs 179
393__SYSCALL(179, sys_syncfs, 1)
394#define __NR_setfsuid 180
395__SYSCALL(180, sys_setfsuid, 1)
396#define __NR_setfsgid 181
397__SYSCALL(181, sys_setfsgid, 1)
398#define __NR_sysfs 182
399__SYSCALL(182, sys_sysfs, 3)
400#define __NR_ustat 183
401__SYSCALL(183, sys_ustat, 2)
402#define __NR_statfs 184
403__SYSCALL(184, sys_statfs, 2)
404#define __NR_fstatfs 185
405__SYSCALL(185, sys_fstatfs, 2)
406#define __NR_statfs64 186
407__SYSCALL(186, sys_statfs64, 3)
408#define __NR_fstatfs64 187
409__SYSCALL(187, sys_fstatfs64, 3)
410
411/* System */
412
413#define __NR_setrlimit 188
414__SYSCALL(188, sys_setrlimit, 2)
415#define __NR_getrlimit 189
416__SYSCALL(189, sys_getrlimit, 2)
417#define __NR_getrusage 190
418__SYSCALL(190, sys_getrusage, 2)
419#define __NR_futex 191
420__SYSCALL(191, sys_futex, 5)
421#define __NR_gettimeofday 192
422__SYSCALL(192, sys_gettimeofday, 2)
423#define __NR_settimeofday 193
424__SYSCALL(193, sys_settimeofday, 2)
425#define __NR_adjtimex 194
426__SYSCALL(194, sys_adjtimex, 1)
427#define __NR_nanosleep 195
428__SYSCALL(195, sys_nanosleep, 2)
429#define __NR_getgroups 196
430__SYSCALL(196, sys_getgroups, 2)
431#define __NR_setgroups 197
432__SYSCALL(197, sys_setgroups, 2)
433#define __NR_sethostname 198
434__SYSCALL(198, sys_sethostname, 2)
435#define __NR_setdomainname 199
436__SYSCALL(199, sys_setdomainname, 2)
437#define __NR_syslog 200
438__SYSCALL(200, sys_syslog, 3)
439#define __NR_vhangup 201
440__SYSCALL(201, sys_vhangup, 0)
441#define __NR_uselib 202
442__SYSCALL(202, sys_uselib, 1)
443#define __NR_reboot 203
444__SYSCALL(203, sys_reboot, 3)
445#define __NR_quotactl 204
446__SYSCALL(204, sys_quotactl, 4)
447#define __NR_nfsservctl 205
448__SYSCALL(205, sys_ni_syscall, 0) /* old nfsservctl */
449#define __NR__sysctl 206
450__SYSCALL(206, sys_sysctl, 1)
451#define __NR_bdflush 207
452__SYSCALL(207, sys_bdflush, 2)
453#define __NR_uname 208
454__SYSCALL(208, sys_newuname, 1)
455#define __NR_sysinfo 209
456__SYSCALL(209, sys_sysinfo, 1)
457#define __NR_init_module 210
458__SYSCALL(210, sys_init_module, 2)
459#define __NR_delete_module 211
460__SYSCALL(211, sys_delete_module, 1)
461
462#define __NR_sched_setparam 212
463__SYSCALL(212, sys_sched_setparam, 2)
464#define __NR_sched_getparam 213
465__SYSCALL(213, sys_sched_getparam, 2)
466#define __NR_sched_setscheduler 214
467__SYSCALL(214, sys_sched_setscheduler, 3)
468#define __NR_sched_getscheduler 215
469__SYSCALL(215, sys_sched_getscheduler, 1)
470#define __NR_sched_get_priority_max 216
471__SYSCALL(216, sys_sched_get_priority_max, 1)
472#define __NR_sched_get_priority_min 217
473__SYSCALL(217, sys_sched_get_priority_min, 1)
474#define __NR_sched_rr_get_interval 218
475__SYSCALL(218, sys_sched_rr_get_interval, 2)
476#define __NR_sched_yield 219
477__SYSCALL(219, sys_sched_yield, 0)
478#define __NR_available222 222
479__SYSCALL(222, sys_ni_syscall, 0)
480
481/* Signal Handling */
482
483#define __NR_restart_syscall 223
484__SYSCALL(223, sys_restart_syscall, 0)
485#define __NR_sigaltstack 224
486__SYSCALL(224, xtensa_sigaltstack, 2)
487#define __NR_rt_sigreturn 225
488__SYSCALL(225, xtensa_rt_sigreturn, 1)
489#define __NR_rt_sigaction 226
490__SYSCALL(226, sys_rt_sigaction, 4)
491#define __NR_rt_sigprocmask 227
492__SYSCALL(227, sys_rt_sigprocmask, 4)
493#define __NR_rt_sigpending 228
494__SYSCALL(228, sys_rt_sigpending, 2)
495#define __NR_rt_sigtimedwait 229
496__SYSCALL(229, sys_rt_sigtimedwait, 4)
497#define __NR_rt_sigqueueinfo 230
498__SYSCALL(230, sys_rt_sigqueueinfo, 3)
499#define __NR_rt_sigsuspend 231
500__SYSCALL(231, sys_rt_sigsuspend, 2)
501
502/* Message */
503
504#define __NR_mq_open 232
505__SYSCALL(232, sys_mq_open, 4)
506#define __NR_mq_unlink 233
507__SYSCALL(233, sys_mq_unlink, 1)
508#define __NR_mq_timedsend 234
509__SYSCALL(234, sys_mq_timedsend, 5)
510#define __NR_mq_timedreceive 235
511__SYSCALL(235, sys_mq_timedreceive, 5)
512#define __NR_mq_notify 236
513__SYSCALL(236, sys_mq_notify, 2)
514#define __NR_mq_getsetattr 237
515__SYSCALL(237, sys_mq_getsetattr, 3)
516#define __NR_available238 238
517__SYSCALL(238, sys_ni_syscall, 0)
518
519/* IO */
520
521#define __NR_io_setup 239
522__SYSCALL(239, sys_io_setup, 2)
523#define __NR_io_destroy 240
524__SYSCALL(240, sys_io_destroy, 1)
525#define __NR_io_submit 241
526__SYSCALL(241, sys_io_submit, 3)
527#define __NR_io_getevents 242
528__SYSCALL(242, sys_io_getevents, 5)
529#define __NR_io_cancel 243
530__SYSCALL(243, sys_io_cancel, 3)
531#define __NR_clock_settime 244
532__SYSCALL(244, sys_clock_settime, 2)
533#define __NR_clock_gettime 245
534__SYSCALL(245, sys_clock_gettime, 2)
535#define __NR_clock_getres 246
536__SYSCALL(246, sys_clock_getres, 2)
537#define __NR_clock_nanosleep 247
538__SYSCALL(247, sys_clock_nanosleep, 4)
539
540/* Timer */
541
542#define __NR_timer_create 248
543__SYSCALL(248, sys_timer_create, 3)
544#define __NR_timer_delete 249
545__SYSCALL(249, sys_timer_delete, 1)
546#define __NR_timer_settime 250
547__SYSCALL(250, sys_timer_settime, 4)
548#define __NR_timer_gettime 251
549__SYSCALL(251, sys_timer_gettime, 2)
550#define __NR_timer_getoverrun 252
551__SYSCALL(252, sys_timer_getoverrun, 1)
552
553/* System */
554
555#define __NR_reserved253 253
556__SYSCALL(253, sys_ni_syscall, 0)
557#define __NR_lookup_dcookie 254
558__SYSCALL(254, sys_lookup_dcookie, 4)
559#define __NR_available255 255
560__SYSCALL(255, sys_ni_syscall, 0)
561#define __NR_add_key 256
562__SYSCALL(256, sys_add_key, 5)
563#define __NR_request_key 257
564__SYSCALL(257, sys_request_key, 5)
565#define __NR_keyctl 258
566__SYSCALL(258, sys_keyctl, 5)
567#define __NR_available259 259
568__SYSCALL(259, sys_ni_syscall, 0)
569
570
571#define __NR_readahead 260
572__SYSCALL(260, sys_readahead, 5)
573#define __NR_remap_file_pages 261
574__SYSCALL(261, sys_remap_file_pages, 5)
575#define __NR_migrate_pages 262
576__SYSCALL(262, sys_migrate_pages, 0)
577#define __NR_mbind 263
578__SYSCALL(263, sys_mbind, 6)
579#define __NR_get_mempolicy 264
580__SYSCALL(264, sys_get_mempolicy, 5)
581#define __NR_set_mempolicy 265
582__SYSCALL(265, sys_set_mempolicy, 3)
583#define __NR_unshare 266
584__SYSCALL(266, sys_unshare, 1)
585#define __NR_move_pages 267
586__SYSCALL(267, sys_move_pages, 0)
587#define __NR_splice 268
588__SYSCALL(268, sys_splice, 0)
589#define __NR_tee 269
590__SYSCALL(269, sys_tee, 0)
591#define __NR_vmsplice 270
592__SYSCALL(270, sys_vmsplice, 0)
593#define __NR_available271 271
594__SYSCALL(271, sys_ni_syscall, 0)
595
596#define __NR_pselect6 272
597__SYSCALL(272, sys_pselect6, 0)
598#define __NR_ppoll 273
599__SYSCALL(273, sys_ppoll, 0)
600#define __NR_epoll_pwait 274
601__SYSCALL(274, sys_epoll_pwait, 0)
602#define __NR_epoll_create1 275
603__SYSCALL(275, sys_epoll_create1, 1)
604
605#define __NR_inotify_init 276
606__SYSCALL(276, sys_inotify_init, 0)
607#define __NR_inotify_add_watch 277
608__SYSCALL(277, sys_inotify_add_watch, 3)
609#define __NR_inotify_rm_watch 278
610__SYSCALL(278, sys_inotify_rm_watch, 2)
611#define __NR_inotify_init1 279
612__SYSCALL(279, sys_inotify_init1, 1)
613
614#define __NR_getcpu 280
615__SYSCALL(280, sys_getcpu, 0)
616#define __NR_kexec_load 281
617__SYSCALL(281, sys_ni_syscall, 0)
618
619#define __NR_ioprio_set 282
620__SYSCALL(282, sys_ioprio_set, 2)
621#define __NR_ioprio_get 283
622__SYSCALL(283, sys_ioprio_get, 3)
623
624#define __NR_set_robust_list 284
625__SYSCALL(284, sys_set_robust_list, 3)
626#define __NR_get_robust_list 285
627__SYSCALL(285, sys_get_robust_list, 3)
628#define __NR_available286 286
629__SYSCALL(286, sys_ni_syscall, 0)
630#define __NR_available287 287
631__SYSCALL(287, sys_ni_syscall, 0)
632
633/* Relative File Operations */
634
635#define __NR_openat 288
636__SYSCALL(288, sys_openat, 4)
637#define __NR_mkdirat 289
638__SYSCALL(289, sys_mkdirat, 3)
639#define __NR_mknodat 290
640__SYSCALL(290, sys_mknodat, 4)
641#define __NR_unlinkat 291
642__SYSCALL(291, sys_unlinkat, 3)
643#define __NR_renameat 292
644__SYSCALL(292, sys_renameat, 4)
645#define __NR_linkat 293
646__SYSCALL(293, sys_linkat, 5)
647#define __NR_symlinkat 294
648__SYSCALL(294, sys_symlinkat, 3)
649#define __NR_readlinkat 295
650__SYSCALL(295, sys_readlinkat, 4)
651#define __NR_utimensat 296
652__SYSCALL(296, sys_utimensat, 0)
653#define __NR_fchownat 297
654__SYSCALL(297, sys_fchownat, 5)
655#define __NR_futimesat 298
656__SYSCALL(298, sys_futimesat, 4)
657#define __NR_fstatat64 299
658__SYSCALL(299, sys_fstatat64, 0)
659#define __NR_fchmodat 300
660__SYSCALL(300, sys_fchmodat, 4)
661#define __NR_faccessat 301
662__SYSCALL(301, sys_faccessat, 4)
663#define __NR_available302 302
664__SYSCALL(302, sys_ni_syscall, 0)
665#define __NR_available303 303
666__SYSCALL(303, sys_ni_syscall, 0)
667
668#define __NR_signalfd 304
669__SYSCALL(304, sys_signalfd, 3)
670/* 305 was __NR_timerfd */
671__SYSCALL(305, sys_ni_syscall, 0)
672#define __NR_eventfd 306
673__SYSCALL(306, sys_eventfd, 1)
674#define __NR_recvmmsg 307
675__SYSCALL(307, sys_recvmmsg, 5)
676
677#define __NR_setns 308
678__SYSCALL(308, sys_setns, 2)
679#define __NR_signalfd4 309
680__SYSCALL(309, sys_signalfd4, 4)
681#define __NR_dup3 310
682__SYSCALL(310, sys_dup3, 3)
683#define __NR_pipe2 311
684__SYSCALL(311, sys_pipe2, 2)
685
686#define __NR_timerfd_create 312
687__SYSCALL(312, sys_timerfd_create, 2)
688#define __NR_timerfd_settime 313
689__SYSCALL(313, sys_timerfd_settime, 4)
690#define __NR_timerfd_gettime 314
691__SYSCALL(314, sys_timerfd_gettime, 2)
692#define __NR_available315 315
693__SYSCALL(315, sys_ni_syscall, 0)
694
695#define __NR_eventfd2 316
696__SYSCALL(316, sys_eventfd2, 2)
697#define __NR_preadv 317
698__SYSCALL(317, sys_preadv, 5)
699#define __NR_pwritev 318
700__SYSCALL(318, sys_pwritev, 5)
701#define __NR_available319 319
702__SYSCALL(319, sys_ni_syscall, 0)
703
704#define __NR_fanotify_init 320
705__SYSCALL(320, sys_fanotify_init, 2)
706#define __NR_fanotify_mark 321
707__SYSCALL(321, sys_fanotify_mark, 6)
708#define __NR_process_vm_readv 322
709__SYSCALL(322, sys_process_vm_readv, 6)
710#define __NR_process_vm_writev 323
711__SYSCALL(323, sys_process_vm_writev, 6)
712
713#define __NR_name_to_handle_at 324
714__SYSCALL(324, sys_name_to_handle_at, 5)
715#define __NR_open_by_handle_at 325
716__SYSCALL(325, sys_open_by_handle_at, 3)
717#define __NR_sync_file_range 326
718__SYSCALL(326, sys_sync_file_range2, 6)
719#define __NR_perf_event_open 327
720__SYSCALL(327, sys_perf_event_open, 5)
721
722#define __NR_rt_tgsigqueueinfo 328
723__SYSCALL(328, sys_rt_tgsigqueueinfo, 4)
724#define __NR_clock_adjtime 329
725__SYSCALL(329, sys_clock_adjtime, 2)
726#define __NR_prlimit64 330
727__SYSCALL(330, sys_prlimit64, 4)
728#define __NR_kcmp 331
729__SYSCALL(331, sys_kcmp, 5)
730
731
732#define __NR_syscall_count 332
733
734/*
735 * sysxtensa syscall handler
736 *
737 * int sysxtensa (SYS_XTENSA_ATOMIC_SET, ptr, val, unused);
738 * int sysxtensa (SYS_XTENSA_ATOMIC_ADD, ptr, val, unused);
739 * int sysxtensa (SYS_XTENSA_ATOMIC_EXG_ADD, ptr, val, unused);
740 * int sysxtensa (SYS_XTENSA_ATOMIC_CMP_SWP, ptr, oldval, newval);
741 * a2 a6 a3 a4 a5
742 */
743
744#define SYS_XTENSA_RESERVED 0 /* don't use this */
745#define SYS_XTENSA_ATOMIC_SET 1 /* set variable */
746#define SYS_XTENSA_ATOMIC_EXG_ADD 2 /* exchange memory and add */
747#define SYS_XTENSA_ATOMIC_ADD 3 /* add to memory */
748#define SYS_XTENSA_ATOMIC_CMP_SWP 4 /* compare and swap */
749
750#define SYS_XTENSA_COUNT 5 /* count */
751
752#undef __SYSCALL
753
754#endif /* _UAPI_XTENSA_UNISTD_H */
diff --git a/arch/xtensa/kernel/align.S b/arch/xtensa/kernel/align.S
index 33d6e9d2e83..934ae58e2c7 100644
--- a/arch/xtensa/kernel/align.S
+++ b/arch/xtensa/kernel/align.S
@@ -170,15 +170,15 @@ ENTRY(fast_unaligned)
170 s32i a7, a2, PT_AREG7 170 s32i a7, a2, PT_AREG7
171 s32i a8, a2, PT_AREG8 171 s32i a8, a2, PT_AREG8
172 172
173 rsr a0, DEPC 173 rsr a0, depc
174 xsr a3, EXCSAVE_1 174 xsr a3, excsave1
175 s32i a0, a2, PT_AREG2 175 s32i a0, a2, PT_AREG2
176 s32i a3, a2, PT_AREG3 176 s32i a3, a2, PT_AREG3
177 177
178 /* Keep value of SAR in a0 */ 178 /* Keep value of SAR in a0 */
179 179
180 rsr a0, SAR 180 rsr a0, sar
181 rsr a8, EXCVADDR # load unaligned memory address 181 rsr a8, excvaddr # load unaligned memory address
182 182
183 /* Now, identify one of the following load/store instructions. 183 /* Now, identify one of the following load/store instructions.
184 * 184 *
@@ -197,7 +197,7 @@ ENTRY(fast_unaligned)
197 197
198 /* Extract the instruction that caused the unaligned access. */ 198 /* Extract the instruction that caused the unaligned access. */
199 199
200 rsr a7, EPC_1 # load exception address 200 rsr a7, epc1 # load exception address
201 movi a3, ~3 201 movi a3, ~3
202 and a3, a3, a7 # mask lower bits 202 and a3, a3, a7 # mask lower bits
203 203
@@ -275,16 +275,16 @@ ENTRY(fast_unaligned)
2751: 2751:
276 276
277#if XCHAL_HAVE_LOOPS 277#if XCHAL_HAVE_LOOPS
278 rsr a5, LEND # check if we reached LEND 278 rsr a5, lend # check if we reached LEND
279 bne a7, a5, 1f 279 bne a7, a5, 1f
280 rsr a5, LCOUNT # and LCOUNT != 0 280 rsr a5, lcount # and LCOUNT != 0
281 beqz a5, 1f 281 beqz a5, 1f
282 addi a5, a5, -1 # decrement LCOUNT and set 282 addi a5, a5, -1 # decrement LCOUNT and set
283 rsr a7, LBEG # set PC to LBEGIN 283 rsr a7, lbeg # set PC to LBEGIN
284 wsr a5, LCOUNT 284 wsr a5, lcount
285#endif 285#endif
286 286
2871: wsr a7, EPC_1 # skip load instruction 2871: wsr a7, epc1 # skip load instruction
288 extui a4, a4, INSN_T, 4 # extract target register 288 extui a4, a4, INSN_T, 4 # extract target register
289 movi a5, .Lload_table 289 movi a5, .Lload_table
290 addx8 a4, a4, a5 290 addx8 a4, a4, a5
@@ -355,16 +355,16 @@ ENTRY(fast_unaligned)
355 355
3561: 3561:
357#if XCHAL_HAVE_LOOPS 357#if XCHAL_HAVE_LOOPS
358 rsr a4, LEND # check if we reached LEND 358 rsr a4, lend # check if we reached LEND
359 bne a7, a4, 1f 359 bne a7, a4, 1f
360 rsr a4, LCOUNT # and LCOUNT != 0 360 rsr a4, lcount # and LCOUNT != 0
361 beqz a4, 1f 361 beqz a4, 1f
362 addi a4, a4, -1 # decrement LCOUNT and set 362 addi a4, a4, -1 # decrement LCOUNT and set
363 rsr a7, LBEG # set PC to LBEGIN 363 rsr a7, lbeg # set PC to LBEGIN
364 wsr a4, LCOUNT 364 wsr a4, lcount
365#endif 365#endif
366 366
3671: wsr a7, EPC_1 # skip store instruction 3671: wsr a7, epc1 # skip store instruction
368 movi a4, ~3 368 movi a4, ~3
369 and a4, a4, a8 # align memory address 369 and a4, a4, a8 # align memory address
370 370
@@ -406,7 +406,7 @@ ENTRY(fast_unaligned)
406 406
407.Lexit: 407.Lexit:
408 movi a4, 0 408 movi a4, 0
409 rsr a3, EXCSAVE_1 409 rsr a3, excsave1
410 s32i a4, a3, EXC_TABLE_FIXUP 410 s32i a4, a3, EXC_TABLE_FIXUP
411 411
412 /* Restore working register */ 412 /* Restore working register */
@@ -420,7 +420,7 @@ ENTRY(fast_unaligned)
420 420
421 /* restore SAR and return */ 421 /* restore SAR and return */
422 422
423 wsr a0, SAR 423 wsr a0, sar
424 l32i a0, a2, PT_AREG0 424 l32i a0, a2, PT_AREG0
425 l32i a2, a2, PT_AREG2 425 l32i a2, a2, PT_AREG2
426 rfe 426 rfe
@@ -438,10 +438,10 @@ ENTRY(fast_unaligned)
438 l32i a6, a2, PT_AREG6 438 l32i a6, a2, PT_AREG6
439 l32i a5, a2, PT_AREG5 439 l32i a5, a2, PT_AREG5
440 l32i a4, a2, PT_AREG4 440 l32i a4, a2, PT_AREG4
441 wsr a0, SAR 441 wsr a0, sar
442 mov a1, a2 442 mov a1, a2
443 443
444 rsr a0, PS 444 rsr a0, ps
445 bbsi.l a2, PS_UM_BIT, 1f # jump if user mode 445 bbsi.l a2, PS_UM_BIT, 1f # jump if user mode
446 446
447 movi a0, _kernel_exception 447 movi a0, _kernel_exception
diff --git a/arch/xtensa/kernel/coprocessor.S b/arch/xtensa/kernel/coprocessor.S
index 2bc1e145c0a..54c3be313bf 100644
--- a/arch/xtensa/kernel/coprocessor.S
+++ b/arch/xtensa/kernel/coprocessor.S
@@ -43,7 +43,7 @@
43/* IO protection is currently unsupported. */ 43/* IO protection is currently unsupported. */
44 44
45ENTRY(fast_io_protect) 45ENTRY(fast_io_protect)
46 wsr a0, EXCSAVE_1 46 wsr a0, excsave1
47 movi a0, unrecoverable_exception 47 movi a0, unrecoverable_exception
48 callx0 a0 48 callx0 a0
49 49
@@ -220,7 +220,7 @@ ENTRY(coprocessor_restore)
220 */ 220 */
221 221
222ENTRY(fast_coprocessor_double) 222ENTRY(fast_coprocessor_double)
223 wsr a0, EXCSAVE_1 223 wsr a0, excsave1
224 movi a0, unrecoverable_exception 224 movi a0, unrecoverable_exception
225 callx0 a0 225 callx0 a0
226 226
@@ -229,13 +229,13 @@ ENTRY(fast_coprocessor)
229 229
230 /* Save remaining registers a1-a3 and SAR */ 230 /* Save remaining registers a1-a3 and SAR */
231 231
232 xsr a3, EXCSAVE_1 232 xsr a3, excsave1
233 s32i a3, a2, PT_AREG3 233 s32i a3, a2, PT_AREG3
234 rsr a3, SAR 234 rsr a3, sar
235 s32i a1, a2, PT_AREG1 235 s32i a1, a2, PT_AREG1
236 s32i a3, a2, PT_SAR 236 s32i a3, a2, PT_SAR
237 mov a1, a2 237 mov a1, a2
238 rsr a2, DEPC 238 rsr a2, depc
239 s32i a2, a1, PT_AREG2 239 s32i a2, a1, PT_AREG2
240 240
241 /* 241 /*
@@ -248,17 +248,17 @@ ENTRY(fast_coprocessor)
248 248
249 /* Find coprocessor number. Subtract first CP EXCCAUSE from EXCCAUSE */ 249 /* Find coprocessor number. Subtract first CP EXCCAUSE from EXCCAUSE */
250 250
251 rsr a3, EXCCAUSE 251 rsr a3, exccause
252 addi a3, a3, -EXCCAUSE_COPROCESSOR0_DISABLED 252 addi a3, a3, -EXCCAUSE_COPROCESSOR0_DISABLED
253 253
254 /* Set corresponding CPENABLE bit -> (sar:cp-index, a3: 1<<cp-index)*/ 254 /* Set corresponding CPENABLE bit -> (sar:cp-index, a3: 1<<cp-index)*/
255 255
256 ssl a3 # SAR: 32 - coprocessor_number 256 ssl a3 # SAR: 32 - coprocessor_number
257 movi a2, 1 257 movi a2, 1
258 rsr a0, CPENABLE 258 rsr a0, cpenable
259 sll a2, a2 259 sll a2, a2
260 or a0, a0, a2 260 or a0, a0, a2
261 wsr a0, CPENABLE 261 wsr a0, cpenable
262 rsync 262 rsync
263 263
264 /* Retrieve previous owner. (a3 still holds CP number) */ 264 /* Retrieve previous owner. (a3 still holds CP number) */
@@ -291,7 +291,7 @@ ENTRY(fast_coprocessor)
291 291
292 /* Note that only a0 and a1 were preserved. */ 292 /* Note that only a0 and a1 were preserved. */
293 293
2942: rsr a3, EXCCAUSE 2942: rsr a3, exccause
295 addi a3, a3, -EXCCAUSE_COPROCESSOR0_DISABLED 295 addi a3, a3, -EXCCAUSE_COPROCESSOR0_DISABLED
296 movi a0, coprocessor_owner 296 movi a0, coprocessor_owner
297 addx4 a0, a3, a0 297 addx4 a0, a3, a0
@@ -321,7 +321,7 @@ ENTRY(fast_coprocessor)
321 l32i a0, a1, PT_SAR 321 l32i a0, a1, PT_SAR
322 l32i a3, a1, PT_AREG3 322 l32i a3, a1, PT_AREG3
323 l32i a2, a1, PT_AREG2 323 l32i a2, a1, PT_AREG2
324 wsr a0, SAR 324 wsr a0, sar
325 l32i a0, a1, PT_AREG0 325 l32i a0, a1, PT_AREG0
326 l32i a1, a1, PT_AREG1 326 l32i a1, a1, PT_AREG1
327 327
diff --git a/arch/xtensa/kernel/entry.S b/arch/xtensa/kernel/entry.S
index 7e623607339..90bfc1dbc13 100644
--- a/arch/xtensa/kernel/entry.S
+++ b/arch/xtensa/kernel/entry.S
@@ -112,8 +112,8 @@ ENTRY(user_exception)
112 112
113 /* Save a2, a3, and depc, restore excsave_1 and set SP. */ 113 /* Save a2, a3, and depc, restore excsave_1 and set SP. */
114 114
115 xsr a3, EXCSAVE_1 115 xsr a3, excsave1
116 rsr a0, DEPC 116 rsr a0, depc
117 s32i a1, a2, PT_AREG1 117 s32i a1, a2, PT_AREG1
118 s32i a0, a2, PT_AREG2 118 s32i a0, a2, PT_AREG2
119 s32i a3, a2, PT_AREG3 119 s32i a3, a2, PT_AREG3
@@ -125,16 +125,16 @@ _user_exception:
125 /* Save SAR and turn off single stepping */ 125 /* Save SAR and turn off single stepping */
126 126
127 movi a2, 0 127 movi a2, 0
128 rsr a3, SAR 128 rsr a3, sar
129 xsr a2, ICOUNTLEVEL 129 xsr a2, icountlevel
130 s32i a3, a1, PT_SAR 130 s32i a3, a1, PT_SAR
131 s32i a2, a1, PT_ICOUNTLEVEL 131 s32i a2, a1, PT_ICOUNTLEVEL
132 132
133 /* Rotate ws so that the current windowbase is at bit0. */ 133 /* Rotate ws so that the current windowbase is at bit0. */
134 /* Assume ws = xxwww1yyyy. Rotate ws right, so that a2 = yyyyxxwww1 */ 134 /* Assume ws = xxwww1yyyy. Rotate ws right, so that a2 = yyyyxxwww1 */
135 135
136 rsr a2, WINDOWBASE 136 rsr a2, windowbase
137 rsr a3, WINDOWSTART 137 rsr a3, windowstart
138 ssr a2 138 ssr a2
139 s32i a2, a1, PT_WINDOWBASE 139 s32i a2, a1, PT_WINDOWBASE
140 s32i a3, a1, PT_WINDOWSTART 140 s32i a3, a1, PT_WINDOWSTART
@@ -205,12 +205,12 @@ _user_exception:
205 205
206 /* WINDOWBASE still in SAR! */ 206 /* WINDOWBASE still in SAR! */
207 207
208 rsr a2, SAR # original WINDOWBASE 208 rsr a2, sar # original WINDOWBASE
209 movi a3, 1 209 movi a3, 1
210 ssl a2 210 ssl a2
211 sll a3, a3 211 sll a3, a3
212 wsr a3, WINDOWSTART # set corresponding WINDOWSTART bit 212 wsr a3, windowstart # set corresponding WINDOWSTART bit
213 wsr a2, WINDOWBASE # and WINDOWSTART 213 wsr a2, windowbase # and WINDOWSTART
214 rsync 214 rsync
215 215
216 /* We are back to the original stack pointer (a1) */ 216 /* We are back to the original stack pointer (a1) */
@@ -252,8 +252,8 @@ ENTRY(kernel_exception)
252 252
253 /* Save a0, a2, a3, DEPC and set SP. */ 253 /* Save a0, a2, a3, DEPC and set SP. */
254 254
255 xsr a3, EXCSAVE_1 # restore a3, excsave_1 255 xsr a3, excsave1 # restore a3, excsave_1
256 rsr a0, DEPC # get a2 256 rsr a0, depc # get a2
257 s32i a1, a2, PT_AREG1 257 s32i a1, a2, PT_AREG1
258 s32i a0, a2, PT_AREG2 258 s32i a0, a2, PT_AREG2
259 s32i a3, a2, PT_AREG3 259 s32i a3, a2, PT_AREG3
@@ -265,16 +265,16 @@ _kernel_exception:
265 /* Save SAR and turn off single stepping */ 265 /* Save SAR and turn off single stepping */
266 266
267 movi a2, 0 267 movi a2, 0
268 rsr a3, SAR 268 rsr a3, sar
269 xsr a2, ICOUNTLEVEL 269 xsr a2, icountlevel
270 s32i a3, a1, PT_SAR 270 s32i a3, a1, PT_SAR
271 s32i a2, a1, PT_ICOUNTLEVEL 271 s32i a2, a1, PT_ICOUNTLEVEL
272 272
273 /* Rotate ws so that the current windowbase is at bit0. */ 273 /* Rotate ws so that the current windowbase is at bit0. */
274 /* Assume ws = xxwww1yyyy. Rotate ws right, so that a2 = yyyyxxwww1 */ 274 /* Assume ws = xxwww1yyyy. Rotate ws right, so that a2 = yyyyxxwww1 */
275 275
276 rsr a2, WINDOWBASE # don't need to save these, we only 276 rsr a2, windowbase # don't need to save these, we only
277 rsr a3, WINDOWSTART # need shifted windowstart: windowmask 277 rsr a3, windowstart # need shifted windowstart: windowmask
278 ssr a2 278 ssr a2
279 slli a2, a3, 32-WSBITS 279 slli a2, a3, 32-WSBITS
280 src a2, a3, a2 280 src a2, a3, a2
@@ -323,24 +323,24 @@ common_exception:
323 323
324 /* Save some registers, disable loops and clear the syscall flag. */ 324 /* Save some registers, disable loops and clear the syscall flag. */
325 325
326 rsr a2, DEBUGCAUSE 326 rsr a2, debugcause
327 rsr a3, EPC_1 327 rsr a3, epc1
328 s32i a2, a1, PT_DEBUGCAUSE 328 s32i a2, a1, PT_DEBUGCAUSE
329 s32i a3, a1, PT_PC 329 s32i a3, a1, PT_PC
330 330
331 movi a2, -1 331 movi a2, -1
332 rsr a3, EXCVADDR 332 rsr a3, excvaddr
333 s32i a2, a1, PT_SYSCALL 333 s32i a2, a1, PT_SYSCALL
334 movi a2, 0 334 movi a2, 0
335 s32i a3, a1, PT_EXCVADDR 335 s32i a3, a1, PT_EXCVADDR
336 xsr a2, LCOUNT 336 xsr a2, lcount
337 s32i a2, a1, PT_LCOUNT 337 s32i a2, a1, PT_LCOUNT
338 338
339 /* It is now save to restore the EXC_TABLE_FIXUP variable. */ 339 /* It is now save to restore the EXC_TABLE_FIXUP variable. */
340 340
341 rsr a0, EXCCAUSE 341 rsr a0, exccause
342 movi a3, 0 342 movi a3, 0
343 rsr a2, EXCSAVE_1 343 rsr a2, excsave1
344 s32i a0, a1, PT_EXCCAUSE 344 s32i a0, a1, PT_EXCCAUSE
345 s32i a3, a2, EXC_TABLE_FIXUP 345 s32i a3, a2, EXC_TABLE_FIXUP
346 346
@@ -352,22 +352,22 @@ common_exception:
352 * (interrupts disabled) and if this exception is not an interrupt. 352 * (interrupts disabled) and if this exception is not an interrupt.
353 */ 353 */
354 354
355 rsr a3, PS 355 rsr a3, ps
356 addi a0, a0, -4 356 addi a0, a0, -4
357 movi a2, 1 357 movi a2, 1
358 extui a3, a3, 0, 1 # a3 = PS.INTLEVEL[0] 358 extui a3, a3, 0, 1 # a3 = PS.INTLEVEL[0]
359 moveqz a3, a2, a0 # a3 = 1 iff interrupt exception 359 moveqz a3, a2, a0 # a3 = 1 iff interrupt exception
360 movi a2, 1 << PS_WOE_BIT 360 movi a2, 1 << PS_WOE_BIT
361 or a3, a3, a2 361 or a3, a3, a2
362 rsr a0, EXCCAUSE 362 rsr a0, exccause
363 xsr a3, PS 363 xsr a3, ps
364 364
365 s32i a3, a1, PT_PS # save ps 365 s32i a3, a1, PT_PS # save ps
366 366
367 /* Save LBEG, LEND */ 367 /* Save lbeg, lend */
368 368
369 rsr a2, LBEG 369 rsr a2, lbeg
370 rsr a3, LEND 370 rsr a3, lend
371 s32i a2, a1, PT_LBEG 371 s32i a2, a1, PT_LBEG
372 s32i a3, a1, PT_LEND 372 s32i a3, a1, PT_LEND
373 373
@@ -432,7 +432,7 @@ common_exception_return:
432 432
433 load_xtregs_opt a1 a2 a4 a5 a6 a7 PT_XTREGS_OPT 433 load_xtregs_opt a1 a2 a4 a5 a6 a7 PT_XTREGS_OPT
434 434
435 wsr a3, PS /* disable interrupts */ 435 wsr a3, ps /* disable interrupts */
436 436
437 _bbci.l a3, PS_UM_BIT, kernel_exception_exit 437 _bbci.l a3, PS_UM_BIT, kernel_exception_exit
438 438
@@ -444,12 +444,12 @@ user_exception_exit:
444 444
445 l32i a2, a1, PT_WINDOWBASE 445 l32i a2, a1, PT_WINDOWBASE
446 l32i a3, a1, PT_WINDOWSTART 446 l32i a3, a1, PT_WINDOWSTART
447 wsr a1, DEPC # use DEPC as temp storage 447 wsr a1, depc # use DEPC as temp storage
448 wsr a3, WINDOWSTART # restore WINDOWSTART 448 wsr a3, windowstart # restore WINDOWSTART
449 ssr a2 # preserve user's WB in the SAR 449 ssr a2 # preserve user's WB in the SAR
450 wsr a2, WINDOWBASE # switch to user's saved WB 450 wsr a2, windowbase # switch to user's saved WB
451 rsync 451 rsync
452 rsr a1, DEPC # restore stack pointer 452 rsr a1, depc # restore stack pointer
453 l32i a2, a1, PT_WMASK # register frames saved (in bits 4...9) 453 l32i a2, a1, PT_WMASK # register frames saved (in bits 4...9)
454 rotw -1 # we restore a4..a7 454 rotw -1 # we restore a4..a7
455 _bltui a6, 16, 1f # only have to restore current window? 455 _bltui a6, 16, 1f # only have to restore current window?
@@ -475,8 +475,8 @@ user_exception_exit:
475 475
476 /* Clear unrestored registers (don't leak anything to user-land */ 476 /* Clear unrestored registers (don't leak anything to user-land */
477 477
4781: rsr a0, WINDOWBASE 4781: rsr a0, windowbase
479 rsr a3, SAR 479 rsr a3, sar
480 sub a3, a0, a3 480 sub a3, a0, a3
481 beqz a3, 2f 481 beqz a3, 2f
482 extui a3, a3, 0, WBBITS 482 extui a3, a3, 0, WBBITS
@@ -556,7 +556,7 @@ kernel_exception_exit:
556 556
557 /* Test WINDOWSTART now. If spilled, do the movsp */ 557 /* Test WINDOWSTART now. If spilled, do the movsp */
558 558
559 rsr a3, WINDOWSTART 559 rsr a3, windowstart
560 addi a0, a3, -1 560 addi a0, a3, -1
561 and a3, a3, a0 561 and a3, a3, a0
562 _bnez a3, common_exception_exit 562 _bnez a3, common_exception_exit
@@ -604,24 +604,24 @@ common_exception_exit:
604 604
6051: l32i a2, a1, PT_PC 6051: l32i a2, a1, PT_PC
606 l32i a3, a1, PT_SAR 606 l32i a3, a1, PT_SAR
607 wsr a2, EPC_1 607 wsr a2, epc1
608 wsr a3, SAR 608 wsr a3, sar
609 609
610 /* Restore LBEG, LEND, LCOUNT */ 610 /* Restore LBEG, LEND, LCOUNT */
611 611
612 l32i a2, a1, PT_LBEG 612 l32i a2, a1, PT_LBEG
613 l32i a3, a1, PT_LEND 613 l32i a3, a1, PT_LEND
614 wsr a2, LBEG 614 wsr a2, lbeg
615 l32i a2, a1, PT_LCOUNT 615 l32i a2, a1, PT_LCOUNT
616 wsr a3, LEND 616 wsr a3, lend
617 wsr a2, LCOUNT 617 wsr a2, lcount
618 618
619 /* We control single stepping through the ICOUNTLEVEL register. */ 619 /* We control single stepping through the ICOUNTLEVEL register. */
620 620
621 l32i a2, a1, PT_ICOUNTLEVEL 621 l32i a2, a1, PT_ICOUNTLEVEL
622 movi a3, -2 622 movi a3, -2
623 wsr a2, ICOUNTLEVEL 623 wsr a2, icountlevel
624 wsr a3, ICOUNT 624 wsr a3, icount
625 625
626 /* Check if it was double exception. */ 626 /* Check if it was double exception. */
627 627
@@ -636,7 +636,7 @@ common_exception_exit:
636 l32i a1, a1, PT_AREG1 636 l32i a1, a1, PT_AREG1
637 rfe 637 rfe
638 638
6391: wsr a0, DEPC 6391: wsr a0, depc
640 l32i a0, a1, PT_AREG0 640 l32i a0, a1, PT_AREG0
641 l32i a1, a1, PT_AREG1 641 l32i a1, a1, PT_AREG1
642 rfde 642 rfde
@@ -651,25 +651,25 @@ common_exception_exit:
651 651
652ENTRY(debug_exception) 652ENTRY(debug_exception)
653 653
654 rsr a0, EPS + XCHAL_DEBUGLEVEL 654 rsr a0, SREG_EPS + XCHAL_DEBUGLEVEL
655 bbsi.l a0, PS_EXCM_BIT, 1f # exception mode 655 bbsi.l a0, PS_EXCM_BIT, 1f # exception mode
656 656
657 /* Set EPC_1 and EXCCAUSE */ 657 /* Set EPC1 and EXCCAUSE */
658 658
659 wsr a2, DEPC # save a2 temporarily 659 wsr a2, depc # save a2 temporarily
660 rsr a2, EPC + XCHAL_DEBUGLEVEL 660 rsr a2, SREG_EPC + XCHAL_DEBUGLEVEL
661 wsr a2, EPC_1 661 wsr a2, epc1
662 662
663 movi a2, EXCCAUSE_MAPPED_DEBUG 663 movi a2, EXCCAUSE_MAPPED_DEBUG
664 wsr a2, EXCCAUSE 664 wsr a2, exccause
665 665
666 /* Restore PS to the value before the debug exc but with PS.EXCM set.*/ 666 /* Restore PS to the value before the debug exc but with PS.EXCM set.*/
667 667
668 movi a2, 1 << PS_EXCM_BIT 668 movi a2, 1 << PS_EXCM_BIT
669 or a2, a0, a2 669 or a2, a0, a2
670 movi a0, debug_exception # restore a3, debug jump vector 670 movi a0, debug_exception # restore a3, debug jump vector
671 wsr a2, PS 671 wsr a2, ps
672 xsr a0, EXCSAVE + XCHAL_DEBUGLEVEL 672 xsr a0, SREG_EXCSAVE + XCHAL_DEBUGLEVEL
673 673
674 /* Switch to kernel/user stack, restore jump vector, and save a0 */ 674 /* Switch to kernel/user stack, restore jump vector, and save a0 */
675 675
@@ -680,19 +680,19 @@ ENTRY(debug_exception)
680 movi a0, 0 680 movi a0, 0
681 s32i a1, a2, PT_AREG1 681 s32i a1, a2, PT_AREG1
682 s32i a0, a2, PT_DEPC # mark it as a regular exception 682 s32i a0, a2, PT_DEPC # mark it as a regular exception
683 xsr a0, DEPC 683 xsr a0, depc
684 s32i a3, a2, PT_AREG3 684 s32i a3, a2, PT_AREG3
685 s32i a0, a2, PT_AREG2 685 s32i a0, a2, PT_AREG2
686 mov a1, a2 686 mov a1, a2
687 j _kernel_exception 687 j _kernel_exception
688 688
6892: rsr a2, EXCSAVE_1 6892: rsr a2, excsave1
690 l32i a2, a2, EXC_TABLE_KSTK # load kernel stack pointer 690 l32i a2, a2, EXC_TABLE_KSTK # load kernel stack pointer
691 s32i a0, a2, PT_AREG0 691 s32i a0, a2, PT_AREG0
692 movi a0, 0 692 movi a0, 0
693 s32i a1, a2, PT_AREG1 693 s32i a1, a2, PT_AREG1
694 s32i a0, a2, PT_DEPC 694 s32i a0, a2, PT_DEPC
695 xsr a0, DEPC 695 xsr a0, depc
696 s32i a3, a2, PT_AREG3 696 s32i a3, a2, PT_AREG3
697 s32i a0, a2, PT_AREG2 697 s32i a0, a2, PT_AREG2
698 mov a1, a2 698 mov a1, a2
@@ -732,12 +732,12 @@ ENTRY(unrecoverable_exception)
732 movi a0, 1 732 movi a0, 1
733 movi a1, 0 733 movi a1, 0
734 734
735 wsr a0, WINDOWSTART 735 wsr a0, windowstart
736 wsr a1, WINDOWBASE 736 wsr a1, windowbase
737 rsync 737 rsync
738 738
739 movi a1, (1 << PS_WOE_BIT) | 1 739 movi a1, (1 << PS_WOE_BIT) | 1
740 wsr a1, PS 740 wsr a1, ps
741 rsync 741 rsync
742 742
743 movi a1, init_task 743 movi a1, init_task
@@ -793,7 +793,7 @@ ENTRY(fast_alloca)
793 l32i a0, a2, PT_DEPC 793 l32i a0, a2, PT_DEPC
794 _bgeui a0, VALID_DOUBLE_EXCEPTION_ADDRESS, .Lunhandled_double 794 _bgeui a0, VALID_DOUBLE_EXCEPTION_ADDRESS, .Lunhandled_double
795 795
796 rsr a0, DEPC # get a2 796 rsr a0, depc # get a2
797 s32i a4, a2, PT_AREG4 # save a4 and 797 s32i a4, a2, PT_AREG4 # save a4 and
798 s32i a0, a2, PT_AREG2 # a2 to stack 798 s32i a0, a2, PT_AREG2 # a2 to stack
799 799
@@ -804,8 +804,8 @@ ENTRY(fast_alloca)
804 804
805 /* Restore a3, excsave_1 */ 805 /* Restore a3, excsave_1 */
806 806
807 xsr a3, EXCSAVE_1 # make sure excsave_1 is valid for dbl. 807 xsr a3, excsave1 # make sure excsave_1 is valid for dbl.
808 rsr a4, EPC_1 # get exception address 808 rsr a4, epc1 # get exception address
809 s32i a3, a2, PT_AREG3 # save a3 to stack 809 s32i a3, a2, PT_AREG3 # save a3 to stack
810 810
811#ifdef ALLOCA_EXCEPTION_IN_IRAM 811#ifdef ALLOCA_EXCEPTION_IN_IRAM
@@ -820,7 +820,7 @@ ENTRY(fast_alloca)
820 jx a3 820 jx a3
821 821
822.Lunhandled_double: 822.Lunhandled_double:
823 wsr a0, EXCSAVE_1 823 wsr a0, excsave1
824 movi a0, unrecoverable_exception 824 movi a0, unrecoverable_exception
825 callx0 a0 825 callx0 a0
826 826
@@ -852,7 +852,7 @@ ENTRY(fast_alloca)
852#endif 852#endif
853 addi a4, a4, 3 # step over movsp 853 addi a4, a4, 3 # step over movsp
854 _EXTUI_MOVSP_DST(a0) # extract destination register 854 _EXTUI_MOVSP_DST(a0) # extract destination register
855 wsr a4, EPC_1 # save new epc_1 855 wsr a4, epc1 # save new epc_1
856 856
857 _bnei a0, 1, 1f # no 'movsp a1, ax': jump 857 _bnei a0, 1, 1f # no 'movsp a1, ax': jump
858 858
@@ -953,14 +953,14 @@ ENTRY(fast_syscall_kernel)
953 953
954 /* Skip syscall. */ 954 /* Skip syscall. */
955 955
956 rsr a0, EPC_1 956 rsr a0, epc1
957 addi a0, a0, 3 957 addi a0, a0, 3
958 wsr a0, EPC_1 958 wsr a0, epc1
959 959
960 l32i a0, a2, PT_DEPC 960 l32i a0, a2, PT_DEPC
961 bgeui a0, VALID_DOUBLE_EXCEPTION_ADDRESS, fast_syscall_unrecoverable 961 bgeui a0, VALID_DOUBLE_EXCEPTION_ADDRESS, fast_syscall_unrecoverable
962 962
963 rsr a0, DEPC # get syscall-nr 963 rsr a0, depc # get syscall-nr
964 _beqz a0, fast_syscall_spill_registers 964 _beqz a0, fast_syscall_spill_registers
965 _beqi a0, __NR_xtensa, fast_syscall_xtensa 965 _beqi a0, __NR_xtensa, fast_syscall_xtensa
966 966
@@ -970,14 +970,14 @@ ENTRY(fast_syscall_user)
970 970
971 /* Skip syscall. */ 971 /* Skip syscall. */
972 972
973 rsr a0, EPC_1 973 rsr a0, epc1
974 addi a0, a0, 3 974 addi a0, a0, 3
975 wsr a0, EPC_1 975 wsr a0, epc1
976 976
977 l32i a0, a2, PT_DEPC 977 l32i a0, a2, PT_DEPC
978 bgeui a0, VALID_DOUBLE_EXCEPTION_ADDRESS, fast_syscall_unrecoverable 978 bgeui a0, VALID_DOUBLE_EXCEPTION_ADDRESS, fast_syscall_unrecoverable
979 979
980 rsr a0, DEPC # get syscall-nr 980 rsr a0, depc # get syscall-nr
981 _beqz a0, fast_syscall_spill_registers 981 _beqz a0, fast_syscall_spill_registers
982 _beqi a0, __NR_xtensa, fast_syscall_xtensa 982 _beqi a0, __NR_xtensa, fast_syscall_xtensa
983 983
@@ -988,10 +988,10 @@ ENTRY(fast_syscall_unrecoverable)
988 /* Restore all states. */ 988 /* Restore all states. */
989 989
990 l32i a0, a2, PT_AREG0 # restore a0 990 l32i a0, a2, PT_AREG0 # restore a0
991 xsr a2, DEPC # restore a2, depc 991 xsr a2, depc # restore a2, depc
992 rsr a3, EXCSAVE_1 992 rsr a3, excsave1
993 993
994 wsr a0, EXCSAVE_1 994 wsr a0, excsave1
995 movi a0, unrecoverable_exception 995 movi a0, unrecoverable_exception
996 callx0 a0 996 callx0 a0
997 997
@@ -1047,7 +1047,7 @@ ENTRY(fast_syscall_unrecoverable)
1047 1047
1048ENTRY(fast_syscall_xtensa) 1048ENTRY(fast_syscall_xtensa)
1049 1049
1050 xsr a3, EXCSAVE_1 # restore a3, excsave1 1050 xsr a3, excsave1 # restore a3, excsave1
1051 1051
1052 s32i a7, a2, PT_AREG7 # we need an additional register 1052 s32i a7, a2, PT_AREG7 # we need an additional register
1053 movi a7, 4 # sizeof(unsigned int) 1053 movi a7, 4 # sizeof(unsigned int)
@@ -1124,13 +1124,13 @@ ENTRY(fast_syscall_spill_registers)
1124 1124
1125 movi a0, fast_syscall_spill_registers_fixup 1125 movi a0, fast_syscall_spill_registers_fixup
1126 s32i a0, a3, EXC_TABLE_FIXUP 1126 s32i a0, a3, EXC_TABLE_FIXUP
1127 rsr a0, WINDOWBASE 1127 rsr a0, windowbase
1128 s32i a0, a3, EXC_TABLE_PARAM 1128 s32i a0, a3, EXC_TABLE_PARAM
1129 1129
1130 /* Save a3 and SAR on stack. */ 1130 /* Save a3 and SAR on stack. */
1131 1131
1132 rsr a0, SAR 1132 rsr a0, sar
1133 xsr a3, EXCSAVE_1 # restore a3 and excsave_1 1133 xsr a3, excsave1 # restore a3 and excsave_1
1134 s32i a3, a2, PT_AREG3 1134 s32i a3, a2, PT_AREG3
1135 s32i a4, a2, PT_AREG4 1135 s32i a4, a2, PT_AREG4
1136 s32i a0, a2, PT_AREG5 # store SAR to PT_AREG5 1136 s32i a0, a2, PT_AREG5 # store SAR to PT_AREG5
@@ -1148,7 +1148,7 @@ ENTRY(fast_syscall_spill_registers)
1148 l32i a3, a2, PT_AREG5 1148 l32i a3, a2, PT_AREG5
1149 l32i a4, a2, PT_AREG4 1149 l32i a4, a2, PT_AREG4
1150 l32i a0, a2, PT_AREG0 1150 l32i a0, a2, PT_AREG0
1151 wsr a3, SAR 1151 wsr a3, sar
1152 l32i a3, a2, PT_AREG3 1152 l32i a3, a2, PT_AREG3
1153 1153
1154 /* Restore clobbered registers. */ 1154 /* Restore clobbered registers. */
@@ -1173,8 +1173,8 @@ ENTRY(fast_syscall_spill_registers)
1173 1173
1174fast_syscall_spill_registers_fixup: 1174fast_syscall_spill_registers_fixup:
1175 1175
1176 rsr a2, WINDOWBASE # get current windowbase (a2 is saved) 1176 rsr a2, windowbase # get current windowbase (a2 is saved)
1177 xsr a0, DEPC # restore depc and a0 1177 xsr a0, depc # restore depc and a0
1178 ssl a2 # set shift (32 - WB) 1178 ssl a2 # set shift (32 - WB)
1179 1179
1180 /* We need to make sure the current registers (a0-a3) are preserved. 1180 /* We need to make sure the current registers (a0-a3) are preserved.
@@ -1182,12 +1182,12 @@ fast_syscall_spill_registers_fixup:
1182 * in WS, so that the exception handlers save them to the task stack. 1182 * in WS, so that the exception handlers save them to the task stack.
1183 */ 1183 */
1184 1184
1185 rsr a3, EXCSAVE_1 # get spill-mask 1185 rsr a3, excsave1 # get spill-mask
1186 slli a2, a3, 1 # shift left by one 1186 slli a2, a3, 1 # shift left by one
1187 1187
1188 slli a3, a2, 32-WSBITS 1188 slli a3, a2, 32-WSBITS
1189 src a2, a2, a3 # a1 = xxwww1yyxxxwww1yy...... 1189 src a2, a2, a3 # a1 = xxwww1yyxxxwww1yy......
1190 wsr a2, WINDOWSTART # set corrected windowstart 1190 wsr a2, windowstart # set corrected windowstart
1191 1191
1192 movi a3, exc_table 1192 movi a3, exc_table
1193 l32i a2, a3, EXC_TABLE_DOUBLE_SAVE # restore a2 1193 l32i a2, a3, EXC_TABLE_DOUBLE_SAVE # restore a2
@@ -1201,7 +1201,7 @@ fast_syscall_spill_registers_fixup:
1201 * excsave_1: a3 1201 * excsave_1: a3
1202 */ 1202 */
1203 1203
1204 wsr a3, WINDOWBASE 1204 wsr a3, windowbase
1205 rsync 1205 rsync
1206 1206
1207 /* We are now in the original frame when we entered _spill_registers: 1207 /* We are now in the original frame when we entered _spill_registers:
@@ -1227,7 +1227,7 @@ fast_syscall_spill_registers_fixup:
1227 /* Jump to the exception handler. */ 1227 /* Jump to the exception handler. */
1228 1228
1229 movi a3, exc_table 1229 movi a3, exc_table
1230 rsr a0, EXCCAUSE 1230 rsr a0, exccause
1231 addx4 a0, a0, a3 # find entry in table 1231 addx4 a0, a0, a3 # find entry in table
1232 l32i a0, a0, EXC_TABLE_FAST_USER # load handler 1232 l32i a0, a0, EXC_TABLE_FAST_USER # load handler
1233 jx a0 1233 jx a0
@@ -1236,28 +1236,28 @@ fast_syscall_spill_registers_fixup_return:
1236 1236
1237 /* When we return here, all registers have been restored (a2: DEPC) */ 1237 /* When we return here, all registers have been restored (a2: DEPC) */
1238 1238
1239 wsr a2, DEPC # exception address 1239 wsr a2, depc # exception address
1240 1240
1241 /* Restore fixup handler. */ 1241 /* Restore fixup handler. */
1242 1242
1243 xsr a3, EXCSAVE_1 1243 xsr a3, excsave1
1244 movi a2, fast_syscall_spill_registers_fixup 1244 movi a2, fast_syscall_spill_registers_fixup
1245 s32i a2, a3, EXC_TABLE_FIXUP 1245 s32i a2, a3, EXC_TABLE_FIXUP
1246 rsr a2, WINDOWBASE 1246 rsr a2, windowbase
1247 s32i a2, a3, EXC_TABLE_PARAM 1247 s32i a2, a3, EXC_TABLE_PARAM
1248 l32i a2, a3, EXC_TABLE_KSTK 1248 l32i a2, a3, EXC_TABLE_KSTK
1249 1249
1250 /* Load WB at the time the exception occurred. */ 1250 /* Load WB at the time the exception occurred. */
1251 1251
1252 rsr a3, SAR # WB is still in SAR 1252 rsr a3, sar # WB is still in SAR
1253 neg a3, a3 1253 neg a3, a3
1254 wsr a3, WINDOWBASE 1254 wsr a3, windowbase
1255 rsync 1255 rsync
1256 1256
1257 /* Restore a3 and return. */ 1257 /* Restore a3 and return. */
1258 1258
1259 movi a3, exc_table 1259 movi a3, exc_table
1260 xsr a3, EXCSAVE_1 1260 xsr a3, excsave1
1261 1261
1262 rfde 1262 rfde
1263 1263
@@ -1283,8 +1283,8 @@ ENTRY(_spill_registers)
1283 * Rotate ws right so that a4 = yyxxxwww1. 1283 * Rotate ws right so that a4 = yyxxxwww1.
1284 */ 1284 */
1285 1285
1286 rsr a4, WINDOWBASE 1286 rsr a4, windowbase
1287 rsr a3, WINDOWSTART # a3 = xxxwww1yy 1287 rsr a3, windowstart # a3 = xxxwww1yy
1288 ssr a4 # holds WB 1288 ssr a4 # holds WB
1289 slli a4, a3, WSBITS 1289 slli a4, a3, WSBITS
1290 or a3, a3, a4 # a3 = xxxwww1yyxxxwww1yy 1290 or a3, a3, a4 # a3 = xxxwww1yyxxxwww1yy
@@ -1302,7 +1302,7 @@ ENTRY(_spill_registers)
1302 1302
1303 /* Skip empty frames - get 'oldest' WINDOWSTART-bit. */ 1303 /* Skip empty frames - get 'oldest' WINDOWSTART-bit. */
1304 1304
1305 wsr a3, WINDOWSTART # save shifted windowstart 1305 wsr a3, windowstart # save shifted windowstart
1306 neg a4, a3 1306 neg a4, a3
1307 and a3, a4, a3 # first bit set from right: 000010000 1307 and a3, a4, a3 # first bit set from right: 000010000
1308 1308
@@ -1311,12 +1311,12 @@ ENTRY(_spill_registers)
1311 sub a4, a3, a4 # WSBITS-a4:number of 0-bits from right 1311 sub a4, a3, a4 # WSBITS-a4:number of 0-bits from right
1312 ssr a4 # save in SAR for later. 1312 ssr a4 # save in SAR for later.
1313 1313
1314 rsr a3, WINDOWBASE 1314 rsr a3, windowbase
1315 add a3, a3, a4 1315 add a3, a3, a4
1316 wsr a3, WINDOWBASE 1316 wsr a3, windowbase
1317 rsync 1317 rsync
1318 1318
1319 rsr a3, WINDOWSTART 1319 rsr a3, windowstart
1320 srl a3, a3 # shift windowstart 1320 srl a3, a3 # shift windowstart
1321 1321
1322 /* WB is now just one frame below the oldest frame in the register 1322 /* WB is now just one frame below the oldest frame in the register
@@ -1364,11 +1364,11 @@ ENTRY(_spill_registers)
1364.Lexit: /* Done. Do the final rotation, set WS, and return. */ 1364.Lexit: /* Done. Do the final rotation, set WS, and return. */
1365 1365
1366 rotw 1 1366 rotw 1
1367 rsr a3, WINDOWBASE 1367 rsr a3, windowbase
1368 ssl a3 1368 ssl a3
1369 movi a3, 1 1369 movi a3, 1
1370 sll a3, a3 1370 sll a3, a3
1371 wsr a3, WINDOWSTART 1371 wsr a3, windowstart
1372 ret 1372 ret
1373 1373
1374.Lc4: s32e a4, a9, -16 1374.Lc4: s32e a4, a9, -16
@@ -1429,7 +1429,7 @@ ENTRY(_spill_registers)
1429 * however, this condition is unrecoverable in kernel space. 1429 * however, this condition is unrecoverable in kernel space.
1430 */ 1430 */
1431 1431
1432 rsr a0, PS 1432 rsr a0, ps
1433 _bbci.l a0, PS_UM_BIT, 1f 1433 _bbci.l a0, PS_UM_BIT, 1f
1434 1434
1435 /* User space: Setup a dummy frame and kill application. 1435 /* User space: Setup a dummy frame and kill application.
@@ -1439,18 +1439,18 @@ ENTRY(_spill_registers)
1439 movi a0, 1 1439 movi a0, 1
1440 movi a1, 0 1440 movi a1, 0
1441 1441
1442 wsr a0, WINDOWSTART 1442 wsr a0, windowstart
1443 wsr a1, WINDOWBASE 1443 wsr a1, windowbase
1444 rsync 1444 rsync
1445 1445
1446 movi a0, 0 1446 movi a0, 0
1447 1447
1448 movi a3, exc_table 1448 movi a3, exc_table
1449 l32i a1, a3, EXC_TABLE_KSTK 1449 l32i a1, a3, EXC_TABLE_KSTK
1450 wsr a3, EXCSAVE_1 1450 wsr a3, excsave1
1451 1451
1452 movi a4, (1 << PS_WOE_BIT) | 1 1452 movi a4, (1 << PS_WOE_BIT) | 1
1453 wsr a4, PS 1453 wsr a4, ps
1454 rsync 1454 rsync
1455 1455
1456 movi a6, SIGSEGV 1456 movi a6, SIGSEGV
@@ -1459,7 +1459,7 @@ ENTRY(_spill_registers)
1459 1459
14601: /* Kernel space: PANIC! */ 14601: /* Kernel space: PANIC! */
1461 1461
1462 wsr a0, EXCSAVE_1 1462 wsr a0, excsave1
1463 movi a0, unrecoverable_exception 1463 movi a0, unrecoverable_exception
1464 callx0 a0 # should not return 1464 callx0 a0 # should not return
14651: j 1b 14651: j 1b
@@ -1524,7 +1524,7 @@ ENTRY(fast_second_level_miss)
1524 1524
1525 /* We deliberately destroy a3 that holds the exception table. */ 1525 /* We deliberately destroy a3 that holds the exception table. */
1526 1526
15278: rsr a3, EXCVADDR # fault address 15278: rsr a3, excvaddr # fault address
1528 _PGD_OFFSET(a0, a3, a1) 1528 _PGD_OFFSET(a0, a3, a1)
1529 l32i a0, a0, 0 # read pmdval 1529 l32i a0, a0, 0 # read pmdval
1530 beqz a0, 2f 1530 beqz a0, 2f
@@ -1542,7 +1542,7 @@ ENTRY(fast_second_level_miss)
1542 * pteval = ((pmdval - PAGE_OFFSET) & PAGE_MASK) | PAGE_DIRECTORY 1542 * pteval = ((pmdval - PAGE_OFFSET) & PAGE_MASK) | PAGE_DIRECTORY
1543 */ 1543 */
1544 1544
1545 movi a1, -PAGE_OFFSET 1545 movi a1, (-PAGE_OFFSET) & 0xffffffff
1546 add a0, a0, a1 # pmdval - PAGE_OFFSET 1546 add a0, a0, a1 # pmdval - PAGE_OFFSET
1547 extui a1, a0, 0, PAGE_SHIFT # ... & PAGE_MASK 1547 extui a1, a0, 0, PAGE_SHIFT # ... & PAGE_MASK
1548 xor a0, a0, a1 1548 xor a0, a0, a1
@@ -1561,7 +1561,7 @@ ENTRY(fast_second_level_miss)
1561 */ 1561 */
1562 1562
1563 extui a3, a3, 28, 2 # addr. bit 28 and 29 0,1,2,3 1563 extui a3, a3, 28, 2 # addr. bit 28 and 29 0,1,2,3
1564 rsr a1, PTEVADDR 1564 rsr a1, ptevaddr
1565 addx2 a3, a3, a3 # -> 0,3,6,9 1565 addx2 a3, a3, a3 # -> 0,3,6,9
1566 srli a1, a1, PAGE_SHIFT 1566 srli a1, a1, PAGE_SHIFT
1567 extui a3, a3, 2, 2 # -> 0,0,1,2 1567 extui a3, a3, 2, 2 # -> 0,0,1,2
@@ -1583,18 +1583,18 @@ ENTRY(fast_second_level_miss)
1583 l32i a0, a2, PT_AREG0 1583 l32i a0, a2, PT_AREG0
1584 l32i a1, a2, PT_AREG1 1584 l32i a1, a2, PT_AREG1
1585 l32i a2, a2, PT_DEPC 1585 l32i a2, a2, PT_DEPC
1586 xsr a3, EXCSAVE_1 1586 xsr a3, excsave1
1587 1587
1588 bgeui a2, VALID_DOUBLE_EXCEPTION_ADDRESS, 1f 1588 bgeui a2, VALID_DOUBLE_EXCEPTION_ADDRESS, 1f
1589 1589
1590 /* Restore excsave1 and return. */ 1590 /* Restore excsave1 and return. */
1591 1591
1592 rsr a2, DEPC 1592 rsr a2, depc
1593 rfe 1593 rfe
1594 1594
1595 /* Return from double exception. */ 1595 /* Return from double exception. */
1596 1596
15971: xsr a2, DEPC 15971: xsr a2, depc
1598 esync 1598 esync
1599 rfde 1599 rfde
1600 1600
@@ -1618,7 +1618,7 @@ ENTRY(fast_second_level_miss)
1618 /* Make sure the exception originated in the special functions */ 1618 /* Make sure the exception originated in the special functions */
1619 1619
1620 movi a0, __tlbtemp_mapping_start 1620 movi a0, __tlbtemp_mapping_start
1621 rsr a3, EPC_1 1621 rsr a3, epc1
1622 bltu a3, a0, 2f 1622 bltu a3, a0, 2f
1623 movi a0, __tlbtemp_mapping_end 1623 movi a0, __tlbtemp_mapping_end
1624 bgeu a3, a0, 2f 1624 bgeu a3, a0, 2f
@@ -1626,7 +1626,7 @@ ENTRY(fast_second_level_miss)
1626 /* Check if excvaddr was in one of the TLBTEMP_BASE areas. */ 1626 /* Check if excvaddr was in one of the TLBTEMP_BASE areas. */
1627 1627
1628 movi a3, TLBTEMP_BASE_1 1628 movi a3, TLBTEMP_BASE_1
1629 rsr a0, EXCVADDR 1629 rsr a0, excvaddr
1630 bltu a0, a3, 2f 1630 bltu a0, a3, 2f
1631 1631
1632 addi a1, a0, -(2 << (DCACHE_ALIAS_ORDER + PAGE_SHIFT)) 1632 addi a1, a0, -(2 << (DCACHE_ALIAS_ORDER + PAGE_SHIFT))
@@ -1635,7 +1635,7 @@ ENTRY(fast_second_level_miss)
1635 /* Check if we have to restore an ITLB mapping. */ 1635 /* Check if we have to restore an ITLB mapping. */
1636 1636
1637 movi a1, __tlbtemp_mapping_itlb 1637 movi a1, __tlbtemp_mapping_itlb
1638 rsr a3, EPC_1 1638 rsr a3, epc1
1639 sub a3, a3, a1 1639 sub a3, a3, a1
1640 1640
1641 /* Calculate VPN */ 1641 /* Calculate VPN */
@@ -1671,13 +1671,13 @@ ENTRY(fast_second_level_miss)
16712: /* Invalid PGD, default exception handling */ 16712: /* Invalid PGD, default exception handling */
1672 1672
1673 movi a3, exc_table 1673 movi a3, exc_table
1674 rsr a1, DEPC 1674 rsr a1, depc
1675 xsr a3, EXCSAVE_1 1675 xsr a3, excsave1
1676 s32i a1, a2, PT_AREG2 1676 s32i a1, a2, PT_AREG2
1677 s32i a3, a2, PT_AREG3 1677 s32i a3, a2, PT_AREG3
1678 mov a1, a2 1678 mov a1, a2
1679 1679
1680 rsr a2, PS 1680 rsr a2, ps
1681 bbsi.l a2, PS_UM_BIT, 1f 1681 bbsi.l a2, PS_UM_BIT, 1f
1682 j _kernel_exception 1682 j _kernel_exception
16831: j _user_exception 16831: j _user_exception
@@ -1712,7 +1712,7 @@ ENTRY(fast_store_prohibited)
1712 l32i a0, a1, TASK_MM # tsk->mm 1712 l32i a0, a1, TASK_MM # tsk->mm
1713 beqz a0, 9f 1713 beqz a0, 9f
1714 1714
17158: rsr a1, EXCVADDR # fault address 17158: rsr a1, excvaddr # fault address
1716 _PGD_OFFSET(a0, a1, a4) 1716 _PGD_OFFSET(a0, a1, a4)
1717 l32i a0, a0, 0 1717 l32i a0, a0, 0
1718 beqz a0, 2f 1718 beqz a0, 2f
@@ -1725,7 +1725,7 @@ ENTRY(fast_store_prohibited)
1725 1725
1726 movi a1, _PAGE_ACCESSED | _PAGE_DIRTY | _PAGE_HW_WRITE 1726 movi a1, _PAGE_ACCESSED | _PAGE_DIRTY | _PAGE_HW_WRITE
1727 or a4, a4, a1 1727 or a4, a4, a1
1728 rsr a1, EXCVADDR 1728 rsr a1, excvaddr
1729 s32i a4, a0, 0 1729 s32i a4, a0, 0
1730 1730
1731 /* We need to flush the cache if we have page coloring. */ 1731 /* We need to flush the cache if we have page coloring. */
@@ -1749,15 +1749,15 @@ ENTRY(fast_store_prohibited)
1749 1749
1750 /* Restore excsave1 and a3. */ 1750 /* Restore excsave1 and a3. */
1751 1751
1752 xsr a3, EXCSAVE_1 1752 xsr a3, excsave1
1753 bgeui a2, VALID_DOUBLE_EXCEPTION_ADDRESS, 1f 1753 bgeui a2, VALID_DOUBLE_EXCEPTION_ADDRESS, 1f
1754 1754
1755 rsr a2, DEPC 1755 rsr a2, depc
1756 rfe 1756 rfe
1757 1757
1758 /* Double exception. Restore FIXUP handler and return. */ 1758 /* Double exception. Restore FIXUP handler and return. */
1759 1759
17601: xsr a2, DEPC 17601: xsr a2, depc
1761 esync 1761 esync
1762 rfde 1762 rfde
1763 1763
@@ -1766,14 +1766,14 @@ ENTRY(fast_store_prohibited)
1766 1766
17672: /* If there was a problem, handle fault in C */ 17672: /* If there was a problem, handle fault in C */
1768 1768
1769 rsr a4, DEPC # still holds a2 1769 rsr a4, depc # still holds a2
1770 xsr a3, EXCSAVE_1 1770 xsr a3, excsave1
1771 s32i a4, a2, PT_AREG2 1771 s32i a4, a2, PT_AREG2
1772 s32i a3, a2, PT_AREG3 1772 s32i a3, a2, PT_AREG3
1773 l32i a4, a2, PT_AREG4 1773 l32i a4, a2, PT_AREG4
1774 mov a1, a2 1774 mov a1, a2
1775 1775
1776 rsr a2, PS 1776 rsr a2, ps
1777 bbsi.l a2, PS_UM_BIT, 1f 1777 bbsi.l a2, PS_UM_BIT, 1f
1778 j _kernel_exception 1778 j _kernel_exception
17791: j _user_exception 17791: j _user_exception
@@ -1833,50 +1833,6 @@ ENTRY(system_call)
1833 1833
1834 1834
1835/* 1835/*
1836 * Create a kernel thread
1837 *
1838 * int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags)
1839 * a2 a2 a3 a4
1840 */
1841
1842ENTRY(kernel_thread)
1843 entry a1, 16
1844
1845 mov a5, a2 # preserve fn over syscall
1846 mov a7, a3 # preserve args over syscall
1847
1848 movi a3, _CLONE_VM | _CLONE_UNTRACED
1849 movi a2, __NR_clone
1850 or a6, a4, a3 # arg0: flags
1851 mov a3, a1 # arg1: sp
1852 syscall
1853
1854 beq a3, a1, 1f # branch if parent
1855 mov a6, a7 # args
1856 callx4 a5 # fn(args)
1857
1858 movi a2, __NR_exit
1859 syscall # return value of fn(args) still in a6
1860
18611: retw
1862
1863/*
1864 * Do a system call from kernel instead of calling sys_execve, so we end up
1865 * with proper pt_regs.
1866 *
1867 * int kernel_execve(const char *fname, char *const argv[], charg *const envp[])
1868 * a2 a2 a3 a4
1869 */
1870
1871ENTRY(kernel_execve)
1872 entry a1, 16
1873 mov a6, a2 # arg0 is in a6
1874 movi a2, __NR_execve
1875 syscall
1876
1877 retw
1878
1879/*
1880 * Task switch. 1836 * Task switch.
1881 * 1837 *
1882 * struct task* _switch_to (struct task* prev, struct task* next) 1838 * struct task* _switch_to (struct task* prev, struct task* next)
@@ -1901,8 +1857,8 @@ ENTRY(_switch_to)
1901 /* Disable ints while we manipulate the stack pointer. */ 1857 /* Disable ints while we manipulate the stack pointer. */
1902 1858
1903 movi a14, (1 << PS_EXCM_BIT) | LOCKLEVEL 1859 movi a14, (1 << PS_EXCM_BIT) | LOCKLEVEL
1904 xsr a14, PS 1860 xsr a14, ps
1905 rsr a3, EXCSAVE_1 1861 rsr a3, excsave1
1906 rsync 1862 rsync
1907 s32i a3, a3, EXC_TABLE_FIXUP /* enter critical section */ 1863 s32i a3, a3, EXC_TABLE_FIXUP /* enter critical section */
1908 1864
@@ -1910,7 +1866,7 @@ ENTRY(_switch_to)
1910 1866
1911#if (XTENSA_HAVE_COPROCESSORS || XTENSA_HAVE_IO_PORTS) 1867#if (XTENSA_HAVE_COPROCESSORS || XTENSA_HAVE_IO_PORTS)
1912 l32i a3, a5, THREAD_CPENABLE 1868 l32i a3, a5, THREAD_CPENABLE
1913 xsr a3, CPENABLE 1869 xsr a3, cpenable
1914 s32i a3, a4, THREAD_CPENABLE 1870 s32i a3, a4, THREAD_CPENABLE
1915#endif 1871#endif
1916 1872
@@ -1924,7 +1880,7 @@ ENTRY(_switch_to)
1924 * we return from kernel space. 1880 * we return from kernel space.
1925 */ 1881 */
1926 1882
1927 rsr a3, EXCSAVE_1 # exc_table 1883 rsr a3, excsave1 # exc_table
1928 movi a6, 0 1884 movi a6, 0
1929 addi a7, a5, PT_REGS_OFFSET 1885 addi a7, a5, PT_REGS_OFFSET
1930 s32i a6, a3, EXC_TABLE_FIXUP 1886 s32i a6, a3, EXC_TABLE_FIXUP
@@ -1937,7 +1893,7 @@ ENTRY(_switch_to)
1937 1893
1938 load_xtregs_user a5 a6 a8 a9 a10 a11 THREAD_XTREGS_USER 1894 load_xtregs_user a5 a6 a8 a9 a10 a11 THREAD_XTREGS_USER
1939 1895
1940 wsr a14, PS 1896 wsr a14, ps
1941 mov a2, a12 # return 'prev' 1897 mov a2, a12 # return 'prev'
1942 rsync 1898 rsync
1943 1899
@@ -1958,3 +1914,16 @@ ENTRY(ret_from_fork)
1958 1914
1959 j common_exception_return 1915 j common_exception_return
1960 1916
1917/*
1918 * Kernel thread creation helper
1919 * On entry, set up by copy_thread: a2 = thread_fn, a3 = thread_fn arg
1920 * left from _switch_to: a6 = prev
1921 */
1922ENTRY(ret_from_kernel_thread)
1923
1924 call4 schedule_tail
1925 mov a6, a3
1926 callx4 a2
1927 j common_exception_return
1928
1929ENDPROC(ret_from_kernel_thread)
diff --git a/arch/xtensa/kernel/head.S b/arch/xtensa/kernel/head.S
index 3ef91a73652..bdc50788f35 100644
--- a/arch/xtensa/kernel/head.S
+++ b/arch/xtensa/kernel/head.S
@@ -61,18 +61,18 @@ _startup:
61 /* Disable interrupts and exceptions. */ 61 /* Disable interrupts and exceptions. */
62 62
63 movi a0, LOCKLEVEL 63 movi a0, LOCKLEVEL
64 wsr a0, PS 64 wsr a0, ps
65 65
66 /* Preserve the pointer to the boot parameter list in EXCSAVE_1 */ 66 /* Preserve the pointer to the boot parameter list in EXCSAVE_1 */
67 67
68 wsr a2, EXCSAVE_1 68 wsr a2, excsave1
69 69
70 /* Start with a fresh windowbase and windowstart. */ 70 /* Start with a fresh windowbase and windowstart. */
71 71
72 movi a1, 1 72 movi a1, 1
73 movi a0, 0 73 movi a0, 0
74 wsr a1, WINDOWSTART 74 wsr a1, windowstart
75 wsr a0, WINDOWBASE 75 wsr a0, windowbase
76 rsync 76 rsync
77 77
78 /* Set a0 to 0 for the remaining initialization. */ 78 /* Set a0 to 0 for the remaining initialization. */
@@ -82,46 +82,46 @@ _startup:
82 /* Clear debugging registers. */ 82 /* Clear debugging registers. */
83 83
84#if XCHAL_HAVE_DEBUG 84#if XCHAL_HAVE_DEBUG
85 wsr a0, IBREAKENABLE 85 wsr a0, ibreakenable
86 wsr a0, ICOUNT 86 wsr a0, icount
87 movi a1, 15 87 movi a1, 15
88 wsr a0, ICOUNTLEVEL 88 wsr a0, icountlevel
89 89
90 .set _index, 0 90 .set _index, 0
91 .rept XCHAL_NUM_DBREAK - 1 91 .rept XCHAL_NUM_DBREAK - 1
92 wsr a0, DBREAKC + _index 92 wsr a0, SREG_DBREAKC + _index
93 .set _index, _index + 1 93 .set _index, _index + 1
94 .endr 94 .endr
95#endif 95#endif
96 96
97 /* Clear CCOUNT (not really necessary, but nice) */ 97 /* Clear CCOUNT (not really necessary, but nice) */
98 98
99 wsr a0, CCOUNT # not really necessary, but nice 99 wsr a0, ccount # not really necessary, but nice
100 100
101 /* Disable zero-loops. */ 101 /* Disable zero-loops. */
102 102
103#if XCHAL_HAVE_LOOPS 103#if XCHAL_HAVE_LOOPS
104 wsr a0, LCOUNT 104 wsr a0, lcount
105#endif 105#endif
106 106
107 /* Disable all timers. */ 107 /* Disable all timers. */
108 108
109 .set _index, 0 109 .set _index, 0
110 .rept XCHAL_NUM_TIMERS - 1 110 .rept XCHAL_NUM_TIMERS - 1
111 wsr a0, CCOMPARE + _index 111 wsr a0, SREG_CCOMPARE + _index
112 .set _index, _index + 1 112 .set _index, _index + 1
113 .endr 113 .endr
114 114
115 /* Interrupt initialization. */ 115 /* Interrupt initialization. */
116 116
117 movi a2, XCHAL_INTTYPE_MASK_SOFTWARE | XCHAL_INTTYPE_MASK_EXTERN_EDGE 117 movi a2, XCHAL_INTTYPE_MASK_SOFTWARE | XCHAL_INTTYPE_MASK_EXTERN_EDGE
118 wsr a0, INTENABLE 118 wsr a0, intenable
119 wsr a2, INTCLEAR 119 wsr a2, intclear
120 120
121 /* Disable coprocessors. */ 121 /* Disable coprocessors. */
122 122
123#if XCHAL_CP_NUM > 0 123#if XCHAL_CP_NUM > 0
124 wsr a0, CPENABLE 124 wsr a0, cpenable
125#endif 125#endif
126 126
127 /* Set PS.INTLEVEL=1, PS.WOE=0, kernel stack, PS.EXCM=0 127 /* Set PS.INTLEVEL=1, PS.WOE=0, kernel stack, PS.EXCM=0
@@ -132,7 +132,7 @@ _startup:
132 */ 132 */
133 133
134 movi a1, 1 134 movi a1, 1
135 wsr a1, PS 135 wsr a1, ps
136 rsync 136 rsync
137 137
138 /* Initialize the caches. 138 /* Initialize the caches.
@@ -206,18 +206,18 @@ _startup:
206 addi a1, a1, KERNEL_STACK_SIZE 206 addi a1, a1, KERNEL_STACK_SIZE
207 207
208 movi a2, 0x00040001 # WOE=1, INTLEVEL=1, UM=0 208 movi a2, 0x00040001 # WOE=1, INTLEVEL=1, UM=0
209 wsr a2, PS # (enable reg-windows; progmode stack) 209 wsr a2, ps # (enable reg-windows; progmode stack)
210 rsync 210 rsync
211 211
212 /* Set up EXCSAVE[DEBUGLEVEL] to point to the Debug Exception Handler.*/ 212 /* Set up EXCSAVE[DEBUGLEVEL] to point to the Debug Exception Handler.*/
213 213
214 movi a2, debug_exception 214 movi a2, debug_exception
215 wsr a2, EXCSAVE + XCHAL_DEBUGLEVEL 215 wsr a2, SREG_EXCSAVE + XCHAL_DEBUGLEVEL
216 216
217 /* Set up EXCSAVE[1] to point to the exc_table. */ 217 /* Set up EXCSAVE[1] to point to the exc_table. */
218 218
219 movi a6, exc_table 219 movi a6, exc_table
220 xsr a6, EXCSAVE_1 220 xsr a6, excsave1
221 221
222 /* init_arch kick-starts the linux kernel */ 222 /* init_arch kick-starts the linux kernel */
223 223
diff --git a/arch/xtensa/kernel/irq.c b/arch/xtensa/kernel/irq.c
index 98e77c3ef1c..a6ce3e56373 100644
--- a/arch/xtensa/kernel/irq.c
+++ b/arch/xtensa/kernel/irq.c
@@ -72,13 +72,13 @@ int arch_show_interrupts(struct seq_file *p, int prec)
72static void xtensa_irq_mask(struct irq_data *d) 72static void xtensa_irq_mask(struct irq_data *d)
73{ 73{
74 cached_irq_mask &= ~(1 << d->irq); 74 cached_irq_mask &= ~(1 << d->irq);
75 set_sr (cached_irq_mask, INTENABLE); 75 set_sr (cached_irq_mask, intenable);
76} 76}
77 77
78static void xtensa_irq_unmask(struct irq_data *d) 78static void xtensa_irq_unmask(struct irq_data *d)
79{ 79{
80 cached_irq_mask |= 1 << d->irq; 80 cached_irq_mask |= 1 << d->irq;
81 set_sr (cached_irq_mask, INTENABLE); 81 set_sr (cached_irq_mask, intenable);
82} 82}
83 83
84static void xtensa_irq_enable(struct irq_data *d) 84static void xtensa_irq_enable(struct irq_data *d)
@@ -95,7 +95,7 @@ static void xtensa_irq_disable(struct irq_data *d)
95 95
96static void xtensa_irq_ack(struct irq_data *d) 96static void xtensa_irq_ack(struct irq_data *d)
97{ 97{
98 set_sr(1 << d->irq, INTCLEAR); 98 set_sr(1 << d->irq, intclear);
99} 99}
100 100
101static int xtensa_irq_retrigger(struct irq_data *d) 101static int xtensa_irq_retrigger(struct irq_data *d)
diff --git a/arch/xtensa/kernel/process.c b/arch/xtensa/kernel/process.c
index bc020825cce..09ae7bfab9a 100644
--- a/arch/xtensa/kernel/process.c
+++ b/arch/xtensa/kernel/process.c
@@ -45,6 +45,7 @@
45#include <asm/regs.h> 45#include <asm/regs.h>
46 46
47extern void ret_from_fork(void); 47extern void ret_from_fork(void);
48extern void ret_from_kernel_thread(void);
48 49
49struct task_struct *current_set[NR_CPUS] = {&init_task, }; 50struct task_struct *current_set[NR_CPUS] = {&init_task, };
50 51
@@ -158,64 +159,123 @@ int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src)
158/* 159/*
159 * Copy thread. 160 * Copy thread.
160 * 161 *
162 * There are two modes in which this function is called:
163 * 1) Userspace thread creation,
164 * regs != NULL, usp_thread_fn is userspace stack pointer.
165 * It is expected to copy parent regs (in case CLONE_VM is not set
166 * in the clone_flags) and set up passed usp in the childregs.
167 * 2) Kernel thread creation,
168 * regs == NULL, usp_thread_fn is the function to run in the new thread
169 * and thread_fn_arg is its parameter.
170 * childregs are not used for the kernel threads.
171 *
161 * The stack layout for the new thread looks like this: 172 * The stack layout for the new thread looks like this:
162 * 173 *
163 * +------------------------+ <- sp in childregs (= tos) 174 * +------------------------+
164 * | childregs | 175 * | childregs |
165 * +------------------------+ <- thread.sp = sp in dummy-frame 176 * +------------------------+ <- thread.sp = sp in dummy-frame
166 * | dummy-frame | (saved in dummy-frame spill-area) 177 * | dummy-frame | (saved in dummy-frame spill-area)
167 * +------------------------+ 178 * +------------------------+
168 * 179 *
169 * We create a dummy frame to return to ret_from_fork: 180 * We create a dummy frame to return to either ret_from_fork or
170 * a0 points to ret_from_fork (simulating a call4) 181 * ret_from_kernel_thread:
182 * a0 points to ret_from_fork/ret_from_kernel_thread (simulating a call4)
171 * sp points to itself (thread.sp) 183 * sp points to itself (thread.sp)
172 * a2, a3 are unused. 184 * a2, a3 are unused for userspace threads,
185 * a2 points to thread_fn, a3 holds thread_fn arg for kernel threads.
173 * 186 *
174 * Note: This is a pristine frame, so we don't need any spill region on top of 187 * Note: This is a pristine frame, so we don't need any spill region on top of
175 * childregs. 188 * childregs.
189 *
190 * The fun part: if we're keeping the same VM (i.e. cloning a thread,
191 * not an entire process), we're normally given a new usp, and we CANNOT share
192 * any live address register windows. If we just copy those live frames over,
193 * the two threads (parent and child) will overflow the same frames onto the
194 * parent stack at different times, likely corrupting the parent stack (esp.
195 * if the parent returns from functions that called clone() and calls new
196 * ones, before the child overflows its now old copies of its parent windows).
197 * One solution is to spill windows to the parent stack, but that's fairly
198 * involved. Much simpler to just not copy those live frames across.
176 */ 199 */
177 200
178int copy_thread(unsigned long clone_flags, unsigned long usp, 201int copy_thread(unsigned long clone_flags, unsigned long usp_thread_fn,
179 unsigned long unused, 202 unsigned long thread_fn_arg,
180 struct task_struct * p, struct pt_regs * regs) 203 struct task_struct *p, struct pt_regs *unused)
181{ 204{
182 struct pt_regs *childregs; 205 struct pt_regs *childregs = task_pt_regs(p);
183 struct thread_info *ti;
184 unsigned long tos;
185 int user_mode = user_mode(regs);
186
187 /* Set up new TSS. */
188 tos = (unsigned long)task_stack_page(p) + THREAD_SIZE;
189 if (user_mode)
190 childregs = (struct pt_regs*)(tos - PT_USER_SIZE);
191 else
192 childregs = (struct pt_regs*)tos - 1;
193 206
194 *childregs = *regs; 207#if (XTENSA_HAVE_COPROCESSORS || XTENSA_HAVE_IO_PORTS)
208 struct thread_info *ti;
209#endif
195 210
196 /* Create a call4 dummy-frame: a0 = 0, a1 = childregs. */ 211 /* Create a call4 dummy-frame: a0 = 0, a1 = childregs. */
197 *((int*)childregs - 3) = (unsigned long)childregs; 212 *((int*)childregs - 3) = (unsigned long)childregs;
198 *((int*)childregs - 4) = 0; 213 *((int*)childregs - 4) = 0;
199 214
200 childregs->areg[1] = tos;
201 childregs->areg[2] = 0;
202 p->set_child_tid = p->clear_child_tid = NULL;
203 p->thread.ra = MAKE_RA_FOR_CALL((unsigned long)ret_from_fork, 0x1);
204 p->thread.sp = (unsigned long)childregs; 215 p->thread.sp = (unsigned long)childregs;
205 216
206 if (user_mode(regs)) { 217 if (!(p->flags & PF_KTHREAD)) {
218 struct pt_regs *regs = current_pt_regs();
219 unsigned long usp = usp_thread_fn ?
220 usp_thread_fn : regs->areg[1];
207 221
208 int len = childregs->wmask & ~0xf; 222 p->thread.ra = MAKE_RA_FOR_CALL(
223 (unsigned long)ret_from_fork, 0x1);
224
225 /* This does not copy all the regs.
226 * In a bout of brilliance or madness,
227 * ARs beyond a0-a15 exist past the end of the struct.
228 */
229 *childregs = *regs;
209 childregs->areg[1] = usp; 230 childregs->areg[1] = usp;
210 memcpy(&childregs->areg[XCHAL_NUM_AREGS - len/4], 231 childregs->areg[2] = 0;
211 &regs->areg[XCHAL_NUM_AREGS - len/4], len); 232
233 /* When sharing memory with the parent thread, the child
234 usually starts on a pristine stack, so we have to reset
235 windowbase, windowstart and wmask.
236 (Note that such a new thread is required to always create
237 an initial call4 frame)
238 The exception is vfork, where the new thread continues to
239 run on the parent's stack until it calls execve. This could
240 be a call8 or call12, which requires a legal stack frame
241 of the previous caller for the overflow handlers to work.
242 (Note that it's always legal to overflow live registers).
243 In this case, ensure to spill at least the stack pointer
244 of that frame. */
245
246 if (clone_flags & CLONE_VM) {
247 /* check that caller window is live and same stack */
248 int len = childregs->wmask & ~0xf;
249 if (regs->areg[1] == usp && len != 0) {
250 int callinc = (regs->areg[0] >> 30) & 3;
251 int caller_ars = XCHAL_NUM_AREGS - callinc * 4;
252 put_user(regs->areg[caller_ars+1],
253 (unsigned __user*)(usp - 12));
254 }
255 childregs->wmask = 1;
256 childregs->windowstart = 1;
257 childregs->windowbase = 0;
258 } else {
259 int len = childregs->wmask & ~0xf;
260 memcpy(&childregs->areg[XCHAL_NUM_AREGS - len/4],
261 &regs->areg[XCHAL_NUM_AREGS - len/4], len);
262 }
212// FIXME: we need to set THREADPTR in thread_info... 263// FIXME: we need to set THREADPTR in thread_info...
213 if (clone_flags & CLONE_SETTLS) 264 if (clone_flags & CLONE_SETTLS)
214 childregs->areg[2] = childregs->areg[6]; 265 childregs->areg[2] = childregs->areg[6];
215
216 } else { 266 } else {
217 /* In kernel space, we start a new thread with a new stack. */ 267 p->thread.ra = MAKE_RA_FOR_CALL(
218 childregs->wmask = 1; 268 (unsigned long)ret_from_kernel_thread, 1);
269
270 /* pass parameters to ret_from_kernel_thread:
271 * a2 = thread_fn, a3 = thread_fn arg
272 */
273 *((int *)childregs - 1) = thread_fn_arg;
274 *((int *)childregs - 2) = usp_thread_fn;
275
276 /* Childregs are only used when we're going to userspace
277 * in which case start_thread will set them up.
278 */
219 } 279 }
220 280
221#if (XTENSA_HAVE_COPROCESSORS || XTENSA_HAVE_IO_PORTS) 281#if (XTENSA_HAVE_COPROCESSORS || XTENSA_HAVE_IO_PORTS)
@@ -311,32 +371,5 @@ long xtensa_clone(unsigned long clone_flags, unsigned long newsp,
311 void __user *child_tid, long a5, 371 void __user *child_tid, long a5,
312 struct pt_regs *regs) 372 struct pt_regs *regs)
313{ 373{
314 if (!newsp)
315 newsp = regs->areg[1];
316 return do_fork(clone_flags, newsp, regs, 0, parent_tid, child_tid); 374 return do_fork(clone_flags, newsp, regs, 0, parent_tid, child_tid);
317} 375}
318
319/*
320 * xtensa_execve() executes a new program.
321 */
322
323asmlinkage
324long xtensa_execve(const char __user *name,
325 const char __user *const __user *argv,
326 const char __user *const __user *envp,
327 long a3, long a4, long a5,
328 struct pt_regs *regs)
329{
330 long error;
331 struct filename *filename;
332
333 filename = getname(name);
334 error = PTR_ERR(filename);
335 if (IS_ERR(filename))
336 goto out;
337 error = do_execve(filename->name, argv, envp, regs);
338 putname(filename);
339out:
340 return error;
341}
342
diff --git a/arch/xtensa/kernel/setup.c b/arch/xtensa/kernel/setup.c
index 270360d9806..b237988ba6d 100644
--- a/arch/xtensa/kernel/setup.c
+++ b/arch/xtensa/kernel/setup.c
@@ -100,7 +100,7 @@ typedef struct tagtable {
100} tagtable_t; 100} tagtable_t;
101 101
102#define __tagtable(tag, fn) static tagtable_t __tagtable_##fn \ 102#define __tagtable(tag, fn) static tagtable_t __tagtable_##fn \
103 __attribute__((unused, __section__(".taglist"))) = { tag, fn } 103 __attribute__((used, section(".taglist"))) = { tag, fn }
104 104
105/* parse current tag */ 105/* parse current tag */
106 106
@@ -120,7 +120,7 @@ static int __init parse_tag_mem(const bp_tag_t *tag)
120 } 120 }
121 sysmem.bank[sysmem.nr_banks].type = mi->type; 121 sysmem.bank[sysmem.nr_banks].type = mi->type;
122 sysmem.bank[sysmem.nr_banks].start = PAGE_ALIGN(mi->start); 122 sysmem.bank[sysmem.nr_banks].start = PAGE_ALIGN(mi->start);
123 sysmem.bank[sysmem.nr_banks].end = mi->end & PAGE_SIZE; 123 sysmem.bank[sysmem.nr_banks].end = mi->end & PAGE_MASK;
124 sysmem.nr_banks++; 124 sysmem.nr_banks++;
125 125
126 return 0; 126 return 0;
diff --git a/arch/xtensa/kernel/syscall.c b/arch/xtensa/kernel/syscall.c
index 05b3f093d5d..5702065f472 100644
--- a/arch/xtensa/kernel/syscall.c
+++ b/arch/xtensa/kernel/syscall.c
@@ -32,11 +32,8 @@ typedef void (*syscall_t)(void);
32syscall_t sys_call_table[__NR_syscall_count] /* FIXME __cacheline_aligned */= { 32syscall_t sys_call_table[__NR_syscall_count] /* FIXME __cacheline_aligned */= {
33 [0 ... __NR_syscall_count - 1] = (syscall_t)&sys_ni_syscall, 33 [0 ... __NR_syscall_count - 1] = (syscall_t)&sys_ni_syscall,
34 34
35#undef __SYSCALL
36#define __SYSCALL(nr,symbol,nargs) [ nr ] = (syscall_t)symbol, 35#define __SYSCALL(nr,symbol,nargs) [ nr ] = (syscall_t)symbol,
37#undef _XTENSA_UNISTD_H 36#include <uapi/asm/unistd.h>
38#undef __KERNEL_SYSCALLS__
39#include <asm/unistd.h>
40}; 37};
41 38
42asmlinkage long xtensa_shmat(int shmid, char __user *shmaddr, int shmflg) 39asmlinkage long xtensa_shmat(int shmid, char __user *shmaddr, int shmflg)
@@ -50,7 +47,8 @@ asmlinkage long xtensa_shmat(int shmid, char __user *shmaddr, int shmflg)
50 return (long)ret; 47 return (long)ret;
51} 48}
52 49
53asmlinkage long xtensa_fadvise64_64(int fd, int advice, unsigned long long offset, unsigned long long len) 50asmlinkage long xtensa_fadvise64_64(int fd, int advice,
51 unsigned long long offset, unsigned long long len)
54{ 52{
55 return sys_fadvise64_64(fd, offset, len, advice); 53 return sys_fadvise64_64(fd, offset, len, advice);
56} 54}
diff --git a/arch/xtensa/kernel/traps.c b/arch/xtensa/kernel/traps.c
index bc1e14cf936..5caf2b64d43 100644
--- a/arch/xtensa/kernel/traps.c
+++ b/arch/xtensa/kernel/traps.c
@@ -97,7 +97,7 @@ static dispatch_init_table_t __initdata dispatch_init_table[] = {
97/* EXCCAUSE_INTEGER_DIVIDE_BY_ZERO unhandled */ 97/* EXCCAUSE_INTEGER_DIVIDE_BY_ZERO unhandled */
98/* EXCCAUSE_PRIVILEGED unhandled */ 98/* EXCCAUSE_PRIVILEGED unhandled */
99#if XCHAL_UNALIGNED_LOAD_EXCEPTION || XCHAL_UNALIGNED_STORE_EXCEPTION 99#if XCHAL_UNALIGNED_LOAD_EXCEPTION || XCHAL_UNALIGNED_STORE_EXCEPTION
100#ifdef CONFIG_UNALIGNED_USER 100#ifdef CONFIG_XTENSA_UNALIGNED_USER
101{ EXCCAUSE_UNALIGNED, USER, fast_unaligned }, 101{ EXCCAUSE_UNALIGNED, USER, fast_unaligned },
102#else 102#else
103{ EXCCAUSE_UNALIGNED, 0, do_unaligned_user }, 103{ EXCCAUSE_UNALIGNED, 0, do_unaligned_user },
@@ -202,8 +202,8 @@ extern void do_IRQ(int, struct pt_regs *);
202 202
203void do_interrupt (struct pt_regs *regs) 203void do_interrupt (struct pt_regs *regs)
204{ 204{
205 unsigned long intread = get_sr (INTREAD); 205 unsigned long intread = get_sr (interrupt);
206 unsigned long intenable = get_sr (INTENABLE); 206 unsigned long intenable = get_sr (intenable);
207 int i, mask; 207 int i, mask;
208 208
209 /* Handle all interrupts (no priorities). 209 /* Handle all interrupts (no priorities).
@@ -213,7 +213,7 @@ void do_interrupt (struct pt_regs *regs)
213 213
214 for (i=0, mask = 1; i < XCHAL_NUM_INTERRUPTS; i++, mask <<= 1) { 214 for (i=0, mask = 1; i < XCHAL_NUM_INTERRUPTS; i++, mask <<= 1) {
215 if (mask & (intread & intenable)) { 215 if (mask & (intread & intenable)) {
216 set_sr (mask, INTCLEAR); 216 set_sr (mask, intclear);
217 do_IRQ (i,regs); 217 do_IRQ (i,regs);
218 } 218 }
219 } 219 }
@@ -244,7 +244,7 @@ do_illegal_instruction(struct pt_regs *regs)
244 */ 244 */
245 245
246#if XCHAL_UNALIGNED_LOAD_EXCEPTION || XCHAL_UNALIGNED_STORE_EXCEPTION 246#if XCHAL_UNALIGNED_LOAD_EXCEPTION || XCHAL_UNALIGNED_STORE_EXCEPTION
247#ifndef CONFIG_UNALIGNED_USER 247#ifndef CONFIG_XTENSA_UNALIGNED_USER
248void 248void
249do_unaligned_user (struct pt_regs *regs) 249do_unaligned_user (struct pt_regs *regs)
250{ 250{
@@ -339,7 +339,7 @@ void __init trap_init(void)
339 /* Initialize EXCSAVE_1 to hold the address of the exception table. */ 339 /* Initialize EXCSAVE_1 to hold the address of the exception table. */
340 340
341 i = (unsigned long)exc_table; 341 i = (unsigned long)exc_table;
342 __asm__ __volatile__("wsr %0, "__stringify(EXCSAVE_1)"\n" : : "a" (i)); 342 __asm__ __volatile__("wsr %0, excsave1\n" : : "a" (i));
343} 343}
344 344
345/* 345/*
@@ -386,16 +386,16 @@ static inline void spill_registers(void)
386 unsigned int a0, ps; 386 unsigned int a0, ps;
387 387
388 __asm__ __volatile__ ( 388 __asm__ __volatile__ (
389 "movi a14," __stringify (PS_EXCM_BIT) " | 1\n\t" 389 "movi a14, " __stringify(PS_EXCM_BIT | 1) "\n\t"
390 "mov a12, a0\n\t" 390 "mov a12, a0\n\t"
391 "rsr a13," __stringify(SAR) "\n\t" 391 "rsr a13, sar\n\t"
392 "xsr a14," __stringify(PS) "\n\t" 392 "xsr a14, ps\n\t"
393 "movi a0, _spill_registers\n\t" 393 "movi a0, _spill_registers\n\t"
394 "rsync\n\t" 394 "rsync\n\t"
395 "callx0 a0\n\t" 395 "callx0 a0\n\t"
396 "mov a0, a12\n\t" 396 "mov a0, a12\n\t"
397 "wsr a13," __stringify(SAR) "\n\t" 397 "wsr a13, sar\n\t"
398 "wsr a14," __stringify(PS) "\n\t" 398 "wsr a14, ps\n\t"
399 :: "a" (&a0), "a" (&ps) 399 :: "a" (&a0), "a" (&ps)
400 : "a2", "a3", "a4", "a7", "a11", "a12", "a13", "a14", "a15", "memory"); 400 : "a2", "a3", "a4", "a7", "a11", "a12", "a13", "a14", "a15", "memory");
401} 401}
diff --git a/arch/xtensa/kernel/vectors.S b/arch/xtensa/kernel/vectors.S
index 70066e3582d..4462c1e595c 100644
--- a/arch/xtensa/kernel/vectors.S
+++ b/arch/xtensa/kernel/vectors.S
@@ -69,11 +69,11 @@
69 69
70ENTRY(_UserExceptionVector) 70ENTRY(_UserExceptionVector)
71 71
72 xsr a3, EXCSAVE_1 # save a3 and get dispatch table 72 xsr a3, excsave1 # save a3 and get dispatch table
73 wsr a2, DEPC # save a2 73 wsr a2, depc # save a2
74 l32i a2, a3, EXC_TABLE_KSTK # load kernel stack to a2 74 l32i a2, a3, EXC_TABLE_KSTK # load kernel stack to a2
75 s32i a0, a2, PT_AREG0 # save a0 to ESF 75 s32i a0, a2, PT_AREG0 # save a0 to ESF
76 rsr a0, EXCCAUSE # retrieve exception cause 76 rsr a0, exccause # retrieve exception cause
77 s32i a0, a2, PT_DEPC # mark it as a regular exception 77 s32i a0, a2, PT_DEPC # mark it as a regular exception
78 addx4 a0, a0, a3 # find entry in table 78 addx4 a0, a0, a3 # find entry in table
79 l32i a0, a0, EXC_TABLE_FAST_USER # load handler 79 l32i a0, a0, EXC_TABLE_FAST_USER # load handler
@@ -93,11 +93,11 @@ ENTRY(_UserExceptionVector)
93 93
94ENTRY(_KernelExceptionVector) 94ENTRY(_KernelExceptionVector)
95 95
96 xsr a3, EXCSAVE_1 # save a3, and get dispatch table 96 xsr a3, excsave1 # save a3, and get dispatch table
97 wsr a2, DEPC # save a2 97 wsr a2, depc # save a2
98 addi a2, a1, -16-PT_SIZE # adjust stack pointer 98 addi a2, a1, -16-PT_SIZE # adjust stack pointer
99 s32i a0, a2, PT_AREG0 # save a0 to ESF 99 s32i a0, a2, PT_AREG0 # save a0 to ESF
100 rsr a0, EXCCAUSE # retrieve exception cause 100 rsr a0, exccause # retrieve exception cause
101 s32i a0, a2, PT_DEPC # mark it as a regular exception 101 s32i a0, a2, PT_DEPC # mark it as a regular exception
102 addx4 a0, a0, a3 # find entry in table 102 addx4 a0, a0, a3 # find entry in table
103 l32i a0, a0, EXC_TABLE_FAST_KERNEL # load handler address 103 l32i a0, a0, EXC_TABLE_FAST_KERNEL # load handler address
@@ -205,17 +205,17 @@ ENTRY(_DoubleExceptionVector)
205 205
206 /* Deliberately destroy excsave (don't assume it's value was valid). */ 206 /* Deliberately destroy excsave (don't assume it's value was valid). */
207 207
208 wsr a3, EXCSAVE_1 # save a3 208 wsr a3, excsave1 # save a3
209 209
210 /* Check for kernel double exception (usually fatal). */ 210 /* Check for kernel double exception (usually fatal). */
211 211
212 rsr a3, PS 212 rsr a3, ps
213 _bbci.l a3, PS_UM_BIT, .Lksp 213 _bbci.l a3, PS_UM_BIT, .Lksp
214 214
215 /* Check if we are currently handling a window exception. */ 215 /* Check if we are currently handling a window exception. */
216 /* Note: We don't need to indicate that we enter a critical section. */ 216 /* Note: We don't need to indicate that we enter a critical section. */
217 217
218 xsr a0, DEPC # get DEPC, save a0 218 xsr a0, depc # get DEPC, save a0
219 219
220 movi a3, XCHAL_WINDOW_VECTORS_VADDR 220 movi a3, XCHAL_WINDOW_VECTORS_VADDR
221 _bltu a0, a3, .Lfixup 221 _bltu a0, a3, .Lfixup
@@ -243,21 +243,21 @@ ENTRY(_DoubleExceptionVector)
243 * Note: We can trash the current window frame (a0...a3) and depc! 243 * Note: We can trash the current window frame (a0...a3) and depc!
244 */ 244 */
245 245
246 wsr a2, DEPC # save stack pointer temporarily 246 wsr a2, depc # save stack pointer temporarily
247 rsr a0, PS 247 rsr a0, ps
248 extui a0, a0, PS_OWB_SHIFT, 4 248 extui a0, a0, PS_OWB_SHIFT, 4
249 wsr a0, WINDOWBASE 249 wsr a0, windowbase
250 rsync 250 rsync
251 251
252 /* We are now in the previous window frame. Save registers again. */ 252 /* We are now in the previous window frame. Save registers again. */
253 253
254 xsr a2, DEPC # save a2 and get stack pointer 254 xsr a2, depc # save a2 and get stack pointer
255 s32i a0, a2, PT_AREG0 255 s32i a0, a2, PT_AREG0
256 256
257 wsr a3, EXCSAVE_1 # save a3 257 wsr a3, excsave1 # save a3
258 movi a3, exc_table 258 movi a3, exc_table
259 259
260 rsr a0, EXCCAUSE 260 rsr a0, exccause
261 s32i a0, a2, PT_DEPC # mark it as a regular exception 261 s32i a0, a2, PT_DEPC # mark it as a regular exception
262 addx4 a0, a0, a3 262 addx4 a0, a0, a3
263 l32i a0, a0, EXC_TABLE_FAST_USER 263 l32i a0, a0, EXC_TABLE_FAST_USER
@@ -290,14 +290,14 @@ ENTRY(_DoubleExceptionVector)
290 290
291 /* a0: depc, a1: a1, a2: kstk, a3: a2, depc: a0, excsave: a3 */ 291 /* a0: depc, a1: a1, a2: kstk, a3: a2, depc: a0, excsave: a3 */
292 292
293 xsr a3, DEPC 293 xsr a3, depc
294 s32i a0, a2, PT_DEPC 294 s32i a0, a2, PT_DEPC
295 s32i a3, a2, PT_AREG0 295 s32i a3, a2, PT_AREG0
296 296
297 /* a0: avail, a1: a1, a2: kstk, a3: avail, depc: a2, excsave: a3 */ 297 /* a0: avail, a1: a1, a2: kstk, a3: avail, depc: a2, excsave: a3 */
298 298
299 movi a3, exc_table 299 movi a3, exc_table
300 rsr a0, EXCCAUSE 300 rsr a0, exccause
301 addx4 a0, a0, a3 301 addx4 a0, a0, a3
302 l32i a0, a0, EXC_TABLE_FAST_USER 302 l32i a0, a0, EXC_TABLE_FAST_USER
303 jx a0 303 jx a0
@@ -312,7 +312,7 @@ ENTRY(_DoubleExceptionVector)
312 312
313.Lksp: /* a0: a0, a1: a1, a2: a2, a3: trashed, depc: depc, excsave: a3 */ 313.Lksp: /* a0: a0, a1: a1, a2: a2, a3: trashed, depc: depc, excsave: a3 */
314 314
315 rsr a3, EXCCAUSE 315 rsr a3, exccause
316 beqi a3, EXCCAUSE_ITLB_MISS, 1f 316 beqi a3, EXCCAUSE_ITLB_MISS, 1f
317 addi a3, a3, -EXCCAUSE_DTLB_MISS 317 addi a3, a3, -EXCCAUSE_DTLB_MISS
318 bnez a3, .Lunrecoverable 318 bnez a3, .Lunrecoverable
@@ -328,11 +328,11 @@ ENTRY(_DoubleExceptionVector)
328 328
329.Lunrecoverable_fixup: 329.Lunrecoverable_fixup:
330 l32i a2, a3, EXC_TABLE_DOUBLE_SAVE 330 l32i a2, a3, EXC_TABLE_DOUBLE_SAVE
331 xsr a0, DEPC 331 xsr a0, depc
332 332
333.Lunrecoverable: 333.Lunrecoverable:
334 rsr a3, EXCSAVE_1 334 rsr a3, excsave1
335 wsr a0, EXCSAVE_1 335 wsr a0, excsave1
336 movi a0, unrecoverable_exception 336 movi a0, unrecoverable_exception
337 callx0 a0 337 callx0 a0
338 338
@@ -349,7 +349,7 @@ ENTRY(_DoubleExceptionVector)
349 .section .DebugInterruptVector.text, "ax" 349 .section .DebugInterruptVector.text, "ax"
350 350
351ENTRY(_DebugInterruptVector) 351ENTRY(_DebugInterruptVector)
352 xsr a0, EXCSAVE + XCHAL_DEBUGLEVEL 352 xsr a0, SREG_EXCSAVE + XCHAL_DEBUGLEVEL
353 jx a0 353 jx a0
354 354
355 355
diff --git a/arch/xtensa/kernel/xtensa_ksyms.c b/arch/xtensa/kernel/xtensa_ksyms.c
index a8b9f1fd1e1..afe058b24e6 100644
--- a/arch/xtensa/kernel/xtensa_ksyms.c
+++ b/arch/xtensa/kernel/xtensa_ksyms.c
@@ -43,7 +43,6 @@ EXPORT_SYMBOL(__strncpy_user);
43EXPORT_SYMBOL(clear_page); 43EXPORT_SYMBOL(clear_page);
44EXPORT_SYMBOL(copy_page); 44EXPORT_SYMBOL(copy_page);
45 45
46EXPORT_SYMBOL(kernel_thread);
47EXPORT_SYMBOL(empty_zero_page); 46EXPORT_SYMBOL(empty_zero_page);
48 47
49/* 48/*
diff --git a/arch/xtensa/lib/memcopy.S b/arch/xtensa/lib/memcopy.S
index ea59dcd0386..c48b80acb5f 100644
--- a/arch/xtensa/lib/memcopy.S
+++ b/arch/xtensa/lib/memcopy.S
@@ -6,7 +6,7 @@
6 * License. See the file "COPYING" in the main directory of this archive 6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details. 7 * for more details.
8 * 8 *
9 * Copyright (C) 2002 - 2005 Tensilica Inc. 9 * Copyright (C) 2002 - 2012 Tensilica Inc.
10 */ 10 */
11 11
12#include <variant/core.h> 12#include <variant/core.h>
@@ -27,14 +27,11 @@
27#endif 27#endif
28 .endm 28 .endm
29 29
30
31/* 30/*
32 * void *memcpy(void *dst, const void *src, size_t len); 31 * void *memcpy(void *dst, const void *src, size_t len);
33 * void *memmove(void *dst, const void *src, size_t len);
34 * void *bcopy(const void *src, void *dst, size_t len);
35 * 32 *
36 * This function is intended to do the same thing as the standard 33 * This function is intended to do the same thing as the standard
37 * library function memcpy() (or bcopy()) for most cases. 34 * library function memcpy() for most cases.
38 * However, where the source and/or destination references 35 * However, where the source and/or destination references
39 * an instruction RAM or ROM or a data RAM or ROM, that 36 * an instruction RAM or ROM or a data RAM or ROM, that
40 * source and/or destination will always be accessed with 37 * source and/or destination will always be accessed with
@@ -45,9 +42,6 @@
45 * !!!!!!! Handling of IRAM/IROM has not yet 42 * !!!!!!! Handling of IRAM/IROM has not yet
46 * !!!!!!! been implemented. 43 * !!!!!!! been implemented.
47 * 44 *
48 * The bcopy version is provided here to avoid the overhead
49 * of an extra call, for callers that require this convention.
50 *
51 * The (general case) algorithm is as follows: 45 * The (general case) algorithm is as follows:
52 * If destination is unaligned, align it by conditionally 46 * If destination is unaligned, align it by conditionally
53 * copying 1 and 2 bytes. 47 * copying 1 and 2 bytes.
@@ -76,17 +70,6 @@
76 */ 70 */
77 71
78 .text 72 .text
79 .align 4
80 .global bcopy
81 .type bcopy,@function
82bcopy:
83 entry sp, 16 # minimal stack frame
84 # a2=src, a3=dst, a4=len
85 mov a5, a3 # copy dst so that a2 is return value
86 mov a3, a2
87 mov a2, a5
88 j .Lcommon # go to common code for memcpy+bcopy
89
90 73
91/* 74/*
92 * Byte by byte copy 75 * Byte by byte copy
@@ -107,7 +90,7 @@ bcopy:
107 s8i a6, a5, 0 90 s8i a6, a5, 0
108 addi a5, a5, 1 91 addi a5, a5, 1
109#if !XCHAL_HAVE_LOOPS 92#if !XCHAL_HAVE_LOOPS
110 blt a3, a7, .Lnextbyte 93 bne a3, a7, .Lnextbyte # continue loop if $a3:src != $a7:src_end
111#endif /* !XCHAL_HAVE_LOOPS */ 94#endif /* !XCHAL_HAVE_LOOPS */
112.Lbytecopydone: 95.Lbytecopydone:
113 retw 96 retw
@@ -144,9 +127,6 @@ bcopy:
144 .global memcpy 127 .global memcpy
145 .type memcpy,@function 128 .type memcpy,@function
146memcpy: 129memcpy:
147 .global memmove
148 .type memmove,@function
149memmove:
150 130
151 entry sp, 16 # minimal stack frame 131 entry sp, 16 # minimal stack frame
152 # a2/ dst, a3/ src, a4/ len 132 # a2/ dst, a3/ src, a4/ len
@@ -182,7 +162,7 @@ memmove:
182 s32i a7, a5, 12 162 s32i a7, a5, 12
183 addi a5, a5, 16 163 addi a5, a5, 16
184#if !XCHAL_HAVE_LOOPS 164#if !XCHAL_HAVE_LOOPS
185 blt a3, a8, .Loop1 165 bne a3, a8, .Loop1 # continue loop if a3:src != a8:src_end
186#endif /* !XCHAL_HAVE_LOOPS */ 166#endif /* !XCHAL_HAVE_LOOPS */
187.Loop1done: 167.Loop1done:
188 bbci.l a4, 3, .L2 168 bbci.l a4, 3, .L2
@@ -260,7 +240,7 @@ memmove:
260 s32i a9, a5, 12 240 s32i a9, a5, 12
261 addi a5, a5, 16 241 addi a5, a5, 16
262#if !XCHAL_HAVE_LOOPS 242#if !XCHAL_HAVE_LOOPS
263 blt a3, a10, .Loop2 243 bne a3, a10, .Loop2 # continue loop if a3:src != a10:src_end
264#endif /* !XCHAL_HAVE_LOOPS */ 244#endif /* !XCHAL_HAVE_LOOPS */
265.Loop2done: 245.Loop2done:
266 bbci.l a4, 3, .L12 246 bbci.l a4, 3, .L12
@@ -305,6 +285,285 @@ memmove:
305 l8ui a6, a3, 0 285 l8ui a6, a3, 0
306 s8i a6, a5, 0 286 s8i a6, a5, 0
307 retw 287 retw
288
289
290/*
291 * void bcopy(const void *src, void *dest, size_t n);
292 */
293 .align 4
294 .global bcopy
295 .type bcopy,@function
296bcopy:
297 entry sp, 16 # minimal stack frame
298 # a2=src, a3=dst, a4=len
299 mov a5, a3
300 mov a3, a2
301 mov a2, a5
302 j .Lmovecommon # go to common code for memmove+bcopy
303
304/*
305 * void *memmove(void *dst, const void *src, size_t len);
306 *
307 * This function is intended to do the same thing as the standard
308 * library function memmove() for most cases.
309 * However, where the source and/or destination references
310 * an instruction RAM or ROM or a data RAM or ROM, that
311 * source and/or destination will always be accessed with
312 * 32-bit load and store instructions (as required for these
313 * types of devices).
314 *
315 * !!!!!!! XTFIXME:
316 * !!!!!!! Handling of IRAM/IROM has not yet
317 * !!!!!!! been implemented.
318 *
319 * The (general case) algorithm is as follows:
320 * If end of source doesn't overlap destination then use memcpy.
321 * Otherwise do memcpy backwards.
322 *
323 * Register use:
324 * a0/ return address
325 * a1/ stack pointer
326 * a2/ return value
327 * a3/ src
328 * a4/ length
329 * a5/ dst
330 * a6/ tmp
331 * a7/ tmp
332 * a8/ tmp
333 * a9/ tmp
334 * a10/ tmp
335 * a11/ tmp
336 */
337
338/*
339 * Byte by byte copy
340 */
341 .align 4
342 .byte 0 # 1 mod 4 alignment for LOOPNEZ
343 # (0 mod 4 alignment for LBEG)
344.Lbackbytecopy:
345#if XCHAL_HAVE_LOOPS
346 loopnez a4, .Lbackbytecopydone
347#else /* !XCHAL_HAVE_LOOPS */
348 beqz a4, .Lbackbytecopydone
349 sub a7, a3, a4 # a7 = start address for source
350#endif /* !XCHAL_HAVE_LOOPS */
351.Lbacknextbyte:
352 addi a3, a3, -1
353 l8ui a6, a3, 0
354 addi a5, a5, -1
355 s8i a6, a5, 0
356#if !XCHAL_HAVE_LOOPS
357 bne a3, a7, .Lbacknextbyte # continue loop if
358 # $a3:src != $a7:src_start
359#endif /* !XCHAL_HAVE_LOOPS */
360.Lbackbytecopydone:
361 retw
362
363/*
364 * Destination is unaligned
365 */
366
367 .align 4
368.Lbackdst1mod2: # dst is only byte aligned
369 _bltui a4, 7, .Lbackbytecopy # do short copies byte by byte
370
371 # copy 1 byte
372 addi a3, a3, -1
373 l8ui a6, a3, 0
374 addi a5, a5, -1
375 s8i a6, a5, 0
376 addi a4, a4, -1
377 _bbci.l a5, 1, .Lbackdstaligned # if dst is now aligned, then
378 # return to main algorithm
379.Lbackdst2mod4: # dst 16-bit aligned
380 # copy 2 bytes
381 _bltui a4, 6, .Lbackbytecopy # do short copies byte by byte
382 addi a3, a3, -2
383 l8ui a6, a3, 0
384 l8ui a7, a3, 1
385 addi a5, a5, -2
386 s8i a6, a5, 0
387 s8i a7, a5, 1
388 addi a4, a4, -2
389 j .Lbackdstaligned # dst is now aligned,
390 # return to main algorithm
391
392 .align 4
393 .global memmove
394 .type memmove,@function
395memmove:
396
397 entry sp, 16 # minimal stack frame
398 # a2/ dst, a3/ src, a4/ len
399 mov a5, a2 # copy dst so that a2 is return value
400.Lmovecommon:
401 sub a6, a5, a3
402 bgeu a6, a4, .Lcommon
403
404 add a5, a5, a4
405 add a3, a3, a4
406
407 _bbsi.l a5, 0, .Lbackdst1mod2 # if dst is 1 mod 2
408 _bbsi.l a5, 1, .Lbackdst2mod4 # if dst is 2 mod 4
409.Lbackdstaligned: # return here from .Lbackdst?mod? once dst is aligned
410 srli a7, a4, 4 # number of loop iterations with 16B
411 # per iteration
412 movi a8, 3 # if source is not aligned,
413 _bany a3, a8, .Lbacksrcunaligned # then use shifting copy
414 /*
415 * Destination and source are word-aligned, use word copy.
416 */
417 # copy 16 bytes per iteration for word-aligned dst and word-aligned src
418#if XCHAL_HAVE_LOOPS
419 loopnez a7, .backLoop1done
420#else /* !XCHAL_HAVE_LOOPS */
421 beqz a7, .backLoop1done
422 slli a8, a7, 4
423 sub a8, a3, a8 # a8 = start of first 16B source chunk
424#endif /* !XCHAL_HAVE_LOOPS */
425.backLoop1:
426 addi a3, a3, -16
427 l32i a7, a3, 12
428 l32i a6, a3, 8
429 addi a5, a5, -16
430 s32i a7, a5, 12
431 l32i a7, a3, 4
432 s32i a6, a5, 8
433 l32i a6, a3, 0
434 s32i a7, a5, 4
435 s32i a6, a5, 0
436#if !XCHAL_HAVE_LOOPS
437 bne a3, a8, .backLoop1 # continue loop if a3:src != a8:src_start
438#endif /* !XCHAL_HAVE_LOOPS */
439.backLoop1done:
440 bbci.l a4, 3, .Lback2
441 # copy 8 bytes
442 addi a3, a3, -8
443 l32i a6, a3, 0
444 l32i a7, a3, 4
445 addi a5, a5, -8
446 s32i a6, a5, 0
447 s32i a7, a5, 4
448.Lback2:
449 bbsi.l a4, 2, .Lback3
450 bbsi.l a4, 1, .Lback4
451 bbsi.l a4, 0, .Lback5
452 retw
453.Lback3:
454 # copy 4 bytes
455 addi a3, a3, -4
456 l32i a6, a3, 0
457 addi a5, a5, -4
458 s32i a6, a5, 0
459 bbsi.l a4, 1, .Lback4
460 bbsi.l a4, 0, .Lback5
461 retw
462.Lback4:
463 # copy 2 bytes
464 addi a3, a3, -2
465 l16ui a6, a3, 0
466 addi a5, a5, -2
467 s16i a6, a5, 0
468 bbsi.l a4, 0, .Lback5
469 retw
470.Lback5:
471 # copy 1 byte
472 addi a3, a3, -1
473 l8ui a6, a3, 0
474 addi a5, a5, -1
475 s8i a6, a5, 0
476 retw
477
478/*
479 * Destination is aligned, Source is unaligned
480 */
481
482 .align 4
483.Lbacksrcunaligned:
484 _beqz a4, .Lbackdone # avoid loading anything for zero-length copies
485 # copy 16 bytes per iteration for word-aligned dst and unaligned src
486 ssa8 a3 # set shift amount from byte offset
487#define SIM_CHECKS_ALIGNMENT 1 /* set to 1 when running on ISS with
488 * the lint or ferret client, or 0
489 * to save a few cycles */
490#if XCHAL_UNALIGNED_LOAD_EXCEPTION || SIM_CHECKS_ALIGNMENT
491 and a11, a3, a8 # save unalignment offset for below
492 sub a3, a3, a11 # align a3
493#endif
494 l32i a6, a3, 0 # load first word
495#if XCHAL_HAVE_LOOPS
496 loopnez a7, .backLoop2done
497#else /* !XCHAL_HAVE_LOOPS */
498 beqz a7, .backLoop2done
499 slli a10, a7, 4
500 sub a10, a3, a10 # a10 = start of first 16B source chunk
501#endif /* !XCHAL_HAVE_LOOPS */
502.backLoop2:
503 addi a3, a3, -16
504 l32i a7, a3, 12
505 l32i a8, a3, 8
506 addi a5, a5, -16
507 src_b a6, a7, a6
508 s32i a6, a5, 12
509 l32i a9, a3, 4
510 src_b a7, a8, a7
511 s32i a7, a5, 8
512 l32i a6, a3, 0
513 src_b a8, a9, a8
514 s32i a8, a5, 4
515 src_b a9, a6, a9
516 s32i a9, a5, 0
517#if !XCHAL_HAVE_LOOPS
518 bne a3, a10, .backLoop2 # continue loop if a3:src != a10:src_start
519#endif /* !XCHAL_HAVE_LOOPS */
520.backLoop2done:
521 bbci.l a4, 3, .Lback12
522 # copy 8 bytes
523 addi a3, a3, -8
524 l32i a7, a3, 4
525 l32i a8, a3, 0
526 addi a5, a5, -8
527 src_b a6, a7, a6
528 s32i a6, a5, 4
529 src_b a7, a8, a7
530 s32i a7, a5, 0
531 mov a6, a8
532.Lback12:
533 bbci.l a4, 2, .Lback13
534 # copy 4 bytes
535 addi a3, a3, -4
536 l32i a7, a3, 0
537 addi a5, a5, -4
538 src_b a6, a7, a6
539 s32i a6, a5, 0
540 mov a6, a7
541.Lback13:
542#if XCHAL_UNALIGNED_LOAD_EXCEPTION || SIM_CHECKS_ALIGNMENT
543 add a3, a3, a11 # readjust a3 with correct misalignment
544#endif
545 bbsi.l a4, 1, .Lback14
546 bbsi.l a4, 0, .Lback15
547.Lbackdone:
548 retw
549.Lback14:
550 # copy 2 bytes
551 addi a3, a3, -2
552 l8ui a6, a3, 0
553 l8ui a7, a3, 1
554 addi a5, a5, -2
555 s8i a6, a5, 0
556 s8i a7, a5, 1
557 bbsi.l a4, 0, .Lback15
558 retw
559.Lback15:
560 # copy 1 byte
561 addi a3, a3, -1
562 addi a5, a5, -1
563 l8ui a6, a3, 0
564 s8i a6, a5, 0
565 retw
566
308 567
309/* 568/*
310 * Local Variables: 569 * Local Variables:
diff --git a/arch/xtensa/mm/fault.c b/arch/xtensa/mm/fault.c
index 2c2f710ed1d..245b08f7eaf 100644
--- a/arch/xtensa/mm/fault.c
+++ b/arch/xtensa/mm/fault.c
@@ -6,7 +6,7 @@
6 * License. See the file "COPYING" in the main directory of this archive 6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details. 7 * for more details.
8 * 8 *
9 * Copyright (C) 2001 - 2005 Tensilica Inc. 9 * Copyright (C) 2001 - 2010 Tensilica Inc.
10 * 10 *
11 * Chris Zankel <chris@zankel.net> 11 * Chris Zankel <chris@zankel.net>
12 * Joe Taylor <joe@tensilica.com, joetylr@yahoo.com> 12 * Joe Taylor <joe@tensilica.com, joetylr@yahoo.com>
@@ -186,6 +186,7 @@ do_sigbus:
186 /* Kernel mode? Handle exceptions or die */ 186 /* Kernel mode? Handle exceptions or die */
187 if (!user_mode(regs)) 187 if (!user_mode(regs))
188 bad_page_fault(regs, address, SIGBUS); 188 bad_page_fault(regs, address, SIGBUS);
189 return;
189 190
190vmalloc_fault: 191vmalloc_fault:
191 { 192 {
diff --git a/arch/xtensa/platforms/iss/console.c b/arch/xtensa/platforms/iss/console.c
index 8ab47edd7c8..7e74895eee0 100644
--- a/arch/xtensa/platforms/iss/console.c
+++ b/arch/xtensa/platforms/iss/console.c
@@ -91,7 +91,7 @@ static int rs_write(struct tty_struct * tty,
91{ 91{
92 /* see drivers/char/serialX.c to reference original version */ 92 /* see drivers/char/serialX.c to reference original version */
93 93
94 __simc (SYS_write, 1, (unsigned long)buf, count, 0, 0); 94 simc_write(1, buf, count);
95 return count; 95 return count;
96} 96}
97 97
@@ -122,12 +122,7 @@ static void rs_poll(unsigned long priv)
122 122
123static int rs_put_char(struct tty_struct *tty, unsigned char ch) 123static int rs_put_char(struct tty_struct *tty, unsigned char ch)
124{ 124{
125 char buf[2]; 125 return rs_write(tty, &ch, 1);
126
127 buf[0] = ch;
128 buf[1] = '\0'; /* Is this NULL necessary? */
129 __simc (SYS_write, 1, (unsigned long) buf, 1, 0, 0);
130 return 1;
131} 126}
132 127
133static void rs_flush_chars(struct tty_struct *tty) 128static void rs_flush_chars(struct tty_struct *tty)
diff --git a/arch/xtensa/platforms/iss/include/platform/simcall.h b/arch/xtensa/platforms/iss/include/platform/simcall.h
index 8c43bfea05e..bd78192e2fc 100644
--- a/arch/xtensa/platforms/iss/include/platform/simcall.h
+++ b/arch/xtensa/platforms/iss/include/platform/simcall.h
@@ -78,8 +78,9 @@ static inline int __simc(int a, int b, int c, int d, int e, int f)
78 return ret; 78 return ret;
79} 79}
80 80
81static inline int simc_open(char *file, int flags, int mode) 81static inline int simc_open(const char *file, int flags, int mode)
82{ 82{
83 wmb();
83 return __simc(SYS_open, (int) file, flags, mode, 0, 0); 84 return __simc(SYS_open, (int) file, flags, mode, 0, 0);
84} 85}
85 86
@@ -90,16 +91,19 @@ static inline int simc_close(int fd)
90 91
91static inline int simc_ioctl(int fd, int request, void *arg) 92static inline int simc_ioctl(int fd, int request, void *arg)
92{ 93{
94 wmb();
93 return __simc(SYS_ioctl, fd, request, (int) arg, 0, 0); 95 return __simc(SYS_ioctl, fd, request, (int) arg, 0, 0);
94} 96}
95 97
96static inline int simc_read(int fd, void *buf, size_t count) 98static inline int simc_read(int fd, void *buf, size_t count)
97{ 99{
100 rmb();
98 return __simc(SYS_read, fd, (int) buf, count, 0, 0); 101 return __simc(SYS_read, fd, (int) buf, count, 0, 0);
99} 102}
100 103
101static inline int simc_write(int fd, void *buf, size_t count) 104static inline int simc_write(int fd, const void *buf, size_t count)
102{ 105{
106 wmb();
103 return __simc(SYS_write, fd, (int) buf, count, 0, 0); 107 return __simc(SYS_write, fd, (int) buf, count, 0, 0);
104} 108}
105 109
@@ -107,6 +111,7 @@ static inline int simc_poll(int fd)
107{ 111{
108 struct timeval tv = { .tv_sec = 0, .tv_usec = 0 }; 112 struct timeval tv = { .tv_sec = 0, .tv_usec = 0 };
109 113
114 wmb();
110 return __simc(SYS_select_one, fd, XTISS_SELECT_ONE_READ, (int)&tv, 115 return __simc(SYS_select_one, fd, XTISS_SELECT_ONE_READ, (int)&tv,
111 0, 0); 116 0, 0);
112} 117}
diff --git a/arch/xtensa/platforms/iss/setup.c b/arch/xtensa/platforms/iss/setup.c
index 927acf378ea..e1700102f35 100644
--- a/arch/xtensa/platforms/iss/setup.c
+++ b/arch/xtensa/platforms/iss/setup.c
@@ -61,13 +61,13 @@ void platform_restart(void)
61 * jump to the reset vector. */ 61 * jump to the reset vector. */
62 62
63 __asm__ __volatile__("movi a2, 15\n\t" 63 __asm__ __volatile__("movi a2, 15\n\t"
64 "wsr a2, " __stringify(ICOUNTLEVEL) "\n\t" 64 "wsr a2, icountlevel\n\t"
65 "movi a2, 0\n\t" 65 "movi a2, 0\n\t"
66 "wsr a2, " __stringify(ICOUNT) "\n\t" 66 "wsr a2, icount\n\t"
67 "wsr a2, " __stringify(IBREAKENABLE) "\n\t" 67 "wsr a2, ibreakenable\n\t"
68 "wsr a2, " __stringify(LCOUNT) "\n\t" 68 "wsr a2, lcount\n\t"
69 "movi a2, 0x1f\n\t" 69 "movi a2, 0x1f\n\t"
70 "wsr a2, " __stringify(PS) "\n\t" 70 "wsr a2, ps\n\t"
71 "isync\n\t" 71 "isync\n\t"
72 "jx %0\n\t" 72 "jx %0\n\t"
73 : 73 :
diff --git a/arch/xtensa/platforms/xt2000/setup.c b/arch/xtensa/platforms/xt2000/setup.c
index 9e83940ac26..c7d90f17886 100644
--- a/arch/xtensa/platforms/xt2000/setup.c
+++ b/arch/xtensa/platforms/xt2000/setup.c
@@ -66,13 +66,13 @@ void platform_restart(void)
66 * jump to the reset vector. */ 66 * jump to the reset vector. */
67 67
68 __asm__ __volatile__ ("movi a2, 15\n\t" 68 __asm__ __volatile__ ("movi a2, 15\n\t"
69 "wsr a2, " __stringify(ICOUNTLEVEL) "\n\t" 69 "wsr a2, icountlevel\n\t"
70 "movi a2, 0\n\t" 70 "movi a2, 0\n\t"
71 "wsr a2, " __stringify(ICOUNT) "\n\t" 71 "wsr a2, icount\n\t"
72 "wsr a2, " __stringify(IBREAKENABLE) "\n\t" 72 "wsr a2, ibreakenable\n\t"
73 "wsr a2, " __stringify(LCOUNT) "\n\t" 73 "wsr a2, lcount\n\t"
74 "movi a2, 0x1f\n\t" 74 "movi a2, 0x1f\n\t"
75 "wsr a2, " __stringify(PS) "\n\t" 75 "wsr a2, ps\n\t"
76 "isync\n\t" 76 "isync\n\t"
77 "jx %0\n\t" 77 "jx %0\n\t"
78 : 78 :
diff --git a/block/Kconfig b/block/Kconfig
index 09acf1b3990..a7e40a7c821 100644
--- a/block/Kconfig
+++ b/block/Kconfig
@@ -89,7 +89,7 @@ config BLK_DEV_INTEGRITY
89 89
90config BLK_DEV_THROTTLING 90config BLK_DEV_THROTTLING
91 bool "Block layer bio throttling support" 91 bool "Block layer bio throttling support"
92 depends on BLK_CGROUP=y && EXPERIMENTAL 92 depends on BLK_CGROUP=y
93 default n 93 default n
94 ---help--- 94 ---help---
95 Block layer bio throttling support. It can be used to limit 95 Block layer bio throttling support. It can be used to limit
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index cafcd743118..d0b770391ad 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -285,6 +285,13 @@ static void blkg_destroy_all(struct request_queue *q)
285 blkg_destroy(blkg); 285 blkg_destroy(blkg);
286 spin_unlock(&blkcg->lock); 286 spin_unlock(&blkcg->lock);
287 } 287 }
288
289 /*
290 * root blkg is destroyed. Just clear the pointer since
291 * root_rl does not take reference on root blkg.
292 */
293 q->root_blkg = NULL;
294 q->root_rl.blkg = NULL;
288} 295}
289 296
290static void blkg_rcu_free(struct rcu_head *rcu_head) 297static void blkg_rcu_free(struct rcu_head *rcu_head)
@@ -326,6 +333,9 @@ struct request_list *__blk_queue_next_rl(struct request_list *rl,
326 */ 333 */
327 if (rl == &q->root_rl) { 334 if (rl == &q->root_rl) {
328 ent = &q->blkg_list; 335 ent = &q->blkg_list;
336 /* There are no more block groups, hence no request lists */
337 if (list_empty(ent))
338 return NULL;
329 } else { 339 } else {
330 blkg = container_of(rl, struct blkcg_gq, rl); 340 blkg = container_of(rl, struct blkcg_gq, rl);
331 ent = &blkg->q_node; 341 ent = &blkg->q_node;
diff --git a/block/blk-core.c b/block/blk-core.c
index a33870b1847..3c95c4d6e31 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -2868,7 +2868,8 @@ static int plug_rq_cmp(void *priv, struct list_head *a, struct list_head *b)
2868 struct request *rqa = container_of(a, struct request, queuelist); 2868 struct request *rqa = container_of(a, struct request, queuelist);
2869 struct request *rqb = container_of(b, struct request, queuelist); 2869 struct request *rqb = container_of(b, struct request, queuelist);
2870 2870
2871 return !(rqa->q <= rqb->q); 2871 return !(rqa->q < rqb->q ||
2872 (rqa->q == rqb->q && blk_rq_pos(rqa) < blk_rq_pos(rqb)));
2872} 2873}
2873 2874
2874/* 2875/*
diff --git a/block/blk-exec.c b/block/blk-exec.c
index 8b6dc5bd4dd..f71eac35c1b 100644
--- a/block/blk-exec.c
+++ b/block/blk-exec.c
@@ -52,11 +52,17 @@ void blk_execute_rq_nowait(struct request_queue *q, struct gendisk *bd_disk,
52 rq_end_io_fn *done) 52 rq_end_io_fn *done)
53{ 53{
54 int where = at_head ? ELEVATOR_INSERT_FRONT : ELEVATOR_INSERT_BACK; 54 int where = at_head ? ELEVATOR_INSERT_FRONT : ELEVATOR_INSERT_BACK;
55 bool is_pm_resume;
55 56
56 WARN_ON(irqs_disabled()); 57 WARN_ON(irqs_disabled());
57 58
58 rq->rq_disk = bd_disk; 59 rq->rq_disk = bd_disk;
59 rq->end_io = done; 60 rq->end_io = done;
61 /*
62 * need to check this before __blk_run_queue(), because rq can
63 * be freed before that returns.
64 */
65 is_pm_resume = rq->cmd_type == REQ_TYPE_PM_RESUME;
60 66
61 spin_lock_irq(q->queue_lock); 67 spin_lock_irq(q->queue_lock);
62 68
@@ -71,7 +77,7 @@ void blk_execute_rq_nowait(struct request_queue *q, struct gendisk *bd_disk,
71 __elv_add_request(q, rq, where); 77 __elv_add_request(q, rq, where);
72 __blk_run_queue(q); 78 __blk_run_queue(q);
73 /* the queue is stopped so it won't be run */ 79 /* the queue is stopped so it won't be run */
74 if (rq->cmd_type == REQ_TYPE_PM_RESUME) 80 if (is_pm_resume)
75 q->request_fn(q); 81 q->request_fn(q);
76 spin_unlock_irq(q->queue_lock); 82 spin_unlock_irq(q->queue_lock);
77} 83}
diff --git a/crypto/cryptd.c b/crypto/cryptd.c
index 671d4d6d14d..7bdd61b867c 100644
--- a/crypto/cryptd.c
+++ b/crypto/cryptd.c
@@ -137,13 +137,18 @@ static void cryptd_queue_worker(struct work_struct *work)
137 struct crypto_async_request *req, *backlog; 137 struct crypto_async_request *req, *backlog;
138 138
139 cpu_queue = container_of(work, struct cryptd_cpu_queue, work); 139 cpu_queue = container_of(work, struct cryptd_cpu_queue, work);
140 /* Only handle one request at a time to avoid hogging crypto 140 /*
141 * workqueue. preempt_disable/enable is used to prevent 141 * Only handle one request at a time to avoid hogging crypto workqueue.
142 * being preempted by cryptd_enqueue_request() */ 142 * preempt_disable/enable is used to prevent being preempted by
143 * cryptd_enqueue_request(). local_bh_disable/enable is used to prevent
144 * cryptd_enqueue_request() being accessed from software interrupts.
145 */
146 local_bh_disable();
143 preempt_disable(); 147 preempt_disable();
144 backlog = crypto_get_backlog(&cpu_queue->queue); 148 backlog = crypto_get_backlog(&cpu_queue->queue);
145 req = crypto_dequeue_request(&cpu_queue->queue); 149 req = crypto_dequeue_request(&cpu_queue->queue);
146 preempt_enable(); 150 preempt_enable();
151 local_bh_enable();
147 152
148 if (!req) 153 if (!req)
149 return; 154 return;
diff --git a/drivers/Makefile b/drivers/Makefile
index 03da5b663ae..a16a8d001ae 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -17,6 +17,10 @@ obj-$(CONFIG_PARISC) += parisc/
17obj-$(CONFIG_RAPIDIO) += rapidio/ 17obj-$(CONFIG_RAPIDIO) += rapidio/
18obj-y += video/ 18obj-y += video/
19obj-y += idle/ 19obj-y += idle/
20
21# IPMI must come before ACPI in order to provide IPMI opregion support
22obj-$(CONFIG_IPMI_HANDLER) += char/ipmi/
23
20obj-$(CONFIG_ACPI) += acpi/ 24obj-$(CONFIG_ACPI) += acpi/
21obj-$(CONFIG_SFI) += sfi/ 25obj-$(CONFIG_SFI) += sfi/
22# PnP must come after ACPI since it will eventually need to check if acpi 26# PnP must come after ACPI since it will eventually need to check if acpi
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index 47199e2a913..82422fe90f8 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -47,6 +47,10 @@ acpi-y += video_detect.o
47endif 47endif
48 48
49# These are (potentially) separate modules 49# These are (potentially) separate modules
50
51# IPMI may be used by other drivers, so it has to initialise before them
52obj-$(CONFIG_ACPI_IPMI) += acpi_ipmi.o
53
50obj-$(CONFIG_ACPI_AC) += ac.o 54obj-$(CONFIG_ACPI_AC) += ac.o
51obj-$(CONFIG_ACPI_BUTTON) += button.o 55obj-$(CONFIG_ACPI_BUTTON) += button.o
52obj-$(CONFIG_ACPI_FAN) += fan.o 56obj-$(CONFIG_ACPI_FAN) += fan.o
@@ -70,6 +74,5 @@ processor-y += processor_idle.o processor_thermal.o
70processor-$(CONFIG_CPU_FREQ) += processor_perflib.o 74processor-$(CONFIG_CPU_FREQ) += processor_perflib.o
71 75
72obj-$(CONFIG_ACPI_PROCESSOR_AGGREGATOR) += acpi_pad.o 76obj-$(CONFIG_ACPI_PROCESSOR_AGGREGATOR) += acpi_pad.o
73obj-$(CONFIG_ACPI_IPMI) += acpi_ipmi.o
74 77
75obj-$(CONFIG_ACPI_APEI) += apei/ 78obj-$(CONFIG_ACPI_APEI) += apei/
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index d1a2d74033e..08373086cd7 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -159,6 +159,7 @@ static int acpi_bind_one(struct device *dev, acpi_handle handle)
159 if (physical_node->node_id >= ACPI_MAX_PHYSICAL_NODE) { 159 if (physical_node->node_id >= ACPI_MAX_PHYSICAL_NODE) {
160 retval = -ENOSPC; 160 retval = -ENOSPC;
161 mutex_unlock(&acpi_dev->physical_node_lock); 161 mutex_unlock(&acpi_dev->physical_node_lock);
162 kfree(physical_node);
162 goto err; 163 goto err;
163 } 164 }
164 165
diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
index e78c2a52ea4..bd4e5dca3ff 100644
--- a/drivers/acpi/processor_driver.c
+++ b/drivers/acpi/processor_driver.c
@@ -409,6 +409,7 @@ static void acpi_processor_notify(struct acpi_device *device, u32 event)
409 acpi_bus_generate_proc_event(device, event, 0); 409 acpi_bus_generate_proc_event(device, event, 0);
410 acpi_bus_generate_netlink_event(device->pnp.device_class, 410 acpi_bus_generate_netlink_event(device->pnp.device_class,
411 dev_name(&device->dev), event, 0); 411 dev_name(&device->dev), event, 0);
412 break;
412 default: 413 default:
413 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 414 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
414 "Unsupported event [0x%x]\n", event)); 415 "Unsupported event [0x%x]\n", event));
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index f94d4c818fc..0230cb6cbb3 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -1345,12 +1345,15 @@ static int
1345acpi_video_bus_get_devices(struct acpi_video_bus *video, 1345acpi_video_bus_get_devices(struct acpi_video_bus *video,
1346 struct acpi_device *device) 1346 struct acpi_device *device)
1347{ 1347{
1348 int status; 1348 int status = 0;
1349 struct acpi_device *dev; 1349 struct acpi_device *dev;
1350 1350
1351 status = acpi_video_device_enumerate(video); 1351 /*
1352 if (status) 1352 * There are systems where video module known to work fine regardless
1353 return status; 1353 * of broken _DOD and ignoring returned value here doesn't cause
1354 * any issues later.
1355 */
1356 acpi_video_device_enumerate(video);
1354 1357
1355 list_for_each_entry(dev, &device->children, node) { 1358 list_for_each_entry(dev, &device->children, node) {
1356 1359
diff --git a/drivers/ata/ahci_platform.c b/drivers/ata/ahci_platform.c
index b1ae48054dc..b7078afddb7 100644
--- a/drivers/ata/ahci_platform.c
+++ b/drivers/ata/ahci_platform.c
@@ -238,7 +238,7 @@ static int __devexit ahci_remove(struct platform_device *pdev)
238 return 0; 238 return 0;
239} 239}
240 240
241#ifdef CONFIG_PM 241#ifdef CONFIG_PM_SLEEP
242static int ahci_suspend(struct device *dev) 242static int ahci_suspend(struct device *dev)
243{ 243{
244 struct ahci_platform_data *pdata = dev_get_platdata(dev); 244 struct ahci_platform_data *pdata = dev_get_platdata(dev);
diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c
index fd9ecf74e63..5b0ba3f20ed 100644
--- a/drivers/ata/libata-acpi.c
+++ b/drivers/ata/libata-acpi.c
@@ -1105,10 +1105,15 @@ static int ata_acpi_bind_device(struct ata_port *ap, struct scsi_device *sdev,
1105 struct acpi_device *acpi_dev; 1105 struct acpi_device *acpi_dev;
1106 struct acpi_device_power_state *states; 1106 struct acpi_device_power_state *states;
1107 1107
1108 if (ap->flags & ATA_FLAG_ACPI_SATA) 1108 if (ap->flags & ATA_FLAG_ACPI_SATA) {
1109 ata_dev = &ap->link.device[sdev->channel]; 1109 if (!sata_pmp_attached(ap))
1110 else 1110 ata_dev = &ap->link.device[sdev->id];
1111 else
1112 ata_dev = &ap->pmp_link[sdev->channel].device[sdev->id];
1113 }
1114 else {
1111 ata_dev = &ap->link.device[sdev->id]; 1115 ata_dev = &ap->link.device[sdev->id];
1116 }
1112 1117
1113 *handle = ata_dev_acpi_handle(ata_dev); 1118 *handle = ata_dev_acpi_handle(ata_dev);
1114 1119
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 3cc7096cfda..f46fbd3bd3f 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -2942,6 +2942,10 @@ const struct ata_timing *ata_timing_find_mode(u8 xfer_mode)
2942 2942
2943 if (xfer_mode == t->mode) 2943 if (xfer_mode == t->mode)
2944 return t; 2944 return t;
2945
2946 WARN_ONCE(true, "%s: unable to find timing for xfer_mode 0x%x\n",
2947 __func__, xfer_mode);
2948
2945 return NULL; 2949 return NULL;
2946} 2950}
2947 2951
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index e3bda074fa1..a6df6a351d6 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -1052,6 +1052,8 @@ static void ata_scsi_sdev_config(struct scsi_device *sdev)
1052{ 1052{
1053 sdev->use_10_for_rw = 1; 1053 sdev->use_10_for_rw = 1;
1054 sdev->use_10_for_ms = 1; 1054 sdev->use_10_for_ms = 1;
1055 sdev->no_report_opcodes = 1;
1056 sdev->no_write_same = 1;
1055 1057
1056 /* Schedule policy is determined by ->qc_defer() callback and 1058 /* Schedule policy is determined by ->qc_defer() callback and
1057 * it needs to see every deferred qc. Set dev_blocked to 1 to 1059 * it needs to see every deferred qc. Set dev_blocked to 1 to
diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
index 26201ebef3c..371fd2c698b 100644
--- a/drivers/ata/pata_arasan_cf.c
+++ b/drivers/ata/pata_arasan_cf.c
@@ -317,6 +317,12 @@ static int cf_init(struct arasan_cf_dev *acdev)
317 return ret; 317 return ret;
318 } 318 }
319 319
320 ret = clk_set_rate(acdev->clk, 166000000);
321 if (ret) {
322 dev_warn(acdev->host->dev, "clock set rate failed");
323 return ret;
324 }
325
320 spin_lock_irqsave(&acdev->host->lock, flags); 326 spin_lock_irqsave(&acdev->host->lock, flags);
321 /* configure CF interface clock */ 327 /* configure CF interface clock */
322 writel((pdata->cf_if_clk <= CF_IF_CLK_200M) ? pdata->cf_if_clk : 328 writel((pdata->cf_if_clk <= CF_IF_CLK_200M) ? pdata->cf_if_clk :
@@ -908,7 +914,7 @@ static int __devexit arasan_cf_remove(struct platform_device *pdev)
908 return 0; 914 return 0;
909} 915}
910 916
911#ifdef CONFIG_PM 917#ifdef CONFIG_PM_SLEEP
912static int arasan_cf_suspend(struct device *dev) 918static int arasan_cf_suspend(struct device *dev)
913{ 919{
914 struct ata_host *host = dev_get_drvdata(dev); 920 struct ata_host *host = dev_get_drvdata(dev);
diff --git a/drivers/ata/sata_highbank.c b/drivers/ata/sata_highbank.c
index 0d7c4c2cd26..400bf1c3e98 100644
--- a/drivers/ata/sata_highbank.c
+++ b/drivers/ata/sata_highbank.c
@@ -260,7 +260,7 @@ static const struct of_device_id ahci_of_match[] = {
260}; 260};
261MODULE_DEVICE_TABLE(of, ahci_of_match); 261MODULE_DEVICE_TABLE(of, ahci_of_match);
262 262
263static int __init ahci_highbank_probe(struct platform_device *pdev) 263static int __devinit ahci_highbank_probe(struct platform_device *pdev)
264{ 264{
265 struct device *dev = &pdev->dev; 265 struct device *dev = &pdev->dev;
266 struct ahci_host_priv *hpriv; 266 struct ahci_host_priv *hpriv;
@@ -378,7 +378,7 @@ static int __devexit ahci_highbank_remove(struct platform_device *pdev)
378 return 0; 378 return 0;
379} 379}
380 380
381#ifdef CONFIG_PM 381#ifdef CONFIG_PM_SLEEP
382static int ahci_highbank_suspend(struct device *dev) 382static int ahci_highbank_suspend(struct device *dev)
383{ 383{
384 struct ata_host *host = dev_get_drvdata(dev); 384 struct ata_host *host = dev_get_drvdata(dev);
diff --git a/drivers/ata/sata_svw.c b/drivers/ata/sata_svw.c
index 44a4256533e..08608de87e4 100644
--- a/drivers/ata/sata_svw.c
+++ b/drivers/ata/sata_svw.c
@@ -142,6 +142,39 @@ static int k2_sata_scr_write(struct ata_link *link,
142 return 0; 142 return 0;
143} 143}
144 144
145static int k2_sata_softreset(struct ata_link *link,
146 unsigned int *class, unsigned long deadline)
147{
148 u8 dmactl;
149 void __iomem *mmio = link->ap->ioaddr.bmdma_addr;
150
151 dmactl = readb(mmio + ATA_DMA_CMD);
152
153 /* Clear the start bit */
154 if (dmactl & ATA_DMA_START) {
155 dmactl &= ~ATA_DMA_START;
156 writeb(dmactl, mmio + ATA_DMA_CMD);
157 }
158
159 return ata_sff_softreset(link, class, deadline);
160}
161
162static int k2_sata_hardreset(struct ata_link *link,
163 unsigned int *class, unsigned long deadline)
164{
165 u8 dmactl;
166 void __iomem *mmio = link->ap->ioaddr.bmdma_addr;
167
168 dmactl = readb(mmio + ATA_DMA_CMD);
169
170 /* Clear the start bit */
171 if (dmactl & ATA_DMA_START) {
172 dmactl &= ~ATA_DMA_START;
173 writeb(dmactl, mmio + ATA_DMA_CMD);
174 }
175
176 return sata_sff_hardreset(link, class, deadline);
177}
145 178
146static void k2_sata_tf_load(struct ata_port *ap, const struct ata_taskfile *tf) 179static void k2_sata_tf_load(struct ata_port *ap, const struct ata_taskfile *tf)
147{ 180{
@@ -346,6 +379,8 @@ static struct scsi_host_template k2_sata_sht = {
346 379
347static struct ata_port_operations k2_sata_ops = { 380static struct ata_port_operations k2_sata_ops = {
348 .inherits = &ata_bmdma_port_ops, 381 .inherits = &ata_bmdma_port_ops,
382 .softreset = k2_sata_softreset,
383 .hardreset = k2_sata_hardreset,
349 .sff_tf_load = k2_sata_tf_load, 384 .sff_tf_load = k2_sata_tf_load,
350 .sff_tf_read = k2_sata_tf_read, 385 .sff_tf_read = k2_sata_tf_read,
351 .sff_check_status = k2_stat_check_status, 386 .sff_check_status = k2_stat_check_status,
diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig
index 08b4c520938..b34b5cda5ae 100644
--- a/drivers/base/Kconfig
+++ b/drivers/base/Kconfig
@@ -236,7 +236,7 @@ config CMA_SIZE_PERCENTAGE
236 236
237choice 237choice
238 prompt "Selected region size" 238 prompt "Selected region size"
239 default CMA_SIZE_SEL_ABSOLUTE 239 default CMA_SIZE_SEL_MBYTES
240 240
241config CMA_SIZE_SEL_MBYTES 241config CMA_SIZE_SEL_MBYTES
242 bool "Use mega bytes value only" 242 bool "Use mega bytes value only"
diff --git a/drivers/base/dma-coherent.c b/drivers/base/dma-coherent.c
index 560a7173f81..bc256b64102 100644
--- a/drivers/base/dma-coherent.c
+++ b/drivers/base/dma-coherent.c
@@ -191,9 +191,8 @@ EXPORT_SYMBOL(dma_release_from_coherent);
191 * This checks whether the memory was allocated from the per-device 191 * This checks whether the memory was allocated from the per-device
192 * coherent memory pool and if so, maps that memory to the provided vma. 192 * coherent memory pool and if so, maps that memory to the provided vma.
193 * 193 *
194 * Returns 1 if we correctly mapped the memory, or 0 if 194 * Returns 1 if we correctly mapped the memory, or 0 if the caller should
195 * dma_release_coherent() should proceed with mapping memory from 195 * proceed with mapping memory from generic pools.
196 * generic pools.
197 */ 196 */
198int dma_mmap_from_coherent(struct device *dev, struct vm_area_struct *vma, 197int dma_mmap_from_coherent(struct device *dev, struct vm_area_struct *vma,
199 void *vaddr, size_t size, int *ret) 198 void *vaddr, size_t size, int *ret)
diff --git a/drivers/base/dma-contiguous.c b/drivers/base/dma-contiguous.c
index 9a1469474f5..612afcc5a93 100644
--- a/drivers/base/dma-contiguous.c
+++ b/drivers/base/dma-contiguous.c
@@ -27,15 +27,12 @@
27#include <linux/mm.h> 27#include <linux/mm.h>
28#include <linux/mutex.h> 28#include <linux/mutex.h>
29#include <linux/page-isolation.h> 29#include <linux/page-isolation.h>
30#include <linux/sizes.h>
30#include <linux/slab.h> 31#include <linux/slab.h>
31#include <linux/swap.h> 32#include <linux/swap.h>
32#include <linux/mm_types.h> 33#include <linux/mm_types.h>
33#include <linux/dma-contiguous.h> 34#include <linux/dma-contiguous.h>
34 35
35#ifndef SZ_1M
36#define SZ_1M (1 << 20)
37#endif
38
39struct cma { 36struct cma {
40 unsigned long base_pfn; 37 unsigned long base_pfn;
41 unsigned long count; 38 unsigned long count;
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 81541452887..8945f4e489e 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -36,68 +36,6 @@ MODULE_AUTHOR("Manuel Estrada Sainz");
36MODULE_DESCRIPTION("Multi purpose firmware loading support"); 36MODULE_DESCRIPTION("Multi purpose firmware loading support");
37MODULE_LICENSE("GPL"); 37MODULE_LICENSE("GPL");
38 38
39static const char *fw_path[] = {
40 "/lib/firmware/updates/" UTS_RELEASE,
41 "/lib/firmware/updates",
42 "/lib/firmware/" UTS_RELEASE,
43 "/lib/firmware"
44};
45
46/* Don't inline this: 'struct kstat' is biggish */
47static noinline long fw_file_size(struct file *file)
48{
49 struct kstat st;
50 if (vfs_getattr(file->f_path.mnt, file->f_path.dentry, &st))
51 return -1;
52 if (!S_ISREG(st.mode))
53 return -1;
54 if (st.size != (long)st.size)
55 return -1;
56 return st.size;
57}
58
59static bool fw_read_file_contents(struct file *file, struct firmware *fw)
60{
61 long size;
62 char *buf;
63
64 size = fw_file_size(file);
65 if (size < 0)
66 return false;
67 buf = vmalloc(size);
68 if (!buf)
69 return false;
70 if (kernel_read(file, 0, buf, size) != size) {
71 vfree(buf);
72 return false;
73 }
74 fw->data = buf;
75 fw->size = size;
76 return true;
77}
78
79static bool fw_get_filesystem_firmware(struct firmware *fw, const char *name)
80{
81 int i;
82 bool success = false;
83 char *path = __getname();
84
85 for (i = 0; i < ARRAY_SIZE(fw_path); i++) {
86 struct file *file;
87 snprintf(path, PATH_MAX, "%s/%s", fw_path[i], name);
88
89 file = filp_open(path, O_RDONLY, 0);
90 if (IS_ERR(file))
91 continue;
92 success = fw_read_file_contents(file, fw);
93 fput(file);
94 if (success)
95 break;
96 }
97 __putname(path);
98 return success;
99}
100
101/* Builtin firmware support */ 39/* Builtin firmware support */
102 40
103#ifdef CONFIG_FW_LOADER 41#ifdef CONFIG_FW_LOADER
@@ -150,6 +88,11 @@ enum {
150 FW_STATUS_ABORT, 88 FW_STATUS_ABORT,
151}; 89};
152 90
91enum fw_buf_fmt {
92 VMALLOC_BUF, /* used in direct loading */
93 PAGE_BUF, /* used in loading via userspace */
94};
95
153static int loading_timeout = 60; /* In seconds */ 96static int loading_timeout = 60; /* In seconds */
154 97
155static inline long firmware_loading_timeout(void) 98static inline long firmware_loading_timeout(void)
@@ -173,8 +116,6 @@ struct firmware_cache {
173 spinlock_t name_lock; 116 spinlock_t name_lock;
174 struct list_head fw_names; 117 struct list_head fw_names;
175 118
176 wait_queue_head_t wait_queue;
177 int cnt;
178 struct delayed_work work; 119 struct delayed_work work;
179 120
180 struct notifier_block pm_notify; 121 struct notifier_block pm_notify;
@@ -187,6 +128,7 @@ struct firmware_buf {
187 struct completion completion; 128 struct completion completion;
188 struct firmware_cache *fwc; 129 struct firmware_cache *fwc;
189 unsigned long status; 130 unsigned long status;
131 enum fw_buf_fmt fmt;
190 void *data; 132 void *data;
191 size_t size; 133 size_t size;
192 struct page **pages; 134 struct page **pages;
@@ -240,6 +182,7 @@ static struct firmware_buf *__allocate_fw_buf(const char *fw_name,
240 strcpy(buf->fw_id, fw_name); 182 strcpy(buf->fw_id, fw_name);
241 buf->fwc = fwc; 183 buf->fwc = fwc;
242 init_completion(&buf->completion); 184 init_completion(&buf->completion);
185 buf->fmt = VMALLOC_BUF;
243 186
244 pr_debug("%s: fw-%s buf=%p\n", __func__, fw_name, buf); 187 pr_debug("%s: fw-%s buf=%p\n", __func__, fw_name, buf);
245 188
@@ -307,10 +250,14 @@ static void __fw_free_buf(struct kref *ref)
307 list_del(&buf->list); 250 list_del(&buf->list);
308 spin_unlock(&fwc->lock); 251 spin_unlock(&fwc->lock);
309 252
310 vunmap(buf->data); 253
311 for (i = 0; i < buf->nr_pages; i++) 254 if (buf->fmt == PAGE_BUF) {
312 __free_page(buf->pages[i]); 255 vunmap(buf->data);
313 kfree(buf->pages); 256 for (i = 0; i < buf->nr_pages; i++)
257 __free_page(buf->pages[i]);
258 kfree(buf->pages);
259 } else
260 vfree(buf->data);
314 kfree(buf); 261 kfree(buf);
315} 262}
316 263
@@ -319,6 +266,69 @@ static void fw_free_buf(struct firmware_buf *buf)
319 kref_put(&buf->ref, __fw_free_buf); 266 kref_put(&buf->ref, __fw_free_buf);
320} 267}
321 268
269/* direct firmware loading support */
270static const char *fw_path[] = {
271 "/lib/firmware/updates/" UTS_RELEASE,
272 "/lib/firmware/updates",
273 "/lib/firmware/" UTS_RELEASE,
274 "/lib/firmware"
275};
276
277/* Don't inline this: 'struct kstat' is biggish */
278static noinline long fw_file_size(struct file *file)
279{
280 struct kstat st;
281 if (vfs_getattr(file->f_path.mnt, file->f_path.dentry, &st))
282 return -1;
283 if (!S_ISREG(st.mode))
284 return -1;
285 if (st.size != (long)st.size)
286 return -1;
287 return st.size;
288}
289
290static bool fw_read_file_contents(struct file *file, struct firmware_buf *fw_buf)
291{
292 long size;
293 char *buf;
294
295 size = fw_file_size(file);
296 if (size < 0)
297 return false;
298 buf = vmalloc(size);
299 if (!buf)
300 return false;
301 if (kernel_read(file, 0, buf, size) != size) {
302 vfree(buf);
303 return false;
304 }
305 fw_buf->data = buf;
306 fw_buf->size = size;
307 return true;
308}
309
310static bool fw_get_filesystem_firmware(struct firmware_buf *buf)
311{
312 int i;
313 bool success = false;
314 char *path = __getname();
315
316 for (i = 0; i < ARRAY_SIZE(fw_path); i++) {
317 struct file *file;
318 snprintf(path, PATH_MAX, "%s/%s", fw_path[i], buf->fw_id);
319
320 file = filp_open(path, O_RDONLY, 0);
321 if (IS_ERR(file))
322 continue;
323 success = fw_read_file_contents(file, buf);
324 fput(file);
325 if (success)
326 break;
327 }
328 __putname(path);
329 return success;
330}
331
322static struct firmware_priv *to_firmware_priv(struct device *dev) 332static struct firmware_priv *to_firmware_priv(struct device *dev)
323{ 333{
324 return container_of(dev, struct firmware_priv, dev); 334 return container_of(dev, struct firmware_priv, dev);
@@ -423,6 +433,21 @@ static void firmware_free_data(const struct firmware *fw)
423#ifndef PAGE_KERNEL_RO 433#ifndef PAGE_KERNEL_RO
424#define PAGE_KERNEL_RO PAGE_KERNEL 434#define PAGE_KERNEL_RO PAGE_KERNEL
425#endif 435#endif
436
437/* one pages buffer should be mapped/unmapped only once */
438static int fw_map_pages_buf(struct firmware_buf *buf)
439{
440 if (buf->fmt != PAGE_BUF)
441 return 0;
442
443 if (buf->data)
444 vunmap(buf->data);
445 buf->data = vmap(buf->pages, buf->nr_pages, 0, PAGE_KERNEL_RO);
446 if (!buf->data)
447 return -ENOMEM;
448 return 0;
449}
450
426/** 451/**
427 * firmware_loading_store - set value in the 'loading' control file 452 * firmware_loading_store - set value in the 'loading' control file
428 * @dev: device pointer 453 * @dev: device pointer
@@ -467,6 +492,14 @@ static ssize_t firmware_loading_store(struct device *dev,
467 if (test_bit(FW_STATUS_LOADING, &fw_buf->status)) { 492 if (test_bit(FW_STATUS_LOADING, &fw_buf->status)) {
468 set_bit(FW_STATUS_DONE, &fw_buf->status); 493 set_bit(FW_STATUS_DONE, &fw_buf->status);
469 clear_bit(FW_STATUS_LOADING, &fw_buf->status); 494 clear_bit(FW_STATUS_LOADING, &fw_buf->status);
495
496 /*
497 * Several loading requests may be pending on
498 * one same firmware buf, so let all requests
499 * see the mapped 'buf->data' once the loading
500 * is completed.
501 * */
502 fw_map_pages_buf(fw_buf);
470 complete_all(&fw_buf->completion); 503 complete_all(&fw_buf->completion);
471 break; 504 break;
472 } 505 }
@@ -670,15 +703,6 @@ exit:
670 return fw_priv; 703 return fw_priv;
671} 704}
672 705
673/* one pages buffer is mapped/unmapped only once */
674static int fw_map_pages_buf(struct firmware_buf *buf)
675{
676 buf->data = vmap(buf->pages, buf->nr_pages, 0, PAGE_KERNEL_RO);
677 if (!buf->data)
678 return -ENOMEM;
679 return 0;
680}
681
682/* store the pages buffer info firmware from buf */ 706/* store the pages buffer info firmware from buf */
683static void fw_set_page_data(struct firmware_buf *buf, struct firmware *fw) 707static void fw_set_page_data(struct firmware_buf *buf, struct firmware *fw)
684{ 708{
@@ -778,11 +802,6 @@ _request_firmware_prepare(const struct firmware **firmware_p, const char *name,
778 return NULL; 802 return NULL;
779 } 803 }
780 804
781 if (fw_get_filesystem_firmware(firmware, name)) {
782 dev_dbg(device, "firmware: direct-loading firmware %s\n", name);
783 return NULL;
784 }
785
786 ret = fw_lookup_and_allocate_buf(name, &fw_cache, &buf); 805 ret = fw_lookup_and_allocate_buf(name, &fw_cache, &buf);
787 if (!ret) 806 if (!ret)
788 fw_priv = fw_create_instance(firmware, name, device, 807 fw_priv = fw_create_instance(firmware, name, device,
@@ -832,6 +851,21 @@ static int _request_firmware_load(struct firmware_priv *fw_priv, bool uevent,
832 struct device *f_dev = &fw_priv->dev; 851 struct device *f_dev = &fw_priv->dev;
833 struct firmware_buf *buf = fw_priv->buf; 852 struct firmware_buf *buf = fw_priv->buf;
834 struct firmware_cache *fwc = &fw_cache; 853 struct firmware_cache *fwc = &fw_cache;
854 int direct_load = 0;
855
856 /* try direct loading from fs first */
857 if (fw_get_filesystem_firmware(buf)) {
858 dev_dbg(f_dev->parent, "firmware: direct-loading"
859 " firmware %s\n", buf->fw_id);
860
861 set_bit(FW_STATUS_DONE, &buf->status);
862 complete_all(&buf->completion);
863 direct_load = 1;
864 goto handle_fw;
865 }
866
867 /* fall back on userspace loading */
868 buf->fmt = PAGE_BUF;
835 869
836 dev_set_uevent_suppress(f_dev, true); 870 dev_set_uevent_suppress(f_dev, true);
837 871
@@ -870,6 +904,7 @@ static int _request_firmware_load(struct firmware_priv *fw_priv, bool uevent,
870 904
871 del_timer_sync(&fw_priv->timeout); 905 del_timer_sync(&fw_priv->timeout);
872 906
907handle_fw:
873 mutex_lock(&fw_lock); 908 mutex_lock(&fw_lock);
874 if (!buf->size || test_bit(FW_STATUS_ABORT, &buf->status)) 909 if (!buf->size || test_bit(FW_STATUS_ABORT, &buf->status))
875 retval = -ENOENT; 910 retval = -ENOENT;
@@ -884,9 +919,6 @@ static int _request_firmware_load(struct firmware_priv *fw_priv, bool uevent,
884 if (!retval && f_dev->parent) 919 if (!retval && f_dev->parent)
885 fw_add_devm_name(f_dev->parent, buf->fw_id); 920 fw_add_devm_name(f_dev->parent, buf->fw_id);
886 921
887 if (!retval)
888 retval = fw_map_pages_buf(buf);
889
890 /* 922 /*
891 * After caching firmware image is started, let it piggyback 923 * After caching firmware image is started, let it piggyback
892 * on request firmware. 924 * on request firmware.
@@ -902,6 +934,9 @@ static int _request_firmware_load(struct firmware_priv *fw_priv, bool uevent,
902 fw_priv->buf = NULL; 934 fw_priv->buf = NULL;
903 mutex_unlock(&fw_lock); 935 mutex_unlock(&fw_lock);
904 936
937 if (direct_load)
938 goto err_put_dev;
939
905 device_remove_file(f_dev, &dev_attr_loading); 940 device_remove_file(f_dev, &dev_attr_loading);
906err_del_bin_attr: 941err_del_bin_attr:
907 device_remove_bin_file(f_dev, &firmware_attr_data); 942 device_remove_bin_file(f_dev, &firmware_attr_data);
@@ -1129,6 +1164,8 @@ int uncache_firmware(const char *fw_name)
1129} 1164}
1130 1165
1131#ifdef CONFIG_PM_SLEEP 1166#ifdef CONFIG_PM_SLEEP
1167static ASYNC_DOMAIN_EXCLUSIVE(fw_cache_domain);
1168
1132static struct fw_cache_entry *alloc_fw_cache_entry(const char *name) 1169static struct fw_cache_entry *alloc_fw_cache_entry(const char *name)
1133{ 1170{
1134 struct fw_cache_entry *fce; 1171 struct fw_cache_entry *fce;
@@ -1142,17 +1179,27 @@ exit:
1142 return fce; 1179 return fce;
1143} 1180}
1144 1181
1145static int fw_cache_piggyback_on_request(const char *name) 1182static int __fw_entry_found(const char *name)
1146{ 1183{
1147 struct firmware_cache *fwc = &fw_cache; 1184 struct firmware_cache *fwc = &fw_cache;
1148 struct fw_cache_entry *fce; 1185 struct fw_cache_entry *fce;
1149 int ret = 0;
1150 1186
1151 spin_lock(&fwc->name_lock);
1152 list_for_each_entry(fce, &fwc->fw_names, list) { 1187 list_for_each_entry(fce, &fwc->fw_names, list) {
1153 if (!strcmp(fce->name, name)) 1188 if (!strcmp(fce->name, name))
1154 goto found; 1189 return 1;
1155 } 1190 }
1191 return 0;
1192}
1193
1194static int fw_cache_piggyback_on_request(const char *name)
1195{
1196 struct firmware_cache *fwc = &fw_cache;
1197 struct fw_cache_entry *fce;
1198 int ret = 0;
1199
1200 spin_lock(&fwc->name_lock);
1201 if (__fw_entry_found(name))
1202 goto found;
1156 1203
1157 fce = alloc_fw_cache_entry(name); 1204 fce = alloc_fw_cache_entry(name);
1158 if (fce) { 1205 if (fce) {
@@ -1185,12 +1232,6 @@ static void __async_dev_cache_fw_image(void *fw_entry,
1185 1232
1186 free_fw_cache_entry(fce); 1233 free_fw_cache_entry(fce);
1187 } 1234 }
1188
1189 spin_lock(&fwc->name_lock);
1190 fwc->cnt--;
1191 spin_unlock(&fwc->name_lock);
1192
1193 wake_up(&fwc->wait_queue);
1194} 1235}
1195 1236
1196/* called with dev->devres_lock held */ 1237/* called with dev->devres_lock held */
@@ -1229,11 +1270,19 @@ static void dev_cache_fw_image(struct device *dev, void *data)
1229 list_del(&fce->list); 1270 list_del(&fce->list);
1230 1271
1231 spin_lock(&fwc->name_lock); 1272 spin_lock(&fwc->name_lock);
1232 fwc->cnt++; 1273 /* only one cache entry for one firmware */
1233 list_add(&fce->list, &fwc->fw_names); 1274 if (!__fw_entry_found(fce->name)) {
1275 list_add(&fce->list, &fwc->fw_names);
1276 } else {
1277 free_fw_cache_entry(fce);
1278 fce = NULL;
1279 }
1234 spin_unlock(&fwc->name_lock); 1280 spin_unlock(&fwc->name_lock);
1235 1281
1236 async_schedule(__async_dev_cache_fw_image, (void *)fce); 1282 if (fce)
1283 async_schedule_domain(__async_dev_cache_fw_image,
1284 (void *)fce,
1285 &fw_cache_domain);
1237 } 1286 }
1238} 1287}
1239 1288
@@ -1275,6 +1324,9 @@ static void device_cache_fw_images(void)
1275 1324
1276 pr_debug("%s\n", __func__); 1325 pr_debug("%s\n", __func__);
1277 1326
1327 /* cancel uncache work */
1328 cancel_delayed_work_sync(&fwc->work);
1329
1278 /* 1330 /*
1279 * use small loading timeout for caching devices' firmware 1331 * use small loading timeout for caching devices' firmware
1280 * because all these firmware images have been loaded 1332 * because all these firmware images have been loaded
@@ -1292,21 +1344,7 @@ static void device_cache_fw_images(void)
1292 mutex_unlock(&fw_lock); 1344 mutex_unlock(&fw_lock);
1293 1345
1294 /* wait for completion of caching firmware for all devices */ 1346 /* wait for completion of caching firmware for all devices */
1295 spin_lock(&fwc->name_lock); 1347 async_synchronize_full_domain(&fw_cache_domain);
1296 for (;;) {
1297 prepare_to_wait(&fwc->wait_queue, &wait,
1298 TASK_UNINTERRUPTIBLE);
1299 if (!fwc->cnt)
1300 break;
1301
1302 spin_unlock(&fwc->name_lock);
1303
1304 schedule();
1305
1306 spin_lock(&fwc->name_lock);
1307 }
1308 spin_unlock(&fwc->name_lock);
1309 finish_wait(&fwc->wait_queue, &wait);
1310 1348
1311 loading_timeout = old_timeout; 1349 loading_timeout = old_timeout;
1312} 1350}
@@ -1394,9 +1432,7 @@ static void __init fw_cache_init(void)
1394#ifdef CONFIG_PM_SLEEP 1432#ifdef CONFIG_PM_SLEEP
1395 spin_lock_init(&fw_cache.name_lock); 1433 spin_lock_init(&fw_cache.name_lock);
1396 INIT_LIST_HEAD(&fw_cache.fw_names); 1434 INIT_LIST_HEAD(&fw_cache.fw_names);
1397 fw_cache.cnt = 0;
1398 1435
1399 init_waitqueue_head(&fw_cache.wait_queue);
1400 INIT_DELAYED_WORK(&fw_cache.work, 1436 INIT_DELAYED_WORK(&fw_cache.work,
1401 device_uncache_fw_images_work); 1437 device_uncache_fw_images_work);
1402 1438
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 8727e9c5eea..72c776f2a1f 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -83,9 +83,16 @@ EXPORT_SYMBOL_GPL(platform_get_resource);
83 */ 83 */
84int platform_get_irq(struct platform_device *dev, unsigned int num) 84int platform_get_irq(struct platform_device *dev, unsigned int num)
85{ 85{
86#ifdef CONFIG_SPARC
87 /* sparc does not have irqs represented as IORESOURCE_IRQ resources */
88 if (!dev || num >= dev->archdata.num_irqs)
89 return -ENXIO;
90 return dev->archdata.irqs[num];
91#else
86 struct resource *r = platform_get_resource(dev, IORESOURCE_IRQ, num); 92 struct resource *r = platform_get_resource(dev, IORESOURCE_IRQ, num);
87 93
88 return r ? r->start : -ENXIO; 94 return r ? r->start : -ENXIO;
95#endif
89} 96}
90EXPORT_SYMBOL_GPL(platform_get_irq); 97EXPORT_SYMBOL_GPL(platform_get_irq);
91 98
diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index c22b869245d..96b71b6536d 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -1862,7 +1862,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
1862 cpuidle_drv = cpuidle_driver_ref(); 1862 cpuidle_drv = cpuidle_driver_ref();
1863 if (!cpuidle_drv) { 1863 if (!cpuidle_drv) {
1864 ret = -ENODEV; 1864 ret = -ENODEV;
1865 goto out; 1865 goto err_drv;
1866 } 1866 }
1867 if (cpuidle_drv->state_count <= state) { 1867 if (cpuidle_drv->state_count <= state) {
1868 ret = -EINVAL; 1868 ret = -EINVAL;
@@ -1884,6 +1884,9 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
1884 1884
1885 err: 1885 err:
1886 cpuidle_driver_unref(); 1886 cpuidle_driver_unref();
1887
1888 err_drv:
1889 kfree(cpu_data);
1887 goto out; 1890 goto out;
1888} 1891}
1889 1892
diff --git a/drivers/base/power/qos.c b/drivers/base/power/qos.c
index 74a67e0019a..fbbd4ed2edf 100644
--- a/drivers/base/power/qos.c
+++ b/drivers/base/power/qos.c
@@ -451,7 +451,7 @@ int dev_pm_qos_add_ancestor_request(struct device *dev,
451 if (ancestor) 451 if (ancestor)
452 error = dev_pm_qos_add_request(ancestor, req, value); 452 error = dev_pm_qos_add_request(ancestor, req, value);
453 453
454 if (error) 454 if (error < 0)
455 req->dev = NULL; 455 req->dev = NULL;
456 456
457 return error; 457 return error;
diff --git a/drivers/base/regmap/Kconfig b/drivers/base/regmap/Kconfig
index 6be390bd8bd..f0d30543fcc 100644
--- a/drivers/base/regmap/Kconfig
+++ b/drivers/base/regmap/Kconfig
@@ -3,7 +3,7 @@
3# subsystems should select the appropriate symbols. 3# subsystems should select the appropriate symbols.
4 4
5config REGMAP 5config REGMAP
6 default y if (REGMAP_I2C || REGMAP_SPI) 6 default y if (REGMAP_I2C || REGMAP_SPI || REGMAP_MMIO || REGMAP_IRQ)
7 select LZO_COMPRESS 7 select LZO_COMPRESS
8 select LZO_DECOMPRESS 8 select LZO_DECOMPRESS
9 select IRQ_DOMAIN if REGMAP_IRQ 9 select IRQ_DOMAIN if REGMAP_IRQ
diff --git a/drivers/bcma/main.c b/drivers/bcma/main.c
index 432aeeedfd5..d865470bc95 100644
--- a/drivers/bcma/main.c
+++ b/drivers/bcma/main.c
@@ -158,9 +158,10 @@ static int bcma_register_cores(struct bcma_bus *bus)
158 158
159static void bcma_unregister_cores(struct bcma_bus *bus) 159static void bcma_unregister_cores(struct bcma_bus *bus)
160{ 160{
161 struct bcma_device *core; 161 struct bcma_device *core, *tmp;
162 162
163 list_for_each_entry(core, &bus->cores, list) { 163 list_for_each_entry_safe(core, tmp, &bus->cores, list) {
164 list_del(&core->list);
164 if (core->dev_registered) 165 if (core->dev_registered)
165 device_unregister(&core->dev); 166 device_unregister(&core->dev);
166 } 167 }
diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index f529407db93..824e09c4d0d 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -131,6 +131,7 @@ config BLK_CPQ_DA
131config BLK_CPQ_CISS_DA 131config BLK_CPQ_CISS_DA
132 tristate "Compaq Smart Array 5xxx support" 132 tristate "Compaq Smart Array 5xxx support"
133 depends on PCI 133 depends on PCI
134 select CHECK_SIGNATURE
134 help 135 help
135 This is the driver for Compaq Smart Array 5xxx controllers. 136 This is the driver for Compaq Smart Array 5xxx controllers.
136 Everyone using these boards should say Y here. 137 Everyone using these boards should say Y here.
@@ -166,8 +167,8 @@ config BLK_DEV_DAC960
166 module will be called DAC960. 167 module will be called DAC960.
167 168
168config BLK_DEV_UMEM 169config BLK_DEV_UMEM
169 tristate "Micro Memory MM5415 Battery Backed RAM support (EXPERIMENTAL)" 170 tristate "Micro Memory MM5415 Battery Backed RAM support"
170 depends on PCI && EXPERIMENTAL 171 depends on PCI
171 ---help--- 172 ---help---
172 Saying Y here will include support for the MM5415 family of 173 Saying Y here will include support for the MM5415 family of
173 battery backed (Non-volatile) RAM cards. 174 battery backed (Non-volatile) RAM cards.
@@ -430,8 +431,8 @@ config CDROM_PKTCDVD_BUFFERS
430 a disc is opened for writing. 431 a disc is opened for writing.
431 432
432config CDROM_PKTCDVD_WCACHE 433config CDROM_PKTCDVD_WCACHE
433 bool "Enable write caching (EXPERIMENTAL)" 434 bool "Enable write caching"
434 depends on CDROM_PKTCDVD && EXPERIMENTAL 435 depends on CDROM_PKTCDVD
435 help 436 help
436 If enabled, write caching will be set for the CD-R/W device. For now 437 If enabled, write caching will be set for the CD-R/W device. For now
437 this option is dangerous unless the CD-RW media is known good, as we 438 this option is dangerous unless the CD-RW media is known good, as we
@@ -508,8 +509,8 @@ config XEN_BLKDEV_BACKEND
508 509
509 510
510config VIRTIO_BLK 511config VIRTIO_BLK
511 tristate "Virtio block driver (EXPERIMENTAL)" 512 tristate "Virtio block driver"
512 depends on EXPERIMENTAL && VIRTIO 513 depends on VIRTIO
513 ---help--- 514 ---help---
514 This is the virtual block driver for virtio. It can be used with 515 This is the virtual block driver for virtio. It can be used with
515 lguest or QEMU based VMMs (like KVM or Xen). Say Y or M. 516 lguest or QEMU based VMMs (like KVM or Xen). Say Y or M.
@@ -528,7 +529,7 @@ config BLK_DEV_HD
528 529
529config BLK_DEV_RBD 530config BLK_DEV_RBD
530 tristate "Rados block device (RBD)" 531 tristate "Rados block device (RBD)"
531 depends on INET && EXPERIMENTAL && BLOCK 532 depends on INET && BLOCK
532 select CEPH_LIB 533 select CEPH_LIB
533 select LIBCRC32C 534 select LIBCRC32C
534 select CRYPTO_AES 535 select CRYPTO_AES
diff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c
index 3804a0af3ef..9fe4f186555 100644
--- a/drivers/block/aoe/aoecmd.c
+++ b/drivers/block/aoe/aoecmd.c
@@ -935,7 +935,7 @@ aoe_end_request(struct aoedev *d, struct request *rq, int fastfail)
935 935
936 /* cf. http://lkml.org/lkml/2006/10/31/28 */ 936 /* cf. http://lkml.org/lkml/2006/10/31/28 */
937 if (!fastfail) 937 if (!fastfail)
938 q->request_fn(q); 938 __blk_run_queue(q);
939} 939}
940 940
941static void 941static void
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index b0f553b26d0..ca83f96756a 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -5205,7 +5205,6 @@ static void cciss_shutdown(struct pci_dev *pdev)
5205 return; 5205 return;
5206 } 5206 }
5207 /* write all data in the battery backed cache to disk */ 5207 /* write all data in the battery backed cache to disk */
5208 memset(flush_buf, 0, 4);
5209 return_code = sendcmd_withirq(h, CCISS_CACHE_FLUSH, flush_buf, 5208 return_code = sendcmd_withirq(h, CCISS_CACHE_FLUSH, flush_buf,
5210 4, 0, CTLR_LUNID, TYPE_CMD); 5209 4, 0, CTLR_LUNID, TYPE_CMD);
5211 kfree(flush_buf); 5210 kfree(flush_buf);
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index 17c675c5229..2ddd64a9ffd 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -4109,12 +4109,19 @@ static struct platform_driver floppy_driver = {
4109 4109
4110static struct platform_device floppy_device[N_DRIVE]; 4110static struct platform_device floppy_device[N_DRIVE];
4111 4111
4112static bool floppy_available(int drive)
4113{
4114 if (!(allowed_drive_mask & (1 << drive)))
4115 return false;
4116 if (fdc_state[FDC(drive)].version == FDC_NONE)
4117 return false;
4118 return true;
4119}
4120
4112static struct kobject *floppy_find(dev_t dev, int *part, void *data) 4121static struct kobject *floppy_find(dev_t dev, int *part, void *data)
4113{ 4122{
4114 int drive = (*part & 3) | ((*part & 0x80) >> 5); 4123 int drive = (*part & 3) | ((*part & 0x80) >> 5);
4115 if (drive >= N_DRIVE || 4124 if (drive >= N_DRIVE || !floppy_available(drive))
4116 !(allowed_drive_mask & (1 << drive)) ||
4117 fdc_state[FDC(drive)].version == FDC_NONE)
4118 return NULL; 4125 return NULL;
4119 if (((*part >> 2) & 0x1f) >= ARRAY_SIZE(floppy_type)) 4126 if (((*part >> 2) & 0x1f) >= ARRAY_SIZE(floppy_type))
4120 return NULL; 4127 return NULL;
@@ -4124,8 +4131,7 @@ static struct kobject *floppy_find(dev_t dev, int *part, void *data)
4124 4131
4125static int __init do_floppy_init(void) 4132static int __init do_floppy_init(void)
4126{ 4133{
4127 int i, unit, drive; 4134 int i, unit, drive, err;
4128 int err, dr;
4129 4135
4130 set_debugt(); 4136 set_debugt();
4131 interruptjiffies = resultjiffies = jiffies; 4137 interruptjiffies = resultjiffies = jiffies;
@@ -4137,34 +4143,32 @@ static int __init do_floppy_init(void)
4137 4143
4138 raw_cmd = NULL; 4144 raw_cmd = NULL;
4139 4145
4140 for (dr = 0; dr < N_DRIVE; dr++) { 4146 floppy_wq = alloc_ordered_workqueue("floppy", 0);
4141 disks[dr] = alloc_disk(1); 4147 if (!floppy_wq)
4142 if (!disks[dr]) { 4148 return -ENOMEM;
4143 err = -ENOMEM;
4144 goto out_put_disk;
4145 }
4146 4149
4147 floppy_wq = alloc_ordered_workqueue("floppy", 0); 4150 for (drive = 0; drive < N_DRIVE; drive++) {
4148 if (!floppy_wq) { 4151 disks[drive] = alloc_disk(1);
4152 if (!disks[drive]) {
4149 err = -ENOMEM; 4153 err = -ENOMEM;
4150 goto out_put_disk; 4154 goto out_put_disk;
4151 } 4155 }
4152 4156
4153 disks[dr]->queue = blk_init_queue(do_fd_request, &floppy_lock); 4157 disks[drive]->queue = blk_init_queue(do_fd_request, &floppy_lock);
4154 if (!disks[dr]->queue) { 4158 if (!disks[drive]->queue) {
4155 err = -ENOMEM; 4159 err = -ENOMEM;
4156 goto out_destroy_workq; 4160 goto out_put_disk;
4157 } 4161 }
4158 4162
4159 blk_queue_max_hw_sectors(disks[dr]->queue, 64); 4163 blk_queue_max_hw_sectors(disks[drive]->queue, 64);
4160 disks[dr]->major = FLOPPY_MAJOR; 4164 disks[drive]->major = FLOPPY_MAJOR;
4161 disks[dr]->first_minor = TOMINOR(dr); 4165 disks[drive]->first_minor = TOMINOR(drive);
4162 disks[dr]->fops = &floppy_fops; 4166 disks[drive]->fops = &floppy_fops;
4163 sprintf(disks[dr]->disk_name, "fd%d", dr); 4167 sprintf(disks[drive]->disk_name, "fd%d", drive);
4164 4168
4165 init_timer(&motor_off_timer[dr]); 4169 init_timer(&motor_off_timer[drive]);
4166 motor_off_timer[dr].data = dr; 4170 motor_off_timer[drive].data = drive;
4167 motor_off_timer[dr].function = motor_off_callback; 4171 motor_off_timer[drive].function = motor_off_callback;
4168 } 4172 }
4169 4173
4170 err = register_blkdev(FLOPPY_MAJOR, "fd"); 4174 err = register_blkdev(FLOPPY_MAJOR, "fd");
@@ -4282,9 +4286,7 @@ static int __init do_floppy_init(void)
4282 } 4286 }
4283 4287
4284 for (drive = 0; drive < N_DRIVE; drive++) { 4288 for (drive = 0; drive < N_DRIVE; drive++) {
4285 if (!(allowed_drive_mask & (1 << drive))) 4289 if (!floppy_available(drive))
4286 continue;
4287 if (fdc_state[FDC(drive)].version == FDC_NONE)
4288 continue; 4290 continue;
4289 4291
4290 floppy_device[drive].name = floppy_device_name; 4292 floppy_device[drive].name = floppy_device_name;
@@ -4293,7 +4295,7 @@ static int __init do_floppy_init(void)
4293 4295
4294 err = platform_device_register(&floppy_device[drive]); 4296 err = platform_device_register(&floppy_device[drive]);
4295 if (err) 4297 if (err)
4296 goto out_release_dma; 4298 goto out_remove_drives;
4297 4299
4298 err = device_create_file(&floppy_device[drive].dev, 4300 err = device_create_file(&floppy_device[drive].dev,
4299 &dev_attr_cmos); 4301 &dev_attr_cmos);
@@ -4311,28 +4313,33 @@ static int __init do_floppy_init(void)
4311 4313
4312out_unreg_platform_dev: 4314out_unreg_platform_dev:
4313 platform_device_unregister(&floppy_device[drive]); 4315 platform_device_unregister(&floppy_device[drive]);
4316out_remove_drives:
4317 while (drive--) {
4318 if (floppy_available(drive)) {
4319 del_gendisk(disks[drive]);
4320 device_remove_file(&floppy_device[drive].dev, &dev_attr_cmos);
4321 platform_device_unregister(&floppy_device[drive]);
4322 }
4323 }
4314out_release_dma: 4324out_release_dma:
4315 if (atomic_read(&usage_count)) 4325 if (atomic_read(&usage_count))
4316 floppy_release_irq_and_dma(); 4326 floppy_release_irq_and_dma();
4317out_unreg_region: 4327out_unreg_region:
4318 blk_unregister_region(MKDEV(FLOPPY_MAJOR, 0), 256); 4328 blk_unregister_region(MKDEV(FLOPPY_MAJOR, 0), 256);
4319 platform_driver_unregister(&floppy_driver); 4329 platform_driver_unregister(&floppy_driver);
4320out_destroy_workq:
4321 destroy_workqueue(floppy_wq);
4322out_unreg_blkdev: 4330out_unreg_blkdev:
4323 unregister_blkdev(FLOPPY_MAJOR, "fd"); 4331 unregister_blkdev(FLOPPY_MAJOR, "fd");
4324out_put_disk: 4332out_put_disk:
4325 while (dr--) { 4333 destroy_workqueue(floppy_wq);
4326 del_timer_sync(&motor_off_timer[dr]); 4334 for (drive = 0; drive < N_DRIVE; drive++) {
4327 if (disks[dr]->queue) { 4335 if (!disks[drive])
4328 blk_cleanup_queue(disks[dr]->queue); 4336 break;
4329 /* 4337 if (disks[drive]->queue) {
4330 * put_disk() is not paired with add_disk() and 4338 del_timer_sync(&motor_off_timer[drive]);
4331 * will put queue reference one extra time. fix it. 4339 blk_cleanup_queue(disks[drive]->queue);
4332 */ 4340 disks[drive]->queue = NULL;
4333 disks[dr]->queue = NULL;
4334 } 4341 }
4335 put_disk(disks[dr]); 4342 put_disk(disks[drive]);
4336 } 4343 }
4337 return err; 4344 return err;
4338} 4345}
@@ -4548,11 +4555,12 @@ static void __exit floppy_module_exit(void)
4548 unregister_blkdev(FLOPPY_MAJOR, "fd"); 4555 unregister_blkdev(FLOPPY_MAJOR, "fd");
4549 platform_driver_unregister(&floppy_driver); 4556 platform_driver_unregister(&floppy_driver);
4550 4557
4558 destroy_workqueue(floppy_wq);
4559
4551 for (drive = 0; drive < N_DRIVE; drive++) { 4560 for (drive = 0; drive < N_DRIVE; drive++) {
4552 del_timer_sync(&motor_off_timer[drive]); 4561 del_timer_sync(&motor_off_timer[drive]);
4553 4562
4554 if ((allowed_drive_mask & (1 << drive)) && 4563 if (floppy_available(drive)) {
4555 fdc_state[FDC(drive)].version != FDC_NONE) {
4556 del_gendisk(disks[drive]); 4564 del_gendisk(disks[drive]);
4557 device_remove_file(&floppy_device[drive].dev, &dev_attr_cmos); 4565 device_remove_file(&floppy_device[drive].dev, &dev_attr_cmos);
4558 platform_device_unregister(&floppy_device[drive]); 4566 platform_device_unregister(&floppy_device[drive]);
@@ -4572,7 +4580,6 @@ static void __exit floppy_module_exit(void)
4572 4580
4573 cancel_delayed_work_sync(&fd_timeout); 4581 cancel_delayed_work_sync(&fd_timeout);
4574 cancel_delayed_work_sync(&fd_timer); 4582 cancel_delayed_work_sync(&fd_timer);
4575 destroy_workqueue(floppy_wq);
4576 4583
4577 if (atomic_read(&usage_count)) 4584 if (atomic_read(&usage_count))
4578 floppy_release_irq_and_dma(); 4585 floppy_release_irq_and_dma();
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index e9d594fd12c..54046e51160 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -976,8 +976,21 @@ static int loop_clr_fd(struct loop_device *lo)
976 if (lo->lo_state != Lo_bound) 976 if (lo->lo_state != Lo_bound)
977 return -ENXIO; 977 return -ENXIO;
978 978
979 if (lo->lo_refcnt > 1) /* we needed one fd for the ioctl */ 979 /*
980 return -EBUSY; 980 * If we've explicitly asked to tear down the loop device,
981 * and it has an elevated reference count, set it for auto-teardown when
982 * the last reference goes away. This stops $!~#$@ udev from
983 * preventing teardown because it decided that it needs to run blkid on
984 * the loopback device whenever they appear. xfstests is notorious for
985 * failing tests because blkid via udev races with a losetup
986 * <dev>/do something like mkfs/losetup -d <dev> causing the losetup -d
987 * command to fail with EBUSY.
988 */
989 if (lo->lo_refcnt > 1) {
990 lo->lo_flags |= LO_FLAGS_AUTOCLEAR;
991 mutex_unlock(&lo->lo_ctl_mutex);
992 return 0;
993 }
981 994
982 if (filp == NULL) 995 if (filp == NULL)
983 return -EINVAL; 996 return -EINVAL;
diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c
index f946d31d691..9694dd99bbb 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -559,7 +559,7 @@ static void mtip_timeout_function(unsigned long int data)
559 struct mtip_cmd *command; 559 struct mtip_cmd *command;
560 int tag, cmdto_cnt = 0; 560 int tag, cmdto_cnt = 0;
561 unsigned int bit, group; 561 unsigned int bit, group;
562 unsigned int num_command_slots = port->dd->slot_groups * 32; 562 unsigned int num_command_slots;
563 unsigned long to, tagaccum[SLOTBITS_IN_LONGS]; 563 unsigned long to, tagaccum[SLOTBITS_IN_LONGS];
564 564
565 if (unlikely(!port)) 565 if (unlikely(!port))
@@ -572,6 +572,7 @@ static void mtip_timeout_function(unsigned long int data)
572 } 572 }
573 /* clear the tag accumulator */ 573 /* clear the tag accumulator */
574 memset(tagaccum, 0, SLOTBITS_IN_LONGS * sizeof(long)); 574 memset(tagaccum, 0, SLOTBITS_IN_LONGS * sizeof(long));
575 num_command_slots = port->dd->slot_groups * 32;
575 576
576 for (tag = 0; tag < num_command_slots; tag++) { 577 for (tag = 0; tag < num_command_slots; tag++) {
577 /* 578 /*
@@ -2035,8 +2036,9 @@ static unsigned int implicit_sector(unsigned char command,
2035 } 2036 }
2036 return rv; 2037 return rv;
2037} 2038}
2038 2039static void mtip_set_timeout(struct driver_data *dd,
2039static void mtip_set_timeout(struct host_to_dev_fis *fis, unsigned int *timeout) 2040 struct host_to_dev_fis *fis,
2041 unsigned int *timeout, u8 erasemode)
2040{ 2042{
2041 switch (fis->command) { 2043 switch (fis->command) {
2042 case ATA_CMD_DOWNLOAD_MICRO: 2044 case ATA_CMD_DOWNLOAD_MICRO:
@@ -2044,7 +2046,10 @@ static void mtip_set_timeout(struct host_to_dev_fis *fis, unsigned int *timeout)
2044 break; 2046 break;
2045 case ATA_CMD_SEC_ERASE_UNIT: 2047 case ATA_CMD_SEC_ERASE_UNIT:
2046 case 0xFC: 2048 case 0xFC:
2047 *timeout = 240000; /* 4 minutes */ 2049 if (erasemode)
2050 *timeout = ((*(dd->port->identify + 90) * 2) * 60000);
2051 else
2052 *timeout = ((*(dd->port->identify + 89) * 2) * 60000);
2048 break; 2053 break;
2049 case ATA_CMD_STANDBYNOW1: 2054 case ATA_CMD_STANDBYNOW1:
2050 *timeout = 120000; /* 2 minutes */ 2055 *timeout = 120000; /* 2 minutes */
@@ -2087,6 +2092,7 @@ static int exec_drive_taskfile(struct driver_data *dd,
2087 unsigned int transfer_size; 2092 unsigned int transfer_size;
2088 unsigned long task_file_data; 2093 unsigned long task_file_data;
2089 int intotal = outtotal + req_task->out_size; 2094 int intotal = outtotal + req_task->out_size;
2095 int erasemode = 0;
2090 2096
2091 taskout = req_task->out_size; 2097 taskout = req_task->out_size;
2092 taskin = req_task->in_size; 2098 taskin = req_task->in_size;
@@ -2212,7 +2218,13 @@ static int exec_drive_taskfile(struct driver_data *dd,
2212 fis.lba_hi, 2218 fis.lba_hi,
2213 fis.device); 2219 fis.device);
2214 2220
2215 mtip_set_timeout(&fis, &timeout); 2221 /* check for erase mode support during secure erase.*/
2222 if ((fis.command == ATA_CMD_SEC_ERASE_UNIT) && outbuf &&
2223 (outbuf[0] & MTIP_SEC_ERASE_MODE)) {
2224 erasemode = 1;
2225 }
2226
2227 mtip_set_timeout(dd, &fis, &timeout, erasemode);
2216 2228
2217 /* Determine the correct transfer size.*/ 2229 /* Determine the correct transfer size.*/
2218 if (force_single_sector) 2230 if (force_single_sector)
@@ -2428,7 +2440,7 @@ static int mtip_hw_ioctl(struct driver_data *dd, unsigned int cmd,
2428 * return value 2440 * return value
2429 * None 2441 * None
2430 */ 2442 */
2431static void mtip_hw_submit_io(struct driver_data *dd, sector_t start, 2443static void mtip_hw_submit_io(struct driver_data *dd, sector_t sector,
2432 int nsect, int nents, int tag, void *callback, 2444 int nsect, int nents, int tag, void *callback,
2433 void *data, int dir) 2445 void *data, int dir)
2434{ 2446{
@@ -2436,6 +2448,7 @@ static void mtip_hw_submit_io(struct driver_data *dd, sector_t start,
2436 struct mtip_port *port = dd->port; 2448 struct mtip_port *port = dd->port;
2437 struct mtip_cmd *command = &port->commands[tag]; 2449 struct mtip_cmd *command = &port->commands[tag];
2438 int dma_dir = (dir == READ) ? DMA_FROM_DEVICE : DMA_TO_DEVICE; 2450 int dma_dir = (dir == READ) ? DMA_FROM_DEVICE : DMA_TO_DEVICE;
2451 u64 start = sector;
2439 2452
2440 /* Map the scatter list for DMA access */ 2453 /* Map the scatter list for DMA access */
2441 nents = dma_map_sg(&dd->pdev->dev, command->sg, nents, dma_dir); 2454 nents = dma_map_sg(&dd->pdev->dev, command->sg, nents, dma_dir);
@@ -2454,8 +2467,12 @@ static void mtip_hw_submit_io(struct driver_data *dd, sector_t start,
2454 fis->opts = 1 << 7; 2467 fis->opts = 1 << 7;
2455 fis->command = 2468 fis->command =
2456 (dir == READ ? ATA_CMD_FPDMA_READ : ATA_CMD_FPDMA_WRITE); 2469 (dir == READ ? ATA_CMD_FPDMA_READ : ATA_CMD_FPDMA_WRITE);
2457 *((unsigned int *) &fis->lba_low) = (start & 0xFFFFFF); 2470 fis->lba_low = start & 0xFF;
2458 *((unsigned int *) &fis->lba_low_ex) = ((start >> 24) & 0xFFFFFF); 2471 fis->lba_mid = (start >> 8) & 0xFF;
2472 fis->lba_hi = (start >> 16) & 0xFF;
2473 fis->lba_low_ex = (start >> 24) & 0xFF;
2474 fis->lba_mid_ex = (start >> 32) & 0xFF;
2475 fis->lba_hi_ex = (start >> 40) & 0xFF;
2459 fis->device = 1 << 6; 2476 fis->device = 1 << 6;
2460 fis->features = nsect & 0xFF; 2477 fis->features = nsect & 0xFF;
2461 fis->features_ex = (nsect >> 8) & 0xFF; 2478 fis->features_ex = (nsect >> 8) & 0xFF;
diff --git a/drivers/block/mtip32xx/mtip32xx.h b/drivers/block/mtip32xx/mtip32xx.h
index 18627a1d04c..b1742640556 100644
--- a/drivers/block/mtip32xx/mtip32xx.h
+++ b/drivers/block/mtip32xx/mtip32xx.h
@@ -33,6 +33,9 @@
33/* offset of Device Control register in PCIe extended capabilites space */ 33/* offset of Device Control register in PCIe extended capabilites space */
34#define PCIE_CONFIG_EXT_DEVICE_CONTROL_OFFSET 0x48 34#define PCIE_CONFIG_EXT_DEVICE_CONTROL_OFFSET 0x48
35 35
36/* check for erase mode support during secure erase */
37#define MTIP_SEC_ERASE_MODE 0x2
38
36/* # of times to retry timed out/failed IOs */ 39/* # of times to retry timed out/failed IOs */
37#define MTIP_MAX_RETRIES 2 40#define MTIP_MAX_RETRIES 2
38 41
@@ -152,14 +155,14 @@ enum {
152 MTIP_DDF_REBUILD_FAILED_BIT = 8, 155 MTIP_DDF_REBUILD_FAILED_BIT = 8,
153}; 156};
154 157
155__packed struct smart_attr{ 158struct smart_attr {
156 u8 attr_id; 159 u8 attr_id;
157 u16 flags; 160 u16 flags;
158 u8 cur; 161 u8 cur;
159 u8 worst; 162 u8 worst;
160 u32 data; 163 u32 data;
161 u8 res[3]; 164 u8 res[3];
162}; 165} __packed;
163 166
164/* Register Frame Information Structure (FIS), host to device. */ 167/* Register Frame Information Structure (FIS), host to device. */
165struct host_to_dev_fis { 168struct host_to_dev_fis {
diff --git a/drivers/block/xen-blkback/common.h b/drivers/block/xen-blkback/common.h
index 9ad3b5ec1dc..9a54623e52d 100644
--- a/drivers/block/xen-blkback/common.h
+++ b/drivers/block/xen-blkback/common.h
@@ -158,8 +158,8 @@ struct xen_vbd {
158 struct block_device *bdev; 158 struct block_device *bdev;
159 /* Cached size parameter. */ 159 /* Cached size parameter. */
160 sector_t size; 160 sector_t size;
161 bool flush_support; 161 unsigned int flush_support:1;
162 bool discard_secure; 162 unsigned int discard_secure:1;
163}; 163};
164 164
165struct backend_info; 165struct backend_info;
diff --git a/drivers/block/xen-blkback/xenbus.c b/drivers/block/xen-blkback/xenbus.c
index 4f66171c668..f58434c2617 100644
--- a/drivers/block/xen-blkback/xenbus.c
+++ b/drivers/block/xen-blkback/xenbus.c
@@ -105,11 +105,10 @@ static struct xen_blkif *xen_blkif_alloc(domid_t domid)
105{ 105{
106 struct xen_blkif *blkif; 106 struct xen_blkif *blkif;
107 107
108 blkif = kmem_cache_alloc(xen_blkif_cachep, GFP_KERNEL); 108 blkif = kmem_cache_zalloc(xen_blkif_cachep, GFP_KERNEL);
109 if (!blkif) 109 if (!blkif)
110 return ERR_PTR(-ENOMEM); 110 return ERR_PTR(-ENOMEM);
111 111
112 memset(blkif, 0, sizeof(*blkif));
113 blkif->domid = domid; 112 blkif->domid = domid;
114 spin_lock_init(&blkif->blk_ring_lock); 113 spin_lock_init(&blkif->blk_ring_lock);
115 atomic_set(&blkif->refcnt, 1); 114 atomic_set(&blkif->refcnt, 1);
@@ -196,7 +195,7 @@ static void xen_blkif_disconnect(struct xen_blkif *blkif)
196 } 195 }
197} 196}
198 197
199void xen_blkif_free(struct xen_blkif *blkif) 198static void xen_blkif_free(struct xen_blkif *blkif)
200{ 199{
201 if (!atomic_dec_and_test(&blkif->refcnt)) 200 if (!atomic_dec_and_test(&blkif->refcnt))
202 BUG(); 201 BUG();
@@ -257,7 +256,7 @@ static struct attribute_group xen_vbdstat_group = {
257VBD_SHOW(physical_device, "%x:%x\n", be->major, be->minor); 256VBD_SHOW(physical_device, "%x:%x\n", be->major, be->minor);
258VBD_SHOW(mode, "%s\n", be->mode); 257VBD_SHOW(mode, "%s\n", be->mode);
259 258
260int xenvbd_sysfs_addif(struct xenbus_device *dev) 259static int xenvbd_sysfs_addif(struct xenbus_device *dev)
261{ 260{
262 int error; 261 int error;
263 262
@@ -281,7 +280,7 @@ fail1: device_remove_file(&dev->dev, &dev_attr_physical_device);
281 return error; 280 return error;
282} 281}
283 282
284void xenvbd_sysfs_delif(struct xenbus_device *dev) 283static void xenvbd_sysfs_delif(struct xenbus_device *dev)
285{ 284{
286 sysfs_remove_group(&dev->dev.kobj, &xen_vbdstat_group); 285 sysfs_remove_group(&dev->dev.kobj, &xen_vbdstat_group);
287 device_remove_file(&dev->dev, &dev_attr_mode); 286 device_remove_file(&dev->dev, &dev_attr_mode);
diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c
index fc2de5528dc..b00000e8aef 100644
--- a/drivers/bluetooth/ath3k.c
+++ b/drivers/bluetooth/ath3k.c
@@ -67,6 +67,7 @@ static struct usb_device_id ath3k_table[] = {
67 { USB_DEVICE(0x13d3, 0x3304) }, 67 { USB_DEVICE(0x13d3, 0x3304) },
68 { USB_DEVICE(0x0930, 0x0215) }, 68 { USB_DEVICE(0x0930, 0x0215) },
69 { USB_DEVICE(0x0489, 0xE03D) }, 69 { USB_DEVICE(0x0489, 0xE03D) },
70 { USB_DEVICE(0x0489, 0xE027) },
70 71
71 /* Atheros AR9285 Malbec with sflash firmware */ 72 /* Atheros AR9285 Malbec with sflash firmware */
72 { USB_DEVICE(0x03F0, 0x311D) }, 73 { USB_DEVICE(0x03F0, 0x311D) },
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index debda27df9b..ee82f2fb65f 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -124,6 +124,7 @@ static struct usb_device_id blacklist_table[] = {
124 { USB_DEVICE(0x13d3, 0x3304), .driver_info = BTUSB_IGNORE }, 124 { USB_DEVICE(0x13d3, 0x3304), .driver_info = BTUSB_IGNORE },
125 { USB_DEVICE(0x0930, 0x0215), .driver_info = BTUSB_IGNORE }, 125 { USB_DEVICE(0x0930, 0x0215), .driver_info = BTUSB_IGNORE },
126 { USB_DEVICE(0x0489, 0xe03d), .driver_info = BTUSB_IGNORE }, 126 { USB_DEVICE(0x0489, 0xe03d), .driver_info = BTUSB_IGNORE },
127 { USB_DEVICE(0x0489, 0xe027), .driver_info = BTUSB_IGNORE },
127 128
128 /* Atheros AR9285 Malbec with sflash firmware */ 129 /* Atheros AR9285 Malbec with sflash firmware */
129 { USB_DEVICE(0x03f0, 0x311d), .driver_info = BTUSB_IGNORE }, 130 { USB_DEVICE(0x03f0, 0x311d), .driver_info = BTUSB_IGNORE },
diff --git a/drivers/bus/omap-ocp2scp.c b/drivers/bus/omap-ocp2scp.c
index ff63560b846..0c48b0e05ed 100644
--- a/drivers/bus/omap-ocp2scp.c
+++ b/drivers/bus/omap-ocp2scp.c
@@ -22,6 +22,26 @@
22#include <linux/pm_runtime.h> 22#include <linux/pm_runtime.h>
23#include <linux/of.h> 23#include <linux/of.h>
24#include <linux/of_platform.h> 24#include <linux/of_platform.h>
25#include <linux/platform_data/omap_ocp2scp.h>
26
27/**
28 * _count_resources - count for the number of resources
29 * @res: struct resource *
30 *
31 * Count and return the number of resources populated for the device that is
32 * connected to ocp2scp.
33 */
34static unsigned _count_resources(struct resource *res)
35{
36 int cnt = 0;
37
38 while (res->start != res->end) {
39 cnt++;
40 res++;
41 }
42
43 return cnt;
44}
25 45
26static int ocp2scp_remove_devices(struct device *dev, void *c) 46static int ocp2scp_remove_devices(struct device *dev, void *c)
27{ 47{
@@ -34,20 +54,62 @@ static int ocp2scp_remove_devices(struct device *dev, void *c)
34 54
35static int __devinit omap_ocp2scp_probe(struct platform_device *pdev) 55static int __devinit omap_ocp2scp_probe(struct platform_device *pdev)
36{ 56{
37 int ret; 57 int ret;
38 struct device_node *np = pdev->dev.of_node; 58 unsigned res_cnt, i;
59 struct device_node *np = pdev->dev.of_node;
60 struct platform_device *pdev_child;
61 struct omap_ocp2scp_platform_data *pdata = pdev->dev.platform_data;
62 struct omap_ocp2scp_dev *dev;
39 63
40 if (np) { 64 if (np) {
41 ret = of_platform_populate(np, NULL, NULL, &pdev->dev); 65 ret = of_platform_populate(np, NULL, NULL, &pdev->dev);
42 if (ret) { 66 if (ret) {
43 dev_err(&pdev->dev, "failed to add resources for ocp2scp child\n"); 67 dev_err(&pdev->dev,
68 "failed to add resources for ocp2scp child\n");
44 goto err0; 69 goto err0;
45 } 70 }
71 } else if (pdata) {
72 for (i = 0, dev = *pdata->devices; i < pdata->dev_cnt; i++,
73 dev++) {
74 res_cnt = _count_resources(dev->res);
75
76 pdev_child = platform_device_alloc(dev->drv_name,
77 PLATFORM_DEVID_AUTO);
78 if (!pdev_child) {
79 dev_err(&pdev->dev,
80 "failed to allocate mem for ocp2scp child\n");
81 goto err0;
82 }
83
84 ret = platform_device_add_resources(pdev_child,
85 dev->res, res_cnt);
86 if (ret) {
87 dev_err(&pdev->dev,
88 "failed to add resources for ocp2scp child\n");
89 goto err1;
90 }
91
92 pdev_child->dev.parent = &pdev->dev;
93
94 ret = platform_device_add(pdev_child);
95 if (ret) {
96 dev_err(&pdev->dev,
97 "failed to register ocp2scp child device\n");
98 goto err1;
99 }
100 }
101 } else {
102 dev_err(&pdev->dev, "OCP2SCP initialized without plat data\n");
103 return -EINVAL;
46 } 104 }
105
47 pm_runtime_enable(&pdev->dev); 106 pm_runtime_enable(&pdev->dev);
48 107
49 return 0; 108 return 0;
50 109
110err1:
111 platform_device_put(pdev_child);
112
51err0: 113err0:
52 device_for_each_child(&pdev->dev, NULL, ocp2scp_remove_devices); 114 device_for_each_child(&pdev->dev, NULL, ocp2scp_remove_devices);
53 115
diff --git a/drivers/char/Makefile b/drivers/char/Makefile
index d0b27a39f1d..7ff1d0d208a 100644
--- a/drivers/char/Makefile
+++ b/drivers/char/Makefile
@@ -52,7 +52,6 @@ obj-$(CONFIG_TELCLOCK) += tlclk.o
52obj-$(CONFIG_MWAVE) += mwave/ 52obj-$(CONFIG_MWAVE) += mwave/
53obj-$(CONFIG_AGP) += agp/ 53obj-$(CONFIG_AGP) += agp/
54obj-$(CONFIG_PCMCIA) += pcmcia/ 54obj-$(CONFIG_PCMCIA) += pcmcia/
55obj-$(CONFIG_IPMI_HANDLER) += ipmi/
56 55
57obj-$(CONFIG_HANGCHECK_TIMER) += hangcheck-timer.o 56obj-$(CONFIG_HANGCHECK_TIMER) += hangcheck-timer.o
58obj-$(CONFIG_TCG_TPM) += tpm/ 57obj-$(CONFIG_TCG_TPM) += tpm/
diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c
index e01f5eaaec8..38390f7c6ab 100644
--- a/drivers/char/agp/intel-gtt.c
+++ b/drivers/char/agp/intel-gtt.c
@@ -667,7 +667,7 @@ static int intel_gtt_init(void)
667 gtt_map_size = intel_private.base.gtt_total_entries * 4; 667 gtt_map_size = intel_private.base.gtt_total_entries * 4;
668 668
669 intel_private.gtt = NULL; 669 intel_private.gtt = NULL;
670 if (INTEL_GTT_GEN < 6) 670 if (INTEL_GTT_GEN < 6 && INTEL_GTT_GEN > 2)
671 intel_private.gtt = ioremap_wc(intel_private.gtt_bus_addr, 671 intel_private.gtt = ioremap_wc(intel_private.gtt_bus_addr,
672 gtt_map_size); 672 gtt_map_size);
673 if (intel_private.gtt == NULL) 673 if (intel_private.gtt == NULL)
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index 2c29942b132..a0c84bb3085 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -1880,7 +1880,7 @@ int ipmi_request_supply_msgs(ipmi_user_t user,
1880 struct ipmi_recv_msg *supplied_recv, 1880 struct ipmi_recv_msg *supplied_recv,
1881 int priority) 1881 int priority)
1882{ 1882{
1883 unsigned char saddr, lun; 1883 unsigned char saddr = 0, lun = 0;
1884 int rv; 1884 int rv;
1885 1885
1886 if (!user) 1886 if (!user)
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index 83f85cf7fb1..32a6c7e256b 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -2424,6 +2424,38 @@ static void ipmi_pci_cleanup(struct smi_info *info)
2424 pci_disable_device(pdev); 2424 pci_disable_device(pdev);
2425} 2425}
2426 2426
2427static int __devinit ipmi_pci_probe_regspacing(struct smi_info *info)
2428{
2429 if (info->si_type == SI_KCS) {
2430 unsigned char status;
2431 int regspacing;
2432
2433 info->io.regsize = DEFAULT_REGSIZE;
2434 info->io.regshift = 0;
2435 info->io_size = 2;
2436 info->handlers = &kcs_smi_handlers;
2437
2438 /* detect 1, 4, 16byte spacing */
2439 for (regspacing = DEFAULT_REGSPACING; regspacing <= 16;) {
2440 info->io.regspacing = regspacing;
2441 if (info->io_setup(info)) {
2442 dev_err(info->dev,
2443 "Could not setup I/O space\n");
2444 return DEFAULT_REGSPACING;
2445 }
2446 /* write invalid cmd */
2447 info->io.outputb(&info->io, 1, 0x10);
2448 /* read status back */
2449 status = info->io.inputb(&info->io, 1);
2450 info->io_cleanup(info);
2451 if (status)
2452 return regspacing;
2453 regspacing *= 4;
2454 }
2455 }
2456 return DEFAULT_REGSPACING;
2457}
2458
2427static int __devinit ipmi_pci_probe(struct pci_dev *pdev, 2459static int __devinit ipmi_pci_probe(struct pci_dev *pdev,
2428 const struct pci_device_id *ent) 2460 const struct pci_device_id *ent)
2429{ 2461{
@@ -2476,8 +2508,8 @@ static int __devinit ipmi_pci_probe(struct pci_dev *pdev,
2476 } 2508 }
2477 info->io.addr_data = pci_resource_start(pdev, 0); 2509 info->io.addr_data = pci_resource_start(pdev, 0);
2478 2510
2479 info->io.regspacing = DEFAULT_REGSPACING; 2511 info->io.regspacing = ipmi_pci_probe_regspacing(info);
2480 info->io.regsize = DEFAULT_REGSPACING; 2512 info->io.regsize = DEFAULT_REGSIZE;
2481 info->io.regshift = 0; 2513 info->io.regshift = 0;
2482 2514
2483 info->irq = pdev->irq; 2515 info->irq = pdev->irq;
diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
index 320debbe32f..9b4f0116ff2 100644
--- a/drivers/char/sonypi.c
+++ b/drivers/char/sonypi.c
@@ -1456,7 +1456,7 @@ static int __devexit sonypi_remove(struct platform_device *dev)
1456 return 0; 1456 return 0;
1457} 1457}
1458 1458
1459#ifdef CONFIG_PM 1459#ifdef CONFIG_PM_SLEEP
1460static int old_camera_power; 1460static int old_camera_power;
1461 1461
1462static int sonypi_suspend(struct device *dev) 1462static int sonypi_suspend(struct device *dev)
diff --git a/drivers/clk/ux500/u8500_clk.c b/drivers/clk/ux500/u8500_clk.c
index ca4a25ed844..e2c17d187d9 100644
--- a/drivers/clk/ux500/u8500_clk.c
+++ b/drivers/clk/ux500/u8500_clk.c
@@ -40,7 +40,7 @@ void u8500_clk_init(void)
40 CLK_IS_ROOT|CLK_IGNORE_UNUSED, 40 CLK_IS_ROOT|CLK_IGNORE_UNUSED,
41 32768); 41 32768);
42 clk_register_clkdev(clk, "clk32k", NULL); 42 clk_register_clkdev(clk, "clk32k", NULL);
43 clk_register_clkdev(clk, NULL, "rtc-pl031"); 43 clk_register_clkdev(clk, "apb_pclk", "rtc-pl031");
44 44
45 /* PRCMU clocks */ 45 /* PRCMU clocks */
46 fw_version = prcmu_get_fw_version(); 46 fw_version = prcmu_get_fw_version();
@@ -228,10 +228,17 @@ void u8500_clk_init(void)
228 228
229 clk = clk_reg_prcc_pclk("p1_pclk2", "per1clk", U8500_CLKRST1_BASE, 229 clk = clk_reg_prcc_pclk("p1_pclk2", "per1clk", U8500_CLKRST1_BASE,
230 BIT(2), 0); 230 BIT(2), 0);
231 clk_register_clkdev(clk, "apb_pclk", "nmk-i2c.1");
232
231 clk = clk_reg_prcc_pclk("p1_pclk3", "per1clk", U8500_CLKRST1_BASE, 233 clk = clk_reg_prcc_pclk("p1_pclk3", "per1clk", U8500_CLKRST1_BASE,
232 BIT(3), 0); 234 BIT(3), 0);
235 clk_register_clkdev(clk, "apb_pclk", "msp0");
236 clk_register_clkdev(clk, "apb_pclk", "ux500-msp-i2s.0");
237
233 clk = clk_reg_prcc_pclk("p1_pclk4", "per1clk", U8500_CLKRST1_BASE, 238 clk = clk_reg_prcc_pclk("p1_pclk4", "per1clk", U8500_CLKRST1_BASE,
234 BIT(4), 0); 239 BIT(4), 0);
240 clk_register_clkdev(clk, "apb_pclk", "msp1");
241 clk_register_clkdev(clk, "apb_pclk", "ux500-msp-i2s.1");
235 242
236 clk = clk_reg_prcc_pclk("p1_pclk5", "per1clk", U8500_CLKRST1_BASE, 243 clk = clk_reg_prcc_pclk("p1_pclk5", "per1clk", U8500_CLKRST1_BASE,
237 BIT(5), 0); 244 BIT(5), 0);
@@ -239,6 +246,7 @@ void u8500_clk_init(void)
239 246
240 clk = clk_reg_prcc_pclk("p1_pclk6", "per1clk", U8500_CLKRST1_BASE, 247 clk = clk_reg_prcc_pclk("p1_pclk6", "per1clk", U8500_CLKRST1_BASE,
241 BIT(6), 0); 248 BIT(6), 0);
249 clk_register_clkdev(clk, "apb_pclk", "nmk-i2c.2");
242 250
243 clk = clk_reg_prcc_pclk("p1_pclk7", "per1clk", U8500_CLKRST1_BASE, 251 clk = clk_reg_prcc_pclk("p1_pclk7", "per1clk", U8500_CLKRST1_BASE,
244 BIT(7), 0); 252 BIT(7), 0);
@@ -246,6 +254,7 @@ void u8500_clk_init(void)
246 254
247 clk = clk_reg_prcc_pclk("p1_pclk8", "per1clk", U8500_CLKRST1_BASE, 255 clk = clk_reg_prcc_pclk("p1_pclk8", "per1clk", U8500_CLKRST1_BASE,
248 BIT(8), 0); 256 BIT(8), 0);
257 clk_register_clkdev(clk, "apb_pclk", "slimbus0");
249 258
250 clk = clk_reg_prcc_pclk("p1_pclk9", "per1clk", U8500_CLKRST1_BASE, 259 clk = clk_reg_prcc_pclk("p1_pclk9", "per1clk", U8500_CLKRST1_BASE,
251 BIT(9), 0); 260 BIT(9), 0);
@@ -255,11 +264,16 @@ void u8500_clk_init(void)
255 264
256 clk = clk_reg_prcc_pclk("p1_pclk10", "per1clk", U8500_CLKRST1_BASE, 265 clk = clk_reg_prcc_pclk("p1_pclk10", "per1clk", U8500_CLKRST1_BASE,
257 BIT(10), 0); 266 BIT(10), 0);
267 clk_register_clkdev(clk, "apb_pclk", "nmk-i2c.4");
268
258 clk = clk_reg_prcc_pclk("p1_pclk11", "per1clk", U8500_CLKRST1_BASE, 269 clk = clk_reg_prcc_pclk("p1_pclk11", "per1clk", U8500_CLKRST1_BASE,
259 BIT(11), 0); 270 BIT(11), 0);
271 clk_register_clkdev(clk, "apb_pclk", "msp3");
272 clk_register_clkdev(clk, "apb_pclk", "ux500-msp-i2s.3");
260 273
261 clk = clk_reg_prcc_pclk("p2_pclk0", "per2clk", U8500_CLKRST2_BASE, 274 clk = clk_reg_prcc_pclk("p2_pclk0", "per2clk", U8500_CLKRST2_BASE,
262 BIT(0), 0); 275 BIT(0), 0);
276 clk_register_clkdev(clk, "apb_pclk", "nmk-i2c.3");
263 277
264 clk = clk_reg_prcc_pclk("p2_pclk1", "per2clk", U8500_CLKRST2_BASE, 278 clk = clk_reg_prcc_pclk("p2_pclk1", "per2clk", U8500_CLKRST2_BASE,
265 BIT(1), 0); 279 BIT(1), 0);
@@ -279,12 +293,13 @@ void u8500_clk_init(void)
279 293
280 clk = clk_reg_prcc_pclk("p2_pclk5", "per2clk", U8500_CLKRST2_BASE, 294 clk = clk_reg_prcc_pclk("p2_pclk5", "per2clk", U8500_CLKRST2_BASE,
281 BIT(5), 0); 295 BIT(5), 0);
296 clk_register_clkdev(clk, "apb_pclk", "msp2");
297 clk_register_clkdev(clk, "apb_pclk", "ux500-msp-i2s.2");
282 298
283 clk = clk_reg_prcc_pclk("p2_pclk6", "per2clk", U8500_CLKRST2_BASE, 299 clk = clk_reg_prcc_pclk("p2_pclk6", "per2clk", U8500_CLKRST2_BASE,
284 BIT(6), 0); 300 BIT(6), 0);
285 clk_register_clkdev(clk, "apb_pclk", "sdi1"); 301 clk_register_clkdev(clk, "apb_pclk", "sdi1");
286 302
287
288 clk = clk_reg_prcc_pclk("p2_pclk7", "per2clk", U8500_CLKRST2_BASE, 303 clk = clk_reg_prcc_pclk("p2_pclk7", "per2clk", U8500_CLKRST2_BASE,
289 BIT(7), 0); 304 BIT(7), 0);
290 clk_register_clkdev(clk, "apb_pclk", "sdi3"); 305 clk_register_clkdev(clk, "apb_pclk", "sdi3");
@@ -316,10 +331,15 @@ void u8500_clk_init(void)
316 331
317 clk = clk_reg_prcc_pclk("p3_pclk1", "per3clk", U8500_CLKRST3_BASE, 332 clk = clk_reg_prcc_pclk("p3_pclk1", "per3clk", U8500_CLKRST3_BASE,
318 BIT(1), 0); 333 BIT(1), 0);
334 clk_register_clkdev(clk, "apb_pclk", "ssp0");
335
319 clk = clk_reg_prcc_pclk("p3_pclk2", "per3clk", U8500_CLKRST3_BASE, 336 clk = clk_reg_prcc_pclk("p3_pclk2", "per3clk", U8500_CLKRST3_BASE,
320 BIT(2), 0); 337 BIT(2), 0);
338 clk_register_clkdev(clk, "apb_pclk", "ssp1");
339
321 clk = clk_reg_prcc_pclk("p3_pclk3", "per3clk", U8500_CLKRST3_BASE, 340 clk = clk_reg_prcc_pclk("p3_pclk3", "per3clk", U8500_CLKRST3_BASE,
322 BIT(3), 0); 341 BIT(3), 0);
342 clk_register_clkdev(clk, "apb_pclk", "nmk-i2c.0");
323 343
324 clk = clk_reg_prcc_pclk("p3_pclk4", "per3clk", U8500_CLKRST3_BASE, 344 clk = clk_reg_prcc_pclk("p3_pclk4", "per3clk", U8500_CLKRST3_BASE,
325 BIT(4), 0); 345 BIT(4), 0);
@@ -401,10 +421,17 @@ void u8500_clk_init(void)
401 421
402 clk = clk_reg_prcc_kclk("p1_i2c1_kclk", "i2cclk", 422 clk = clk_reg_prcc_kclk("p1_i2c1_kclk", "i2cclk",
403 U8500_CLKRST1_BASE, BIT(2), CLK_SET_RATE_GATE); 423 U8500_CLKRST1_BASE, BIT(2), CLK_SET_RATE_GATE);
424 clk_register_clkdev(clk, NULL, "nmk-i2c.1");
425
404 clk = clk_reg_prcc_kclk("p1_msp0_kclk", "msp02clk", 426 clk = clk_reg_prcc_kclk("p1_msp0_kclk", "msp02clk",
405 U8500_CLKRST1_BASE, BIT(3), CLK_SET_RATE_GATE); 427 U8500_CLKRST1_BASE, BIT(3), CLK_SET_RATE_GATE);
428 clk_register_clkdev(clk, NULL, "msp0");
429 clk_register_clkdev(clk, NULL, "ux500-msp-i2s.0");
430
406 clk = clk_reg_prcc_kclk("p1_msp1_kclk", "msp1clk", 431 clk = clk_reg_prcc_kclk("p1_msp1_kclk", "msp1clk",
407 U8500_CLKRST1_BASE, BIT(4), CLK_SET_RATE_GATE); 432 U8500_CLKRST1_BASE, BIT(4), CLK_SET_RATE_GATE);
433 clk_register_clkdev(clk, NULL, "msp1");
434 clk_register_clkdev(clk, NULL, "ux500-msp-i2s.1");
408 435
409 clk = clk_reg_prcc_kclk("p1_sdi0_kclk", "sdmmcclk", 436 clk = clk_reg_prcc_kclk("p1_sdi0_kclk", "sdmmcclk",
410 U8500_CLKRST1_BASE, BIT(5), CLK_SET_RATE_GATE); 437 U8500_CLKRST1_BASE, BIT(5), CLK_SET_RATE_GATE);
@@ -412,17 +439,25 @@ void u8500_clk_init(void)
412 439
413 clk = clk_reg_prcc_kclk("p1_i2c2_kclk", "i2cclk", 440 clk = clk_reg_prcc_kclk("p1_i2c2_kclk", "i2cclk",
414 U8500_CLKRST1_BASE, BIT(6), CLK_SET_RATE_GATE); 441 U8500_CLKRST1_BASE, BIT(6), CLK_SET_RATE_GATE);
442 clk_register_clkdev(clk, NULL, "nmk-i2c.2");
443
415 clk = clk_reg_prcc_kclk("p1_slimbus0_kclk", "slimclk", 444 clk = clk_reg_prcc_kclk("p1_slimbus0_kclk", "slimclk",
416 U8500_CLKRST1_BASE, BIT(3), CLK_SET_RATE_GATE); 445 U8500_CLKRST1_BASE, BIT(8), CLK_SET_RATE_GATE);
417 /* FIXME: Redefinition of BIT(3). */ 446 clk_register_clkdev(clk, NULL, "slimbus0");
447
418 clk = clk_reg_prcc_kclk("p1_i2c4_kclk", "i2cclk", 448 clk = clk_reg_prcc_kclk("p1_i2c4_kclk", "i2cclk",
419 U8500_CLKRST1_BASE, BIT(9), CLK_SET_RATE_GATE); 449 U8500_CLKRST1_BASE, BIT(9), CLK_SET_RATE_GATE);
450 clk_register_clkdev(clk, NULL, "nmk-i2c.4");
451
420 clk = clk_reg_prcc_kclk("p1_msp3_kclk", "msp1clk", 452 clk = clk_reg_prcc_kclk("p1_msp3_kclk", "msp1clk",
421 U8500_CLKRST1_BASE, BIT(10), CLK_SET_RATE_GATE); 453 U8500_CLKRST1_BASE, BIT(10), CLK_SET_RATE_GATE);
454 clk_register_clkdev(clk, NULL, "msp3");
455 clk_register_clkdev(clk, NULL, "ux500-msp-i2s.3");
422 456
423 /* Periph2 */ 457 /* Periph2 */
424 clk = clk_reg_prcc_kclk("p2_i2c3_kclk", "i2cclk", 458 clk = clk_reg_prcc_kclk("p2_i2c3_kclk", "i2cclk",
425 U8500_CLKRST2_BASE, BIT(0), CLK_SET_RATE_GATE); 459 U8500_CLKRST2_BASE, BIT(0), CLK_SET_RATE_GATE);
460 clk_register_clkdev(clk, NULL, "nmk-i2c.3");
426 461
427 clk = clk_reg_prcc_kclk("p2_sdi4_kclk", "sdmmcclk", 462 clk = clk_reg_prcc_kclk("p2_sdi4_kclk", "sdmmcclk",
428 U8500_CLKRST2_BASE, BIT(2), CLK_SET_RATE_GATE); 463 U8500_CLKRST2_BASE, BIT(2), CLK_SET_RATE_GATE);
@@ -430,6 +465,8 @@ void u8500_clk_init(void)
430 465
431 clk = clk_reg_prcc_kclk("p2_msp2_kclk", "msp02clk", 466 clk = clk_reg_prcc_kclk("p2_msp2_kclk", "msp02clk",
432 U8500_CLKRST2_BASE, BIT(3), CLK_SET_RATE_GATE); 467 U8500_CLKRST2_BASE, BIT(3), CLK_SET_RATE_GATE);
468 clk_register_clkdev(clk, NULL, "msp2");
469 clk_register_clkdev(clk, NULL, "ux500-msp-i2s.2");
433 470
434 clk = clk_reg_prcc_kclk("p2_sdi1_kclk", "sdmmcclk", 471 clk = clk_reg_prcc_kclk("p2_sdi1_kclk", "sdmmcclk",
435 U8500_CLKRST2_BASE, BIT(4), CLK_SET_RATE_GATE); 472 U8500_CLKRST2_BASE, BIT(4), CLK_SET_RATE_GATE);
@@ -450,10 +487,15 @@ void u8500_clk_init(void)
450 /* Periph3 */ 487 /* Periph3 */
451 clk = clk_reg_prcc_kclk("p3_ssp0_kclk", "sspclk", 488 clk = clk_reg_prcc_kclk("p3_ssp0_kclk", "sspclk",
452 U8500_CLKRST3_BASE, BIT(1), CLK_SET_RATE_GATE); 489 U8500_CLKRST3_BASE, BIT(1), CLK_SET_RATE_GATE);
490 clk_register_clkdev(clk, NULL, "ssp0");
491
453 clk = clk_reg_prcc_kclk("p3_ssp1_kclk", "sspclk", 492 clk = clk_reg_prcc_kclk("p3_ssp1_kclk", "sspclk",
454 U8500_CLKRST3_BASE, BIT(2), CLK_SET_RATE_GATE); 493 U8500_CLKRST3_BASE, BIT(2), CLK_SET_RATE_GATE);
494 clk_register_clkdev(clk, NULL, "ssp1");
495
455 clk = clk_reg_prcc_kclk("p3_i2c0_kclk", "i2cclk", 496 clk = clk_reg_prcc_kclk("p3_i2c0_kclk", "i2cclk",
456 U8500_CLKRST3_BASE, BIT(3), CLK_SET_RATE_GATE); 497 U8500_CLKRST3_BASE, BIT(3), CLK_SET_RATE_GATE);
498 clk_register_clkdev(clk, NULL, "nmk-i2c.0");
457 499
458 clk = clk_reg_prcc_kclk("p3_sdi2_kclk", "sdmmcclk", 500 clk = clk_reg_prcc_kclk("p3_sdi2_kclk", "sdmmcclk",
459 U8500_CLKRST3_BASE, BIT(4), CLK_SET_RATE_GATE); 501 U8500_CLKRST3_BASE, BIT(4), CLK_SET_RATE_GATE);
diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
index b40ee1403be..399831690fe 100644
--- a/drivers/cpufreq/cpufreq_stats.c
+++ b/drivers/cpufreq/cpufreq_stats.c
@@ -328,6 +328,7 @@ static int __cpuinit cpufreq_stat_cpu_callback(struct notifier_block *nfb,
328 cpufreq_update_policy(cpu); 328 cpufreq_update_policy(cpu);
329 break; 329 break;
330 case CPU_DOWN_PREPARE: 330 case CPU_DOWN_PREPARE:
331 case CPU_DOWN_PREPARE_FROZEN:
331 cpufreq_stats_free_sysfs(cpu); 332 cpufreq_stats_free_sysfs(cpu);
332 break; 333 break;
333 case CPU_DEAD: 334 case CPU_DEAD:
diff --git a/drivers/cpufreq/powernow-k8.c b/drivers/cpufreq/powernow-k8.c
index 129e80bfff2..e3ebb4fa2c3 100644
--- a/drivers/cpufreq/powernow-k8.c
+++ b/drivers/cpufreq/powernow-k8.c
@@ -5,7 +5,7 @@
5 * http://www.gnu.org/licenses/gpl.html 5 * http://www.gnu.org/licenses/gpl.html
6 * 6 *
7 * Maintainer: 7 * Maintainer:
8 * Andreas Herrmann <andreas.herrmann3@amd.com> 8 * Andreas Herrmann <herrmann.der.user@googlemail.com>
9 * 9 *
10 * Based on the powernow-k7.c module written by Dave Jones. 10 * Based on the powernow-k7.c module written by Dave Jones.
11 * (C) 2003 Dave Jones on behalf of SuSE Labs 11 * (C) 2003 Dave Jones on behalf of SuSE Labs
@@ -1052,14 +1052,7 @@ static int powernowk8_target(struct cpufreq_policy *pol,
1052 struct powernowk8_target_arg pta = { .pol = pol, .targfreq = targfreq, 1052 struct powernowk8_target_arg pta = { .pol = pol, .targfreq = targfreq,
1053 .relation = relation }; 1053 .relation = relation };
1054 1054
1055 /* 1055 return work_on_cpu(pol->cpu, powernowk8_target_fn, &pta);
1056 * Must run on @pol->cpu. cpufreq core is responsible for ensuring
1057 * that we're bound to the current CPU and pol->cpu stays online.
1058 */
1059 if (smp_processor_id() == pol->cpu)
1060 return powernowk8_target_fn(&pta);
1061 else
1062 return work_on_cpu(pol->cpu, powernowk8_target_fn, &pta);
1063} 1056}
1064 1057
1065/* Driver entry point to verify the policy and range of frequencies */ 1058/* Driver entry point to verify the policy and range of frequencies */
diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig
index 677cd6e4e1a..d4c12180c65 100644
--- a/drivers/dma/Kconfig
+++ b/drivers/dma/Kconfig
@@ -90,6 +90,17 @@ config DW_DMAC
90 Support the Synopsys DesignWare AHB DMA controller. This 90 Support the Synopsys DesignWare AHB DMA controller. This
91 can be integrated in chips such as the Atmel AT32ap7000. 91 can be integrated in chips such as the Atmel AT32ap7000.
92 92
93config DW_DMAC_BIG_ENDIAN_IO
94 bool "Use big endian I/O register access"
95 default y if AVR32
96 depends on DW_DMAC
97 help
98 Say yes here to use big endian I/O access when reading and writing
99 to the DMA controller registers. This is needed on some platforms,
100 like the Atmel AVR32 architecture.
101
102 If unsure, use the default setting.
103
93config AT_HDMAC 104config AT_HDMAC
94 tristate "Atmel AHB DMA support" 105 tristate "Atmel AHB DMA support"
95 depends on ARCH_AT91 106 depends on ARCH_AT91
diff --git a/drivers/dma/dw_dmac_regs.h b/drivers/dma/dw_dmac_regs.h
index ff39fa6cd2b..88965597b7d 100644
--- a/drivers/dma/dw_dmac_regs.h
+++ b/drivers/dma/dw_dmac_regs.h
@@ -98,9 +98,17 @@ struct dw_dma_regs {
98 u32 DW_PARAMS; 98 u32 DW_PARAMS;
99}; 99};
100 100
101#ifdef CONFIG_DW_DMAC_BIG_ENDIAN_IO
102#define dma_readl_native ioread32be
103#define dma_writel_native iowrite32be
104#else
105#define dma_readl_native readl
106#define dma_writel_native writel
107#endif
108
101/* To access the registers in early stage of probe */ 109/* To access the registers in early stage of probe */
102#define dma_read_byaddr(addr, name) \ 110#define dma_read_byaddr(addr, name) \
103 readl((addr) + offsetof(struct dw_dma_regs, name)) 111 dma_readl_native((addr) + offsetof(struct dw_dma_regs, name))
104 112
105/* Bitfields in DW_PARAMS */ 113/* Bitfields in DW_PARAMS */
106#define DW_PARAMS_NR_CHAN 8 /* number of channels */ 114#define DW_PARAMS_NR_CHAN 8 /* number of channels */
@@ -216,9 +224,9 @@ __dwc_regs(struct dw_dma_chan *dwc)
216} 224}
217 225
218#define channel_readl(dwc, name) \ 226#define channel_readl(dwc, name) \
219 readl(&(__dwc_regs(dwc)->name)) 227 dma_readl_native(&(__dwc_regs(dwc)->name))
220#define channel_writel(dwc, name, val) \ 228#define channel_writel(dwc, name, val) \
221 writel((val), &(__dwc_regs(dwc)->name)) 229 dma_writel_native((val), &(__dwc_regs(dwc)->name))
222 230
223static inline struct dw_dma_chan *to_dw_dma_chan(struct dma_chan *chan) 231static inline struct dw_dma_chan *to_dw_dma_chan(struct dma_chan *chan)
224{ 232{
@@ -246,9 +254,9 @@ static inline struct dw_dma_regs __iomem *__dw_regs(struct dw_dma *dw)
246} 254}
247 255
248#define dma_readl(dw, name) \ 256#define dma_readl(dw, name) \
249 readl(&(__dw_regs(dw)->name)) 257 dma_readl_native(&(__dw_regs(dw)->name))
250#define dma_writel(dw, name, val) \ 258#define dma_writel(dw, name, val) \
251 writel((val), &(__dw_regs(dw)->name)) 259 dma_writel_native((val), &(__dw_regs(dw)->name))
252 260
253#define channel_set_bit(dw, reg, mask) \ 261#define channel_set_bit(dw, reg, mask) \
254 dma_writel(dw, reg, ((mask) << 8) | (mask)) 262 dma_writel(dw, reg, ((mask) << 8) | (mask))
diff --git a/drivers/dma/imx-dma.c b/drivers/dma/imx-dma.c
index f11b5b2b1a1..7d9554cc497 100644
--- a/drivers/dma/imx-dma.c
+++ b/drivers/dma/imx-dma.c
@@ -474,8 +474,10 @@ static int imxdma_xfer_desc(struct imxdma_desc *d)
474 slot = i; 474 slot = i;
475 break; 475 break;
476 } 476 }
477 if (slot < 0) 477 if (slot < 0) {
478 spin_unlock_irqrestore(&imxdma->lock, flags);
478 return -EBUSY; 479 return -EBUSY;
480 }
479 481
480 imxdma->slots_2d[slot].xsr = d->x; 482 imxdma->slots_2d[slot].xsr = d->x;
481 imxdma->slots_2d[slot].ysr = d->y; 483 imxdma->slots_2d[slot].ysr = d->y;
diff --git a/drivers/dma/sirf-dma.c b/drivers/dma/sirf-dma.c
index 64385cde044..d451caace80 100644
--- a/drivers/dma/sirf-dma.c
+++ b/drivers/dma/sirf-dma.c
@@ -109,7 +109,7 @@ static void sirfsoc_dma_execute(struct sirfsoc_dma_chan *schan)
109 sdesc = list_first_entry(&schan->queued, struct sirfsoc_dma_desc, 109 sdesc = list_first_entry(&schan->queued, struct sirfsoc_dma_desc,
110 node); 110 node);
111 /* Move the first queued descriptor to active list */ 111 /* Move the first queued descriptor to active list */
112 list_move_tail(&schan->queued, &schan->active); 112 list_move_tail(&sdesc->node, &schan->active);
113 113
114 /* Start the DMA transfer */ 114 /* Start the DMA transfer */
115 writel_relaxed(sdesc->width, sdma->base + SIRFSOC_DMA_WIDTH_0 + 115 writel_relaxed(sdesc->width, sdma->base + SIRFSOC_DMA_WIDTH_0 +
@@ -428,7 +428,7 @@ static struct dma_async_tx_descriptor *sirfsoc_dma_prep_interleaved(
428 unsigned long iflags; 428 unsigned long iflags;
429 int ret; 429 int ret;
430 430
431 if ((xt->dir != DMA_MEM_TO_DEV) || (xt->dir != DMA_DEV_TO_MEM)) { 431 if ((xt->dir != DMA_MEM_TO_DEV) && (xt->dir != DMA_DEV_TO_MEM)) {
432 ret = -EINVAL; 432 ret = -EINVAL;
433 goto err_dir; 433 goto err_dir;
434 } 434 }
diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
index 5a297a26211..cc8e7c78a23 100644
--- a/drivers/edac/amd64_edac.c
+++ b/drivers/edac/amd64_edac.c
@@ -170,8 +170,11 @@ static int __amd64_set_scrub_rate(struct pci_dev *ctl, u32 new_bw, u32 min_rate)
170 * memory controller and apply to register. Search for the first 170 * memory controller and apply to register. Search for the first
171 * bandwidth entry that is greater or equal than the setting requested 171 * bandwidth entry that is greater or equal than the setting requested
172 * and program that. If at last entry, turn off DRAM scrubbing. 172 * and program that. If at last entry, turn off DRAM scrubbing.
173 *
174 * If no suitable bandwidth is found, turn off DRAM scrubbing entirely
175 * by falling back to the last element in scrubrates[].
173 */ 176 */
174 for (i = 0; i < ARRAY_SIZE(scrubrates); i++) { 177 for (i = 0; i < ARRAY_SIZE(scrubrates) - 1; i++) {
175 /* 178 /*
176 * skip scrub rates which aren't recommended 179 * skip scrub rates which aren't recommended
177 * (see F10 BKDG, F3x58) 180 * (see F10 BKDG, F3x58)
@@ -181,12 +184,6 @@ static int __amd64_set_scrub_rate(struct pci_dev *ctl, u32 new_bw, u32 min_rate)
181 184
182 if (scrubrates[i].bandwidth <= new_bw) 185 if (scrubrates[i].bandwidth <= new_bw)
183 break; 186 break;
184
185 /*
186 * if no suitable bandwidth found, turn off DRAM scrubbing
187 * entirely by falling back to the last element in the
188 * scrubrates array.
189 */
190 } 187 }
191 188
192 scrubval = scrubrates[i].scrubval; 189 scrubval = scrubrates[i].scrubval;
diff --git a/drivers/edac/amd64_edac.h b/drivers/edac/amd64_edac.h
index 8d4804732ba..8c4139647ef 100644
--- a/drivers/edac/amd64_edac.h
+++ b/drivers/edac/amd64_edac.h
@@ -33,7 +33,7 @@
33 * detection. The mods to Rev F required more family 33 * detection. The mods to Rev F required more family
34 * information detection. 34 * information detection.
35 * 35 *
36 * Changes/Fixes by Borislav Petkov <borislav.petkov@amd.com>: 36 * Changes/Fixes by Borislav Petkov <bp@alien8.de>:
37 * - misc fixes and code cleanups 37 * - misc fixes and code cleanups
38 * 38 *
39 * This module is based on the following documents 39 * This module is based on the following documents
diff --git a/drivers/edac/edac_stub.c b/drivers/edac/edac_stub.c
index 6c86f6e5455..351945fa2ec 100644
--- a/drivers/edac/edac_stub.c
+++ b/drivers/edac/edac_stub.c
@@ -5,7 +5,7 @@
5 * 5 *
6 * 2007 (c) MontaVista Software, Inc. 6 * 2007 (c) MontaVista Software, Inc.
7 * 2010 (c) Advanced Micro Devices Inc. 7 * 2010 (c) Advanced Micro Devices Inc.
8 * Borislav Petkov <borislav.petkov@amd.com> 8 * Borislav Petkov <bp@alien8.de>
9 * 9 *
10 * This file is licensed under the terms of the GNU General Public 10 * This file is licensed under the terms of the GNU General Public
11 * License version 2. This program is licensed "as is" without any 11 * License version 2. This program is licensed "as is" without any
diff --git a/drivers/edac/mce_amd_inj.c b/drivers/edac/mce_amd_inj.c
index 66b5151c108..2ae78f20cc2 100644
--- a/drivers/edac/mce_amd_inj.c
+++ b/drivers/edac/mce_amd_inj.c
@@ -6,7 +6,7 @@
6 * This file may be distributed under the terms of the GNU General Public 6 * This file may be distributed under the terms of the GNU General Public
7 * License version 2. 7 * License version 2.
8 * 8 *
9 * Copyright (c) 2010: Borislav Petkov <borislav.petkov@amd.com> 9 * Copyright (c) 2010: Borislav Petkov <bp@alien8.de>
10 * Advanced Micro Devices Inc. 10 * Advanced Micro Devices Inc.
11 */ 11 */
12 12
@@ -168,6 +168,6 @@ module_init(edac_init_mce_inject);
168module_exit(edac_exit_mce_inject); 168module_exit(edac_exit_mce_inject);
169 169
170MODULE_LICENSE("GPL"); 170MODULE_LICENSE("GPL");
171MODULE_AUTHOR("Borislav Petkov <borislav.petkov@amd.com>"); 171MODULE_AUTHOR("Borislav Petkov <bp@alien8.de>");
172MODULE_AUTHOR("AMD Inc."); 172MODULE_AUTHOR("AMD Inc.");
173MODULE_DESCRIPTION("MCE injection facility for testing MCE decoding"); 173MODULE_DESCRIPTION("MCE injection facility for testing MCE decoding");
diff --git a/drivers/extcon/extcon-adc-jack.c b/drivers/extcon/extcon-adc-jack.c
index 725eb5aa8d8..e87196f6d2d 100644
--- a/drivers/extcon/extcon-adc-jack.c
+++ b/drivers/extcon/extcon-adc-jack.c
@@ -14,6 +14,7 @@
14 * 14 *
15 */ 15 */
16 16
17#include <linux/module.h>
17#include <linux/slab.h> 18#include <linux/slab.h>
18#include <linux/device.h> 19#include <linux/device.h>
19#include <linux/platform_device.h> 20#include <linux/platform_device.h>
@@ -161,13 +162,12 @@ static int __devinit adc_jack_probe(struct platform_device *pdev)
161 err = request_any_context_irq(data->irq, adc_jack_irq_thread, 162 err = request_any_context_irq(data->irq, adc_jack_irq_thread,
162 pdata->irq_flags, pdata->name, data); 163 pdata->irq_flags, pdata->name, data);
163 164
164 if (err) { 165 if (err < 0) {
165 dev_err(&pdev->dev, "error: irq %d\n", data->irq); 166 dev_err(&pdev->dev, "error: irq %d\n", data->irq);
166 err = -EINVAL;
167 goto err_irq; 167 goto err_irq;
168 } 168 }
169 169
170 goto out; 170 return 0;
171 171
172err_irq: 172err_irq:
173 extcon_dev_unregister(&data->edev); 173 extcon_dev_unregister(&data->edev);
@@ -196,3 +196,7 @@ static struct platform_driver adc_jack_driver = {
196}; 196};
197 197
198module_platform_driver(adc_jack_driver); 198module_platform_driver(adc_jack_driver);
199
200MODULE_AUTHOR("MyungJoo Ham <myungjoo.ham@samsung.com>");
201MODULE_DESCRIPTION("ADC Jack extcon driver");
202MODULE_LICENSE("GPL v2");
diff --git a/drivers/extcon/extcon-class.c b/drivers/extcon/extcon-class.c
index 946a3188b2b..d398821097f 100644
--- a/drivers/extcon/extcon-class.c
+++ b/drivers/extcon/extcon-class.c
@@ -41,7 +41,7 @@
41 * every single port-type of the following cable names. Please choose cable 41 * every single port-type of the following cable names. Please choose cable
42 * names that are actually used in your extcon device. 42 * names that are actually used in your extcon device.
43 */ 43 */
44const char *extcon_cable_name[] = { 44const char extcon_cable_name[][CABLE_NAME_MAX + 1] = {
45 [EXTCON_USB] = "USB", 45 [EXTCON_USB] = "USB",
46 [EXTCON_USB_HOST] = "USB-Host", 46 [EXTCON_USB_HOST] = "USB-Host",
47 [EXTCON_TA] = "TA", 47 [EXTCON_TA] = "TA",
@@ -62,8 +62,6 @@ const char *extcon_cable_name[] = {
62 [EXTCON_VIDEO_IN] = "Video-in", 62 [EXTCON_VIDEO_IN] = "Video-in",
63 [EXTCON_VIDEO_OUT] = "Video-out", 63 [EXTCON_VIDEO_OUT] = "Video-out",
64 [EXTCON_MECHANICAL] = "Mechanical", 64 [EXTCON_MECHANICAL] = "Mechanical",
65
66 NULL,
67}; 65};
68 66
69static struct class *extcon_class; 67static struct class *extcon_class;
@@ -91,17 +89,13 @@ static int check_mutually_exclusive(struct extcon_dev *edev, u32 new_state)
91 return 0; 89 return 0;
92 90
93 for (i = 0; edev->mutually_exclusive[i]; i++) { 91 for (i = 0; edev->mutually_exclusive[i]; i++) {
94 int count = 0, j; 92 int weight;
95 u32 correspondants = new_state & edev->mutually_exclusive[i]; 93 u32 correspondants = new_state & edev->mutually_exclusive[i];
96 u32 exp = 1; 94
97 95 /* calculate the total number of bits set */
98 for (j = 0; j < 32; j++) { 96 weight = hweight32(correspondants);
99 if (exp & correspondants) 97 if (weight > 1)
100 count++; 98 return i + 1;
101 if (count > 1)
102 return i + 1;
103 exp <<= 1;
104 }
105 } 99 }
106 100
107 return 0; 101 return 0;
@@ -362,7 +356,7 @@ int extcon_get_cable_state(struct extcon_dev *edev, const char *cable_name)
362EXPORT_SYMBOL_GPL(extcon_get_cable_state); 356EXPORT_SYMBOL_GPL(extcon_get_cable_state);
363 357
364/** 358/**
365 * extcon_get_cable_state_() - Set the status of a specific cable. 359 * extcon_set_cable_state_() - Set the status of a specific cable.
366 * @edev: the extcon device that has the cable. 360 * @edev: the extcon device that has the cable.
367 * @index: cable index that can be retrieved by extcon_find_cable_index(). 361 * @index: cable index that can be retrieved by extcon_find_cable_index().
368 * @cable_state: the new cable status. The default semantics is 362 * @cable_state: the new cable status. The default semantics is
@@ -382,7 +376,7 @@ int extcon_set_cable_state_(struct extcon_dev *edev,
382EXPORT_SYMBOL_GPL(extcon_set_cable_state_); 376EXPORT_SYMBOL_GPL(extcon_set_cable_state_);
383 377
384/** 378/**
385 * extcon_get_cable_state() - Set the status of a specific cable. 379 * extcon_set_cable_state() - Set the status of a specific cable.
386 * @edev: the extcon device that has the cable. 380 * @edev: the extcon device that has the cable.
387 * @cable_name: cable name. 381 * @cable_name: cable name.
388 * @cable_state: the new cable status. The default semantics is 382 * @cable_state: the new cable status. The default semantics is
@@ -447,6 +441,8 @@ static int _call_per_cable(struct notifier_block *nb, unsigned long val,
447 * extcon device. 441 * extcon device.
448 * @obj: an empty extcon_specific_cable_nb object to be returned. 442 * @obj: an empty extcon_specific_cable_nb object to be returned.
449 * @extcon_name: the name of extcon device. 443 * @extcon_name: the name of extcon device.
444 * if NULL, extcon_register_interest will register
445 * every cable with the target cable_name given.
450 * @cable_name: the target cable name. 446 * @cable_name: the target cable name.
451 * @nb: the notifier block to get notified. 447 * @nb: the notifier block to get notified.
452 * 448 *
@@ -466,22 +462,44 @@ int extcon_register_interest(struct extcon_specific_cable_nb *obj,
466 const char *extcon_name, const char *cable_name, 462 const char *extcon_name, const char *cable_name,
467 struct notifier_block *nb) 463 struct notifier_block *nb)
468{ 464{
469 if (!obj || !extcon_name || !cable_name || !nb) 465 if (!obj || !cable_name || !nb)
470 return -EINVAL; 466 return -EINVAL;
471 467
472 obj->edev = extcon_get_extcon_dev(extcon_name); 468 if (extcon_name) {
473 if (!obj->edev) 469 obj->edev = extcon_get_extcon_dev(extcon_name);
474 return -ENODEV; 470 if (!obj->edev)
471 return -ENODEV;
475 472
476 obj->cable_index = extcon_find_cable_index(obj->edev, cable_name); 473 obj->cable_index = extcon_find_cable_index(obj->edev, cable_name);
477 if (obj->cable_index < 0) 474 if (obj->cable_index < 0)
478 return -ENODEV; 475 return -ENODEV;
476
477 obj->user_nb = nb;
479 478
480 obj->user_nb = nb; 479 obj->internal_nb.notifier_call = _call_per_cable;
481 480
482 obj->internal_nb.notifier_call = _call_per_cable; 481 return raw_notifier_chain_register(&obj->edev->nh, &obj->internal_nb);
482 } else {
483 struct class_dev_iter iter;
484 struct extcon_dev *extd;
485 struct device *dev;
486
487 if (!extcon_class)
488 return -ENODEV;
489 class_dev_iter_init(&iter, extcon_class, NULL, NULL);
490 while ((dev = class_dev_iter_next(&iter))) {
491 extd = (struct extcon_dev *)dev_get_drvdata(dev);
492
493 if (extcon_find_cable_index(extd, cable_name) < 0)
494 continue;
495
496 class_dev_iter_exit(&iter);
497 return extcon_register_interest(obj, extd->name,
498 cable_name, nb);
499 }
483 500
484 return raw_notifier_chain_register(&obj->edev->nh, &obj->internal_nb); 501 return -ENODEV;
502 }
485} 503}
486 504
487/** 505/**
@@ -551,43 +569,9 @@ static int create_extcon_class(void)
551 return 0; 569 return 0;
552} 570}
553 571
554static void extcon_cleanup(struct extcon_dev *edev, bool skip)
555{
556 mutex_lock(&extcon_dev_list_lock);
557 list_del(&edev->entry);
558 mutex_unlock(&extcon_dev_list_lock);
559
560 if (!skip && get_device(edev->dev)) {
561 int index;
562
563 if (edev->mutually_exclusive && edev->max_supported) {
564 for (index = 0; edev->mutually_exclusive[index];
565 index++)
566 kfree(edev->d_attrs_muex[index].attr.name);
567 kfree(edev->d_attrs_muex);
568 kfree(edev->attrs_muex);
569 }
570
571 for (index = 0; index < edev->max_supported; index++)
572 kfree(edev->cables[index].attr_g.name);
573
574 if (edev->max_supported) {
575 kfree(edev->extcon_dev_type.groups);
576 kfree(edev->cables);
577 }
578
579 device_unregister(edev->dev);
580 put_device(edev->dev);
581 }
582
583 kfree(edev->dev);
584}
585
586static void extcon_dev_release(struct device *dev) 572static void extcon_dev_release(struct device *dev)
587{ 573{
588 struct extcon_dev *edev = (struct extcon_dev *) dev_get_drvdata(dev); 574 kfree(dev);
589
590 extcon_cleanup(edev, true);
591} 575}
592 576
593static const char *muex_name = "mutually_exclusive"; 577static const char *muex_name = "mutually_exclusive";
@@ -813,7 +797,40 @@ EXPORT_SYMBOL_GPL(extcon_dev_register);
813 */ 797 */
814void extcon_dev_unregister(struct extcon_dev *edev) 798void extcon_dev_unregister(struct extcon_dev *edev)
815{ 799{
816 extcon_cleanup(edev, false); 800 int index;
801
802 mutex_lock(&extcon_dev_list_lock);
803 list_del(&edev->entry);
804 mutex_unlock(&extcon_dev_list_lock);
805
806 if (IS_ERR_OR_NULL(get_device(edev->dev))) {
807 dev_err(edev->dev, "Failed to unregister extcon_dev (%s)\n",
808 dev_name(edev->dev));
809 return;
810 }
811
812 if (edev->mutually_exclusive && edev->max_supported) {
813 for (index = 0; edev->mutually_exclusive[index];
814 index++)
815 kfree(edev->d_attrs_muex[index].attr.name);
816 kfree(edev->d_attrs_muex);
817 kfree(edev->attrs_muex);
818 }
819
820 for (index = 0; index < edev->max_supported; index++)
821 kfree(edev->cables[index].attr_g.name);
822
823 if (edev->max_supported) {
824 kfree(edev->extcon_dev_type.groups);
825 kfree(edev->cables);
826 }
827
828#if defined(CONFIG_ANDROID)
829 if (switch_class)
830 class_compat_remove_link(switch_class, edev->dev, NULL);
831#endif
832 device_unregister(edev->dev);
833 put_device(edev->dev);
817} 834}
818EXPORT_SYMBOL_GPL(extcon_dev_unregister); 835EXPORT_SYMBOL_GPL(extcon_dev_unregister);
819 836
@@ -825,6 +842,9 @@ module_init(extcon_class_init);
825 842
826static void __exit extcon_class_exit(void) 843static void __exit extcon_class_exit(void)
827{ 844{
845#if defined(CONFIG_ANDROID)
846 class_compat_unregister(switch_class);
847#endif
828 class_destroy(extcon_class); 848 class_destroy(extcon_class);
829} 849}
830module_exit(extcon_class_exit); 850module_exit(extcon_class_exit);
diff --git a/drivers/extcon/extcon-gpio.c b/drivers/extcon/extcon-gpio.c
index 3cc152e690b..71d3ab7b3d8 100644
--- a/drivers/extcon/extcon-gpio.c
+++ b/drivers/extcon/extcon-gpio.c
@@ -26,7 +26,6 @@
26#include <linux/interrupt.h> 26#include <linux/interrupt.h>
27#include <linux/platform_device.h> 27#include <linux/platform_device.h>
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <linux/extcon.h>
30#include <linux/workqueue.h> 29#include <linux/workqueue.h>
31#include <linux/gpio.h> 30#include <linux/gpio.h>
32#include <linux/extcon.h> 31#include <linux/extcon.h>
diff --git a/drivers/extcon/extcon-max77693.c b/drivers/extcon/extcon-max77693.c
index e21387e2da5..a17d0d91ada 100644
--- a/drivers/extcon/extcon-max77693.c
+++ b/drivers/extcon/extcon-max77693.c
@@ -239,25 +239,19 @@ const char *max77693_extcon_cable[] = {
239static int max77693_muic_set_debounce_time(struct max77693_muic_info *info, 239static int max77693_muic_set_debounce_time(struct max77693_muic_info *info,
240 enum max77693_muic_adc_debounce_time time) 240 enum max77693_muic_adc_debounce_time time)
241{ 241{
242 int ret = 0; 242 int ret;
243 u8 ctrl3;
244 243
245 switch (time) { 244 switch (time) {
246 case ADC_DEBOUNCE_TIME_5MS: 245 case ADC_DEBOUNCE_TIME_5MS:
247 case ADC_DEBOUNCE_TIME_10MS: 246 case ADC_DEBOUNCE_TIME_10MS:
248 case ADC_DEBOUNCE_TIME_25MS: 247 case ADC_DEBOUNCE_TIME_25MS:
249 case ADC_DEBOUNCE_TIME_38_62MS: 248 case ADC_DEBOUNCE_TIME_38_62MS:
250 ret = max77693_read_reg(info->max77693->regmap_muic, 249 ret = max77693_update_reg(info->max77693->regmap_muic,
251 MAX77693_MUIC_REG_CTRL3, &ctrl3); 250 MAX77693_MUIC_REG_CTRL3,
252 ctrl3 &= ~CONTROL3_ADCDBSET_MASK; 251 time << CONTROL3_ADCDBSET_SHIFT,
253 ctrl3 |= (time << CONTROL3_ADCDBSET_SHIFT); 252 CONTROL3_ADCDBSET_MASK);
254 253 if (ret)
255 ret = max77693_write_reg(info->max77693->regmap_muic,
256 MAX77693_MUIC_REG_CTRL3, ctrl3);
257 if (ret) {
258 dev_err(info->dev, "failed to set ADC debounce time\n"); 254 dev_err(info->dev, "failed to set ADC debounce time\n");
259 ret = -EINVAL;
260 }
261 break; 255 break;
262 default: 256 default:
263 dev_err(info->dev, "invalid ADC debounce time\n"); 257 dev_err(info->dev, "invalid ADC debounce time\n");
@@ -657,6 +651,8 @@ out:
657static int __devinit max77693_muic_probe(struct platform_device *pdev) 651static int __devinit max77693_muic_probe(struct platform_device *pdev)
658{ 652{
659 struct max77693_dev *max77693 = dev_get_drvdata(pdev->dev.parent); 653 struct max77693_dev *max77693 = dev_get_drvdata(pdev->dev.parent);
654 struct max77693_platform_data *pdata = dev_get_platdata(max77693->dev);
655 struct max77693_muic_platform_data *muic_pdata = pdata->muic_data;
660 struct max77693_muic_info *info; 656 struct max77693_muic_info *info;
661 int ret, i; 657 int ret, i;
662 u8 id; 658 u8 id;
@@ -727,6 +723,31 @@ static int __devinit max77693_muic_probe(struct platform_device *pdev)
727 goto err_extcon; 723 goto err_extcon;
728 } 724 }
729 725
726 /* Initialize MUIC register by using platform data */
727 for (i = 0 ; i < muic_pdata->num_init_data ; i++) {
728 enum max77693_irq_source irq_src = MAX77693_IRQ_GROUP_NR;
729
730 max77693_write_reg(info->max77693->regmap_muic,
731 muic_pdata->init_data[i].addr,
732 muic_pdata->init_data[i].data);
733
734 switch (muic_pdata->init_data[i].addr) {
735 case MAX77693_MUIC_REG_INTMASK1:
736 irq_src = MUIC_INT1;
737 break;
738 case MAX77693_MUIC_REG_INTMASK2:
739 irq_src = MUIC_INT2;
740 break;
741 case MAX77693_MUIC_REG_INTMASK3:
742 irq_src = MUIC_INT3;
743 break;
744 }
745
746 if (irq_src < MAX77693_IRQ_GROUP_NR)
747 info->max77693->irq_masks_cur[irq_src]
748 = muic_pdata->init_data[i].data;
749 }
750
730 /* Check revision number of MUIC device*/ 751 /* Check revision number of MUIC device*/
731 ret = max77693_read_reg(info->max77693->regmap_muic, 752 ret = max77693_read_reg(info->max77693->regmap_muic,
732 MAX77693_MUIC_REG_ID, &id); 753 MAX77693_MUIC_REG_ID, &id);
@@ -762,6 +783,7 @@ static int __devexit max77693_muic_remove(struct platform_device *pdev)
762 free_irq(muic_irqs[i].virq, info); 783 free_irq(muic_irqs[i].virq, info);
763 cancel_work_sync(&info->irq_work); 784 cancel_work_sync(&info->irq_work);
764 extcon_dev_unregister(info->edev); 785 extcon_dev_unregister(info->edev);
786 kfree(info->edev);
765 kfree(info); 787 kfree(info);
766 788
767 return 0; 789 return 0;
diff --git a/drivers/extcon/extcon-max8997.c b/drivers/extcon/extcon-max8997.c
index ef9090a4271..77b66b0cc8f 100644
--- a/drivers/extcon/extcon-max8997.c
+++ b/drivers/extcon/extcon-max8997.c
@@ -271,8 +271,6 @@ out:
271static int max8997_muic_handle_charger_type_detach( 271static int max8997_muic_handle_charger_type_detach(
272 struct max8997_muic_info *info) 272 struct max8997_muic_info *info)
273{ 273{
274 int ret = 0;
275
276 switch (info->pre_charger_type) { 274 switch (info->pre_charger_type) {
277 case MAX8997_CHARGER_TYPE_USB: 275 case MAX8997_CHARGER_TYPE_USB:
278 extcon_set_cable_state(info->edev, "USB", false); 276 extcon_set_cable_state(info->edev, "USB", false);
@@ -290,11 +288,11 @@ static int max8997_muic_handle_charger_type_detach(
290 extcon_set_cable_state(info->edev, "Fast-charger", false); 288 extcon_set_cable_state(info->edev, "Fast-charger", false);
291 break; 289 break;
292 default: 290 default:
293 ret = -EINVAL; 291 return -EINVAL;
294 break; 292 break;
295 } 293 }
296 294
297 return ret; 295 return 0;
298} 296}
299 297
300static int max8997_muic_handle_charger_type(struct max8997_muic_info *info, 298static int max8997_muic_handle_charger_type(struct max8997_muic_info *info,
diff --git a/drivers/firewire/sbp2.c b/drivers/firewire/sbp2.c
index 1162d6b3bf8..bb1b392f5cd 100644
--- a/drivers/firewire/sbp2.c
+++ b/drivers/firewire/sbp2.c
@@ -1546,6 +1546,8 @@ static int sbp2_scsi_slave_configure(struct scsi_device *sdev)
1546 struct sbp2_logical_unit *lu = sdev->hostdata; 1546 struct sbp2_logical_unit *lu = sdev->hostdata;
1547 1547
1548 sdev->use_10_for_rw = 1; 1548 sdev->use_10_for_rw = 1;
1549 sdev->no_report_opcodes = 1;
1550 sdev->no_write_same = 1;
1549 1551
1550 if (sbp2_param_exclusive_login) 1552 if (sbp2_param_exclusive_login)
1551 sdev->manage_start_stop = 1; 1553 sdev->manage_start_stop = 1;
diff --git a/drivers/firmware/memmap.c b/drivers/firmware/memmap.c
index c1cdc923666..90723e65b08 100644
--- a/drivers/firmware/memmap.c
+++ b/drivers/firmware/memmap.c
@@ -237,7 +237,7 @@ static ssize_t memmap_attr_show(struct kobject *kobj,
237 * firmware_map_add() or firmware_map_add_early() afterwards, the entries 237 * firmware_map_add() or firmware_map_add_early() afterwards, the entries
238 * are not added to sysfs. 238 * are not added to sysfs.
239 */ 239 */
240static int __init memmap_init(void) 240static int __init firmware_memmap_init(void)
241{ 241{
242 struct firmware_map_entry *entry; 242 struct firmware_map_entry *entry;
243 243
@@ -246,5 +246,5 @@ static int __init memmap_init(void)
246 246
247 return 0; 247 return 0;
248} 248}
249late_initcall(memmap_init); 249late_initcall(firmware_memmap_init);
250 250
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index d055cee3694..47150f5ded0 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -47,7 +47,7 @@ if GPIOLIB
47 47
48config OF_GPIO 48config OF_GPIO
49 def_bool y 49 def_bool y
50 depends on OF && !SPARC 50 depends on OF
51 51
52config DEBUG_GPIO 52config DEBUG_GPIO
53 bool "Debug GPIO calls" 53 bool "Debug GPIO calls"
@@ -466,7 +466,7 @@ config GPIO_ADP5588_IRQ
466 466
467config GPIO_ADNP 467config GPIO_ADNP
468 tristate "Avionic Design N-bit GPIO expander" 468 tristate "Avionic Design N-bit GPIO expander"
469 depends on I2C && OF 469 depends on I2C && OF_GPIO
470 help 470 help
471 This option enables support for N GPIOs found on Avionic Design 471 This option enables support for N GPIOs found on Avionic Design
472 I2C GPIO expanders. The register space will be extended by powers 472 I2C GPIO expanders. The register space will be extended by powers
diff --git a/drivers/gpio/gpio-74x164.c b/drivers/gpio/gpio-74x164.c
index ed3e55161bd..f05e54258ff 100644
--- a/drivers/gpio/gpio-74x164.c
+++ b/drivers/gpio/gpio-74x164.c
@@ -153,7 +153,7 @@ static int __devinit gen_74x164_probe(struct spi_device *spi)
153 } 153 }
154 154
155 chip->gpio_chip.ngpio = GEN_74X164_NUMBER_GPIOS * chip->registers; 155 chip->gpio_chip.ngpio = GEN_74X164_NUMBER_GPIOS * chip->registers;
156 chip->buffer = devm_kzalloc(&spi->dev, chip->gpio_chip.ngpio, GFP_KERNEL); 156 chip->buffer = devm_kzalloc(&spi->dev, chip->registers, GFP_KERNEL);
157 if (!chip->buffer) { 157 if (!chip->buffer) {
158 ret = -ENOMEM; 158 ret = -ENOMEM;
159 goto exit_destroy; 159 goto exit_destroy;
diff --git a/drivers/gpio/gpio-mcp23s08.c b/drivers/gpio/gpio-mcp23s08.c
index 0f425189de1..ce1c8476007 100644
--- a/drivers/gpio/gpio-mcp23s08.c
+++ b/drivers/gpio/gpio-mcp23s08.c
@@ -77,7 +77,7 @@ struct mcp23s08_driver_data {
77 77
78/*----------------------------------------------------------------------*/ 78/*----------------------------------------------------------------------*/
79 79
80#ifdef CONFIG_I2C 80#if IS_ENABLED(CONFIG_I2C)
81 81
82static int mcp23008_read(struct mcp23s08 *mcp, unsigned reg) 82static int mcp23008_read(struct mcp23s08 *mcp, unsigned reg)
83{ 83{
@@ -399,7 +399,7 @@ static int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev,
399 break; 399 break;
400#endif /* CONFIG_SPI_MASTER */ 400#endif /* CONFIG_SPI_MASTER */
401 401
402#ifdef CONFIG_I2C 402#if IS_ENABLED(CONFIG_I2C)
403 case MCP_TYPE_008: 403 case MCP_TYPE_008:
404 mcp->ops = &mcp23008_ops; 404 mcp->ops = &mcp23008_ops;
405 mcp->chip.ngpio = 8; 405 mcp->chip.ngpio = 8;
@@ -473,7 +473,7 @@ fail:
473 473
474/*----------------------------------------------------------------------*/ 474/*----------------------------------------------------------------------*/
475 475
476#ifdef CONFIG_I2C 476#if IS_ENABLED(CONFIG_I2C)
477 477
478static int __devinit mcp230xx_probe(struct i2c_client *client, 478static int __devinit mcp230xx_probe(struct i2c_client *client,
479 const struct i2c_device_id *id) 479 const struct i2c_device_id *id)
diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c
index 902af437eaf..be65c0451ad 100644
--- a/drivers/gpio/gpio-mvebu.c
+++ b/drivers/gpio/gpio-mvebu.c
@@ -92,6 +92,11 @@ static inline void __iomem *mvebu_gpioreg_out(struct mvebu_gpio_chip *mvchip)
92 return mvchip->membase + GPIO_OUT_OFF; 92 return mvchip->membase + GPIO_OUT_OFF;
93} 93}
94 94
95static inline void __iomem *mvebu_gpioreg_blink(struct mvebu_gpio_chip *mvchip)
96{
97 return mvchip->membase + GPIO_BLINK_EN_OFF;
98}
99
95static inline void __iomem *mvebu_gpioreg_io_conf(struct mvebu_gpio_chip *mvchip) 100static inline void __iomem *mvebu_gpioreg_io_conf(struct mvebu_gpio_chip *mvchip)
96{ 101{
97 return mvchip->membase + GPIO_IO_CONF_OFF; 102 return mvchip->membase + GPIO_IO_CONF_OFF;
@@ -206,6 +211,23 @@ static int mvebu_gpio_get(struct gpio_chip *chip, unsigned pin)
206 return (u >> pin) & 1; 211 return (u >> pin) & 1;
207} 212}
208 213
214static void mvebu_gpio_blink(struct gpio_chip *chip, unsigned pin, int value)
215{
216 struct mvebu_gpio_chip *mvchip =
217 container_of(chip, struct mvebu_gpio_chip, chip);
218 unsigned long flags;
219 u32 u;
220
221 spin_lock_irqsave(&mvchip->lock, flags);
222 u = readl_relaxed(mvebu_gpioreg_blink(mvchip));
223 if (value)
224 u |= 1 << pin;
225 else
226 u &= ~(1 << pin);
227 writel_relaxed(u, mvebu_gpioreg_blink(mvchip));
228 spin_unlock_irqrestore(&mvchip->lock, flags);
229}
230
209static int mvebu_gpio_direction_input(struct gpio_chip *chip, unsigned pin) 231static int mvebu_gpio_direction_input(struct gpio_chip *chip, unsigned pin)
210{ 232{
211 struct mvebu_gpio_chip *mvchip = 233 struct mvebu_gpio_chip *mvchip =
@@ -244,6 +266,9 @@ static int mvebu_gpio_direction_output(struct gpio_chip *chip, unsigned pin,
244 if (ret) 266 if (ret)
245 return ret; 267 return ret;
246 268
269 mvebu_gpio_blink(chip, pin, 0);
270 mvebu_gpio_set(chip, pin, value);
271
247 spin_lock_irqsave(&mvchip->lock, flags); 272 spin_lock_irqsave(&mvchip->lock, flags);
248 u = readl_relaxed(mvebu_gpioreg_io_conf(mvchip)); 273 u = readl_relaxed(mvebu_gpioreg_io_conf(mvchip));
249 u &= ~(1 << pin); 274 u &= ~(1 << pin);
@@ -381,11 +406,13 @@ static int mvebu_gpio_irq_set_type(struct irq_data *d, unsigned int type)
381 u = readl_relaxed(mvebu_gpioreg_in_pol(mvchip)); 406 u = readl_relaxed(mvebu_gpioreg_in_pol(mvchip));
382 u &= ~(1 << pin); 407 u &= ~(1 << pin);
383 writel_relaxed(u, mvebu_gpioreg_in_pol(mvchip)); 408 writel_relaxed(u, mvebu_gpioreg_in_pol(mvchip));
409 break;
384 case IRQ_TYPE_EDGE_FALLING: 410 case IRQ_TYPE_EDGE_FALLING:
385 case IRQ_TYPE_LEVEL_LOW: 411 case IRQ_TYPE_LEVEL_LOW:
386 u = readl_relaxed(mvebu_gpioreg_in_pol(mvchip)); 412 u = readl_relaxed(mvebu_gpioreg_in_pol(mvchip));
387 u |= 1 << pin; 413 u |= 1 << pin;
388 writel_relaxed(u, mvebu_gpioreg_in_pol(mvchip)); 414 writel_relaxed(u, mvebu_gpioreg_in_pol(mvchip));
415 break;
389 case IRQ_TYPE_EDGE_BOTH: { 416 case IRQ_TYPE_EDGE_BOTH: {
390 u32 v; 417 u32 v;
391 418
@@ -401,6 +428,7 @@ static int mvebu_gpio_irq_set_type(struct irq_data *d, unsigned int type)
401 else 428 else
402 u &= ~(1 << pin); /* rising */ 429 u &= ~(1 << pin); /* rising */
403 writel_relaxed(u, mvebu_gpioreg_in_pol(mvchip)); 430 writel_relaxed(u, mvebu_gpioreg_in_pol(mvchip));
431 break;
404 } 432 }
405 } 433 }
406 return 0; 434 return 0;
@@ -641,7 +669,7 @@ static int __devinit mvebu_gpio_probe(struct platform_device *pdev)
641 ct->handler = handle_edge_irq; 669 ct->handler = handle_edge_irq;
642 ct->chip.name = mvchip->chip.label; 670 ct->chip.name = mvchip->chip.label;
643 671
644 irq_setup_generic_chip(gc, IRQ_MSK(ngpios), IRQ_GC_INIT_MASK_CACHE, 672 irq_setup_generic_chip(gc, IRQ_MSK(ngpios), 0,
645 IRQ_NOREQUEST, IRQ_LEVEL | IRQ_NOPROBE); 673 IRQ_NOREQUEST, IRQ_LEVEL | IRQ_NOPROBE);
646 674
647 /* Setup irq domain on top of the generic chip. */ 675 /* Setup irq domain on top of the generic chip. */
diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index 94cbc842fbc..d335af1d4d8 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -251,6 +251,40 @@ static void _set_gpio_debounce(struct gpio_bank *bank, unsigned gpio,
251 } 251 }
252} 252}
253 253
254/**
255 * _clear_gpio_debounce - clear debounce settings for a gpio
256 * @bank: the gpio bank we're acting upon
257 * @gpio: the gpio number on this @gpio
258 *
259 * If a gpio is using debounce, then clear the debounce enable bit and if
260 * this is the only gpio in this bank using debounce, then clear the debounce
261 * time too. The debounce clock will also be disabled when calling this function
262 * if this is the only gpio in the bank using debounce.
263 */
264static void _clear_gpio_debounce(struct gpio_bank *bank, unsigned gpio)
265{
266 u32 gpio_bit = GPIO_BIT(bank, gpio);
267
268 if (!bank->dbck_flag)
269 return;
270
271 if (!(bank->dbck_enable_mask & gpio_bit))
272 return;
273
274 bank->dbck_enable_mask &= ~gpio_bit;
275 bank->context.debounce_en &= ~gpio_bit;
276 __raw_writel(bank->context.debounce_en,
277 bank->base + bank->regs->debounce_en);
278
279 if (!bank->dbck_enable_mask) {
280 bank->context.debounce = 0;
281 __raw_writel(bank->context.debounce, bank->base +
282 bank->regs->debounce);
283 clk_disable(bank->dbck);
284 bank->dbck_enabled = false;
285 }
286}
287
254static inline void set_gpio_trigger(struct gpio_bank *bank, int gpio, 288static inline void set_gpio_trigger(struct gpio_bank *bank, int gpio,
255 unsigned trigger) 289 unsigned trigger)
256{ 290{
@@ -539,6 +573,7 @@ static void _reset_gpio(struct gpio_bank *bank, int gpio)
539 _set_gpio_irqenable(bank, gpio, 0); 573 _set_gpio_irqenable(bank, gpio, 0);
540 _clear_gpio_irqstatus(bank, gpio); 574 _clear_gpio_irqstatus(bank, gpio);
541 _set_gpio_triggering(bank, GPIO_INDEX(bank, gpio), IRQ_TYPE_NONE); 575 _set_gpio_triggering(bank, GPIO_INDEX(bank, gpio), IRQ_TYPE_NONE);
576 _clear_gpio_debounce(bank, gpio);
542} 577}
543 578
544/* Use disable_irq_wake() and enable_irq_wake() functions from drivers */ 579/* Use disable_irq_wake() and enable_irq_wake() functions from drivers */
diff --git a/drivers/gpio/gpio-timberdale.c b/drivers/gpio/gpio-timberdale.c
index 031c6adf5b6..1a3e2b9b477 100644
--- a/drivers/gpio/gpio-timberdale.c
+++ b/drivers/gpio/gpio-timberdale.c
@@ -116,7 +116,7 @@ static void timbgpio_irq_disable(struct irq_data *d)
116 unsigned long flags; 116 unsigned long flags;
117 117
118 spin_lock_irqsave(&tgpio->lock, flags); 118 spin_lock_irqsave(&tgpio->lock, flags);
119 tgpio->last_ier &= ~(1 << offset); 119 tgpio->last_ier &= ~(1UL << offset);
120 iowrite32(tgpio->last_ier, tgpio->membase + TGPIO_IER); 120 iowrite32(tgpio->last_ier, tgpio->membase + TGPIO_IER);
121 spin_unlock_irqrestore(&tgpio->lock, flags); 121 spin_unlock_irqrestore(&tgpio->lock, flags);
122} 122}
@@ -128,7 +128,7 @@ static void timbgpio_irq_enable(struct irq_data *d)
128 unsigned long flags; 128 unsigned long flags;
129 129
130 spin_lock_irqsave(&tgpio->lock, flags); 130 spin_lock_irqsave(&tgpio->lock, flags);
131 tgpio->last_ier |= 1 << offset; 131 tgpio->last_ier |= 1UL << offset;
132 iowrite32(tgpio->last_ier, tgpio->membase + TGPIO_IER); 132 iowrite32(tgpio->last_ier, tgpio->membase + TGPIO_IER);
133 spin_unlock_irqrestore(&tgpio->lock, flags); 133 spin_unlock_irqrestore(&tgpio->lock, flags);
134} 134}
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 5d6c71edc73..1c8d9e3380e 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -623,9 +623,11 @@ static ssize_t export_store(struct class *class,
623 */ 623 */
624 624
625 status = gpio_request(gpio, "sysfs"); 625 status = gpio_request(gpio, "sysfs");
626 if (status < 0) 626 if (status < 0) {
627 if (status == -EPROBE_DEFER)
628 status = -ENODEV;
627 goto done; 629 goto done;
628 630 }
629 status = gpio_export(gpio, true); 631 status = gpio_export(gpio, true);
630 if (status < 0) 632 if (status < 0)
631 gpio_free(gpio); 633 gpio_free(gpio);
@@ -1191,8 +1193,10 @@ int gpio_request(unsigned gpio, const char *label)
1191 1193
1192 spin_lock_irqsave(&gpio_lock, flags); 1194 spin_lock_irqsave(&gpio_lock, flags);
1193 1195
1194 if (!gpio_is_valid(gpio)) 1196 if (!gpio_is_valid(gpio)) {
1197 status = -EINVAL;
1195 goto done; 1198 goto done;
1199 }
1196 desc = &gpio_desc[gpio]; 1200 desc = &gpio_desc[gpio];
1197 chip = desc->chip; 1201 chip = desc->chip;
1198 if (chip == NULL) 1202 if (chip == NULL)
diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c b/drivers/gpu/drm/drm_fb_cma_helper.c
index 09e11a5d921..fd9d0af4d53 100644
--- a/drivers/gpu/drm/drm_fb_cma_helper.c
+++ b/drivers/gpu/drm/drm_fb_cma_helper.c
@@ -206,7 +206,7 @@ static int drm_fbdev_cma_create(struct drm_fb_helper *helper,
206 size_t size; 206 size_t size;
207 int ret; 207 int ret;
208 208
209 DRM_DEBUG_KMS("surface width(%d), height(%d) and bpp(%d\n", 209 DRM_DEBUG_KMS("surface width(%d), height(%d) and bpp(%d)\n",
210 sizes->surface_width, sizes->surface_height, 210 sizes->surface_width, sizes->surface_height,
211 sizes->surface_bpp); 211 sizes->surface_bpp);
212 212
@@ -220,7 +220,7 @@ static int drm_fbdev_cma_create(struct drm_fb_helper *helper,
220 220
221 size = mode_cmd.pitches[0] * mode_cmd.height; 221 size = mode_cmd.pitches[0] * mode_cmd.height;
222 obj = drm_gem_cma_create(dev, size); 222 obj = drm_gem_cma_create(dev, size);
223 if (!obj) 223 if (IS_ERR(obj))
224 return -ENOMEM; 224 return -ENOMEM;
225 225
226 fbi = framebuffer_alloc(0, dev->dev); 226 fbi = framebuffer_alloc(0, dev->dev);
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index 7ef1b673e1b..133b4132983 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -121,6 +121,8 @@ int drm_open(struct inode *inode, struct file *filp)
121 int minor_id = iminor(inode); 121 int minor_id = iminor(inode);
122 struct drm_minor *minor; 122 struct drm_minor *minor;
123 int retcode = 0; 123 int retcode = 0;
124 int need_setup = 0;
125 struct address_space *old_mapping;
124 126
125 minor = idr_find(&drm_minors_idr, minor_id); 127 minor = idr_find(&drm_minors_idr, minor_id);
126 if (!minor) 128 if (!minor)
@@ -132,23 +134,37 @@ int drm_open(struct inode *inode, struct file *filp)
132 if (drm_device_is_unplugged(dev)) 134 if (drm_device_is_unplugged(dev))
133 return -ENODEV; 135 return -ENODEV;
134 136
137 if (!dev->open_count++)
138 need_setup = 1;
139 mutex_lock(&dev->struct_mutex);
140 old_mapping = dev->dev_mapping;
141 if (old_mapping == NULL)
142 dev->dev_mapping = &inode->i_data;
143 /* ihold ensures nobody can remove inode with our i_data */
144 ihold(container_of(dev->dev_mapping, struct inode, i_data));
145 inode->i_mapping = dev->dev_mapping;
146 filp->f_mapping = dev->dev_mapping;
147 mutex_unlock(&dev->struct_mutex);
148
135 retcode = drm_open_helper(inode, filp, dev); 149 retcode = drm_open_helper(inode, filp, dev);
136 if (!retcode) { 150 if (retcode)
137 atomic_inc(&dev->counts[_DRM_STAT_OPENS]); 151 goto err_undo;
138 if (!dev->open_count++) 152 atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
139 retcode = drm_setup(dev); 153 if (need_setup) {
140 } 154 retcode = drm_setup(dev);
141 if (!retcode) { 155 if (retcode)
142 mutex_lock(&dev->struct_mutex); 156 goto err_undo;
143 if (dev->dev_mapping == NULL)
144 dev->dev_mapping = &inode->i_data;
145 /* ihold ensures nobody can remove inode with our i_data */
146 ihold(container_of(dev->dev_mapping, struct inode, i_data));
147 inode->i_mapping = dev->dev_mapping;
148 filp->f_mapping = dev->dev_mapping;
149 mutex_unlock(&dev->struct_mutex);
150 } 157 }
158 return 0;
151 159
160err_undo:
161 mutex_lock(&dev->struct_mutex);
162 filp->f_mapping = old_mapping;
163 inode->i_mapping = old_mapping;
164 iput(container_of(dev->dev_mapping, struct inode, i_data));
165 dev->dev_mapping = old_mapping;
166 mutex_unlock(&dev->struct_mutex);
167 dev->open_count--;
152 return retcode; 168 return retcode;
153} 169}
154EXPORT_SYMBOL(drm_open); 170EXPORT_SYMBOL(drm_open);
diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
index cdf8b1e7602..d4b20ceda3f 100644
--- a/drivers/gpu/drm/drm_info.c
+++ b/drivers/gpu/drm/drm_info.c
@@ -205,8 +205,6 @@ static int drm_gem_one_name_info(int id, void *ptr, void *data)
205 struct drm_gem_object *obj = ptr; 205 struct drm_gem_object *obj = ptr;
206 struct seq_file *m = data; 206 struct seq_file *m = data;
207 207
208 seq_printf(m, "name %d size %zd\n", obj->name, obj->size);
209
210 seq_printf(m, "%6d %8zd %7d %8d\n", 208 seq_printf(m, "%6d %8zd %7d %8d\n",
211 obj->name, obj->size, 209 obj->name, obj->size,
212 atomic_read(&obj->handle_count), 210 atomic_read(&obj->handle_count),
@@ -239,7 +237,7 @@ int drm_vma_info(struct seq_file *m, void *data)
239 mutex_lock(&dev->struct_mutex); 237 mutex_lock(&dev->struct_mutex);
240 seq_printf(m, "vma use count: %d, high_memory = %pK, 0x%pK\n", 238 seq_printf(m, "vma use count: %d, high_memory = %pK, 0x%pK\n",
241 atomic_read(&dev->vma_count), 239 atomic_read(&dev->vma_count),
242 high_memory, (void *)virt_to_phys(high_memory)); 240 high_memory, (void *)(unsigned long)virt_to_phys(high_memory));
243 241
244 list_for_each_entry(pt, &dev->vmalist, head) { 242 list_for_each_entry(pt, &dev->vmalist, head) {
245 vma = pt->vma; 243 vma = pt->vma;
diff --git a/drivers/gpu/drm/drm_platform.c b/drivers/gpu/drm/drm_platform.c
index aaeb6f8d69c..b8a282ea875 100644
--- a/drivers/gpu/drm/drm_platform.c
+++ b/drivers/gpu/drm/drm_platform.c
@@ -64,7 +64,6 @@ int drm_get_platform_dev(struct platform_device *platdev,
64 } 64 }
65 65
66 if (drm_core_check_feature(dev, DRIVER_MODESET)) { 66 if (drm_core_check_feature(dev, DRIVER_MODESET)) {
67 dev_set_drvdata(&platdev->dev, dev);
68 ret = drm_get_minor(dev, &dev->control, DRM_MINOR_CONTROL); 67 ret = drm_get_minor(dev, &dev->control, DRM_MINOR_CONTROL);
69 if (ret) 68 if (ret)
70 goto err_g1; 69 goto err_g1;
diff --git a/drivers/gpu/drm/exynos/Kconfig b/drivers/gpu/drm/exynos/Kconfig
index 59a26e577b5..fc345d4ebb0 100644
--- a/drivers/gpu/drm/exynos/Kconfig
+++ b/drivers/gpu/drm/exynos/Kconfig
@@ -1,6 +1,6 @@
1config DRM_EXYNOS 1config DRM_EXYNOS
2 tristate "DRM Support for Samsung SoC EXYNOS Series" 2 tristate "DRM Support for Samsung SoC EXYNOS Series"
3 depends on DRM && PLAT_SAMSUNG 3 depends on DRM && (PLAT_SAMSUNG || ARCH_MULTIPLATFORM)
4 select DRM_KMS_HELPER 4 select DRM_KMS_HELPER
5 select FB_CFB_FILLRECT 5 select FB_CFB_FILLRECT
6 select FB_CFB_COPYAREA 6 select FB_CFB_COPYAREA
diff --git a/drivers/gpu/drm/exynos/exynos_drm_connector.c b/drivers/gpu/drm/exynos/exynos_drm_connector.c
index 18c271862ca..0f68a287267 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_connector.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_connector.c
@@ -374,6 +374,7 @@ struct drm_connector *exynos_drm_connector_create(struct drm_device *dev,
374 exynos_connector->encoder_id = encoder->base.id; 374 exynos_connector->encoder_id = encoder->base.id;
375 exynos_connector->manager = manager; 375 exynos_connector->manager = manager;
376 exynos_connector->dpms = DRM_MODE_DPMS_OFF; 376 exynos_connector->dpms = DRM_MODE_DPMS_OFF;
377 connector->dpms = DRM_MODE_DPMS_OFF;
377 connector->encoder = encoder; 378 connector->encoder = encoder;
378 379
379 err = drm_mode_connector_attach_encoder(connector, encoder); 380 err = drm_mode_connector_attach_encoder(connector, encoder);
diff --git a/drivers/gpu/drm/exynos/exynos_drm_encoder.c b/drivers/gpu/drm/exynos/exynos_drm_encoder.c
index e51503fbaf2..241ad1eeec6 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_encoder.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_encoder.c
@@ -43,12 +43,14 @@
43 * @manager: specific encoder has its own manager to control a hardware 43 * @manager: specific encoder has its own manager to control a hardware
44 * appropriately and we can access a hardware drawing on this manager. 44 * appropriately and we can access a hardware drawing on this manager.
45 * @dpms: store the encoder dpms value. 45 * @dpms: store the encoder dpms value.
46 * @updated: indicate whether overlay data updating is needed or not.
46 */ 47 */
47struct exynos_drm_encoder { 48struct exynos_drm_encoder {
48 struct drm_crtc *old_crtc; 49 struct drm_crtc *old_crtc;
49 struct drm_encoder drm_encoder; 50 struct drm_encoder drm_encoder;
50 struct exynos_drm_manager *manager; 51 struct exynos_drm_manager *manager;
51 int dpms; 52 int dpms;
53 bool updated;
52}; 54};
53 55
54static void exynos_drm_connector_power(struct drm_encoder *encoder, int mode) 56static void exynos_drm_connector_power(struct drm_encoder *encoder, int mode)
@@ -85,7 +87,9 @@ static void exynos_drm_encoder_dpms(struct drm_encoder *encoder, int mode)
85 switch (mode) { 87 switch (mode) {
86 case DRM_MODE_DPMS_ON: 88 case DRM_MODE_DPMS_ON:
87 if (manager_ops && manager_ops->apply) 89 if (manager_ops && manager_ops->apply)
88 manager_ops->apply(manager->dev); 90 if (!exynos_encoder->updated)
91 manager_ops->apply(manager->dev);
92
89 exynos_drm_connector_power(encoder, mode); 93 exynos_drm_connector_power(encoder, mode);
90 exynos_encoder->dpms = mode; 94 exynos_encoder->dpms = mode;
91 break; 95 break;
@@ -94,6 +98,7 @@ static void exynos_drm_encoder_dpms(struct drm_encoder *encoder, int mode)
94 case DRM_MODE_DPMS_OFF: 98 case DRM_MODE_DPMS_OFF:
95 exynos_drm_connector_power(encoder, mode); 99 exynos_drm_connector_power(encoder, mode);
96 exynos_encoder->dpms = mode; 100 exynos_encoder->dpms = mode;
101 exynos_encoder->updated = false;
97 break; 102 break;
98 default: 103 default:
99 DRM_ERROR("unspecified mode %d\n", mode); 104 DRM_ERROR("unspecified mode %d\n", mode);
@@ -205,13 +210,22 @@ static void exynos_drm_encoder_prepare(struct drm_encoder *encoder)
205 210
206static void exynos_drm_encoder_commit(struct drm_encoder *encoder) 211static void exynos_drm_encoder_commit(struct drm_encoder *encoder)
207{ 212{
208 struct exynos_drm_manager *manager = exynos_drm_get_manager(encoder); 213 struct exynos_drm_encoder *exynos_encoder = to_exynos_encoder(encoder);
214 struct exynos_drm_manager *manager = exynos_encoder->manager;
209 struct exynos_drm_manager_ops *manager_ops = manager->ops; 215 struct exynos_drm_manager_ops *manager_ops = manager->ops;
210 216
211 DRM_DEBUG_KMS("%s\n", __FILE__); 217 DRM_DEBUG_KMS("%s\n", __FILE__);
212 218
213 if (manager_ops && manager_ops->commit) 219 if (manager_ops && manager_ops->commit)
214 manager_ops->commit(manager->dev); 220 manager_ops->commit(manager->dev);
221
222 /*
223 * this will avoid one issue that overlay data is updated to
224 * real hardware two times.
225 * And this variable will be used to check if the data was
226 * already updated or not by exynos_drm_encoder_dpms function.
227 */
228 exynos_encoder->updated = true;
215} 229}
216 230
217static void exynos_drm_encoder_disable(struct drm_encoder *encoder) 231static void exynos_drm_encoder_disable(struct drm_encoder *encoder)
@@ -401,19 +415,6 @@ void exynos_drm_encoder_crtc_dpms(struct drm_encoder *encoder, void *data)
401 manager_ops->dpms(manager->dev, mode); 415 manager_ops->dpms(manager->dev, mode);
402 416
403 /* 417 /*
404 * set current mode to new one so that data aren't updated into
405 * registers by drm_helper_connector_dpms two times.
406 *
407 * in case that drm_crtc_helper_set_mode() is called,
408 * overlay_ops->commit() and manager_ops->commit() callbacks
409 * can be called two times, first at drm_crtc_helper_set_mode()
410 * and second at drm_helper_connector_dpms().
411 * so with this setting, when drm_helper_connector_dpms() is called
412 * encoder->funcs->dpms() will be ignored.
413 */
414 exynos_encoder->dpms = mode;
415
416 /*
417 * if this condition is ok then it means that the crtc is already 418 * if this condition is ok then it means that the crtc is already
418 * detached from encoder and last function for detaching is properly 419 * detached from encoder and last function for detaching is properly
419 * done, so clear pipe from manager to prevent repeated call. 420 * done, so clear pipe from manager to prevent repeated call.
diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c b/drivers/gpu/drm/exynos/exynos_mixer.c
index 614b2e9ac46..e7fbb823fd8 100644
--- a/drivers/gpu/drm/exynos/exynos_mixer.c
+++ b/drivers/gpu/drm/exynos/exynos_mixer.c
@@ -1142,7 +1142,7 @@ static int __devinit mixer_probe(struct platform_device *pdev)
1142 const struct of_device_id *match; 1142 const struct of_device_id *match;
1143 match = of_match_node(of_match_ptr(mixer_match_types), 1143 match = of_match_node(of_match_ptr(mixer_match_types),
1144 pdev->dev.of_node); 1144 pdev->dev.of_node);
1145 drv = match->data; 1145 drv = (struct mixer_drv_data *)match->data;
1146 } else { 1146 } else {
1147 drv = (struct mixer_drv_data *) 1147 drv = (struct mixer_drv_data *)
1148 platform_get_device_id(pdev)->driver_data; 1148 platform_get_device_id(pdev)->driver_data;
diff --git a/drivers/gpu/drm/i915/dvo_ch7xxx.c b/drivers/gpu/drm/i915/dvo_ch7xxx.c
index 38f3a6cb8c7..3edd981e077 100644
--- a/drivers/gpu/drm/i915/dvo_ch7xxx.c
+++ b/drivers/gpu/drm/i915/dvo_ch7xxx.c
@@ -303,10 +303,10 @@ static bool ch7xxx_get_hw_state(struct intel_dvo_device *dvo)
303 303
304 ch7xxx_readb(dvo, CH7xxx_PM, &val); 304 ch7xxx_readb(dvo, CH7xxx_PM, &val);
305 305
306 if (val & CH7xxx_PM_FPD) 306 if (val & (CH7xxx_PM_DVIL | CH7xxx_PM_DVIP))
307 return false;
308 else
309 return true; 307 return true;
308 else
309 return false;
310} 310}
311 311
312static void ch7xxx_dump_regs(struct intel_dvo_device *dvo) 312static void ch7xxx_dump_regs(struct intel_dvo_device *dvo)
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index c9bfd83dde6..61ae104dca8 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -1505,7 +1505,8 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
1505 goto put_gmch; 1505 goto put_gmch;
1506 } 1506 }
1507 1507
1508 i915_kick_out_firmware_fb(dev_priv); 1508 if (drm_core_check_feature(dev, DRIVER_MODESET))
1509 i915_kick_out_firmware_fb(dev_priv);
1509 1510
1510 pci_set_master(dev->pdev); 1511 pci_set_master(dev->pdev);
1511 1512
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index aac4e5e1a5b..6770ee6084b 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -118,6 +118,13 @@ module_param_named(i915_enable_ppgtt, i915_enable_ppgtt, int, 0600);
118MODULE_PARM_DESC(i915_enable_ppgtt, 118MODULE_PARM_DESC(i915_enable_ppgtt,
119 "Enable PPGTT (default: true)"); 119 "Enable PPGTT (default: true)");
120 120
121unsigned int i915_preliminary_hw_support __read_mostly = 0;
122module_param_named(preliminary_hw_support, i915_preliminary_hw_support, int, 0600);
123MODULE_PARM_DESC(preliminary_hw_support,
124 "Enable preliminary hardware support. "
125 "Enable Haswell and ValleyView Support. "
126 "(default: false)");
127
121static struct drm_driver driver; 128static struct drm_driver driver;
122extern int intel_agp_enabled; 129extern int intel_agp_enabled;
123 130
@@ -826,6 +833,12 @@ i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
826 struct intel_device_info *intel_info = 833 struct intel_device_info *intel_info =
827 (struct intel_device_info *) ent->driver_data; 834 (struct intel_device_info *) ent->driver_data;
828 835
836 if (intel_info->is_haswell || intel_info->is_valleyview)
837 if(!i915_preliminary_hw_support) {
838 DRM_ERROR("Preliminary hardware support disabled\n");
839 return -ENODEV;
840 }
841
829 /* Only bind to function 0 of the device. Early generations 842 /* Only bind to function 0 of the device. Early generations
830 * used function 1 as a placeholder for multi-head. This causes 843 * used function 1 as a placeholder for multi-head. This causes
831 * us confusion instead, especially on the systems where both 844 * us confusion instead, especially on the systems where both
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 4f2831aa5fe..f511fa2f416 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1217,6 +1217,7 @@ extern int i915_enable_rc6 __read_mostly;
1217extern int i915_enable_fbc __read_mostly; 1217extern int i915_enable_fbc __read_mostly;
1218extern bool i915_enable_hangcheck __read_mostly; 1218extern bool i915_enable_hangcheck __read_mostly;
1219extern int i915_enable_ppgtt __read_mostly; 1219extern int i915_enable_ppgtt __read_mostly;
1220extern unsigned int i915_preliminary_hw_support __read_mostly;
1220 1221
1221extern int i915_suspend(struct drm_device *dev, pm_message_t state); 1222extern int i915_suspend(struct drm_device *dev, pm_message_t state);
1222extern int i915_resume(struct drm_device *dev); 1223extern int i915_resume(struct drm_device *dev);
@@ -1341,9 +1342,14 @@ int __must_check i915_gem_object_get_pages(struct drm_i915_gem_object *obj);
1341static inline struct page *i915_gem_object_get_page(struct drm_i915_gem_object *obj, int n) 1342static inline struct page *i915_gem_object_get_page(struct drm_i915_gem_object *obj, int n)
1342{ 1343{
1343 struct scatterlist *sg = obj->pages->sgl; 1344 struct scatterlist *sg = obj->pages->sgl;
1344 while (n >= SG_MAX_SINGLE_ALLOC) { 1345 int nents = obj->pages->nents;
1346 while (nents > SG_MAX_SINGLE_ALLOC) {
1347 if (n < SG_MAX_SINGLE_ALLOC - 1)
1348 break;
1349
1345 sg = sg_chain_ptr(sg + SG_MAX_SINGLE_ALLOC - 1); 1350 sg = sg_chain_ptr(sg + SG_MAX_SINGLE_ALLOC - 1);
1346 n -= SG_MAX_SINGLE_ALLOC - 1; 1351 n -= SG_MAX_SINGLE_ALLOC - 1;
1352 nents -= SG_MAX_SINGLE_ALLOC - 1;
1347 } 1353 }
1348 return sg_page(sg+n); 1354 return sg_page(sg+n);
1349} 1355}
@@ -1427,7 +1433,7 @@ int __must_check i915_gpu_idle(struct drm_device *dev);
1427int __must_check i915_gem_idle(struct drm_device *dev); 1433int __must_check i915_gem_idle(struct drm_device *dev);
1428int i915_add_request(struct intel_ring_buffer *ring, 1434int i915_add_request(struct intel_ring_buffer *ring,
1429 struct drm_file *file, 1435 struct drm_file *file,
1430 struct drm_i915_gem_request *request); 1436 u32 *seqno);
1431int __must_check i915_wait_seqno(struct intel_ring_buffer *ring, 1437int __must_check i915_wait_seqno(struct intel_ring_buffer *ring,
1432 uint32_t seqno); 1438 uint32_t seqno);
1433int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf); 1439int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf);
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 19dbdd7dd56..107f09befe9 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -1407,8 +1407,10 @@ out:
1407 return VM_FAULT_NOPAGE; 1407 return VM_FAULT_NOPAGE;
1408 case -ENOMEM: 1408 case -ENOMEM:
1409 return VM_FAULT_OOM; 1409 return VM_FAULT_OOM;
1410 case -ENOSPC:
1411 return VM_FAULT_SIGBUS;
1410 default: 1412 default:
1411 WARN_ON_ONCE(ret); 1413 WARN_ONCE(ret, "unhandled error in i915_gem_fault: %i\n", ret);
1412 return VM_FAULT_SIGBUS; 1414 return VM_FAULT_SIGBUS;
1413 } 1415 }
1414} 1416}
@@ -1822,10 +1824,11 @@ i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj)
1822 sg_set_page(sg, page, PAGE_SIZE, 0); 1824 sg_set_page(sg, page, PAGE_SIZE, 0);
1823 } 1825 }
1824 1826
1827 obj->pages = st;
1828
1825 if (i915_gem_object_needs_bit17_swizzle(obj)) 1829 if (i915_gem_object_needs_bit17_swizzle(obj))
1826 i915_gem_object_do_bit_17_swizzle(obj); 1830 i915_gem_object_do_bit_17_swizzle(obj);
1827 1831
1828 obj->pages = st;
1829 return 0; 1832 return 0;
1830 1833
1831err_pages: 1834err_pages:
@@ -1955,11 +1958,12 @@ i915_gem_next_request_seqno(struct intel_ring_buffer *ring)
1955int 1958int
1956i915_add_request(struct intel_ring_buffer *ring, 1959i915_add_request(struct intel_ring_buffer *ring,
1957 struct drm_file *file, 1960 struct drm_file *file,
1958 struct drm_i915_gem_request *request) 1961 u32 *out_seqno)
1959{ 1962{
1960 drm_i915_private_t *dev_priv = ring->dev->dev_private; 1963 drm_i915_private_t *dev_priv = ring->dev->dev_private;
1961 uint32_t seqno; 1964 struct drm_i915_gem_request *request;
1962 u32 request_ring_position; 1965 u32 request_ring_position;
1966 u32 seqno;
1963 int was_empty; 1967 int was_empty;
1964 int ret; 1968 int ret;
1965 1969
@@ -1974,11 +1978,9 @@ i915_add_request(struct intel_ring_buffer *ring,
1974 if (ret) 1978 if (ret)
1975 return ret; 1979 return ret;
1976 1980
1977 if (request == NULL) { 1981 request = kmalloc(sizeof(*request), GFP_KERNEL);
1978 request = kmalloc(sizeof(*request), GFP_KERNEL); 1982 if (request == NULL)
1979 if (request == NULL) 1983 return -ENOMEM;
1980 return -ENOMEM;
1981 }
1982 1984
1983 seqno = i915_gem_next_request_seqno(ring); 1985 seqno = i915_gem_next_request_seqno(ring);
1984 1986
@@ -2030,6 +2032,8 @@ i915_add_request(struct intel_ring_buffer *ring,
2030 } 2032 }
2031 } 2033 }
2032 2034
2035 if (out_seqno)
2036 *out_seqno = seqno;
2033 return 0; 2037 return 0;
2034} 2038}
2035 2039
@@ -3959,6 +3963,9 @@ i915_gem_init_hw(struct drm_device *dev)
3959 if (!intel_enable_gtt()) 3963 if (!intel_enable_gtt())
3960 return -EIO; 3964 return -EIO;
3961 3965
3966 if (IS_HASWELL(dev) && (I915_READ(0x120010) == 1))
3967 I915_WRITE(0x9008, I915_READ(0x9008) | 0xf0000);
3968
3962 i915_gem_l3_remap(dev); 3969 i915_gem_l3_remap(dev);
3963 3970
3964 i915_gem_init_swizzling(dev); 3971 i915_gem_init_swizzling(dev);
@@ -4098,7 +4105,6 @@ i915_gem_entervt_ioctl(struct drm_device *dev, void *data,
4098 } 4105 }
4099 4106
4100 BUG_ON(!list_empty(&dev_priv->mm.active_list)); 4107 BUG_ON(!list_empty(&dev_priv->mm.active_list));
4101 BUG_ON(!list_empty(&dev_priv->mm.inactive_list));
4102 mutex_unlock(&dev->struct_mutex); 4108 mutex_unlock(&dev->struct_mutex);
4103 4109
4104 ret = drm_irq_install(dev); 4110 ret = drm_irq_install(dev);
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 64c1be0a9cf..a4162ddff6c 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -521,7 +521,7 @@
521 */ 521 */
522# define _3D_CHICKEN2_WM_READ_PIPELINED (1 << 14) 522# define _3D_CHICKEN2_WM_READ_PIPELINED (1 << 14)
523#define _3D_CHICKEN3 0x02090 523#define _3D_CHICKEN3 0x02090
524#define _3D_CHICKEN_SF_DISABLE_FASTCLIP_CULL (1 << 5) 524#define _3D_CHICKEN3_SF_DISABLE_FASTCLIP_CULL (1 << 5)
525 525
526#define MI_MODE 0x0209c 526#define MI_MODE 0x0209c
527# define VS_TIMER_DISPATCH (1 << 6) 527# define VS_TIMER_DISPATCH (1 << 6)
diff --git a/drivers/gpu/drm/i915/intel_crt.c b/drivers/gpu/drm/i915/intel_crt.c
index 893f30164b7..6345878ae1e 100644
--- a/drivers/gpu/drm/i915/intel_crt.c
+++ b/drivers/gpu/drm/i915/intel_crt.c
@@ -143,7 +143,7 @@ static void intel_crt_dpms(struct drm_connector *connector, int mode)
143 int old_dpms; 143 int old_dpms;
144 144
145 /* PCH platforms and VLV only support on/off. */ 145 /* PCH platforms and VLV only support on/off. */
146 if (INTEL_INFO(dev)->gen < 5 && mode != DRM_MODE_DPMS_ON) 146 if (INTEL_INFO(dev)->gen >= 5 && mode != DRM_MODE_DPMS_ON)
147 mode = DRM_MODE_DPMS_OFF; 147 mode = DRM_MODE_DPMS_OFF;
148 148
149 if (mode == connector->dpms) 149 if (mode == connector->dpms)
@@ -219,20 +219,7 @@ static void intel_crt_mode_set(struct drm_encoder *encoder,
219 intel_encoder_to_crt(to_intel_encoder(encoder)); 219 intel_encoder_to_crt(to_intel_encoder(encoder));
220 struct intel_crtc *intel_crtc = to_intel_crtc(crtc); 220 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
221 struct drm_i915_private *dev_priv = dev->dev_private; 221 struct drm_i915_private *dev_priv = dev->dev_private;
222 int dpll_md_reg; 222 u32 adpa;
223 u32 adpa, dpll_md;
224
225 dpll_md_reg = DPLL_MD(intel_crtc->pipe);
226
227 /*
228 * Disable separate mode multiplier used when cloning SDVO to CRT
229 * XXX this needs to be adjusted when we really are cloning
230 */
231 if (INTEL_INFO(dev)->gen >= 4 && !HAS_PCH_SPLIT(dev)) {
232 dpll_md = I915_READ(dpll_md_reg);
233 I915_WRITE(dpll_md_reg,
234 dpll_md & ~DPLL_MD_UDI_MULTIPLIER_MASK);
235 }
236 223
237 adpa = ADPA_HOTPLUG_BITS; 224 adpa = ADPA_HOTPLUG_BITS;
238 if (adjusted_mode->flags & DRM_MODE_FLAG_PHSYNC) 225 if (adjusted_mode->flags & DRM_MODE_FLAG_PHSYNC)
@@ -742,7 +729,7 @@ void intel_crt_init(struct drm_device *dev)
742 729
743 crt->base.type = INTEL_OUTPUT_ANALOG; 730 crt->base.type = INTEL_OUTPUT_ANALOG;
744 crt->base.cloneable = true; 731 crt->base.cloneable = true;
745 if (IS_HASWELL(dev)) 732 if (IS_HASWELL(dev) || IS_I830(dev))
746 crt->base.crtc_mask = (1 << 0); 733 crt->base.crtc_mask = (1 << 0);
747 else 734 else
748 crt->base.crtc_mask = (1 << 0) | (1 << 1) | (1 << 2); 735 crt->base.crtc_mask = (1 << 0) | (1 << 1) | (1 << 2);
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 2b6ce9b2674..4154bcd7a07 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -3253,6 +3253,16 @@ static void ironlake_crtc_enable(struct drm_crtc *crtc)
3253 3253
3254 if (HAS_PCH_CPT(dev)) 3254 if (HAS_PCH_CPT(dev))
3255 intel_cpt_verify_modeset(dev, intel_crtc->pipe); 3255 intel_cpt_verify_modeset(dev, intel_crtc->pipe);
3256
3257 /*
3258 * There seems to be a race in PCH platform hw (at least on some
3259 * outputs) where an enabled pipe still completes any pageflip right
3260 * away (as if the pipe is off) instead of waiting for vblank. As soon
3261 * as the first vblank happend, everything works as expected. Hence just
3262 * wait for one vblank before returning to avoid strange things
3263 * happening.
3264 */
3265 intel_wait_for_vblank(dev, intel_crtc->pipe);
3256} 3266}
3257 3267
3258static void ironlake_crtc_disable(struct drm_crtc *crtc) 3268static void ironlake_crtc_disable(struct drm_crtc *crtc)
@@ -3831,6 +3841,17 @@ static bool intel_choose_pipe_bpp_dither(struct drm_crtc *crtc,
3831 } 3841 }
3832 } 3842 }
3833 3843
3844 if (intel_encoder->type == INTEL_OUTPUT_EDP) {
3845 /* Use VBT settings if we have an eDP panel */
3846 unsigned int edp_bpc = dev_priv->edp.bpp / 3;
3847
3848 if (edp_bpc < display_bpc) {
3849 DRM_DEBUG_KMS("clamping display bpc (was %d) to eDP (%d)\n", display_bpc, edp_bpc);
3850 display_bpc = edp_bpc;
3851 }
3852 continue;
3853 }
3854
3834 /* 3855 /*
3835 * HDMI is either 12 or 8, so if the display lets 10bpc sneak 3856 * HDMI is either 12 or 8, so if the display lets 10bpc sneak
3836 * through, clamp it down. (Note: >12bpc will be caught below.) 3857 * through, clamp it down. (Note: >12bpc will be caught below.)
@@ -7882,6 +7903,34 @@ struct intel_quirk {
7882 void (*hook)(struct drm_device *dev); 7903 void (*hook)(struct drm_device *dev);
7883}; 7904};
7884 7905
7906/* For systems that don't have a meaningful PCI subdevice/subvendor ID */
7907struct intel_dmi_quirk {
7908 void (*hook)(struct drm_device *dev);
7909 const struct dmi_system_id (*dmi_id_list)[];
7910};
7911
7912static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
7913{
7914 DRM_INFO("Backlight polarity reversed on %s\n", id->ident);
7915 return 1;
7916}
7917
7918static const struct intel_dmi_quirk intel_dmi_quirks[] = {
7919 {
7920 .dmi_id_list = &(const struct dmi_system_id[]) {
7921 {
7922 .callback = intel_dmi_reverse_brightness,
7923 .ident = "NCR Corporation",
7924 .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
7925 DMI_MATCH(DMI_PRODUCT_NAME, ""),
7926 },
7927 },
7928 { } /* terminating entry */
7929 },
7930 .hook = quirk_invert_brightness,
7931 },
7932};
7933
7885static struct intel_quirk intel_quirks[] = { 7934static struct intel_quirk intel_quirks[] = {
7886 /* HP Mini needs pipe A force quirk (LP: #322104) */ 7935 /* HP Mini needs pipe A force quirk (LP: #322104) */
7887 { 0x27ae, 0x103c, 0x361a, quirk_pipea_force }, 7936 { 0x27ae, 0x103c, 0x361a, quirk_pipea_force },
@@ -7892,8 +7941,7 @@ static struct intel_quirk intel_quirks[] = {
7892 /* ThinkPad T60 needs pipe A force quirk (bug #16494) */ 7941 /* ThinkPad T60 needs pipe A force quirk (bug #16494) */
7893 { 0x2782, 0x17aa, 0x201a, quirk_pipea_force }, 7942 { 0x2782, 0x17aa, 0x201a, quirk_pipea_force },
7894 7943
7895 /* 855 & before need to leave pipe A & dpll A up */ 7944 /* 830/845 need to leave pipe A & dpll A up */
7896 { 0x3582, PCI_ANY_ID, PCI_ANY_ID, quirk_pipea_force },
7897 { 0x2562, PCI_ANY_ID, PCI_ANY_ID, quirk_pipea_force }, 7945 { 0x2562, PCI_ANY_ID, PCI_ANY_ID, quirk_pipea_force },
7898 { 0x3577, PCI_ANY_ID, PCI_ANY_ID, quirk_pipea_force }, 7946 { 0x3577, PCI_ANY_ID, PCI_ANY_ID, quirk_pipea_force },
7899 7947
@@ -7922,6 +7970,10 @@ static void intel_init_quirks(struct drm_device *dev)
7922 q->subsystem_device == PCI_ANY_ID)) 7970 q->subsystem_device == PCI_ANY_ID))
7923 q->hook(dev); 7971 q->hook(dev);
7924 } 7972 }
7973 for (i = 0; i < ARRAY_SIZE(intel_dmi_quirks); i++) {
7974 if (dmi_check_system(*intel_dmi_quirks[i].dmi_id_list) != 0)
7975 intel_dmi_quirks[i].hook(dev);
7976 }
7925} 7977}
7926 7978
7927/* Disable the VGA plane that we never use */ 7979/* Disable the VGA plane that we never use */
@@ -8049,29 +8101,42 @@ static void intel_enable_pipe_a(struct drm_device *dev)
8049 8101
8050} 8102}
8051 8103
8104static bool
8105intel_check_plane_mapping(struct intel_crtc *crtc)
8106{
8107 struct drm_i915_private *dev_priv = crtc->base.dev->dev_private;
8108 u32 reg, val;
8109
8110 if (dev_priv->num_pipe == 1)
8111 return true;
8112
8113 reg = DSPCNTR(!crtc->plane);
8114 val = I915_READ(reg);
8115
8116 if ((val & DISPLAY_PLANE_ENABLE) &&
8117 (!!(val & DISPPLANE_SEL_PIPE_MASK) == crtc->pipe))
8118 return false;
8119
8120 return true;
8121}
8122
8052static void intel_sanitize_crtc(struct intel_crtc *crtc) 8123static void intel_sanitize_crtc(struct intel_crtc *crtc)
8053{ 8124{
8054 struct drm_device *dev = crtc->base.dev; 8125 struct drm_device *dev = crtc->base.dev;
8055 struct drm_i915_private *dev_priv = dev->dev_private; 8126 struct drm_i915_private *dev_priv = dev->dev_private;
8056 u32 reg, val; 8127 u32 reg;
8057 8128
8058 /* Clear any frame start delays used for debugging left by the BIOS */ 8129 /* Clear any frame start delays used for debugging left by the BIOS */
8059 reg = PIPECONF(crtc->pipe); 8130 reg = PIPECONF(crtc->pipe);
8060 I915_WRITE(reg, I915_READ(reg) & ~PIPECONF_FRAME_START_DELAY_MASK); 8131 I915_WRITE(reg, I915_READ(reg) & ~PIPECONF_FRAME_START_DELAY_MASK);
8061 8132
8062 /* We need to sanitize the plane -> pipe mapping first because this will 8133 /* We need to sanitize the plane -> pipe mapping first because this will
8063 * disable the crtc (and hence change the state) if it is wrong. */ 8134 * disable the crtc (and hence change the state) if it is wrong. Note
8064 if (!HAS_PCH_SPLIT(dev)) { 8135 * that gen4+ has a fixed plane -> pipe mapping. */
8136 if (INTEL_INFO(dev)->gen < 4 && !intel_check_plane_mapping(crtc)) {
8065 struct intel_connector *connector; 8137 struct intel_connector *connector;
8066 bool plane; 8138 bool plane;
8067 8139
8068 reg = DSPCNTR(crtc->plane);
8069 val = I915_READ(reg);
8070
8071 if ((val & DISPLAY_PLANE_ENABLE) == 0 &&
8072 (!!(val & DISPPLANE_SEL_PIPE_MASK) == crtc->pipe))
8073 goto ok;
8074
8075 DRM_DEBUG_KMS("[CRTC:%d] wrong plane connection detected!\n", 8140 DRM_DEBUG_KMS("[CRTC:%d] wrong plane connection detected!\n",
8076 crtc->base.base.id); 8141 crtc->base.base.id);
8077 8142
@@ -8095,7 +8160,6 @@ static void intel_sanitize_crtc(struct intel_crtc *crtc)
8095 WARN_ON(crtc->active); 8160 WARN_ON(crtc->active);
8096 crtc->base.enabled = false; 8161 crtc->base.enabled = false;
8097 } 8162 }
8098ok:
8099 8163
8100 if (dev_priv->quirks & QUIRK_PIPEA_FORCE && 8164 if (dev_priv->quirks & QUIRK_PIPEA_FORCE &&
8101 crtc->pipe == PIPE_A && !crtc->active) { 8165 crtc->pipe == PIPE_A && !crtc->active) {
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index d1e8ddb2d6c..368ed8ef160 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -1797,7 +1797,8 @@ intel_dp_start_link_train(struct intel_dp *intel_dp)
1797 if ((intel_dp->train_set[i] & DP_TRAIN_MAX_SWING_REACHED) == 0) 1797 if ((intel_dp->train_set[i] & DP_TRAIN_MAX_SWING_REACHED) == 0)
1798 break; 1798 break;
1799 if (i == intel_dp->lane_count && voltage_tries == 5) { 1799 if (i == intel_dp->lane_count && voltage_tries == 5) {
1800 if (++loop_tries == 5) { 1800 ++loop_tries;
1801 if (loop_tries == 5) {
1801 DRM_DEBUG_KMS("too many full retries, give up\n"); 1802 DRM_DEBUG_KMS("too many full retries, give up\n");
1802 break; 1803 break;
1803 } 1804 }
@@ -1807,11 +1808,15 @@ intel_dp_start_link_train(struct intel_dp *intel_dp)
1807 } 1808 }
1808 1809
1809 /* Check to see if we've tried the same voltage 5 times */ 1810 /* Check to see if we've tried the same voltage 5 times */
1810 if ((intel_dp->train_set[0] & DP_TRAIN_VOLTAGE_SWING_MASK) != voltage) { 1811 if ((intel_dp->train_set[0] & DP_TRAIN_VOLTAGE_SWING_MASK) == voltage) {
1811 voltage = intel_dp->train_set[0] & DP_TRAIN_VOLTAGE_SWING_MASK;
1812 voltage_tries = 0;
1813 } else
1814 ++voltage_tries; 1812 ++voltage_tries;
1813 if (voltage_tries == 5) {
1814 DRM_DEBUG_KMS("too many voltage retries, give up\n");
1815 break;
1816 }
1817 } else
1818 voltage_tries = 0;
1819 voltage = intel_dp->train_set[0] & DP_TRAIN_VOLTAGE_SWING_MASK;
1815 1820
1816 /* Compute new intel_dp->train_set as requested by target */ 1821 /* Compute new intel_dp->train_set as requested by target */
1817 intel_get_adjust_train(intel_dp, link_status); 1822 intel_get_adjust_train(intel_dp, link_status);
@@ -2369,8 +2374,9 @@ static void
2369intel_dp_destroy(struct drm_connector *connector) 2374intel_dp_destroy(struct drm_connector *connector)
2370{ 2375{
2371 struct drm_device *dev = connector->dev; 2376 struct drm_device *dev = connector->dev;
2377 struct intel_dp *intel_dp = intel_attached_dp(connector);
2372 2378
2373 if (intel_dpd_is_edp(dev)) 2379 if (is_edp(intel_dp))
2374 intel_panel_destroy_backlight(dev); 2380 intel_panel_destroy_backlight(dev);
2375 2381
2376 drm_sysfs_connector_remove(connector); 2382 drm_sysfs_connector_remove(connector);
diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c
index e3166df55da..edba93b3474 100644
--- a/drivers/gpu/drm/i915/intel_lvds.c
+++ b/drivers/gpu/drm/i915/intel_lvds.c
@@ -777,6 +777,14 @@ static const struct dmi_system_id intel_no_lvds[] = {
777 DMI_MATCH(DMI_BOARD_NAME, "D525TUD"), 777 DMI_MATCH(DMI_BOARD_NAME, "D525TUD"),
778 }, 778 },
779 }, 779 },
780 {
781 .callback = intel_no_lvds_dmi_callback,
782 .ident = "Supermicro X7SPA-H",
783 .matches = {
784 DMI_MATCH(DMI_SYS_VENDOR, "Supermicro"),
785 DMI_MATCH(DMI_PRODUCT_NAME, "X7SPA-H"),
786 },
787 },
780 788
781 { } /* terminating entry */ 789 { } /* terminating entry */
782}; 790};
diff --git a/drivers/gpu/drm/i915/intel_overlay.c b/drivers/gpu/drm/i915/intel_overlay.c
index ebff850a9ab..d7bc817f51a 100644
--- a/drivers/gpu/drm/i915/intel_overlay.c
+++ b/drivers/gpu/drm/i915/intel_overlay.c
@@ -209,7 +209,6 @@ static void intel_overlay_unmap_regs(struct intel_overlay *overlay,
209} 209}
210 210
211static int intel_overlay_do_wait_request(struct intel_overlay *overlay, 211static int intel_overlay_do_wait_request(struct intel_overlay *overlay,
212 struct drm_i915_gem_request *request,
213 void (*tail)(struct intel_overlay *)) 212 void (*tail)(struct intel_overlay *))
214{ 213{
215 struct drm_device *dev = overlay->dev; 214 struct drm_device *dev = overlay->dev;
@@ -218,12 +217,10 @@ static int intel_overlay_do_wait_request(struct intel_overlay *overlay,
218 int ret; 217 int ret;
219 218
220 BUG_ON(overlay->last_flip_req); 219 BUG_ON(overlay->last_flip_req);
221 ret = i915_add_request(ring, NULL, request); 220 ret = i915_add_request(ring, NULL, &overlay->last_flip_req);
222 if (ret) { 221 if (ret)
223 kfree(request); 222 return ret;
224 return ret; 223
225 }
226 overlay->last_flip_req = request->seqno;
227 overlay->flip_tail = tail; 224 overlay->flip_tail = tail;
228 ret = i915_wait_seqno(ring, overlay->last_flip_req); 225 ret = i915_wait_seqno(ring, overlay->last_flip_req);
229 if (ret) 226 if (ret)
@@ -240,7 +237,6 @@ static int intel_overlay_on(struct intel_overlay *overlay)
240 struct drm_device *dev = overlay->dev; 237 struct drm_device *dev = overlay->dev;
241 struct drm_i915_private *dev_priv = dev->dev_private; 238 struct drm_i915_private *dev_priv = dev->dev_private;
242 struct intel_ring_buffer *ring = &dev_priv->ring[RCS]; 239 struct intel_ring_buffer *ring = &dev_priv->ring[RCS];
243 struct drm_i915_gem_request *request;
244 int ret; 240 int ret;
245 241
246 BUG_ON(overlay->active); 242 BUG_ON(overlay->active);
@@ -248,17 +244,9 @@ static int intel_overlay_on(struct intel_overlay *overlay)
248 244
249 WARN_ON(IS_I830(dev) && !(dev_priv->quirks & QUIRK_PIPEA_FORCE)); 245 WARN_ON(IS_I830(dev) && !(dev_priv->quirks & QUIRK_PIPEA_FORCE));
250 246
251 request = kzalloc(sizeof(*request), GFP_KERNEL);
252 if (request == NULL) {
253 ret = -ENOMEM;
254 goto out;
255 }
256
257 ret = intel_ring_begin(ring, 4); 247 ret = intel_ring_begin(ring, 4);
258 if (ret) { 248 if (ret)
259 kfree(request); 249 return ret;
260 goto out;
261 }
262 250
263 intel_ring_emit(ring, MI_OVERLAY_FLIP | MI_OVERLAY_ON); 251 intel_ring_emit(ring, MI_OVERLAY_FLIP | MI_OVERLAY_ON);
264 intel_ring_emit(ring, overlay->flip_addr | OFC_UPDATE); 252 intel_ring_emit(ring, overlay->flip_addr | OFC_UPDATE);
@@ -266,9 +254,7 @@ static int intel_overlay_on(struct intel_overlay *overlay)
266 intel_ring_emit(ring, MI_NOOP); 254 intel_ring_emit(ring, MI_NOOP);
267 intel_ring_advance(ring); 255 intel_ring_advance(ring);
268 256
269 ret = intel_overlay_do_wait_request(overlay, request, NULL); 257 return intel_overlay_do_wait_request(overlay, NULL);
270out:
271 return ret;
272} 258}
273 259
274/* overlay needs to be enabled in OCMD reg */ 260/* overlay needs to be enabled in OCMD reg */
@@ -278,17 +264,12 @@ static int intel_overlay_continue(struct intel_overlay *overlay,
278 struct drm_device *dev = overlay->dev; 264 struct drm_device *dev = overlay->dev;
279 drm_i915_private_t *dev_priv = dev->dev_private; 265 drm_i915_private_t *dev_priv = dev->dev_private;
280 struct intel_ring_buffer *ring = &dev_priv->ring[RCS]; 266 struct intel_ring_buffer *ring = &dev_priv->ring[RCS];
281 struct drm_i915_gem_request *request;
282 u32 flip_addr = overlay->flip_addr; 267 u32 flip_addr = overlay->flip_addr;
283 u32 tmp; 268 u32 tmp;
284 int ret; 269 int ret;
285 270
286 BUG_ON(!overlay->active); 271 BUG_ON(!overlay->active);
287 272
288 request = kzalloc(sizeof(*request), GFP_KERNEL);
289 if (request == NULL)
290 return -ENOMEM;
291
292 if (load_polyphase_filter) 273 if (load_polyphase_filter)
293 flip_addr |= OFC_UPDATE; 274 flip_addr |= OFC_UPDATE;
294 275
@@ -298,22 +279,14 @@ static int intel_overlay_continue(struct intel_overlay *overlay,
298 DRM_DEBUG("overlay underrun, DOVSTA: %x\n", tmp); 279 DRM_DEBUG("overlay underrun, DOVSTA: %x\n", tmp);
299 280
300 ret = intel_ring_begin(ring, 2); 281 ret = intel_ring_begin(ring, 2);
301 if (ret) { 282 if (ret)
302 kfree(request);
303 return ret; 283 return ret;
304 } 284
305 intel_ring_emit(ring, MI_OVERLAY_FLIP | MI_OVERLAY_CONTINUE); 285 intel_ring_emit(ring, MI_OVERLAY_FLIP | MI_OVERLAY_CONTINUE);
306 intel_ring_emit(ring, flip_addr); 286 intel_ring_emit(ring, flip_addr);
307 intel_ring_advance(ring); 287 intel_ring_advance(ring);
308 288
309 ret = i915_add_request(ring, NULL, request); 289 return i915_add_request(ring, NULL, &overlay->last_flip_req);
310 if (ret) {
311 kfree(request);
312 return ret;
313 }
314
315 overlay->last_flip_req = request->seqno;
316 return 0;
317} 290}
318 291
319static void intel_overlay_release_old_vid_tail(struct intel_overlay *overlay) 292static void intel_overlay_release_old_vid_tail(struct intel_overlay *overlay)
@@ -349,15 +322,10 @@ static int intel_overlay_off(struct intel_overlay *overlay)
349 struct drm_i915_private *dev_priv = dev->dev_private; 322 struct drm_i915_private *dev_priv = dev->dev_private;
350 struct intel_ring_buffer *ring = &dev_priv->ring[RCS]; 323 struct intel_ring_buffer *ring = &dev_priv->ring[RCS];
351 u32 flip_addr = overlay->flip_addr; 324 u32 flip_addr = overlay->flip_addr;
352 struct drm_i915_gem_request *request;
353 int ret; 325 int ret;
354 326
355 BUG_ON(!overlay->active); 327 BUG_ON(!overlay->active);
356 328
357 request = kzalloc(sizeof(*request), GFP_KERNEL);
358 if (request == NULL)
359 return -ENOMEM;
360
361 /* According to intel docs the overlay hw may hang (when switching 329 /* According to intel docs the overlay hw may hang (when switching
362 * off) without loading the filter coeffs. It is however unclear whether 330 * off) without loading the filter coeffs. It is however unclear whether
363 * this applies to the disabling of the overlay or to the switching off 331 * this applies to the disabling of the overlay or to the switching off
@@ -365,22 +333,28 @@ static int intel_overlay_off(struct intel_overlay *overlay)
365 flip_addr |= OFC_UPDATE; 333 flip_addr |= OFC_UPDATE;
366 334
367 ret = intel_ring_begin(ring, 6); 335 ret = intel_ring_begin(ring, 6);
368 if (ret) { 336 if (ret)
369 kfree(request);
370 return ret; 337 return ret;
371 } 338
372 /* wait for overlay to go idle */ 339 /* wait for overlay to go idle */
373 intel_ring_emit(ring, MI_OVERLAY_FLIP | MI_OVERLAY_CONTINUE); 340 intel_ring_emit(ring, MI_OVERLAY_FLIP | MI_OVERLAY_CONTINUE);
374 intel_ring_emit(ring, flip_addr); 341 intel_ring_emit(ring, flip_addr);
375 intel_ring_emit(ring, MI_WAIT_FOR_EVENT | MI_WAIT_FOR_OVERLAY_FLIP); 342 intel_ring_emit(ring, MI_WAIT_FOR_EVENT | MI_WAIT_FOR_OVERLAY_FLIP);
376 /* turn overlay off */ 343 /* turn overlay off */
377 intel_ring_emit(ring, MI_OVERLAY_FLIP | MI_OVERLAY_OFF); 344 if (IS_I830(dev)) {
378 intel_ring_emit(ring, flip_addr); 345 /* Workaround: Don't disable the overlay fully, since otherwise
379 intel_ring_emit(ring, MI_WAIT_FOR_EVENT | MI_WAIT_FOR_OVERLAY_FLIP); 346 * it dies on the next OVERLAY_ON cmd. */
347 intel_ring_emit(ring, MI_NOOP);
348 intel_ring_emit(ring, MI_NOOP);
349 intel_ring_emit(ring, MI_NOOP);
350 } else {
351 intel_ring_emit(ring, MI_OVERLAY_FLIP | MI_OVERLAY_OFF);
352 intel_ring_emit(ring, flip_addr);
353 intel_ring_emit(ring, MI_WAIT_FOR_EVENT | MI_WAIT_FOR_OVERLAY_FLIP);
354 }
380 intel_ring_advance(ring); 355 intel_ring_advance(ring);
381 356
382 return intel_overlay_do_wait_request(overlay, request, 357 return intel_overlay_do_wait_request(overlay, intel_overlay_off_tail);
383 intel_overlay_off_tail);
384} 358}
385 359
386/* recover from an interruption due to a signal 360/* recover from an interruption due to a signal
@@ -425,24 +399,16 @@ static int intel_overlay_release_old_vid(struct intel_overlay *overlay)
425 return 0; 399 return 0;
426 400
427 if (I915_READ(ISR) & I915_OVERLAY_PLANE_FLIP_PENDING_INTERRUPT) { 401 if (I915_READ(ISR) & I915_OVERLAY_PLANE_FLIP_PENDING_INTERRUPT) {
428 struct drm_i915_gem_request *request;
429
430 /* synchronous slowpath */ 402 /* synchronous slowpath */
431 request = kzalloc(sizeof(*request), GFP_KERNEL);
432 if (request == NULL)
433 return -ENOMEM;
434
435 ret = intel_ring_begin(ring, 2); 403 ret = intel_ring_begin(ring, 2);
436 if (ret) { 404 if (ret)
437 kfree(request);
438 return ret; 405 return ret;
439 }
440 406
441 intel_ring_emit(ring, MI_WAIT_FOR_EVENT | MI_WAIT_FOR_OVERLAY_FLIP); 407 intel_ring_emit(ring, MI_WAIT_FOR_EVENT | MI_WAIT_FOR_OVERLAY_FLIP);
442 intel_ring_emit(ring, MI_NOOP); 408 intel_ring_emit(ring, MI_NOOP);
443 intel_ring_advance(ring); 409 intel_ring_advance(ring);
444 410
445 ret = intel_overlay_do_wait_request(overlay, request, 411 ret = intel_overlay_do_wait_request(overlay,
446 intel_overlay_release_old_vid_tail); 412 intel_overlay_release_old_vid_tail);
447 if (ret) 413 if (ret)
448 return ret; 414 return ret;
diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c
index e019b236986..e2aacd32954 100644
--- a/drivers/gpu/drm/i915/intel_panel.c
+++ b/drivers/gpu/drm/i915/intel_panel.c
@@ -435,7 +435,7 @@ int intel_panel_setup_backlight(struct drm_device *dev)
435 props.type = BACKLIGHT_RAW; 435 props.type = BACKLIGHT_RAW;
436 props.max_brightness = _intel_panel_get_max_backlight(dev); 436 props.max_brightness = _intel_panel_get_max_backlight(dev);
437 if (props.max_brightness == 0) { 437 if (props.max_brightness == 0) {
438 DRM_ERROR("Failed to get maximum backlight value\n"); 438 DRM_DEBUG_DRIVER("Failed to get maximum backlight value\n");
439 return -ENODEV; 439 return -ENODEV;
440 } 440 }
441 dev_priv->backlight = 441 dev_priv->backlight =
diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
index b3b4b6cea8b..72f41aaa71f 100644
--- a/drivers/gpu/drm/i915/intel_pm.c
+++ b/drivers/gpu/drm/i915/intel_pm.c
@@ -3442,8 +3442,8 @@ static void gen6_init_clock_gating(struct drm_device *dev)
3442 GEN6_RCCUNIT_CLOCK_GATE_DISABLE); 3442 GEN6_RCCUNIT_CLOCK_GATE_DISABLE);
3443 3443
3444 /* Bspec says we need to always set all mask bits. */ 3444 /* Bspec says we need to always set all mask bits. */
3445 I915_WRITE(_3D_CHICKEN, (0xFFFF << 16) | 3445 I915_WRITE(_3D_CHICKEN3, (0xFFFF << 16) |
3446 _3D_CHICKEN_SF_DISABLE_FASTCLIP_CULL); 3446 _3D_CHICKEN3_SF_DISABLE_FASTCLIP_CULL);
3447 3447
3448 /* 3448 /*
3449 * According to the spec the following bits should be 3449 * According to the spec the following bits should be
diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c
index 0007a4d9bf6..c600fb06e25 100644
--- a/drivers/gpu/drm/i915/intel_sdvo.c
+++ b/drivers/gpu/drm/i915/intel_sdvo.c
@@ -139,6 +139,11 @@ struct intel_sdvo {
139 139
140 /* DDC bus used by this SDVO encoder */ 140 /* DDC bus used by this SDVO encoder */
141 uint8_t ddc_bus; 141 uint8_t ddc_bus;
142
143 /*
144 * the sdvo flag gets lost in round trip: dtd->adjusted_mode->dtd
145 */
146 uint8_t dtd_sdvo_flags;
142}; 147};
143 148
144struct intel_sdvo_connector { 149struct intel_sdvo_connector {
@@ -889,6 +894,45 @@ static void intel_sdvo_dump_hdmi_buf(struct intel_sdvo *intel_sdvo)
889} 894}
890#endif 895#endif
891 896
897static bool intel_sdvo_write_infoframe(struct intel_sdvo *intel_sdvo,
898 unsigned if_index, uint8_t tx_rate,
899 uint8_t *data, unsigned length)
900{
901 uint8_t set_buf_index[2] = { if_index, 0 };
902 uint8_t hbuf_size, tmp[8];
903 int i;
904
905 if (!intel_sdvo_set_value(intel_sdvo,
906 SDVO_CMD_SET_HBUF_INDEX,
907 set_buf_index, 2))
908 return false;
909
910 if (!intel_sdvo_get_value(intel_sdvo, SDVO_CMD_GET_HBUF_INFO,
911 &hbuf_size, 1))
912 return false;
913
914 /* Buffer size is 0 based, hooray! */
915 hbuf_size++;
916
917 DRM_DEBUG_KMS("writing sdvo hbuf: %i, hbuf_size %i, hbuf_size: %i\n",
918 if_index, length, hbuf_size);
919
920 for (i = 0; i < hbuf_size; i += 8) {
921 memset(tmp, 0, 8);
922 if (i < length)
923 memcpy(tmp, data + i, min_t(unsigned, 8, length - i));
924
925 if (!intel_sdvo_set_value(intel_sdvo,
926 SDVO_CMD_SET_HBUF_DATA,
927 tmp, 8))
928 return false;
929 }
930
931 return intel_sdvo_set_value(intel_sdvo,
932 SDVO_CMD_SET_HBUF_TXRATE,
933 &tx_rate, 1);
934}
935
892static bool intel_sdvo_set_avi_infoframe(struct intel_sdvo *intel_sdvo) 936static bool intel_sdvo_set_avi_infoframe(struct intel_sdvo *intel_sdvo)
893{ 937{
894 struct dip_infoframe avi_if = { 938 struct dip_infoframe avi_if = {
@@ -896,11 +940,7 @@ static bool intel_sdvo_set_avi_infoframe(struct intel_sdvo *intel_sdvo)
896 .ver = DIP_VERSION_AVI, 940 .ver = DIP_VERSION_AVI,
897 .len = DIP_LEN_AVI, 941 .len = DIP_LEN_AVI,
898 }; 942 };
899 uint8_t tx_rate = SDVO_HBUF_TX_VSYNC;
900 uint8_t set_buf_index[2] = { 1, 0 };
901 uint8_t sdvo_data[4 + sizeof(avi_if.body.avi)]; 943 uint8_t sdvo_data[4 + sizeof(avi_if.body.avi)];
902 uint64_t *data = (uint64_t *)sdvo_data;
903 unsigned i;
904 944
905 intel_dip_infoframe_csum(&avi_if); 945 intel_dip_infoframe_csum(&avi_if);
906 946
@@ -910,22 +950,9 @@ static bool intel_sdvo_set_avi_infoframe(struct intel_sdvo *intel_sdvo)
910 sdvo_data[3] = avi_if.checksum; 950 sdvo_data[3] = avi_if.checksum;
911 memcpy(&sdvo_data[4], &avi_if.body, sizeof(avi_if.body.avi)); 951 memcpy(&sdvo_data[4], &avi_if.body, sizeof(avi_if.body.avi));
912 952
913 if (!intel_sdvo_set_value(intel_sdvo, 953 return intel_sdvo_write_infoframe(intel_sdvo, SDVO_HBUF_INDEX_AVI_IF,
914 SDVO_CMD_SET_HBUF_INDEX, 954 SDVO_HBUF_TX_VSYNC,
915 set_buf_index, 2)) 955 sdvo_data, sizeof(sdvo_data));
916 return false;
917
918 for (i = 0; i < sizeof(sdvo_data); i += 8) {
919 if (!intel_sdvo_set_value(intel_sdvo,
920 SDVO_CMD_SET_HBUF_DATA,
921 data, 8))
922 return false;
923 data++;
924 }
925
926 return intel_sdvo_set_value(intel_sdvo,
927 SDVO_CMD_SET_HBUF_TXRATE,
928 &tx_rate, 1);
929} 956}
930 957
931static bool intel_sdvo_set_tv_format(struct intel_sdvo *intel_sdvo) 958static bool intel_sdvo_set_tv_format(struct intel_sdvo *intel_sdvo)
@@ -984,6 +1011,7 @@ intel_sdvo_get_preferred_input_mode(struct intel_sdvo *intel_sdvo,
984 return false; 1011 return false;
985 1012
986 intel_sdvo_get_mode_from_dtd(adjusted_mode, &input_dtd); 1013 intel_sdvo_get_mode_from_dtd(adjusted_mode, &input_dtd);
1014 intel_sdvo->dtd_sdvo_flags = input_dtd.part2.sdvo_flags;
987 1015
988 return true; 1016 return true;
989} 1017}
@@ -1092,6 +1120,8 @@ static void intel_sdvo_mode_set(struct drm_encoder *encoder,
1092 * adjusted_mode. 1120 * adjusted_mode.
1093 */ 1121 */
1094 intel_sdvo_get_dtd_from_mode(&input_dtd, adjusted_mode); 1122 intel_sdvo_get_dtd_from_mode(&input_dtd, adjusted_mode);
1123 if (intel_sdvo->is_tv || intel_sdvo->is_lvds)
1124 input_dtd.part2.sdvo_flags = intel_sdvo->dtd_sdvo_flags;
1095 if (!intel_sdvo_set_input_timing(intel_sdvo, &input_dtd)) 1125 if (!intel_sdvo_set_input_timing(intel_sdvo, &input_dtd))
1096 DRM_INFO("Setting input timings on %s failed\n", 1126 DRM_INFO("Setting input timings on %s failed\n",
1097 SDVO_NAME(intel_sdvo)); 1127 SDVO_NAME(intel_sdvo));
@@ -2277,10 +2307,8 @@ intel_sdvo_lvds_init(struct intel_sdvo *intel_sdvo, int device)
2277 intel_sdvo_connector->output_flag = SDVO_OUTPUT_LVDS1; 2307 intel_sdvo_connector->output_flag = SDVO_OUTPUT_LVDS1;
2278 } 2308 }
2279 2309
2280 /* SDVO LVDS is cloneable because the SDVO encoder does the upscaling, 2310 /* SDVO LVDS is not cloneable because the input mode gets adjusted by the encoder */
2281 * as opposed to native LVDS, where we upscale with the panel-fitter 2311 intel_sdvo->base.cloneable = false;
2282 * (and hence only the native LVDS resolution could be cloned). */
2283 intel_sdvo->base.cloneable = true;
2284 2312
2285 intel_sdvo_connector_init(intel_sdvo_connector, intel_sdvo); 2313 intel_sdvo_connector_init(intel_sdvo_connector, intel_sdvo);
2286 if (!intel_sdvo_create_enhance_property(intel_sdvo, intel_sdvo_connector)) 2314 if (!intel_sdvo_create_enhance_property(intel_sdvo, intel_sdvo_connector))
@@ -2354,6 +2382,18 @@ intel_sdvo_output_setup(struct intel_sdvo *intel_sdvo, uint16_t flags)
2354 return true; 2382 return true;
2355} 2383}
2356 2384
2385static void intel_sdvo_output_cleanup(struct intel_sdvo *intel_sdvo)
2386{
2387 struct drm_device *dev = intel_sdvo->base.base.dev;
2388 struct drm_connector *connector, *tmp;
2389
2390 list_for_each_entry_safe(connector, tmp,
2391 &dev->mode_config.connector_list, head) {
2392 if (intel_attached_encoder(connector) == &intel_sdvo->base)
2393 intel_sdvo_destroy(connector);
2394 }
2395}
2396
2357static bool intel_sdvo_tv_create_property(struct intel_sdvo *intel_sdvo, 2397static bool intel_sdvo_tv_create_property(struct intel_sdvo *intel_sdvo,
2358 struct intel_sdvo_connector *intel_sdvo_connector, 2398 struct intel_sdvo_connector *intel_sdvo_connector,
2359 int type) 2399 int type)
@@ -2677,7 +2717,8 @@ bool intel_sdvo_init(struct drm_device *dev, uint32_t sdvo_reg, bool is_sdvob)
2677 intel_sdvo->caps.output_flags) != true) { 2717 intel_sdvo->caps.output_flags) != true) {
2678 DRM_DEBUG_KMS("SDVO output failed to setup on %s\n", 2718 DRM_DEBUG_KMS("SDVO output failed to setup on %s\n",
2679 SDVO_NAME(intel_sdvo)); 2719 SDVO_NAME(intel_sdvo));
2680 goto err; 2720 /* Output_setup can leave behind connectors! */
2721 goto err_output;
2681 } 2722 }
2682 2723
2683 /* Only enable the hotplug irq if we need it, to work around noisy 2724 /* Only enable the hotplug irq if we need it, to work around noisy
@@ -2690,12 +2731,12 @@ bool intel_sdvo_init(struct drm_device *dev, uint32_t sdvo_reg, bool is_sdvob)
2690 2731
2691 /* Set the input timing to the screen. Assume always input 0. */ 2732 /* Set the input timing to the screen. Assume always input 0. */
2692 if (!intel_sdvo_set_target_input(intel_sdvo)) 2733 if (!intel_sdvo_set_target_input(intel_sdvo))
2693 goto err; 2734 goto err_output;
2694 2735
2695 if (!intel_sdvo_get_input_pixel_clock_range(intel_sdvo, 2736 if (!intel_sdvo_get_input_pixel_clock_range(intel_sdvo,
2696 &intel_sdvo->pixel_clock_min, 2737 &intel_sdvo->pixel_clock_min,
2697 &intel_sdvo->pixel_clock_max)) 2738 &intel_sdvo->pixel_clock_max))
2698 goto err; 2739 goto err_output;
2699 2740
2700 DRM_DEBUG_KMS("%s device VID/DID: %02X:%02X.%02X, " 2741 DRM_DEBUG_KMS("%s device VID/DID: %02X:%02X.%02X, "
2701 "clock range %dMHz - %dMHz, " 2742 "clock range %dMHz - %dMHz, "
@@ -2715,6 +2756,9 @@ bool intel_sdvo_init(struct drm_device *dev, uint32_t sdvo_reg, bool is_sdvob)
2715 (SDVO_OUTPUT_TMDS1 | SDVO_OUTPUT_RGB1) ? 'Y' : 'N'); 2756 (SDVO_OUTPUT_TMDS1 | SDVO_OUTPUT_RGB1) ? 'Y' : 'N');
2716 return true; 2757 return true;
2717 2758
2759err_output:
2760 intel_sdvo_output_cleanup(intel_sdvo);
2761
2718err: 2762err:
2719 drm_encoder_cleanup(&intel_encoder->base); 2763 drm_encoder_cleanup(&intel_encoder->base);
2720 i2c_del_adapter(&intel_sdvo->ddc); 2764 i2c_del_adapter(&intel_sdvo->ddc);
diff --git a/drivers/gpu/drm/i915/intel_sdvo_regs.h b/drivers/gpu/drm/i915/intel_sdvo_regs.h
index 9d030142ee4..770bdd6ecd9 100644
--- a/drivers/gpu/drm/i915/intel_sdvo_regs.h
+++ b/drivers/gpu/drm/i915/intel_sdvo_regs.h
@@ -708,6 +708,8 @@ struct intel_sdvo_enhancements_arg {
708#define SDVO_CMD_SET_AUDIO_STAT 0x91 708#define SDVO_CMD_SET_AUDIO_STAT 0x91
709#define SDVO_CMD_GET_AUDIO_STAT 0x92 709#define SDVO_CMD_GET_AUDIO_STAT 0x92
710#define SDVO_CMD_SET_HBUF_INDEX 0x93 710#define SDVO_CMD_SET_HBUF_INDEX 0x93
711 #define SDVO_HBUF_INDEX_ELD 0
712 #define SDVO_HBUF_INDEX_AVI_IF 1
711#define SDVO_CMD_GET_HBUF_INDEX 0x94 713#define SDVO_CMD_GET_HBUF_INDEX 0x94
712#define SDVO_CMD_GET_HBUF_INFO 0x95 714#define SDVO_CMD_GET_HBUF_INFO 0x95
713#define SDVO_CMD_SET_HBUF_AV_SPLIT 0x96 715#define SDVO_CMD_SET_HBUF_AV_SPLIT 0x96
diff --git a/drivers/gpu/drm/nouveau/core/core/gpuobj.c b/drivers/gpu/drm/nouveau/core/core/gpuobj.c
index 1f34549aff1..70586fde69c 100644
--- a/drivers/gpu/drm/nouveau/core/core/gpuobj.c
+++ b/drivers/gpu/drm/nouveau/core/core/gpuobj.c
@@ -39,6 +39,11 @@ nouveau_gpuobj_destroy(struct nouveau_gpuobj *gpuobj)
39 nv_wo32(gpuobj, i, 0x00000000); 39 nv_wo32(gpuobj, i, 0x00000000);
40 } 40 }
41 41
42 if (gpuobj->node) {
43 nouveau_mm_free(&nv_gpuobj(gpuobj->parent)->heap,
44 &gpuobj->node);
45 }
46
42 if (gpuobj->heap.block_size) 47 if (gpuobj->heap.block_size)
43 nouveau_mm_fini(&gpuobj->heap); 48 nouveau_mm_fini(&gpuobj->heap);
44 49
diff --git a/drivers/gpu/drm/nouveau/core/core/mm.c b/drivers/gpu/drm/nouveau/core/core/mm.c
index bfddf87926d..a6d3cd6490f 100644
--- a/drivers/gpu/drm/nouveau/core/core/mm.c
+++ b/drivers/gpu/drm/nouveau/core/core/mm.c
@@ -218,13 +218,16 @@ nouveau_mm_init(struct nouveau_mm *mm, u32 offset, u32 length, u32 block)
218 node = kzalloc(sizeof(*node), GFP_KERNEL); 218 node = kzalloc(sizeof(*node), GFP_KERNEL);
219 if (!node) 219 if (!node)
220 return -ENOMEM; 220 return -ENOMEM;
221 node->offset = roundup(offset, mm->block_size); 221
222 node->length = rounddown(offset + length, mm->block_size) - node->offset; 222 if (length) {
223 node->offset = roundup(offset, mm->block_size);
224 node->length = rounddown(offset + length, mm->block_size);
225 node->length -= node->offset;
226 }
223 227
224 list_add_tail(&node->nl_entry, &mm->nodes); 228 list_add_tail(&node->nl_entry, &mm->nodes);
225 list_add_tail(&node->fl_entry, &mm->free); 229 list_add_tail(&node->fl_entry, &mm->free);
226 mm->heap_nodes++; 230 mm->heap_nodes++;
227 mm->heap_size += length;
228 return 0; 231 return 0;
229} 232}
230 233
@@ -236,7 +239,7 @@ nouveau_mm_fini(struct nouveau_mm *mm)
236 int nodes = 0; 239 int nodes = 0;
237 240
238 list_for_each_entry(node, &mm->nodes, nl_entry) { 241 list_for_each_entry(node, &mm->nodes, nl_entry) {
239 if (nodes++ == mm->heap_nodes) 242 if (WARN_ON(nodes++ == mm->heap_nodes))
240 return -EBUSY; 243 return -EBUSY;
241 } 244 }
242 245
diff --git a/drivers/gpu/drm/nouveau/core/engine/disp/nv50.c b/drivers/gpu/drm/nouveau/core/engine/disp/nv50.c
index 16a9afb1060..15b182c84ce 100644
--- a/drivers/gpu/drm/nouveau/core/engine/disp/nv50.c
+++ b/drivers/gpu/drm/nouveau/core/engine/disp/nv50.c
@@ -22,6 +22,8 @@
22 * Authors: Ben Skeggs 22 * Authors: Ben Skeggs
23 */ 23 */
24 24
25#include <subdev/bar.h>
26
25#include <engine/software.h> 27#include <engine/software.h>
26#include <engine/disp.h> 28#include <engine/disp.h>
27 29
@@ -37,6 +39,7 @@ nv50_disp_sclass[] = {
37static void 39static void
38nv50_disp_intr_vblank(struct nv50_disp_priv *priv, int crtc) 40nv50_disp_intr_vblank(struct nv50_disp_priv *priv, int crtc)
39{ 41{
42 struct nouveau_bar *bar = nouveau_bar(priv);
40 struct nouveau_disp *disp = &priv->base; 43 struct nouveau_disp *disp = &priv->base;
41 struct nouveau_software_chan *chan, *temp; 44 struct nouveau_software_chan *chan, *temp;
42 unsigned long flags; 45 unsigned long flags;
@@ -46,19 +49,25 @@ nv50_disp_intr_vblank(struct nv50_disp_priv *priv, int crtc)
46 if (chan->vblank.crtc != crtc) 49 if (chan->vblank.crtc != crtc)
47 continue; 50 continue;
48 51
49 nv_wr32(priv, 0x001704, chan->vblank.channel); 52 if (nv_device(priv)->chipset >= 0xc0) {
50 nv_wr32(priv, 0x001710, 0x80000000 | chan->vblank.ctxdma); 53 nv_wr32(priv, 0x001718, 0x80000000 | chan->vblank.channel);
51 54 bar->flush(bar);
52 if (nv_device(priv)->chipset == 0x50) { 55 nv_wr32(priv, 0x06000c,
53 nv_wr32(priv, 0x001570, chan->vblank.offset); 56 upper_32_bits(chan->vblank.offset));
54 nv_wr32(priv, 0x001574, chan->vblank.value); 57 nv_wr32(priv, 0x060010,
58 lower_32_bits(chan->vblank.offset));
59 nv_wr32(priv, 0x060014, chan->vblank.value);
55 } else { 60 } else {
56 if (nv_device(priv)->chipset >= 0xc0) { 61 nv_wr32(priv, 0x001704, chan->vblank.channel);
57 nv_wr32(priv, 0x06000c, 62 nv_wr32(priv, 0x001710, 0x80000000 | chan->vblank.ctxdma);
58 upper_32_bits(chan->vblank.offset)); 63 bar->flush(bar);
64 if (nv_device(priv)->chipset == 0x50) {
65 nv_wr32(priv, 0x001570, chan->vblank.offset);
66 nv_wr32(priv, 0x001574, chan->vblank.value);
67 } else {
68 nv_wr32(priv, 0x060010, chan->vblank.offset);
69 nv_wr32(priv, 0x060014, chan->vblank.value);
59 } 70 }
60 nv_wr32(priv, 0x060010, chan->vblank.offset);
61 nv_wr32(priv, 0x060014, chan->vblank.value);
62 } 71 }
63 72
64 list_del(&chan->vblank.head); 73 list_del(&chan->vblank.head);
diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/ctxnv40.c b/drivers/gpu/drm/nouveau/core/engine/graph/ctxnv40.c
index e45035efb8c..7bbb1e1b7a8 100644
--- a/drivers/gpu/drm/nouveau/core/engine/graph/ctxnv40.c
+++ b/drivers/gpu/drm/nouveau/core/engine/graph/ctxnv40.c
@@ -669,21 +669,27 @@ nv40_grctx_fill(struct nouveau_device *device, struct nouveau_gpuobj *mem)
669 }); 669 });
670} 670}
671 671
672void 672int
673nv40_grctx_init(struct nouveau_device *device, u32 *size) 673nv40_grctx_init(struct nouveau_device *device, u32 *size)
674{ 674{
675 u32 ctxprog[256], i; 675 u32 *ctxprog = kmalloc(256 * 4, GFP_KERNEL), i;
676 struct nouveau_grctx ctx = { 676 struct nouveau_grctx ctx = {
677 .device = device, 677 .device = device,
678 .mode = NOUVEAU_GRCTX_PROG, 678 .mode = NOUVEAU_GRCTX_PROG,
679 .data = ctxprog, 679 .data = ctxprog,
680 .ctxprog_max = ARRAY_SIZE(ctxprog) 680 .ctxprog_max = 256,
681 }; 681 };
682 682
683 if (!ctxprog)
684 return -ENOMEM;
685
683 nv40_grctx_generate(&ctx); 686 nv40_grctx_generate(&ctx);
684 687
685 nv_wr32(device, 0x400324, 0); 688 nv_wr32(device, 0x400324, 0);
686 for (i = 0; i < ctx.ctxprog_len; i++) 689 for (i = 0; i < ctx.ctxprog_len; i++)
687 nv_wr32(device, 0x400328, ctxprog[i]); 690 nv_wr32(device, 0x400328, ctxprog[i]);
688 *size = ctx.ctxvals_pos * 4; 691 *size = ctx.ctxvals_pos * 4;
692
693 kfree(ctxprog);
694 return 0;
689} 695}
diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/nv40.c b/drivers/gpu/drm/nouveau/core/engine/graph/nv40.c
index 8d0021049ec..cc6574eeb80 100644
--- a/drivers/gpu/drm/nouveau/core/engine/graph/nv40.c
+++ b/drivers/gpu/drm/nouveau/core/engine/graph/nv40.c
@@ -156,8 +156,8 @@ nv40_graph_context_ctor(struct nouveau_object *parent,
156static int 156static int
157nv40_graph_context_fini(struct nouveau_object *object, bool suspend) 157nv40_graph_context_fini(struct nouveau_object *object, bool suspend)
158{ 158{
159 struct nv04_graph_priv *priv = (void *)object->engine; 159 struct nv40_graph_priv *priv = (void *)object->engine;
160 struct nv04_graph_chan *chan = (void *)object; 160 struct nv40_graph_chan *chan = (void *)object;
161 u32 inst = 0x01000000 | nv_gpuobj(chan)->addr >> 4; 161 u32 inst = 0x01000000 | nv_gpuobj(chan)->addr >> 4;
162 int ret = 0; 162 int ret = 0;
163 163
@@ -346,7 +346,9 @@ nv40_graph_init(struct nouveau_object *object)
346 return ret; 346 return ret;
347 347
348 /* generate and upload context program */ 348 /* generate and upload context program */
349 nv40_grctx_init(nv_device(priv), &priv->size); 349 ret = nv40_grctx_init(nv_device(priv), &priv->size);
350 if (ret)
351 return ret;
350 352
351 /* No context present currently */ 353 /* No context present currently */
352 nv_wr32(priv, NV40_PGRAPH_CTXCTL_CUR, 0x00000000); 354 nv_wr32(priv, NV40_PGRAPH_CTXCTL_CUR, 0x00000000);
diff --git a/drivers/gpu/drm/nouveau/core/engine/graph/nv40.h b/drivers/gpu/drm/nouveau/core/engine/graph/nv40.h
index d2ac975afc2..7da35a4e797 100644
--- a/drivers/gpu/drm/nouveau/core/engine/graph/nv40.h
+++ b/drivers/gpu/drm/nouveau/core/engine/graph/nv40.h
@@ -15,7 +15,7 @@ nv44_graph_class(void *priv)
15 return !(0x0baf & (1 << (device->chipset & 0x0f))); 15 return !(0x0baf & (1 << (device->chipset & 0x0f)));
16} 16}
17 17
18void nv40_grctx_init(struct nouveau_device *, u32 *size); 18int nv40_grctx_init(struct nouveau_device *, u32 *size);
19void nv40_grctx_fill(struct nouveau_device *, struct nouveau_gpuobj *); 19void nv40_grctx_fill(struct nouveau_device *, struct nouveau_gpuobj *);
20 20
21#endif 21#endif
diff --git a/drivers/gpu/drm/nouveau/core/engine/mpeg/nv40.c b/drivers/gpu/drm/nouveau/core/engine/mpeg/nv40.c
index 12418574efe..f7c581ad199 100644
--- a/drivers/gpu/drm/nouveau/core/engine/mpeg/nv40.c
+++ b/drivers/gpu/drm/nouveau/core/engine/mpeg/nv40.c
@@ -38,7 +38,7 @@ struct nv40_mpeg_priv {
38}; 38};
39 39
40struct nv40_mpeg_chan { 40struct nv40_mpeg_chan {
41 struct nouveau_mpeg base; 41 struct nouveau_mpeg_chan base;
42}; 42};
43 43
44/******************************************************************************* 44/*******************************************************************************
diff --git a/drivers/gpu/drm/nouveau/core/include/core/mm.h b/drivers/gpu/drm/nouveau/core/include/core/mm.h
index 9ee9bf4028c..975137ba34a 100644
--- a/drivers/gpu/drm/nouveau/core/include/core/mm.h
+++ b/drivers/gpu/drm/nouveau/core/include/core/mm.h
@@ -19,7 +19,6 @@ struct nouveau_mm {
19 19
20 u32 block_size; 20 u32 block_size;
21 int heap_nodes; 21 int heap_nodes;
22 u32 heap_size;
23}; 22};
24 23
25int nouveau_mm_init(struct nouveau_mm *, u32 offset, u32 length, u32 block); 24int nouveau_mm_init(struct nouveau_mm *, u32 offset, u32 length, u32 block);
diff --git a/drivers/gpu/drm/nouveau/core/include/core/object.h b/drivers/gpu/drm/nouveau/core/include/core/object.h
index 818feabbf4a..486f1a9217f 100644
--- a/drivers/gpu/drm/nouveau/core/include/core/object.h
+++ b/drivers/gpu/drm/nouveau/core/include/core/object.h
@@ -175,14 +175,18 @@ nv_mo32(void *obj, u32 addr, u32 mask, u32 data)
175 return temp; 175 return temp;
176} 176}
177 177
178static inline bool 178static inline int
179nv_strncmp(void *obj, u32 addr, u32 len, const char *str) 179nv_memcmp(void *obj, u32 addr, const char *str, u32 len)
180{ 180{
181 unsigned char c1, c2;
182
181 while (len--) { 183 while (len--) {
182 if (nv_ro08(obj, addr++) != *(str++)) 184 c1 = nv_ro08(obj, addr++);
183 return false; 185 c2 = *(str++);
186 if (c1 != c2)
187 return c1 - c2;
184 } 188 }
185 return true; 189 return 0;
186} 190}
187 191
188#endif 192#endif
diff --git a/drivers/gpu/drm/nouveau/core/include/subdev/clock.h b/drivers/gpu/drm/nouveau/core/include/subdev/clock.h
index 39e73b91d36..41b7a6a76f1 100644
--- a/drivers/gpu/drm/nouveau/core/include/subdev/clock.h
+++ b/drivers/gpu/drm/nouveau/core/include/subdev/clock.h
@@ -54,6 +54,7 @@ int nv04_clock_pll_calc(struct nouveau_clock *, struct nvbios_pll *,
54 int clk, struct nouveau_pll_vals *); 54 int clk, struct nouveau_pll_vals *);
55int nv04_clock_pll_prog(struct nouveau_clock *, u32 reg1, 55int nv04_clock_pll_prog(struct nouveau_clock *, u32 reg1,
56 struct nouveau_pll_vals *); 56 struct nouveau_pll_vals *);
57 57int nva3_clock_pll_calc(struct nouveau_clock *, struct nvbios_pll *,
58 int clk, struct nouveau_pll_vals *);
58 59
59#endif 60#endif
diff --git a/drivers/gpu/drm/nouveau/core/subdev/bios/base.c b/drivers/gpu/drm/nouveau/core/subdev/bios/base.c
index dcb5c2befc9..70ca7d5a1aa 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/bios/base.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/bios/base.c
@@ -72,7 +72,7 @@ nouveau_bios_shadow_of(struct nouveau_bios *bios)
72 } 72 }
73 73
74 data = of_get_property(dn, "NVDA,BMP", &size); 74 data = of_get_property(dn, "NVDA,BMP", &size);
75 if (data) { 75 if (data && size) {
76 bios->size = size; 76 bios->size = size;
77 bios->data = kmalloc(bios->size, GFP_KERNEL); 77 bios->data = kmalloc(bios->size, GFP_KERNEL);
78 if (bios->data) 78 if (bios->data)
@@ -104,6 +104,9 @@ nouveau_bios_shadow_pramin(struct nouveau_bios *bios)
104 goto out; 104 goto out;
105 105
106 bios->size = nv_rd08(bios, 0x700002) * 512; 106 bios->size = nv_rd08(bios, 0x700002) * 512;
107 if (!bios->size)
108 goto out;
109
107 bios->data = kmalloc(bios->size, GFP_KERNEL); 110 bios->data = kmalloc(bios->size, GFP_KERNEL);
108 if (bios->data) { 111 if (bios->data) {
109 for (i = 0; i < bios->size; i++) 112 for (i = 0; i < bios->size; i++)
@@ -155,6 +158,9 @@ nouveau_bios_shadow_prom(struct nouveau_bios *bios)
155 158
156 /* read entire bios image to system memory */ 159 /* read entire bios image to system memory */
157 bios->size = nv_rd08(bios, 0x300002) * 512; 160 bios->size = nv_rd08(bios, 0x300002) * 512;
161 if (!bios->size)
162 goto out;
163
158 bios->data = kmalloc(bios->size, GFP_KERNEL); 164 bios->data = kmalloc(bios->size, GFP_KERNEL);
159 if (bios->data) { 165 if (bios->data) {
160 for (i = 0; i < bios->size; i++) 166 for (i = 0; i < bios->size; i++)
@@ -186,14 +192,22 @@ nouveau_bios_shadow_acpi(struct nouveau_bios *bios)
186{ 192{
187 struct pci_dev *pdev = nv_device(bios)->pdev; 193 struct pci_dev *pdev = nv_device(bios)->pdev;
188 int ret, cnt, i; 194 int ret, cnt, i;
189 u8 data[3];
190 195
191 if (!nouveau_acpi_rom_supported(pdev)) 196 if (!nouveau_acpi_rom_supported(pdev)) {
197 bios->data = NULL;
192 return; 198 return;
199 }
193 200
194 bios->size = 0; 201 bios->size = 0;
195 if (nouveau_acpi_get_bios_chunk(data, 0, 3) == 3) 202 bios->data = kmalloc(4096, GFP_KERNEL);
196 bios->size = data[2] * 512; 203 if (bios->data) {
204 if (nouveau_acpi_get_bios_chunk(bios->data, 0, 4096) == 4096)
205 bios->size = bios->data[2] * 512;
206 kfree(bios->data);
207 }
208
209 if (!bios->size)
210 return;
197 211
198 bios->data = kmalloc(bios->size, GFP_KERNEL); 212 bios->data = kmalloc(bios->size, GFP_KERNEL);
199 for (i = 0; bios->data && i < bios->size; i += cnt) { 213 for (i = 0; bios->data && i < bios->size; i += cnt) {
@@ -229,12 +243,14 @@ nouveau_bios_shadow_pci(struct nouveau_bios *bios)
229static int 243static int
230nouveau_bios_score(struct nouveau_bios *bios, const bool writeable) 244nouveau_bios_score(struct nouveau_bios *bios, const bool writeable)
231{ 245{
232 if (!bios->data || bios->data[0] != 0x55 || bios->data[1] != 0xAA) { 246 if (bios->size < 3 || !bios->data || bios->data[0] != 0x55 ||
247 bios->data[1] != 0xAA) {
233 nv_info(bios, "... signature not found\n"); 248 nv_info(bios, "... signature not found\n");
234 return 0; 249 return 0;
235 } 250 }
236 251
237 if (nvbios_checksum(bios->data, bios->data[2] * 512)) { 252 if (nvbios_checksum(bios->data,
253 min_t(u32, bios->data[2] * 512, bios->size))) {
238 nv_info(bios, "... checksum invalid\n"); 254 nv_info(bios, "... checksum invalid\n");
239 /* if a ro image is somewhat bad, it's probably all rubbish */ 255 /* if a ro image is somewhat bad, it's probably all rubbish */
240 return writeable ? 2 : 1; 256 return writeable ? 2 : 1;
diff --git a/drivers/gpu/drm/nouveau/core/subdev/bios/dcb.c b/drivers/gpu/drm/nouveau/core/subdev/bios/dcb.c
index 9ed6e728a94..c5119715774 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/bios/dcb.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/bios/dcb.c
@@ -43,7 +43,7 @@ dcb_table(struct nouveau_bios *bios, u8 *ver, u8 *hdr, u8 *cnt, u8 *len)
43 *ver = nv_ro08(bios, dcb); 43 *ver = nv_ro08(bios, dcb);
44 44
45 if (*ver >= 0x41) { 45 if (*ver >= 0x41) {
46 nv_warn(bios, "DCB *ver 0x%02x unknown\n", *ver); 46 nv_warn(bios, "DCB version 0x%02x unknown\n", *ver);
47 return 0x0000; 47 return 0x0000;
48 } else 48 } else
49 if (*ver >= 0x30) { 49 if (*ver >= 0x30) {
@@ -64,7 +64,7 @@ dcb_table(struct nouveau_bios *bios, u8 *ver, u8 *hdr, u8 *cnt, u8 *len)
64 } 64 }
65 } else 65 } else
66 if (*ver >= 0x15) { 66 if (*ver >= 0x15) {
67 if (!nv_strncmp(bios, dcb - 7, 7, "DEV_REC")) { 67 if (!nv_memcmp(bios, dcb - 7, "DEV_REC", 7)) {
68 u16 i2c = nv_ro16(bios, dcb + 2); 68 u16 i2c = nv_ro16(bios, dcb + 2);
69 *hdr = 4; 69 *hdr = 4;
70 *cnt = (i2c - dcb) / 10; 70 *cnt = (i2c - dcb) / 10;
diff --git a/drivers/gpu/drm/nouveau/core/subdev/bios/pll.c b/drivers/gpu/drm/nouveau/core/subdev/bios/pll.c
index 5e5f4cddae3..f835501203e 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/bios/pll.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/bios/pll.c
@@ -157,11 +157,10 @@ pll_map_reg(struct nouveau_bios *bios, u32 reg, u32 *type, u8 *ver, u8 *len)
157 while (map->reg) { 157 while (map->reg) {
158 if (map->reg == reg && *ver >= 0x20) { 158 if (map->reg == reg && *ver >= 0x20) {
159 u16 addr = (data += hdr); 159 u16 addr = (data += hdr);
160 *type = map->type;
160 while (cnt--) { 161 while (cnt--) {
161 if (nv_ro32(bios, data) == map->reg) { 162 if (nv_ro32(bios, data) == map->reg)
162 *type = map->type;
163 return data; 163 return data;
164 }
165 data += *len; 164 data += *len;
166 } 165 }
167 return addr; 166 return addr;
@@ -200,11 +199,10 @@ pll_map_type(struct nouveau_bios *bios, u8 type, u32 *reg, u8 *ver, u8 *len)
200 while (map->reg) { 199 while (map->reg) {
201 if (map->type == type && *ver >= 0x20) { 200 if (map->type == type && *ver >= 0x20) {
202 u16 addr = (data += hdr); 201 u16 addr = (data += hdr);
202 *reg = map->reg;
203 while (cnt--) { 203 while (cnt--) {
204 if (nv_ro32(bios, data) == map->reg) { 204 if (nv_ro32(bios, data) == map->reg)
205 *reg = map->reg;
206 return data; 205 return data;
207 }
208 data += *len; 206 data += *len;
209 } 207 }
210 return addr; 208 return addr;
diff --git a/drivers/gpu/drm/nouveau/core/subdev/clock/nva3.c b/drivers/gpu/drm/nouveau/core/subdev/clock/nva3.c
index cc8d7d162d7..9068c98b96f 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/clock/nva3.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/clock/nva3.c
@@ -66,6 +66,24 @@ nva3_clock_pll_set(struct nouveau_clock *clk, u32 type, u32 freq)
66 return ret; 66 return ret;
67} 67}
68 68
69int
70nva3_clock_pll_calc(struct nouveau_clock *clock, struct nvbios_pll *info,
71 int clk, struct nouveau_pll_vals *pv)
72{
73 int ret, N, M, P;
74
75 ret = nva3_pll_calc(clock, info, clk, &N, NULL, &M, &P);
76
77 if (ret > 0) {
78 pv->refclk = info->refclk;
79 pv->N1 = N;
80 pv->M1 = M;
81 pv->log2P = P;
82 }
83 return ret;
84}
85
86
69static int 87static int
70nva3_clock_ctor(struct nouveau_object *parent, struct nouveau_object *engine, 88nva3_clock_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
71 struct nouveau_oclass *oclass, void *data, u32 size, 89 struct nouveau_oclass *oclass, void *data, u32 size,
@@ -80,6 +98,7 @@ nva3_clock_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
80 return ret; 98 return ret;
81 99
82 priv->base.pll_set = nva3_clock_pll_set; 100 priv->base.pll_set = nva3_clock_pll_set;
101 priv->base.pll_calc = nva3_clock_pll_calc;
83 return 0; 102 return 0;
84} 103}
85 104
diff --git a/drivers/gpu/drm/nouveau/core/subdev/clock/nvc0.c b/drivers/gpu/drm/nouveau/core/subdev/clock/nvc0.c
index 5ccce0b17bf..f6962c9b6c3 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/clock/nvc0.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/clock/nvc0.c
@@ -79,6 +79,7 @@ nvc0_clock_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
79 return ret; 79 return ret;
80 80
81 priv->base.pll_set = nvc0_clock_pll_set; 81 priv->base.pll_set = nvc0_clock_pll_set;
82 priv->base.pll_calc = nva3_clock_pll_calc;
82 return 0; 83 return 0;
83} 84}
84 85
diff --git a/drivers/gpu/drm/nouveau/core/subdev/fb/nv50.c b/drivers/gpu/drm/nouveau/core/subdev/fb/nv50.c
index 436e9efe7ef..5f570806143 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/fb/nv50.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/fb/nv50.c
@@ -219,13 +219,11 @@ nv50_fb_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
219 ((priv->base.ram.size & 0x000000ff) << 32); 219 ((priv->base.ram.size & 0x000000ff) << 32);
220 220
221 tags = nv_rd32(priv, 0x100320); 221 tags = nv_rd32(priv, 0x100320);
222 if (tags) { 222 ret = nouveau_mm_init(&priv->base.tags, 0, tags, 1);
223 ret = nouveau_mm_init(&priv->base.tags, 0, tags, 1); 223 if (ret)
224 if (ret) 224 return ret;
225 return ret;
226 225
227 nv_debug(priv, "%d compression tags\n", tags); 226 nv_debug(priv, "%d compression tags\n", tags);
228 }
229 227
230 size = (priv->base.ram.size >> 12) - rsvd_head - rsvd_tail; 228 size = (priv->base.ram.size >> 12) - rsvd_head - rsvd_tail;
231 switch (device->chipset) { 229 switch (device->chipset) {
@@ -237,6 +235,7 @@ nv50_fb_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
237 return ret; 235 return ret;
238 236
239 priv->base.ram.stolen = (u64)nv_rd32(priv, 0x100e10) << 12; 237 priv->base.ram.stolen = (u64)nv_rd32(priv, 0x100e10) << 12;
238 priv->base.ram.type = NV_MEM_TYPE_STOLEN;
240 break; 239 break;
241 default: 240 default:
242 ret = nouveau_mm_init(&priv->base.vram, rsvd_head, size, 241 ret = nouveau_mm_init(&priv->base.vram, rsvd_head, size,
@@ -277,7 +276,6 @@ nv50_fb_dtor(struct nouveau_object *object)
277 __free_page(priv->r100c08_page); 276 __free_page(priv->r100c08_page);
278 } 277 }
279 278
280 nouveau_mm_fini(&priv->base.vram);
281 nouveau_fb_destroy(&priv->base); 279 nouveau_fb_destroy(&priv->base);
282} 280}
283 281
diff --git a/drivers/gpu/drm/nouveau/core/subdev/i2c/base.c b/drivers/gpu/drm/nouveau/core/subdev/i2c/base.c
index 3d2c88310f9..dbfc2abf0cf 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/i2c/base.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/i2c/base.c
@@ -292,7 +292,7 @@ nouveau_i2c_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
292 case DCB_I2C_NVIO_BIT: 292 case DCB_I2C_NVIO_BIT:
293 port->drive = info.drive & 0x0f; 293 port->drive = info.drive & 0x0f;
294 if (device->card_type < NV_D0) { 294 if (device->card_type < NV_D0) {
295 if (info.drive >= ARRAY_SIZE(nv50_i2c_port)) 295 if (port->drive >= ARRAY_SIZE(nv50_i2c_port))
296 break; 296 break;
297 port->drive = nv50_i2c_port[port->drive]; 297 port->drive = nv50_i2c_port[port->drive];
298 port->sense = port->drive; 298 port->sense = port->drive;
diff --git a/drivers/gpu/drm/nouveau/core/subdev/therm/fan.c b/drivers/gpu/drm/nouveau/core/subdev/therm/fan.c
index b29237970fa..52317868518 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/therm/fan.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/therm/fan.c
@@ -134,7 +134,7 @@ nouveau_therm_fan_sense(struct nouveau_therm *therm)
134 end = ptimer->read(ptimer); 134 end = ptimer->read(ptimer);
135 135
136 if (cycles == 5) { 136 if (cycles == 5) {
137 tach = (u64)60000000000; 137 tach = (u64)60000000000ULL;
138 do_div(tach, (end - start)); 138 do_div(tach, (end - start));
139 return tach; 139 return tach;
140 } else 140 } else
diff --git a/drivers/gpu/drm/nouveau/core/subdev/vm/nv41.c b/drivers/gpu/drm/nouveau/core/subdev/vm/nv41.c
index 0203e1e12ca..9474cfca6e4 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/vm/nv41.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/vm/nv41.c
@@ -67,7 +67,7 @@ nv41_vm_unmap(struct nouveau_gpuobj *pgt, u32 pte, u32 cnt)
67static void 67static void
68nv41_vm_flush(struct nouveau_vm *vm) 68nv41_vm_flush(struct nouveau_vm *vm)
69{ 69{
70 struct nv04_vm_priv *priv = (void *)vm->vmm; 70 struct nv04_vmmgr_priv *priv = (void *)vm->vmm;
71 71
72 mutex_lock(&nv_subdev(priv)->mutex); 72 mutex_lock(&nv_subdev(priv)->mutex);
73 nv_wr32(priv, 0x100810, 0x00000022); 73 nv_wr32(priv, 0x100810, 0x00000022);
@@ -92,7 +92,8 @@ nv41_vmmgr_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
92 struct nv04_vmmgr_priv *priv; 92 struct nv04_vmmgr_priv *priv;
93 int ret; 93 int ret;
94 94
95 if (!nouveau_boolopt(device->cfgopt, "NvPCIE", true)) { 95 if (pci_find_capability(device->pdev, PCI_CAP_ID_AGP) ||
96 !nouveau_boolopt(device->cfgopt, "NvPCIE", true)) {
96 return nouveau_object_ctor(parent, engine, &nv04_vmmgr_oclass, 97 return nouveau_object_ctor(parent, engine, &nv04_vmmgr_oclass,
97 data, size, pobject); 98 data, size, pobject);
98 } 99 }
diff --git a/drivers/gpu/drm/nouveau/core/subdev/vm/nv44.c b/drivers/gpu/drm/nouveau/core/subdev/vm/nv44.c
index 0ac18d05a14..aa8131436e3 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/vm/nv44.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/vm/nv44.c
@@ -163,7 +163,8 @@ nv44_vmmgr_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
163 struct nv04_vmmgr_priv *priv; 163 struct nv04_vmmgr_priv *priv;
164 int ret; 164 int ret;
165 165
166 if (!nouveau_boolopt(device->cfgopt, "NvPCIE", true)) { 166 if (pci_find_capability(device->pdev, PCI_CAP_ID_AGP) ||
167 !nouveau_boolopt(device->cfgopt, "NvPCIE", true)) {
167 return nouveau_object_ctor(parent, engine, &nv04_vmmgr_oclass, 168 return nouveau_object_ctor(parent, engine, &nv04_vmmgr_oclass,
168 data, size, pobject); 169 data, size, pobject);
169 } 170 }
diff --git a/drivers/gpu/drm/nouveau/nouveau_abi16.c b/drivers/gpu/drm/nouveau/nouveau_abi16.c
index cc79c796afe..cbf1fc60a38 100644
--- a/drivers/gpu/drm/nouveau/nouveau_abi16.c
+++ b/drivers/gpu/drm/nouveau/nouveau_abi16.c
@@ -241,6 +241,10 @@ nouveau_abi16_ioctl_channel_alloc(ABI16_IOCTL_ARGS)
241 241
242 if (unlikely(!abi16)) 242 if (unlikely(!abi16))
243 return -ENOMEM; 243 return -ENOMEM;
244
245 if (!drm->channel)
246 return nouveau_abi16_put(abi16, -ENODEV);
247
244 client = nv_client(abi16->client); 248 client = nv_client(abi16->client);
245 249
246 if (init->fb_ctxdma_handle == ~0 || init->tt_ctxdma_handle == ~0) 250 if (init->fb_ctxdma_handle == ~0 || init->tt_ctxdma_handle == ~0)
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 259e5f1adf4..35ac57f0aab 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -456,6 +456,7 @@ static struct ttm_tt *
456nouveau_ttm_tt_create(struct ttm_bo_device *bdev, unsigned long size, 456nouveau_ttm_tt_create(struct ttm_bo_device *bdev, unsigned long size,
457 uint32_t page_flags, struct page *dummy_read) 457 uint32_t page_flags, struct page *dummy_read)
458{ 458{
459#if __OS_HAS_AGP
459 struct nouveau_drm *drm = nouveau_bdev(bdev); 460 struct nouveau_drm *drm = nouveau_bdev(bdev);
460 struct drm_device *dev = drm->dev; 461 struct drm_device *dev = drm->dev;
461 462
@@ -463,6 +464,7 @@ nouveau_ttm_tt_create(struct ttm_bo_device *bdev, unsigned long size,
463 return ttm_agp_tt_create(bdev, dev->agp->bridge, size, 464 return ttm_agp_tt_create(bdev, dev->agp->bridge, size,
464 page_flags, dummy_read); 465 page_flags, dummy_read);
465 } 466 }
467#endif
466 468
467 return nouveau_sgdma_create_ttm(bdev, size, page_flags, dummy_read); 469 return nouveau_sgdma_create_ttm(bdev, size, page_flags, dummy_read);
468} 470}
diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c
index 9a6e2cb282d..d3595b23434 100644
--- a/drivers/gpu/drm/nouveau/nouveau_connector.c
+++ b/drivers/gpu/drm/nouveau/nouveau_connector.c
@@ -355,7 +355,7 @@ nouveau_connector_detect_lvds(struct drm_connector *connector, bool force)
355 * valid - it's not (rh#613284) 355 * valid - it's not (rh#613284)
356 */ 356 */
357 if (nv_encoder->dcb->lvdsconf.use_acpi_for_edid) { 357 if (nv_encoder->dcb->lvdsconf.use_acpi_for_edid) {
358 if (!(nv_connector->edid = nouveau_acpi_edid(dev, connector))) { 358 if ((nv_connector->edid = nouveau_acpi_edid(dev, connector))) {
359 status = connector_status_connected; 359 status = connector_status_connected;
360 goto out; 360 goto out;
361 } 361 }
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
index 8f98e5a8c48..86124b131f4 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -290,6 +290,7 @@ nouveau_display_create(struct drm_device *dev)
290 struct nouveau_drm *drm = nouveau_drm(dev); 290 struct nouveau_drm *drm = nouveau_drm(dev);
291 struct nouveau_disp *pdisp = nouveau_disp(drm->device); 291 struct nouveau_disp *pdisp = nouveau_disp(drm->device);
292 struct nouveau_display *disp; 292 struct nouveau_display *disp;
293 u32 pclass = dev->pdev->class >> 8;
293 int ret, gen; 294 int ret, gen;
294 295
295 disp = drm->display = kzalloc(sizeof(*disp), GFP_KERNEL); 296 disp = drm->display = kzalloc(sizeof(*disp), GFP_KERNEL);
@@ -360,23 +361,27 @@ nouveau_display_create(struct drm_device *dev)
360 drm_kms_helper_poll_init(dev); 361 drm_kms_helper_poll_init(dev);
361 drm_kms_helper_poll_disable(dev); 362 drm_kms_helper_poll_disable(dev);
362 363
363 if (nv_device(drm->device)->card_type < NV_50) 364 if (nouveau_modeset == 1 ||
364 ret = nv04_display_create(dev); 365 (nouveau_modeset < 0 && pclass == PCI_CLASS_DISPLAY_VGA)) {
365 else 366 if (nv_device(drm->device)->card_type < NV_50)
366 if (nv_device(drm->device)->card_type < NV_D0) 367 ret = nv04_display_create(dev);
367 ret = nv50_display_create(dev); 368 else
368 else 369 if (nv_device(drm->device)->card_type < NV_D0)
369 ret = nvd0_display_create(dev); 370 ret = nv50_display_create(dev);
370 if (ret) 371 else
371 goto disp_create_err; 372 ret = nvd0_display_create(dev);
372
373 if (dev->mode_config.num_crtc) {
374 ret = drm_vblank_init(dev, dev->mode_config.num_crtc);
375 if (ret) 373 if (ret)
376 goto vblank_err; 374 goto disp_create_err;
375
376 if (dev->mode_config.num_crtc) {
377 ret = drm_vblank_init(dev, dev->mode_config.num_crtc);
378 if (ret)
379 goto vblank_err;
380 }
381
382 nouveau_backlight_init(dev);
377 } 383 }
378 384
379 nouveau_backlight_init(dev);
380 return 0; 385 return 0;
381 386
382vblank_err: 387vblank_err:
@@ -395,7 +400,8 @@ nouveau_display_destroy(struct drm_device *dev)
395 nouveau_backlight_exit(dev); 400 nouveau_backlight_exit(dev);
396 drm_vblank_cleanup(dev); 401 drm_vblank_cleanup(dev);
397 402
398 disp->dtor(dev); 403 if (disp->dtor)
404 disp->dtor(dev);
399 405
400 drm_kms_helper_poll_fini(dev); 406 drm_kms_helper_poll_fini(dev);
401 drm_mode_config_cleanup(dev); 407 drm_mode_config_cleanup(dev);
@@ -530,9 +536,11 @@ nouveau_page_flip_reserve(struct nouveau_bo *old_bo,
530 if (ret) 536 if (ret)
531 goto fail; 537 goto fail;
532 538
533 ret = ttm_bo_reserve(&old_bo->bo, false, false, false, 0); 539 if (likely(old_bo != new_bo)) {
534 if (ret) 540 ret = ttm_bo_reserve(&old_bo->bo, false, false, false, 0);
535 goto fail_unreserve; 541 if (ret)
542 goto fail_unreserve;
543 }
536 544
537 return 0; 545 return 0;
538 546
@@ -551,8 +559,10 @@ nouveau_page_flip_unreserve(struct nouveau_bo *old_bo,
551 nouveau_bo_fence(new_bo, fence); 559 nouveau_bo_fence(new_bo, fence);
552 ttm_bo_unreserve(&new_bo->bo); 560 ttm_bo_unreserve(&new_bo->bo);
553 561
554 nouveau_bo_fence(old_bo, fence); 562 if (likely(old_bo != new_bo)) {
555 ttm_bo_unreserve(&old_bo->bo); 563 nouveau_bo_fence(old_bo, fence);
564 ttm_bo_unreserve(&old_bo->bo);
565 }
556 566
557 nouveau_bo_unpin(old_bo); 567 nouveau_bo_unpin(old_bo);
558} 568}
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
index ccae8c26ae2..8503b2ea570 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
@@ -63,8 +63,9 @@ MODULE_PARM_DESC(noaccel, "disable kernel/abi16 acceleration");
63static int nouveau_noaccel = 0; 63static int nouveau_noaccel = 0;
64module_param_named(noaccel, nouveau_noaccel, int, 0400); 64module_param_named(noaccel, nouveau_noaccel, int, 0400);
65 65
66MODULE_PARM_DESC(modeset, "enable driver"); 66MODULE_PARM_DESC(modeset, "enable driver (default: auto, "
67static int nouveau_modeset = -1; 67 "0 = disabled, 1 = enabled, 2 = headless)");
68int nouveau_modeset = -1;
68module_param_named(modeset, nouveau_modeset, int, 0400); 69module_param_named(modeset, nouveau_modeset, int, 0400);
69 70
70static struct drm_driver driver; 71static struct drm_driver driver;
@@ -128,7 +129,8 @@ nouveau_accel_init(struct nouveau_drm *drm)
128 129
129 /* initialise synchronisation routines */ 130 /* initialise synchronisation routines */
130 if (device->card_type < NV_10) ret = nv04_fence_create(drm); 131 if (device->card_type < NV_10) ret = nv04_fence_create(drm);
131 else if (device->chipset < 0x84) ret = nv10_fence_create(drm); 132 else if (device->card_type < NV_50) ret = nv10_fence_create(drm);
133 else if (device->chipset < 0x84) ret = nv50_fence_create(drm);
132 else if (device->card_type < NV_C0) ret = nv84_fence_create(drm); 134 else if (device->card_type < NV_C0) ret = nv84_fence_create(drm);
133 else ret = nvc0_fence_create(drm); 135 else ret = nvc0_fence_create(drm);
134 if (ret) { 136 if (ret) {
@@ -363,7 +365,8 @@ nouveau_drm_unload(struct drm_device *dev)
363 365
364 nouveau_pm_fini(dev); 366 nouveau_pm_fini(dev);
365 367
366 nouveau_display_fini(dev); 368 if (dev->mode_config.num_crtc)
369 nouveau_display_fini(dev);
367 nouveau_display_destroy(dev); 370 nouveau_display_destroy(dev);
368 371
369 nouveau_irq_fini(dev); 372 nouveau_irq_fini(dev);
@@ -403,13 +406,15 @@ nouveau_drm_suspend(struct pci_dev *pdev, pm_message_t pm_state)
403 pm_state.event == PM_EVENT_PRETHAW) 406 pm_state.event == PM_EVENT_PRETHAW)
404 return 0; 407 return 0;
405 408
406 NV_INFO(drm, "suspending fbcon...\n"); 409 if (dev->mode_config.num_crtc) {
407 nouveau_fbcon_set_suspend(dev, 1); 410 NV_INFO(drm, "suspending fbcon...\n");
411 nouveau_fbcon_set_suspend(dev, 1);
408 412
409 NV_INFO(drm, "suspending display...\n"); 413 NV_INFO(drm, "suspending display...\n");
410 ret = nouveau_display_suspend(dev); 414 ret = nouveau_display_suspend(dev);
411 if (ret) 415 if (ret)
412 return ret; 416 return ret;
417 }
413 418
414 NV_INFO(drm, "evicting buffers...\n"); 419 NV_INFO(drm, "evicting buffers...\n");
415 ttm_bo_evict_mm(&drm->ttm.bdev, TTM_PL_VRAM); 420 ttm_bo_evict_mm(&drm->ttm.bdev, TTM_PL_VRAM);
@@ -445,8 +450,10 @@ fail_client:
445 nouveau_client_init(&cli->base); 450 nouveau_client_init(&cli->base);
446 } 451 }
447 452
448 NV_INFO(drm, "resuming display...\n"); 453 if (dev->mode_config.num_crtc) {
449 nouveau_display_resume(dev); 454 NV_INFO(drm, "resuming display...\n");
455 nouveau_display_resume(dev);
456 }
450 return ret; 457 return ret;
451} 458}
452 459
@@ -486,8 +493,10 @@ nouveau_drm_resume(struct pci_dev *pdev)
486 nouveau_irq_postinstall(dev); 493 nouveau_irq_postinstall(dev);
487 nouveau_pm_resume(dev); 494 nouveau_pm_resume(dev);
488 495
489 NV_INFO(drm, "resuming display...\n"); 496 if (dev->mode_config.num_crtc) {
490 nouveau_display_resume(dev); 497 NV_INFO(drm, "resuming display...\n");
498 nouveau_display_resume(dev);
499 }
491 return 0; 500 return 0;
492} 501}
493 502
@@ -662,9 +671,7 @@ nouveau_drm_init(void)
662#ifdef CONFIG_VGA_CONSOLE 671#ifdef CONFIG_VGA_CONSOLE
663 if (vgacon_text_force()) 672 if (vgacon_text_force())
664 nouveau_modeset = 0; 673 nouveau_modeset = 0;
665 else
666#endif 674#endif
667 nouveau_modeset = 1;
668 } 675 }
669 676
670 if (!nouveau_modeset) 677 if (!nouveau_modeset)
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
index 81947121754..a1016992708 100644
--- a/drivers/gpu/drm/nouveau/nouveau_drm.h
+++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
@@ -141,4 +141,6 @@ int nouveau_drm_resume(struct pci_dev *);
141 nv_info((cli), fmt, ##args); \ 141 nv_info((cli), fmt, ##args); \
142} while (0) 142} while (0)
143 143
144extern int nouveau_modeset;
145
144#endif 146#endif
diff --git a/drivers/gpu/drm/nouveau/nouveau_irq.c b/drivers/gpu/drm/nouveau/nouveau_irq.c
index 9ca8afdb554..1d8cb506a28 100644
--- a/drivers/gpu/drm/nouveau/nouveau_irq.c
+++ b/drivers/gpu/drm/nouveau/nouveau_irq.c
@@ -61,13 +61,15 @@ nouveau_irq_handler(DRM_IRQ_ARGS)
61 61
62 nv_subdev(pmc)->intr(nv_subdev(pmc)); 62 nv_subdev(pmc)->intr(nv_subdev(pmc));
63 63
64 if (device->card_type >= NV_D0) { 64 if (dev->mode_config.num_crtc) {
65 if (nv_rd32(device, 0x000100) & 0x04000000) 65 if (device->card_type >= NV_D0) {
66 nvd0_display_intr(dev); 66 if (nv_rd32(device, 0x000100) & 0x04000000)
67 } else 67 nvd0_display_intr(dev);
68 if (device->card_type >= NV_50) { 68 } else
69 if (nv_rd32(device, 0x000100) & 0x04000000) 69 if (device->card_type >= NV_50) {
70 nv50_display_intr(dev); 70 if (nv_rd32(device, 0x000100) & 0x04000000)
71 nv50_display_intr(dev);
72 }
71 } 73 }
72 74
73 return IRQ_HANDLED; 75 return IRQ_HANDLED;
diff --git a/drivers/gpu/drm/nouveau/nouveau_pm.c b/drivers/gpu/drm/nouveau/nouveau_pm.c
index 0bf64c90aa2..5566172774d 100644
--- a/drivers/gpu/drm/nouveau/nouveau_pm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_pm.c
@@ -52,7 +52,7 @@ nouveau_pm_perflvl_aux(struct drm_device *dev, struct nouveau_pm_level *perflvl,
52{ 52{
53 struct nouveau_drm *drm = nouveau_drm(dev); 53 struct nouveau_drm *drm = nouveau_drm(dev);
54 struct nouveau_pm *pm = nouveau_pm(dev); 54 struct nouveau_pm *pm = nouveau_pm(dev);
55 struct nouveau_therm *therm = nouveau_therm(drm); 55 struct nouveau_therm *therm = nouveau_therm(drm->device);
56 int ret; 56 int ret;
57 57
58 /*XXX: not on all boards, we should control based on temperature 58 /*XXX: not on all boards, we should control based on temperature
@@ -64,7 +64,6 @@ nouveau_pm_perflvl_aux(struct drm_device *dev, struct nouveau_pm_level *perflvl,
64 ret = therm->fan_set(therm, perflvl->fanspeed); 64 ret = therm->fan_set(therm, perflvl->fanspeed);
65 if (ret && ret != -ENODEV) { 65 if (ret && ret != -ENODEV) {
66 NV_ERROR(drm, "fanspeed set failed: %d\n", ret); 66 NV_ERROR(drm, "fanspeed set failed: %d\n", ret);
67 return ret;
68 } 67 }
69 } 68 }
70 69
@@ -706,8 +705,7 @@ nouveau_hwmon_init(struct drm_device *dev)
706 struct device *hwmon_dev; 705 struct device *hwmon_dev;
707 int ret = 0; 706 int ret = 0;
708 707
709 if (!therm || !therm->temp_get || !therm->attr_get || 708 if (!therm || !therm->temp_get || !therm->attr_get || !therm->attr_set)
710 !therm->attr_set || therm->temp_get(therm) < 0)
711 return -ENODEV; 709 return -ENODEV;
712 710
713 hwmon_dev = hwmon_device_register(&dev->pdev->dev); 711 hwmon_dev = hwmon_device_register(&dev->pdev->dev);
diff --git a/drivers/gpu/drm/nouveau/nv04_dac.c b/drivers/gpu/drm/nouveau/nv04_dac.c
index 347a3bd78d0..64f7020fb60 100644
--- a/drivers/gpu/drm/nouveau/nv04_dac.c
+++ b/drivers/gpu/drm/nouveau/nv04_dac.c
@@ -220,7 +220,7 @@ out:
220 NVWriteVgaCrtc(dev, 0, NV_CIO_CR_MODE_INDEX, saved_cr_mode); 220 NVWriteVgaCrtc(dev, 0, NV_CIO_CR_MODE_INDEX, saved_cr_mode);
221 221
222 if (blue == 0x18) { 222 if (blue == 0x18) {
223 NV_INFO(drm, "Load detected on head A\n"); 223 NV_DEBUG(drm, "Load detected on head A\n");
224 return connector_status_connected; 224 return connector_status_connected;
225 } 225 }
226 226
@@ -338,8 +338,8 @@ nv17_dac_detect(struct drm_encoder *encoder, struct drm_connector *connector)
338 338
339 if (nv17_dac_sample_load(encoder) & 339 if (nv17_dac_sample_load(encoder) &
340 NV_PRAMDAC_TEST_CONTROL_SENSEB_ALLHI) { 340 NV_PRAMDAC_TEST_CONTROL_SENSEB_ALLHI) {
341 NV_INFO(drm, "Load detected on output %c\n", 341 NV_DEBUG(drm, "Load detected on output %c\n",
342 '@' + ffs(dcb->or)); 342 '@' + ffs(dcb->or));
343 return connector_status_connected; 343 return connector_status_connected;
344 } else { 344 } else {
345 return connector_status_disconnected; 345 return connector_status_disconnected;
@@ -413,9 +413,9 @@ static void nv04_dac_commit(struct drm_encoder *encoder)
413 413
414 helper->dpms(encoder, DRM_MODE_DPMS_ON); 414 helper->dpms(encoder, DRM_MODE_DPMS_ON);
415 415
416 NV_INFO(drm, "Output %s is running on CRTC %d using output %c\n", 416 NV_DEBUG(drm, "Output %s is running on CRTC %d using output %c\n",
417 drm_get_connector_name(&nouveau_encoder_connector_get(nv_encoder)->base), 417 drm_get_connector_name(&nouveau_encoder_connector_get(nv_encoder)->base),
418 nv_crtc->index, '@' + ffs(nv_encoder->dcb->or)); 418 nv_crtc->index, '@' + ffs(nv_encoder->dcb->or));
419} 419}
420 420
421void nv04_dac_update_dacclk(struct drm_encoder *encoder, bool enable) 421void nv04_dac_update_dacclk(struct drm_encoder *encoder, bool enable)
@@ -461,8 +461,8 @@ static void nv04_dac_dpms(struct drm_encoder *encoder, int mode)
461 return; 461 return;
462 nv_encoder->last_dpms = mode; 462 nv_encoder->last_dpms = mode;
463 463
464 NV_INFO(drm, "Setting dpms mode %d on vga encoder (output %d)\n", 464 NV_DEBUG(drm, "Setting dpms mode %d on vga encoder (output %d)\n",
465 mode, nv_encoder->dcb->index); 465 mode, nv_encoder->dcb->index);
466 466
467 nv04_dac_update_dacclk(encoder, mode == DRM_MODE_DPMS_ON); 467 nv04_dac_update_dacclk(encoder, mode == DRM_MODE_DPMS_ON);
468} 468}
diff --git a/drivers/gpu/drm/nouveau/nv04_dfp.c b/drivers/gpu/drm/nouveau/nv04_dfp.c
index da55d7642c8..184cdf80676 100644
--- a/drivers/gpu/drm/nouveau/nv04_dfp.c
+++ b/drivers/gpu/drm/nouveau/nv04_dfp.c
@@ -476,9 +476,9 @@ static void nv04_dfp_commit(struct drm_encoder *encoder)
476 476
477 helper->dpms(encoder, DRM_MODE_DPMS_ON); 477 helper->dpms(encoder, DRM_MODE_DPMS_ON);
478 478
479 NV_INFO(drm, "Output %s is running on CRTC %d using output %c\n", 479 NV_DEBUG(drm, "Output %s is running on CRTC %d using output %c\n",
480 drm_get_connector_name(&nouveau_encoder_connector_get(nv_encoder)->base), 480 drm_get_connector_name(&nouveau_encoder_connector_get(nv_encoder)->base),
481 nv_crtc->index, '@' + ffs(nv_encoder->dcb->or)); 481 nv_crtc->index, '@' + ffs(nv_encoder->dcb->or));
482} 482}
483 483
484static void nv04_dfp_update_backlight(struct drm_encoder *encoder, int mode) 484static void nv04_dfp_update_backlight(struct drm_encoder *encoder, int mode)
@@ -520,8 +520,8 @@ static void nv04_lvds_dpms(struct drm_encoder *encoder, int mode)
520 return; 520 return;
521 nv_encoder->last_dpms = mode; 521 nv_encoder->last_dpms = mode;
522 522
523 NV_INFO(drm, "Setting dpms mode %d on lvds encoder (output %d)\n", 523 NV_DEBUG(drm, "Setting dpms mode %d on lvds encoder (output %d)\n",
524 mode, nv_encoder->dcb->index); 524 mode, nv_encoder->dcb->index);
525 525
526 if (was_powersaving && is_powersaving_dpms(mode)) 526 if (was_powersaving && is_powersaving_dpms(mode))
527 return; 527 return;
@@ -565,8 +565,8 @@ static void nv04_tmds_dpms(struct drm_encoder *encoder, int mode)
565 return; 565 return;
566 nv_encoder->last_dpms = mode; 566 nv_encoder->last_dpms = mode;
567 567
568 NV_INFO(drm, "Setting dpms mode %d on tmds encoder (output %d)\n", 568 NV_DEBUG(drm, "Setting dpms mode %d on tmds encoder (output %d)\n",
569 mode, nv_encoder->dcb->index); 569 mode, nv_encoder->dcb->index);
570 570
571 nv04_dfp_update_backlight(encoder, mode); 571 nv04_dfp_update_backlight(encoder, mode);
572 nv04_dfp_update_fp_control(encoder, mode); 572 nv04_dfp_update_fp_control(encoder, mode);
diff --git a/drivers/gpu/drm/nouveau/nv04_tv.c b/drivers/gpu/drm/nouveau/nv04_tv.c
index 099fbeda6e2..62e826a139b 100644
--- a/drivers/gpu/drm/nouveau/nv04_tv.c
+++ b/drivers/gpu/drm/nouveau/nv04_tv.c
@@ -75,8 +75,8 @@ static void nv04_tv_dpms(struct drm_encoder *encoder, int mode)
75 struct nv04_mode_state *state = &nv04_display(dev)->mode_reg; 75 struct nv04_mode_state *state = &nv04_display(dev)->mode_reg;
76 uint8_t crtc1A; 76 uint8_t crtc1A;
77 77
78 NV_INFO(drm, "Setting dpms mode %d on TV encoder (output %d)\n", 78 NV_DEBUG(drm, "Setting dpms mode %d on TV encoder (output %d)\n",
79 mode, nv_encoder->dcb->index); 79 mode, nv_encoder->dcb->index);
80 80
81 state->pllsel &= ~(PLLSEL_TV_CRTC1_MASK | PLLSEL_TV_CRTC2_MASK); 81 state->pllsel &= ~(PLLSEL_TV_CRTC1_MASK | PLLSEL_TV_CRTC2_MASK);
82 82
@@ -167,9 +167,8 @@ static void nv04_tv_commit(struct drm_encoder *encoder)
167 167
168 helper->dpms(encoder, DRM_MODE_DPMS_ON); 168 helper->dpms(encoder, DRM_MODE_DPMS_ON);
169 169
170 NV_INFO(drm, "Output %s is running on CRTC %d using output %c\n", 170 NV_DEBUG(drm, "Output %s is running on CRTC %d using output %c\n",
171 drm_get_connector_name(&nouveau_encoder_connector_get(nv_encoder)->base), nv_crtc->index, 171 drm_get_connector_name(&nouveau_encoder_connector_get(nv_encoder)->base), nv_crtc->index, '@' + ffs(nv_encoder->dcb->or));
172 '@' + ffs(nv_encoder->dcb->or));
173} 172}
174 173
175static void nv04_tv_destroy(struct drm_encoder *encoder) 174static void nv04_tv_destroy(struct drm_encoder *encoder)
diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c
index 96184d02c8d..3bce0299f64 100644
--- a/drivers/gpu/drm/radeon/atombios_crtc.c
+++ b/drivers/gpu/drm/radeon/atombios_crtc.c
@@ -1690,41 +1690,49 @@ static int radeon_atom_pick_pll(struct drm_crtc *crtc)
1690 } 1690 }
1691 /* all other cases */ 1691 /* all other cases */
1692 pll_in_use = radeon_get_pll_use_mask(crtc); 1692 pll_in_use = radeon_get_pll_use_mask(crtc);
1693 if (!(pll_in_use & (1 << ATOM_PPLL2)))
1694 return ATOM_PPLL2;
1695 if (!(pll_in_use & (1 << ATOM_PPLL1))) 1693 if (!(pll_in_use & (1 << ATOM_PPLL1)))
1696 return ATOM_PPLL1; 1694 return ATOM_PPLL1;
1695 if (!(pll_in_use & (1 << ATOM_PPLL2)))
1696 return ATOM_PPLL2;
1697 DRM_ERROR("unable to allocate a PPLL\n"); 1697 DRM_ERROR("unable to allocate a PPLL\n");
1698 return ATOM_PPLL_INVALID; 1698 return ATOM_PPLL_INVALID;
1699 } else { 1699 } else if (ASIC_IS_AVIVO(rdev)) {
1700 if (ASIC_IS_AVIVO(rdev)) { 1700 /* in DP mode, the DP ref clock can come from either PPLL
1701 /* in DP mode, the DP ref clock can come from either PPLL 1701 * depending on the asic:
1702 * depending on the asic: 1702 * DCE3: PPLL1 or PPLL2
1703 * DCE3: PPLL1 or PPLL2 1703 */
1704 */ 1704 if (ENCODER_MODE_IS_DP(atombios_get_encoder_mode(radeon_crtc->encoder))) {
1705 if (ENCODER_MODE_IS_DP(atombios_get_encoder_mode(radeon_crtc->encoder))) { 1705 /* use the same PPLL for all DP monitors */
1706 /* use the same PPLL for all DP monitors */ 1706 pll = radeon_get_shared_dp_ppll(crtc);
1707 pll = radeon_get_shared_dp_ppll(crtc); 1707 if (pll != ATOM_PPLL_INVALID)
1708 if (pll != ATOM_PPLL_INVALID) 1708 return pll;
1709 return pll; 1709 } else {
1710 } else { 1710 /* use the same PPLL for all monitors with the same clock */
1711 /* use the same PPLL for all monitors with the same clock */ 1711 pll = radeon_get_shared_nondp_ppll(crtc);
1712 pll = radeon_get_shared_nondp_ppll(crtc); 1712 if (pll != ATOM_PPLL_INVALID)
1713 if (pll != ATOM_PPLL_INVALID) 1713 return pll;
1714 return pll; 1714 }
1715 } 1715 /* all other cases */
1716 /* all other cases */ 1716 pll_in_use = radeon_get_pll_use_mask(crtc);
1717 pll_in_use = radeon_get_pll_use_mask(crtc); 1717 /* the order shouldn't matter here, but we probably
1718 * need this until we have atomic modeset
1719 */
1720 if (rdev->flags & RADEON_IS_IGP) {
1721 if (!(pll_in_use & (1 << ATOM_PPLL1)))
1722 return ATOM_PPLL1;
1723 if (!(pll_in_use & (1 << ATOM_PPLL2)))
1724 return ATOM_PPLL2;
1725 } else {
1718 if (!(pll_in_use & (1 << ATOM_PPLL2))) 1726 if (!(pll_in_use & (1 << ATOM_PPLL2)))
1719 return ATOM_PPLL2; 1727 return ATOM_PPLL2;
1720 if (!(pll_in_use & (1 << ATOM_PPLL1))) 1728 if (!(pll_in_use & (1 << ATOM_PPLL1)))
1721 return ATOM_PPLL1; 1729 return ATOM_PPLL1;
1722 DRM_ERROR("unable to allocate a PPLL\n");
1723 return ATOM_PPLL_INVALID;
1724 } else {
1725 /* on pre-R5xx asics, the crtc to pll mapping is hardcoded */
1726 return radeon_crtc->crtc_id;
1727 } 1730 }
1731 DRM_ERROR("unable to allocate a PPLL\n");
1732 return ATOM_PPLL_INVALID;
1733 } else {
1734 /* on pre-R5xx asics, the crtc to pll mapping is hardcoded */
1735 return radeon_crtc->crtc_id;
1728 } 1736 }
1729} 1737}
1730 1738
diff --git a/drivers/gpu/drm/radeon/atombios_encoders.c b/drivers/gpu/drm/radeon/atombios_encoders.c
index 49cbb3795a1..010bae19554 100644
--- a/drivers/gpu/drm/radeon/atombios_encoders.c
+++ b/drivers/gpu/drm/radeon/atombios_encoders.c
@@ -184,6 +184,7 @@ void radeon_atom_backlight_init(struct radeon_encoder *radeon_encoder,
184 struct radeon_backlight_privdata *pdata; 184 struct radeon_backlight_privdata *pdata;
185 struct radeon_encoder_atom_dig *dig; 185 struct radeon_encoder_atom_dig *dig;
186 u8 backlight_level; 186 u8 backlight_level;
187 char bl_name[16];
187 188
188 if (!radeon_encoder->enc_priv) 189 if (!radeon_encoder->enc_priv)
189 return; 190 return;
@@ -203,7 +204,9 @@ void radeon_atom_backlight_init(struct radeon_encoder *radeon_encoder,
203 memset(&props, 0, sizeof(props)); 204 memset(&props, 0, sizeof(props));
204 props.max_brightness = RADEON_MAX_BL_LEVEL; 205 props.max_brightness = RADEON_MAX_BL_LEVEL;
205 props.type = BACKLIGHT_RAW; 206 props.type = BACKLIGHT_RAW;
206 bd = backlight_device_register("radeon_bl", &drm_connector->kdev, 207 snprintf(bl_name, sizeof(bl_name),
208 "radeon_bl%d", dev->primary->index);
209 bd = backlight_device_register(bl_name, &drm_connector->kdev,
207 pdata, &radeon_atom_backlight_ops, &props); 210 pdata, &radeon_atom_backlight_ops, &props);
208 if (IS_ERR(bd)) { 211 if (IS_ERR(bd)) {
209 DRM_ERROR("Backlight registration failed\n"); 212 DRM_ERROR("Backlight registration failed\n");
@@ -1622,7 +1625,7 @@ radeon_atom_encoder_dpms_dig(struct drm_encoder *encoder, int mode)
1622 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_SETUP, 0, 0); 1625 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_SETUP, 0, 0);
1623 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_ENABLE, 0, 0); 1626 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_ENABLE, 0, 0);
1624 /* some early dce3.2 boards have a bug in their transmitter control table */ 1627 /* some early dce3.2 boards have a bug in their transmitter control table */
1625 if ((rdev->family != CHIP_RV710) || (rdev->family != CHIP_RV730)) 1628 if ((rdev->family != CHIP_RV710) && (rdev->family != CHIP_RV730))
1626 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_ENABLE_OUTPUT, 0, 0); 1629 atombios_dig_transmitter_setup(encoder, ATOM_TRANSMITTER_ACTION_ENABLE_OUTPUT, 0, 0);
1627 } 1630 }
1628 if (ENCODER_MODE_IS_DP(atombios_get_encoder_mode(encoder)) && connector) { 1631 if (ENCODER_MODE_IS_DP(atombios_get_encoder_mode(encoder)) && connector) {
diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c
index a1f49c5fd74..219942c660d 100644
--- a/drivers/gpu/drm/radeon/evergreen.c
+++ b/drivers/gpu/drm/radeon/evergreen.c
@@ -1330,6 +1330,8 @@ void evergreen_mc_stop(struct radeon_device *rdev, struct evergreen_mc_save *sav
1330 break; 1330 break;
1331 udelay(1); 1331 udelay(1);
1332 } 1332 }
1333 } else {
1334 save->crtc_enabled[i] = false;
1333 } 1335 }
1334 } 1336 }
1335 1337
@@ -1372,7 +1374,7 @@ void evergreen_mc_resume(struct radeon_device *rdev, struct evergreen_mc_save *s
1372 WREG32(BIF_FB_EN, FB_READ_EN | FB_WRITE_EN); 1374 WREG32(BIF_FB_EN, FB_READ_EN | FB_WRITE_EN);
1373 1375
1374 for (i = 0; i < rdev->num_crtc; i++) { 1376 for (i = 0; i < rdev->num_crtc; i++) {
1375 if (save->crtc_enabled) { 1377 if (save->crtc_enabled[i]) {
1376 if (ASIC_IS_DCE6(rdev)) { 1378 if (ASIC_IS_DCE6(rdev)) {
1377 tmp = RREG32(EVERGREEN_CRTC_BLANK_CONTROL + crtc_offsets[i]); 1379 tmp = RREG32(EVERGREEN_CRTC_BLANK_CONTROL + crtc_offsets[i]);
1378 tmp |= EVERGREEN_CRTC_BLANK_DATA_EN; 1380 tmp |= EVERGREEN_CRTC_BLANK_DATA_EN;
@@ -3431,9 +3433,14 @@ void evergreen_pcie_gen2_enable(struct radeon_device *rdev)
3431 if (!(mask & DRM_PCIE_SPEED_50)) 3433 if (!(mask & DRM_PCIE_SPEED_50))
3432 return; 3434 return;
3433 3435
3436 speed_cntl = RREG32_PCIE_P(PCIE_LC_SPEED_CNTL);
3437 if (speed_cntl & LC_CURRENT_DATA_RATE) {
3438 DRM_INFO("PCIE gen 2 link speeds already enabled\n");
3439 return;
3440 }
3441
3434 DRM_INFO("enabling PCIE gen 2 link speeds, disable with radeon.pcie_gen2=0\n"); 3442 DRM_INFO("enabling PCIE gen 2 link speeds, disable with radeon.pcie_gen2=0\n");
3435 3443
3436 speed_cntl = RREG32_PCIE_P(PCIE_LC_SPEED_CNTL);
3437 if ((speed_cntl & LC_OTHER_SIDE_EVER_SENT_GEN2) || 3444 if ((speed_cntl & LC_OTHER_SIDE_EVER_SENT_GEN2) ||
3438 (speed_cntl & LC_OTHER_SIDE_SUPPORTS_GEN2)) { 3445 (speed_cntl & LC_OTHER_SIDE_SUPPORTS_GEN2)) {
3439 3446
diff --git a/drivers/gpu/drm/radeon/evergreen_cs.c b/drivers/gpu/drm/radeon/evergreen_cs.c
index 573ed1bc6cf..c042e497e45 100644
--- a/drivers/gpu/drm/radeon/evergreen_cs.c
+++ b/drivers/gpu/drm/radeon/evergreen_cs.c
@@ -264,7 +264,7 @@ static int evergreen_surface_check_2d(struct radeon_cs_parser *p,
264 /* macro tile width & height */ 264 /* macro tile width & height */
265 palign = (8 * surf->bankw * track->npipes) * surf->mtilea; 265 palign = (8 * surf->bankw * track->npipes) * surf->mtilea;
266 halign = (8 * surf->bankh * surf->nbanks) / surf->mtilea; 266 halign = (8 * surf->bankh * surf->nbanks) / surf->mtilea;
267 mtileb = (palign / 8) * (halign / 8) * tileb;; 267 mtileb = (palign / 8) * (halign / 8) * tileb;
268 mtile_pr = surf->nbx / palign; 268 mtile_pr = surf->nbx / palign;
269 mtile_ps = (mtile_pr * surf->nby) / halign; 269 mtile_ps = (mtile_pr * surf->nby) / halign;
270 surf->layer_size = mtile_ps * mtileb * slice_pt; 270 surf->layer_size = mtile_ps * mtileb * slice_pt;
@@ -2725,6 +2725,9 @@ static bool evergreen_vm_reg_valid(u32 reg)
2725 /* check config regs */ 2725 /* check config regs */
2726 switch (reg) { 2726 switch (reg) {
2727 case GRBM_GFX_INDEX: 2727 case GRBM_GFX_INDEX:
2728 case CP_STRMOUT_CNTL:
2729 case CP_COHER_CNTL:
2730 case CP_COHER_SIZE:
2728 case VGT_VTX_VECT_EJECT_REG: 2731 case VGT_VTX_VECT_EJECT_REG:
2729 case VGT_CACHE_INVALIDATION: 2732 case VGT_CACHE_INVALIDATION:
2730 case VGT_GS_VERTEX_REUSE: 2733 case VGT_GS_VERTEX_REUSE:
@@ -2829,6 +2832,7 @@ static bool evergreen_vm_reg_valid(u32 reg)
2829 case CAYMAN_SQ_EX_ALLOC_TABLE_SLOTS: 2832 case CAYMAN_SQ_EX_ALLOC_TABLE_SLOTS:
2830 return true; 2833 return true;
2831 default: 2834 default:
2835 DRM_ERROR("Invalid register 0x%x in CS\n", reg);
2832 return false; 2836 return false;
2833 } 2837 }
2834} 2838}
diff --git a/drivers/gpu/drm/radeon/evergreend.h b/drivers/gpu/drm/radeon/evergreend.h
index df542f1a5df..2bc0f6a1b42 100644
--- a/drivers/gpu/drm/radeon/evergreend.h
+++ b/drivers/gpu/drm/radeon/evergreend.h
@@ -91,6 +91,10 @@
91#define FB_READ_EN (1 << 0) 91#define FB_READ_EN (1 << 0)
92#define FB_WRITE_EN (1 << 1) 92#define FB_WRITE_EN (1 << 1)
93 93
94#define CP_STRMOUT_CNTL 0x84FC
95
96#define CP_COHER_CNTL 0x85F0
97#define CP_COHER_SIZE 0x85F4
94#define CP_COHER_BASE 0x85F8 98#define CP_COHER_BASE 0x85F8
95#define CP_STALLED_STAT1 0x8674 99#define CP_STALLED_STAT1 0x8674
96#define CP_STALLED_STAT2 0x8678 100#define CP_STALLED_STAT2 0x8678
diff --git a/drivers/gpu/drm/radeon/ni.c b/drivers/gpu/drm/radeon/ni.c
index 8bcb554ea0c..81e6a568c29 100644
--- a/drivers/gpu/drm/radeon/ni.c
+++ b/drivers/gpu/drm/radeon/ni.c
@@ -770,9 +770,13 @@ static int cayman_pcie_gart_enable(struct radeon_device *rdev)
770 WREG32(0x15DC, 0); 770 WREG32(0x15DC, 0);
771 771
772 /* empty context1-7 */ 772 /* empty context1-7 */
773 /* Assign the pt base to something valid for now; the pts used for
774 * the VMs are determined by the application and setup and assigned
775 * on the fly in the vm part of radeon_gart.c
776 */
773 for (i = 1; i < 8; i++) { 777 for (i = 1; i < 8; i++) {
774 WREG32(VM_CONTEXT0_PAGE_TABLE_START_ADDR + (i << 2), 0); 778 WREG32(VM_CONTEXT0_PAGE_TABLE_START_ADDR + (i << 2), 0);
775 WREG32(VM_CONTEXT0_PAGE_TABLE_END_ADDR + (i << 2), 0); 779 WREG32(VM_CONTEXT0_PAGE_TABLE_END_ADDR + (i << 2), rdev->vm_manager.max_pfn);
776 WREG32(VM_CONTEXT0_PAGE_TABLE_BASE_ADDR + (i << 2), 780 WREG32(VM_CONTEXT0_PAGE_TABLE_BASE_ADDR + (i << 2),
777 rdev->gart.table_addr >> 12); 781 rdev->gart.table_addr >> 12);
778 } 782 }
@@ -1534,26 +1538,31 @@ void cayman_vm_set_page(struct radeon_device *rdev, uint64_t pe,
1534{ 1538{
1535 struct radeon_ring *ring = &rdev->ring[rdev->asic->vm.pt_ring_index]; 1539 struct radeon_ring *ring = &rdev->ring[rdev->asic->vm.pt_ring_index];
1536 uint32_t r600_flags = cayman_vm_page_flags(rdev, flags); 1540 uint32_t r600_flags = cayman_vm_page_flags(rdev, flags);
1537 int i;
1538 1541
1539 radeon_ring_write(ring, PACKET3(PACKET3_ME_WRITE, 1 + count * 2)); 1542 while (count) {
1540 radeon_ring_write(ring, pe); 1543 unsigned ndw = 1 + count * 2;
1541 radeon_ring_write(ring, upper_32_bits(pe) & 0xff); 1544 if (ndw > 0x3FFF)
1542 for (i = 0; i < count; ++i) { 1545 ndw = 0x3FFF;
1543 uint64_t value = 0; 1546
1544 if (flags & RADEON_VM_PAGE_SYSTEM) { 1547 radeon_ring_write(ring, PACKET3(PACKET3_ME_WRITE, ndw));
1545 value = radeon_vm_map_gart(rdev, addr); 1548 radeon_ring_write(ring, pe);
1546 value &= 0xFFFFFFFFFFFFF000ULL; 1549 radeon_ring_write(ring, upper_32_bits(pe) & 0xff);
1547 addr += incr; 1550 for (; ndw > 1; ndw -= 2, --count, pe += 8) {
1548 1551 uint64_t value = 0;
1549 } else if (flags & RADEON_VM_PAGE_VALID) { 1552 if (flags & RADEON_VM_PAGE_SYSTEM) {
1550 value = addr; 1553 value = radeon_vm_map_gart(rdev, addr);
1551 addr += incr; 1554 value &= 0xFFFFFFFFFFFFF000ULL;
1552 } 1555 addr += incr;
1556
1557 } else if (flags & RADEON_VM_PAGE_VALID) {
1558 value = addr;
1559 addr += incr;
1560 }
1553 1561
1554 value |= r600_flags; 1562 value |= r600_flags;
1555 radeon_ring_write(ring, value); 1563 radeon_ring_write(ring, value);
1556 radeon_ring_write(ring, upper_32_bits(value)); 1564 radeon_ring_write(ring, upper_32_bits(value));
1565 }
1557 } 1566 }
1558} 1567}
1559 1568
@@ -1572,12 +1581,6 @@ void cayman_vm_flush(struct radeon_device *rdev, int ridx, struct radeon_vm *vm)
1572 if (vm == NULL) 1581 if (vm == NULL)
1573 return; 1582 return;
1574 1583
1575 radeon_ring_write(ring, PACKET0(VM_CONTEXT0_PAGE_TABLE_START_ADDR + (vm->id << 2), 0));
1576 radeon_ring_write(ring, 0);
1577
1578 radeon_ring_write(ring, PACKET0(VM_CONTEXT0_PAGE_TABLE_END_ADDR + (vm->id << 2), 0));
1579 radeon_ring_write(ring, vm->last_pfn);
1580
1581 radeon_ring_write(ring, PACKET0(VM_CONTEXT0_PAGE_TABLE_BASE_ADDR + (vm->id << 2), 0)); 1584 radeon_ring_write(ring, PACKET0(VM_CONTEXT0_PAGE_TABLE_BASE_ADDR + (vm->id << 2), 0));
1582 radeon_ring_write(ring, vm->pd_gpu_addr >> 12); 1585 radeon_ring_write(ring, vm->pd_gpu_addr >> 12);
1583 1586
@@ -1588,4 +1591,8 @@ void cayman_vm_flush(struct radeon_device *rdev, int ridx, struct radeon_vm *vm)
1588 /* bits 0-7 are the VM contexts0-7 */ 1591 /* bits 0-7 are the VM contexts0-7 */
1589 radeon_ring_write(ring, PACKET0(VM_INVALIDATE_REQUEST, 0)); 1592 radeon_ring_write(ring, PACKET0(VM_INVALIDATE_REQUEST, 0));
1590 radeon_ring_write(ring, 1 << vm->id); 1593 radeon_ring_write(ring, 1 << vm->id);
1594
1595 /* sync PFP to ME, otherwise we might get invalid PFP reads */
1596 radeon_ring_write(ring, PACKET3(PACKET3_PFP_SYNC_ME, 0));
1597 radeon_ring_write(ring, 0x0);
1591} 1598}
diff --git a/drivers/gpu/drm/radeon/nid.h b/drivers/gpu/drm/radeon/nid.h
index 2423d1b5d38..cbef6815907 100644
--- a/drivers/gpu/drm/radeon/nid.h
+++ b/drivers/gpu/drm/radeon/nid.h
@@ -502,6 +502,7 @@
502#define PACKET3_MPEG_INDEX 0x3A 502#define PACKET3_MPEG_INDEX 0x3A
503#define PACKET3_WAIT_REG_MEM 0x3C 503#define PACKET3_WAIT_REG_MEM 0x3C
504#define PACKET3_MEM_WRITE 0x3D 504#define PACKET3_MEM_WRITE 0x3D
505#define PACKET3_PFP_SYNC_ME 0x42
505#define PACKET3_SURFACE_SYNC 0x43 506#define PACKET3_SURFACE_SYNC 0x43
506# define PACKET3_CB0_DEST_BASE_ENA (1 << 6) 507# define PACKET3_CB0_DEST_BASE_ENA (1 << 6)
507# define PACKET3_CB1_DEST_BASE_ENA (1 << 7) 508# define PACKET3_CB1_DEST_BASE_ENA (1 << 7)
diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
index 70c800ff619..cda280d157d 100644
--- a/drivers/gpu/drm/radeon/r600.c
+++ b/drivers/gpu/drm/radeon/r600.c
@@ -3703,6 +3703,12 @@ static void r600_pcie_gen2_enable(struct radeon_device *rdev)
3703 if (!(mask & DRM_PCIE_SPEED_50)) 3703 if (!(mask & DRM_PCIE_SPEED_50))
3704 return; 3704 return;
3705 3705
3706 speed_cntl = RREG32_PCIE_P(PCIE_LC_SPEED_CNTL);
3707 if (speed_cntl & LC_CURRENT_DATA_RATE) {
3708 DRM_INFO("PCIE gen 2 link speeds already enabled\n");
3709 return;
3710 }
3711
3706 DRM_INFO("enabling PCIE gen 2 link speeds, disable with radeon.pcie_gen2=0\n"); 3712 DRM_INFO("enabling PCIE gen 2 link speeds, disable with radeon.pcie_gen2=0\n");
3707 3713
3708 /* 55 nm r6xx asics */ 3714 /* 55 nm r6xx asics */
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index b04c06444d8..8c42d54c2e2 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -663,9 +663,14 @@ struct radeon_vm {
663 struct list_head list; 663 struct list_head list;
664 struct list_head va; 664 struct list_head va;
665 unsigned id; 665 unsigned id;
666 unsigned last_pfn; 666
667 u64 pd_gpu_addr; 667 /* contains the page directory */
668 struct radeon_sa_bo *sa_bo; 668 struct radeon_sa_bo *page_directory;
669 uint64_t pd_gpu_addr;
670
671 /* array of page tables, one for each page directory entry */
672 struct radeon_sa_bo **page_tables;
673
669 struct mutex mutex; 674 struct mutex mutex;
670 /* last fence for cs using this vm */ 675 /* last fence for cs using this vm */
671 struct radeon_fence *fence; 676 struct radeon_fence *fence;
@@ -1843,9 +1848,10 @@ extern void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size
1843 */ 1848 */
1844int radeon_vm_manager_init(struct radeon_device *rdev); 1849int radeon_vm_manager_init(struct radeon_device *rdev);
1845void radeon_vm_manager_fini(struct radeon_device *rdev); 1850void radeon_vm_manager_fini(struct radeon_device *rdev);
1846int radeon_vm_init(struct radeon_device *rdev, struct radeon_vm *vm); 1851void radeon_vm_init(struct radeon_device *rdev, struct radeon_vm *vm);
1847void radeon_vm_fini(struct radeon_device *rdev, struct radeon_vm *vm); 1852void radeon_vm_fini(struct radeon_device *rdev, struct radeon_vm *vm);
1848int radeon_vm_alloc_pt(struct radeon_device *rdev, struct radeon_vm *vm); 1853int radeon_vm_alloc_pt(struct radeon_device *rdev, struct radeon_vm *vm);
1854void radeon_vm_add_to_lru(struct radeon_device *rdev, struct radeon_vm *vm);
1849struct radeon_fence *radeon_vm_grab_id(struct radeon_device *rdev, 1855struct radeon_fence *radeon_vm_grab_id(struct radeon_device *rdev,
1850 struct radeon_vm *vm, int ring); 1856 struct radeon_vm *vm, int ring);
1851void radeon_vm_fence(struct radeon_device *rdev, 1857void radeon_vm_fence(struct radeon_device *rdev,
diff --git a/drivers/gpu/drm/radeon/radeon_acpi.c b/drivers/gpu/drm/radeon/radeon_acpi.c
index b0a5688c67f..196d28d9957 100644
--- a/drivers/gpu/drm/radeon/radeon_acpi.c
+++ b/drivers/gpu/drm/radeon/radeon_acpi.c
@@ -201,7 +201,7 @@ static int radeon_atif_verify_interface(acpi_handle handle,
201 201
202 size = *(u16 *) info->buffer.pointer; 202 size = *(u16 *) info->buffer.pointer;
203 if (size < 12) { 203 if (size < 12) {
204 DRM_INFO("ATIF buffer is too small: %lu\n", size); 204 DRM_INFO("ATIF buffer is too small: %zu\n", size);
205 err = -EINVAL; 205 err = -EINVAL;
206 goto out; 206 goto out;
207 } 207 }
@@ -370,6 +370,7 @@ int radeon_atif_handler(struct radeon_device *rdev,
370 370
371 radeon_set_backlight_level(rdev, enc, req.backlight_level); 371 radeon_set_backlight_level(rdev, enc, req.backlight_level);
372 372
373#if defined(CONFIG_BACKLIGHT_CLASS_DEVICE) || defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE)
373 if (rdev->is_atom_bios) { 374 if (rdev->is_atom_bios) {
374 struct radeon_encoder_atom_dig *dig = enc->enc_priv; 375 struct radeon_encoder_atom_dig *dig = enc->enc_priv;
375 backlight_force_update(dig->bl_dev, 376 backlight_force_update(dig->bl_dev,
@@ -379,6 +380,7 @@ int radeon_atif_handler(struct radeon_device *rdev,
379 backlight_force_update(dig->bl_dev, 380 backlight_force_update(dig->bl_dev,
380 BACKLIGHT_UPDATE_HOTKEY); 381 BACKLIGHT_UPDATE_HOTKEY);
381 } 382 }
383#endif
382 } 384 }
383 } 385 }
384 /* TODO: check other events */ 386 /* TODO: check other events */
@@ -485,7 +487,7 @@ static int radeon_atcs_verify_interface(acpi_handle handle,
485 487
486 size = *(u16 *) info->buffer.pointer; 488 size = *(u16 *) info->buffer.pointer;
487 if (size < 8) { 489 if (size < 8) {
488 DRM_INFO("ATCS buffer is too small: %lu\n", size); 490 DRM_INFO("ATCS buffer is too small: %zu\n", size);
489 err = -EINVAL; 491 err = -EINVAL;
490 goto out; 492 goto out;
491 } 493 }
diff --git a/drivers/gpu/drm/radeon/radeon_agp.c b/drivers/gpu/drm/radeon/radeon_agp.c
index 10ea17a6b2a..42433344cb1 100644
--- a/drivers/gpu/drm/radeon/radeon_agp.c
+++ b/drivers/gpu/drm/radeon/radeon_agp.c
@@ -69,9 +69,12 @@ static struct radeon_agpmode_quirk radeon_agpmode_quirk_list[] = {
69 /* Intel 82830 830 Chipset Host Bridge / Mobility M6 LY Needs AGPMode 2 (fdo #17360)*/ 69 /* Intel 82830 830 Chipset Host Bridge / Mobility M6 LY Needs AGPMode 2 (fdo #17360)*/
70 { PCI_VENDOR_ID_INTEL, 0x3575, PCI_VENDOR_ID_ATI, 0x4c59, 70 { PCI_VENDOR_ID_INTEL, 0x3575, PCI_VENDOR_ID_ATI, 0x4c59,
71 PCI_VENDOR_ID_DELL, 0x00e3, 2}, 71 PCI_VENDOR_ID_DELL, 0x00e3, 2},
72 /* Intel 82852/82855 host bridge / Mobility FireGL 9000 R250 Needs AGPMode 1 (lp #296617) */ 72 /* Intel 82852/82855 host bridge / Mobility FireGL 9000 RV250 Needs AGPMode 1 (lp #296617) */
73 { PCI_VENDOR_ID_INTEL, 0x3580, PCI_VENDOR_ID_ATI, 0x4c66, 73 { PCI_VENDOR_ID_INTEL, 0x3580, PCI_VENDOR_ID_ATI, 0x4c66,
74 PCI_VENDOR_ID_DELL, 0x0149, 1}, 74 PCI_VENDOR_ID_DELL, 0x0149, 1},
75 /* Intel 82855PM host bridge / Mobility FireGL 9000 RV250 Needs AGPMode 1 for suspend/resume */
76 { PCI_VENDOR_ID_INTEL, 0x3340, PCI_VENDOR_ID_ATI, 0x4c66,
77 PCI_VENDOR_ID_IBM, 0x0531, 1},
75 /* Intel 82852/82855 host bridge / Mobility 9600 M10 RV350 Needs AGPMode 1 (deb #467460) */ 78 /* Intel 82852/82855 host bridge / Mobility 9600 M10 RV350 Needs AGPMode 1 (deb #467460) */
76 { PCI_VENDOR_ID_INTEL, 0x3580, PCI_VENDOR_ID_ATI, 0x4e50, 79 { PCI_VENDOR_ID_INTEL, 0x3580, PCI_VENDOR_ID_ATI, 0x4e50,
77 0x1025, 0x0061, 1}, 80 0x1025, 0x0061, 1},
diff --git a/drivers/gpu/drm/radeon/radeon_atpx_handler.c b/drivers/gpu/drm/radeon/radeon_atpx_handler.c
index 582e99449c1..15f5ded65e0 100644
--- a/drivers/gpu/drm/radeon/radeon_atpx_handler.c
+++ b/drivers/gpu/drm/radeon/radeon_atpx_handler.c
@@ -87,7 +87,7 @@ static union acpi_object *radeon_atpx_call(acpi_handle handle, int function,
87 atpx_arg_elements[1].integer.value = 0; 87 atpx_arg_elements[1].integer.value = 0;
88 } 88 }
89 89
90 status = acpi_evaluate_object(handle, "ATPX", &atpx_arg, &buffer); 90 status = acpi_evaluate_object(handle, NULL, &atpx_arg, &buffer);
91 91
92 /* Fail only if calling the method fails and ATPX is supported */ 92 /* Fail only if calling the method fails and ATPX is supported */
93 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) { 93 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
@@ -148,7 +148,7 @@ static int radeon_atpx_verify_interface(struct radeon_atpx *atpx)
148 148
149 size = *(u16 *) info->buffer.pointer; 149 size = *(u16 *) info->buffer.pointer;
150 if (size < 8) { 150 if (size < 8) {
151 printk("ATPX buffer is too small: %lu\n", size); 151 printk("ATPX buffer is too small: %zu\n", size);
152 err = -EINVAL; 152 err = -EINVAL;
153 goto out; 153 goto out;
154 } 154 }
@@ -352,9 +352,9 @@ static int radeon_atpx_switchto(enum vga_switcheroo_client_id id)
352} 352}
353 353
354/** 354/**
355 * radeon_atpx_switchto - switch to the requested GPU 355 * radeon_atpx_power_state - power down/up the requested GPU
356 * 356 *
357 * @id: GPU to switch to 357 * @id: GPU to power down/up
358 * @state: requested power state (0 = off, 1 = on) 358 * @state: requested power state (0 = off, 1 = on)
359 * 359 *
360 * Execute the necessary ATPX function to power down/up the discrete GPU 360 * Execute the necessary ATPX function to power down/up the discrete GPU
@@ -373,11 +373,11 @@ static int radeon_atpx_power_state(enum vga_switcheroo_client_id id,
373} 373}
374 374
375/** 375/**
376 * radeon_atpx_pci_probe_handle - look up the ATRM and ATPX handles 376 * radeon_atpx_pci_probe_handle - look up the ATPX handle
377 * 377 *
378 * @pdev: pci device 378 * @pdev: pci device
379 * 379 *
380 * Look up the ATPX and ATRM handles (all asics). 380 * Look up the ATPX handles (all asics).
381 * Returns true if the handles are found, false if not. 381 * Returns true if the handles are found, false if not.
382 */ 382 */
383static bool radeon_atpx_pci_probe_handle(struct pci_dev *pdev) 383static bool radeon_atpx_pci_probe_handle(struct pci_dev *pdev)
diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
index 67cfc1795ec..b884c362a8c 100644
--- a/drivers/gpu/drm/radeon/radeon_connectors.c
+++ b/drivers/gpu/drm/radeon/radeon_connectors.c
@@ -941,7 +941,7 @@ radeon_dvi_detect(struct drm_connector *connector, bool force)
941 struct drm_mode_object *obj; 941 struct drm_mode_object *obj;
942 int i; 942 int i;
943 enum drm_connector_status ret = connector_status_disconnected; 943 enum drm_connector_status ret = connector_status_disconnected;
944 bool dret = false; 944 bool dret = false, broken_edid = false;
945 945
946 if (!force && radeon_check_hpd_status_unchanged(connector)) 946 if (!force && radeon_check_hpd_status_unchanged(connector))
947 return connector->status; 947 return connector->status;
@@ -965,6 +965,9 @@ radeon_dvi_detect(struct drm_connector *connector, bool force)
965 ret = connector_status_disconnected; 965 ret = connector_status_disconnected;
966 DRM_ERROR("%s: detected RS690 floating bus bug, stopping ddc detect\n", drm_get_connector_name(connector)); 966 DRM_ERROR("%s: detected RS690 floating bus bug, stopping ddc detect\n", drm_get_connector_name(connector));
967 radeon_connector->ddc_bus = NULL; 967 radeon_connector->ddc_bus = NULL;
968 } else {
969 ret = connector_status_connected;
970 broken_edid = true; /* defer use_digital to later */
968 } 971 }
969 } else { 972 } else {
970 radeon_connector->use_digital = !!(radeon_connector->edid->input & DRM_EDID_INPUT_DIGITAL); 973 radeon_connector->use_digital = !!(radeon_connector->edid->input & DRM_EDID_INPUT_DIGITAL);
@@ -1047,13 +1050,24 @@ radeon_dvi_detect(struct drm_connector *connector, bool force)
1047 1050
1048 encoder_funcs = encoder->helper_private; 1051 encoder_funcs = encoder->helper_private;
1049 if (encoder_funcs->detect) { 1052 if (encoder_funcs->detect) {
1050 if (ret != connector_status_connected) { 1053 if (!broken_edid) {
1051 ret = encoder_funcs->detect(encoder, connector); 1054 if (ret != connector_status_connected) {
1052 if (ret == connector_status_connected) { 1055 /* deal with analog monitors without DDC */
1053 radeon_connector->use_digital = false; 1056 ret = encoder_funcs->detect(encoder, connector);
1057 if (ret == connector_status_connected) {
1058 radeon_connector->use_digital = false;
1059 }
1060 if (ret != connector_status_disconnected)
1061 radeon_connector->detected_by_load = true;
1054 } 1062 }
1055 if (ret != connector_status_disconnected) 1063 } else {
1056 radeon_connector->detected_by_load = true; 1064 enum drm_connector_status lret;
1065 /* assume digital unless load detected otherwise */
1066 radeon_connector->use_digital = true;
1067 lret = encoder_funcs->detect(encoder, connector);
1068 DRM_DEBUG_KMS("load_detect %x returned: %x\n",encoder->encoder_type,lret);
1069 if (lret == connector_status_connected)
1070 radeon_connector->use_digital = false;
1057 } 1071 }
1058 break; 1072 break;
1059 } 1073 }
diff --git a/drivers/gpu/drm/radeon/radeon_cs.c b/drivers/gpu/drm/radeon/radeon_cs.c
index cb7b7c062fe..41672cc563f 100644
--- a/drivers/gpu/drm/radeon/radeon_cs.c
+++ b/drivers/gpu/drm/radeon/radeon_cs.c
@@ -478,6 +478,7 @@ static int radeon_cs_ib_vm_chunk(struct radeon_device *rdev,
478 } 478 }
479 479
480out: 480out:
481 radeon_vm_add_to_lru(rdev, vm);
481 mutex_unlock(&vm->mutex); 482 mutex_unlock(&vm->mutex);
482 mutex_unlock(&rdev->vm_manager.lock); 483 mutex_unlock(&rdev->vm_manager.lock);
483 return r; 484 return r;
diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
index 64a42647f08..e2f5f888c37 100644
--- a/drivers/gpu/drm/radeon/radeon_device.c
+++ b/drivers/gpu/drm/radeon/radeon_device.c
@@ -355,6 +355,8 @@ int radeon_wb_init(struct radeon_device *rdev)
355 */ 355 */
356void radeon_vram_location(struct radeon_device *rdev, struct radeon_mc *mc, u64 base) 356void radeon_vram_location(struct radeon_device *rdev, struct radeon_mc *mc, u64 base)
357{ 357{
358 uint64_t limit = (uint64_t)radeon_vram_limit << 20;
359
358 mc->vram_start = base; 360 mc->vram_start = base;
359 if (mc->mc_vram_size > (0xFFFFFFFF - base + 1)) { 361 if (mc->mc_vram_size > (0xFFFFFFFF - base + 1)) {
360 dev_warn(rdev->dev, "limiting VRAM to PCI aperture size\n"); 362 dev_warn(rdev->dev, "limiting VRAM to PCI aperture size\n");
@@ -368,8 +370,8 @@ void radeon_vram_location(struct radeon_device *rdev, struct radeon_mc *mc, u64
368 mc->mc_vram_size = mc->aper_size; 370 mc->mc_vram_size = mc->aper_size;
369 } 371 }
370 mc->vram_end = mc->vram_start + mc->mc_vram_size - 1; 372 mc->vram_end = mc->vram_start + mc->mc_vram_size - 1;
371 if (radeon_vram_limit && radeon_vram_limit < mc->real_vram_size) 373 if (limit && limit < mc->real_vram_size)
372 mc->real_vram_size = radeon_vram_limit; 374 mc->real_vram_size = limit;
373 dev_info(rdev->dev, "VRAM: %lluM 0x%016llX - 0x%016llX (%lluM used)\n", 375 dev_info(rdev->dev, "VRAM: %lluM 0x%016llX - 0x%016llX (%lluM used)\n",
374 mc->mc_vram_size >> 20, mc->vram_start, 376 mc->mc_vram_size >> 20, mc->vram_start,
375 mc->vram_end, mc->real_vram_size >> 20); 377 mc->vram_end, mc->real_vram_size >> 20);
@@ -835,6 +837,19 @@ static unsigned int radeon_vga_set_decode(void *cookie, bool state)
835} 837}
836 838
837/** 839/**
840 * radeon_check_pot_argument - check that argument is a power of two
841 *
842 * @arg: value to check
843 *
844 * Validates that a certain argument is a power of two (all asics).
845 * Returns true if argument is valid.
846 */
847static bool radeon_check_pot_argument(int arg)
848{
849 return (arg & (arg - 1)) == 0;
850}
851
852/**
838 * radeon_check_arguments - validate module params 853 * radeon_check_arguments - validate module params
839 * 854 *
840 * @rdev: radeon_device pointer 855 * @rdev: radeon_device pointer
@@ -845,52 +860,25 @@ static unsigned int radeon_vga_set_decode(void *cookie, bool state)
845static void radeon_check_arguments(struct radeon_device *rdev) 860static void radeon_check_arguments(struct radeon_device *rdev)
846{ 861{
847 /* vramlimit must be a power of two */ 862 /* vramlimit must be a power of two */
848 switch (radeon_vram_limit) { 863 if (!radeon_check_pot_argument(radeon_vram_limit)) {
849 case 0:
850 case 4:
851 case 8:
852 case 16:
853 case 32:
854 case 64:
855 case 128:
856 case 256:
857 case 512:
858 case 1024:
859 case 2048:
860 case 4096:
861 break;
862 default:
863 dev_warn(rdev->dev, "vram limit (%d) must be a power of 2\n", 864 dev_warn(rdev->dev, "vram limit (%d) must be a power of 2\n",
864 radeon_vram_limit); 865 radeon_vram_limit);
865 radeon_vram_limit = 0; 866 radeon_vram_limit = 0;
866 break;
867 } 867 }
868 radeon_vram_limit = radeon_vram_limit << 20; 868
869 /* gtt size must be power of two and greater or equal to 32M */ 869 /* gtt size must be power of two and greater or equal to 32M */
870 switch (radeon_gart_size) { 870 if (radeon_gart_size < 32) {
871 case 4:
872 case 8:
873 case 16:
874 dev_warn(rdev->dev, "gart size (%d) too small forcing to 512M\n", 871 dev_warn(rdev->dev, "gart size (%d) too small forcing to 512M\n",
875 radeon_gart_size); 872 radeon_gart_size);
876 radeon_gart_size = 512; 873 radeon_gart_size = 512;
877 break; 874
878 case 32: 875 } else if (!radeon_check_pot_argument(radeon_gart_size)) {
879 case 64:
880 case 128:
881 case 256:
882 case 512:
883 case 1024:
884 case 2048:
885 case 4096:
886 break;
887 default:
888 dev_warn(rdev->dev, "gart size (%d) must be a power of 2\n", 876 dev_warn(rdev->dev, "gart size (%d) must be a power of 2\n",
889 radeon_gart_size); 877 radeon_gart_size);
890 radeon_gart_size = 512; 878 radeon_gart_size = 512;
891 break;
892 } 879 }
893 rdev->mc.gtt_size = radeon_gart_size * 1024 * 1024; 880 rdev->mc.gtt_size = (uint64_t)radeon_gart_size << 20;
881
894 /* AGP mode can only be -1, 1, 2, 4, 8 */ 882 /* AGP mode can only be -1, 1, 2, 4, 8 */
895 switch (radeon_agpmode) { 883 switch (radeon_agpmode) {
896 case -1: 884 case -1:
@@ -1018,6 +1006,10 @@ int radeon_device_init(struct radeon_device *rdev,
1018 return r; 1006 return r;
1019 /* initialize vm here */ 1007 /* initialize vm here */
1020 mutex_init(&rdev->vm_manager.lock); 1008 mutex_init(&rdev->vm_manager.lock);
1009 /* Adjust VM size here.
1010 * Currently set to 4GB ((1 << 20) 4k pages).
1011 * Max GPUVM size for cayman and SI is 40 bits.
1012 */
1021 rdev->vm_manager.max_pfn = 1 << 20; 1013 rdev->vm_manager.max_pfn = 1 << 20;
1022 INIT_LIST_HEAD(&rdev->vm_manager.lru_vm); 1014 INIT_LIST_HEAD(&rdev->vm_manager.lru_vm);
1023 1015
diff --git a/drivers/gpu/drm/radeon/radeon_gart.c b/drivers/gpu/drm/radeon/radeon_gart.c
index f0c06d196b7..4debd60e5aa 100644
--- a/drivers/gpu/drm/radeon/radeon_gart.c
+++ b/drivers/gpu/drm/radeon/radeon_gart.c
@@ -355,14 +355,13 @@ int radeon_gart_init(struct radeon_device *rdev)
355 DRM_INFO("GART: num cpu pages %u, num gpu pages %u\n", 355 DRM_INFO("GART: num cpu pages %u, num gpu pages %u\n",
356 rdev->gart.num_cpu_pages, rdev->gart.num_gpu_pages); 356 rdev->gart.num_cpu_pages, rdev->gart.num_gpu_pages);
357 /* Allocate pages table */ 357 /* Allocate pages table */
358 rdev->gart.pages = kzalloc(sizeof(void *) * rdev->gart.num_cpu_pages, 358 rdev->gart.pages = vzalloc(sizeof(void *) * rdev->gart.num_cpu_pages);
359 GFP_KERNEL);
360 if (rdev->gart.pages == NULL) { 359 if (rdev->gart.pages == NULL) {
361 radeon_gart_fini(rdev); 360 radeon_gart_fini(rdev);
362 return -ENOMEM; 361 return -ENOMEM;
363 } 362 }
364 rdev->gart.pages_addr = kzalloc(sizeof(dma_addr_t) * 363 rdev->gart.pages_addr = vzalloc(sizeof(dma_addr_t) *
365 rdev->gart.num_cpu_pages, GFP_KERNEL); 364 rdev->gart.num_cpu_pages);
366 if (rdev->gart.pages_addr == NULL) { 365 if (rdev->gart.pages_addr == NULL) {
367 radeon_gart_fini(rdev); 366 radeon_gart_fini(rdev);
368 return -ENOMEM; 367 return -ENOMEM;
@@ -388,8 +387,8 @@ void radeon_gart_fini(struct radeon_device *rdev)
388 radeon_gart_unbind(rdev, 0, rdev->gart.num_cpu_pages); 387 radeon_gart_unbind(rdev, 0, rdev->gart.num_cpu_pages);
389 } 388 }
390 rdev->gart.ready = false; 389 rdev->gart.ready = false;
391 kfree(rdev->gart.pages); 390 vfree(rdev->gart.pages);
392 kfree(rdev->gart.pages_addr); 391 vfree(rdev->gart.pages_addr);
393 rdev->gart.pages = NULL; 392 rdev->gart.pages = NULL;
394 rdev->gart.pages_addr = NULL; 393 rdev->gart.pages_addr = NULL;
395 394
@@ -423,6 +422,18 @@ void radeon_gart_fini(struct radeon_device *rdev)
423 */ 422 */
424 423
425/** 424/**
425 * radeon_vm_num_pde - return the number of page directory entries
426 *
427 * @rdev: radeon_device pointer
428 *
429 * Calculate the number of page directory entries (cayman+).
430 */
431static unsigned radeon_vm_num_pdes(struct radeon_device *rdev)
432{
433 return rdev->vm_manager.max_pfn >> RADEON_VM_BLOCK_SIZE;
434}
435
436/**
426 * radeon_vm_directory_size - returns the size of the page directory in bytes 437 * radeon_vm_directory_size - returns the size of the page directory in bytes
427 * 438 *
428 * @rdev: radeon_device pointer 439 * @rdev: radeon_device pointer
@@ -431,7 +442,7 @@ void radeon_gart_fini(struct radeon_device *rdev)
431 */ 442 */
432static unsigned radeon_vm_directory_size(struct radeon_device *rdev) 443static unsigned radeon_vm_directory_size(struct radeon_device *rdev)
433{ 444{
434 return (rdev->vm_manager.max_pfn >> RADEON_VM_BLOCK_SIZE) * 8; 445 return RADEON_GPU_PAGE_ALIGN(radeon_vm_num_pdes(rdev) * 8);
435} 446}
436 447
437/** 448/**
@@ -451,11 +462,11 @@ int radeon_vm_manager_init(struct radeon_device *rdev)
451 462
452 if (!rdev->vm_manager.enabled) { 463 if (!rdev->vm_manager.enabled) {
453 /* allocate enough for 2 full VM pts */ 464 /* allocate enough for 2 full VM pts */
454 size = RADEON_GPU_PAGE_ALIGN(radeon_vm_directory_size(rdev)); 465 size = radeon_vm_directory_size(rdev);
455 size += RADEON_GPU_PAGE_ALIGN(rdev->vm_manager.max_pfn * 8); 466 size += rdev->vm_manager.max_pfn * 8;
456 size *= 2; 467 size *= 2;
457 r = radeon_sa_bo_manager_init(rdev, &rdev->vm_manager.sa_manager, 468 r = radeon_sa_bo_manager_init(rdev, &rdev->vm_manager.sa_manager,
458 size, 469 RADEON_GPU_PAGE_ALIGN(size),
459 RADEON_GEM_DOMAIN_VRAM); 470 RADEON_GEM_DOMAIN_VRAM);
460 if (r) { 471 if (r) {
461 dev_err(rdev->dev, "failed to allocate vm bo (%dKB)\n", 472 dev_err(rdev->dev, "failed to allocate vm bo (%dKB)\n",
@@ -476,7 +487,7 @@ int radeon_vm_manager_init(struct radeon_device *rdev)
476 487
477 /* restore page table */ 488 /* restore page table */
478 list_for_each_entry(vm, &rdev->vm_manager.lru_vm, list) { 489 list_for_each_entry(vm, &rdev->vm_manager.lru_vm, list) {
479 if (vm->sa_bo == NULL) 490 if (vm->page_directory == NULL)
480 continue; 491 continue;
481 492
482 list_for_each_entry(bo_va, &vm->va, vm_list) { 493 list_for_each_entry(bo_va, &vm->va, vm_list) {
@@ -500,16 +511,25 @@ static void radeon_vm_free_pt(struct radeon_device *rdev,
500 struct radeon_vm *vm) 511 struct radeon_vm *vm)
501{ 512{
502 struct radeon_bo_va *bo_va; 513 struct radeon_bo_va *bo_va;
514 int i;
503 515
504 if (!vm->sa_bo) 516 if (!vm->page_directory)
505 return; 517 return;
506 518
507 list_del_init(&vm->list); 519 list_del_init(&vm->list);
508 radeon_sa_bo_free(rdev, &vm->sa_bo, vm->fence); 520 radeon_sa_bo_free(rdev, &vm->page_directory, vm->fence);
509 521
510 list_for_each_entry(bo_va, &vm->va, vm_list) { 522 list_for_each_entry(bo_va, &vm->va, vm_list) {
511 bo_va->valid = false; 523 bo_va->valid = false;
512 } 524 }
525
526 if (vm->page_tables == NULL)
527 return;
528
529 for (i = 0; i < radeon_vm_num_pdes(rdev); i++)
530 radeon_sa_bo_free(rdev, &vm->page_tables[i], vm->fence);
531
532 kfree(vm->page_tables);
513} 533}
514 534
515/** 535/**
@@ -546,63 +566,106 @@ void radeon_vm_manager_fini(struct radeon_device *rdev)
546} 566}
547 567
548/** 568/**
569 * radeon_vm_evict - evict page table to make room for new one
570 *
571 * @rdev: radeon_device pointer
572 * @vm: VM we want to allocate something for
573 *
574 * Evict a VM from the lru, making sure that it isn't @vm. (cayman+).
575 * Returns 0 for success, -ENOMEM for failure.
576 *
577 * Global and local mutex must be locked!
578 */
579static int radeon_vm_evict(struct radeon_device *rdev, struct radeon_vm *vm)
580{
581 struct radeon_vm *vm_evict;
582
583 if (list_empty(&rdev->vm_manager.lru_vm))
584 return -ENOMEM;
585
586 vm_evict = list_first_entry(&rdev->vm_manager.lru_vm,
587 struct radeon_vm, list);
588 if (vm_evict == vm)
589 return -ENOMEM;
590
591 mutex_lock(&vm_evict->mutex);
592 radeon_vm_free_pt(rdev, vm_evict);
593 mutex_unlock(&vm_evict->mutex);
594 return 0;
595}
596
597/**
549 * radeon_vm_alloc_pt - allocates a page table for a VM 598 * radeon_vm_alloc_pt - allocates a page table for a VM
550 * 599 *
551 * @rdev: radeon_device pointer 600 * @rdev: radeon_device pointer
552 * @vm: vm to bind 601 * @vm: vm to bind
553 * 602 *
554 * Allocate a page table for the requested vm (cayman+). 603 * Allocate a page table for the requested vm (cayman+).
555 * Also starts to populate the page table.
556 * Returns 0 for success, error for failure. 604 * Returns 0 for success, error for failure.
557 * 605 *
558 * Global and local mutex must be locked! 606 * Global and local mutex must be locked!
559 */ 607 */
560int radeon_vm_alloc_pt(struct radeon_device *rdev, struct radeon_vm *vm) 608int radeon_vm_alloc_pt(struct radeon_device *rdev, struct radeon_vm *vm)
561{ 609{
562 struct radeon_vm *vm_evict; 610 unsigned pd_size, pts_size;
563 int r;
564 u64 *pd_addr; 611 u64 *pd_addr;
565 int tables_size; 612 int r;
566 613
567 if (vm == NULL) { 614 if (vm == NULL) {
568 return -EINVAL; 615 return -EINVAL;
569 } 616 }
570 617
571 /* allocate enough to cover the current VM size */ 618 if (vm->page_directory != NULL) {
572 tables_size = RADEON_GPU_PAGE_ALIGN(radeon_vm_directory_size(rdev));
573 tables_size += RADEON_GPU_PAGE_ALIGN(vm->last_pfn * 8);
574
575 if (vm->sa_bo != NULL) {
576 /* update lru */
577 list_del_init(&vm->list);
578 list_add_tail(&vm->list, &rdev->vm_manager.lru_vm);
579 return 0; 619 return 0;
580 } 620 }
581 621
582retry: 622retry:
583 r = radeon_sa_bo_new(rdev, &rdev->vm_manager.sa_manager, &vm->sa_bo, 623 pd_size = RADEON_GPU_PAGE_ALIGN(radeon_vm_directory_size(rdev));
584 tables_size, RADEON_GPU_PAGE_SIZE, false); 624 r = radeon_sa_bo_new(rdev, &rdev->vm_manager.sa_manager,
625 &vm->page_directory, pd_size,
626 RADEON_GPU_PAGE_SIZE, false);
585 if (r == -ENOMEM) { 627 if (r == -ENOMEM) {
586 if (list_empty(&rdev->vm_manager.lru_vm)) { 628 r = radeon_vm_evict(rdev, vm);
629 if (r)
587 return r; 630 return r;
588 }
589 vm_evict = list_first_entry(&rdev->vm_manager.lru_vm, struct radeon_vm, list);
590 mutex_lock(&vm_evict->mutex);
591 radeon_vm_free_pt(rdev, vm_evict);
592 mutex_unlock(&vm_evict->mutex);
593 goto retry; 631 goto retry;
594 632
595 } else if (r) { 633 } else if (r) {
596 return r; 634 return r;
597 } 635 }
598 636
599 pd_addr = radeon_sa_bo_cpu_addr(vm->sa_bo); 637 vm->pd_gpu_addr = radeon_sa_bo_gpu_addr(vm->page_directory);
600 vm->pd_gpu_addr = radeon_sa_bo_gpu_addr(vm->sa_bo); 638
601 memset(pd_addr, 0, tables_size); 639 /* Initially clear the page directory */
640 pd_addr = radeon_sa_bo_cpu_addr(vm->page_directory);
641 memset(pd_addr, 0, pd_size);
642
643 pts_size = radeon_vm_num_pdes(rdev) * sizeof(struct radeon_sa_bo *);
644 vm->page_tables = kzalloc(pts_size, GFP_KERNEL);
645
646 if (vm->page_tables == NULL) {
647 DRM_ERROR("Cannot allocate memory for page table array\n");
648 radeon_sa_bo_free(rdev, &vm->page_directory, vm->fence);
649 return -ENOMEM;
650 }
651
652 return 0;
653}
602 654
655/**
656 * radeon_vm_add_to_lru - add VMs page table to LRU list
657 *
658 * @rdev: radeon_device pointer
659 * @vm: vm to add to LRU
660 *
661 * Add the allocated page table to the LRU list (cayman+).
662 *
663 * Global mutex must be locked!
664 */
665void radeon_vm_add_to_lru(struct radeon_device *rdev, struct radeon_vm *vm)
666{
667 list_del_init(&vm->list);
603 list_add_tail(&vm->list, &rdev->vm_manager.lru_vm); 668 list_add_tail(&vm->list, &rdev->vm_manager.lru_vm);
604 return radeon_vm_bo_update_pte(rdev, vm, rdev->ring_tmp_bo.bo,
605 &rdev->ring_tmp_bo.bo->tbo.mem);
606} 669}
607 670
608/** 671/**
@@ -793,20 +856,6 @@ int radeon_vm_bo_set_addr(struct radeon_device *rdev,
793 } 856 }
794 857
795 mutex_lock(&vm->mutex); 858 mutex_lock(&vm->mutex);
796 if (last_pfn > vm->last_pfn) {
797 /* release mutex and lock in right order */
798 mutex_unlock(&vm->mutex);
799 mutex_lock(&rdev->vm_manager.lock);
800 mutex_lock(&vm->mutex);
801 /* and check again */
802 if (last_pfn > vm->last_pfn) {
803 /* grow va space 32M by 32M */
804 unsigned align = ((32 << 20) >> 12) - 1;
805 radeon_vm_free_pt(rdev, vm);
806 vm->last_pfn = (last_pfn + align) & ~align;
807 }
808 mutex_unlock(&rdev->vm_manager.lock);
809 }
810 head = &vm->va; 859 head = &vm->va;
811 last_offset = 0; 860 last_offset = 0;
812 list_for_each_entry(tmp, &vm->va, vm_list) { 861 list_for_each_entry(tmp, &vm->va, vm_list) {
@@ -865,6 +914,154 @@ uint64_t radeon_vm_map_gart(struct radeon_device *rdev, uint64_t addr)
865} 914}
866 915
867/** 916/**
917 * radeon_vm_update_pdes - make sure that page directory is valid
918 *
919 * @rdev: radeon_device pointer
920 * @vm: requested vm
921 * @start: start of GPU address range
922 * @end: end of GPU address range
923 *
924 * Allocates new page tables if necessary
925 * and updates the page directory (cayman+).
926 * Returns 0 for success, error for failure.
927 *
928 * Global and local mutex must be locked!
929 */
930static int radeon_vm_update_pdes(struct radeon_device *rdev,
931 struct radeon_vm *vm,
932 uint64_t start, uint64_t end)
933{
934 static const uint32_t incr = RADEON_VM_PTE_COUNT * 8;
935
936 uint64_t last_pde = ~0, last_pt = ~0;
937 unsigned count = 0;
938 uint64_t pt_idx;
939 int r;
940
941 start = (start / RADEON_GPU_PAGE_SIZE) >> RADEON_VM_BLOCK_SIZE;
942 end = (end / RADEON_GPU_PAGE_SIZE) >> RADEON_VM_BLOCK_SIZE;
943
944 /* walk over the address space and update the page directory */
945 for (pt_idx = start; pt_idx <= end; ++pt_idx) {
946 uint64_t pde, pt;
947
948 if (vm->page_tables[pt_idx])
949 continue;
950
951retry:
952 r = radeon_sa_bo_new(rdev, &rdev->vm_manager.sa_manager,
953 &vm->page_tables[pt_idx],
954 RADEON_VM_PTE_COUNT * 8,
955 RADEON_GPU_PAGE_SIZE, false);
956
957 if (r == -ENOMEM) {
958 r = radeon_vm_evict(rdev, vm);
959 if (r)
960 return r;
961 goto retry;
962 } else if (r) {
963 return r;
964 }
965
966 pde = vm->pd_gpu_addr + pt_idx * 8;
967
968 pt = radeon_sa_bo_gpu_addr(vm->page_tables[pt_idx]);
969
970 if (((last_pde + 8 * count) != pde) ||
971 ((last_pt + incr * count) != pt)) {
972
973 if (count) {
974 radeon_asic_vm_set_page(rdev, last_pde,
975 last_pt, count, incr,
976 RADEON_VM_PAGE_VALID);
977 }
978
979 count = 1;
980 last_pde = pde;
981 last_pt = pt;
982 } else {
983 ++count;
984 }
985 }
986
987 if (count) {
988 radeon_asic_vm_set_page(rdev, last_pde, last_pt, count,
989 incr, RADEON_VM_PAGE_VALID);
990
991 }
992
993 return 0;
994}
995
996/**
997 * radeon_vm_update_ptes - make sure that page tables are valid
998 *
999 * @rdev: radeon_device pointer
1000 * @vm: requested vm
1001 * @start: start of GPU address range
1002 * @end: end of GPU address range
1003 * @dst: destination address to map to
1004 * @flags: mapping flags
1005 *
1006 * Update the page tables in the range @start - @end (cayman+).
1007 *
1008 * Global and local mutex must be locked!
1009 */
1010static void radeon_vm_update_ptes(struct radeon_device *rdev,
1011 struct radeon_vm *vm,
1012 uint64_t start, uint64_t end,
1013 uint64_t dst, uint32_t flags)
1014{
1015 static const uint64_t mask = RADEON_VM_PTE_COUNT - 1;
1016
1017 uint64_t last_pte = ~0, last_dst = ~0;
1018 unsigned count = 0;
1019 uint64_t addr;
1020
1021 start = start / RADEON_GPU_PAGE_SIZE;
1022 end = end / RADEON_GPU_PAGE_SIZE;
1023
1024 /* walk over the address space and update the page tables */
1025 for (addr = start; addr < end; ) {
1026 uint64_t pt_idx = addr >> RADEON_VM_BLOCK_SIZE;
1027 unsigned nptes;
1028 uint64_t pte;
1029
1030 if ((addr & ~mask) == (end & ~mask))
1031 nptes = end - addr;
1032 else
1033 nptes = RADEON_VM_PTE_COUNT - (addr & mask);
1034
1035 pte = radeon_sa_bo_gpu_addr(vm->page_tables[pt_idx]);
1036 pte += (addr & mask) * 8;
1037
1038 if ((last_pte + 8 * count) != pte) {
1039
1040 if (count) {
1041 radeon_asic_vm_set_page(rdev, last_pte,
1042 last_dst, count,
1043 RADEON_GPU_PAGE_SIZE,
1044 flags);
1045 }
1046
1047 count = nptes;
1048 last_pte = pte;
1049 last_dst = dst;
1050 } else {
1051 count += nptes;
1052 }
1053
1054 addr += nptes;
1055 dst += nptes * RADEON_GPU_PAGE_SIZE;
1056 }
1057
1058 if (count) {
1059 radeon_asic_vm_set_page(rdev, last_pte, last_dst, count,
1060 RADEON_GPU_PAGE_SIZE, flags);
1061 }
1062}
1063
1064/**
868 * radeon_vm_bo_update_pte - map a bo into the vm page table 1065 * radeon_vm_bo_update_pte - map a bo into the vm page table
869 * 1066 *
870 * @rdev: radeon_device pointer 1067 * @rdev: radeon_device pointer
@@ -887,12 +1084,11 @@ int radeon_vm_bo_update_pte(struct radeon_device *rdev,
887 struct radeon_semaphore *sem = NULL; 1084 struct radeon_semaphore *sem = NULL;
888 struct radeon_bo_va *bo_va; 1085 struct radeon_bo_va *bo_va;
889 unsigned nptes, npdes, ndw; 1086 unsigned nptes, npdes, ndw;
890 uint64_t pe, addr; 1087 uint64_t addr;
891 uint64_t pfn;
892 int r; 1088 int r;
893 1089
894 /* nothing to do if vm isn't bound */ 1090 /* nothing to do if vm isn't bound */
895 if (vm->sa_bo == NULL) 1091 if (vm->page_directory == NULL)
896 return 0; 1092 return 0;
897 1093
898 bo_va = radeon_vm_bo_find(vm, bo); 1094 bo_va = radeon_vm_bo_find(vm, bo);
@@ -939,25 +1135,29 @@ int radeon_vm_bo_update_pte(struct radeon_device *rdev,
939 } 1135 }
940 } 1136 }
941 1137
942 /* estimate number of dw needed */
943 /* reserve space for 32-bit padding */
944 ndw = 32;
945
946 nptes = radeon_bo_ngpu_pages(bo); 1138 nptes = radeon_bo_ngpu_pages(bo);
947 1139
948 pfn = (bo_va->soffset / RADEON_GPU_PAGE_SIZE); 1140 /* assume two extra pdes in case the mapping overlaps the borders */
1141 npdes = (nptes >> RADEON_VM_BLOCK_SIZE) + 2;
949 1142
950 /* handle cases where a bo spans several pdes */ 1143 /* estimate number of dw needed */
951 npdes = (ALIGN(pfn + nptes, RADEON_VM_PTE_COUNT) - 1144 /* semaphore, fence and padding */
952 (pfn & ~(RADEON_VM_PTE_COUNT - 1))) >> RADEON_VM_BLOCK_SIZE; 1145 ndw = 32;
1146
1147 if (RADEON_VM_BLOCK_SIZE > 11)
1148 /* reserve space for one header for every 2k dwords */
1149 ndw += (nptes >> 11) * 4;
1150 else
1151 /* reserve space for one header for
1152 every (1 << BLOCK_SIZE) entries */
1153 ndw += (nptes >> RADEON_VM_BLOCK_SIZE) * 4;
953 1154
954 /* reserve space for one header for every 2k dwords */
955 ndw += (nptes >> 11) * 3;
956 /* reserve space for pte addresses */ 1155 /* reserve space for pte addresses */
957 ndw += nptes * 2; 1156 ndw += nptes * 2;
958 1157
959 /* reserve space for one header for every 2k dwords */ 1158 /* reserve space for one header for every 2k dwords */
960 ndw += (npdes >> 11) * 3; 1159 ndw += (npdes >> 11) * 4;
1160
961 /* reserve space for pde addresses */ 1161 /* reserve space for pde addresses */
962 ndw += npdes * 2; 1162 ndw += npdes * 2;
963 1163
@@ -971,22 +1171,14 @@ int radeon_vm_bo_update_pte(struct radeon_device *rdev,
971 radeon_fence_note_sync(vm->fence, ridx); 1171 radeon_fence_note_sync(vm->fence, ridx);
972 } 1172 }
973 1173
974 /* update page table entries */ 1174 r = radeon_vm_update_pdes(rdev, vm, bo_va->soffset, bo_va->eoffset);
975 pe = vm->pd_gpu_addr; 1175 if (r) {
976 pe += radeon_vm_directory_size(rdev); 1176 radeon_ring_unlock_undo(rdev, ring);
977 pe += (bo_va->soffset / RADEON_GPU_PAGE_SIZE) * 8; 1177 return r;
978 1178 }
979 radeon_asic_vm_set_page(rdev, pe, addr, nptes,
980 RADEON_GPU_PAGE_SIZE, bo_va->flags);
981
982 /* update page directory entries */
983 addr = pe;
984
985 pe = vm->pd_gpu_addr;
986 pe += ((bo_va->soffset / RADEON_GPU_PAGE_SIZE) >> RADEON_VM_BLOCK_SIZE) * 8;
987 1179
988 radeon_asic_vm_set_page(rdev, pe, addr, npdes, 1180 radeon_vm_update_ptes(rdev, vm, bo_va->soffset, bo_va->eoffset,
989 RADEON_VM_PTE_COUNT * 8, RADEON_VM_PAGE_VALID); 1181 addr, bo_va->flags);
990 1182
991 radeon_fence_unref(&vm->fence); 1183 radeon_fence_unref(&vm->fence);
992 r = radeon_fence_emit(rdev, &vm->fence, ridx); 1184 r = radeon_fence_emit(rdev, &vm->fence, ridx);
@@ -997,6 +1189,7 @@ int radeon_vm_bo_update_pte(struct radeon_device *rdev,
997 radeon_ring_unlock_commit(rdev, ring); 1189 radeon_ring_unlock_commit(rdev, ring);
998 radeon_semaphore_free(rdev, &sem, vm->fence); 1190 radeon_semaphore_free(rdev, &sem, vm->fence);
999 radeon_fence_unref(&vm->last_flush); 1191 radeon_fence_unref(&vm->last_flush);
1192
1000 return 0; 1193 return 0;
1001} 1194}
1002 1195
@@ -1056,31 +1249,15 @@ void radeon_vm_bo_invalidate(struct radeon_device *rdev,
1056 * @rdev: radeon_device pointer 1249 * @rdev: radeon_device pointer
1057 * @vm: requested vm 1250 * @vm: requested vm
1058 * 1251 *
1059 * Init @vm (cayman+). 1252 * Init @vm fields (cayman+).
1060 * Map the IB pool and any other shared objects into the VM
1061 * by default as it's used by all VMs.
1062 * Returns 0 for success, error for failure.
1063 */ 1253 */
1064int radeon_vm_init(struct radeon_device *rdev, struct radeon_vm *vm) 1254void radeon_vm_init(struct radeon_device *rdev, struct radeon_vm *vm)
1065{ 1255{
1066 struct radeon_bo_va *bo_va;
1067 int r;
1068
1069 vm->id = 0; 1256 vm->id = 0;
1070 vm->fence = NULL; 1257 vm->fence = NULL;
1071 vm->last_pfn = 0;
1072 mutex_init(&vm->mutex); 1258 mutex_init(&vm->mutex);
1073 INIT_LIST_HEAD(&vm->list); 1259 INIT_LIST_HEAD(&vm->list);
1074 INIT_LIST_HEAD(&vm->va); 1260 INIT_LIST_HEAD(&vm->va);
1075
1076 /* map the ib pool buffer at 0 in virtual address space, set
1077 * read only
1078 */
1079 bo_va = radeon_vm_bo_add(rdev, vm, rdev->ring_tmp_bo.bo);
1080 r = radeon_vm_bo_set_addr(rdev, bo_va, RADEON_VA_IB_OFFSET,
1081 RADEON_VM_PAGE_READABLE |
1082 RADEON_VM_PAGE_SNOOPED);
1083 return r;
1084} 1261}
1085 1262
1086/** 1263/**
@@ -1102,17 +1279,6 @@ void radeon_vm_fini(struct radeon_device *rdev, struct radeon_vm *vm)
1102 radeon_vm_free_pt(rdev, vm); 1279 radeon_vm_free_pt(rdev, vm);
1103 mutex_unlock(&rdev->vm_manager.lock); 1280 mutex_unlock(&rdev->vm_manager.lock);
1104 1281
1105 /* remove all bo at this point non are busy any more because unbind
1106 * waited for the last vm fence to signal
1107 */
1108 r = radeon_bo_reserve(rdev->ring_tmp_bo.bo, false);
1109 if (!r) {
1110 bo_va = radeon_vm_bo_find(vm, rdev->ring_tmp_bo.bo);
1111 list_del_init(&bo_va->bo_list);
1112 list_del_init(&bo_va->vm_list);
1113 radeon_bo_unreserve(rdev->ring_tmp_bo.bo);
1114 kfree(bo_va);
1115 }
1116 if (!list_empty(&vm->va)) { 1282 if (!list_empty(&vm->va)) {
1117 dev_err(rdev->dev, "still active bo inside vm\n"); 1283 dev_err(rdev->dev, "still active bo inside vm\n");
1118 } 1284 }
diff --git a/drivers/gpu/drm/radeon/radeon_gem.c b/drivers/gpu/drm/radeon/radeon_gem.c
index f38fbcc4693..fe5c1f6b795 100644
--- a/drivers/gpu/drm/radeon/radeon_gem.c
+++ b/drivers/gpu/drm/radeon/radeon_gem.c
@@ -53,6 +53,7 @@ int radeon_gem_object_create(struct radeon_device *rdev, int size,
53 struct drm_gem_object **obj) 53 struct drm_gem_object **obj)
54{ 54{
55 struct radeon_bo *robj; 55 struct radeon_bo *robj;
56 unsigned long max_size;
56 int r; 57 int r;
57 58
58 *obj = NULL; 59 *obj = NULL;
@@ -60,11 +61,26 @@ int radeon_gem_object_create(struct radeon_device *rdev, int size,
60 if (alignment < PAGE_SIZE) { 61 if (alignment < PAGE_SIZE) {
61 alignment = PAGE_SIZE; 62 alignment = PAGE_SIZE;
62 } 63 }
64
65 /* maximun bo size is the minimun btw visible vram and gtt size */
66 max_size = min(rdev->mc.visible_vram_size, rdev->mc.gtt_size);
67 if (size > max_size) {
68 printk(KERN_WARNING "%s:%d alloc size %dMb bigger than %ldMb limit\n",
69 __func__, __LINE__, size >> 20, max_size >> 20);
70 return -ENOMEM;
71 }
72
73retry:
63 r = radeon_bo_create(rdev, size, alignment, kernel, initial_domain, NULL, &robj); 74 r = radeon_bo_create(rdev, size, alignment, kernel, initial_domain, NULL, &robj);
64 if (r) { 75 if (r) {
65 if (r != -ERESTARTSYS) 76 if (r != -ERESTARTSYS) {
77 if (initial_domain == RADEON_GEM_DOMAIN_VRAM) {
78 initial_domain |= RADEON_GEM_DOMAIN_GTT;
79 goto retry;
80 }
66 DRM_ERROR("Failed to allocate GEM object (%d, %d, %u, %d)\n", 81 DRM_ERROR("Failed to allocate GEM object (%d, %d, %u, %d)\n",
67 size, initial_domain, alignment, r); 82 size, initial_domain, alignment, r);
83 }
68 return r; 84 return r;
69 } 85 }
70 *obj = &robj->gem_base; 86 *obj = &robj->gem_base;
diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c
index 83b8d8aa71c..dc781c49b96 100644
--- a/drivers/gpu/drm/radeon/radeon_kms.c
+++ b/drivers/gpu/drm/radeon/radeon_kms.c
@@ -419,6 +419,7 @@ int radeon_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
419 /* new gpu have virtual address space support */ 419 /* new gpu have virtual address space support */
420 if (rdev->family >= CHIP_CAYMAN) { 420 if (rdev->family >= CHIP_CAYMAN) {
421 struct radeon_fpriv *fpriv; 421 struct radeon_fpriv *fpriv;
422 struct radeon_bo_va *bo_va;
422 int r; 423 int r;
423 424
424 fpriv = kzalloc(sizeof(*fpriv), GFP_KERNEL); 425 fpriv = kzalloc(sizeof(*fpriv), GFP_KERNEL);
@@ -426,7 +427,15 @@ int radeon_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv)
426 return -ENOMEM; 427 return -ENOMEM;
427 } 428 }
428 429
429 r = radeon_vm_init(rdev, &fpriv->vm); 430 radeon_vm_init(rdev, &fpriv->vm);
431
432 /* map the ib pool buffer read only into
433 * virtual address space */
434 bo_va = radeon_vm_bo_add(rdev, &fpriv->vm,
435 rdev->ring_tmp_bo.bo);
436 r = radeon_vm_bo_set_addr(rdev, bo_va, RADEON_VA_IB_OFFSET,
437 RADEON_VM_PAGE_READABLE |
438 RADEON_VM_PAGE_SNOOPED);
430 if (r) { 439 if (r) {
431 radeon_vm_fini(rdev, &fpriv->vm); 440 radeon_vm_fini(rdev, &fpriv->vm);
432 kfree(fpriv); 441 kfree(fpriv);
@@ -454,6 +463,17 @@ void radeon_driver_postclose_kms(struct drm_device *dev,
454 /* new gpu have virtual address space support */ 463 /* new gpu have virtual address space support */
455 if (rdev->family >= CHIP_CAYMAN && file_priv->driver_priv) { 464 if (rdev->family >= CHIP_CAYMAN && file_priv->driver_priv) {
456 struct radeon_fpriv *fpriv = file_priv->driver_priv; 465 struct radeon_fpriv *fpriv = file_priv->driver_priv;
466 struct radeon_bo_va *bo_va;
467 int r;
468
469 r = radeon_bo_reserve(rdev->ring_tmp_bo.bo, false);
470 if (!r) {
471 bo_va = radeon_vm_bo_find(&fpriv->vm,
472 rdev->ring_tmp_bo.bo);
473 if (bo_va)
474 radeon_vm_bo_rmv(rdev, bo_va);
475 radeon_bo_unreserve(rdev->ring_tmp_bo.bo);
476 }
457 477
458 radeon_vm_fini(rdev, &fpriv->vm); 478 radeon_vm_fini(rdev, &fpriv->vm);
459 kfree(fpriv); 479 kfree(fpriv);
diff --git a/drivers/gpu/drm/radeon/radeon_legacy_crtc.c b/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
index 5677a424b58..6857cb4efb7 100644
--- a/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
+++ b/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
@@ -295,6 +295,7 @@ static void radeon_crtc_dpms(struct drm_crtc *crtc, int mode)
295 struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); 295 struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc);
296 struct drm_device *dev = crtc->dev; 296 struct drm_device *dev = crtc->dev;
297 struct radeon_device *rdev = dev->dev_private; 297 struct radeon_device *rdev = dev->dev_private;
298 uint32_t crtc_ext_cntl = 0;
298 uint32_t mask; 299 uint32_t mask;
299 300
300 if (radeon_crtc->crtc_id) 301 if (radeon_crtc->crtc_id)
@@ -307,6 +308,16 @@ static void radeon_crtc_dpms(struct drm_crtc *crtc, int mode)
307 RADEON_CRTC_VSYNC_DIS | 308 RADEON_CRTC_VSYNC_DIS |
308 RADEON_CRTC_HSYNC_DIS); 309 RADEON_CRTC_HSYNC_DIS);
309 310
311 /*
312 * On all dual CRTC GPUs this bit controls the CRTC of the primary DAC.
313 * Therefore it is set in the DAC DMPS function.
314 * This is different for GPU's with a single CRTC but a primary and a
315 * TV DAC: here it controls the single CRTC no matter where it is
316 * routed. Therefore we set it here.
317 */
318 if (rdev->flags & RADEON_SINGLE_CRTC)
319 crtc_ext_cntl = RADEON_CRTC_CRT_ON;
320
310 switch (mode) { 321 switch (mode) {
311 case DRM_MODE_DPMS_ON: 322 case DRM_MODE_DPMS_ON:
312 radeon_crtc->enabled = true; 323 radeon_crtc->enabled = true;
@@ -317,7 +328,7 @@ static void radeon_crtc_dpms(struct drm_crtc *crtc, int mode)
317 else { 328 else {
318 WREG32_P(RADEON_CRTC_GEN_CNTL, RADEON_CRTC_EN, ~(RADEON_CRTC_EN | 329 WREG32_P(RADEON_CRTC_GEN_CNTL, RADEON_CRTC_EN, ~(RADEON_CRTC_EN |
319 RADEON_CRTC_DISP_REQ_EN_B)); 330 RADEON_CRTC_DISP_REQ_EN_B));
320 WREG32_P(RADEON_CRTC_EXT_CNTL, 0, ~mask); 331 WREG32_P(RADEON_CRTC_EXT_CNTL, crtc_ext_cntl, ~(mask | crtc_ext_cntl));
321 } 332 }
322 drm_vblank_post_modeset(dev, radeon_crtc->crtc_id); 333 drm_vblank_post_modeset(dev, radeon_crtc->crtc_id);
323 radeon_crtc_load_lut(crtc); 334 radeon_crtc_load_lut(crtc);
@@ -331,7 +342,7 @@ static void radeon_crtc_dpms(struct drm_crtc *crtc, int mode)
331 else { 342 else {
332 WREG32_P(RADEON_CRTC_GEN_CNTL, RADEON_CRTC_DISP_REQ_EN_B, ~(RADEON_CRTC_EN | 343 WREG32_P(RADEON_CRTC_GEN_CNTL, RADEON_CRTC_DISP_REQ_EN_B, ~(RADEON_CRTC_EN |
333 RADEON_CRTC_DISP_REQ_EN_B)); 344 RADEON_CRTC_DISP_REQ_EN_B));
334 WREG32_P(RADEON_CRTC_EXT_CNTL, mask, ~mask); 345 WREG32_P(RADEON_CRTC_EXT_CNTL, mask, ~(mask | crtc_ext_cntl));
335 } 346 }
336 radeon_crtc->enabled = false; 347 radeon_crtc->enabled = false;
337 /* adjust pm to dpms changes AFTER disabling crtcs */ 348 /* adjust pm to dpms changes AFTER disabling crtcs */
diff --git a/drivers/gpu/drm/radeon/radeon_legacy_encoders.c b/drivers/gpu/drm/radeon/radeon_legacy_encoders.c
index 92487e61477..f5ba2241dac 100644
--- a/drivers/gpu/drm/radeon/radeon_legacy_encoders.c
+++ b/drivers/gpu/drm/radeon/radeon_legacy_encoders.c
@@ -269,27 +269,6 @@ static const struct drm_encoder_helper_funcs radeon_legacy_lvds_helper_funcs = {
269 .disable = radeon_legacy_encoder_disable, 269 .disable = radeon_legacy_encoder_disable,
270}; 270};
271 271
272#if defined(CONFIG_BACKLIGHT_CLASS_DEVICE) || defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE)
273
274static uint8_t radeon_legacy_lvds_level(struct backlight_device *bd)
275{
276 struct radeon_backlight_privdata *pdata = bl_get_data(bd);
277 uint8_t level;
278
279 /* Convert brightness to hardware level */
280 if (bd->props.brightness < 0)
281 level = 0;
282 else if (bd->props.brightness > RADEON_MAX_BL_LEVEL)
283 level = RADEON_MAX_BL_LEVEL;
284 else
285 level = bd->props.brightness;
286
287 if (pdata->negative)
288 level = RADEON_MAX_BL_LEVEL - level;
289
290 return level;
291}
292
293u8 272u8
294radeon_legacy_get_backlight_level(struct radeon_encoder *radeon_encoder) 273radeon_legacy_get_backlight_level(struct radeon_encoder *radeon_encoder)
295{ 274{
@@ -331,6 +310,27 @@ radeon_legacy_set_backlight_level(struct radeon_encoder *radeon_encoder, u8 leve
331 radeon_legacy_lvds_update(&radeon_encoder->base, dpms_mode); 310 radeon_legacy_lvds_update(&radeon_encoder->base, dpms_mode);
332} 311}
333 312
313#if defined(CONFIG_BACKLIGHT_CLASS_DEVICE) || defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE)
314
315static uint8_t radeon_legacy_lvds_level(struct backlight_device *bd)
316{
317 struct radeon_backlight_privdata *pdata = bl_get_data(bd);
318 uint8_t level;
319
320 /* Convert brightness to hardware level */
321 if (bd->props.brightness < 0)
322 level = 0;
323 else if (bd->props.brightness > RADEON_MAX_BL_LEVEL)
324 level = RADEON_MAX_BL_LEVEL;
325 else
326 level = bd->props.brightness;
327
328 if (pdata->negative)
329 level = RADEON_MAX_BL_LEVEL - level;
330
331 return level;
332}
333
334static int radeon_legacy_backlight_update_status(struct backlight_device *bd) 334static int radeon_legacy_backlight_update_status(struct backlight_device *bd)
335{ 335{
336 struct radeon_backlight_privdata *pdata = bl_get_data(bd); 336 struct radeon_backlight_privdata *pdata = bl_get_data(bd);
@@ -370,6 +370,7 @@ void radeon_legacy_backlight_init(struct radeon_encoder *radeon_encoder,
370 struct backlight_properties props; 370 struct backlight_properties props;
371 struct radeon_backlight_privdata *pdata; 371 struct radeon_backlight_privdata *pdata;
372 uint8_t backlight_level; 372 uint8_t backlight_level;
373 char bl_name[16];
373 374
374 if (!radeon_encoder->enc_priv) 375 if (!radeon_encoder->enc_priv)
375 return; 376 return;
@@ -389,7 +390,9 @@ void radeon_legacy_backlight_init(struct radeon_encoder *radeon_encoder,
389 memset(&props, 0, sizeof(props)); 390 memset(&props, 0, sizeof(props));
390 props.max_brightness = RADEON_MAX_BL_LEVEL; 391 props.max_brightness = RADEON_MAX_BL_LEVEL;
391 props.type = BACKLIGHT_RAW; 392 props.type = BACKLIGHT_RAW;
392 bd = backlight_device_register("radeon_bl", &drm_connector->kdev, 393 snprintf(bl_name, sizeof(bl_name),
394 "radeon_bl%d", dev->primary->index);
395 bd = backlight_device_register(bl_name, &drm_connector->kdev,
393 pdata, &radeon_backlight_ops, &props); 396 pdata, &radeon_backlight_ops, &props);
394 if (IS_ERR(bd)) { 397 if (IS_ERR(bd)) {
395 DRM_ERROR("Backlight registration failed\n"); 398 DRM_ERROR("Backlight registration failed\n");
@@ -534,7 +537,9 @@ static void radeon_legacy_primary_dac_dpms(struct drm_encoder *encoder, int mode
534 break; 537 break;
535 } 538 }
536 539
537 WREG32(RADEON_CRTC_EXT_CNTL, crtc_ext_cntl); 540 /* handled in radeon_crtc_dpms() */
541 if (!(rdev->flags & RADEON_SINGLE_CRTC))
542 WREG32(RADEON_CRTC_EXT_CNTL, crtc_ext_cntl);
538 WREG32(RADEON_DAC_CNTL, dac_cntl); 543 WREG32(RADEON_DAC_CNTL, dac_cntl);
539 WREG32(RADEON_DAC_MACRO_CNTL, dac_macro_cntl); 544 WREG32(RADEON_DAC_MACRO_CNTL, dac_macro_cntl);
540 545
@@ -659,6 +664,8 @@ static enum drm_connector_status radeon_legacy_primary_dac_detect(struct drm_enc
659 664
660 if (ASIC_IS_R300(rdev)) 665 if (ASIC_IS_R300(rdev))
661 tmp |= (0x1b6 << RADEON_DAC_FORCE_DATA_SHIFT); 666 tmp |= (0x1b6 << RADEON_DAC_FORCE_DATA_SHIFT);
667 else if (ASIC_IS_RV100(rdev))
668 tmp |= (0x1ac << RADEON_DAC_FORCE_DATA_SHIFT);
662 else 669 else
663 tmp |= (0x180 << RADEON_DAC_FORCE_DATA_SHIFT); 670 tmp |= (0x180 << RADEON_DAC_FORCE_DATA_SHIFT);
664 671
@@ -668,6 +675,7 @@ static enum drm_connector_status radeon_legacy_primary_dac_detect(struct drm_enc
668 tmp |= RADEON_DAC_RANGE_CNTL_PS2 | RADEON_DAC_CMP_EN; 675 tmp |= RADEON_DAC_RANGE_CNTL_PS2 | RADEON_DAC_CMP_EN;
669 WREG32(RADEON_DAC_CNTL, tmp); 676 WREG32(RADEON_DAC_CNTL, tmp);
670 677
678 tmp = dac_macro_cntl;
671 tmp &= ~(RADEON_DAC_PDWN_R | 679 tmp &= ~(RADEON_DAC_PDWN_R |
672 RADEON_DAC_PDWN_G | 680 RADEON_DAC_PDWN_G |
673 RADEON_DAC_PDWN_B); 681 RADEON_DAC_PDWN_B);
@@ -991,11 +999,7 @@ static void radeon_legacy_tmds_ext_mode_set(struct drm_encoder *encoder,
991static void radeon_ext_tmds_enc_destroy(struct drm_encoder *encoder) 999static void radeon_ext_tmds_enc_destroy(struct drm_encoder *encoder)
992{ 1000{
993 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 1001 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
994 struct radeon_encoder_ext_tmds *tmds = radeon_encoder->enc_priv; 1002 /* don't destroy the i2c bus record here, this will be done in radeon_i2c_fini */
995 if (tmds) {
996 if (tmds->i2c_bus)
997 radeon_i2c_destroy(tmds->i2c_bus);
998 }
999 kfree(radeon_encoder->enc_priv); 1003 kfree(radeon_encoder->enc_priv);
1000 drm_encoder_cleanup(encoder); 1004 drm_encoder_cleanup(encoder);
1001 kfree(radeon_encoder); 1005 kfree(radeon_encoder);
@@ -1093,7 +1097,8 @@ static void radeon_legacy_tv_dac_dpms(struct drm_encoder *encoder, int mode)
1093 } else { 1097 } else {
1094 if (is_tv) 1098 if (is_tv)
1095 WREG32(RADEON_TV_MASTER_CNTL, tv_master_cntl); 1099 WREG32(RADEON_TV_MASTER_CNTL, tv_master_cntl);
1096 else 1100 /* handled in radeon_crtc_dpms() */
1101 else if (!(rdev->flags & RADEON_SINGLE_CRTC))
1097 WREG32(RADEON_CRTC2_GEN_CNTL, crtc2_gen_cntl); 1102 WREG32(RADEON_CRTC2_GEN_CNTL, crtc2_gen_cntl);
1098 WREG32(RADEON_TV_DAC_CNTL, tv_dac_cntl); 1103 WREG32(RADEON_TV_DAC_CNTL, tv_dac_cntl);
1099 } 1104 }
@@ -1417,13 +1422,104 @@ static bool radeon_legacy_tv_detect(struct drm_encoder *encoder,
1417 return found; 1422 return found;
1418} 1423}
1419 1424
1425static bool radeon_legacy_ext_dac_detect(struct drm_encoder *encoder,
1426 struct drm_connector *connector)
1427{
1428 struct drm_device *dev = encoder->dev;
1429 struct radeon_device *rdev = dev->dev_private;
1430 uint32_t gpio_monid, fp2_gen_cntl, disp_output_cntl, crtc2_gen_cntl;
1431 uint32_t disp_lin_trans_grph_a, disp_lin_trans_grph_b, disp_lin_trans_grph_c;
1432 uint32_t disp_lin_trans_grph_d, disp_lin_trans_grph_e, disp_lin_trans_grph_f;
1433 uint32_t tmp, crtc2_h_total_disp, crtc2_v_total_disp;
1434 uint32_t crtc2_h_sync_strt_wid, crtc2_v_sync_strt_wid;
1435 bool found = false;
1436 int i;
1437
1438 /* save the regs we need */
1439 gpio_monid = RREG32(RADEON_GPIO_MONID);
1440 fp2_gen_cntl = RREG32(RADEON_FP2_GEN_CNTL);
1441 disp_output_cntl = RREG32(RADEON_DISP_OUTPUT_CNTL);
1442 crtc2_gen_cntl = RREG32(RADEON_CRTC2_GEN_CNTL);
1443 disp_lin_trans_grph_a = RREG32(RADEON_DISP_LIN_TRANS_GRPH_A);
1444 disp_lin_trans_grph_b = RREG32(RADEON_DISP_LIN_TRANS_GRPH_B);
1445 disp_lin_trans_grph_c = RREG32(RADEON_DISP_LIN_TRANS_GRPH_C);
1446 disp_lin_trans_grph_d = RREG32(RADEON_DISP_LIN_TRANS_GRPH_D);
1447 disp_lin_trans_grph_e = RREG32(RADEON_DISP_LIN_TRANS_GRPH_E);
1448 disp_lin_trans_grph_f = RREG32(RADEON_DISP_LIN_TRANS_GRPH_F);
1449 crtc2_h_total_disp = RREG32(RADEON_CRTC2_H_TOTAL_DISP);
1450 crtc2_v_total_disp = RREG32(RADEON_CRTC2_V_TOTAL_DISP);
1451 crtc2_h_sync_strt_wid = RREG32(RADEON_CRTC2_H_SYNC_STRT_WID);
1452 crtc2_v_sync_strt_wid = RREG32(RADEON_CRTC2_V_SYNC_STRT_WID);
1453
1454 tmp = RREG32(RADEON_GPIO_MONID);
1455 tmp &= ~RADEON_GPIO_A_0;
1456 WREG32(RADEON_GPIO_MONID, tmp);
1457
1458 WREG32(RADEON_FP2_GEN_CNTL, (RADEON_FP2_ON |
1459 RADEON_FP2_PANEL_FORMAT |
1460 R200_FP2_SOURCE_SEL_TRANS_UNIT |
1461 RADEON_FP2_DVO_EN |
1462 R200_FP2_DVO_RATE_SEL_SDR));
1463
1464 WREG32(RADEON_DISP_OUTPUT_CNTL, (RADEON_DISP_DAC_SOURCE_RMX |
1465 RADEON_DISP_TRANS_MATRIX_GRAPHICS));
1466
1467 WREG32(RADEON_CRTC2_GEN_CNTL, (RADEON_CRTC2_EN |
1468 RADEON_CRTC2_DISP_REQ_EN_B));
1469
1470 WREG32(RADEON_DISP_LIN_TRANS_GRPH_A, 0x00000000);
1471 WREG32(RADEON_DISP_LIN_TRANS_GRPH_B, 0x000003f0);
1472 WREG32(RADEON_DISP_LIN_TRANS_GRPH_C, 0x00000000);
1473 WREG32(RADEON_DISP_LIN_TRANS_GRPH_D, 0x000003f0);
1474 WREG32(RADEON_DISP_LIN_TRANS_GRPH_E, 0x00000000);
1475 WREG32(RADEON_DISP_LIN_TRANS_GRPH_F, 0x000003f0);
1476
1477 WREG32(RADEON_CRTC2_H_TOTAL_DISP, 0x01000008);
1478 WREG32(RADEON_CRTC2_H_SYNC_STRT_WID, 0x00000800);
1479 WREG32(RADEON_CRTC2_V_TOTAL_DISP, 0x00080001);
1480 WREG32(RADEON_CRTC2_V_SYNC_STRT_WID, 0x00000080);
1481
1482 for (i = 0; i < 200; i++) {
1483 tmp = RREG32(RADEON_GPIO_MONID);
1484 if (tmp & RADEON_GPIO_Y_0)
1485 found = true;
1486
1487 if (found)
1488 break;
1489
1490 if (!drm_can_sleep())
1491 mdelay(1);
1492 else
1493 msleep(1);
1494 }
1495
1496 /* restore the regs we used */
1497 WREG32(RADEON_DISP_LIN_TRANS_GRPH_A, disp_lin_trans_grph_a);
1498 WREG32(RADEON_DISP_LIN_TRANS_GRPH_B, disp_lin_trans_grph_b);
1499 WREG32(RADEON_DISP_LIN_TRANS_GRPH_C, disp_lin_trans_grph_c);
1500 WREG32(RADEON_DISP_LIN_TRANS_GRPH_D, disp_lin_trans_grph_d);
1501 WREG32(RADEON_DISP_LIN_TRANS_GRPH_E, disp_lin_trans_grph_e);
1502 WREG32(RADEON_DISP_LIN_TRANS_GRPH_F, disp_lin_trans_grph_f);
1503 WREG32(RADEON_CRTC2_H_TOTAL_DISP, crtc2_h_total_disp);
1504 WREG32(RADEON_CRTC2_V_TOTAL_DISP, crtc2_v_total_disp);
1505 WREG32(RADEON_CRTC2_H_SYNC_STRT_WID, crtc2_h_sync_strt_wid);
1506 WREG32(RADEON_CRTC2_V_SYNC_STRT_WID, crtc2_v_sync_strt_wid);
1507 WREG32(RADEON_CRTC2_GEN_CNTL, crtc2_gen_cntl);
1508 WREG32(RADEON_DISP_OUTPUT_CNTL, disp_output_cntl);
1509 WREG32(RADEON_FP2_GEN_CNTL, fp2_gen_cntl);
1510 WREG32(RADEON_GPIO_MONID, gpio_monid);
1511
1512 return found;
1513}
1514
1420static enum drm_connector_status radeon_legacy_tv_dac_detect(struct drm_encoder *encoder, 1515static enum drm_connector_status radeon_legacy_tv_dac_detect(struct drm_encoder *encoder,
1421 struct drm_connector *connector) 1516 struct drm_connector *connector)
1422{ 1517{
1423 struct drm_device *dev = encoder->dev; 1518 struct drm_device *dev = encoder->dev;
1424 struct radeon_device *rdev = dev->dev_private; 1519 struct radeon_device *rdev = dev->dev_private;
1425 uint32_t crtc2_gen_cntl, tv_dac_cntl, dac_cntl2, dac_ext_cntl; 1520 uint32_t crtc2_gen_cntl = 0, tv_dac_cntl, dac_cntl2, dac_ext_cntl;
1426 uint32_t disp_hw_debug, disp_output_cntl, gpiopad_a, pixclks_cntl, tmp; 1521 uint32_t gpiopad_a = 0, pixclks_cntl, tmp;
1522 uint32_t disp_output_cntl = 0, disp_hw_debug = 0, crtc_ext_cntl = 0;
1427 enum drm_connector_status found = connector_status_disconnected; 1523 enum drm_connector_status found = connector_status_disconnected;
1428 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 1524 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
1429 struct radeon_encoder_tv_dac *tv_dac = radeon_encoder->enc_priv; 1525 struct radeon_encoder_tv_dac *tv_dac = radeon_encoder->enc_priv;
@@ -1460,12 +1556,27 @@ static enum drm_connector_status radeon_legacy_tv_dac_detect(struct drm_encoder
1460 return connector_status_disconnected; 1556 return connector_status_disconnected;
1461 } 1557 }
1462 1558
1559 /* R200 uses an external DAC for secondary DAC */
1560 if (rdev->family == CHIP_R200) {
1561 if (radeon_legacy_ext_dac_detect(encoder, connector))
1562 found = connector_status_connected;
1563 return found;
1564 }
1565
1463 /* save the regs we need */ 1566 /* save the regs we need */
1464 pixclks_cntl = RREG32_PLL(RADEON_PIXCLKS_CNTL); 1567 pixclks_cntl = RREG32_PLL(RADEON_PIXCLKS_CNTL);
1465 gpiopad_a = ASIC_IS_R300(rdev) ? RREG32(RADEON_GPIOPAD_A) : 0; 1568
1466 disp_output_cntl = ASIC_IS_R300(rdev) ? RREG32(RADEON_DISP_OUTPUT_CNTL) : 0; 1569 if (rdev->flags & RADEON_SINGLE_CRTC) {
1467 disp_hw_debug = ASIC_IS_R300(rdev) ? 0 : RREG32(RADEON_DISP_HW_DEBUG); 1570 crtc_ext_cntl = RREG32(RADEON_CRTC_EXT_CNTL);
1468 crtc2_gen_cntl = RREG32(RADEON_CRTC2_GEN_CNTL); 1571 } else {
1572 if (ASIC_IS_R300(rdev)) {
1573 gpiopad_a = RREG32(RADEON_GPIOPAD_A);
1574 disp_output_cntl = RREG32(RADEON_DISP_OUTPUT_CNTL);
1575 } else {
1576 disp_hw_debug = RREG32(RADEON_DISP_HW_DEBUG);
1577 }
1578 crtc2_gen_cntl = RREG32(RADEON_CRTC2_GEN_CNTL);
1579 }
1469 tv_dac_cntl = RREG32(RADEON_TV_DAC_CNTL); 1580 tv_dac_cntl = RREG32(RADEON_TV_DAC_CNTL);
1470 dac_ext_cntl = RREG32(RADEON_DAC_EXT_CNTL); 1581 dac_ext_cntl = RREG32(RADEON_DAC_EXT_CNTL);
1471 dac_cntl2 = RREG32(RADEON_DAC_CNTL2); 1582 dac_cntl2 = RREG32(RADEON_DAC_CNTL2);
@@ -1474,22 +1585,24 @@ static enum drm_connector_status radeon_legacy_tv_dac_detect(struct drm_encoder
1474 | RADEON_PIX2CLK_DAC_ALWAYS_ONb); 1585 | RADEON_PIX2CLK_DAC_ALWAYS_ONb);
1475 WREG32_PLL(RADEON_PIXCLKS_CNTL, tmp); 1586 WREG32_PLL(RADEON_PIXCLKS_CNTL, tmp);
1476 1587
1477 if (ASIC_IS_R300(rdev)) 1588 if (rdev->flags & RADEON_SINGLE_CRTC) {
1478 WREG32_P(RADEON_GPIOPAD_A, 1, ~1); 1589 tmp = crtc_ext_cntl | RADEON_CRTC_CRT_ON;
1479 1590 WREG32(RADEON_CRTC_EXT_CNTL, tmp);
1480 tmp = crtc2_gen_cntl & ~RADEON_CRTC2_PIX_WIDTH_MASK;
1481 tmp |= RADEON_CRTC2_CRT2_ON |
1482 (2 << RADEON_CRTC2_PIX_WIDTH_SHIFT);
1483
1484 WREG32(RADEON_CRTC2_GEN_CNTL, tmp);
1485
1486 if (ASIC_IS_R300(rdev)) {
1487 tmp = disp_output_cntl & ~RADEON_DISP_TVDAC_SOURCE_MASK;
1488 tmp |= RADEON_DISP_TVDAC_SOURCE_CRTC2;
1489 WREG32(RADEON_DISP_OUTPUT_CNTL, tmp);
1490 } else { 1591 } else {
1491 tmp = disp_hw_debug & ~RADEON_CRT2_DISP1_SEL; 1592 tmp = crtc2_gen_cntl & ~RADEON_CRTC2_PIX_WIDTH_MASK;
1492 WREG32(RADEON_DISP_HW_DEBUG, tmp); 1593 tmp |= RADEON_CRTC2_CRT2_ON |
1594 (2 << RADEON_CRTC2_PIX_WIDTH_SHIFT);
1595 WREG32(RADEON_CRTC2_GEN_CNTL, tmp);
1596
1597 if (ASIC_IS_R300(rdev)) {
1598 WREG32_P(RADEON_GPIOPAD_A, 1, ~1);
1599 tmp = disp_output_cntl & ~RADEON_DISP_TVDAC_SOURCE_MASK;
1600 tmp |= RADEON_DISP_TVDAC_SOURCE_CRTC2;
1601 WREG32(RADEON_DISP_OUTPUT_CNTL, tmp);
1602 } else {
1603 tmp = disp_hw_debug & ~RADEON_CRT2_DISP1_SEL;
1604 WREG32(RADEON_DISP_HW_DEBUG, tmp);
1605 }
1493 } 1606 }
1494 1607
1495 tmp = RADEON_TV_DAC_NBLANK | 1608 tmp = RADEON_TV_DAC_NBLANK |
@@ -1531,14 +1644,19 @@ static enum drm_connector_status radeon_legacy_tv_dac_detect(struct drm_encoder
1531 WREG32(RADEON_DAC_CNTL2, dac_cntl2); 1644 WREG32(RADEON_DAC_CNTL2, dac_cntl2);
1532 WREG32(RADEON_DAC_EXT_CNTL, dac_ext_cntl); 1645 WREG32(RADEON_DAC_EXT_CNTL, dac_ext_cntl);
1533 WREG32(RADEON_TV_DAC_CNTL, tv_dac_cntl); 1646 WREG32(RADEON_TV_DAC_CNTL, tv_dac_cntl);
1534 WREG32(RADEON_CRTC2_GEN_CNTL, crtc2_gen_cntl);
1535 1647
1536 if (ASIC_IS_R300(rdev)) { 1648 if (rdev->flags & RADEON_SINGLE_CRTC) {
1537 WREG32(RADEON_DISP_OUTPUT_CNTL, disp_output_cntl); 1649 WREG32(RADEON_CRTC_EXT_CNTL, crtc_ext_cntl);
1538 WREG32_P(RADEON_GPIOPAD_A, gpiopad_a, ~1);
1539 } else { 1650 } else {
1540 WREG32(RADEON_DISP_HW_DEBUG, disp_hw_debug); 1651 WREG32(RADEON_CRTC2_GEN_CNTL, crtc2_gen_cntl);
1652 if (ASIC_IS_R300(rdev)) {
1653 WREG32(RADEON_DISP_OUTPUT_CNTL, disp_output_cntl);
1654 WREG32_P(RADEON_GPIOPAD_A, gpiopad_a, ~1);
1655 } else {
1656 WREG32(RADEON_DISP_HW_DEBUG, disp_hw_debug);
1657 }
1541 } 1658 }
1659
1542 WREG32_PLL(RADEON_PIXCLKS_CNTL, pixclks_cntl); 1660 WREG32_PLL(RADEON_PIXCLKS_CNTL, pixclks_cntl);
1543 1661
1544 return found; 1662 return found;
diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c
index 8b27dd6e314..b91118ccef8 100644
--- a/drivers/gpu/drm/radeon/radeon_object.c
+++ b/drivers/gpu/drm/radeon/radeon_object.c
@@ -105,7 +105,6 @@ int radeon_bo_create(struct radeon_device *rdev,
105 struct radeon_bo *bo; 105 struct radeon_bo *bo;
106 enum ttm_bo_type type; 106 enum ttm_bo_type type;
107 unsigned long page_align = roundup(byte_align, PAGE_SIZE) >> PAGE_SHIFT; 107 unsigned long page_align = roundup(byte_align, PAGE_SIZE) >> PAGE_SHIFT;
108 unsigned long max_size = 0;
109 size_t acc_size; 108 size_t acc_size;
110 int r; 109 int r;
111 110
@@ -121,18 +120,9 @@ int radeon_bo_create(struct radeon_device *rdev,
121 } 120 }
122 *bo_ptr = NULL; 121 *bo_ptr = NULL;
123 122
124 /* maximun bo size is the minimun btw visible vram and gtt size */
125 max_size = min(rdev->mc.visible_vram_size, rdev->mc.gtt_size);
126 if ((page_align << PAGE_SHIFT) >= max_size) {
127 printk(KERN_WARNING "%s:%d alloc size %ldM bigger than %ldMb limit\n",
128 __func__, __LINE__, page_align >> (20 - PAGE_SHIFT), max_size >> 20);
129 return -ENOMEM;
130 }
131
132 acc_size = ttm_bo_dma_acc_size(&rdev->mman.bdev, size, 123 acc_size = ttm_bo_dma_acc_size(&rdev->mman.bdev, size,
133 sizeof(struct radeon_bo)); 124 sizeof(struct radeon_bo));
134 125
135retry:
136 bo = kzalloc(sizeof(struct radeon_bo), GFP_KERNEL); 126 bo = kzalloc(sizeof(struct radeon_bo), GFP_KERNEL);
137 if (bo == NULL) 127 if (bo == NULL)
138 return -ENOMEM; 128 return -ENOMEM;
@@ -154,15 +144,6 @@ retry:
154 acc_size, sg, &radeon_ttm_bo_destroy); 144 acc_size, sg, &radeon_ttm_bo_destroy);
155 up_read(&rdev->pm.mclk_lock); 145 up_read(&rdev->pm.mclk_lock);
156 if (unlikely(r != 0)) { 146 if (unlikely(r != 0)) {
157 if (r != -ERESTARTSYS) {
158 if (domain == RADEON_GEM_DOMAIN_VRAM) {
159 domain |= RADEON_GEM_DOMAIN_GTT;
160 goto retry;
161 }
162 dev_err(rdev->dev,
163 "object_init failed for (%lu, 0x%08X)\n",
164 size, domain);
165 }
166 return r; 147 return r;
167 } 148 }
168 *bo_ptr = bo; 149 *bo_ptr = bo;
diff --git a/drivers/gpu/drm/radeon/radeon_ring.c b/drivers/gpu/drm/radeon/radeon_ring.c
index bba66902c83..47634f27f2e 100644
--- a/drivers/gpu/drm/radeon/radeon_ring.c
+++ b/drivers/gpu/drm/radeon/radeon_ring.c
@@ -305,7 +305,7 @@ void radeon_ring_write(struct radeon_ring *ring, uint32_t v)
305{ 305{
306#if DRM_DEBUG_CODE 306#if DRM_DEBUG_CODE
307 if (ring->count_dw <= 0) { 307 if (ring->count_dw <= 0) {
308 DRM_ERROR("radeon: writting more dword to ring than expected !\n"); 308 DRM_ERROR("radeon: writing more dwords to the ring than expected!\n");
309 } 309 }
310#endif 310#endif
311 ring->ring[ring->wptr++] = v; 311 ring->ring[ring->wptr++] = v;
diff --git a/drivers/gpu/drm/radeon/si.c b/drivers/gpu/drm/radeon/si.c
index f79633a036c..4422d630b33 100644
--- a/drivers/gpu/drm/radeon/si.c
+++ b/drivers/gpu/drm/radeon/si.c
@@ -2407,12 +2407,13 @@ static int si_pcie_gart_enable(struct radeon_device *rdev)
2407 WREG32(0x15DC, 0); 2407 WREG32(0x15DC, 0);
2408 2408
2409 /* empty context1-15 */ 2409 /* empty context1-15 */
2410 /* FIXME start with 4G, once using 2 level pt switch to full
2411 * vm size space
2412 */
2413 /* set vm size, must be a multiple of 4 */ 2410 /* set vm size, must be a multiple of 4 */
2414 WREG32(VM_CONTEXT1_PAGE_TABLE_START_ADDR, 0); 2411 WREG32(VM_CONTEXT1_PAGE_TABLE_START_ADDR, 0);
2415 WREG32(VM_CONTEXT1_PAGE_TABLE_END_ADDR, rdev->vm_manager.max_pfn); 2412 WREG32(VM_CONTEXT1_PAGE_TABLE_END_ADDR, rdev->vm_manager.max_pfn);
2413 /* Assign the pt base to something valid for now; the pts used for
2414 * the VMs are determined by the application and setup and assigned
2415 * on the fly in the vm part of radeon_gart.c
2416 */
2416 for (i = 1; i < 16; i++) { 2417 for (i = 1; i < 16; i++) {
2417 if (i < 8) 2418 if (i < 8)
2418 WREG32(VM_CONTEXT0_PAGE_TABLE_BASE_ADDR + (i << 2), 2419 WREG32(VM_CONTEXT0_PAGE_TABLE_BASE_ADDR + (i << 2),
@@ -2473,6 +2474,7 @@ static bool si_vm_reg_valid(u32 reg)
2473 /* check config regs */ 2474 /* check config regs */
2474 switch (reg) { 2475 switch (reg) {
2475 case GRBM_GFX_INDEX: 2476 case GRBM_GFX_INDEX:
2477 case CP_STRMOUT_CNTL:
2476 case VGT_VTX_VECT_EJECT_REG: 2478 case VGT_VTX_VECT_EJECT_REG:
2477 case VGT_CACHE_INVALIDATION: 2479 case VGT_CACHE_INVALIDATION:
2478 case VGT_ESGS_RING_SIZE: 2480 case VGT_ESGS_RING_SIZE:
@@ -2807,26 +2809,31 @@ void si_vm_set_page(struct radeon_device *rdev, uint64_t pe,
2807{ 2809{
2808 struct radeon_ring *ring = &rdev->ring[rdev->asic->vm.pt_ring_index]; 2810 struct radeon_ring *ring = &rdev->ring[rdev->asic->vm.pt_ring_index];
2809 uint32_t r600_flags = cayman_vm_page_flags(rdev, flags); 2811 uint32_t r600_flags = cayman_vm_page_flags(rdev, flags);
2810 int i;
2811 uint64_t value;
2812 2812
2813 radeon_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, 2 + count * 2)); 2813 while (count) {
2814 radeon_ring_write(ring, (WRITE_DATA_ENGINE_SEL(0) | 2814 unsigned ndw = 2 + count * 2;
2815 WRITE_DATA_DST_SEL(1))); 2815 if (ndw > 0x3FFE)
2816 radeon_ring_write(ring, pe); 2816 ndw = 0x3FFE;
2817 radeon_ring_write(ring, upper_32_bits(pe)); 2817
2818 for (i = 0; i < count; ++i) { 2818 radeon_ring_write(ring, PACKET3(PACKET3_WRITE_DATA, ndw));
2819 if (flags & RADEON_VM_PAGE_SYSTEM) { 2819 radeon_ring_write(ring, (WRITE_DATA_ENGINE_SEL(0) |
2820 value = radeon_vm_map_gart(rdev, addr); 2820 WRITE_DATA_DST_SEL(1)));
2821 value &= 0xFFFFFFFFFFFFF000ULL; 2821 radeon_ring_write(ring, pe);
2822 } else if (flags & RADEON_VM_PAGE_VALID) 2822 radeon_ring_write(ring, upper_32_bits(pe));
2823 value = addr; 2823 for (; ndw > 2; ndw -= 2, --count, pe += 8) {
2824 else 2824 uint64_t value;
2825 value = 0; 2825 if (flags & RADEON_VM_PAGE_SYSTEM) {
2826 addr += incr; 2826 value = radeon_vm_map_gart(rdev, addr);
2827 value |= r600_flags; 2827 value &= 0xFFFFFFFFFFFFF000ULL;
2828 radeon_ring_write(ring, value); 2828 } else if (flags & RADEON_VM_PAGE_VALID)
2829 radeon_ring_write(ring, upper_32_bits(value)); 2829 value = addr;
2830 else
2831 value = 0;
2832 addr += incr;
2833 value |= r600_flags;
2834 radeon_ring_write(ring, value);
2835 radeon_ring_write(ring, upper_32_bits(value));
2836 }
2830 } 2837 }
2831} 2838}
2832 2839
@@ -2867,6 +2874,10 @@ void si_vm_flush(struct radeon_device *rdev, int ridx, struct radeon_vm *vm)
2867 radeon_ring_write(ring, VM_INVALIDATE_REQUEST >> 2); 2874 radeon_ring_write(ring, VM_INVALIDATE_REQUEST >> 2);
2868 radeon_ring_write(ring, 0); 2875 radeon_ring_write(ring, 0);
2869 radeon_ring_write(ring, 1 << vm->id); 2876 radeon_ring_write(ring, 1 << vm->id);
2877
2878 /* sync PFP to ME, otherwise we might get invalid PFP reads */
2879 radeon_ring_write(ring, PACKET3(PACKET3_PFP_SYNC_ME, 0));
2880 radeon_ring_write(ring, 0x0);
2870} 2881}
2871 2882
2872/* 2883/*
diff --git a/drivers/gpu/drm/radeon/sid.h b/drivers/gpu/drm/radeon/sid.h
index 7d2a20e5657..a8871afc5b4 100644
--- a/drivers/gpu/drm/radeon/sid.h
+++ b/drivers/gpu/drm/radeon/sid.h
@@ -424,6 +424,7 @@
424# define RDERR_INT_ENABLE (1 << 0) 424# define RDERR_INT_ENABLE (1 << 0)
425# define GUI_IDLE_INT_ENABLE (1 << 19) 425# define GUI_IDLE_INT_ENABLE (1 << 19)
426 426
427#define CP_STRMOUT_CNTL 0x84FC
427#define SCRATCH_REG0 0x8500 428#define SCRATCH_REG0 0x8500
428#define SCRATCH_REG1 0x8504 429#define SCRATCH_REG1 0x8504
429#define SCRATCH_REG2 0x8508 430#define SCRATCH_REG2 0x8508
diff --git a/drivers/gpu/drm/shmobile/shmob_drm_drv.c b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
index c71d493fd0c..1c350fc4e44 100644
--- a/drivers/gpu/drm/shmobile/shmob_drm_drv.c
+++ b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
@@ -201,6 +201,8 @@ static int shmob_drm_load(struct drm_device *dev, unsigned long flags)
201 goto done; 201 goto done;
202 } 202 }
203 203
204 platform_set_drvdata(pdev, sdev);
205
204done: 206done:
205 if (ret) 207 if (ret)
206 shmob_drm_unload(dev); 208 shmob_drm_unload(dev);
@@ -299,11 +301,9 @@ static struct drm_driver shmob_drm_driver = {
299#if CONFIG_PM_SLEEP 301#if CONFIG_PM_SLEEP
300static int shmob_drm_pm_suspend(struct device *dev) 302static int shmob_drm_pm_suspend(struct device *dev)
301{ 303{
302 struct platform_device *pdev = to_platform_device(dev); 304 struct shmob_drm_device *sdev = dev_get_drvdata(dev);
303 struct drm_device *ddev = platform_get_drvdata(pdev);
304 struct shmob_drm_device *sdev = ddev->dev_private;
305 305
306 drm_kms_helper_poll_disable(ddev); 306 drm_kms_helper_poll_disable(sdev->ddev);
307 shmob_drm_crtc_suspend(&sdev->crtc); 307 shmob_drm_crtc_suspend(&sdev->crtc);
308 308
309 return 0; 309 return 0;
@@ -311,9 +311,7 @@ static int shmob_drm_pm_suspend(struct device *dev)
311 311
312static int shmob_drm_pm_resume(struct device *dev) 312static int shmob_drm_pm_resume(struct device *dev)
313{ 313{
314 struct platform_device *pdev = to_platform_device(dev); 314 struct shmob_drm_device *sdev = dev_get_drvdata(dev);
315 struct drm_device *ddev = platform_get_drvdata(pdev);
316 struct shmob_drm_device *sdev = ddev->dev_private;
317 315
318 mutex_lock(&sdev->ddev->mode_config.mutex); 316 mutex_lock(&sdev->ddev->mode_config.mutex);
319 shmob_drm_crtc_resume(&sdev->crtc); 317 shmob_drm_crtc_resume(&sdev->crtc);
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 402ab69f9f9..bf6e4b5a73b 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -580,6 +580,7 @@ retry:
580 if (unlikely(ret != 0)) 580 if (unlikely(ret != 0))
581 return ret; 581 return ret;
582 582
583retry_reserve:
583 spin_lock(&glob->lru_lock); 584 spin_lock(&glob->lru_lock);
584 585
585 if (unlikely(list_empty(&bo->ddestroy))) { 586 if (unlikely(list_empty(&bo->ddestroy))) {
@@ -587,14 +588,20 @@ retry:
587 return 0; 588 return 0;
588 } 589 }
589 590
590 ret = ttm_bo_reserve_locked(bo, interruptible, 591 ret = ttm_bo_reserve_locked(bo, false, true, false, 0);
591 no_wait_reserve, false, 0);
592 592
593 if (unlikely(ret != 0)) { 593 if (unlikely(ret == -EBUSY)) {
594 spin_unlock(&glob->lru_lock); 594 spin_unlock(&glob->lru_lock);
595 return ret; 595 if (likely(!no_wait_reserve))
596 ret = ttm_bo_wait_unreserved(bo, interruptible);
597 if (unlikely(ret != 0))
598 return ret;
599
600 goto retry_reserve;
596 } 601 }
597 602
603 BUG_ON(ret != 0);
604
598 /** 605 /**
599 * We can re-check for sync object without taking 606 * We can re-check for sync object without taking
600 * the bo::lock since setting the sync object requires 607 * the bo::lock since setting the sync object requires
@@ -811,17 +818,14 @@ retry:
811 no_wait_reserve, no_wait_gpu); 818 no_wait_reserve, no_wait_gpu);
812 kref_put(&bo->list_kref, ttm_bo_release_list); 819 kref_put(&bo->list_kref, ttm_bo_release_list);
813 820
814 if (likely(ret == 0 || ret == -ERESTARTSYS)) 821 return ret;
815 return ret;
816
817 goto retry;
818 } 822 }
819 823
820 ret = ttm_bo_reserve_locked(bo, false, no_wait_reserve, false, 0); 824 ret = ttm_bo_reserve_locked(bo, false, true, false, 0);
821 825
822 if (unlikely(ret == -EBUSY)) { 826 if (unlikely(ret == -EBUSY)) {
823 spin_unlock(&glob->lru_lock); 827 spin_unlock(&glob->lru_lock);
824 if (likely(!no_wait_gpu)) 828 if (likely(!no_wait_reserve))
825 ret = ttm_bo_wait_unreserved(bo, interruptible); 829 ret = ttm_bo_wait_unreserved(bo, interruptible);
826 830
827 kref_put(&bo->list_kref, ttm_bo_release_list); 831 kref_put(&bo->list_kref, ttm_bo_release_list);
diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
index 860dc4813e9..bd2a3b40cd1 100644
--- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
+++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
@@ -749,7 +749,10 @@ static int ttm_get_pages(struct page **pages, unsigned npages, int flags,
749 /* clear the pages coming from the pool if requested */ 749 /* clear the pages coming from the pool if requested */
750 if (flags & TTM_PAGE_FLAG_ZERO_ALLOC) { 750 if (flags & TTM_PAGE_FLAG_ZERO_ALLOC) {
751 list_for_each_entry(p, &plist, lru) { 751 list_for_each_entry(p, &plist, lru) {
752 clear_page(page_address(p)); 752 if (PageHighMem(p))
753 clear_highpage(p);
754 else
755 clear_page(page_address(p));
753 } 756 }
754 } 757 }
755 758
diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c
index bf8260133ea..7d759a43029 100644
--- a/drivers/gpu/drm/ttm/ttm_tt.c
+++ b/drivers/gpu/drm/ttm/ttm_tt.c
@@ -308,9 +308,7 @@ int ttm_tt_swapin(struct ttm_tt *ttm)
308 if (unlikely(to_page == NULL)) 308 if (unlikely(to_page == NULL))
309 goto out_err; 309 goto out_err;
310 310
311 preempt_disable();
312 copy_highpage(to_page, from_page); 311 copy_highpage(to_page, from_page);
313 preempt_enable();
314 page_cache_release(from_page); 312 page_cache_release(from_page);
315 } 313 }
316 314
@@ -358,9 +356,7 @@ int ttm_tt_swapout(struct ttm_tt *ttm, struct file *persistent_swap_storage)
358 ret = PTR_ERR(to_page); 356 ret = PTR_ERR(to_page);
359 goto out_err; 357 goto out_err;
360 } 358 }
361 preempt_disable();
362 copy_highpage(to_page, from_page); 359 copy_highpage(to_page, from_page);
363 preempt_enable();
364 set_page_dirty(to_page); 360 set_page_dirty(to_page);
365 mark_page_accessed(to_page); 361 mark_page_accessed(to_page);
366 page_cache_release(to_page); 362 page_cache_release(to_page);
diff --git a/drivers/gpu/drm/udl/udl_drv.h b/drivers/gpu/drm/udl/udl_drv.h
index fccd361f7b5..87aa5f5d3c8 100644
--- a/drivers/gpu/drm/udl/udl_drv.h
+++ b/drivers/gpu/drm/udl/udl_drv.h
@@ -104,7 +104,7 @@ udl_fb_user_fb_create(struct drm_device *dev,
104 104
105int udl_render_hline(struct drm_device *dev, int bpp, struct urb **urb_ptr, 105int udl_render_hline(struct drm_device *dev, int bpp, struct urb **urb_ptr,
106 const char *front, char **urb_buf_ptr, 106 const char *front, char **urb_buf_ptr,
107 u32 byte_offset, u32 byte_width, 107 u32 byte_offset, u32 device_byte_offset, u32 byte_width,
108 int *ident_ptr, int *sent_ptr); 108 int *ident_ptr, int *sent_ptr);
109 109
110int udl_dumb_create(struct drm_file *file_priv, 110int udl_dumb_create(struct drm_file *file_priv,
diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
index 69a2b16f42a..d4ab3beaada 100644
--- a/drivers/gpu/drm/udl/udl_fb.c
+++ b/drivers/gpu/drm/udl/udl_fb.c
@@ -114,9 +114,10 @@ static void udlfb_dpy_deferred_io(struct fb_info *info,
114 list_for_each_entry(cur, &fbdefio->pagelist, lru) { 114 list_for_each_entry(cur, &fbdefio->pagelist, lru) {
115 115
116 if (udl_render_hline(dev, (ufbdev->ufb.base.bits_per_pixel / 8), 116 if (udl_render_hline(dev, (ufbdev->ufb.base.bits_per_pixel / 8),
117 &urb, (char *) info->fix.smem_start, 117 &urb, (char *) info->fix.smem_start,
118 &cmd, cur->index << PAGE_SHIFT, 118 &cmd, cur->index << PAGE_SHIFT,
119 PAGE_SIZE, &bytes_identical, &bytes_sent)) 119 cur->index << PAGE_SHIFT,
120 PAGE_SIZE, &bytes_identical, &bytes_sent))
120 goto error; 121 goto error;
121 bytes_rendered += PAGE_SIZE; 122 bytes_rendered += PAGE_SIZE;
122 } 123 }
@@ -187,10 +188,11 @@ int udl_handle_damage(struct udl_framebuffer *fb, int x, int y,
187 for (i = y; i < y + height ; i++) { 188 for (i = y; i < y + height ; i++) {
188 const int line_offset = fb->base.pitches[0] * i; 189 const int line_offset = fb->base.pitches[0] * i;
189 const int byte_offset = line_offset + (x * bpp); 190 const int byte_offset = line_offset + (x * bpp);
190 191 const int dev_byte_offset = (fb->base.width * bpp * i) + (x * bpp);
191 if (udl_render_hline(dev, bpp, &urb, 192 if (udl_render_hline(dev, bpp, &urb,
192 (char *) fb->obj->vmapping, 193 (char *) fb->obj->vmapping,
193 &cmd, byte_offset, width * bpp, 194 &cmd, byte_offset, dev_byte_offset,
195 width * bpp,
194 &bytes_identical, &bytes_sent)) 196 &bytes_identical, &bytes_sent))
195 goto error; 197 goto error;
196 } 198 }
diff --git a/drivers/gpu/drm/udl/udl_transfer.c b/drivers/gpu/drm/udl/udl_transfer.c
index dc095526ffb..142fee5f983 100644
--- a/drivers/gpu/drm/udl/udl_transfer.c
+++ b/drivers/gpu/drm/udl/udl_transfer.c
@@ -213,11 +213,12 @@ static void udl_compress_hline16(
213 */ 213 */
214int udl_render_hline(struct drm_device *dev, int bpp, struct urb **urb_ptr, 214int udl_render_hline(struct drm_device *dev, int bpp, struct urb **urb_ptr,
215 const char *front, char **urb_buf_ptr, 215 const char *front, char **urb_buf_ptr,
216 u32 byte_offset, u32 byte_width, 216 u32 byte_offset, u32 device_byte_offset,
217 u32 byte_width,
217 int *ident_ptr, int *sent_ptr) 218 int *ident_ptr, int *sent_ptr)
218{ 219{
219 const u8 *line_start, *line_end, *next_pixel; 220 const u8 *line_start, *line_end, *next_pixel;
220 u32 base16 = 0 + (byte_offset / bpp) * 2; 221 u32 base16 = 0 + (device_byte_offset / bpp) * 2;
221 struct urb *urb = *urb_ptr; 222 struct urb *urb = *urb_ptr;
222 u8 *cmd = *urb_buf_ptr; 223 u8 *cmd = *urb_buf_ptr;
223 u8 *cmd_end = (u8 *) urb->transfer_buffer + urb->transfer_buffer_length; 224 u8 *cmd_end = (u8 *) urb->transfer_buffer + urb->transfer_buffer_length;
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_dmabuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_dmabuf.c
index 3ce68a2e312..d1498bfd787 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_dmabuf.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_dmabuf.c
@@ -306,7 +306,7 @@ void vmw_bo_pin(struct ttm_buffer_object *bo, bool pin)
306 306
307 BUG_ON(!atomic_read(&bo->reserved)); 307 BUG_ON(!atomic_read(&bo->reserved));
308 BUG_ON(old_mem_type != TTM_PL_VRAM && 308 BUG_ON(old_mem_type != TTM_PL_VRAM &&
309 old_mem_type != VMW_PL_FLAG_GMR); 309 old_mem_type != VMW_PL_GMR);
310 310
311 pl_flags = TTM_PL_FLAG_VRAM | VMW_PL_FLAG_GMR | TTM_PL_FLAG_CACHED; 311 pl_flags = TTM_PL_FLAG_VRAM | VMW_PL_FLAG_GMR | TTM_PL_FLAG_CACHED;
312 if (pin) 312 if (pin)
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index ed3c1e7ddde..2dd185e42f2 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -1098,6 +1098,11 @@ static void vmw_pm_complete(struct device *kdev)
1098 struct drm_device *dev = pci_get_drvdata(pdev); 1098 struct drm_device *dev = pci_get_drvdata(pdev);
1099 struct vmw_private *dev_priv = vmw_priv(dev); 1099 struct vmw_private *dev_priv = vmw_priv(dev);
1100 1100
1101 mutex_lock(&dev_priv->hw_mutex);
1102 vmw_write(dev_priv, SVGA_REG_ID, SVGA_ID_2);
1103 (void) vmw_read(dev_priv, SVGA_REG_ID);
1104 mutex_unlock(&dev_priv->hw_mutex);
1105
1101 /** 1106 /**
1102 * Reclaim 3d reference held by fbdev and potentially 1107 * Reclaim 3d reference held by fbdev and potentially
1103 * start fifo. 1108 * start fifo.
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
index b07ca2e4d04..7290811f89b 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
@@ -110,6 +110,8 @@ int vmw_get_cap_3d_ioctl(struct drm_device *dev, void *data,
110 memcpy_fromio(bounce, &fifo_mem[SVGA_FIFO_3D_CAPS], size); 110 memcpy_fromio(bounce, &fifo_mem[SVGA_FIFO_3D_CAPS], size);
111 111
112 ret = copy_to_user(buffer, bounce, size); 112 ret = copy_to_user(buffer, bounce, size);
113 if (ret)
114 ret = -EFAULT;
113 vfree(bounce); 115 vfree(bounce);
114 116
115 if (unlikely(ret != 0)) 117 if (unlikely(ret != 0))
diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c
index 06ebdbb6ea0..fd7722aecf7 100644
--- a/drivers/hid/hid-apple.c
+++ b/drivers/hid/hid-apple.c
@@ -522,6 +522,12 @@ static const struct hid_device_id apple_devices[] = {
522 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD }, 522 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
523 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_JIS), 523 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_JIS),
524 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS }, 524 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
525 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7A_ANSI),
526 .driver_data = APPLE_HAS_FN },
527 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7A_ISO),
528 .driver_data = APPLE_HAS_FN | APPLE_ISO_KEYBOARD },
529 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7A_JIS),
530 .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS },
525 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI), 531 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI),
526 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, 532 .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
527 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO), 533 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO),
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index bd3971bf31b..f4109fd657f 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1532,6 +1532,9 @@ static const struct hid_device_id hid_have_special_driver[] = {
1532 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_ANSI) }, 1532 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_ANSI) },
1533 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_ISO) }, 1533 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_ISO) },
1534 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_JIS) }, 1534 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_JIS) },
1535 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7A_ANSI) },
1536 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7A_ISO) },
1537 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7A_JIS) },
1535 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI) }, 1538 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI) },
1536 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO) }, 1539 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO) },
1537 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS) }, 1540 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS) },
@@ -2139,6 +2142,9 @@ static const struct hid_device_id hid_mouse_ignore_list[] = {
2139 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_ANSI) }, 2142 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_ANSI) },
2140 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_ISO) }, 2143 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_ISO) },
2141 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_JIS) }, 2144 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_JIS) },
2145 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7A_ANSI) },
2146 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7A_ISO) },
2147 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7A_JIS) },
2142 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) }, 2148 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) },
2143 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, 2149 { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) },
2144 { } 2150 { }
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index 269b50912a4..9d7a42857ea 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -118,6 +118,9 @@
118#define USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI 0x0252 118#define USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI 0x0252
119#define USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO 0x0253 119#define USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO 0x0253
120#define USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS 0x0254 120#define USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS 0x0254
121#define USB_DEVICE_ID_APPLE_WELLSPRING7A_ANSI 0x0259
122#define USB_DEVICE_ID_APPLE_WELLSPRING7A_ISO 0x025a
123#define USB_DEVICE_ID_APPLE_WELLSPRING7A_JIS 0x025b
121#define USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI 0x0249 124#define USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI 0x0249
122#define USB_DEVICE_ID_APPLE_WELLSPRING6A_ISO 0x024a 125#define USB_DEVICE_ID_APPLE_WELLSPRING6A_ISO 0x024a
123#define USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS 0x024b 126#define USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS 0x024b
diff --git a/drivers/hid/hid-microsoft.c b/drivers/hid/hid-microsoft.c
index 3acdcfcc17d..6fcd466d082 100644
--- a/drivers/hid/hid-microsoft.c
+++ b/drivers/hid/hid-microsoft.c
@@ -28,22 +28,30 @@
28#define MS_RDESC 0x08 28#define MS_RDESC 0x08
29#define MS_NOGET 0x10 29#define MS_NOGET 0x10
30#define MS_DUPLICATE_USAGES 0x20 30#define MS_DUPLICATE_USAGES 0x20
31#define MS_RDESC_3K 0x40
31 32
32/*
33 * Microsoft Wireless Desktop Receiver (Model 1028) has
34 * 'Usage Min/Max' where it ought to have 'Physical Min/Max'
35 */
36static __u8 *ms_report_fixup(struct hid_device *hdev, __u8 *rdesc, 33static __u8 *ms_report_fixup(struct hid_device *hdev, __u8 *rdesc,
37 unsigned int *rsize) 34 unsigned int *rsize)
38{ 35{
39 unsigned long quirks = (unsigned long)hid_get_drvdata(hdev); 36 unsigned long quirks = (unsigned long)hid_get_drvdata(hdev);
40 37
38 /*
39 * Microsoft Wireless Desktop Receiver (Model 1028) has
40 * 'Usage Min/Max' where it ought to have 'Physical Min/Max'
41 */
41 if ((quirks & MS_RDESC) && *rsize == 571 && rdesc[557] == 0x19 && 42 if ((quirks & MS_RDESC) && *rsize == 571 && rdesc[557] == 0x19 &&
42 rdesc[559] == 0x29) { 43 rdesc[559] == 0x29) {
43 hid_info(hdev, "fixing up Microsoft Wireless Receiver Model 1028 report descriptor\n"); 44 hid_info(hdev, "fixing up Microsoft Wireless Receiver Model 1028 report descriptor\n");
44 rdesc[557] = 0x35; 45 rdesc[557] = 0x35;
45 rdesc[559] = 0x45; 46 rdesc[559] = 0x45;
46 } 47 }
48 /* the same as above (s/usage/physical/) */
49 if ((quirks & MS_RDESC_3K) && *rsize == 106 && rdesc[94] == 0x19 &&
50 rdesc[95] == 0x00 && rdesc[96] == 0x29 &&
51 rdesc[97] == 0xff) {
52 rdesc[94] = 0x35;
53 rdesc[96] = 0x45;
54 }
47 return rdesc; 55 return rdesc;
48} 56}
49 57
@@ -192,7 +200,7 @@ static const struct hid_device_id ms_devices[] = {
192 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_USB), 200 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_USB),
193 .driver_data = MS_PRESENTER }, 201 .driver_data = MS_PRESENTER },
194 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_DIGITAL_MEDIA_3K), 202 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_DIGITAL_MEDIA_3K),
195 .driver_data = MS_ERGONOMY }, 203 .driver_data = MS_ERGONOMY | MS_RDESC_3K },
196 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_WIRELESS_OPTICAL_DESKTOP_3_0), 204 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_WIRELESS_OPTICAL_DESKTOP_3_0),
197 .driver_data = MS_NOGET }, 205 .driver_data = MS_NOGET },
198 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_COMFORT_MOUSE_4500), 206 { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_COMFORT_MOUSE_4500),
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
index 3eb02b94fc8..7867d69f0ef 100644
--- a/drivers/hid/hid-multitouch.c
+++ b/drivers/hid/hid-multitouch.c
@@ -210,8 +210,7 @@ static struct mt_class mt_classes[] = {
210 }, 210 },
211 { .name = MT_CLS_GENERALTOUCH_PWT_TENFINGERS, 211 { .name = MT_CLS_GENERALTOUCH_PWT_TENFINGERS,
212 .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP | 212 .quirks = MT_QUIRK_NOT_SEEN_MEANS_UP |
213 MT_QUIRK_SLOT_IS_CONTACTNUMBER, 213 MT_QUIRK_SLOT_IS_CONTACTNUMBER
214 .maxcontacts = 10
215 }, 214 },
216 215
217 { .name = MT_CLS_FLATFROG, 216 { .name = MT_CLS_FLATFROG,
@@ -421,11 +420,11 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi,
421 * contact max are global to the report */ 420 * contact max are global to the report */
422 td->last_field_index = field->index; 421 td->last_field_index = field->index;
423 return -1; 422 return -1;
424 }
425 case HID_DG_TOUCH: 423 case HID_DG_TOUCH:
426 /* Legacy devices use TIPSWITCH and not TOUCH. 424 /* Legacy devices use TIPSWITCH and not TOUCH.
427 * Let's just ignore this field. */ 425 * Let's just ignore this field. */
428 return -1; 426 return -1;
427 }
429 /* let hid-input decide for the others */ 428 /* let hid-input decide for the others */
430 return 0; 429 return 0;
431 430
diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c
index 17d15bb610d..7c47fc3f7b2 100644
--- a/drivers/hid/hidraw.c
+++ b/drivers/hid/hidraw.c
@@ -42,7 +42,6 @@ static struct cdev hidraw_cdev;
42static struct class *hidraw_class; 42static struct class *hidraw_class;
43static struct hidraw *hidraw_table[HIDRAW_MAX_DEVICES]; 43static struct hidraw *hidraw_table[HIDRAW_MAX_DEVICES];
44static DEFINE_MUTEX(minors_lock); 44static DEFINE_MUTEX(minors_lock);
45static void drop_ref(struct hidraw *hid, int exists_bit);
46 45
47static ssize_t hidraw_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos) 46static ssize_t hidraw_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos)
48{ 47{
@@ -114,7 +113,7 @@ static ssize_t hidraw_send_report(struct file *file, const char __user *buffer,
114 __u8 *buf; 113 __u8 *buf;
115 int ret = 0; 114 int ret = 0;
116 115
117 if (!hidraw_table[minor] || !hidraw_table[minor]->exist) { 116 if (!hidraw_table[minor]) {
118 ret = -ENODEV; 117 ret = -ENODEV;
119 goto out; 118 goto out;
120 } 119 }
@@ -262,7 +261,7 @@ static int hidraw_open(struct inode *inode, struct file *file)
262 } 261 }
263 262
264 mutex_lock(&minors_lock); 263 mutex_lock(&minors_lock);
265 if (!hidraw_table[minor] || !hidraw_table[minor]->exist) { 264 if (!hidraw_table[minor]) {
266 err = -ENODEV; 265 err = -ENODEV;
267 goto out_unlock; 266 goto out_unlock;
268 } 267 }
@@ -299,12 +298,36 @@ out:
299static int hidraw_release(struct inode * inode, struct file * file) 298static int hidraw_release(struct inode * inode, struct file * file)
300{ 299{
301 unsigned int minor = iminor(inode); 300 unsigned int minor = iminor(inode);
301 struct hidraw *dev;
302 struct hidraw_list *list = file->private_data; 302 struct hidraw_list *list = file->private_data;
303 int ret;
304 int i;
305
306 mutex_lock(&minors_lock);
307 if (!hidraw_table[minor]) {
308 ret = -ENODEV;
309 goto unlock;
310 }
303 311
304 drop_ref(hidraw_table[minor], 0);
305 list_del(&list->node); 312 list_del(&list->node);
313 dev = hidraw_table[minor];
314 if (!--dev->open) {
315 if (list->hidraw->exist) {
316 hid_hw_power(dev->hid, PM_HINT_NORMAL);
317 hid_hw_close(dev->hid);
318 } else {
319 kfree(list->hidraw);
320 }
321 }
322
323 for (i = 0; i < HIDRAW_BUFFER_SIZE; ++i)
324 kfree(list->buffer[i].value);
306 kfree(list); 325 kfree(list);
307 return 0; 326 ret = 0;
327unlock:
328 mutex_unlock(&minors_lock);
329
330 return ret;
308} 331}
309 332
310static long hidraw_ioctl(struct file *file, unsigned int cmd, 333static long hidraw_ioctl(struct file *file, unsigned int cmd,
@@ -506,7 +529,21 @@ EXPORT_SYMBOL_GPL(hidraw_connect);
506void hidraw_disconnect(struct hid_device *hid) 529void hidraw_disconnect(struct hid_device *hid)
507{ 530{
508 struct hidraw *hidraw = hid->hidraw; 531 struct hidraw *hidraw = hid->hidraw;
509 drop_ref(hidraw, 1); 532
533 mutex_lock(&minors_lock);
534 hidraw->exist = 0;
535
536 device_destroy(hidraw_class, MKDEV(hidraw_major, hidraw->minor));
537
538 hidraw_table[hidraw->minor] = NULL;
539
540 if (hidraw->open) {
541 hid_hw_close(hid);
542 wake_up_interruptible(&hidraw->wait);
543 } else {
544 kfree(hidraw);
545 }
546 mutex_unlock(&minors_lock);
510} 547}
511EXPORT_SYMBOL_GPL(hidraw_disconnect); 548EXPORT_SYMBOL_GPL(hidraw_disconnect);
512 549
@@ -555,23 +592,3 @@ void hidraw_exit(void)
555 unregister_chrdev_region(dev_id, HIDRAW_MAX_DEVICES); 592 unregister_chrdev_region(dev_id, HIDRAW_MAX_DEVICES);
556 593
557} 594}
558
559static void drop_ref(struct hidraw *hidraw, int exists_bit)
560{
561 mutex_lock(&minors_lock);
562 if (exists_bit) {
563 hid_hw_close(hidraw->hid);
564 hidraw->exist = 0;
565 if (hidraw->open)
566 wake_up_interruptible(&hidraw->wait);
567 } else {
568 --hidraw->open;
569 }
570
571 if (!hidraw->open && !hidraw->exist) {
572 device_destroy(hidraw_class, MKDEV(hidraw_major, hidraw->minor));
573 hidraw_table[hidraw->minor] = NULL;
574 kfree(hidraw);
575 }
576 mutex_unlock(&minors_lock);
577}
diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
index 406537420ff..f4c3d28cd1f 100644
--- a/drivers/hv/channel.c
+++ b/drivers/hv/channel.c
@@ -146,14 +146,14 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
146 146
147 if (ret != 0) { 147 if (ret != 0) {
148 err = ret; 148 err = ret;
149 goto errorout; 149 goto error0;
150 } 150 }
151 151
152 ret = hv_ringbuffer_init( 152 ret = hv_ringbuffer_init(
153 &newchannel->inbound, in, recv_ringbuffer_size); 153 &newchannel->inbound, in, recv_ringbuffer_size);
154 if (ret != 0) { 154 if (ret != 0) {
155 err = ret; 155 err = ret;
156 goto errorout; 156 goto error0;
157 } 157 }
158 158
159 159
@@ -168,7 +168,7 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
168 168
169 if (ret != 0) { 169 if (ret != 0) {
170 err = ret; 170 err = ret;
171 goto errorout; 171 goto error0;
172 } 172 }
173 173
174 /* Create and init the channel open message */ 174 /* Create and init the channel open message */
@@ -177,7 +177,7 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
177 GFP_KERNEL); 177 GFP_KERNEL);
178 if (!open_info) { 178 if (!open_info) {
179 err = -ENOMEM; 179 err = -ENOMEM;
180 goto errorout; 180 goto error0;
181 } 181 }
182 182
183 init_completion(&open_info->waitevent); 183 init_completion(&open_info->waitevent);
@@ -193,7 +193,7 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
193 193
194 if (userdatalen > MAX_USER_DEFINED_BYTES) { 194 if (userdatalen > MAX_USER_DEFINED_BYTES) {
195 err = -EINVAL; 195 err = -EINVAL;
196 goto errorout; 196 goto error0;
197 } 197 }
198 198
199 if (userdatalen) 199 if (userdatalen)
@@ -208,19 +208,18 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
208 sizeof(struct vmbus_channel_open_channel)); 208 sizeof(struct vmbus_channel_open_channel));
209 209
210 if (ret != 0) 210 if (ret != 0)
211 goto cleanup; 211 goto error1;
212 212
213 t = wait_for_completion_timeout(&open_info->waitevent, 5*HZ); 213 t = wait_for_completion_timeout(&open_info->waitevent, 5*HZ);
214 if (t == 0) { 214 if (t == 0) {
215 err = -ETIMEDOUT; 215 err = -ETIMEDOUT;
216 goto errorout; 216 goto error1;
217 } 217 }
218 218
219 219
220 if (open_info->response.open_result.status) 220 if (open_info->response.open_result.status)
221 err = open_info->response.open_result.status; 221 err = open_info->response.open_result.status;
222 222
223cleanup:
224 spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags); 223 spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
225 list_del(&open_info->msglistentry); 224 list_del(&open_info->msglistentry);
226 spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags); 225 spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
@@ -228,9 +227,12 @@ cleanup:
228 kfree(open_info); 227 kfree(open_info);
229 return err; 228 return err;
230 229
231errorout: 230error1:
232 hv_ringbuffer_cleanup(&newchannel->outbound); 231 spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
233 hv_ringbuffer_cleanup(&newchannel->inbound); 232 list_del(&open_info->msglistentry);
233 spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
234
235error0:
234 free_pages((unsigned long)out, 236 free_pages((unsigned long)out,
235 get_order(send_ringbuffer_size + recv_ringbuffer_size)); 237 get_order(send_ringbuffer_size + recv_ringbuffer_size));
236 kfree(open_info); 238 kfree(open_info);
diff --git a/drivers/hwmon/asb100.c b/drivers/hwmon/asb100.c
index a227be47149..520e5bf4f76 100644
--- a/drivers/hwmon/asb100.c
+++ b/drivers/hwmon/asb100.c
@@ -32,7 +32,7 @@
32 * ASB100-A supports pwm1, while plain ASB100 does not. There is no known 32 * ASB100-A supports pwm1, while plain ASB100 does not. There is no known
33 * way for the driver to tell which one is there. 33 * way for the driver to tell which one is there.
34 * 34 *
35 * Chip #vin #fanin #pwm #temp wchipid vendid i2c ISA 35 * Chip #vin #fanin #pwm #temp wchipid vendid i2c ISA
36 * asb100 7 3 1 4 0x31 0x0694 yes no 36 * asb100 7 3 1 4 0x31 0x0694 yes no
37 */ 37 */
38 38
diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
index 984a3f13923..47b8d84b489 100644
--- a/drivers/hwmon/coretemp.c
+++ b/drivers/hwmon/coretemp.c
@@ -205,8 +205,11 @@ static const struct tjmax __cpuinitconst tjmax_table[] = {
205 { "CPU N455", 100000 }, 205 { "CPU N455", 100000 },
206 { "CPU N470", 100000 }, 206 { "CPU N470", 100000 },
207 { "CPU N475", 100000 }, 207 { "CPU N475", 100000 },
208 { "CPU 230", 100000 }, 208 { "CPU 230", 100000 }, /* Model 0x1c, stepping 2 */
209 { "CPU 330", 125000 }, 209 { "CPU 330", 125000 }, /* Model 0x1c, stepping 2 */
210 { "CPU CE4110", 110000 }, /* Model 0x1c, stepping 10 */
211 { "CPU CE4150", 110000 }, /* Model 0x1c, stepping 10 */
212 { "CPU CE4170", 110000 }, /* Model 0x1c, stepping 10 */
210}; 213};
211 214
212static int __cpuinit adjust_tjmax(struct cpuinfo_x86 *c, u32 id, 215static int __cpuinit adjust_tjmax(struct cpuinfo_x86 *c, u32 id,
diff --git a/drivers/hwmon/fam15h_power.c b/drivers/hwmon/fam15h_power.c
index 68ad7d25551..4f411040738 100644
--- a/drivers/hwmon/fam15h_power.c
+++ b/drivers/hwmon/fam15h_power.c
@@ -2,7 +2,7 @@
2 * fam15h_power.c - AMD Family 15h processor power monitoring 2 * fam15h_power.c - AMD Family 15h processor power monitoring
3 * 3 *
4 * Copyright (c) 2011 Advanced Micro Devices, Inc. 4 * Copyright (c) 2011 Advanced Micro Devices, Inc.
5 * Author: Andreas Herrmann <andreas.herrmann3@amd.com> 5 * Author: Andreas Herrmann <herrmann.der.user@googlemail.com>
6 * 6 *
7 * 7 *
8 * This driver is free software; you can redistribute it and/or 8 * This driver is free software; you can redistribute it and/or
@@ -28,7 +28,7 @@
28#include <asm/processor.h> 28#include <asm/processor.h>
29 29
30MODULE_DESCRIPTION("AMD Family 15h CPU processor power monitor"); 30MODULE_DESCRIPTION("AMD Family 15h CPU processor power monitor");
31MODULE_AUTHOR("Andreas Herrmann <andreas.herrmann3@amd.com>"); 31MODULE_AUTHOR("Andreas Herrmann <herrmann.der.user@googlemail.com>");
32MODULE_LICENSE("GPL"); 32MODULE_LICENSE("GPL");
33 33
34/* D18F3 */ 34/* D18F3 */
diff --git a/drivers/hwmon/gpio-fan.c b/drivers/hwmon/gpio-fan.c
index 36509ae3208..1381a2e3bbd 100644
--- a/drivers/hwmon/gpio-fan.c
+++ b/drivers/hwmon/gpio-fan.c
@@ -630,7 +630,9 @@ static struct platform_driver gpio_fan_driver = {
630 .driver = { 630 .driver = {
631 .name = "gpio-fan", 631 .name = "gpio-fan",
632 .pm = GPIO_FAN_PM, 632 .pm = GPIO_FAN_PM,
633#ifdef CONFIG_OF_GPIO
633 .of_match_table = of_match_ptr(of_gpio_fan_match), 634 .of_match_table = of_match_ptr(of_gpio_fan_match),
635#endif
634 }, 636 },
635}; 637};
636 638
diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig
index 2ca6a5a4f5a..60745a53582 100644
--- a/drivers/hwmon/pmbus/Kconfig
+++ b/drivers/hwmon/pmbus/Kconfig
@@ -4,7 +4,7 @@
4 4
5menuconfig PMBUS 5menuconfig PMBUS
6 tristate "PMBus support" 6 tristate "PMBus support"
7 depends on I2C && EXPERIMENTAL 7 depends on I2C
8 default n 8 default n
9 help 9 help
10 Say yes here if you want to enable PMBus support. 10 Say yes here if you want to enable PMBus support.
diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c
index 1821b7423d5..de3c7e04c3b 100644
--- a/drivers/hwmon/w83627ehf.c
+++ b/drivers/hwmon/w83627ehf.c
@@ -2083,6 +2083,7 @@ static int __devinit w83627ehf_probe(struct platform_device *pdev)
2083 mutex_init(&data->lock); 2083 mutex_init(&data->lock);
2084 mutex_init(&data->update_lock); 2084 mutex_init(&data->update_lock);
2085 data->name = w83627ehf_device_names[sio_data->kind]; 2085 data->name = w83627ehf_device_names[sio_data->kind];
2086 data->bank = 0xff; /* Force initial bank selection */
2086 platform_set_drvdata(pdev, data); 2087 platform_set_drvdata(pdev, data);
2087 2088
2088 /* 627EHG and 627EHF have 10 voltage inputs; 627DHG and 667HG have 9 */ 2089 /* 627EHG and 627EHF have 10 voltage inputs; 627DHG and 667HG have 9 */
diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c
index 5b1a6a66644..af158990870 100644
--- a/drivers/hwmon/w83627hf.c
+++ b/drivers/hwmon/w83627hf.c
@@ -25,7 +25,7 @@
25/* 25/*
26 * Supports following chips: 26 * Supports following chips:
27 * 27 *
28 * Chip #vin #fanin #pwm #temp wchipid vendid i2c ISA 28 * Chip #vin #fanin #pwm #temp wchipid vendid i2c ISA
29 * w83627hf 9 3 2 3 0x20 0x5ca3 no yes(LPC) 29 * w83627hf 9 3 2 3 0x20 0x5ca3 no yes(LPC)
30 * w83627thf 7 3 3 3 0x90 0x5ca3 no yes(LPC) 30 * w83627thf 7 3 3 3 0x90 0x5ca3 no yes(LPC)
31 * w83637hf 7 3 3 3 0x80 0x5ca3 no yes(LPC) 31 * w83637hf 7 3 3 3 0x80 0x5ca3 no yes(LPC)
diff --git a/drivers/hwmon/w83781d.c b/drivers/hwmon/w83781d.c
index 5a5046d94c3..20f11d31da4 100644
--- a/drivers/hwmon/w83781d.c
+++ b/drivers/hwmon/w83781d.c
@@ -24,7 +24,7 @@
24/* 24/*
25 * Supports following chips: 25 * Supports following chips:
26 * 26 *
27 * Chip #vin #fanin #pwm #temp wchipid vendid i2c ISA 27 * Chip #vin #fanin #pwm #temp wchipid vendid i2c ISA
28 * as99127f 7 3 0 3 0x31 0x12c3 yes no 28 * as99127f 7 3 0 3 0x31 0x12c3 yes no
29 * as99127f rev.2 (type_name = as99127f) 0x31 0x5ca3 yes no 29 * as99127f rev.2 (type_name = as99127f) 0x31 0x5ca3 yes no
30 * w83781d 7 3 0 3 0x10-1 0x5ca3 yes yes 30 * w83781d 7 3 0 3 0x10-1 0x5ca3 yes yes
diff --git a/drivers/hwmon/w83791d.c b/drivers/hwmon/w83791d.c
index 39ab7bcc616..ed397c64519 100644
--- a/drivers/hwmon/w83791d.c
+++ b/drivers/hwmon/w83791d.c
@@ -22,7 +22,7 @@
22/* 22/*
23 * Supports following chips: 23 * Supports following chips:
24 * 24 *
25 * Chip #vin #fanin #pwm #temp wchipid vendid i2c ISA 25 * Chip #vin #fanin #pwm #temp wchipid vendid i2c ISA
26 * w83791d 10 5 5 3 0x71 0x5ca3 yes no 26 * w83791d 10 5 5 3 0x71 0x5ca3 yes no
27 * 27 *
28 * The w83791d chip appears to be part way between the 83781d and the 28 * The w83791d chip appears to be part way between the 83781d and the
diff --git a/drivers/hwmon/w83792d.c b/drivers/hwmon/w83792d.c
index 053645279f3..301942d0845 100644
--- a/drivers/hwmon/w83792d.c
+++ b/drivers/hwmon/w83792d.c
@@ -31,7 +31,7 @@
31/* 31/*
32 * Supports following chips: 32 * Supports following chips:
33 * 33 *
34 * Chip #vin #fanin #pwm #temp wchipid vendid i2c ISA 34 * Chip #vin #fanin #pwm #temp wchipid vendid i2c ISA
35 * w83792d 9 7 7 3 0x7a 0x5ca3 yes no 35 * w83792d 9 7 7 3 0x7a 0x5ca3 yes no
36 */ 36 */
37 37
diff --git a/drivers/hwmon/w83l786ng.c b/drivers/hwmon/w83l786ng.c
index f0e8286c3c7..79710bcac2f 100644
--- a/drivers/hwmon/w83l786ng.c
+++ b/drivers/hwmon/w83l786ng.c
@@ -20,7 +20,7 @@
20/* 20/*
21 * Supports following chips: 21 * Supports following chips:
22 * 22 *
23 * Chip #vin #fanin #pwm #temp wchipid vendid i2c ISA 23 * Chip #vin #fanin #pwm #temp wchipid vendid i2c ISA
24 * w83l786ng 3 2 2 2 0x7b 0x5ca3 yes no 24 * w83l786ng 3 2 2 2 0x7b 0x5ca3 yes no
25 */ 25 */
26 26
diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile
index beee6b2d361..1722f50f247 100644
--- a/drivers/i2c/Makefile
+++ b/drivers/i2c/Makefile
@@ -8,6 +8,7 @@ obj-$(CONFIG_I2C_SMBUS) += i2c-smbus.o
8obj-$(CONFIG_I2C_CHARDEV) += i2c-dev.o 8obj-$(CONFIG_I2C_CHARDEV) += i2c-dev.o
9obj-$(CONFIG_I2C_MUX) += i2c-mux.o 9obj-$(CONFIG_I2C_MUX) += i2c-mux.o
10obj-y += algos/ busses/ muxes/ 10obj-y += algos/ busses/ muxes/
11obj-$(CONFIG_I2C_STUB) += i2c-stub.o
11 12
12ccflags-$(CONFIG_I2C_DEBUG_CORE) := -DDEBUG 13ccflags-$(CONFIG_I2C_DEBUG_CORE) := -DDEBUG
13CFLAGS_i2c-core.o := -Wno-deprecated-declarations 14CFLAGS_i2c-core.o := -Wno-deprecated-declarations
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 65dd599a026..e9df4612b7e 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -81,7 +81,6 @@ config I2C_I801
81 tristate "Intel 82801 (ICH/PCH)" 81 tristate "Intel 82801 (ICH/PCH)"
82 depends on PCI 82 depends on PCI
83 select CHECK_SIGNATURE if X86 && DMI 83 select CHECK_SIGNATURE if X86 && DMI
84 select GPIOLIB if I2C_MUX
85 help 84 help
86 If you say yes to this option, support will be included for the Intel 85 If you say yes to this option, support will be included for the Intel
87 801 family of mainboard I2C interfaces. Specifically, the following 86 801 family of mainboard I2C interfaces. Specifically, the following
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index 2d33d62952c..395b516ffa0 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -85,7 +85,6 @@ obj-$(CONFIG_I2C_ACORN) += i2c-acorn.o
85obj-$(CONFIG_I2C_ELEKTOR) += i2c-elektor.o 85obj-$(CONFIG_I2C_ELEKTOR) += i2c-elektor.o
86obj-$(CONFIG_I2C_PCA_ISA) += i2c-pca-isa.o 86obj-$(CONFIG_I2C_PCA_ISA) += i2c-pca-isa.o
87obj-$(CONFIG_I2C_SIBYTE) += i2c-sibyte.o 87obj-$(CONFIG_I2C_SIBYTE) += i2c-sibyte.o
88obj-$(CONFIG_I2C_STUB) += i2c-stub.o
89obj-$(CONFIG_SCx200_ACB) += scx200_acb.o 88obj-$(CONFIG_SCx200_ACB) += scx200_acb.o
90obj-$(CONFIG_SCx200_I2C) += scx200_i2c.o 89obj-$(CONFIG_SCx200_I2C) += scx200_i2c.o
91 90
diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
index aa59a254be2..c02bf208084 100644
--- a/drivers/i2c/busses/i2c-at91.c
+++ b/drivers/i2c/busses/i2c-at91.c
@@ -39,6 +39,7 @@
39#define AT91_TWI_STOP 0x0002 /* Send a Stop Condition */ 39#define AT91_TWI_STOP 0x0002 /* Send a Stop Condition */
40#define AT91_TWI_MSEN 0x0004 /* Master Transfer Enable */ 40#define AT91_TWI_MSEN 0x0004 /* Master Transfer Enable */
41#define AT91_TWI_SVDIS 0x0020 /* Slave Transfer Disable */ 41#define AT91_TWI_SVDIS 0x0020 /* Slave Transfer Disable */
42#define AT91_TWI_QUICK 0x0040 /* SMBus quick command */
42#define AT91_TWI_SWRST 0x0080 /* Software Reset */ 43#define AT91_TWI_SWRST 0x0080 /* Software Reset */
43 44
44#define AT91_TWI_MMR 0x0004 /* Master Mode Register */ 45#define AT91_TWI_MMR 0x0004 /* Master Mode Register */
@@ -212,7 +213,11 @@ static int at91_do_twi_transfer(struct at91_twi_dev *dev)
212 213
213 INIT_COMPLETION(dev->cmd_complete); 214 INIT_COMPLETION(dev->cmd_complete);
214 dev->transfer_status = 0; 215 dev->transfer_status = 0;
215 if (dev->msg->flags & I2C_M_RD) { 216
217 if (!dev->buf_len) {
218 at91_twi_write(dev, AT91_TWI_CR, AT91_TWI_QUICK);
219 at91_twi_write(dev, AT91_TWI_IER, AT91_TWI_TXCOMP);
220 } else if (dev->msg->flags & I2C_M_RD) {
216 unsigned start_flags = AT91_TWI_START; 221 unsigned start_flags = AT91_TWI_START;
217 222
218 if (at91_twi_read(dev, AT91_TWI_SR) & AT91_TWI_RXRDY) { 223 if (at91_twi_read(dev, AT91_TWI_SR) & AT91_TWI_RXRDY) {
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index 37793156bd9..6abc00d5988 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -82,7 +82,8 @@
82#include <linux/wait.h> 82#include <linux/wait.h>
83#include <linux/err.h> 83#include <linux/err.h>
84 84
85#if defined CONFIG_I2C_MUX || defined CONFIG_I2C_MUX_MODULE 85#if (defined CONFIG_I2C_MUX_GPIO || defined CONFIG_I2C_MUX_GPIO_MODULE) && \
86 defined CONFIG_DMI
86#include <linux/gpio.h> 87#include <linux/gpio.h>
87#include <linux/i2c-mux-gpio.h> 88#include <linux/i2c-mux-gpio.h>
88#include <linux/platform_device.h> 89#include <linux/platform_device.h>
@@ -192,7 +193,8 @@ struct i801_priv {
192 int len; 193 int len;
193 u8 *data; 194 u8 *data;
194 195
195#if defined CONFIG_I2C_MUX || defined CONFIG_I2C_MUX_MODULE 196#if (defined CONFIG_I2C_MUX_GPIO || defined CONFIG_I2C_MUX_GPIO_MODULE) && \
197 defined CONFIG_DMI
196 const struct i801_mux_config *mux_drvdata; 198 const struct i801_mux_config *mux_drvdata;
197 struct platform_device *mux_pdev; 199 struct platform_device *mux_pdev;
198#endif 200#endif
@@ -921,7 +923,8 @@ static void __init input_apanel_init(void) {}
921static void __devinit i801_probe_optional_slaves(struct i801_priv *priv) {} 923static void __devinit i801_probe_optional_slaves(struct i801_priv *priv) {}
922#endif /* CONFIG_X86 && CONFIG_DMI */ 924#endif /* CONFIG_X86 && CONFIG_DMI */
923 925
924#if defined CONFIG_I2C_MUX || defined CONFIG_I2C_MUX_MODULE 926#if (defined CONFIG_I2C_MUX_GPIO || defined CONFIG_I2C_MUX_GPIO_MODULE) && \
927 defined CONFIG_DMI
925static struct i801_mux_config i801_mux_config_asus_z8_d12 = { 928static struct i801_mux_config i801_mux_config_asus_z8_d12 = {
926 .gpio_chip = "gpio_ich", 929 .gpio_chip = "gpio_ich",
927 .values = { 0x02, 0x03 }, 930 .values = { 0x02, 0x03 },
@@ -1059,7 +1062,7 @@ static unsigned int __devinit i801_get_adapter_class(struct i801_priv *priv)
1059 1062
1060 id = dmi_first_match(mux_dmi_table); 1063 id = dmi_first_match(mux_dmi_table);
1061 if (id) { 1064 if (id) {
1062 /* Remove from branch classes from trunk */ 1065 /* Remove branch classes from trunk */
1063 mux_config = id->driver_data; 1066 mux_config = id->driver_data;
1064 for (i = 0; i < mux_config->n_values; i++) 1067 for (i = 0; i < mux_config->n_values; i++)
1065 class &= ~mux_config->classes[i]; 1068 class &= ~mux_config->classes[i];
diff --git a/drivers/i2c/busses/i2c-mxs.c b/drivers/i2c/busses/i2c-mxs.c
index 1f58197062c..0670da79ee5 100644
--- a/drivers/i2c/busses/i2c-mxs.c
+++ b/drivers/i2c/busses/i2c-mxs.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Freescale MXS I2C bus driver 2 * Freescale MXS I2C bus driver
3 * 3 *
4 * Copyright (C) 2011 Wolfram Sang, Pengutronix e.K. 4 * Copyright (C) 2011-2012 Wolfram Sang, Pengutronix e.K.
5 * 5 *
6 * based on a (non-working) driver which was: 6 * based on a (non-working) driver which was:
7 * 7 *
@@ -35,10 +35,6 @@
35 35
36#define DRIVER_NAME "mxs-i2c" 36#define DRIVER_NAME "mxs-i2c"
37 37
38static bool use_pioqueue;
39module_param(use_pioqueue, bool, 0);
40MODULE_PARM_DESC(use_pioqueue, "Use PIOQUEUE mode for transfer instead of DMA");
41
42#define MXS_I2C_CTRL0 (0x00) 38#define MXS_I2C_CTRL0 (0x00)
43#define MXS_I2C_CTRL0_SET (0x04) 39#define MXS_I2C_CTRL0_SET (0x04)
44 40
@@ -75,23 +71,6 @@ MODULE_PARM_DESC(use_pioqueue, "Use PIOQUEUE mode for transfer instead of DMA");
75 MXS_I2C_CTRL1_SLAVE_STOP_IRQ | \ 71 MXS_I2C_CTRL1_SLAVE_STOP_IRQ | \
76 MXS_I2C_CTRL1_SLAVE_IRQ) 72 MXS_I2C_CTRL1_SLAVE_IRQ)
77 73
78#define MXS_I2C_QUEUECTRL (0x60)
79#define MXS_I2C_QUEUECTRL_SET (0x64)
80#define MXS_I2C_QUEUECTRL_CLR (0x68)
81
82#define MXS_I2C_QUEUECTRL_QUEUE_RUN 0x20
83#define MXS_I2C_QUEUECTRL_PIO_QUEUE_MODE 0x04
84
85#define MXS_I2C_QUEUESTAT (0x70)
86#define MXS_I2C_QUEUESTAT_RD_QUEUE_EMPTY 0x00002000
87#define MXS_I2C_QUEUESTAT_WRITE_QUEUE_CNT_MASK 0x0000001F
88
89#define MXS_I2C_QUEUECMD (0x80)
90
91#define MXS_I2C_QUEUEDATA (0x90)
92
93#define MXS_I2C_DATA (0xa0)
94
95 74
96#define MXS_CMD_I2C_SELECT (MXS_I2C_CTRL0_RETAIN_CLOCK | \ 75#define MXS_CMD_I2C_SELECT (MXS_I2C_CTRL0_RETAIN_CLOCK | \
97 MXS_I2C_CTRL0_PRE_SEND_START | \ 76 MXS_I2C_CTRL0_PRE_SEND_START | \
@@ -153,7 +132,6 @@ struct mxs_i2c_dev {
153 const struct mxs_i2c_speed_config *speed; 132 const struct mxs_i2c_speed_config *speed;
154 133
155 /* DMA support components */ 134 /* DMA support components */
156 bool dma_mode;
157 int dma_channel; 135 int dma_channel;
158 struct dma_chan *dmach; 136 struct dma_chan *dmach;
159 struct mxs_dma_data dma_data; 137 struct mxs_dma_data dma_data;
@@ -172,99 +150,6 @@ static void mxs_i2c_reset(struct mxs_i2c_dev *i2c)
172 writel(i2c->speed->timing2, i2c->regs + MXS_I2C_TIMING2); 150 writel(i2c->speed->timing2, i2c->regs + MXS_I2C_TIMING2);
173 151
174 writel(MXS_I2C_IRQ_MASK << 8, i2c->regs + MXS_I2C_CTRL1_SET); 152 writel(MXS_I2C_IRQ_MASK << 8, i2c->regs + MXS_I2C_CTRL1_SET);
175 if (i2c->dma_mode)
176 writel(MXS_I2C_QUEUECTRL_PIO_QUEUE_MODE,
177 i2c->regs + MXS_I2C_QUEUECTRL_CLR);
178 else
179 writel(MXS_I2C_QUEUECTRL_PIO_QUEUE_MODE,
180 i2c->regs + MXS_I2C_QUEUECTRL_SET);
181}
182
183static void mxs_i2c_pioq_setup_read(struct mxs_i2c_dev *i2c, u8 addr, int len,
184 int flags)
185{
186 u32 data;
187
188 writel(MXS_CMD_I2C_SELECT, i2c->regs + MXS_I2C_QUEUECMD);
189
190 data = (addr << 1) | I2C_SMBUS_READ;
191 writel(data, i2c->regs + MXS_I2C_DATA);
192
193 data = MXS_CMD_I2C_READ | MXS_I2C_CTRL0_XFER_COUNT(len) | flags;
194 writel(data, i2c->regs + MXS_I2C_QUEUECMD);
195}
196
197static void mxs_i2c_pioq_setup_write(struct mxs_i2c_dev *i2c,
198 u8 addr, u8 *buf, int len, int flags)
199{
200 u32 data;
201 int i, shifts_left;
202
203 data = MXS_CMD_I2C_WRITE | MXS_I2C_CTRL0_XFER_COUNT(len + 1) | flags;
204 writel(data, i2c->regs + MXS_I2C_QUEUECMD);
205
206 /*
207 * We have to copy the slave address (u8) and buffer (arbitrary number
208 * of u8) into the data register (u32). To achieve that, the u8 are put
209 * into the MSBs of 'data' which is then shifted for the next u8. When
210 * appropriate, 'data' is written to MXS_I2C_DATA. So, the first u32
211 * looks like this:
212 *
213 * 3 2 1 0
214 * 10987654|32109876|54321098|76543210
215 * --------+--------+--------+--------
216 * buffer+2|buffer+1|buffer+0|slave_addr
217 */
218
219 data = ((addr << 1) | I2C_SMBUS_WRITE) << 24;
220
221 for (i = 0; i < len; i++) {
222 data >>= 8;
223 data |= buf[i] << 24;
224 if ((i & 3) == 2)
225 writel(data, i2c->regs + MXS_I2C_DATA);
226 }
227
228 /* Write out the remaining bytes if any */
229 shifts_left = 24 - (i & 3) * 8;
230 if (shifts_left)
231 writel(data >> shifts_left, i2c->regs + MXS_I2C_DATA);
232}
233
234/*
235 * TODO: should be replaceable with a waitqueue and RD_QUEUE_IRQ (setting the
236 * rd_threshold to 1). Couldn't get this to work, though.
237 */
238static int mxs_i2c_wait_for_data(struct mxs_i2c_dev *i2c)
239{
240 unsigned long timeout = jiffies + msecs_to_jiffies(1000);
241
242 while (readl(i2c->regs + MXS_I2C_QUEUESTAT)
243 & MXS_I2C_QUEUESTAT_RD_QUEUE_EMPTY) {
244 if (time_after(jiffies, timeout))
245 return -ETIMEDOUT;
246 cond_resched();
247 }
248
249 return 0;
250}
251
252static int mxs_i2c_finish_read(struct mxs_i2c_dev *i2c, u8 *buf, int len)
253{
254 u32 uninitialized_var(data);
255 int i;
256
257 for (i = 0; i < len; i++) {
258 if ((i & 3) == 0) {
259 if (mxs_i2c_wait_for_data(i2c))
260 return -ETIMEDOUT;
261 data = readl(i2c->regs + MXS_I2C_QUEUEDATA);
262 }
263 buf[i] = data & 0xff;
264 data >>= 8;
265 }
266
267 return 0;
268} 153}
269 154
270static void mxs_i2c_dma_finish(struct mxs_i2c_dev *i2c) 155static void mxs_i2c_dma_finish(struct mxs_i2c_dev *i2c)
@@ -402,12 +287,14 @@ read_init_dma_fail:
402select_init_dma_fail: 287select_init_dma_fail:
403 dma_unmap_sg(i2c->dev, &i2c->sg_io[0], 1, DMA_TO_DEVICE); 288 dma_unmap_sg(i2c->dev, &i2c->sg_io[0], 1, DMA_TO_DEVICE);
404select_init_pio_fail: 289select_init_pio_fail:
290 dmaengine_terminate_all(i2c->dmach);
405 return -EINVAL; 291 return -EINVAL;
406 292
407/* Write failpath. */ 293/* Write failpath. */
408write_init_dma_fail: 294write_init_dma_fail:
409 dma_unmap_sg(i2c->dev, i2c->sg_io, 2, DMA_TO_DEVICE); 295 dma_unmap_sg(i2c->dev, i2c->sg_io, 2, DMA_TO_DEVICE);
410write_init_pio_fail: 296write_init_pio_fail:
297 dmaengine_terminate_all(i2c->dmach);
411 return -EINVAL; 298 return -EINVAL;
412} 299}
413 300
@@ -432,39 +319,17 @@ static int mxs_i2c_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg,
432 init_completion(&i2c->cmd_complete); 319 init_completion(&i2c->cmd_complete);
433 i2c->cmd_err = 0; 320 i2c->cmd_err = 0;
434 321
435 if (i2c->dma_mode) { 322 ret = mxs_i2c_dma_setup_xfer(adap, msg, flags);
436 ret = mxs_i2c_dma_setup_xfer(adap, msg, flags); 323 if (ret)
437 if (ret) 324 return ret;
438 return ret;
439 } else {
440 if (msg->flags & I2C_M_RD) {
441 mxs_i2c_pioq_setup_read(i2c, msg->addr,
442 msg->len, flags);
443 } else {
444 mxs_i2c_pioq_setup_write(i2c, msg->addr, msg->buf,
445 msg->len, flags);
446 }
447
448 writel(MXS_I2C_QUEUECTRL_QUEUE_RUN,
449 i2c->regs + MXS_I2C_QUEUECTRL_SET);
450 }
451 325
452 ret = wait_for_completion_timeout(&i2c->cmd_complete, 326 ret = wait_for_completion_timeout(&i2c->cmd_complete,
453 msecs_to_jiffies(1000)); 327 msecs_to_jiffies(1000));
454 if (ret == 0) 328 if (ret == 0)
455 goto timeout; 329 goto timeout;
456 330
457 if (!i2c->dma_mode && !i2c->cmd_err && (msg->flags & I2C_M_RD)) {
458 ret = mxs_i2c_finish_read(i2c, msg->buf, msg->len);
459 if (ret)
460 goto timeout;
461 }
462
463 if (i2c->cmd_err == -ENXIO) 331 if (i2c->cmd_err == -ENXIO)
464 mxs_i2c_reset(i2c); 332 mxs_i2c_reset(i2c);
465 else
466 writel(MXS_I2C_QUEUECTRL_QUEUE_RUN,
467 i2c->regs + MXS_I2C_QUEUECTRL_CLR);
468 333
469 dev_dbg(i2c->dev, "Done with err=%d\n", i2c->cmd_err); 334 dev_dbg(i2c->dev, "Done with err=%d\n", i2c->cmd_err);
470 335
@@ -472,8 +337,7 @@ static int mxs_i2c_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg,
472 337
473timeout: 338timeout:
474 dev_dbg(i2c->dev, "Timeout!\n"); 339 dev_dbg(i2c->dev, "Timeout!\n");
475 if (i2c->dma_mode) 340 mxs_i2c_dma_finish(i2c);
476 mxs_i2c_dma_finish(i2c);
477 mxs_i2c_reset(i2c); 341 mxs_i2c_reset(i2c);
478 return -ETIMEDOUT; 342 return -ETIMEDOUT;
479} 343}
@@ -502,7 +366,6 @@ static irqreturn_t mxs_i2c_isr(int this_irq, void *dev_id)
502{ 366{
503 struct mxs_i2c_dev *i2c = dev_id; 367 struct mxs_i2c_dev *i2c = dev_id;
504 u32 stat = readl(i2c->regs + MXS_I2C_CTRL1) & MXS_I2C_IRQ_MASK; 368 u32 stat = readl(i2c->regs + MXS_I2C_CTRL1) & MXS_I2C_IRQ_MASK;
505 bool is_last_cmd;
506 369
507 if (!stat) 370 if (!stat)
508 return IRQ_NONE; 371 return IRQ_NONE;
@@ -515,14 +378,6 @@ static irqreturn_t mxs_i2c_isr(int this_irq, void *dev_id)
515 /* MXS_I2C_CTRL1_OVERSIZE_XFER_TERM_IRQ is only for slaves */ 378 /* MXS_I2C_CTRL1_OVERSIZE_XFER_TERM_IRQ is only for slaves */
516 i2c->cmd_err = -EIO; 379 i2c->cmd_err = -EIO;
517 380
518 if (!i2c->dma_mode) {
519 is_last_cmd = (readl(i2c->regs + MXS_I2C_QUEUESTAT) &
520 MXS_I2C_QUEUESTAT_WRITE_QUEUE_CNT_MASK) == 0;
521
522 if (is_last_cmd || i2c->cmd_err)
523 complete(&i2c->cmd_complete);
524 }
525
526 writel(stat, i2c->regs + MXS_I2C_CTRL1_CLR); 381 writel(stat, i2c->regs + MXS_I2C_CTRL1_CLR);
527 382
528 return IRQ_HANDLED; 383 return IRQ_HANDLED;
@@ -556,23 +411,14 @@ static int mxs_i2c_get_ofdata(struct mxs_i2c_dev *i2c)
556 int ret; 411 int ret;
557 412
558 /* 413 /*
559 * The MXS I2C DMA mode is prefered and enabled by default.
560 * The PIO mode is still supported, but should be used only
561 * for debuging purposes etc.
562 */
563 i2c->dma_mode = !use_pioqueue;
564 if (!i2c->dma_mode)
565 dev_info(dev, "Using PIOQUEUE mode for I2C transfers!\n");
566
567 /*
568 * TODO: This is a temporary solution and should be changed 414 * TODO: This is a temporary solution and should be changed
569 * to use generic DMA binding later when the helpers get in. 415 * to use generic DMA binding later when the helpers get in.
570 */ 416 */
571 ret = of_property_read_u32(node, "fsl,i2c-dma-channel", 417 ret = of_property_read_u32(node, "fsl,i2c-dma-channel",
572 &i2c->dma_channel); 418 &i2c->dma_channel);
573 if (ret) { 419 if (ret) {
574 dev_warn(dev, "Failed to get DMA channel, using PIOQUEUE!\n"); 420 dev_err(dev, "Failed to get DMA channel!\n");
575 i2c->dma_mode = 0; 421 return -ENODEV;
576 } 422 }
577 423
578 ret = of_property_read_u32(node, "clock-frequency", &speed); 424 ret = of_property_read_u32(node, "clock-frequency", &speed);
@@ -634,15 +480,13 @@ static int __devinit mxs_i2c_probe(struct platform_device *pdev)
634 } 480 }
635 481
636 /* Setup the DMA */ 482 /* Setup the DMA */
637 if (i2c->dma_mode) { 483 dma_cap_zero(mask);
638 dma_cap_zero(mask); 484 dma_cap_set(DMA_SLAVE, mask);
639 dma_cap_set(DMA_SLAVE, mask); 485 i2c->dma_data.chan_irq = dmairq;
640 i2c->dma_data.chan_irq = dmairq; 486 i2c->dmach = dma_request_channel(mask, mxs_i2c_dma_filter, i2c);
641 i2c->dmach = dma_request_channel(mask, mxs_i2c_dma_filter, i2c); 487 if (!i2c->dmach) {
642 if (!i2c->dmach) { 488 dev_err(dev, "Failed to request dma\n");
643 dev_err(dev, "Failed to request dma\n"); 489 return -ENODEV;
644 return -ENODEV;
645 }
646 } 490 }
647 491
648 platform_set_drvdata(pdev, i2c); 492 platform_set_drvdata(pdev, i2c);
diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c
index 698d7acb0f0..02c3115a2df 100644
--- a/drivers/i2c/busses/i2c-nomadik.c
+++ b/drivers/i2c/busses/i2c-nomadik.c
@@ -644,7 +644,11 @@ static int nmk_i2c_xfer(struct i2c_adapter *i2c_adap,
644 644
645 pm_runtime_get_sync(&dev->adev->dev); 645 pm_runtime_get_sync(&dev->adev->dev);
646 646
647 clk_enable(dev->clk); 647 status = clk_prepare_enable(dev->clk);
648 if (status) {
649 dev_err(&dev->adev->dev, "can't prepare_enable clock\n");
650 goto out_clk;
651 }
648 652
649 status = init_hw(dev); 653 status = init_hw(dev);
650 if (status) 654 if (status)
@@ -671,7 +675,8 @@ static int nmk_i2c_xfer(struct i2c_adapter *i2c_adap,
671 } 675 }
672 676
673out: 677out:
674 clk_disable(dev->clk); 678 clk_disable_unprepare(dev->clk);
679out_clk:
675 pm_runtime_put_sync(&dev->adev->dev); 680 pm_runtime_put_sync(&dev->adev->dev);
676 681
677 dev->busy = false; 682 dev->busy = false;
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index db31eaed6ea..3525c9e62cb 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -43,7 +43,6 @@
43#include <linux/slab.h> 43#include <linux/slab.h>
44#include <linux/i2c-omap.h> 44#include <linux/i2c-omap.h>
45#include <linux/pm_runtime.h> 45#include <linux/pm_runtime.h>
46#include <linux/pm_qos.h>
47 46
48/* I2C controller revisions */ 47/* I2C controller revisions */
49#define OMAP_I2C_OMAP1_REV_2 0x20 48#define OMAP_I2C_OMAP1_REV_2 0x20
@@ -187,8 +186,9 @@ struct omap_i2c_dev {
187 int reg_shift; /* bit shift for I2C register addresses */ 186 int reg_shift; /* bit shift for I2C register addresses */
188 struct completion cmd_complete; 187 struct completion cmd_complete;
189 struct resource *ioarea; 188 struct resource *ioarea;
190 u32 latency; /* maximum MPU wkup latency */ 189 u32 latency; /* maximum mpu wkup latency */
191 struct pm_qos_request pm_qos_request; 190 void (*set_mpu_wkup_lat)(struct device *dev,
191 long latency);
192 u32 speed; /* Speed of bus in kHz */ 192 u32 speed; /* Speed of bus in kHz */
193 u32 dtrev; /* extra revision from DT */ 193 u32 dtrev; /* extra revision from DT */
194 u32 flags; 194 u32 flags;
@@ -494,7 +494,9 @@ static void omap_i2c_resize_fifo(struct omap_i2c_dev *dev, u8 size, bool is_rx)
494 dev->b_hw = 1; /* Enable hardware fixes */ 494 dev->b_hw = 1; /* Enable hardware fixes */
495 495
496 /* calculate wakeup latency constraint for MPU */ 496 /* calculate wakeup latency constraint for MPU */
497 dev->latency = (1000000 * dev->threshold) / (1000 * dev->speed / 8); 497 if (dev->set_mpu_wkup_lat != NULL)
498 dev->latency = (1000000 * dev->threshold) /
499 (1000 * dev->speed / 8);
498} 500}
499 501
500/* 502/*
@@ -522,6 +524,9 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adap,
522 dev->buf = msg->buf; 524 dev->buf = msg->buf;
523 dev->buf_len = msg->len; 525 dev->buf_len = msg->len;
524 526
527 /* make sure writes to dev->buf_len are ordered */
528 barrier();
529
525 omap_i2c_write_reg(dev, OMAP_I2C_CNT_REG, dev->buf_len); 530 omap_i2c_write_reg(dev, OMAP_I2C_CNT_REG, dev->buf_len);
526 531
527 /* Clear the FIFO Buffers */ 532 /* Clear the FIFO Buffers */
@@ -579,7 +584,6 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adap,
579 */ 584 */
580 timeout = wait_for_completion_timeout(&dev->cmd_complete, 585 timeout = wait_for_completion_timeout(&dev->cmd_complete,
581 OMAP_I2C_TIMEOUT); 586 OMAP_I2C_TIMEOUT);
582 dev->buf_len = 0;
583 if (timeout == 0) { 587 if (timeout == 0) {
584 dev_err(dev->dev, "controller timed out\n"); 588 dev_err(dev->dev, "controller timed out\n");
585 omap_i2c_init(dev); 589 omap_i2c_init(dev);
@@ -629,16 +633,8 @@ omap_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
629 if (r < 0) 633 if (r < 0)
630 goto out; 634 goto out;
631 635
632 /* 636 if (dev->set_mpu_wkup_lat != NULL)
633 * When waiting for completion of a i2c transfer, we need to 637 dev->set_mpu_wkup_lat(dev->dev, dev->latency);
634 * set a wake up latency constraint for the MPU. This is to
635 * ensure quick enough wakeup from idle, when transfer
636 * completes.
637 */
638 if (dev->latency)
639 pm_qos_add_request(&dev->pm_qos_request,
640 PM_QOS_CPU_DMA_LATENCY,
641 dev->latency);
642 638
643 for (i = 0; i < num; i++) { 639 for (i = 0; i < num; i++) {
644 r = omap_i2c_xfer_msg(adap, &msgs[i], (i == (num - 1))); 640 r = omap_i2c_xfer_msg(adap, &msgs[i], (i == (num - 1)));
@@ -646,8 +642,8 @@ omap_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
646 break; 642 break;
647 } 643 }
648 644
649 if (dev->latency) 645 if (dev->set_mpu_wkup_lat != NULL)
650 pm_qos_remove_request(&dev->pm_qos_request); 646 dev->set_mpu_wkup_lat(dev->dev, -1);
651 647
652 if (r == 0) 648 if (r == 0)
653 r = num; 649 r = num;
@@ -1104,6 +1100,7 @@ omap_i2c_probe(struct platform_device *pdev)
1104 } else if (pdata != NULL) { 1100 } else if (pdata != NULL) {
1105 dev->speed = pdata->clkrate; 1101 dev->speed = pdata->clkrate;
1106 dev->flags = pdata->flags; 1102 dev->flags = pdata->flags;
1103 dev->set_mpu_wkup_lat = pdata->set_mpu_wkup_lat;
1107 dev->dtrev = pdata->rev; 1104 dev->dtrev = pdata->rev;
1108 } 1105 }
1109 1106
@@ -1159,8 +1156,9 @@ omap_i2c_probe(struct platform_device *pdev)
1159 dev->b_hw = 1; /* Enable hardware fixes */ 1156 dev->b_hw = 1; /* Enable hardware fixes */
1160 1157
1161 /* calculate wakeup latency constraint for MPU */ 1158 /* calculate wakeup latency constraint for MPU */
1162 dev->latency = (1000000 * dev->fifo_size) / 1159 if (dev->set_mpu_wkup_lat != NULL)
1163 (1000 * dev->speed / 8); 1160 dev->latency = (1000000 * dev->fifo_size) /
1161 (1000 * dev->speed / 8);
1164 } 1162 }
1165 1163
1166 /* reset ASAP, clearing any IRQs */ 1164 /* reset ASAP, clearing any IRQs */
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index 3e0335f1fc6..9d902725bac 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -806,6 +806,7 @@ static int s3c24xx_i2c_parse_dt_gpio(struct s3c24xx_i2c *i2c)
806 dev_err(i2c->dev, "invalid gpio[%d]: %d\n", idx, gpio); 806 dev_err(i2c->dev, "invalid gpio[%d]: %d\n", idx, gpio);
807 goto free_gpio; 807 goto free_gpio;
808 } 808 }
809 i2c->gpios[idx] = gpio;
809 810
810 ret = gpio_request(gpio, "i2c-bus"); 811 ret = gpio_request(gpio, "i2c-bus");
811 if (ret) { 812 if (ret) {
diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
index f981ac4e678..dcea77bf6f5 100644
--- a/drivers/i2c/busses/i2c-tegra.c
+++ b/drivers/i2c/busses/i2c-tegra.c
@@ -742,7 +742,7 @@ static int __devinit tegra_i2c_probe(struct platform_device *pdev)
742 } 742 }
743 743
744 ret = devm_request_irq(&pdev->dev, i2c_dev->irq, 744 ret = devm_request_irq(&pdev->dev, i2c_dev->irq,
745 tegra_i2c_isr, 0, pdev->name, i2c_dev); 745 tegra_i2c_isr, 0, dev_name(&pdev->dev), i2c_dev);
746 if (ret) { 746 if (ret) {
747 dev_err(&pdev->dev, "Failed to request irq %i\n", i2c_dev->irq); 747 dev_err(&pdev->dev, "Failed to request irq %i\n", i2c_dev->irq);
748 return ret; 748 return ret;
diff --git a/drivers/i2c/busses/i2c-stub.c b/drivers/i2c/i2c-stub.c
index b1b3447942c..d0a9c590c3c 100644
--- a/drivers/i2c/busses/i2c-stub.c
+++ b/drivers/i2c/i2c-stub.c
@@ -2,7 +2,7 @@
2 i2c-stub.c - I2C/SMBus chip emulator 2 i2c-stub.c - I2C/SMBus chip emulator
3 3
4 Copyright (c) 2004 Mark M. Hoffman <mhoffman@lightlink.com> 4 Copyright (c) 2004 Mark M. Hoffman <mhoffman@lightlink.com>
5 Copyright (C) 2007 Jean Delvare <khali@linux-fr.org> 5 Copyright (C) 2007, 2012 Jean Delvare <khali@linux-fr.org>
6 6
7 This program is free software; you can redistribute it and/or modify 7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
@@ -51,8 +51,8 @@ struct stub_chip {
51static struct stub_chip *stub_chips; 51static struct stub_chip *stub_chips;
52 52
53/* Return negative errno on error. */ 53/* Return negative errno on error. */
54static s32 stub_xfer(struct i2c_adapter * adap, u16 addr, unsigned short flags, 54static s32 stub_xfer(struct i2c_adapter *adap, u16 addr, unsigned short flags,
55 char read_write, u8 command, int size, union i2c_smbus_data * data) 55 char read_write, u8 command, int size, union i2c_smbus_data *data)
56{ 56{
57 s32 ret; 57 s32 ret;
58 int i, len; 58 int i, len;
@@ -78,14 +78,14 @@ static s32 stub_xfer(struct i2c_adapter * adap, u16 addr, unsigned short flags,
78 case I2C_SMBUS_BYTE: 78 case I2C_SMBUS_BYTE:
79 if (read_write == I2C_SMBUS_WRITE) { 79 if (read_write == I2C_SMBUS_WRITE) {
80 chip->pointer = command; 80 chip->pointer = command;
81 dev_dbg(&adap->dev, "smbus byte - addr 0x%02x, " 81 dev_dbg(&adap->dev,
82 "wrote 0x%02x.\n", 82 "smbus byte - addr 0x%02x, wrote 0x%02x.\n",
83 addr, command); 83 addr, command);
84 } else { 84 } else {
85 data->byte = chip->words[chip->pointer++] & 0xff; 85 data->byte = chip->words[chip->pointer++] & 0xff;
86 dev_dbg(&adap->dev, "smbus byte - addr 0x%02x, " 86 dev_dbg(&adap->dev,
87 "read 0x%02x.\n", 87 "smbus byte - addr 0x%02x, read 0x%02x.\n",
88 addr, data->byte); 88 addr, data->byte);
89 } 89 }
90 90
91 ret = 0; 91 ret = 0;
@@ -95,14 +95,14 @@ static s32 stub_xfer(struct i2c_adapter * adap, u16 addr, unsigned short flags,
95 if (read_write == I2C_SMBUS_WRITE) { 95 if (read_write == I2C_SMBUS_WRITE) {
96 chip->words[command] &= 0xff00; 96 chip->words[command] &= 0xff00;
97 chip->words[command] |= data->byte; 97 chip->words[command] |= data->byte;
98 dev_dbg(&adap->dev, "smbus byte data - addr 0x%02x, " 98 dev_dbg(&adap->dev,
99 "wrote 0x%02x at 0x%02x.\n", 99 "smbus byte data - addr 0x%02x, wrote 0x%02x at 0x%02x.\n",
100 addr, data->byte, command); 100 addr, data->byte, command);
101 } else { 101 } else {
102 data->byte = chip->words[command] & 0xff; 102 data->byte = chip->words[command] & 0xff;
103 dev_dbg(&adap->dev, "smbus byte data - addr 0x%02x, " 103 dev_dbg(&adap->dev,
104 "read 0x%02x at 0x%02x.\n", 104 "smbus byte data - addr 0x%02x, read 0x%02x at 0x%02x.\n",
105 addr, data->byte, command); 105 addr, data->byte, command);
106 } 106 }
107 chip->pointer = command + 1; 107 chip->pointer = command + 1;
108 108
@@ -112,14 +112,14 @@ static s32 stub_xfer(struct i2c_adapter * adap, u16 addr, unsigned short flags,
112 case I2C_SMBUS_WORD_DATA: 112 case I2C_SMBUS_WORD_DATA:
113 if (read_write == I2C_SMBUS_WRITE) { 113 if (read_write == I2C_SMBUS_WRITE) {
114 chip->words[command] = data->word; 114 chip->words[command] = data->word;
115 dev_dbg(&adap->dev, "smbus word data - addr 0x%02x, " 115 dev_dbg(&adap->dev,
116 "wrote 0x%04x at 0x%02x.\n", 116 "smbus word data - addr 0x%02x, wrote 0x%04x at 0x%02x.\n",
117 addr, data->word, command); 117 addr, data->word, command);
118 } else { 118 } else {
119 data->word = chip->words[command]; 119 data->word = chip->words[command];
120 dev_dbg(&adap->dev, "smbus word data - addr 0x%02x, " 120 dev_dbg(&adap->dev,
121 "read 0x%04x at 0x%02x.\n", 121 "smbus word data - addr 0x%02x, read 0x%04x at 0x%02x.\n",
122 addr, data->word, command); 122 addr, data->word, command);
123 } 123 }
124 124
125 ret = 0; 125 ret = 0;
@@ -132,17 +132,17 @@ static s32 stub_xfer(struct i2c_adapter * adap, u16 addr, unsigned short flags,
132 chip->words[command + i] &= 0xff00; 132 chip->words[command + i] &= 0xff00;
133 chip->words[command + i] |= data->block[1 + i]; 133 chip->words[command + i] |= data->block[1 + i];
134 } 134 }
135 dev_dbg(&adap->dev, "i2c block data - addr 0x%02x, " 135 dev_dbg(&adap->dev,
136 "wrote %d bytes at 0x%02x.\n", 136 "i2c block data - addr 0x%02x, wrote %d bytes at 0x%02x.\n",
137 addr, len, command); 137 addr, len, command);
138 } else { 138 } else {
139 for (i = 0; i < len; i++) { 139 for (i = 0; i < len; i++) {
140 data->block[1 + i] = 140 data->block[1 + i] =
141 chip->words[command + i] & 0xff; 141 chip->words[command + i] & 0xff;
142 } 142 }
143 dev_dbg(&adap->dev, "i2c block data - addr 0x%02x, " 143 dev_dbg(&adap->dev,
144 "read %d bytes at 0x%02x.\n", 144 "i2c block data - addr 0x%02x, read %d bytes at 0x%02x.\n",
145 addr, len, command); 145 addr, len, command);
146 } 146 }
147 147
148 ret = 0; 148 ret = 0;
@@ -179,25 +179,24 @@ static int __init i2c_stub_init(void)
179 int i, ret; 179 int i, ret;
180 180
181 if (!chip_addr[0]) { 181 if (!chip_addr[0]) {
182 printk(KERN_ERR "i2c-stub: Please specify a chip address\n"); 182 pr_err("i2c-stub: Please specify a chip address\n");
183 return -ENODEV; 183 return -ENODEV;
184 } 184 }
185 185
186 for (i = 0; i < MAX_CHIPS && chip_addr[i]; i++) { 186 for (i = 0; i < MAX_CHIPS && chip_addr[i]; i++) {
187 if (chip_addr[i] < 0x03 || chip_addr[i] > 0x77) { 187 if (chip_addr[i] < 0x03 || chip_addr[i] > 0x77) {
188 printk(KERN_ERR "i2c-stub: Invalid chip address " 188 pr_err("i2c-stub: Invalid chip address 0x%02x\n",
189 "0x%02x\n", chip_addr[i]); 189 chip_addr[i]);
190 return -EINVAL; 190 return -EINVAL;
191 } 191 }
192 192
193 printk(KERN_INFO "i2c-stub: Virtual chip at 0x%02x\n", 193 pr_info("i2c-stub: Virtual chip at 0x%02x\n", chip_addr[i]);
194 chip_addr[i]);
195 } 194 }
196 195
197 /* Allocate memory for all chips at once */ 196 /* Allocate memory for all chips at once */
198 stub_chips = kzalloc(i * sizeof(struct stub_chip), GFP_KERNEL); 197 stub_chips = kzalloc(i * sizeof(struct stub_chip), GFP_KERNEL);
199 if (!stub_chips) { 198 if (!stub_chips) {
200 printk(KERN_ERR "i2c-stub: Out of memory\n"); 199 pr_err("i2c-stub: Out of memory\n");
201 return -ENOMEM; 200 return -ENOMEM;
202 } 201 }
203 202
@@ -219,4 +218,3 @@ MODULE_LICENSE("GPL");
219 218
220module_init(i2c_stub_init); 219module_init(i2c_stub_init);
221module_exit(i2c_stub_exit); 220module_exit(i2c_stub_exit);
222
diff --git a/drivers/i2c/muxes/i2c-mux-pinctrl.c b/drivers/i2c/muxes/i2c-mux-pinctrl.c
index 5f097f309b9..7fa5b24b16d 100644
--- a/drivers/i2c/muxes/i2c-mux-pinctrl.c
+++ b/drivers/i2c/muxes/i2c-mux-pinctrl.c
@@ -169,7 +169,7 @@ static int __devinit i2c_mux_pinctrl_probe(struct platform_device *pdev)
169 mux->busses = devm_kzalloc(&pdev->dev, 169 mux->busses = devm_kzalloc(&pdev->dev,
170 sizeof(mux->busses) * mux->pdata->bus_count, 170 sizeof(mux->busses) * mux->pdata->bus_count,
171 GFP_KERNEL); 171 GFP_KERNEL);
172 if (!mux->states) { 172 if (!mux->busses) {
173 dev_err(&pdev->dev, "Cannot allocate busses\n"); 173 dev_err(&pdev->dev, "Cannot allocate busses\n");
174 ret = -ENOMEM; 174 ret = -ENOMEM;
175 goto err; 175 goto err;
diff --git a/drivers/iio/Kconfig b/drivers/iio/Kconfig
index 6e3f143fc71..fc937aca71f 100644
--- a/drivers/iio/Kconfig
+++ b/drivers/iio/Kconfig
@@ -62,7 +62,6 @@ source "drivers/iio/frequency/Kconfig"
62source "drivers/iio/dac/Kconfig" 62source "drivers/iio/dac/Kconfig"
63source "drivers/iio/common/Kconfig" 63source "drivers/iio/common/Kconfig"
64source "drivers/iio/gyro/Kconfig" 64source "drivers/iio/gyro/Kconfig"
65source "drivers/iio/light/Kconfig"
66source "drivers/iio/magnetometer/Kconfig" 65source "drivers/iio/magnetometer/Kconfig"
67 66
68endif # IIO 67endif # IIO
diff --git a/drivers/iio/Makefile b/drivers/iio/Makefile
index f7fa3c0867b..761f2b65ac5 100644
--- a/drivers/iio/Makefile
+++ b/drivers/iio/Makefile
@@ -18,5 +18,4 @@ obj-y += frequency/
18obj-y += dac/ 18obj-y += dac/
19obj-y += common/ 19obj-y += common/
20obj-y += gyro/ 20obj-y += gyro/
21obj-y += light/
22obj-y += magnetometer/ 21obj-y += magnetometer/
diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
index 57e07c61ace..afd81790ab3 100644
--- a/drivers/infiniband/hw/cxgb4/mem.c
+++ b/drivers/infiniband/hw/cxgb4/mem.c
@@ -468,7 +468,7 @@ struct ib_mr *c4iw_register_phys_mem(struct ib_pd *pd,
468 ret = alloc_pbl(mhp, npages); 468 ret = alloc_pbl(mhp, npages);
469 if (ret) { 469 if (ret) {
470 kfree(page_list); 470 kfree(page_list);
471 goto err_pbl; 471 goto err;
472 } 472 }
473 473
474 ret = write_pbl(&mhp->rhp->rdev, page_list, mhp->attr.pbl_addr, 474 ret = write_pbl(&mhp->rhp->rdev, page_list, mhp->attr.pbl_addr,
diff --git a/drivers/infiniband/hw/mlx4/alias_GUID.c b/drivers/infiniband/hw/mlx4/alias_GUID.c
index d2fb38d4357..2f215b93db6 100644
--- a/drivers/infiniband/hw/mlx4/alias_GUID.c
+++ b/drivers/infiniband/hw/mlx4/alias_GUID.c
@@ -107,7 +107,7 @@ static __be64 get_cached_alias_guid(struct mlx4_ib_dev *dev, int port, int index
107{ 107{
108 if (index >= NUM_ALIAS_GUID_PER_PORT) { 108 if (index >= NUM_ALIAS_GUID_PER_PORT) {
109 pr_err("%s: ERROR: asked for index:%d\n", __func__, index); 109 pr_err("%s: ERROR: asked for index:%d\n", __func__, index);
110 return (__force __be64) ((u64) 0xFFFFFFFFFFFFFFFFUL); 110 return (__force __be64) -1;
111 } 111 }
112 return *(__be64 *)&dev->sriov.demux[port - 1].guid_cache[index]; 112 return *(__be64 *)&dev->sriov.demux[port - 1].guid_cache[index];
113} 113}
diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 21a794152d1..0a903c129f0 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -409,38 +409,45 @@ int mlx4_ib_find_real_gid(struct ib_device *ibdev, u8 port, __be64 guid)
409} 409}
410 410
411 411
412static int get_pkey_phys_indices(struct mlx4_ib_dev *ibdev, u8 port, u8 ph_pkey_ix, 412static int find_slave_port_pkey_ix(struct mlx4_ib_dev *dev, int slave,
413 u8 *full_pk_ix, u8 *partial_pk_ix, 413 u8 port, u16 pkey, u16 *ix)
414 int *is_full_member)
415{ 414{
416 u16 search_pkey; 415 int i, ret;
417 int fm; 416 u8 unassigned_pkey_ix, pkey_ix, partial_ix = 0xFF;
418 int err = 0; 417 u16 slot_pkey;
419 u16 pk;
420 418
421 err = ib_get_cached_pkey(&ibdev->ib_dev, port, ph_pkey_ix, &search_pkey); 419 if (slave == mlx4_master_func_num(dev->dev))
422 if (err) 420 return ib_find_cached_pkey(&dev->ib_dev, port, pkey, ix);
423 return err;
424 421
425 fm = (search_pkey & 0x8000) ? 1 : 0; 422 unassigned_pkey_ix = dev->dev->phys_caps.pkey_phys_table_len[port] - 1;
426 if (fm) {
427 *full_pk_ix = ph_pkey_ix;
428 search_pkey &= 0x7FFF;
429 } else {
430 *partial_pk_ix = ph_pkey_ix;
431 search_pkey |= 0x8000;
432 }
433 423
434 if (ib_find_exact_cached_pkey(&ibdev->ib_dev, port, search_pkey, &pk)) 424 for (i = 0; i < dev->dev->caps.pkey_table_len[port]; i++) {
435 pk = 0xFFFF; 425 if (dev->pkeys.virt2phys_pkey[slave][port - 1][i] == unassigned_pkey_ix)
426 continue;
436 427
437 if (fm) 428 pkey_ix = dev->pkeys.virt2phys_pkey[slave][port - 1][i];
438 *partial_pk_ix = (pk & 0xFF);
439 else
440 *full_pk_ix = (pk & 0xFF);
441 429
442 *is_full_member = fm; 430 ret = ib_get_cached_pkey(&dev->ib_dev, port, pkey_ix, &slot_pkey);
443 return err; 431 if (ret)
432 continue;
433 if ((slot_pkey & 0x7FFF) == (pkey & 0x7FFF)) {
434 if (slot_pkey & 0x8000) {
435 *ix = (u16) pkey_ix;
436 return 0;
437 } else {
438 /* take first partial pkey index found */
439 if (partial_ix == 0xFF)
440 partial_ix = pkey_ix;
441 }
442 }
443 }
444
445 if (partial_ix < 0xFF) {
446 *ix = (u16) partial_ix;
447 return 0;
448 }
449
450 return -EINVAL;
444} 451}
445 452
446int mlx4_ib_send_to_slave(struct mlx4_ib_dev *dev, int slave, u8 port, 453int mlx4_ib_send_to_slave(struct mlx4_ib_dev *dev, int slave, u8 port,
@@ -458,10 +465,8 @@ int mlx4_ib_send_to_slave(struct mlx4_ib_dev *dev, int slave, u8 port,
458 unsigned tun_tx_ix = 0; 465 unsigned tun_tx_ix = 0;
459 int dqpn; 466 int dqpn;
460 int ret = 0; 467 int ret = 0;
461 int i;
462 int is_full_member = 0;
463 u16 tun_pkey_ix; 468 u16 tun_pkey_ix;
464 u8 ph_pkey_ix, full_pk_ix = 0, partial_pk_ix = 0; 469 u16 cached_pkey;
465 470
466 if (dest_qpt > IB_QPT_GSI) 471 if (dest_qpt > IB_QPT_GSI)
467 return -EINVAL; 472 return -EINVAL;
@@ -481,27 +486,17 @@ int mlx4_ib_send_to_slave(struct mlx4_ib_dev *dev, int slave, u8 port,
481 else 486 else
482 tun_qp = &tun_ctx->qp[1]; 487 tun_qp = &tun_ctx->qp[1];
483 488
484 /* compute pkey index for slave */ 489 /* compute P_Key index to put in tunnel header for slave */
485 /* get physical pkey -- virtualized Dom0 pkey to phys*/
486 if (dest_qpt) { 490 if (dest_qpt) {
487 ph_pkey_ix = 491 u16 pkey_ix;
488 dev->pkeys.virt2phys_pkey[mlx4_master_func_num(dev->dev)][port - 1][wc->pkey_index]; 492 ret = ib_get_cached_pkey(&dev->ib_dev, port, wc->pkey_index, &cached_pkey);
489
490 /* now, translate this to the slave pkey index */
491 ret = get_pkey_phys_indices(dev, port, ph_pkey_ix, &full_pk_ix,
492 &partial_pk_ix, &is_full_member);
493 if (ret) 493 if (ret)
494 return -EINVAL; 494 return -EINVAL;
495 495
496 for (i = 0; i < dev->dev->caps.pkey_table_len[port]; i++) { 496 ret = find_slave_port_pkey_ix(dev, slave, port, cached_pkey, &pkey_ix);
497 if ((dev->pkeys.virt2phys_pkey[slave][port - 1][i] == full_pk_ix) || 497 if (ret)
498 (is_full_member &&
499 (dev->pkeys.virt2phys_pkey[slave][port - 1][i] == partial_pk_ix)))
500 break;
501 }
502 if (i == dev->dev->caps.pkey_table_len[port])
503 return -EINVAL; 498 return -EINVAL;
504 tun_pkey_ix = i; 499 tun_pkey_ix = pkey_ix;
505 } else 500 } else
506 tun_pkey_ix = dev->pkeys.virt2phys_pkey[slave][port - 1][0]; 501 tun_pkey_ix = dev->pkeys.virt2phys_pkey[slave][port - 1][0];
507 502
diff --git a/drivers/infiniband/hw/mlx4/mcg.c b/drivers/infiniband/hw/mlx4/mcg.c
index 3c3b54c3fdd..25b2cdff00f 100644
--- a/drivers/infiniband/hw/mlx4/mcg.c
+++ b/drivers/infiniband/hw/mlx4/mcg.c
@@ -233,7 +233,8 @@ static int send_mad_to_slave(int slave, struct mlx4_ib_demux_ctx *ctx,
233 233
234 ib_query_ah(dev->sm_ah[ctx->port - 1], &ah_attr); 234 ib_query_ah(dev->sm_ah[ctx->port - 1], &ah_attr);
235 235
236 wc.pkey_index = 0; 236 if (ib_find_cached_pkey(&dev->ib_dev, ctx->port, IB_DEFAULT_PKEY_FULL, &wc.pkey_index))
237 return -EINVAL;
237 wc.sl = 0; 238 wc.sl = 0;
238 wc.dlid_path_bits = 0; 239 wc.dlid_path_bits = 0;
239 wc.port_num = ctx->port; 240 wc.port_num = ctx->port;
@@ -1074,10 +1075,6 @@ static void _mlx4_ib_mcg_port_cleanup(struct mlx4_ib_demux_ctx *ctx, int destroy
1074 unsigned long end; 1075 unsigned long end;
1075 int count; 1076 int count;
1076 1077
1077 if (ctx->flushing)
1078 return;
1079
1080 ctx->flushing = 1;
1081 for (i = 0; i < MAX_VFS; ++i) 1078 for (i = 0; i < MAX_VFS; ++i)
1082 clean_vf_mcast(ctx, i); 1079 clean_vf_mcast(ctx, i);
1083 1080
@@ -1107,9 +1104,6 @@ static void _mlx4_ib_mcg_port_cleanup(struct mlx4_ib_demux_ctx *ctx, int destroy
1107 force_clean_group(group); 1104 force_clean_group(group);
1108 } 1105 }
1109 mutex_unlock(&ctx->mcg_table_lock); 1106 mutex_unlock(&ctx->mcg_table_lock);
1110
1111 if (!destroy_wq)
1112 ctx->flushing = 0;
1113} 1107}
1114 1108
1115struct clean_work { 1109struct clean_work {
@@ -1123,6 +1117,7 @@ static void mcg_clean_task(struct work_struct *work)
1123 struct clean_work *cw = container_of(work, struct clean_work, work); 1117 struct clean_work *cw = container_of(work, struct clean_work, work);
1124 1118
1125 _mlx4_ib_mcg_port_cleanup(cw->ctx, cw->destroy_wq); 1119 _mlx4_ib_mcg_port_cleanup(cw->ctx, cw->destroy_wq);
1120 cw->ctx->flushing = 0;
1126 kfree(cw); 1121 kfree(cw);
1127} 1122}
1128 1123
@@ -1130,13 +1125,20 @@ void mlx4_ib_mcg_port_cleanup(struct mlx4_ib_demux_ctx *ctx, int destroy_wq)
1130{ 1125{
1131 struct clean_work *work; 1126 struct clean_work *work;
1132 1127
1128 if (ctx->flushing)
1129 return;
1130
1131 ctx->flushing = 1;
1132
1133 if (destroy_wq) { 1133 if (destroy_wq) {
1134 _mlx4_ib_mcg_port_cleanup(ctx, destroy_wq); 1134 _mlx4_ib_mcg_port_cleanup(ctx, destroy_wq);
1135 ctx->flushing = 0;
1135 return; 1136 return;
1136 } 1137 }
1137 1138
1138 work = kmalloc(sizeof *work, GFP_KERNEL); 1139 work = kmalloc(sizeof *work, GFP_KERNEL);
1139 if (!work) { 1140 if (!work) {
1141 ctx->flushing = 0;
1140 mcg_warn("failed allocating work for cleanup\n"); 1142 mcg_warn("failed allocating work for cleanup\n");
1141 return; 1143 return;
1142 } 1144 }
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index 6ae2ac47c9c..f0f8928b3c8 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -292,7 +292,6 @@ static int evdev_release(struct inode *inode, struct file *file)
292 kfree(client); 292 kfree(client);
293 293
294 evdev_close_device(evdev); 294 evdev_close_device(evdev);
295 put_device(&evdev->dev);
296 295
297 return 0; 296 return 0;
298} 297}
@@ -331,7 +330,6 @@ static int evdev_open(struct inode *inode, struct file *file)
331 file->private_data = client; 330 file->private_data = client;
332 nonseekable_open(inode, file); 331 nonseekable_open(inode, file);
333 332
334 get_device(&evdev->dev);
335 return 0; 333 return 0;
336 334
337 err_free_client: 335 err_free_client:
@@ -1001,6 +999,7 @@ static int evdev_connect(struct input_handler *handler, struct input_dev *dev,
1001 goto err_free_evdev; 999 goto err_free_evdev;
1002 1000
1003 cdev_init(&evdev->cdev, &evdev_fops); 1001 cdev_init(&evdev->cdev, &evdev_fops);
1002 evdev->cdev.kobj.parent = &evdev->dev.kobj;
1004 error = cdev_add(&evdev->cdev, evdev->dev.devt, 1); 1003 error = cdev_add(&evdev->cdev, evdev->dev.devt, 1);
1005 if (error) 1004 if (error)
1006 goto err_unregister_handle; 1005 goto err_unregister_handle;
diff --git a/drivers/input/input-mt.c b/drivers/input/input-mt.c
index c0ec7d42c3b..1abbc170d8b 100644
--- a/drivers/input/input-mt.c
+++ b/drivers/input/input-mt.c
@@ -26,10 +26,14 @@ static void copy_abs(struct input_dev *dev, unsigned int dst, unsigned int src)
26 * input_mt_init_slots() - initialize MT input slots 26 * input_mt_init_slots() - initialize MT input slots
27 * @dev: input device supporting MT events and finger tracking 27 * @dev: input device supporting MT events and finger tracking
28 * @num_slots: number of slots used by the device 28 * @num_slots: number of slots used by the device
29 * @flags: mt tasks to handle in core
29 * 30 *
30 * This function allocates all necessary memory for MT slot handling 31 * This function allocates all necessary memory for MT slot handling
31 * in the input device, prepares the ABS_MT_SLOT and 32 * in the input device, prepares the ABS_MT_SLOT and
32 * ABS_MT_TRACKING_ID events for use and sets up appropriate buffers. 33 * ABS_MT_TRACKING_ID events for use and sets up appropriate buffers.
34 * Depending on the flags set, it also performs pointer emulation and
35 * frame synchronization.
36 *
33 * May be called repeatedly. Returns -EINVAL if attempting to 37 * May be called repeatedly. Returns -EINVAL if attempting to
34 * reinitialize with a different number of slots. 38 * reinitialize with a different number of slots.
35 */ 39 */
diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c
index b62b5891f39..f362883c94e 100644
--- a/drivers/input/joydev.c
+++ b/drivers/input/joydev.c
@@ -243,7 +243,6 @@ static int joydev_release(struct inode *inode, struct file *file)
243 kfree(client); 243 kfree(client);
244 244
245 joydev_close_device(joydev); 245 joydev_close_device(joydev);
246 put_device(&joydev->dev);
247 246
248 return 0; 247 return 0;
249} 248}
@@ -270,7 +269,6 @@ static int joydev_open(struct inode *inode, struct file *file)
270 file->private_data = client; 269 file->private_data = client;
271 nonseekable_open(inode, file); 270 nonseekable_open(inode, file);
272 271
273 get_device(&joydev->dev);
274 return 0; 272 return 0;
275 273
276 err_free_client: 274 err_free_client:
@@ -858,6 +856,7 @@ static int joydev_connect(struct input_handler *handler, struct input_dev *dev,
858 goto err_free_joydev; 856 goto err_free_joydev;
859 857
860 cdev_init(&joydev->cdev, &joydev_fops); 858 cdev_init(&joydev->cdev, &joydev_fops);
859 joydev->cdev.kobj.parent = &joydev->dev.kobj;
861 error = cdev_add(&joydev->cdev, joydev->dev.devt, 1); 860 error = cdev_add(&joydev->cdev, joydev->dev.devt, 1);
862 if (error) 861 if (error)
863 goto err_unregister_handle; 862 goto err_unregister_handle;
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index b4b65af8612..de0874054e9 100644
--- a/drivers/input/keyboard/Kconfig
+++ b/drivers/input/keyboard/Kconfig
@@ -335,6 +335,7 @@ config KEYBOARD_LOCOMO
335config KEYBOARD_LPC32XX 335config KEYBOARD_LPC32XX
336 tristate "LPC32XX matrix key scanner support" 336 tristate "LPC32XX matrix key scanner support"
337 depends on ARCH_LPC32XX && OF 337 depends on ARCH_LPC32XX && OF
338 select INPUT_MATRIXKMAP
338 help 339 help
339 Say Y here if you want to use NXP LPC32XX SoC key scanner interface, 340 Say Y here if you want to use NXP LPC32XX SoC key scanner interface,
340 connected to a key matrix. 341 connected to a key matrix.
diff --git a/drivers/input/keyboard/pxa27x_keypad.c b/drivers/input/keyboard/pxa27x_keypad.c
index 803ff6fe021..cad9d5dd597 100644
--- a/drivers/input/keyboard/pxa27x_keypad.c
+++ b/drivers/input/keyboard/pxa27x_keypad.c
@@ -368,6 +368,9 @@ static void pxa27x_keypad_config(struct pxa27x_keypad *keypad)
368 unsigned int mask = 0, direct_key_num = 0; 368 unsigned int mask = 0, direct_key_num = 0;
369 unsigned long kpc = 0; 369 unsigned long kpc = 0;
370 370
371 /* clear pending interrupt bit */
372 keypad_readl(KPC);
373
371 /* enable matrix keys with automatic scan */ 374 /* enable matrix keys with automatic scan */
372 if (pdata->matrix_key_rows && pdata->matrix_key_cols) { 375 if (pdata->matrix_key_rows && pdata->matrix_key_cols) {
373 kpc |= KPC_ASACT | KPC_MIE | KPC_ME | KPC_MS_ALL; 376 kpc |= KPC_ASACT | KPC_MIE | KPC_ME | KPC_MS_ALL;
diff --git a/drivers/input/misc/xen-kbdfront.c b/drivers/input/misc/xen-kbdfront.c
index 02ca8680ea5..6f7d9901303 100644
--- a/drivers/input/misc/xen-kbdfront.c
+++ b/drivers/input/misc/xen-kbdfront.c
@@ -311,7 +311,6 @@ static void xenkbd_backend_changed(struct xenbus_device *dev,
311 case XenbusStateReconfiguring: 311 case XenbusStateReconfiguring:
312 case XenbusStateReconfigured: 312 case XenbusStateReconfigured:
313 case XenbusStateUnknown: 313 case XenbusStateUnknown:
314 case XenbusStateClosed:
315 break; 314 break;
316 315
317 case XenbusStateInitWait: 316 case XenbusStateInitWait:
@@ -350,6 +349,10 @@ InitWait:
350 349
351 break; 350 break;
352 351
352 case XenbusStateClosed:
353 if (dev->state == XenbusStateClosed)
354 break;
355 /* Missed the backend's CLOSING state -- fallthrough */
353 case XenbusStateClosing: 356 case XenbusStateClosing:
354 xenbus_frontend_closed(dev); 357 xenbus_frontend_closed(dev);
355 break; 358 break;
diff --git a/drivers/input/mouse/bcm5974.c b/drivers/input/mouse/bcm5974.c
index 3a78f235fa3..2baff1b79a5 100644
--- a/drivers/input/mouse/bcm5974.c
+++ b/drivers/input/mouse/bcm5974.c
@@ -84,6 +84,10 @@
84#define USB_DEVICE_ID_APPLE_WELLSPRING7_ANSI 0x0262 84#define USB_DEVICE_ID_APPLE_WELLSPRING7_ANSI 0x0262
85#define USB_DEVICE_ID_APPLE_WELLSPRING7_ISO 0x0263 85#define USB_DEVICE_ID_APPLE_WELLSPRING7_ISO 0x0263
86#define USB_DEVICE_ID_APPLE_WELLSPRING7_JIS 0x0264 86#define USB_DEVICE_ID_APPLE_WELLSPRING7_JIS 0x0264
87/* MacbookPro10,2 (unibody, October 2012) */
88#define USB_DEVICE_ID_APPLE_WELLSPRING7A_ANSI 0x0259
89#define USB_DEVICE_ID_APPLE_WELLSPRING7A_ISO 0x025a
90#define USB_DEVICE_ID_APPLE_WELLSPRING7A_JIS 0x025b
87 91
88#define BCM5974_DEVICE(prod) { \ 92#define BCM5974_DEVICE(prod) { \
89 .match_flags = (USB_DEVICE_ID_MATCH_DEVICE | \ 93 .match_flags = (USB_DEVICE_ID_MATCH_DEVICE | \
@@ -137,6 +141,10 @@ static const struct usb_device_id bcm5974_table[] = {
137 BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING7_ANSI), 141 BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING7_ANSI),
138 BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING7_ISO), 142 BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING7_ISO),
139 BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING7_JIS), 143 BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING7_JIS),
144 /* MacbookPro10,2 */
145 BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING7A_ANSI),
146 BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING7A_ISO),
147 BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING7A_JIS),
140 /* Terminating entry */ 148 /* Terminating entry */
141 {} 149 {}
142}; 150};
@@ -379,6 +387,19 @@ static const struct bcm5974_config bcm5974_config_table[] = {
379 { SN_COORD, -150, 6730 }, 387 { SN_COORD, -150, 6730 },
380 { SN_ORIENT, -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION } 388 { SN_ORIENT, -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION }
381 }, 389 },
390 {
391 USB_DEVICE_ID_APPLE_WELLSPRING7A_ANSI,
392 USB_DEVICE_ID_APPLE_WELLSPRING7A_ISO,
393 USB_DEVICE_ID_APPLE_WELLSPRING7A_JIS,
394 HAS_INTEGRATED_BUTTON,
395 0x84, sizeof(struct bt_data),
396 0x81, TYPE2, FINGER_TYPE2, FINGER_TYPE2 + SIZEOF_ALL_FINGERS,
397 { SN_PRESSURE, 0, 300 },
398 { SN_WIDTH, 0, 2048 },
399 { SN_COORD, -4750, 5280 },
400 { SN_COORD, -150, 6730 },
401 { SN_ORIENT, -MAX_FINGER_ORIENTATION, MAX_FINGER_ORIENTATION }
402 },
382 {} 403 {}
383}; 404};
384 405
diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
index a1b4c37956b..4c842c320c2 100644
--- a/drivers/input/mousedev.c
+++ b/drivers/input/mousedev.c
@@ -12,8 +12,8 @@
12#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 12#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
13 13
14#define MOUSEDEV_MINOR_BASE 32 14#define MOUSEDEV_MINOR_BASE 32
15#define MOUSEDEV_MINORS 32 15#define MOUSEDEV_MINORS 31
16#define MOUSEDEV_MIX 31 16#define MOUSEDEV_MIX 63
17 17
18#include <linux/sched.h> 18#include <linux/sched.h>
19#include <linux/slab.h> 19#include <linux/slab.h>
@@ -523,7 +523,6 @@ static int mousedev_release(struct inode *inode, struct file *file)
523 kfree(client); 523 kfree(client);
524 524
525 mousedev_close_device(mousedev); 525 mousedev_close_device(mousedev);
526 put_device(&mousedev->dev);
527 526
528 return 0; 527 return 0;
529} 528}
@@ -558,7 +557,6 @@ static int mousedev_open(struct inode *inode, struct file *file)
558 file->private_data = client; 557 file->private_data = client;
559 nonseekable_open(inode, file); 558 nonseekable_open(inode, file);
560 559
561 get_device(&mousedev->dev);
562 return 0; 560 return 0;
563 561
564 err_free_client: 562 err_free_client:
@@ -892,6 +890,7 @@ static struct mousedev *mousedev_create(struct input_dev *dev,
892 } 890 }
893 891
894 cdev_init(&mousedev->cdev, &mousedev_fops); 892 cdev_init(&mousedev->cdev, &mousedev_fops);
893 mousedev->cdev.kobj.parent = &mousedev->dev.kobj;
895 error = cdev_add(&mousedev->cdev, mousedev->dev.devt, 1); 894 error = cdev_add(&mousedev->cdev, mousedev->dev.devt, 1);
896 if (error) 895 if (error)
897 goto err_unregister_handle; 896 goto err_unregister_handle;
diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
index 9edf9806cff..858ad446de9 100644
--- a/drivers/input/tablet/wacom_sys.c
+++ b/drivers/input/tablet/wacom_sys.c
@@ -391,7 +391,7 @@ static int wacom_parse_hid(struct usb_interface *intf,
391 features->pktlen = WACOM_PKGLEN_TPC2FG; 391 features->pktlen = WACOM_PKGLEN_TPC2FG;
392 } 392 }
393 393
394 if (features->type == MTSCREEN) 394 if (features->type == MTSCREEN || features->type == WACOM_24HDT)
395 features->pktlen = WACOM_PKGLEN_MTOUCH; 395 features->pktlen = WACOM_PKGLEN_MTOUCH;
396 396
397 if (features->type == BAMBOO_PT) { 397 if (features->type == BAMBOO_PT) {
@@ -402,6 +402,14 @@ static int wacom_parse_hid(struct usb_interface *intf,
402 features->x_max = 402 features->x_max =
403 get_unaligned_le16(&report[i + 8]); 403 get_unaligned_le16(&report[i + 8]);
404 i += 15; 404 i += 15;
405 } else if (features->type == WACOM_24HDT) {
406 features->x_max =
407 get_unaligned_le16(&report[i + 3]);
408 features->x_phy =
409 get_unaligned_le16(&report[i + 8]);
410 features->unit = report[i - 1];
411 features->unitExpo = report[i - 3];
412 i += 12;
405 } else { 413 } else {
406 features->x_max = 414 features->x_max =
407 get_unaligned_le16(&report[i + 3]); 415 get_unaligned_le16(&report[i + 3]);
@@ -434,6 +442,12 @@ static int wacom_parse_hid(struct usb_interface *intf,
434 features->y_phy = 442 features->y_phy =
435 get_unaligned_le16(&report[i + 6]); 443 get_unaligned_le16(&report[i + 6]);
436 i += 7; 444 i += 7;
445 } else if (type == WACOM_24HDT) {
446 features->y_max =
447 get_unaligned_le16(&report[i + 3]);
448 features->y_phy =
449 get_unaligned_le16(&report[i - 2]);
450 i += 7;
437 } else if (type == BAMBOO_PT) { 451 } else if (type == BAMBOO_PT) {
438 features->y_phy = 452 features->y_phy =
439 get_unaligned_le16(&report[i + 3]); 453 get_unaligned_le16(&report[i + 3]);
@@ -541,6 +555,9 @@ static int wacom_query_tablet_data(struct usb_interface *intf, struct wacom_feat
541 /* MT Tablet PC touch */ 555 /* MT Tablet PC touch */
542 return wacom_set_device_mode(intf, 3, 4, 4); 556 return wacom_set_device_mode(intf, 3, 4, 4);
543 } 557 }
558 else if (features->type == WACOM_24HDT) {
559 return wacom_set_device_mode(intf, 18, 3, 2);
560 }
544 } else if (features->device_type == BTN_TOOL_PEN) { 561 } else if (features->device_type == BTN_TOOL_PEN) {
545 if (features->type <= BAMBOO_PT && features->type != WIRELESS) { 562 if (features->type <= BAMBOO_PT && features->type != WIRELESS) {
546 return wacom_set_device_mode(intf, 2, 2, 2); 563 return wacom_set_device_mode(intf, 2, 2, 2);
@@ -613,6 +630,30 @@ struct wacom_usbdev_data {
613static LIST_HEAD(wacom_udev_list); 630static LIST_HEAD(wacom_udev_list);
614static DEFINE_MUTEX(wacom_udev_list_lock); 631static DEFINE_MUTEX(wacom_udev_list_lock);
615 632
633static struct usb_device *wacom_get_sibling(struct usb_device *dev, int vendor, int product)
634{
635 int port1;
636 struct usb_device *sibling;
637
638 if (vendor == 0 && product == 0)
639 return dev;
640
641 if (dev->parent == NULL)
642 return NULL;
643
644 usb_hub_for_each_child(dev->parent, port1, sibling) {
645 struct usb_device_descriptor *d;
646 if (sibling == NULL)
647 continue;
648
649 d = &sibling->descriptor;
650 if (d->idVendor == vendor && d->idProduct == product)
651 return sibling;
652 }
653
654 return NULL;
655}
656
616static struct wacom_usbdev_data *wacom_get_usbdev_data(struct usb_device *dev) 657static struct wacom_usbdev_data *wacom_get_usbdev_data(struct usb_device *dev)
617{ 658{
618 struct wacom_usbdev_data *data; 659 struct wacom_usbdev_data *data;
@@ -1257,13 +1298,19 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
1257 strlcpy(wacom_wac->name, features->name, sizeof(wacom_wac->name)); 1298 strlcpy(wacom_wac->name, features->name, sizeof(wacom_wac->name));
1258 1299
1259 if (features->quirks & WACOM_QUIRK_MULTI_INPUT) { 1300 if (features->quirks & WACOM_QUIRK_MULTI_INPUT) {
1301 struct usb_device *other_dev;
1302
1260 /* Append the device type to the name */ 1303 /* Append the device type to the name */
1261 strlcat(wacom_wac->name, 1304 strlcat(wacom_wac->name,
1262 features->device_type == BTN_TOOL_PEN ? 1305 features->device_type == BTN_TOOL_PEN ?
1263 " Pen" : " Finger", 1306 " Pen" : " Finger",
1264 sizeof(wacom_wac->name)); 1307 sizeof(wacom_wac->name));
1265 1308
1266 error = wacom_add_shared_data(wacom_wac, dev); 1309
1310 other_dev = wacom_get_sibling(dev, features->oVid, features->oPid);
1311 if (other_dev == NULL || wacom_get_usbdev_data(other_dev) == NULL)
1312 other_dev = dev;
1313 error = wacom_add_shared_data(wacom_wac, other_dev);
1267 if (error) 1314 if (error)
1268 goto fail3; 1315 goto fail3;
1269 } 1316 }
diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c
index c3468c8dbd8..0a67031ffc1 100644
--- a/drivers/input/tablet/wacom_wac.c
+++ b/drivers/input/tablet/wacom_wac.c
@@ -806,6 +806,70 @@ static int find_slot_from_contactid(struct wacom_wac *wacom, int contactid)
806 return -1; 806 return -1;
807} 807}
808 808
809static int int_dist(int x1, int y1, int x2, int y2)
810{
811 int x = x2 - x1;
812 int y = y2 - y1;
813
814 return int_sqrt(x*x + y*y);
815}
816
817static int wacom_24hdt_irq(struct wacom_wac *wacom)
818{
819 struct input_dev *input = wacom->input;
820 char *data = wacom->data;
821 int i;
822 int current_num_contacts = data[61];
823 int contacts_to_send = 0;
824
825 /*
826 * First packet resets the counter since only the first
827 * packet in series will have non-zero current_num_contacts.
828 */
829 if (current_num_contacts)
830 wacom->num_contacts_left = current_num_contacts;
831
832 /* There are at most 4 contacts per packet */
833 contacts_to_send = min(4, wacom->num_contacts_left);
834
835 for (i = 0; i < contacts_to_send; i++) {
836 int offset = (WACOM_BYTES_PER_24HDT_PACKET * i) + 1;
837 bool touch = data[offset] & 0x1 && !wacom->shared->stylus_in_proximity;
838 int id = data[offset + 1];
839 int slot = find_slot_from_contactid(wacom, id);
840
841 if (slot < 0)
842 continue;
843 input_mt_slot(input, slot);
844 input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
845
846 if (touch) {
847 int t_x = le16_to_cpup((__le16 *)&data[offset + 2]);
848 int c_x = le16_to_cpup((__le16 *)&data[offset + 4]);
849 int t_y = le16_to_cpup((__le16 *)&data[offset + 6]);
850 int c_y = le16_to_cpup((__le16 *)&data[offset + 8]);
851 int w = le16_to_cpup((__le16 *)&data[offset + 10]);
852 int h = le16_to_cpup((__le16 *)&data[offset + 12]);
853
854 input_report_abs(input, ABS_MT_POSITION_X, t_x);
855 input_report_abs(input, ABS_MT_POSITION_Y, t_y);
856 input_report_abs(input, ABS_MT_TOUCH_MAJOR, min(w,h));
857 input_report_abs(input, ABS_MT_WIDTH_MAJOR, min(w, h) + int_dist(t_x, t_y, c_x, c_y));
858 input_report_abs(input, ABS_MT_WIDTH_MINOR, min(w, h));
859 input_report_abs(input, ABS_MT_ORIENTATION, w > h);
860 }
861 wacom->slots[slot] = touch ? id : -1;
862 }
863
864 input_mt_report_pointer_emulation(input, true);
865
866 wacom->num_contacts_left -= contacts_to_send;
867 if (wacom->num_contacts_left <= 0)
868 wacom->num_contacts_left = 0;
869
870 return 1;
871}
872
809static int wacom_mt_touch(struct wacom_wac *wacom) 873static int wacom_mt_touch(struct wacom_wac *wacom)
810{ 874{
811 struct input_dev *input = wacom->input; 875 struct input_dev *input = wacom->input;
@@ -1255,6 +1319,10 @@ void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
1255 sync = wacom_intuos_irq(wacom_wac); 1319 sync = wacom_intuos_irq(wacom_wac);
1256 break; 1320 break;
1257 1321
1322 case WACOM_24HDT:
1323 sync = wacom_24hdt_irq(wacom_wac);
1324 break;
1325
1258 case INTUOS5S: 1326 case INTUOS5S:
1259 case INTUOS5: 1327 case INTUOS5:
1260 case INTUOS5L: 1328 case INTUOS5L:
@@ -1340,7 +1408,8 @@ void wacom_setup_device_quirks(struct wacom_features *features)
1340 1408
1341 /* these device have multiple inputs */ 1409 /* these device have multiple inputs */
1342 if (features->type >= WIRELESS || 1410 if (features->type >= WIRELESS ||
1343 (features->type >= INTUOS5S && features->type <= INTUOS5L)) 1411 (features->type >= INTUOS5S && features->type <= INTUOS5L) ||
1412 (features->oVid && features->oPid))
1344 features->quirks |= WACOM_QUIRK_MULTI_INPUT; 1413 features->quirks |= WACOM_QUIRK_MULTI_INPUT;
1345 1414
1346 /* quirk for bamboo touch with 2 low res touches */ 1415 /* quirk for bamboo touch with 2 low res touches */
@@ -1449,6 +1518,9 @@ int wacom_setup_input_capabilities(struct input_dev *input_dev,
1449 1518
1450 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0); 1519 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
1451 input_set_abs_params(input_dev, ABS_THROTTLE, 0, 71, 0, 0); 1520 input_set_abs_params(input_dev, ABS_THROTTLE, 0, 71, 0, 0);
1521
1522 __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
1523
1452 wacom_setup_cintiq(wacom_wac); 1524 wacom_setup_cintiq(wacom_wac);
1453 break; 1525 break;
1454 1526
@@ -1575,6 +1647,15 @@ int wacom_setup_input_capabilities(struct input_dev *input_dev,
1575 __set_bit(INPUT_PROP_POINTER, input_dev->propbit); 1647 __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
1576 break; 1648 break;
1577 1649
1650 case WACOM_24HDT:
1651 if (features->device_type == BTN_TOOL_FINGER) {
1652 input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0);
1653 input_set_abs_params(input_dev, ABS_MT_WIDTH_MAJOR, 0, features->x_max, 0, 0);
1654 input_set_abs_params(input_dev, ABS_MT_WIDTH_MINOR, 0, features->y_max, 0, 0);
1655 input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 1, 0, 0);
1656 }
1657 /* fall through */
1658
1578 case MTSCREEN: 1659 case MTSCREEN:
1579 if (features->device_type == BTN_TOOL_FINGER) { 1660 if (features->device_type == BTN_TOOL_FINGER) {
1580 wacom_wac->slots = kmalloc(features->touch_max * 1661 wacom_wac->slots = kmalloc(features->touch_max *
@@ -1869,8 +1950,11 @@ static const struct wacom_features wacom_features_0xF4 =
1869 { "Wacom Cintiq 24HD", WACOM_PKGLEN_INTUOS, 104480, 65600, 2047, 1950 { "Wacom Cintiq 24HD", WACOM_PKGLEN_INTUOS, 104480, 65600, 2047,
1870 63, WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; 1951 63, WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
1871static const struct wacom_features wacom_features_0xF8 = 1952static const struct wacom_features wacom_features_0xF8 =
1872 { "Wacom Cintiq 24HD touch", WACOM_PKGLEN_INTUOS, 104480, 65600, 2047, 1953 { "Wacom Cintiq 24HD touch", WACOM_PKGLEN_INTUOS, 104480, 65600, 2047, /* Pen */
1873 63, WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; 1954 63, WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf6 };
1955static const struct wacom_features wacom_features_0xF6 =
1956 { "Wacom Cintiq 24HD touch", .type = WACOM_24HDT, /* Touch */
1957 .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf8, .touch_max = 10 };
1874static const struct wacom_features wacom_features_0x3F = 1958static const struct wacom_features wacom_features_0x3F =
1875 { "Wacom Cintiq 21UX", WACOM_PKGLEN_INTUOS, 87200, 65600, 1023, 1959 { "Wacom Cintiq 21UX", WACOM_PKGLEN_INTUOS, 87200, 65600, 1023,
1876 63, CINTIQ, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES }; 1960 63, CINTIQ, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
@@ -2113,6 +2197,7 @@ const struct usb_device_id wacom_ids[] = {
2113 { USB_DEVICE_WACOM(0x47) }, 2197 { USB_DEVICE_WACOM(0x47) },
2114 { USB_DEVICE_WACOM(0xF4) }, 2198 { USB_DEVICE_WACOM(0xF4) },
2115 { USB_DEVICE_WACOM(0xF8) }, 2199 { USB_DEVICE_WACOM(0xF8) },
2200 { USB_DEVICE_WACOM(0xF6) },
2116 { USB_DEVICE_WACOM(0xFA) }, 2201 { USB_DEVICE_WACOM(0xFA) },
2117 { USB_DEVICE_LENOVO(0x6004) }, 2202 { USB_DEVICE_LENOVO(0x6004) },
2118 { } 2203 { }
diff --git a/drivers/input/tablet/wacom_wac.h b/drivers/input/tablet/wacom_wac.h
index 96c185cc301..345f1e76975 100644
--- a/drivers/input/tablet/wacom_wac.h
+++ b/drivers/input/tablet/wacom_wac.h
@@ -29,6 +29,7 @@
29 29
30/* wacom data size per MT contact */ 30/* wacom data size per MT contact */
31#define WACOM_BYTES_PER_MT_PACKET 11 31#define WACOM_BYTES_PER_MT_PACKET 11
32#define WACOM_BYTES_PER_24HDT_PACKET 14
32 33
33/* device IDs */ 34/* device IDs */
34#define STYLUS_DEVICE_ID 0x02 35#define STYLUS_DEVICE_ID 0x02
@@ -49,6 +50,7 @@
49#define WACOM_REPORT_TPCHID 15 50#define WACOM_REPORT_TPCHID 15
50#define WACOM_REPORT_TPCST 16 51#define WACOM_REPORT_TPCST 16
51#define WACOM_REPORT_TPC1FGE 18 52#define WACOM_REPORT_TPC1FGE 18
53#define WACOM_REPORT_24HDT 1
52 54
53/* device quirks */ 55/* device quirks */
54#define WACOM_QUIRK_MULTI_INPUT 0x0001 56#define WACOM_QUIRK_MULTI_INPUT 0x0001
@@ -81,6 +83,7 @@ enum {
81 WACOM_MO, 83 WACOM_MO,
82 WIRELESS, 84 WIRELESS,
83 BAMBOO_PT, 85 BAMBOO_PT,
86 WACOM_24HDT,
84 TABLETPC, /* add new TPC below */ 87 TABLETPC, /* add new TPC below */
85 TABLETPCE, 88 TABLETPCE,
86 TABLETPC2FG, 89 TABLETPC2FG,
@@ -109,6 +112,8 @@ struct wacom_features {
109 int distance_fuzz; 112 int distance_fuzz;
110 unsigned quirks; 113 unsigned quirks;
111 unsigned touch_max; 114 unsigned touch_max;
115 int oVid;
116 int oPid;
112}; 117};
113 118
114struct wacom_shared { 119struct wacom_shared {
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index 1ba232cbc09..f7668b24c37 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -239,7 +239,7 @@ config TOUCHSCREEN_EETI
239 239
240config TOUCHSCREEN_EGALAX 240config TOUCHSCREEN_EGALAX
241 tristate "EETI eGalax multi-touch panel support" 241 tristate "EETI eGalax multi-touch panel support"
242 depends on I2C 242 depends on I2C && OF
243 help 243 help
244 Say Y here to enable support for I2C connected EETI 244 Say Y here to enable support for I2C connected EETI
245 eGalax multi-touch panels. 245 eGalax multi-touch panels.
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index f02028ec3db..78e5d9ab0ba 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -955,7 +955,8 @@ static int ads7846_resume(struct device *dev)
955 955
956static SIMPLE_DEV_PM_OPS(ads7846_pm, ads7846_suspend, ads7846_resume); 956static SIMPLE_DEV_PM_OPS(ads7846_pm, ads7846_suspend, ads7846_resume);
957 957
958static int __devinit ads7846_setup_pendown(struct spi_device *spi, struct ads7846 *ts) 958static int __devinit ads7846_setup_pendown(struct spi_device *spi,
959 struct ads7846 *ts)
959{ 960{
960 struct ads7846_platform_data *pdata = spi->dev.platform_data; 961 struct ads7846_platform_data *pdata = spi->dev.platform_data;
961 int err; 962 int err;
@@ -981,6 +982,9 @@ static int __devinit ads7846_setup_pendown(struct spi_device *spi, struct ads784
981 982
982 ts->gpio_pendown = pdata->gpio_pendown; 983 ts->gpio_pendown = pdata->gpio_pendown;
983 984
985 if (pdata->gpio_pendown_debounce)
986 gpio_set_debounce(pdata->gpio_pendown,
987 pdata->gpio_pendown_debounce);
984 } else { 988 } else {
985 dev_err(&spi->dev, "no get_pendown_state nor gpio_pendown?\n"); 989 dev_err(&spi->dev, "no get_pendown_state nor gpio_pendown?\n");
986 return -EINVAL; 990 return -EINVAL;
diff --git a/drivers/input/touchscreen/egalax_ts.c b/drivers/input/touchscreen/egalax_ts.c
index c1e3460f119..13fa62fdfb0 100644
--- a/drivers/input/touchscreen/egalax_ts.c
+++ b/drivers/input/touchscreen/egalax_ts.c
@@ -28,6 +28,7 @@
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <linux/bitops.h> 29#include <linux/bitops.h>
30#include <linux/input/mt.h> 30#include <linux/input/mt.h>
31#include <linux/of_gpio.h>
31 32
32/* 33/*
33 * Mouse Mode: some panel may configure the controller to mouse mode, 34 * Mouse Mode: some panel may configure the controller to mouse mode,
@@ -122,9 +123,17 @@ static irqreturn_t egalax_ts_interrupt(int irq, void *dev_id)
122/* wake up controller by an falling edge of interrupt gpio. */ 123/* wake up controller by an falling edge of interrupt gpio. */
123static int egalax_wake_up_device(struct i2c_client *client) 124static int egalax_wake_up_device(struct i2c_client *client)
124{ 125{
125 int gpio = irq_to_gpio(client->irq); 126 struct device_node *np = client->dev.of_node;
127 int gpio;
126 int ret; 128 int ret;
127 129
130 if (!np)
131 return -ENODEV;
132
133 gpio = of_get_named_gpio(np, "wakeup-gpios", 0);
134 if (!gpio_is_valid(gpio))
135 return -ENODEV;
136
128 ret = gpio_request(gpio, "egalax_irq"); 137 ret = gpio_request(gpio, "egalax_irq");
129 if (ret < 0) { 138 if (ret < 0) {
130 dev_err(&client->dev, 139 dev_err(&client->dev,
@@ -181,7 +190,11 @@ static int __devinit egalax_ts_probe(struct i2c_client *client,
181 ts->input_dev = input_dev; 190 ts->input_dev = input_dev;
182 191
183 /* controller may be in sleep, wake it up. */ 192 /* controller may be in sleep, wake it up. */
184 egalax_wake_up_device(client); 193 error = egalax_wake_up_device(client);
194 if (error) {
195 dev_err(&client->dev, "Failed to wake up the controller\n");
196 goto err_free_dev;
197 }
185 198
186 ret = egalax_firmware_version(client); 199 ret = egalax_firmware_version(client);
187 if (ret < 0) { 200 if (ret < 0) {
@@ -274,11 +287,17 @@ static int egalax_ts_resume(struct device *dev)
274 287
275static SIMPLE_DEV_PM_OPS(egalax_ts_pm_ops, egalax_ts_suspend, egalax_ts_resume); 288static SIMPLE_DEV_PM_OPS(egalax_ts_pm_ops, egalax_ts_suspend, egalax_ts_resume);
276 289
290static struct of_device_id egalax_ts_dt_ids[] = {
291 { .compatible = "eeti,egalax_ts" },
292 { /* sentinel */ }
293};
294
277static struct i2c_driver egalax_ts_driver = { 295static struct i2c_driver egalax_ts_driver = {
278 .driver = { 296 .driver = {
279 .name = "egalax_ts", 297 .name = "egalax_ts",
280 .owner = THIS_MODULE, 298 .owner = THIS_MODULE,
281 .pm = &egalax_ts_pm_ops, 299 .pm = &egalax_ts_pm_ops,
300 .of_match_table = of_match_ptr(egalax_ts_dt_ids),
282 }, 301 },
283 .id_table = egalax_ts_id, 302 .id_table = egalax_ts_id,
284 .probe = egalax_ts_probe, 303 .probe = egalax_ts_probe,
diff --git a/drivers/input/touchscreen/tsc40.c b/drivers/input/touchscreen/tsc40.c
index 63209aaa55f..eb96f168fb9 100644
--- a/drivers/input/touchscreen/tsc40.c
+++ b/drivers/input/touchscreen/tsc40.c
@@ -107,7 +107,6 @@ static int tsc_connect(struct serio *serio, struct serio_driver *drv)
107 __set_bit(BTN_TOUCH, input_dev->keybit); 107 __set_bit(BTN_TOUCH, input_dev->keybit);
108 input_set_abs_params(ptsc->dev, ABS_X, 0, 0x3ff, 0, 0); 108 input_set_abs_params(ptsc->dev, ABS_X, 0, 0x3ff, 0, 0);
109 input_set_abs_params(ptsc->dev, ABS_Y, 0, 0x3ff, 0, 0); 109 input_set_abs_params(ptsc->dev, ABS_Y, 0, 0x3ff, 0, 0);
110 input_set_abs_params(ptsc->dev, ABS_PRESSURE, 0, 0, 0, 0);
111 110
112 serio_set_drvdata(serio, ptsc); 111 serio_set_drvdata(serio, ptsc);
113 112
diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c
index 18b0d99bd4d..81837b0710a 100644
--- a/drivers/iommu/amd_iommu_init.c
+++ b/drivers/iommu/amd_iommu_init.c
@@ -1599,21 +1599,46 @@ static void __init free_on_init_error(void)
1599#endif 1599#endif
1600} 1600}
1601 1601
1602/* SB IOAPIC is always on this device in AMD systems */
1603#define IOAPIC_SB_DEVID ((0x00 << 8) | PCI_DEVFN(0x14, 0))
1604
1602static bool __init check_ioapic_information(void) 1605static bool __init check_ioapic_information(void)
1603{ 1606{
1607 bool ret, has_sb_ioapic;
1604 int idx; 1608 int idx;
1605 1609
1606 for (idx = 0; idx < nr_ioapics; idx++) { 1610 has_sb_ioapic = false;
1607 int id = mpc_ioapic_id(idx); 1611 ret = false;
1608 1612
1609 if (get_ioapic_devid(id) < 0) { 1613 for (idx = 0; idx < nr_ioapics; idx++) {
1610 pr_err(FW_BUG "AMD-Vi: IO-APIC[%d] not in IVRS table\n", id); 1614 int devid, id = mpc_ioapic_id(idx);
1611 pr_err("AMD-Vi: Disabling interrupt remapping due to BIOS Bug\n"); 1615
1612 return false; 1616 devid = get_ioapic_devid(id);
1617 if (devid < 0) {
1618 pr_err(FW_BUG "AMD-Vi: IOAPIC[%d] not in IVRS table\n", id);
1619 ret = false;
1620 } else if (devid == IOAPIC_SB_DEVID) {
1621 has_sb_ioapic = true;
1622 ret = true;
1613 } 1623 }
1614 } 1624 }
1615 1625
1616 return true; 1626 if (!has_sb_ioapic) {
1627 /*
1628 * We expect the SB IOAPIC to be listed in the IVRS
1629 * table. The system timer is connected to the SB IOAPIC
1630 * and if we don't have it in the list the system will
1631 * panic at boot time. This situation usually happens
1632 * when the BIOS is buggy and provides us the wrong
1633 * device id for the IOAPIC in the system.
1634 */
1635 pr_err(FW_BUG "AMD-Vi: No southbridge IOAPIC found in IVRS table\n");
1636 }
1637
1638 if (!ret)
1639 pr_err("AMD-Vi: Disabling interrupt remapping due to BIOS Bug(s)\n");
1640
1641 return ret;
1617} 1642}
1618 1643
1619static void __init free_dma_resources(void) 1644static void __init free_dma_resources(void)
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index d4a4cd445ca..0badfa48b32 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -4108,7 +4108,7 @@ static void swap_pci_ref(struct pci_dev **from, struct pci_dev *to)
4108static int intel_iommu_add_device(struct device *dev) 4108static int intel_iommu_add_device(struct device *dev)
4109{ 4109{
4110 struct pci_dev *pdev = to_pci_dev(dev); 4110 struct pci_dev *pdev = to_pci_dev(dev);
4111 struct pci_dev *bridge, *dma_pdev; 4111 struct pci_dev *bridge, *dma_pdev = NULL;
4112 struct iommu_group *group; 4112 struct iommu_group *group;
4113 int ret; 4113 int ret;
4114 4114
@@ -4122,7 +4122,7 @@ static int intel_iommu_add_device(struct device *dev)
4122 dma_pdev = pci_get_domain_bus_and_slot( 4122 dma_pdev = pci_get_domain_bus_and_slot(
4123 pci_domain_nr(pdev->bus), 4123 pci_domain_nr(pdev->bus),
4124 bridge->subordinate->number, 0); 4124 bridge->subordinate->number, 0);
4125 else 4125 if (!dma_pdev)
4126 dma_pdev = pci_dev_get(bridge); 4126 dma_pdev = pci_dev_get(bridge);
4127 } else 4127 } else
4128 dma_pdev = pci_dev_get(pdev); 4128 dma_pdev = pci_dev_get(pdev);
diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c
index 0b4d62e0c64..c0f7a426626 100644
--- a/drivers/iommu/tegra-smmu.c
+++ b/drivers/iommu/tegra-smmu.c
@@ -200,7 +200,7 @@ enum {
200 200
201#define SMMU_ADDR_TO_PFN(addr) ((addr) >> 12) 201#define SMMU_ADDR_TO_PFN(addr) ((addr) >> 12)
202#define SMMU_ADDR_TO_PDN(addr) ((addr) >> 22) 202#define SMMU_ADDR_TO_PDN(addr) ((addr) >> 22)
203#define SMMU_PDN_TO_ADDR(addr) ((pdn) << 22) 203#define SMMU_PDN_TO_ADDR(pdn) ((pdn) << 22)
204 204
205#define _READABLE (1 << SMMU_PTB_DATA_ASID_READABLE_SHIFT) 205#define _READABLE (1 << SMMU_PTB_DATA_ASID_READABLE_SHIFT)
206#define _WRITABLE (1 << SMMU_PTB_DATA_ASID_WRITABLE_SHIFT) 206#define _WRITABLE (1 << SMMU_PTB_DATA_ASID_WRITABLE_SHIFT)
@@ -1054,6 +1054,7 @@ static int smmu_debugfs_stats_show(struct seq_file *s, void *v)
1054 stats[i], val, offs); 1054 stats[i], val, offs);
1055 } 1055 }
1056 seq_printf(s, "\n"); 1056 seq_printf(s, "\n");
1057 dput(dent);
1057 1058
1058 return 0; 1059 return 0;
1059} 1060}
diff --git a/drivers/irqchip/irq-bcm2835.c b/drivers/irqchip/irq-bcm2835.c
index dc670ccc697..16c78f1c5ef 100644
--- a/drivers/irqchip/irq-bcm2835.c
+++ b/drivers/irqchip/irq-bcm2835.c
@@ -168,7 +168,8 @@ static int __init armctrl_of_init(struct device_node *node,
168} 168}
169 169
170static struct of_device_id irq_of_match[] __initconst = { 170static struct of_device_id irq_of_match[] __initconst = {
171 { .compatible = "brcm,bcm2835-armctrl-ic", .data = armctrl_of_init } 171 { .compatible = "brcm,bcm2835-armctrl-ic", .data = armctrl_of_init },
172 { }
172}; 173};
173 174
174void __init bcm2835_init_irq(void) 175void __init bcm2835_init_irq(void)
diff --git a/drivers/isdn/Kconfig b/drivers/isdn/Kconfig
index a233ed53913..86cd75a0e84 100644
--- a/drivers/isdn/Kconfig
+++ b/drivers/isdn/Kconfig
@@ -4,7 +4,7 @@
4 4
5menuconfig ISDN 5menuconfig ISDN
6 bool "ISDN support" 6 bool "ISDN support"
7 depends on NET 7 depends on NET && NETDEVICES
8 depends on !S390 && !UML 8 depends on !S390 && !UML
9 ---help--- 9 ---help---
10 ISDN ("Integrated Services Digital Network", called RNIS in France) 10 ISDN ("Integrated Services Digital Network", called RNIS in France)
diff --git a/drivers/isdn/gigaset/bas-gigaset.c b/drivers/isdn/gigaset/bas-gigaset.c
index 52758870894..c44950d3eb7 100644
--- a/drivers/isdn/gigaset/bas-gigaset.c
+++ b/drivers/isdn/gigaset/bas-gigaset.c
@@ -617,7 +617,13 @@ static void int_in_work(struct work_struct *work)
617 if (rc == 0) 617 if (rc == 0)
618 /* success, resubmit interrupt read URB */ 618 /* success, resubmit interrupt read URB */
619 rc = usb_submit_urb(urb, GFP_ATOMIC); 619 rc = usb_submit_urb(urb, GFP_ATOMIC);
620 if (rc != 0 && rc != -ENODEV) { 620
621 switch (rc) {
622 case 0: /* success */
623 case -ENODEV: /* device gone */
624 case -EINVAL: /* URB already resubmitted, or terminal badness */
625 break;
626 default: /* failure: try to recover by resetting the device */
621 dev_err(cs->dev, "clear halt failed: %s\n", get_usb_rcmsg(rc)); 627 dev_err(cs->dev, "clear halt failed: %s\n", get_usb_rcmsg(rc));
622 rc = usb_lock_device_for_reset(ucs->udev, ucs->interface); 628 rc = usb_lock_device_for_reset(ucs->udev, ucs->interface);
623 if (rc == 0) { 629 if (rc == 0) {
@@ -2442,7 +2448,9 @@ static void gigaset_disconnect(struct usb_interface *interface)
2442} 2448}
2443 2449
2444/* gigaset_suspend 2450/* gigaset_suspend
2445 * This function is called before the USB connection is suspended. 2451 * This function is called before the USB connection is suspended
2452 * or before the USB device is reset.
2453 * In the latter case, message == PMSG_ON.
2446 */ 2454 */
2447static int gigaset_suspend(struct usb_interface *intf, pm_message_t message) 2455static int gigaset_suspend(struct usb_interface *intf, pm_message_t message)
2448{ 2456{
@@ -2498,7 +2506,12 @@ static int gigaset_suspend(struct usb_interface *intf, pm_message_t message)
2498 del_timer_sync(&ucs->timer_atrdy); 2506 del_timer_sync(&ucs->timer_atrdy);
2499 del_timer_sync(&ucs->timer_cmd_in); 2507 del_timer_sync(&ucs->timer_cmd_in);
2500 del_timer_sync(&ucs->timer_int_in); 2508 del_timer_sync(&ucs->timer_int_in);
2501 cancel_work_sync(&ucs->int_in_wq); 2509
2510 /* don't try to cancel int_in_wq from within reset as it
2511 * might be the one requesting the reset
2512 */
2513 if (message.event != PM_EVENT_ON)
2514 cancel_work_sync(&ucs->int_in_wq);
2502 2515
2503 gig_dbg(DEBUG_SUSPEND, "suspend complete"); 2516 gig_dbg(DEBUG_SUSPEND, "suspend complete");
2504 return 0; 2517 return 0;
diff --git a/drivers/isdn/i4l/Kconfig b/drivers/isdn/i4l/Kconfig
index 2302fbe70ac..9c6650ea848 100644
--- a/drivers/isdn/i4l/Kconfig
+++ b/drivers/isdn/i4l/Kconfig
@@ -6,7 +6,7 @@ if ISDN_I4L
6 6
7config ISDN_PPP 7config ISDN_PPP
8 bool "Support synchronous PPP" 8 bool "Support synchronous PPP"
9 depends on INET && NETDEVICES 9 depends on INET
10 select SLHC 10 select SLHC
11 help 11 help
12 Over digital connections such as ISDN, there is no need to 12 Over digital connections such as ISDN, there is no need to
diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
index 8c610fa6782..e2a945ee9f0 100644
--- a/drivers/isdn/i4l/isdn_common.c
+++ b/drivers/isdn/i4l/isdn_common.c
@@ -1312,7 +1312,6 @@ isdn_ioctl(struct file *file, uint cmd, ulong arg)
1312 } else 1312 } else
1313 return -EINVAL; 1313 return -EINVAL;
1314 break; 1314 break;
1315#ifdef CONFIG_NETDEVICES
1316 case IIOCNETGPN: 1315 case IIOCNETGPN:
1317 /* Get peer phone number of a connected 1316 /* Get peer phone number of a connected
1318 * isdn network interface */ 1317 * isdn network interface */
@@ -1322,7 +1321,6 @@ isdn_ioctl(struct file *file, uint cmd, ulong arg)
1322 return isdn_net_getpeer(&phone, argp); 1321 return isdn_net_getpeer(&phone, argp);
1323 } else 1322 } else
1324 return -EINVAL; 1323 return -EINVAL;
1325#endif
1326 default: 1324 default:
1327 return -EINVAL; 1325 return -EINVAL;
1328 } 1326 }
@@ -1352,7 +1350,6 @@ isdn_ioctl(struct file *file, uint cmd, ulong arg)
1352 case IIOCNETLCR: 1350 case IIOCNETLCR:
1353 printk(KERN_INFO "INFO: ISDN_ABC_LCR_SUPPORT not enabled\n"); 1351 printk(KERN_INFO "INFO: ISDN_ABC_LCR_SUPPORT not enabled\n");
1354 return -ENODEV; 1352 return -ENODEV;
1355#ifdef CONFIG_NETDEVICES
1356 case IIOCNETAIF: 1353 case IIOCNETAIF:
1357 /* Add a network-interface */ 1354 /* Add a network-interface */
1358 if (arg) { 1355 if (arg) {
@@ -1491,7 +1488,6 @@ isdn_ioctl(struct file *file, uint cmd, ulong arg)
1491 return -EFAULT; 1488 return -EFAULT;
1492 return isdn_net_force_hangup(name); 1489 return isdn_net_force_hangup(name);
1493 break; 1490 break;
1494#endif /* CONFIG_NETDEVICES */
1495 case IIOCSETVER: 1491 case IIOCSETVER:
1496 dev->net_verbose = arg; 1492 dev->net_verbose = arg;
1497 printk(KERN_INFO "isdn: Verbose-Level is %d\n", dev->net_verbose); 1493 printk(KERN_INFO "isdn: Verbose-Level is %d\n", dev->net_verbose);
diff --git a/drivers/leds/ledtrig-cpu.c b/drivers/leds/ledtrig-cpu.c
index b312056da14..4239b3955ff 100644
--- a/drivers/leds/ledtrig-cpu.c
+++ b/drivers/leds/ledtrig-cpu.c
@@ -33,8 +33,6 @@
33struct led_trigger_cpu { 33struct led_trigger_cpu {
34 char name[MAX_NAME_LEN]; 34 char name[MAX_NAME_LEN];
35 struct led_trigger *_trig; 35 struct led_trigger *_trig;
36 struct mutex lock;
37 int lock_is_inited;
38}; 36};
39 37
40static DEFINE_PER_CPU(struct led_trigger_cpu, cpu_trig); 38static DEFINE_PER_CPU(struct led_trigger_cpu, cpu_trig);
@@ -50,12 +48,6 @@ void ledtrig_cpu(enum cpu_led_event ledevt)
50{ 48{
51 struct led_trigger_cpu *trig = &__get_cpu_var(cpu_trig); 49 struct led_trigger_cpu *trig = &__get_cpu_var(cpu_trig);
52 50
53 /* mutex lock should be initialized before calling mutex_call() */
54 if (!trig->lock_is_inited)
55 return;
56
57 mutex_lock(&trig->lock);
58
59 /* Locate the correct CPU LED */ 51 /* Locate the correct CPU LED */
60 switch (ledevt) { 52 switch (ledevt) {
61 case CPU_LED_IDLE_END: 53 case CPU_LED_IDLE_END:
@@ -75,8 +67,6 @@ void ledtrig_cpu(enum cpu_led_event ledevt)
75 /* Will leave the LED as it is */ 67 /* Will leave the LED as it is */
76 break; 68 break;
77 } 69 }
78
79 mutex_unlock(&trig->lock);
80} 70}
81EXPORT_SYMBOL(ledtrig_cpu); 71EXPORT_SYMBOL(ledtrig_cpu);
82 72
@@ -117,14 +107,9 @@ static int __init ledtrig_cpu_init(void)
117 for_each_possible_cpu(cpu) { 107 for_each_possible_cpu(cpu) {
118 struct led_trigger_cpu *trig = &per_cpu(cpu_trig, cpu); 108 struct led_trigger_cpu *trig = &per_cpu(cpu_trig, cpu);
119 109
120 mutex_init(&trig->lock);
121
122 snprintf(trig->name, MAX_NAME_LEN, "cpu%d", cpu); 110 snprintf(trig->name, MAX_NAME_LEN, "cpu%d", cpu);
123 111
124 mutex_lock(&trig->lock);
125 led_trigger_register_simple(trig->name, &trig->_trig); 112 led_trigger_register_simple(trig->name, &trig->_trig);
126 trig->lock_is_inited = 1;
127 mutex_unlock(&trig->lock);
128 } 113 }
129 114
130 register_syscore_ops(&ledtrig_cpu_syscore_ops); 115 register_syscore_ops(&ledtrig_cpu_syscore_ops);
@@ -142,15 +127,9 @@ static void __exit ledtrig_cpu_exit(void)
142 for_each_possible_cpu(cpu) { 127 for_each_possible_cpu(cpu) {
143 struct led_trigger_cpu *trig = &per_cpu(cpu_trig, cpu); 128 struct led_trigger_cpu *trig = &per_cpu(cpu_trig, cpu);
144 129
145 mutex_lock(&trig->lock);
146
147 led_trigger_unregister_simple(trig->_trig); 130 led_trigger_unregister_simple(trig->_trig);
148 trig->_trig = NULL; 131 trig->_trig = NULL;
149 memset(trig->name, 0, MAX_NAME_LEN); 132 memset(trig->name, 0, MAX_NAME_LEN);
150 trig->lock_is_inited = 0;
151
152 mutex_unlock(&trig->lock);
153 mutex_destroy(&trig->lock);
154 } 133 }
155 134
156 unregister_syscore_ops(&ledtrig_cpu_syscore_ops); 135 unregister_syscore_ops(&ledtrig_cpu_syscore_ops);
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 02db9183ca0..77e6eff41ca 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -740,8 +740,14 @@ static void rq_completed(struct mapped_device *md, int rw, int run_queue)
740 if (!md_in_flight(md)) 740 if (!md_in_flight(md))
741 wake_up(&md->wait); 741 wake_up(&md->wait);
742 742
743 /*
744 * Run this off this callpath, as drivers could invoke end_io while
745 * inside their request_fn (and holding the queue lock). Calling
746 * back into ->request_fn() could deadlock attempting to grab the
747 * queue lock again.
748 */
743 if (run_queue) 749 if (run_queue)
744 blk_run_queue(md->queue); 750 blk_run_queue_async(md->queue);
745 751
746 /* 752 /*
747 * dm_put() must be at the end of this function. See the comment above 753 * dm_put() must be at the end of this function. See the comment above
diff --git a/drivers/md/faulty.c b/drivers/md/faulty.c
index 45135f69509..5e7dc772f5d 100644
--- a/drivers/md/faulty.c
+++ b/drivers/md/faulty.c
@@ -315,8 +315,11 @@ static int run(struct mddev *mddev)
315 } 315 }
316 conf->nfaults = 0; 316 conf->nfaults = 0;
317 317
318 rdev_for_each(rdev, mddev) 318 rdev_for_each(rdev, mddev) {
319 conf->rdev = rdev; 319 conf->rdev = rdev;
320 disk_stack_limits(mddev->gendisk, rdev->bdev,
321 rdev->data_offset << 9);
322 }
320 323
321 md_set_array_sectors(mddev, faulty_size(mddev, 0, 0)); 324 md_set_array_sectors(mddev, faulty_size(mddev, 0, 0));
322 mddev->private = conf; 325 mddev->private = conf;
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 9ab768acfb6..61200717687 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -1817,10 +1817,10 @@ retry:
1817 memset(bbp, 0xff, PAGE_SIZE); 1817 memset(bbp, 0xff, PAGE_SIZE);
1818 1818
1819 for (i = 0 ; i < bb->count ; i++) { 1819 for (i = 0 ; i < bb->count ; i++) {
1820 u64 internal_bb = *p++; 1820 u64 internal_bb = p[i];
1821 u64 store_bb = ((BB_OFFSET(internal_bb) << 10) 1821 u64 store_bb = ((BB_OFFSET(internal_bb) << 10)
1822 | BB_LEN(internal_bb)); 1822 | BB_LEN(internal_bb));
1823 *bbp++ = cpu_to_le64(store_bb); 1823 bbp[i] = cpu_to_le64(store_bb);
1824 } 1824 }
1825 bb->changed = 0; 1825 bb->changed = 0;
1826 if (read_seqretry(&bb->lock, seq)) 1826 if (read_seqretry(&bb->lock, seq))
@@ -5294,7 +5294,7 @@ void md_stop_writes(struct mddev *mddev)
5294} 5294}
5295EXPORT_SYMBOL_GPL(md_stop_writes); 5295EXPORT_SYMBOL_GPL(md_stop_writes);
5296 5296
5297void md_stop(struct mddev *mddev) 5297static void __md_stop(struct mddev *mddev)
5298{ 5298{
5299 mddev->ready = 0; 5299 mddev->ready = 0;
5300 mddev->pers->stop(mddev); 5300 mddev->pers->stop(mddev);
@@ -5304,6 +5304,18 @@ void md_stop(struct mddev *mddev)
5304 mddev->pers = NULL; 5304 mddev->pers = NULL;
5305 clear_bit(MD_RECOVERY_FROZEN, &mddev->recovery); 5305 clear_bit(MD_RECOVERY_FROZEN, &mddev->recovery);
5306} 5306}
5307
5308void md_stop(struct mddev *mddev)
5309{
5310 /* stop the array and free an attached data structures.
5311 * This is called from dm-raid
5312 */
5313 __md_stop(mddev);
5314 bitmap_destroy(mddev);
5315 if (mddev->bio_set)
5316 bioset_free(mddev->bio_set);
5317}
5318
5307EXPORT_SYMBOL_GPL(md_stop); 5319EXPORT_SYMBOL_GPL(md_stop);
5308 5320
5309static int md_set_readonly(struct mddev *mddev, struct block_device *bdev) 5321static int md_set_readonly(struct mddev *mddev, struct block_device *bdev)
@@ -5364,7 +5376,7 @@ static int do_md_stop(struct mddev * mddev, int mode,
5364 set_disk_ro(disk, 0); 5376 set_disk_ro(disk, 0);
5365 5377
5366 __md_stop_writes(mddev); 5378 __md_stop_writes(mddev);
5367 md_stop(mddev); 5379 __md_stop(mddev);
5368 mddev->queue->merge_bvec_fn = NULL; 5380 mddev->queue->merge_bvec_fn = NULL;
5369 mddev->queue->backing_dev_info.congested_fn = NULL; 5381 mddev->queue->backing_dev_info.congested_fn = NULL;
5370 5382
@@ -7936,9 +7948,9 @@ int md_is_badblock(struct badblocks *bb, sector_t s, int sectors,
7936 sector_t *first_bad, int *bad_sectors) 7948 sector_t *first_bad, int *bad_sectors)
7937{ 7949{
7938 int hi; 7950 int hi;
7939 int lo = 0; 7951 int lo;
7940 u64 *p = bb->page; 7952 u64 *p = bb->page;
7941 int rv = 0; 7953 int rv;
7942 sector_t target = s + sectors; 7954 sector_t target = s + sectors;
7943 unsigned seq; 7955 unsigned seq;
7944 7956
@@ -7953,7 +7965,8 @@ int md_is_badblock(struct badblocks *bb, sector_t s, int sectors,
7953 7965
7954retry: 7966retry:
7955 seq = read_seqbegin(&bb->lock); 7967 seq = read_seqbegin(&bb->lock);
7956 7968 lo = 0;
7969 rv = 0;
7957 hi = bb->count; 7970 hi = bb->count;
7958 7971
7959 /* Binary search between lo and hi for 'target' 7972 /* Binary search between lo and hi for 'target'
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 8034fbd6190..636bae0405e 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -2710,7 +2710,7 @@ static struct r1conf *setup_conf(struct mddev *mddev)
2710 || disk_idx < 0) 2710 || disk_idx < 0)
2711 continue; 2711 continue;
2712 if (test_bit(Replacement, &rdev->flags)) 2712 if (test_bit(Replacement, &rdev->flags))
2713 disk = conf->mirrors + conf->raid_disks + disk_idx; 2713 disk = conf->mirrors + mddev->raid_disks + disk_idx;
2714 else 2714 else
2715 disk = conf->mirrors + disk_idx; 2715 disk = conf->mirrors + disk_idx;
2716 2716
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 906ccbd0f7d..0d5d0ff2c0f 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -499,7 +499,7 @@ static void raid10_end_write_request(struct bio *bio, int error)
499 */ 499 */
500 one_write_done(r10_bio); 500 one_write_done(r10_bio);
501 if (dec_rdev) 501 if (dec_rdev)
502 rdev_dec_pending(conf->mirrors[dev].rdev, conf->mddev); 502 rdev_dec_pending(rdev, conf->mddev);
503} 503}
504 504
505/* 505/*
@@ -1334,18 +1334,21 @@ retry_write:
1334 blocked_rdev = rrdev; 1334 blocked_rdev = rrdev;
1335 break; 1335 break;
1336 } 1336 }
1337 if (rdev && (test_bit(Faulty, &rdev->flags)
1338 || test_bit(Unmerged, &rdev->flags)))
1339 rdev = NULL;
1337 if (rrdev && (test_bit(Faulty, &rrdev->flags) 1340 if (rrdev && (test_bit(Faulty, &rrdev->flags)
1338 || test_bit(Unmerged, &rrdev->flags))) 1341 || test_bit(Unmerged, &rrdev->flags)))
1339 rrdev = NULL; 1342 rrdev = NULL;
1340 1343
1341 r10_bio->devs[i].bio = NULL; 1344 r10_bio->devs[i].bio = NULL;
1342 r10_bio->devs[i].repl_bio = NULL; 1345 r10_bio->devs[i].repl_bio = NULL;
1343 if (!rdev || test_bit(Faulty, &rdev->flags) || 1346
1344 test_bit(Unmerged, &rdev->flags)) { 1347 if (!rdev && !rrdev) {
1345 set_bit(R10BIO_Degraded, &r10_bio->state); 1348 set_bit(R10BIO_Degraded, &r10_bio->state);
1346 continue; 1349 continue;
1347 } 1350 }
1348 if (test_bit(WriteErrorSeen, &rdev->flags)) { 1351 if (rdev && test_bit(WriteErrorSeen, &rdev->flags)) {
1349 sector_t first_bad; 1352 sector_t first_bad;
1350 sector_t dev_sector = r10_bio->devs[i].addr; 1353 sector_t dev_sector = r10_bio->devs[i].addr;
1351 int bad_sectors; 1354 int bad_sectors;
@@ -1387,8 +1390,10 @@ retry_write:
1387 max_sectors = good_sectors; 1390 max_sectors = good_sectors;
1388 } 1391 }
1389 } 1392 }
1390 r10_bio->devs[i].bio = bio; 1393 if (rdev) {
1391 atomic_inc(&rdev->nr_pending); 1394 r10_bio->devs[i].bio = bio;
1395 atomic_inc(&rdev->nr_pending);
1396 }
1392 if (rrdev) { 1397 if (rrdev) {
1393 r10_bio->devs[i].repl_bio = bio; 1398 r10_bio->devs[i].repl_bio = bio;
1394 atomic_inc(&rrdev->nr_pending); 1399 atomic_inc(&rrdev->nr_pending);
@@ -1444,69 +1449,71 @@ retry_write:
1444 for (i = 0; i < conf->copies; i++) { 1449 for (i = 0; i < conf->copies; i++) {
1445 struct bio *mbio; 1450 struct bio *mbio;
1446 int d = r10_bio->devs[i].devnum; 1451 int d = r10_bio->devs[i].devnum;
1447 if (!r10_bio->devs[i].bio) 1452 if (r10_bio->devs[i].bio) {
1448 continue; 1453 struct md_rdev *rdev = conf->mirrors[d].rdev;
1454 mbio = bio_clone_mddev(bio, GFP_NOIO, mddev);
1455 md_trim_bio(mbio, r10_bio->sector - bio->bi_sector,
1456 max_sectors);
1457 r10_bio->devs[i].bio = mbio;
1458
1459 mbio->bi_sector = (r10_bio->devs[i].addr+
1460 choose_data_offset(r10_bio,
1461 rdev));
1462 mbio->bi_bdev = rdev->bdev;
1463 mbio->bi_end_io = raid10_end_write_request;
1464 mbio->bi_rw = WRITE | do_sync | do_fua | do_discard;
1465 mbio->bi_private = r10_bio;
1449 1466
1450 mbio = bio_clone_mddev(bio, GFP_NOIO, mddev); 1467 atomic_inc(&r10_bio->remaining);
1451 md_trim_bio(mbio, r10_bio->sector - bio->bi_sector,
1452 max_sectors);
1453 r10_bio->devs[i].bio = mbio;
1454 1468
1455 mbio->bi_sector = (r10_bio->devs[i].addr+ 1469 cb = blk_check_plugged(raid10_unplug, mddev,
1456 choose_data_offset(r10_bio, 1470 sizeof(*plug));
1457 conf->mirrors[d].rdev)); 1471 if (cb)
1458 mbio->bi_bdev = conf->mirrors[d].rdev->bdev; 1472 plug = container_of(cb, struct raid10_plug_cb,
1459 mbio->bi_end_io = raid10_end_write_request; 1473 cb);
1460 mbio->bi_rw = WRITE | do_sync | do_fua | do_discard; 1474 else
1461 mbio->bi_private = r10_bio; 1475 plug = NULL;
1476 spin_lock_irqsave(&conf->device_lock, flags);
1477 if (plug) {
1478 bio_list_add(&plug->pending, mbio);
1479 plug->pending_cnt++;
1480 } else {
1481 bio_list_add(&conf->pending_bio_list, mbio);
1482 conf->pending_count++;
1483 }
1484 spin_unlock_irqrestore(&conf->device_lock, flags);
1485 if (!plug)
1486 md_wakeup_thread(mddev->thread);
1487 }
1462 1488
1463 atomic_inc(&r10_bio->remaining); 1489 if (r10_bio->devs[i].repl_bio) {
1490 struct md_rdev *rdev = conf->mirrors[d].replacement;
1491 if (rdev == NULL) {
1492 /* Replacement just got moved to main 'rdev' */
1493 smp_mb();
1494 rdev = conf->mirrors[d].rdev;
1495 }
1496 mbio = bio_clone_mddev(bio, GFP_NOIO, mddev);
1497 md_trim_bio(mbio, r10_bio->sector - bio->bi_sector,
1498 max_sectors);
1499 r10_bio->devs[i].repl_bio = mbio;
1500
1501 mbio->bi_sector = (r10_bio->devs[i].addr +
1502 choose_data_offset(
1503 r10_bio, rdev));
1504 mbio->bi_bdev = rdev->bdev;
1505 mbio->bi_end_io = raid10_end_write_request;
1506 mbio->bi_rw = WRITE | do_sync | do_fua | do_discard;
1507 mbio->bi_private = r10_bio;
1464 1508
1465 cb = blk_check_plugged(raid10_unplug, mddev, sizeof(*plug)); 1509 atomic_inc(&r10_bio->remaining);
1466 if (cb) 1510 spin_lock_irqsave(&conf->device_lock, flags);
1467 plug = container_of(cb, struct raid10_plug_cb, cb);
1468 else
1469 plug = NULL;
1470 spin_lock_irqsave(&conf->device_lock, flags);
1471 if (plug) {
1472 bio_list_add(&plug->pending, mbio);
1473 plug->pending_cnt++;
1474 } else {
1475 bio_list_add(&conf->pending_bio_list, mbio); 1511 bio_list_add(&conf->pending_bio_list, mbio);
1476 conf->pending_count++; 1512 conf->pending_count++;
1513 spin_unlock_irqrestore(&conf->device_lock, flags);
1514 if (!mddev_check_plugged(mddev))
1515 md_wakeup_thread(mddev->thread);
1477 } 1516 }
1478 spin_unlock_irqrestore(&conf->device_lock, flags);
1479 if (!plug)
1480 md_wakeup_thread(mddev->thread);
1481
1482 if (!r10_bio->devs[i].repl_bio)
1483 continue;
1484
1485 mbio = bio_clone_mddev(bio, GFP_NOIO, mddev);
1486 md_trim_bio(mbio, r10_bio->sector - bio->bi_sector,
1487 max_sectors);
1488 r10_bio->devs[i].repl_bio = mbio;
1489
1490 /* We are actively writing to the original device
1491 * so it cannot disappear, so the replacement cannot
1492 * become NULL here
1493 */
1494 mbio->bi_sector = (r10_bio->devs[i].addr +
1495 choose_data_offset(
1496 r10_bio,
1497 conf->mirrors[d].replacement));
1498 mbio->bi_bdev = conf->mirrors[d].replacement->bdev;
1499 mbio->bi_end_io = raid10_end_write_request;
1500 mbio->bi_rw = WRITE | do_sync | do_fua | do_discard;
1501 mbio->bi_private = r10_bio;
1502
1503 atomic_inc(&r10_bio->remaining);
1504 spin_lock_irqsave(&conf->device_lock, flags);
1505 bio_list_add(&conf->pending_bio_list, mbio);
1506 conf->pending_count++;
1507 spin_unlock_irqrestore(&conf->device_lock, flags);
1508 if (!mddev_check_plugged(mddev))
1509 md_wakeup_thread(mddev->thread);
1510 } 1517 }
1511 1518
1512 /* Don't remove the bias on 'remaining' (one_write_done) until 1519 /* Don't remove the bias on 'remaining' (one_write_done) until
@@ -1783,7 +1790,7 @@ static int raid10_add_disk(struct mddev *mddev, struct md_rdev *rdev)
1783 clear_bit(Unmerged, &rdev->flags); 1790 clear_bit(Unmerged, &rdev->flags);
1784 } 1791 }
1785 md_integrity_add_rdev(rdev, mddev); 1792 md_integrity_add_rdev(rdev, mddev);
1786 if (blk_queue_discard(bdev_get_queue(rdev->bdev))) 1793 if (mddev->queue && blk_queue_discard(bdev_get_queue(rdev->bdev)))
1787 queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, mddev->queue); 1794 queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, mddev->queue);
1788 1795
1789 print_conf(conf); 1796 print_conf(conf);
@@ -3613,11 +3620,14 @@ static int run(struct mddev *mddev)
3613 discard_supported = true; 3620 discard_supported = true;
3614 } 3621 }
3615 3622
3616 if (discard_supported) 3623 if (mddev->queue) {
3617 queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, mddev->queue); 3624 if (discard_supported)
3618 else 3625 queue_flag_set_unlocked(QUEUE_FLAG_DISCARD,
3619 queue_flag_clear_unlocked(QUEUE_FLAG_DISCARD, mddev->queue); 3626 mddev->queue);
3620 3627 else
3628 queue_flag_clear_unlocked(QUEUE_FLAG_DISCARD,
3629 mddev->queue);
3630 }
3621 /* need to check that every block has at least one working mirror */ 3631 /* need to check that every block has at least one working mirror */
3622 if (!enough(conf, -1)) { 3632 if (!enough(conf, -1)) {
3623 printk(KERN_ERR "md/raid10:%s: not enough operational mirrors.\n", 3633 printk(KERN_ERR "md/raid10:%s: not enough operational mirrors.\n",
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index c5439dce029..a4502686e7a 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -2774,10 +2774,12 @@ static void handle_stripe_clean_event(struct r5conf *conf,
2774 dev = &sh->dev[i]; 2774 dev = &sh->dev[i];
2775 if (!test_bit(R5_LOCKED, &dev->flags) && 2775 if (!test_bit(R5_LOCKED, &dev->flags) &&
2776 (test_bit(R5_UPTODATE, &dev->flags) || 2776 (test_bit(R5_UPTODATE, &dev->flags) ||
2777 test_and_clear_bit(R5_Discard, &dev->flags))) { 2777 test_bit(R5_Discard, &dev->flags))) {
2778 /* We can return any write requests */ 2778 /* We can return any write requests */
2779 struct bio *wbi, *wbi2; 2779 struct bio *wbi, *wbi2;
2780 pr_debug("Return write for disc %d\n", i); 2780 pr_debug("Return write for disc %d\n", i);
2781 if (test_and_clear_bit(R5_Discard, &dev->flags))
2782 clear_bit(R5_UPTODATE, &dev->flags);
2781 wbi = dev->written; 2783 wbi = dev->written;
2782 dev->written = NULL; 2784 dev->written = NULL;
2783 while (wbi && wbi->bi_sector < 2785 while (wbi && wbi->bi_sector <
@@ -2795,7 +2797,8 @@ static void handle_stripe_clean_event(struct r5conf *conf,
2795 !test_bit(STRIPE_DEGRADED, &sh->state), 2797 !test_bit(STRIPE_DEGRADED, &sh->state),
2796 0); 2798 0);
2797 } 2799 }
2798 } 2800 } else if (test_bit(R5_Discard, &sh->dev[i].flags))
2801 clear_bit(R5_Discard, &sh->dev[i].flags);
2799 2802
2800 if (test_and_clear_bit(STRIPE_FULL_WRITE, &sh->state)) 2803 if (test_and_clear_bit(STRIPE_FULL_WRITE, &sh->state))
2801 if (atomic_dec_and_test(&conf->pending_full_writes)) 2804 if (atomic_dec_and_test(&conf->pending_full_writes))
@@ -3490,40 +3493,6 @@ static void handle_stripe(struct stripe_head *sh)
3490 handle_failed_sync(conf, sh, &s); 3493 handle_failed_sync(conf, sh, &s);
3491 } 3494 }
3492 3495
3493 /*
3494 * might be able to return some write requests if the parity blocks
3495 * are safe, or on a failed drive
3496 */
3497 pdev = &sh->dev[sh->pd_idx];
3498 s.p_failed = (s.failed >= 1 && s.failed_num[0] == sh->pd_idx)
3499 || (s.failed >= 2 && s.failed_num[1] == sh->pd_idx);
3500 qdev = &sh->dev[sh->qd_idx];
3501 s.q_failed = (s.failed >= 1 && s.failed_num[0] == sh->qd_idx)
3502 || (s.failed >= 2 && s.failed_num[1] == sh->qd_idx)
3503 || conf->level < 6;
3504
3505 if (s.written &&
3506 (s.p_failed || ((test_bit(R5_Insync, &pdev->flags)
3507 && !test_bit(R5_LOCKED, &pdev->flags)
3508 && (test_bit(R5_UPTODATE, &pdev->flags) ||
3509 test_bit(R5_Discard, &pdev->flags))))) &&
3510 (s.q_failed || ((test_bit(R5_Insync, &qdev->flags)
3511 && !test_bit(R5_LOCKED, &qdev->flags)
3512 && (test_bit(R5_UPTODATE, &qdev->flags) ||
3513 test_bit(R5_Discard, &qdev->flags))))))
3514 handle_stripe_clean_event(conf, sh, disks, &s.return_bi);
3515
3516 /* Now we might consider reading some blocks, either to check/generate
3517 * parity, or to satisfy requests
3518 * or to load a block that is being partially written.
3519 */
3520 if (s.to_read || s.non_overwrite
3521 || (conf->level == 6 && s.to_write && s.failed)
3522 || (s.syncing && (s.uptodate + s.compute < disks))
3523 || s.replacing
3524 || s.expanding)
3525 handle_stripe_fill(sh, &s, disks);
3526
3527 /* Now we check to see if any write operations have recently 3496 /* Now we check to see if any write operations have recently
3528 * completed 3497 * completed
3529 */ 3498 */
@@ -3561,6 +3530,40 @@ static void handle_stripe(struct stripe_head *sh)
3561 s.dec_preread_active = 1; 3530 s.dec_preread_active = 1;
3562 } 3531 }
3563 3532
3533 /*
3534 * might be able to return some write requests if the parity blocks
3535 * are safe, or on a failed drive
3536 */
3537 pdev = &sh->dev[sh->pd_idx];
3538 s.p_failed = (s.failed >= 1 && s.failed_num[0] == sh->pd_idx)
3539 || (s.failed >= 2 && s.failed_num[1] == sh->pd_idx);
3540 qdev = &sh->dev[sh->qd_idx];
3541 s.q_failed = (s.failed >= 1 && s.failed_num[0] == sh->qd_idx)
3542 || (s.failed >= 2 && s.failed_num[1] == sh->qd_idx)
3543 || conf->level < 6;
3544
3545 if (s.written &&
3546 (s.p_failed || ((test_bit(R5_Insync, &pdev->flags)
3547 && !test_bit(R5_LOCKED, &pdev->flags)
3548 && (test_bit(R5_UPTODATE, &pdev->flags) ||
3549 test_bit(R5_Discard, &pdev->flags))))) &&
3550 (s.q_failed || ((test_bit(R5_Insync, &qdev->flags)
3551 && !test_bit(R5_LOCKED, &qdev->flags)
3552 && (test_bit(R5_UPTODATE, &qdev->flags) ||
3553 test_bit(R5_Discard, &qdev->flags))))))
3554 handle_stripe_clean_event(conf, sh, disks, &s.return_bi);
3555
3556 /* Now we might consider reading some blocks, either to check/generate
3557 * parity, or to satisfy requests
3558 * or to load a block that is being partially written.
3559 */
3560 if (s.to_read || s.non_overwrite
3561 || (conf->level == 6 && s.to_write && s.failed)
3562 || (s.syncing && (s.uptodate + s.compute < disks))
3563 || s.replacing
3564 || s.expanding)
3565 handle_stripe_fill(sh, &s, disks);
3566
3564 /* Now to consider new write requests and what else, if anything 3567 /* Now to consider new write requests and what else, if anything
3565 * should be read. We do not handle new writes when: 3568 * should be read. We do not handle new writes when:
3566 * 1/ A 'write' operation (copy+xor) is already in flight. 3569 * 1/ A 'write' operation (copy+xor) is already in flight.
@@ -5529,6 +5532,10 @@ static int run(struct mddev *mddev)
5529 * discard data disk but write parity disk 5532 * discard data disk but write parity disk
5530 */ 5533 */
5531 stripe = stripe * PAGE_SIZE; 5534 stripe = stripe * PAGE_SIZE;
5535 /* Round up to power of 2, as discard handling
5536 * currently assumes that */
5537 while ((stripe-1) & stripe)
5538 stripe = (stripe | (stripe-1)) + 1;
5532 mddev->queue->limits.discard_alignment = stripe; 5539 mddev->queue->limits.discard_alignment = stripe;
5533 mddev->queue->limits.discard_granularity = stripe; 5540 mddev->queue->limits.discard_granularity = stripe;
5534 /* 5541 /*
diff --git a/drivers/media/Kconfig b/drivers/media/Kconfig
index dd13e3a4c27..4ef0d80b57f 100644
--- a/drivers/media/Kconfig
+++ b/drivers/media/Kconfig
@@ -163,19 +163,21 @@ source "drivers/media/common/Kconfig"
163# 163#
164 164
165config MEDIA_SUBDRV_AUTOSELECT 165config MEDIA_SUBDRV_AUTOSELECT
166 bool "Autoselect analog and hybrid tuner modules to build" 166 bool "Autoselect tuners and i2c modules to build"
167 depends on MEDIA_TUNER 167 depends on MEDIA_ANALOG_TV_SUPPORT || MEDIA_DIGITAL_TV_SUPPORT || MEDIA_CAMERA_SUPPORT
168 default y 168 default y
169 help 169 help
170 By default, a TV driver auto-selects all possible tuners 170 By default, a media driver auto-selects all possible i2c
171 thar could be used by the driver. 171 devices that are used by any of the supported devices.
172 172
173 This is generally the right thing to do, except when there 173 This is generally the right thing to do, except when there
174 are strict constraints with regards to the kernel size. 174 are strict constraints with regards to the kernel size,
175 like on embedded systems.
175 176
176 Use this option with care, as deselecting tuner drivers which 177 Use this option with care, as deselecting ancillary drivers which
177 are in fact necessary will result in TV devices which cannot 178 are, in fact, necessary will result in the lack of the needed
178 be tuned due to lack of the tuning driver. 179 functionality for your device (it may not tune or may not have
180 the need demodulers).
179 181
180 If unsure say Y. 182 If unsure say Y.
181 183
diff --git a/drivers/mmc/host/dw_mmc-exynos.c b/drivers/mmc/host/dw_mmc-exynos.c
index 660bbc52886..4d50da61816 100644
--- a/drivers/mmc/host/dw_mmc-exynos.c
+++ b/drivers/mmc/host/dw_mmc-exynos.c
@@ -208,7 +208,7 @@ static unsigned long exynos5250_dwmmc_caps[4] = {
208 MMC_CAP_CMD23, 208 MMC_CAP_CMD23,
209}; 209};
210 210
211static struct dw_mci_drv_data exynos5250_drv_data = { 211static const struct dw_mci_drv_data exynos5250_drv_data = {
212 .caps = exynos5250_dwmmc_caps, 212 .caps = exynos5250_dwmmc_caps,
213 .init = dw_mci_exynos_priv_init, 213 .init = dw_mci_exynos_priv_init,
214 .setup_clock = dw_mci_exynos_setup_clock, 214 .setup_clock = dw_mci_exynos_setup_clock,
@@ -220,14 +220,14 @@ static struct dw_mci_drv_data exynos5250_drv_data = {
220 220
221static const struct of_device_id dw_mci_exynos_match[] = { 221static const struct of_device_id dw_mci_exynos_match[] = {
222 { .compatible = "samsung,exynos5250-dw-mshc", 222 { .compatible = "samsung,exynos5250-dw-mshc",
223 .data = (void *)&exynos5250_drv_data, }, 223 .data = &exynos5250_drv_data, },
224 {}, 224 {},
225}; 225};
226MODULE_DEVICE_TABLE(of, dw_mci_pltfm_match); 226MODULE_DEVICE_TABLE(of, dw_mci_exynos_match);
227 227
228int dw_mci_exynos_probe(struct platform_device *pdev) 228int dw_mci_exynos_probe(struct platform_device *pdev)
229{ 229{
230 struct dw_mci_drv_data *drv_data; 230 const struct dw_mci_drv_data *drv_data;
231 const struct of_device_id *match; 231 const struct of_device_id *match;
232 232
233 match = of_match_node(dw_mci_exynos_match, pdev->dev.of_node); 233 match = of_match_node(dw_mci_exynos_match, pdev->dev.of_node);
diff --git a/drivers/mmc/host/dw_mmc-pltfm.c b/drivers/mmc/host/dw_mmc-pltfm.c
index c960ca7ffbe..917936bee5d 100644
--- a/drivers/mmc/host/dw_mmc-pltfm.c
+++ b/drivers/mmc/host/dw_mmc-pltfm.c
@@ -24,7 +24,7 @@
24#include "dw_mmc.h" 24#include "dw_mmc.h"
25 25
26int dw_mci_pltfm_register(struct platform_device *pdev, 26int dw_mci_pltfm_register(struct platform_device *pdev,
27 struct dw_mci_drv_data *drv_data) 27 const struct dw_mci_drv_data *drv_data)
28{ 28{
29 struct dw_mci *host; 29 struct dw_mci *host;
30 struct resource *regs; 30 struct resource *regs;
@@ -50,8 +50,8 @@ int dw_mci_pltfm_register(struct platform_device *pdev,
50 if (!host->regs) 50 if (!host->regs)
51 return -ENOMEM; 51 return -ENOMEM;
52 52
53 if (host->drv_data->init) { 53 if (drv_data && drv_data->init) {
54 ret = host->drv_data->init(host); 54 ret = drv_data->init(host);
55 if (ret) 55 if (ret)
56 return ret; 56 return ret;
57 } 57 }
diff --git a/drivers/mmc/host/dw_mmc-pltfm.h b/drivers/mmc/host/dw_mmc-pltfm.h
index 301f24541fc..2ac37b81de4 100644
--- a/drivers/mmc/host/dw_mmc-pltfm.h
+++ b/drivers/mmc/host/dw_mmc-pltfm.h
@@ -13,7 +13,7 @@
13#define _DW_MMC_PLTFM_H_ 13#define _DW_MMC_PLTFM_H_
14 14
15extern int dw_mci_pltfm_register(struct platform_device *pdev, 15extern int dw_mci_pltfm_register(struct platform_device *pdev,
16 struct dw_mci_drv_data *drv_data); 16 const struct dw_mci_drv_data *drv_data);
17extern int __devexit dw_mci_pltfm_remove(struct platform_device *pdev); 17extern int __devexit dw_mci_pltfm_remove(struct platform_device *pdev);
18extern const struct dev_pm_ops dw_mci_pltfm_pmops; 18extern const struct dev_pm_ops dw_mci_pltfm_pmops;
19 19
diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
index c2828f35c3b..c0667c8af2b 100644
--- a/drivers/mmc/host/dw_mmc.c
+++ b/drivers/mmc/host/dw_mmc.c
@@ -232,6 +232,7 @@ static u32 dw_mci_prepare_command(struct mmc_host *mmc, struct mmc_command *cmd)
232{ 232{
233 struct mmc_data *data; 233 struct mmc_data *data;
234 struct dw_mci_slot *slot = mmc_priv(mmc); 234 struct dw_mci_slot *slot = mmc_priv(mmc);
235 struct dw_mci_drv_data *drv_data = slot->host->drv_data;
235 u32 cmdr; 236 u32 cmdr;
236 cmd->error = -EINPROGRESS; 237 cmd->error = -EINPROGRESS;
237 238
@@ -261,8 +262,8 @@ static u32 dw_mci_prepare_command(struct mmc_host *mmc, struct mmc_command *cmd)
261 cmdr |= SDMMC_CMD_DAT_WR; 262 cmdr |= SDMMC_CMD_DAT_WR;
262 } 263 }
263 264
264 if (slot->host->drv_data->prepare_command) 265 if (drv_data && drv_data->prepare_command)
265 slot->host->drv_data->prepare_command(slot->host, &cmdr); 266 drv_data->prepare_command(slot->host, &cmdr);
266 267
267 return cmdr; 268 return cmdr;
268} 269}
@@ -434,7 +435,7 @@ static int dw_mci_idmac_init(struct dw_mci *host)
434 return 0; 435 return 0;
435} 436}
436 437
437static struct dw_mci_dma_ops dw_mci_idmac_ops = { 438static const struct dw_mci_dma_ops dw_mci_idmac_ops = {
438 .init = dw_mci_idmac_init, 439 .init = dw_mci_idmac_init,
439 .start = dw_mci_idmac_start_dma, 440 .start = dw_mci_idmac_start_dma,
440 .stop = dw_mci_idmac_stop_dma, 441 .stop = dw_mci_idmac_stop_dma,
@@ -772,6 +773,7 @@ static void dw_mci_request(struct mmc_host *mmc, struct mmc_request *mrq)
772static void dw_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) 773static void dw_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
773{ 774{
774 struct dw_mci_slot *slot = mmc_priv(mmc); 775 struct dw_mci_slot *slot = mmc_priv(mmc);
776 struct dw_mci_drv_data *drv_data = slot->host->drv_data;
775 u32 regs; 777 u32 regs;
776 778
777 /* set default 1 bit mode */ 779 /* set default 1 bit mode */
@@ -807,8 +809,8 @@ static void dw_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
807 slot->clock = ios->clock; 809 slot->clock = ios->clock;
808 } 810 }
809 811
810 if (slot->host->drv_data->set_ios) 812 if (drv_data && drv_data->set_ios)
811 slot->host->drv_data->set_ios(slot->host, ios); 813 drv_data->set_ios(slot->host, ios);
812 814
813 switch (ios->power_mode) { 815 switch (ios->power_mode) {
814 case MMC_POWER_UP: 816 case MMC_POWER_UP:
@@ -1815,6 +1817,7 @@ static int dw_mci_init_slot(struct dw_mci *host, unsigned int id)
1815{ 1817{
1816 struct mmc_host *mmc; 1818 struct mmc_host *mmc;
1817 struct dw_mci_slot *slot; 1819 struct dw_mci_slot *slot;
1820 struct dw_mci_drv_data *drv_data = host->drv_data;
1818 int ctrl_id, ret; 1821 int ctrl_id, ret;
1819 u8 bus_width; 1822 u8 bus_width;
1820 1823
@@ -1854,8 +1857,8 @@ static int dw_mci_init_slot(struct dw_mci *host, unsigned int id)
1854 } else { 1857 } else {
1855 ctrl_id = to_platform_device(host->dev)->id; 1858 ctrl_id = to_platform_device(host->dev)->id;
1856 } 1859 }
1857 if (host->drv_data && host->drv_data->caps) 1860 if (drv_data && drv_data->caps)
1858 mmc->caps |= host->drv_data->caps[ctrl_id]; 1861 mmc->caps |= drv_data->caps[ctrl_id];
1859 1862
1860 if (host->pdata->caps2) 1863 if (host->pdata->caps2)
1861 mmc->caps2 = host->pdata->caps2; 1864 mmc->caps2 = host->pdata->caps2;
@@ -1867,10 +1870,10 @@ static int dw_mci_init_slot(struct dw_mci *host, unsigned int id)
1867 else 1870 else
1868 bus_width = 1; 1871 bus_width = 1;
1869 1872
1870 if (host->drv_data->setup_bus) { 1873 if (drv_data && drv_data->setup_bus) {
1871 struct device_node *slot_np; 1874 struct device_node *slot_np;
1872 slot_np = dw_mci_of_find_slot_node(host->dev, slot->id); 1875 slot_np = dw_mci_of_find_slot_node(host->dev, slot->id);
1873 ret = host->drv_data->setup_bus(host, slot_np, bus_width); 1876 ret = drv_data->setup_bus(host, slot_np, bus_width);
1874 if (ret) 1877 if (ret)
1875 goto err_setup_bus; 1878 goto err_setup_bus;
1876 } 1879 }
@@ -1968,7 +1971,7 @@ static void dw_mci_init_dma(struct dw_mci *host)
1968 /* Determine which DMA interface to use */ 1971 /* Determine which DMA interface to use */
1969#ifdef CONFIG_MMC_DW_IDMAC 1972#ifdef CONFIG_MMC_DW_IDMAC
1970 host->dma_ops = &dw_mci_idmac_ops; 1973 host->dma_ops = &dw_mci_idmac_ops;
1971 dev_info(&host->dev, "Using internal DMA controller.\n"); 1974 dev_info(host->dev, "Using internal DMA controller.\n");
1972#endif 1975#endif
1973 1976
1974 if (!host->dma_ops) 1977 if (!host->dma_ops)
@@ -2035,6 +2038,7 @@ static struct dw_mci_board *dw_mci_parse_dt(struct dw_mci *host)
2035 struct dw_mci_board *pdata; 2038 struct dw_mci_board *pdata;
2036 struct device *dev = host->dev; 2039 struct device *dev = host->dev;
2037 struct device_node *np = dev->of_node; 2040 struct device_node *np = dev->of_node;
2041 struct dw_mci_drv_data *drv_data = host->drv_data;
2038 int idx, ret; 2042 int idx, ret;
2039 2043
2040 pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); 2044 pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
@@ -2062,8 +2066,8 @@ static struct dw_mci_board *dw_mci_parse_dt(struct dw_mci *host)
2062 2066
2063 of_property_read_u32(np, "card-detect-delay", &pdata->detect_delay_ms); 2067 of_property_read_u32(np, "card-detect-delay", &pdata->detect_delay_ms);
2064 2068
2065 if (host->drv_data->parse_dt) { 2069 if (drv_data && drv_data->parse_dt) {
2066 ret = host->drv_data->parse_dt(host); 2070 ret = drv_data->parse_dt(host);
2067 if (ret) 2071 if (ret)
2068 return ERR_PTR(ret); 2072 return ERR_PTR(ret);
2069 } 2073 }
@@ -2080,6 +2084,7 @@ static struct dw_mci_board *dw_mci_parse_dt(struct dw_mci *host)
2080 2084
2081int dw_mci_probe(struct dw_mci *host) 2085int dw_mci_probe(struct dw_mci *host)
2082{ 2086{
2087 struct dw_mci_drv_data *drv_data = host->drv_data;
2083 int width, i, ret = 0; 2088 int width, i, ret = 0;
2084 u32 fifo_size; 2089 u32 fifo_size;
2085 int init_slots = 0; 2090 int init_slots = 0;
@@ -2127,8 +2132,8 @@ int dw_mci_probe(struct dw_mci *host)
2127 else 2132 else
2128 host->bus_hz = clk_get_rate(host->ciu_clk); 2133 host->bus_hz = clk_get_rate(host->ciu_clk);
2129 2134
2130 if (host->drv_data->setup_clock) { 2135 if (drv_data && drv_data->setup_clock) {
2131 ret = host->drv_data->setup_clock(host); 2136 ret = drv_data->setup_clock(host);
2132 if (ret) { 2137 if (ret) {
2133 dev_err(host->dev, 2138 dev_err(host->dev,
2134 "implementation specific clock setup failed\n"); 2139 "implementation specific clock setup failed\n");
@@ -2228,6 +2233,21 @@ int dw_mci_probe(struct dw_mci *host)
2228 else 2233 else
2229 host->num_slots = ((mci_readl(host, HCON) >> 1) & 0x1F) + 1; 2234 host->num_slots = ((mci_readl(host, HCON) >> 1) & 0x1F) + 1;
2230 2235
2236 /*
2237 * Enable interrupts for command done, data over, data empty, card det,
2238 * receive ready and error such as transmit, receive timeout, crc error
2239 */
2240 mci_writel(host, RINTSTS, 0xFFFFFFFF);
2241 mci_writel(host, INTMASK, SDMMC_INT_CMD_DONE | SDMMC_INT_DATA_OVER |
2242 SDMMC_INT_TXDR | SDMMC_INT_RXDR |
2243 DW_MCI_ERROR_FLAGS | SDMMC_INT_CD);
2244 mci_writel(host, CTRL, SDMMC_CTRL_INT_ENABLE); /* Enable mci interrupt */
2245
2246 dev_info(host->dev, "DW MMC controller at irq %d, "
2247 "%d bit host data width, "
2248 "%u deep fifo\n",
2249 host->irq, width, fifo_size);
2250
2231 /* We need at least one slot to succeed */ 2251 /* We need at least one slot to succeed */
2232 for (i = 0; i < host->num_slots; i++) { 2252 for (i = 0; i < host->num_slots; i++) {
2233 ret = dw_mci_init_slot(host, i); 2253 ret = dw_mci_init_slot(host, i);
@@ -2257,20 +2277,6 @@ int dw_mci_probe(struct dw_mci *host)
2257 else 2277 else
2258 host->data_offset = DATA_240A_OFFSET; 2278 host->data_offset = DATA_240A_OFFSET;
2259 2279
2260 /*
2261 * Enable interrupts for command done, data over, data empty, card det,
2262 * receive ready and error such as transmit, receive timeout, crc error
2263 */
2264 mci_writel(host, RINTSTS, 0xFFFFFFFF);
2265 mci_writel(host, INTMASK, SDMMC_INT_CMD_DONE | SDMMC_INT_DATA_OVER |
2266 SDMMC_INT_TXDR | SDMMC_INT_RXDR |
2267 DW_MCI_ERROR_FLAGS | SDMMC_INT_CD);
2268 mci_writel(host, CTRL, SDMMC_CTRL_INT_ENABLE); /* Enable mci interrupt */
2269
2270 dev_info(host->dev, "DW MMC controller at irq %d, "
2271 "%d bit host data width, "
2272 "%u deep fifo\n",
2273 host->irq, width, fifo_size);
2274 if (host->quirks & DW_MCI_QUIRK_IDMAC_DTO) 2280 if (host->quirks & DW_MCI_QUIRK_IDMAC_DTO)
2275 dev_info(host->dev, "Internal DMAC interrupt fix enabled.\n"); 2281 dev_info(host->dev, "Internal DMAC interrupt fix enabled.\n");
2276 2282
diff --git a/drivers/mmc/host/mxcmmc.c b/drivers/mmc/host/mxcmmc.c
index 565c2e4fac7..6290b7f1ccf 100644
--- a/drivers/mmc/host/mxcmmc.c
+++ b/drivers/mmc/host/mxcmmc.c
@@ -1134,4 +1134,4 @@ module_platform_driver(mxcmci_driver);
1134MODULE_DESCRIPTION("i.MX Multimedia Card Interface Driver"); 1134MODULE_DESCRIPTION("i.MX Multimedia Card Interface Driver");
1135MODULE_AUTHOR("Sascha Hauer, Pengutronix"); 1135MODULE_AUTHOR("Sascha Hauer, Pengutronix");
1136MODULE_LICENSE("GPL"); 1136MODULE_LICENSE("GPL");
1137MODULE_ALIAS("platform:imx-mmc"); 1137MODULE_ALIAS("platform:mxc-mmc");
diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
index 54bfd0cc106..fedd258cc4e 100644
--- a/drivers/mmc/host/omap_hsmmc.c
+++ b/drivers/mmc/host/omap_hsmmc.c
@@ -178,7 +178,8 @@ struct omap_hsmmc_host {
178 178
179static int omap_hsmmc_card_detect(struct device *dev, int slot) 179static int omap_hsmmc_card_detect(struct device *dev, int slot)
180{ 180{
181 struct omap_mmc_platform_data *mmc = dev->platform_data; 181 struct omap_hsmmc_host *host = dev_get_drvdata(dev);
182 struct omap_mmc_platform_data *mmc = host->pdata;
182 183
183 /* NOTE: assumes card detect signal is active-low */ 184 /* NOTE: assumes card detect signal is active-low */
184 return !gpio_get_value_cansleep(mmc->slots[0].switch_pin); 185 return !gpio_get_value_cansleep(mmc->slots[0].switch_pin);
@@ -186,7 +187,8 @@ static int omap_hsmmc_card_detect(struct device *dev, int slot)
186 187
187static int omap_hsmmc_get_wp(struct device *dev, int slot) 188static int omap_hsmmc_get_wp(struct device *dev, int slot)
188{ 189{
189 struct omap_mmc_platform_data *mmc = dev->platform_data; 190 struct omap_hsmmc_host *host = dev_get_drvdata(dev);
191 struct omap_mmc_platform_data *mmc = host->pdata;
190 192
191 /* NOTE: assumes write protect signal is active-high */ 193 /* NOTE: assumes write protect signal is active-high */
192 return gpio_get_value_cansleep(mmc->slots[0].gpio_wp); 194 return gpio_get_value_cansleep(mmc->slots[0].gpio_wp);
@@ -194,7 +196,8 @@ static int omap_hsmmc_get_wp(struct device *dev, int slot)
194 196
195static int omap_hsmmc_get_cover_state(struct device *dev, int slot) 197static int omap_hsmmc_get_cover_state(struct device *dev, int slot)
196{ 198{
197 struct omap_mmc_platform_data *mmc = dev->platform_data; 199 struct omap_hsmmc_host *host = dev_get_drvdata(dev);
200 struct omap_mmc_platform_data *mmc = host->pdata;
198 201
199 /* NOTE: assumes card detect signal is active-low */ 202 /* NOTE: assumes card detect signal is active-low */
200 return !gpio_get_value_cansleep(mmc->slots[0].switch_pin); 203 return !gpio_get_value_cansleep(mmc->slots[0].switch_pin);
@@ -204,7 +207,8 @@ static int omap_hsmmc_get_cover_state(struct device *dev, int slot)
204 207
205static int omap_hsmmc_suspend_cdirq(struct device *dev, int slot) 208static int omap_hsmmc_suspend_cdirq(struct device *dev, int slot)
206{ 209{
207 struct omap_mmc_platform_data *mmc = dev->platform_data; 210 struct omap_hsmmc_host *host = dev_get_drvdata(dev);
211 struct omap_mmc_platform_data *mmc = host->pdata;
208 212
209 disable_irq(mmc->slots[0].card_detect_irq); 213 disable_irq(mmc->slots[0].card_detect_irq);
210 return 0; 214 return 0;
@@ -212,7 +216,8 @@ static int omap_hsmmc_suspend_cdirq(struct device *dev, int slot)
212 216
213static int omap_hsmmc_resume_cdirq(struct device *dev, int slot) 217static int omap_hsmmc_resume_cdirq(struct device *dev, int slot)
214{ 218{
215 struct omap_mmc_platform_data *mmc = dev->platform_data; 219 struct omap_hsmmc_host *host = dev_get_drvdata(dev);
220 struct omap_mmc_platform_data *mmc = host->pdata;
216 221
217 enable_irq(mmc->slots[0].card_detect_irq); 222 enable_irq(mmc->slots[0].card_detect_irq);
218 return 0; 223 return 0;
@@ -2009,9 +2014,9 @@ static int __devexit omap_hsmmc_remove(struct platform_device *pdev)
2009 clk_put(host->dbclk); 2014 clk_put(host->dbclk);
2010 } 2015 }
2011 2016
2012 mmc_free_host(host->mmc); 2017 omap_hsmmc_gpio_free(host->pdata);
2013 iounmap(host->base); 2018 iounmap(host->base);
2014 omap_hsmmc_gpio_free(pdev->dev.platform_data); 2019 mmc_free_host(host->mmc);
2015 2020
2016 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 2021 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
2017 if (res) 2022 if (res)
diff --git a/drivers/mmc/host/sdhci-dove.c b/drivers/mmc/host/sdhci-dove.c
index 90140eb03e3..8fd50a21103 100644
--- a/drivers/mmc/host/sdhci-dove.c
+++ b/drivers/mmc/host/sdhci-dove.c
@@ -19,6 +19,7 @@
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 20 */
21 21
22#include <linux/err.h>
22#include <linux/io.h> 23#include <linux/io.h>
23#include <linux/clk.h> 24#include <linux/clk.h>
24#include <linux/err.h> 25#include <linux/err.h>
@@ -84,30 +85,32 @@ static int __devinit sdhci_dove_probe(struct platform_device *pdev)
84 struct sdhci_dove_priv *priv; 85 struct sdhci_dove_priv *priv;
85 int ret; 86 int ret;
86 87
87 ret = sdhci_pltfm_register(pdev, &sdhci_dove_pdata);
88 if (ret)
89 goto sdhci_dove_register_fail;
90
91 priv = devm_kzalloc(&pdev->dev, sizeof(struct sdhci_dove_priv), 88 priv = devm_kzalloc(&pdev->dev, sizeof(struct sdhci_dove_priv),
92 GFP_KERNEL); 89 GFP_KERNEL);
93 if (!priv) { 90 if (!priv) {
94 dev_err(&pdev->dev, "unable to allocate private data"); 91 dev_err(&pdev->dev, "unable to allocate private data");
95 ret = -ENOMEM; 92 return -ENOMEM;
96 goto sdhci_dove_allocate_fail;
97 } 93 }
98 94
95 priv->clk = clk_get(&pdev->dev, NULL);
96 if (!IS_ERR(priv->clk))
97 clk_prepare_enable(priv->clk);
98
99 ret = sdhci_pltfm_register(pdev, &sdhci_dove_pdata);
100 if (ret)
101 goto sdhci_dove_register_fail;
102
99 host = platform_get_drvdata(pdev); 103 host = platform_get_drvdata(pdev);
100 pltfm_host = sdhci_priv(host); 104 pltfm_host = sdhci_priv(host);
101 pltfm_host->priv = priv; 105 pltfm_host->priv = priv;
102 106
103 priv->clk = clk_get(&pdev->dev, NULL);
104 if (!IS_ERR(priv->clk))
105 clk_prepare_enable(priv->clk);
106 return 0; 107 return 0;
107 108
108sdhci_dove_allocate_fail:
109 sdhci_pltfm_unregister(pdev);
110sdhci_dove_register_fail: 109sdhci_dove_register_fail:
110 if (!IS_ERR(priv->clk)) {
111 clk_disable_unprepare(priv->clk);
112 clk_put(priv->clk);
113 }
111 return ret; 114 return ret;
112} 115}
113 116
@@ -117,14 +120,13 @@ static int __devexit sdhci_dove_remove(struct platform_device *pdev)
117 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 120 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
118 struct sdhci_dove_priv *priv = pltfm_host->priv; 121 struct sdhci_dove_priv *priv = pltfm_host->priv;
119 122
120 if (priv->clk) { 123 sdhci_pltfm_unregister(pdev);
121 if (!IS_ERR(priv->clk)) { 124
122 clk_disable_unprepare(priv->clk); 125 if (!IS_ERR(priv->clk)) {
123 clk_put(priv->clk); 126 clk_disable_unprepare(priv->clk);
124 } 127 clk_put(priv->clk);
125 devm_kfree(&pdev->dev, priv->clk);
126 } 128 }
127 return sdhci_pltfm_unregister(pdev); 129 return 0;
128} 130}
129 131
130static const struct of_device_id sdhci_dove_of_match_table[] __devinitdata = { 132static const struct of_device_id sdhci_dove_of_match_table[] __devinitdata = {
diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c
index ae5fcbfa1ee..63d219f57ca 100644
--- a/drivers/mmc/host/sdhci-of-esdhc.c
+++ b/drivers/mmc/host/sdhci-of-esdhc.c
@@ -169,6 +169,16 @@ static void esdhc_of_resume(struct sdhci_host *host)
169} 169}
170#endif 170#endif
171 171
172static void esdhc_of_platform_init(struct sdhci_host *host)
173{
174 u32 vvn;
175
176 vvn = in_be32(host->ioaddr + SDHCI_SLOT_INT_STATUS);
177 vvn = (vvn & SDHCI_VENDOR_VER_MASK) >> SDHCI_VENDOR_VER_SHIFT;
178 if (vvn == VENDOR_V_22)
179 host->quirks2 |= SDHCI_QUIRK2_HOST_NO_CMD23;
180}
181
172static struct sdhci_ops sdhci_esdhc_ops = { 182static struct sdhci_ops sdhci_esdhc_ops = {
173 .read_l = esdhc_readl, 183 .read_l = esdhc_readl,
174 .read_w = esdhc_readw, 184 .read_w = esdhc_readw,
@@ -180,6 +190,7 @@ static struct sdhci_ops sdhci_esdhc_ops = {
180 .enable_dma = esdhc_of_enable_dma, 190 .enable_dma = esdhc_of_enable_dma,
181 .get_max_clock = esdhc_of_get_max_clock, 191 .get_max_clock = esdhc_of_get_max_clock,
182 .get_min_clock = esdhc_of_get_min_clock, 192 .get_min_clock = esdhc_of_get_min_clock,
193 .platform_init = esdhc_of_platform_init,
183#ifdef CONFIG_PM 194#ifdef CONFIG_PM
184 .platform_suspend = esdhc_of_suspend, 195 .platform_suspend = esdhc_of_suspend,
185 .platform_resume = esdhc_of_resume, 196 .platform_resume = esdhc_of_resume,
diff --git a/drivers/mmc/host/sdhci-pci.c b/drivers/mmc/host/sdhci-pci.c
index 4bb74b042a0..04936f353ce 100644
--- a/drivers/mmc/host/sdhci-pci.c
+++ b/drivers/mmc/host/sdhci-pci.c
@@ -1196,7 +1196,7 @@ static struct sdhci_pci_slot * __devinit sdhci_pci_probe_slot(
1196 return ERR_PTR(-ENODEV); 1196 return ERR_PTR(-ENODEV);
1197 } 1197 }
1198 1198
1199 if (pci_resource_len(pdev, bar) != 0x100) { 1199 if (pci_resource_len(pdev, bar) < 0x100) {
1200 dev_err(&pdev->dev, "Invalid iomem size. You may " 1200 dev_err(&pdev->dev, "Invalid iomem size. You may "
1201 "experience problems.\n"); 1201 "experience problems.\n");
1202 } 1202 }
diff --git a/drivers/mmc/host/sdhci-pltfm.c b/drivers/mmc/host/sdhci-pltfm.c
index 65551a9709c..27164457f86 100644
--- a/drivers/mmc/host/sdhci-pltfm.c
+++ b/drivers/mmc/host/sdhci-pltfm.c
@@ -150,6 +150,13 @@ struct sdhci_host *sdhci_pltfm_init(struct platform_device *pdev,
150 goto err_remap; 150 goto err_remap;
151 } 151 }
152 152
153 /*
154 * Some platforms need to probe the controller to be able to
155 * determine which caps should be used.
156 */
157 if (host->ops && host->ops->platform_init)
158 host->ops->platform_init(host);
159
153 platform_set_drvdata(pdev, host); 160 platform_set_drvdata(pdev, host);
154 161
155 return host; 162 return host;
diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
index 2903949594c..a54dd5d7a5f 100644
--- a/drivers/mmc/host/sdhci-s3c.c
+++ b/drivers/mmc/host/sdhci-s3c.c
@@ -211,8 +211,8 @@ static void sdhci_s3c_set_clock(struct sdhci_host *host, unsigned int clock)
211 if (ourhost->cur_clk != best_src) { 211 if (ourhost->cur_clk != best_src) {
212 struct clk *clk = ourhost->clk_bus[best_src]; 212 struct clk *clk = ourhost->clk_bus[best_src];
213 213
214 clk_enable(clk); 214 clk_prepare_enable(clk);
215 clk_disable(ourhost->clk_bus[ourhost->cur_clk]); 215 clk_disable_unprepare(ourhost->clk_bus[ourhost->cur_clk]);
216 216
217 /* turn clock off to card before changing clock source */ 217 /* turn clock off to card before changing clock source */
218 writew(0, host->ioaddr + SDHCI_CLOCK_CONTROL); 218 writew(0, host->ioaddr + SDHCI_CLOCK_CONTROL);
@@ -607,7 +607,7 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
607 } 607 }
608 608
609 /* enable the local io clock and keep it running for the moment. */ 609 /* enable the local io clock and keep it running for the moment. */
610 clk_enable(sc->clk_io); 610 clk_prepare_enable(sc->clk_io);
611 611
612 for (clks = 0, ptr = 0; ptr < MAX_BUS_CLK; ptr++) { 612 for (clks = 0, ptr = 0; ptr < MAX_BUS_CLK; ptr++) {
613 struct clk *clk; 613 struct clk *clk;
@@ -638,7 +638,7 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
638 } 638 }
639 639
640#ifndef CONFIG_PM_RUNTIME 640#ifndef CONFIG_PM_RUNTIME
641 clk_enable(sc->clk_bus[sc->cur_clk]); 641 clk_prepare_enable(sc->clk_bus[sc->cur_clk]);
642#endif 642#endif
643 643
644 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 644 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -747,13 +747,14 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
747 sdhci_s3c_setup_card_detect_gpio(sc); 747 sdhci_s3c_setup_card_detect_gpio(sc);
748 748
749#ifdef CONFIG_PM_RUNTIME 749#ifdef CONFIG_PM_RUNTIME
750 clk_disable(sc->clk_io); 750 if (pdata->cd_type != S3C_SDHCI_CD_INTERNAL)
751 clk_disable_unprepare(sc->clk_io);
751#endif 752#endif
752 return 0; 753 return 0;
753 754
754 err_req_regs: 755 err_req_regs:
755#ifndef CONFIG_PM_RUNTIME 756#ifndef CONFIG_PM_RUNTIME
756 clk_disable(sc->clk_bus[sc->cur_clk]); 757 clk_disable_unprepare(sc->clk_bus[sc->cur_clk]);
757#endif 758#endif
758 for (ptr = 0; ptr < MAX_BUS_CLK; ptr++) { 759 for (ptr = 0; ptr < MAX_BUS_CLK; ptr++) {
759 if (sc->clk_bus[ptr]) { 760 if (sc->clk_bus[ptr]) {
@@ -762,7 +763,7 @@ static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
762 } 763 }
763 764
764 err_no_busclks: 765 err_no_busclks:
765 clk_disable(sc->clk_io); 766 clk_disable_unprepare(sc->clk_io);
766 clk_put(sc->clk_io); 767 clk_put(sc->clk_io);
767 768
768 err_io_clk: 769 err_io_clk:
@@ -794,7 +795,8 @@ static int __devexit sdhci_s3c_remove(struct platform_device *pdev)
794 gpio_free(sc->ext_cd_gpio); 795 gpio_free(sc->ext_cd_gpio);
795 796
796#ifdef CONFIG_PM_RUNTIME 797#ifdef CONFIG_PM_RUNTIME
797 clk_enable(sc->clk_io); 798 if (pdata->cd_type != S3C_SDHCI_CD_INTERNAL)
799 clk_prepare_enable(sc->clk_io);
798#endif 800#endif
799 sdhci_remove_host(host, 1); 801 sdhci_remove_host(host, 1);
800 802
@@ -802,14 +804,14 @@ static int __devexit sdhci_s3c_remove(struct platform_device *pdev)
802 pm_runtime_disable(&pdev->dev); 804 pm_runtime_disable(&pdev->dev);
803 805
804#ifndef CONFIG_PM_RUNTIME 806#ifndef CONFIG_PM_RUNTIME
805 clk_disable(sc->clk_bus[sc->cur_clk]); 807 clk_disable_unprepare(sc->clk_bus[sc->cur_clk]);
806#endif 808#endif
807 for (ptr = 0; ptr < MAX_BUS_CLK; ptr++) { 809 for (ptr = 0; ptr < MAX_BUS_CLK; ptr++) {
808 if (sc->clk_bus[ptr]) { 810 if (sc->clk_bus[ptr]) {
809 clk_put(sc->clk_bus[ptr]); 811 clk_put(sc->clk_bus[ptr]);
810 } 812 }
811 } 813 }
812 clk_disable(sc->clk_io); 814 clk_disable_unprepare(sc->clk_io);
813 clk_put(sc->clk_io); 815 clk_put(sc->clk_io);
814 816
815 if (pdev->dev.of_node) { 817 if (pdev->dev.of_node) {
@@ -849,8 +851,8 @@ static int sdhci_s3c_runtime_suspend(struct device *dev)
849 851
850 ret = sdhci_runtime_suspend_host(host); 852 ret = sdhci_runtime_suspend_host(host);
851 853
852 clk_disable(ourhost->clk_bus[ourhost->cur_clk]); 854 clk_disable_unprepare(ourhost->clk_bus[ourhost->cur_clk]);
853 clk_disable(busclk); 855 clk_disable_unprepare(busclk);
854 return ret; 856 return ret;
855} 857}
856 858
@@ -861,8 +863,8 @@ static int sdhci_s3c_runtime_resume(struct device *dev)
861 struct clk *busclk = ourhost->clk_io; 863 struct clk *busclk = ourhost->clk_io;
862 int ret; 864 int ret;
863 865
864 clk_enable(busclk); 866 clk_prepare_enable(busclk);
865 clk_enable(ourhost->clk_bus[ourhost->cur_clk]); 867 clk_prepare_enable(ourhost->clk_bus[ourhost->cur_clk]);
866 ret = sdhci_runtime_resume_host(host); 868 ret = sdhci_runtime_resume_host(host);
867 return ret; 869 return ret;
868} 870}
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 7922adb4238..c7851c0aabc 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -1315,16 +1315,19 @@ static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
1315 */ 1315 */
1316 if ((host->flags & SDHCI_NEEDS_RETUNING) && 1316 if ((host->flags & SDHCI_NEEDS_RETUNING) &&
1317 !(present_state & (SDHCI_DOING_WRITE | SDHCI_DOING_READ))) { 1317 !(present_state & (SDHCI_DOING_WRITE | SDHCI_DOING_READ))) {
1318 /* eMMC uses cmd21 while sd and sdio use cmd19 */ 1318 if (mmc->card) {
1319 tuning_opcode = mmc->card->type == MMC_TYPE_MMC ? 1319 /* eMMC uses cmd21 but sd and sdio use cmd19 */
1320 MMC_SEND_TUNING_BLOCK_HS200 : 1320 tuning_opcode =
1321 MMC_SEND_TUNING_BLOCK; 1321 mmc->card->type == MMC_TYPE_MMC ?
1322 spin_unlock_irqrestore(&host->lock, flags); 1322 MMC_SEND_TUNING_BLOCK_HS200 :
1323 sdhci_execute_tuning(mmc, tuning_opcode); 1323 MMC_SEND_TUNING_BLOCK;
1324 spin_lock_irqsave(&host->lock, flags); 1324 spin_unlock_irqrestore(&host->lock, flags);
1325 1325 sdhci_execute_tuning(mmc, tuning_opcode);
1326 /* Restore original mmc_request structure */ 1326 spin_lock_irqsave(&host->lock, flags);
1327 host->mrq = mrq; 1327
1328 /* Restore original mmc_request structure */
1329 host->mrq = mrq;
1330 }
1328 } 1331 }
1329 1332
1330 if (mrq->sbc && !(host->flags & SDHCI_AUTO_CMD23)) 1333 if (mrq->sbc && !(host->flags & SDHCI_AUTO_CMD23))
@@ -2837,6 +2840,9 @@ int sdhci_add_host(struct sdhci_host *host)
2837 if (!(host->quirks & SDHCI_QUIRK_FORCE_1_BIT_DATA)) 2840 if (!(host->quirks & SDHCI_QUIRK_FORCE_1_BIT_DATA))
2838 mmc->caps |= MMC_CAP_4_BIT_DATA; 2841 mmc->caps |= MMC_CAP_4_BIT_DATA;
2839 2842
2843 if (host->quirks2 & SDHCI_QUIRK2_HOST_NO_CMD23)
2844 mmc->caps &= ~MMC_CAP_CMD23;
2845
2840 if (caps[0] & SDHCI_CAN_DO_HISPD) 2846 if (caps[0] & SDHCI_CAN_DO_HISPD)
2841 mmc->caps |= MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED; 2847 mmc->caps |= MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED;
2842 2848
@@ -2846,9 +2852,12 @@ int sdhci_add_host(struct sdhci_host *host)
2846 2852
2847 /* If vqmmc regulator and no 1.8V signalling, then there's no UHS */ 2853 /* If vqmmc regulator and no 1.8V signalling, then there's no UHS */
2848 host->vqmmc = regulator_get(mmc_dev(mmc), "vqmmc"); 2854 host->vqmmc = regulator_get(mmc_dev(mmc), "vqmmc");
2849 if (IS_ERR(host->vqmmc)) { 2855 if (IS_ERR_OR_NULL(host->vqmmc)) {
2850 pr_info("%s: no vqmmc regulator found\n", mmc_hostname(mmc)); 2856 if (PTR_ERR(host->vqmmc) < 0) {
2851 host->vqmmc = NULL; 2857 pr_info("%s: no vqmmc regulator found\n",
2858 mmc_hostname(mmc));
2859 host->vqmmc = NULL;
2860 }
2852 } 2861 }
2853 else if (regulator_is_supported_voltage(host->vqmmc, 1800000, 1800000)) 2862 else if (regulator_is_supported_voltage(host->vqmmc, 1800000, 1800000))
2854 regulator_enable(host->vqmmc); 2863 regulator_enable(host->vqmmc);
@@ -2904,9 +2913,12 @@ int sdhci_add_host(struct sdhci_host *host)
2904 ocr_avail = 0; 2913 ocr_avail = 0;
2905 2914
2906 host->vmmc = regulator_get(mmc_dev(mmc), "vmmc"); 2915 host->vmmc = regulator_get(mmc_dev(mmc), "vmmc");
2907 if (IS_ERR(host->vmmc)) { 2916 if (IS_ERR_OR_NULL(host->vmmc)) {
2908 pr_info("%s: no vmmc regulator found\n", mmc_hostname(mmc)); 2917 if (PTR_ERR(host->vmmc) < 0) {
2909 host->vmmc = NULL; 2918 pr_info("%s: no vmmc regulator found\n",
2919 mmc_hostname(mmc));
2920 host->vmmc = NULL;
2921 }
2910 } else 2922 } else
2911 regulator_enable(host->vmmc); 2923 regulator_enable(host->vmmc);
2912 2924
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index 97653ea8942..71a4a7ed46c 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -278,6 +278,7 @@ struct sdhci_ops {
278 void (*hw_reset)(struct sdhci_host *host); 278 void (*hw_reset)(struct sdhci_host *host);
279 void (*platform_suspend)(struct sdhci_host *host); 279 void (*platform_suspend)(struct sdhci_host *host);
280 void (*platform_resume)(struct sdhci_host *host); 280 void (*platform_resume)(struct sdhci_host *host);
281 void (*platform_init)(struct sdhci_host *host);
281}; 282};
282 283
283#ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS 284#ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS
diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c
index 11d2bc3b51d..d25bc97dc5c 100644
--- a/drivers/mmc/host/sh_mmcif.c
+++ b/drivers/mmc/host/sh_mmcif.c
@@ -1466,9 +1466,9 @@ static int __devexit sh_mmcif_remove(struct platform_device *pdev)
1466 1466
1467 platform_set_drvdata(pdev, NULL); 1467 platform_set_drvdata(pdev, NULL);
1468 1468
1469 clk_disable(host->hclk);
1469 mmc_free_host(host->mmc); 1470 mmc_free_host(host->mmc);
1470 pm_runtime_put_sync(&pdev->dev); 1471 pm_runtime_put_sync(&pdev->dev);
1471 clk_disable(host->hclk);
1472 pm_runtime_disable(&pdev->dev); 1472 pm_runtime_disable(&pdev->dev);
1473 1473
1474 return 0; 1474 return 0;
diff --git a/drivers/mtd/devices/slram.c b/drivers/mtd/devices/slram.c
index 8f52fc858e4..5a5cd2ace4a 100644
--- a/drivers/mtd/devices/slram.c
+++ b/drivers/mtd/devices/slram.c
@@ -240,7 +240,7 @@ static int parse_cmdline(char *devname, char *szstart, char *szlength)
240 240
241 if (*(szlength) != '+') { 241 if (*(szlength) != '+') {
242 devlength = simple_strtoul(szlength, &buffer, 0); 242 devlength = simple_strtoul(szlength, &buffer, 0);
243 devlength = handle_unit(devlength, buffer) - devstart; 243 devlength = handle_unit(devlength, buffer);
244 if (devlength < devstart) 244 if (devlength < devstart)
245 goto err_out; 245 goto err_out;
246 246
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index ec6841d8e95..1a03b7f673c 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -2983,13 +2983,15 @@ static void nand_decode_ext_id(struct mtd_info *mtd, struct nand_chip *chip,
2983 /* 2983 /*
2984 * Field definitions are in the following datasheets: 2984 * Field definitions are in the following datasheets:
2985 * Old style (4,5 byte ID): Samsung K9GAG08U0M (p.32) 2985 * Old style (4,5 byte ID): Samsung K9GAG08U0M (p.32)
2986 * New style (6 byte ID): Samsung K9GAG08U0F (p.44) 2986 * New Samsung (6 byte ID): Samsung K9GAG08U0F (p.44)
2987 * Hynix MLC (6 byte ID): Hynix H27UBG8T2B (p.22) 2987 * Hynix MLC (6 byte ID): Hynix H27UBG8T2B (p.22)
2988 * 2988 *
2989 * Check for ID length, cell type, and Hynix/Samsung ID to decide what 2989 * Check for ID length, non-zero 6th byte, cell type, and Hynix/Samsung
2990 * to do. 2990 * ID to decide what to do.
2991 */ 2991 */
2992 if (id_len == 6 && id_data[0] == NAND_MFR_SAMSUNG) { 2992 if (id_len == 6 && id_data[0] == NAND_MFR_SAMSUNG &&
2993 (chip->cellinfo & NAND_CI_CELLTYPE_MSK) &&
2994 id_data[5] != 0x00) {
2993 /* Calc pagesize */ 2995 /* Calc pagesize */
2994 mtd->writesize = 2048 << (extid & 0x03); 2996 mtd->writesize = 2048 << (extid & 0x03);
2995 extid >>= 2; 2997 extid >>= 2;
diff --git a/drivers/mtd/ofpart.c b/drivers/mtd/ofpart.c
index 64be8f0848b..d9127e2ed80 100644
--- a/drivers/mtd/ofpart.c
+++ b/drivers/mtd/ofpart.c
@@ -121,7 +121,7 @@ static int parse_ofoldpart_partitions(struct mtd_info *master,
121 nr_parts = plen / sizeof(part[0]); 121 nr_parts = plen / sizeof(part[0]);
122 122
123 *pparts = kzalloc(nr_parts * sizeof(*(*pparts)), GFP_KERNEL); 123 *pparts = kzalloc(nr_parts * sizeof(*(*pparts)), GFP_KERNEL);
124 if (!pparts) 124 if (!*pparts)
125 return -ENOMEM; 125 return -ENOMEM;
126 126
127 names = of_get_property(dp, "partition-names", &plen); 127 names = of_get_property(dp, "partition-names", &plen);
diff --git a/drivers/mtd/onenand/onenand_base.c b/drivers/mtd/onenand/onenand_base.c
index 7153e0d2710..b3f41f20062 100644
--- a/drivers/mtd/onenand/onenand_base.c
+++ b/drivers/mtd/onenand/onenand_base.c
@@ -3694,7 +3694,7 @@ static int flexonenand_check_blocks_erased(struct mtd_info *mtd, int start, int
3694 * flexonenand_set_boundary - Writes the SLC boundary 3694 * flexonenand_set_boundary - Writes the SLC boundary
3695 * @param mtd - mtd info structure 3695 * @param mtd - mtd info structure
3696 */ 3696 */
3697int flexonenand_set_boundary(struct mtd_info *mtd, int die, 3697static int flexonenand_set_boundary(struct mtd_info *mtd, int die,
3698 int boundary, int lock) 3698 int boundary, int lock)
3699{ 3699{
3700 struct onenand_chip *this = mtd->priv; 3700 struct onenand_chip *this = mtd->priv;
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index b721902bb6b..5f5b69f37d2 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1379,6 +1379,8 @@ static void bond_compute_features(struct bonding *bond)
1379 struct net_device *bond_dev = bond->dev; 1379 struct net_device *bond_dev = bond->dev;
1380 netdev_features_t vlan_features = BOND_VLAN_FEATURES; 1380 netdev_features_t vlan_features = BOND_VLAN_FEATURES;
1381 unsigned short max_hard_header_len = ETH_HLEN; 1381 unsigned short max_hard_header_len = ETH_HLEN;
1382 unsigned int gso_max_size = GSO_MAX_SIZE;
1383 u16 gso_max_segs = GSO_MAX_SEGS;
1382 int i; 1384 int i;
1383 unsigned int flags, dst_release_flag = IFF_XMIT_DST_RELEASE; 1385 unsigned int flags, dst_release_flag = IFF_XMIT_DST_RELEASE;
1384 1386
@@ -1394,11 +1396,16 @@ static void bond_compute_features(struct bonding *bond)
1394 dst_release_flag &= slave->dev->priv_flags; 1396 dst_release_flag &= slave->dev->priv_flags;
1395 if (slave->dev->hard_header_len > max_hard_header_len) 1397 if (slave->dev->hard_header_len > max_hard_header_len)
1396 max_hard_header_len = slave->dev->hard_header_len; 1398 max_hard_header_len = slave->dev->hard_header_len;
1399
1400 gso_max_size = min(gso_max_size, slave->dev->gso_max_size);
1401 gso_max_segs = min(gso_max_segs, slave->dev->gso_max_segs);
1397 } 1402 }
1398 1403
1399done: 1404done:
1400 bond_dev->vlan_features = vlan_features; 1405 bond_dev->vlan_features = vlan_features;
1401 bond_dev->hard_header_len = max_hard_header_len; 1406 bond_dev->hard_header_len = max_hard_header_len;
1407 bond_dev->gso_max_segs = gso_max_segs;
1408 netif_set_gso_max_size(bond_dev, gso_max_size);
1402 1409
1403 flags = bond_dev->priv_flags & ~IFF_XMIT_DST_RELEASE; 1410 flags = bond_dev->priv_flags & ~IFF_XMIT_DST_RELEASE;
1404 bond_dev->priv_flags = flags | dst_release_flag; 1411 bond_dev->priv_flags = flags | dst_release_flag;
@@ -1519,7 +1526,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1519 /* no need to lock since we're protected by rtnl_lock */ 1526 /* no need to lock since we're protected by rtnl_lock */
1520 if (slave_dev->features & NETIF_F_VLAN_CHALLENGED) { 1527 if (slave_dev->features & NETIF_F_VLAN_CHALLENGED) {
1521 pr_debug("%s: NETIF_F_VLAN_CHALLENGED\n", slave_dev->name); 1528 pr_debug("%s: NETIF_F_VLAN_CHALLENGED\n", slave_dev->name);
1522 if (bond_vlan_used(bond)) { 1529 if (vlan_uses_dev(bond_dev)) {
1523 pr_err("%s: Error: cannot enslave VLAN challenged slave %s on VLAN enabled bond %s\n", 1530 pr_err("%s: Error: cannot enslave VLAN challenged slave %s on VLAN enabled bond %s\n",
1524 bond_dev->name, slave_dev->name, bond_dev->name); 1531 bond_dev->name, slave_dev->name, bond_dev->name);
1525 return -EPERM; 1532 return -EPERM;
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index dc15d248443..ef8d2a080d1 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -1060,7 +1060,7 @@ static ssize_t bonding_store_primary(struct device *d,
1060 goto out; 1060 goto out;
1061 } 1061 }
1062 1062
1063 sscanf(buf, "%16s", ifname); /* IFNAMSIZ */ 1063 sscanf(buf, "%15s", ifname); /* IFNAMSIZ */
1064 1064
1065 /* check to see if we are clearing primary */ 1065 /* check to see if we are clearing primary */
1066 if (!strlen(ifname) || buf[0] == '\n') { 1066 if (!strlen(ifname) || buf[0] == '\n') {
@@ -1237,7 +1237,7 @@ static ssize_t bonding_store_active_slave(struct device *d,
1237 goto out; 1237 goto out;
1238 } 1238 }
1239 1239
1240 sscanf(buf, "%16s", ifname); /* IFNAMSIZ */ 1240 sscanf(buf, "%15s", ifname); /* IFNAMSIZ */
1241 1241
1242 /* check to see if we are clearing active */ 1242 /* check to see if we are clearing active */
1243 if (!strlen(ifname) || buf[0] == '\n') { 1243 if (!strlen(ifname) || buf[0] == '\n') {
diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
index c78ecfca1e4..a412bf6d73e 100644
--- a/drivers/net/can/flexcan.c
+++ b/drivers/net/can/flexcan.c
@@ -144,9 +144,22 @@
144 144
145#define FLEXCAN_MB_CODE_MASK (0xf0ffffff) 145#define FLEXCAN_MB_CODE_MASK (0xf0ffffff)
146 146
147/* FLEXCAN hardware feature flags */ 147/*
148 * FLEXCAN hardware feature flags
149 *
150 * Below is some version info we got:
151 * SOC Version IP-Version Glitch- [TR]WRN_INT
152 * Filter? connected?
153 * MX25 FlexCAN2 03.00.00.00 no no
154 * MX28 FlexCAN2 03.00.04.00 yes yes
155 * MX35 FlexCAN2 03.00.00.00 no no
156 * MX53 FlexCAN2 03.00.00.00 yes no
157 * MX6s FlexCAN3 10.00.12.00 yes yes
158 *
159 * Some SOCs do not have the RX_WARN & TX_WARN interrupt line connected.
160 */
148#define FLEXCAN_HAS_V10_FEATURES BIT(1) /* For core version >= 10 */ 161#define FLEXCAN_HAS_V10_FEATURES BIT(1) /* For core version >= 10 */
149#define FLEXCAN_HAS_BROKEN_ERR_STATE BIT(2) /* Broken error state handling */ 162#define FLEXCAN_HAS_BROKEN_ERR_STATE BIT(2) /* [TR]WRN_INT not connected */
150 163
151/* Structure of the message buffer */ 164/* Structure of the message buffer */
152struct flexcan_mb { 165struct flexcan_mb {
@@ -205,7 +218,7 @@ static struct flexcan_devtype_data fsl_p1010_devtype_data = {
205}; 218};
206static struct flexcan_devtype_data fsl_imx28_devtype_data; 219static struct flexcan_devtype_data fsl_imx28_devtype_data;
207static struct flexcan_devtype_data fsl_imx6q_devtype_data = { 220static struct flexcan_devtype_data fsl_imx6q_devtype_data = {
208 .features = FLEXCAN_HAS_V10_FEATURES | FLEXCAN_HAS_BROKEN_ERR_STATE, 221 .features = FLEXCAN_HAS_V10_FEATURES,
209}; 222};
210 223
211static const struct can_bittiming_const flexcan_bittiming_const = { 224static const struct can_bittiming_const flexcan_bittiming_const = {
diff --git a/drivers/net/can/sja1000/peak_pci.c b/drivers/net/can/sja1000/peak_pci.c
index f5b82aeb254..6525dbcca4e 100644
--- a/drivers/net/can/sja1000/peak_pci.c
+++ b/drivers/net/can/sja1000/peak_pci.c
@@ -30,9 +30,10 @@
30 30
31#include "sja1000.h" 31#include "sja1000.h"
32 32
33MODULE_AUTHOR("Wolfgang Grandegger <wg@grandegger.com>"); 33MODULE_AUTHOR("Stephane Grosjean <s.grosjean@peak-system.com>");
34MODULE_DESCRIPTION("Socket-CAN driver for PEAK PCAN PCI family cards"); 34MODULE_DESCRIPTION("Socket-CAN driver for PEAK PCAN PCI family cards");
35MODULE_SUPPORTED_DEVICE("PEAK PCAN PCI/PCIe/PCIeC miniPCI CAN cards"); 35MODULE_SUPPORTED_DEVICE("PEAK PCAN PCI/PCIe/PCIeC miniPCI CAN cards");
36MODULE_SUPPORTED_DEVICE("PEAK PCAN miniPCIe/cPCI PC/104+ PCI/104e CAN Cards");
36MODULE_LICENSE("GPL v2"); 37MODULE_LICENSE("GPL v2");
37 38
38#define DRV_NAME "peak_pci" 39#define DRV_NAME "peak_pci"
@@ -64,7 +65,11 @@ struct peak_pci_chan {
64#define PEAK_PCI_DEVICE_ID 0x0001 /* for PCI/PCIe slot cards */ 65#define PEAK_PCI_DEVICE_ID 0x0001 /* for PCI/PCIe slot cards */
65#define PEAK_PCIEC_DEVICE_ID 0x0002 /* for ExpressCard slot cards */ 66#define PEAK_PCIEC_DEVICE_ID 0x0002 /* for ExpressCard slot cards */
66#define PEAK_PCIE_DEVICE_ID 0x0003 /* for nextgen PCIe slot cards */ 67#define PEAK_PCIE_DEVICE_ID 0x0003 /* for nextgen PCIe slot cards */
67#define PEAK_MPCI_DEVICE_ID 0x0008 /* The miniPCI slot cards */ 68#define PEAK_CPCI_DEVICE_ID 0x0004 /* for nextgen cPCI slot cards */
69#define PEAK_MPCI_DEVICE_ID 0x0005 /* for nextgen miniPCI slot cards */
70#define PEAK_PC_104P_DEVICE_ID 0x0006 /* PCAN-PC/104+ cards */
71#define PEAK_PCI_104E_DEVICE_ID 0x0007 /* PCAN-PCI/104 Express cards */
72#define PEAK_MPCIE_DEVICE_ID 0x0008 /* The miniPCIe slot cards */
68 73
69#define PEAK_PCI_CHAN_MAX 4 74#define PEAK_PCI_CHAN_MAX 4
70 75
@@ -76,6 +81,10 @@ static DEFINE_PCI_DEVICE_TABLE(peak_pci_tbl) = {
76 {PEAK_PCI_VENDOR_ID, PEAK_PCI_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,}, 81 {PEAK_PCI_VENDOR_ID, PEAK_PCI_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,},
77 {PEAK_PCI_VENDOR_ID, PEAK_PCIE_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,}, 82 {PEAK_PCI_VENDOR_ID, PEAK_PCIE_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,},
78 {PEAK_PCI_VENDOR_ID, PEAK_MPCI_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,}, 83 {PEAK_PCI_VENDOR_ID, PEAK_MPCI_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,},
84 {PEAK_PCI_VENDOR_ID, PEAK_MPCIE_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,},
85 {PEAK_PCI_VENDOR_ID, PEAK_PC_104P_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,},
86 {PEAK_PCI_VENDOR_ID, PEAK_PCI_104E_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,},
87 {PEAK_PCI_VENDOR_ID, PEAK_CPCI_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,},
79#ifdef CONFIG_CAN_PEAK_PCIEC 88#ifdef CONFIG_CAN_PEAK_PCIEC
80 {PEAK_PCI_VENDOR_ID, PEAK_PCIEC_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,}, 89 {PEAK_PCI_VENDOR_ID, PEAK_PCIEC_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,},
81#endif 90#endif
diff --git a/drivers/net/ethernet/8390/ne.c b/drivers/net/ethernet/8390/ne.c
index d04911d33b6..47618e50535 100644
--- a/drivers/net/ethernet/8390/ne.c
+++ b/drivers/net/ethernet/8390/ne.c
@@ -813,6 +813,7 @@ static int __init ne_drv_probe(struct platform_device *pdev)
813 dev->irq = irq[this_dev]; 813 dev->irq = irq[this_dev];
814 dev->mem_end = bad[this_dev]; 814 dev->mem_end = bad[this_dev];
815 } 815 }
816 SET_NETDEV_DEV(dev, &pdev->dev);
816 err = do_ne_probe(dev); 817 err = do_ne_probe(dev);
817 if (err) { 818 if (err) {
818 free_netdev(dev); 819 free_netdev(dev);
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
index 24220992413..4833b6a9031 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
@@ -2957,9 +2957,13 @@ netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev)
2957 skb_shinfo(skb)->nr_frags + 2957 skb_shinfo(skb)->nr_frags +
2958 BDS_PER_TX_PKT + 2958 BDS_PER_TX_PKT +
2959 NEXT_CNT_PER_TX_PKT(MAX_BDS_PER_TX_PKT))) { 2959 NEXT_CNT_PER_TX_PKT(MAX_BDS_PER_TX_PKT))) {
2960 bnx2x_fp_qstats(bp, txdata->parent_fp)->driver_xoff++; 2960 /* Handle special storage cases separately */
2961 netif_tx_stop_queue(txq); 2961 if (txdata->tx_ring_size != 0) {
2962 BNX2X_ERR("BUG! Tx ring full when queue awake!\n"); 2962 BNX2X_ERR("BUG! Tx ring full when queue awake!\n");
2963 bnx2x_fp_qstats(bp, txdata->parent_fp)->driver_xoff++;
2964 netif_tx_stop_queue(txq);
2965 }
2966
2963 return NETDEV_TX_BUSY; 2967 return NETDEV_TX_BUSY;
2964 } 2968 }
2965 2969
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
index c65295dded3..6e5bdd1a31d 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
@@ -1702,7 +1702,7 @@ static int bnx2x_set_eee(struct net_device *dev, struct ethtool_eee *edata)
1702 SHMEM_EEE_ADV_STATUS_SHIFT); 1702 SHMEM_EEE_ADV_STATUS_SHIFT);
1703 if ((advertised != (eee_cfg & SHMEM_EEE_ADV_STATUS_MASK))) { 1703 if ((advertised != (eee_cfg & SHMEM_EEE_ADV_STATUS_MASK))) {
1704 DP(BNX2X_MSG_ETHTOOL, 1704 DP(BNX2X_MSG_ETHTOOL,
1705 "Direct manipulation of EEE advertisment is not supported\n"); 1705 "Direct manipulation of EEE advertisement is not supported\n");
1706 return -EINVAL; 1706 return -EINVAL;
1707 } 1707 }
1708 1708
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c
index e2e45ee5df3..f6cfdc6cf20 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_link.c
@@ -137,7 +137,16 @@
137#define LINK_20GTFD LINK_STATUS_SPEED_AND_DUPLEX_20GTFD 137#define LINK_20GTFD LINK_STATUS_SPEED_AND_DUPLEX_20GTFD
138#define LINK_20GXFD LINK_STATUS_SPEED_AND_DUPLEX_20GXFD 138#define LINK_20GXFD LINK_STATUS_SPEED_AND_DUPLEX_20GXFD
139 139
140 140#define LINK_UPDATE_MASK \
141 (LINK_STATUS_SPEED_AND_DUPLEX_MASK | \
142 LINK_STATUS_LINK_UP | \
143 LINK_STATUS_PHYSICAL_LINK_FLAG | \
144 LINK_STATUS_AUTO_NEGOTIATE_COMPLETE | \
145 LINK_STATUS_RX_FLOW_CONTROL_FLAG_MASK | \
146 LINK_STATUS_TX_FLOW_CONTROL_FLAG_MASK | \
147 LINK_STATUS_PARALLEL_DETECTION_FLAG_MASK | \
148 LINK_STATUS_LINK_PARTNER_SYMMETRIC_PAUSE | \
149 LINK_STATUS_LINK_PARTNER_ASYMMETRIC_PAUSE)
141 150
142#define SFP_EEPROM_CON_TYPE_ADDR 0x2 151#define SFP_EEPROM_CON_TYPE_ADDR 0x2
143 #define SFP_EEPROM_CON_TYPE_VAL_LC 0x7 152 #define SFP_EEPROM_CON_TYPE_VAL_LC 0x7
@@ -3295,6 +3304,21 @@ static void bnx2x_serdes_deassert(struct bnx2x *bp, u8 port)
3295 DEFAULT_PHY_DEV_ADDR); 3304 DEFAULT_PHY_DEV_ADDR);
3296} 3305}
3297 3306
3307static void bnx2x_xgxs_specific_func(struct bnx2x_phy *phy,
3308 struct link_params *params,
3309 u32 action)
3310{
3311 struct bnx2x *bp = params->bp;
3312 switch (action) {
3313 case PHY_INIT:
3314 /* Set correct devad */
3315 REG_WR(bp, NIG_REG_XGXS0_CTRL_MD_ST + params->port*0x18, 0);
3316 REG_WR(bp, NIG_REG_XGXS0_CTRL_MD_DEVAD + params->port*0x18,
3317 phy->def_md_devad);
3318 break;
3319 }
3320}
3321
3298static void bnx2x_xgxs_deassert(struct link_params *params) 3322static void bnx2x_xgxs_deassert(struct link_params *params)
3299{ 3323{
3300 struct bnx2x *bp = params->bp; 3324 struct bnx2x *bp = params->bp;
@@ -3309,10 +3333,8 @@ static void bnx2x_xgxs_deassert(struct link_params *params)
3309 REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_3_CLEAR, val); 3333 REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_3_CLEAR, val);
3310 udelay(500); 3334 udelay(500);
3311 REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_3_SET, val); 3335 REG_WR(bp, GRCBASE_MISC + MISC_REGISTERS_RESET_REG_3_SET, val);
3312 3336 bnx2x_xgxs_specific_func(&params->phy[INT_PHY], params,
3313 REG_WR(bp, NIG_REG_XGXS0_CTRL_MD_ST + port*0x18, 0); 3337 PHY_INIT);
3314 REG_WR(bp, NIG_REG_XGXS0_CTRL_MD_DEVAD + port*0x18,
3315 params->phy[INT_PHY].def_md_devad);
3316} 3338}
3317 3339
3318static void bnx2x_calc_ieee_aneg_adv(struct bnx2x_phy *phy, 3340static void bnx2x_calc_ieee_aneg_adv(struct bnx2x_phy *phy,
@@ -3545,14 +3567,11 @@ static void bnx2x_warpcore_set_lpi_passthrough(struct bnx2x_phy *phy,
3545static void bnx2x_warpcore_enable_AN_KR(struct bnx2x_phy *phy, 3567static void bnx2x_warpcore_enable_AN_KR(struct bnx2x_phy *phy,
3546 struct link_params *params, 3568 struct link_params *params,
3547 struct link_vars *vars) { 3569 struct link_vars *vars) {
3548 u16 val16 = 0, lane, i; 3570 u16 lane, i, cl72_ctrl, an_adv = 0;
3571 u16 ucode_ver;
3549 struct bnx2x *bp = params->bp; 3572 struct bnx2x *bp = params->bp;
3550 static struct bnx2x_reg_set reg_set[] = { 3573 static struct bnx2x_reg_set reg_set[] = {
3551 {MDIO_WC_DEVAD, MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2, 0x7}, 3574 {MDIO_WC_DEVAD, MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2, 0x7},
3552 {MDIO_AN_DEVAD, MDIO_WC_REG_PAR_DET_10G_CTRL, 0},
3553 {MDIO_WC_DEVAD, MDIO_WC_REG_CL72_USERB0_CL72_MISC1_CONTROL, 0},
3554 {MDIO_WC_DEVAD, MDIO_WC_REG_XGXSBLK1_LANECTRL0, 0xff},
3555 {MDIO_WC_DEVAD, MDIO_WC_REG_XGXSBLK1_LANECTRL1, 0x5555},
3556 {MDIO_PMA_DEVAD, MDIO_WC_REG_IEEE0BLK_AUTONEGNP, 0x0}, 3575 {MDIO_PMA_DEVAD, MDIO_WC_REG_IEEE0BLK_AUTONEGNP, 0x0},
3557 {MDIO_WC_DEVAD, MDIO_WC_REG_RX66_CONTROL, 0x7415}, 3576 {MDIO_WC_DEVAD, MDIO_WC_REG_RX66_CONTROL, 0x7415},
3558 {MDIO_WC_DEVAD, MDIO_WC_REG_SERDESDIGITAL_MISC2, 0x6190}, 3577 {MDIO_WC_DEVAD, MDIO_WC_REG_SERDESDIGITAL_MISC2, 0x6190},
@@ -3565,12 +3584,19 @@ static void bnx2x_warpcore_enable_AN_KR(struct bnx2x_phy *phy,
3565 bnx2x_cl45_write(bp, phy, reg_set[i].devad, reg_set[i].reg, 3584 bnx2x_cl45_write(bp, phy, reg_set[i].devad, reg_set[i].reg,
3566 reg_set[i].val); 3585 reg_set[i].val);
3567 3586
3587 bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD,
3588 MDIO_WC_REG_CL72_USERB0_CL72_MISC1_CONTROL, &cl72_ctrl);
3589 cl72_ctrl &= 0xf8ff;
3590 cl72_ctrl |= 0x3800;
3591 bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD,
3592 MDIO_WC_REG_CL72_USERB0_CL72_MISC1_CONTROL, cl72_ctrl);
3593
3568 /* Check adding advertisement for 1G KX */ 3594 /* Check adding advertisement for 1G KX */
3569 if (((vars->line_speed == SPEED_AUTO_NEG) && 3595 if (((vars->line_speed == SPEED_AUTO_NEG) &&
3570 (phy->speed_cap_mask & PORT_HW_CFG_SPEED_CAPABILITY_D0_1G)) || 3596 (phy->speed_cap_mask & PORT_HW_CFG_SPEED_CAPABILITY_D0_1G)) ||
3571 (vars->line_speed == SPEED_1000)) { 3597 (vars->line_speed == SPEED_1000)) {
3572 u32 addr = MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2; 3598 u32 addr = MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2;
3573 val16 |= (1<<5); 3599 an_adv |= (1<<5);
3574 3600
3575 /* Enable CL37 1G Parallel Detect */ 3601 /* Enable CL37 1G Parallel Detect */
3576 bnx2x_cl45_read_or_write(bp, phy, MDIO_WC_DEVAD, addr, 0x1); 3602 bnx2x_cl45_read_or_write(bp, phy, MDIO_WC_DEVAD, addr, 0x1);
@@ -3580,11 +3606,14 @@ static void bnx2x_warpcore_enable_AN_KR(struct bnx2x_phy *phy,
3580 (phy->speed_cap_mask & PORT_HW_CFG_SPEED_CAPABILITY_D0_10G)) || 3606 (phy->speed_cap_mask & PORT_HW_CFG_SPEED_CAPABILITY_D0_10G)) ||
3581 (vars->line_speed == SPEED_10000)) { 3607 (vars->line_speed == SPEED_10000)) {
3582 /* Check adding advertisement for 10G KR */ 3608 /* Check adding advertisement for 10G KR */
3583 val16 |= (1<<7); 3609 an_adv |= (1<<7);
3584 /* Enable 10G Parallel Detect */ 3610 /* Enable 10G Parallel Detect */
3611 CL22_WR_OVER_CL45(bp, phy, MDIO_REG_BANK_AER_BLOCK,
3612 MDIO_AER_BLOCK_AER_REG, 0);
3613
3585 bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, 3614 bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD,
3586 MDIO_WC_REG_PAR_DET_10G_CTRL, 1); 3615 MDIO_WC_REG_PAR_DET_10G_CTRL, 1);
3587 3616 bnx2x_set_aer_mmd(params, phy);
3588 DP(NETIF_MSG_LINK, "Advertize 10G\n"); 3617 DP(NETIF_MSG_LINK, "Advertize 10G\n");
3589 } 3618 }
3590 3619
@@ -3604,7 +3633,7 @@ static void bnx2x_warpcore_enable_AN_KR(struct bnx2x_phy *phy,
3604 3633
3605 /* Advertised speeds */ 3634 /* Advertised speeds */
3606 bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, 3635 bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD,
3607 MDIO_WC_REG_AN_IEEE1BLK_AN_ADVERTISEMENT1, val16); 3636 MDIO_WC_REG_AN_IEEE1BLK_AN_ADVERTISEMENT1, an_adv);
3608 3637
3609 /* Advertised and set FEC (Forward Error Correction) */ 3638 /* Advertised and set FEC (Forward Error Correction) */
3610 bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD, 3639 bnx2x_cl45_write(bp, phy, MDIO_AN_DEVAD,
@@ -3628,9 +3657,10 @@ static void bnx2x_warpcore_enable_AN_KR(struct bnx2x_phy *phy,
3628 /* Set KR Autoneg Work-Around flag for Warpcore version older than D108 3657 /* Set KR Autoneg Work-Around flag for Warpcore version older than D108
3629 */ 3658 */
3630 bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD, 3659 bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD,
3631 MDIO_WC_REG_UC_INFO_B1_VERSION, &val16); 3660 MDIO_WC_REG_UC_INFO_B1_VERSION, &ucode_ver);
3632 if (val16 < 0xd108) { 3661 if (ucode_ver < 0xd108) {
3633 DP(NETIF_MSG_LINK, "Enable AN KR work-around\n"); 3662 DP(NETIF_MSG_LINK, "Enable AN KR work-around. WC ver:0x%x\n",
3663 ucode_ver);
3634 vars->rx_tx_asic_rst = MAX_KR_LINK_RETRY; 3664 vars->rx_tx_asic_rst = MAX_KR_LINK_RETRY;
3635 } 3665 }
3636 bnx2x_cl45_read_or_write(bp, phy, MDIO_WC_DEVAD, 3666 bnx2x_cl45_read_or_write(bp, phy, MDIO_WC_DEVAD,
@@ -3651,21 +3681,16 @@ static void bnx2x_warpcore_set_10G_KR(struct bnx2x_phy *phy,
3651 struct link_vars *vars) 3681 struct link_vars *vars)
3652{ 3682{
3653 struct bnx2x *bp = params->bp; 3683 struct bnx2x *bp = params->bp;
3654 u16 i; 3684 u16 val16, i, lane;
3655 static struct bnx2x_reg_set reg_set[] = { 3685 static struct bnx2x_reg_set reg_set[] = {
3656 /* Disable Autoneg */ 3686 /* Disable Autoneg */
3657 {MDIO_WC_DEVAD, MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2, 0x7}, 3687 {MDIO_WC_DEVAD, MDIO_WC_REG_SERDESDIGITAL_CONTROL1000X2, 0x7},
3658 {MDIO_AN_DEVAD, MDIO_WC_REG_PAR_DET_10G_CTRL, 0},
3659 {MDIO_WC_DEVAD, MDIO_WC_REG_CL72_USERB0_CL72_MISC1_CONTROL, 3688 {MDIO_WC_DEVAD, MDIO_WC_REG_CL72_USERB0_CL72_MISC1_CONTROL,
3660 0x3f00}, 3689 0x3f00},
3661 {MDIO_AN_DEVAD, MDIO_WC_REG_AN_IEEE1BLK_AN_ADVERTISEMENT1, 0}, 3690 {MDIO_AN_DEVAD, MDIO_WC_REG_AN_IEEE1BLK_AN_ADVERTISEMENT1, 0},
3662 {MDIO_AN_DEVAD, MDIO_WC_REG_IEEE0BLK_MIICNTL, 0x0}, 3691 {MDIO_AN_DEVAD, MDIO_WC_REG_IEEE0BLK_MIICNTL, 0x0},
3663 {MDIO_WC_DEVAD, MDIO_WC_REG_DIGITAL3_UP1, 0x1}, 3692 {MDIO_WC_DEVAD, MDIO_WC_REG_DIGITAL3_UP1, 0x1},
3664 {MDIO_WC_DEVAD, MDIO_WC_REG_DIGITAL5_MISC7, 0xa}, 3693 {MDIO_WC_DEVAD, MDIO_WC_REG_DIGITAL5_MISC7, 0xa},
3665 /* Disable CL36 PCS Tx */
3666 {MDIO_WC_DEVAD, MDIO_WC_REG_XGXSBLK1_LANECTRL0, 0x0},
3667 /* Double Wide Single Data Rate @ pll rate */
3668 {MDIO_WC_DEVAD, MDIO_WC_REG_XGXSBLK1_LANECTRL1, 0xFFFF},
3669 /* Leave cl72 training enable, needed for KR */ 3694 /* Leave cl72 training enable, needed for KR */
3670 {MDIO_PMA_DEVAD, 3695 {MDIO_PMA_DEVAD,
3671 MDIO_WC_REG_PMD_IEEE9BLK_TENGBASE_KR_PMD_CONTROL_REGISTER_150, 3696 MDIO_WC_REG_PMD_IEEE9BLK_TENGBASE_KR_PMD_CONTROL_REGISTER_150,
@@ -3676,11 +3701,24 @@ static void bnx2x_warpcore_set_10G_KR(struct bnx2x_phy *phy,
3676 bnx2x_cl45_write(bp, phy, reg_set[i].devad, reg_set[i].reg, 3701 bnx2x_cl45_write(bp, phy, reg_set[i].devad, reg_set[i].reg,
3677 reg_set[i].val); 3702 reg_set[i].val);
3678 3703
3679 /* Leave CL72 enabled */ 3704 lane = bnx2x_get_warpcore_lane(phy, params);
3680 bnx2x_cl45_read_or_write(bp, phy, MDIO_WC_DEVAD, 3705 /* Global registers */
3681 MDIO_WC_REG_CL72_USERB0_CL72_MISC1_CONTROL, 3706 CL22_WR_OVER_CL45(bp, phy, MDIO_REG_BANK_AER_BLOCK,
3682 0x3800); 3707 MDIO_AER_BLOCK_AER_REG, 0);
3708 /* Disable CL36 PCS Tx */
3709 bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD,
3710 MDIO_WC_REG_XGXSBLK1_LANECTRL0, &val16);
3711 val16 &= ~(0x0011 << lane);
3712 bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD,
3713 MDIO_WC_REG_XGXSBLK1_LANECTRL0, val16);
3683 3714
3715 bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD,
3716 MDIO_WC_REG_XGXSBLK1_LANECTRL1, &val16);
3717 val16 |= (0x0303 << (lane << 1));
3718 bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD,
3719 MDIO_WC_REG_XGXSBLK1_LANECTRL1, val16);
3720 /* Restore AER */
3721 bnx2x_set_aer_mmd(params, phy);
3684 /* Set speed via PMA/PMD register */ 3722 /* Set speed via PMA/PMD register */
3685 bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD, 3723 bnx2x_cl45_write(bp, phy, MDIO_PMA_DEVAD,
3686 MDIO_WC_REG_IEEE0BLK_MIICNTL, 0x2040); 3724 MDIO_WC_REG_IEEE0BLK_MIICNTL, 0x2040);
@@ -4303,7 +4341,7 @@ static void bnx2x_warpcore_link_reset(struct bnx2x_phy *phy,
4303 struct link_params *params) 4341 struct link_params *params)
4304{ 4342{
4305 struct bnx2x *bp = params->bp; 4343 struct bnx2x *bp = params->bp;
4306 u16 val16; 4344 u16 val16, lane;
4307 bnx2x_sfp_e3_set_transmitter(params, phy, 0); 4345 bnx2x_sfp_e3_set_transmitter(params, phy, 0);
4308 bnx2x_set_mdio_clk(bp, params->chip_id, params->port); 4346 bnx2x_set_mdio_clk(bp, params->chip_id, params->port);
4309 bnx2x_set_aer_mmd(params, phy); 4347 bnx2x_set_aer_mmd(params, phy);
@@ -4340,6 +4378,30 @@ static void bnx2x_warpcore_link_reset(struct bnx2x_phy *phy,
4340 MDIO_WC_REG_XGXSBLK1_LANECTRL2, 4378 MDIO_WC_REG_XGXSBLK1_LANECTRL2,
4341 val16 & 0xff00); 4379 val16 & 0xff00);
4342 4380
4381 lane = bnx2x_get_warpcore_lane(phy, params);
4382 /* Disable CL36 PCS Tx */
4383 bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD,
4384 MDIO_WC_REG_XGXSBLK1_LANECTRL0, &val16);
4385 val16 |= (0x11 << lane);
4386 if (phy->flags & FLAGS_WC_DUAL_MODE)
4387 val16 |= (0x22 << lane);
4388 bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD,
4389 MDIO_WC_REG_XGXSBLK1_LANECTRL0, val16);
4390
4391 bnx2x_cl45_read(bp, phy, MDIO_WC_DEVAD,
4392 MDIO_WC_REG_XGXSBLK1_LANECTRL1, &val16);
4393 val16 &= ~(0x0303 << (lane << 1));
4394 val16 |= (0x0101 << (lane << 1));
4395 if (phy->flags & FLAGS_WC_DUAL_MODE) {
4396 val16 &= ~(0x0c0c << (lane << 1));
4397 val16 |= (0x0404 << (lane << 1));
4398 }
4399
4400 bnx2x_cl45_write(bp, phy, MDIO_WC_DEVAD,
4401 MDIO_WC_REG_XGXSBLK1_LANECTRL1, val16);
4402 /* Restore AER */
4403 bnx2x_set_aer_mmd(params, phy);
4404
4343} 4405}
4344 4406
4345static void bnx2x_set_warpcore_loopback(struct bnx2x_phy *phy, 4407static void bnx2x_set_warpcore_loopback(struct bnx2x_phy *phy,
@@ -6296,15 +6358,7 @@ static int bnx2x_update_link_down(struct link_params *params,
6296 vars->mac_type = MAC_TYPE_NONE; 6358 vars->mac_type = MAC_TYPE_NONE;
6297 6359
6298 /* Update shared memory */ 6360 /* Update shared memory */
6299 vars->link_status &= ~(LINK_STATUS_SPEED_AND_DUPLEX_MASK | 6361 vars->link_status &= ~LINK_UPDATE_MASK;
6300 LINK_STATUS_LINK_UP |
6301 LINK_STATUS_PHYSICAL_LINK_FLAG |
6302 LINK_STATUS_AUTO_NEGOTIATE_COMPLETE |
6303 LINK_STATUS_RX_FLOW_CONTROL_FLAG_MASK |
6304 LINK_STATUS_TX_FLOW_CONTROL_FLAG_MASK |
6305 LINK_STATUS_PARALLEL_DETECTION_FLAG_MASK |
6306 LINK_STATUS_LINK_PARTNER_SYMMETRIC_PAUSE |
6307 LINK_STATUS_LINK_PARTNER_ASYMMETRIC_PAUSE);
6308 vars->line_speed = 0; 6362 vars->line_speed = 0;
6309 bnx2x_update_mng(params, vars->link_status); 6363 bnx2x_update_mng(params, vars->link_status);
6310 6364
@@ -6452,6 +6506,7 @@ int bnx2x_link_update(struct link_params *params, struct link_vars *vars)
6452 u16 ext_phy_line_speed = 0, prev_line_speed = vars->line_speed; 6506 u16 ext_phy_line_speed = 0, prev_line_speed = vars->line_speed;
6453 u8 active_external_phy = INT_PHY; 6507 u8 active_external_phy = INT_PHY;
6454 vars->phy_flags &= ~PHY_HALF_OPEN_CONN_FLAG; 6508 vars->phy_flags &= ~PHY_HALF_OPEN_CONN_FLAG;
6509 vars->link_status &= ~LINK_UPDATE_MASK;
6455 for (phy_index = INT_PHY; phy_index < params->num_phys; 6510 for (phy_index = INT_PHY; phy_index < params->num_phys;
6456 phy_index++) { 6511 phy_index++) {
6457 phy_vars[phy_index].flow_ctrl = 0; 6512 phy_vars[phy_index].flow_ctrl = 0;
@@ -7579,7 +7634,7 @@ static void bnx2x_warpcore_power_module(struct link_params *params,
7579static int bnx2x_warpcore_read_sfp_module_eeprom(struct bnx2x_phy *phy, 7634static int bnx2x_warpcore_read_sfp_module_eeprom(struct bnx2x_phy *phy,
7580 struct link_params *params, 7635 struct link_params *params,
7581 u16 addr, u8 byte_cnt, 7636 u16 addr, u8 byte_cnt,
7582 u8 *o_buf) 7637 u8 *o_buf, u8 is_init)
7583{ 7638{
7584 int rc = 0; 7639 int rc = 0;
7585 u8 i, j = 0, cnt = 0; 7640 u8 i, j = 0, cnt = 0;
@@ -7596,10 +7651,10 @@ static int bnx2x_warpcore_read_sfp_module_eeprom(struct bnx2x_phy *phy,
7596 /* 4 byte aligned address */ 7651 /* 4 byte aligned address */
7597 addr32 = addr & (~0x3); 7652 addr32 = addr & (~0x3);
7598 do { 7653 do {
7599 if (cnt == I2C_WA_PWR_ITER) { 7654 if ((!is_init) && (cnt == I2C_WA_PWR_ITER)) {
7600 bnx2x_warpcore_power_module(params, phy, 0); 7655 bnx2x_warpcore_power_module(params, phy, 0);
7601 /* Note that 100us are not enough here */ 7656 /* Note that 100us are not enough here */
7602 usleep_range(1000,1000); 7657 usleep_range(1000, 2000);
7603 bnx2x_warpcore_power_module(params, phy, 1); 7658 bnx2x_warpcore_power_module(params, phy, 1);
7604 } 7659 }
7605 rc = bnx2x_bsc_read(params, phy, 0xa0, addr32, 0, byte_cnt, 7660 rc = bnx2x_bsc_read(params, phy, 0xa0, addr32, 0, byte_cnt,
@@ -7719,7 +7774,7 @@ int bnx2x_read_sfp_module_eeprom(struct bnx2x_phy *phy,
7719 break; 7774 break;
7720 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT: 7775 case PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT:
7721 rc = bnx2x_warpcore_read_sfp_module_eeprom(phy, params, addr, 7776 rc = bnx2x_warpcore_read_sfp_module_eeprom(phy, params, addr,
7722 byte_cnt, o_buf); 7777 byte_cnt, o_buf, 0);
7723 break; 7778 break;
7724 } 7779 }
7725 return rc; 7780 return rc;
@@ -7923,6 +7978,7 @@ static int bnx2x_wait_for_sfp_module_initialized(struct bnx2x_phy *phy,
7923 7978
7924{ 7979{
7925 u8 val; 7980 u8 val;
7981 int rc;
7926 struct bnx2x *bp = params->bp; 7982 struct bnx2x *bp = params->bp;
7927 u16 timeout; 7983 u16 timeout;
7928 /* Initialization time after hot-plug may take up to 300ms for 7984 /* Initialization time after hot-plug may take up to 300ms for
@@ -7930,8 +7986,14 @@ static int bnx2x_wait_for_sfp_module_initialized(struct bnx2x_phy *phy,
7930 */ 7986 */
7931 7987
7932 for (timeout = 0; timeout < 60; timeout++) { 7988 for (timeout = 0; timeout < 60; timeout++) {
7933 if (bnx2x_read_sfp_module_eeprom(phy, params, 1, 1, &val) 7989 if (phy->type == PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT)
7934 == 0) { 7990 rc = bnx2x_warpcore_read_sfp_module_eeprom(phy,
7991 params, 1,
7992 1, &val, 1);
7993 else
7994 rc = bnx2x_read_sfp_module_eeprom(phy, params, 1, 1,
7995 &val);
7996 if (rc == 0) {
7935 DP(NETIF_MSG_LINK, 7997 DP(NETIF_MSG_LINK,
7936 "SFP+ module initialization took %d ms\n", 7998 "SFP+ module initialization took %d ms\n",
7937 timeout * 5); 7999 timeout * 5);
@@ -7939,7 +8001,8 @@ static int bnx2x_wait_for_sfp_module_initialized(struct bnx2x_phy *phy,
7939 } 8001 }
7940 usleep_range(5000, 10000); 8002 usleep_range(5000, 10000);
7941 } 8003 }
7942 return -EINVAL; 8004 rc = bnx2x_read_sfp_module_eeprom(phy, params, 1, 1, &val);
8005 return rc;
7943} 8006}
7944 8007
7945static void bnx2x_8727_power_module(struct bnx2x *bp, 8008static void bnx2x_8727_power_module(struct bnx2x *bp,
@@ -9878,7 +9941,7 @@ static int bnx2x_848x3_config_init(struct bnx2x_phy *phy,
9878 else 9941 else
9879 rc = bnx2x_8483x_disable_eee(phy, params, vars); 9942 rc = bnx2x_8483x_disable_eee(phy, params, vars);
9880 if (rc) { 9943 if (rc) {
9881 DP(NETIF_MSG_LINK, "Failed to set EEE advertisment\n"); 9944 DP(NETIF_MSG_LINK, "Failed to set EEE advertisement\n");
9882 return rc; 9945 return rc;
9883 } 9946 }
9884 } else { 9947 } else {
@@ -10993,7 +11056,7 @@ static struct bnx2x_phy phy_xgxs = {
10993 .format_fw_ver = (format_fw_ver_t)NULL, 11056 .format_fw_ver = (format_fw_ver_t)NULL,
10994 .hw_reset = (hw_reset_t)NULL, 11057 .hw_reset = (hw_reset_t)NULL,
10995 .set_link_led = (set_link_led_t)NULL, 11058 .set_link_led = (set_link_led_t)NULL,
10996 .phy_specific_func = (phy_specific_func_t)NULL 11059 .phy_specific_func = (phy_specific_func_t)bnx2x_xgxs_specific_func
10997}; 11060};
10998static struct bnx2x_phy phy_warpcore = { 11061static struct bnx2x_phy phy_warpcore = {
10999 .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT, 11062 .type = PORT_HW_CFG_XGXS_EXT_PHY_TYPE_DIRECT,
@@ -11465,6 +11528,11 @@ static int bnx2x_populate_int_phy(struct bnx2x *bp, u32 shmem_base, u8 port,
11465 phy->media_type = ETH_PHY_BASE_T; 11528 phy->media_type = ETH_PHY_BASE_T;
11466 break; 11529 break;
11467 case PORT_HW_CFG_NET_SERDES_IF_XFI: 11530 case PORT_HW_CFG_NET_SERDES_IF_XFI:
11531 phy->supported &= (SUPPORTED_1000baseT_Full |
11532 SUPPORTED_10000baseT_Full |
11533 SUPPORTED_FIBRE |
11534 SUPPORTED_Pause |
11535 SUPPORTED_Asym_Pause);
11468 phy->media_type = ETH_PHY_XFP_FIBER; 11536 phy->media_type = ETH_PHY_XFP_FIBER;
11469 break; 11537 break;
11470 case PORT_HW_CFG_NET_SERDES_IF_SFI: 11538 case PORT_HW_CFG_NET_SERDES_IF_SFI:
@@ -12919,7 +12987,7 @@ static u8 bnx2x_analyze_link_error(struct link_params *params,
12919 DP(NETIF_MSG_LINK, "Analyze TX Fault\n"); 12987 DP(NETIF_MSG_LINK, "Analyze TX Fault\n");
12920 break; 12988 break;
12921 default: 12989 default:
12922 DP(NETIF_MSG_LINK, "Analyze UNKOWN\n"); 12990 DP(NETIF_MSG_LINK, "Analyze UNKNOWN\n");
12923 } 12991 }
12924 DP(NETIF_MSG_LINK, "Link changed:[%x %x]->%x\n", vars->link_up, 12992 DP(NETIF_MSG_LINK, "Link changed:[%x %x]->%x\n", vars->link_up,
12925 old_status, status); 12993 old_status, status);
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index d5648fc666b..01611b33a93 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -6794,8 +6794,9 @@ static int bnx2x_init_hw_port(struct bnx2x *bp)
6794 6794
6795 bnx2x_init_block(bp, BLOCK_DORQ, init_phase); 6795 bnx2x_init_block(bp, BLOCK_DORQ, init_phase);
6796 6796
6797 bnx2x_init_block(bp, BLOCK_BRB1, init_phase);
6798
6797 if (CHIP_IS_E1(bp) || CHIP_IS_E1H(bp)) { 6799 if (CHIP_IS_E1(bp) || CHIP_IS_E1H(bp)) {
6798 bnx2x_init_block(bp, BLOCK_BRB1, init_phase);
6799 6800
6800 if (IS_MF(bp)) 6801 if (IS_MF(bp))
6801 low = ((bp->flags & ONE_PORT_FLAG) ? 160 : 246); 6802 low = ((bp->flags & ONE_PORT_FLAG) ? 160 : 246);
@@ -9544,10 +9545,13 @@ static int __devinit bnx2x_prev_unload_common(struct bnx2x *bp)
9544 */ 9545 */
9545static void __devinit bnx2x_prev_interrupted_dmae(struct bnx2x *bp) 9546static void __devinit bnx2x_prev_interrupted_dmae(struct bnx2x *bp)
9546{ 9547{
9547 u32 val = REG_RD(bp, PGLUE_B_REG_PGLUE_B_INT_STS); 9548 if (!CHIP_IS_E1x(bp)) {
9548 if (val & PGLUE_B_PGLUE_B_INT_STS_REG_WAS_ERROR_ATTN) { 9549 u32 val = REG_RD(bp, PGLUE_B_REG_PGLUE_B_INT_STS);
9549 BNX2X_ERR("was error bit was found to be set in pglueb upon startup. Clearing"); 9550 if (val & PGLUE_B_PGLUE_B_INT_STS_REG_WAS_ERROR_ATTN) {
9550 REG_WR(bp, PGLUE_B_REG_WAS_ERROR_PF_7_0_CLR, 1 << BP_FUNC(bp)); 9551 BNX2X_ERR("was error bit was found to be set in pglueb upon startup. Clearing");
9552 REG_WR(bp, PGLUE_B_REG_WAS_ERROR_PF_7_0_CLR,
9553 1 << BP_FUNC(bp));
9554 }
9551 } 9555 }
9552} 9556}
9553 9557
@@ -11902,7 +11906,15 @@ static int __devinit bnx2x_init_one(struct pci_dev *pdev,
11902 /* disable FCOE L2 queue for E1x */ 11906 /* disable FCOE L2 queue for E1x */
11903 if (CHIP_IS_E1x(bp)) 11907 if (CHIP_IS_E1x(bp))
11904 bp->flags |= NO_FCOE_FLAG; 11908 bp->flags |= NO_FCOE_FLAG;
11905 11909 /* disable FCOE for 57840 device, until FW supports it */
11910 switch (ent->driver_data) {
11911 case BCM57840_O:
11912 case BCM57840_4_10:
11913 case BCM57840_2_20:
11914 case BCM57840_MFO:
11915 case BCM57840_MF:
11916 bp->flags |= NO_FCOE_FLAG;
11917 }
11906#endif 11918#endif
11907 11919
11908 11920
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
index 71971a161bd..614981c0226 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
@@ -126,7 +126,7 @@ static inline int bnx2x_exe_queue_add(struct bnx2x *bp,
126 /* Check if this request is ok */ 126 /* Check if this request is ok */
127 rc = o->validate(bp, o->owner, elem); 127 rc = o->validate(bp, o->owner, elem);
128 if (rc) { 128 if (rc) {
129 BNX2X_ERR("Preamble failed: %d\n", rc); 129 DP(BNX2X_MSG_SP, "Preamble failed: %d\n", rc);
130 goto free_and_exit; 130 goto free_and_exit;
131 } 131 }
132 } 132 }
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index a4da893ac1e..378988b5709 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -251,6 +251,8 @@ struct adapter_params {
251 unsigned char rev; /* chip revision */ 251 unsigned char rev; /* chip revision */
252 unsigned char offload; 252 unsigned char offload;
253 253
254 unsigned char bypass;
255
254 unsigned int ofldq_wr_cred; 256 unsigned int ofldq_wr_cred;
255}; 257};
256 258
@@ -642,6 +644,23 @@ extern int dbfifo_int_thresh;
642#define for_each_port(adapter, iter) \ 644#define for_each_port(adapter, iter) \
643 for (iter = 0; iter < (adapter)->params.nports; ++iter) 645 for (iter = 0; iter < (adapter)->params.nports; ++iter)
644 646
647static inline int is_bypass(struct adapter *adap)
648{
649 return adap->params.bypass;
650}
651
652static inline int is_bypass_device(int device)
653{
654 /* this should be set based upon device capabilities */
655 switch (device) {
656 case 0x440b:
657 case 0x440c:
658 return 1;
659 default:
660 return 0;
661 }
662}
663
645static inline unsigned int core_ticks_per_usec(const struct adapter *adap) 664static inline unsigned int core_ticks_per_usec(const struct adapter *adap)
646{ 665{
647 return adap->params.vpd.cclk / 1000; 666 return adap->params.vpd.cclk / 1000;
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 604f4f87f55..0df1284df49 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -3416,16 +3416,6 @@ static int adap_init0_config(struct adapter *adapter, int reset)
3416 finicsum, cfcsum); 3416 finicsum, cfcsum);
3417 3417
3418 /* 3418 /*
3419 * If we're a pure NIC driver then disable all offloading facilities.
3420 * This will allow the firmware to optimize aspects of the hardware
3421 * configuration which will result in improved performance.
3422 */
3423 caps_cmd.ofldcaps = 0;
3424 caps_cmd.iscsicaps = 0;
3425 caps_cmd.rdmacaps = 0;
3426 caps_cmd.fcoecaps = 0;
3427
3428 /*
3429 * And now tell the firmware to use the configuration we just loaded. 3419 * And now tell the firmware to use the configuration we just loaded.
3430 */ 3420 */
3431 caps_cmd.op_to_write = 3421 caps_cmd.op_to_write =
@@ -3513,18 +3503,6 @@ static int adap_init0_no_config(struct adapter *adapter, int reset)
3513 if (ret < 0) 3503 if (ret < 0)
3514 goto bye; 3504 goto bye;
3515 3505
3516#ifndef CONFIG_CHELSIO_T4_OFFLOAD
3517 /*
3518 * If we're a pure NIC driver then disable all offloading facilities.
3519 * This will allow the firmware to optimize aspects of the hardware
3520 * configuration which will result in improved performance.
3521 */
3522 caps_cmd.ofldcaps = 0;
3523 caps_cmd.iscsicaps = 0;
3524 caps_cmd.rdmacaps = 0;
3525 caps_cmd.fcoecaps = 0;
3526#endif
3527
3528 if (caps_cmd.niccaps & htons(FW_CAPS_CONFIG_NIC_VM)) { 3506 if (caps_cmd.niccaps & htons(FW_CAPS_CONFIG_NIC_VM)) {
3529 if (!vf_acls) 3507 if (!vf_acls)
3530 caps_cmd.niccaps ^= htons(FW_CAPS_CONFIG_NIC_VM); 3508 caps_cmd.niccaps ^= htons(FW_CAPS_CONFIG_NIC_VM);
@@ -3745,6 +3723,7 @@ static int adap_init0(struct adapter *adap)
3745 u32 v, port_vec; 3723 u32 v, port_vec;
3746 enum dev_state state; 3724 enum dev_state state;
3747 u32 params[7], val[7]; 3725 u32 params[7], val[7];
3726 struct fw_caps_config_cmd caps_cmd;
3748 int reset = 1, j; 3727 int reset = 1, j;
3749 3728
3750 /* 3729 /*
@@ -3898,6 +3877,9 @@ static int adap_init0(struct adapter *adap)
3898 goto bye; 3877 goto bye;
3899 } 3878 }
3900 3879
3880 if (is_bypass_device(adap->pdev->device))
3881 adap->params.bypass = 1;
3882
3901 /* 3883 /*
3902 * Grab some of our basic fundamental operating parameters. 3884 * Grab some of our basic fundamental operating parameters.
3903 */ 3885 */
@@ -3940,13 +3922,12 @@ static int adap_init0(struct adapter *adap)
3940 adap->tids.aftid_end = val[1]; 3922 adap->tids.aftid_end = val[1];
3941 } 3923 }
3942 3924
3943#ifdef CONFIG_CHELSIO_T4_OFFLOAD
3944 /* 3925 /*
3945 * Get device capabilities so we can determine what resources we need 3926 * Get device capabilities so we can determine what resources we need
3946 * to manage. 3927 * to manage.
3947 */ 3928 */
3948 memset(&caps_cmd, 0, sizeof(caps_cmd)); 3929 memset(&caps_cmd, 0, sizeof(caps_cmd));
3949 caps_cmd.op_to_write = htonl(V_FW_CMD_OP(FW_CAPS_CONFIG_CMD) | 3930 caps_cmd.op_to_write = htonl(FW_CMD_OP(FW_CAPS_CONFIG_CMD) |
3950 FW_CMD_REQUEST | FW_CMD_READ); 3931 FW_CMD_REQUEST | FW_CMD_READ);
3951 caps_cmd.retval_len16 = htonl(FW_LEN16(caps_cmd)); 3932 caps_cmd.retval_len16 = htonl(FW_LEN16(caps_cmd));
3952 ret = t4_wr_mbox(adap, adap->mbox, &caps_cmd, sizeof(caps_cmd), 3933 ret = t4_wr_mbox(adap, adap->mbox, &caps_cmd, sizeof(caps_cmd),
@@ -3991,15 +3972,6 @@ static int adap_init0(struct adapter *adap)
3991 adap->vres.ddp.size = val[4] - val[3] + 1; 3972 adap->vres.ddp.size = val[4] - val[3] + 1;
3992 adap->params.ofldq_wr_cred = val[5]; 3973 adap->params.ofldq_wr_cred = val[5];
3993 3974
3994 params[0] = FW_PARAM_PFVF(ETHOFLD_START);
3995 params[1] = FW_PARAM_PFVF(ETHOFLD_END);
3996 ret = t4_query_params(adap, adap->mbox, adap->fn, 0, 2,
3997 params, val);
3998 if ((val[0] != val[1]) && (ret >= 0)) {
3999 adap->tids.uotid_base = val[0];
4000 adap->tids.nuotids = val[1] - val[0] + 1;
4001 }
4002
4003 adap->params.offload = 1; 3975 adap->params.offload = 1;
4004 } 3976 }
4005 if (caps_cmd.rdmacaps) { 3977 if (caps_cmd.rdmacaps) {
@@ -4048,7 +4020,6 @@ static int adap_init0(struct adapter *adap)
4048 } 4020 }
4049#undef FW_PARAM_PFVF 4021#undef FW_PARAM_PFVF
4050#undef FW_PARAM_DEV 4022#undef FW_PARAM_DEV
4051#endif /* CONFIG_CHELSIO_T4_OFFLOAD */
4052 4023
4053 /* 4024 /*
4054 * These are finalized by FW initialization, load their values now. 4025 * These are finalized by FW initialization, load their values now.
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h
index 1b899fea1a9..39bec73ff87 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h
@@ -102,6 +102,9 @@ struct tid_info {
102 unsigned int ftid_base; 102 unsigned int ftid_base;
103 unsigned int aftid_base; 103 unsigned int aftid_base;
104 unsigned int aftid_end; 104 unsigned int aftid_end;
105 /* Server filter region */
106 unsigned int sftid_base;
107 unsigned int nsftids;
105 108
106 spinlock_t atid_lock ____cacheline_aligned_in_smp; 109 spinlock_t atid_lock ____cacheline_aligned_in_smp;
107 union aopen_entry *afree; 110 union aopen_entry *afree;
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
index 32eec15fe4c..730ae2cfa49 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
@@ -2519,6 +2519,7 @@ int t4_fw_bye(struct adapter *adap, unsigned int mbox)
2519{ 2519{
2520 struct fw_bye_cmd c; 2520 struct fw_bye_cmd c;
2521 2521
2522 memset(&c, 0, sizeof(c));
2522 INIT_CMD(c, BYE, WRITE); 2523 INIT_CMD(c, BYE, WRITE);
2523 return t4_wr_mbox(adap, mbox, &c, sizeof(c), NULL); 2524 return t4_wr_mbox(adap, mbox, &c, sizeof(c), NULL);
2524} 2525}
@@ -2535,6 +2536,7 @@ int t4_early_init(struct adapter *adap, unsigned int mbox)
2535{ 2536{
2536 struct fw_initialize_cmd c; 2537 struct fw_initialize_cmd c;
2537 2538
2539 memset(&c, 0, sizeof(c));
2538 INIT_CMD(c, INITIALIZE, WRITE); 2540 INIT_CMD(c, INITIALIZE, WRITE);
2539 return t4_wr_mbox(adap, mbox, &c, sizeof(c), NULL); 2541 return t4_wr_mbox(adap, mbox, &c, sizeof(c), NULL);
2540} 2542}
@@ -2551,6 +2553,7 @@ int t4_fw_reset(struct adapter *adap, unsigned int mbox, int reset)
2551{ 2553{
2552 struct fw_reset_cmd c; 2554 struct fw_reset_cmd c;
2553 2555
2556 memset(&c, 0, sizeof(c));
2554 INIT_CMD(c, RESET, WRITE); 2557 INIT_CMD(c, RESET, WRITE);
2555 c.val = htonl(reset); 2558 c.val = htonl(reset);
2556 return t4_wr_mbox(adap, mbox, &c, sizeof(c), NULL); 2559 return t4_wr_mbox(adap, mbox, &c, sizeof(c), NULL);
@@ -2828,7 +2831,7 @@ int t4_fixup_host_params(struct adapter *adap, unsigned int page_size,
2828 HOSTPAGESIZEPF7(sge_hps)); 2831 HOSTPAGESIZEPF7(sge_hps));
2829 2832
2830 t4_set_reg_field(adap, SGE_CONTROL, 2833 t4_set_reg_field(adap, SGE_CONTROL,
2831 INGPADBOUNDARY(INGPADBOUNDARY_MASK) | 2834 INGPADBOUNDARY_MASK |
2832 EGRSTATUSPAGESIZE_MASK, 2835 EGRSTATUSPAGESIZE_MASK,
2833 INGPADBOUNDARY(fl_align_log - 5) | 2836 INGPADBOUNDARY(fl_align_log - 5) |
2834 EGRSTATUSPAGESIZE(stat_len != 64)); 2837 EGRSTATUSPAGESIZE(stat_len != 64));
@@ -3278,6 +3281,7 @@ int t4_identify_port(struct adapter *adap, unsigned int mbox, unsigned int viid,
3278{ 3281{
3279 struct fw_vi_enable_cmd c; 3282 struct fw_vi_enable_cmd c;
3280 3283
3284 memset(&c, 0, sizeof(c));
3281 c.op_to_viid = htonl(FW_CMD_OP(FW_VI_ENABLE_CMD) | FW_CMD_REQUEST | 3285 c.op_to_viid = htonl(FW_CMD_OP(FW_VI_ENABLE_CMD) | FW_CMD_REQUEST |
3282 FW_CMD_EXEC | FW_VI_ENABLE_CMD_VIID(viid)); 3286 FW_CMD_EXEC | FW_VI_ENABLE_CMD_VIID(viid));
3283 c.ien_to_len16 = htonl(FW_VI_ENABLE_CMD_LED | FW_LEN16(c)); 3287 c.ien_to_len16 = htonl(FW_VI_ENABLE_CMD_LED | FW_LEN16(c));
diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c
index 1d03dcdd5e5..19ac096cb07 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -1353,8 +1353,11 @@ static int gfar_restore(struct device *dev)
1353 struct gfar_private *priv = dev_get_drvdata(dev); 1353 struct gfar_private *priv = dev_get_drvdata(dev);
1354 struct net_device *ndev = priv->ndev; 1354 struct net_device *ndev = priv->ndev;
1355 1355
1356 if (!netif_running(ndev)) 1356 if (!netif_running(ndev)) {
1357 netif_device_attach(ndev);
1358
1357 return 0; 1359 return 0;
1360 }
1358 1361
1359 gfar_init_bds(ndev); 1362 gfar_init_bds(ndev);
1360 init_registers(ndev); 1363 init_registers(ndev);
diff --git a/drivers/net/ethernet/freescale/gianfar_ptp.c b/drivers/net/ethernet/freescale/gianfar_ptp.c
index b9db0e04056..2e5daee0438 100644
--- a/drivers/net/ethernet/freescale/gianfar_ptp.c
+++ b/drivers/net/ethernet/freescale/gianfar_ptp.c
@@ -478,7 +478,7 @@ static int gianfar_ptp_probe(struct platform_device *dev)
478 pr_err("no resource\n"); 478 pr_err("no resource\n");
479 goto no_resource; 479 goto no_resource;
480 } 480 }
481 if (request_resource(&ioport_resource, etsects->rsrc)) { 481 if (request_resource(&iomem_resource, etsects->rsrc)) {
482 pr_err("resource busy\n"); 482 pr_err("resource busy\n");
483 goto no_resource; 483 goto no_resource;
484 } 484 }
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
index 56b20d17d0e..116f0e901be 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
@@ -2673,6 +2673,9 @@ static int ixgbe_get_ts_info(struct net_device *dev,
2673 case ixgbe_mac_X540: 2673 case ixgbe_mac_X540:
2674 case ixgbe_mac_82599EB: 2674 case ixgbe_mac_82599EB:
2675 info->so_timestamping = 2675 info->so_timestamping =
2676 SOF_TIMESTAMPING_TX_SOFTWARE |
2677 SOF_TIMESTAMPING_RX_SOFTWARE |
2678 SOF_TIMESTAMPING_SOFTWARE |
2676 SOF_TIMESTAMPING_TX_HARDWARE | 2679 SOF_TIMESTAMPING_TX_HARDWARE |
2677 SOF_TIMESTAMPING_RX_HARDWARE | 2680 SOF_TIMESTAMPING_RX_HARDWARE |
2678 SOF_TIMESTAMPING_RAW_HARDWARE; 2681 SOF_TIMESTAMPING_RAW_HARDWARE;
diff --git a/drivers/net/ethernet/jme.c b/drivers/net/ethernet/jme.c
index f8064df10cc..60ac46f4ac0 100644
--- a/drivers/net/ethernet/jme.c
+++ b/drivers/net/ethernet/jme.c
@@ -1860,10 +1860,14 @@ jme_open(struct net_device *netdev)
1860 jme_clear_pm(jme); 1860 jme_clear_pm(jme);
1861 JME_NAPI_ENABLE(jme); 1861 JME_NAPI_ENABLE(jme);
1862 1862
1863 tasklet_enable(&jme->linkch_task); 1863 tasklet_init(&jme->linkch_task, jme_link_change_tasklet,
1864 tasklet_enable(&jme->txclean_task); 1864 (unsigned long) jme);
1865 tasklet_hi_enable(&jme->rxclean_task); 1865 tasklet_init(&jme->txclean_task, jme_tx_clean_tasklet,
1866 tasklet_hi_enable(&jme->rxempty_task); 1866 (unsigned long) jme);
1867 tasklet_init(&jme->rxclean_task, jme_rx_clean_tasklet,
1868 (unsigned long) jme);
1869 tasklet_init(&jme->rxempty_task, jme_rx_empty_tasklet,
1870 (unsigned long) jme);
1867 1871
1868 rc = jme_request_irq(jme); 1872 rc = jme_request_irq(jme);
1869 if (rc) 1873 if (rc)
@@ -1948,10 +1952,10 @@ jme_close(struct net_device *netdev)
1948 1952
1949 JME_NAPI_DISABLE(jme); 1953 JME_NAPI_DISABLE(jme);
1950 1954
1951 tasklet_disable(&jme->linkch_task); 1955 tasklet_kill(&jme->linkch_task);
1952 tasklet_disable(&jme->txclean_task); 1956 tasklet_kill(&jme->txclean_task);
1953 tasklet_disable(&jme->rxclean_task); 1957 tasklet_kill(&jme->rxclean_task);
1954 tasklet_disable(&jme->rxempty_task); 1958 tasklet_kill(&jme->rxempty_task);
1955 1959
1956 jme_disable_rx_engine(jme); 1960 jme_disable_rx_engine(jme);
1957 jme_disable_tx_engine(jme); 1961 jme_disable_tx_engine(jme);
@@ -3079,22 +3083,6 @@ jme_init_one(struct pci_dev *pdev,
3079 tasklet_init(&jme->pcc_task, 3083 tasklet_init(&jme->pcc_task,
3080 jme_pcc_tasklet, 3084 jme_pcc_tasklet,
3081 (unsigned long) jme); 3085 (unsigned long) jme);
3082 tasklet_init(&jme->linkch_task,
3083 jme_link_change_tasklet,
3084 (unsigned long) jme);
3085 tasklet_init(&jme->txclean_task,
3086 jme_tx_clean_tasklet,
3087 (unsigned long) jme);
3088 tasklet_init(&jme->rxclean_task,
3089 jme_rx_clean_tasklet,
3090 (unsigned long) jme);
3091 tasklet_init(&jme->rxempty_task,
3092 jme_rx_empty_tasklet,
3093 (unsigned long) jme);
3094 tasklet_disable_nosync(&jme->linkch_task);
3095 tasklet_disable_nosync(&jme->txclean_task);
3096 tasklet_disable_nosync(&jme->rxclean_task);
3097 tasklet_disable_nosync(&jme->rxempty_task);
3098 jme->dpi.cur = PCC_P1; 3086 jme->dpi.cur = PCC_P1;
3099 3087
3100 jme->reg_ghc = 0; 3088 jme->reg_ghc = 0;
diff --git a/drivers/net/ethernet/marvell/skge.c b/drivers/net/ethernet/marvell/skge.c
index 9b9c2ac5c4c..d19a143aa5a 100644
--- a/drivers/net/ethernet/marvell/skge.c
+++ b/drivers/net/ethernet/marvell/skge.c
@@ -4026,7 +4026,7 @@ static void __devexit skge_remove(struct pci_dev *pdev)
4026 dev0 = hw->dev[0]; 4026 dev0 = hw->dev[0];
4027 unregister_netdev(dev0); 4027 unregister_netdev(dev0);
4028 4028
4029 tasklet_disable(&hw->phy_task); 4029 tasklet_kill(&hw->phy_task);
4030 4030
4031 spin_lock_irq(&hw->hw_lock); 4031 spin_lock_irq(&hw->hw_lock);
4032 hw->intr_mask = 0; 4032 hw->intr_mask = 0;
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
index c10e3a6de09..b35094c590b 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
@@ -143,7 +143,6 @@ void mlx4_en_destroy_tx_ring(struct mlx4_en_priv *priv,
143 mlx4_bf_free(mdev->dev, &ring->bf); 143 mlx4_bf_free(mdev->dev, &ring->bf);
144 mlx4_qp_remove(mdev->dev, &ring->qp); 144 mlx4_qp_remove(mdev->dev, &ring->qp);
145 mlx4_qp_free(mdev->dev, &ring->qp); 145 mlx4_qp_free(mdev->dev, &ring->qp);
146 mlx4_qp_release_range(mdev->dev, ring->qpn, 1);
147 mlx4_en_unmap_buffer(&ring->wqres.buf); 146 mlx4_en_unmap_buffer(&ring->wqres.buf);
148 mlx4_free_hwq_res(mdev->dev, &ring->wqres, ring->buf_size); 147 mlx4_free_hwq_res(mdev->dev, &ring->wqres, ring->buf_size);
149 kfree(ring->bounce_buf); 148 kfree(ring->bounce_buf);
@@ -712,7 +711,7 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
712 if (bounce) 711 if (bounce)
713 tx_desc = mlx4_en_bounce_to_desc(priv, ring, index, desc_size); 712 tx_desc = mlx4_en_bounce_to_desc(priv, ring, index, desc_size);
714 713
715 if (ring->bf_enabled && desc_size <= MAX_BF && !bounce && !vlan_tag) { 714 if (ring->bf_enabled && desc_size <= MAX_BF && !bounce && !vlan_tx_tag_present(skb)) {
716 *(__be32 *) (&tx_desc->ctrl.vlan_tag) |= cpu_to_be32(ring->doorbell_qpn); 715 *(__be32 *) (&tx_desc->ctrl.vlan_tag) |= cpu_to_be32(ring->doorbell_qpn);
717 op_own |= htonl((bf_index & 0xffff) << 8); 716 op_own |= htonl((bf_index & 0xffff) << 8);
718 /* Ensure new descirptor hits memory 717 /* Ensure new descirptor hits memory
diff --git a/drivers/net/ethernet/mellanox/mlx4/eq.c b/drivers/net/ethernet/mellanox/mlx4/eq.c
index 51c764901ad..b84a88bc44d 100644
--- a/drivers/net/ethernet/mellanox/mlx4/eq.c
+++ b/drivers/net/ethernet/mellanox/mlx4/eq.c
@@ -329,9 +329,6 @@ int set_and_calc_slave_port_state(struct mlx4_dev *dev, int slave,
329 ctx = &priv->mfunc.master.slave_state[slave]; 329 ctx = &priv->mfunc.master.slave_state[slave];
330 spin_lock_irqsave(&ctx->lock, flags); 330 spin_lock_irqsave(&ctx->lock, flags);
331 331
332 mlx4_dbg(dev, "%s: slave: %d, current state: %d new event :%d\n",
333 __func__, slave, cur_state, event);
334
335 switch (cur_state) { 332 switch (cur_state) {
336 case SLAVE_PORT_DOWN: 333 case SLAVE_PORT_DOWN:
337 if (MLX4_PORT_STATE_DEV_EVENT_PORT_UP == event) 334 if (MLX4_PORT_STATE_DEV_EVENT_PORT_UP == event)
@@ -366,9 +363,6 @@ int set_and_calc_slave_port_state(struct mlx4_dev *dev, int slave,
366 goto out; 363 goto out;
367 } 364 }
368 ret = mlx4_get_slave_port_state(dev, slave, port); 365 ret = mlx4_get_slave_port_state(dev, slave, port);
369 mlx4_dbg(dev, "%s: slave: %d, current state: %d new event"
370 " :%d gen_event: %d\n",
371 __func__, slave, cur_state, event, *gen_event);
372 366
373out: 367out:
374 spin_unlock_irqrestore(&ctx->lock, flags); 368 spin_unlock_irqrestore(&ctx->lock, flags);
@@ -843,6 +837,18 @@ static void __iomem *mlx4_get_eq_uar(struct mlx4_dev *dev, struct mlx4_eq *eq)
843 return priv->eq_table.uar_map[index] + 0x800 + 8 * (eq->eqn % 4); 837 return priv->eq_table.uar_map[index] + 0x800 + 8 * (eq->eqn % 4);
844} 838}
845 839
840static void mlx4_unmap_uar(struct mlx4_dev *dev)
841{
842 struct mlx4_priv *priv = mlx4_priv(dev);
843 int i;
844
845 for (i = 0; i < mlx4_num_eq_uar(dev); ++i)
846 if (priv->eq_table.uar_map[i]) {
847 iounmap(priv->eq_table.uar_map[i]);
848 priv->eq_table.uar_map[i] = NULL;
849 }
850}
851
846static int mlx4_create_eq(struct mlx4_dev *dev, int nent, 852static int mlx4_create_eq(struct mlx4_dev *dev, int nent,
847 u8 intr, struct mlx4_eq *eq) 853 u8 intr, struct mlx4_eq *eq)
848{ 854{
@@ -1207,6 +1213,7 @@ err_out_unmap:
1207 mlx4_free_irqs(dev); 1213 mlx4_free_irqs(dev);
1208 1214
1209err_out_bitmap: 1215err_out_bitmap:
1216 mlx4_unmap_uar(dev);
1210 mlx4_bitmap_cleanup(&priv->eq_table.bitmap); 1217 mlx4_bitmap_cleanup(&priv->eq_table.bitmap);
1211 1218
1212err_out_free: 1219err_out_free:
@@ -1231,10 +1238,7 @@ void mlx4_cleanup_eq_table(struct mlx4_dev *dev)
1231 if (!mlx4_is_slave(dev)) 1238 if (!mlx4_is_slave(dev))
1232 mlx4_unmap_clr_int(dev); 1239 mlx4_unmap_clr_int(dev);
1233 1240
1234 for (i = 0; i < mlx4_num_eq_uar(dev); ++i) 1241 mlx4_unmap_uar(dev);
1235 if (priv->eq_table.uar_map[i])
1236 iounmap(priv->eq_table.uar_map[i]);
1237
1238 mlx4_bitmap_cleanup(&priv->eq_table.bitmap); 1242 mlx4_bitmap_cleanup(&priv->eq_table.bitmap);
1239 1243
1240 kfree(priv->eq_table.uar_map); 1244 kfree(priv->eq_table.uar_map);
diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
index 80df2ab0177..2aa80afd98d 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -1405,7 +1405,10 @@ unmap_bf:
1405 unmap_bf_area(dev); 1405 unmap_bf_area(dev);
1406 1406
1407err_close: 1407err_close:
1408 mlx4_close_hca(dev); 1408 if (mlx4_is_slave(dev))
1409 mlx4_slave_exit(dev);
1410 else
1411 mlx4_CLOSE_HCA(dev, 0);
1409 1412
1410err_free_icm: 1413err_free_icm:
1411 if (!mlx4_is_slave(dev)) 1414 if (!mlx4_is_slave(dev))
diff --git a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
index 926c911c0ac..b05705f50f0 100644
--- a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
+++ b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
@@ -330,9 +330,6 @@ static void update_pkey_index(struct mlx4_dev *dev, int slave,
330 330
331 new_index = priv->virt2phys_pkey[slave][port - 1][orig_index]; 331 new_index = priv->virt2phys_pkey[slave][port - 1][orig_index];
332 *(u8 *)(inbox->buf + 35) = new_index; 332 *(u8 *)(inbox->buf + 35) = new_index;
333
334 mlx4_dbg(dev, "port = %d, orig pkey index = %d, "
335 "new pkey index = %d\n", port, orig_index, new_index);
336} 333}
337 334
338static void update_gid(struct mlx4_dev *dev, struct mlx4_cmd_mailbox *inbox, 335static void update_gid(struct mlx4_dev *dev, struct mlx4_cmd_mailbox *inbox,
@@ -351,9 +348,6 @@ static void update_gid(struct mlx4_dev *dev, struct mlx4_cmd_mailbox *inbox,
351 if (optpar & MLX4_QP_OPTPAR_ALT_ADDR_PATH) 348 if (optpar & MLX4_QP_OPTPAR_ALT_ADDR_PATH)
352 qp_ctx->alt_path.mgid_index = slave & 0x7F; 349 qp_ctx->alt_path.mgid_index = slave & 0x7F;
353 } 350 }
354
355 mlx4_dbg(dev, "slave %d, new gid index: 0x%x ",
356 slave, qp_ctx->pri_path.mgid_index);
357} 351}
358 352
359static int mpt_mask(struct mlx4_dev *dev) 353static int mpt_mask(struct mlx4_dev *dev)
diff --git a/drivers/net/ethernet/micrel/ksz884x.c b/drivers/net/ethernet/micrel/ksz884x.c
index 318fee91c79..69e01977a1d 100644
--- a/drivers/net/ethernet/micrel/ksz884x.c
+++ b/drivers/net/ethernet/micrel/ksz884x.c
@@ -5407,8 +5407,8 @@ static int netdev_close(struct net_device *dev)
5407 /* Delay for receive task to stop scheduling itself. */ 5407 /* Delay for receive task to stop scheduling itself. */
5408 msleep(2000 / HZ); 5408 msleep(2000 / HZ);
5409 5409
5410 tasklet_disable(&hw_priv->rx_tasklet); 5410 tasklet_kill(&hw_priv->rx_tasklet);
5411 tasklet_disable(&hw_priv->tx_tasklet); 5411 tasklet_kill(&hw_priv->tx_tasklet);
5412 free_irq(dev->irq, hw_priv->dev); 5412 free_irq(dev->irq, hw_priv->dev);
5413 5413
5414 transmit_cleanup(hw_priv, 0); 5414 transmit_cleanup(hw_priv, 0);
@@ -5459,8 +5459,10 @@ static int prepare_hardware(struct net_device *dev)
5459 rc = request_irq(dev->irq, netdev_intr, IRQF_SHARED, dev->name, dev); 5459 rc = request_irq(dev->irq, netdev_intr, IRQF_SHARED, dev->name, dev);
5460 if (rc) 5460 if (rc)
5461 return rc; 5461 return rc;
5462 tasklet_enable(&hw_priv->rx_tasklet); 5462 tasklet_init(&hw_priv->rx_tasklet, rx_proc_task,
5463 tasklet_enable(&hw_priv->tx_tasklet); 5463 (unsigned long) hw_priv);
5464 tasklet_init(&hw_priv->tx_tasklet, tx_proc_task,
5465 (unsigned long) hw_priv);
5464 5466
5465 hw->promiscuous = 0; 5467 hw->promiscuous = 0;
5466 hw->all_multi = 0; 5468 hw->all_multi = 0;
@@ -7033,16 +7035,6 @@ static int __devinit pcidev_init(struct pci_dev *pdev,
7033 spin_lock_init(&hw_priv->hwlock); 7035 spin_lock_init(&hw_priv->hwlock);
7034 mutex_init(&hw_priv->lock); 7036 mutex_init(&hw_priv->lock);
7035 7037
7036 /* tasklet is enabled. */
7037 tasklet_init(&hw_priv->rx_tasklet, rx_proc_task,
7038 (unsigned long) hw_priv);
7039 tasklet_init(&hw_priv->tx_tasklet, tx_proc_task,
7040 (unsigned long) hw_priv);
7041
7042 /* tasklet_enable will decrement the atomic counter. */
7043 tasklet_disable(&hw_priv->rx_tasklet);
7044 tasklet_disable(&hw_priv->tx_tasklet);
7045
7046 for (i = 0; i < TOTAL_PORT_NUM; i++) 7038 for (i = 0; i < TOTAL_PORT_NUM; i++)
7047 init_waitqueue_head(&hw_priv->counter[i].counter); 7039 init_waitqueue_head(&hw_priv->counter[i].counter);
7048 7040
diff --git a/drivers/net/ethernet/nxp/lpc_eth.c b/drivers/net/ethernet/nxp/lpc_eth.c
index 53743f7a2ca..af8b4142088 100644
--- a/drivers/net/ethernet/nxp/lpc_eth.c
+++ b/drivers/net/ethernet/nxp/lpc_eth.c
@@ -1524,6 +1524,7 @@ static int lpc_eth_drv_remove(struct platform_device *pdev)
1524 pldat->dma_buff_base_p); 1524 pldat->dma_buff_base_p);
1525 free_irq(ndev->irq, ndev); 1525 free_irq(ndev->irq, ndev);
1526 iounmap(pldat->net_base); 1526 iounmap(pldat->net_base);
1527 mdiobus_unregister(pldat->mii_bus);
1527 mdiobus_free(pldat->mii_bus); 1528 mdiobus_free(pldat->mii_bus);
1528 clk_disable(pldat->clk); 1529 clk_disable(pldat->clk);
1529 clk_put(pldat->clk); 1530 clk_put(pldat->clk);
diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
index b2a94d02a52..4c4fe5b1a29 100644
--- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
+++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
@@ -339,26 +339,6 @@ static void pch_gbe_wait_clr_bit(void *reg, u32 bit)
339} 339}
340 340
341/** 341/**
342 * pch_gbe_wait_clr_bit_irq - Wait to clear a bit for interrupt context
343 * @reg: Pointer of register
344 * @busy: Busy bit
345 */
346static int pch_gbe_wait_clr_bit_irq(void *reg, u32 bit)
347{
348 u32 tmp;
349 int ret = -1;
350 /* wait busy */
351 tmp = 20;
352 while ((ioread32(reg) & bit) && --tmp)
353 udelay(5);
354 if (!tmp)
355 pr_err("Error: busy bit is not cleared\n");
356 else
357 ret = 0;
358 return ret;
359}
360
361/**
362 * pch_gbe_mac_mar_set - Set MAC address register 342 * pch_gbe_mac_mar_set - Set MAC address register
363 * @hw: Pointer to the HW structure 343 * @hw: Pointer to the HW structure
364 * @addr: Pointer to the MAC address 344 * @addr: Pointer to the MAC address
@@ -409,15 +389,20 @@ static void pch_gbe_mac_reset_hw(struct pch_gbe_hw *hw)
409 return; 389 return;
410} 390}
411 391
412static void pch_gbe_mac_reset_rx(struct pch_gbe_hw *hw) 392static void pch_gbe_disable_mac_rx(struct pch_gbe_hw *hw)
413{ 393{
414 /* Read the MAC addresses. and store to the private data */ 394 u32 rctl;
415 pch_gbe_mac_read_mac_addr(hw); 395 /* Disables Receive MAC */
416 iowrite32(PCH_GBE_RX_RST, &hw->reg->RESET); 396 rctl = ioread32(&hw->reg->MAC_RX_EN);
417 pch_gbe_wait_clr_bit_irq(&hw->reg->RESET, PCH_GBE_RX_RST); 397 iowrite32((rctl & ~PCH_GBE_MRE_MAC_RX_EN), &hw->reg->MAC_RX_EN);
418 /* Setup the MAC addresses */ 398}
419 pch_gbe_mac_mar_set(hw, hw->mac.addr, 0); 399
420 return; 400static void pch_gbe_enable_mac_rx(struct pch_gbe_hw *hw)
401{
402 u32 rctl;
403 /* Enables Receive MAC */
404 rctl = ioread32(&hw->reg->MAC_RX_EN);
405 iowrite32((rctl | PCH_GBE_MRE_MAC_RX_EN), &hw->reg->MAC_RX_EN);
421} 406}
422 407
423/** 408/**
@@ -913,7 +898,7 @@ static void pch_gbe_setup_rctl(struct pch_gbe_adapter *adapter)
913static void pch_gbe_configure_rx(struct pch_gbe_adapter *adapter) 898static void pch_gbe_configure_rx(struct pch_gbe_adapter *adapter)
914{ 899{
915 struct pch_gbe_hw *hw = &adapter->hw; 900 struct pch_gbe_hw *hw = &adapter->hw;
916 u32 rdba, rdlen, rctl, rxdma; 901 u32 rdba, rdlen, rxdma;
917 902
918 pr_debug("dma adr = 0x%08llx size = 0x%08x\n", 903 pr_debug("dma adr = 0x%08llx size = 0x%08x\n",
919 (unsigned long long)adapter->rx_ring->dma, 904 (unsigned long long)adapter->rx_ring->dma,
@@ -921,9 +906,7 @@ static void pch_gbe_configure_rx(struct pch_gbe_adapter *adapter)
921 906
922 pch_gbe_mac_force_mac_fc(hw); 907 pch_gbe_mac_force_mac_fc(hw);
923 908
924 /* Disables Receive MAC */ 909 pch_gbe_disable_mac_rx(hw);
925 rctl = ioread32(&hw->reg->MAC_RX_EN);
926 iowrite32((rctl & ~PCH_GBE_MRE_MAC_RX_EN), &hw->reg->MAC_RX_EN);
927 910
928 /* Disables Receive DMA */ 911 /* Disables Receive DMA */
929 rxdma = ioread32(&hw->reg->DMA_CTRL); 912 rxdma = ioread32(&hw->reg->DMA_CTRL);
@@ -1316,38 +1299,17 @@ void pch_gbe_update_stats(struct pch_gbe_adapter *adapter)
1316 spin_unlock_irqrestore(&adapter->stats_lock, flags); 1299 spin_unlock_irqrestore(&adapter->stats_lock, flags);
1317} 1300}
1318 1301
1319static void pch_gbe_stop_receive(struct pch_gbe_adapter *adapter) 1302static void pch_gbe_disable_dma_rx(struct pch_gbe_hw *hw)
1320{ 1303{
1321 struct pch_gbe_hw *hw = &adapter->hw;
1322 u32 rxdma; 1304 u32 rxdma;
1323 u16 value;
1324 int ret;
1325 1305
1326 /* Disable Receive DMA */ 1306 /* Disable Receive DMA */
1327 rxdma = ioread32(&hw->reg->DMA_CTRL); 1307 rxdma = ioread32(&hw->reg->DMA_CTRL);
1328 rxdma &= ~PCH_GBE_RX_DMA_EN; 1308 rxdma &= ~PCH_GBE_RX_DMA_EN;
1329 iowrite32(rxdma, &hw->reg->DMA_CTRL); 1309 iowrite32(rxdma, &hw->reg->DMA_CTRL);
1330 /* Wait Rx DMA BUS is IDLE */
1331 ret = pch_gbe_wait_clr_bit_irq(&hw->reg->RX_DMA_ST, PCH_GBE_IDLE_CHECK);
1332 if (ret) {
1333 /* Disable Bus master */
1334 pci_read_config_word(adapter->pdev, PCI_COMMAND, &value);
1335 value &= ~PCI_COMMAND_MASTER;
1336 pci_write_config_word(adapter->pdev, PCI_COMMAND, value);
1337 /* Stop Receive */
1338 pch_gbe_mac_reset_rx(hw);
1339 /* Enable Bus master */
1340 value |= PCI_COMMAND_MASTER;
1341 pci_write_config_word(adapter->pdev, PCI_COMMAND, value);
1342 } else {
1343 /* Stop Receive */
1344 pch_gbe_mac_reset_rx(hw);
1345 }
1346 /* reprogram multicast address register after reset */
1347 pch_gbe_set_multi(adapter->netdev);
1348} 1310}
1349 1311
1350static void pch_gbe_start_receive(struct pch_gbe_hw *hw) 1312static void pch_gbe_enable_dma_rx(struct pch_gbe_hw *hw)
1351{ 1313{
1352 u32 rxdma; 1314 u32 rxdma;
1353 1315
@@ -1355,9 +1317,6 @@ static void pch_gbe_start_receive(struct pch_gbe_hw *hw)
1355 rxdma = ioread32(&hw->reg->DMA_CTRL); 1317 rxdma = ioread32(&hw->reg->DMA_CTRL);
1356 rxdma |= PCH_GBE_RX_DMA_EN; 1318 rxdma |= PCH_GBE_RX_DMA_EN;
1357 iowrite32(rxdma, &hw->reg->DMA_CTRL); 1319 iowrite32(rxdma, &hw->reg->DMA_CTRL);
1358 /* Enables Receive */
1359 iowrite32(PCH_GBE_MRE_MAC_RX_EN, &hw->reg->MAC_RX_EN);
1360 return;
1361} 1320}
1362 1321
1363/** 1322/**
@@ -1393,7 +1352,7 @@ static irqreturn_t pch_gbe_intr(int irq, void *data)
1393 int_en = ioread32(&hw->reg->INT_EN); 1352 int_en = ioread32(&hw->reg->INT_EN);
1394 iowrite32((int_en & ~PCH_GBE_INT_RX_FIFO_ERR), 1353 iowrite32((int_en & ~PCH_GBE_INT_RX_FIFO_ERR),
1395 &hw->reg->INT_EN); 1354 &hw->reg->INT_EN);
1396 pch_gbe_stop_receive(adapter); 1355 pch_gbe_disable_dma_rx(&adapter->hw);
1397 int_st |= ioread32(&hw->reg->INT_ST); 1356 int_st |= ioread32(&hw->reg->INT_ST);
1398 int_st = int_st & ioread32(&hw->reg->INT_EN); 1357 int_st = int_st & ioread32(&hw->reg->INT_EN);
1399 } 1358 }
@@ -1971,12 +1930,12 @@ int pch_gbe_up(struct pch_gbe_adapter *adapter)
1971 struct net_device *netdev = adapter->netdev; 1930 struct net_device *netdev = adapter->netdev;
1972 struct pch_gbe_tx_ring *tx_ring = adapter->tx_ring; 1931 struct pch_gbe_tx_ring *tx_ring = adapter->tx_ring;
1973 struct pch_gbe_rx_ring *rx_ring = adapter->rx_ring; 1932 struct pch_gbe_rx_ring *rx_ring = adapter->rx_ring;
1974 int err; 1933 int err = -EINVAL;
1975 1934
1976 /* Ensure we have a valid MAC */ 1935 /* Ensure we have a valid MAC */
1977 if (!is_valid_ether_addr(adapter->hw.mac.addr)) { 1936 if (!is_valid_ether_addr(adapter->hw.mac.addr)) {
1978 pr_err("Error: Invalid MAC address\n"); 1937 pr_err("Error: Invalid MAC address\n");
1979 return -EINVAL; 1938 goto out;
1980 } 1939 }
1981 1940
1982 /* hardware has been reset, we need to reload some things */ 1941 /* hardware has been reset, we need to reload some things */
@@ -1989,18 +1948,19 @@ int pch_gbe_up(struct pch_gbe_adapter *adapter)
1989 1948
1990 err = pch_gbe_request_irq(adapter); 1949 err = pch_gbe_request_irq(adapter);
1991 if (err) { 1950 if (err) {
1992 pr_err("Error: can't bring device up\n"); 1951 pr_err("Error: can't bring device up - irq request failed\n");
1993 return err; 1952 goto out;
1994 } 1953 }
1995 err = pch_gbe_alloc_rx_buffers_pool(adapter, rx_ring, rx_ring->count); 1954 err = pch_gbe_alloc_rx_buffers_pool(adapter, rx_ring, rx_ring->count);
1996 if (err) { 1955 if (err) {
1997 pr_err("Error: can't bring device up\n"); 1956 pr_err("Error: can't bring device up - alloc rx buffers pool failed\n");
1998 return err; 1957 goto freeirq;
1999 } 1958 }
2000 pch_gbe_alloc_tx_buffers(adapter, tx_ring); 1959 pch_gbe_alloc_tx_buffers(adapter, tx_ring);
2001 pch_gbe_alloc_rx_buffers(adapter, rx_ring, rx_ring->count); 1960 pch_gbe_alloc_rx_buffers(adapter, rx_ring, rx_ring->count);
2002 adapter->tx_queue_len = netdev->tx_queue_len; 1961 adapter->tx_queue_len = netdev->tx_queue_len;
2003 pch_gbe_start_receive(&adapter->hw); 1962 pch_gbe_enable_dma_rx(&adapter->hw);
1963 pch_gbe_enable_mac_rx(&adapter->hw);
2004 1964
2005 mod_timer(&adapter->watchdog_timer, jiffies); 1965 mod_timer(&adapter->watchdog_timer, jiffies);
2006 1966
@@ -2009,6 +1969,11 @@ int pch_gbe_up(struct pch_gbe_adapter *adapter)
2009 netif_start_queue(adapter->netdev); 1969 netif_start_queue(adapter->netdev);
2010 1970
2011 return 0; 1971 return 0;
1972
1973freeirq:
1974 pch_gbe_free_irq(adapter);
1975out:
1976 return err;
2012} 1977}
2013 1978
2014/** 1979/**
@@ -2405,7 +2370,6 @@ static int pch_gbe_napi_poll(struct napi_struct *napi, int budget)
2405 int work_done = 0; 2370 int work_done = 0;
2406 bool poll_end_flag = false; 2371 bool poll_end_flag = false;
2407 bool cleaned = false; 2372 bool cleaned = false;
2408 u32 int_en;
2409 2373
2410 pr_debug("budget : %d\n", budget); 2374 pr_debug("budget : %d\n", budget);
2411 2375
@@ -2422,19 +2386,13 @@ static int pch_gbe_napi_poll(struct napi_struct *napi, int budget)
2422 2386
2423 if (poll_end_flag) { 2387 if (poll_end_flag) {
2424 napi_complete(napi); 2388 napi_complete(napi);
2425 if (adapter->rx_stop_flag) {
2426 adapter->rx_stop_flag = false;
2427 pch_gbe_start_receive(&adapter->hw);
2428 }
2429 pch_gbe_irq_enable(adapter); 2389 pch_gbe_irq_enable(adapter);
2430 } else 2390 }
2431 if (adapter->rx_stop_flag) { 2391
2432 adapter->rx_stop_flag = false; 2392 if (adapter->rx_stop_flag) {
2433 pch_gbe_start_receive(&adapter->hw); 2393 adapter->rx_stop_flag = false;
2434 int_en = ioread32(&adapter->hw.reg->INT_EN); 2394 pch_gbe_enable_dma_rx(&adapter->hw);
2435 iowrite32((int_en | PCH_GBE_INT_RX_FIFO_ERR), 2395 }
2436 &adapter->hw.reg->INT_EN);
2437 }
2438 2396
2439 pr_debug("poll_end_flag : %d work_done : %d budget : %d\n", 2397 pr_debug("poll_end_flag : %d work_done : %d budget : %d\n",
2440 poll_end_flag, work_done, budget); 2398 poll_end_flag, work_done, budget);
diff --git a/drivers/net/ethernet/qlogic/qla3xxx.c b/drivers/net/ethernet/qlogic/qla3xxx.c
index df09b1cb742..6407d0d77e8 100644
--- a/drivers/net/ethernet/qlogic/qla3xxx.c
+++ b/drivers/net/ethernet/qlogic/qla3xxx.c
@@ -2525,6 +2525,13 @@ static int ql_alloc_net_req_rsp_queues(struct ql3_adapter *qdev)
2525 qdev->req_q_size = 2525 qdev->req_q_size =
2526 (u32) (NUM_REQ_Q_ENTRIES * sizeof(struct ob_mac_iocb_req)); 2526 (u32) (NUM_REQ_Q_ENTRIES * sizeof(struct ob_mac_iocb_req));
2527 2527
2528 qdev->rsp_q_size = NUM_RSP_Q_ENTRIES * sizeof(struct net_rsp_iocb);
2529
2530 /* The barrier is required to ensure request and response queue
2531 * addr writes to the registers.
2532 */
2533 wmb();
2534
2528 qdev->req_q_virt_addr = 2535 qdev->req_q_virt_addr =
2529 pci_alloc_consistent(qdev->pdev, 2536 pci_alloc_consistent(qdev->pdev,
2530 (size_t) qdev->req_q_size, 2537 (size_t) qdev->req_q_size,
@@ -2536,8 +2543,6 @@ static int ql_alloc_net_req_rsp_queues(struct ql3_adapter *qdev)
2536 return -ENOMEM; 2543 return -ENOMEM;
2537 } 2544 }
2538 2545
2539 qdev->rsp_q_size = NUM_RSP_Q_ENTRIES * sizeof(struct net_rsp_iocb);
2540
2541 qdev->rsp_q_virt_addr = 2546 qdev->rsp_q_virt_addr =
2542 pci_alloc_consistent(qdev->pdev, 2547 pci_alloc_consistent(qdev->pdev,
2543 (size_t) qdev->rsp_q_size, 2548 (size_t) qdev->rsp_q_size,
diff --git a/drivers/net/ethernet/realtek/8139cp.c b/drivers/net/ethernet/realtek/8139cp.c
index 1c818254b7b..b01f83a044c 100644
--- a/drivers/net/ethernet/realtek/8139cp.c
+++ b/drivers/net/ethernet/realtek/8139cp.c
@@ -979,17 +979,6 @@ static void cp_init_hw (struct cp_private *cp)
979 cpw32_f (MAC0 + 0, le32_to_cpu (*(__le32 *) (dev->dev_addr + 0))); 979 cpw32_f (MAC0 + 0, le32_to_cpu (*(__le32 *) (dev->dev_addr + 0)));
980 cpw32_f (MAC0 + 4, le32_to_cpu (*(__le32 *) (dev->dev_addr + 4))); 980 cpw32_f (MAC0 + 4, le32_to_cpu (*(__le32 *) (dev->dev_addr + 4)));
981 981
982 cpw32_f(HiTxRingAddr, 0);
983 cpw32_f(HiTxRingAddr + 4, 0);
984
985 ring_dma = cp->ring_dma;
986 cpw32_f(RxRingAddr, ring_dma & 0xffffffff);
987 cpw32_f(RxRingAddr + 4, (ring_dma >> 16) >> 16);
988
989 ring_dma += sizeof(struct cp_desc) * CP_RX_RING_SIZE;
990 cpw32_f(TxRingAddr, ring_dma & 0xffffffff);
991 cpw32_f(TxRingAddr + 4, (ring_dma >> 16) >> 16);
992
993 cp_start_hw(cp); 982 cp_start_hw(cp);
994 cpw8(TxThresh, 0x06); /* XXX convert magic num to a constant */ 983 cpw8(TxThresh, 0x06); /* XXX convert magic num to a constant */
995 984
@@ -1003,6 +992,17 @@ static void cp_init_hw (struct cp_private *cp)
1003 992
1004 cpw8(Config5, cpr8(Config5) & PMEStatus); 993 cpw8(Config5, cpr8(Config5) & PMEStatus);
1005 994
995 cpw32_f(HiTxRingAddr, 0);
996 cpw32_f(HiTxRingAddr + 4, 0);
997
998 ring_dma = cp->ring_dma;
999 cpw32_f(RxRingAddr, ring_dma & 0xffffffff);
1000 cpw32_f(RxRingAddr + 4, (ring_dma >> 16) >> 16);
1001
1002 ring_dma += sizeof(struct cp_desc) * CP_RX_RING_SIZE;
1003 cpw32_f(TxRingAddr, ring_dma & 0xffffffff);
1004 cpw32_f(TxRingAddr + 4, (ring_dma >> 16) >> 16);
1005
1006 cpw16(MultiIntr, 0); 1006 cpw16(MultiIntr, 0);
1007 1007
1008 cpw8_f(Cfg9346, Cfg9346_Lock); 1008 cpw8_f(Cfg9346, Cfg9346_Lock);
diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
index e7ff886e804..927aa33d434 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -3827,6 +3827,8 @@ static void rtl_wol_suspend_quirk(struct rtl8169_private *tp)
3827 void __iomem *ioaddr = tp->mmio_addr; 3827 void __iomem *ioaddr = tp->mmio_addr;
3828 3828
3829 switch (tp->mac_version) { 3829 switch (tp->mac_version) {
3830 case RTL_GIGA_MAC_VER_25:
3831 case RTL_GIGA_MAC_VER_26:
3830 case RTL_GIGA_MAC_VER_29: 3832 case RTL_GIGA_MAC_VER_29:
3831 case RTL_GIGA_MAC_VER_30: 3833 case RTL_GIGA_MAC_VER_30:
3832 case RTL_GIGA_MAC_VER_32: 3834 case RTL_GIGA_MAC_VER_32:
@@ -4519,6 +4521,9 @@ static void rtl_set_rx_mode(struct net_device *dev)
4519 mc_filter[1] = swab32(data); 4521 mc_filter[1] = swab32(data);
4520 } 4522 }
4521 4523
4524 if (tp->mac_version == RTL_GIGA_MAC_VER_35)
4525 mc_filter[1] = mc_filter[0] = 0xffffffff;
4526
4522 RTL_W32(MAR0 + 4, mc_filter[1]); 4527 RTL_W32(MAR0 + 4, mc_filter[1]);
4523 RTL_W32(MAR0 + 0, mc_filter[0]); 4528 RTL_W32(MAR0 + 0, mc_filter[0]);
4524 4529
diff --git a/drivers/net/ethernet/sis/sis900.c b/drivers/net/ethernet/sis/sis900.c
index fb9f6b38511..edf5edb1314 100644
--- a/drivers/net/ethernet/sis/sis900.c
+++ b/drivers/net/ethernet/sis/sis900.c
@@ -2479,7 +2479,7 @@ static int sis900_resume(struct pci_dev *pci_dev)
2479 netif_start_queue(net_dev); 2479 netif_start_queue(net_dev);
2480 2480
2481 /* Workaround for EDB */ 2481 /* Workaround for EDB */
2482 sis900_set_mode(ioaddr, HW_SPEED_10_MBPS, FDX_CAPABLE_HALF_SELECTED); 2482 sis900_set_mode(sis_priv, HW_SPEED_10_MBPS, FDX_CAPABLE_HALF_SELECTED);
2483 2483
2484 /* Enable all known interrupts by setting the interrupt mask. */ 2484 /* Enable all known interrupts by setting the interrupt mask. */
2485 sw32(imr, RxSOVR | RxORN | RxERR | RxOK | TxURN | TxERR | TxIDLE); 2485 sw32(imr, RxSOVR | RxORN | RxERR | RxOK | TxURN | TxERR | TxIDLE);
diff --git a/drivers/net/ethernet/smsc/smsc911x.c b/drivers/net/ethernet/smsc/smsc911x.c
index 62d1baf111e..c53c0f4e2ce 100644
--- a/drivers/net/ethernet/smsc/smsc911x.c
+++ b/drivers/net/ethernet/smsc/smsc911x.c
@@ -2110,7 +2110,7 @@ static void __devinit smsc911x_read_mac_address(struct net_device *dev)
2110static int __devinit smsc911x_init(struct net_device *dev) 2110static int __devinit smsc911x_init(struct net_device *dev)
2111{ 2111{
2112 struct smsc911x_data *pdata = netdev_priv(dev); 2112 struct smsc911x_data *pdata = netdev_priv(dev);
2113 unsigned int byte_test; 2113 unsigned int byte_test, mask;
2114 unsigned int to = 100; 2114 unsigned int to = 100;
2115 2115
2116 SMSC_TRACE(pdata, probe, "Driver Parameters:"); 2116 SMSC_TRACE(pdata, probe, "Driver Parameters:");
@@ -2130,9 +2130,22 @@ static int __devinit smsc911x_init(struct net_device *dev)
2130 /* 2130 /*
2131 * poll the READY bit in PMT_CTRL. Any other access to the device is 2131 * poll the READY bit in PMT_CTRL. Any other access to the device is
2132 * forbidden while this bit isn't set. Try for 100ms 2132 * forbidden while this bit isn't set. Try for 100ms
2133 *
2134 * Note that this test is done before the WORD_SWAP register is
2135 * programmed. So in some configurations the READY bit is at 16 before
2136 * WORD_SWAP is written to. This issue is worked around by waiting
2137 * until either bit 0 or bit 16 gets set in PMT_CTRL.
2138 *
2139 * SMSC has confirmed that checking bit 16 (marked as reserved in
2140 * the datasheet) is fine since these bits "will either never be set
2141 * or can only go high after READY does (so also indicate the device
2142 * is ready)".
2133 */ 2143 */
2134 while (!(smsc911x_reg_read(pdata, PMT_CTRL) & PMT_CTRL_READY_) && --to) 2144
2145 mask = PMT_CTRL_READY_ | swahw32(PMT_CTRL_READY_);
2146 while (!(smsc911x_reg_read(pdata, PMT_CTRL) & mask) && --to)
2135 udelay(1000); 2147 udelay(1000);
2148
2136 if (to == 0) { 2149 if (to == 0) {
2137 pr_err("Device not READY in 100ms aborting\n"); 2150 pr_err("Device not READY in 100ms aborting\n");
2138 return -ENODEV; 2151 return -ENODEV;
diff --git a/drivers/net/ethernet/ti/Kconfig b/drivers/net/ethernet/ti/Kconfig
index b26cbda5efa..2c41894d547 100644
--- a/drivers/net/ethernet/ti/Kconfig
+++ b/drivers/net/ethernet/ti/Kconfig
@@ -5,7 +5,7 @@
5config NET_VENDOR_TI 5config NET_VENDOR_TI
6 bool "Texas Instruments (TI) devices" 6 bool "Texas Instruments (TI) devices"
7 default y 7 default y
8 depends on PCI || EISA || AR7 || (ARM && (ARCH_DAVINCI || ARCH_OMAP3)) 8 depends on PCI || EISA || AR7 || (ARM && (ARCH_DAVINCI || ARCH_OMAP3 || SOC_AM33XX))
9 ---help--- 9 ---help---
10 If you have a network (Ethernet) card belonging to this class, say Y 10 If you have a network (Ethernet) card belonging to this class, say Y
11 and read the Ethernet-HOWTO, available from 11 and read the Ethernet-HOWTO, available from
diff --git a/drivers/net/ethernet/tile/tilegx.c b/drivers/net/ethernet/tile/tilegx.c
index 4e2a1628484..66e025ad5df 100644
--- a/drivers/net/ethernet/tile/tilegx.c
+++ b/drivers/net/ethernet/tile/tilegx.c
@@ -917,7 +917,7 @@ static int tile_net_setup_interrupts(struct net_device *dev)
917 ingress_irq = rc; 917 ingress_irq = rc;
918 tile_irq_activate(ingress_irq, TILE_IRQ_PERCPU); 918 tile_irq_activate(ingress_irq, TILE_IRQ_PERCPU);
919 rc = request_irq(ingress_irq, tile_net_handle_ingress_irq, 919 rc = request_irq(ingress_irq, tile_net_handle_ingress_irq,
920 0, NULL, NULL); 920 0, "tile_net", NULL);
921 if (rc != 0) { 921 if (rc != 0) {
922 netdev_err(dev, "request_irq failed: %d\n", rc); 922 netdev_err(dev, "request_irq failed: %d\n", rc);
923 destroy_irq(ingress_irq); 923 destroy_irq(ingress_irq);
@@ -1334,11 +1334,11 @@ static int tso_count_edescs(struct sk_buff *skb)
1334{ 1334{
1335 struct skb_shared_info *sh = skb_shinfo(skb); 1335 struct skb_shared_info *sh = skb_shinfo(skb);
1336 unsigned int sh_len = skb_transport_offset(skb) + tcp_hdrlen(skb); 1336 unsigned int sh_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
1337 unsigned int data_len = skb->data_len + skb->hdr_len - sh_len; 1337 unsigned int data_len = skb->len - sh_len;
1338 unsigned int p_len = sh->gso_size; 1338 unsigned int p_len = sh->gso_size;
1339 long f_id = -1; /* id of the current fragment */ 1339 long f_id = -1; /* id of the current fragment */
1340 long f_size = skb->hdr_len; /* size of the current fragment */ 1340 long f_size = skb_headlen(skb) - sh_len; /* current fragment size */
1341 long f_used = sh_len; /* bytes used from the current fragment */ 1341 long f_used = 0; /* bytes used from the current fragment */
1342 long n; /* size of the current piece of payload */ 1342 long n; /* size of the current piece of payload */
1343 int num_edescs = 0; 1343 int num_edescs = 0;
1344 int segment; 1344 int segment;
@@ -1353,7 +1353,7 @@ static int tso_count_edescs(struct sk_buff *skb)
1353 /* Advance as needed. */ 1353 /* Advance as needed. */
1354 while (f_used >= f_size) { 1354 while (f_used >= f_size) {
1355 f_id++; 1355 f_id++;
1356 f_size = sh->frags[f_id].size; 1356 f_size = skb_frag_size(&sh->frags[f_id]);
1357 f_used = 0; 1357 f_used = 0;
1358 } 1358 }
1359 1359
@@ -1384,13 +1384,13 @@ static void tso_headers_prepare(struct sk_buff *skb, unsigned char *headers,
1384 struct iphdr *ih; 1384 struct iphdr *ih;
1385 struct tcphdr *th; 1385 struct tcphdr *th;
1386 unsigned int sh_len = skb_transport_offset(skb) + tcp_hdrlen(skb); 1386 unsigned int sh_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
1387 unsigned int data_len = skb->data_len + skb->hdr_len - sh_len; 1387 unsigned int data_len = skb->len - sh_len;
1388 unsigned char *data = skb->data; 1388 unsigned char *data = skb->data;
1389 unsigned int ih_off, th_off, p_len; 1389 unsigned int ih_off, th_off, p_len;
1390 unsigned int isum_seed, tsum_seed, id, seq; 1390 unsigned int isum_seed, tsum_seed, id, seq;
1391 long f_id = -1; /* id of the current fragment */ 1391 long f_id = -1; /* id of the current fragment */
1392 long f_size = skb->hdr_len; /* size of the current fragment */ 1392 long f_size = skb_headlen(skb) - sh_len; /* current fragment size */
1393 long f_used = sh_len; /* bytes used from the current fragment */ 1393 long f_used = 0; /* bytes used from the current fragment */
1394 long n; /* size of the current piece of payload */ 1394 long n; /* size of the current piece of payload */
1395 int segment; 1395 int segment;
1396 1396
@@ -1405,7 +1405,7 @@ static void tso_headers_prepare(struct sk_buff *skb, unsigned char *headers,
1405 isum_seed = ((0xFFFF - ih->check) + 1405 isum_seed = ((0xFFFF - ih->check) +
1406 (0xFFFF - ih->tot_len) + 1406 (0xFFFF - ih->tot_len) +
1407 (0xFFFF - ih->id)); 1407 (0xFFFF - ih->id));
1408 tsum_seed = th->check + (0xFFFF ^ htons(sh_len + data_len)); 1408 tsum_seed = th->check + (0xFFFF ^ htons(skb->len));
1409 id = ntohs(ih->id); 1409 id = ntohs(ih->id);
1410 seq = ntohl(th->seq); 1410 seq = ntohl(th->seq);
1411 1411
@@ -1444,7 +1444,7 @@ static void tso_headers_prepare(struct sk_buff *skb, unsigned char *headers,
1444 /* Advance as needed. */ 1444 /* Advance as needed. */
1445 while (f_used >= f_size) { 1445 while (f_used >= f_size) {
1446 f_id++; 1446 f_id++;
1447 f_size = sh->frags[f_id].size; 1447 f_size = skb_frag_size(&sh->frags[f_id]);
1448 f_used = 0; 1448 f_used = 0;
1449 } 1449 }
1450 1450
@@ -1478,14 +1478,14 @@ static void tso_egress(struct net_device *dev, gxio_mpipe_equeue_t *equeue,
1478 struct tile_net_priv *priv = netdev_priv(dev); 1478 struct tile_net_priv *priv = netdev_priv(dev);
1479 struct skb_shared_info *sh = skb_shinfo(skb); 1479 struct skb_shared_info *sh = skb_shinfo(skb);
1480 unsigned int sh_len = skb_transport_offset(skb) + tcp_hdrlen(skb); 1480 unsigned int sh_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
1481 unsigned int data_len = skb->data_len + skb->hdr_len - sh_len; 1481 unsigned int data_len = skb->len - sh_len;
1482 unsigned int p_len = sh->gso_size; 1482 unsigned int p_len = sh->gso_size;
1483 gxio_mpipe_edesc_t edesc_head = { { 0 } }; 1483 gxio_mpipe_edesc_t edesc_head = { { 0 } };
1484 gxio_mpipe_edesc_t edesc_body = { { 0 } }; 1484 gxio_mpipe_edesc_t edesc_body = { { 0 } };
1485 long f_id = -1; /* id of the current fragment */ 1485 long f_id = -1; /* id of the current fragment */
1486 long f_size = skb->hdr_len; /* size of the current fragment */ 1486 long f_size = skb_headlen(skb) - sh_len; /* current fragment size */
1487 long f_used = sh_len; /* bytes used from the current fragment */ 1487 long f_used = 0; /* bytes used from the current fragment */
1488 void *f_data = skb->data; 1488 void *f_data = skb->data + sh_len;
1489 long n; /* size of the current piece of payload */ 1489 long n; /* size of the current piece of payload */
1490 unsigned long tx_packets = 0, tx_bytes = 0; 1490 unsigned long tx_packets = 0, tx_bytes = 0;
1491 unsigned int csum_start; 1491 unsigned int csum_start;
@@ -1516,15 +1516,18 @@ static void tso_egress(struct net_device *dev, gxio_mpipe_equeue_t *equeue,
1516 1516
1517 /* Egress the payload. */ 1517 /* Egress the payload. */
1518 while (p_used < p_len) { 1518 while (p_used < p_len) {
1519 void *va;
1519 1520
1520 /* Advance as needed. */ 1521 /* Advance as needed. */
1521 while (f_used >= f_size) { 1522 while (f_used >= f_size) {
1522 f_id++; 1523 f_id++;
1523 f_size = sh->frags[f_id].size; 1524 f_size = skb_frag_size(&sh->frags[f_id]);
1524 f_used = 0;
1525 f_data = tile_net_frag_buf(&sh->frags[f_id]); 1525 f_data = tile_net_frag_buf(&sh->frags[f_id]);
1526 f_used = 0;
1526 } 1527 }
1527 1528
1529 va = f_data + f_used;
1530
1528 /* Use bytes from the current fragment. */ 1531 /* Use bytes from the current fragment. */
1529 n = p_len - p_used; 1532 n = p_len - p_used;
1530 if (n > f_size - f_used) 1533 if (n > f_size - f_used)
@@ -1533,7 +1536,7 @@ static void tso_egress(struct net_device *dev, gxio_mpipe_equeue_t *equeue,
1533 p_used += n; 1536 p_used += n;
1534 1537
1535 /* Egress a piece of the payload. */ 1538 /* Egress a piece of the payload. */
1536 edesc_body.va = va_to_tile_io_addr(f_data) + f_used; 1539 edesc_body.va = va_to_tile_io_addr(va);
1537 edesc_body.xfer_size = n; 1540 edesc_body.xfer_size = n;
1538 edesc_body.bound = !(p_used < p_len); 1541 edesc_body.bound = !(p_used < p_len);
1539 gxio_mpipe_equeue_put_at(equeue, edesc_body, slot); 1542 gxio_mpipe_equeue_put_at(equeue, edesc_body, slot);
diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
index 0793299bd39..a788501e978 100644
--- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
+++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
@@ -894,6 +894,8 @@ out:
894 return IRQ_HANDLED; 894 return IRQ_HANDLED;
895} 895}
896 896
897static void axienet_dma_err_handler(unsigned long data);
898
897/** 899/**
898 * axienet_open - Driver open routine. 900 * axienet_open - Driver open routine.
899 * @ndev: Pointer to net_device structure 901 * @ndev: Pointer to net_device structure
@@ -942,6 +944,10 @@ static int axienet_open(struct net_device *ndev)
942 phy_start(lp->phy_dev); 944 phy_start(lp->phy_dev);
943 } 945 }
944 946
947 /* Enable tasklets for Axi DMA error handling */
948 tasklet_init(&lp->dma_err_tasklet, axienet_dma_err_handler,
949 (unsigned long) lp);
950
945 /* Enable interrupts for Axi DMA Tx */ 951 /* Enable interrupts for Axi DMA Tx */
946 ret = request_irq(lp->tx_irq, axienet_tx_irq, 0, ndev->name, ndev); 952 ret = request_irq(lp->tx_irq, axienet_tx_irq, 0, ndev->name, ndev);
947 if (ret) 953 if (ret)
@@ -950,8 +956,7 @@ static int axienet_open(struct net_device *ndev)
950 ret = request_irq(lp->rx_irq, axienet_rx_irq, 0, ndev->name, ndev); 956 ret = request_irq(lp->rx_irq, axienet_rx_irq, 0, ndev->name, ndev);
951 if (ret) 957 if (ret)
952 goto err_rx_irq; 958 goto err_rx_irq;
953 /* Enable tasklets for Axi DMA error handling */ 959
954 tasklet_enable(&lp->dma_err_tasklet);
955 return 0; 960 return 0;
956 961
957err_rx_irq: 962err_rx_irq:
@@ -960,6 +965,7 @@ err_tx_irq:
960 if (lp->phy_dev) 965 if (lp->phy_dev)
961 phy_disconnect(lp->phy_dev); 966 phy_disconnect(lp->phy_dev);
962 lp->phy_dev = NULL; 967 lp->phy_dev = NULL;
968 tasklet_kill(&lp->dma_err_tasklet);
963 dev_err(lp->dev, "request_irq() failed\n"); 969 dev_err(lp->dev, "request_irq() failed\n");
964 return ret; 970 return ret;
965} 971}
@@ -990,7 +996,7 @@ static int axienet_stop(struct net_device *ndev)
990 axienet_setoptions(ndev, lp->options & 996 axienet_setoptions(ndev, lp->options &
991 ~(XAE_OPTION_TXEN | XAE_OPTION_RXEN)); 997 ~(XAE_OPTION_TXEN | XAE_OPTION_RXEN));
992 998
993 tasklet_disable(&lp->dma_err_tasklet); 999 tasklet_kill(&lp->dma_err_tasklet);
994 1000
995 free_irq(lp->tx_irq, ndev); 1001 free_irq(lp->tx_irq, ndev);
996 free_irq(lp->rx_irq, ndev); 1002 free_irq(lp->rx_irq, ndev);
@@ -1613,10 +1619,6 @@ static int __devinit axienet_of_probe(struct platform_device *op)
1613 goto err_iounmap_2; 1619 goto err_iounmap_2;
1614 } 1620 }
1615 1621
1616 tasklet_init(&lp->dma_err_tasklet, axienet_dma_err_handler,
1617 (unsigned long) lp);
1618 tasklet_disable(&lp->dma_err_tasklet);
1619
1620 return 0; 1622 return 0;
1621 1623
1622err_iounmap_2: 1624err_iounmap_2:
diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c
index 98934bdf6ac..477d6729b17 100644
--- a/drivers/net/ethernet/xscale/ixp4xx_eth.c
+++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c
@@ -1102,10 +1102,12 @@ static int init_queues(struct port *port)
1102{ 1102{
1103 int i; 1103 int i;
1104 1104
1105 if (!ports_open) 1105 if (!ports_open) {
1106 if (!(dma_pool = dma_pool_create(DRV_NAME, NULL, 1106 dma_pool = dma_pool_create(DRV_NAME, &port->netdev->dev,
1107 POOL_ALLOC_SIZE, 32, 0))) 1107 POOL_ALLOC_SIZE, 32, 0);
1108 if (!dma_pool)
1108 return -ENOMEM; 1109 return -ENOMEM;
1110 }
1109 1111
1110 if (!(port->desc_tab = dma_pool_alloc(dma_pool, GFP_KERNEL, 1112 if (!(port->desc_tab = dma_pool_alloc(dma_pool, GFP_KERNEL,
1111 &port->desc_tab_phys))) 1113 &port->desc_tab_phys)))
diff --git a/drivers/net/irda/sir_dev.c b/drivers/net/irda/sir_dev.c
index 5039f08f5a5..43e9ab4f4d7 100644
--- a/drivers/net/irda/sir_dev.c
+++ b/drivers/net/irda/sir_dev.c
@@ -222,7 +222,7 @@ static void sirdev_config_fsm(struct work_struct *work)
222 break; 222 break;
223 223
224 case SIRDEV_STATE_DONGLE_SPEED: 224 case SIRDEV_STATE_DONGLE_SPEED:
225 if (dev->dongle_drv->reset) { 225 if (dev->dongle_drv->set_speed) {
226 ret = dev->dongle_drv->set_speed(dev, fsm->param); 226 ret = dev->dongle_drv->set_speed(dev, fsm->param);
227 if (ret < 0) { 227 if (ret < 0) {
228 fsm->result = ret; 228 fsm->result = ret;
diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index 983bbf4d5ef..961f0b29391 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -15,6 +15,11 @@ if PHYLIB
15 15
16comment "MII PHY device drivers" 16comment "MII PHY device drivers"
17 17
18config AT803X_PHY
19 tristate "Drivers for Atheros AT803X PHYs"
20 ---help---
21 Currently supports the AT8030 and AT8035 model
22
18config AMD_PHY 23config AMD_PHY
19 tristate "Drivers for the AMD PHYs" 24 tristate "Drivers for the AMD PHYs"
20 ---help--- 25 ---help---
diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
index 426674debae..9645e389a58 100644
--- a/drivers/net/phy/Makefile
+++ b/drivers/net/phy/Makefile
@@ -25,6 +25,7 @@ obj-$(CONFIG_STE10XP) += ste10Xp.o
25obj-$(CONFIG_MICREL_PHY) += micrel.o 25obj-$(CONFIG_MICREL_PHY) += micrel.o
26obj-$(CONFIG_MDIO_OCTEON) += mdio-octeon.o 26obj-$(CONFIG_MDIO_OCTEON) += mdio-octeon.o
27obj-$(CONFIG_MICREL_KS8995MA) += spi_ks8995.o 27obj-$(CONFIG_MICREL_KS8995MA) += spi_ks8995.o
28obj-$(CONFIG_AT803X_PHY) += at803x.o
28obj-$(CONFIG_AMD_PHY) += amd.o 29obj-$(CONFIG_AMD_PHY) += amd.o
29obj-$(CONFIG_MDIO_BUS_MUX) += mdio-mux.o 30obj-$(CONFIG_MDIO_BUS_MUX) += mdio-mux.o
30obj-$(CONFIG_MDIO_BUS_MUX_GPIO) += mdio-mux-gpio.o 31obj-$(CONFIG_MDIO_BUS_MUX_GPIO) += mdio-mux-gpio.o
diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c
new file mode 100644
index 00000000000..45cbc10de01
--- /dev/null
+++ b/drivers/net/phy/at803x.c
@@ -0,0 +1,176 @@
1/*
2 * drivers/net/phy/at803x.c
3 *
4 * Driver for Atheros 803x PHY
5 *
6 * Author: Matus Ujhelyi <ujhelyi.m@gmail.com>
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/phy.h>
15#include <linux/module.h>
16#include <linux/string.h>
17#include <linux/netdevice.h>
18#include <linux/etherdevice.h>
19
20#define AT803X_INTR_ENABLE 0x12
21#define AT803X_INTR_STATUS 0x13
22#define AT803X_WOL_ENABLE 0x01
23#define AT803X_DEVICE_ADDR 0x03
24#define AT803X_LOC_MAC_ADDR_0_15_OFFSET 0x804C
25#define AT803X_LOC_MAC_ADDR_16_31_OFFSET 0x804B
26#define AT803X_LOC_MAC_ADDR_32_47_OFFSET 0x804A
27#define AT803X_MMD_ACCESS_CONTROL 0x0D
28#define AT803X_MMD_ACCESS_CONTROL_DATA 0x0E
29#define AT803X_FUNC_DATA 0x4003
30
31MODULE_DESCRIPTION("Atheros 803x PHY driver");
32MODULE_AUTHOR("Matus Ujhelyi");
33MODULE_LICENSE("GPL");
34
35static void at803x_set_wol_mac_addr(struct phy_device *phydev)
36{
37 struct net_device *ndev = phydev->attached_dev;
38 const u8 *mac;
39 unsigned int i, offsets[] = {
40 AT803X_LOC_MAC_ADDR_32_47_OFFSET,
41 AT803X_LOC_MAC_ADDR_16_31_OFFSET,
42 AT803X_LOC_MAC_ADDR_0_15_OFFSET,
43 };
44
45 if (!ndev)
46 return;
47
48 mac = (const u8 *) ndev->dev_addr;
49
50 if (!is_valid_ether_addr(mac))
51 return;
52
53 for (i = 0; i < 3; i++) {
54 phy_write(phydev, AT803X_MMD_ACCESS_CONTROL,
55 AT803X_DEVICE_ADDR);
56 phy_write(phydev, AT803X_MMD_ACCESS_CONTROL_DATA,
57 offsets[i]);
58 phy_write(phydev, AT803X_MMD_ACCESS_CONTROL,
59 AT803X_FUNC_DATA);
60 phy_write(phydev, AT803X_MMD_ACCESS_CONTROL_DATA,
61 mac[(i * 2) + 1] | (mac[(i * 2)] << 8));
62 }
63}
64
65static int at803x_config_init(struct phy_device *phydev)
66{
67 int val;
68 u32 features;
69 int status;
70
71 features = SUPPORTED_TP | SUPPORTED_MII | SUPPORTED_AUI |
72 SUPPORTED_FIBRE | SUPPORTED_BNC;
73
74 val = phy_read(phydev, MII_BMSR);
75 if (val < 0)
76 return val;
77
78 if (val & BMSR_ANEGCAPABLE)
79 features |= SUPPORTED_Autoneg;
80 if (val & BMSR_100FULL)
81 features |= SUPPORTED_100baseT_Full;
82 if (val & BMSR_100HALF)
83 features |= SUPPORTED_100baseT_Half;
84 if (val & BMSR_10FULL)
85 features |= SUPPORTED_10baseT_Full;
86 if (val & BMSR_10HALF)
87 features |= SUPPORTED_10baseT_Half;
88
89 if (val & BMSR_ESTATEN) {
90 val = phy_read(phydev, MII_ESTATUS);
91 if (val < 0)
92 return val;
93
94 if (val & ESTATUS_1000_TFULL)
95 features |= SUPPORTED_1000baseT_Full;
96 if (val & ESTATUS_1000_THALF)
97 features |= SUPPORTED_1000baseT_Half;
98 }
99
100 phydev->supported = features;
101 phydev->advertising = features;
102
103 /* enable WOL */
104 at803x_set_wol_mac_addr(phydev);
105 status = phy_write(phydev, AT803X_INTR_ENABLE, AT803X_WOL_ENABLE);
106 status = phy_read(phydev, AT803X_INTR_STATUS);
107
108 return 0;
109}
110
111/* ATHEROS 8035 */
112static struct phy_driver at8035_driver = {
113 .phy_id = 0x004dd072,
114 .name = "Atheros 8035 ethernet",
115 .phy_id_mask = 0xffffffef,
116 .config_init = at803x_config_init,
117 .features = PHY_GBIT_FEATURES,
118 .flags = PHY_HAS_INTERRUPT,
119 .config_aneg = &genphy_config_aneg,
120 .read_status = &genphy_read_status,
121 .driver = {
122 .owner = THIS_MODULE,
123 },
124};
125
126/* ATHEROS 8030 */
127static struct phy_driver at8030_driver = {
128 .phy_id = 0x004dd076,
129 .name = "Atheros 8030 ethernet",
130 .phy_id_mask = 0xffffffef,
131 .config_init = at803x_config_init,
132 .features = PHY_GBIT_FEATURES,
133 .flags = PHY_HAS_INTERRUPT,
134 .config_aneg = &genphy_config_aneg,
135 .read_status = &genphy_read_status,
136 .driver = {
137 .owner = THIS_MODULE,
138 },
139};
140
141static int __init atheros_init(void)
142{
143 int ret;
144
145 ret = phy_driver_register(&at8035_driver);
146 if (ret)
147 goto err1;
148
149 ret = phy_driver_register(&at8030_driver);
150 if (ret)
151 goto err2;
152
153 return 0;
154
155err2:
156 phy_driver_unregister(&at8035_driver);
157err1:
158 return ret;
159}
160
161static void __exit atheros_exit(void)
162{
163 phy_driver_unregister(&at8035_driver);
164 phy_driver_unregister(&at8030_driver);
165}
166
167module_init(atheros_init);
168module_exit(atheros_exit);
169
170static struct mdio_device_id __maybe_unused atheros_tbl[] = {
171 { 0x004dd076, 0xffffffef },
172 { 0x004dd072, 0xffffffef },
173 { }
174};
175
176MODULE_DEVICE_TABLE(mdio, atheros_tbl);
diff --git a/drivers/net/phy/mdio-gpio.c b/drivers/net/phy/mdio-gpio.c
index 899274f2f9b..2ed1140df3e 100644
--- a/drivers/net/phy/mdio-gpio.c
+++ b/drivers/net/phy/mdio-gpio.c
@@ -185,17 +185,20 @@ static int __devinit mdio_gpio_probe(struct platform_device *pdev)
185{ 185{
186 struct mdio_gpio_platform_data *pdata; 186 struct mdio_gpio_platform_data *pdata;
187 struct mii_bus *new_bus; 187 struct mii_bus *new_bus;
188 int ret; 188 int ret, bus_id;
189 189
190 if (pdev->dev.of_node) 190 if (pdev->dev.of_node) {
191 pdata = mdio_gpio_of_get_data(pdev); 191 pdata = mdio_gpio_of_get_data(pdev);
192 else 192 bus_id = of_alias_get_id(pdev->dev.of_node, "mdio-gpio");
193 } else {
193 pdata = pdev->dev.platform_data; 194 pdata = pdev->dev.platform_data;
195 bus_id = pdev->id;
196 }
194 197
195 if (!pdata) 198 if (!pdata)
196 return -ENODEV; 199 return -ENODEV;
197 200
198 new_bus = mdio_gpio_bus_init(&pdev->dev, pdata, pdev->id); 201 new_bus = mdio_gpio_bus_init(&pdev->dev, pdata, bus_id);
199 if (!new_bus) 202 if (!new_bus)
200 return -ENODEV; 203 return -ENODEV;
201 204
diff --git a/drivers/net/team/team_mode_broadcast.c b/drivers/net/team/team_mode_broadcast.c
index 9db0171e936..c5db428e73f 100644
--- a/drivers/net/team/team_mode_broadcast.c
+++ b/drivers/net/team/team_mode_broadcast.c
@@ -29,8 +29,8 @@ static bool bc_transmit(struct team *team, struct sk_buff *skb)
29 if (last) { 29 if (last) {
30 skb2 = skb_clone(skb, GFP_ATOMIC); 30 skb2 = skb_clone(skb, GFP_ATOMIC);
31 if (skb2) { 31 if (skb2) {
32 ret = team_dev_queue_xmit(team, last, 32 ret = !team_dev_queue_xmit(team, last,
33 skb2); 33 skb2);
34 if (!sum_ret) 34 if (!sum_ret)
35 sum_ret = ret; 35 sum_ret = ret;
36 } 36 }
@@ -39,7 +39,7 @@ static bool bc_transmit(struct team *team, struct sk_buff *skb)
39 } 39 }
40 } 40 }
41 if (last) { 41 if (last) {
42 ret = team_dev_queue_xmit(team, last, skb); 42 ret = !team_dev_queue_xmit(team, last, skb);
43 if (!sum_ret) 43 if (!sum_ret)
44 sum_ret = ret; 44 sum_ret = ret;
45 } 45 }
diff --git a/drivers/net/usb/cdc_eem.c b/drivers/net/usb/cdc_eem.c
index c81e278629f..08d55b6bf27 100644
--- a/drivers/net/usb/cdc_eem.c
+++ b/drivers/net/usb/cdc_eem.c
@@ -31,6 +31,7 @@
31#include <linux/usb/cdc.h> 31#include <linux/usb/cdc.h>
32#include <linux/usb/usbnet.h> 32#include <linux/usb/usbnet.h>
33#include <linux/gfp.h> 33#include <linux/gfp.h>
34#include <linux/if_vlan.h>
34 35
35 36
36/* 37/*
@@ -92,7 +93,7 @@ static int eem_bind(struct usbnet *dev, struct usb_interface *intf)
92 93
93 /* no jumbogram (16K) support for now */ 94 /* no jumbogram (16K) support for now */
94 95
95 dev->net->hard_header_len += EEM_HEAD + ETH_FCS_LEN; 96 dev->net->hard_header_len += EEM_HEAD + ETH_FCS_LEN + VLAN_HLEN;
96 dev->hard_mtu = dev->net->mtu + dev->net->hard_header_len; 97 dev->hard_mtu = dev->net->mtu + dev->net->hard_header_len;
97 98
98 return 0; 99 return 0;
diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c
index a03de719704..d0129827602 100644
--- a/drivers/net/usb/cdc_ether.c
+++ b/drivers/net/usb/cdc_ether.c
@@ -592,6 +592,32 @@ static const struct usb_device_id products [] = {
592 .driver_info = 0, 592 .driver_info = 0,
593}, 593},
594 594
595/* Novatel USB551L and MC551 - handled by qmi_wwan */
596{
597 .match_flags = USB_DEVICE_ID_MATCH_VENDOR
598 | USB_DEVICE_ID_MATCH_PRODUCT
599 | USB_DEVICE_ID_MATCH_INT_INFO,
600 .idVendor = NOVATEL_VENDOR_ID,
601 .idProduct = 0xB001,
602 .bInterfaceClass = USB_CLASS_COMM,
603 .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET,
604 .bInterfaceProtocol = USB_CDC_PROTO_NONE,
605 .driver_info = 0,
606},
607
608/* Novatel E362 - handled by qmi_wwan */
609{
610 .match_flags = USB_DEVICE_ID_MATCH_VENDOR
611 | USB_DEVICE_ID_MATCH_PRODUCT
612 | USB_DEVICE_ID_MATCH_INT_INFO,
613 .idVendor = NOVATEL_VENDOR_ID,
614 .idProduct = 0x9010,
615 .bInterfaceClass = USB_CLASS_COMM,
616 .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET,
617 .bInterfaceProtocol = USB_CDC_PROTO_NONE,
618 .driver_info = 0,
619},
620
595/* 621/*
596 * WHITELIST!!! 622 * WHITELIST!!!
597 * 623 *
@@ -604,21 +630,6 @@ static const struct usb_device_id products [] = {
604 * because of bugs/quirks in a given product (like Zaurus, above). 630 * because of bugs/quirks in a given product (like Zaurus, above).
605 */ 631 */
606{ 632{
607 /* Novatel USB551L */
608 /* This match must come *before* the generic CDC-ETHER match so that
609 * we get FLAG_WWAN set on the device, since it's descriptors are
610 * generic CDC-ETHER.
611 */
612 .match_flags = USB_DEVICE_ID_MATCH_VENDOR
613 | USB_DEVICE_ID_MATCH_PRODUCT
614 | USB_DEVICE_ID_MATCH_INT_INFO,
615 .idVendor = NOVATEL_VENDOR_ID,
616 .idProduct = 0xB001,
617 .bInterfaceClass = USB_CLASS_COMM,
618 .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET,
619 .bInterfaceProtocol = USB_CDC_PROTO_NONE,
620 .driver_info = (unsigned long)&wwan_info,
621}, {
622 /* ZTE (Vodafone) K3805-Z */ 633 /* ZTE (Vodafone) K3805-Z */
623 .match_flags = USB_DEVICE_ID_MATCH_VENDOR 634 .match_flags = USB_DEVICE_ID_MATCH_VENDOR
624 | USB_DEVICE_ID_MATCH_PRODUCT 635 | USB_DEVICE_ID_MATCH_PRODUCT
diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index 4cd582a4f62..74fab1a4015 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -540,10 +540,12 @@ advance:
540 (ctx->ether_desc == NULL) || (ctx->control != intf)) 540 (ctx->ether_desc == NULL) || (ctx->control != intf))
541 goto error; 541 goto error;
542 542
543 /* claim interfaces, if any */ 543 /* claim data interface, if different from control */
544 temp = usb_driver_claim_interface(driver, ctx->data, dev); 544 if (ctx->data != ctx->control) {
545 if (temp) 545 temp = usb_driver_claim_interface(driver, ctx->data, dev);
546 goto error; 546 if (temp)
547 goto error;
548 }
547 549
548 iface_no = ctx->data->cur_altsetting->desc.bInterfaceNumber; 550 iface_no = ctx->data->cur_altsetting->desc.bInterfaceNumber;
549 551
@@ -623,6 +625,10 @@ static void cdc_ncm_unbind(struct usbnet *dev, struct usb_interface *intf)
623 625
624 tasklet_kill(&ctx->bh); 626 tasklet_kill(&ctx->bh);
625 627
628 /* handle devices with combined control and data interface */
629 if (ctx->control == ctx->data)
630 ctx->data = NULL;
631
626 /* disconnect master --> disconnect slave */ 632 /* disconnect master --> disconnect slave */
627 if (intf == ctx->control && ctx->data) { 633 if (intf == ctx->control && ctx->data) {
628 usb_set_intfdata(ctx->data, NULL); 634 usb_set_intfdata(ctx->data, NULL);
@@ -1245,6 +1251,14 @@ static const struct usb_device_id cdc_devs[] = {
1245 .driver_info = (unsigned long) &wwan_info, 1251 .driver_info = (unsigned long) &wwan_info,
1246 }, 1252 },
1247 1253
1254 /* Huawei NCM devices disguised as vendor specific */
1255 { USB_VENDOR_AND_INTERFACE_INFO(0x12d1, 0xff, 0x02, 0x16),
1256 .driver_info = (unsigned long)&wwan_info,
1257 },
1258 { USB_VENDOR_AND_INTERFACE_INFO(0x12d1, 0xff, 0x02, 0x46),
1259 .driver_info = (unsigned long)&wwan_info,
1260 },
1261
1248 /* Generic CDC-NCM devices */ 1262 /* Generic CDC-NCM devices */
1249 { USB_INTERFACE_INFO(USB_CLASS_COMM, 1263 { USB_INTERFACE_INFO(USB_CLASS_COMM,
1250 USB_CDC_SUBCLASS_NCM, USB_CDC_PROTO_NONE), 1264 USB_CDC_SUBCLASS_NCM, USB_CDC_PROTO_NONE),
diff --git a/drivers/net/usb/ipheth.c b/drivers/net/usb/ipheth.c
index a28a983d465..534d8becbbd 100644
--- a/drivers/net/usb/ipheth.c
+++ b/drivers/net/usb/ipheth.c
@@ -62,6 +62,7 @@
62#define USB_PRODUCT_IPAD 0x129a 62#define USB_PRODUCT_IPAD 0x129a
63#define USB_PRODUCT_IPHONE_4_VZW 0x129c 63#define USB_PRODUCT_IPHONE_4_VZW 0x129c
64#define USB_PRODUCT_IPHONE_4S 0x12a0 64#define USB_PRODUCT_IPHONE_4S 0x12a0
65#define USB_PRODUCT_IPHONE_5 0x12a8
65 66
66#define IPHETH_USBINTF_CLASS 255 67#define IPHETH_USBINTF_CLASS 255
67#define IPHETH_USBINTF_SUBCLASS 253 68#define IPHETH_USBINTF_SUBCLASS 253
@@ -113,6 +114,10 @@ static struct usb_device_id ipheth_table[] = {
113 USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_4S, 114 USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_4S,
114 IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS, 115 IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
115 IPHETH_USBINTF_PROTO) }, 116 IPHETH_USBINTF_PROTO) },
117 { USB_DEVICE_AND_INTERFACE_INFO(
118 USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_5,
119 IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS,
120 IPHETH_USBINTF_PROTO) },
116 { } 121 { }
117}; 122};
118MODULE_DEVICE_TABLE(usb, ipheth_table); 123MODULE_DEVICE_TABLE(usb, ipheth_table);
diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
index 6883c371c59..3b566fa0f8e 100644
--- a/drivers/net/usb/qmi_wwan.c
+++ b/drivers/net/usb/qmi_wwan.c
@@ -369,18 +369,73 @@ static const struct usb_device_id products[] = {
369 USB_VENDOR_AND_INTERFACE_INFO(0x106c, USB_CLASS_VENDOR_SPEC, 0xf1, 0xff), 369 USB_VENDOR_AND_INTERFACE_INFO(0x106c, USB_CLASS_VENDOR_SPEC, 0xf1, 0xff),
370 .driver_info = (unsigned long)&qmi_wwan_info, 370 .driver_info = (unsigned long)&qmi_wwan_info,
371 }, 371 },
372 { /* Novatel USB551L and MC551 */
373 USB_DEVICE_AND_INTERFACE_INFO(0x1410, 0xb001,
374 USB_CLASS_COMM,
375 USB_CDC_SUBCLASS_ETHERNET,
376 USB_CDC_PROTO_NONE),
377 .driver_info = (unsigned long)&qmi_wwan_info,
378 },
379 { /* Novatel E362 */
380 USB_DEVICE_AND_INTERFACE_INFO(0x1410, 0x9010,
381 USB_CLASS_COMM,
382 USB_CDC_SUBCLASS_ETHERNET,
383 USB_CDC_PROTO_NONE),
384 .driver_info = (unsigned long)&qmi_wwan_info,
385 },
372 386
373 /* 3. Combined interface devices matching on interface number */ 387 /* 3. Combined interface devices matching on interface number */
388 {QMI_FIXED_INTF(0x19d2, 0x0002, 1)},
389 {QMI_FIXED_INTF(0x19d2, 0x0012, 1)},
390 {QMI_FIXED_INTF(0x19d2, 0x0017, 3)},
391 {QMI_FIXED_INTF(0x19d2, 0x0021, 4)},
392 {QMI_FIXED_INTF(0x19d2, 0x0025, 1)},
393 {QMI_FIXED_INTF(0x19d2, 0x0031, 4)},
394 {QMI_FIXED_INTF(0x19d2, 0x0042, 4)},
395 {QMI_FIXED_INTF(0x19d2, 0x0049, 5)},
396 {QMI_FIXED_INTF(0x19d2, 0x0052, 4)},
374 {QMI_FIXED_INTF(0x19d2, 0x0055, 1)}, /* ZTE (Vodafone) K3520-Z */ 397 {QMI_FIXED_INTF(0x19d2, 0x0055, 1)}, /* ZTE (Vodafone) K3520-Z */
398 {QMI_FIXED_INTF(0x19d2, 0x0058, 4)},
375 {QMI_FIXED_INTF(0x19d2, 0x0063, 4)}, /* ZTE (Vodafone) K3565-Z */ 399 {QMI_FIXED_INTF(0x19d2, 0x0063, 4)}, /* ZTE (Vodafone) K3565-Z */
376 {QMI_FIXED_INTF(0x19d2, 0x0104, 4)}, /* ZTE (Vodafone) K4505-Z */ 400 {QMI_FIXED_INTF(0x19d2, 0x0104, 4)}, /* ZTE (Vodafone) K4505-Z */
401 {QMI_FIXED_INTF(0x19d2, 0x0113, 5)},
402 {QMI_FIXED_INTF(0x19d2, 0x0118, 5)},
403 {QMI_FIXED_INTF(0x19d2, 0x0121, 5)},
404 {QMI_FIXED_INTF(0x19d2, 0x0123, 4)},
405 {QMI_FIXED_INTF(0x19d2, 0x0124, 5)},
406 {QMI_FIXED_INTF(0x19d2, 0x0125, 6)},
407 {QMI_FIXED_INTF(0x19d2, 0x0126, 5)},
408 {QMI_FIXED_INTF(0x19d2, 0x0130, 1)},
409 {QMI_FIXED_INTF(0x19d2, 0x0133, 3)},
410 {QMI_FIXED_INTF(0x19d2, 0x0141, 5)},
377 {QMI_FIXED_INTF(0x19d2, 0x0157, 5)}, /* ZTE MF683 */ 411 {QMI_FIXED_INTF(0x19d2, 0x0157, 5)}, /* ZTE MF683 */
412 {QMI_FIXED_INTF(0x19d2, 0x0158, 3)},
378 {QMI_FIXED_INTF(0x19d2, 0x0167, 4)}, /* ZTE MF820D */ 413 {QMI_FIXED_INTF(0x19d2, 0x0167, 4)}, /* ZTE MF820D */
414 {QMI_FIXED_INTF(0x19d2, 0x0168, 4)},
415 {QMI_FIXED_INTF(0x19d2, 0x0176, 3)},
416 {QMI_FIXED_INTF(0x19d2, 0x0178, 3)},
417 {QMI_FIXED_INTF(0x19d2, 0x0191, 4)}, /* ZTE EuFi890 */
418 {QMI_FIXED_INTF(0x19d2, 0x0199, 1)}, /* ZTE MF820S */
419 {QMI_FIXED_INTF(0x19d2, 0x0200, 1)},
420 {QMI_FIXED_INTF(0x19d2, 0x0257, 3)}, /* ZTE MF821 */
379 {QMI_FIXED_INTF(0x19d2, 0x0326, 4)}, /* ZTE MF821D */ 421 {QMI_FIXED_INTF(0x19d2, 0x0326, 4)}, /* ZTE MF821D */
380 {QMI_FIXED_INTF(0x19d2, 0x1008, 4)}, /* ZTE (Vodafone) K3570-Z */ 422 {QMI_FIXED_INTF(0x19d2, 0x1008, 4)}, /* ZTE (Vodafone) K3570-Z */
381 {QMI_FIXED_INTF(0x19d2, 0x1010, 4)}, /* ZTE (Vodafone) K3571-Z */ 423 {QMI_FIXED_INTF(0x19d2, 0x1010, 4)}, /* ZTE (Vodafone) K3571-Z */
424 {QMI_FIXED_INTF(0x19d2, 0x1012, 4)},
382 {QMI_FIXED_INTF(0x19d2, 0x1018, 3)}, /* ZTE (Vodafone) K5006-Z */ 425 {QMI_FIXED_INTF(0x19d2, 0x1018, 3)}, /* ZTE (Vodafone) K5006-Z */
426 {QMI_FIXED_INTF(0x19d2, 0x1021, 2)},
427 {QMI_FIXED_INTF(0x19d2, 0x1245, 4)},
428 {QMI_FIXED_INTF(0x19d2, 0x1247, 4)},
429 {QMI_FIXED_INTF(0x19d2, 0x1252, 4)},
430 {QMI_FIXED_INTF(0x19d2, 0x1254, 4)},
431 {QMI_FIXED_INTF(0x19d2, 0x1255, 3)},
432 {QMI_FIXED_INTF(0x19d2, 0x1255, 4)},
433 {QMI_FIXED_INTF(0x19d2, 0x1256, 4)},
434 {QMI_FIXED_INTF(0x19d2, 0x1401, 2)},
383 {QMI_FIXED_INTF(0x19d2, 0x1402, 2)}, /* ZTE MF60 */ 435 {QMI_FIXED_INTF(0x19d2, 0x1402, 2)}, /* ZTE MF60 */
436 {QMI_FIXED_INTF(0x19d2, 0x1424, 2)},
437 {QMI_FIXED_INTF(0x19d2, 0x1425, 2)},
438 {QMI_FIXED_INTF(0x19d2, 0x1426, 2)}, /* ZTE MF91 */
384 {QMI_FIXED_INTF(0x19d2, 0x2002, 4)}, /* ZTE (Vodafone) K3765-Z */ 439 {QMI_FIXED_INTF(0x19d2, 0x2002, 4)}, /* ZTE (Vodafone) K3765-Z */
385 {QMI_FIXED_INTF(0x0f3d, 0x68a2, 8)}, /* Sierra Wireless MC7700 */ 440 {QMI_FIXED_INTF(0x0f3d, 0x68a2, 8)}, /* Sierra Wireless MC7700 */
386 {QMI_FIXED_INTF(0x114f, 0x68a2, 8)}, /* Sierra Wireless MC7750 */ 441 {QMI_FIXED_INTF(0x114f, 0x68a2, 8)}, /* Sierra Wireless MC7750 */
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index 7479a5761d0..362cb8cfeb9 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -184,7 +184,7 @@ static int smsc95xx_mdio_read(struct net_device *netdev, int phy_id, int idx)
184 /* set the address, index & direction (read from PHY) */ 184 /* set the address, index & direction (read from PHY) */
185 phy_id &= dev->mii.phy_id_mask; 185 phy_id &= dev->mii.phy_id_mask;
186 idx &= dev->mii.reg_num_mask; 186 idx &= dev->mii.reg_num_mask;
187 addr = (phy_id << 11) | (idx << 6) | MII_READ_; 187 addr = (phy_id << 11) | (idx << 6) | MII_READ_ | MII_BUSY_;
188 ret = smsc95xx_write_reg(dev, MII_ADDR, addr); 188 ret = smsc95xx_write_reg(dev, MII_ADDR, addr);
189 check_warn_goto_done(ret, "Error writing MII_ADDR"); 189 check_warn_goto_done(ret, "Error writing MII_ADDR");
190 190
@@ -221,7 +221,7 @@ static void smsc95xx_mdio_write(struct net_device *netdev, int phy_id, int idx,
221 /* set the address, index & direction (write to PHY) */ 221 /* set the address, index & direction (write to PHY) */
222 phy_id &= dev->mii.phy_id_mask; 222 phy_id &= dev->mii.phy_id_mask;
223 idx &= dev->mii.reg_num_mask; 223 idx &= dev->mii.reg_num_mask;
224 addr = (phy_id << 11) | (idx << 6) | MII_WRITE_; 224 addr = (phy_id << 11) | (idx << 6) | MII_WRITE_ | MII_BUSY_;
225 ret = smsc95xx_write_reg(dev, MII_ADDR, addr); 225 ret = smsc95xx_write_reg(dev, MII_ADDR, addr);
226 check_warn_goto_done(ret, "Error writing MII_ADDR"); 226 check_warn_goto_done(ret, "Error writing MII_ADDR");
227 227
@@ -1344,6 +1344,7 @@ static struct sk_buff *smsc95xx_tx_fixup(struct usbnet *dev,
1344 } else { 1344 } else {
1345 u32 csum_preamble = smsc95xx_calc_csum_preamble(skb); 1345 u32 csum_preamble = smsc95xx_calc_csum_preamble(skb);
1346 skb_push(skb, 4); 1346 skb_push(skb, 4);
1347 cpu_to_le32s(&csum_preamble);
1347 memcpy(skb->data, &csum_preamble, 4); 1348 memcpy(skb->data, &csum_preamble, 4);
1348 } 1349 }
1349 } 1350 }
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index f9819d10b1f..edb81ed0695 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -359,10 +359,12 @@ static enum skb_state defer_bh(struct usbnet *dev, struct sk_buff *skb,
359void usbnet_defer_kevent (struct usbnet *dev, int work) 359void usbnet_defer_kevent (struct usbnet *dev, int work)
360{ 360{
361 set_bit (work, &dev->flags); 361 set_bit (work, &dev->flags);
362 if (!schedule_work (&dev->kevent)) 362 if (!schedule_work (&dev->kevent)) {
363 netdev_err(dev->net, "kevent %d may have been dropped\n", work); 363 if (net_ratelimit())
364 else 364 netdev_err(dev->net, "kevent %d may have been dropped\n", work);
365 } else {
365 netdev_dbg(dev->net, "kevent %d scheduled\n", work); 366 netdev_dbg(dev->net, "kevent %d scheduled\n", work);
367 }
366} 368}
367EXPORT_SYMBOL_GPL(usbnet_defer_kevent); 369EXPORT_SYMBOL_GPL(usbnet_defer_kevent);
368 370
@@ -1158,6 +1160,7 @@ netdev_tx_t usbnet_start_xmit (struct sk_buff *skb,
1158 usb_anchor_urb(urb, &dev->deferred); 1160 usb_anchor_urb(urb, &dev->deferred);
1159 /* no use to process more packets */ 1161 /* no use to process more packets */
1160 netif_stop_queue(net); 1162 netif_stop_queue(net);
1163 usb_put_urb(urb);
1161 spin_unlock_irqrestore(&dev->txq.lock, flags); 1164 spin_unlock_irqrestore(&dev->txq.lock, flags);
1162 netdev_dbg(dev->net, "Delaying transmission for resumption\n"); 1165 netdev_dbg(dev->net, "Delaying transmission for resumption\n");
1163 goto deferred; 1166 goto deferred;
@@ -1310,6 +1313,8 @@ void usbnet_disconnect (struct usb_interface *intf)
1310 1313
1311 cancel_work_sync(&dev->kevent); 1314 cancel_work_sync(&dev->kevent);
1312 1315
1316 usb_scuttle_anchored_urbs(&dev->deferred);
1317
1313 if (dev->driver_info->unbind) 1318 if (dev->driver_info->unbind)
1314 dev->driver_info->unbind (dev, intf); 1319 dev->driver_info->unbind (dev, intf);
1315 1320
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c
index ce9d4f2c977..0ae1bcc6da7 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -744,28 +744,43 @@ vmxnet3_map_pkt(struct sk_buff *skb, struct vmxnet3_tx_ctx *ctx,
744 744
745 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { 745 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
746 const struct skb_frag_struct *frag = &skb_shinfo(skb)->frags[i]; 746 const struct skb_frag_struct *frag = &skb_shinfo(skb)->frags[i];
747 u32 buf_size;
747 748
748 tbi = tq->buf_info + tq->tx_ring.next2fill; 749 buf_offset = 0;
749 tbi->map_type = VMXNET3_MAP_PAGE; 750 len = skb_frag_size(frag);
750 tbi->dma_addr = skb_frag_dma_map(&adapter->pdev->dev, frag, 751 while (len) {
751 0, skb_frag_size(frag), 752 tbi = tq->buf_info + tq->tx_ring.next2fill;
752 DMA_TO_DEVICE); 753 if (len < VMXNET3_MAX_TX_BUF_SIZE) {
754 buf_size = len;
755 dw2 |= len;
756 } else {
757 buf_size = VMXNET3_MAX_TX_BUF_SIZE;
758 /* spec says that for TxDesc.len, 0 == 2^14 */
759 }
760 tbi->map_type = VMXNET3_MAP_PAGE;
761 tbi->dma_addr = skb_frag_dma_map(&adapter->pdev->dev, frag,
762 buf_offset, buf_size,
763 DMA_TO_DEVICE);
753 764
754 tbi->len = skb_frag_size(frag); 765 tbi->len = buf_size;
755 766
756 gdesc = tq->tx_ring.base + tq->tx_ring.next2fill; 767 gdesc = tq->tx_ring.base + tq->tx_ring.next2fill;
757 BUG_ON(gdesc->txd.gen == tq->tx_ring.gen); 768 BUG_ON(gdesc->txd.gen == tq->tx_ring.gen);
758 769
759 gdesc->txd.addr = cpu_to_le64(tbi->dma_addr); 770 gdesc->txd.addr = cpu_to_le64(tbi->dma_addr);
760 gdesc->dword[2] = cpu_to_le32(dw2 | skb_frag_size(frag)); 771 gdesc->dword[2] = cpu_to_le32(dw2);
761 gdesc->dword[3] = 0; 772 gdesc->dword[3] = 0;
762 773
763 dev_dbg(&adapter->netdev->dev, 774 dev_dbg(&adapter->netdev->dev,
764 "txd[%u]: 0x%llu %u %u\n", 775 "txd[%u]: 0x%llu %u %u\n",
765 tq->tx_ring.next2fill, le64_to_cpu(gdesc->txd.addr), 776 tq->tx_ring.next2fill, le64_to_cpu(gdesc->txd.addr),
766 le32_to_cpu(gdesc->dword[2]), gdesc->dword[3]); 777 le32_to_cpu(gdesc->dword[2]), gdesc->dword[3]);
767 vmxnet3_cmd_ring_adv_next2fill(&tq->tx_ring); 778 vmxnet3_cmd_ring_adv_next2fill(&tq->tx_ring);
768 dw2 = tq->tx_ring.gen << VMXNET3_TXD_GEN_SHIFT; 779 dw2 = tq->tx_ring.gen << VMXNET3_TXD_GEN_SHIFT;
780
781 len -= buf_size;
782 buf_offset += buf_size;
783 }
769 } 784 }
770 785
771 ctx->eop_txd = gdesc; 786 ctx->eop_txd = gdesc;
@@ -886,6 +901,18 @@ vmxnet3_prepare_tso(struct sk_buff *skb,
886 } 901 }
887} 902}
888 903
904static int txd_estimate(const struct sk_buff *skb)
905{
906 int count = VMXNET3_TXD_NEEDED(skb_headlen(skb)) + 1;
907 int i;
908
909 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
910 const struct skb_frag_struct *frag = &skb_shinfo(skb)->frags[i];
911
912 count += VMXNET3_TXD_NEEDED(skb_frag_size(frag));
913 }
914 return count;
915}
889 916
890/* 917/*
891 * Transmits a pkt thru a given tq 918 * Transmits a pkt thru a given tq
@@ -914,9 +941,7 @@ vmxnet3_tq_xmit(struct sk_buff *skb, struct vmxnet3_tx_queue *tq,
914 union Vmxnet3_GenericDesc tempTxDesc; 941 union Vmxnet3_GenericDesc tempTxDesc;
915#endif 942#endif
916 943
917 /* conservatively estimate # of descriptors to use */ 944 count = txd_estimate(skb);
918 count = VMXNET3_TXD_NEEDED(skb_headlen(skb)) +
919 skb_shinfo(skb)->nr_frags + 1;
920 945
921 ctx.ipv4 = (vlan_get_protocol(skb) == cpu_to_be16(ETH_P_IP)); 946 ctx.ipv4 = (vlan_get_protocol(skb) == cpu_to_be16(ETH_P_IP));
922 947
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 607976c0016..8b5c6191707 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * VXLAN: Virtual eXtensiable Local Area Network 2 * VXLAN: Virtual eXtensible Local Area Network
3 * 3 *
4 * Copyright (c) 2012 Vyatta Inc. 4 * Copyright (c) 2012 Vyatta Inc.
5 * 5 *
@@ -50,8 +50,8 @@
50 50
51#define VXLAN_N_VID (1u << 24) 51#define VXLAN_N_VID (1u << 24)
52#define VXLAN_VID_MASK (VXLAN_N_VID - 1) 52#define VXLAN_VID_MASK (VXLAN_N_VID - 1)
53/* VLAN + IP header + UDP + VXLAN */ 53/* IP header + UDP + VXLAN + Ethernet header */
54#define VXLAN_HEADROOM (4 + 20 + 8 + 8) 54#define VXLAN_HEADROOM (20 + 8 + 8 + 14)
55 55
56#define VXLAN_FLAGS 0x08000000 /* struct vxlanhdr.vx_flags required value. */ 56#define VXLAN_FLAGS 0x08000000 /* struct vxlanhdr.vx_flags required value. */
57 57
@@ -816,7 +816,7 @@ static void vxlan_cleanup(unsigned long arg)
816 = container_of(p, struct vxlan_fdb, hlist); 816 = container_of(p, struct vxlan_fdb, hlist);
817 unsigned long timeout; 817 unsigned long timeout;
818 818
819 if (f->state == NUD_PERMANENT) 819 if (f->state & NUD_PERMANENT)
820 continue; 820 continue;
821 821
822 timeout = f->used + vxlan->age_interval * HZ; 822 timeout = f->used + vxlan->age_interval * HZ;
@@ -1102,6 +1102,10 @@ static int vxlan_newlink(struct net *net, struct net_device *dev,
1102 1102
1103 if (!tb[IFLA_MTU]) 1103 if (!tb[IFLA_MTU])
1104 dev->mtu = lowerdev->mtu - VXLAN_HEADROOM; 1104 dev->mtu = lowerdev->mtu - VXLAN_HEADROOM;
1105
1106 /* update header length based on lower device */
1107 dev->hard_header_len = lowerdev->hard_header_len +
1108 VXLAN_HEADROOM;
1105 } 1109 }
1106 1110
1107 if (data[IFLA_VXLAN_TOS]) 1111 if (data[IFLA_VXLAN_TOS])
diff --git a/drivers/net/wan/ixp4xx_hss.c b/drivers/net/wan/ixp4xx_hss.c
index 3f575afd8cf..e9a3da588e9 100644
--- a/drivers/net/wan/ixp4xx_hss.c
+++ b/drivers/net/wan/ixp4xx_hss.c
@@ -969,10 +969,12 @@ static int init_hdlc_queues(struct port *port)
969{ 969{
970 int i; 970 int i;
971 971
972 if (!ports_open) 972 if (!ports_open) {
973 if (!(dma_pool = dma_pool_create(DRV_NAME, NULL, 973 dma_pool = dma_pool_create(DRV_NAME, &port->netdev->dev,
974 POOL_ALLOC_SIZE, 32, 0))) 974 POOL_ALLOC_SIZE, 32, 0);
975 if (!dma_pool)
975 return -ENOMEM; 976 return -ENOMEM;
977 }
976 978
977 if (!(port->desc_tab = dma_pool_alloc(dma_pool, GFP_KERNEL, 979 if (!(port->desc_tab = dma_pool_alloc(dma_pool, GFP_KERNEL,
978 &port->desc_tab_phys))) 980 &port->desc_tab_phys)))
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h b/drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h
index 89bf94d4d8a..6f7cf49eff4 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h
+++ b/drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h
@@ -534,107 +534,107 @@ static const u32 ar9300_2p2_baseband_core[][2] = {
534 534
535static const u32 ar9300Modes_high_power_tx_gain_table_2p2[][5] = { 535static const u32 ar9300Modes_high_power_tx_gain_table_2p2[][5] = {
536 /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ 536 /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */
537 {0x0000a2dc, 0x000cfff0, 0x000cfff0, 0x03aaa352, 0x03aaa352}, 537 {0x0000a2dc, 0x00033800, 0x00033800, 0x03aaa352, 0x03aaa352},
538 {0x0000a2e0, 0x000f0000, 0x000f0000, 0x03ccc584, 0x03ccc584}, 538 {0x0000a2e0, 0x0003c000, 0x0003c000, 0x03ccc584, 0x03ccc584},
539 {0x0000a2e4, 0x03f00000, 0x03f00000, 0x03f0f800, 0x03f0f800}, 539 {0x0000a2e4, 0x03fc0000, 0x03fc0000, 0x03f0f800, 0x03f0f800},
540 {0x0000a2e8, 0x00000000, 0x00000000, 0x03ff0000, 0x03ff0000}, 540 {0x0000a2e8, 0x00000000, 0x00000000, 0x03ff0000, 0x03ff0000},
541 {0x0000a410, 0x000050d9, 0x000050d9, 0x000050d9, 0x000050d9}, 541 {0x0000a410, 0x000050d9, 0x000050d9, 0x000050d9, 0x000050d9},
542 {0x0000a500, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, 542 {0x0000a500, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
543 {0x0000a504, 0x06000003, 0x06000003, 0x04000002, 0x04000002}, 543 {0x0000a504, 0x06000003, 0x06000003, 0x04000002, 0x04000002},
544 {0x0000a508, 0x0a000020, 0x0a000020, 0x08000004, 0x08000004}, 544 {0x0000a508, 0x0a000020, 0x0a000020, 0x08000004, 0x08000004},
545 {0x0000a50c, 0x10000023, 0x10000023, 0x0b000200, 0x0b000200}, 545 {0x0000a50c, 0x10000023, 0x10000023, 0x0b000200, 0x0b000200},
546 {0x0000a510, 0x15000028, 0x15000028, 0x0f000202, 0x0f000202}, 546 {0x0000a510, 0x16000220, 0x16000220, 0x0f000202, 0x0f000202},
547 {0x0000a514, 0x1b00002b, 0x1b00002b, 0x12000400, 0x12000400}, 547 {0x0000a514, 0x1c000223, 0x1c000223, 0x12000400, 0x12000400},
548 {0x0000a518, 0x1f020028, 0x1f020028, 0x16000402, 0x16000402}, 548 {0x0000a518, 0x21002220, 0x21002220, 0x16000402, 0x16000402},
549 {0x0000a51c, 0x2502002b, 0x2502002b, 0x19000404, 0x19000404}, 549 {0x0000a51c, 0x27002223, 0x27002223, 0x19000404, 0x19000404},
550 {0x0000a520, 0x2a04002a, 0x2a04002a, 0x1c000603, 0x1c000603}, 550 {0x0000a520, 0x2b022220, 0x2b022220, 0x1c000603, 0x1c000603},
551 {0x0000a524, 0x2e06002a, 0x2e06002a, 0x21000a02, 0x21000a02}, 551 {0x0000a524, 0x2f022222, 0x2f022222, 0x21000a02, 0x21000a02},
552 {0x0000a528, 0x3302202d, 0x3302202d, 0x25000a04, 0x25000a04}, 552 {0x0000a528, 0x34022225, 0x34022225, 0x25000a04, 0x25000a04},
553 {0x0000a52c, 0x3804202c, 0x3804202c, 0x28000a20, 0x28000a20}, 553 {0x0000a52c, 0x3a02222a, 0x3a02222a, 0x28000a20, 0x28000a20},
554 {0x0000a530, 0x3c06202c, 0x3c06202c, 0x2c000e20, 0x2c000e20}, 554 {0x0000a530, 0x3e02222c, 0x3e02222c, 0x2c000e20, 0x2c000e20},
555 {0x0000a534, 0x4108202d, 0x4108202d, 0x30000e22, 0x30000e22}, 555 {0x0000a534, 0x4202242a, 0x4202242a, 0x30000e22, 0x30000e22},
556 {0x0000a538, 0x4506402d, 0x4506402d, 0x34000e24, 0x34000e24}, 556 {0x0000a538, 0x4702244a, 0x4702244a, 0x34000e24, 0x34000e24},
557 {0x0000a53c, 0x4906222d, 0x4906222d, 0x38001640, 0x38001640}, 557 {0x0000a53c, 0x4b02244c, 0x4b02244c, 0x38001640, 0x38001640},
558 {0x0000a540, 0x4d062231, 0x4d062231, 0x3c001660, 0x3c001660}, 558 {0x0000a540, 0x4e02246c, 0x4e02246c, 0x3c001660, 0x3c001660},
559 {0x0000a544, 0x50082231, 0x50082231, 0x3f001861, 0x3f001861}, 559 {0x0000a544, 0x52022470, 0x52022470, 0x3f001861, 0x3f001861},
560 {0x0000a548, 0x5608422e, 0x5608422e, 0x43001a81, 0x43001a81}, 560 {0x0000a548, 0x55022490, 0x55022490, 0x43001a81, 0x43001a81},
561 {0x0000a54c, 0x5a08442e, 0x5a08442e, 0x47001a83, 0x47001a83}, 561 {0x0000a54c, 0x59022492, 0x59022492, 0x47001a83, 0x47001a83},
562 {0x0000a550, 0x5e0a4431, 0x5e0a4431, 0x4a001c84, 0x4a001c84}, 562 {0x0000a550, 0x5d022692, 0x5d022692, 0x4a001c84, 0x4a001c84},
563 {0x0000a554, 0x640a4432, 0x640a4432, 0x4e001ce3, 0x4e001ce3}, 563 {0x0000a554, 0x61022892, 0x61022892, 0x4e001ce3, 0x4e001ce3},
564 {0x0000a558, 0x680a4434, 0x680a4434, 0x52001ce5, 0x52001ce5}, 564 {0x0000a558, 0x65024890, 0x65024890, 0x52001ce5, 0x52001ce5},
565 {0x0000a55c, 0x6c0a6434, 0x6c0a6434, 0x56001ce9, 0x56001ce9}, 565 {0x0000a55c, 0x69024892, 0x69024892, 0x56001ce9, 0x56001ce9},
566 {0x0000a560, 0x6f0a6633, 0x6f0a6633, 0x5a001ceb, 0x5a001ceb}, 566 {0x0000a560, 0x6e024c92, 0x6e024c92, 0x5a001ceb, 0x5a001ceb},
567 {0x0000a564, 0x730c6634, 0x730c6634, 0x5d001eec, 0x5d001eec}, 567 {0x0000a564, 0x74026e92, 0x74026e92, 0x5d001eec, 0x5d001eec},
568 {0x0000a568, 0x730c6634, 0x730c6634, 0x5d001eec, 0x5d001eec}, 568 {0x0000a568, 0x74026e92, 0x74026e92, 0x5d001eec, 0x5d001eec},
569 {0x0000a56c, 0x730c6634, 0x730c6634, 0x5d001eec, 0x5d001eec}, 569 {0x0000a56c, 0x74026e92, 0x74026e92, 0x5d001eec, 0x5d001eec},
570 {0x0000a570, 0x730c6634, 0x730c6634, 0x5d001eec, 0x5d001eec}, 570 {0x0000a570, 0x74026e92, 0x74026e92, 0x5d001eec, 0x5d001eec},
571 {0x0000a574, 0x730c6634, 0x730c6634, 0x5d001eec, 0x5d001eec}, 571 {0x0000a574, 0x74026e92, 0x74026e92, 0x5d001eec, 0x5d001eec},
572 {0x0000a578, 0x730c6634, 0x730c6634, 0x5d001eec, 0x5d001eec}, 572 {0x0000a578, 0x74026e92, 0x74026e92, 0x5d001eec, 0x5d001eec},
573 {0x0000a57c, 0x730c6634, 0x730c6634, 0x5d001eec, 0x5d001eec}, 573 {0x0000a57c, 0x74026e92, 0x74026e92, 0x5d001eec, 0x5d001eec},
574 {0x0000a580, 0x00800000, 0x00800000, 0x00800000, 0x00800000}, 574 {0x0000a580, 0x00800000, 0x00800000, 0x00800000, 0x00800000},
575 {0x0000a584, 0x06800003, 0x06800003, 0x04800002, 0x04800002}, 575 {0x0000a584, 0x06800003, 0x06800003, 0x04800002, 0x04800002},
576 {0x0000a588, 0x0a800020, 0x0a800020, 0x08800004, 0x08800004}, 576 {0x0000a588, 0x0a800020, 0x0a800020, 0x08800004, 0x08800004},
577 {0x0000a58c, 0x10800023, 0x10800023, 0x0b800200, 0x0b800200}, 577 {0x0000a58c, 0x10800023, 0x10800023, 0x0b800200, 0x0b800200},
578 {0x0000a590, 0x15800028, 0x15800028, 0x0f800202, 0x0f800202}, 578 {0x0000a590, 0x16800220, 0x16800220, 0x0f800202, 0x0f800202},
579 {0x0000a594, 0x1b80002b, 0x1b80002b, 0x12800400, 0x12800400}, 579 {0x0000a594, 0x1c800223, 0x1c800223, 0x12800400, 0x12800400},
580 {0x0000a598, 0x1f820028, 0x1f820028, 0x16800402, 0x16800402}, 580 {0x0000a598, 0x21802220, 0x21802220, 0x16800402, 0x16800402},
581 {0x0000a59c, 0x2582002b, 0x2582002b, 0x19800404, 0x19800404}, 581 {0x0000a59c, 0x27802223, 0x27802223, 0x19800404, 0x19800404},
582 {0x0000a5a0, 0x2a84002a, 0x2a84002a, 0x1c800603, 0x1c800603}, 582 {0x0000a5a0, 0x2b822220, 0x2b822220, 0x1c800603, 0x1c800603},
583 {0x0000a5a4, 0x2e86002a, 0x2e86002a, 0x21800a02, 0x21800a02}, 583 {0x0000a5a4, 0x2f822222, 0x2f822222, 0x21800a02, 0x21800a02},
584 {0x0000a5a8, 0x3382202d, 0x3382202d, 0x25800a04, 0x25800a04}, 584 {0x0000a5a8, 0x34822225, 0x34822225, 0x25800a04, 0x25800a04},
585 {0x0000a5ac, 0x3884202c, 0x3884202c, 0x28800a20, 0x28800a20}, 585 {0x0000a5ac, 0x3a82222a, 0x3a82222a, 0x28800a20, 0x28800a20},
586 {0x0000a5b0, 0x3c86202c, 0x3c86202c, 0x2c800e20, 0x2c800e20}, 586 {0x0000a5b0, 0x3e82222c, 0x3e82222c, 0x2c800e20, 0x2c800e20},
587 {0x0000a5b4, 0x4188202d, 0x4188202d, 0x30800e22, 0x30800e22}, 587 {0x0000a5b4, 0x4282242a, 0x4282242a, 0x30800e22, 0x30800e22},
588 {0x0000a5b8, 0x4586402d, 0x4586402d, 0x34800e24, 0x34800e24}, 588 {0x0000a5b8, 0x4782244a, 0x4782244a, 0x34800e24, 0x34800e24},
589 {0x0000a5bc, 0x4986222d, 0x4986222d, 0x38801640, 0x38801640}, 589 {0x0000a5bc, 0x4b82244c, 0x4b82244c, 0x38801640, 0x38801640},
590 {0x0000a5c0, 0x4d862231, 0x4d862231, 0x3c801660, 0x3c801660}, 590 {0x0000a5c0, 0x4e82246c, 0x4e82246c, 0x3c801660, 0x3c801660},
591 {0x0000a5c4, 0x50882231, 0x50882231, 0x3f801861, 0x3f801861}, 591 {0x0000a5c4, 0x52822470, 0x52822470, 0x3f801861, 0x3f801861},
592 {0x0000a5c8, 0x5688422e, 0x5688422e, 0x43801a81, 0x43801a81}, 592 {0x0000a5c8, 0x55822490, 0x55822490, 0x43801a81, 0x43801a81},
593 {0x0000a5cc, 0x5a88442e, 0x5a88442e, 0x47801a83, 0x47801a83}, 593 {0x0000a5cc, 0x59822492, 0x59822492, 0x47801a83, 0x47801a83},
594 {0x0000a5d0, 0x5e8a4431, 0x5e8a4431, 0x4a801c84, 0x4a801c84}, 594 {0x0000a5d0, 0x5d822692, 0x5d822692, 0x4a801c84, 0x4a801c84},
595 {0x0000a5d4, 0x648a4432, 0x648a4432, 0x4e801ce3, 0x4e801ce3}, 595 {0x0000a5d4, 0x61822892, 0x61822892, 0x4e801ce3, 0x4e801ce3},
596 {0x0000a5d8, 0x688a4434, 0x688a4434, 0x52801ce5, 0x52801ce5}, 596 {0x0000a5d8, 0x65824890, 0x65824890, 0x52801ce5, 0x52801ce5},
597 {0x0000a5dc, 0x6c8a6434, 0x6c8a6434, 0x56801ce9, 0x56801ce9}, 597 {0x0000a5dc, 0x69824892, 0x69824892, 0x56801ce9, 0x56801ce9},
598 {0x0000a5e0, 0x6f8a6633, 0x6f8a6633, 0x5a801ceb, 0x5a801ceb}, 598 {0x0000a5e0, 0x6e824c92, 0x6e824c92, 0x5a801ceb, 0x5a801ceb},
599 {0x0000a5e4, 0x738c6634, 0x738c6634, 0x5d801eec, 0x5d801eec}, 599 {0x0000a5e4, 0x74826e92, 0x74826e92, 0x5d801eec, 0x5d801eec},
600 {0x0000a5e8, 0x738c6634, 0x738c6634, 0x5d801eec, 0x5d801eec}, 600 {0x0000a5e8, 0x74826e92, 0x74826e92, 0x5d801eec, 0x5d801eec},
601 {0x0000a5ec, 0x738c6634, 0x738c6634, 0x5d801eec, 0x5d801eec}, 601 {0x0000a5ec, 0x74826e92, 0x74826e92, 0x5d801eec, 0x5d801eec},
602 {0x0000a5f0, 0x738c6634, 0x738c6634, 0x5d801eec, 0x5d801eec}, 602 {0x0000a5f0, 0x74826e92, 0x74826e92, 0x5d801eec, 0x5d801eec},
603 {0x0000a5f4, 0x738c6634, 0x738c6634, 0x5d801eec, 0x5d801eec}, 603 {0x0000a5f4, 0x74826e92, 0x74826e92, 0x5d801eec, 0x5d801eec},
604 {0x0000a5f8, 0x738c6634, 0x738c6634, 0x5d801eec, 0x5d801eec}, 604 {0x0000a5f8, 0x74826e92, 0x74826e92, 0x5d801eec, 0x5d801eec},
605 {0x0000a5fc, 0x738c6634, 0x738c6634, 0x5d801eec, 0x5d801eec}, 605 {0x0000a5fc, 0x74826e92, 0x74826e92, 0x5d801eec, 0x5d801eec},
606 {0x0000a600, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, 606 {0x0000a600, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
607 {0x0000a604, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, 607 {0x0000a604, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
608 {0x0000a608, 0x01804601, 0x01804601, 0x00000000, 0x00000000}, 608 {0x0000a608, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
609 {0x0000a60c, 0x01804601, 0x01804601, 0x00000000, 0x00000000}, 609 {0x0000a60c, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
610 {0x0000a610, 0x01804601, 0x01804601, 0x00000000, 0x00000000}, 610 {0x0000a610, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
611 {0x0000a614, 0x01804601, 0x01804601, 0x01404000, 0x01404000}, 611 {0x0000a614, 0x02004000, 0x02004000, 0x01404000, 0x01404000},
612 {0x0000a618, 0x01804601, 0x01804601, 0x01404501, 0x01404501}, 612 {0x0000a618, 0x02004801, 0x02004801, 0x01404501, 0x01404501},
613 {0x0000a61c, 0x01804601, 0x01804601, 0x02008501, 0x02008501}, 613 {0x0000a61c, 0x02808a02, 0x02808a02, 0x02008501, 0x02008501},
614 {0x0000a620, 0x03408d02, 0x03408d02, 0x0280ca03, 0x0280ca03}, 614 {0x0000a620, 0x0380ce03, 0x0380ce03, 0x0280ca03, 0x0280ca03},
615 {0x0000a624, 0x0300cc03, 0x0300cc03, 0x03010c04, 0x03010c04}, 615 {0x0000a624, 0x04411104, 0x04411104, 0x03010c04, 0x03010c04},
616 {0x0000a628, 0x03410d04, 0x03410d04, 0x04014c04, 0x04014c04}, 616 {0x0000a628, 0x04411104, 0x04411104, 0x04014c04, 0x04014c04},
617 {0x0000a62c, 0x03410d04, 0x03410d04, 0x04015005, 0x04015005}, 617 {0x0000a62c, 0x04411104, 0x04411104, 0x04015005, 0x04015005},
618 {0x0000a630, 0x03410d04, 0x03410d04, 0x04015005, 0x04015005}, 618 {0x0000a630, 0x04411104, 0x04411104, 0x04015005, 0x04015005},
619 {0x0000a634, 0x03410d04, 0x03410d04, 0x04015005, 0x04015005}, 619 {0x0000a634, 0x04411104, 0x04411104, 0x04015005, 0x04015005},
620 {0x0000a638, 0x03410d04, 0x03410d04, 0x04015005, 0x04015005}, 620 {0x0000a638, 0x04411104, 0x04411104, 0x04015005, 0x04015005},
621 {0x0000a63c, 0x03410d04, 0x03410d04, 0x04015005, 0x04015005}, 621 {0x0000a63c, 0x04411104, 0x04411104, 0x04015005, 0x04015005},
622 {0x0000b2dc, 0x000cfff0, 0x000cfff0, 0x03aaa352, 0x03aaa352}, 622 {0x0000b2dc, 0x00033800, 0x00033800, 0x03aaa352, 0x03aaa352},
623 {0x0000b2e0, 0x000f0000, 0x000f0000, 0x03ccc584, 0x03ccc584}, 623 {0x0000b2e0, 0x0003c000, 0x0003c000, 0x03ccc584, 0x03ccc584},
624 {0x0000b2e4, 0x03f00000, 0x03f00000, 0x03f0f800, 0x03f0f800}, 624 {0x0000b2e4, 0x03fc0000, 0x03fc0000, 0x03f0f800, 0x03f0f800},
625 {0x0000b2e8, 0x00000000, 0x00000000, 0x03ff0000, 0x03ff0000}, 625 {0x0000b2e8, 0x00000000, 0x00000000, 0x03ff0000, 0x03ff0000},
626 {0x0000c2dc, 0x000cfff0, 0x000cfff0, 0x03aaa352, 0x03aaa352}, 626 {0x0000c2dc, 0x00033800, 0x00033800, 0x03aaa352, 0x03aaa352},
627 {0x0000c2e0, 0x000f0000, 0x000f0000, 0x03ccc584, 0x03ccc584}, 627 {0x0000c2e0, 0x0003c000, 0x0003c000, 0x03ccc584, 0x03ccc584},
628 {0x0000c2e4, 0x03f00000, 0x03f00000, 0x03f0f800, 0x03f0f800}, 628 {0x0000c2e4, 0x03fc0000, 0x03fc0000, 0x03f0f800, 0x03f0f800},
629 {0x0000c2e8, 0x00000000, 0x00000000, 0x03ff0000, 0x03ff0000}, 629 {0x0000c2e8, 0x00000000, 0x00000000, 0x03ff0000, 0x03ff0000},
630 {0x00016044, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4}, 630 {0x00016044, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4},
631 {0x00016048, 0x61200001, 0x61200001, 0x66480001, 0x66480001}, 631 {0x00016048, 0x66480001, 0x66480001, 0x66480001, 0x66480001},
632 {0x00016068, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c}, 632 {0x00016068, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
633 {0x00016444, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4}, 633 {0x00016444, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4},
634 {0x00016448, 0x61200001, 0x61200001, 0x66480001, 0x66480001}, 634 {0x00016448, 0x66480001, 0x66480001, 0x66480001, 0x66480001},
635 {0x00016468, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c}, 635 {0x00016468, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
636 {0x00016844, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4}, 636 {0x00016844, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4},
637 {0x00016848, 0x61200001, 0x61200001, 0x66480001, 0x66480001}, 637 {0x00016848, 0x66480001, 0x66480001, 0x66480001, 0x66480001},
638 {0x00016868, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c}, 638 {0x00016868, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
639}; 639};
640 640
diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.c b/drivers/net/wireless/ath/ath9k/hif_usb.c
index 924c4616c3d..f5dda84176c 100644
--- a/drivers/net/wireless/ath/ath9k/hif_usb.c
+++ b/drivers/net/wireless/ath/ath9k/hif_usb.c
@@ -38,6 +38,7 @@ static struct usb_device_id ath9k_hif_usb_ids[] = {
38 { USB_DEVICE(0x04CA, 0x4605) }, /* Liteon */ 38 { USB_DEVICE(0x04CA, 0x4605) }, /* Liteon */
39 { USB_DEVICE(0x040D, 0x3801) }, /* VIA */ 39 { USB_DEVICE(0x040D, 0x3801) }, /* VIA */
40 { USB_DEVICE(0x0cf3, 0xb003) }, /* Ubiquiti WifiStation Ext */ 40 { USB_DEVICE(0x0cf3, 0xb003) }, /* Ubiquiti WifiStation Ext */
41 { USB_DEVICE(0x0cf3, 0xb002) }, /* Ubiquiti WifiStation */
41 { USB_DEVICE(0x057c, 0x8403) }, /* AVM FRITZ!WLAN 11N v2 USB */ 42 { USB_DEVICE(0x057c, 0x8403) }, /* AVM FRITZ!WLAN 11N v2 USB */
42 43
43 { USB_DEVICE(0x0cf3, 0x7015), 44 { USB_DEVICE(0x0cf3, 0x7015),
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
index 8e1559aba49..1829b445d0b 100644
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -1456,7 +1456,7 @@ static bool ath9k_hw_set_reset_reg(struct ath_hw *ah, u32 type)
1456 switch (type) { 1456 switch (type) {
1457 case ATH9K_RESET_POWER_ON: 1457 case ATH9K_RESET_POWER_ON:
1458 ret = ath9k_hw_set_reset_power_on(ah); 1458 ret = ath9k_hw_set_reset_power_on(ah);
1459 if (!ret) 1459 if (ret)
1460 ah->reset_power_on = true; 1460 ah->reset_power_on = true;
1461 break; 1461 break;
1462 case ATH9K_RESET_WARM: 1462 case ATH9K_RESET_WARM:
diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c
index 378bd70256b..741918a2027 100644
--- a/drivers/net/wireless/ath/ath9k/xmit.c
+++ b/drivers/net/wireless/ath/ath9k/xmit.c
@@ -312,6 +312,7 @@ static struct ath_buf *ath_tx_get_buffer(struct ath_softc *sc)
312 } 312 }
313 313
314 bf = list_first_entry(&sc->tx.txbuf, struct ath_buf, list); 314 bf = list_first_entry(&sc->tx.txbuf, struct ath_buf, list);
315 bf->bf_next = NULL;
315 list_del(&bf->list); 316 list_del(&bf->list);
316 317
317 spin_unlock_bh(&sc->tx.txbuflock); 318 spin_unlock_bh(&sc->tx.txbuflock);
@@ -393,7 +394,7 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq,
393 u16 seq_st = 0, acked_cnt = 0, txfail_cnt = 0, seq_first; 394 u16 seq_st = 0, acked_cnt = 0, txfail_cnt = 0, seq_first;
394 u32 ba[WME_BA_BMP_SIZE >> 5]; 395 u32 ba[WME_BA_BMP_SIZE >> 5];
395 int isaggr, txfail, txpending, sendbar = 0, needreset = 0, nbad = 0; 396 int isaggr, txfail, txpending, sendbar = 0, needreset = 0, nbad = 0;
396 bool rc_update = true; 397 bool rc_update = true, isba;
397 struct ieee80211_tx_rate rates[4]; 398 struct ieee80211_tx_rate rates[4];
398 struct ath_frame_info *fi; 399 struct ath_frame_info *fi;
399 int nframes; 400 int nframes;
@@ -437,13 +438,17 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq,
437 tidno = ieee80211_get_qos_ctl(hdr)[0] & IEEE80211_QOS_CTL_TID_MASK; 438 tidno = ieee80211_get_qos_ctl(hdr)[0] & IEEE80211_QOS_CTL_TID_MASK;
438 tid = ATH_AN_2_TID(an, tidno); 439 tid = ATH_AN_2_TID(an, tidno);
439 seq_first = tid->seq_start; 440 seq_first = tid->seq_start;
441 isba = ts->ts_flags & ATH9K_TX_BA;
440 442
441 /* 443 /*
442 * The hardware occasionally sends a tx status for the wrong TID. 444 * The hardware occasionally sends a tx status for the wrong TID.
443 * In this case, the BA status cannot be considered valid and all 445 * In this case, the BA status cannot be considered valid and all
444 * subframes need to be retransmitted 446 * subframes need to be retransmitted
447 *
448 * Only BlockAcks have a TID and therefore normal Acks cannot be
449 * checked
445 */ 450 */
446 if (tidno != ts->tid) 451 if (isba && tidno != ts->tid)
447 txok = false; 452 txok = false;
448 453
449 isaggr = bf_isaggr(bf); 454 isaggr = bf_isaggr(bf);
@@ -1774,6 +1779,7 @@ static void ath_tx_send_normal(struct ath_softc *sc, struct ath_txq *txq,
1774 list_add_tail(&bf->list, &bf_head); 1779 list_add_tail(&bf->list, &bf_head);
1775 bf->bf_state.bf_type = 0; 1780 bf->bf_state.bf_type = 0;
1776 1781
1782 bf->bf_next = NULL;
1777 bf->bf_lastbf = bf; 1783 bf->bf_lastbf = bf;
1778 ath_tx_fill_desc(sc, bf, txq, fi->framelen); 1784 ath_tx_fill_desc(sc, bf, txq, fi->framelen);
1779 ath_tx_txqaddbuf(sc, txq, &bf_head, false); 1785 ath_tx_txqaddbuf(sc, txq, &bf_head, false);
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
index 73730e94e0a..c5a99c8c816 100644
--- a/drivers/net/wireless/b43/main.c
+++ b/drivers/net/wireless/b43/main.c
@@ -5404,6 +5404,8 @@ static void b43_bcma_remove(struct bcma_device *core)
5404 cancel_work_sync(&wldev->restart_work); 5404 cancel_work_sync(&wldev->restart_work);
5405 5405
5406 B43_WARN_ON(!wl); 5406 B43_WARN_ON(!wl);
5407 if (!wldev->fw.ucode.data)
5408 return; /* NULL if firmware never loaded */
5407 if (wl->current_dev == wldev && wl->hw_registred) { 5409 if (wl->current_dev == wldev && wl->hw_registred) {
5408 b43_leds_stop(wldev); 5410 b43_leds_stop(wldev);
5409 ieee80211_unregister_hw(wl->hw); 5411 ieee80211_unregister_hw(wl->hw);
@@ -5478,6 +5480,8 @@ static void b43_ssb_remove(struct ssb_device *sdev)
5478 cancel_work_sync(&wldev->restart_work); 5480 cancel_work_sync(&wldev->restart_work);
5479 5481
5480 B43_WARN_ON(!wl); 5482 B43_WARN_ON(!wl);
5483 if (!wldev->fw.ucode.data)
5484 return; /* NULL if firmware never loaded */
5481 if (wl->current_dev == wldev && wl->hw_registred) { 5485 if (wl->current_dev == wldev && wl->hw_registred) {
5482 b43_leds_stop(wldev); 5486 b43_leds_stop(wldev);
5483 ieee80211_unregister_hw(wl->hw); 5487 ieee80211_unregister_hw(wl->hw);
diff --git a/drivers/net/wireless/b43legacy/pio.c b/drivers/net/wireless/b43legacy/pio.c
index 192251adf98..282eedec675 100644
--- a/drivers/net/wireless/b43legacy/pio.c
+++ b/drivers/net/wireless/b43legacy/pio.c
@@ -382,7 +382,7 @@ static void cancel_transfers(struct b43legacy_pioqueue *queue)
382{ 382{
383 struct b43legacy_pio_txpacket *packet, *tmp_packet; 383 struct b43legacy_pio_txpacket *packet, *tmp_packet;
384 384
385 tasklet_disable(&queue->txtask); 385 tasklet_kill(&queue->txtask);
386 386
387 list_for_each_entry_safe(packet, tmp_packet, &queue->txrunning, list) 387 list_for_each_entry_safe(packet, tmp_packet, &queue->txrunning, list)
388 free_txpacket(packet, 0); 388 free_txpacket(packet, 0);
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/usb.c b/drivers/net/wireless/brcm80211/brcmfmac/usb.c
index a2b4b1e7101..7a6dfdc67b6 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/usb.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/usb.c
@@ -1339,7 +1339,7 @@ static int brcmf_usb_probe_cb(struct brcmf_usbdev_info *devinfo,
1339 } 1339 }
1340 1340
1341 ret = brcmf_bus_start(dev); 1341 ret = brcmf_bus_start(dev);
1342 if (ret == -ENOLINK) { 1342 if (ret) {
1343 brcmf_dbg(ERROR, "dongle is not responding\n"); 1343 brcmf_dbg(ERROR, "dongle is not responding\n");
1344 brcmf_detach(dev); 1344 brcmf_detach(dev);
1345 goto fail; 1345 goto fail;
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
index c1abaa6db59..481345c23de 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
@@ -3569,7 +3569,7 @@ brcmf_cfg80211_sched_scan_start(struct wiphy *wiphy,
3569 3569
3570 if (!request || !request->n_ssids || !request->n_match_sets) { 3570 if (!request || !request->n_ssids || !request->n_match_sets) {
3571 WL_ERR("Invalid sched scan req!! n_ssids:%d\n", 3571 WL_ERR("Invalid sched scan req!! n_ssids:%d\n",
3572 request->n_ssids); 3572 request ? request->n_ssids : 0);
3573 return -EINVAL; 3573 return -EINVAL;
3574 } 3574 }
3575 3575
@@ -3972,7 +3972,7 @@ brcmf_set_management_ie(struct brcmf_cfg80211_info *cfg,
3972 u8 *iovar_ie_buf; 3972 u8 *iovar_ie_buf;
3973 u8 *curr_ie_buf; 3973 u8 *curr_ie_buf;
3974 u8 *mgmt_ie_buf = NULL; 3974 u8 *mgmt_ie_buf = NULL;
3975 u32 mgmt_ie_buf_len = 0; 3975 int mgmt_ie_buf_len;
3976 u32 *mgmt_ie_len = 0; 3976 u32 *mgmt_ie_len = 0;
3977 u32 del_add_ie_buf_len = 0; 3977 u32 del_add_ie_buf_len = 0;
3978 u32 total_ie_buf_len = 0; 3978 u32 total_ie_buf_len = 0;
@@ -3982,7 +3982,7 @@ brcmf_set_management_ie(struct brcmf_cfg80211_info *cfg,
3982 struct parsed_vndr_ie_info *vndrie_info; 3982 struct parsed_vndr_ie_info *vndrie_info;
3983 s32 i; 3983 s32 i;
3984 u8 *ptr; 3984 u8 *ptr;
3985 u32 remained_buf_len; 3985 int remained_buf_len;
3986 3986
3987 WL_TRACE("bssidx %d, pktflag : 0x%02X\n", bssidx, pktflag); 3987 WL_TRACE("bssidx %d, pktflag : 0x%02X\n", bssidx, pktflag);
3988 iovar_ie_buf = kzalloc(WL_EXTRA_BUF_MAX, GFP_KERNEL); 3988 iovar_ie_buf = kzalloc(WL_EXTRA_BUF_MAX, GFP_KERNEL);
@@ -4401,7 +4401,7 @@ static s32 brcmf_mode_to_nl80211_iftype(s32 mode)
4401 4401
4402static void brcmf_wiphy_pno_params(struct wiphy *wiphy) 4402static void brcmf_wiphy_pno_params(struct wiphy *wiphy)
4403{ 4403{
4404#ifndef CONFIG_BRCMFISCAN 4404#ifndef CONFIG_BRCMISCAN
4405 /* scheduled scan settings */ 4405 /* scheduled scan settings */
4406 wiphy->max_sched_scan_ssids = BRCMF_PNO_MAX_PFN_COUNT; 4406 wiphy->max_sched_scan_ssids = BRCMF_PNO_MAX_PFN_COUNT;
4407 wiphy->max_match_sets = BRCMF_PNO_MAX_PFN_COUNT; 4407 wiphy->max_match_sets = BRCMF_PNO_MAX_PFN_COUNT;
@@ -4606,12 +4606,13 @@ brcmf_bss_roaming_done(struct brcmf_cfg80211_info *cfg,
4606 struct brcmf_cfg80211_profile *profile = cfg->profile; 4606 struct brcmf_cfg80211_profile *profile = cfg->profile;
4607 struct brcmf_cfg80211_connect_info *conn_info = cfg_to_conn(cfg); 4607 struct brcmf_cfg80211_connect_info *conn_info = cfg_to_conn(cfg);
4608 struct wiphy *wiphy = cfg_to_wiphy(cfg); 4608 struct wiphy *wiphy = cfg_to_wiphy(cfg);
4609 struct brcmf_channel_info_le channel_le; 4609 struct ieee80211_channel *notify_channel = NULL;
4610 struct ieee80211_channel *notify_channel;
4611 struct ieee80211_supported_band *band; 4610 struct ieee80211_supported_band *band;
4611 struct brcmf_bss_info_le *bi;
4612 u32 freq; 4612 u32 freq;
4613 s32 err = 0; 4613 s32 err = 0;
4614 u32 target_channel; 4614 u32 target_channel;
4615 u8 *buf;
4615 4616
4616 WL_TRACE("Enter\n"); 4617 WL_TRACE("Enter\n");
4617 4618
@@ -4619,11 +4620,22 @@ brcmf_bss_roaming_done(struct brcmf_cfg80211_info *cfg,
4619 memcpy(profile->bssid, e->addr, ETH_ALEN); 4620 memcpy(profile->bssid, e->addr, ETH_ALEN);
4620 brcmf_update_bss_info(cfg); 4621 brcmf_update_bss_info(cfg);
4621 4622
4622 brcmf_exec_dcmd(ndev, BRCMF_C_GET_CHANNEL, &channel_le, 4623 buf = kzalloc(WL_BSS_INFO_MAX, GFP_KERNEL);
4623 sizeof(channel_le)); 4624 if (buf == NULL) {
4625 err = -ENOMEM;
4626 goto done;
4627 }
4624 4628
4625 target_channel = le32_to_cpu(channel_le.target_channel); 4629 /* data sent to dongle has to be little endian */
4626 WL_CONN("Roamed to channel %d\n", target_channel); 4630 *(__le32 *)buf = cpu_to_le32(WL_BSS_INFO_MAX);
4631 err = brcmf_exec_dcmd(ndev, BRCMF_C_GET_BSS_INFO, buf, WL_BSS_INFO_MAX);
4632
4633 if (err)
4634 goto done;
4635
4636 bi = (struct brcmf_bss_info_le *)(buf + 4);
4637 target_channel = bi->ctl_ch ? bi->ctl_ch :
4638 CHSPEC_CHANNEL(le16_to_cpu(bi->chanspec));
4627 4639
4628 if (target_channel <= CH_MAX_2G_CHANNEL) 4640 if (target_channel <= CH_MAX_2G_CHANNEL)
4629 band = wiphy->bands[IEEE80211_BAND_2GHZ]; 4641 band = wiphy->bands[IEEE80211_BAND_2GHZ];
@@ -4633,6 +4645,8 @@ brcmf_bss_roaming_done(struct brcmf_cfg80211_info *cfg,
4633 freq = ieee80211_channel_to_frequency(target_channel, band->band); 4645 freq = ieee80211_channel_to_frequency(target_channel, band->band);
4634 notify_channel = ieee80211_get_channel(wiphy, freq); 4646 notify_channel = ieee80211_get_channel(wiphy, freq);
4635 4647
4648done:
4649 kfree(buf);
4636 cfg80211_roamed(ndev, notify_channel, (u8 *)profile->bssid, 4650 cfg80211_roamed(ndev, notify_channel, (u8 *)profile->bssid,
4637 conn_info->req_ie, conn_info->req_ie_len, 4651 conn_info->req_ie, conn_info->req_ie_len,
4638 conn_info->resp_ie, conn_info->resp_ie_len, GFP_KERNEL); 4652 conn_info->resp_ie, conn_info->resp_ie_len, GFP_KERNEL);
@@ -5186,41 +5200,6 @@ brcmf_cfg80211_event(struct net_device *ndev,
5186 schedule_work(&cfg->event_work); 5200 schedule_work(&cfg->event_work);
5187} 5201}
5188 5202
5189static s32 brcmf_dongle_mode(struct net_device *ndev, s32 iftype)
5190{
5191 s32 infra = 0;
5192 s32 err = 0;
5193
5194 switch (iftype) {
5195 case NL80211_IFTYPE_MONITOR:
5196 case NL80211_IFTYPE_WDS:
5197 WL_ERR("type (%d) : currently we do not support this mode\n",
5198 iftype);
5199 err = -EINVAL;
5200 return err;
5201 case NL80211_IFTYPE_ADHOC:
5202 infra = 0;
5203 break;
5204 case NL80211_IFTYPE_STATION:
5205 infra = 1;
5206 break;
5207 case NL80211_IFTYPE_AP:
5208 infra = 1;
5209 break;
5210 default:
5211 err = -EINVAL;
5212 WL_ERR("invalid type (%d)\n", iftype);
5213 return err;
5214 }
5215 err = brcmf_exec_dcmd_u32(ndev, BRCMF_C_SET_INFRA, &infra);
5216 if (err) {
5217 WL_ERR("WLC_SET_INFRA error (%d)\n", err);
5218 return err;
5219 }
5220
5221 return 0;
5222}
5223
5224static s32 brcmf_dongle_eventmsg(struct net_device *ndev) 5203static s32 brcmf_dongle_eventmsg(struct net_device *ndev)
5225{ 5204{
5226 /* Room for "event_msgs" + '\0' + bitvec */ 5205 /* Room for "event_msgs" + '\0' + bitvec */
@@ -5439,7 +5418,8 @@ static s32 brcmf_config_dongle(struct brcmf_cfg80211_info *cfg)
5439 WL_BEACON_TIMEOUT); 5418 WL_BEACON_TIMEOUT);
5440 if (err) 5419 if (err)
5441 goto default_conf_out; 5420 goto default_conf_out;
5442 err = brcmf_dongle_mode(ndev, wdev->iftype); 5421 err = brcmf_cfg80211_change_iface(wdev->wiphy, ndev, wdev->iftype,
5422 NULL, NULL);
5443 if (err && err != -EINPROGRESS) 5423 if (err && err != -EINPROGRESS)
5444 goto default_conf_out; 5424 goto default_conf_out;
5445 err = brcmf_dongle_probecap(cfg); 5425 err = brcmf_dongle_probecap(cfg);
diff --git a/drivers/net/wireless/ipw2x00/ipw2200.c b/drivers/net/wireless/ipw2x00/ipw2200.c
index 935120fc8c9..768bf612533 100644
--- a/drivers/net/wireless/ipw2x00/ipw2200.c
+++ b/drivers/net/wireless/ipw2x00/ipw2200.c
@@ -10472,7 +10472,7 @@ static void ipw_handle_promiscuous_tx(struct ipw_priv *priv,
10472 } else 10472 } else
10473 len = src->len; 10473 len = src->len;
10474 10474
10475 dst = alloc_skb(len + sizeof(*rt_hdr), GFP_ATOMIC); 10475 dst = alloc_skb(len + sizeof(*rt_hdr) + sizeof(u16)*2, GFP_ATOMIC);
10476 if (!dst) 10476 if (!dst)
10477 continue; 10477 continue;
10478 10478
diff --git a/drivers/net/wireless/iwlwifi/dvm/devices.c b/drivers/net/wireless/iwlwifi/dvm/devices.c
index 349c205d5f6..da586206419 100644
--- a/drivers/net/wireless/iwlwifi/dvm/devices.c
+++ b/drivers/net/wireless/iwlwifi/dvm/devices.c
@@ -518,7 +518,7 @@ static int iwl6000_hw_channel_switch(struct iwl_priv *priv,
518 * See iwlagn_mac_channel_switch. 518 * See iwlagn_mac_channel_switch.
519 */ 519 */
520 struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; 520 struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
521 struct iwl6000_channel_switch_cmd cmd; 521 struct iwl6000_channel_switch_cmd *cmd;
522 u32 switch_time_in_usec, ucode_switch_time; 522 u32 switch_time_in_usec, ucode_switch_time;
523 u16 ch; 523 u16 ch;
524 u32 tsf_low; 524 u32 tsf_low;
@@ -527,18 +527,25 @@ static int iwl6000_hw_channel_switch(struct iwl_priv *priv,
527 struct ieee80211_vif *vif = ctx->vif; 527 struct ieee80211_vif *vif = ctx->vif;
528 struct iwl_host_cmd hcmd = { 528 struct iwl_host_cmd hcmd = {
529 .id = REPLY_CHANNEL_SWITCH, 529 .id = REPLY_CHANNEL_SWITCH,
530 .len = { sizeof(cmd), }, 530 .len = { sizeof(*cmd), },
531 .flags = CMD_SYNC, 531 .flags = CMD_SYNC,
532 .data = { &cmd, }, 532 .dataflags[0] = IWL_HCMD_DFL_NOCOPY,
533 }; 533 };
534 int err;
534 535
535 cmd.band = priv->band == IEEE80211_BAND_2GHZ; 536 cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
537 if (!cmd)
538 return -ENOMEM;
539
540 hcmd.data[0] = cmd;
541
542 cmd->band = priv->band == IEEE80211_BAND_2GHZ;
536 ch = ch_switch->channel->hw_value; 543 ch = ch_switch->channel->hw_value;
537 IWL_DEBUG_11H(priv, "channel switch from %u to %u\n", 544 IWL_DEBUG_11H(priv, "channel switch from %u to %u\n",
538 ctx->active.channel, ch); 545 ctx->active.channel, ch);
539 cmd.channel = cpu_to_le16(ch); 546 cmd->channel = cpu_to_le16(ch);
540 cmd.rxon_flags = ctx->staging.flags; 547 cmd->rxon_flags = ctx->staging.flags;
541 cmd.rxon_filter_flags = ctx->staging.filter_flags; 548 cmd->rxon_filter_flags = ctx->staging.filter_flags;
542 switch_count = ch_switch->count; 549 switch_count = ch_switch->count;
543 tsf_low = ch_switch->timestamp & 0x0ffffffff; 550 tsf_low = ch_switch->timestamp & 0x0ffffffff;
544 /* 551 /*
@@ -554,23 +561,25 @@ static int iwl6000_hw_channel_switch(struct iwl_priv *priv,
554 switch_count = 0; 561 switch_count = 0;
555 } 562 }
556 if (switch_count <= 1) 563 if (switch_count <= 1)
557 cmd.switch_time = cpu_to_le32(priv->ucode_beacon_time); 564 cmd->switch_time = cpu_to_le32(priv->ucode_beacon_time);
558 else { 565 else {
559 switch_time_in_usec = 566 switch_time_in_usec =
560 vif->bss_conf.beacon_int * switch_count * TIME_UNIT; 567 vif->bss_conf.beacon_int * switch_count * TIME_UNIT;
561 ucode_switch_time = iwl_usecs_to_beacons(priv, 568 ucode_switch_time = iwl_usecs_to_beacons(priv,
562 switch_time_in_usec, 569 switch_time_in_usec,
563 beacon_interval); 570 beacon_interval);
564 cmd.switch_time = iwl_add_beacon_time(priv, 571 cmd->switch_time = iwl_add_beacon_time(priv,
565 priv->ucode_beacon_time, 572 priv->ucode_beacon_time,
566 ucode_switch_time, 573 ucode_switch_time,
567 beacon_interval); 574 beacon_interval);
568 } 575 }
569 IWL_DEBUG_11H(priv, "uCode time for the switch is 0x%x\n", 576 IWL_DEBUG_11H(priv, "uCode time for the switch is 0x%x\n",
570 cmd.switch_time); 577 cmd->switch_time);
571 cmd.expect_beacon = ch_switch->channel->flags & IEEE80211_CHAN_RADAR; 578 cmd->expect_beacon = ch_switch->channel->flags & IEEE80211_CHAN_RADAR;
572 579
573 return iwl_dvm_send_cmd(priv, &hcmd); 580 err = iwl_dvm_send_cmd(priv, &hcmd);
581 kfree(cmd);
582 return err;
574} 583}
575 584
576struct iwl_lib_ops iwl6000_lib = { 585struct iwl_lib_ops iwl6000_lib = {
diff --git a/drivers/net/wireless/iwlwifi/dvm/mac80211.c b/drivers/net/wireless/iwlwifi/dvm/mac80211.c
index ff8162d4c45..2d9eee93c74 100644
--- a/drivers/net/wireless/iwlwifi/dvm/mac80211.c
+++ b/drivers/net/wireless/iwlwifi/dvm/mac80211.c
@@ -521,7 +521,7 @@ static void iwlagn_mac_tx(struct ieee80211_hw *hw,
521 ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); 521 ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate);
522 522
523 if (iwlagn_tx_skb(priv, control->sta, skb)) 523 if (iwlagn_tx_skb(priv, control->sta, skb))
524 dev_kfree_skb_any(skb); 524 ieee80211_free_txskb(hw, skb);
525} 525}
526 526
527static void iwlagn_mac_update_tkip_key(struct ieee80211_hw *hw, 527static void iwlagn_mac_update_tkip_key(struct ieee80211_hw *hw,
@@ -1354,6 +1354,20 @@ static int iwlagn_mac_add_interface(struct ieee80211_hw *hw,
1354 vif_priv->ctx = ctx; 1354 vif_priv->ctx = ctx;
1355 ctx->vif = vif; 1355 ctx->vif = vif;
1356 1356
1357 /*
1358 * In SNIFFER device type, the firmware reports the FCS to
1359 * the host, rather than snipping it off. Unfortunately,
1360 * mac80211 doesn't (yet) provide a per-packet flag for
1361 * this, so that we have to set the hardware flag based
1362 * on the interfaces added. As the monitor interface can
1363 * only be present by itself, and will be removed before
1364 * other interfaces are added, this is safe.
1365 */
1366 if (vif->type == NL80211_IFTYPE_MONITOR)
1367 priv->hw->flags |= IEEE80211_HW_RX_INCLUDES_FCS;
1368 else
1369 priv->hw->flags &= ~IEEE80211_HW_RX_INCLUDES_FCS;
1370
1357 err = iwl_setup_interface(priv, ctx); 1371 err = iwl_setup_interface(priv, ctx);
1358 if (!err || reset) 1372 if (!err || reset)
1359 goto out; 1373 goto out;
diff --git a/drivers/net/wireless/iwlwifi/dvm/main.c b/drivers/net/wireless/iwlwifi/dvm/main.c
index 7ff3f143067..408132cf83c 100644
--- a/drivers/net/wireless/iwlwifi/dvm/main.c
+++ b/drivers/net/wireless/iwlwifi/dvm/main.c
@@ -2114,7 +2114,7 @@ static void iwl_free_skb(struct iwl_op_mode *op_mode, struct sk_buff *skb)
2114 2114
2115 info = IEEE80211_SKB_CB(skb); 2115 info = IEEE80211_SKB_CB(skb);
2116 iwl_trans_free_tx_cmd(priv->trans, info->driver_data[1]); 2116 iwl_trans_free_tx_cmd(priv->trans, info->driver_data[1]);
2117 dev_kfree_skb_any(skb); 2117 ieee80211_free_txskb(priv->hw, skb);
2118} 2118}
2119 2119
2120static void iwl_set_hw_rfkill_state(struct iwl_op_mode *op_mode, bool state) 2120static void iwl_set_hw_rfkill_state(struct iwl_op_mode *op_mode, bool state)
diff --git a/drivers/net/wireless/iwlwifi/pcie/rx.c b/drivers/net/wireless/iwlwifi/pcie/rx.c
index 17c8e5d8268..bb69f8f90b3 100644
--- a/drivers/net/wireless/iwlwifi/pcie/rx.c
+++ b/drivers/net/wireless/iwlwifi/pcie/rx.c
@@ -321,6 +321,14 @@ static void iwl_rx_allocate(struct iwl_trans *trans, gfp_t priority)
321 dma_map_page(trans->dev, page, 0, 321 dma_map_page(trans->dev, page, 0,
322 PAGE_SIZE << trans_pcie->rx_page_order, 322 PAGE_SIZE << trans_pcie->rx_page_order,
323 DMA_FROM_DEVICE); 323 DMA_FROM_DEVICE);
324 if (dma_mapping_error(trans->dev, rxb->page_dma)) {
325 rxb->page = NULL;
326 spin_lock_irqsave(&rxq->lock, flags);
327 list_add(&rxb->list, &rxq->rx_used);
328 spin_unlock_irqrestore(&rxq->lock, flags);
329 __free_pages(page, trans_pcie->rx_page_order);
330 return;
331 }
324 /* dma address must be no more than 36 bits */ 332 /* dma address must be no more than 36 bits */
325 BUG_ON(rxb->page_dma & ~DMA_BIT_MASK(36)); 333 BUG_ON(rxb->page_dma & ~DMA_BIT_MASK(36));
326 /* and also 256 byte aligned! */ 334 /* and also 256 byte aligned! */
@@ -488,8 +496,19 @@ static void iwl_rx_handle_rxbuf(struct iwl_trans *trans,
488 dma_map_page(trans->dev, rxb->page, 0, 496 dma_map_page(trans->dev, rxb->page, 0,
489 PAGE_SIZE << trans_pcie->rx_page_order, 497 PAGE_SIZE << trans_pcie->rx_page_order,
490 DMA_FROM_DEVICE); 498 DMA_FROM_DEVICE);
491 list_add_tail(&rxb->list, &rxq->rx_free); 499 if (dma_mapping_error(trans->dev, rxb->page_dma)) {
492 rxq->free_count++; 500 /*
501 * free the page(s) as well to not break
502 * the invariant that the items on the used
503 * list have no page(s)
504 */
505 __free_pages(rxb->page, trans_pcie->rx_page_order);
506 rxb->page = NULL;
507 list_add_tail(&rxb->list, &rxq->rx_used);
508 } else {
509 list_add_tail(&rxb->list, &rxq->rx_free);
510 rxq->free_count++;
511 }
493 } else 512 } else
494 list_add_tail(&rxb->list, &rxq->rx_used); 513 list_add_tail(&rxb->list, &rxq->rx_used);
495 spin_unlock_irqrestore(&rxq->lock, flags); 514 spin_unlock_irqrestore(&rxq->lock, flags);
diff --git a/drivers/net/wireless/iwlwifi/pcie/tx.c b/drivers/net/wireless/iwlwifi/pcie/tx.c
index 105e3af3c62..79a4ddc002d 100644
--- a/drivers/net/wireless/iwlwifi/pcie/tx.c
+++ b/drivers/net/wireless/iwlwifi/pcie/tx.c
@@ -480,20 +480,12 @@ void iwl_trans_pcie_txq_enable(struct iwl_trans *trans, int txq_id, int fifo,
480void iwl_trans_pcie_txq_disable(struct iwl_trans *trans, int txq_id) 480void iwl_trans_pcie_txq_disable(struct iwl_trans *trans, int txq_id)
481{ 481{
482 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); 482 struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
483 u16 rd_ptr, wr_ptr;
484 int n_bd = trans_pcie->txq[txq_id].q.n_bd;
485 483
486 if (!test_and_clear_bit(txq_id, trans_pcie->queue_used)) { 484 if (!test_and_clear_bit(txq_id, trans_pcie->queue_used)) {
487 WARN_ONCE(1, "queue %d not used", txq_id); 485 WARN_ONCE(1, "queue %d not used", txq_id);
488 return; 486 return;
489 } 487 }
490 488
491 rd_ptr = iwl_read_prph(trans, SCD_QUEUE_RDPTR(txq_id)) & (n_bd - 1);
492 wr_ptr = iwl_read_prph(trans, SCD_QUEUE_WRPTR(txq_id));
493
494 WARN_ONCE(rd_ptr != wr_ptr, "queue %d isn't empty: [%d,%d]",
495 txq_id, rd_ptr, wr_ptr);
496
497 iwl_txq_set_inactive(trans, txq_id); 489 iwl_txq_set_inactive(trans, txq_id);
498 IWL_DEBUG_TX_QUEUES(trans, "Deactivate queue %d\n", txq_id); 490 IWL_DEBUG_TX_QUEUES(trans, "Deactivate queue %d\n", txq_id);
499} 491}
diff --git a/drivers/net/wireless/mwifiex/cfg80211.c b/drivers/net/wireless/mwifiex/cfg80211.c
index 0679458a1ba..780d3e16829 100644
--- a/drivers/net/wireless/mwifiex/cfg80211.c
+++ b/drivers/net/wireless/mwifiex/cfg80211.c
@@ -1825,8 +1825,6 @@ mwifiex_cfg80211_scan(struct wiphy *wiphy,
1825 return -EBUSY; 1825 return -EBUSY;
1826 } 1826 }
1827 1827
1828 priv->scan_request = request;
1829
1830 priv->user_scan_cfg = kzalloc(sizeof(struct mwifiex_user_scan_cfg), 1828 priv->user_scan_cfg = kzalloc(sizeof(struct mwifiex_user_scan_cfg),
1831 GFP_KERNEL); 1829 GFP_KERNEL);
1832 if (!priv->user_scan_cfg) { 1830 if (!priv->user_scan_cfg) {
@@ -1834,6 +1832,8 @@ mwifiex_cfg80211_scan(struct wiphy *wiphy,
1834 return -ENOMEM; 1832 return -ENOMEM;
1835 } 1833 }
1836 1834
1835 priv->scan_request = request;
1836
1837 priv->user_scan_cfg->num_ssids = request->n_ssids; 1837 priv->user_scan_cfg->num_ssids = request->n_ssids;
1838 priv->user_scan_cfg->ssid_list = request->ssids; 1838 priv->user_scan_cfg->ssid_list = request->ssids;
1839 1839
@@ -1870,6 +1870,9 @@ mwifiex_cfg80211_scan(struct wiphy *wiphy,
1870 ret = mwifiex_scan_networks(priv, priv->user_scan_cfg); 1870 ret = mwifiex_scan_networks(priv, priv->user_scan_cfg);
1871 if (ret) { 1871 if (ret) {
1872 dev_err(priv->adapter->dev, "scan failed: %d\n", ret); 1872 dev_err(priv->adapter->dev, "scan failed: %d\n", ret);
1873 priv->scan_request = NULL;
1874 kfree(priv->user_scan_cfg);
1875 priv->user_scan_cfg = NULL;
1873 return ret; 1876 return ret;
1874 } 1877 }
1875 1878
diff --git a/drivers/net/wireless/mwifiex/cmdevt.c b/drivers/net/wireless/mwifiex/cmdevt.c
index 8d465107f52..ae9010ed58d 100644
--- a/drivers/net/wireless/mwifiex/cmdevt.c
+++ b/drivers/net/wireless/mwifiex/cmdevt.c
@@ -890,9 +890,6 @@ mwifiex_cmd_timeout_func(unsigned long function_context)
890 return; 890 return;
891 } 891 }
892 cmd_node = adapter->curr_cmd; 892 cmd_node = adapter->curr_cmd;
893 if (cmd_node->wait_q_enabled)
894 adapter->cmd_wait_q.status = -ETIMEDOUT;
895
896 if (cmd_node) { 893 if (cmd_node) {
897 adapter->dbg.timeout_cmd_id = 894 adapter->dbg.timeout_cmd_id =
898 adapter->dbg.last_cmd_id[adapter->dbg.last_cmd_index]; 895 adapter->dbg.last_cmd_id[adapter->dbg.last_cmd_index];
@@ -938,6 +935,14 @@ mwifiex_cmd_timeout_func(unsigned long function_context)
938 935
939 dev_err(adapter->dev, "ps_mode=%d ps_state=%d\n", 936 dev_err(adapter->dev, "ps_mode=%d ps_state=%d\n",
940 adapter->ps_mode, adapter->ps_state); 937 adapter->ps_mode, adapter->ps_state);
938
939 if (cmd_node->wait_q_enabled) {
940 adapter->cmd_wait_q.status = -ETIMEDOUT;
941 wake_up_interruptible(&adapter->cmd_wait_q.wait);
942 mwifiex_cancel_pending_ioctl(adapter);
943 /* reset cmd_sent flag to unblock new commands */
944 adapter->cmd_sent = false;
945 }
941 } 946 }
942 if (adapter->hw_status == MWIFIEX_HW_STATUS_INITIALIZING) 947 if (adapter->hw_status == MWIFIEX_HW_STATUS_INITIALIZING)
943 mwifiex_init_fw_complete(adapter); 948 mwifiex_init_fw_complete(adapter);
diff --git a/drivers/net/wireless/mwifiex/scan.c b/drivers/net/wireless/mwifiex/scan.c
index 00b658d3b6e..9171aaedbcc 100644
--- a/drivers/net/wireless/mwifiex/scan.c
+++ b/drivers/net/wireless/mwifiex/scan.c
@@ -1843,21 +1843,18 @@ static int mwifiex_scan_specific_ssid(struct mwifiex_private *priv,
1843 struct cfg80211_ssid *req_ssid) 1843 struct cfg80211_ssid *req_ssid)
1844{ 1844{
1845 struct mwifiex_adapter *adapter = priv->adapter; 1845 struct mwifiex_adapter *adapter = priv->adapter;
1846 int ret = 0; 1846 int ret;
1847 struct mwifiex_user_scan_cfg *scan_cfg; 1847 struct mwifiex_user_scan_cfg *scan_cfg;
1848 1848
1849 if (!req_ssid)
1850 return -1;
1851
1852 if (adapter->scan_processing) { 1849 if (adapter->scan_processing) {
1853 dev_dbg(adapter->dev, "cmd: Scan already in process...\n"); 1850 dev_err(adapter->dev, "cmd: Scan already in process...\n");
1854 return ret; 1851 return -EBUSY;
1855 } 1852 }
1856 1853
1857 if (priv->scan_block) { 1854 if (priv->scan_block) {
1858 dev_dbg(adapter->dev, 1855 dev_err(adapter->dev,
1859 "cmd: Scan is blocked during association...\n"); 1856 "cmd: Scan is blocked during association...\n");
1860 return ret; 1857 return -EBUSY;
1861 } 1858 }
1862 1859
1863 scan_cfg = kzalloc(sizeof(struct mwifiex_user_scan_cfg), GFP_KERNEL); 1860 scan_cfg = kzalloc(sizeof(struct mwifiex_user_scan_cfg), GFP_KERNEL);
diff --git a/drivers/net/wireless/mwifiex/sdio.c b/drivers/net/wireless/mwifiex/sdio.c
index fc8a9bfa124..82cf0fa2d9f 100644
--- a/drivers/net/wireless/mwifiex/sdio.c
+++ b/drivers/net/wireless/mwifiex/sdio.c
@@ -161,7 +161,6 @@ static int mwifiex_sdio_suspend(struct device *dev)
161 struct sdio_mmc_card *card; 161 struct sdio_mmc_card *card;
162 struct mwifiex_adapter *adapter; 162 struct mwifiex_adapter *adapter;
163 mmc_pm_flag_t pm_flag = 0; 163 mmc_pm_flag_t pm_flag = 0;
164 int hs_actived = 0;
165 int i; 164 int i;
166 int ret = 0; 165 int ret = 0;
167 166
@@ -188,12 +187,14 @@ static int mwifiex_sdio_suspend(struct device *dev)
188 adapter = card->adapter; 187 adapter = card->adapter;
189 188
190 /* Enable the Host Sleep */ 189 /* Enable the Host Sleep */
191 hs_actived = mwifiex_enable_hs(adapter); 190 if (!mwifiex_enable_hs(adapter)) {
192 if (hs_actived) { 191 dev_err(adapter->dev, "cmd: failed to suspend\n");
193 pr_debug("cmd: suspend with MMC_PM_KEEP_POWER\n"); 192 return -EFAULT;
194 ret = sdio_set_host_pm_flags(func, MMC_PM_KEEP_POWER);
195 } 193 }
196 194
195 dev_dbg(adapter->dev, "cmd: suspend with MMC_PM_KEEP_POWER\n");
196 ret = sdio_set_host_pm_flags(func, MMC_PM_KEEP_POWER);
197
197 /* Indicate device suspended */ 198 /* Indicate device suspended */
198 adapter->is_suspended = true; 199 adapter->is_suspended = true;
199 200
diff --git a/drivers/net/wireless/rt2x00/rt2500usb.c b/drivers/net/wireless/rt2x00/rt2500usb.c
index a12e84f892b..6b2e1e431dd 100644
--- a/drivers/net/wireless/rt2x00/rt2500usb.c
+++ b/drivers/net/wireless/rt2x00/rt2500usb.c
@@ -1988,6 +1988,7 @@ static struct usb_driver rt2500usb_driver = {
1988 .disconnect = rt2x00usb_disconnect, 1988 .disconnect = rt2x00usb_disconnect,
1989 .suspend = rt2x00usb_suspend, 1989 .suspend = rt2x00usb_suspend,
1990 .resume = rt2x00usb_resume, 1990 .resume = rt2x00usb_resume,
1991 .reset_resume = rt2x00usb_resume,
1991 .disable_hub_initiated_lpm = 1, 1992 .disable_hub_initiated_lpm = 1,
1992}; 1993};
1993 1994
diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index 01dc8891070..59474ae0aec 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -2449,7 +2449,7 @@ static int rt2800_get_gain_calibration_delta(struct rt2x00_dev *rt2x00dev)
2449 /* 2449 /*
2450 * Check if temperature compensation is supported. 2450 * Check if temperature compensation is supported.
2451 */ 2451 */
2452 if (tssi_bounds[4] == 0xff) 2452 if (tssi_bounds[4] == 0xff || step == 0xff)
2453 return 0; 2453 return 0;
2454 2454
2455 /* 2455 /*
diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c
index c9e9370eb78..3b8fb5a603f 100644
--- a/drivers/net/wireless/rt2x00/rt2800usb.c
+++ b/drivers/net/wireless/rt2x00/rt2800usb.c
@@ -1282,6 +1282,7 @@ static struct usb_driver rt2800usb_driver = {
1282 .disconnect = rt2x00usb_disconnect, 1282 .disconnect = rt2x00usb_disconnect,
1283 .suspend = rt2x00usb_suspend, 1283 .suspend = rt2x00usb_suspend,
1284 .resume = rt2x00usb_resume, 1284 .resume = rt2x00usb_resume,
1285 .reset_resume = rt2x00usb_resume,
1285 .disable_hub_initiated_lpm = 1, 1286 .disable_hub_initiated_lpm = 1,
1286}; 1287};
1287 1288
diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c
index e5eb43b3eee..24eec66e9fd 100644
--- a/drivers/net/wireless/rt2x00/rt73usb.c
+++ b/drivers/net/wireless/rt2x00/rt73usb.c
@@ -2535,6 +2535,7 @@ static struct usb_driver rt73usb_driver = {
2535 .disconnect = rt2x00usb_disconnect, 2535 .disconnect = rt2x00usb_disconnect,
2536 .suspend = rt2x00usb_suspend, 2536 .suspend = rt2x00usb_suspend,
2537 .resume = rt2x00usb_resume, 2537 .resume = rt2x00usb_resume,
2538 .reset_resume = rt2x00usb_resume,
2538 .disable_hub_initiated_lpm = 1, 2539 .disable_hub_initiated_lpm = 1,
2539}; 2540};
2540 2541
diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c b/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c
index 9970c2b1b19..b7e6607e6b6 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c
@@ -297,6 +297,7 @@ static struct usb_device_id rtl8192c_usb_ids[] = {
297 /*=== Customer ID ===*/ 297 /*=== Customer ID ===*/
298 /****** 8188CU ********/ 298 /****** 8188CU ********/
299 {RTL_USB_DEVICE(0x050d, 0x1102, rtl92cu_hal_cfg)}, /*Belkin - Edimax*/ 299 {RTL_USB_DEVICE(0x050d, 0x1102, rtl92cu_hal_cfg)}, /*Belkin - Edimax*/
300 {RTL_USB_DEVICE(0x050d, 0x11f2, rtl92cu_hal_cfg)}, /*Belkin - ISY*/
300 {RTL_USB_DEVICE(0x06f8, 0xe033, rtl92cu_hal_cfg)}, /*Hercules - Edimax*/ 301 {RTL_USB_DEVICE(0x06f8, 0xe033, rtl92cu_hal_cfg)}, /*Hercules - Edimax*/
301 {RTL_USB_DEVICE(0x07b8, 0x8188, rtl92cu_hal_cfg)}, /*Abocom - Abocom*/ 302 {RTL_USB_DEVICE(0x07b8, 0x8188, rtl92cu_hal_cfg)}, /*Abocom - Abocom*/
302 {RTL_USB_DEVICE(0x07b8, 0x8189, rtl92cu_hal_cfg)}, /*Funai - Abocom*/ 303 {RTL_USB_DEVICE(0x07b8, 0x8189, rtl92cu_hal_cfg)}, /*Funai - Abocom*/
diff --git a/drivers/net/wireless/rtlwifi/usb.c b/drivers/net/wireless/rtlwifi/usb.c
index 030beb45d8b..e3ea4b34688 100644
--- a/drivers/net/wireless/rtlwifi/usb.c
+++ b/drivers/net/wireless/rtlwifi/usb.c
@@ -673,7 +673,7 @@ static int rtl_usb_start(struct ieee80211_hw *hw)
673 set_hal_start(rtlhal); 673 set_hal_start(rtlhal);
674 674
675 /* Start bulk IN */ 675 /* Start bulk IN */
676 _rtl_usb_receive(hw); 676 err = _rtl_usb_receive(hw);
677 } 677 }
678 678
679 return err; 679 return err;
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index caa011008cd..fc24eb9b394 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -452,29 +452,85 @@ static void xennet_make_frags(struct sk_buff *skb, struct net_device *dev,
452 /* Grant backend access to each skb fragment page. */ 452 /* Grant backend access to each skb fragment page. */
453 for (i = 0; i < frags; i++) { 453 for (i = 0; i < frags; i++) {
454 skb_frag_t *frag = skb_shinfo(skb)->frags + i; 454 skb_frag_t *frag = skb_shinfo(skb)->frags + i;
455 struct page *page = skb_frag_page(frag);
455 456
456 tx->flags |= XEN_NETTXF_more_data; 457 len = skb_frag_size(frag);
458 offset = frag->page_offset;
457 459
458 id = get_id_from_freelist(&np->tx_skb_freelist, np->tx_skbs); 460 /* Data must not cross a page boundary. */
459 np->tx_skbs[id].skb = skb_get(skb); 461 BUG_ON(len + offset > PAGE_SIZE<<compound_order(page));
460 tx = RING_GET_REQUEST(&np->tx, prod++);
461 tx->id = id;
462 ref = gnttab_claim_grant_reference(&np->gref_tx_head);
463 BUG_ON((signed short)ref < 0);
464 462
465 mfn = pfn_to_mfn(page_to_pfn(skb_frag_page(frag))); 463 /* Skip unused frames from start of page */
466 gnttab_grant_foreign_access_ref(ref, np->xbdev->otherend_id, 464 page += offset >> PAGE_SHIFT;
467 mfn, GNTMAP_readonly); 465 offset &= ~PAGE_MASK;
468 466
469 tx->gref = np->grant_tx_ref[id] = ref; 467 while (len > 0) {
470 tx->offset = frag->page_offset; 468 unsigned long bytes;
471 tx->size = skb_frag_size(frag); 469
472 tx->flags = 0; 470 BUG_ON(offset >= PAGE_SIZE);
471
472 bytes = PAGE_SIZE - offset;
473 if (bytes > len)
474 bytes = len;
475
476 tx->flags |= XEN_NETTXF_more_data;
477
478 id = get_id_from_freelist(&np->tx_skb_freelist,
479 np->tx_skbs);
480 np->tx_skbs[id].skb = skb_get(skb);
481 tx = RING_GET_REQUEST(&np->tx, prod++);
482 tx->id = id;
483 ref = gnttab_claim_grant_reference(&np->gref_tx_head);
484 BUG_ON((signed short)ref < 0);
485
486 mfn = pfn_to_mfn(page_to_pfn(page));
487 gnttab_grant_foreign_access_ref(ref,
488 np->xbdev->otherend_id,
489 mfn, GNTMAP_readonly);
490
491 tx->gref = np->grant_tx_ref[id] = ref;
492 tx->offset = offset;
493 tx->size = bytes;
494 tx->flags = 0;
495
496 offset += bytes;
497 len -= bytes;
498
499 /* Next frame */
500 if (offset == PAGE_SIZE && len) {
501 BUG_ON(!PageCompound(page));
502 page++;
503 offset = 0;
504 }
505 }
473 } 506 }
474 507
475 np->tx.req_prod_pvt = prod; 508 np->tx.req_prod_pvt = prod;
476} 509}
477 510
511/*
512 * Count how many ring slots are required to send the frags of this
513 * skb. Each frag might be a compound page.
514 */
515static int xennet_count_skb_frag_slots(struct sk_buff *skb)
516{
517 int i, frags = skb_shinfo(skb)->nr_frags;
518 int pages = 0;
519
520 for (i = 0; i < frags; i++) {
521 skb_frag_t *frag = skb_shinfo(skb)->frags + i;
522 unsigned long size = skb_frag_size(frag);
523 unsigned long offset = frag->page_offset;
524
525 /* Skip unused frames from start of page */
526 offset &= ~PAGE_MASK;
527
528 pages += PFN_UP(offset + size);
529 }
530
531 return pages;
532}
533
478static int xennet_start_xmit(struct sk_buff *skb, struct net_device *dev) 534static int xennet_start_xmit(struct sk_buff *skb, struct net_device *dev)
479{ 535{
480 unsigned short id; 536 unsigned short id;
@@ -487,23 +543,23 @@ static int xennet_start_xmit(struct sk_buff *skb, struct net_device *dev)
487 grant_ref_t ref; 543 grant_ref_t ref;
488 unsigned long mfn; 544 unsigned long mfn;
489 int notify; 545 int notify;
490 int frags = skb_shinfo(skb)->nr_frags; 546 int slots;
491 unsigned int offset = offset_in_page(data); 547 unsigned int offset = offset_in_page(data);
492 unsigned int len = skb_headlen(skb); 548 unsigned int len = skb_headlen(skb);
493 unsigned long flags; 549 unsigned long flags;
494 550
495 frags += DIV_ROUND_UP(offset + len, PAGE_SIZE); 551 slots = DIV_ROUND_UP(offset + len, PAGE_SIZE) +
496 if (unlikely(frags > MAX_SKB_FRAGS + 1)) { 552 xennet_count_skb_frag_slots(skb);
497 printk(KERN_ALERT "xennet: skb rides the rocket: %d frags\n", 553 if (unlikely(slots > MAX_SKB_FRAGS + 1)) {
498 frags); 554 net_alert_ratelimited(
499 dump_stack(); 555 "xennet: skb rides the rocket: %d slots\n", slots);
500 goto drop; 556 goto drop;
501 } 557 }
502 558
503 spin_lock_irqsave(&np->tx_lock, flags); 559 spin_lock_irqsave(&np->tx_lock, flags);
504 560
505 if (unlikely(!netif_carrier_ok(dev) || 561 if (unlikely(!netif_carrier_ok(dev) ||
506 (frags > 1 && !xennet_can_sg(dev)) || 562 (slots > 1 && !xennet_can_sg(dev)) ||
507 netif_needs_gso(skb, netif_skb_features(skb)))) { 563 netif_needs_gso(skb, netif_skb_features(skb)))) {
508 spin_unlock_irqrestore(&np->tx_lock, flags); 564 spin_unlock_irqrestore(&np->tx_lock, flags);
509 goto drop; 565 goto drop;
diff --git a/drivers/nfc/pn533.c b/drivers/nfc/pn533.c
index 97c440a8cd6..30ae18a03a9 100644
--- a/drivers/nfc/pn533.c
+++ b/drivers/nfc/pn533.c
@@ -698,13 +698,14 @@ static void pn533_wq_cmd(struct work_struct *work)
698 698
699 cmd = list_first_entry(&dev->cmd_queue, struct pn533_cmd, queue); 699 cmd = list_first_entry(&dev->cmd_queue, struct pn533_cmd, queue);
700 700
701 list_del(&cmd->queue);
702
701 mutex_unlock(&dev->cmd_lock); 703 mutex_unlock(&dev->cmd_lock);
702 704
703 __pn533_send_cmd_frame_async(dev, cmd->out_frame, cmd->in_frame, 705 __pn533_send_cmd_frame_async(dev, cmd->out_frame, cmd->in_frame,
704 cmd->in_frame_len, cmd->cmd_complete, 706 cmd->in_frame_len, cmd->cmd_complete,
705 cmd->arg, cmd->flags); 707 cmd->arg, cmd->flags);
706 708
707 list_del(&cmd->queue);
708 kfree(cmd); 709 kfree(cmd);
709} 710}
710 711
@@ -1678,11 +1679,14 @@ static void pn533_deactivate_target(struct nfc_dev *nfc_dev,
1678static int pn533_in_dep_link_up_complete(struct pn533 *dev, void *arg, 1679static int pn533_in_dep_link_up_complete(struct pn533 *dev, void *arg,
1679 u8 *params, int params_len) 1680 u8 *params, int params_len)
1680{ 1681{
1681 struct pn533_cmd_jump_dep *cmd;
1682 struct pn533_cmd_jump_dep_response *resp; 1682 struct pn533_cmd_jump_dep_response *resp;
1683 struct nfc_target nfc_target; 1683 struct nfc_target nfc_target;
1684 u8 target_gt_len; 1684 u8 target_gt_len;
1685 int rc; 1685 int rc;
1686 struct pn533_cmd_jump_dep *cmd = (struct pn533_cmd_jump_dep *)arg;
1687 u8 active = cmd->active;
1688
1689 kfree(arg);
1686 1690
1687 if (params_len == -ENOENT) { 1691 if (params_len == -ENOENT) {
1688 nfc_dev_dbg(&dev->interface->dev, ""); 1692 nfc_dev_dbg(&dev->interface->dev, "");
@@ -1704,7 +1708,6 @@ static int pn533_in_dep_link_up_complete(struct pn533 *dev, void *arg,
1704 } 1708 }
1705 1709
1706 resp = (struct pn533_cmd_jump_dep_response *) params; 1710 resp = (struct pn533_cmd_jump_dep_response *) params;
1707 cmd = (struct pn533_cmd_jump_dep *) arg;
1708 rc = resp->status & PN533_CMD_RET_MASK; 1711 rc = resp->status & PN533_CMD_RET_MASK;
1709 if (rc != PN533_CMD_RET_SUCCESS) { 1712 if (rc != PN533_CMD_RET_SUCCESS) {
1710 nfc_dev_err(&dev->interface->dev, 1713 nfc_dev_err(&dev->interface->dev,
@@ -1734,7 +1737,7 @@ static int pn533_in_dep_link_up_complete(struct pn533 *dev, void *arg,
1734 if (rc == 0) 1737 if (rc == 0)
1735 rc = nfc_dep_link_is_up(dev->nfc_dev, 1738 rc = nfc_dep_link_is_up(dev->nfc_dev,
1736 dev->nfc_dev->targets[0].idx, 1739 dev->nfc_dev->targets[0].idx,
1737 !cmd->active, NFC_RF_INITIATOR); 1740 !active, NFC_RF_INITIATOR);
1738 1741
1739 return 0; 1742 return 0;
1740} 1743}
@@ -1819,12 +1822,8 @@ static int pn533_dep_link_up(struct nfc_dev *nfc_dev, struct nfc_target *target,
1819 rc = pn533_send_cmd_frame_async(dev, dev->out_frame, dev->in_frame, 1822 rc = pn533_send_cmd_frame_async(dev, dev->out_frame, dev->in_frame,
1820 dev->in_maxlen, pn533_in_dep_link_up_complete, 1823 dev->in_maxlen, pn533_in_dep_link_up_complete,
1821 cmd, GFP_KERNEL); 1824 cmd, GFP_KERNEL);
1822 if (rc) 1825 if (rc < 0)
1823 goto out; 1826 kfree(cmd);
1824
1825
1826out:
1827 kfree(cmd);
1828 1827
1829 return rc; 1828 return rc;
1830} 1829}
@@ -2078,8 +2077,12 @@ error:
2078static int pn533_tm_send_complete(struct pn533 *dev, void *arg, 2077static int pn533_tm_send_complete(struct pn533 *dev, void *arg,
2079 u8 *params, int params_len) 2078 u8 *params, int params_len)
2080{ 2079{
2080 struct sk_buff *skb_out = arg;
2081
2081 nfc_dev_dbg(&dev->interface->dev, "%s", __func__); 2082 nfc_dev_dbg(&dev->interface->dev, "%s", __func__);
2082 2083
2084 dev_kfree_skb(skb_out);
2085
2083 if (params_len < 0) { 2086 if (params_len < 0) {
2084 nfc_dev_err(&dev->interface->dev, 2087 nfc_dev_err(&dev->interface->dev,
2085 "Error %d when sending data", 2088 "Error %d when sending data",
@@ -2117,7 +2120,7 @@ static int pn533_tm_send(struct nfc_dev *nfc_dev, struct sk_buff *skb)
2117 2120
2118 rc = pn533_send_cmd_frame_async(dev, out_frame, dev->in_frame, 2121 rc = pn533_send_cmd_frame_async(dev, out_frame, dev->in_frame,
2119 dev->in_maxlen, pn533_tm_send_complete, 2122 dev->in_maxlen, pn533_tm_send_complete,
2120 NULL, GFP_KERNEL); 2123 skb, GFP_KERNEL);
2121 if (rc) { 2124 if (rc) {
2122 nfc_dev_err(&dev->interface->dev, 2125 nfc_dev_err(&dev->interface->dev,
2123 "Error %d when trying to send data", rc); 2126 "Error %d when trying to send data", rc);
diff --git a/drivers/of/address.c b/drivers/of/address.c
index 72e496f1e9b..0125524c08c 100644
--- a/drivers/of/address.c
+++ b/drivers/of/address.c
@@ -37,9 +37,9 @@ struct of_bus {
37 int (*match)(struct device_node *parent); 37 int (*match)(struct device_node *parent);
38 void (*count_cells)(struct device_node *child, 38 void (*count_cells)(struct device_node *child,
39 int *addrc, int *sizec); 39 int *addrc, int *sizec);
40 u64 (*map)(u32 *addr, const __be32 *range, 40 u64 (*map)(__be32 *addr, const __be32 *range,
41 int na, int ns, int pna); 41 int na, int ns, int pna);
42 int (*translate)(u32 *addr, u64 offset, int na); 42 int (*translate)(__be32 *addr, u64 offset, int na);
43 unsigned int (*get_flags)(const __be32 *addr); 43 unsigned int (*get_flags)(const __be32 *addr);
44}; 44};
45 45
@@ -56,7 +56,7 @@ static void of_bus_default_count_cells(struct device_node *dev,
56 *sizec = of_n_size_cells(dev); 56 *sizec = of_n_size_cells(dev);
57} 57}
58 58
59static u64 of_bus_default_map(u32 *addr, const __be32 *range, 59static u64 of_bus_default_map(__be32 *addr, const __be32 *range,
60 int na, int ns, int pna) 60 int na, int ns, int pna)
61{ 61{
62 u64 cp, s, da; 62 u64 cp, s, da;
@@ -82,7 +82,7 @@ static u64 of_bus_default_map(u32 *addr, const __be32 *range,
82 return da - cp; 82 return da - cp;
83} 83}
84 84
85static int of_bus_default_translate(u32 *addr, u64 offset, int na) 85static int of_bus_default_translate(__be32 *addr, u64 offset, int na)
86{ 86{
87 u64 a = of_read_number(addr, na); 87 u64 a = of_read_number(addr, na);
88 memset(addr, 0, na * 4); 88 memset(addr, 0, na * 4);
@@ -138,7 +138,7 @@ static unsigned int of_bus_pci_get_flags(const __be32 *addr)
138 return flags; 138 return flags;
139} 139}
140 140
141static u64 of_bus_pci_map(u32 *addr, const __be32 *range, int na, int ns, 141static u64 of_bus_pci_map(__be32 *addr, const __be32 *range, int na, int ns,
142 int pna) 142 int pna)
143{ 143{
144 u64 cp, s, da; 144 u64 cp, s, da;
@@ -165,7 +165,7 @@ static u64 of_bus_pci_map(u32 *addr, const __be32 *range, int na, int ns,
165 return da - cp; 165 return da - cp;
166} 166}
167 167
168static int of_bus_pci_translate(u32 *addr, u64 offset, int na) 168static int of_bus_pci_translate(__be32 *addr, u64 offset, int na)
169{ 169{
170 return of_bus_default_translate(addr + 1, offset, na - 1); 170 return of_bus_default_translate(addr + 1, offset, na - 1);
171} 171}
@@ -247,7 +247,7 @@ static void of_bus_isa_count_cells(struct device_node *child,
247 *sizec = 1; 247 *sizec = 1;
248} 248}
249 249
250static u64 of_bus_isa_map(u32 *addr, const __be32 *range, int na, int ns, 250static u64 of_bus_isa_map(__be32 *addr, const __be32 *range, int na, int ns,
251 int pna) 251 int pna)
252{ 252{
253 u64 cp, s, da; 253 u64 cp, s, da;
@@ -270,7 +270,7 @@ static u64 of_bus_isa_map(u32 *addr, const __be32 *range, int na, int ns,
270 return da - cp; 270 return da - cp;
271} 271}
272 272
273static int of_bus_isa_translate(u32 *addr, u64 offset, int na) 273static int of_bus_isa_translate(__be32 *addr, u64 offset, int na)
274{ 274{
275 return of_bus_default_translate(addr + 1, offset, na - 1); 275 return of_bus_default_translate(addr + 1, offset, na - 1);
276} 276}
@@ -338,7 +338,7 @@ static struct of_bus *of_match_bus(struct device_node *np)
338} 338}
339 339
340static int of_translate_one(struct device_node *parent, struct of_bus *bus, 340static int of_translate_one(struct device_node *parent, struct of_bus *bus,
341 struct of_bus *pbus, u32 *addr, 341 struct of_bus *pbus, __be32 *addr,
342 int na, int ns, int pna, const char *rprop) 342 int na, int ns, int pna, const char *rprop)
343{ 343{
344 const __be32 *ranges; 344 const __be32 *ranges;
@@ -409,12 +409,12 @@ static int of_translate_one(struct device_node *parent, struct of_bus *bus,
409 * that can be mapped to a cpu physical address). This is not really specified 409 * that can be mapped to a cpu physical address). This is not really specified
410 * that way, but this is traditionally the way IBM at least do things 410 * that way, but this is traditionally the way IBM at least do things
411 */ 411 */
412u64 __of_translate_address(struct device_node *dev, const __be32 *in_addr, 412static u64 __of_translate_address(struct device_node *dev,
413 const char *rprop) 413 const __be32 *in_addr, const char *rprop)
414{ 414{
415 struct device_node *parent = NULL; 415 struct device_node *parent = NULL;
416 struct of_bus *bus, *pbus; 416 struct of_bus *bus, *pbus;
417 u32 addr[OF_MAX_ADDR_CELLS]; 417 __be32 addr[OF_MAX_ADDR_CELLS];
418 int na, ns, pna, pns; 418 int na, ns, pna, pns;
419 u64 result = OF_BAD_ADDR; 419 u64 result = OF_BAD_ADDR;
420 420
diff --git a/drivers/of/irq.c b/drivers/of/irq.c
index a23ec777999..a3c1c5aae6a 100644
--- a/drivers/of/irq.c
+++ b/drivers/of/irq.c
@@ -192,11 +192,13 @@ int of_irq_map_raw(struct device_node *parent, const __be32 *intspec,
192 /* Compare specifiers */ 192 /* Compare specifiers */
193 match = 1; 193 match = 1;
194 for (i = 0; i < addrsize && match; ++i) { 194 for (i = 0; i < addrsize && match; ++i) {
195 u32 mask = imask ? imask[i] : 0xffffffffu; 195 __be32 mask = imask ? imask[i]
196 : cpu_to_be32(0xffffffffu);
196 match = ((addr[i] ^ imap[i]) & mask) == 0; 197 match = ((addr[i] ^ imap[i]) & mask) == 0;
197 } 198 }
198 for (; i < (addrsize + intsize) && match; ++i) { 199 for (; i < (addrsize + intsize) && match; ++i) {
199 u32 mask = imask ? imask[i] : 0xffffffffu; 200 __be32 mask = imask ? imask[i]
201 : cpu_to_be32(0xffffffffu);
200 match = 202 match =
201 ((intspec[i-addrsize] ^ imap[i]) & mask) == 0; 203 ((intspec[i-addrsize] ^ imap[i]) & mask) == 0;
202 } 204 }
@@ -465,7 +467,7 @@ void __init of_irq_init(const struct of_device_id *matches)
465 pr_debug("of_irq_init: init %s @ %p, parent %p\n", 467 pr_debug("of_irq_init: init %s @ %p, parent %p\n",
466 match->compatible, 468 match->compatible,
467 desc->dev, desc->interrupt_parent); 469 desc->dev, desc->interrupt_parent);
468 irq_init_cb = match->data; 470 irq_init_cb = (of_irq_init_cb_t)match->data;
469 ret = irq_init_cb(desc->dev, desc->interrupt_parent); 471 ret = irq_init_cb(desc->dev, desc->interrupt_parent);
470 if (ret) { 472 if (ret) {
471 kfree(desc); 473 kfree(desc);
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index 9bdeaf30b17..b80891b4381 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -76,7 +76,7 @@ void of_device_make_bus_id(struct device *dev)
76{ 76{
77 static atomic_t bus_no_reg_magic; 77 static atomic_t bus_no_reg_magic;
78 struct device_node *node = dev->of_node; 78 struct device_node *node = dev->of_node;
79 const u32 *reg; 79 const __be32 *reg;
80 u64 addr; 80 u64 addr;
81 const __be32 *addrp; 81 const __be32 *addrp;
82 int magic; 82 int magic;
diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c
index 6241fd05bd4..a543746fb35 100644
--- a/drivers/pci/bus.c
+++ b/drivers/pci/bus.c
@@ -320,10 +320,7 @@ void pci_walk_bus(struct pci_bus *top, int (*cb)(struct pci_dev *, void *),
320 } else 320 } else
321 next = dev->bus_list.next; 321 next = dev->bus_list.next;
322 322
323 /* Run device routines with the device locked */
324 device_lock(&dev->dev);
325 retval = cb(dev, userdata); 323 retval = cb(dev, userdata);
326 device_unlock(&dev->dev);
327 if (retval) 324 if (retval)
328 break; 325 break;
329 } 326 }
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index 94c6e2aa03d..6c94fc9489e 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -398,6 +398,8 @@ static void pci_device_shutdown(struct device *dev)
398 struct pci_dev *pci_dev = to_pci_dev(dev); 398 struct pci_dev *pci_dev = to_pci_dev(dev);
399 struct pci_driver *drv = pci_dev->driver; 399 struct pci_driver *drv = pci_dev->driver;
400 400
401 pm_runtime_resume(dev);
402
401 if (drv && drv->shutdown) 403 if (drv && drv->shutdown)
402 drv->shutdown(pci_dev); 404 drv->shutdown(pci_dev);
403 pci_msi_shutdown(pci_dev); 405 pci_msi_shutdown(pci_dev);
@@ -408,16 +410,6 @@ static void pci_device_shutdown(struct device *dev)
408 * continue to do DMA 410 * continue to do DMA
409 */ 411 */
410 pci_disable_device(pci_dev); 412 pci_disable_device(pci_dev);
411
412 /*
413 * Devices may be enabled to wake up by runtime PM, but they need not
414 * be supposed to wake up the system from its "power off" state (e.g.
415 * ACPI S5). Therefore disable wakeup for all devices that aren't
416 * supposed to wake up the system at this point. The state argument
417 * will be ignored by pci_enable_wake().
418 */
419 if (!device_may_wakeup(dev))
420 pci_enable_wake(pci_dev, PCI_UNKNOWN, false);
421} 413}
422 414
423#ifdef CONFIG_PM 415#ifdef CONFIG_PM
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 02d107b1528..f39378d9da1 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -458,40 +458,6 @@ boot_vga_show(struct device *dev, struct device_attribute *attr, char *buf)
458} 458}
459struct device_attribute vga_attr = __ATTR_RO(boot_vga); 459struct device_attribute vga_attr = __ATTR_RO(boot_vga);
460 460
461static void
462pci_config_pm_runtime_get(struct pci_dev *pdev)
463{
464 struct device *dev = &pdev->dev;
465 struct device *parent = dev->parent;
466
467 if (parent)
468 pm_runtime_get_sync(parent);
469 pm_runtime_get_noresume(dev);
470 /*
471 * pdev->current_state is set to PCI_D3cold during suspending,
472 * so wait until suspending completes
473 */
474 pm_runtime_barrier(dev);
475 /*
476 * Only need to resume devices in D3cold, because config
477 * registers are still accessible for devices suspended but
478 * not in D3cold.
479 */
480 if (pdev->current_state == PCI_D3cold)
481 pm_runtime_resume(dev);
482}
483
484static void
485pci_config_pm_runtime_put(struct pci_dev *pdev)
486{
487 struct device *dev = &pdev->dev;
488 struct device *parent = dev->parent;
489
490 pm_runtime_put(dev);
491 if (parent)
492 pm_runtime_put_sync(parent);
493}
494
495static ssize_t 461static ssize_t
496pci_read_config(struct file *filp, struct kobject *kobj, 462pci_read_config(struct file *filp, struct kobject *kobj,
497 struct bin_attribute *bin_attr, 463 struct bin_attribute *bin_attr,
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 54858838f09..aabf64798bd 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -1858,6 +1858,38 @@ bool pci_dev_run_wake(struct pci_dev *dev)
1858} 1858}
1859EXPORT_SYMBOL_GPL(pci_dev_run_wake); 1859EXPORT_SYMBOL_GPL(pci_dev_run_wake);
1860 1860
1861void pci_config_pm_runtime_get(struct pci_dev *pdev)
1862{
1863 struct device *dev = &pdev->dev;
1864 struct device *parent = dev->parent;
1865
1866 if (parent)
1867 pm_runtime_get_sync(parent);
1868 pm_runtime_get_noresume(dev);
1869 /*
1870 * pdev->current_state is set to PCI_D3cold during suspending,
1871 * so wait until suspending completes
1872 */
1873 pm_runtime_barrier(dev);
1874 /*
1875 * Only need to resume devices in D3cold, because config
1876 * registers are still accessible for devices suspended but
1877 * not in D3cold.
1878 */
1879 if (pdev->current_state == PCI_D3cold)
1880 pm_runtime_resume(dev);
1881}
1882
1883void pci_config_pm_runtime_put(struct pci_dev *pdev)
1884{
1885 struct device *dev = &pdev->dev;
1886 struct device *parent = dev->parent;
1887
1888 pm_runtime_put(dev);
1889 if (parent)
1890 pm_runtime_put_sync(parent);
1891}
1892
1861/** 1893/**
1862 * pci_pm_init - Initialize PM functions of given PCI device 1894 * pci_pm_init - Initialize PM functions of given PCI device
1863 * @dev: PCI device to handle. 1895 * @dev: PCI device to handle.
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index bacbcba69cf..fd92aab9904 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -72,6 +72,8 @@ extern void pci_disable_enabled_device(struct pci_dev *dev);
72extern int pci_finish_runtime_suspend(struct pci_dev *dev); 72extern int pci_finish_runtime_suspend(struct pci_dev *dev);
73extern int __pci_pme_wakeup(struct pci_dev *dev, void *ign); 73extern int __pci_pme_wakeup(struct pci_dev *dev, void *ign);
74extern void pci_wakeup_bus(struct pci_bus *bus); 74extern void pci_wakeup_bus(struct pci_bus *bus);
75extern void pci_config_pm_runtime_get(struct pci_dev *dev);
76extern void pci_config_pm_runtime_put(struct pci_dev *dev);
75extern void pci_pm_init(struct pci_dev *dev); 77extern void pci_pm_init(struct pci_dev *dev);
76extern void platform_pci_wakeup_init(struct pci_dev *dev); 78extern void platform_pci_wakeup_init(struct pci_dev *dev);
77extern void pci_allocate_cap_save_buffers(struct pci_dev *dev); 79extern void pci_allocate_cap_save_buffers(struct pci_dev *dev);
diff --git a/drivers/pci/pcie/aer/aerdrv_core.c b/drivers/pci/pcie/aer/aerdrv_core.c
index 06bad96af41..af4e31cd3a3 100644
--- a/drivers/pci/pcie/aer/aerdrv_core.c
+++ b/drivers/pci/pcie/aer/aerdrv_core.c
@@ -213,6 +213,7 @@ static int report_error_detected(struct pci_dev *dev, void *data)
213 struct aer_broadcast_data *result_data; 213 struct aer_broadcast_data *result_data;
214 result_data = (struct aer_broadcast_data *) data; 214 result_data = (struct aer_broadcast_data *) data;
215 215
216 device_lock(&dev->dev);
216 dev->error_state = result_data->state; 217 dev->error_state = result_data->state;
217 218
218 if (!dev->driver || 219 if (!dev->driver ||
@@ -231,12 +232,14 @@ static int report_error_detected(struct pci_dev *dev, void *data)
231 dev->driver ? 232 dev->driver ?
232 "no AER-aware driver" : "no driver"); 233 "no AER-aware driver" : "no driver");
233 } 234 }
234 return 0; 235 goto out;
235 } 236 }
236 237
237 err_handler = dev->driver->err_handler; 238 err_handler = dev->driver->err_handler;
238 vote = err_handler->error_detected(dev, result_data->state); 239 vote = err_handler->error_detected(dev, result_data->state);
239 result_data->result = merge_result(result_data->result, vote); 240 result_data->result = merge_result(result_data->result, vote);
241out:
242 device_unlock(&dev->dev);
240 return 0; 243 return 0;
241} 244}
242 245
@@ -247,14 +250,17 @@ static int report_mmio_enabled(struct pci_dev *dev, void *data)
247 struct aer_broadcast_data *result_data; 250 struct aer_broadcast_data *result_data;
248 result_data = (struct aer_broadcast_data *) data; 251 result_data = (struct aer_broadcast_data *) data;
249 252
253 device_lock(&dev->dev);
250 if (!dev->driver || 254 if (!dev->driver ||
251 !dev->driver->err_handler || 255 !dev->driver->err_handler ||
252 !dev->driver->err_handler->mmio_enabled) 256 !dev->driver->err_handler->mmio_enabled)
253 return 0; 257 goto out;
254 258
255 err_handler = dev->driver->err_handler; 259 err_handler = dev->driver->err_handler;
256 vote = err_handler->mmio_enabled(dev); 260 vote = err_handler->mmio_enabled(dev);
257 result_data->result = merge_result(result_data->result, vote); 261 result_data->result = merge_result(result_data->result, vote);
262out:
263 device_unlock(&dev->dev);
258 return 0; 264 return 0;
259} 265}
260 266
@@ -265,14 +271,17 @@ static int report_slot_reset(struct pci_dev *dev, void *data)
265 struct aer_broadcast_data *result_data; 271 struct aer_broadcast_data *result_data;
266 result_data = (struct aer_broadcast_data *) data; 272 result_data = (struct aer_broadcast_data *) data;
267 273
274 device_lock(&dev->dev);
268 if (!dev->driver || 275 if (!dev->driver ||
269 !dev->driver->err_handler || 276 !dev->driver->err_handler ||
270 !dev->driver->err_handler->slot_reset) 277 !dev->driver->err_handler->slot_reset)
271 return 0; 278 goto out;
272 279
273 err_handler = dev->driver->err_handler; 280 err_handler = dev->driver->err_handler;
274 vote = err_handler->slot_reset(dev); 281 vote = err_handler->slot_reset(dev);
275 result_data->result = merge_result(result_data->result, vote); 282 result_data->result = merge_result(result_data->result, vote);
283out:
284 device_unlock(&dev->dev);
276 return 0; 285 return 0;
277} 286}
278 287
@@ -280,15 +289,18 @@ static int report_resume(struct pci_dev *dev, void *data)
280{ 289{
281 const struct pci_error_handlers *err_handler; 290 const struct pci_error_handlers *err_handler;
282 291
292 device_lock(&dev->dev);
283 dev->error_state = pci_channel_io_normal; 293 dev->error_state = pci_channel_io_normal;
284 294
285 if (!dev->driver || 295 if (!dev->driver ||
286 !dev->driver->err_handler || 296 !dev->driver->err_handler ||
287 !dev->driver->err_handler->resume) 297 !dev->driver->err_handler->resume)
288 return 0; 298 goto out;
289 299
290 err_handler = dev->driver->err_handler; 300 err_handler = dev->driver->err_handler;
291 err_handler->resume(dev); 301 err_handler->resume(dev);
302out:
303 device_unlock(&dev->dev);
292 return 0; 304 return 0;
293} 305}
294 306
diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c
index d03a7a39b2d..ed129b41462 100644
--- a/drivers/pci/pcie/portdrv_core.c
+++ b/drivers/pci/pcie/portdrv_core.c
@@ -272,7 +272,8 @@ static int get_port_device_capability(struct pci_dev *dev)
272 } 272 }
273 273
274 /* Hot-Plug Capable */ 274 /* Hot-Plug Capable */
275 if (cap_mask & PCIE_PORT_SERVICE_HP) { 275 if ((cap_mask & PCIE_PORT_SERVICE_HP) &&
276 dev->pcie_flags_reg & PCI_EXP_FLAGS_SLOT) {
276 pcie_capability_read_dword(dev, PCI_EXP_SLTCAP, &reg32); 277 pcie_capability_read_dword(dev, PCI_EXP_SLTCAP, &reg32);
277 if (reg32 & PCI_EXP_SLTCAP_HPC) { 278 if (reg32 & PCI_EXP_SLTCAP_HPC) {
278 services |= PCIE_PORT_SERVICE_HP; 279 services |= PCIE_PORT_SERVICE_HP;
diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
index eb907a8faf2..9b8505ccc56 100644
--- a/drivers/pci/proc.c
+++ b/drivers/pci/proc.c
@@ -76,6 +76,8 @@ proc_bus_pci_read(struct file *file, char __user *buf, size_t nbytes, loff_t *pp
76 if (!access_ok(VERIFY_WRITE, buf, cnt)) 76 if (!access_ok(VERIFY_WRITE, buf, cnt))
77 return -EINVAL; 77 return -EINVAL;
78 78
79 pci_config_pm_runtime_get(dev);
80
79 if ((pos & 1) && cnt) { 81 if ((pos & 1) && cnt) {
80 unsigned char val; 82 unsigned char val;
81 pci_user_read_config_byte(dev, pos, &val); 83 pci_user_read_config_byte(dev, pos, &val);
@@ -121,6 +123,8 @@ proc_bus_pci_read(struct file *file, char __user *buf, size_t nbytes, loff_t *pp
121 cnt--; 123 cnt--;
122 } 124 }
123 125
126 pci_config_pm_runtime_put(dev);
127
124 *ppos = pos; 128 *ppos = pos;
125 return nbytes; 129 return nbytes;
126} 130}
@@ -146,6 +150,8 @@ proc_bus_pci_write(struct file *file, const char __user *buf, size_t nbytes, lof
146 if (!access_ok(VERIFY_READ, buf, cnt)) 150 if (!access_ok(VERIFY_READ, buf, cnt))
147 return -EINVAL; 151 return -EINVAL;
148 152
153 pci_config_pm_runtime_get(dev);
154
149 if ((pos & 1) && cnt) { 155 if ((pos & 1) && cnt) {
150 unsigned char val; 156 unsigned char val;
151 __get_user(val, buf); 157 __get_user(val, buf);
@@ -191,6 +197,8 @@ proc_bus_pci_write(struct file *file, const char __user *buf, size_t nbytes, lof
191 cnt--; 197 cnt--;
192 } 198 }
193 199
200 pci_config_pm_runtime_put(dev);
201
194 *ppos = pos; 202 *ppos = pos;
195 i_size_write(ino, dp->size); 203 i_size_write(ino, dp->size);
196 return nbytes; 204 return nbytes;
diff --git a/drivers/pcmcia/pxa2xx_sharpsl.c b/drivers/pcmcia/pxa2xx_sharpsl.c
index b066273b6b4..7dd879ce514 100644
--- a/drivers/pcmcia/pxa2xx_sharpsl.c
+++ b/drivers/pcmcia/pxa2xx_sharpsl.c
@@ -194,7 +194,7 @@ static void sharpsl_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
194 sharpsl_pcmcia_init_reset(skt); 194 sharpsl_pcmcia_init_reset(skt);
195} 195}
196 196
197static struct pcmcia_low_level sharpsl_pcmcia_ops __initdata = { 197static struct pcmcia_low_level sharpsl_pcmcia_ops = {
198 .owner = THIS_MODULE, 198 .owner = THIS_MODULE,
199 .hw_init = sharpsl_pcmcia_hw_init, 199 .hw_init = sharpsl_pcmcia_hw_init,
200 .socket_state = sharpsl_pcmcia_socket_state, 200 .socket_state = sharpsl_pcmcia_socket_state,
diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig
index 7bf914df6e9..aeecf0f72ca 100644
--- a/drivers/pinctrl/Kconfig
+++ b/drivers/pinctrl/Kconfig
@@ -178,12 +178,14 @@ config PINCTRL_COH901
178 ports of 8 GPIO pins each. 178 ports of 8 GPIO pins each.
179 179
180config PINCTRL_SAMSUNG 180config PINCTRL_SAMSUNG
181 bool "Samsung pinctrl driver" 181 bool
182 depends on OF && GPIOLIB
182 select PINMUX 183 select PINMUX
183 select PINCONF 184 select PINCONF
184 185
185config PINCTRL_EXYNOS4 186config PINCTRL_EXYNOS4
186 bool "Pinctrl driver data for Exynos4 SoC" 187 bool "Pinctrl driver data for Exynos4 SoC"
188 depends on OF && GPIOLIB
187 select PINCTRL_SAMSUNG 189 select PINCTRL_SAMSUNG
188 190
189config PINCTRL_MVEBU 191config PINCTRL_MVEBU
diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
index 0f1ec9e8ff1..2e39c04fc16 100644
--- a/drivers/pinctrl/core.c
+++ b/drivers/pinctrl/core.c
@@ -1061,8 +1061,10 @@ static int pinctrl_groups_show(struct seq_file *s, void *what)
1061 seq_printf(s, "group: %s\n", gname); 1061 seq_printf(s, "group: %s\n", gname);
1062 for (i = 0; i < num_pins; i++) { 1062 for (i = 0; i < num_pins; i++) {
1063 pname = pin_get_name(pctldev, pins[i]); 1063 pname = pin_get_name(pctldev, pins[i]);
1064 if (WARN_ON(!pname)) 1064 if (WARN_ON(!pname)) {
1065 mutex_unlock(&pinctrl_mutex);
1065 return -EINVAL; 1066 return -EINVAL;
1067 }
1066 seq_printf(s, "pin %d (%s)\n", pins[i], pname); 1068 seq_printf(s, "pin %d (%s)\n", pins[i], pname);
1067 } 1069 }
1068 seq_puts(s, "\n"); 1070 seq_puts(s, "\n");
diff --git a/drivers/pinctrl/pinconf.c b/drivers/pinctrl/pinconf.c
index 43f474cdc11..baee2cc46a1 100644
--- a/drivers/pinctrl/pinconf.c
+++ b/drivers/pinctrl/pinconf.c
@@ -537,8 +537,6 @@ static int pinconf_groups_show(struct seq_file *s, void *what)
537 seq_puts(s, "Pin config settings per pin group\n"); 537 seq_puts(s, "Pin config settings per pin group\n");
538 seq_puts(s, "Format: group (name): configs\n"); 538 seq_puts(s, "Format: group (name): configs\n");
539 539
540 mutex_lock(&pinctrl_mutex);
541
542 while (selector < ngroups) { 540 while (selector < ngroups) {
543 const char *gname = pctlops->get_group_name(pctldev, selector); 541 const char *gname = pctlops->get_group_name(pctldev, selector);
544 542
@@ -549,8 +547,6 @@ static int pinconf_groups_show(struct seq_file *s, void *what)
549 selector++; 547 selector++;
550 } 548 }
551 549
552 mutex_unlock(&pinctrl_mutex);
553
554 return 0; 550 return 0;
555} 551}
556 552
diff --git a/drivers/pinctrl/pinctrl-bcm2835.c b/drivers/pinctrl/pinctrl-bcm2835.c
index a4adee633fa..7e9be18ec2d 100644
--- a/drivers/pinctrl/pinctrl-bcm2835.c
+++ b/drivers/pinctrl/pinctrl-bcm2835.c
@@ -29,7 +29,6 @@
29#include <linux/irq.h> 29#include <linux/irq.h>
30#include <linux/irqdesc.h> 30#include <linux/irqdesc.h>
31#include <linux/irqdomain.h> 31#include <linux/irqdomain.h>
32#include <linux/irq.h>
33#include <linux/module.h> 32#include <linux/module.h>
34#include <linux/of_address.h> 33#include <linux/of_address.h>
35#include <linux/of.h> 34#include <linux/of.h>
@@ -960,7 +959,7 @@ static int __devinit bcm2835_pinctrl_probe(struct platform_device *pdev)
960 return err; 959 return err;
961 } 960 }
962 961
963 pc->base = devm_request_and_ioremap(&pdev->dev, &iomem); 962 pc->base = devm_request_and_ioremap(dev, &iomem);
964 if (!pc->base) 963 if (!pc->base)
965 return -EADDRNOTAVAIL; 964 return -EADDRNOTAVAIL;
966 965
@@ -1032,7 +1031,7 @@ static int __devinit bcm2835_pinctrl_probe(struct platform_device *pdev)
1032 pc->pctl_dev = pinctrl_register(&bcm2835_pinctrl_desc, dev, pc); 1031 pc->pctl_dev = pinctrl_register(&bcm2835_pinctrl_desc, dev, pc);
1033 if (!pc->pctl_dev) { 1032 if (!pc->pctl_dev) {
1034 gpiochip_remove(&pc->gpio_chip); 1033 gpiochip_remove(&pc->gpio_chip);
1035 return PTR_ERR(pc->pctl_dev); 1034 return -EINVAL;
1036 } 1035 }
1037 1036
1038 pc->gpio_range = bcm2835_pinctrl_gpio_range; 1037 pc->gpio_range = bcm2835_pinctrl_gpio_range;
diff --git a/drivers/pinctrl/pinctrl-nomadik.c b/drivers/pinctrl/pinctrl-nomadik.c
index fec9c30133d..cf82d9ce4de 100644
--- a/drivers/pinctrl/pinctrl-nomadik.c
+++ b/drivers/pinctrl/pinctrl-nomadik.c
@@ -30,7 +30,20 @@
30#include <linux/pinctrl/pinconf.h> 30#include <linux/pinctrl/pinconf.h>
31/* Since we request GPIOs from ourself */ 31/* Since we request GPIOs from ourself */
32#include <linux/pinctrl/consumer.h> 32#include <linux/pinctrl/consumer.h>
33/*
34 * For the U8500 archs, use the PRCMU register interface, for the older
35 * Nomadik, provide some stubs. The functions using these will only be
36 * called on the U8500 series.
37 */
38#ifdef CONFIG_ARCH_U8500
33#include <linux/mfd/dbx500-prcmu.h> 39#include <linux/mfd/dbx500-prcmu.h>
40#else
41static inline u32 prcmu_read(unsigned int reg) {
42 return 0;
43}
44static inline void prcmu_write(unsigned int reg, u32 value) {}
45static inline void prcmu_write_masked(unsigned int reg, u32 mask, u32 value) {}
46#endif
34 47
35#include <asm/mach/irq.h> 48#include <asm/mach/irq.h>
36 49
@@ -1043,7 +1056,7 @@ static int nmk_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
1043 struct nmk_gpio_chip *nmk_chip = 1056 struct nmk_gpio_chip *nmk_chip =
1044 container_of(chip, struct nmk_gpio_chip, chip); 1057 container_of(chip, struct nmk_gpio_chip, chip);
1045 1058
1046 return irq_find_mapping(nmk_chip->domain, offset); 1059 return irq_create_mapping(nmk_chip->domain, offset);
1047} 1060}
1048 1061
1049#ifdef CONFIG_DEBUG_FS 1062#ifdef CONFIG_DEBUG_FS
@@ -1268,6 +1281,7 @@ static int __devinit nmk_gpio_probe(struct platform_device *dev)
1268 struct clk *clk; 1281 struct clk *clk;
1269 int secondary_irq; 1282 int secondary_irq;
1270 void __iomem *base; 1283 void __iomem *base;
1284 int irq_start = 0;
1271 int irq; 1285 int irq;
1272 int ret; 1286 int ret;
1273 1287
@@ -1371,19 +1385,11 @@ static int __devinit nmk_gpio_probe(struct platform_device *dev)
1371 1385
1372 platform_set_drvdata(dev, nmk_chip); 1386 platform_set_drvdata(dev, nmk_chip);
1373 1387
1374 if (np) { 1388 if (!np)
1375 /* The DT case will just grab a set of IRQ numbers */
1376 nmk_chip->domain = irq_domain_add_linear(np, NMK_GPIO_PER_CHIP,
1377 &nmk_gpio_irq_simple_ops, nmk_chip);
1378 } else {
1379 /* Non-DT legacy mode, use hardwired IRQ numbers */
1380 int irq_start;
1381
1382 irq_start = NOMADIK_GPIO_TO_IRQ(pdata->first_gpio); 1389 irq_start = NOMADIK_GPIO_TO_IRQ(pdata->first_gpio);
1383 nmk_chip->domain = irq_domain_add_simple(NULL, 1390 nmk_chip->domain = irq_domain_add_simple(np,
1384 NMK_GPIO_PER_CHIP, irq_start, 1391 NMK_GPIO_PER_CHIP, irq_start,
1385 &nmk_gpio_irq_simple_ops, nmk_chip); 1392 &nmk_gpio_irq_simple_ops, nmk_chip);
1386 }
1387 if (!nmk_chip->domain) { 1393 if (!nmk_chip->domain) {
1388 dev_err(&dev->dev, "failed to create irqdomain\n"); 1394 dev_err(&dev->dev, "failed to create irqdomain\n");
1389 ret = -ENOSYS; 1395 ret = -ENOSYS;
diff --git a/drivers/pinctrl/pinctrl-samsung.c b/drivers/pinctrl/pinctrl-samsung.c
index dd108a94acf..861cd5f04d5 100644
--- a/drivers/pinctrl/pinctrl-samsung.c
+++ b/drivers/pinctrl/pinctrl-samsung.c
@@ -513,7 +513,7 @@ static int samsung_gpio_direction_output(struct gpio_chip *gc, unsigned offset,
513 * Parse the pin names listed in the 'samsung,pins' property and convert it 513 * Parse the pin names listed in the 'samsung,pins' property and convert it
514 * into a list of gpio numbers are create a pin group from it. 514 * into a list of gpio numbers are create a pin group from it.
515 */ 515 */
516static int __init samsung_pinctrl_parse_dt_pins(struct platform_device *pdev, 516static int __devinit samsung_pinctrl_parse_dt_pins(struct platform_device *pdev,
517 struct device_node *cfg_np, struct pinctrl_desc *pctl, 517 struct device_node *cfg_np, struct pinctrl_desc *pctl,
518 unsigned int **pin_list, unsigned int *npins) 518 unsigned int **pin_list, unsigned int *npins)
519{ 519{
@@ -560,7 +560,7 @@ static int __init samsung_pinctrl_parse_dt_pins(struct platform_device *pdev,
560 * from device node of the pin-controller. A pin group is formed with all 560 * from device node of the pin-controller. A pin group is formed with all
561 * the pins listed in the "samsung,pins" property. 561 * the pins listed in the "samsung,pins" property.
562 */ 562 */
563static int __init samsung_pinctrl_parse_dt(struct platform_device *pdev, 563static int __devinit samsung_pinctrl_parse_dt(struct platform_device *pdev,
564 struct samsung_pinctrl_drv_data *drvdata) 564 struct samsung_pinctrl_drv_data *drvdata)
565{ 565{
566 struct device *dev = &pdev->dev; 566 struct device *dev = &pdev->dev;
@@ -655,7 +655,7 @@ static int __init samsung_pinctrl_parse_dt(struct platform_device *pdev,
655} 655}
656 656
657/* register the pinctrl interface with the pinctrl subsystem */ 657/* register the pinctrl interface with the pinctrl subsystem */
658static int __init samsung_pinctrl_register(struct platform_device *pdev, 658static int __devinit samsung_pinctrl_register(struct platform_device *pdev,
659 struct samsung_pinctrl_drv_data *drvdata) 659 struct samsung_pinctrl_drv_data *drvdata)
660{ 660{
661 struct pinctrl_desc *ctrldesc = &drvdata->pctl; 661 struct pinctrl_desc *ctrldesc = &drvdata->pctl;
@@ -729,7 +729,7 @@ static int __init samsung_pinctrl_register(struct platform_device *pdev,
729} 729}
730 730
731/* register the gpiolib interface with the gpiolib subsystem */ 731/* register the gpiolib interface with the gpiolib subsystem */
732static int __init samsung_gpiolib_register(struct platform_device *pdev, 732static int __devinit samsung_gpiolib_register(struct platform_device *pdev,
733 struct samsung_pinctrl_drv_data *drvdata) 733 struct samsung_pinctrl_drv_data *drvdata)
734{ 734{
735 struct gpio_chip *gc; 735 struct gpio_chip *gc;
@@ -762,7 +762,7 @@ static int __init samsung_gpiolib_register(struct platform_device *pdev,
762} 762}
763 763
764/* unregister the gpiolib interface with the gpiolib subsystem */ 764/* unregister the gpiolib interface with the gpiolib subsystem */
765static int __init samsung_gpiolib_unregister(struct platform_device *pdev, 765static int __devinit samsung_gpiolib_unregister(struct platform_device *pdev,
766 struct samsung_pinctrl_drv_data *drvdata) 766 struct samsung_pinctrl_drv_data *drvdata)
767{ 767{
768 int ret = gpiochip_remove(drvdata->gc); 768 int ret = gpiochip_remove(drvdata->gc);
diff --git a/drivers/pinctrl/pinctrl-sirf.c b/drivers/pinctrl/pinctrl-sirf.c
index 675497c1514..9ecacf3d0a7 100644
--- a/drivers/pinctrl/pinctrl-sirf.c
+++ b/drivers/pinctrl/pinctrl-sirf.c
@@ -1323,41 +1323,6 @@ static inline struct sirfsoc_gpio_bank *sirfsoc_gpio_to_bank(unsigned int gpio)
1323 return &sgpio_bank[gpio / SIRFSOC_GPIO_BANK_SIZE]; 1323 return &sgpio_bank[gpio / SIRFSOC_GPIO_BANK_SIZE];
1324} 1324}
1325 1325
1326void sirfsoc_gpio_set_pull(unsigned gpio, unsigned mode)
1327{
1328 struct sirfsoc_gpio_bank *bank = sirfsoc_gpio_to_bank(gpio);
1329 int idx = sirfsoc_gpio_to_offset(gpio);
1330 u32 val, offset;
1331 unsigned long flags;
1332
1333 offset = SIRFSOC_GPIO_CTRL(bank->id, idx);
1334
1335 spin_lock_irqsave(&sgpio_lock, flags);
1336
1337 val = readl(bank->chip.regs + offset);
1338
1339 switch (mode) {
1340 case SIRFSOC_GPIO_PULL_NONE:
1341 val &= ~SIRFSOC_GPIO_CTL_PULL_MASK;
1342 break;
1343 case SIRFSOC_GPIO_PULL_UP:
1344 val |= SIRFSOC_GPIO_CTL_PULL_MASK;
1345 val |= SIRFSOC_GPIO_CTL_PULL_HIGH;
1346 break;
1347 case SIRFSOC_GPIO_PULL_DOWN:
1348 val |= SIRFSOC_GPIO_CTL_PULL_MASK;
1349 val &= ~SIRFSOC_GPIO_CTL_PULL_HIGH;
1350 break;
1351 default:
1352 break;
1353 }
1354
1355 writel(val, bank->chip.regs + offset);
1356
1357 spin_unlock_irqrestore(&sgpio_lock, flags);
1358}
1359EXPORT_SYMBOL(sirfsoc_gpio_set_pull);
1360
1361static inline struct sirfsoc_gpio_bank *sirfsoc_irqchip_to_bank(struct gpio_chip *chip) 1326static inline struct sirfsoc_gpio_bank *sirfsoc_irqchip_to_bank(struct gpio_chip *chip)
1362{ 1327{
1363 return container_of(to_of_mm_gpio_chip(chip), struct sirfsoc_gpio_bank, chip); 1328 return container_of(to_of_mm_gpio_chip(chip), struct sirfsoc_gpio_bank, chip);
diff --git a/drivers/pinctrl/pinctrl-tegra.c b/drivers/pinctrl/pinctrl-tegra.c
index 729b686c3ad..7da0b371fd6 100644
--- a/drivers/pinctrl/pinctrl-tegra.c
+++ b/drivers/pinctrl/pinctrl-tegra.c
@@ -464,7 +464,7 @@ static int tegra_pinconf_reg(struct tegra_pmx *pmx,
464 *bank = g->drv_bank; 464 *bank = g->drv_bank;
465 *reg = g->drv_reg; 465 *reg = g->drv_reg;
466 *bit = g->lpmd_bit; 466 *bit = g->lpmd_bit;
467 *width = 1; 467 *width = 2;
468 break; 468 break;
469 case TEGRA_PINCONF_PARAM_DRIVE_DOWN_STRENGTH: 469 case TEGRA_PINCONF_PARAM_DRIVE_DOWN_STRENGTH:
470 *bank = g->drv_bank; 470 *bank = g->drv_bank;
diff --git a/drivers/pinctrl/pinctrl-tegra30.c b/drivers/pinctrl/pinctrl-tegra30.c
index 0386fdf0da1..7894f14c705 100644
--- a/drivers/pinctrl/pinctrl-tegra30.c
+++ b/drivers/pinctrl/pinctrl-tegra30.c
@@ -3345,10 +3345,10 @@ static const struct tegra_function tegra30_functions[] = {
3345 FUNCTION(vi_alt3), 3345 FUNCTION(vi_alt3),
3346}; 3346};
3347 3347
3348#define MUXCTL_REG_A 0x3000 3348#define DRV_PINGROUP_REG_A 0x868 /* bank 0 */
3349#define PINGROUP_REG_A 0x868 3349#define PINGROUP_REG_A 0x3000 /* bank 1 */
3350 3350
3351#define PINGROUP_REG_Y(r) ((r) - MUXCTL_REG_A) 3351#define PINGROUP_REG_Y(r) ((r) - PINGROUP_REG_A)
3352#define PINGROUP_REG_N(r) -1 3352#define PINGROUP_REG_N(r) -1
3353 3353
3354#define PINGROUP(pg_name, f0, f1, f2, f3, f_safe, r, od, ior) \ 3354#define PINGROUP(pg_name, f0, f1, f2, f3, f_safe, r, od, ior) \
@@ -3364,25 +3364,25 @@ static const struct tegra_function tegra30_functions[] = {
3364 }, \ 3364 }, \
3365 .func_safe = TEGRA_MUX_ ## f_safe, \ 3365 .func_safe = TEGRA_MUX_ ## f_safe, \
3366 .mux_reg = PINGROUP_REG_Y(r), \ 3366 .mux_reg = PINGROUP_REG_Y(r), \
3367 .mux_bank = 0, \ 3367 .mux_bank = 1, \
3368 .mux_bit = 0, \ 3368 .mux_bit = 0, \
3369 .pupd_reg = PINGROUP_REG_Y(r), \ 3369 .pupd_reg = PINGROUP_REG_Y(r), \
3370 .pupd_bank = 0, \ 3370 .pupd_bank = 1, \
3371 .pupd_bit = 2, \ 3371 .pupd_bit = 2, \
3372 .tri_reg = PINGROUP_REG_Y(r), \ 3372 .tri_reg = PINGROUP_REG_Y(r), \
3373 .tri_bank = 0, \ 3373 .tri_bank = 1, \
3374 .tri_bit = 4, \ 3374 .tri_bit = 4, \
3375 .einput_reg = PINGROUP_REG_Y(r), \ 3375 .einput_reg = PINGROUP_REG_Y(r), \
3376 .einput_bank = 0, \ 3376 .einput_bank = 1, \
3377 .einput_bit = 5, \ 3377 .einput_bit = 5, \
3378 .odrain_reg = PINGROUP_REG_##od(r), \ 3378 .odrain_reg = PINGROUP_REG_##od(r), \
3379 .odrain_bank = 0, \ 3379 .odrain_bank = 1, \
3380 .odrain_bit = 6, \ 3380 .odrain_bit = 6, \
3381 .lock_reg = PINGROUP_REG_Y(r), \ 3381 .lock_reg = PINGROUP_REG_Y(r), \
3382 .lock_bank = 0, \ 3382 .lock_bank = 1, \
3383 .lock_bit = 7, \ 3383 .lock_bit = 7, \
3384 .ioreset_reg = PINGROUP_REG_##ior(r), \ 3384 .ioreset_reg = PINGROUP_REG_##ior(r), \
3385 .ioreset_bank = 0, \ 3385 .ioreset_bank = 1, \
3386 .ioreset_bit = 8, \ 3386 .ioreset_bit = 8, \
3387 .drv_reg = -1, \ 3387 .drv_reg = -1, \
3388 } 3388 }
@@ -3401,8 +3401,8 @@ static const struct tegra_function tegra30_functions[] = {
3401 .odrain_reg = -1, \ 3401 .odrain_reg = -1, \
3402 .lock_reg = -1, \ 3402 .lock_reg = -1, \
3403 .ioreset_reg = -1, \ 3403 .ioreset_reg = -1, \
3404 .drv_reg = ((r) - PINGROUP_REG_A), \ 3404 .drv_reg = ((r) - DRV_PINGROUP_REG_A), \
3405 .drv_bank = 1, \ 3405 .drv_bank = 0, \
3406 .hsm_bit = hsm_b, \ 3406 .hsm_bit = hsm_b, \
3407 .schmitt_bit = schmitt_b, \ 3407 .schmitt_bit = schmitt_b, \
3408 .lpmd_bit = lpmd_b, \ 3408 .lpmd_bit = lpmd_b, \
diff --git a/drivers/pinctrl/pinctrl-xway.c b/drivers/pinctrl/pinctrl-xway.c
index f8d917d40c9..b9bcaec6622 100644
--- a/drivers/pinctrl/pinctrl-xway.c
+++ b/drivers/pinctrl/pinctrl-xway.c
@@ -17,8 +17,6 @@
17#include <linux/ioport.h> 17#include <linux/ioport.h>
18#include <linux/io.h> 18#include <linux/io.h>
19#include <linux/device.h> 19#include <linux/device.h>
20#include <linux/module.h>
21#include <linux/io.h>
22#include <linux/platform_device.h> 20#include <linux/platform_device.h>
23 21
24#include "pinctrl-lantiq.h" 22#include "pinctrl-lantiq.h"
diff --git a/drivers/pinctrl/spear/pinctrl-spear.c b/drivers/pinctrl/spear/pinctrl-spear.c
index 5d4f44f462f..b1fd6ee33c6 100644
--- a/drivers/pinctrl/spear/pinctrl-spear.c
+++ b/drivers/pinctrl/spear/pinctrl-spear.c
@@ -244,7 +244,7 @@ static int spear_pinctrl_endisable(struct pinctrl_dev *pctldev,
244 else 244 else
245 temp = ~muxreg->val; 245 temp = ~muxreg->val;
246 246
247 val |= temp; 247 val |= muxreg->mask & temp;
248 pmx_writel(pmx, val, muxreg->reg); 248 pmx_writel(pmx, val, muxreg->reg);
249 } 249 }
250 } 250 }
diff --git a/drivers/pinctrl/spear/pinctrl-spear1310.c b/drivers/pinctrl/spear/pinctrl-spear1310.c
index d6cca8c81b9..0436fc7895d 100644
--- a/drivers/pinctrl/spear/pinctrl-spear1310.c
+++ b/drivers/pinctrl/spear/pinctrl-spear1310.c
@@ -25,8 +25,8 @@ static const struct pinctrl_pin_desc spear1310_pins[] = {
25}; 25};
26 26
27/* registers */ 27/* registers */
28#define PERIP_CFG 0x32C 28#define PERIP_CFG 0x3B0
29 #define MCIF_SEL_SHIFT 3 29 #define MCIF_SEL_SHIFT 5
30 #define MCIF_SEL_SD (0x1 << MCIF_SEL_SHIFT) 30 #define MCIF_SEL_SD (0x1 << MCIF_SEL_SHIFT)
31 #define MCIF_SEL_CF (0x2 << MCIF_SEL_SHIFT) 31 #define MCIF_SEL_CF (0x2 << MCIF_SEL_SHIFT)
32 #define MCIF_SEL_XD (0x3 << MCIF_SEL_SHIFT) 32 #define MCIF_SEL_XD (0x3 << MCIF_SEL_SHIFT)
@@ -164,6 +164,10 @@ static const struct pinctrl_pin_desc spear1310_pins[] = {
164 #define PMX_SSP0_CS0_MASK (1 << 29) 164 #define PMX_SSP0_CS0_MASK (1 << 29)
165 #define PMX_SSP0_CS1_2_MASK (1 << 30) 165 #define PMX_SSP0_CS1_2_MASK (1 << 30)
166 166
167#define PAD_DIRECTION_SEL_0 0x65C
168#define PAD_DIRECTION_SEL_1 0x660
169#define PAD_DIRECTION_SEL_2 0x664
170
167/* combined macros */ 171/* combined macros */
168#define PMX_GMII_MASK (PMX_GMIICLK_MASK | \ 172#define PMX_GMII_MASK (PMX_GMIICLK_MASK | \
169 PMX_GMIICOL_CRS_XFERER_MIITXCLK_MASK | \ 173 PMX_GMIICOL_CRS_XFERER_MIITXCLK_MASK | \
@@ -237,6 +241,10 @@ static struct spear_muxreg i2c0_muxreg[] = {
237 .reg = PAD_FUNCTION_EN_0, 241 .reg = PAD_FUNCTION_EN_0,
238 .mask = PMX_I2C0_MASK, 242 .mask = PMX_I2C0_MASK,
239 .val = PMX_I2C0_MASK, 243 .val = PMX_I2C0_MASK,
244 }, {
245 .reg = PAD_DIRECTION_SEL_0,
246 .mask = PMX_I2C0_MASK,
247 .val = PMX_I2C0_MASK,
240 }, 248 },
241}; 249};
242 250
@@ -269,6 +277,10 @@ static struct spear_muxreg ssp0_muxreg[] = {
269 .reg = PAD_FUNCTION_EN_0, 277 .reg = PAD_FUNCTION_EN_0,
270 .mask = PMX_SSP0_MASK, 278 .mask = PMX_SSP0_MASK,
271 .val = PMX_SSP0_MASK, 279 .val = PMX_SSP0_MASK,
280 }, {
281 .reg = PAD_DIRECTION_SEL_0,
282 .mask = PMX_SSP0_MASK,
283 .val = PMX_SSP0_MASK,
272 }, 284 },
273}; 285};
274 286
@@ -294,6 +306,10 @@ static struct spear_muxreg ssp0_cs0_muxreg[] = {
294 .reg = PAD_FUNCTION_EN_2, 306 .reg = PAD_FUNCTION_EN_2,
295 .mask = PMX_SSP0_CS0_MASK, 307 .mask = PMX_SSP0_CS0_MASK,
296 .val = PMX_SSP0_CS0_MASK, 308 .val = PMX_SSP0_CS0_MASK,
309 }, {
310 .reg = PAD_DIRECTION_SEL_2,
311 .mask = PMX_SSP0_CS0_MASK,
312 .val = PMX_SSP0_CS0_MASK,
297 }, 313 },
298}; 314};
299 315
@@ -319,6 +335,10 @@ static struct spear_muxreg ssp0_cs1_2_muxreg[] = {
319 .reg = PAD_FUNCTION_EN_2, 335 .reg = PAD_FUNCTION_EN_2,
320 .mask = PMX_SSP0_CS1_2_MASK, 336 .mask = PMX_SSP0_CS1_2_MASK,
321 .val = PMX_SSP0_CS1_2_MASK, 337 .val = PMX_SSP0_CS1_2_MASK,
338 }, {
339 .reg = PAD_DIRECTION_SEL_2,
340 .mask = PMX_SSP0_CS1_2_MASK,
341 .val = PMX_SSP0_CS1_2_MASK,
322 }, 342 },
323}; 343};
324 344
@@ -352,6 +372,10 @@ static struct spear_muxreg i2s0_muxreg[] = {
352 .reg = PAD_FUNCTION_EN_0, 372 .reg = PAD_FUNCTION_EN_0,
353 .mask = PMX_I2S0_MASK, 373 .mask = PMX_I2S0_MASK,
354 .val = PMX_I2S0_MASK, 374 .val = PMX_I2S0_MASK,
375 }, {
376 .reg = PAD_DIRECTION_SEL_0,
377 .mask = PMX_I2S0_MASK,
378 .val = PMX_I2S0_MASK,
355 }, 379 },
356}; 380};
357 381
@@ -384,6 +408,10 @@ static struct spear_muxreg i2s1_muxreg[] = {
384 .reg = PAD_FUNCTION_EN_1, 408 .reg = PAD_FUNCTION_EN_1,
385 .mask = PMX_I2S1_MASK, 409 .mask = PMX_I2S1_MASK,
386 .val = PMX_I2S1_MASK, 410 .val = PMX_I2S1_MASK,
411 }, {
412 .reg = PAD_DIRECTION_SEL_1,
413 .mask = PMX_I2S1_MASK,
414 .val = PMX_I2S1_MASK,
387 }, 415 },
388}; 416};
389 417
@@ -418,6 +446,10 @@ static struct spear_muxreg clcd_muxreg[] = {
418 .reg = PAD_FUNCTION_EN_0, 446 .reg = PAD_FUNCTION_EN_0,
419 .mask = PMX_CLCD1_MASK, 447 .mask = PMX_CLCD1_MASK,
420 .val = PMX_CLCD1_MASK, 448 .val = PMX_CLCD1_MASK,
449 }, {
450 .reg = PAD_DIRECTION_SEL_0,
451 .mask = PMX_CLCD1_MASK,
452 .val = PMX_CLCD1_MASK,
421 }, 453 },
422}; 454};
423 455
@@ -443,6 +475,10 @@ static struct spear_muxreg clcd_high_res_muxreg[] = {
443 .reg = PAD_FUNCTION_EN_1, 475 .reg = PAD_FUNCTION_EN_1,
444 .mask = PMX_CLCD2_MASK, 476 .mask = PMX_CLCD2_MASK,
445 .val = PMX_CLCD2_MASK, 477 .val = PMX_CLCD2_MASK,
478 }, {
479 .reg = PAD_DIRECTION_SEL_1,
480 .mask = PMX_CLCD2_MASK,
481 .val = PMX_CLCD2_MASK,
446 }, 482 },
447}; 483};
448 484
@@ -461,7 +497,7 @@ static struct spear_pingroup clcd_high_res_pingroup = {
461 .nmodemuxs = ARRAY_SIZE(clcd_high_res_modemux), 497 .nmodemuxs = ARRAY_SIZE(clcd_high_res_modemux),
462}; 498};
463 499
464static const char *const clcd_grps[] = { "clcd_grp", "clcd_high_res" }; 500static const char *const clcd_grps[] = { "clcd_grp", "clcd_high_res_grp" };
465static struct spear_function clcd_function = { 501static struct spear_function clcd_function = {
466 .name = "clcd", 502 .name = "clcd",
467 .groups = clcd_grps, 503 .groups = clcd_grps,
@@ -479,6 +515,14 @@ static struct spear_muxreg arm_gpio_muxreg[] = {
479 .reg = PAD_FUNCTION_EN_1, 515 .reg = PAD_FUNCTION_EN_1,
480 .mask = PMX_EGPIO_1_GRP_MASK, 516 .mask = PMX_EGPIO_1_GRP_MASK,
481 .val = PMX_EGPIO_1_GRP_MASK, 517 .val = PMX_EGPIO_1_GRP_MASK,
518 }, {
519 .reg = PAD_DIRECTION_SEL_0,
520 .mask = PMX_EGPIO_0_GRP_MASK,
521 .val = PMX_EGPIO_0_GRP_MASK,
522 }, {
523 .reg = PAD_DIRECTION_SEL_1,
524 .mask = PMX_EGPIO_1_GRP_MASK,
525 .val = PMX_EGPIO_1_GRP_MASK,
482 }, 526 },
483}; 527};
484 528
@@ -511,6 +555,10 @@ static struct spear_muxreg smi_2_chips_muxreg[] = {
511 .reg = PAD_FUNCTION_EN_0, 555 .reg = PAD_FUNCTION_EN_0,
512 .mask = PMX_SMI_MASK, 556 .mask = PMX_SMI_MASK,
513 .val = PMX_SMI_MASK, 557 .val = PMX_SMI_MASK,
558 }, {
559 .reg = PAD_DIRECTION_SEL_0,
560 .mask = PMX_SMI_MASK,
561 .val = PMX_SMI_MASK,
514 }, 562 },
515}; 563};
516 564
@@ -539,6 +587,14 @@ static struct spear_muxreg smi_4_chips_muxreg[] = {
539 .reg = PAD_FUNCTION_EN_1, 587 .reg = PAD_FUNCTION_EN_1,
540 .mask = PMX_SMINCS2_MASK | PMX_SMINCS3_MASK, 588 .mask = PMX_SMINCS2_MASK | PMX_SMINCS3_MASK,
541 .val = PMX_SMINCS2_MASK | PMX_SMINCS3_MASK, 589 .val = PMX_SMINCS2_MASK | PMX_SMINCS3_MASK,
590 }, {
591 .reg = PAD_DIRECTION_SEL_0,
592 .mask = PMX_SMI_MASK,
593 .val = PMX_SMI_MASK,
594 }, {
595 .reg = PAD_DIRECTION_SEL_1,
596 .mask = PMX_SMINCS2_MASK | PMX_SMINCS3_MASK,
597 .val = PMX_SMINCS2_MASK | PMX_SMINCS3_MASK,
542 }, 598 },
543}; 599};
544 600
@@ -573,6 +629,10 @@ static struct spear_muxreg gmii_muxreg[] = {
573 .reg = PAD_FUNCTION_EN_0, 629 .reg = PAD_FUNCTION_EN_0,
574 .mask = PMX_GMII_MASK, 630 .mask = PMX_GMII_MASK,
575 .val = PMX_GMII_MASK, 631 .val = PMX_GMII_MASK,
632 }, {
633 .reg = PAD_DIRECTION_SEL_0,
634 .mask = PMX_GMII_MASK,
635 .val = PMX_GMII_MASK,
576 }, 636 },
577}; 637};
578 638
@@ -615,6 +675,18 @@ static struct spear_muxreg rgmii_muxreg[] = {
615 .reg = PAD_FUNCTION_EN_2, 675 .reg = PAD_FUNCTION_EN_2,
616 .mask = PMX_RGMII_REG2_MASK, 676 .mask = PMX_RGMII_REG2_MASK,
617 .val = 0, 677 .val = 0,
678 }, {
679 .reg = PAD_DIRECTION_SEL_0,
680 .mask = PMX_RGMII_REG0_MASK,
681 .val = PMX_RGMII_REG0_MASK,
682 }, {
683 .reg = PAD_DIRECTION_SEL_1,
684 .mask = PMX_RGMII_REG1_MASK,
685 .val = PMX_RGMII_REG1_MASK,
686 }, {
687 .reg = PAD_DIRECTION_SEL_2,
688 .mask = PMX_RGMII_REG2_MASK,
689 .val = PMX_RGMII_REG2_MASK,
618 }, 690 },
619}; 691};
620 692
@@ -649,6 +721,10 @@ static struct spear_muxreg smii_0_1_2_muxreg[] = {
649 .reg = PAD_FUNCTION_EN_1, 721 .reg = PAD_FUNCTION_EN_1,
650 .mask = PMX_SMII_0_1_2_MASK, 722 .mask = PMX_SMII_0_1_2_MASK,
651 .val = 0, 723 .val = 0,
724 }, {
725 .reg = PAD_DIRECTION_SEL_1,
726 .mask = PMX_SMII_0_1_2_MASK,
727 .val = PMX_SMII_0_1_2_MASK,
652 }, 728 },
653}; 729};
654 730
@@ -681,6 +757,10 @@ static struct spear_muxreg ras_mii_txclk_muxreg[] = {
681 .reg = PAD_FUNCTION_EN_1, 757 .reg = PAD_FUNCTION_EN_1,
682 .mask = PMX_NFCE2_MASK, 758 .mask = PMX_NFCE2_MASK,
683 .val = 0, 759 .val = 0,
760 }, {
761 .reg = PAD_DIRECTION_SEL_1,
762 .mask = PMX_NFCE2_MASK,
763 .val = PMX_NFCE2_MASK,
684 }, 764 },
685}; 765};
686 766
@@ -721,6 +801,14 @@ static struct spear_muxreg nand_8bit_muxreg[] = {
721 .reg = PAD_FUNCTION_EN_1, 801 .reg = PAD_FUNCTION_EN_1,
722 .mask = PMX_NAND8BIT_1_MASK, 802 .mask = PMX_NAND8BIT_1_MASK,
723 .val = PMX_NAND8BIT_1_MASK, 803 .val = PMX_NAND8BIT_1_MASK,
804 }, {
805 .reg = PAD_DIRECTION_SEL_0,
806 .mask = PMX_NAND8BIT_0_MASK,
807 .val = PMX_NAND8BIT_0_MASK,
808 }, {
809 .reg = PAD_DIRECTION_SEL_1,
810 .mask = PMX_NAND8BIT_1_MASK,
811 .val = PMX_NAND8BIT_1_MASK,
724 }, 812 },
725}; 813};
726 814
@@ -747,6 +835,10 @@ static struct spear_muxreg nand_16bit_muxreg[] = {
747 .reg = PAD_FUNCTION_EN_1, 835 .reg = PAD_FUNCTION_EN_1,
748 .mask = PMX_NAND16BIT_1_MASK, 836 .mask = PMX_NAND16BIT_1_MASK,
749 .val = PMX_NAND16BIT_1_MASK, 837 .val = PMX_NAND16BIT_1_MASK,
838 }, {
839 .reg = PAD_DIRECTION_SEL_1,
840 .mask = PMX_NAND16BIT_1_MASK,
841 .val = PMX_NAND16BIT_1_MASK,
750 }, 842 },
751}; 843};
752 844
@@ -772,6 +864,10 @@ static struct spear_muxreg nand_4_chips_muxreg[] = {
772 .reg = PAD_FUNCTION_EN_1, 864 .reg = PAD_FUNCTION_EN_1,
773 .mask = PMX_NAND_4CHIPS_MASK, 865 .mask = PMX_NAND_4CHIPS_MASK,
774 .val = PMX_NAND_4CHIPS_MASK, 866 .val = PMX_NAND_4CHIPS_MASK,
867 }, {
868 .reg = PAD_DIRECTION_SEL_1,
869 .mask = PMX_NAND_4CHIPS_MASK,
870 .val = PMX_NAND_4CHIPS_MASK,
775 }, 871 },
776}; 872};
777 873
@@ -833,6 +929,10 @@ static struct spear_muxreg keyboard_rowcol6_8_muxreg[] = {
833 .reg = PAD_FUNCTION_EN_1, 929 .reg = PAD_FUNCTION_EN_1,
834 .mask = PMX_KBD_ROWCOL68_MASK, 930 .mask = PMX_KBD_ROWCOL68_MASK,
835 .val = PMX_KBD_ROWCOL68_MASK, 931 .val = PMX_KBD_ROWCOL68_MASK,
932 }, {
933 .reg = PAD_DIRECTION_SEL_1,
934 .mask = PMX_KBD_ROWCOL68_MASK,
935 .val = PMX_KBD_ROWCOL68_MASK,
836 }, 936 },
837}; 937};
838 938
@@ -866,6 +966,10 @@ static struct spear_muxreg uart0_muxreg[] = {
866 .reg = PAD_FUNCTION_EN_0, 966 .reg = PAD_FUNCTION_EN_0,
867 .mask = PMX_UART0_MASK, 967 .mask = PMX_UART0_MASK,
868 .val = PMX_UART0_MASK, 968 .val = PMX_UART0_MASK,
969 }, {
970 .reg = PAD_DIRECTION_SEL_0,
971 .mask = PMX_UART0_MASK,
972 .val = PMX_UART0_MASK,
869 }, 973 },
870}; 974};
871 975
@@ -891,6 +995,10 @@ static struct spear_muxreg uart0_modem_muxreg[] = {
891 .reg = PAD_FUNCTION_EN_1, 995 .reg = PAD_FUNCTION_EN_1,
892 .mask = PMX_UART0_MODEM_MASK, 996 .mask = PMX_UART0_MODEM_MASK,
893 .val = PMX_UART0_MODEM_MASK, 997 .val = PMX_UART0_MODEM_MASK,
998 }, {
999 .reg = PAD_DIRECTION_SEL_1,
1000 .mask = PMX_UART0_MODEM_MASK,
1001 .val = PMX_UART0_MODEM_MASK,
894 }, 1002 },
895}; 1003};
896 1004
@@ -923,6 +1031,10 @@ static struct spear_muxreg gpt0_tmr0_muxreg[] = {
923 .reg = PAD_FUNCTION_EN_1, 1031 .reg = PAD_FUNCTION_EN_1,
924 .mask = PMX_GPT0_TMR0_MASK, 1032 .mask = PMX_GPT0_TMR0_MASK,
925 .val = PMX_GPT0_TMR0_MASK, 1033 .val = PMX_GPT0_TMR0_MASK,
1034 }, {
1035 .reg = PAD_DIRECTION_SEL_1,
1036 .mask = PMX_GPT0_TMR0_MASK,
1037 .val = PMX_GPT0_TMR0_MASK,
926 }, 1038 },
927}; 1039};
928 1040
@@ -948,6 +1060,10 @@ static struct spear_muxreg gpt0_tmr1_muxreg[] = {
948 .reg = PAD_FUNCTION_EN_1, 1060 .reg = PAD_FUNCTION_EN_1,
949 .mask = PMX_GPT0_TMR1_MASK, 1061 .mask = PMX_GPT0_TMR1_MASK,
950 .val = PMX_GPT0_TMR1_MASK, 1062 .val = PMX_GPT0_TMR1_MASK,
1063 }, {
1064 .reg = PAD_DIRECTION_SEL_1,
1065 .mask = PMX_GPT0_TMR1_MASK,
1066 .val = PMX_GPT0_TMR1_MASK,
951 }, 1067 },
952}; 1068};
953 1069
@@ -980,6 +1096,10 @@ static struct spear_muxreg gpt1_tmr0_muxreg[] = {
980 .reg = PAD_FUNCTION_EN_1, 1096 .reg = PAD_FUNCTION_EN_1,
981 .mask = PMX_GPT1_TMR0_MASK, 1097 .mask = PMX_GPT1_TMR0_MASK,
982 .val = PMX_GPT1_TMR0_MASK, 1098 .val = PMX_GPT1_TMR0_MASK,
1099 }, {
1100 .reg = PAD_DIRECTION_SEL_1,
1101 .mask = PMX_GPT1_TMR0_MASK,
1102 .val = PMX_GPT1_TMR0_MASK,
983 }, 1103 },
984}; 1104};
985 1105
@@ -1005,6 +1125,10 @@ static struct spear_muxreg gpt1_tmr1_muxreg[] = {
1005 .reg = PAD_FUNCTION_EN_1, 1125 .reg = PAD_FUNCTION_EN_1,
1006 .mask = PMX_GPT1_TMR1_MASK, 1126 .mask = PMX_GPT1_TMR1_MASK,
1007 .val = PMX_GPT1_TMR1_MASK, 1127 .val = PMX_GPT1_TMR1_MASK,
1128 }, {
1129 .reg = PAD_DIRECTION_SEL_1,
1130 .mask = PMX_GPT1_TMR1_MASK,
1131 .val = PMX_GPT1_TMR1_MASK,
1008 }, 1132 },
1009}; 1133};
1010 1134
@@ -1049,6 +1173,20 @@ static const unsigned mcif_pins[] = { 86, 87, 88, 89, 90, 91, 92, 93, 213, 214,
1049 .reg = PAD_FUNCTION_EN_2, \ 1173 .reg = PAD_FUNCTION_EN_2, \
1050 .mask = PMX_MCIFALL_2_MASK, \ 1174 .mask = PMX_MCIFALL_2_MASK, \
1051 .val = PMX_MCIFALL_2_MASK, \ 1175 .val = PMX_MCIFALL_2_MASK, \
1176 }, { \
1177 .reg = PAD_DIRECTION_SEL_0, \
1178 .mask = PMX_MCI_DATA8_15_MASK, \
1179 .val = PMX_MCI_DATA8_15_MASK, \
1180 }, { \
1181 .reg = PAD_DIRECTION_SEL_1, \
1182 .mask = PMX_MCIFALL_1_MASK | PMX_NFWPRT1_MASK | \
1183 PMX_NFWPRT2_MASK, \
1184 .val = PMX_MCIFALL_1_MASK | PMX_NFWPRT1_MASK | \
1185 PMX_NFWPRT2_MASK, \
1186 }, { \
1187 .reg = PAD_DIRECTION_SEL_2, \
1188 .mask = PMX_MCIFALL_2_MASK, \
1189 .val = PMX_MCIFALL_2_MASK, \
1052 } 1190 }
1053 1191
1054/* sdhci device */ 1192/* sdhci device */
@@ -1154,6 +1292,10 @@ static struct spear_muxreg touch_xy_muxreg[] = {
1154 .reg = PAD_FUNCTION_EN_2, 1292 .reg = PAD_FUNCTION_EN_2,
1155 .mask = PMX_TOUCH_XY_MASK, 1293 .mask = PMX_TOUCH_XY_MASK,
1156 .val = PMX_TOUCH_XY_MASK, 1294 .val = PMX_TOUCH_XY_MASK,
1295 }, {
1296 .reg = PAD_DIRECTION_SEL_2,
1297 .mask = PMX_TOUCH_XY_MASK,
1298 .val = PMX_TOUCH_XY_MASK,
1157 }, 1299 },
1158}; 1300};
1159 1301
@@ -1187,6 +1329,10 @@ static struct spear_muxreg uart1_dis_i2c_muxreg[] = {
1187 .reg = PAD_FUNCTION_EN_0, 1329 .reg = PAD_FUNCTION_EN_0,
1188 .mask = PMX_I2C0_MASK, 1330 .mask = PMX_I2C0_MASK,
1189 .val = 0, 1331 .val = 0,
1332 }, {
1333 .reg = PAD_DIRECTION_SEL_0,
1334 .mask = PMX_I2C0_MASK,
1335 .val = PMX_I2C0_MASK,
1190 }, 1336 },
1191}; 1337};
1192 1338
@@ -1213,6 +1359,12 @@ static struct spear_muxreg uart1_dis_sd_muxreg[] = {
1213 .mask = PMX_MCIDATA1_MASK | 1359 .mask = PMX_MCIDATA1_MASK |
1214 PMX_MCIDATA2_MASK, 1360 PMX_MCIDATA2_MASK,
1215 .val = 0, 1361 .val = 0,
1362 }, {
1363 .reg = PAD_DIRECTION_SEL_1,
1364 .mask = PMX_MCIDATA1_MASK |
1365 PMX_MCIDATA2_MASK,
1366 .val = PMX_MCIDATA1_MASK |
1367 PMX_MCIDATA2_MASK,
1216 }, 1368 },
1217}; 1369};
1218 1370
@@ -1246,6 +1398,10 @@ static struct spear_muxreg uart2_3_muxreg[] = {
1246 .reg = PAD_FUNCTION_EN_0, 1398 .reg = PAD_FUNCTION_EN_0,
1247 .mask = PMX_I2S0_MASK, 1399 .mask = PMX_I2S0_MASK,
1248 .val = 0, 1400 .val = 0,
1401 }, {
1402 .reg = PAD_DIRECTION_SEL_0,
1403 .mask = PMX_I2S0_MASK,
1404 .val = PMX_I2S0_MASK,
1249 }, 1405 },
1250}; 1406};
1251 1407
@@ -1278,6 +1434,10 @@ static struct spear_muxreg uart4_muxreg[] = {
1278 .reg = PAD_FUNCTION_EN_0, 1434 .reg = PAD_FUNCTION_EN_0,
1279 .mask = PMX_I2S0_MASK | PMX_CLCD1_MASK, 1435 .mask = PMX_I2S0_MASK | PMX_CLCD1_MASK,
1280 .val = 0, 1436 .val = 0,
1437 }, {
1438 .reg = PAD_DIRECTION_SEL_0,
1439 .mask = PMX_I2S0_MASK | PMX_CLCD1_MASK,
1440 .val = PMX_I2S0_MASK | PMX_CLCD1_MASK,
1281 }, 1441 },
1282}; 1442};
1283 1443
@@ -1310,6 +1470,10 @@ static struct spear_muxreg uart5_muxreg[] = {
1310 .reg = PAD_FUNCTION_EN_0, 1470 .reg = PAD_FUNCTION_EN_0,
1311 .mask = PMX_CLCD1_MASK, 1471 .mask = PMX_CLCD1_MASK,
1312 .val = 0, 1472 .val = 0,
1473 }, {
1474 .reg = PAD_DIRECTION_SEL_0,
1475 .mask = PMX_CLCD1_MASK,
1476 .val = PMX_CLCD1_MASK,
1313 }, 1477 },
1314}; 1478};
1315 1479
@@ -1344,6 +1508,10 @@ static struct spear_muxreg rs485_0_1_tdm_0_1_muxreg[] = {
1344 .reg = PAD_FUNCTION_EN_0, 1508 .reg = PAD_FUNCTION_EN_0,
1345 .mask = PMX_CLCD1_MASK, 1509 .mask = PMX_CLCD1_MASK,
1346 .val = 0, 1510 .val = 0,
1511 }, {
1512 .reg = PAD_DIRECTION_SEL_0,
1513 .mask = PMX_CLCD1_MASK,
1514 .val = PMX_CLCD1_MASK,
1347 }, 1515 },
1348}; 1516};
1349 1517
@@ -1376,6 +1544,10 @@ static struct spear_muxreg i2c_1_2_muxreg[] = {
1376 .reg = PAD_FUNCTION_EN_0, 1544 .reg = PAD_FUNCTION_EN_0,
1377 .mask = PMX_CLCD1_MASK, 1545 .mask = PMX_CLCD1_MASK,
1378 .val = 0, 1546 .val = 0,
1547 }, {
1548 .reg = PAD_DIRECTION_SEL_0,
1549 .mask = PMX_CLCD1_MASK,
1550 .val = PMX_CLCD1_MASK,
1379 }, 1551 },
1380}; 1552};
1381 1553
@@ -1409,6 +1581,10 @@ static struct spear_muxreg i2c3_dis_smi_clcd_muxreg[] = {
1409 .reg = PAD_FUNCTION_EN_0, 1581 .reg = PAD_FUNCTION_EN_0,
1410 .mask = PMX_CLCD1_MASK | PMX_SMI_MASK, 1582 .mask = PMX_CLCD1_MASK | PMX_SMI_MASK,
1411 .val = 0, 1583 .val = 0,
1584 }, {
1585 .reg = PAD_DIRECTION_SEL_0,
1586 .mask = PMX_CLCD1_MASK | PMX_SMI_MASK,
1587 .val = PMX_CLCD1_MASK | PMX_SMI_MASK,
1412 }, 1588 },
1413}; 1589};
1414 1590
@@ -1435,6 +1611,10 @@ static struct spear_muxreg i2c3_dis_sd_i2s0_muxreg[] = {
1435 .reg = PAD_FUNCTION_EN_1, 1611 .reg = PAD_FUNCTION_EN_1,
1436 .mask = PMX_I2S1_MASK | PMX_MCIDATA3_MASK, 1612 .mask = PMX_I2S1_MASK | PMX_MCIDATA3_MASK,
1437 .val = 0, 1613 .val = 0,
1614 }, {
1615 .reg = PAD_DIRECTION_SEL_1,
1616 .mask = PMX_I2S1_MASK | PMX_MCIDATA3_MASK,
1617 .val = PMX_I2S1_MASK | PMX_MCIDATA3_MASK,
1438 }, 1618 },
1439}; 1619};
1440 1620
@@ -1469,6 +1649,10 @@ static struct spear_muxreg i2c_4_5_dis_smi_muxreg[] = {
1469 .reg = PAD_FUNCTION_EN_0, 1649 .reg = PAD_FUNCTION_EN_0,
1470 .mask = PMX_SMI_MASK, 1650 .mask = PMX_SMI_MASK,
1471 .val = 0, 1651 .val = 0,
1652 }, {
1653 .reg = PAD_DIRECTION_SEL_0,
1654 .mask = PMX_SMI_MASK,
1655 .val = PMX_SMI_MASK,
1472 }, 1656 },
1473}; 1657};
1474 1658
@@ -1499,6 +1683,14 @@ static struct spear_muxreg i2c4_dis_sd_muxreg[] = {
1499 .reg = PAD_FUNCTION_EN_2, 1683 .reg = PAD_FUNCTION_EN_2,
1500 .mask = PMX_MCIDATA5_MASK, 1684 .mask = PMX_MCIDATA5_MASK,
1501 .val = 0, 1685 .val = 0,
1686 }, {
1687 .reg = PAD_DIRECTION_SEL_1,
1688 .mask = PMX_MCIDATA4_MASK,
1689 .val = PMX_MCIDATA4_MASK,
1690 }, {
1691 .reg = PAD_DIRECTION_SEL_2,
1692 .mask = PMX_MCIDATA5_MASK,
1693 .val = PMX_MCIDATA5_MASK,
1502 }, 1694 },
1503}; 1695};
1504 1696
@@ -1526,6 +1718,12 @@ static struct spear_muxreg i2c5_dis_sd_muxreg[] = {
1526 .mask = PMX_MCIDATA6_MASK | 1718 .mask = PMX_MCIDATA6_MASK |
1527 PMX_MCIDATA7_MASK, 1719 PMX_MCIDATA7_MASK,
1528 .val = 0, 1720 .val = 0,
1721 }, {
1722 .reg = PAD_DIRECTION_SEL_2,
1723 .mask = PMX_MCIDATA6_MASK |
1724 PMX_MCIDATA7_MASK,
1725 .val = PMX_MCIDATA6_MASK |
1726 PMX_MCIDATA7_MASK,
1529 }, 1727 },
1530}; 1728};
1531 1729
@@ -1560,6 +1758,10 @@ static struct spear_muxreg i2c_6_7_dis_kbd_muxreg[] = {
1560 .reg = PAD_FUNCTION_EN_1, 1758 .reg = PAD_FUNCTION_EN_1,
1561 .mask = PMX_KBD_ROWCOL25_MASK, 1759 .mask = PMX_KBD_ROWCOL25_MASK,
1562 .val = 0, 1760 .val = 0,
1761 }, {
1762 .reg = PAD_DIRECTION_SEL_1,
1763 .mask = PMX_KBD_ROWCOL25_MASK,
1764 .val = PMX_KBD_ROWCOL25_MASK,
1563 }, 1765 },
1564}; 1766};
1565 1767
@@ -1587,6 +1789,12 @@ static struct spear_muxreg i2c6_dis_sd_muxreg[] = {
1587 .mask = PMX_MCIIORDRE_MASK | 1789 .mask = PMX_MCIIORDRE_MASK |
1588 PMX_MCIIOWRWE_MASK, 1790 PMX_MCIIOWRWE_MASK,
1589 .val = 0, 1791 .val = 0,
1792 }, {
1793 .reg = PAD_DIRECTION_SEL_2,
1794 .mask = PMX_MCIIORDRE_MASK |
1795 PMX_MCIIOWRWE_MASK,
1796 .val = PMX_MCIIORDRE_MASK |
1797 PMX_MCIIOWRWE_MASK,
1590 }, 1798 },
1591}; 1799};
1592 1800
@@ -1613,6 +1821,12 @@ static struct spear_muxreg i2c7_dis_sd_muxreg[] = {
1613 .mask = PMX_MCIRESETCF_MASK | 1821 .mask = PMX_MCIRESETCF_MASK |
1614 PMX_MCICS0CE_MASK, 1822 PMX_MCICS0CE_MASK,
1615 .val = 0, 1823 .val = 0,
1824 }, {
1825 .reg = PAD_DIRECTION_SEL_2,
1826 .mask = PMX_MCIRESETCF_MASK |
1827 PMX_MCICS0CE_MASK,
1828 .val = PMX_MCIRESETCF_MASK |
1829 PMX_MCICS0CE_MASK,
1616 }, 1830 },
1617}; 1831};
1618 1832
@@ -1651,6 +1865,14 @@ static struct spear_muxreg can0_dis_nor_muxreg[] = {
1651 .reg = PAD_FUNCTION_EN_1, 1865 .reg = PAD_FUNCTION_EN_1,
1652 .mask = PMX_NFRSTPWDWN3_MASK, 1866 .mask = PMX_NFRSTPWDWN3_MASK,
1653 .val = 0, 1867 .val = 0,
1868 }, {
1869 .reg = PAD_DIRECTION_SEL_0,
1870 .mask = PMX_NFRSTPWDWN2_MASK,
1871 .val = PMX_NFRSTPWDWN2_MASK,
1872 }, {
1873 .reg = PAD_DIRECTION_SEL_1,
1874 .mask = PMX_NFRSTPWDWN3_MASK,
1875 .val = PMX_NFRSTPWDWN3_MASK,
1654 }, 1876 },
1655}; 1877};
1656 1878
@@ -1677,6 +1899,10 @@ static struct spear_muxreg can0_dis_sd_muxreg[] = {
1677 .reg = PAD_FUNCTION_EN_2, 1899 .reg = PAD_FUNCTION_EN_2,
1678 .mask = PMX_MCICFINTR_MASK | PMX_MCIIORDY_MASK, 1900 .mask = PMX_MCICFINTR_MASK | PMX_MCIIORDY_MASK,
1679 .val = 0, 1901 .val = 0,
1902 }, {
1903 .reg = PAD_DIRECTION_SEL_2,
1904 .mask = PMX_MCICFINTR_MASK | PMX_MCIIORDY_MASK,
1905 .val = PMX_MCICFINTR_MASK | PMX_MCIIORDY_MASK,
1680 }, 1906 },
1681}; 1907};
1682 1908
@@ -1711,6 +1937,10 @@ static struct spear_muxreg can1_dis_sd_muxreg[] = {
1711 .reg = PAD_FUNCTION_EN_2, 1937 .reg = PAD_FUNCTION_EN_2,
1712 .mask = PMX_MCICS1_MASK | PMX_MCIDMAACK_MASK, 1938 .mask = PMX_MCICS1_MASK | PMX_MCIDMAACK_MASK,
1713 .val = 0, 1939 .val = 0,
1940 }, {
1941 .reg = PAD_DIRECTION_SEL_2,
1942 .mask = PMX_MCICS1_MASK | PMX_MCIDMAACK_MASK,
1943 .val = PMX_MCICS1_MASK | PMX_MCIDMAACK_MASK,
1714 }, 1944 },
1715}; 1945};
1716 1946
@@ -1737,6 +1967,10 @@ static struct spear_muxreg can1_dis_kbd_muxreg[] = {
1737 .reg = PAD_FUNCTION_EN_1, 1967 .reg = PAD_FUNCTION_EN_1,
1738 .mask = PMX_KBD_ROWCOL25_MASK, 1968 .mask = PMX_KBD_ROWCOL25_MASK,
1739 .val = 0, 1969 .val = 0,
1970 }, {
1971 .reg = PAD_DIRECTION_SEL_1,
1972 .mask = PMX_KBD_ROWCOL25_MASK,
1973 .val = PMX_KBD_ROWCOL25_MASK,
1740 }, 1974 },
1741}; 1975};
1742 1976
@@ -1763,29 +1997,64 @@ static struct spear_function can1_function = {
1763 .ngroups = ARRAY_SIZE(can1_grps), 1997 .ngroups = ARRAY_SIZE(can1_grps),
1764}; 1998};
1765 1999
1766/* Pad multiplexing for pci device */ 2000/* Pad multiplexing for (ras-ip) pci device */
1767static const unsigned pci_sata_pins[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 18, 2001static const unsigned pci_pins[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 18,
1768 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 2002 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
1769 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 2003 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1770 55, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 }; 2004 55, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 };
1771#define PCI_SATA_MUXREG \
1772 { \
1773 .reg = PAD_FUNCTION_EN_0, \
1774 .mask = PMX_MCI_DATA8_15_MASK, \
1775 .val = 0, \
1776 }, { \
1777 .reg = PAD_FUNCTION_EN_1, \
1778 .mask = PMX_PCI_REG1_MASK, \
1779 .val = 0, \
1780 }, { \
1781 .reg = PAD_FUNCTION_EN_2, \
1782 .mask = PMX_PCI_REG2_MASK, \
1783 .val = 0, \
1784 }
1785 2005
1786/* pad multiplexing for pcie0 device */ 2006static struct spear_muxreg pci_muxreg[] = {
2007 {
2008 .reg = PAD_FUNCTION_EN_0,
2009 .mask = PMX_MCI_DATA8_15_MASK,
2010 .val = 0,
2011 }, {
2012 .reg = PAD_FUNCTION_EN_1,
2013 .mask = PMX_PCI_REG1_MASK,
2014 .val = 0,
2015 }, {
2016 .reg = PAD_FUNCTION_EN_2,
2017 .mask = PMX_PCI_REG2_MASK,
2018 .val = 0,
2019 }, {
2020 .reg = PAD_DIRECTION_SEL_0,
2021 .mask = PMX_MCI_DATA8_15_MASK,
2022 .val = PMX_MCI_DATA8_15_MASK,
2023 }, {
2024 .reg = PAD_DIRECTION_SEL_1,
2025 .mask = PMX_PCI_REG1_MASK,
2026 .val = PMX_PCI_REG1_MASK,
2027 }, {
2028 .reg = PAD_DIRECTION_SEL_2,
2029 .mask = PMX_PCI_REG2_MASK,
2030 .val = PMX_PCI_REG2_MASK,
2031 },
2032};
2033
2034static struct spear_modemux pci_modemux[] = {
2035 {
2036 .muxregs = pci_muxreg,
2037 .nmuxregs = ARRAY_SIZE(pci_muxreg),
2038 },
2039};
2040
2041static struct spear_pingroup pci_pingroup = {
2042 .name = "pci_grp",
2043 .pins = pci_pins,
2044 .npins = ARRAY_SIZE(pci_pins),
2045 .modemuxs = pci_modemux,
2046 .nmodemuxs = ARRAY_SIZE(pci_modemux),
2047};
2048
2049static const char *const pci_grps[] = { "pci_grp" };
2050static struct spear_function pci_function = {
2051 .name = "pci",
2052 .groups = pci_grps,
2053 .ngroups = ARRAY_SIZE(pci_grps),
2054};
2055
2056/* pad multiplexing for (fix-part) pcie0 device */
1787static struct spear_muxreg pcie0_muxreg[] = { 2057static struct spear_muxreg pcie0_muxreg[] = {
1788 PCI_SATA_MUXREG,
1789 { 2058 {
1790 .reg = PCIE_SATA_CFG, 2059 .reg = PCIE_SATA_CFG,
1791 .mask = PCIE_CFG_VAL(0), 2060 .mask = PCIE_CFG_VAL(0),
@@ -1802,15 +2071,12 @@ static struct spear_modemux pcie0_modemux[] = {
1802 2071
1803static struct spear_pingroup pcie0_pingroup = { 2072static struct spear_pingroup pcie0_pingroup = {
1804 .name = "pcie0_grp", 2073 .name = "pcie0_grp",
1805 .pins = pci_sata_pins,
1806 .npins = ARRAY_SIZE(pci_sata_pins),
1807 .modemuxs = pcie0_modemux, 2074 .modemuxs = pcie0_modemux,
1808 .nmodemuxs = ARRAY_SIZE(pcie0_modemux), 2075 .nmodemuxs = ARRAY_SIZE(pcie0_modemux),
1809}; 2076};
1810 2077
1811/* pad multiplexing for pcie1 device */ 2078/* pad multiplexing for (fix-part) pcie1 device */
1812static struct spear_muxreg pcie1_muxreg[] = { 2079static struct spear_muxreg pcie1_muxreg[] = {
1813 PCI_SATA_MUXREG,
1814 { 2080 {
1815 .reg = PCIE_SATA_CFG, 2081 .reg = PCIE_SATA_CFG,
1816 .mask = PCIE_CFG_VAL(1), 2082 .mask = PCIE_CFG_VAL(1),
@@ -1827,15 +2093,12 @@ static struct spear_modemux pcie1_modemux[] = {
1827 2093
1828static struct spear_pingroup pcie1_pingroup = { 2094static struct spear_pingroup pcie1_pingroup = {
1829 .name = "pcie1_grp", 2095 .name = "pcie1_grp",
1830 .pins = pci_sata_pins,
1831 .npins = ARRAY_SIZE(pci_sata_pins),
1832 .modemuxs = pcie1_modemux, 2096 .modemuxs = pcie1_modemux,
1833 .nmodemuxs = ARRAY_SIZE(pcie1_modemux), 2097 .nmodemuxs = ARRAY_SIZE(pcie1_modemux),
1834}; 2098};
1835 2099
1836/* pad multiplexing for pcie2 device */ 2100/* pad multiplexing for (fix-part) pcie2 device */
1837static struct spear_muxreg pcie2_muxreg[] = { 2101static struct spear_muxreg pcie2_muxreg[] = {
1838 PCI_SATA_MUXREG,
1839 { 2102 {
1840 .reg = PCIE_SATA_CFG, 2103 .reg = PCIE_SATA_CFG,
1841 .mask = PCIE_CFG_VAL(2), 2104 .mask = PCIE_CFG_VAL(2),
@@ -1852,22 +2115,20 @@ static struct spear_modemux pcie2_modemux[] = {
1852 2115
1853static struct spear_pingroup pcie2_pingroup = { 2116static struct spear_pingroup pcie2_pingroup = {
1854 .name = "pcie2_grp", 2117 .name = "pcie2_grp",
1855 .pins = pci_sata_pins,
1856 .npins = ARRAY_SIZE(pci_sata_pins),
1857 .modemuxs = pcie2_modemux, 2118 .modemuxs = pcie2_modemux,
1858 .nmodemuxs = ARRAY_SIZE(pcie2_modemux), 2119 .nmodemuxs = ARRAY_SIZE(pcie2_modemux),
1859}; 2120};
1860 2121
1861static const char *const pci_grps[] = { "pcie0_grp", "pcie1_grp", "pcie2_grp" }; 2122static const char *const pcie_grps[] = { "pcie0_grp", "pcie1_grp", "pcie2_grp"
1862static struct spear_function pci_function = { 2123};
1863 .name = "pci", 2124static struct spear_function pcie_function = {
1864 .groups = pci_grps, 2125 .name = "pci_express",
1865 .ngroups = ARRAY_SIZE(pci_grps), 2126 .groups = pcie_grps,
2127 .ngroups = ARRAY_SIZE(pcie_grps),
1866}; 2128};
1867 2129
1868/* pad multiplexing for sata0 device */ 2130/* pad multiplexing for sata0 device */
1869static struct spear_muxreg sata0_muxreg[] = { 2131static struct spear_muxreg sata0_muxreg[] = {
1870 PCI_SATA_MUXREG,
1871 { 2132 {
1872 .reg = PCIE_SATA_CFG, 2133 .reg = PCIE_SATA_CFG,
1873 .mask = SATA_CFG_VAL(0), 2134 .mask = SATA_CFG_VAL(0),
@@ -1884,15 +2145,12 @@ static struct spear_modemux sata0_modemux[] = {
1884 2145
1885static struct spear_pingroup sata0_pingroup = { 2146static struct spear_pingroup sata0_pingroup = {
1886 .name = "sata0_grp", 2147 .name = "sata0_grp",
1887 .pins = pci_sata_pins,
1888 .npins = ARRAY_SIZE(pci_sata_pins),
1889 .modemuxs = sata0_modemux, 2148 .modemuxs = sata0_modemux,
1890 .nmodemuxs = ARRAY_SIZE(sata0_modemux), 2149 .nmodemuxs = ARRAY_SIZE(sata0_modemux),
1891}; 2150};
1892 2151
1893/* pad multiplexing for sata1 device */ 2152/* pad multiplexing for sata1 device */
1894static struct spear_muxreg sata1_muxreg[] = { 2153static struct spear_muxreg sata1_muxreg[] = {
1895 PCI_SATA_MUXREG,
1896 { 2154 {
1897 .reg = PCIE_SATA_CFG, 2155 .reg = PCIE_SATA_CFG,
1898 .mask = SATA_CFG_VAL(1), 2156 .mask = SATA_CFG_VAL(1),
@@ -1909,15 +2167,12 @@ static struct spear_modemux sata1_modemux[] = {
1909 2167
1910static struct spear_pingroup sata1_pingroup = { 2168static struct spear_pingroup sata1_pingroup = {
1911 .name = "sata1_grp", 2169 .name = "sata1_grp",
1912 .pins = pci_sata_pins,
1913 .npins = ARRAY_SIZE(pci_sata_pins),
1914 .modemuxs = sata1_modemux, 2170 .modemuxs = sata1_modemux,
1915 .nmodemuxs = ARRAY_SIZE(sata1_modemux), 2171 .nmodemuxs = ARRAY_SIZE(sata1_modemux),
1916}; 2172};
1917 2173
1918/* pad multiplexing for sata2 device */ 2174/* pad multiplexing for sata2 device */
1919static struct spear_muxreg sata2_muxreg[] = { 2175static struct spear_muxreg sata2_muxreg[] = {
1920 PCI_SATA_MUXREG,
1921 { 2176 {
1922 .reg = PCIE_SATA_CFG, 2177 .reg = PCIE_SATA_CFG,
1923 .mask = SATA_CFG_VAL(2), 2178 .mask = SATA_CFG_VAL(2),
@@ -1934,8 +2189,6 @@ static struct spear_modemux sata2_modemux[] = {
1934 2189
1935static struct spear_pingroup sata2_pingroup = { 2190static struct spear_pingroup sata2_pingroup = {
1936 .name = "sata2_grp", 2191 .name = "sata2_grp",
1937 .pins = pci_sata_pins,
1938 .npins = ARRAY_SIZE(pci_sata_pins),
1939 .modemuxs = sata2_modemux, 2192 .modemuxs = sata2_modemux,
1940 .nmodemuxs = ARRAY_SIZE(sata2_modemux), 2193 .nmodemuxs = ARRAY_SIZE(sata2_modemux),
1941}; 2194};
@@ -1957,6 +2210,14 @@ static struct spear_muxreg ssp1_dis_kbd_muxreg[] = {
1957 PMX_KBD_COL0_MASK | PMX_NFIO8_15_MASK | PMX_NFCE1_MASK | 2210 PMX_KBD_COL0_MASK | PMX_NFIO8_15_MASK | PMX_NFCE1_MASK |
1958 PMX_NFCE2_MASK, 2211 PMX_NFCE2_MASK,
1959 .val = 0, 2212 .val = 0,
2213 }, {
2214 .reg = PAD_DIRECTION_SEL_1,
2215 .mask = PMX_KBD_ROWCOL25_MASK | PMX_KBD_COL1_MASK |
2216 PMX_KBD_COL0_MASK | PMX_NFIO8_15_MASK | PMX_NFCE1_MASK |
2217 PMX_NFCE2_MASK,
2218 .val = PMX_KBD_ROWCOL25_MASK | PMX_KBD_COL1_MASK |
2219 PMX_KBD_COL0_MASK | PMX_NFIO8_15_MASK | PMX_NFCE1_MASK |
2220 PMX_NFCE2_MASK,
1960 }, 2221 },
1961}; 2222};
1962 2223
@@ -1983,6 +2244,12 @@ static struct spear_muxreg ssp1_dis_sd_muxreg[] = {
1983 .mask = PMX_MCIADDR0ALE_MASK | PMX_MCIADDR2_MASK | 2244 .mask = PMX_MCIADDR0ALE_MASK | PMX_MCIADDR2_MASK |
1984 PMX_MCICECF_MASK | PMX_MCICEXD_MASK, 2245 PMX_MCICECF_MASK | PMX_MCICEXD_MASK,
1985 .val = 0, 2246 .val = 0,
2247 }, {
2248 .reg = PAD_DIRECTION_SEL_2,
2249 .mask = PMX_MCIADDR0ALE_MASK | PMX_MCIADDR2_MASK |
2250 PMX_MCICECF_MASK | PMX_MCICEXD_MASK,
2251 .val = PMX_MCIADDR0ALE_MASK | PMX_MCIADDR2_MASK |
2252 PMX_MCICECF_MASK | PMX_MCICEXD_MASK,
1986 }, 2253 },
1987}; 2254};
1988 2255
@@ -2017,6 +2284,12 @@ static struct spear_muxreg gpt64_muxreg[] = {
2017 .mask = PMX_MCICDCF1_MASK | PMX_MCICDCF2_MASK | PMX_MCICDXD_MASK 2284 .mask = PMX_MCICDCF1_MASK | PMX_MCICDCF2_MASK | PMX_MCICDXD_MASK
2018 | PMX_MCILEDS_MASK, 2285 | PMX_MCILEDS_MASK,
2019 .val = 0, 2286 .val = 0,
2287 }, {
2288 .reg = PAD_DIRECTION_SEL_2,
2289 .mask = PMX_MCICDCF1_MASK | PMX_MCICDCF2_MASK | PMX_MCICDXD_MASK
2290 | PMX_MCILEDS_MASK,
2291 .val = PMX_MCICDCF1_MASK | PMX_MCICDCF2_MASK | PMX_MCICDXD_MASK
2292 | PMX_MCILEDS_MASK,
2020 }, 2293 },
2021}; 2294};
2022 2295
@@ -2093,6 +2366,7 @@ static struct spear_pingroup *spear1310_pingroups[] = {
2093 &can0_dis_sd_pingroup, 2366 &can0_dis_sd_pingroup,
2094 &can1_dis_sd_pingroup, 2367 &can1_dis_sd_pingroup,
2095 &can1_dis_kbd_pingroup, 2368 &can1_dis_kbd_pingroup,
2369 &pci_pingroup,
2096 &pcie0_pingroup, 2370 &pcie0_pingroup,
2097 &pcie1_pingroup, 2371 &pcie1_pingroup,
2098 &pcie2_pingroup, 2372 &pcie2_pingroup,
@@ -2138,6 +2412,7 @@ static struct spear_function *spear1310_functions[] = {
2138 &can0_function, 2412 &can0_function,
2139 &can1_function, 2413 &can1_function,
2140 &pci_function, 2414 &pci_function,
2415 &pcie_function,
2141 &sata_function, 2416 &sata_function,
2142 &ssp1_function, 2417 &ssp1_function,
2143 &gpt64_function, 2418 &gpt64_function,
diff --git a/drivers/pinctrl/spear/pinctrl-spear1340.c b/drivers/pinctrl/spear/pinctrl-spear1340.c
index a0eb057e55b..0606b8cf3f2 100644
--- a/drivers/pinctrl/spear/pinctrl-spear1340.c
+++ b/drivers/pinctrl/spear/pinctrl-spear1340.c
@@ -213,7 +213,7 @@ static const struct pinctrl_pin_desc spear1340_pins[] = {
213 * Pad multiplexing for making all pads as gpio's. This is done to override the 213 * Pad multiplexing for making all pads as gpio's. This is done to override the
214 * values passed from bootloader and start from scratch. 214 * values passed from bootloader and start from scratch.
215 */ 215 */
216static const unsigned pads_as_gpio_pins[] = { 251 }; 216static const unsigned pads_as_gpio_pins[] = { 12, 88, 89, 251 };
217static struct spear_muxreg pads_as_gpio_muxreg[] = { 217static struct spear_muxreg pads_as_gpio_muxreg[] = {
218 { 218 {
219 .reg = PAD_FUNCTION_EN_1, 219 .reg = PAD_FUNCTION_EN_1,
@@ -1692,7 +1692,43 @@ static struct spear_pingroup clcd_pingroup = {
1692 .nmodemuxs = ARRAY_SIZE(clcd_modemux), 1692 .nmodemuxs = ARRAY_SIZE(clcd_modemux),
1693}; 1693};
1694 1694
1695static const char *const clcd_grps[] = { "clcd_grp" }; 1695/* Disable cld runtime to save panel damage */
1696static struct spear_muxreg clcd_sleep_muxreg[] = {
1697 {
1698 .reg = PAD_SHARED_IP_EN_1,
1699 .mask = ARM_TRACE_MASK | MIPHY_DBG_MASK,
1700 .val = 0,
1701 }, {
1702 .reg = PAD_FUNCTION_EN_5,
1703 .mask = CLCD_REG4_MASK | CLCD_AND_ARM_TRACE_REG4_MASK,
1704 .val = 0x0,
1705 }, {
1706 .reg = PAD_FUNCTION_EN_6,
1707 .mask = CLCD_AND_ARM_TRACE_REG5_MASK,
1708 .val = 0x0,
1709 }, {
1710 .reg = PAD_FUNCTION_EN_7,
1711 .mask = CLCD_AND_ARM_TRACE_REG6_MASK,
1712 .val = 0x0,
1713 },
1714};
1715
1716static struct spear_modemux clcd_sleep_modemux[] = {
1717 {
1718 .muxregs = clcd_sleep_muxreg,
1719 .nmuxregs = ARRAY_SIZE(clcd_sleep_muxreg),
1720 },
1721};
1722
1723static struct spear_pingroup clcd_sleep_pingroup = {
1724 .name = "clcd_sleep_grp",
1725 .pins = clcd_pins,
1726 .npins = ARRAY_SIZE(clcd_pins),
1727 .modemuxs = clcd_sleep_modemux,
1728 .nmodemuxs = ARRAY_SIZE(clcd_sleep_modemux),
1729};
1730
1731static const char *const clcd_grps[] = { "clcd_grp", "clcd_sleep_grp" };
1696static struct spear_function clcd_function = { 1732static struct spear_function clcd_function = {
1697 .name = "clcd", 1733 .name = "clcd",
1698 .groups = clcd_grps, 1734 .groups = clcd_grps,
@@ -1893,6 +1929,7 @@ static struct spear_pingroup *spear1340_pingroups[] = {
1893 &sdhci_pingroup, 1929 &sdhci_pingroup,
1894 &cf_pingroup, 1930 &cf_pingroup,
1895 &xd_pingroup, 1931 &xd_pingroup,
1932 &clcd_sleep_pingroup,
1896 &clcd_pingroup, 1933 &clcd_pingroup,
1897 &arm_trace_pingroup, 1934 &arm_trace_pingroup,
1898 &miphy_dbg_pingroup, 1935 &miphy_dbg_pingroup,
diff --git a/drivers/pinctrl/spear/pinctrl-spear320.c b/drivers/pinctrl/spear/pinctrl-spear320.c
index 020b1e0bdb3..ca47b0e5078 100644
--- a/drivers/pinctrl/spear/pinctrl-spear320.c
+++ b/drivers/pinctrl/spear/pinctrl-spear320.c
@@ -2240,6 +2240,10 @@ static struct spear_muxreg pwm2_pin_34_muxreg[] = {
2240 .mask = PMX_SSP_CS_MASK, 2240 .mask = PMX_SSP_CS_MASK,
2241 .val = 0, 2241 .val = 0,
2242 }, { 2242 }, {
2243 .reg = MODE_CONFIG_REG,
2244 .mask = PMX_PWM_MASK,
2245 .val = PMX_PWM_MASK,
2246 }, {
2243 .reg = IP_SEL_PAD_30_39_REG, 2247 .reg = IP_SEL_PAD_30_39_REG,
2244 .mask = PMX_PL_34_MASK, 2248 .mask = PMX_PL_34_MASK,
2245 .val = PMX_PWM2_PL_34_VAL, 2249 .val = PMX_PWM2_PL_34_VAL,
@@ -2956,9 +2960,9 @@ static struct spear_function mii2_function = {
2956}; 2960};
2957 2961
2958/* Pad multiplexing for cadence mii 1_2 as smii or rmii device */ 2962/* Pad multiplexing for cadence mii 1_2 as smii or rmii device */
2959static const unsigned smii0_1_pins[] = { 10, 11, 13, 14, 15, 16, 17, 18, 19, 20, 2963static const unsigned rmii0_1_pins[] = { 10, 11, 13, 14, 15, 16, 17, 18, 19, 20,
2960 21, 22, 23, 24, 25, 26, 27 }; 2964 21, 22, 23, 24, 25, 26, 27 };
2961static const unsigned rmii0_1_pins[] = { 10, 11, 21, 22, 23, 24, 25, 26, 27 }; 2965static const unsigned smii0_1_pins[] = { 10, 11, 21, 22, 23, 24, 25, 26, 27 };
2962static struct spear_muxreg mii0_1_muxreg[] = { 2966static struct spear_muxreg mii0_1_muxreg[] = {
2963 { 2967 {
2964 .reg = PMX_CONFIG_REG, 2968 .reg = PMX_CONFIG_REG,
diff --git a/drivers/pinctrl/spear/pinctrl-spear3xx.h b/drivers/pinctrl/spear/pinctrl-spear3xx.h
index 31f44347f17..7860b36053c 100644
--- a/drivers/pinctrl/spear/pinctrl-spear3xx.h
+++ b/drivers/pinctrl/spear/pinctrl-spear3xx.h
@@ -15,6 +15,7 @@
15#include "pinctrl-spear.h" 15#include "pinctrl-spear.h"
16 16
17/* pad mux declarations */ 17/* pad mux declarations */
18#define PMX_PWM_MASK (1 << 16)
18#define PMX_FIRDA_MASK (1 << 14) 19#define PMX_FIRDA_MASK (1 << 14)
19#define PMX_I2C_MASK (1 << 13) 20#define PMX_I2C_MASK (1 << 13)
20#define PMX_SSP_CS_MASK (1 << 12) 21#define PMX_SSP_CS_MASK (1 << 12)
diff --git a/drivers/rapidio/rio.c b/drivers/rapidio/rio.c
index c17ae22567e..0c6fcb461fa 100644
--- a/drivers/rapidio/rio.c
+++ b/drivers/rapidio/rio.c
@@ -401,7 +401,7 @@ EXPORT_SYMBOL_GPL(rio_release_inb_pwrite);
401/** 401/**
402 * rio_map_inb_region -- Map inbound memory region. 402 * rio_map_inb_region -- Map inbound memory region.
403 * @mport: Master port. 403 * @mport: Master port.
404 * @lstart: physical address of memory region to be mapped 404 * @local: physical address of memory region to be mapped
405 * @rbase: RIO base address assigned to this window 405 * @rbase: RIO base address assigned to this window
406 * @size: Size of the memory region 406 * @size: Size of the memory region
407 * @rflags: Flags for mapping. 407 * @rflags: Flags for mapping.
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 5c4829cba6a..e872c8be080 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1381,22 +1381,14 @@ struct regulator *regulator_get_exclusive(struct device *dev, const char *id)
1381} 1381}
1382EXPORT_SYMBOL_GPL(regulator_get_exclusive); 1382EXPORT_SYMBOL_GPL(regulator_get_exclusive);
1383 1383
1384/** 1384/* Locks held by regulator_put() */
1385 * regulator_put - "free" the regulator source 1385static void _regulator_put(struct regulator *regulator)
1386 * @regulator: regulator source
1387 *
1388 * Note: drivers must ensure that all regulator_enable calls made on this
1389 * regulator source are balanced by regulator_disable calls prior to calling
1390 * this function.
1391 */
1392void regulator_put(struct regulator *regulator)
1393{ 1386{
1394 struct regulator_dev *rdev; 1387 struct regulator_dev *rdev;
1395 1388
1396 if (regulator == NULL || IS_ERR(regulator)) 1389 if (regulator == NULL || IS_ERR(regulator))
1397 return; 1390 return;
1398 1391
1399 mutex_lock(&regulator_list_mutex);
1400 rdev = regulator->rdev; 1392 rdev = regulator->rdev;
1401 1393
1402 debugfs_remove_recursive(regulator->debugfs); 1394 debugfs_remove_recursive(regulator->debugfs);
@@ -1412,6 +1404,20 @@ void regulator_put(struct regulator *regulator)
1412 rdev->exclusive = 0; 1404 rdev->exclusive = 0;
1413 1405
1414 module_put(rdev->owner); 1406 module_put(rdev->owner);
1407}
1408
1409/**
1410 * regulator_put - "free" the regulator source
1411 * @regulator: regulator source
1412 *
1413 * Note: drivers must ensure that all regulator_enable calls made on this
1414 * regulator source are balanced by regulator_disable calls prior to calling
1415 * this function.
1416 */
1417void regulator_put(struct regulator *regulator)
1418{
1419 mutex_lock(&regulator_list_mutex);
1420 _regulator_put(regulator);
1415 mutex_unlock(&regulator_list_mutex); 1421 mutex_unlock(&regulator_list_mutex);
1416} 1422}
1417EXPORT_SYMBOL_GPL(regulator_put); 1423EXPORT_SYMBOL_GPL(regulator_put);
@@ -1974,7 +1980,7 @@ int regulator_is_supported_voltage(struct regulator *regulator,
1974 if (!(rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_VOLTAGE)) { 1980 if (!(rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_VOLTAGE)) {
1975 ret = regulator_get_voltage(regulator); 1981 ret = regulator_get_voltage(regulator);
1976 if (ret >= 0) 1982 if (ret >= 0)
1977 return (min_uV >= ret && ret <= max_uV); 1983 return (min_uV <= ret && ret <= max_uV);
1978 else 1984 else
1979 return ret; 1985 return ret;
1980 } 1986 }
@@ -3365,7 +3371,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
3365 if (ret != 0) { 3371 if (ret != 0) {
3366 rdev_err(rdev, "Failed to request enable GPIO%d: %d\n", 3372 rdev_err(rdev, "Failed to request enable GPIO%d: %d\n",
3367 config->ena_gpio, ret); 3373 config->ena_gpio, ret);
3368 goto clean; 3374 goto wash;
3369 } 3375 }
3370 3376
3371 rdev->ena_gpio = config->ena_gpio; 3377 rdev->ena_gpio = config->ena_gpio;
@@ -3445,10 +3451,11 @@ unset_supplies:
3445 3451
3446scrub: 3452scrub:
3447 if (rdev->supply) 3453 if (rdev->supply)
3448 regulator_put(rdev->supply); 3454 _regulator_put(rdev->supply);
3449 if (rdev->ena_gpio) 3455 if (rdev->ena_gpio)
3450 gpio_free(rdev->ena_gpio); 3456 gpio_free(rdev->ena_gpio);
3451 kfree(rdev->constraints); 3457 kfree(rdev->constraints);
3458wash:
3452 device_unregister(&rdev->dev); 3459 device_unregister(&rdev->dev);
3453 /* device core frees rdev */ 3460 /* device core frees rdev */
3454 rdev = ERR_PTR(ret); 3461 rdev = ERR_PTR(ret);
diff --git a/drivers/rtc/rtc-imxdi.c b/drivers/rtc/rtc-imxdi.c
index 891cd6c61d0..4eed51044c5 100644
--- a/drivers/rtc/rtc-imxdi.c
+++ b/drivers/rtc/rtc-imxdi.c
@@ -392,6 +392,8 @@ static int dryice_rtc_probe(struct platform_device *pdev)
392 if (imxdi->ioaddr == NULL) 392 if (imxdi->ioaddr == NULL)
393 return -ENOMEM; 393 return -ENOMEM;
394 394
395 spin_lock_init(&imxdi->irq_lock);
396
395 imxdi->irq = platform_get_irq(pdev, 0); 397 imxdi->irq = platform_get_irq(pdev, 0);
396 if (imxdi->irq < 0) 398 if (imxdi->irq < 0)
397 return imxdi->irq; 399 return imxdi->irq;
diff --git a/drivers/s390/char/con3215.c b/drivers/s390/char/con3215.c
index 9ffb6d5f17a..4ed343e4eb4 100644
--- a/drivers/s390/char/con3215.c
+++ b/drivers/s390/char/con3215.c
@@ -44,7 +44,6 @@
44#define RAW3215_NR_CCWS 3 44#define RAW3215_NR_CCWS 3
45#define RAW3215_TIMEOUT HZ/10 /* time for delayed output */ 45#define RAW3215_TIMEOUT HZ/10 /* time for delayed output */
46 46
47#define RAW3215_FIXED 1 /* 3215 console device is not be freed */
48#define RAW3215_WORKING 4 /* set if a request is being worked on */ 47#define RAW3215_WORKING 4 /* set if a request is being worked on */
49#define RAW3215_THROTTLED 8 /* set if reading is disabled */ 48#define RAW3215_THROTTLED 8 /* set if reading is disabled */
50#define RAW3215_STOPPED 16 /* set if writing is disabled */ 49#define RAW3215_STOPPED 16 /* set if writing is disabled */
@@ -339,8 +338,10 @@ static void raw3215_wakeup(unsigned long data)
339 struct tty_struct *tty; 338 struct tty_struct *tty;
340 339
341 tty = tty_port_tty_get(&raw->port); 340 tty = tty_port_tty_get(&raw->port);
342 tty_wakeup(tty); 341 if (tty) {
343 tty_kref_put(tty); 342 tty_wakeup(tty);
343 tty_kref_put(tty);
344 }
344} 345}
345 346
346/* 347/*
@@ -629,8 +630,7 @@ static void raw3215_shutdown(struct raw3215_info *raw)
629 DECLARE_WAITQUEUE(wait, current); 630 DECLARE_WAITQUEUE(wait, current);
630 unsigned long flags; 631 unsigned long flags;
631 632
632 if (!(raw->port.flags & ASYNC_INITIALIZED) || 633 if (!(raw->port.flags & ASYNC_INITIALIZED))
633 (raw->flags & RAW3215_FIXED))
634 return; 634 return;
635 /* Wait for outstanding requests, then free irq */ 635 /* Wait for outstanding requests, then free irq */
636 spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags); 636 spin_lock_irqsave(get_ccwdev_lock(raw->cdev), flags);
@@ -926,8 +926,6 @@ static int __init con3215_init(void)
926 dev_set_drvdata(&cdev->dev, raw); 926 dev_set_drvdata(&cdev->dev, raw);
927 cdev->handler = raw3215_irq; 927 cdev->handler = raw3215_irq;
928 928
929 raw->flags |= RAW3215_FIXED;
930
931 /* Request the console irq */ 929 /* Request the console irq */
932 if (raw3215_startup(raw) != 0) { 930 if (raw3215_startup(raw) != 0) {
933 raw3215_free_info(raw); 931 raw3215_free_info(raw);
diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c
index b4d572f65f0..fd00afd8b85 100644
--- a/drivers/s390/cio/css.c
+++ b/drivers/s390/cio/css.c
@@ -377,7 +377,11 @@ static int css_evaluate_new_subchannel(struct subchannel_id schid, int slow)
377 /* Will be done on the slow path. */ 377 /* Will be done on the slow path. */
378 return -EAGAIN; 378 return -EAGAIN;
379 } 379 }
380 if (stsch_err(schid, &schib) || !css_sch_is_valid(&schib)) { 380 if (stsch_err(schid, &schib)) {
381 /* Subchannel is not provided. */
382 return -ENXIO;
383 }
384 if (!css_sch_is_valid(&schib)) {
381 /* Unusable - ignore. */ 385 /* Unusable - ignore. */
382 return 0; 386 return 0;
383 } 387 }
@@ -536,6 +540,7 @@ static int slow_eval_unknown_fn(struct subchannel_id schid, void *data)
536 case -ENOMEM: 540 case -ENOMEM:
537 case -EIO: 541 case -EIO:
538 /* These should abort looping */ 542 /* These should abort looping */
543 idset_sch_del_subseq(slow_subchannel_set, schid);
539 break; 544 break;
540 default: 545 default:
541 rc = 0; 546 rc = 0;
diff --git a/drivers/s390/cio/css.h b/drivers/s390/cio/css.h
index 33bb4d891e1..4af3dfe70ef 100644
--- a/drivers/s390/cio/css.h
+++ b/drivers/s390/cio/css.h
@@ -112,9 +112,6 @@ extern int for_each_subchannel(int(*fn)(struct subchannel_id, void *), void *);
112extern void css_reiterate_subchannels(void); 112extern void css_reiterate_subchannels(void);
113void css_update_ssd_info(struct subchannel *sch); 113void css_update_ssd_info(struct subchannel *sch);
114 114
115#define __MAX_SUBCHANNEL 65535
116#define __MAX_SSID 3
117
118struct channel_subsystem { 115struct channel_subsystem {
119 u8 cssid; 116 u8 cssid;
120 int valid; 117 int valid;
diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c
index fc916f5d731..fd3143c291c 100644
--- a/drivers/s390/cio/device.c
+++ b/drivers/s390/cio/device.c
@@ -1424,7 +1424,7 @@ static enum io_sch_action sch_get_action(struct subchannel *sch)
1424 } 1424 }
1425 if (device_is_disconnected(cdev)) 1425 if (device_is_disconnected(cdev))
1426 return IO_SCH_REPROBE; 1426 return IO_SCH_REPROBE;
1427 if (cdev->online) 1427 if (cdev->online && !cdev->private->flags.resuming)
1428 return IO_SCH_VERIFY; 1428 return IO_SCH_VERIFY;
1429 if (cdev->private->state == DEV_STATE_NOT_OPER) 1429 if (cdev->private->state == DEV_STATE_NOT_OPER)
1430 return IO_SCH_UNREG_ATTACH; 1430 return IO_SCH_UNREG_ATTACH;
@@ -1469,12 +1469,6 @@ static int io_subchannel_sch_event(struct subchannel *sch, int process)
1469 rc = 0; 1469 rc = 0;
1470 goto out_unlock; 1470 goto out_unlock;
1471 case IO_SCH_VERIFY: 1471 case IO_SCH_VERIFY:
1472 if (cdev->private->flags.resuming == 1) {
1473 if (cio_enable_subchannel(sch, (u32)(addr_t)sch)) {
1474 ccw_device_set_notoper(cdev);
1475 break;
1476 }
1477 }
1478 /* Trigger path verification. */ 1472 /* Trigger path verification. */
1479 io_subchannel_verify(sch); 1473 io_subchannel_verify(sch);
1480 rc = 0; 1474 rc = 0;
diff --git a/drivers/s390/cio/idset.c b/drivers/s390/cio/idset.c
index e6d5f8c4952..65d13e38803 100644
--- a/drivers/s390/cio/idset.c
+++ b/drivers/s390/cio/idset.c
@@ -1,9 +1,10 @@
1/* 1/*
2 * Copyright IBM Corp. 2007 2 * Copyright IBM Corp. 2007, 2012
3 * Author(s): Peter Oberparleiter <peter.oberparleiter@de.ibm.com> 3 * Author(s): Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
4 */ 4 */
5 5
6#include <linux/vmalloc.h> 6#include <linux/vmalloc.h>
7#include <linux/bitmap.h>
7#include <linux/bitops.h> 8#include <linux/bitops.h>
8#include "idset.h" 9#include "idset.h"
9#include "css.h" 10#include "css.h"
@@ -89,6 +90,14 @@ void idset_sch_del(struct idset *set, struct subchannel_id schid)
89 idset_del(set, schid.ssid, schid.sch_no); 90 idset_del(set, schid.ssid, schid.sch_no);
90} 91}
91 92
93/* Clear ids starting from @schid up to end of subchannel set. */
94void idset_sch_del_subseq(struct idset *set, struct subchannel_id schid)
95{
96 int pos = schid.ssid * set->num_id + schid.sch_no;
97
98 bitmap_clear(set->bitmap, pos, set->num_id - schid.sch_no);
99}
100
92int idset_sch_contains(struct idset *set, struct subchannel_id schid) 101int idset_sch_contains(struct idset *set, struct subchannel_id schid)
93{ 102{
94 return idset_contains(set, schid.ssid, schid.sch_no); 103 return idset_contains(set, schid.ssid, schid.sch_no);
@@ -111,20 +120,12 @@ int idset_sch_get_first(struct idset *set, struct subchannel_id *schid)
111 120
112int idset_is_empty(struct idset *set) 121int idset_is_empty(struct idset *set)
113{ 122{
114 int bitnum; 123 return bitmap_empty(set->bitmap, set->num_ssid * set->num_id);
115
116 bitnum = find_first_bit(set->bitmap, set->num_ssid * set->num_id);
117 if (bitnum >= set->num_ssid * set->num_id)
118 return 1;
119 return 0;
120} 124}
121 125
122void idset_add_set(struct idset *to, struct idset *from) 126void idset_add_set(struct idset *to, struct idset *from)
123{ 127{
124 unsigned long i, len; 128 int len = min(to->num_ssid * to->num_id, from->num_ssid * from->num_id);
125 129
126 len = min(__BITOPS_WORDS(to->num_ssid * to->num_id), 130 bitmap_or(to->bitmap, to->bitmap, from->bitmap, len);
127 __BITOPS_WORDS(from->num_ssid * from->num_id));
128 for (i = 0; i < len ; i++)
129 to->bitmap[i] |= from->bitmap[i];
130} 131}
diff --git a/drivers/s390/cio/idset.h b/drivers/s390/cio/idset.h
index 3d943f03591..06d3bc01bb0 100644
--- a/drivers/s390/cio/idset.h
+++ b/drivers/s390/cio/idset.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright IBM Corp. 2007 2 * Copyright IBM Corp. 2007, 2012
3 * Author(s): Peter Oberparleiter <peter.oberparleiter@de.ibm.com> 3 * Author(s): Peter Oberparleiter <peter.oberparleiter@de.ibm.com>
4 */ 4 */
5 5
@@ -17,6 +17,7 @@ void idset_fill(struct idset *set);
17struct idset *idset_sch_new(void); 17struct idset *idset_sch_new(void);
18void idset_sch_add(struct idset *set, struct subchannel_id id); 18void idset_sch_add(struct idset *set, struct subchannel_id id);
19void idset_sch_del(struct idset *set, struct subchannel_id id); 19void idset_sch_del(struct idset *set, struct subchannel_id id);
20void idset_sch_del_subseq(struct idset *set, struct subchannel_id schid);
20int idset_sch_contains(struct idset *set, struct subchannel_id id); 21int idset_sch_contains(struct idset *set, struct subchannel_id id);
21int idset_sch_get_first(struct idset *set, struct subchannel_id *id); 22int idset_sch_get_first(struct idset *set, struct subchannel_id *id);
22int idset_is_empty(struct idset *set); 23int idset_is_empty(struct idset *set);
diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c
index 3e25d315045..4d6ba00d004 100644
--- a/drivers/s390/net/qeth_core_main.c
+++ b/drivers/s390/net/qeth_core_main.c
@@ -2942,13 +2942,33 @@ static int qeth_query_ipassists_cb(struct qeth_card *card,
2942 QETH_DBF_TEXT(SETUP, 2, "qipasscb"); 2942 QETH_DBF_TEXT(SETUP, 2, "qipasscb");
2943 2943
2944 cmd = (struct qeth_ipa_cmd *) data; 2944 cmd = (struct qeth_ipa_cmd *) data;
2945
2946 switch (cmd->hdr.return_code) {
2947 case IPA_RC_NOTSUPP:
2948 case IPA_RC_L2_UNSUPPORTED_CMD:
2949 QETH_DBF_TEXT(SETUP, 2, "ipaunsup");
2950 card->options.ipa4.supported_funcs |= IPA_SETADAPTERPARMS;
2951 card->options.ipa6.supported_funcs |= IPA_SETADAPTERPARMS;
2952 return -0;
2953 default:
2954 if (cmd->hdr.return_code) {
2955 QETH_DBF_MESSAGE(1, "%s IPA_CMD_QIPASSIST: Unhandled "
2956 "rc=%d\n",
2957 dev_name(&card->gdev->dev),
2958 cmd->hdr.return_code);
2959 return 0;
2960 }
2961 }
2962
2945 if (cmd->hdr.prot_version == QETH_PROT_IPV4) { 2963 if (cmd->hdr.prot_version == QETH_PROT_IPV4) {
2946 card->options.ipa4.supported_funcs = cmd->hdr.ipa_supported; 2964 card->options.ipa4.supported_funcs = cmd->hdr.ipa_supported;
2947 card->options.ipa4.enabled_funcs = cmd->hdr.ipa_enabled; 2965 card->options.ipa4.enabled_funcs = cmd->hdr.ipa_enabled;
2948 } else { 2966 } else if (cmd->hdr.prot_version == QETH_PROT_IPV6) {
2949 card->options.ipa6.supported_funcs = cmd->hdr.ipa_supported; 2967 card->options.ipa6.supported_funcs = cmd->hdr.ipa_supported;
2950 card->options.ipa6.enabled_funcs = cmd->hdr.ipa_enabled; 2968 card->options.ipa6.enabled_funcs = cmd->hdr.ipa_enabled;
2951 } 2969 } else
2970 QETH_DBF_MESSAGE(1, "%s IPA_CMD_QIPASSIST: Flawed LIC detected"
2971 "\n", dev_name(&card->gdev->dev));
2952 QETH_DBF_TEXT(SETUP, 2, "suppenbl"); 2972 QETH_DBF_TEXT(SETUP, 2, "suppenbl");
2953 QETH_DBF_TEXT_(SETUP, 2, "%08x", (__u32)cmd->hdr.ipa_supported); 2973 QETH_DBF_TEXT_(SETUP, 2, "%08x", (__u32)cmd->hdr.ipa_supported);
2954 QETH_DBF_TEXT_(SETUP, 2, "%08x", (__u32)cmd->hdr.ipa_enabled); 2974 QETH_DBF_TEXT_(SETUP, 2, "%08x", (__u32)cmd->hdr.ipa_enabled);
diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c
index 2db409330c2..fddb62654b6 100644
--- a/drivers/s390/net/qeth_l2_main.c
+++ b/drivers/s390/net/qeth_l2_main.c
@@ -626,10 +626,13 @@ static int qeth_l2_request_initial_mac(struct qeth_card *card)
626 QETH_DBF_TEXT(SETUP, 2, "doL2init"); 626 QETH_DBF_TEXT(SETUP, 2, "doL2init");
627 QETH_DBF_TEXT_(SETUP, 2, "doL2%s", CARD_BUS_ID(card)); 627 QETH_DBF_TEXT_(SETUP, 2, "doL2%s", CARD_BUS_ID(card));
628 628
629 rc = qeth_query_setadapterparms(card); 629 if (qeth_is_supported(card, IPA_SETADAPTERPARMS)) {
630 if (rc) { 630 rc = qeth_query_setadapterparms(card);
631 QETH_DBF_MESSAGE(2, "could not query adapter parameters on " 631 if (rc) {
632 "device %s: x%x\n", CARD_BUS_ID(card), rc); 632 QETH_DBF_MESSAGE(2, "could not query adapter "
633 "parameters on device %s: x%x\n",
634 CARD_BUS_ID(card), rc);
635 }
633 } 636 }
634 637
635 if (card->info.type == QETH_CARD_TYPE_IQD || 638 if (card->info.type == QETH_CARD_TYPE_IQD ||
@@ -676,7 +679,7 @@ static int qeth_l2_set_mac_address(struct net_device *dev, void *p)
676 return -ERESTARTSYS; 679 return -ERESTARTSYS;
677 } 680 }
678 rc = qeth_l2_send_delmac(card, &card->dev->dev_addr[0]); 681 rc = qeth_l2_send_delmac(card, &card->dev->dev_addr[0]);
679 if (!rc) 682 if (!rc || (rc == IPA_RC_L2_MAC_NOT_FOUND))
680 rc = qeth_l2_send_setmac(card, addr->sa_data); 683 rc = qeth_l2_send_setmac(card, addr->sa_data);
681 return rc ? -EINVAL : 0; 684 return rc ? -EINVAL : 0;
682} 685}
@@ -1141,11 +1144,12 @@ static int qeth_l2_recover(void *ptr)
1141 dev_info(&card->gdev->dev, 1144 dev_info(&card->gdev->dev,
1142 "Device successfully recovered!\n"); 1145 "Device successfully recovered!\n");
1143 else { 1146 else {
1144 rtnl_lock(); 1147 if (rtnl_trylock()) {
1145 dev_close(card->dev); 1148 dev_close(card->dev);
1146 rtnl_unlock(); 1149 rtnl_unlock();
1147 dev_warn(&card->gdev->dev, "The qeth device driver " 1150 dev_warn(&card->gdev->dev, "The qeth device driver "
1148 "failed to recover an error on the device\n"); 1151 "failed to recover an error on the device\n");
1152 }
1149 } 1153 }
1150 qeth_clear_thread_start_bit(card, QETH_RECOVER_THREAD); 1154 qeth_clear_thread_start_bit(card, QETH_RECOVER_THREAD);
1151 qeth_clear_thread_running_bit(card, QETH_RECOVER_THREAD); 1155 qeth_clear_thread_running_bit(card, QETH_RECOVER_THREAD);
diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c
index 4cd310cb5bd..5ba39065849 100644
--- a/drivers/s390/net/qeth_l3_main.c
+++ b/drivers/s390/net/qeth_l3_main.c
@@ -3510,11 +3510,12 @@ static int qeth_l3_recover(void *ptr)
3510 dev_info(&card->gdev->dev, 3510 dev_info(&card->gdev->dev,
3511 "Device successfully recovered!\n"); 3511 "Device successfully recovered!\n");
3512 else { 3512 else {
3513 rtnl_lock(); 3513 if (rtnl_trylock()) {
3514 dev_close(card->dev); 3514 dev_close(card->dev);
3515 rtnl_unlock(); 3515 rtnl_unlock();
3516 dev_warn(&card->gdev->dev, "The qeth device driver " 3516 dev_warn(&card->gdev->dev, "The qeth device driver "
3517 "failed to recover an error on the device\n"); 3517 "failed to recover an error on the device\n");
3518 }
3518 } 3519 }
3519 qeth_clear_thread_start_bit(card, QETH_RECOVER_THREAD); 3520 qeth_clear_thread_start_bit(card, QETH_RECOVER_THREAD);
3520 qeth_clear_thread_running_bit(card, QETH_RECOVER_THREAD); 3521 qeth_clear_thread_running_bit(card, QETH_RECOVER_THREAD);
diff --git a/drivers/s390/net/smsgiucv.c b/drivers/s390/net/smsgiucv.c
index 207b7d74244..d8f990b6b33 100644
--- a/drivers/s390/net/smsgiucv.c
+++ b/drivers/s390/net/smsgiucv.c
@@ -157,7 +157,7 @@ static int smsg_pm_restore_thaw(struct device *dev)
157#ifdef CONFIG_PM_DEBUG 157#ifdef CONFIG_PM_DEBUG
158 printk(KERN_WARNING "smsg_pm_restore_thaw\n"); 158 printk(KERN_WARNING "smsg_pm_restore_thaw\n");
159#endif 159#endif
160 if (smsg_path && iucv_path_connected) { 160 if (smsg_path && !iucv_path_connected) {
161 memset(smsg_path, 0, sizeof(*smsg_path)); 161 memset(smsg_path, 0, sizeof(*smsg_path));
162 smsg_path->msglim = 255; 162 smsg_path->msglim = 255;
163 smsg_path->flags = 0; 163 smsg_path->flags = 0;
diff --git a/drivers/scsi/arm/fas216.c b/drivers/scsi/arm/fas216.c
index 6206a666a8e..737554c37d9 100644
--- a/drivers/scsi/arm/fas216.c
+++ b/drivers/scsi/arm/fas216.c
@@ -179,6 +179,7 @@ static void print_SCp(struct scsi_pointer *SCp, const char *prefix, const char *
179 SCp->buffers_residual, suffix); 179 SCp->buffers_residual, suffix);
180} 180}
181 181
182#ifdef CHECK_STRUCTURE
182static void fas216_dumpinfo(FAS216_Info *info) 183static void fas216_dumpinfo(FAS216_Info *info)
183{ 184{
184 static int used = 0; 185 static int used = 0;
@@ -223,7 +224,6 @@ static void fas216_dumpinfo(FAS216_Info *info)
223 info->internal_done, info->magic_end); 224 info->internal_done, info->magic_end);
224} 225}
225 226
226#ifdef CHECK_STRUCTURE
227static void __fas216_checkmagic(FAS216_Info *info, const char *func) 227static void __fas216_checkmagic(FAS216_Info *info, const char *func)
228{ 228{
229 int corruption = 0; 229 int corruption = 0;
diff --git a/drivers/scsi/arm/oak.c b/drivers/scsi/arm/oak.c
index d25f944b59c..fc6a5aabf66 100644
--- a/drivers/scsi/arm/oak.c
+++ b/drivers/scsi/arm/oak.c
@@ -21,6 +21,7 @@
21/*#define PSEUDO_DMA*/ 21/*#define PSEUDO_DMA*/
22 22
23#define OAKSCSI_PUBLIC_RELEASE 1 23#define OAKSCSI_PUBLIC_RELEASE 1
24#define DONT_USE_INTR
24 25
25#define priv(host) ((struct NCR5380_hostdata *)(host)->hostdata) 26#define priv(host) ((struct NCR5380_hostdata *)(host)->hostdata)
26#define NCR5380_local_declare() void __iomem *_base 27#define NCR5380_local_declare() void __iomem *_base
diff --git a/drivers/scsi/isci/request.c b/drivers/scsi/isci/request.c
index c1bafc3f3fb..9594ab62702 100644
--- a/drivers/scsi/isci/request.c
+++ b/drivers/scsi/isci/request.c
@@ -1972,7 +1972,7 @@ sci_io_request_frame_handler(struct isci_request *ireq,
1972 frame_index, 1972 frame_index,
1973 (void **)&frame_buffer); 1973 (void **)&frame_buffer);
1974 1974
1975 sci_controller_copy_sata_response(&ireq->stp.req, 1975 sci_controller_copy_sata_response(&ireq->stp.rsp,
1976 frame_header, 1976 frame_header,
1977 frame_buffer); 1977 frame_buffer);
1978 1978
diff --git a/drivers/scsi/qla2xxx/qla_mid.c b/drivers/scsi/qla2xxx/qla_mid.c
index bd4708a422c..20fd974f903 100644
--- a/drivers/scsi/qla2xxx/qla_mid.c
+++ b/drivers/scsi/qla2xxx/qla_mid.c
@@ -149,6 +149,7 @@ qla2x00_mark_vp_devices_dead(scsi_qla_host_t *vha)
149int 149int
150qla24xx_disable_vp(scsi_qla_host_t *vha) 150qla24xx_disable_vp(scsi_qla_host_t *vha)
151{ 151{
152 unsigned long flags;
152 int ret; 153 int ret;
153 154
154 ret = qla24xx_control_vp(vha, VCE_COMMAND_DISABLE_VPS_LOGO_ALL); 155 ret = qla24xx_control_vp(vha, VCE_COMMAND_DISABLE_VPS_LOGO_ALL);
@@ -156,7 +157,9 @@ qla24xx_disable_vp(scsi_qla_host_t *vha)
156 atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); 157 atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME);
157 158
158 /* Remove port id from vp target map */ 159 /* Remove port id from vp target map */
160 spin_lock_irqsave(&vha->hw->vport_slock, flags);
159 qlt_update_vp_map(vha, RESET_AL_PA); 161 qlt_update_vp_map(vha, RESET_AL_PA);
162 spin_unlock_irqrestore(&vha->hw->vport_slock, flags);
160 163
161 qla2x00_mark_vp_devices_dead(vha); 164 qla2x00_mark_vp_devices_dead(vha);
162 atomic_set(&vha->vp_state, VP_FAILED); 165 atomic_set(&vha->vp_state, VP_FAILED);
diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c
index 0e09d8f433d..62aa5584f64 100644
--- a/drivers/scsi/qla2xxx/qla_target.c
+++ b/drivers/scsi/qla2xxx/qla_target.c
@@ -557,6 +557,7 @@ static bool qlt_check_fcport_exist(struct scsi_qla_host *vha,
557 int pmap_len; 557 int pmap_len;
558 fc_port_t *fcport; 558 fc_port_t *fcport;
559 int global_resets; 559 int global_resets;
560 unsigned long flags;
560 561
561retry: 562retry:
562 global_resets = atomic_read(&ha->tgt.qla_tgt->tgt_global_resets_count); 563 global_resets = atomic_read(&ha->tgt.qla_tgt->tgt_global_resets_count);
@@ -625,10 +626,10 @@ retry:
625 sess->s_id.b.area, sess->loop_id, fcport->d_id.b.domain, 626 sess->s_id.b.area, sess->loop_id, fcport->d_id.b.domain,
626 fcport->d_id.b.al_pa, fcport->d_id.b.area, fcport->loop_id); 627 fcport->d_id.b.al_pa, fcport->d_id.b.area, fcport->loop_id);
627 628
628 sess->s_id = fcport->d_id; 629 spin_lock_irqsave(&ha->hardware_lock, flags);
629 sess->loop_id = fcport->loop_id; 630 ha->tgt.tgt_ops->update_sess(sess, fcport->d_id, fcport->loop_id,
630 sess->conf_compl_supported = !!(fcport->flags & 631 (fcport->flags & FCF_CONF_COMP_SUPPORTED));
631 FCF_CONF_COMP_SUPPORTED); 632 spin_unlock_irqrestore(&ha->hardware_lock, flags);
632 633
633 res = true; 634 res = true;
634 635
@@ -740,10 +741,9 @@ static struct qla_tgt_sess *qlt_create_sess(
740 qlt_undelete_sess(sess); 741 qlt_undelete_sess(sess);
741 742
742 kref_get(&sess->se_sess->sess_kref); 743 kref_get(&sess->se_sess->sess_kref);
743 sess->s_id = fcport->d_id; 744 ha->tgt.tgt_ops->update_sess(sess, fcport->d_id, fcport->loop_id,
744 sess->loop_id = fcport->loop_id; 745 (fcport->flags & FCF_CONF_COMP_SUPPORTED));
745 sess->conf_compl_supported = !!(fcport->flags & 746
746 FCF_CONF_COMP_SUPPORTED);
747 if (sess->local && !local) 747 if (sess->local && !local)
748 sess->local = 0; 748 sess->local = 0;
749 spin_unlock_irqrestore(&ha->hardware_lock, flags); 749 spin_unlock_irqrestore(&ha->hardware_lock, flags);
@@ -796,8 +796,7 @@ static struct qla_tgt_sess *qlt_create_sess(
796 */ 796 */
797 kref_get(&sess->se_sess->sess_kref); 797 kref_get(&sess->se_sess->sess_kref);
798 798
799 sess->conf_compl_supported = !!(fcport->flags & 799 sess->conf_compl_supported = (fcport->flags & FCF_CONF_COMP_SUPPORTED);
800 FCF_CONF_COMP_SUPPORTED);
801 BUILD_BUG_ON(sizeof(sess->port_name) != sizeof(fcport->port_name)); 800 BUILD_BUG_ON(sizeof(sess->port_name) != sizeof(fcport->port_name));
802 memcpy(sess->port_name, fcport->port_name, sizeof(sess->port_name)); 801 memcpy(sess->port_name, fcport->port_name, sizeof(sess->port_name));
803 802
@@ -869,10 +868,8 @@ void qlt_fc_port_added(struct scsi_qla_host *vha, fc_port_t *fcport)
869 ql_dbg(ql_dbg_tgt_mgt, vha, 0xf007, 868 ql_dbg(ql_dbg_tgt_mgt, vha, 0xf007,
870 "Reappeared sess %p\n", sess); 869 "Reappeared sess %p\n", sess);
871 } 870 }
872 sess->s_id = fcport->d_id; 871 ha->tgt.tgt_ops->update_sess(sess, fcport->d_id, fcport->loop_id,
873 sess->loop_id = fcport->loop_id; 872 (fcport->flags & FCF_CONF_COMP_SUPPORTED));
874 sess->conf_compl_supported = !!(fcport->flags &
875 FCF_CONF_COMP_SUPPORTED);
876 } 873 }
877 874
878 if (sess && sess->local) { 875 if (sess && sess->local) {
diff --git a/drivers/scsi/qla2xxx/qla_target.h b/drivers/scsi/qla2xxx/qla_target.h
index 170af157121..bad749561ec 100644
--- a/drivers/scsi/qla2xxx/qla_target.h
+++ b/drivers/scsi/qla2xxx/qla_target.h
@@ -648,6 +648,7 @@ struct qla_tgt_func_tmpl {
648 648
649 int (*check_initiator_node_acl)(struct scsi_qla_host *, unsigned char *, 649 int (*check_initiator_node_acl)(struct scsi_qla_host *, unsigned char *,
650 void *, uint8_t *, uint16_t); 650 void *, uint8_t *, uint16_t);
651 void (*update_sess)(struct qla_tgt_sess *, port_id_t, uint16_t, bool);
651 struct qla_tgt_sess *(*find_sess_by_loop_id)(struct scsi_qla_host *, 652 struct qla_tgt_sess *(*find_sess_by_loop_id)(struct scsi_qla_host *,
652 const uint16_t); 653 const uint16_t);
653 struct qla_tgt_sess *(*find_sess_by_s_id)(struct scsi_qla_host *, 654 struct qla_tgt_sess *(*find_sess_by_s_id)(struct scsi_qla_host *,
diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
index 2358c16c4c8..3d74f2f39ae 100644
--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
+++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
@@ -237,7 +237,7 @@ static char *tcm_qla2xxx_get_fabric_wwn(struct se_portal_group *se_tpg)
237 struct tcm_qla2xxx_tpg, se_tpg); 237 struct tcm_qla2xxx_tpg, se_tpg);
238 struct tcm_qla2xxx_lport *lport = tpg->lport; 238 struct tcm_qla2xxx_lport *lport = tpg->lport;
239 239
240 return &lport->lport_name[0]; 240 return lport->lport_naa_name;
241} 241}
242 242
243static char *tcm_qla2xxx_npiv_get_fabric_wwn(struct se_portal_group *se_tpg) 243static char *tcm_qla2xxx_npiv_get_fabric_wwn(struct se_portal_group *se_tpg)
@@ -1457,6 +1457,78 @@ static int tcm_qla2xxx_check_initiator_node_acl(
1457 return 0; 1457 return 0;
1458} 1458}
1459 1459
1460static void tcm_qla2xxx_update_sess(struct qla_tgt_sess *sess, port_id_t s_id,
1461 uint16_t loop_id, bool conf_compl_supported)
1462{
1463 struct qla_tgt *tgt = sess->tgt;
1464 struct qla_hw_data *ha = tgt->ha;
1465 struct tcm_qla2xxx_lport *lport = ha->tgt.target_lport_ptr;
1466 struct se_node_acl *se_nacl = sess->se_sess->se_node_acl;
1467 struct tcm_qla2xxx_nacl *nacl = container_of(se_nacl,
1468 struct tcm_qla2xxx_nacl, se_node_acl);
1469 u32 key;
1470
1471
1472 if (sess->loop_id != loop_id || sess->s_id.b24 != s_id.b24)
1473 pr_info("Updating session %p from port %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x loop_id %d -> %d s_id %x:%x:%x -> %x:%x:%x\n",
1474 sess,
1475 sess->port_name[0], sess->port_name[1],
1476 sess->port_name[2], sess->port_name[3],
1477 sess->port_name[4], sess->port_name[5],
1478 sess->port_name[6], sess->port_name[7],
1479 sess->loop_id, loop_id,
1480 sess->s_id.b.domain, sess->s_id.b.area, sess->s_id.b.al_pa,
1481 s_id.b.domain, s_id.b.area, s_id.b.al_pa);
1482
1483 if (sess->loop_id != loop_id) {
1484 /*
1485 * Because we can shuffle loop IDs around and we
1486 * update different sessions non-atomically, we might
1487 * have overwritten this session's old loop ID
1488 * already, and we might end up overwriting some other
1489 * session that will be updated later. So we have to
1490 * be extra careful and we can't warn about those things...
1491 */
1492 if (lport->lport_loopid_map[sess->loop_id].se_nacl == se_nacl)
1493 lport->lport_loopid_map[sess->loop_id].se_nacl = NULL;
1494
1495 lport->lport_loopid_map[loop_id].se_nacl = se_nacl;
1496
1497 sess->loop_id = loop_id;
1498 }
1499
1500 if (sess->s_id.b24 != s_id.b24) {
1501 key = (((u32) sess->s_id.b.domain << 16) |
1502 ((u32) sess->s_id.b.area << 8) |
1503 ((u32) sess->s_id.b.al_pa));
1504
1505 if (btree_lookup32(&lport->lport_fcport_map, key))
1506 WARN(btree_remove32(&lport->lport_fcport_map, key) != se_nacl,
1507 "Found wrong se_nacl when updating s_id %x:%x:%x\n",
1508 sess->s_id.b.domain, sess->s_id.b.area, sess->s_id.b.al_pa);
1509 else
1510 WARN(1, "No lport_fcport_map entry for s_id %x:%x:%x\n",
1511 sess->s_id.b.domain, sess->s_id.b.area, sess->s_id.b.al_pa);
1512
1513 key = (((u32) s_id.b.domain << 16) |
1514 ((u32) s_id.b.area << 8) |
1515 ((u32) s_id.b.al_pa));
1516
1517 if (btree_lookup32(&lport->lport_fcport_map, key)) {
1518 WARN(1, "Already have lport_fcport_map entry for s_id %x:%x:%x\n",
1519 s_id.b.domain, s_id.b.area, s_id.b.al_pa);
1520 btree_update32(&lport->lport_fcport_map, key, se_nacl);
1521 } else {
1522 btree_insert32(&lport->lport_fcport_map, key, se_nacl, GFP_ATOMIC);
1523 }
1524
1525 sess->s_id = s_id;
1526 nacl->nport_id = key;
1527 }
1528
1529 sess->conf_compl_supported = conf_compl_supported;
1530}
1531
1460/* 1532/*
1461 * Calls into tcm_qla2xxx used by qla2xxx LLD I/O path. 1533 * Calls into tcm_qla2xxx used by qla2xxx LLD I/O path.
1462 */ 1534 */
@@ -1467,6 +1539,7 @@ static struct qla_tgt_func_tmpl tcm_qla2xxx_template = {
1467 .free_cmd = tcm_qla2xxx_free_cmd, 1539 .free_cmd = tcm_qla2xxx_free_cmd,
1468 .free_mcmd = tcm_qla2xxx_free_mcmd, 1540 .free_mcmd = tcm_qla2xxx_free_mcmd,
1469 .free_session = tcm_qla2xxx_free_session, 1541 .free_session = tcm_qla2xxx_free_session,
1542 .update_sess = tcm_qla2xxx_update_sess,
1470 .check_initiator_node_acl = tcm_qla2xxx_check_initiator_node_acl, 1543 .check_initiator_node_acl = tcm_qla2xxx_check_initiator_node_acl,
1471 .find_sess_by_s_id = tcm_qla2xxx_find_sess_by_s_id, 1544 .find_sess_by_s_id = tcm_qla2xxx_find_sess_by_s_id,
1472 .find_sess_by_loop_id = tcm_qla2xxx_find_sess_by_loop_id, 1545 .find_sess_by_loop_id = tcm_qla2xxx_find_sess_by_loop_id,
@@ -1534,6 +1607,7 @@ static struct se_wwn *tcm_qla2xxx_make_lport(
1534 lport->lport_wwpn = wwpn; 1607 lport->lport_wwpn = wwpn;
1535 tcm_qla2xxx_format_wwn(&lport->lport_name[0], TCM_QLA2XXX_NAMELEN, 1608 tcm_qla2xxx_format_wwn(&lport->lport_name[0], TCM_QLA2XXX_NAMELEN,
1536 wwpn); 1609 wwpn);
1610 sprintf(lport->lport_naa_name, "naa.%016llx", (unsigned long long) wwpn);
1537 1611
1538 ret = tcm_qla2xxx_init_lport(lport); 1612 ret = tcm_qla2xxx_init_lport(lport);
1539 if (ret != 0) 1613 if (ret != 0)
@@ -1601,6 +1675,7 @@ static struct se_wwn *tcm_qla2xxx_npiv_make_lport(
1601 lport->lport_npiv_wwnn = npiv_wwnn; 1675 lport->lport_npiv_wwnn = npiv_wwnn;
1602 tcm_qla2xxx_npiv_format_wwn(&lport->lport_npiv_name[0], 1676 tcm_qla2xxx_npiv_format_wwn(&lport->lport_npiv_name[0],
1603 TCM_QLA2XXX_NAMELEN, npiv_wwpn, npiv_wwnn); 1677 TCM_QLA2XXX_NAMELEN, npiv_wwpn, npiv_wwnn);
1678 sprintf(lport->lport_naa_name, "naa.%016llx", (unsigned long long) npiv_wwpn);
1604 1679
1605/* FIXME: tcm_qla2xxx_npiv_make_lport */ 1680/* FIXME: tcm_qla2xxx_npiv_make_lport */
1606 ret = -ENOSYS; 1681 ret = -ENOSYS;
diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.h b/drivers/scsi/qla2xxx/tcm_qla2xxx.h
index 82549810335..9ba075fe978 100644
--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.h
+++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.h
@@ -61,6 +61,8 @@ struct tcm_qla2xxx_lport {
61 u64 lport_npiv_wwnn; 61 u64 lport_npiv_wwnn;
62 /* ASCII formatted WWPN for FC Target Lport */ 62 /* ASCII formatted WWPN for FC Target Lport */
63 char lport_name[TCM_QLA2XXX_NAMELEN]; 63 char lport_name[TCM_QLA2XXX_NAMELEN];
64 /* ASCII formatted naa WWPN for VPD page 83 etc */
65 char lport_naa_name[TCM_QLA2XXX_NAMELEN];
64 /* ASCII formatted WWPN+WWNN for NPIV FC Target Lport */ 66 /* ASCII formatted WWPN+WWNN for NPIV FC Target Lport */
65 char lport_npiv_name[TCM_QLA2XXX_NPIV_NAMELEN]; 67 char lport_npiv_name[TCM_QLA2XXX_NPIV_NAMELEN];
66 /* map for fc_port pointers in 24-bit FC Port ID space */ 68 /* map for fc_port pointers in 24-bit FC Port ID space */
diff --git a/drivers/scsi/qlogicpti.c b/drivers/scsi/qlogicpti.c
index b191dd54920..71fddbc60f1 100644
--- a/drivers/scsi/qlogicpti.c
+++ b/drivers/scsi/qlogicpti.c
@@ -1294,26 +1294,19 @@ static struct scsi_host_template qpti_template = {
1294static const struct of_device_id qpti_match[]; 1294static const struct of_device_id qpti_match[];
1295static int __devinit qpti_sbus_probe(struct platform_device *op) 1295static int __devinit qpti_sbus_probe(struct platform_device *op)
1296{ 1296{
1297 const struct of_device_id *match;
1298 struct scsi_host_template *tpnt;
1299 struct device_node *dp = op->dev.of_node; 1297 struct device_node *dp = op->dev.of_node;
1300 struct Scsi_Host *host; 1298 struct Scsi_Host *host;
1301 struct qlogicpti *qpti; 1299 struct qlogicpti *qpti;
1302 static int nqptis; 1300 static int nqptis;
1303 const char *fcode; 1301 const char *fcode;
1304 1302
1305 match = of_match_device(qpti_match, &op->dev);
1306 if (!match)
1307 return -EINVAL;
1308 tpnt = match->data;
1309
1310 /* Sometimes Antares cards come up not completely 1303 /* Sometimes Antares cards come up not completely
1311 * setup, and we get a report of a zero IRQ. 1304 * setup, and we get a report of a zero IRQ.
1312 */ 1305 */
1313 if (op->archdata.irqs[0] == 0) 1306 if (op->archdata.irqs[0] == 0)
1314 return -ENODEV; 1307 return -ENODEV;
1315 1308
1316 host = scsi_host_alloc(tpnt, sizeof(struct qlogicpti)); 1309 host = scsi_host_alloc(&qpti_template, sizeof(struct qlogicpti));
1317 if (!host) 1310 if (!host)
1318 return -ENOMEM; 1311 return -ENOMEM;
1319 1312
@@ -1445,19 +1438,15 @@ static int __devexit qpti_sbus_remove(struct platform_device *op)
1445static const struct of_device_id qpti_match[] = { 1438static const struct of_device_id qpti_match[] = {
1446 { 1439 {
1447 .name = "ptisp", 1440 .name = "ptisp",
1448 .data = &qpti_template,
1449 }, 1441 },
1450 { 1442 {
1451 .name = "PTI,ptisp", 1443 .name = "PTI,ptisp",
1452 .data = &qpti_template,
1453 }, 1444 },
1454 { 1445 {
1455 .name = "QLGC,isp", 1446 .name = "QLGC,isp",
1456 .data = &qpti_template,
1457 }, 1447 },
1458 { 1448 {
1459 .name = "SUNW,isp", 1449 .name = "SUNW,isp",
1460 .data = &qpti_template,
1461 }, 1450 },
1462 {}, 1451 {},
1463}; 1452};
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 2936b447cae..2c0d0ec8150 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -55,6 +55,7 @@
55#include <linux/cpu.h> 55#include <linux/cpu.h>
56#include <linux/mutex.h> 56#include <linux/mutex.h>
57#include <linux/async.h> 57#include <linux/async.h>
58#include <asm/unaligned.h>
58 59
59#include <scsi/scsi.h> 60#include <scsi/scsi.h>
60#include <scsi/scsi_cmnd.h> 61#include <scsi/scsi_cmnd.h>
@@ -1062,6 +1063,50 @@ int scsi_get_vpd_page(struct scsi_device *sdev, u8 page, unsigned char *buf,
1062EXPORT_SYMBOL_GPL(scsi_get_vpd_page); 1063EXPORT_SYMBOL_GPL(scsi_get_vpd_page);
1063 1064
1064/** 1065/**
1066 * scsi_report_opcode - Find out if a given command opcode is supported
1067 * @sdev: scsi device to query
1068 * @buffer: scratch buffer (must be at least 20 bytes long)
1069 * @len: length of buffer
1070 * @opcode: opcode for command to look up
1071 *
1072 * Uses the REPORT SUPPORTED OPERATION CODES to look up the given
1073 * opcode. Returns 0 if RSOC fails or if the command opcode is
1074 * unsupported. Returns 1 if the device claims to support the command.
1075 */
1076int scsi_report_opcode(struct scsi_device *sdev, unsigned char *buffer,
1077 unsigned int len, unsigned char opcode)
1078{
1079 unsigned char cmd[16];
1080 struct scsi_sense_hdr sshdr;
1081 int result;
1082
1083 if (sdev->no_report_opcodes || sdev->scsi_level < SCSI_SPC_3)
1084 return 0;
1085
1086 memset(cmd, 0, 16);
1087 cmd[0] = MAINTENANCE_IN;
1088 cmd[1] = MI_REPORT_SUPPORTED_OPERATION_CODES;
1089 cmd[2] = 1; /* One command format */
1090 cmd[3] = opcode;
1091 put_unaligned_be32(len, &cmd[6]);
1092 memset(buffer, 0, len);
1093
1094 result = scsi_execute_req(sdev, cmd, DMA_FROM_DEVICE, buffer, len,
1095 &sshdr, 30 * HZ, 3, NULL);
1096
1097 if (result && scsi_sense_valid(&sshdr) &&
1098 sshdr.sense_key == ILLEGAL_REQUEST &&
1099 (sshdr.asc == 0x20 || sshdr.asc == 0x24) && sshdr.ascq == 0x00)
1100 return 0;
1101
1102 if ((buffer[1] & 3) == 3) /* Command supported */
1103 return 1;
1104
1105 return 0;
1106}
1107EXPORT_SYMBOL(scsi_report_opcode);
1108
1109/**
1065 * scsi_device_get - get an additional reference to a scsi_device 1110 * scsi_device_get - get an additional reference to a scsi_device
1066 * @sdev: device to get a reference to 1111 * @sdev: device to get a reference to
1067 * 1112 *
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index da36a3a81a9..9032e910bca 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -900,11 +900,23 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
900 action = ACTION_FAIL; 900 action = ACTION_FAIL;
901 error = -EILSEQ; 901 error = -EILSEQ;
902 /* INVALID COMMAND OPCODE or INVALID FIELD IN CDB */ 902 /* INVALID COMMAND OPCODE or INVALID FIELD IN CDB */
903 } else if ((sshdr.asc == 0x20 || sshdr.asc == 0x24) && 903 } else if (sshdr.asc == 0x20 || sshdr.asc == 0x24) {
904 (cmd->cmnd[0] == UNMAP || 904 switch (cmd->cmnd[0]) {
905 cmd->cmnd[0] == WRITE_SAME_16 || 905 case UNMAP:
906 cmd->cmnd[0] == WRITE_SAME)) { 906 description = "Discard failure";
907 description = "Discard failure"; 907 break;
908 case WRITE_SAME:
909 case WRITE_SAME_16:
910 if (cmd->cmnd[1] & 0x8)
911 description = "Discard failure";
912 else
913 description =
914 "Write same failure";
915 break;
916 default:
917 description = "Invalid command failure";
918 break;
919 }
908 action = ACTION_FAIL; 920 action = ACTION_FAIL;
909 error = -EREMOTEIO; 921 error = -EREMOTEIO;
910 } else 922 } else
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 12f6fdfc114..352bc77b7c8 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -99,6 +99,7 @@ MODULE_ALIAS_SCSI_DEVICE(TYPE_RBC);
99#endif 99#endif
100 100
101static void sd_config_discard(struct scsi_disk *, unsigned int); 101static void sd_config_discard(struct scsi_disk *, unsigned int);
102static void sd_config_write_same(struct scsi_disk *);
102static int sd_revalidate_disk(struct gendisk *); 103static int sd_revalidate_disk(struct gendisk *);
103static void sd_unlock_native_capacity(struct gendisk *disk); 104static void sd_unlock_native_capacity(struct gendisk *disk);
104static int sd_probe(struct device *); 105static int sd_probe(struct device *);
@@ -395,6 +396,45 @@ sd_store_max_medium_access_timeouts(struct device *dev,
395 return err ? err : count; 396 return err ? err : count;
396} 397}
397 398
399static ssize_t
400sd_show_write_same_blocks(struct device *dev, struct device_attribute *attr,
401 char *buf)
402{
403 struct scsi_disk *sdkp = to_scsi_disk(dev);
404
405 return snprintf(buf, 20, "%u\n", sdkp->max_ws_blocks);
406}
407
408static ssize_t
409sd_store_write_same_blocks(struct device *dev, struct device_attribute *attr,
410 const char *buf, size_t count)
411{
412 struct scsi_disk *sdkp = to_scsi_disk(dev);
413 struct scsi_device *sdp = sdkp->device;
414 unsigned long max;
415 int err;
416
417 if (!capable(CAP_SYS_ADMIN))
418 return -EACCES;
419
420 if (sdp->type != TYPE_DISK)
421 return -EINVAL;
422
423 err = kstrtoul(buf, 10, &max);
424
425 if (err)
426 return err;
427
428 if (max == 0)
429 sdp->no_write_same = 1;
430 else if (max <= SD_MAX_WS16_BLOCKS)
431 sdkp->max_ws_blocks = max;
432
433 sd_config_write_same(sdkp);
434
435 return count;
436}
437
398static struct device_attribute sd_disk_attrs[] = { 438static struct device_attribute sd_disk_attrs[] = {
399 __ATTR(cache_type, S_IRUGO|S_IWUSR, sd_show_cache_type, 439 __ATTR(cache_type, S_IRUGO|S_IWUSR, sd_show_cache_type,
400 sd_store_cache_type), 440 sd_store_cache_type),
@@ -410,6 +450,8 @@ static struct device_attribute sd_disk_attrs[] = {
410 __ATTR(thin_provisioning, S_IRUGO, sd_show_thin_provisioning, NULL), 450 __ATTR(thin_provisioning, S_IRUGO, sd_show_thin_provisioning, NULL),
411 __ATTR(provisioning_mode, S_IRUGO|S_IWUSR, sd_show_provisioning_mode, 451 __ATTR(provisioning_mode, S_IRUGO|S_IWUSR, sd_show_provisioning_mode,
412 sd_store_provisioning_mode), 452 sd_store_provisioning_mode),
453 __ATTR(max_write_same_blocks, S_IRUGO|S_IWUSR,
454 sd_show_write_same_blocks, sd_store_write_same_blocks),
413 __ATTR(max_medium_access_timeouts, S_IRUGO|S_IWUSR, 455 __ATTR(max_medium_access_timeouts, S_IRUGO|S_IWUSR,
414 sd_show_max_medium_access_timeouts, 456 sd_show_max_medium_access_timeouts,
415 sd_store_max_medium_access_timeouts), 457 sd_store_max_medium_access_timeouts),
@@ -561,19 +603,23 @@ static void sd_config_discard(struct scsi_disk *sdkp, unsigned int mode)
561 return; 603 return;
562 604
563 case SD_LBP_UNMAP: 605 case SD_LBP_UNMAP:
564 max_blocks = min_not_zero(sdkp->max_unmap_blocks, 0xffffffff); 606 max_blocks = min_not_zero(sdkp->max_unmap_blocks,
607 (u32)SD_MAX_WS16_BLOCKS);
565 break; 608 break;
566 609
567 case SD_LBP_WS16: 610 case SD_LBP_WS16:
568 max_blocks = min_not_zero(sdkp->max_ws_blocks, 0xffffffff); 611 max_blocks = min_not_zero(sdkp->max_ws_blocks,
612 (u32)SD_MAX_WS16_BLOCKS);
569 break; 613 break;
570 614
571 case SD_LBP_WS10: 615 case SD_LBP_WS10:
572 max_blocks = min_not_zero(sdkp->max_ws_blocks, (u32)0xffff); 616 max_blocks = min_not_zero(sdkp->max_ws_blocks,
617 (u32)SD_MAX_WS10_BLOCKS);
573 break; 618 break;
574 619
575 case SD_LBP_ZERO: 620 case SD_LBP_ZERO:
576 max_blocks = min_not_zero(sdkp->max_ws_blocks, (u32)0xffff); 621 max_blocks = min_not_zero(sdkp->max_ws_blocks,
622 (u32)SD_MAX_WS10_BLOCKS);
577 q->limits.discard_zeroes_data = 1; 623 q->limits.discard_zeroes_data = 1;
578 break; 624 break;
579 } 625 }
@@ -583,29 +629,26 @@ static void sd_config_discard(struct scsi_disk *sdkp, unsigned int mode)
583} 629}
584 630
585/** 631/**
586 * scsi_setup_discard_cmnd - unmap blocks on thinly provisioned device 632 * sd_setup_discard_cmnd - unmap blocks on thinly provisioned device
587 * @sdp: scsi device to operate one 633 * @sdp: scsi device to operate one
588 * @rq: Request to prepare 634 * @rq: Request to prepare
589 * 635 *
590 * Will issue either UNMAP or WRITE SAME(16) depending on preference 636 * Will issue either UNMAP or WRITE SAME(16) depending on preference
591 * indicated by target device. 637 * indicated by target device.
592 **/ 638 **/
593static int scsi_setup_discard_cmnd(struct scsi_device *sdp, struct request *rq) 639static int sd_setup_discard_cmnd(struct scsi_device *sdp, struct request *rq)
594{ 640{
595 struct scsi_disk *sdkp = scsi_disk(rq->rq_disk); 641 struct scsi_disk *sdkp = scsi_disk(rq->rq_disk);
596 struct bio *bio = rq->bio; 642 sector_t sector = blk_rq_pos(rq);
597 sector_t sector = bio->bi_sector; 643 unsigned int nr_sectors = blk_rq_sectors(rq);
598 unsigned int nr_sectors = bio_sectors(bio); 644 unsigned int nr_bytes = blk_rq_bytes(rq);
599 unsigned int len; 645 unsigned int len;
600 int ret; 646 int ret;
601 char *buf; 647 char *buf;
602 struct page *page; 648 struct page *page;
603 649
604 if (sdkp->device->sector_size == 4096) { 650 sector >>= ilog2(sdp->sector_size) - 9;
605 sector >>= 3; 651 nr_sectors >>= ilog2(sdp->sector_size) - 9;
606 nr_sectors >>= 3;
607 }
608
609 rq->timeout = SD_TIMEOUT; 652 rq->timeout = SD_TIMEOUT;
610 653
611 memset(rq->cmd, 0, rq->cmd_len); 654 memset(rq->cmd, 0, rq->cmd_len);
@@ -660,6 +703,7 @@ static int scsi_setup_discard_cmnd(struct scsi_device *sdp, struct request *rq)
660 blk_add_request_payload(rq, page, len); 703 blk_add_request_payload(rq, page, len);
661 ret = scsi_setup_blk_pc_cmnd(sdp, rq); 704 ret = scsi_setup_blk_pc_cmnd(sdp, rq);
662 rq->buffer = page_address(page); 705 rq->buffer = page_address(page);
706 rq->__data_len = nr_bytes;
663 707
664out: 708out:
665 if (ret != BLKPREP_OK) { 709 if (ret != BLKPREP_OK) {
@@ -669,6 +713,83 @@ out:
669 return ret; 713 return ret;
670} 714}
671 715
716static void sd_config_write_same(struct scsi_disk *sdkp)
717{
718 struct request_queue *q = sdkp->disk->queue;
719 unsigned int logical_block_size = sdkp->device->sector_size;
720 unsigned int blocks = 0;
721
722 if (sdkp->device->no_write_same) {
723 sdkp->max_ws_blocks = 0;
724 goto out;
725 }
726
727 /* Some devices can not handle block counts above 0xffff despite
728 * supporting WRITE SAME(16). Consequently we default to 64k
729 * blocks per I/O unless the device explicitly advertises a
730 * bigger limit.
731 */
732 if (sdkp->max_ws_blocks == 0)
733 sdkp->max_ws_blocks = SD_MAX_WS10_BLOCKS;
734
735 if (sdkp->ws16 || sdkp->max_ws_blocks > SD_MAX_WS10_BLOCKS)
736 blocks = min_not_zero(sdkp->max_ws_blocks,
737 (u32)SD_MAX_WS16_BLOCKS);
738 else
739 blocks = min_not_zero(sdkp->max_ws_blocks,
740 (u32)SD_MAX_WS10_BLOCKS);
741
742out:
743 blk_queue_max_write_same_sectors(q, blocks * (logical_block_size >> 9));
744}
745
746/**
747 * sd_setup_write_same_cmnd - write the same data to multiple blocks
748 * @sdp: scsi device to operate one
749 * @rq: Request to prepare
750 *
751 * Will issue either WRITE SAME(10) or WRITE SAME(16) depending on
752 * preference indicated by target device.
753 **/
754static int sd_setup_write_same_cmnd(struct scsi_device *sdp, struct request *rq)
755{
756 struct scsi_disk *sdkp = scsi_disk(rq->rq_disk);
757 struct bio *bio = rq->bio;
758 sector_t sector = blk_rq_pos(rq);
759 unsigned int nr_sectors = blk_rq_sectors(rq);
760 unsigned int nr_bytes = blk_rq_bytes(rq);
761 int ret;
762
763 if (sdkp->device->no_write_same)
764 return BLKPREP_KILL;
765
766 BUG_ON(bio_offset(bio) || bio_iovec(bio)->bv_len != sdp->sector_size);
767
768 sector >>= ilog2(sdp->sector_size) - 9;
769 nr_sectors >>= ilog2(sdp->sector_size) - 9;
770
771 rq->__data_len = sdp->sector_size;
772 rq->timeout = SD_WRITE_SAME_TIMEOUT;
773 memset(rq->cmd, 0, rq->cmd_len);
774
775 if (sdkp->ws16 || sector > 0xffffffff || nr_sectors > 0xffff) {
776 rq->cmd_len = 16;
777 rq->cmd[0] = WRITE_SAME_16;
778 put_unaligned_be64(sector, &rq->cmd[2]);
779 put_unaligned_be32(nr_sectors, &rq->cmd[10]);
780 } else {
781 rq->cmd_len = 10;
782 rq->cmd[0] = WRITE_SAME;
783 put_unaligned_be32(sector, &rq->cmd[2]);
784 put_unaligned_be16(nr_sectors, &rq->cmd[7]);
785 }
786
787 ret = scsi_setup_blk_pc_cmnd(sdp, rq);
788 rq->__data_len = nr_bytes;
789
790 return ret;
791}
792
672static int scsi_setup_flush_cmnd(struct scsi_device *sdp, struct request *rq) 793static int scsi_setup_flush_cmnd(struct scsi_device *sdp, struct request *rq)
673{ 794{
674 rq->timeout = SD_FLUSH_TIMEOUT; 795 rq->timeout = SD_FLUSH_TIMEOUT;
@@ -712,7 +833,10 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq)
712 * block PC requests to make life easier. 833 * block PC requests to make life easier.
713 */ 834 */
714 if (rq->cmd_flags & REQ_DISCARD) { 835 if (rq->cmd_flags & REQ_DISCARD) {
715 ret = scsi_setup_discard_cmnd(sdp, rq); 836 ret = sd_setup_discard_cmnd(sdp, rq);
837 goto out;
838 } else if (rq->cmd_flags & REQ_WRITE_SAME) {
839 ret = sd_setup_write_same_cmnd(sdp, rq);
716 goto out; 840 goto out;
717 } else if (rq->cmd_flags & REQ_FLUSH) { 841 } else if (rq->cmd_flags & REQ_FLUSH) {
718 ret = scsi_setup_flush_cmnd(sdp, rq); 842 ret = scsi_setup_flush_cmnd(sdp, rq);
@@ -1482,12 +1606,21 @@ static int sd_done(struct scsi_cmnd *SCpnt)
1482 unsigned int good_bytes = result ? 0 : scsi_bufflen(SCpnt); 1606 unsigned int good_bytes = result ? 0 : scsi_bufflen(SCpnt);
1483 struct scsi_sense_hdr sshdr; 1607 struct scsi_sense_hdr sshdr;
1484 struct scsi_disk *sdkp = scsi_disk(SCpnt->request->rq_disk); 1608 struct scsi_disk *sdkp = scsi_disk(SCpnt->request->rq_disk);
1609 struct request *req = SCpnt->request;
1485 int sense_valid = 0; 1610 int sense_valid = 0;
1486 int sense_deferred = 0; 1611 int sense_deferred = 0;
1487 unsigned char op = SCpnt->cmnd[0]; 1612 unsigned char op = SCpnt->cmnd[0];
1613 unsigned char unmap = SCpnt->cmnd[1] & 8;
1488 1614
1489 if ((SCpnt->request->cmd_flags & REQ_DISCARD) && !result) 1615 if (req->cmd_flags & REQ_DISCARD || req->cmd_flags & REQ_WRITE_SAME) {
1490 scsi_set_resid(SCpnt, 0); 1616 if (!result) {
1617 good_bytes = blk_rq_bytes(req);
1618 scsi_set_resid(SCpnt, 0);
1619 } else {
1620 good_bytes = 0;
1621 scsi_set_resid(SCpnt, blk_rq_bytes(req));
1622 }
1623 }
1491 1624
1492 if (result) { 1625 if (result) {
1493 sense_valid = scsi_command_normalize_sense(SCpnt, &sshdr); 1626 sense_valid = scsi_command_normalize_sense(SCpnt, &sshdr);
@@ -1536,9 +1669,25 @@ static int sd_done(struct scsi_cmnd *SCpnt)
1536 if (sshdr.asc == 0x10) /* DIX: Host detected corruption */ 1669 if (sshdr.asc == 0x10) /* DIX: Host detected corruption */
1537 good_bytes = sd_completed_bytes(SCpnt); 1670 good_bytes = sd_completed_bytes(SCpnt);
1538 /* INVALID COMMAND OPCODE or INVALID FIELD IN CDB */ 1671 /* INVALID COMMAND OPCODE or INVALID FIELD IN CDB */
1539 if ((sshdr.asc == 0x20 || sshdr.asc == 0x24) && 1672 if (sshdr.asc == 0x20 || sshdr.asc == 0x24) {
1540 (op == UNMAP || op == WRITE_SAME_16 || op == WRITE_SAME)) 1673 switch (op) {
1541 sd_config_discard(sdkp, SD_LBP_DISABLE); 1674 case UNMAP:
1675 sd_config_discard(sdkp, SD_LBP_DISABLE);
1676 break;
1677 case WRITE_SAME_16:
1678 case WRITE_SAME:
1679 if (unmap)
1680 sd_config_discard(sdkp, SD_LBP_DISABLE);
1681 else {
1682 sdkp->device->no_write_same = 1;
1683 sd_config_write_same(sdkp);
1684
1685 good_bytes = 0;
1686 req->__data_len = blk_rq_bytes(req);
1687 req->cmd_flags |= REQ_QUIET;
1688 }
1689 }
1690 }
1542 break; 1691 break;
1543 default: 1692 default:
1544 break; 1693 break;
@@ -2374,9 +2523,7 @@ static void sd_read_block_limits(struct scsi_disk *sdkp)
2374 if (buffer[3] == 0x3c) { 2523 if (buffer[3] == 0x3c) {
2375 unsigned int lba_count, desc_count; 2524 unsigned int lba_count, desc_count;
2376 2525
2377 sdkp->max_ws_blocks = 2526 sdkp->max_ws_blocks = (u32)get_unaligned_be64(&buffer[36]);
2378 (u32) min_not_zero(get_unaligned_be64(&buffer[36]),
2379 (u64)0xffffffff);
2380 2527
2381 if (!sdkp->lbpme) 2528 if (!sdkp->lbpme)
2382 goto out; 2529 goto out;
@@ -2469,6 +2616,13 @@ static void sd_read_block_provisioning(struct scsi_disk *sdkp)
2469 kfree(buffer); 2616 kfree(buffer);
2470} 2617}
2471 2618
2619static void sd_read_write_same(struct scsi_disk *sdkp, unsigned char *buffer)
2620{
2621 if (scsi_report_opcode(sdkp->device, buffer, SD_BUF_SIZE,
2622 WRITE_SAME_16))
2623 sdkp->ws16 = 1;
2624}
2625
2472static int sd_try_extended_inquiry(struct scsi_device *sdp) 2626static int sd_try_extended_inquiry(struct scsi_device *sdp)
2473{ 2627{
2474 /* 2628 /*
@@ -2528,6 +2682,7 @@ static int sd_revalidate_disk(struct gendisk *disk)
2528 sd_read_write_protect_flag(sdkp, buffer); 2682 sd_read_write_protect_flag(sdkp, buffer);
2529 sd_read_cache_type(sdkp, buffer); 2683 sd_read_cache_type(sdkp, buffer);
2530 sd_read_app_tag_own(sdkp, buffer); 2684 sd_read_app_tag_own(sdkp, buffer);
2685 sd_read_write_same(sdkp, buffer);
2531 } 2686 }
2532 2687
2533 sdkp->first_scan = 0; 2688 sdkp->first_scan = 0;
@@ -2545,6 +2700,7 @@ static int sd_revalidate_disk(struct gendisk *disk)
2545 blk_queue_flush(sdkp->disk->queue, flush); 2700 blk_queue_flush(sdkp->disk->queue, flush);
2546 2701
2547 set_capacity(disk, sdkp->capacity); 2702 set_capacity(disk, sdkp->capacity);
2703 sd_config_write_same(sdkp);
2548 kfree(buffer); 2704 kfree(buffer);
2549 2705
2550 out: 2706 out:
diff --git a/drivers/scsi/sd.h b/drivers/scsi/sd.h
index 47c52a6d733..74a1e4ca540 100644
--- a/drivers/scsi/sd.h
+++ b/drivers/scsi/sd.h
@@ -14,6 +14,7 @@
14#define SD_TIMEOUT (30 * HZ) 14#define SD_TIMEOUT (30 * HZ)
15#define SD_MOD_TIMEOUT (75 * HZ) 15#define SD_MOD_TIMEOUT (75 * HZ)
16#define SD_FLUSH_TIMEOUT (60 * HZ) 16#define SD_FLUSH_TIMEOUT (60 * HZ)
17#define SD_WRITE_SAME_TIMEOUT (120 * HZ)
17 18
18/* 19/*
19 * Number of allowed retries 20 * Number of allowed retries
@@ -39,6 +40,11 @@ enum {
39}; 40};
40 41
41enum { 42enum {
43 SD_MAX_WS10_BLOCKS = 0xffff,
44 SD_MAX_WS16_BLOCKS = 0x7fffff,
45};
46
47enum {
42 SD_LBP_FULL = 0, /* Full logical block provisioning */ 48 SD_LBP_FULL = 0, /* Full logical block provisioning */
43 SD_LBP_UNMAP, /* Use UNMAP command */ 49 SD_LBP_UNMAP, /* Use UNMAP command */
44 SD_LBP_WS16, /* Use WRITE SAME(16) with UNMAP bit */ 50 SD_LBP_WS16, /* Use WRITE SAME(16) with UNMAP bit */
@@ -77,6 +83,7 @@ struct scsi_disk {
77 unsigned lbpws : 1; 83 unsigned lbpws : 1;
78 unsigned lbpws10 : 1; 84 unsigned lbpws10 : 1;
79 unsigned lbpvpd : 1; 85 unsigned lbpvpd : 1;
86 unsigned ws16 : 1;
80}; 87};
81#define to_scsi_disk(obj) container_of(obj,struct scsi_disk,dev) 88#define to_scsi_disk(obj) container_of(obj,struct scsi_disk,dev)
82 89
diff --git a/drivers/sh/intc/access.c b/drivers/sh/intc/access.c
index f892ae1d212..114390f967d 100644
--- a/drivers/sh/intc/access.c
+++ b/drivers/sh/intc/access.c
@@ -75,54 +75,61 @@ unsigned long intc_get_field_from_handle(unsigned int value, unsigned int handle
75static unsigned long test_8(unsigned long addr, unsigned long h, 75static unsigned long test_8(unsigned long addr, unsigned long h,
76 unsigned long ignore) 76 unsigned long ignore)
77{ 77{
78 return intc_get_field_from_handle(__raw_readb(addr), h); 78 void __iomem *ptr = (void __iomem *)addr;
79 return intc_get_field_from_handle(__raw_readb(ptr), h);
79} 80}
80 81
81static unsigned long test_16(unsigned long addr, unsigned long h, 82static unsigned long test_16(unsigned long addr, unsigned long h,
82 unsigned long ignore) 83 unsigned long ignore)
83{ 84{
84 return intc_get_field_from_handle(__raw_readw(addr), h); 85 void __iomem *ptr = (void __iomem *)addr;
86 return intc_get_field_from_handle(__raw_readw(ptr), h);
85} 87}
86 88
87static unsigned long test_32(unsigned long addr, unsigned long h, 89static unsigned long test_32(unsigned long addr, unsigned long h,
88 unsigned long ignore) 90 unsigned long ignore)
89{ 91{
90 return intc_get_field_from_handle(__raw_readl(addr), h); 92 void __iomem *ptr = (void __iomem *)addr;
93 return intc_get_field_from_handle(__raw_readl(ptr), h);
91} 94}
92 95
93static unsigned long write_8(unsigned long addr, unsigned long h, 96static unsigned long write_8(unsigned long addr, unsigned long h,
94 unsigned long data) 97 unsigned long data)
95{ 98{
96 __raw_writeb(intc_set_field_from_handle(0, data, h), addr); 99 void __iomem *ptr = (void __iomem *)addr;
97 (void)__raw_readb(addr); /* Defeat write posting */ 100 __raw_writeb(intc_set_field_from_handle(0, data, h), ptr);
101 (void)__raw_readb(ptr); /* Defeat write posting */
98 return 0; 102 return 0;
99} 103}
100 104
101static unsigned long write_16(unsigned long addr, unsigned long h, 105static unsigned long write_16(unsigned long addr, unsigned long h,
102 unsigned long data) 106 unsigned long data)
103{ 107{
104 __raw_writew(intc_set_field_from_handle(0, data, h), addr); 108 void __iomem *ptr = (void __iomem *)addr;
105 (void)__raw_readw(addr); /* Defeat write posting */ 109 __raw_writew(intc_set_field_from_handle(0, data, h), ptr);
110 (void)__raw_readw(ptr); /* Defeat write posting */
106 return 0; 111 return 0;
107} 112}
108 113
109static unsigned long write_32(unsigned long addr, unsigned long h, 114static unsigned long write_32(unsigned long addr, unsigned long h,
110 unsigned long data) 115 unsigned long data)
111{ 116{
112 __raw_writel(intc_set_field_from_handle(0, data, h), addr); 117 void __iomem *ptr = (void __iomem *)addr;
113 (void)__raw_readl(addr); /* Defeat write posting */ 118 __raw_writel(intc_set_field_from_handle(0, data, h), ptr);
119 (void)__raw_readl(ptr); /* Defeat write posting */
114 return 0; 120 return 0;
115} 121}
116 122
117static unsigned long modify_8(unsigned long addr, unsigned long h, 123static unsigned long modify_8(unsigned long addr, unsigned long h,
118 unsigned long data) 124 unsigned long data)
119{ 125{
126 void __iomem *ptr = (void __iomem *)addr;
120 unsigned long flags; 127 unsigned long flags;
121 unsigned int value; 128 unsigned int value;
122 local_irq_save(flags); 129 local_irq_save(flags);
123 value = intc_set_field_from_handle(__raw_readb(addr), data, h); 130 value = intc_set_field_from_handle(__raw_readb(ptr), data, h);
124 __raw_writeb(value, addr); 131 __raw_writeb(value, ptr);
125 (void)__raw_readb(addr); /* Defeat write posting */ 132 (void)__raw_readb(ptr); /* Defeat write posting */
126 local_irq_restore(flags); 133 local_irq_restore(flags);
127 return 0; 134 return 0;
128} 135}
@@ -130,12 +137,13 @@ static unsigned long modify_8(unsigned long addr, unsigned long h,
130static unsigned long modify_16(unsigned long addr, unsigned long h, 137static unsigned long modify_16(unsigned long addr, unsigned long h,
131 unsigned long data) 138 unsigned long data)
132{ 139{
140 void __iomem *ptr = (void __iomem *)addr;
133 unsigned long flags; 141 unsigned long flags;
134 unsigned int value; 142 unsigned int value;
135 local_irq_save(flags); 143 local_irq_save(flags);
136 value = intc_set_field_from_handle(__raw_readw(addr), data, h); 144 value = intc_set_field_from_handle(__raw_readw(ptr), data, h);
137 __raw_writew(value, addr); 145 __raw_writew(value, ptr);
138 (void)__raw_readw(addr); /* Defeat write posting */ 146 (void)__raw_readw(ptr); /* Defeat write posting */
139 local_irq_restore(flags); 147 local_irq_restore(flags);
140 return 0; 148 return 0;
141} 149}
@@ -143,12 +151,13 @@ static unsigned long modify_16(unsigned long addr, unsigned long h,
143static unsigned long modify_32(unsigned long addr, unsigned long h, 151static unsigned long modify_32(unsigned long addr, unsigned long h,
144 unsigned long data) 152 unsigned long data)
145{ 153{
154 void __iomem *ptr = (void __iomem *)addr;
146 unsigned long flags; 155 unsigned long flags;
147 unsigned int value; 156 unsigned int value;
148 local_irq_save(flags); 157 local_irq_save(flags);
149 value = intc_set_field_from_handle(__raw_readl(addr), data, h); 158 value = intc_set_field_from_handle(__raw_readl(ptr), data, h);
150 __raw_writel(value, addr); 159 __raw_writel(value, ptr);
151 (void)__raw_readl(addr); /* Defeat write posting */ 160 (void)__raw_readl(ptr); /* Defeat write posting */
152 local_irq_restore(flags); 161 local_irq_restore(flags);
153 return 0; 162 return 0;
154} 163}
diff --git a/drivers/sh/intc/chip.c b/drivers/sh/intc/chip.c
index 012df2676a2..46427b48e2f 100644
--- a/drivers/sh/intc/chip.c
+++ b/drivers/sh/intc/chip.c
@@ -83,7 +83,7 @@ static void intc_mask_ack(struct irq_data *data)
83 unsigned int irq = data->irq; 83 unsigned int irq = data->irq;
84 struct intc_desc_int *d = get_intc_desc(irq); 84 struct intc_desc_int *d = get_intc_desc(irq);
85 unsigned long handle = intc_get_ack_handle(irq); 85 unsigned long handle = intc_get_ack_handle(irq);
86 unsigned long addr; 86 void __iomem *addr;
87 87
88 intc_disable(data); 88 intc_disable(data);
89 89
@@ -91,7 +91,7 @@ static void intc_mask_ack(struct irq_data *data)
91 if (handle) { 91 if (handle) {
92 unsigned int value; 92 unsigned int value;
93 93
94 addr = INTC_REG(d, _INTC_ADDR_D(handle), 0); 94 addr = (void __iomem *)INTC_REG(d, _INTC_ADDR_D(handle), 0);
95 value = intc_set_field_from_handle(0, 1, handle); 95 value = intc_set_field_from_handle(0, 1, handle);
96 96
97 switch (_INTC_FN(handle)) { 97 switch (_INTC_FN(handle)) {
diff --git a/drivers/spi/spi-mxs.c b/drivers/spi/spi-mxs.c
index edf1360ab09..86dd04d6bc8 100644
--- a/drivers/spi/spi-mxs.c
+++ b/drivers/spi/spi-mxs.c
@@ -323,6 +323,7 @@ static int mxs_spi_txrx_dma(struct mxs_spi *spi, int cs,
323 if (!ret) { 323 if (!ret) {
324 dev_err(ssp->dev, "DMA transfer timeout\n"); 324 dev_err(ssp->dev, "DMA transfer timeout\n");
325 ret = -ETIMEDOUT; 325 ret = -ETIMEDOUT;
326 dmaengine_terminate_all(ssp->dmach);
326 goto err_vmalloc; 327 goto err_vmalloc;
327 } 328 }
328 329
@@ -480,7 +481,7 @@ static int mxs_spi_transfer_one(struct spi_master *master,
480 first = last = 0; 481 first = last = 0;
481 } 482 }
482 483
483 m->status = 0; 484 m->status = status;
484 spi_finalize_current_message(master); 485 spi_finalize_current_message(master);
485 486
486 return status; 487 return status;
diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
index 919464102d3..a1db91a99b8 100644
--- a/drivers/spi/spi-pl022.c
+++ b/drivers/spi/spi-pl022.c
@@ -2186,8 +2186,6 @@ pl022_probe(struct amba_device *adev, const struct amba_id *id)
2186 printk(KERN_INFO "pl022: mapped registers from 0x%08x to %p\n", 2186 printk(KERN_INFO "pl022: mapped registers from 0x%08x to %p\n",
2187 adev->res.start, pl022->virtbase); 2187 adev->res.start, pl022->virtbase);
2188 2188
2189 pm_runtime_resume(dev);
2190
2191 pl022->clk = devm_clk_get(&adev->dev, NULL); 2189 pl022->clk = devm_clk_get(&adev->dev, NULL);
2192 if (IS_ERR(pl022->clk)) { 2190 if (IS_ERR(pl022->clk)) {
2193 status = PTR_ERR(pl022->clk); 2191 status = PTR_ERR(pl022->clk);
@@ -2292,7 +2290,6 @@ pl022_remove(struct amba_device *adev)
2292 2290
2293 clk_disable(pl022->clk); 2291 clk_disable(pl022->clk);
2294 clk_unprepare(pl022->clk); 2292 clk_unprepare(pl022->clk);
2295 pm_runtime_disable(&adev->dev);
2296 amba_release_regions(adev); 2293 amba_release_regions(adev);
2297 tasklet_disable(&pl022->pump_transfers); 2294 tasklet_disable(&pl022->pump_transfers);
2298 spi_unregister_master(pl022->master); 2295 spi_unregister_master(pl022->master);
diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
index 4894bde4bbf..30faf6d4ab9 100644
--- a/drivers/spi/spi-rspi.c
+++ b/drivers/spi/spi-rspi.c
@@ -147,8 +147,6 @@ struct rspi_data {
147 unsigned char spsr; 147 unsigned char spsr;
148 148
149 /* for dmaengine */ 149 /* for dmaengine */
150 struct sh_dmae_slave dma_tx;
151 struct sh_dmae_slave dma_rx;
152 struct dma_chan *chan_tx; 150 struct dma_chan *chan_tx;
153 struct dma_chan *chan_rx; 151 struct dma_chan *chan_rx;
154 int irq; 152 int irq;
@@ -663,20 +661,16 @@ static irqreturn_t rspi_irq(int irq, void *_sr)
663 return ret; 661 return ret;
664} 662}
665 663
666static bool rspi_filter(struct dma_chan *chan, void *filter_param) 664static int __devinit rspi_request_dma(struct rspi_data *rspi,
667{ 665 struct platform_device *pdev)
668 chan->private = filter_param;
669 return true;
670}
671
672static void __devinit rspi_request_dma(struct rspi_data *rspi,
673 struct platform_device *pdev)
674{ 666{
675 struct rspi_plat_data *rspi_pd = pdev->dev.platform_data; 667 struct rspi_plat_data *rspi_pd = pdev->dev.platform_data;
676 dma_cap_mask_t mask; 668 dma_cap_mask_t mask;
669 struct dma_slave_config cfg;
670 int ret;
677 671
678 if (!rspi_pd) 672 if (!rspi_pd)
679 return; 673 return 0; /* The driver assumes no error. */
680 674
681 rspi->dma_width_16bit = rspi_pd->dma_width_16bit; 675 rspi->dma_width_16bit = rspi_pd->dma_width_16bit;
682 676
@@ -684,21 +678,35 @@ static void __devinit rspi_request_dma(struct rspi_data *rspi,
684 if (rspi_pd->dma_rx_id && rspi_pd->dma_tx_id) { 678 if (rspi_pd->dma_rx_id && rspi_pd->dma_tx_id) {
685 dma_cap_zero(mask); 679 dma_cap_zero(mask);
686 dma_cap_set(DMA_SLAVE, mask); 680 dma_cap_set(DMA_SLAVE, mask);
687 rspi->dma_rx.slave_id = rspi_pd->dma_rx_id; 681 rspi->chan_rx = dma_request_channel(mask, shdma_chan_filter,
688 rspi->chan_rx = dma_request_channel(mask, rspi_filter, 682 (void *)rspi_pd->dma_rx_id);
689 &rspi->dma_rx); 683 if (rspi->chan_rx) {
690 if (rspi->chan_rx) 684 cfg.slave_id = rspi_pd->dma_rx_id;
691 dev_info(&pdev->dev, "Use DMA when rx.\n"); 685 cfg.direction = DMA_DEV_TO_MEM;
686 ret = dmaengine_slave_config(rspi->chan_rx, &cfg);
687 if (!ret)
688 dev_info(&pdev->dev, "Use DMA when rx.\n");
689 else
690 return ret;
691 }
692 } 692 }
693 if (rspi_pd->dma_tx_id) { 693 if (rspi_pd->dma_tx_id) {
694 dma_cap_zero(mask); 694 dma_cap_zero(mask);
695 dma_cap_set(DMA_SLAVE, mask); 695 dma_cap_set(DMA_SLAVE, mask);
696 rspi->dma_tx.slave_id = rspi_pd->dma_tx_id; 696 rspi->chan_tx = dma_request_channel(mask, shdma_chan_filter,
697 rspi->chan_tx = dma_request_channel(mask, rspi_filter, 697 (void *)rspi_pd->dma_tx_id);
698 &rspi->dma_tx); 698 if (rspi->chan_tx) {
699 if (rspi->chan_tx) 699 cfg.slave_id = rspi_pd->dma_tx_id;
700 dev_info(&pdev->dev, "Use DMA when tx\n"); 700 cfg.direction = DMA_MEM_TO_DEV;
701 ret = dmaengine_slave_config(rspi->chan_tx, &cfg);
702 if (!ret)
703 dev_info(&pdev->dev, "Use DMA when tx\n");
704 else
705 return ret;
706 }
701 } 707 }
708
709 return 0;
702} 710}
703 711
704static void __devexit rspi_release_dma(struct rspi_data *rspi) 712static void __devexit rspi_release_dma(struct rspi_data *rspi)
@@ -788,7 +796,11 @@ static int __devinit rspi_probe(struct platform_device *pdev)
788 } 796 }
789 797
790 rspi->irq = irq; 798 rspi->irq = irq;
791 rspi_request_dma(rspi, pdev); 799 ret = rspi_request_dma(rspi, pdev);
800 if (ret < 0) {
801 dev_err(&pdev->dev, "rspi_request_dma failed.\n");
802 goto error4;
803 }
792 804
793 ret = spi_register_master(master); 805 ret = spi_register_master(master);
794 if (ret < 0) { 806 if (ret < 0) {
diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
index 1a81c90a4a7..6e7a805d324 100644
--- a/drivers/spi/spi-s3c64xx.c
+++ b/drivers/spi/spi-s3c64xx.c
@@ -132,7 +132,7 @@
132 132
133struct s3c64xx_spi_dma_data { 133struct s3c64xx_spi_dma_data {
134 unsigned ch; 134 unsigned ch;
135 enum dma_data_direction direction; 135 enum dma_transfer_direction direction;
136 enum dma_ch dmach; 136 enum dma_ch dmach;
137 struct property *dma_prop; 137 struct property *dma_prop;
138}; 138};
@@ -1067,11 +1067,11 @@ static int __devinit s3c64xx_spi_get_dmares(
1067 1067
1068 if (tx) { 1068 if (tx) {
1069 dma_data = &sdd->tx_dma; 1069 dma_data = &sdd->tx_dma;
1070 dma_data->direction = DMA_TO_DEVICE; 1070 dma_data->direction = DMA_MEM_TO_DEV;
1071 chan_str = "tx"; 1071 chan_str = "tx";
1072 } else { 1072 } else {
1073 dma_data = &sdd->rx_dma; 1073 dma_data = &sdd->rx_dma;
1074 dma_data->direction = DMA_FROM_DEVICE; 1074 dma_data->direction = DMA_DEV_TO_MEM;
1075 chan_str = "rx"; 1075 chan_str = "rx";
1076 } 1076 }
1077 1077
diff --git a/drivers/staging/android/android_alarm.h b/drivers/staging/android/android_alarm.h
index f2ffd963f1c..d0cafd63719 100644
--- a/drivers/staging/android/android_alarm.h
+++ b/drivers/staging/android/android_alarm.h
@@ -51,12 +51,10 @@ enum android_alarm_return_flags {
51#define ANDROID_ALARM_WAIT _IO('a', 1) 51#define ANDROID_ALARM_WAIT _IO('a', 1)
52 52
53#define ALARM_IOW(c, type, size) _IOW('a', (c) | ((type) << 4), size) 53#define ALARM_IOW(c, type, size) _IOW('a', (c) | ((type) << 4), size)
54#define ALARM_IOR(c, type, size) _IOR('a', (c) | ((type) << 4), size)
55
56/* Set alarm */ 54/* Set alarm */
57#define ANDROID_ALARM_SET(type) ALARM_IOW(2, type, struct timespec) 55#define ANDROID_ALARM_SET(type) ALARM_IOW(2, type, struct timespec)
58#define ANDROID_ALARM_SET_AND_WAIT(type) ALARM_IOW(3, type, struct timespec) 56#define ANDROID_ALARM_SET_AND_WAIT(type) ALARM_IOW(3, type, struct timespec)
59#define ANDROID_ALARM_GET_TIME(type) ALARM_IOR(4, type, struct timespec) 57#define ANDROID_ALARM_GET_TIME(type) ALARM_IOW(4, type, struct timespec)
60#define ANDROID_ALARM_SET_RTC _IOW('a', 5, struct timespec) 58#define ANDROID_ALARM_SET_RTC _IOW('a', 5, struct timespec)
61#define ANDROID_ALARM_BASE_CMD(cmd) (cmd & ~(_IOC(0, 0, 0xf0, 0))) 59#define ANDROID_ALARM_BASE_CMD(cmd) (cmd & ~(_IOC(0, 0, 0xf0, 0)))
62#define ANDROID_ALARM_IOCTL_TO_TYPE(cmd) (_IOC_NR(cmd) >> 4) 60#define ANDROID_ALARM_IOCTL_TO_TYPE(cmd) (_IOC_NR(cmd) >> 4)
diff --git a/drivers/staging/android/binder.c b/drivers/staging/android/binder.c
index 7b0ba92e7e4..5d4610babd8 100644
--- a/drivers/staging/android/binder.c
+++ b/drivers/staging/android/binder.c
@@ -567,7 +567,7 @@ static int binder_update_page_range(struct binder_proc *proc, int allocate,
567 page = &proc->pages[(page_addr - proc->buffer) / PAGE_SIZE]; 567 page = &proc->pages[(page_addr - proc->buffer) / PAGE_SIZE];
568 568
569 BUG_ON(*page); 569 BUG_ON(*page);
570 *page = alloc_page(GFP_KERNEL | __GFP_ZERO); 570 *page = alloc_page(GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO);
571 if (*page == NULL) { 571 if (*page == NULL) {
572 pr_err("binder: %d: binder_alloc_buf failed " 572 pr_err("binder: %d: binder_alloc_buf failed "
573 "for page at %p\n", proc->pid, page_addr); 573 "for page at %p\n", proc->pid, page_addr);
@@ -2419,14 +2419,38 @@ static void binder_release_work(struct list_head *list)
2419 struct binder_transaction *t; 2419 struct binder_transaction *t;
2420 2420
2421 t = container_of(w, struct binder_transaction, work); 2421 t = container_of(w, struct binder_transaction, work);
2422 if (t->buffer->target_node && !(t->flags & TF_ONE_WAY)) 2422 if (t->buffer->target_node &&
2423 !(t->flags & TF_ONE_WAY)) {
2423 binder_send_failed_reply(t, BR_DEAD_REPLY); 2424 binder_send_failed_reply(t, BR_DEAD_REPLY);
2425 } else {
2426 binder_debug(BINDER_DEBUG_DEAD_TRANSACTION,
2427 "binder: undelivered transaction %d\n",
2428 t->debug_id);
2429 t->buffer->transaction = NULL;
2430 kfree(t);
2431 binder_stats_deleted(BINDER_STAT_TRANSACTION);
2432 }
2424 } break; 2433 } break;
2425 case BINDER_WORK_TRANSACTION_COMPLETE: { 2434 case BINDER_WORK_TRANSACTION_COMPLETE: {
2435 binder_debug(BINDER_DEBUG_DEAD_TRANSACTION,
2436 "binder: undelivered TRANSACTION_COMPLETE\n");
2426 kfree(w); 2437 kfree(w);
2427 binder_stats_deleted(BINDER_STAT_TRANSACTION_COMPLETE); 2438 binder_stats_deleted(BINDER_STAT_TRANSACTION_COMPLETE);
2428 } break; 2439 } break;
2440 case BINDER_WORK_DEAD_BINDER_AND_CLEAR:
2441 case BINDER_WORK_CLEAR_DEATH_NOTIFICATION: {
2442 struct binder_ref_death *death;
2443
2444 death = container_of(w, struct binder_ref_death, work);
2445 binder_debug(BINDER_DEBUG_DEAD_TRANSACTION,
2446 "binder: undelivered death notification, %p\n",
2447 death->cookie);
2448 kfree(death);
2449 binder_stats_deleted(BINDER_STAT_DEATH);
2450 } break;
2429 default: 2451 default:
2452 pr_err("binder: unexpected work type, %d, not freed\n",
2453 w->type);
2430 break; 2454 break;
2431 } 2455 }
2432 } 2456 }
@@ -2899,6 +2923,7 @@ static void binder_deferred_release(struct binder_proc *proc)
2899 nodes++; 2923 nodes++;
2900 rb_erase(&node->rb_node, &proc->nodes); 2924 rb_erase(&node->rb_node, &proc->nodes);
2901 list_del_init(&node->work.entry); 2925 list_del_init(&node->work.entry);
2926 binder_release_work(&node->async_todo);
2902 if (hlist_empty(&node->refs)) { 2927 if (hlist_empty(&node->refs)) {
2903 kfree(node); 2928 kfree(node);
2904 binder_stats_deleted(BINDER_STAT_NODE); 2929 binder_stats_deleted(BINDER_STAT_NODE);
@@ -2937,6 +2962,7 @@ static void binder_deferred_release(struct binder_proc *proc)
2937 binder_delete_ref(ref); 2962 binder_delete_ref(ref);
2938 } 2963 }
2939 binder_release_work(&proc->todo); 2964 binder_release_work(&proc->todo);
2965 binder_release_work(&proc->delivered_death);
2940 buffers = 0; 2966 buffers = 0;
2941 2967
2942 while ((n = rb_first(&proc->allocated_buffers))) { 2968 while ((n = rb_first(&proc->allocated_buffers))) {
diff --git a/drivers/staging/comedi/drivers/8255_pci.c b/drivers/staging/comedi/drivers/8255_pci.c
index 7dff3c01dc2..d00aff6671d 100644
--- a/drivers/staging/comedi/drivers/8255_pci.c
+++ b/drivers/staging/comedi/drivers/8255_pci.c
@@ -289,6 +289,8 @@ static void pci_8255_detach(struct comedi_device *dev)
289 struct comedi_subdevice *s; 289 struct comedi_subdevice *s;
290 int i; 290 int i;
291 291
292 if (!board || !devpriv)
293 return;
292 if (dev->subdevices) { 294 if (dev->subdevices) {
293 for (i = 0; i < board->n_8255; i++) { 295 for (i = 0; i < board->n_8255; i++) {
294 s = &dev->subdevices[i]; 296 s = &dev->subdevices[i];
diff --git a/drivers/staging/comedi/drivers/amplc_dio200.c b/drivers/staging/comedi/drivers/amplc_dio200.c
index 08f305210a6..29eb52d11d2 100644
--- a/drivers/staging/comedi/drivers/amplc_dio200.c
+++ b/drivers/staging/comedi/drivers/amplc_dio200.c
@@ -1410,6 +1410,8 @@ static void dio200_detach(struct comedi_device *dev)
1410 const struct dio200_layout_struct *layout; 1410 const struct dio200_layout_struct *layout;
1411 unsigned n; 1411 unsigned n;
1412 1412
1413 if (!thisboard)
1414 return;
1413 if (dev->irq) 1415 if (dev->irq)
1414 free_irq(dev->irq, dev); 1416 free_irq(dev->irq, dev);
1415 if (dev->subdevices) { 1417 if (dev->subdevices) {
diff --git a/drivers/staging/comedi/drivers/amplc_pc236.c b/drivers/staging/comedi/drivers/amplc_pc236.c
index eacb5e4735d..4e4f3c15df8 100644
--- a/drivers/staging/comedi/drivers/amplc_pc236.c
+++ b/drivers/staging/comedi/drivers/amplc_pc236.c
@@ -573,9 +573,10 @@ static int __devinit pc236_attach_pci(struct comedi_device *dev,
573static void pc236_detach(struct comedi_device *dev) 573static void pc236_detach(struct comedi_device *dev)
574{ 574{
575 const struct pc236_board *thisboard = comedi_board(dev); 575 const struct pc236_board *thisboard = comedi_board(dev);
576 struct pc236_private *devpriv = dev->private;
577 576
578 if (devpriv) 577 if (!thisboard)
578 return;
579 if (dev->iobase)
579 pc236_intr_disable(dev); 580 pc236_intr_disable(dev);
580 if (dev->irq) 581 if (dev->irq)
581 free_irq(dev->irq, dev); 582 free_irq(dev->irq, dev);
diff --git a/drivers/staging/comedi/drivers/amplc_pc263.c b/drivers/staging/comedi/drivers/amplc_pc263.c
index 60830ccfb90..d0a4c441228 100644
--- a/drivers/staging/comedi/drivers/amplc_pc263.c
+++ b/drivers/staging/comedi/drivers/amplc_pc263.c
@@ -323,6 +323,8 @@ static void pc263_detach(struct comedi_device *dev)
323{ 323{
324 const struct pc263_board *thisboard = comedi_board(dev); 324 const struct pc263_board *thisboard = comedi_board(dev);
325 325
326 if (!thisboard)
327 return;
326 if (is_isa_board(thisboard)) { 328 if (is_isa_board(thisboard)) {
327 if (dev->iobase) 329 if (dev->iobase)
328 release_region(dev->iobase, PC263_IO_SIZE); 330 release_region(dev->iobase, PC263_IO_SIZE);
diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c
index 5fd21fa6c1c..c304528cfb1 100644
--- a/drivers/staging/comedi/drivers/das08.c
+++ b/drivers/staging/comedi/drivers/das08.c
@@ -846,6 +846,8 @@ static void __maybe_unused das08_detach(struct comedi_device *dev)
846{ 846{
847 const struct das08_board_struct *thisboard = comedi_board(dev); 847 const struct das08_board_struct *thisboard = comedi_board(dev);
848 848
849 if (!thisboard)
850 return;
849 das08_common_detach(dev); 851 das08_common_detach(dev);
850 if (is_isa_board(thisboard)) { 852 if (is_isa_board(thisboard)) {
851 if (dev->iobase) 853 if (dev->iobase)
diff --git a/drivers/staging/comedi/drivers/ni_daq_700.c b/drivers/staging/comedi/drivers/ni_daq_700.c
index 2ba0ade45c6..68d7c6a5db7 100644
--- a/drivers/staging/comedi/drivers/ni_daq_700.c
+++ b/drivers/staging/comedi/drivers/ni_daq_700.c
@@ -95,7 +95,7 @@ static int daq700_dio_insn_bits(struct comedi_device *dev,
95 } 95 }
96 96
97 data[1] = s->state & 0xff; 97 data[1] = s->state & 0xff;
98 data[1] |= inb(dev->iobase + DIO_R); 98 data[1] |= inb(dev->iobase + DIO_R) << 8;
99 99
100 return insn->n; 100 return insn->n;
101} 101}
diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/staging/comedi/drivers/ni_labpc.c
index 28b91a6c378..b5a19a0863f 100644
--- a/drivers/staging/comedi/drivers/ni_labpc.c
+++ b/drivers/staging/comedi/drivers/ni_labpc.c
@@ -772,6 +772,8 @@ void labpc_common_detach(struct comedi_device *dev)
772{ 772{
773 struct comedi_subdevice *s; 773 struct comedi_subdevice *s;
774 774
775 if (!thisboard)
776 return;
775 if (dev->subdevices) { 777 if (dev->subdevices) {
776 s = &dev->subdevices[2]; 778 s = &dev->subdevices[2];
777 subdev_8255_cleanup(dev, s); 779 subdev_8255_cleanup(dev, s);
diff --git a/drivers/staging/dgrp/dgrp_mon_ops.c b/drivers/staging/dgrp/dgrp_mon_ops.c
index 268dcb95204..4792d056a36 100644
--- a/drivers/staging/dgrp/dgrp_mon_ops.c
+++ b/drivers/staging/dgrp/dgrp_mon_ops.c
@@ -38,6 +38,7 @@
38#include <linux/sched.h> 38#include <linux/sched.h>
39#include <asm/unaligned.h> 39#include <asm/unaligned.h>
40#include <linux/proc_fs.h> 40#include <linux/proc_fs.h>
41#include <linux/uaccess.h>
41 42
42#include "dgrp_common.h" 43#include "dgrp_common.h"
43 44
diff --git a/drivers/staging/dgrp/dgrp_specproc.c b/drivers/staging/dgrp/dgrp_specproc.c
index 28f5c9ab6b4..24327c3bad8 100644
--- a/drivers/staging/dgrp/dgrp_specproc.c
+++ b/drivers/staging/dgrp/dgrp_specproc.c
@@ -39,6 +39,7 @@
39#include <linux/proc_fs.h> 39#include <linux/proc_fs.h>
40#include <linux/ctype.h> 40#include <linux/ctype.h>
41#include <linux/seq_file.h> 41#include <linux/seq_file.h>
42#include <linux/uaccess.h>
42#include <linux/vmalloc.h> 43#include <linux/vmalloc.h>
43 44
44#include "dgrp_common.h" 45#include "dgrp_common.h"
@@ -228,6 +229,9 @@ static void register_proc_table(struct dgrp_proc_entry *table,
228 int len; 229 int len;
229 mode_t mode; 230 mode_t mode;
230 231
232 if (table == NULL)
233 return;
234
231 for (; table->id; table++) { 235 for (; table->id; table++) {
232 /* Can't do anything without a proc name. */ 236 /* Can't do anything without a proc name. */
233 if (!table->name) 237 if (!table->name)
@@ -296,6 +300,9 @@ static void unregister_proc_table(struct dgrp_proc_entry *table,
296 struct proc_dir_entry *de; 300 struct proc_dir_entry *de;
297 struct nd_struct *tmp; 301 struct nd_struct *tmp;
298 302
303 if (table == NULL)
304 return;
305
299 list_for_each_entry(tmp, &nd_struct_list, list) { 306 list_for_each_entry(tmp, &nd_struct_list, list) {
300 if ((table == dgrp_net_table) && (tmp->nd_net_de)) { 307 if ((table == dgrp_net_table) && (tmp->nd_net_de)) {
301 unregister_dgrp_device(tmp->nd_net_de); 308 unregister_dgrp_device(tmp->nd_net_de);
diff --git a/drivers/staging/dgrp/dgrp_tty.c b/drivers/staging/dgrp/dgrp_tty.c
index 7d7de873870..e125b03598d 100644
--- a/drivers/staging/dgrp/dgrp_tty.c
+++ b/drivers/staging/dgrp/dgrp_tty.c
@@ -40,6 +40,7 @@
40#include <linux/tty.h> 40#include <linux/tty.h>
41#include <linux/tty_flip.h> 41#include <linux/tty_flip.h>
42#include <linux/sched.h> 42#include <linux/sched.h>
43#include <linux/uaccess.h>
43 44
44#include "dgrp_common.h" 45#include "dgrp_common.h"
45 46
@@ -3172,6 +3173,9 @@ dgrp_tty_init(struct nd_struct *nd)
3172 */ 3173 */
3173 3174
3174 nd->nd_serial_ttdriver = alloc_tty_driver(CHAN_MAX); 3175 nd->nd_serial_ttdriver = alloc_tty_driver(CHAN_MAX);
3176 if (!nd->nd_serial_ttdriver)
3177 return -ENOMEM;
3178
3175 sprintf(nd->nd_serial_name, "tty_dgrp_%s_", id); 3179 sprintf(nd->nd_serial_name, "tty_dgrp_%s_", id);
3176 3180
3177 nd->nd_serial_ttdriver->owner = THIS_MODULE; 3181 nd->nd_serial_ttdriver->owner = THIS_MODULE;
@@ -3231,6 +3235,9 @@ dgrp_tty_init(struct nd_struct *nd)
3231 } 3235 }
3232 3236
3233 nd->nd_callout_ttdriver = alloc_tty_driver(CHAN_MAX); 3237 nd->nd_callout_ttdriver = alloc_tty_driver(CHAN_MAX);
3238 if (!nd->nd_callout_ttdriver)
3239 return -ENOMEM;
3240
3234 sprintf(nd->nd_callout_name, "cu_dgrp_%s_", id); 3241 sprintf(nd->nd_callout_name, "cu_dgrp_%s_", id);
3235 3242
3236 nd->nd_callout_ttdriver->owner = THIS_MODULE; 3243 nd->nd_callout_ttdriver->owner = THIS_MODULE;
@@ -3268,6 +3275,9 @@ dgrp_tty_init(struct nd_struct *nd)
3268 3275
3269 3276
3270 nd->nd_xprint_ttdriver = alloc_tty_driver(CHAN_MAX); 3277 nd->nd_xprint_ttdriver = alloc_tty_driver(CHAN_MAX);
3278 if (!nd->nd_xprint_ttdriver)
3279 return -ENOMEM;
3280
3271 sprintf(nd->nd_xprint_name, "pr_dgrp_%s_", id); 3281 sprintf(nd->nd_xprint_name, "pr_dgrp_%s_", id);
3272 3282
3273 nd->nd_xprint_ttdriver->owner = THIS_MODULE; 3283 nd->nd_xprint_ttdriver->owner = THIS_MODULE;
diff --git a/drivers/staging/gdm72xx/gdm_usb.c b/drivers/staging/gdm72xx/gdm_usb.c
index 0c9e8958009..39db582ab1a 100644
--- a/drivers/staging/gdm72xx/gdm_usb.c
+++ b/drivers/staging/gdm72xx/gdm_usb.c
@@ -701,8 +701,6 @@ static int k_mode_thread(void *arg)
701 unsigned long flags, flags2, expire; 701 unsigned long flags, flags2, expire;
702 int ret; 702 int ret;
703 703
704 daemonize("k_mode_wimax");
705
706 while (!k_mode_stop) { 704 while (!k_mode_stop) {
707 705
708 spin_lock_irqsave(&k_lock, flags2); 706 spin_lock_irqsave(&k_lock, flags2);
@@ -764,7 +762,7 @@ static struct usb_driver gdm_usb_driver = {
764static int __init usb_gdm_wimax_init(void) 762static int __init usb_gdm_wimax_init(void)
765{ 763{
766#ifdef CONFIG_WIMAX_GDM72XX_K_MODE 764#ifdef CONFIG_WIMAX_GDM72XX_K_MODE
767 kthread_run(k_mode_thread, NULL, "WiMax_thread"); 765 kthread_run(k_mode_thread, NULL, "k_mode_wimax");
768#endif /* CONFIG_WIMAX_GDM72XX_K_MODE */ 766#endif /* CONFIG_WIMAX_GDM72XX_K_MODE */
769 return usb_register(&gdm_usb_driver); 767 return usb_register(&gdm_usb_driver);
770} 768}
diff --git a/drivers/staging/iio/accel/adis16201_core.c b/drivers/staging/iio/accel/adis16201_core.c
index 8e37d6e0427..b12ca68cd9e 100644
--- a/drivers/staging/iio/accel/adis16201_core.c
+++ b/drivers/staging/iio/accel/adis16201_core.c
@@ -310,30 +310,32 @@ static int adis16201_read_raw(struct iio_dev *indio_dev,
310 case IIO_CHAN_INFO_SCALE: 310 case IIO_CHAN_INFO_SCALE:
311 switch (chan->type) { 311 switch (chan->type) {
312 case IIO_VOLTAGE: 312 case IIO_VOLTAGE:
313 *val = 0; 313 if (chan->channel == 0) {
314 if (chan->channel == 0) 314 *val = 1;
315 *val2 = 1220; 315 *val2 = 220000; /* 1.22 mV */
316 else 316 } else {
317 *val2 = 610; 317 *val = 0;
318 *val2 = 610000; /* 0.610 mV */
319 }
318 return IIO_VAL_INT_PLUS_MICRO; 320 return IIO_VAL_INT_PLUS_MICRO;
319 case IIO_TEMP: 321 case IIO_TEMP:
320 *val = 0; 322 *val = -470; /* 0.47 C */
321 *val2 = -470000; 323 *val2 = 0;
322 return IIO_VAL_INT_PLUS_MICRO; 324 return IIO_VAL_INT_PLUS_MICRO;
323 case IIO_ACCEL: 325 case IIO_ACCEL:
324 *val = 0; 326 *val = 0;
325 *val2 = 462500; 327 *val2 = IIO_G_TO_M_S_2(462400); /* 0.4624 mg */
326 return IIO_VAL_INT_PLUS_MICRO; 328 return IIO_VAL_INT_PLUS_NANO;
327 case IIO_INCLI: 329 case IIO_INCLI:
328 *val = 0; 330 *val = 0;
329 *val2 = 100000; 331 *val2 = 100000; /* 0.1 degree */
330 return IIO_VAL_INT_PLUS_MICRO; 332 return IIO_VAL_INT_PLUS_MICRO;
331 default: 333 default:
332 return -EINVAL; 334 return -EINVAL;
333 } 335 }
334 break; 336 break;
335 case IIO_CHAN_INFO_OFFSET: 337 case IIO_CHAN_INFO_OFFSET:
336 *val = 25; 338 *val = 25000 / -470 - 1278; /* 25 C = 1278 */
337 return IIO_VAL_INT; 339 return IIO_VAL_INT;
338 case IIO_CHAN_INFO_CALIBBIAS: 340 case IIO_CHAN_INFO_CALIBBIAS:
339 switch (chan->type) { 341 switch (chan->type) {
diff --git a/drivers/staging/iio/accel/adis16203_core.c b/drivers/staging/iio/accel/adis16203_core.c
index 002fa9dfc37..e7b3441115a 100644
--- a/drivers/staging/iio/accel/adis16203_core.c
+++ b/drivers/staging/iio/accel/adis16203_core.c
@@ -316,25 +316,27 @@ static int adis16203_read_raw(struct iio_dev *indio_dev,
316 case IIO_CHAN_INFO_SCALE: 316 case IIO_CHAN_INFO_SCALE:
317 switch (chan->type) { 317 switch (chan->type) {
318 case IIO_VOLTAGE: 318 case IIO_VOLTAGE:
319 *val = 0; 319 if (chan->channel == 0) {
320 if (chan->channel == 0) 320 *val = 1;
321 *val2 = 1220; 321 *val2 = 220000; /* 1.22 mV */
322 else 322 } else {
323 *val2 = 610; 323 *val = 0;
324 *val2 = 610000; /* 0.61 mV */
325 }
324 return IIO_VAL_INT_PLUS_MICRO; 326 return IIO_VAL_INT_PLUS_MICRO;
325 case IIO_TEMP: 327 case IIO_TEMP:
326 *val = 0; 328 *val = -470; /* -0.47 C */
327 *val2 = -470000; 329 *val2 = 0;
328 return IIO_VAL_INT_PLUS_MICRO; 330 return IIO_VAL_INT_PLUS_MICRO;
329 case IIO_INCLI: 331 case IIO_INCLI:
330 *val = 0; 332 *val = 0;
331 *val2 = 25000; 333 *val2 = 25000; /* 0.025 degree */
332 return IIO_VAL_INT_PLUS_MICRO; 334 return IIO_VAL_INT_PLUS_MICRO;
333 default: 335 default:
334 return -EINVAL; 336 return -EINVAL;
335 } 337 }
336 case IIO_CHAN_INFO_OFFSET: 338 case IIO_CHAN_INFO_OFFSET:
337 *val = 25; 339 *val = 25000 / -470 - 1278; /* 25 C = 1278 */
338 return IIO_VAL_INT; 340 return IIO_VAL_INT;
339 case IIO_CHAN_INFO_CALIBBIAS: 341 case IIO_CHAN_INFO_CALIBBIAS:
340 bits = 14; 342 bits = 14;
diff --git a/drivers/staging/iio/accel/adis16204_core.c b/drivers/staging/iio/accel/adis16204_core.c
index 05bdb7c2c8e..c6234c2f46a 100644
--- a/drivers/staging/iio/accel/adis16204_core.c
+++ b/drivers/staging/iio/accel/adis16204_core.c
@@ -317,26 +317,28 @@ static int adis16204_read_raw(struct iio_dev *indio_dev,
317 case IIO_CHAN_INFO_SCALE: 317 case IIO_CHAN_INFO_SCALE:
318 switch (chan->type) { 318 switch (chan->type) {
319 case IIO_VOLTAGE: 319 case IIO_VOLTAGE:
320 *val = 0; 320 if (chan->channel == 0) {
321 if (chan->channel == 0) 321 *val = 1;
322 *val2 = 1220; 322 *val2 = 220000; /* 1.22 mV */
323 else 323 } else {
324 *val2 = 610; 324 *val = 0;
325 *val2 = 610000; /* 0.61 mV */
326 }
325 return IIO_VAL_INT_PLUS_MICRO; 327 return IIO_VAL_INT_PLUS_MICRO;
326 case IIO_TEMP: 328 case IIO_TEMP:
327 *val = 0; 329 *val = -470; /* 0.47 C */
328 *val2 = -470000; 330 *val2 = 0;
329 return IIO_VAL_INT_PLUS_MICRO; 331 return IIO_VAL_INT_PLUS_MICRO;
330 case IIO_ACCEL: 332 case IIO_ACCEL:
331 *val = 0; 333 *val = 0;
332 switch (chan->channel2) { 334 switch (chan->channel2) {
333 case IIO_MOD_X: 335 case IIO_MOD_X:
334 case IIO_MOD_ROOT_SUM_SQUARED_X_Y: 336 case IIO_MOD_ROOT_SUM_SQUARED_X_Y:
335 *val2 = 17125; 337 *val2 = IIO_G_TO_M_S_2(17125); /* 17.125 mg */
336 break; 338 break;
337 case IIO_MOD_Y: 339 case IIO_MOD_Y:
338 case IIO_MOD_Z: 340 case IIO_MOD_Z:
339 *val2 = 8407; 341 *val2 = IIO_G_TO_M_S_2(8407); /* 8.407 mg */
340 break; 342 break;
341 } 343 }
342 return IIO_VAL_INT_PLUS_MICRO; 344 return IIO_VAL_INT_PLUS_MICRO;
@@ -345,7 +347,7 @@ static int adis16204_read_raw(struct iio_dev *indio_dev,
345 } 347 }
346 break; 348 break;
347 case IIO_CHAN_INFO_OFFSET: 349 case IIO_CHAN_INFO_OFFSET:
348 *val = 25; 350 *val = 25000 / -470 - 1278; /* 25 C = 1278 */
349 return IIO_VAL_INT; 351 return IIO_VAL_INT;
350 case IIO_CHAN_INFO_CALIBBIAS: 352 case IIO_CHAN_INFO_CALIBBIAS:
351 case IIO_CHAN_INFO_PEAK: 353 case IIO_CHAN_INFO_PEAK:
diff --git a/drivers/staging/iio/accel/adis16209_core.c b/drivers/staging/iio/accel/adis16209_core.c
index b7333bfe0b2..7ee974b45d7 100644
--- a/drivers/staging/iio/accel/adis16209_core.c
+++ b/drivers/staging/iio/accel/adis16209_core.c
@@ -343,28 +343,29 @@ static int adis16209_read_raw(struct iio_dev *indio_dev,
343 case IIO_VOLTAGE: 343 case IIO_VOLTAGE:
344 *val = 0; 344 *val = 0;
345 if (chan->channel == 0) 345 if (chan->channel == 0)
346 *val2 = 305180; 346 *val2 = 305180; /* 0.30518 mV */
347 else 347 else
348 *val2 = 610500; 348 *val2 = 610500; /* 0.6105 mV */
349 return IIO_VAL_INT_PLUS_MICRO; 349 return IIO_VAL_INT_PLUS_MICRO;
350 case IIO_TEMP: 350 case IIO_TEMP:
351 *val = 0; 351 *val = -470; /* -0.47 C */
352 *val2 = -470000; 352 *val2 = 0;
353 return IIO_VAL_INT_PLUS_MICRO; 353 return IIO_VAL_INT_PLUS_MICRO;
354 case IIO_ACCEL: 354 case IIO_ACCEL:
355 *val = 0; 355 *val = 0;
356 *val2 = 2394; 356 *val2 = IIO_G_TO_M_S_2(244140); /* 0.244140 mg */
357 return IIO_VAL_INT_PLUS_MICRO; 357 return IIO_VAL_INT_PLUS_NANO;
358 case IIO_INCLI: 358 case IIO_INCLI:
359 case IIO_ROT:
359 *val = 0; 360 *val = 0;
360 *val2 = 436; 361 *val2 = 25000; /* 0.025 degree */
361 return IIO_VAL_INT_PLUS_MICRO; 362 return IIO_VAL_INT_PLUS_MICRO;
362 default: 363 default:
363 return -EINVAL; 364 return -EINVAL;
364 } 365 }
365 break; 366 break;
366 case IIO_CHAN_INFO_OFFSET: 367 case IIO_CHAN_INFO_OFFSET:
367 *val = 25; 368 *val = 25000 / -470 - 0x4FE; /* 25 C = 0x4FE */
368 return IIO_VAL_INT; 369 return IIO_VAL_INT;
369 case IIO_CHAN_INFO_CALIBBIAS: 370 case IIO_CHAN_INFO_CALIBBIAS:
370 switch (chan->type) { 371 switch (chan->type) {
@@ -491,6 +492,7 @@ static const struct iio_chan_spec adis16209_channels[] = {
491 .modified = 1, 492 .modified = 1,
492 .channel2 = IIO_MOD_X, 493 .channel2 = IIO_MOD_X,
493 .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT, 494 .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT,
495 IIO_CHAN_INFO_SCALE_SHARED_BIT,
494 .address = rot, 496 .address = rot,
495 .scan_index = ADIS16209_SCAN_ROT, 497 .scan_index = ADIS16209_SCAN_ROT,
496 .scan_type = { 498 .scan_type = {
diff --git a/drivers/staging/iio/accel/adis16220_core.c b/drivers/staging/iio/accel/adis16220_core.c
index c755089c711..eaadd9df3f7 100644
--- a/drivers/staging/iio/accel/adis16220_core.c
+++ b/drivers/staging/iio/accel/adis16220_core.c
@@ -486,7 +486,7 @@ static int adis16220_read_raw(struct iio_dev *indio_dev,
486 break; 486 break;
487 case IIO_CHAN_INFO_OFFSET: 487 case IIO_CHAN_INFO_OFFSET:
488 if (chan->type == IIO_TEMP) { 488 if (chan->type == IIO_TEMP) {
489 *val = 25; 489 *val = 25000 / -470 - 1278; /* 25 C = 1278 */
490 return IIO_VAL_INT; 490 return IIO_VAL_INT;
491 } 491 }
492 addrind = 1; 492 addrind = 1;
@@ -495,19 +495,22 @@ static int adis16220_read_raw(struct iio_dev *indio_dev,
495 addrind = 2; 495 addrind = 2;
496 break; 496 break;
497 case IIO_CHAN_INFO_SCALE: 497 case IIO_CHAN_INFO_SCALE:
498 *val = 0;
499 switch (chan->type) { 498 switch (chan->type) {
500 case IIO_TEMP: 499 case IIO_TEMP:
501 *val2 = -470000; 500 *val = -470; /* -0.47 C */
501 *val2 = 0;
502 return IIO_VAL_INT_PLUS_MICRO; 502 return IIO_VAL_INT_PLUS_MICRO;
503 case IIO_ACCEL: 503 case IIO_ACCEL:
504 *val2 = 1887042; 504 *val2 = IIO_G_TO_M_S_2(19073); /* 19.073 g */
505 return IIO_VAL_INT_PLUS_MICRO; 505 return IIO_VAL_INT_PLUS_MICRO;
506 case IIO_VOLTAGE: 506 case IIO_VOLTAGE:
507 if (chan->channel == 0) 507 if (chan->channel == 0) {
508 *val2 = 0012221; 508 *val = 1;
509 else /* Should really be dependent on VDD */ 509 *val2 = 220700; /* 1.2207 mV */
510 *val2 = 305; 510 } else {
511 /* Should really be dependent on VDD */
512 *val2 = 305180; /* 305.18 uV */
513 }
511 return IIO_VAL_INT_PLUS_MICRO; 514 return IIO_VAL_INT_PLUS_MICRO;
512 default: 515 default:
513 return -EINVAL; 516 return -EINVAL;
diff --git a/drivers/staging/iio/accel/adis16240_core.c b/drivers/staging/iio/accel/adis16240_core.c
index 0fc26a49d68..35e093973d5 100644
--- a/drivers/staging/iio/accel/adis16240_core.c
+++ b/drivers/staging/iio/accel/adis16240_core.c
@@ -373,30 +373,31 @@ static int adis16240_read_raw(struct iio_dev *indio_dev,
373 case IIO_CHAN_INFO_SCALE: 373 case IIO_CHAN_INFO_SCALE:
374 switch (chan->type) { 374 switch (chan->type) {
375 case IIO_VOLTAGE: 375 case IIO_VOLTAGE:
376 *val = 0; 376 if (chan->channel == 0) {
377 if (chan->channel == 0) 377 *val = 4;
378 *val2 = 4880; 378 *val2 = 880000; /* 4.88 mV */
379 else 379 return IIO_VAL_INT_PLUS_MICRO;
380 } else {
380 return -EINVAL; 381 return -EINVAL;
381 return IIO_VAL_INT_PLUS_MICRO; 382 }
382 case IIO_TEMP: 383 case IIO_TEMP:
383 *val = 0; 384 *val = 244; /* 0.244 C */
384 *val2 = 244000; 385 *val2 = 0;
385 return IIO_VAL_INT_PLUS_MICRO; 386 return IIO_VAL_INT_PLUS_MICRO;
386 case IIO_ACCEL: 387 case IIO_ACCEL:
387 *val = 0; 388 *val = 0;
388 *val2 = 504062; 389 *val2 = IIO_G_TO_M_S_2(51400); /* 51.4 mg */
389 return IIO_VAL_INT_PLUS_MICRO; 390 return IIO_VAL_INT_PLUS_MICRO;
390 default: 391 default:
391 return -EINVAL; 392 return -EINVAL;
392 } 393 }
393 break; 394 break;
394 case IIO_CHAN_INFO_PEAK_SCALE: 395 case IIO_CHAN_INFO_PEAK_SCALE:
395 *val = 6; 396 *val = 0;
396 *val2 = 629295; 397 *val2 = IIO_G_TO_M_S_2(51400); /* 51.4 mg */
397 return IIO_VAL_INT_PLUS_MICRO; 398 return IIO_VAL_INT_PLUS_MICRO;
398 case IIO_CHAN_INFO_OFFSET: 399 case IIO_CHAN_INFO_OFFSET:
399 *val = 25; 400 *val = 25000 / 244 - 0x133; /* 25 C = 0x133 */
400 return IIO_VAL_INT; 401 return IIO_VAL_INT;
401 case IIO_CHAN_INFO_CALIBBIAS: 402 case IIO_CHAN_INFO_CALIBBIAS:
402 bits = 10; 403 bits = 10;
diff --git a/drivers/staging/iio/gyro/adis16260_core.c b/drivers/staging/iio/gyro/adis16260_core.c
index 9571c03aa4c..aa964a2d829 100644
--- a/drivers/staging/iio/gyro/adis16260_core.c
+++ b/drivers/staging/iio/gyro/adis16260_core.c
@@ -498,28 +498,33 @@ static int adis16260_read_raw(struct iio_dev *indio_dev,
498 switch (chan->type) { 498 switch (chan->type) {
499 case IIO_ANGL_VEL: 499 case IIO_ANGL_VEL:
500 *val = 0; 500 *val = 0;
501 if (spi_get_device_id(st->us)->driver_data) 501 if (spi_get_device_id(st->us)->driver_data) {
502 *val2 = 320; 502 /* 0.01832 degree / sec */
503 else 503 *val2 = IIO_DEGREE_TO_RAD(18320);
504 *val2 = 1278; 504 } else {
505 /* 0.07326 degree / sec */
506 *val2 = IIO_DEGREE_TO_RAD(73260);
507 }
505 return IIO_VAL_INT_PLUS_MICRO; 508 return IIO_VAL_INT_PLUS_MICRO;
506 case IIO_VOLTAGE: 509 case IIO_VOLTAGE:
507 *val = 0; 510 if (chan->channel == 0) {
508 if (chan->channel == 0) 511 *val = 1;
509 *val2 = 18315; 512 *val2 = 831500; /* 1.8315 mV */
510 else 513 } else {
511 *val2 = 610500; 514 *val = 0;
515 *val2 = 610500; /* 610.5 uV */
516 }
512 return IIO_VAL_INT_PLUS_MICRO; 517 return IIO_VAL_INT_PLUS_MICRO;
513 case IIO_TEMP: 518 case IIO_TEMP:
514 *val = 0; 519 *val = 145;
515 *val2 = 145300; 520 *val2 = 300000; /* 0.1453 C */
516 return IIO_VAL_INT_PLUS_MICRO; 521 return IIO_VAL_INT_PLUS_MICRO;
517 default: 522 default:
518 return -EINVAL; 523 return -EINVAL;
519 } 524 }
520 break; 525 break;
521 case IIO_CHAN_INFO_OFFSET: 526 case IIO_CHAN_INFO_OFFSET:
522 *val = 25; 527 *val = 250000 / 1453; /* 25 C = 0x00 */
523 return IIO_VAL_INT; 528 return IIO_VAL_INT;
524 case IIO_CHAN_INFO_CALIBBIAS: 529 case IIO_CHAN_INFO_CALIBBIAS:
525 switch (chan->type) { 530 switch (chan->type) {
diff --git a/drivers/staging/iio/imu/adis16400.h b/drivers/staging/iio/imu/adis16400.h
index d59d7ac856a..77c601da184 100644
--- a/drivers/staging/iio/imu/adis16400.h
+++ b/drivers/staging/iio/imu/adis16400.h
@@ -139,6 +139,8 @@ struct adis16400_chip_info {
139 const long flags; 139 const long flags;
140 unsigned int gyro_scale_micro; 140 unsigned int gyro_scale_micro;
141 unsigned int accel_scale_micro; 141 unsigned int accel_scale_micro;
142 int temp_scale_nano;
143 int temp_offset;
142 unsigned long default_scan_mask; 144 unsigned long default_scan_mask;
143}; 145};
144 146
diff --git a/drivers/staging/iio/imu/adis16400_core.c b/drivers/staging/iio/imu/adis16400_core.c
index b302c9ba271..3144a7b1e1c 100644
--- a/drivers/staging/iio/imu/adis16400_core.c
+++ b/drivers/staging/iio/imu/adis16400_core.c
@@ -553,10 +553,13 @@ static int adis16400_read_raw(struct iio_dev *indio_dev,
553 return IIO_VAL_INT_PLUS_MICRO; 553 return IIO_VAL_INT_PLUS_MICRO;
554 case IIO_VOLTAGE: 554 case IIO_VOLTAGE:
555 *val = 0; 555 *val = 0;
556 if (chan->channel == 0) 556 if (chan->channel == 0) {
557 *val2 = 2418; 557 *val = 2;
558 else 558 *val2 = 418000; /* 2.418 mV */
559 *val2 = 806; 559 } else {
560 *val = 0;
561 *val2 = 805800; /* 805.8 uV */
562 }
560 return IIO_VAL_INT_PLUS_MICRO; 563 return IIO_VAL_INT_PLUS_MICRO;
561 case IIO_ACCEL: 564 case IIO_ACCEL:
562 *val = 0; 565 *val = 0;
@@ -564,11 +567,11 @@ static int adis16400_read_raw(struct iio_dev *indio_dev,
564 return IIO_VAL_INT_PLUS_MICRO; 567 return IIO_VAL_INT_PLUS_MICRO;
565 case IIO_MAGN: 568 case IIO_MAGN:
566 *val = 0; 569 *val = 0;
567 *val2 = 500; 570 *val2 = 500; /* 0.5 mgauss */
568 return IIO_VAL_INT_PLUS_MICRO; 571 return IIO_VAL_INT_PLUS_MICRO;
569 case IIO_TEMP: 572 case IIO_TEMP:
570 *val = 0; 573 *val = st->variant->temp_scale_nano / 1000000;
571 *val2 = 140000; 574 *val2 = (st->variant->temp_scale_nano % 1000000);
572 return IIO_VAL_INT_PLUS_MICRO; 575 return IIO_VAL_INT_PLUS_MICRO;
573 default: 576 default:
574 return -EINVAL; 577 return -EINVAL;
@@ -586,9 +589,8 @@ static int adis16400_read_raw(struct iio_dev *indio_dev,
586 return IIO_VAL_INT; 589 return IIO_VAL_INT;
587 case IIO_CHAN_INFO_OFFSET: 590 case IIO_CHAN_INFO_OFFSET:
588 /* currently only temperature */ 591 /* currently only temperature */
589 *val = 198; 592 *val = st->variant->temp_offset;
590 *val2 = 160000; 593 return IIO_VAL_INT;
591 return IIO_VAL_INT_PLUS_MICRO;
592 case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY: 594 case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY:
593 mutex_lock(&indio_dev->mlock); 595 mutex_lock(&indio_dev->mlock);
594 /* Need both the number of taps and the sampling frequency */ 596 /* Need both the number of taps and the sampling frequency */
@@ -1035,7 +1037,7 @@ static const struct iio_chan_spec adis16334_channels[] = {
1035 .indexed = 1, 1037 .indexed = 1,
1036 .channel = 0, 1038 .channel = 0,
1037 .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | 1039 .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
1038 IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT | 1040 IIO_CHAN_INFO_OFFSET_SEPARATE_BIT |
1039 IIO_CHAN_INFO_SCALE_SHARED_BIT, 1041 IIO_CHAN_INFO_SCALE_SHARED_BIT,
1040 .address = temp0, 1042 .address = temp0,
1041 .scan_index = ADIS16400_SCAN_TEMP, 1043 .scan_index = ADIS16400_SCAN_TEMP,
@@ -1058,8 +1060,10 @@ static struct adis16400_chip_info adis16400_chips[] = {
1058 [ADIS16300] = { 1060 [ADIS16300] = {
1059 .channels = adis16300_channels, 1061 .channels = adis16300_channels,
1060 .num_channels = ARRAY_SIZE(adis16300_channels), 1062 .num_channels = ARRAY_SIZE(adis16300_channels),
1061 .gyro_scale_micro = 873, 1063 .gyro_scale_micro = IIO_DEGREE_TO_RAD(50000), /* 0.05 deg/s */
1062 .accel_scale_micro = 5884, 1064 .accel_scale_micro = 5884,
1065 .temp_scale_nano = 140000000, /* 0.14 C */
1066 .temp_offset = 25000000 / 140000, /* 25 C = 0x00 */
1063 .default_scan_mask = (1 << ADIS16400_SCAN_SUPPLY) | 1067 .default_scan_mask = (1 << ADIS16400_SCAN_SUPPLY) |
1064 (1 << ADIS16400_SCAN_GYRO_X) | (1 << ADIS16400_SCAN_ACC_X) | 1068 (1 << ADIS16400_SCAN_GYRO_X) | (1 << ADIS16400_SCAN_ACC_X) |
1065 (1 << ADIS16400_SCAN_ACC_Y) | (1 << ADIS16400_SCAN_ACC_Z) | 1069 (1 << ADIS16400_SCAN_ACC_Y) | (1 << ADIS16400_SCAN_ACC_Z) |
@@ -1070,8 +1074,10 @@ static struct adis16400_chip_info adis16400_chips[] = {
1070 [ADIS16334] = { 1074 [ADIS16334] = {
1071 .channels = adis16334_channels, 1075 .channels = adis16334_channels,
1072 .num_channels = ARRAY_SIZE(adis16334_channels), 1076 .num_channels = ARRAY_SIZE(adis16334_channels),
1073 .gyro_scale_micro = 873, 1077 .gyro_scale_micro = IIO_DEGREE_TO_RAD(50000), /* 0.05 deg/s */
1074 .accel_scale_micro = 981, 1078 .accel_scale_micro = IIO_G_TO_M_S_2(1000), /* 1 mg */
1079 .temp_scale_nano = 67850000, /* 0.06785 C */
1080 .temp_offset = 25000000 / 67850, /* 25 C = 0x00 */
1075 .default_scan_mask = (1 << ADIS16400_SCAN_GYRO_X) | 1081 .default_scan_mask = (1 << ADIS16400_SCAN_GYRO_X) |
1076 (1 << ADIS16400_SCAN_GYRO_Y) | (1 << ADIS16400_SCAN_GYRO_Z) | 1082 (1 << ADIS16400_SCAN_GYRO_Y) | (1 << ADIS16400_SCAN_GYRO_Z) |
1077 (1 << ADIS16400_SCAN_ACC_X) | (1 << ADIS16400_SCAN_ACC_Y) | 1083 (1 << ADIS16400_SCAN_ACC_X) | (1 << ADIS16400_SCAN_ACC_Y) |
@@ -1080,8 +1086,10 @@ static struct adis16400_chip_info adis16400_chips[] = {
1080 [ADIS16350] = { 1086 [ADIS16350] = {
1081 .channels = adis16350_channels, 1087 .channels = adis16350_channels,
1082 .num_channels = ARRAY_SIZE(adis16350_channels), 1088 .num_channels = ARRAY_SIZE(adis16350_channels),
1083 .gyro_scale_micro = 872664, 1089 .gyro_scale_micro = IIO_DEGREE_TO_RAD(73260), /* 0.07326 deg/s */
1084 .accel_scale_micro = 24732, 1090 .accel_scale_micro = IIO_G_TO_M_S_2(2522), /* 0.002522 g */
1091 .temp_scale_nano = 145300000, /* 0.1453 C */
1092 .temp_offset = 25000000 / 145300, /* 25 C = 0x00 */
1085 .default_scan_mask = 0x7FF, 1093 .default_scan_mask = 0x7FF,
1086 .flags = ADIS16400_NO_BURST, 1094 .flags = ADIS16400_NO_BURST,
1087 }, 1095 },
@@ -1090,8 +1098,10 @@ static struct adis16400_chip_info adis16400_chips[] = {
1090 .num_channels = ARRAY_SIZE(adis16350_channels), 1098 .num_channels = ARRAY_SIZE(adis16350_channels),
1091 .flags = ADIS16400_HAS_PROD_ID, 1099 .flags = ADIS16400_HAS_PROD_ID,
1092 .product_id = 0x3FE8, 1100 .product_id = 0x3FE8,
1093 .gyro_scale_micro = 1279, 1101 .gyro_scale_micro = IIO_DEGREE_TO_RAD(50000), /* 0.05 deg/s */
1094 .accel_scale_micro = 24732, 1102 .accel_scale_micro = IIO_G_TO_M_S_2(3333), /* 3.333 mg */
1103 .temp_scale_nano = 136000000, /* 0.136 C */
1104 .temp_offset = 25000000 / 136000, /* 25 C = 0x00 */
1095 .default_scan_mask = 0x7FF, 1105 .default_scan_mask = 0x7FF,
1096 }, 1106 },
1097 [ADIS16362] = { 1107 [ADIS16362] = {
@@ -1099,8 +1109,10 @@ static struct adis16400_chip_info adis16400_chips[] = {
1099 .num_channels = ARRAY_SIZE(adis16350_channels), 1109 .num_channels = ARRAY_SIZE(adis16350_channels),
1100 .flags = ADIS16400_HAS_PROD_ID, 1110 .flags = ADIS16400_HAS_PROD_ID,
1101 .product_id = 0x3FEA, 1111 .product_id = 0x3FEA,
1102 .gyro_scale_micro = 1279, 1112 .gyro_scale_micro = IIO_DEGREE_TO_RAD(50000), /* 0.05 deg/s */
1103 .accel_scale_micro = 24732, 1113 .accel_scale_micro = IIO_G_TO_M_S_2(333), /* 0.333 mg */
1114 .temp_scale_nano = 136000000, /* 0.136 C */
1115 .temp_offset = 25000000 / 136000, /* 25 C = 0x00 */
1104 .default_scan_mask = 0x7FF, 1116 .default_scan_mask = 0x7FF,
1105 }, 1117 },
1106 [ADIS16364] = { 1118 [ADIS16364] = {
@@ -1108,8 +1120,10 @@ static struct adis16400_chip_info adis16400_chips[] = {
1108 .num_channels = ARRAY_SIZE(adis16350_channels), 1120 .num_channels = ARRAY_SIZE(adis16350_channels),
1109 .flags = ADIS16400_HAS_PROD_ID, 1121 .flags = ADIS16400_HAS_PROD_ID,
1110 .product_id = 0x3FEC, 1122 .product_id = 0x3FEC,
1111 .gyro_scale_micro = 1279, 1123 .gyro_scale_micro = IIO_DEGREE_TO_RAD(50000), /* 0.05 deg/s */
1112 .accel_scale_micro = 24732, 1124 .accel_scale_micro = IIO_G_TO_M_S_2(1000), /* 1 mg */
1125 .temp_scale_nano = 136000000, /* 0.136 C */
1126 .temp_offset = 25000000 / 136000, /* 25 C = 0x00 */
1113 .default_scan_mask = 0x7FF, 1127 .default_scan_mask = 0x7FF,
1114 }, 1128 },
1115 [ADIS16365] = { 1129 [ADIS16365] = {
@@ -1117,8 +1131,10 @@ static struct adis16400_chip_info adis16400_chips[] = {
1117 .num_channels = ARRAY_SIZE(adis16350_channels), 1131 .num_channels = ARRAY_SIZE(adis16350_channels),
1118 .flags = ADIS16400_HAS_PROD_ID, 1132 .flags = ADIS16400_HAS_PROD_ID,
1119 .product_id = 0x3FED, 1133 .product_id = 0x3FED,
1120 .gyro_scale_micro = 1279, 1134 .gyro_scale_micro = IIO_DEGREE_TO_RAD(50000), /* 0.05 deg/s */
1121 .accel_scale_micro = 24732, 1135 .accel_scale_micro = IIO_G_TO_M_S_2(1000), /* 1 mg */
1136 .temp_scale_nano = 136000000, /* 0.136 C */
1137 .temp_offset = 25000000 / 136000, /* 25 C = 0x00 */
1122 .default_scan_mask = 0x7FF, 1138 .default_scan_mask = 0x7FF,
1123 }, 1139 },
1124 [ADIS16400] = { 1140 [ADIS16400] = {
@@ -1126,9 +1142,11 @@ static struct adis16400_chip_info adis16400_chips[] = {
1126 .num_channels = ARRAY_SIZE(adis16400_channels), 1142 .num_channels = ARRAY_SIZE(adis16400_channels),
1127 .flags = ADIS16400_HAS_PROD_ID, 1143 .flags = ADIS16400_HAS_PROD_ID,
1128 .product_id = 0x4015, 1144 .product_id = 0x4015,
1129 .gyro_scale_micro = 873, 1145 .gyro_scale_micro = IIO_DEGREE_TO_RAD(50000), /* 0.05 deg/s */
1130 .accel_scale_micro = 32656, 1146 .accel_scale_micro = IIO_G_TO_M_S_2(3333), /* 3.333 mg */
1131 .default_scan_mask = 0xFFF, 1147 .default_scan_mask = 0xFFF,
1148 .temp_scale_nano = 140000000, /* 0.14 C */
1149 .temp_offset = 25000000 / 140000, /* 25 C = 0x00 */
1132 } 1150 }
1133}; 1151};
1134 1152
diff --git a/drivers/staging/ipack/bridges/tpci200.c b/drivers/staging/ipack/bridges/tpci200.c
index bb8aa70281c..46d6657280b 100644
--- a/drivers/staging/ipack/bridges/tpci200.c
+++ b/drivers/staging/ipack/bridges/tpci200.c
@@ -12,6 +12,7 @@
12 */ 12 */
13 13
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/slab.h>
15#include "tpci200.h" 16#include "tpci200.h"
16 17
17static u16 tpci200_status_timeout[] = { 18static u16 tpci200_status_timeout[] = {
diff --git a/drivers/staging/omapdrm/omap_gem.c b/drivers/staging/omapdrm/omap_gem.c
index 3434e6ec014..66e2c2f8a23 100644
--- a/drivers/staging/omapdrm/omap_gem.c
+++ b/drivers/staging/omapdrm/omap_gem.c
@@ -246,7 +246,7 @@ static int omap_gem_attach_pages(struct drm_gem_object *obj)
246 * DSS, GPU, etc. are not cache coherent: 246 * DSS, GPU, etc. are not cache coherent:
247 */ 247 */
248 if (omap_obj->flags & (OMAP_BO_WC|OMAP_BO_UNCACHED)) { 248 if (omap_obj->flags & (OMAP_BO_WC|OMAP_BO_UNCACHED)) {
249 addrs = kmalloc(npages * sizeof(addrs), GFP_KERNEL); 249 addrs = kmalloc(npages * sizeof(*addrs), GFP_KERNEL);
250 if (!addrs) { 250 if (!addrs) {
251 ret = -ENOMEM; 251 ret = -ENOMEM;
252 goto free_pages; 252 goto free_pages;
@@ -257,7 +257,7 @@ static int omap_gem_attach_pages(struct drm_gem_object *obj)
257 0, PAGE_SIZE, DMA_BIDIRECTIONAL); 257 0, PAGE_SIZE, DMA_BIDIRECTIONAL);
258 } 258 }
259 } else { 259 } else {
260 addrs = kzalloc(npages * sizeof(addrs), GFP_KERNEL); 260 addrs = kzalloc(npages * sizeof(*addrs), GFP_KERNEL);
261 if (!addrs) { 261 if (!addrs) {
262 ret = -ENOMEM; 262 ret = -ENOMEM;
263 goto free_pages; 263 goto free_pages;
diff --git a/drivers/staging/ramster/Kconfig b/drivers/staging/ramster/Kconfig
index 843c5410143..3abf6619dac 100644
--- a/drivers/staging/ramster/Kconfig
+++ b/drivers/staging/ramster/Kconfig
@@ -18,6 +18,7 @@ config ZCACHE2
18config RAMSTER 18config RAMSTER
19 bool "Cross-machine RAM capacity sharing, aka peer-to-peer tmem" 19 bool "Cross-machine RAM capacity sharing, aka peer-to-peer tmem"
20 depends on CONFIGFS_FS=y && SYSFS=y && !HIGHMEM && ZCACHE2=y 20 depends on CONFIGFS_FS=y && SYSFS=y && !HIGHMEM && ZCACHE2=y
21 depends on NET
21 # must ensure struct page is 8-byte aligned 22 # must ensure struct page is 8-byte aligned
22 select HAVE_ALIGNED_STRUCT_PAGE if !64_BIT 23 select HAVE_ALIGNED_STRUCT_PAGE if !64_BIT
23 default n 24 default n
diff --git a/drivers/staging/tidspbridge/core/tiomap3430.c b/drivers/staging/tidspbridge/core/tiomap3430.c
index 066a3ceec65..f619fb3c56d 100644
--- a/drivers/staging/tidspbridge/core/tiomap3430.c
+++ b/drivers/staging/tidspbridge/core/tiomap3430.c
@@ -126,7 +126,8 @@ static int mem_map_vmalloc(struct bridge_dev_context *dev_context,
126 u32 ul_num_bytes, 126 u32 ul_num_bytes,
127 struct hw_mmu_map_attrs_t *hw_attrs); 127 struct hw_mmu_map_attrs_t *hw_attrs);
128 128
129bool wait_for_start(struct bridge_dev_context *dev_context, u32 dw_sync_addr); 129bool wait_for_start(struct bridge_dev_context *dev_context,
130 void __iomem *sync_addr);
130 131
131/* ----------------------------------- Globals */ 132/* ----------------------------------- Globals */
132 133
@@ -363,10 +364,11 @@ static int bridge_brd_start(struct bridge_dev_context *dev_ctxt,
363{ 364{
364 int status = 0; 365 int status = 0;
365 struct bridge_dev_context *dev_context = dev_ctxt; 366 struct bridge_dev_context *dev_context = dev_ctxt;
366 u32 dw_sync_addr = 0; 367 void __iomem *sync_addr;
367 u32 ul_shm_base; /* Gpp Phys SM base addr(byte) */ 368 u32 ul_shm_base; /* Gpp Phys SM base addr(byte) */
368 u32 ul_shm_base_virt; /* Dsp Virt SM base addr */ 369 u32 ul_shm_base_virt; /* Dsp Virt SM base addr */
369 u32 ul_tlb_base_virt; /* Base of MMU TLB entry */ 370 u32 ul_tlb_base_virt; /* Base of MMU TLB entry */
371 u32 shm_sync_pa;
370 /* Offset of shm_base_virt from tlb_base_virt */ 372 /* Offset of shm_base_virt from tlb_base_virt */
371 u32 ul_shm_offset_virt; 373 u32 ul_shm_offset_virt;
372 s32 entry_ndx; 374 s32 entry_ndx;
@@ -397,15 +399,22 @@ static int bridge_brd_start(struct bridge_dev_context *dev_ctxt,
397 /* Kernel logical address */ 399 /* Kernel logical address */
398 ul_shm_base = dev_context->atlb_entry[0].gpp_va + ul_shm_offset_virt; 400 ul_shm_base = dev_context->atlb_entry[0].gpp_va + ul_shm_offset_virt;
399 401
402 /* SHM physical sync address */
403 shm_sync_pa = dev_context->atlb_entry[0].gpp_pa + ul_shm_offset_virt +
404 SHMSYNCOFFSET;
405
400 /* 2nd wd is used as sync field */ 406 /* 2nd wd is used as sync field */
401 dw_sync_addr = ul_shm_base + SHMSYNCOFFSET; 407 sync_addr = ioremap(shm_sync_pa, SZ_32);
408 if (!sync_addr)
409 return -ENOMEM;
410
402 /* Write a signature into the shm base + offset; this will 411 /* Write a signature into the shm base + offset; this will
403 * get cleared when the DSP program starts. */ 412 * get cleared when the DSP program starts. */
404 if ((ul_shm_base_virt == 0) || (ul_shm_base == 0)) { 413 if ((ul_shm_base_virt == 0) || (ul_shm_base == 0)) {
405 pr_err("%s: Illegal SM base\n", __func__); 414 pr_err("%s: Illegal SM base\n", __func__);
406 status = -EPERM; 415 status = -EPERM;
407 } else 416 } else
408 __raw_writel(0xffffffff, dw_sync_addr); 417 __raw_writel(0xffffffff, sync_addr);
409 418
410 if (!status) { 419 if (!status) {
411 resources = dev_context->resources; 420 resources = dev_context->resources;
@@ -419,8 +428,10 @@ static int bridge_brd_start(struct bridge_dev_context *dev_ctxt,
419 * function is made available. 428 * function is made available.
420 */ 429 */
421 void __iomem *ctrl = ioremap(0x48002000, SZ_4K); 430 void __iomem *ctrl = ioremap(0x48002000, SZ_4K);
422 if (!ctrl) 431 if (!ctrl) {
432 iounmap(sync_addr);
423 return -ENOMEM; 433 return -ENOMEM;
434 }
424 435
425 (*pdata->dsp_prm_rmw_bits)(OMAP3430_RST1_IVA2_MASK, 436 (*pdata->dsp_prm_rmw_bits)(OMAP3430_RST1_IVA2_MASK,
426 OMAP3430_RST1_IVA2_MASK, OMAP3430_IVA2_MOD, 437 OMAP3430_RST1_IVA2_MASK, OMAP3430_IVA2_MOD,
@@ -588,15 +599,15 @@ static int bridge_brd_start(struct bridge_dev_context *dev_ctxt,
588 (*pdata->dsp_prm_rmw_bits)(OMAP3430_RST1_IVA2_MASK, 0, 599 (*pdata->dsp_prm_rmw_bits)(OMAP3430_RST1_IVA2_MASK, 0,
589 OMAP3430_IVA2_MOD, OMAP2_RM_RSTCTRL); 600 OMAP3430_IVA2_MOD, OMAP2_RM_RSTCTRL);
590 601
591 dev_dbg(bridge, "Waiting for Sync @ 0x%x\n", dw_sync_addr); 602 dev_dbg(bridge, "Waiting for Sync @ 0x%x\n", *(u32 *)sync_addr);
592 dev_dbg(bridge, "DSP c_int00 Address = 0x%x\n", dsp_addr); 603 dev_dbg(bridge, "DSP c_int00 Address = 0x%x\n", dsp_addr);
593 if (dsp_debug) 604 if (dsp_debug)
594 while (__raw_readw(dw_sync_addr)) 605 while (__raw_readw(sync_addr))
595 ; 606 ;
596 607
597 /* Wait for DSP to clear word in shared memory */ 608 /* Wait for DSP to clear word in shared memory */
598 /* Read the Location */ 609 /* Read the Location */
599 if (!wait_for_start(dev_context, dw_sync_addr)) 610 if (!wait_for_start(dev_context, sync_addr))
600 status = -ETIMEDOUT; 611 status = -ETIMEDOUT;
601 612
602 dev_get_symbol(dev_context->dev_obj, "_WDT_enable", &wdt_en); 613 dev_get_symbol(dev_context->dev_obj, "_WDT_enable", &wdt_en);
@@ -612,7 +623,7 @@ static int bridge_brd_start(struct bridge_dev_context *dev_ctxt,
612 /* Write the synchronization bit to indicate the 623 /* Write the synchronization bit to indicate the
613 * completion of OPP table update to DSP 624 * completion of OPP table update to DSP
614 */ 625 */
615 __raw_writel(0XCAFECAFE, dw_sync_addr); 626 __raw_writel(0XCAFECAFE, sync_addr);
616 627
617 /* update board state */ 628 /* update board state */
618 dev_context->brd_state = BRD_RUNNING; 629 dev_context->brd_state = BRD_RUNNING;
@@ -621,6 +632,9 @@ static int bridge_brd_start(struct bridge_dev_context *dev_ctxt,
621 dev_context->brd_state = BRD_UNKNOWN; 632 dev_context->brd_state = BRD_UNKNOWN;
622 } 633 }
623 } 634 }
635
636 iounmap(sync_addr);
637
624 return status; 638 return status;
625} 639}
626 640
@@ -1796,12 +1810,13 @@ static int mem_map_vmalloc(struct bridge_dev_context *dev_context,
1796 * ======== wait_for_start ======== 1810 * ======== wait_for_start ========
1797 * Wait for the singal from DSP that it has started, or time out. 1811 * Wait for the singal from DSP that it has started, or time out.
1798 */ 1812 */
1799bool wait_for_start(struct bridge_dev_context *dev_context, u32 dw_sync_addr) 1813bool wait_for_start(struct bridge_dev_context *dev_context,
1814 void __iomem *sync_addr)
1800{ 1815{
1801 u16 timeout = TIHELEN_ACKTIMEOUT; 1816 u16 timeout = TIHELEN_ACKTIMEOUT;
1802 1817
1803 /* Wait for response from board */ 1818 /* Wait for response from board */
1804 while (__raw_readw(dw_sync_addr) && --timeout) 1819 while (__raw_readw(sync_addr) && --timeout)
1805 udelay(10); 1820 udelay(10);
1806 1821
1807 /* If timed out: return false */ 1822 /* If timed out: return false */
diff --git a/drivers/staging/tidspbridge/hw/hw_mmu.c b/drivers/staging/tidspbridge/hw/hw_mmu.c
index 71cb8229364..50244a47417 100644
--- a/drivers/staging/tidspbridge/hw/hw_mmu.c
+++ b/drivers/staging/tidspbridge/hw/hw_mmu.c
@@ -48,37 +48,12 @@ enum hw_mmu_page_size_t {
48}; 48};
49 49
50/* 50/*
51 * FUNCTION : mmu_flush_entry
52 *
53 * INPUTS:
54 *
55 * Identifier : base_address
56 * Type : const u32
57 * Description : Base Address of instance of MMU module
58 *
59 * RETURNS:
60 *
61 * Type : hw_status
62 * Description : 0 -- No errors occurred
63 * RET_BAD_NULL_PARAM -- A Pointer
64 * Parameter was set to NULL
65 *
66 * PURPOSE: : Flush the TLB entry pointed by the
67 * lock counter register
68 * even if this entry is set protected
69 *
70 * METHOD: : Check the Input parameter and Flush a
71 * single entry in the TLB.
72 */
73static hw_status mmu_flush_entry(const void __iomem *base_address);
74
75/*
76 * FUNCTION : mmu_set_cam_entry 51 * FUNCTION : mmu_set_cam_entry
77 * 52 *
78 * INPUTS: 53 * INPUTS:
79 * 54 *
80 * Identifier : base_address 55 * Identifier : base_address
81 * TypE : const u32 56 * Type : void __iomem *
82 * Description : Base Address of instance of MMU module 57 * Description : Base Address of instance of MMU module
83 * 58 *
84 * Identifier : page_sz 59 * Identifier : page_sz
@@ -112,7 +87,7 @@ static hw_status mmu_flush_entry(const void __iomem *base_address);
112 * 87 *
113 * METHOD: : Check the Input parameters and set the CAM entry. 88 * METHOD: : Check the Input parameters and set the CAM entry.
114 */ 89 */
115static hw_status mmu_set_cam_entry(const void __iomem *base_address, 90static hw_status mmu_set_cam_entry(void __iomem *base_address,
116 const u32 page_sz, 91 const u32 page_sz,
117 const u32 preserved_bit, 92 const u32 preserved_bit,
118 const u32 valid_bit, 93 const u32 valid_bit,
@@ -124,7 +99,7 @@ static hw_status mmu_set_cam_entry(const void __iomem *base_address,
124 * INPUTS: 99 * INPUTS:
125 * 100 *
126 * Identifier : base_address 101 * Identifier : base_address
127 * Type : const u32 102 * Type : void __iomem *
128 * Description : Base Address of instance of MMU module 103 * Description : Base Address of instance of MMU module
129 * 104 *
130 * Identifier : physical_addr 105 * Identifier : physical_addr
@@ -157,7 +132,7 @@ static hw_status mmu_set_cam_entry(const void __iomem *base_address,
157 * 132 *
158 * METHOD: : Check the Input parameters and set the RAM entry. 133 * METHOD: : Check the Input parameters and set the RAM entry.
159 */ 134 */
160static hw_status mmu_set_ram_entry(const void __iomem *base_address, 135static hw_status mmu_set_ram_entry(void __iomem *base_address,
161 const u32 physical_addr, 136 const u32 physical_addr,
162 enum hw_endianism_t endianism, 137 enum hw_endianism_t endianism,
163 enum hw_element_size_t element_size, 138 enum hw_element_size_t element_size,
@@ -165,7 +140,7 @@ static hw_status mmu_set_ram_entry(const void __iomem *base_address,
165 140
166/* HW FUNCTIONS */ 141/* HW FUNCTIONS */
167 142
168hw_status hw_mmu_enable(const void __iomem *base_address) 143hw_status hw_mmu_enable(void __iomem *base_address)
169{ 144{
170 hw_status status = 0; 145 hw_status status = 0;
171 146
@@ -174,7 +149,7 @@ hw_status hw_mmu_enable(const void __iomem *base_address)
174 return status; 149 return status;
175} 150}
176 151
177hw_status hw_mmu_disable(const void __iomem *base_address) 152hw_status hw_mmu_disable(void __iomem *base_address)
178{ 153{
179 hw_status status = 0; 154 hw_status status = 0;
180 155
@@ -183,7 +158,7 @@ hw_status hw_mmu_disable(const void __iomem *base_address)
183 return status; 158 return status;
184} 159}
185 160
186hw_status hw_mmu_num_locked_set(const void __iomem *base_address, 161hw_status hw_mmu_num_locked_set(void __iomem *base_address,
187 u32 num_locked_entries) 162 u32 num_locked_entries)
188{ 163{
189 hw_status status = 0; 164 hw_status status = 0;
@@ -193,7 +168,7 @@ hw_status hw_mmu_num_locked_set(const void __iomem *base_address,
193 return status; 168 return status;
194} 169}
195 170
196hw_status hw_mmu_victim_num_set(const void __iomem *base_address, 171hw_status hw_mmu_victim_num_set(void __iomem *base_address,
197 u32 victim_entry_num) 172 u32 victim_entry_num)
198{ 173{
199 hw_status status = 0; 174 hw_status status = 0;
@@ -203,7 +178,7 @@ hw_status hw_mmu_victim_num_set(const void __iomem *base_address,
203 return status; 178 return status;
204} 179}
205 180
206hw_status hw_mmu_event_ack(const void __iomem *base_address, u32 irq_mask) 181hw_status hw_mmu_event_ack(void __iomem *base_address, u32 irq_mask)
207{ 182{
208 hw_status status = 0; 183 hw_status status = 0;
209 184
@@ -212,7 +187,7 @@ hw_status hw_mmu_event_ack(const void __iomem *base_address, u32 irq_mask)
212 return status; 187 return status;
213} 188}
214 189
215hw_status hw_mmu_event_disable(const void __iomem *base_address, u32 irq_mask) 190hw_status hw_mmu_event_disable(void __iomem *base_address, u32 irq_mask)
216{ 191{
217 hw_status status = 0; 192 hw_status status = 0;
218 u32 irq_reg; 193 u32 irq_reg;
@@ -224,7 +199,7 @@ hw_status hw_mmu_event_disable(const void __iomem *base_address, u32 irq_mask)
224 return status; 199 return status;
225} 200}
226 201
227hw_status hw_mmu_event_enable(const void __iomem *base_address, u32 irq_mask) 202hw_status hw_mmu_event_enable(void __iomem *base_address, u32 irq_mask)
228{ 203{
229 hw_status status = 0; 204 hw_status status = 0;
230 u32 irq_reg; 205 u32 irq_reg;
@@ -236,7 +211,7 @@ hw_status hw_mmu_event_enable(const void __iomem *base_address, u32 irq_mask)
236 return status; 211 return status;
237} 212}
238 213
239hw_status hw_mmu_event_status(const void __iomem *base_address, u32 *irq_mask) 214hw_status hw_mmu_event_status(void __iomem *base_address, u32 *irq_mask)
240{ 215{
241 hw_status status = 0; 216 hw_status status = 0;
242 217
@@ -245,7 +220,7 @@ hw_status hw_mmu_event_status(const void __iomem *base_address, u32 *irq_mask)
245 return status; 220 return status;
246} 221}
247 222
248hw_status hw_mmu_fault_addr_read(const void __iomem *base_address, u32 *addr) 223hw_status hw_mmu_fault_addr_read(void __iomem *base_address, u32 *addr)
249{ 224{
250 hw_status status = 0; 225 hw_status status = 0;
251 226
@@ -255,7 +230,7 @@ hw_status hw_mmu_fault_addr_read(const void __iomem *base_address, u32 *addr)
255 return status; 230 return status;
256} 231}
257 232
258hw_status hw_mmu_ttb_set(const void __iomem *base_address, u32 ttb_phys_addr) 233hw_status hw_mmu_ttb_set(void __iomem *base_address, u32 ttb_phys_addr)
259{ 234{
260 hw_status status = 0; 235 hw_status status = 0;
261 u32 load_ttb; 236 u32 load_ttb;
@@ -267,7 +242,7 @@ hw_status hw_mmu_ttb_set(const void __iomem *base_address, u32 ttb_phys_addr)
267 return status; 242 return status;
268} 243}
269 244
270hw_status hw_mmu_twl_enable(const void __iomem *base_address) 245hw_status hw_mmu_twl_enable(void __iomem *base_address)
271{ 246{
272 hw_status status = 0; 247 hw_status status = 0;
273 248
@@ -276,7 +251,7 @@ hw_status hw_mmu_twl_enable(const void __iomem *base_address)
276 return status; 251 return status;
277} 252}
278 253
279hw_status hw_mmu_twl_disable(const void __iomem *base_address) 254hw_status hw_mmu_twl_disable(void __iomem *base_address)
280{ 255{
281 hw_status status = 0; 256 hw_status status = 0;
282 257
@@ -285,45 +260,7 @@ hw_status hw_mmu_twl_disable(const void __iomem *base_address)
285 return status; 260 return status;
286} 261}
287 262
288hw_status hw_mmu_tlb_flush(const void __iomem *base_address, u32 virtual_addr, 263hw_status hw_mmu_tlb_add(void __iomem *base_address,
289 u32 page_sz)
290{
291 hw_status status = 0;
292 u32 virtual_addr_tag;
293 enum hw_mmu_page_size_t pg_size_bits;
294
295 switch (page_sz) {
296 case HW_PAGE_SIZE4KB:
297 pg_size_bits = HW_MMU_SMALL_PAGE;
298 break;
299
300 case HW_PAGE_SIZE64KB:
301 pg_size_bits = HW_MMU_LARGE_PAGE;
302 break;
303
304 case HW_PAGE_SIZE1MB:
305 pg_size_bits = HW_MMU_SECTION;
306 break;
307
308 case HW_PAGE_SIZE16MB:
309 pg_size_bits = HW_MMU_SUPERSECTION;
310 break;
311
312 default:
313 return -EINVAL;
314 }
315
316 /* Generate the 20-bit tag from virtual address */
317 virtual_addr_tag = ((virtual_addr & MMU_ADDR_MASK) >> 12);
318
319 mmu_set_cam_entry(base_address, pg_size_bits, 0, 0, virtual_addr_tag);
320
321 mmu_flush_entry(base_address);
322
323 return status;
324}
325
326hw_status hw_mmu_tlb_add(const void __iomem *base_address,
327 u32 physical_addr, 264 u32 physical_addr,
328 u32 virtual_addr, 265 u32 virtual_addr,
329 u32 page_sz, 266 u32 page_sz,
@@ -503,20 +440,8 @@ hw_status hw_mmu_pte_clear(const u32 pg_tbl_va, u32 virtual_addr, u32 page_size)
503 return status; 440 return status;
504} 441}
505 442
506/* mmu_flush_entry */
507static hw_status mmu_flush_entry(const void __iomem *base_address)
508{
509 hw_status status = 0;
510 u32 flush_entry_data = 0x1;
511
512 /* write values to register */
513 MMUMMU_FLUSH_ENTRY_WRITE_REGISTER32(base_address, flush_entry_data);
514
515 return status;
516}
517
518/* mmu_set_cam_entry */ 443/* mmu_set_cam_entry */
519static hw_status mmu_set_cam_entry(const void __iomem *base_address, 444static hw_status mmu_set_cam_entry(void __iomem *base_address,
520 const u32 page_sz, 445 const u32 page_sz,
521 const u32 preserved_bit, 446 const u32 preserved_bit,
522 const u32 valid_bit, 447 const u32 valid_bit,
@@ -536,7 +461,7 @@ static hw_status mmu_set_cam_entry(const void __iomem *base_address,
536} 461}
537 462
538/* mmu_set_ram_entry */ 463/* mmu_set_ram_entry */
539static hw_status mmu_set_ram_entry(const void __iomem *base_address, 464static hw_status mmu_set_ram_entry(void __iomem *base_address,
540 const u32 physical_addr, 465 const u32 physical_addr,
541 enum hw_endianism_t endianism, 466 enum hw_endianism_t endianism,
542 enum hw_element_size_t element_size, 467 enum hw_element_size_t element_size,
@@ -556,7 +481,7 @@ static hw_status mmu_set_ram_entry(const void __iomem *base_address,
556 481
557} 482}
558 483
559void hw_mmu_tlb_flush_all(const void __iomem *base) 484void hw_mmu_tlb_flush_all(void __iomem *base)
560{ 485{
561 __raw_writel(1, base + MMU_GFLUSH); 486 __raw_writel(1, base + MMU_GFLUSH);
562} 487}
diff --git a/drivers/staging/tidspbridge/hw/hw_mmu.h b/drivers/staging/tidspbridge/hw/hw_mmu.h
index 1458a2c6027..1c50bb36edf 100644
--- a/drivers/staging/tidspbridge/hw/hw_mmu.h
+++ b/drivers/staging/tidspbridge/hw/hw_mmu.h
@@ -42,44 +42,41 @@ struct hw_mmu_map_attrs_t {
42 bool donotlockmpupage; 42 bool donotlockmpupage;
43}; 43};
44 44
45extern hw_status hw_mmu_enable(const void __iomem *base_address); 45extern hw_status hw_mmu_enable(void __iomem *base_address);
46 46
47extern hw_status hw_mmu_disable(const void __iomem *base_address); 47extern hw_status hw_mmu_disable(void __iomem *base_address);
48 48
49extern hw_status hw_mmu_num_locked_set(const void __iomem *base_address, 49extern hw_status hw_mmu_num_locked_set(void __iomem *base_address,
50 u32 num_locked_entries); 50 u32 num_locked_entries);
51 51
52extern hw_status hw_mmu_victim_num_set(const void __iomem *base_address, 52extern hw_status hw_mmu_victim_num_set(void __iomem *base_address,
53 u32 victim_entry_num); 53 u32 victim_entry_num);
54 54
55/* For MMU faults */ 55/* For MMU faults */
56extern hw_status hw_mmu_event_ack(const void __iomem *base_address, 56extern hw_status hw_mmu_event_ack(void __iomem *base_address,
57 u32 irq_mask); 57 u32 irq_mask);
58 58
59extern hw_status hw_mmu_event_disable(const void __iomem *base_address, 59extern hw_status hw_mmu_event_disable(void __iomem *base_address,
60 u32 irq_mask); 60 u32 irq_mask);
61 61
62extern hw_status hw_mmu_event_enable(const void __iomem *base_address, 62extern hw_status hw_mmu_event_enable(void __iomem *base_address,
63 u32 irq_mask); 63 u32 irq_mask);
64 64
65extern hw_status hw_mmu_event_status(const void __iomem *base_address, 65extern hw_status hw_mmu_event_status(void __iomem *base_address,
66 u32 *irq_mask); 66 u32 *irq_mask);
67 67
68extern hw_status hw_mmu_fault_addr_read(const void __iomem *base_address, 68extern hw_status hw_mmu_fault_addr_read(void __iomem *base_address,
69 u32 *addr); 69 u32 *addr);
70 70
71/* Set the TT base address */ 71/* Set the TT base address */
72extern hw_status hw_mmu_ttb_set(const void __iomem *base_address, 72extern hw_status hw_mmu_ttb_set(void __iomem *base_address,
73 u32 ttb_phys_addr); 73 u32 ttb_phys_addr);
74 74
75extern hw_status hw_mmu_twl_enable(const void __iomem *base_address); 75extern hw_status hw_mmu_twl_enable(void __iomem *base_address);
76 76
77extern hw_status hw_mmu_twl_disable(const void __iomem *base_address); 77extern hw_status hw_mmu_twl_disable(void __iomem *base_address);
78 78
79extern hw_status hw_mmu_tlb_flush(const void __iomem *base_address, 79extern hw_status hw_mmu_tlb_add(void __iomem *base_address,
80 u32 virtual_addr, u32 page_sz);
81
82extern hw_status hw_mmu_tlb_add(const void __iomem *base_address,
83 u32 physical_addr, 80 u32 physical_addr,
84 u32 virtual_addr, 81 u32 virtual_addr,
85 u32 page_sz, 82 u32 page_sz,
@@ -97,7 +94,7 @@ extern hw_status hw_mmu_pte_set(const u32 pg_tbl_va,
97extern hw_status hw_mmu_pte_clear(const u32 pg_tbl_va, 94extern hw_status hw_mmu_pte_clear(const u32 pg_tbl_va,
98 u32 virtual_addr, u32 page_size); 95 u32 virtual_addr, u32 page_size);
99 96
100void hw_mmu_tlb_flush_all(const void __iomem *base); 97void hw_mmu_tlb_flush_all(void __iomem *base);
101 98
102static inline u32 hw_mmu_pte_addr_l1(u32 l1_base, u32 va) 99static inline u32 hw_mmu_pte_addr_l1(u32 l1_base, u32 va)
103{ 100{
diff --git a/drivers/staging/tidspbridge/include/dspbridge/cfgdefs.h b/drivers/staging/tidspbridge/include/dspbridge/cfgdefs.h
index 60a278136bd..b32c75673ab 100644
--- a/drivers/staging/tidspbridge/include/dspbridge/cfgdefs.h
+++ b/drivers/staging/tidspbridge/include/dspbridge/cfgdefs.h
@@ -53,8 +53,8 @@ struct cfg_hostres {
53 u32 chnl_buf_size; 53 u32 chnl_buf_size;
54 u32 num_chnls; 54 u32 num_chnls;
55 void __iomem *per_base; 55 void __iomem *per_base;
56 u32 per_pm_base; 56 void __iomem *per_pm_base;
57 u32 core_pm_base; 57 void __iomem *core_pm_base;
58 void __iomem *dmmu_base; 58 void __iomem *dmmu_base;
59}; 59};
60 60
diff --git a/drivers/staging/tidspbridge/include/dspbridge/host_os.h b/drivers/staging/tidspbridge/include/dspbridge/host_os.h
index ed00d3da320..5e2f4d82d92 100644
--- a/drivers/staging/tidspbridge/include/dspbridge/host_os.h
+++ b/drivers/staging/tidspbridge/include/dspbridge/host_os.h
@@ -47,8 +47,8 @@
47#include <asm/cacheflush.h> 47#include <asm/cacheflush.h>
48#include <linux/dma-mapping.h> 48#include <linux/dma-mapping.h>
49 49
50/* TODO -- Remove, once BP defines them */ 50/* TODO -- Remove, once omap-iommu is used */
51#define INT_DSP_MMU_IRQ 28 51#define INT_DSP_MMU_IRQ (28 + NR_IRQS)
52 52
53#define PRCM_VDD1 1 53#define PRCM_VDD1 1
54 54
diff --git a/drivers/staging/tidspbridge/rmgr/drv.c b/drivers/staging/tidspbridge/rmgr/drv.c
index 6795205b015..db1da28cecb 100644
--- a/drivers/staging/tidspbridge/rmgr/drv.c
+++ b/drivers/staging/tidspbridge/rmgr/drv.c
@@ -667,10 +667,10 @@ int drv_request_bridge_res_dsp(void **phost_resources)
667 OMAP_DSP_MEM3_SIZE); 667 OMAP_DSP_MEM3_SIZE);
668 host_res->per_base = ioremap(OMAP_PER_CM_BASE, 668 host_res->per_base = ioremap(OMAP_PER_CM_BASE,
669 OMAP_PER_CM_SIZE); 669 OMAP_PER_CM_SIZE);
670 host_res->per_pm_base = (u32) ioremap(OMAP_PER_PRM_BASE, 670 host_res->per_pm_base = ioremap(OMAP_PER_PRM_BASE,
671 OMAP_PER_PRM_SIZE); 671 OMAP_PER_PRM_SIZE);
672 host_res->core_pm_base = (u32) ioremap(OMAP_CORE_PRM_BASE, 672 host_res->core_pm_base = ioremap(OMAP_CORE_PRM_BASE,
673 OMAP_CORE_PRM_SIZE); 673 OMAP_CORE_PRM_SIZE);
674 host_res->dmmu_base = ioremap(OMAP_DMMU_BASE, 674 host_res->dmmu_base = ioremap(OMAP_DMMU_BASE,
675 OMAP_DMMU_SIZE); 675 OMAP_DMMU_SIZE);
676 676
diff --git a/drivers/staging/tidspbridge/rmgr/node.c b/drivers/staging/tidspbridge/rmgr/node.c
index c2fc6137c77..294e9b40f51 100644
--- a/drivers/staging/tidspbridge/rmgr/node.c
+++ b/drivers/staging/tidspbridge/rmgr/node.c
@@ -304,8 +304,7 @@ int node_allocate(struct proc_object *hprocessor,
304 u32 pul_value; 304 u32 pul_value;
305 u32 dynext_base; 305 u32 dynext_base;
306 u32 off_set = 0; 306 u32 off_set = 0;
307 u32 ul_stack_seg_addr, ul_stack_seg_val; 307 u32 ul_stack_seg_val;
308 u32 ul_gpp_mem_base;
309 struct cfg_hostres *host_res; 308 struct cfg_hostres *host_res;
310 struct bridge_dev_context *pbridge_context; 309 struct bridge_dev_context *pbridge_context;
311 u32 mapped_addr = 0; 310 u32 mapped_addr = 0;
@@ -581,6 +580,9 @@ func_cont:
581 if (strcmp((char *) 580 if (strcmp((char *)
582 pnode->dcd_props.obj_data.node_obj.ndb_props. 581 pnode->dcd_props.obj_data.node_obj.ndb_props.
583 stack_seg_name, STACKSEGLABEL) == 0) { 582 stack_seg_name, STACKSEGLABEL) == 0) {
583 void __iomem *stack_seg;
584 u32 stack_seg_pa;
585
584 status = 586 status =
585 hnode_mgr->nldr_fxns. 587 hnode_mgr->nldr_fxns.
586 get_fxn_addr(pnode->nldr_node_obj, "DYNEXT_BEG", 588 get_fxn_addr(pnode->nldr_node_obj, "DYNEXT_BEG",
@@ -608,14 +610,21 @@ func_cont:
608 goto func_end; 610 goto func_end;
609 } 611 }
610 612
611 ul_gpp_mem_base = (u32) host_res->mem_base[1];
612 off_set = pul_value - dynext_base; 613 off_set = pul_value - dynext_base;
613 ul_stack_seg_addr = ul_gpp_mem_base + off_set; 614 stack_seg_pa = host_res->mem_phys[1] + off_set;
614 ul_stack_seg_val = readl(ul_stack_seg_addr); 615 stack_seg = ioremap(stack_seg_pa, SZ_32);
616 if (!stack_seg) {
617 status = -ENOMEM;
618 goto func_end;
619 }
620
621 ul_stack_seg_val = readl(stack_seg);
622
623 iounmap(stack_seg);
615 624
616 dev_dbg(bridge, "%s: StackSegVal = 0x%x, StackSegAddr =" 625 dev_dbg(bridge, "%s: StackSegVal = 0x%x, StackSegAddr ="
617 " 0x%x\n", __func__, ul_stack_seg_val, 626 " 0x%x\n", __func__, ul_stack_seg_val,
618 ul_stack_seg_addr); 627 host_res->mem_base[1] + off_set);
619 628
620 pnode->create_args.asa.task_arg_obj.stack_seg = 629 pnode->create_args.asa.task_arg_obj.stack_seg =
621 ul_stack_seg_val; 630 ul_stack_seg_val;
diff --git a/drivers/staging/zram/zram_drv.c b/drivers/staging/zram/zram_drv.c
index 653b074035f..6edefde2372 100644
--- a/drivers/staging/zram/zram_drv.c
+++ b/drivers/staging/zram/zram_drv.c
@@ -223,8 +223,13 @@ static int zram_bvec_read(struct zram *zram, struct bio_vec *bvec,
223 cmem = zs_map_object(zram->mem_pool, zram->table[index].handle, 223 cmem = zs_map_object(zram->mem_pool, zram->table[index].handle,
224 ZS_MM_RO); 224 ZS_MM_RO);
225 225
226 ret = lzo1x_decompress_safe(cmem, zram->table[index].size, 226 if (zram->table[index].size == PAGE_SIZE) {
227 memcpy(uncmem, cmem, PAGE_SIZE);
228 ret = LZO_E_OK;
229 } else {
230 ret = lzo1x_decompress_safe(cmem, zram->table[index].size,
227 uncmem, &clen); 231 uncmem, &clen);
232 }
228 233
229 if (is_partial_io(bvec)) { 234 if (is_partial_io(bvec)) {
230 memcpy(user_mem + bvec->bv_offset, uncmem + offset, 235 memcpy(user_mem + bvec->bv_offset, uncmem + offset,
@@ -342,8 +347,11 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index,
342 goto out; 347 goto out;
343 } 348 }
344 349
345 if (unlikely(clen > max_zpage_size)) 350 if (unlikely(clen > max_zpage_size)) {
346 zram_stat_inc(&zram->stats.bad_compress); 351 zram_stat_inc(&zram->stats.bad_compress);
352 src = uncmem;
353 clen = PAGE_SIZE;
354 }
347 355
348 handle = zs_malloc(zram->mem_pool, clen); 356 handle = zs_malloc(zram->mem_pool, clen);
349 if (!handle) { 357 if (!handle) {
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
index d6ce2182e67..035c2c76253 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -3719,7 +3719,9 @@ restart:
3719 */ 3719 */
3720 iscsit_thread_check_cpumask(conn, current, 1); 3720 iscsit_thread_check_cpumask(conn, current, 1);
3721 3721
3722 schedule_timeout_interruptible(MAX_SCHEDULE_TIMEOUT); 3722 wait_event_interruptible(conn->queues_wq,
3723 !iscsit_conn_all_queues_empty(conn) ||
3724 ts->status == ISCSI_THREAD_SET_RESET);
3723 3725
3724 if ((ts->status == ISCSI_THREAD_SET_RESET) || 3726 if ((ts->status == ISCSI_THREAD_SET_RESET) ||
3725 signal_pending(current)) 3727 signal_pending(current))
diff --git a/drivers/target/iscsi/iscsi_target_core.h b/drivers/target/iscsi/iscsi_target_core.h
index 2ba9f9b9435..21048dbf7d1 100644
--- a/drivers/target/iscsi/iscsi_target_core.h
+++ b/drivers/target/iscsi/iscsi_target_core.h
@@ -486,6 +486,7 @@ struct iscsi_tmr_req {
486}; 486};
487 487
488struct iscsi_conn { 488struct iscsi_conn {
489 wait_queue_head_t queues_wq;
489 /* Authentication Successful for this connection */ 490 /* Authentication Successful for this connection */
490 u8 auth_complete; 491 u8 auth_complete;
491 /* State connection is currently in */ 492 /* State connection is currently in */
diff --git a/drivers/target/iscsi/iscsi_target_login.c b/drivers/target/iscsi/iscsi_target_login.c
index cdc8a10939c..f8dbec05d5e 100644
--- a/drivers/target/iscsi/iscsi_target_login.c
+++ b/drivers/target/iscsi/iscsi_target_login.c
@@ -41,6 +41,7 @@
41 41
42static int iscsi_login_init_conn(struct iscsi_conn *conn) 42static int iscsi_login_init_conn(struct iscsi_conn *conn)
43{ 43{
44 init_waitqueue_head(&conn->queues_wq);
44 INIT_LIST_HEAD(&conn->conn_list); 45 INIT_LIST_HEAD(&conn->conn_list);
45 INIT_LIST_HEAD(&conn->conn_cmd_list); 46 INIT_LIST_HEAD(&conn->conn_cmd_list);
46 INIT_LIST_HEAD(&conn->immed_queue_list); 47 INIT_LIST_HEAD(&conn->immed_queue_list);
diff --git a/drivers/target/iscsi/iscsi_target_util.c b/drivers/target/iscsi/iscsi_target_util.c
index afd98ccd40a..1a91195ab61 100644
--- a/drivers/target/iscsi/iscsi_target_util.c
+++ b/drivers/target/iscsi/iscsi_target_util.c
@@ -488,7 +488,7 @@ void iscsit_add_cmd_to_immediate_queue(
488 atomic_set(&conn->check_immediate_queue, 1); 488 atomic_set(&conn->check_immediate_queue, 1);
489 spin_unlock_bh(&conn->immed_queue_lock); 489 spin_unlock_bh(&conn->immed_queue_lock);
490 490
491 wake_up_process(conn->thread_set->tx_thread); 491 wake_up(&conn->queues_wq);
492} 492}
493 493
494struct iscsi_queue_req *iscsit_get_cmd_from_immediate_queue(struct iscsi_conn *conn) 494struct iscsi_queue_req *iscsit_get_cmd_from_immediate_queue(struct iscsi_conn *conn)
@@ -562,7 +562,7 @@ void iscsit_add_cmd_to_response_queue(
562 atomic_inc(&cmd->response_queue_count); 562 atomic_inc(&cmd->response_queue_count);
563 spin_unlock_bh(&conn->response_queue_lock); 563 spin_unlock_bh(&conn->response_queue_lock);
564 564
565 wake_up_process(conn->thread_set->tx_thread); 565 wake_up(&conn->queues_wq);
566} 566}
567 567
568struct iscsi_queue_req *iscsit_get_cmd_from_response_queue(struct iscsi_conn *conn) 568struct iscsi_queue_req *iscsit_get_cmd_from_response_queue(struct iscsi_conn *conn)
@@ -616,6 +616,24 @@ static void iscsit_remove_cmd_from_response_queue(
616 } 616 }
617} 617}
618 618
619bool iscsit_conn_all_queues_empty(struct iscsi_conn *conn)
620{
621 bool empty;
622
623 spin_lock_bh(&conn->immed_queue_lock);
624 empty = list_empty(&conn->immed_queue_list);
625 spin_unlock_bh(&conn->immed_queue_lock);
626
627 if (!empty)
628 return empty;
629
630 spin_lock_bh(&conn->response_queue_lock);
631 empty = list_empty(&conn->response_queue_list);
632 spin_unlock_bh(&conn->response_queue_lock);
633
634 return empty;
635}
636
619void iscsit_free_queue_reqs_for_conn(struct iscsi_conn *conn) 637void iscsit_free_queue_reqs_for_conn(struct iscsi_conn *conn)
620{ 638{
621 struct iscsi_queue_req *qr, *qr_tmp; 639 struct iscsi_queue_req *qr, *qr_tmp;
diff --git a/drivers/target/iscsi/iscsi_target_util.h b/drivers/target/iscsi/iscsi_target_util.h
index 44054bd3543..894d0f83792 100644
--- a/drivers/target/iscsi/iscsi_target_util.h
+++ b/drivers/target/iscsi/iscsi_target_util.h
@@ -25,6 +25,7 @@ extern struct iscsi_queue_req *iscsit_get_cmd_from_immediate_queue(struct iscsi_
25extern void iscsit_add_cmd_to_response_queue(struct iscsi_cmd *, struct iscsi_conn *, u8); 25extern void iscsit_add_cmd_to_response_queue(struct iscsi_cmd *, struct iscsi_conn *, u8);
26extern struct iscsi_queue_req *iscsit_get_cmd_from_response_queue(struct iscsi_conn *); 26extern struct iscsi_queue_req *iscsit_get_cmd_from_response_queue(struct iscsi_conn *);
27extern void iscsit_remove_cmd_from_tx_queues(struct iscsi_cmd *, struct iscsi_conn *); 27extern void iscsit_remove_cmd_from_tx_queues(struct iscsi_cmd *, struct iscsi_conn *);
28extern bool iscsit_conn_all_queues_empty(struct iscsi_conn *);
28extern void iscsit_free_queue_reqs_for_conn(struct iscsi_conn *); 29extern void iscsit_free_queue_reqs_for_conn(struct iscsi_conn *);
29extern void iscsit_release_cmd(struct iscsi_cmd *); 30extern void iscsit_release_cmd(struct iscsi_cmd *);
30extern void iscsit_free_cmd(struct iscsi_cmd *); 31extern void iscsit_free_cmd(struct iscsi_cmd *);
diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
index 015f5be27bf..c123327499a 100644
--- a/drivers/target/target_core_configfs.c
+++ b/drivers/target/target_core_configfs.c
@@ -3206,7 +3206,8 @@ static int __init target_core_init_configfs(void)
3206 if (ret < 0) 3206 if (ret < 0)
3207 goto out; 3207 goto out;
3208 3208
3209 if (core_dev_setup_virtual_lun0() < 0) 3209 ret = core_dev_setup_virtual_lun0();
3210 if (ret < 0)
3210 goto out; 3211 goto out;
3211 3212
3212 return 0; 3213 return 0;
diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
index 8d774da1632..9abef9f8eb7 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -850,20 +850,20 @@ int se_dev_check_shutdown(struct se_device *dev)
850 850
851static u32 se_dev_align_max_sectors(u32 max_sectors, u32 block_size) 851static u32 se_dev_align_max_sectors(u32 max_sectors, u32 block_size)
852{ 852{
853 u32 tmp, aligned_max_sectors; 853 u32 aligned_max_sectors;
854 u32 alignment;
854 /* 855 /*
855 * Limit max_sectors to a PAGE_SIZE aligned value for modern 856 * Limit max_sectors to a PAGE_SIZE aligned value for modern
856 * transport_allocate_data_tasks() operation. 857 * transport_allocate_data_tasks() operation.
857 */ 858 */
858 tmp = rounddown((max_sectors * block_size), PAGE_SIZE); 859 alignment = max(1ul, PAGE_SIZE / block_size);
859 aligned_max_sectors = (tmp / block_size); 860 aligned_max_sectors = rounddown(max_sectors, alignment);
860 if (max_sectors != aligned_max_sectors) { 861
861 printk(KERN_INFO "Rounding down aligned max_sectors from %u" 862 if (max_sectors != aligned_max_sectors)
862 " to %u\n", max_sectors, aligned_max_sectors); 863 pr_info("Rounding down aligned max_sectors from %u to %u\n",
863 return aligned_max_sectors; 864 max_sectors, aligned_max_sectors);
864 }
865 865
866 return max_sectors; 866 return aligned_max_sectors;
867} 867}
868 868
869void se_dev_set_default_attribs( 869void se_dev_set_default_attribs(
diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c
index 868f8aa04f1..a6e27d967c7 100644
--- a/drivers/target/target_core_sbc.c
+++ b/drivers/target/target_core_sbc.c
@@ -135,6 +135,12 @@ static int sbc_emulate_verify(struct se_cmd *cmd)
135 return 0; 135 return 0;
136} 136}
137 137
138static int sbc_emulate_noop(struct se_cmd *cmd)
139{
140 target_complete_cmd(cmd, GOOD);
141 return 0;
142}
143
138static inline u32 sbc_get_size(struct se_cmd *cmd, u32 sectors) 144static inline u32 sbc_get_size(struct se_cmd *cmd, u32 sectors)
139{ 145{
140 return cmd->se_dev->se_sub_dev->se_dev_attrib.block_size * sectors; 146 return cmd->se_dev->se_sub_dev->se_dev_attrib.block_size * sectors;
@@ -531,6 +537,18 @@ int sbc_parse_cdb(struct se_cmd *cmd, struct spc_ops *ops)
531 size = 0; 537 size = 0;
532 cmd->execute_cmd = sbc_emulate_verify; 538 cmd->execute_cmd = sbc_emulate_verify;
533 break; 539 break;
540 case REZERO_UNIT:
541 case SEEK_6:
542 case SEEK_10:
543 /*
544 * There are still clients out there which use these old SCSI-2
545 * commands. This mainly happens when running VMs with legacy
546 * guest systems, connected via SCSI command pass-through to
547 * iSCSI targets. Make them happy and return status GOOD.
548 */
549 size = 0;
550 cmd->execute_cmd = sbc_emulate_noop;
551 break;
534 default: 552 default:
535 ret = spc_parse_cdb(cmd, &size); 553 ret = spc_parse_cdb(cmd, &size);
536 if (ret) 554 if (ret)
diff --git a/drivers/target/target_core_spc.c b/drivers/target/target_core_spc.c
index 9229bd9ad61..6fd434d3d7e 100644
--- a/drivers/target/target_core_spc.c
+++ b/drivers/target/target_core_spc.c
@@ -605,6 +605,8 @@ static int spc_emulate_inquiry(struct se_cmd *cmd)
605 unsigned char buf[SE_INQUIRY_BUF]; 605 unsigned char buf[SE_INQUIRY_BUF];
606 int p, ret; 606 int p, ret;
607 607
608 memset(buf, 0, SE_INQUIRY_BUF);
609
608 if (dev == tpg->tpg_virt_lun0.lun_se_dev) 610 if (dev == tpg->tpg_virt_lun0.lun_se_dev)
609 buf[0] = 0x3f; /* Not connected */ 611 buf[0] = 0x3f; /* Not connected */
610 else 612 else
diff --git a/drivers/target/target_core_tmr.c b/drivers/target/target_core_tmr.c
index 1c59a3c23b2..be75c4331a9 100644
--- a/drivers/target/target_core_tmr.c
+++ b/drivers/target/target_core_tmr.c
@@ -140,15 +140,15 @@ void core_tmr_abort_task(
140 printk("ABORT_TASK: Found referenced %s task_tag: %u\n", 140 printk("ABORT_TASK: Found referenced %s task_tag: %u\n",
141 se_cmd->se_tfo->get_fabric_name(), ref_tag); 141 se_cmd->se_tfo->get_fabric_name(), ref_tag);
142 142
143 spin_lock_irq(&se_cmd->t_state_lock); 143 spin_lock(&se_cmd->t_state_lock);
144 if (se_cmd->transport_state & CMD_T_COMPLETE) { 144 if (se_cmd->transport_state & CMD_T_COMPLETE) {
145 printk("ABORT_TASK: ref_tag: %u already complete, skipping\n", ref_tag); 145 printk("ABORT_TASK: ref_tag: %u already complete, skipping\n", ref_tag);
146 spin_unlock_irq(&se_cmd->t_state_lock); 146 spin_unlock(&se_cmd->t_state_lock);
147 spin_unlock_irqrestore(&se_sess->sess_cmd_lock, flags); 147 spin_unlock_irqrestore(&se_sess->sess_cmd_lock, flags);
148 goto out; 148 goto out;
149 } 149 }
150 se_cmd->transport_state |= CMD_T_ABORTED; 150 se_cmd->transport_state |= CMD_T_ABORTED;
151 spin_unlock_irq(&se_cmd->t_state_lock); 151 spin_unlock(&se_cmd->t_state_lock);
152 152
153 list_del_init(&se_cmd->se_cmd_list); 153 list_del_init(&se_cmd->se_cmd_list);
154 kref_get(&se_cmd->cmd_kref); 154 kref_get(&se_cmd->cmd_kref);
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index c33baff86aa..9097155e9eb 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -1616,7 +1616,6 @@ static void target_complete_tmr_failure(struct work_struct *work)
1616 1616
1617 se_cmd->se_tmr_req->response = TMR_LUN_DOES_NOT_EXIST; 1617 se_cmd->se_tmr_req->response = TMR_LUN_DOES_NOT_EXIST;
1618 se_cmd->se_tfo->queue_tm_rsp(se_cmd); 1618 se_cmd->se_tfo->queue_tm_rsp(se_cmd);
1619 transport_generic_free_cmd(se_cmd, 0);
1620} 1619}
1621 1620
1622/** 1621/**
diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
index edfd67d2501..e1cb6bd75f6 100644
--- a/drivers/thermal/Kconfig
+++ b/drivers/thermal/Kconfig
@@ -22,6 +22,7 @@ config THERMAL_HWMON
22config CPU_THERMAL 22config CPU_THERMAL
23 bool "generic cpu cooling support" 23 bool "generic cpu cooling support"
24 depends on THERMAL && CPU_FREQ 24 depends on THERMAL && CPU_FREQ
25 select CPU_FREQ_TABLE
25 help 26 help
26 This implements the generic cpu cooling mechanism through frequency 27 This implements the generic cpu cooling mechanism through frequency
27 reduction, cpu hotplug and any other ways of reducing temperature. An 28 reduction, cpu hotplug and any other ways of reducing temperature. An
@@ -50,6 +51,7 @@ config RCAR_THERMAL
50config EXYNOS_THERMAL 51config EXYNOS_THERMAL
51 tristate "Temperature sensor on Samsung EXYNOS" 52 tristate "Temperature sensor on Samsung EXYNOS"
52 depends on (ARCH_EXYNOS4 || ARCH_EXYNOS5) && THERMAL 53 depends on (ARCH_EXYNOS4 || ARCH_EXYNOS5) && THERMAL
54 select CPU_FREQ_TABLE
53 help 55 help
54 If you say yes here you get support for TMU (Thermal Managment 56 If you say yes here you get support for TMU (Thermal Managment
55 Unit) on SAMSUNG EXYNOS series of SoC. 57 Unit) on SAMSUNG EXYNOS series of SoC.
diff --git a/drivers/thermal/exynos_thermal.c b/drivers/thermal/exynos_thermal.c
index fd03e8581af..6dd29e4ce36 100644
--- a/drivers/thermal/exynos_thermal.c
+++ b/drivers/thermal/exynos_thermal.c
@@ -815,7 +815,7 @@ static struct platform_device_id exynos_tmu_driver_ids[] = {
815 }, 815 },
816 { }, 816 { },
817}; 817};
818MODULE_DEVICE_TABLE(platform, exynos4_tmu_driver_ids); 818MODULE_DEVICE_TABLE(platform, exynos_tmu_driver_ids);
819 819
820static inline struct exynos_tmu_platform_data *exynos_get_driver_data( 820static inline struct exynos_tmu_platform_data *exynos_get_driver_data(
821 struct platform_device *pdev) 821 struct platform_device *pdev)
diff --git a/drivers/thermal/rcar_thermal.c b/drivers/thermal/rcar_thermal.c
index d4452716aaa..f7a1b574a30 100644
--- a/drivers/thermal/rcar_thermal.c
+++ b/drivers/thermal/rcar_thermal.c
@@ -210,7 +210,7 @@ static int rcar_thermal_probe(struct platform_device *pdev)
210 goto error_free_priv; 210 goto error_free_priv;
211 } 211 }
212 212
213 zone = thermal_zone_device_register("rcar_thermal", 0, priv, 213 zone = thermal_zone_device_register("rcar_thermal", 0, 0, priv,
214 &rcar_thermal_zone_ops, 0, 0); 214 &rcar_thermal_zone_ops, 0, 0);
215 if (IS_ERR(zone)) { 215 if (IS_ERR(zone)) {
216 dev_err(&pdev->dev, "thermal zone device is NULL\n"); 216 dev_err(&pdev->dev, "thermal zone device is NULL\n");
diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
index a5dec1ca1b8..13ee53bd0bf 100644
--- a/drivers/tty/hvc/hvc_console.c
+++ b/drivers/tty/hvc/hvc_console.c
@@ -424,7 +424,6 @@ static void hvc_hangup(struct tty_struct *tty)
424{ 424{
425 struct hvc_struct *hp = tty->driver_data; 425 struct hvc_struct *hp = tty->driver_data;
426 unsigned long flags; 426 unsigned long flags;
427 int temp_open_count;
428 427
429 if (!hp) 428 if (!hp)
430 return; 429 return;
@@ -444,7 +443,6 @@ static void hvc_hangup(struct tty_struct *tty)
444 return; 443 return;
445 } 444 }
446 445
447 temp_open_count = hp->port.count;
448 hp->port.count = 0; 446 hp->port.count = 0;
449 spin_unlock_irqrestore(&hp->port.lock, flags); 447 spin_unlock_irqrestore(&hp->port.lock, flags);
450 tty_port_tty_set(&hp->port, NULL); 448 tty_port_tty_set(&hp->port, NULL);
@@ -453,11 +451,6 @@ static void hvc_hangup(struct tty_struct *tty)
453 451
454 if (hp->ops->notifier_hangup) 452 if (hp->ops->notifier_hangup)
455 hp->ops->notifier_hangup(hp, hp->data); 453 hp->ops->notifier_hangup(hp, hp->data);
456
457 while(temp_open_count) {
458 --temp_open_count;
459 tty_port_put(&hp->port);
460 }
461} 454}
462 455
463/* 456/*
diff --git a/drivers/tty/serial/8250/8250_hp300.c b/drivers/tty/serial/8250/8250_hp300.c
index 8f1dd2cc00a..f3d0edf4664 100644
--- a/drivers/tty/serial/8250/8250_hp300.c
+++ b/drivers/tty/serial/8250/8250_hp300.c
@@ -162,7 +162,7 @@ int __init hp300_setup_serial_console(void)
162static int __devinit hpdca_init_one(struct dio_dev *d, 162static int __devinit hpdca_init_one(struct dio_dev *d,
163 const struct dio_device_id *ent) 163 const struct dio_device_id *ent)
164{ 164{
165 struct uart_port port; 165 struct uart_8250_port uart;
166 int line; 166 int line;
167 167
168#ifdef CONFIG_SERIAL_8250_CONSOLE 168#ifdef CONFIG_SERIAL_8250_CONSOLE
@@ -174,19 +174,19 @@ static int __devinit hpdca_init_one(struct dio_dev *d,
174 memset(&uart, 0, sizeof(uart)); 174 memset(&uart, 0, sizeof(uart));
175 175
176 /* Memory mapped I/O */ 176 /* Memory mapped I/O */
177 port.iotype = UPIO_MEM; 177 uart.port.iotype = UPIO_MEM;
178 port.flags = UPF_SKIP_TEST | UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF; 178 uart.port.flags = UPF_SKIP_TEST | UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF;
179 port.irq = d->ipl; 179 uart.port.irq = d->ipl;
180 port.uartclk = HPDCA_BAUD_BASE * 16; 180 uart.port.uartclk = HPDCA_BAUD_BASE * 16;
181 port.mapbase = (d->resource.start + UART_OFFSET); 181 uart.port.mapbase = (d->resource.start + UART_OFFSET);
182 port.membase = (char *)(port.mapbase + DIO_VIRADDRBASE); 182 uart.port.membase = (char *)(uart.port.mapbase + DIO_VIRADDRBASE);
183 port.regshift = 1; 183 uart.port.regshift = 1;
184 port.dev = &d->dev; 184 uart.port.dev = &d->dev;
185 line = serial8250_register_8250_port(&uart); 185 line = serial8250_register_8250_port(&uart);
186 186
187 if (line < 0) { 187 if (line < 0) {
188 printk(KERN_NOTICE "8250_hp300: register_serial() DCA scode %d" 188 printk(KERN_NOTICE "8250_hp300: register_serial() DCA scode %d"
189 " irq %d failed\n", d->scode, port.irq); 189 " irq %d failed\n", d->scode, uart.port.irq);
190 return -ENOMEM; 190 return -ENOMEM;
191 } 191 }
192 192
diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
index 233fbaaf255..2a53be5f010 100644
--- a/drivers/tty/serial/Kconfig
+++ b/drivers/tty/serial/Kconfig
@@ -1150,7 +1150,7 @@ config SERIAL_SC26XX_CONSOLE
1150 Support for Console on SC2681/SC2692 serial ports. 1150 Support for Console on SC2681/SC2692 serial ports.
1151 1151
1152config SERIAL_SCCNXP 1152config SERIAL_SCCNXP
1153 bool "SCCNXP serial port support" 1153 tristate "SCCNXP serial port support"
1154 depends on !SERIAL_SC26XX 1154 depends on !SERIAL_SC26XX
1155 select SERIAL_CORE 1155 select SERIAL_CORE
1156 default n 1156 default n
@@ -1162,7 +1162,7 @@ config SERIAL_SCCNXP
1162 1162
1163config SERIAL_SCCNXP_CONSOLE 1163config SERIAL_SCCNXP_CONSOLE
1164 bool "Console on SCCNXP serial port" 1164 bool "Console on SCCNXP serial port"
1165 depends on SERIAL_SCCNXP 1165 depends on SERIAL_SCCNXP=y
1166 select SERIAL_CORE_CONSOLE 1166 select SERIAL_CORE_CONSOLE
1167 help 1167 help
1168 Support for console on SCCNXP serial ports. 1168 Support for console on SCCNXP serial ports.
diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c
index 2bc28a59d38..1ab1d2c66de 100644
--- a/drivers/tty/serial/max310x.c
+++ b/drivers/tty/serial/max310x.c
@@ -1239,6 +1239,7 @@ static int __devexit max310x_remove(struct spi_device *spi)
1239static const struct spi_device_id max310x_id_table[] = { 1239static const struct spi_device_id max310x_id_table[] = {
1240 { "max3107", MAX310X_TYPE_MAX3107 }, 1240 { "max3107", MAX310X_TYPE_MAX3107 },
1241 { "max3108", MAX310X_TYPE_MAX3108 }, 1241 { "max3108", MAX310X_TYPE_MAX3108 },
1242 { }
1242}; 1243};
1243MODULE_DEVICE_TABLE(spi, max310x_id_table); 1244MODULE_DEVICE_TABLE(spi, max310x_id_table);
1244 1245
diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c
index 6ede6fd92b4..6d3d26a607b 100644
--- a/drivers/tty/serial/omap-serial.c
+++ b/drivers/tty/serial/omap-serial.c
@@ -671,19 +671,19 @@ serial_omap_configure_xonxoff
671 671
672 /* 672 /*
673 * IXON Flag: 673 * IXON Flag:
674 * Flow control for OMAP.TX 674 * Enable XON/XOFF flow control on output.
675 * OMAP.RX should listen for XON/XOFF 675 * Transmit XON1, XOFF1
676 */ 676 */
677 if (termios->c_iflag & IXON) 677 if (termios->c_iflag & IXON)
678 up->efr |= OMAP_UART_SW_RX; 678 up->efr |= OMAP_UART_SW_TX;
679 679
680 /* 680 /*
681 * IXOFF Flag: 681 * IXOFF Flag:
682 * Flow control for OMAP.RX 682 * Enable XON/XOFF flow control on input.
683 * OMAP.TX should send XON/XOFF 683 * Receiver compares XON1, XOFF1.
684 */ 684 */
685 if (termios->c_iflag & IXOFF) 685 if (termios->c_iflag & IXOFF)
686 up->efr |= OMAP_UART_SW_TX; 686 up->efr |= OMAP_UART_SW_RX;
687 687
688 serial_out(up, UART_EFR, up->efr | UART_EFR_ECB); 688 serial_out(up, UART_EFR, up->efr | UART_EFR_ECB);
689 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_A); 689 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_A);
diff --git a/drivers/tty/serial/sccnxp.c b/drivers/tty/serial/sccnxp.c
index b7086d004f5..e821068cd95 100644
--- a/drivers/tty/serial/sccnxp.c
+++ b/drivers/tty/serial/sccnxp.c
@@ -971,6 +971,7 @@ static const struct platform_device_id sccnxp_id_table[] = {
971 { "sc28202", SCCNXP_TYPE_SC28202 }, 971 { "sc28202", SCCNXP_TYPE_SC28202 },
972 { "sc68681", SCCNXP_TYPE_SC68681 }, 972 { "sc68681", SCCNXP_TYPE_SC68681 },
973 { "sc68692", SCCNXP_TYPE_SC68692 }, 973 { "sc68692", SCCNXP_TYPE_SC68692 },
974 { },
974}; 975};
975MODULE_DEVICE_TABLE(platform, sccnxp_id_table); 976MODULE_DEVICE_TABLE(platform, sccnxp_id_table);
976 977
diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index 9be296cf729..6ee59001d61 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -530,7 +530,8 @@ static inline int sci_rxd_in(struct uart_port *port)
530 if (s->cfg->port_reg <= 0) 530 if (s->cfg->port_reg <= 0)
531 return 1; 531 return 1;
532 532
533 return !!__raw_readb(s->cfg->port_reg); 533 /* Cast for ARM damage */
534 return !!__raw_readb((void __iomem *)s->cfg->port_reg);
534} 535}
535 536
536/* ********************************************************************** * 537/* ********************************************************************** *
diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
index 05728894a88..16ee6cee07d 100644
--- a/drivers/tty/sysrq.c
+++ b/drivers/tty/sysrq.c
@@ -452,6 +452,7 @@ static struct sysrq_key_op *sysrq_key_table[36] = {
452 NULL, /* v */ 452 NULL, /* v */
453 &sysrq_showstate_blocked_op, /* w */ 453 &sysrq_showstate_blocked_op, /* w */
454 /* x: May be registered on ppc/powerpc for xmon */ 454 /* x: May be registered on ppc/powerpc for xmon */
455 /* x: May be registered on sparc64 for global PMU dump */
455 NULL, /* x */ 456 NULL, /* x */
456 /* y: May be registered on sparc64 for global register dump */ 457 /* y: May be registered on sparc64 for global register dump */
457 NULL, /* y */ 458 NULL, /* y */
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 981f2132d12..6e49ec6f3ad 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -817,10 +817,6 @@ static const __u32 acm_tty_speed[] = {
817 2500000, 3000000, 3500000, 4000000 817 2500000, 3000000, 3500000, 4000000
818}; 818};
819 819
820static const __u8 acm_tty_size[] = {
821 5, 6, 7, 8
822};
823
824static void acm_tty_set_termios(struct tty_struct *tty, 820static void acm_tty_set_termios(struct tty_struct *tty,
825 struct ktermios *termios_old) 821 struct ktermios *termios_old)
826{ 822{
@@ -834,7 +830,21 @@ static void acm_tty_set_termios(struct tty_struct *tty,
834 newline.bParityType = termios->c_cflag & PARENB ? 830 newline.bParityType = termios->c_cflag & PARENB ?
835 (termios->c_cflag & PARODD ? 1 : 2) + 831 (termios->c_cflag & PARODD ? 1 : 2) +
836 (termios->c_cflag & CMSPAR ? 2 : 0) : 0; 832 (termios->c_cflag & CMSPAR ? 2 : 0) : 0;
837 newline.bDataBits = acm_tty_size[(termios->c_cflag & CSIZE) >> 4]; 833 switch (termios->c_cflag & CSIZE) {
834 case CS5:
835 newline.bDataBits = 5;
836 break;
837 case CS6:
838 newline.bDataBits = 6;
839 break;
840 case CS7:
841 newline.bDataBits = 7;
842 break;
843 case CS8:
844 default:
845 newline.bDataBits = 8;
846 break;
847 }
838 /* FIXME: Needs to clear unsupported bits in the termios */ 848 /* FIXME: Needs to clear unsupported bits in the termios */
839 acm->clocal = ((termios->c_cflag & CLOCAL) != 0); 849 acm->clocal = ((termios->c_cflag & CLOCAL) != 0);
840 850
@@ -1233,7 +1243,7 @@ made_compressed_probe:
1233 1243
1234 if (usb_endpoint_xfer_int(epwrite)) 1244 if (usb_endpoint_xfer_int(epwrite))
1235 usb_fill_int_urb(snd->urb, usb_dev, 1245 usb_fill_int_urb(snd->urb, usb_dev,
1236 usb_sndbulkpipe(usb_dev, epwrite->bEndpointAddress), 1246 usb_sndintpipe(usb_dev, epwrite->bEndpointAddress),
1237 NULL, acm->writesize, acm_write_bulk, snd, epwrite->bInterval); 1247 NULL, acm->writesize, acm_write_bulk, snd, epwrite->bInterval);
1238 else 1248 else
1239 usb_fill_bulk_urb(snd->urb, usb_dev, 1249 usb_fill_bulk_urb(snd->urb, usb_dev,
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index e0356cb859b..b78fbe222b7 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -1348,6 +1348,7 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,
1348 ret = -EFAULT; 1348 ret = -EFAULT;
1349 goto error; 1349 goto error;
1350 } 1350 }
1351 uurb->buffer += u;
1351 } 1352 }
1352 totlen -= u; 1353 totlen -= u;
1353 } 1354 }
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index ddd820d2528..6056db7af41 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -367,6 +367,10 @@ static int usb_probe_interface(struct device *dev)
367 intf->condition = USB_INTERFACE_UNBOUND; 367 intf->condition = USB_INTERFACE_UNBOUND;
368 usb_cancel_queued_reset(intf); 368 usb_cancel_queued_reset(intf);
369 369
370 /* If the LPM disable succeeded, balance the ref counts. */
371 if (!lpm_disable_error)
372 usb_unlocked_enable_lpm(udev);
373
370 /* Unbound interfaces are always runtime-PM-disabled and -suspended */ 374 /* Unbound interfaces are always runtime-PM-disabled and -suspended */
371 if (driver->supports_autosuspend) 375 if (driver->supports_autosuspend)
372 pm_runtime_disable(dev); 376 pm_runtime_disable(dev);
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 1e741bca026..f034716190f 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -2151,8 +2151,15 @@ EXPORT_SYMBOL_GPL(usb_bus_start_enum);
2151irqreturn_t usb_hcd_irq (int irq, void *__hcd) 2151irqreturn_t usb_hcd_irq (int irq, void *__hcd)
2152{ 2152{
2153 struct usb_hcd *hcd = __hcd; 2153 struct usb_hcd *hcd = __hcd;
2154 unsigned long flags;
2154 irqreturn_t rc; 2155 irqreturn_t rc;
2155 2156
2157 /* IRQF_DISABLED doesn't work correctly with shared IRQs
2158 * when the first handler doesn't use it. So let's just
2159 * assume it's never used.
2160 */
2161 local_irq_save(flags);
2162
2156 if (unlikely(HCD_DEAD(hcd) || !HCD_HW_ACCESSIBLE(hcd))) 2163 if (unlikely(HCD_DEAD(hcd) || !HCD_HW_ACCESSIBLE(hcd)))
2157 rc = IRQ_NONE; 2164 rc = IRQ_NONE;
2158 else if (hcd->driver->irq(hcd) == IRQ_NONE) 2165 else if (hcd->driver->irq(hcd) == IRQ_NONE)
@@ -2160,6 +2167,7 @@ irqreturn_t usb_hcd_irq (int irq, void *__hcd)
2160 else 2167 else
2161 rc = IRQ_HANDLED; 2168 rc = IRQ_HANDLED;
2162 2169
2170 local_irq_restore(flags);
2163 return rc; 2171 return rc;
2164} 2172}
2165EXPORT_SYMBOL_GPL(usb_hcd_irq); 2173EXPORT_SYMBOL_GPL(usb_hcd_irq);
@@ -2347,6 +2355,14 @@ static int usb_hcd_request_irqs(struct usb_hcd *hcd,
2347 int retval; 2355 int retval;
2348 2356
2349 if (hcd->driver->irq) { 2357 if (hcd->driver->irq) {
2358
2359 /* IRQF_DISABLED doesn't work as advertised when used together
2360 * with IRQF_SHARED. As usb_hcd_irq() will always disable
2361 * interrupts we can remove it here.
2362 */
2363 if (irqflags & IRQF_SHARED)
2364 irqflags &= ~IRQF_DISABLED;
2365
2350 snprintf(hcd->irq_descr, sizeof(hcd->irq_descr), "%s:usb%d", 2366 snprintf(hcd->irq_descr, sizeof(hcd->irq_descr), "%s:usb%d",
2351 hcd->driver->description, hcd->self.busnum); 2367 hcd->driver->description, hcd->self.busnum);
2352 retval = request_irq(irqnum, &usb_hcd_irq, irqflags, 2368 retval = request_irq(irqnum, &usb_hcd_irq, irqflags,
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 673ee469626..1af04bdeaf0 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -739,13 +739,16 @@ static void hub_tt_work(struct work_struct *work)
739 int limit = 100; 739 int limit = 100;
740 740
741 spin_lock_irqsave (&hub->tt.lock, flags); 741 spin_lock_irqsave (&hub->tt.lock, flags);
742 while (--limit && !list_empty (&hub->tt.clear_list)) { 742 while (!list_empty(&hub->tt.clear_list)) {
743 struct list_head *next; 743 struct list_head *next;
744 struct usb_tt_clear *clear; 744 struct usb_tt_clear *clear;
745 struct usb_device *hdev = hub->hdev; 745 struct usb_device *hdev = hub->hdev;
746 const struct hc_driver *drv; 746 const struct hc_driver *drv;
747 int status; 747 int status;
748 748
749 if (!hub->quiescing && --limit < 0)
750 break;
751
749 next = hub->tt.clear_list.next; 752 next = hub->tt.clear_list.next;
750 clear = list_entry (next, struct usb_tt_clear, clear_list); 753 clear = list_entry (next, struct usb_tt_clear, clear_list);
751 list_del (&clear->clear_list); 754 list_del (&clear->clear_list);
@@ -1210,7 +1213,7 @@ static void hub_quiesce(struct usb_hub *hub, enum hub_quiescing_type type)
1210 if (hub->has_indicators) 1213 if (hub->has_indicators)
1211 cancel_delayed_work_sync(&hub->leds); 1214 cancel_delayed_work_sync(&hub->leds);
1212 if (hub->tt.hub) 1215 if (hub->tt.hub)
1213 cancel_work_sync(&hub->tt.clear_work); 1216 flush_work(&hub->tt.clear_work);
1214} 1217}
1215 1218
1216/* caller has locked the hub device */ 1219/* caller has locked the hub device */
@@ -3241,8 +3244,7 @@ static int usb_req_set_sel(struct usb_device *udev, enum usb3_link_state state)
3241 (state == USB3_LPM_U2 && 3244 (state == USB3_LPM_U2 &&
3242 (u2_sel > USB3_LPM_MAX_U2_SEL_PEL || 3245 (u2_sel > USB3_LPM_MAX_U2_SEL_PEL ||
3243 u2_pel > USB3_LPM_MAX_U2_SEL_PEL))) { 3246 u2_pel > USB3_LPM_MAX_U2_SEL_PEL))) {
3244 dev_dbg(&udev->dev, "Device-initiated %s disabled due " 3247 dev_dbg(&udev->dev, "Device-initiated %s disabled due to long SEL %llu us or PEL %llu us\n",
3245 "to long SEL %llu ms or PEL %llu ms\n",
3246 usb3_lpm_names[state], u1_sel, u1_pel); 3248 usb3_lpm_names[state], u1_sel, u1_pel);
3247 return -EINVAL; 3249 return -EINVAL;
3248 } 3250 }
@@ -3320,16 +3322,6 @@ static int usb_set_device_initiated_lpm(struct usb_device *udev,
3320 3322
3321 if (enable) { 3323 if (enable) {
3322 /* 3324 /*
3323 * First, let the device know about the exit latencies
3324 * associated with the link state we're about to enable.
3325 */
3326 ret = usb_req_set_sel(udev, state);
3327 if (ret < 0) {
3328 dev_warn(&udev->dev, "Set SEL for device-initiated "
3329 "%s failed.\n", usb3_lpm_names[state]);
3330 return -EBUSY;
3331 }
3332 /*
3333 * Now send the control transfer to enable device-initiated LPM 3325 * Now send the control transfer to enable device-initiated LPM
3334 * for either U1 or U2. 3326 * for either U1 or U2.
3335 */ 3327 */
@@ -3414,7 +3406,28 @@ static int usb_set_lpm_timeout(struct usb_device *udev,
3414static void usb_enable_link_state(struct usb_hcd *hcd, struct usb_device *udev, 3406static void usb_enable_link_state(struct usb_hcd *hcd, struct usb_device *udev,
3415 enum usb3_link_state state) 3407 enum usb3_link_state state)
3416{ 3408{
3417 int timeout; 3409 int timeout, ret;
3410 __u8 u1_mel = udev->bos->ss_cap->bU1devExitLat;
3411 __le16 u2_mel = udev->bos->ss_cap->bU2DevExitLat;
3412
3413 /* If the device says it doesn't have *any* exit latency to come out of
3414 * U1 or U2, it's probably lying. Assume it doesn't implement that link
3415 * state.
3416 */
3417 if ((state == USB3_LPM_U1 && u1_mel == 0) ||
3418 (state == USB3_LPM_U2 && u2_mel == 0))
3419 return;
3420
3421 /*
3422 * First, let the device know about the exit latencies
3423 * associated with the link state we're about to enable.
3424 */
3425 ret = usb_req_set_sel(udev, state);
3426 if (ret < 0) {
3427 dev_warn(&udev->dev, "Set SEL for device-initiated %s failed.\n",
3428 usb3_lpm_names[state]);
3429 return;
3430 }
3418 3431
3419 /* We allow the host controller to set the U1/U2 timeout internally 3432 /* We allow the host controller to set the U1/U2 timeout internally
3420 * first, so that it can change its schedule to account for the 3433 * first, so that it can change its schedule to account for the
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index b415c0c859d..c14ebc975ba 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -409,6 +409,10 @@ static void dwc3_core_exit(struct dwc3 *dwc)
409{ 409{
410 dwc3_event_buffers_cleanup(dwc); 410 dwc3_event_buffers_cleanup(dwc);
411 dwc3_free_event_buffers(dwc); 411 dwc3_free_event_buffers(dwc);
412
413 usb_phy_shutdown(dwc->usb2_phy);
414 usb_phy_shutdown(dwc->usb3_phy);
415
412} 416}
413 417
414#define DWC3_ALIGN_MASK (16 - 1) 418#define DWC3_ALIGN_MASK (16 - 1)
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index c9e729a4bf6..7b7deddf6a5 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1904,7 +1904,7 @@ static void dwc3_stop_active_transfer(struct dwc3 *dwc, u32 epnum)
1904 ret = dwc3_send_gadget_ep_cmd(dwc, dep->number, cmd, &params); 1904 ret = dwc3_send_gadget_ep_cmd(dwc, dep->number, cmd, &params);
1905 WARN_ON_ONCE(ret); 1905 WARN_ON_ONCE(ret);
1906 dep->resource_index = 0; 1906 dep->resource_index = 0;
1907 1907 dep->flags &= ~DWC3_EP_BUSY;
1908 udelay(100); 1908 udelay(100);
1909} 1909}
1910 1910
diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
index e426ad626d7..4bfa78af379 100644
--- a/drivers/usb/early/ehci-dbgp.c
+++ b/drivers/usb/early/ehci-dbgp.c
@@ -20,6 +20,7 @@
20#include <linux/usb/ehci_def.h> 20#include <linux/usb/ehci_def.h>
21#include <linux/delay.h> 21#include <linux/delay.h>
22#include <linux/serial_core.h> 22#include <linux/serial_core.h>
23#include <linux/kconfig.h>
23#include <linux/kgdb.h> 24#include <linux/kgdb.h>
24#include <linux/kthread.h> 25#include <linux/kthread.h>
25#include <asm/io.h> 26#include <asm/io.h>
@@ -614,12 +615,6 @@ err:
614 return -ENODEV; 615 return -ENODEV;
615} 616}
616 617
617int dbgp_external_startup(struct usb_hcd *hcd)
618{
619 return xen_dbgp_external_startup(hcd) ?: _dbgp_external_startup();
620}
621EXPORT_SYMBOL_GPL(dbgp_external_startup);
622
623static int ehci_reset_port(int port) 618static int ehci_reset_port(int port)
624{ 619{
625 u32 portsc; 620 u32 portsc;
@@ -979,6 +974,7 @@ struct console early_dbgp_console = {
979 .index = -1, 974 .index = -1,
980}; 975};
981 976
977#if IS_ENABLED(CONFIG_USB_EHCI_HCD)
982int dbgp_reset_prep(struct usb_hcd *hcd) 978int dbgp_reset_prep(struct usb_hcd *hcd)
983{ 979{
984 int ret = xen_dbgp_reset_prep(hcd); 980 int ret = xen_dbgp_reset_prep(hcd);
@@ -1007,6 +1003,13 @@ int dbgp_reset_prep(struct usb_hcd *hcd)
1007} 1003}
1008EXPORT_SYMBOL_GPL(dbgp_reset_prep); 1004EXPORT_SYMBOL_GPL(dbgp_reset_prep);
1009 1005
1006int dbgp_external_startup(struct usb_hcd *hcd)
1007{
1008 return xen_dbgp_external_startup(hcd) ?: _dbgp_external_startup();
1009}
1010EXPORT_SYMBOL_GPL(dbgp_external_startup);
1011#endif /* USB_EHCI_HCD */
1012
1010#ifdef CONFIG_KGDB 1013#ifdef CONFIG_KGDB
1011 1014
1012static char kgdbdbgp_buf[DBGP_MAX_PACKET]; 1015static char kgdbdbgp_buf[DBGP_MAX_PACKET];
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index dfb51a45496..e0ff51b8952 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -952,6 +952,7 @@ endif
952config USB_G_WEBCAM 952config USB_G_WEBCAM
953 tristate "USB Webcam Gadget" 953 tristate "USB Webcam Gadget"
954 depends on VIDEO_DEV 954 depends on VIDEO_DEV
955 select USB_LIBCOMPOSITE
955 help 956 help
956 The Webcam Gadget acts as a composite USB Audio and Video Class 957 The Webcam Gadget acts as a composite USB Audio and Video Class
957 device. It provides a userspace API to process UVC control requests 958 device. It provides a userspace API to process UVC control requests
diff --git a/drivers/usb/gadget/lpc32xx_udc.c b/drivers/usb/gadget/lpc32xx_udc.c
index f696fb9b136..21a9861dabf 100644
--- a/drivers/usb/gadget/lpc32xx_udc.c
+++ b/drivers/usb/gadget/lpc32xx_udc.c
@@ -2930,10 +2930,10 @@ static void vbus_work(struct work_struct *work)
2930 2930
2931 /* Get the VBUS status from the transceiver */ 2931 /* Get the VBUS status from the transceiver */
2932 value = i2c_smbus_read_byte_data(udc->isp1301_i2c_client, 2932 value = i2c_smbus_read_byte_data(udc->isp1301_i2c_client,
2933 ISP1301_I2C_OTG_CONTROL_2); 2933 ISP1301_I2C_INTERRUPT_SOURCE);
2934 2934
2935 /* VBUS on or off? */ 2935 /* VBUS on or off? */
2936 if (value & OTG_B_SESS_VLD) 2936 if (value & INT_SESS_VLD)
2937 udc->vbus = 1; 2937 udc->vbus = 1;
2938 else 2938 else
2939 udc->vbus = 0; 2939 udc->vbus = 0;
diff --git a/drivers/usb/gadget/net2272.c b/drivers/usb/gadget/net2272.c
index 43ac7482fa9..c009263a47e 100644
--- a/drivers/usb/gadget/net2272.c
+++ b/drivers/usb/gadget/net2272.c
@@ -2069,8 +2069,10 @@ static irqreturn_t net2272_irq(int irq, void *_dev)
2069#if defined(PLX_PCI_RDK2) 2069#if defined(PLX_PCI_RDK2)
2070 /* see if PCI int for us by checking irqstat */ 2070 /* see if PCI int for us by checking irqstat */
2071 intcsr = readl(dev->rdk2.fpga_base_addr + RDK2_IRQSTAT); 2071 intcsr = readl(dev->rdk2.fpga_base_addr + RDK2_IRQSTAT);
2072 if (!intcsr & (1 << NET2272_PCI_IRQ)) 2072 if (!intcsr & (1 << NET2272_PCI_IRQ)) {
2073 spin_unlock(&dev->lock);
2073 return IRQ_NONE; 2074 return IRQ_NONE;
2075 }
2074 /* check dma interrupts */ 2076 /* check dma interrupts */
2075#endif 2077#endif
2076 /* Platform/devcice interrupt handler */ 2078 /* Platform/devcice interrupt handler */
diff --git a/drivers/usb/gadget/u_ether.c b/drivers/usb/gadget/u_ether.c
index 6458764994e..4ec3c0d7a18 100644
--- a/drivers/usb/gadget/u_ether.c
+++ b/drivers/usb/gadget/u_ether.c
@@ -20,6 +20,7 @@
20#include <linux/ctype.h> 20#include <linux/ctype.h>
21#include <linux/etherdevice.h> 21#include <linux/etherdevice.h>
22#include <linux/ethtool.h> 22#include <linux/ethtool.h>
23#include <linux/if_vlan.h>
23 24
24#include "u_ether.h" 25#include "u_ether.h"
25 26
@@ -295,7 +296,7 @@ static void rx_complete(struct usb_ep *ep, struct usb_request *req)
295 while (skb2) { 296 while (skb2) {
296 if (status < 0 297 if (status < 0
297 || ETH_HLEN > skb2->len 298 || ETH_HLEN > skb2->len
298 || skb2->len > ETH_FRAME_LEN) { 299 || skb2->len > VLAN_ETH_FRAME_LEN) {
299 dev->net->stats.rx_errors++; 300 dev->net->stats.rx_errors++;
300 dev->net->stats.rx_length_errors++; 301 dev->net->stats.rx_length_errors++;
301 DBG(dev, "rx length %d\n", skb2->len); 302 DBG(dev, "rx length %d\n", skb2->len);
diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c
index 9bfde82078e..0d2f35ca93f 100644
--- a/drivers/usb/host/ehci-fsl.c
+++ b/drivers/usb/host/ehci-fsl.c
@@ -222,7 +222,7 @@ static int ehci_fsl_setup_phy(struct usb_hcd *hcd,
222 222
223 if (pdata->controller_ver < 0) { 223 if (pdata->controller_ver < 0) {
224 dev_warn(hcd->self.controller, "Could not get controller version\n"); 224 dev_warn(hcd->self.controller, "Could not get controller version\n");
225 return; 225 return -ENODEV;
226 } 226 }
227 227
228 portsc = ehci_readl(ehci, &ehci->regs->port_status[port_offset]); 228 portsc = ehci_readl(ehci, &ehci->regs->port_status[port_offset]);
diff --git a/drivers/usb/host/ehci-ls1x.c b/drivers/usb/host/ehci-ls1x.c
index ca759652626..aa0f328922d 100644
--- a/drivers/usb/host/ehci-ls1x.c
+++ b/drivers/usb/host/ehci-ls1x.c
@@ -113,7 +113,7 @@ static int ehci_hcd_ls1x_probe(struct platform_device *pdev)
113 goto err_put_hcd; 113 goto err_put_hcd;
114 } 114 }
115 115
116 ret = usb_add_hcd(hcd, irq, IRQF_SHARED); 116 ret = usb_add_hcd(hcd, irq, IRQF_DISABLED | IRQF_SHARED);
117 if (ret) 117 if (ret)
118 goto err_put_hcd; 118 goto err_put_hcd;
119 119
diff --git a/drivers/usb/host/ehci-orion.c b/drivers/usb/host/ehci-orion.c
index 8e7eca62f16..9c2717d6673 100644
--- a/drivers/usb/host/ehci-orion.c
+++ b/drivers/usb/host/ehci-orion.c
@@ -160,7 +160,7 @@ static const struct hc_driver ehci_orion_hc_driver = {
160 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, 160 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
161}; 161};
162 162
163static void __init 163static void __devinit
164ehci_orion_conf_mbus_windows(struct usb_hcd *hcd, 164ehci_orion_conf_mbus_windows(struct usb_hcd *hcd,
165 const struct mbus_dram_target_info *dram) 165 const struct mbus_dram_target_info *dram)
166{ 166{
diff --git a/drivers/usb/host/ehci-vt8500.c b/drivers/usb/host/ehci-vt8500.c
index 96722bfebc8..d3c9a3e397b 100644
--- a/drivers/usb/host/ehci-vt8500.c
+++ b/drivers/usb/host/ehci-vt8500.c
@@ -85,6 +85,8 @@ static const struct hc_driver vt8500_ehci_hc_driver = {
85 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, 85 .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
86}; 86};
87 87
88static u64 vt8500_ehci_dma_mask = DMA_BIT_MASK(32);
89
88static int vt8500_ehci_drv_probe(struct platform_device *pdev) 90static int vt8500_ehci_drv_probe(struct platform_device *pdev)
89{ 91{
90 struct usb_hcd *hcd; 92 struct usb_hcd *hcd;
@@ -95,6 +97,14 @@ static int vt8500_ehci_drv_probe(struct platform_device *pdev)
95 if (usb_disabled()) 97 if (usb_disabled())
96 return -ENODEV; 98 return -ENODEV;
97 99
100 /*
101 * Right now device-tree probed devices don't get dma_mask set.
102 * Since shared usb code relies on it, set it here for now.
103 * Once we have dma capability bindings this can go away.
104 */
105 if (!pdev->dev.dma_mask)
106 pdev->dev.dma_mask = &vt8500_ehci_dma_mask;
107
98 if (pdev->resource[1].flags != IORESOURCE_IRQ) { 108 if (pdev->resource[1].flags != IORESOURCE_IRQ) {
99 pr_debug("resource[1] is not IORESOURCE_IRQ"); 109 pr_debug("resource[1] is not IORESOURCE_IRQ");
100 return -ENOMEM; 110 return -ENOMEM;
diff --git a/drivers/usb/host/ohci-xls.c b/drivers/usb/host/ohci-xls.c
index 84201cd1a47..41e378f17c6 100644
--- a/drivers/usb/host/ohci-xls.c
+++ b/drivers/usb/host/ohci-xls.c
@@ -56,7 +56,7 @@ static int ohci_xls_probe_internal(const struct hc_driver *driver,
56 goto err3; 56 goto err3;
57 } 57 }
58 58
59 retval = usb_add_hcd(hcd, irq, IRQF_SHARED); 59 retval = usb_add_hcd(hcd, irq, IRQF_DISABLED | IRQF_SHARED);
60 if (retval != 0) 60 if (retval != 0)
61 goto err4; 61 goto err4;
62 return retval; 62 return retval;
diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c
index 966d1484ee7..39f9e4a9a2d 100644
--- a/drivers/usb/host/pci-quirks.c
+++ b/drivers/usb/host/pci-quirks.c
@@ -545,7 +545,14 @@ static const struct dmi_system_id __devinitconst ehci_dmi_nohandoff_table[] = {
545 /* Pegatron Lucid (Ordissimo AIRIS) */ 545 /* Pegatron Lucid (Ordissimo AIRIS) */
546 .matches = { 546 .matches = {
547 DMI_MATCH(DMI_BOARD_NAME, "M11JB"), 547 DMI_MATCH(DMI_BOARD_NAME, "M11JB"),
548 DMI_MATCH(DMI_BIOS_VERSION, "Lucid-GE-133"), 548 DMI_MATCH(DMI_BIOS_VERSION, "Lucid-"),
549 },
550 },
551 {
552 /* Pegatron Lucid (Ordissimo) */
553 .matches = {
554 DMI_MATCH(DMI_BOARD_NAME, "Ordissimo"),
555 DMI_MATCH(DMI_BIOS_VERSION, "Lucid-"),
549 }, 556 },
550 }, 557 },
551 { } 558 { }
diff --git a/drivers/usb/host/uhci-platform.c b/drivers/usb/host/uhci-platform.c
index e4780491df4..68ebf20e151 100644
--- a/drivers/usb/host/uhci-platform.c
+++ b/drivers/usb/host/uhci-platform.c
@@ -60,6 +60,7 @@ static const struct hc_driver uhci_platform_hc_driver = {
60 .hub_control = uhci_hub_control, 60 .hub_control = uhci_hub_control,
61}; 61};
62 62
63static u64 platform_uhci_dma_mask = DMA_BIT_MASK(32);
63 64
64static int __devinit uhci_hcd_platform_probe(struct platform_device *pdev) 65static int __devinit uhci_hcd_platform_probe(struct platform_device *pdev)
65{ 66{
@@ -71,6 +72,14 @@ static int __devinit uhci_hcd_platform_probe(struct platform_device *pdev)
71 if (usb_disabled()) 72 if (usb_disabled())
72 return -ENODEV; 73 return -ENODEV;
73 74
75 /*
76 * Right now device-tree probed devices don't get dma_mask set.
77 * Since shared usb code relies on it, set it here for now.
78 * Once we have dma capability bindings this can go away.
79 */
80 if (!pdev->dev.dma_mask)
81 pdev->dev.dma_mask = &platform_uhci_dma_mask;
82
74 hcd = usb_create_hcd(&uhci_platform_hc_driver, &pdev->dev, 83 hcd = usb_create_hcd(&uhci_platform_hc_driver, &pdev->dev,
75 pdev->name); 84 pdev->name);
76 if (!hcd) 85 if (!hcd)
diff --git a/drivers/usb/host/xhci-dbg.c b/drivers/usb/host/xhci-dbg.c
index 4b436f5a417..5f3a7c74aa8 100644
--- a/drivers/usb/host/xhci-dbg.c
+++ b/drivers/usb/host/xhci-dbg.c
@@ -544,7 +544,6 @@ void xhci_dbg_ctx(struct xhci_hcd *xhci,
544 int i; 544 int i;
545 /* Fields are 32 bits wide, DMA addresses are in bytes */ 545 /* Fields are 32 bits wide, DMA addresses are in bytes */
546 int field_size = 32 / 8; 546 int field_size = 32 / 8;
547 struct xhci_slot_ctx *slot_ctx;
548 dma_addr_t dma = ctx->dma; 547 dma_addr_t dma = ctx->dma;
549 int csz = HCC_64BYTE_CONTEXT(xhci->hcc_params); 548 int csz = HCC_64BYTE_CONTEXT(xhci->hcc_params);
550 549
@@ -570,7 +569,6 @@ void xhci_dbg_ctx(struct xhci_hcd *xhci,
570 dbg_rsvd64(xhci, (u64 *)ctrl_ctx, dma); 569 dbg_rsvd64(xhci, (u64 *)ctrl_ctx, dma);
571 } 570 }
572 571
573 slot_ctx = xhci_get_slot_ctx(xhci, ctx);
574 xhci_dbg_slot_ctx(xhci, ctx); 572 xhci_dbg_slot_ctx(xhci, ctx);
575 xhci_dbg_ep_ctx(xhci, ctx, last_ep); 573 xhci_dbg_ep_ctx(xhci, ctx, last_ep);
576} 574}
diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index aa90ad4d4fd..a686cf4905b 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -151,9 +151,8 @@ static void xhci_usb3_hub_descriptor(struct usb_hcd *hcd, struct xhci_hcd *xhci,
151 if (portsc & PORT_DEV_REMOVE) 151 if (portsc & PORT_DEV_REMOVE)
152 port_removable |= 1 << (i + 1); 152 port_removable |= 1 << (i + 1);
153 } 153 }
154 memset(&desc->u.ss.DeviceRemovable, 154
155 (__force __u16) cpu_to_le16(port_removable), 155 desc->u.ss.DeviceRemovable = cpu_to_le16(port_removable);
156 sizeof(__u16));
157} 156}
158 157
159static void xhci_hub_descriptor(struct usb_hcd *hcd, struct xhci_hcd *xhci, 158static void xhci_hub_descriptor(struct usb_hcd *hcd, struct xhci_hcd *xhci,
@@ -809,11 +808,13 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
809 temp = xhci_readl(xhci, port_array[wIndex]); 808 temp = xhci_readl(xhci, port_array[wIndex]);
810 xhci_dbg(xhci, "set port power, actual port %d status = 0x%x\n", wIndex, temp); 809 xhci_dbg(xhci, "set port power, actual port %d status = 0x%x\n", wIndex, temp);
811 810
811 spin_unlock_irqrestore(&xhci->lock, flags);
812 temp = usb_acpi_power_manageable(hcd->self.root_hub, 812 temp = usb_acpi_power_manageable(hcd->self.root_hub,
813 wIndex); 813 wIndex);
814 if (temp) 814 if (temp)
815 usb_acpi_set_power_state(hcd->self.root_hub, 815 usb_acpi_set_power_state(hcd->self.root_hub,
816 wIndex, true); 816 wIndex, true);
817 spin_lock_irqsave(&xhci->lock, flags);
817 break; 818 break;
818 case USB_PORT_FEAT_RESET: 819 case USB_PORT_FEAT_RESET:
819 temp = (temp | PORT_RESET); 820 temp = (temp | PORT_RESET);
@@ -917,11 +918,13 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
917 xhci_writel(xhci, temp & ~PORT_POWER, 918 xhci_writel(xhci, temp & ~PORT_POWER,
918 port_array[wIndex]); 919 port_array[wIndex]);
919 920
921 spin_unlock_irqrestore(&xhci->lock, flags);
920 temp = usb_acpi_power_manageable(hcd->self.root_hub, 922 temp = usb_acpi_power_manageable(hcd->self.root_hub,
921 wIndex); 923 wIndex);
922 if (temp) 924 if (temp)
923 usb_acpi_set_power_state(hcd->self.root_hub, 925 usb_acpi_set_power_state(hcd->self.root_hub,
924 wIndex, false); 926 wIndex, false);
927 spin_lock_irqsave(&xhci->lock, flags);
925 break; 928 break;
926 default: 929 default:
927 goto error; 930 goto error;
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index c6ebb176dc4..4e1a8946b8d 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -1228,6 +1228,17 @@ static void xhci_cmd_to_noop(struct xhci_hcd *xhci, struct xhci_cd *cur_cd)
1228 cur_seg = find_trb_seg(xhci->cmd_ring->first_seg, 1228 cur_seg = find_trb_seg(xhci->cmd_ring->first_seg,
1229 xhci->cmd_ring->dequeue, &cycle_state); 1229 xhci->cmd_ring->dequeue, &cycle_state);
1230 1230
1231 if (!cur_seg) {
1232 xhci_warn(xhci, "Command ring mismatch, dequeue = %p %llx (dma)\n",
1233 xhci->cmd_ring->dequeue,
1234 (unsigned long long)
1235 xhci_trb_virt_to_dma(xhci->cmd_ring->deq_seg,
1236 xhci->cmd_ring->dequeue));
1237 xhci_debug_ring(xhci, xhci->cmd_ring);
1238 xhci_dbg_ring_ptrs(xhci, xhci->cmd_ring);
1239 return;
1240 }
1241
1231 /* find the command trb matched by cd from command ring */ 1242 /* find the command trb matched by cd from command ring */
1232 for (cmd_trb = xhci->cmd_ring->dequeue; 1243 for (cmd_trb = xhci->cmd_ring->dequeue;
1233 cmd_trb != xhci->cmd_ring->enqueue; 1244 cmd_trb != xhci->cmd_ring->enqueue;
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 8d7fcbbe6ad..c9e419f29b7 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -479,7 +479,8 @@ static bool compliance_mode_recovery_timer_quirk_check(void)
479 479
480 if (strstr(dmi_product_name, "Z420") || 480 if (strstr(dmi_product_name, "Z420") ||
481 strstr(dmi_product_name, "Z620") || 481 strstr(dmi_product_name, "Z620") ||
482 strstr(dmi_product_name, "Z820")) 482 strstr(dmi_product_name, "Z820") ||
483 strstr(dmi_product_name, "Z1"))
483 return true; 484 return true;
484 485
485 return false; 486 return false;
@@ -1626,7 +1627,6 @@ int xhci_add_endpoint(struct usb_hcd *hcd, struct usb_device *udev,
1626 struct xhci_hcd *xhci; 1627 struct xhci_hcd *xhci;
1627 struct xhci_container_ctx *in_ctx, *out_ctx; 1628 struct xhci_container_ctx *in_ctx, *out_ctx;
1628 unsigned int ep_index; 1629 unsigned int ep_index;
1629 struct xhci_ep_ctx *ep_ctx;
1630 struct xhci_slot_ctx *slot_ctx; 1630 struct xhci_slot_ctx *slot_ctx;
1631 struct xhci_input_control_ctx *ctrl_ctx; 1631 struct xhci_input_control_ctx *ctrl_ctx;
1632 u32 added_ctxs; 1632 u32 added_ctxs;
@@ -1662,7 +1662,6 @@ int xhci_add_endpoint(struct usb_hcd *hcd, struct usb_device *udev,
1662 out_ctx = virt_dev->out_ctx; 1662 out_ctx = virt_dev->out_ctx;
1663 ctrl_ctx = xhci_get_input_control_ctx(xhci, in_ctx); 1663 ctrl_ctx = xhci_get_input_control_ctx(xhci, in_ctx);
1664 ep_index = xhci_get_endpoint_index(&ep->desc); 1664 ep_index = xhci_get_endpoint_index(&ep->desc);
1665 ep_ctx = xhci_get_ep_ctx(xhci, out_ctx, ep_index);
1666 1665
1667 /* If this endpoint is already in use, and the upper layers are trying 1666 /* If this endpoint is already in use, and the upper layers are trying
1668 * to add it again without dropping it, reject the addition. 1667 * to add it again without dropping it, reject the addition.
@@ -1816,6 +1815,8 @@ static int xhci_evaluate_context_result(struct xhci_hcd *xhci,
1816 case COMP_EBADSLT: 1815 case COMP_EBADSLT:
1817 dev_warn(&udev->dev, "WARN: slot not enabled for" 1816 dev_warn(&udev->dev, "WARN: slot not enabled for"
1818 "evaluate context command.\n"); 1817 "evaluate context command.\n");
1818 ret = -EINVAL;
1819 break;
1819 case COMP_CTX_STATE: 1820 case COMP_CTX_STATE:
1820 dev_warn(&udev->dev, "WARN: invalid context state for " 1821 dev_warn(&udev->dev, "WARN: invalid context state for "
1821 "evaluate context command.\n"); 1822 "evaluate context command.\n");
@@ -4020,7 +4021,7 @@ int xhci_update_device(struct usb_hcd *hcd, struct usb_device *udev)
4020static unsigned long long xhci_service_interval_to_ns( 4021static unsigned long long xhci_service_interval_to_ns(
4021 struct usb_endpoint_descriptor *desc) 4022 struct usb_endpoint_descriptor *desc)
4022{ 4023{
4023 return (1 << (desc->bInterval - 1)) * 125 * 1000; 4024 return (1ULL << (desc->bInterval - 1)) * 125 * 1000;
4024} 4025}
4025 4026
4026static u16 xhci_get_timeout_no_hub_lpm(struct usb_device *udev, 4027static u16 xhci_get_timeout_no_hub_lpm(struct usb_device *udev,
@@ -4141,7 +4142,7 @@ static u16 xhci_calculate_intel_u2_timeout(struct usb_device *udev,
4141 (xhci_service_interval_to_ns(desc) > timeout_ns)) 4142 (xhci_service_interval_to_ns(desc) > timeout_ns))
4142 timeout_ns = xhci_service_interval_to_ns(desc); 4143 timeout_ns = xhci_service_interval_to_ns(desc);
4143 4144
4144 u2_del_ns = udev->bos->ss_cap->bU2DevExitLat * 1000; 4145 u2_del_ns = le16_to_cpu(udev->bos->ss_cap->bU2DevExitLat) * 1000ULL;
4145 if (u2_del_ns > timeout_ns) 4146 if (u2_del_ns > timeout_ns)
4146 timeout_ns = u2_del_ns; 4147 timeout_ns = u2_del_ns;
4147 4148
diff --git a/drivers/usb/misc/ezusb.c b/drivers/usb/misc/ezusb.c
index 4223d761223..6589268a651 100644
--- a/drivers/usb/misc/ezusb.c
+++ b/drivers/usb/misc/ezusb.c
@@ -158,3 +158,4 @@ int ezusb_fx2_ihex_firmware_download(struct usb_device *dev,
158} 158}
159EXPORT_SYMBOL_GPL(ezusb_fx2_ihex_firmware_download); 159EXPORT_SYMBOL_GPL(ezusb_fx2_ihex_firmware_download);
160 160
161MODULE_LICENSE("GPL");
diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c
index 457f25e62c5..c964d6af178 100644
--- a/drivers/usb/musb/am35x.c
+++ b/drivers/usb/musb/am35x.c
@@ -305,6 +305,12 @@ static irqreturn_t am35x_musb_interrupt(int irq, void *hci)
305 ret = IRQ_HANDLED; 305 ret = IRQ_HANDLED;
306 } 306 }
307 307
308 /* Drop spurious RX and TX if device is disconnected */
309 if (musb->int_usb & MUSB_INTR_DISCONNECT) {
310 musb->int_tx = 0;
311 musb->int_rx = 0;
312 }
313
308 if (musb->int_tx || musb->int_rx || musb->int_usb) 314 if (musb->int_tx || musb->int_rx || musb->int_usb)
309 ret |= musb_interrupt(musb); 315 ret |= musb_interrupt(musb);
310 316
diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c
index 444346e1e10..ff5f112053d 100644
--- a/drivers/usb/musb/musb_dsps.c
+++ b/drivers/usb/musb/musb_dsps.c
@@ -458,11 +458,11 @@ static int __devinit dsps_create_musb_pdev(struct dsps_glue *glue, u8 id)
458 struct platform_device *musb; 458 struct platform_device *musb;
459 struct resource *res; 459 struct resource *res;
460 struct resource resources[2]; 460 struct resource resources[2];
461 char res_name[10]; 461 char res_name[11];
462 int ret, musbid; 462 int ret, musbid;
463 463
464 /* get memory resource */ 464 /* get memory resource */
465 sprintf(res_name, "musb%d", id); 465 snprintf(res_name, sizeof(res_name), "musb%d", id);
466 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, res_name); 466 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, res_name);
467 if (!res) { 467 if (!res) {
468 dev_err(dev, "%s get mem resource failed\n", res_name); 468 dev_err(dev, "%s get mem resource failed\n", res_name);
@@ -473,7 +473,7 @@ static int __devinit dsps_create_musb_pdev(struct dsps_glue *glue, u8 id)
473 resources[0] = *res; 473 resources[0] = *res;
474 474
475 /* get irq resource */ 475 /* get irq resource */
476 sprintf(res_name, "musb%d-irq", id); 476 snprintf(res_name, sizeof(res_name), "musb%d-irq", id);
477 res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, res_name); 477 res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, res_name);
478 if (!res) { 478 if (!res) {
479 dev_err(dev, "%s get irq resource failed\n", res_name); 479 dev_err(dev, "%s get irq resource failed\n", res_name);
@@ -530,7 +530,7 @@ static int __devinit dsps_create_musb_pdev(struct dsps_glue *glue, u8 id)
530 530
531 of_property_read_u32(np, "num-eps", (u32 *)&config->num_eps); 531 of_property_read_u32(np, "num-eps", (u32 *)&config->num_eps);
532 of_property_read_u32(np, "ram-bits", (u32 *)&config->ram_bits); 532 of_property_read_u32(np, "ram-bits", (u32 *)&config->ram_bits);
533 sprintf(res_name, "port%d-mode", id); 533 snprintf(res_name, sizeof(res_name), "port%d-mode", id);
534 of_property_read_u32(np, res_name, (u32 *)&pdata->mode); 534 of_property_read_u32(np, res_name, (u32 *)&pdata->mode);
535 of_property_read_u32(np, "power", (u32 *)&pdata->power); 535 of_property_read_u32(np, "power", (u32 *)&pdata->power);
536 config->multipoint = of_property_read_bool(np, "multipoint"); 536 config->multipoint = of_property_read_bool(np, "multipoint");
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index d0b87e7b4ab..b6b84dacc79 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -707,11 +707,12 @@ static void rxstate(struct musb *musb, struct musb_request *req)
707 fifo_count = musb_readw(epio, MUSB_RXCOUNT); 707 fifo_count = musb_readw(epio, MUSB_RXCOUNT);
708 708
709 /* 709 /*
710 * use mode 1 only if we expect data of at least ep packet_sz 710 * Enable Mode 1 on RX transfers only when short_not_ok flag
711 * and have not yet received a short packet 711 * is set. Currently short_not_ok flag is set only from
712 * file_storage and f_mass_storage drivers
712 */ 713 */
713 if ((request->length - request->actual >= musb_ep->packet_sz) && 714
714 (fifo_count >= musb_ep->packet_sz)) 715 if (request->short_not_ok && fifo_count == musb_ep->packet_sz)
715 use_mode_1 = 1; 716 use_mode_1 = 1;
716 else 717 else
717 use_mode_1 = 0; 718 use_mode_1 = 0;
@@ -727,6 +728,27 @@ static void rxstate(struct musb *musb, struct musb_request *req)
727 c = musb->dma_controller; 728 c = musb->dma_controller;
728 channel = musb_ep->dma; 729 channel = musb_ep->dma;
729 730
731 /* We use DMA Req mode 0 in rx_csr, and DMA controller operates in
732 * mode 0 only. So we do not get endpoint interrupts due to DMA
733 * completion. We only get interrupts from DMA controller.
734 *
735 * We could operate in DMA mode 1 if we knew the size of the tranfer
736 * in advance. For mass storage class, request->length = what the host
737 * sends, so that'd work. But for pretty much everything else,
738 * request->length is routinely more than what the host sends. For
739 * most these gadgets, end of is signified either by a short packet,
740 * or filling the last byte of the buffer. (Sending extra data in
741 * that last pckate should trigger an overflow fault.) But in mode 1,
742 * we don't get DMA completion interrupt for short packets.
743 *
744 * Theoretically, we could enable DMAReq irq (MUSB_RXCSR_DMAMODE = 1),
745 * to get endpoint interrupt on every DMA req, but that didn't seem
746 * to work reliably.
747 *
748 * REVISIT an updated g_file_storage can set req->short_not_ok, which
749 * then becomes usable as a runtime "use mode 1" hint...
750 */
751
730 /* Experimental: Mode1 works with mass storage use cases */ 752 /* Experimental: Mode1 works with mass storage use cases */
731 if (use_mode_1) { 753 if (use_mode_1) {
732 csr |= MUSB_RXCSR_AUTOCLEAR; 754 csr |= MUSB_RXCSR_AUTOCLEAR;
diff --git a/drivers/usb/musb/ux500.c b/drivers/usb/musb/ux500.c
index d62a91fedc2..0e62f504410 100644
--- a/drivers/usb/musb/ux500.c
+++ b/drivers/usb/musb/ux500.c
@@ -65,7 +65,7 @@ static int __devinit ux500_probe(struct platform_device *pdev)
65 struct platform_device *musb; 65 struct platform_device *musb;
66 struct ux500_glue *glue; 66 struct ux500_glue *glue;
67 struct clk *clk; 67 struct clk *clk;
68 68 int musbid;
69 int ret = -ENOMEM; 69 int ret = -ENOMEM;
70 70
71 glue = kzalloc(sizeof(*glue), GFP_KERNEL); 71 glue = kzalloc(sizeof(*glue), GFP_KERNEL);
diff --git a/drivers/usb/otg/Kconfig b/drivers/usb/otg/Kconfig
index d8c8a42bff3..6223062d5d1 100644
--- a/drivers/usb/otg/Kconfig
+++ b/drivers/usb/otg/Kconfig
@@ -58,7 +58,7 @@ config USB_ULPI_VIEWPORT
58 58
59config TWL4030_USB 59config TWL4030_USB
60 tristate "TWL4030 USB Transceiver Driver" 60 tristate "TWL4030 USB Transceiver Driver"
61 depends on TWL4030_CORE && REGULATOR_TWL4030 61 depends on TWL4030_CORE && REGULATOR_TWL4030 && USB_MUSB_OMAP2PLUS
62 select USB_OTG_UTILS 62 select USB_OTG_UTILS
63 help 63 help
64 Enable this to support the USB OTG transceiver on TWL4030 64 Enable this to support the USB OTG transceiver on TWL4030
@@ -68,7 +68,7 @@ config TWL4030_USB
68 68
69config TWL6030_USB 69config TWL6030_USB
70 tristate "TWL6030 USB Transceiver Driver" 70 tristate "TWL6030 USB Transceiver Driver"
71 depends on TWL4030_CORE && OMAP_USB2 71 depends on TWL4030_CORE && OMAP_USB2 && USB_MUSB_OMAP2PLUS
72 select USB_OTG_UTILS 72 select USB_OTG_UTILS
73 help 73 help
74 Enable this to support the USB OTG transceiver on TWL6030 74 Enable this to support the USB OTG transceiver on TWL6030
diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c
index 143c4e9e1be..c021b202c0f 100644
--- a/drivers/usb/renesas_usbhs/fifo.c
+++ b/drivers/usb/renesas_usbhs/fifo.c
@@ -795,6 +795,7 @@ static void xfer_work(struct work_struct *work)
795 dev_dbg(dev, " %s %d (%d/ %d)\n", 795 dev_dbg(dev, " %s %d (%d/ %d)\n",
796 fifo->name, usbhs_pipe_number(pipe), pkt->length, pkt->zero); 796 fifo->name, usbhs_pipe_number(pipe), pkt->length, pkt->zero);
797 797
798 usbhs_pipe_enable(pipe);
798 usbhsf_dma_start(pipe, fifo); 799 usbhsf_dma_start(pipe, fifo);
799 dma_async_issue_pending(chan); 800 dma_async_issue_pending(chan);
800} 801}
diff --git a/drivers/usb/renesas_usbhs/mod.c b/drivers/usb/renesas_usbhs/mod.c
index 35c5208f324..61933a90e5b 100644
--- a/drivers/usb/renesas_usbhs/mod.c
+++ b/drivers/usb/renesas_usbhs/mod.c
@@ -273,9 +273,9 @@ static irqreturn_t usbhs_interrupt(int irq, void *data)
273 usbhs_write(priv, INTSTS0, ~irq_state.intsts0 & INTSTS0_MAGIC); 273 usbhs_write(priv, INTSTS0, ~irq_state.intsts0 & INTSTS0_MAGIC);
274 usbhs_write(priv, INTSTS1, ~irq_state.intsts1 & INTSTS1_MAGIC); 274 usbhs_write(priv, INTSTS1, ~irq_state.intsts1 & INTSTS1_MAGIC);
275 275
276 usbhs_write(priv, BRDYSTS, 0); 276 usbhs_write(priv, BRDYSTS, ~irq_state.brdysts);
277 usbhs_write(priv, NRDYSTS, 0); 277 usbhs_write(priv, NRDYSTS, ~irq_state.nrdysts);
278 usbhs_write(priv, BEMPSTS, 0); 278 usbhs_write(priv, BEMPSTS, ~irq_state.bempsts);
279 279
280 /* 280 /*
281 * call irq callback functions 281 * call irq callback functions
diff --git a/drivers/usb/renesas_usbhs/mod_host.c b/drivers/usb/renesas_usbhs/mod_host.c
index 9b69a132329..069cd765400 100644
--- a/drivers/usb/renesas_usbhs/mod_host.c
+++ b/drivers/usb/renesas_usbhs/mod_host.c
@@ -334,6 +334,11 @@ static void usbhsh_pipe_detach(struct usbhsh_hpriv *hpriv,
334 struct device *dev = usbhs_priv_to_dev(priv); 334 struct device *dev = usbhs_priv_to_dev(priv);
335 unsigned long flags; 335 unsigned long flags;
336 336
337 if (unlikely(!uep)) {
338 dev_err(dev, "no uep\n");
339 return;
340 }
341
337 /******************** spin lock ********************/ 342 /******************** spin lock ********************/
338 usbhs_lock(priv, flags); 343 usbhs_lock(priv, flags);
339 344
diff --git a/drivers/usb/renesas_usbhs/pipe.h b/drivers/usb/renesas_usbhs/pipe.h
index 08786c06dcf..3d80c7b1fd1 100644
--- a/drivers/usb/renesas_usbhs/pipe.h
+++ b/drivers/usb/renesas_usbhs/pipe.h
@@ -54,7 +54,7 @@ struct usbhs_pipe_info {
54 * pipe list 54 * pipe list
55 */ 55 */
56#define __usbhs_for_each_pipe(start, pos, info, i) \ 56#define __usbhs_for_each_pipe(start, pos, info, i) \
57 for (i = start, pos = (info)->pipe; \ 57 for (i = start, pos = (info)->pipe + i; \
58 i < (info)->size; \ 58 i < (info)->size; \
59 i++, pos = (info)->pipe + i) 59 i++, pos = (info)->pipe + i)
60 60
diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c
index cf2522c397d..bd50a8a41a0 100644
--- a/drivers/usb/serial/ark3116.c
+++ b/drivers/usb/serial/ark3116.c
@@ -125,9 +125,6 @@ static inline int calc_divisor(int bps)
125 125
126static int ark3116_attach(struct usb_serial *serial) 126static int ark3116_attach(struct usb_serial *serial)
127{ 127{
128 struct usb_serial_port *port = serial->port[0];
129 struct ark3116_private *priv;
130
131 /* make sure we have our end-points */ 128 /* make sure we have our end-points */
132 if ((serial->num_bulk_in == 0) || 129 if ((serial->num_bulk_in == 0) ||
133 (serial->num_bulk_out == 0) || 130 (serial->num_bulk_out == 0) ||
@@ -142,8 +139,15 @@ static int ark3116_attach(struct usb_serial *serial)
142 return -EINVAL; 139 return -EINVAL;
143 } 140 }
144 141
145 priv = kzalloc(sizeof(struct ark3116_private), 142 return 0;
146 GFP_KERNEL); 143}
144
145static int ark3116_port_probe(struct usb_serial_port *port)
146{
147 struct usb_serial *serial = port->serial;
148 struct ark3116_private *priv;
149
150 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
147 if (!priv) 151 if (!priv)
148 return -ENOMEM; 152 return -ENOMEM;
149 153
@@ -198,18 +202,15 @@ static int ark3116_attach(struct usb_serial *serial)
198 return 0; 202 return 0;
199} 203}
200 204
201static void ark3116_release(struct usb_serial *serial) 205static int ark3116_port_remove(struct usb_serial_port *port)
202{ 206{
203 struct usb_serial_port *port = serial->port[0];
204 struct ark3116_private *priv = usb_get_serial_port_data(port); 207 struct ark3116_private *priv = usb_get_serial_port_data(port);
205 208
206 /* device is closed, so URBs and DMA should be down */ 209 /* device is closed, so URBs and DMA should be down */
207
208 usb_set_serial_port_data(port, NULL);
209
210 mutex_destroy(&priv->hw_lock); 210 mutex_destroy(&priv->hw_lock);
211
212 kfree(priv); 211 kfree(priv);
212
213 return 0;
213} 214}
214 215
215static void ark3116_init_termios(struct tty_struct *tty) 216static void ark3116_init_termios(struct tty_struct *tty)
@@ -723,7 +724,8 @@ static struct usb_serial_driver ark3116_device = {
723 .id_table = id_table, 724 .id_table = id_table,
724 .num_ports = 1, 725 .num_ports = 1,
725 .attach = ark3116_attach, 726 .attach = ark3116_attach,
726 .release = ark3116_release, 727 .port_probe = ark3116_port_probe,
728 .port_remove = ark3116_port_remove,
727 .set_termios = ark3116_set_termios, 729 .set_termios = ark3116_set_termios,
728 .init_termios = ark3116_init_termios, 730 .init_termios = ark3116_init_termios,
729 .ioctl = ark3116_ioctl, 731 .ioctl = ark3116_ioctl,
diff --git a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c
index 99449424193..ea29556f0d7 100644
--- a/drivers/usb/serial/belkin_sa.c
+++ b/drivers/usb/serial/belkin_sa.c
@@ -45,8 +45,8 @@
45#define DRIVER_DESC "USB Belkin Serial converter driver" 45#define DRIVER_DESC "USB Belkin Serial converter driver"
46 46
47/* function prototypes for a Belkin USB Serial Adapter F5U103 */ 47/* function prototypes for a Belkin USB Serial Adapter F5U103 */
48static int belkin_sa_startup(struct usb_serial *serial); 48static int belkin_sa_port_probe(struct usb_serial_port *port);
49static void belkin_sa_release(struct usb_serial *serial); 49static int belkin_sa_port_remove(struct usb_serial_port *port);
50static int belkin_sa_open(struct tty_struct *tty, 50static int belkin_sa_open(struct tty_struct *tty,
51 struct usb_serial_port *port); 51 struct usb_serial_port *port);
52static void belkin_sa_close(struct usb_serial_port *port); 52static void belkin_sa_close(struct usb_serial_port *port);
@@ -88,8 +88,8 @@ static struct usb_serial_driver belkin_device = {
88 .break_ctl = belkin_sa_break_ctl, 88 .break_ctl = belkin_sa_break_ctl,
89 .tiocmget = belkin_sa_tiocmget, 89 .tiocmget = belkin_sa_tiocmget,
90 .tiocmset = belkin_sa_tiocmset, 90 .tiocmset = belkin_sa_tiocmset,
91 .attach = belkin_sa_startup, 91 .port_probe = belkin_sa_port_probe,
92 .release = belkin_sa_release, 92 .port_remove = belkin_sa_port_remove,
93}; 93};
94 94
95static struct usb_serial_driver * const serial_drivers[] = { 95static struct usb_serial_driver * const serial_drivers[] = {
@@ -118,17 +118,15 @@ struct belkin_sa_private {
118 (c), BELKIN_SA_SET_REQUEST_TYPE, \ 118 (c), BELKIN_SA_SET_REQUEST_TYPE, \
119 (v), 0, NULL, 0, WDR_TIMEOUT) 119 (v), 0, NULL, 0, WDR_TIMEOUT)
120 120
121/* do some startup allocations not currently performed by usb_serial_probe() */ 121static int belkin_sa_port_probe(struct usb_serial_port *port)
122static int belkin_sa_startup(struct usb_serial *serial)
123{ 122{
124 struct usb_device *dev = serial->dev; 123 struct usb_device *dev = port->serial->dev;
125 struct belkin_sa_private *priv; 124 struct belkin_sa_private *priv;
126 125
127 /* allocate the private data structure */
128 priv = kmalloc(sizeof(struct belkin_sa_private), GFP_KERNEL); 126 priv = kmalloc(sizeof(struct belkin_sa_private), GFP_KERNEL);
129 if (!priv) 127 if (!priv)
130 return -1; /* error */ 128 return -ENOMEM;
131 /* set initial values for control structures */ 129
132 spin_lock_init(&priv->lock); 130 spin_lock_init(&priv->lock);
133 priv->control_state = 0; 131 priv->control_state = 0;
134 priv->last_lsr = 0; 132 priv->last_lsr = 0;
@@ -140,18 +138,19 @@ static int belkin_sa_startup(struct usb_serial *serial)
140 le16_to_cpu(dev->descriptor.bcdDevice), 138 le16_to_cpu(dev->descriptor.bcdDevice),
141 priv->bad_flow_control); 139 priv->bad_flow_control);
142 140
143 init_waitqueue_head(&serial->port[0]->write_wait); 141 usb_set_serial_port_data(port, priv);
144 usb_set_serial_port_data(serial->port[0], priv);
145 142
146 return 0; 143 return 0;
147} 144}
148 145
149static void belkin_sa_release(struct usb_serial *serial) 146static int belkin_sa_port_remove(struct usb_serial_port *port)
150{ 147{
151 int i; 148 struct belkin_sa_private *priv;
152 149
153 for (i = 0; i < serial->num_ports; ++i) 150 priv = usb_get_serial_port_data(port);
154 kfree(usb_get_serial_port_data(serial->port[i])); 151 kfree(priv);
152
153 return 0;
155} 154}
156 155
157static int belkin_sa_open(struct tty_struct *tty, 156static int belkin_sa_open(struct tty_struct *tty,
diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c
index e9c7046ae35..d255f66e708 100644
--- a/drivers/usb/serial/ch341.c
+++ b/drivers/usb/serial/ch341.c
@@ -242,13 +242,11 @@ out: kfree(buffer);
242 return r; 242 return r;
243} 243}
244 244
245/* allocate private data */ 245static int ch341_port_probe(struct usb_serial_port *port)
246static int ch341_attach(struct usb_serial *serial)
247{ 246{
248 struct ch341_private *priv; 247 struct ch341_private *priv;
249 int r; 248 int r;
250 249
251 /* private data */
252 priv = kzalloc(sizeof(struct ch341_private), GFP_KERNEL); 250 priv = kzalloc(sizeof(struct ch341_private), GFP_KERNEL);
253 if (!priv) 251 if (!priv)
254 return -ENOMEM; 252 return -ENOMEM;
@@ -258,17 +256,27 @@ static int ch341_attach(struct usb_serial *serial)
258 priv->baud_rate = DEFAULT_BAUD_RATE; 256 priv->baud_rate = DEFAULT_BAUD_RATE;
259 priv->line_control = CH341_BIT_RTS | CH341_BIT_DTR; 257 priv->line_control = CH341_BIT_RTS | CH341_BIT_DTR;
260 258
261 r = ch341_configure(serial->dev, priv); 259 r = ch341_configure(port->serial->dev, priv);
262 if (r < 0) 260 if (r < 0)
263 goto error; 261 goto error;
264 262
265 usb_set_serial_port_data(serial->port[0], priv); 263 usb_set_serial_port_data(port, priv);
266 return 0; 264 return 0;
267 265
268error: kfree(priv); 266error: kfree(priv);
269 return r; 267 return r;
270} 268}
271 269
270static int ch341_port_remove(struct usb_serial_port *port)
271{
272 struct ch341_private *priv;
273
274 priv = usb_get_serial_port_data(port);
275 kfree(priv);
276
277 return 0;
278}
279
272static int ch341_carrier_raised(struct usb_serial_port *port) 280static int ch341_carrier_raised(struct usb_serial_port *port)
273{ 281{
274 struct ch341_private *priv = usb_get_serial_port_data(port); 282 struct ch341_private *priv = usb_get_serial_port_data(port);
@@ -304,7 +312,7 @@ static void ch341_close(struct usb_serial_port *port)
304static int ch341_open(struct tty_struct *tty, struct usb_serial_port *port) 312static int ch341_open(struct tty_struct *tty, struct usb_serial_port *port)
305{ 313{
306 struct usb_serial *serial = port->serial; 314 struct usb_serial *serial = port->serial;
307 struct ch341_private *priv = usb_get_serial_port_data(serial->port[0]); 315 struct ch341_private *priv = usb_get_serial_port_data(port);
308 int r; 316 int r;
309 317
310 priv->baud_rate = DEFAULT_BAUD_RATE; 318 priv->baud_rate = DEFAULT_BAUD_RATE;
@@ -608,7 +616,8 @@ static struct usb_serial_driver ch341_device = {
608 .tiocmget = ch341_tiocmget, 616 .tiocmget = ch341_tiocmget,
609 .tiocmset = ch341_tiocmset, 617 .tiocmset = ch341_tiocmset,
610 .read_int_callback = ch341_read_int_callback, 618 .read_int_callback = ch341_read_int_callback,
611 .attach = ch341_attach, 619 .port_probe = ch341_port_probe,
620 .port_remove = ch341_port_remove,
612 .reset_resume = ch341_reset_resume, 621 .reset_resume = ch341_reset_resume,
613}; 622};
614 623
diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c
index 28af5acc336..eb033fc92a1 100644
--- a/drivers/usb/serial/cp210x.c
+++ b/drivers/usb/serial/cp210x.c
@@ -162,7 +162,7 @@ static const struct usb_device_id id_table[] = {
162 162
163MODULE_DEVICE_TABLE(usb, id_table); 163MODULE_DEVICE_TABLE(usb, id_table);
164 164
165struct cp210x_port_private { 165struct cp210x_serial_private {
166 __u8 bInterfaceNumber; 166 __u8 bInterfaceNumber;
167}; 167};
168 168
@@ -276,7 +276,7 @@ static int cp210x_get_config(struct usb_serial_port *port, u8 request,
276 unsigned int *data, int size) 276 unsigned int *data, int size)
277{ 277{
278 struct usb_serial *serial = port->serial; 278 struct usb_serial *serial = port->serial;
279 struct cp210x_port_private *port_priv = usb_get_serial_port_data(port); 279 struct cp210x_serial_private *spriv = usb_get_serial_data(serial);
280 __le32 *buf; 280 __le32 *buf;
281 int result, i, length; 281 int result, i, length;
282 282
@@ -292,7 +292,7 @@ static int cp210x_get_config(struct usb_serial_port *port, u8 request,
292 /* Issue the request, attempting to read 'size' bytes */ 292 /* Issue the request, attempting to read 'size' bytes */
293 result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), 293 result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
294 request, REQTYPE_INTERFACE_TO_HOST, 0x0000, 294 request, REQTYPE_INTERFACE_TO_HOST, 0x0000,
295 port_priv->bInterfaceNumber, buf, size, 295 spriv->bInterfaceNumber, buf, size,
296 USB_CTRL_GET_TIMEOUT); 296 USB_CTRL_GET_TIMEOUT);
297 297
298 /* Convert data into an array of integers */ 298 /* Convert data into an array of integers */
@@ -323,7 +323,7 @@ static int cp210x_set_config(struct usb_serial_port *port, u8 request,
323 unsigned int *data, int size) 323 unsigned int *data, int size)
324{ 324{
325 struct usb_serial *serial = port->serial; 325 struct usb_serial *serial = port->serial;
326 struct cp210x_port_private *port_priv = usb_get_serial_port_data(port); 326 struct cp210x_serial_private *spriv = usb_get_serial_data(serial);
327 __le32 *buf; 327 __le32 *buf;
328 int result, i, length; 328 int result, i, length;
329 329
@@ -345,13 +345,13 @@ static int cp210x_set_config(struct usb_serial_port *port, u8 request,
345 result = usb_control_msg(serial->dev, 345 result = usb_control_msg(serial->dev,
346 usb_sndctrlpipe(serial->dev, 0), 346 usb_sndctrlpipe(serial->dev, 0),
347 request, REQTYPE_HOST_TO_INTERFACE, 0x0000, 347 request, REQTYPE_HOST_TO_INTERFACE, 0x0000,
348 port_priv->bInterfaceNumber, buf, size, 348 spriv->bInterfaceNumber, buf, size,
349 USB_CTRL_SET_TIMEOUT); 349 USB_CTRL_SET_TIMEOUT);
350 } else { 350 } else {
351 result = usb_control_msg(serial->dev, 351 result = usb_control_msg(serial->dev,
352 usb_sndctrlpipe(serial->dev, 0), 352 usb_sndctrlpipe(serial->dev, 0),
353 request, REQTYPE_HOST_TO_INTERFACE, data[0], 353 request, REQTYPE_HOST_TO_INTERFACE, data[0],
354 port_priv->bInterfaceNumber, NULL, 0, 354 spriv->bInterfaceNumber, NULL, 0,
355 USB_CTRL_SET_TIMEOUT); 355 USB_CTRL_SET_TIMEOUT);
356 } 356 }
357 357
@@ -845,36 +845,30 @@ static void cp210x_break_ctl (struct tty_struct *tty, int break_state)
845 845
846static int cp210x_startup(struct usb_serial *serial) 846static int cp210x_startup(struct usb_serial *serial)
847{ 847{
848 struct cp210x_port_private *port_priv; 848 struct usb_host_interface *cur_altsetting;
849 int i; 849 struct cp210x_serial_private *spriv;
850 850
851 /* cp210x buffers behave strangely unless device is reset */ 851 /* cp210x buffers behave strangely unless device is reset */
852 usb_reset_device(serial->dev); 852 usb_reset_device(serial->dev);
853 853
854 for (i = 0; i < serial->num_ports; i++) { 854 spriv = kzalloc(sizeof(*spriv), GFP_KERNEL);
855 port_priv = kzalloc(sizeof(*port_priv), GFP_KERNEL); 855 if (!spriv)
856 if (!port_priv) 856 return -ENOMEM;
857 return -ENOMEM;
858 857
859 port_priv->bInterfaceNumber = 858 cur_altsetting = serial->interface->cur_altsetting;
860 serial->interface->cur_altsetting->desc.bInterfaceNumber; 859 spriv->bInterfaceNumber = cur_altsetting->desc.bInterfaceNumber;
861 860
862 usb_set_serial_port_data(serial->port[i], port_priv); 861 usb_set_serial_data(serial, spriv);
863 }
864 862
865 return 0; 863 return 0;
866} 864}
867 865
868static void cp210x_release(struct usb_serial *serial) 866static void cp210x_release(struct usb_serial *serial)
869{ 867{
870 struct cp210x_port_private *port_priv; 868 struct cp210x_serial_private *spriv;
871 int i;
872 869
873 for (i = 0; i < serial->num_ports; i++) { 870 spriv = usb_get_serial_data(serial);
874 port_priv = usb_get_serial_port_data(serial->port[i]); 871 kfree(spriv);
875 kfree(port_priv);
876 usb_set_serial_port_data(serial->port[i], NULL);
877 }
878} 872}
879 873
880module_usb_serial_driver(serial_drivers, id_table); 874module_usb_serial_driver(serial_drivers, id_table);
diff --git a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c
index 2a7aecc7223..4ee77dcbe69 100644
--- a/drivers/usb/serial/cyberjack.c
+++ b/drivers/usb/serial/cyberjack.c
@@ -55,9 +55,9 @@
55#define CYBERJACK_PRODUCT_ID 0x0100 55#define CYBERJACK_PRODUCT_ID 0x0100
56 56
57/* Function prototypes */ 57/* Function prototypes */
58static int cyberjack_startup(struct usb_serial *serial);
59static void cyberjack_disconnect(struct usb_serial *serial); 58static void cyberjack_disconnect(struct usb_serial *serial);
60static void cyberjack_release(struct usb_serial *serial); 59static int cyberjack_port_probe(struct usb_serial_port *port);
60static int cyberjack_port_remove(struct usb_serial_port *port);
61static int cyberjack_open(struct tty_struct *tty, 61static int cyberjack_open(struct tty_struct *tty,
62 struct usb_serial_port *port); 62 struct usb_serial_port *port);
63static void cyberjack_close(struct usb_serial_port *port); 63static void cyberjack_close(struct usb_serial_port *port);
@@ -83,9 +83,9 @@ static struct usb_serial_driver cyberjack_device = {
83 .description = "Reiner SCT Cyberjack USB card reader", 83 .description = "Reiner SCT Cyberjack USB card reader",
84 .id_table = id_table, 84 .id_table = id_table,
85 .num_ports = 1, 85 .num_ports = 1,
86 .attach = cyberjack_startup,
87 .disconnect = cyberjack_disconnect, 86 .disconnect = cyberjack_disconnect,
88 .release = cyberjack_release, 87 .port_probe = cyberjack_port_probe,
88 .port_remove = cyberjack_port_remove,
89 .open = cyberjack_open, 89 .open = cyberjack_open,
90 .close = cyberjack_close, 90 .close = cyberjack_close,
91 .write = cyberjack_write, 91 .write = cyberjack_write,
@@ -107,56 +107,45 @@ struct cyberjack_private {
107 short wrsent; /* Data already sent */ 107 short wrsent; /* Data already sent */
108}; 108};
109 109
110/* do some startup allocations not currently performed by usb_serial_probe() */ 110static int cyberjack_port_probe(struct usb_serial_port *port)
111static int cyberjack_startup(struct usb_serial *serial)
112{ 111{
113 struct cyberjack_private *priv; 112 struct cyberjack_private *priv;
114 int i; 113 int result;
115 114
116 /* allocate the private data structure */
117 priv = kmalloc(sizeof(struct cyberjack_private), GFP_KERNEL); 115 priv = kmalloc(sizeof(struct cyberjack_private), GFP_KERNEL);
118 if (!priv) 116 if (!priv)
119 return -ENOMEM; 117 return -ENOMEM;
120 118
121 /* set initial values */
122 spin_lock_init(&priv->lock); 119 spin_lock_init(&priv->lock);
123 priv->rdtodo = 0; 120 priv->rdtodo = 0;
124 priv->wrfilled = 0; 121 priv->wrfilled = 0;
125 priv->wrsent = 0; 122 priv->wrsent = 0;
126 usb_set_serial_port_data(serial->port[0], priv);
127 123
128 init_waitqueue_head(&serial->port[0]->write_wait); 124 usb_set_serial_port_data(port, priv);
129 125
130 for (i = 0; i < serial->num_ports; ++i) { 126 result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
131 int result; 127 if (result)
132 result = usb_submit_urb(serial->port[i]->interrupt_in_urb, 128 dev_err(&port->dev, "usb_submit_urb(read int) failed\n");
133 GFP_KERNEL);
134 if (result)
135 dev_err(&serial->dev->dev,
136 "usb_submit_urb(read int) failed\n");
137 dev_dbg(&serial->dev->dev, "%s - usb_submit_urb(int urb)\n",
138 __func__);
139 }
140 129
141 return 0; 130 return 0;
142} 131}
143 132
144static void cyberjack_disconnect(struct usb_serial *serial) 133static int cyberjack_port_remove(struct usb_serial_port *port)
145{ 134{
146 int i; 135 struct cyberjack_private *priv;
147 136
148 for (i = 0; i < serial->num_ports; ++i) 137 priv = usb_get_serial_port_data(port);
149 usb_kill_urb(serial->port[i]->interrupt_in_urb); 138 kfree(priv);
139
140 return 0;
150} 141}
151 142
152static void cyberjack_release(struct usb_serial *serial) 143static void cyberjack_disconnect(struct usb_serial *serial)
153{ 144{
154 int i; 145 int i;
155 146
156 for (i = 0; i < serial->num_ports; ++i) { 147 for (i = 0; i < serial->num_ports; ++i)
157 /* My special items, the standard routines free my urbs */ 148 usb_kill_urb(serial->port[i]->interrupt_in_urb);
158 kfree(usb_get_serial_port_data(serial->port[i]));
159 }
160} 149}
161 150
162static int cyberjack_open(struct tty_struct *tty, 151static int cyberjack_open(struct tty_struct *tty,
diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c
index 1befce21e17..f0da1279c11 100644
--- a/drivers/usb/serial/cypress_m8.c
+++ b/drivers/usb/serial/cypress_m8.c
@@ -123,10 +123,10 @@ struct cypress_private {
123}; 123};
124 124
125/* function prototypes for the Cypress USB to serial device */ 125/* function prototypes for the Cypress USB to serial device */
126static int cypress_earthmate_startup(struct usb_serial *serial); 126static int cypress_earthmate_port_probe(struct usb_serial_port *port);
127static int cypress_hidcom_startup(struct usb_serial *serial); 127static int cypress_hidcom_port_probe(struct usb_serial_port *port);
128static int cypress_ca42v2_startup(struct usb_serial *serial); 128static int cypress_ca42v2_port_probe(struct usb_serial_port *port);
129static void cypress_release(struct usb_serial *serial); 129static int cypress_port_remove(struct usb_serial_port *port);
130static int cypress_open(struct tty_struct *tty, struct usb_serial_port *port); 130static int cypress_open(struct tty_struct *tty, struct usb_serial_port *port);
131static void cypress_close(struct usb_serial_port *port); 131static void cypress_close(struct usb_serial_port *port);
132static void cypress_dtr_rts(struct usb_serial_port *port, int on); 132static void cypress_dtr_rts(struct usb_serial_port *port, int on);
@@ -156,8 +156,8 @@ static struct usb_serial_driver cypress_earthmate_device = {
156 .description = "DeLorme Earthmate USB", 156 .description = "DeLorme Earthmate USB",
157 .id_table = id_table_earthmate, 157 .id_table = id_table_earthmate,
158 .num_ports = 1, 158 .num_ports = 1,
159 .attach = cypress_earthmate_startup, 159 .port_probe = cypress_earthmate_port_probe,
160 .release = cypress_release, 160 .port_remove = cypress_port_remove,
161 .open = cypress_open, 161 .open = cypress_open,
162 .close = cypress_close, 162 .close = cypress_close,
163 .dtr_rts = cypress_dtr_rts, 163 .dtr_rts = cypress_dtr_rts,
@@ -182,8 +182,8 @@ static struct usb_serial_driver cypress_hidcom_device = {
182 .description = "HID->COM RS232 Adapter", 182 .description = "HID->COM RS232 Adapter",
183 .id_table = id_table_cyphidcomrs232, 183 .id_table = id_table_cyphidcomrs232,
184 .num_ports = 1, 184 .num_ports = 1,
185 .attach = cypress_hidcom_startup, 185 .port_probe = cypress_hidcom_port_probe,
186 .release = cypress_release, 186 .port_remove = cypress_port_remove,
187 .open = cypress_open, 187 .open = cypress_open,
188 .close = cypress_close, 188 .close = cypress_close,
189 .dtr_rts = cypress_dtr_rts, 189 .dtr_rts = cypress_dtr_rts,
@@ -208,8 +208,8 @@ static struct usb_serial_driver cypress_ca42v2_device = {
208 .description = "Nokia CA-42 V2 Adapter", 208 .description = "Nokia CA-42 V2 Adapter",
209 .id_table = id_table_nokiaca42v2, 209 .id_table = id_table_nokiaca42v2,
210 .num_ports = 1, 210 .num_ports = 1,
211 .attach = cypress_ca42v2_startup, 211 .port_probe = cypress_ca42v2_port_probe,
212 .release = cypress_release, 212 .port_remove = cypress_port_remove,
213 .open = cypress_open, 213 .open = cypress_open,
214 .close = cypress_close, 214 .close = cypress_close,
215 .dtr_rts = cypress_dtr_rts, 215 .dtr_rts = cypress_dtr_rts,
@@ -438,10 +438,10 @@ static void cypress_set_dead(struct usb_serial_port *port)
438 *****************************************************************************/ 438 *****************************************************************************/
439 439
440 440
441static int generic_startup(struct usb_serial *serial) 441static int cypress_generic_port_probe(struct usb_serial_port *port)
442{ 442{
443 struct usb_serial *serial = port->serial;
443 struct cypress_private *priv; 444 struct cypress_private *priv;
444 struct usb_serial_port *port = serial->port[0];
445 445
446 priv = kzalloc(sizeof(struct cypress_private), GFP_KERNEL); 446 priv = kzalloc(sizeof(struct cypress_private), GFP_KERNEL);
447 if (!priv) 447 if (!priv)
@@ -490,14 +490,16 @@ static int generic_startup(struct usb_serial *serial)
490} 490}
491 491
492 492
493static int cypress_earthmate_startup(struct usb_serial *serial) 493static int cypress_earthmate_port_probe(struct usb_serial_port *port)
494{ 494{
495 struct usb_serial *serial = port->serial;
495 struct cypress_private *priv; 496 struct cypress_private *priv;
496 struct usb_serial_port *port = serial->port[0]; 497 int ret;
497 498
498 if (generic_startup(serial)) { 499 ret = cypress_generic_port_probe(port);
500 if (ret) {
499 dev_dbg(&port->dev, "%s - Failed setting up port\n", __func__); 501 dev_dbg(&port->dev, "%s - Failed setting up port\n", __func__);
500 return 1; 502 return ret;
501 } 503 }
502 504
503 priv = usb_get_serial_port_data(port); 505 priv = usb_get_serial_port_data(port);
@@ -518,56 +520,53 @@ static int cypress_earthmate_startup(struct usb_serial *serial)
518 } 520 }
519 521
520 return 0; 522 return 0;
521} /* cypress_earthmate_startup */ 523}
522
523 524
524static int cypress_hidcom_startup(struct usb_serial *serial) 525static int cypress_hidcom_port_probe(struct usb_serial_port *port)
525{ 526{
526 struct cypress_private *priv; 527 struct cypress_private *priv;
527 struct usb_serial_port *port = serial->port[0]; 528 int ret;
528 529
529 if (generic_startup(serial)) { 530 ret = cypress_generic_port_probe(port);
531 if (ret) {
530 dev_dbg(&port->dev, "%s - Failed setting up port\n", __func__); 532 dev_dbg(&port->dev, "%s - Failed setting up port\n", __func__);
531 return 1; 533 return ret;
532 } 534 }
533 535
534 priv = usb_get_serial_port_data(port); 536 priv = usb_get_serial_port_data(port);
535 priv->chiptype = CT_CYPHIDCOM; 537 priv->chiptype = CT_CYPHIDCOM;
536 538
537 return 0; 539 return 0;
538} /* cypress_hidcom_startup */ 540}
539
540 541
541static int cypress_ca42v2_startup(struct usb_serial *serial) 542static int cypress_ca42v2_port_probe(struct usb_serial_port *port)
542{ 543{
543 struct cypress_private *priv; 544 struct cypress_private *priv;
544 struct usb_serial_port *port = serial->port[0]; 545 int ret;
545 546
546 if (generic_startup(serial)) { 547 ret = cypress_generic_port_probe(port);
548 if (ret) {
547 dev_dbg(&port->dev, "%s - Failed setting up port\n", __func__); 549 dev_dbg(&port->dev, "%s - Failed setting up port\n", __func__);
548 return 1; 550 return ret;
549 } 551 }
550 552
551 priv = usb_get_serial_port_data(port); 553 priv = usb_get_serial_port_data(port);
552 priv->chiptype = CT_CA42V2; 554 priv->chiptype = CT_CA42V2;
553 555
554 return 0; 556 return 0;
555} /* cypress_ca42v2_startup */ 557}
556
557 558
558static void cypress_release(struct usb_serial *serial) 559static int cypress_port_remove(struct usb_serial_port *port)
559{ 560{
560 struct cypress_private *priv; 561 struct cypress_private *priv;
561 562
562 /* all open ports are closed at this point */ 563 priv = usb_get_serial_port_data(port);
563 priv = usb_get_serial_port_data(serial->port[0]);
564 564
565 if (priv) { 565 kfifo_free(&priv->write_fifo);
566 kfifo_free(&priv->write_fifo); 566 kfree(priv);
567 kfree(priv);
568 }
569}
570 567
568 return 0;
569}
571 570
572static int cypress_open(struct tty_struct *tty, struct usb_serial_port *port) 571static int cypress_open(struct tty_struct *tty, struct usb_serial_port *port)
573{ 572{
diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c
index c86f68c6b07..b50fa1c6d88 100644
--- a/drivers/usb/serial/digi_acceleport.c
+++ b/drivers/usb/serial/digi_acceleport.c
@@ -244,6 +244,8 @@ static int digi_startup_device(struct usb_serial *serial);
244static int digi_startup(struct usb_serial *serial); 244static int digi_startup(struct usb_serial *serial);
245static void digi_disconnect(struct usb_serial *serial); 245static void digi_disconnect(struct usb_serial *serial);
246static void digi_release(struct usb_serial *serial); 246static void digi_release(struct usb_serial *serial);
247static int digi_port_probe(struct usb_serial_port *port);
248static int digi_port_remove(struct usb_serial_port *port);
247static void digi_read_bulk_callback(struct urb *urb); 249static void digi_read_bulk_callback(struct urb *urb);
248static int digi_read_inb_callback(struct urb *urb); 250static int digi_read_inb_callback(struct urb *urb);
249static int digi_read_oob_callback(struct urb *urb); 251static int digi_read_oob_callback(struct urb *urb);
@@ -294,6 +296,8 @@ static struct usb_serial_driver digi_acceleport_2_device = {
294 .attach = digi_startup, 296 .attach = digi_startup,
295 .disconnect = digi_disconnect, 297 .disconnect = digi_disconnect,
296 .release = digi_release, 298 .release = digi_release,
299 .port_probe = digi_port_probe,
300 .port_remove = digi_port_remove,
297}; 301};
298 302
299static struct usb_serial_driver digi_acceleport_4_device = { 303static struct usb_serial_driver digi_acceleport_4_device = {
@@ -320,6 +324,8 @@ static struct usb_serial_driver digi_acceleport_4_device = {
320 .attach = digi_startup, 324 .attach = digi_startup,
321 .disconnect = digi_disconnect, 325 .disconnect = digi_disconnect,
322 .release = digi_release, 326 .release = digi_release,
327 .port_probe = digi_port_probe,
328 .port_remove = digi_port_remove,
323}; 329};
324 330
325static struct usb_serial_driver * const serial_drivers[] = { 331static struct usb_serial_driver * const serial_drivers[] = {
@@ -1240,59 +1246,50 @@ static int digi_startup_device(struct usb_serial *serial)
1240 return ret; 1246 return ret;
1241} 1247}
1242 1248
1243 1249static int digi_port_init(struct usb_serial_port *port, unsigned port_num)
1244static int digi_startup(struct usb_serial *serial)
1245{ 1250{
1246
1247 int i;
1248 struct digi_port *priv; 1251 struct digi_port *priv;
1249 struct digi_serial *serial_priv;
1250 1252
1251 /* allocate the private data structures for all ports */ 1253 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
1252 /* number of regular ports + 1 for the out-of-band port */ 1254 if (!priv)
1253 for (i = 0; i < serial->type->num_ports + 1; i++) { 1255 return -ENOMEM;
1254 /* allocate port private structure */
1255 priv = kmalloc(sizeof(struct digi_port), GFP_KERNEL);
1256 if (priv == NULL) {
1257 while (--i >= 0)
1258 kfree(usb_get_serial_port_data(serial->port[i]));
1259 return 1; /* error */
1260 }
1261 1256
1262 /* initialize port private structure */ 1257 spin_lock_init(&priv->dp_port_lock);
1263 spin_lock_init(&priv->dp_port_lock); 1258 priv->dp_port_num = port_num;
1264 priv->dp_port_num = i; 1259 init_waitqueue_head(&priv->dp_modem_change_wait);
1265 priv->dp_out_buf_len = 0; 1260 init_waitqueue_head(&priv->dp_transmit_idle_wait);
1266 priv->dp_write_urb_in_use = 0; 1261 init_waitqueue_head(&priv->dp_flush_wait);
1267 priv->dp_modem_signals = 0; 1262 init_waitqueue_head(&priv->dp_close_wait);
1268 init_waitqueue_head(&priv->dp_modem_change_wait); 1263 INIT_WORK(&priv->dp_wakeup_work, digi_wakeup_write_lock);
1269 priv->dp_transmit_idle = 0; 1264 priv->dp_port = port;
1270 init_waitqueue_head(&priv->dp_transmit_idle_wait);
1271 priv->dp_throttled = 0;
1272 priv->dp_throttle_restart = 0;
1273 init_waitqueue_head(&priv->dp_flush_wait);
1274 init_waitqueue_head(&priv->dp_close_wait);
1275 INIT_WORK(&priv->dp_wakeup_work, digi_wakeup_write_lock);
1276 priv->dp_port = serial->port[i];
1277 /* initialize write wait queue for this port */
1278 init_waitqueue_head(&serial->port[i]->write_wait);
1279
1280 usb_set_serial_port_data(serial->port[i], priv);
1281 }
1282 1265
1283 /* allocate serial private structure */ 1266 init_waitqueue_head(&port->write_wait);
1284 serial_priv = kmalloc(sizeof(struct digi_serial), GFP_KERNEL); 1267
1285 if (serial_priv == NULL) { 1268 usb_set_serial_port_data(port, priv);
1286 for (i = 0; i < serial->type->num_ports + 1; i++) 1269
1287 kfree(usb_get_serial_port_data(serial->port[i])); 1270 return 0;
1288 return 1; /* error */ 1271}
1289 } 1272
1273static int digi_startup(struct usb_serial *serial)
1274{
1275 struct digi_serial *serial_priv;
1276 int ret;
1277
1278 serial_priv = kzalloc(sizeof(*serial_priv), GFP_KERNEL);
1279 if (!serial_priv)
1280 return -ENOMEM;
1290 1281
1291 /* initialize serial private structure */
1292 spin_lock_init(&serial_priv->ds_serial_lock); 1282 spin_lock_init(&serial_priv->ds_serial_lock);
1293 serial_priv->ds_oob_port_num = serial->type->num_ports; 1283 serial_priv->ds_oob_port_num = serial->type->num_ports;
1294 serial_priv->ds_oob_port = serial->port[serial_priv->ds_oob_port_num]; 1284 serial_priv->ds_oob_port = serial->port[serial_priv->ds_oob_port_num];
1295 serial_priv->ds_device_started = 0; 1285
1286 ret = digi_port_init(serial_priv->ds_oob_port,
1287 serial_priv->ds_oob_port_num);
1288 if (ret) {
1289 kfree(serial_priv);
1290 return ret;
1291 }
1292
1296 usb_set_serial_data(serial, serial_priv); 1293 usb_set_serial_data(serial, serial_priv);
1297 1294
1298 return 0; 1295 return 0;
@@ -1313,15 +1310,35 @@ static void digi_disconnect(struct usb_serial *serial)
1313 1310
1314static void digi_release(struct usb_serial *serial) 1311static void digi_release(struct usb_serial *serial)
1315{ 1312{
1316 int i; 1313 struct digi_serial *serial_priv;
1314 struct digi_port *priv;
1315
1316 serial_priv = usb_get_serial_data(serial);
1317
1318 priv = usb_get_serial_port_data(serial_priv->ds_oob_port);
1319 kfree(priv);
1317 1320
1318 /* free the private data structures for all ports */ 1321 kfree(serial_priv);
1319 /* number of regular ports + 1 for the out-of-band port */
1320 for (i = 0; i < serial->type->num_ports + 1; i++)
1321 kfree(usb_get_serial_port_data(serial->port[i]));
1322 kfree(usb_get_serial_data(serial));
1323} 1322}
1324 1323
1324static int digi_port_probe(struct usb_serial_port *port)
1325{
1326 unsigned port_num;
1327
1328 port_num = port->number - port->serial->minor;
1329
1330 return digi_port_init(port, port_num);
1331}
1332
1333static int digi_port_remove(struct usb_serial_port *port)
1334{
1335 struct digi_port *priv;
1336
1337 priv = usb_get_serial_port_data(port);
1338 kfree(priv);
1339
1340 return 0;
1341}
1325 1342
1326static void digi_read_bulk_callback(struct urb *urb) 1343static void digi_read_bulk_callback(struct urb *urb)
1327{ 1344{
diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c
index 244477107e2..6e4eb57d017 100644
--- a/drivers/usb/serial/f81232.c
+++ b/drivers/usb/serial/f81232.c
@@ -318,39 +318,30 @@ static int f81232_ioctl(struct tty_struct *tty,
318 return -ENOIOCTLCMD; 318 return -ENOIOCTLCMD;
319} 319}
320 320
321static int f81232_startup(struct usb_serial *serial) 321static int f81232_port_probe(struct usb_serial_port *port)
322{ 322{
323 struct f81232_private *priv; 323 struct f81232_private *priv;
324 int i;
325 324
326 for (i = 0; i < serial->num_ports; ++i) { 325 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
327 priv = kzalloc(sizeof(struct f81232_private), GFP_KERNEL); 326 if (!priv)
328 if (!priv) 327 return -ENOMEM;
329 goto cleanup;
330 spin_lock_init(&priv->lock);
331 init_waitqueue_head(&priv->delta_msr_wait);
332 usb_set_serial_port_data(serial->port[i], priv);
333 }
334 return 0;
335 328
336cleanup: 329 spin_lock_init(&priv->lock);
337 for (--i; i >= 0; --i) { 330 init_waitqueue_head(&priv->delta_msr_wait);
338 priv = usb_get_serial_port_data(serial->port[i]); 331
339 kfree(priv); 332 usb_set_serial_port_data(port, priv);
340 usb_set_serial_port_data(serial->port[i], NULL); 333
341 } 334 return 0;
342 return -ENOMEM;
343} 335}
344 336
345static void f81232_release(struct usb_serial *serial) 337static int f81232_port_remove(struct usb_serial_port *port)
346{ 338{
347 int i;
348 struct f81232_private *priv; 339 struct f81232_private *priv;
349 340
350 for (i = 0; i < serial->num_ports; ++i) { 341 priv = usb_get_serial_port_data(port);
351 priv = usb_get_serial_port_data(serial->port[i]); 342 kfree(priv);
352 kfree(priv); 343
353 } 344 return 0;
354} 345}
355 346
356static struct usb_serial_driver f81232_device = { 347static struct usb_serial_driver f81232_device = {
@@ -373,8 +364,8 @@ static struct usb_serial_driver f81232_device = {
373 .tiocmset = f81232_tiocmset, 364 .tiocmset = f81232_tiocmset,
374 .process_read_urb = f81232_process_read_urb, 365 .process_read_urb = f81232_process_read_urb,
375 .read_int_callback = f81232_read_int_callback, 366 .read_int_callback = f81232_read_int_callback,
376 .attach = f81232_startup, 367 .port_probe = f81232_port_probe,
377 .release = f81232_release, 368 .port_remove = f81232_port_remove,
378}; 369};
379 370
380static struct usb_serial_driver * const serial_drivers[] = { 371static struct usb_serial_driver * const serial_drivers[] = {
diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c
index 3ee92648c02..203358d7e7b 100644
--- a/drivers/usb/serial/garmin_gps.c
+++ b/drivers/usb/serial/garmin_gps.c
@@ -1405,11 +1405,10 @@ static void timeout_handler(unsigned long data)
1405 1405
1406 1406
1407 1407
1408static int garmin_attach(struct usb_serial *serial) 1408static int garmin_port_probe(struct usb_serial_port *port)
1409{ 1409{
1410 int status = 0; 1410 int status;
1411 struct usb_serial_port *port = serial->port[0]; 1411 struct garmin_data *garmin_data_p;
1412 struct garmin_data *garmin_data_p = NULL;
1413 1412
1414 garmin_data_p = kzalloc(sizeof(struct garmin_data), GFP_KERNEL); 1413 garmin_data_p = kzalloc(sizeof(struct garmin_data), GFP_KERNEL);
1415 if (garmin_data_p == NULL) { 1414 if (garmin_data_p == NULL) {
@@ -1434,22 +1433,14 @@ static int garmin_attach(struct usb_serial *serial)
1434} 1433}
1435 1434
1436 1435
1437static void garmin_disconnect(struct usb_serial *serial) 1436static int garmin_port_remove(struct usb_serial_port *port)
1438{ 1437{
1439 struct usb_serial_port *port = serial->port[0];
1440 struct garmin_data *garmin_data_p = usb_get_serial_port_data(port); 1438 struct garmin_data *garmin_data_p = usb_get_serial_port_data(port);
1441 1439
1442 usb_kill_urb(port->interrupt_in_urb); 1440 usb_kill_urb(port->interrupt_in_urb);
1443 del_timer_sync(&garmin_data_p->timer); 1441 del_timer_sync(&garmin_data_p->timer);
1444}
1445
1446
1447static void garmin_release(struct usb_serial *serial)
1448{
1449 struct usb_serial_port *port = serial->port[0];
1450 struct garmin_data *garmin_data_p = usb_get_serial_port_data(port);
1451
1452 kfree(garmin_data_p); 1442 kfree(garmin_data_p);
1443 return 0;
1453} 1444}
1454 1445
1455 1446
@@ -1466,9 +1457,8 @@ static struct usb_serial_driver garmin_device = {
1466 .close = garmin_close, 1457 .close = garmin_close,
1467 .throttle = garmin_throttle, 1458 .throttle = garmin_throttle,
1468 .unthrottle = garmin_unthrottle, 1459 .unthrottle = garmin_unthrottle,
1469 .attach = garmin_attach, 1460 .port_probe = garmin_port_probe,
1470 .disconnect = garmin_disconnect, 1461 .port_remove = garmin_port_remove,
1471 .release = garmin_release,
1472 .write = garmin_write, 1462 .write = garmin_write,
1473 .write_room = garmin_write_room, 1463 .write_room = garmin_write_room,
1474 .write_bulk_callback = garmin_write_bulk_callback, 1464 .write_bulk_callback = garmin_write_bulk_callback,
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
index 8e6faaf3580..5acc0d13864 100644
--- a/drivers/usb/serial/io_edgeport.c
+++ b/drivers/usb/serial/io_edgeport.c
@@ -225,6 +225,8 @@ static int edge_get_icount(struct tty_struct *tty,
225static int edge_startup(struct usb_serial *serial); 225static int edge_startup(struct usb_serial *serial);
226static void edge_disconnect(struct usb_serial *serial); 226static void edge_disconnect(struct usb_serial *serial);
227static void edge_release(struct usb_serial *serial); 227static void edge_release(struct usb_serial *serial);
228static int edge_port_probe(struct usb_serial_port *port);
229static int edge_port_remove(struct usb_serial_port *port);
228 230
229#include "io_tables.h" /* all of the devices that this driver supports */ 231#include "io_tables.h" /* all of the devices that this driver supports */
230 232
@@ -2875,10 +2877,9 @@ static void load_application_firmware(struct edgeport_serial *edge_serial)
2875static int edge_startup(struct usb_serial *serial) 2877static int edge_startup(struct usb_serial *serial)
2876{ 2878{
2877 struct edgeport_serial *edge_serial; 2879 struct edgeport_serial *edge_serial;
2878 struct edgeport_port *edge_port;
2879 struct usb_device *dev; 2880 struct usb_device *dev;
2880 struct device *ddev = &serial->dev->dev; 2881 struct device *ddev = &serial->dev->dev;
2881 int i, j; 2882 int i;
2882 int response; 2883 int response;
2883 bool interrupt_in_found; 2884 bool interrupt_in_found;
2884 bool bulk_in_found; 2885 bool bulk_in_found;
@@ -2961,25 +2962,6 @@ static int edge_startup(struct usb_serial *serial)
2961 /* we set up the pointers to the endpoints in the edge_open function, 2962 /* we set up the pointers to the endpoints in the edge_open function,
2962 * as the structures aren't created yet. */ 2963 * as the structures aren't created yet. */
2963 2964
2964 /* set up our port private structures */
2965 for (i = 0; i < serial->num_ports; ++i) {
2966 edge_port = kzalloc(sizeof(struct edgeport_port), GFP_KERNEL);
2967 if (edge_port == NULL) {
2968 dev_err(ddev, "%s - Out of memory\n", __func__);
2969 for (j = 0; j < i; ++j) {
2970 kfree(usb_get_serial_port_data(serial->port[j]));
2971 usb_set_serial_port_data(serial->port[j],
2972 NULL);
2973 }
2974 usb_set_serial_data(serial, NULL);
2975 kfree(edge_serial);
2976 return -ENOMEM;
2977 }
2978 spin_lock_init(&edge_port->ep_lock);
2979 edge_port->port = serial->port[i];
2980 usb_set_serial_port_data(serial->port[i], edge_port);
2981 }
2982
2983 response = 0; 2965 response = 0;
2984 2966
2985 if (edge_serial->is_epic) { 2967 if (edge_serial->is_epic) {
@@ -3120,14 +3102,36 @@ static void edge_disconnect(struct usb_serial *serial)
3120static void edge_release(struct usb_serial *serial) 3102static void edge_release(struct usb_serial *serial)
3121{ 3103{
3122 struct edgeport_serial *edge_serial = usb_get_serial_data(serial); 3104 struct edgeport_serial *edge_serial = usb_get_serial_data(serial);
3123 int i;
3124
3125 for (i = 0; i < serial->num_ports; ++i)
3126 kfree(usb_get_serial_port_data(serial->port[i]));
3127 3105
3128 kfree(edge_serial); 3106 kfree(edge_serial);
3129} 3107}
3130 3108
3109static int edge_port_probe(struct usb_serial_port *port)
3110{
3111 struct edgeport_port *edge_port;
3112
3113 edge_port = kzalloc(sizeof(*edge_port), GFP_KERNEL);
3114 if (!edge_port)
3115 return -ENOMEM;
3116
3117 spin_lock_init(&edge_port->ep_lock);
3118 edge_port->port = port;
3119
3120 usb_set_serial_port_data(port, edge_port);
3121
3122 return 0;
3123}
3124
3125static int edge_port_remove(struct usb_serial_port *port)
3126{
3127 struct edgeport_port *edge_port;
3128
3129 edge_port = usb_get_serial_port_data(port);
3130 kfree(edge_port);
3131
3132 return 0;
3133}
3134
3131module_usb_serial_driver(serial_drivers, id_table_combined); 3135module_usb_serial_driver(serial_drivers, id_table_combined);
3132 3136
3133MODULE_AUTHOR(DRIVER_AUTHOR); 3137MODULE_AUTHOR(DRIVER_AUTHOR);
diff --git a/drivers/usb/serial/io_tables.h b/drivers/usb/serial/io_tables.h
index 350afddb55b..1511dd0ad32 100644
--- a/drivers/usb/serial/io_tables.h
+++ b/drivers/usb/serial/io_tables.h
@@ -110,6 +110,8 @@ static struct usb_serial_driver edgeport_2port_device = {
110 .attach = edge_startup, 110 .attach = edge_startup,
111 .disconnect = edge_disconnect, 111 .disconnect = edge_disconnect,
112 .release = edge_release, 112 .release = edge_release,
113 .port_probe = edge_port_probe,
114 .port_remove = edge_port_remove,
113 .ioctl = edge_ioctl, 115 .ioctl = edge_ioctl,
114 .set_termios = edge_set_termios, 116 .set_termios = edge_set_termios,
115 .tiocmget = edge_tiocmget, 117 .tiocmget = edge_tiocmget,
@@ -139,6 +141,8 @@ static struct usb_serial_driver edgeport_4port_device = {
139 .attach = edge_startup, 141 .attach = edge_startup,
140 .disconnect = edge_disconnect, 142 .disconnect = edge_disconnect,
141 .release = edge_release, 143 .release = edge_release,
144 .port_probe = edge_port_probe,
145 .port_remove = edge_port_remove,
142 .ioctl = edge_ioctl, 146 .ioctl = edge_ioctl,
143 .set_termios = edge_set_termios, 147 .set_termios = edge_set_termios,
144 .tiocmget = edge_tiocmget, 148 .tiocmget = edge_tiocmget,
@@ -168,6 +172,8 @@ static struct usb_serial_driver edgeport_8port_device = {
168 .attach = edge_startup, 172 .attach = edge_startup,
169 .disconnect = edge_disconnect, 173 .disconnect = edge_disconnect,
170 .release = edge_release, 174 .release = edge_release,
175 .port_probe = edge_port_probe,
176 .port_remove = edge_port_remove,
171 .ioctl = edge_ioctl, 177 .ioctl = edge_ioctl,
172 .set_termios = edge_set_termios, 178 .set_termios = edge_set_termios,
173 .tiocmget = edge_tiocmget, 179 .tiocmget = edge_tiocmget,
@@ -197,6 +203,8 @@ static struct usb_serial_driver epic_device = {
197 .attach = edge_startup, 203 .attach = edge_startup,
198 .disconnect = edge_disconnect, 204 .disconnect = edge_disconnect,
199 .release = edge_release, 205 .release = edge_release,
206 .port_probe = edge_port_probe,
207 .port_remove = edge_port_remove,
200 .ioctl = edge_ioctl, 208 .ioctl = edge_ioctl,
201 .set_termios = edge_set_termios, 209 .set_termios = edge_set_termios,
202 .tiocmget = edge_tiocmget, 210 .tiocmget = edge_tiocmget,
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
index a2209cd4509..60023c2d2a3 100644
--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -2532,12 +2532,7 @@ static void edge_break(struct tty_struct *tty, int break_state)
2532static int edge_startup(struct usb_serial *serial) 2532static int edge_startup(struct usb_serial *serial)
2533{ 2533{
2534 struct edgeport_serial *edge_serial; 2534 struct edgeport_serial *edge_serial;
2535 struct edgeport_port *edge_port;
2536 struct usb_device *dev;
2537 int status; 2535 int status;
2538 int i;
2539
2540 dev = serial->dev;
2541 2536
2542 /* create our private serial structure */ 2537 /* create our private serial structure */
2543 edge_serial = kzalloc(sizeof(struct edgeport_serial), GFP_KERNEL); 2538 edge_serial = kzalloc(sizeof(struct edgeport_serial), GFP_KERNEL);
@@ -2555,40 +2550,7 @@ static int edge_startup(struct usb_serial *serial)
2555 return status; 2550 return status;
2556 } 2551 }
2557 2552
2558 /* set up our port private structures */
2559 for (i = 0; i < serial->num_ports; ++i) {
2560 edge_port = kzalloc(sizeof(struct edgeport_port), GFP_KERNEL);
2561 if (edge_port == NULL) {
2562 dev_err(&serial->dev->dev, "%s - Out of memory\n",
2563 __func__);
2564 goto cleanup;
2565 }
2566 spin_lock_init(&edge_port->ep_lock);
2567 if (kfifo_alloc(&edge_port->write_fifo, EDGE_OUT_BUF_SIZE,
2568 GFP_KERNEL)) {
2569 dev_err(&serial->dev->dev, "%s - Out of memory\n",
2570 __func__);
2571 kfree(edge_port);
2572 goto cleanup;
2573 }
2574 edge_port->port = serial->port[i];
2575 edge_port->edge_serial = edge_serial;
2576 usb_set_serial_port_data(serial->port[i], edge_port);
2577 edge_port->bUartMode = default_uart_mode;
2578 }
2579
2580 return 0; 2553 return 0;
2581
2582cleanup:
2583 for (--i; i >= 0; --i) {
2584 edge_port = usb_get_serial_port_data(serial->port[i]);
2585 kfifo_free(&edge_port->write_fifo);
2586 kfree(edge_port);
2587 usb_set_serial_port_data(serial->port[i], NULL);
2588 }
2589 kfree(edge_serial);
2590 usb_set_serial_data(serial, NULL);
2591 return -ENOMEM;
2592} 2554}
2593 2555
2594static void edge_disconnect(struct usb_serial *serial) 2556static void edge_disconnect(struct usb_serial *serial)
@@ -2597,17 +2559,54 @@ static void edge_disconnect(struct usb_serial *serial)
2597 2559
2598static void edge_release(struct usb_serial *serial) 2560static void edge_release(struct usb_serial *serial)
2599{ 2561{
2600 int i; 2562 kfree(usb_get_serial_data(serial));
2563}
2564
2565static int edge_port_probe(struct usb_serial_port *port)
2566{
2601 struct edgeport_port *edge_port; 2567 struct edgeport_port *edge_port;
2568 int ret;
2602 2569
2603 for (i = 0; i < serial->num_ports; ++i) { 2570 edge_port = kzalloc(sizeof(*edge_port), GFP_KERNEL);
2604 edge_port = usb_get_serial_port_data(serial->port[i]); 2571 if (!edge_port)
2572 return -ENOMEM;
2573
2574 ret = kfifo_alloc(&edge_port->write_fifo, EDGE_OUT_BUF_SIZE,
2575 GFP_KERNEL);
2576 if (ret) {
2577 kfree(edge_port);
2578 return -ENOMEM;
2579 }
2580
2581 spin_lock_init(&edge_port->ep_lock);
2582 edge_port->port = port;
2583 edge_port->edge_serial = usb_get_serial_data(port->serial);
2584 edge_port->bUartMode = default_uart_mode;
2585
2586 usb_set_serial_port_data(port, edge_port);
2587
2588 ret = edge_create_sysfs_attrs(port);
2589 if (ret) {
2605 kfifo_free(&edge_port->write_fifo); 2590 kfifo_free(&edge_port->write_fifo);
2606 kfree(edge_port); 2591 kfree(edge_port);
2592 return ret;
2607 } 2593 }
2608 kfree(usb_get_serial_data(serial)); 2594
2595 return 0;
2609} 2596}
2610 2597
2598static int edge_port_remove(struct usb_serial_port *port)
2599{
2600 struct edgeport_port *edge_port;
2601
2602 edge_port = usb_get_serial_port_data(port);
2603
2604 edge_remove_sysfs_attrs(port);
2605 kfifo_free(&edge_port->write_fifo);
2606 kfree(edge_port);
2607
2608 return 0;
2609}
2611 2610
2612/* Sysfs Attributes */ 2611/* Sysfs Attributes */
2613 2612
@@ -2667,8 +2666,8 @@ static struct usb_serial_driver edgeport_1port_device = {
2667 .attach = edge_startup, 2666 .attach = edge_startup,
2668 .disconnect = edge_disconnect, 2667 .disconnect = edge_disconnect,
2669 .release = edge_release, 2668 .release = edge_release,
2670 .port_probe = edge_create_sysfs_attrs, 2669 .port_probe = edge_port_probe,
2671 .port_remove = edge_remove_sysfs_attrs, 2670 .port_remove = edge_port_remove,
2672 .ioctl = edge_ioctl, 2671 .ioctl = edge_ioctl,
2673 .set_termios = edge_set_termios, 2672 .set_termios = edge_set_termios,
2674 .tiocmget = edge_tiocmget, 2673 .tiocmget = edge_tiocmget,
@@ -2698,8 +2697,8 @@ static struct usb_serial_driver edgeport_2port_device = {
2698 .attach = edge_startup, 2697 .attach = edge_startup,
2699 .disconnect = edge_disconnect, 2698 .disconnect = edge_disconnect,
2700 .release = edge_release, 2699 .release = edge_release,
2701 .port_probe = edge_create_sysfs_attrs, 2700 .port_probe = edge_port_probe,
2702 .port_remove = edge_remove_sysfs_attrs, 2701 .port_remove = edge_port_remove,
2703 .ioctl = edge_ioctl, 2702 .ioctl = edge_ioctl,
2704 .set_termios = edge_set_termios, 2703 .set_termios = edge_set_termios,
2705 .tiocmget = edge_tiocmget, 2704 .tiocmget = edge_tiocmget,
diff --git a/drivers/usb/serial/ipw.c b/drivers/usb/serial/ipw.c
index 20a132ec39e..4264821a3b3 100644
--- a/drivers/usb/serial/ipw.c
+++ b/drivers/usb/serial/ipw.c
@@ -203,8 +203,7 @@ static int ipw_open(struct tty_struct *tty, struct usb_serial_port *port)
203 return 0; 203 return 0;
204} 204}
205 205
206/* fake probe - only to allocate data structures */ 206static int ipw_attach(struct usb_serial *serial)
207static int ipw_probe(struct usb_serial *serial, const struct usb_device_id *id)
208{ 207{
209 struct usb_wwan_intf_private *data; 208 struct usb_wwan_intf_private *data;
210 209
@@ -303,9 +302,9 @@ static struct usb_serial_driver ipw_device = {
303 .num_ports = 1, 302 .num_ports = 1,
304 .open = ipw_open, 303 .open = ipw_open,
305 .close = ipw_close, 304 .close = ipw_close,
306 .probe = ipw_probe, 305 .attach = ipw_attach,
307 .attach = usb_wwan_startup,
308 .release = ipw_release, 306 .release = ipw_release,
307 .port_probe = usb_wwan_port_probe,
309 .port_remove = usb_wwan_port_remove, 308 .port_remove = usb_wwan_port_remove,
310 .dtr_rts = ipw_dtr_rts, 309 .dtr_rts = ipw_dtr_rts,
311 .write = usb_wwan_write, 310 .write = usb_wwan_write,
diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c
index 01da3ea36e8..cd5533e81de 100644
--- a/drivers/usb/serial/iuu_phoenix.c
+++ b/drivers/usb/serial/iuu_phoenix.c
@@ -53,6 +53,8 @@ static int iuu_cardout;
53static bool xmas; 53static bool xmas;
54static int vcc_default = 5; 54static int vcc_default = 5;
55 55
56static int iuu_create_sysfs_attrs(struct usb_serial_port *port);
57static int iuu_remove_sysfs_attrs(struct usb_serial_port *port);
56static void read_rxcmd_callback(struct urb *urb); 58static void read_rxcmd_callback(struct urb *urb);
57 59
58struct iuu_private { 60struct iuu_private {
@@ -72,63 +74,55 @@ struct iuu_private {
72 u32 clk; 74 u32 clk;
73}; 75};
74 76
75 77static int iuu_port_probe(struct usb_serial_port *port)
76static void iuu_free_buf(struct iuu_private *priv)
77{
78 kfree(priv->buf);
79 kfree(priv->writebuf);
80}
81
82static int iuu_alloc_buf(struct usb_serial *serial, struct iuu_private *priv)
83{
84 priv->buf = kzalloc(256, GFP_KERNEL);
85 priv->writebuf = kzalloc(256, GFP_KERNEL);
86 if (!priv->buf || !priv->writebuf) {
87 iuu_free_buf(priv);
88 dev_dbg(&serial->dev->dev, "%s problem allocation buffer\n", __func__);
89 return -ENOMEM;
90 }
91 dev_dbg(&serial->dev->dev, "%s - Privates buffers allocation success\n", __func__);
92 return 0;
93}
94
95static int iuu_startup(struct usb_serial *serial)
96{ 78{
97 struct iuu_private *priv; 79 struct iuu_private *priv;
80 int ret;
98 81
99 priv = kzalloc(sizeof(struct iuu_private), GFP_KERNEL); 82 priv = kzalloc(sizeof(struct iuu_private), GFP_KERNEL);
100 dev_dbg(&serial->dev->dev, "%s- priv allocation success\n", __func__);
101 if (!priv) 83 if (!priv)
102 return -ENOMEM; 84 return -ENOMEM;
103 if (iuu_alloc_buf(serial, priv)) { 85
86 priv->buf = kzalloc(256, GFP_KERNEL);
87 if (!priv->buf) {
88 kfree(priv);
89 return -ENOMEM;
90 }
91
92 priv->writebuf = kzalloc(256, GFP_KERNEL);
93 if (!priv->writebuf) {
94 kfree(priv->buf);
104 kfree(priv); 95 kfree(priv);
105 return -ENOMEM; 96 return -ENOMEM;
106 } 97 }
98
107 priv->vcc = vcc_default; 99 priv->vcc = vcc_default;
108 spin_lock_init(&priv->lock); 100 spin_lock_init(&priv->lock);
109 init_waitqueue_head(&priv->delta_msr_wait); 101 init_waitqueue_head(&priv->delta_msr_wait);
110 usb_set_serial_port_data(serial->port[0], priv); 102
103 usb_set_serial_port_data(port, priv);
104
105 ret = iuu_create_sysfs_attrs(port);
106 if (ret) {
107 kfree(priv->writebuf);
108 kfree(priv->buf);
109 kfree(priv);
110 return ret;
111 }
112
111 return 0; 113 return 0;
112} 114}
113 115
114/* Release function */ 116static int iuu_port_remove(struct usb_serial_port *port)
115static void iuu_release(struct usb_serial *serial)
116{ 117{
117 struct usb_serial_port *port = serial->port[0];
118 struct iuu_private *priv = usb_get_serial_port_data(port); 118 struct iuu_private *priv = usb_get_serial_port_data(port);
119 if (!port)
120 return;
121 119
122 if (priv) { 120 iuu_remove_sysfs_attrs(port);
123 iuu_free_buf(priv); 121 kfree(priv->writebuf);
124 dev_dbg(&port->dev, "%s - I will free all\n", __func__); 122 kfree(priv->buf);
125 usb_set_serial_port_data(port, NULL); 123 kfree(priv);
126
127 dev_dbg(&port->dev, "%s - priv is not anymore in port structure\n", __func__);
128 kfree(priv);
129 124
130 dev_dbg(&port->dev, "%s priv is now kfree\n", __func__); 125 return 0;
131 }
132} 126}
133 127
134static int iuu_tiocmset(struct tty_struct *tty, 128static int iuu_tiocmset(struct tty_struct *tty,
@@ -1215,8 +1209,6 @@ static struct usb_serial_driver iuu_device = {
1215 .num_ports = 1, 1209 .num_ports = 1,
1216 .bulk_in_size = 512, 1210 .bulk_in_size = 512,
1217 .bulk_out_size = 512, 1211 .bulk_out_size = 512,
1218 .port_probe = iuu_create_sysfs_attrs,
1219 .port_remove = iuu_remove_sysfs_attrs,
1220 .open = iuu_open, 1212 .open = iuu_open,
1221 .close = iuu_close, 1213 .close = iuu_close,
1222 .write = iuu_uart_write, 1214 .write = iuu_uart_write,
@@ -1225,8 +1217,8 @@ static struct usb_serial_driver iuu_device = {
1225 .tiocmset = iuu_tiocmset, 1217 .tiocmset = iuu_tiocmset,
1226 .set_termios = iuu_set_termios, 1218 .set_termios = iuu_set_termios,
1227 .init_termios = iuu_init_termios, 1219 .init_termios = iuu_init_termios,
1228 .attach = iuu_startup, 1220 .port_probe = iuu_port_probe,
1229 .release = iuu_release, 1221 .port_remove = iuu_port_remove,
1230}; 1222};
1231 1223
1232static struct usb_serial_driver * const serial_drivers[] = { 1224static struct usb_serial_driver * const serial_drivers[] = {
diff --git a/drivers/usb/serial/keyspan.c b/drivers/usb/serial/keyspan.c
index 29c943d737d..cff8dd5b462 100644
--- a/drivers/usb/serial/keyspan.c
+++ b/drivers/usb/serial/keyspan.c
@@ -1374,13 +1374,9 @@ static struct callbacks {
1374 data in device_details */ 1374 data in device_details */
1375static void keyspan_setup_urbs(struct usb_serial *serial) 1375static void keyspan_setup_urbs(struct usb_serial *serial)
1376{ 1376{
1377 int i, j;
1378 struct keyspan_serial_private *s_priv; 1377 struct keyspan_serial_private *s_priv;
1379 const struct keyspan_device_details *d_details; 1378 const struct keyspan_device_details *d_details;
1380 struct usb_serial_port *port;
1381 struct keyspan_port_private *p_priv;
1382 struct callbacks *cback; 1379 struct callbacks *cback;
1383 int endp;
1384 1380
1385 s_priv = usb_get_serial_data(serial); 1381 s_priv = usb_get_serial_data(serial);
1386 d_details = s_priv->device_details; 1382 d_details = s_priv->device_details;
@@ -1404,45 +1400,6 @@ static void keyspan_setup_urbs(struct usb_serial *serial)
1404 (serial, d_details->glocont_endpoint, USB_DIR_OUT, 1400 (serial, d_details->glocont_endpoint, USB_DIR_OUT,
1405 serial, s_priv->glocont_buf, GLOCONT_BUFLEN, 1401 serial, s_priv->glocont_buf, GLOCONT_BUFLEN,
1406 cback->glocont_callback); 1402 cback->glocont_callback);
1407
1408 /* Setup endpoints for each port specific thing */
1409 for (i = 0; i < d_details->num_ports; i++) {
1410 port = serial->port[i];
1411 p_priv = usb_get_serial_port_data(port);
1412
1413 /* Do indat endpoints first, once for each flip */
1414 endp = d_details->indat_endpoints[i];
1415 for (j = 0; j <= d_details->indat_endp_flip; ++j, ++endp) {
1416 p_priv->in_urbs[j] = keyspan_setup_urb
1417 (serial, endp, USB_DIR_IN, port,
1418 p_priv->in_buffer[j], 64,
1419 cback->indat_callback);
1420 }
1421 for (; j < 2; ++j)
1422 p_priv->in_urbs[j] = NULL;
1423
1424 /* outdat endpoints also have flip */
1425 endp = d_details->outdat_endpoints[i];
1426 for (j = 0; j <= d_details->outdat_endp_flip; ++j, ++endp) {
1427 p_priv->out_urbs[j] = keyspan_setup_urb
1428 (serial, endp, USB_DIR_OUT, port,
1429 p_priv->out_buffer[j], 64,
1430 cback->outdat_callback);
1431 }
1432 for (; j < 2; ++j)
1433 p_priv->out_urbs[j] = NULL;
1434
1435 /* inack endpoint */
1436 p_priv->inack_urb = keyspan_setup_urb
1437 (serial, d_details->inack_endpoints[i], USB_DIR_IN,
1438 port, p_priv->inack_buffer, 1, cback->inack_callback);
1439
1440 /* outcont endpoint */
1441 p_priv->outcont_urb = keyspan_setup_urb
1442 (serial, d_details->outcont_endpoints[i], USB_DIR_OUT,
1443 port, p_priv->outcont_buffer, 64,
1444 cback->outcont_callback);
1445 }
1446} 1403}
1447 1404
1448/* usa19 function doesn't require prescaler */ 1405/* usa19 function doesn't require prescaler */
@@ -2407,9 +2364,7 @@ static void keyspan_send_setup(struct usb_serial_port *port, int reset_port)
2407static int keyspan_startup(struct usb_serial *serial) 2364static int keyspan_startup(struct usb_serial *serial)
2408{ 2365{
2409 int i, err; 2366 int i, err;
2410 struct usb_serial_port *port;
2411 struct keyspan_serial_private *s_priv; 2367 struct keyspan_serial_private *s_priv;
2412 struct keyspan_port_private *p_priv;
2413 const struct keyspan_device_details *d_details; 2368 const struct keyspan_device_details *d_details;
2414 2369
2415 for (i = 0; (d_details = keyspan_devices[i]) != NULL; ++i) 2370 for (i = 0; (d_details = keyspan_devices[i]) != NULL; ++i)
@@ -2432,19 +2387,6 @@ static int keyspan_startup(struct usb_serial *serial)
2432 s_priv->device_details = d_details; 2387 s_priv->device_details = d_details;
2433 usb_set_serial_data(serial, s_priv); 2388 usb_set_serial_data(serial, s_priv);
2434 2389
2435 /* Now setup per port private data */
2436 for (i = 0; i < serial->num_ports; i++) {
2437 port = serial->port[i];
2438 p_priv = kzalloc(sizeof(struct keyspan_port_private),
2439 GFP_KERNEL);
2440 if (!p_priv) {
2441 dev_dbg(&port->dev, "%s - kmalloc for keyspan_port_private (%d) failed!.\n", __func__, i);
2442 return 1;
2443 }
2444 p_priv->device_details = d_details;
2445 usb_set_serial_port_data(port, p_priv);
2446 }
2447
2448 keyspan_setup_urbs(serial); 2390 keyspan_setup_urbs(serial);
2449 2391
2450 if (s_priv->instat_urb != NULL) { 2392 if (s_priv->instat_urb != NULL) {
@@ -2463,59 +2405,111 @@ static int keyspan_startup(struct usb_serial *serial)
2463 2405
2464static void keyspan_disconnect(struct usb_serial *serial) 2406static void keyspan_disconnect(struct usb_serial *serial)
2465{ 2407{
2466 int i, j; 2408 struct keyspan_serial_private *s_priv;
2467 struct usb_serial_port *port;
2468 struct keyspan_serial_private *s_priv;
2469 struct keyspan_port_private *p_priv;
2470 2409
2471 s_priv = usb_get_serial_data(serial); 2410 s_priv = usb_get_serial_data(serial);
2472 2411
2473 /* Stop reading/writing urbs */
2474 stop_urb(s_priv->instat_urb); 2412 stop_urb(s_priv->instat_urb);
2475 stop_urb(s_priv->glocont_urb); 2413 stop_urb(s_priv->glocont_urb);
2476 stop_urb(s_priv->indat_urb); 2414 stop_urb(s_priv->indat_urb);
2477 for (i = 0; i < serial->num_ports; ++i) { 2415}
2478 port = serial->port[i]; 2416
2479 p_priv = usb_get_serial_port_data(port); 2417static void keyspan_release(struct usb_serial *serial)
2480 stop_urb(p_priv->inack_urb); 2418{
2481 stop_urb(p_priv->outcont_urb); 2419 struct keyspan_serial_private *s_priv;
2482 for (j = 0; j < 2; j++) { 2420
2483 stop_urb(p_priv->in_urbs[j]); 2421 s_priv = usb_get_serial_data(serial);
2484 stop_urb(p_priv->out_urbs[j]);
2485 }
2486 }
2487 2422
2488 /* Now free them */
2489 usb_free_urb(s_priv->instat_urb); 2423 usb_free_urb(s_priv->instat_urb);
2490 usb_free_urb(s_priv->indat_urb); 2424 usb_free_urb(s_priv->indat_urb);
2491 usb_free_urb(s_priv->glocont_urb); 2425 usb_free_urb(s_priv->glocont_urb);
2492 for (i = 0; i < serial->num_ports; ++i) { 2426
2493 port = serial->port[i]; 2427 kfree(s_priv);
2494 p_priv = usb_get_serial_port_data(port);
2495 usb_free_urb(p_priv->inack_urb);
2496 usb_free_urb(p_priv->outcont_urb);
2497 for (j = 0; j < 2; j++) {
2498 usb_free_urb(p_priv->in_urbs[j]);
2499 usb_free_urb(p_priv->out_urbs[j]);
2500 }
2501 }
2502} 2428}
2503 2429
2504static void keyspan_release(struct usb_serial *serial) 2430static int keyspan_port_probe(struct usb_serial_port *port)
2505{ 2431{
2506 int i; 2432 struct usb_serial *serial = port->serial;
2507 struct usb_serial_port *port; 2433 struct keyspan_serial_private *s_priv;
2508 struct keyspan_serial_private *s_priv; 2434 struct keyspan_port_private *p_priv;
2435 const struct keyspan_device_details *d_details;
2436 struct callbacks *cback;
2437 int endp;
2438 int port_num;
2439 int i;
2509 2440
2510 s_priv = usb_get_serial_data(serial); 2441 s_priv = usb_get_serial_data(serial);
2442 d_details = s_priv->device_details;
2511 2443
2512 kfree(s_priv); 2444 p_priv = kzalloc(sizeof(*p_priv), GFP_KERNEL);
2445 if (!p_priv)
2446 return -ENOMEM;
2513 2447
2514 /* Now free per port private data */ 2448 p_priv->device_details = d_details;
2515 for (i = 0; i < serial->num_ports; i++) { 2449
2516 port = serial->port[i]; 2450 /* Setup values for the various callback routines */
2517 kfree(usb_get_serial_port_data(port)); 2451 cback = &keyspan_callbacks[d_details->msg_format];
2452
2453 port_num = port->number - port->serial->minor;
2454
2455 /* Do indat endpoints first, once for each flip */
2456 endp = d_details->indat_endpoints[port_num];
2457 for (i = 0; i <= d_details->indat_endp_flip; ++i, ++endp) {
2458 p_priv->in_urbs[i] = keyspan_setup_urb(serial, endp,
2459 USB_DIR_IN, port,
2460 p_priv->in_buffer[i], 64,
2461 cback->indat_callback);
2462 }
2463 /* outdat endpoints also have flip */
2464 endp = d_details->outdat_endpoints[port_num];
2465 for (i = 0; i <= d_details->outdat_endp_flip; ++i, ++endp) {
2466 p_priv->out_urbs[i] = keyspan_setup_urb(serial, endp,
2467 USB_DIR_OUT, port,
2468 p_priv->out_buffer[i], 64,
2469 cback->outdat_callback);
2470 }
2471 /* inack endpoint */
2472 p_priv->inack_urb = keyspan_setup_urb(serial,
2473 d_details->inack_endpoints[port_num],
2474 USB_DIR_IN, port,
2475 p_priv->inack_buffer, 1,
2476 cback->inack_callback);
2477 /* outcont endpoint */
2478 p_priv->outcont_urb = keyspan_setup_urb(serial,
2479 d_details->outcont_endpoints[port_num],
2480 USB_DIR_OUT, port,
2481 p_priv->outcont_buffer, 64,
2482 cback->outcont_callback);
2483
2484 usb_set_serial_port_data(port, p_priv);
2485
2486 return 0;
2487}
2488
2489static int keyspan_port_remove(struct usb_serial_port *port)
2490{
2491 struct keyspan_port_private *p_priv;
2492 int i;
2493
2494 p_priv = usb_get_serial_port_data(port);
2495
2496 stop_urb(p_priv->inack_urb);
2497 stop_urb(p_priv->outcont_urb);
2498 for (i = 0; i < 2; i++) {
2499 stop_urb(p_priv->in_urbs[i]);
2500 stop_urb(p_priv->out_urbs[i]);
2501 }
2502
2503 usb_free_urb(p_priv->inack_urb);
2504 usb_free_urb(p_priv->outcont_urb);
2505 for (i = 0; i < 2; i++) {
2506 usb_free_urb(p_priv->in_urbs[i]);
2507 usb_free_urb(p_priv->out_urbs[i]);
2518 } 2508 }
2509
2510 kfree(p_priv);
2511
2512 return 0;
2519} 2513}
2520 2514
2521MODULE_AUTHOR(DRIVER_AUTHOR); 2515MODULE_AUTHOR(DRIVER_AUTHOR);
diff --git a/drivers/usb/serial/keyspan.h b/drivers/usb/serial/keyspan.h
index 0a8a40b5711..0273dda303a 100644
--- a/drivers/usb/serial/keyspan.h
+++ b/drivers/usb/serial/keyspan.h
@@ -42,6 +42,8 @@ static void keyspan_dtr_rts (struct usb_serial_port *port, int on);
42static int keyspan_startup (struct usb_serial *serial); 42static int keyspan_startup (struct usb_serial *serial);
43static void keyspan_disconnect (struct usb_serial *serial); 43static void keyspan_disconnect (struct usb_serial *serial);
44static void keyspan_release (struct usb_serial *serial); 44static void keyspan_release (struct usb_serial *serial);
45static int keyspan_port_probe(struct usb_serial_port *port);
46static int keyspan_port_remove(struct usb_serial_port *port);
45static int keyspan_write_room (struct tty_struct *tty); 47static int keyspan_write_room (struct tty_struct *tty);
46 48
47static int keyspan_write (struct tty_struct *tty, 49static int keyspan_write (struct tty_struct *tty,
@@ -567,6 +569,8 @@ static struct usb_serial_driver keyspan_1port_device = {
567 .attach = keyspan_startup, 569 .attach = keyspan_startup,
568 .disconnect = keyspan_disconnect, 570 .disconnect = keyspan_disconnect,
569 .release = keyspan_release, 571 .release = keyspan_release,
572 .port_probe = keyspan_port_probe,
573 .port_remove = keyspan_port_remove,
570}; 574};
571 575
572static struct usb_serial_driver keyspan_2port_device = { 576static struct usb_serial_driver keyspan_2port_device = {
@@ -589,6 +593,8 @@ static struct usb_serial_driver keyspan_2port_device = {
589 .attach = keyspan_startup, 593 .attach = keyspan_startup,
590 .disconnect = keyspan_disconnect, 594 .disconnect = keyspan_disconnect,
591 .release = keyspan_release, 595 .release = keyspan_release,
596 .port_probe = keyspan_port_probe,
597 .port_remove = keyspan_port_remove,
592}; 598};
593 599
594static struct usb_serial_driver keyspan_4port_device = { 600static struct usb_serial_driver keyspan_4port_device = {
@@ -611,6 +617,8 @@ static struct usb_serial_driver keyspan_4port_device = {
611 .attach = keyspan_startup, 617 .attach = keyspan_startup,
612 .disconnect = keyspan_disconnect, 618 .disconnect = keyspan_disconnect,
613 .release = keyspan_release, 619 .release = keyspan_release,
620 .port_probe = keyspan_port_probe,
621 .port_remove = keyspan_port_remove,
614}; 622};
615 623
616static struct usb_serial_driver * const serial_drivers[] = { 624static struct usb_serial_driver * const serial_drivers[] = {
diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c
index ca43ecb4a2b..bb87e29c4ac 100644
--- a/drivers/usb/serial/keyspan_pda.c
+++ b/drivers/usb/serial/keyspan_pda.c
@@ -713,29 +713,33 @@ MODULE_FIRMWARE("keyspan_pda/keyspan_pda.fw");
713MODULE_FIRMWARE("keyspan_pda/xircom_pgs.fw"); 713MODULE_FIRMWARE("keyspan_pda/xircom_pgs.fw");
714#endif 714#endif
715 715
716static int keyspan_pda_startup(struct usb_serial *serial) 716static int keyspan_pda_port_probe(struct usb_serial_port *port)
717{ 717{
718 718
719 struct keyspan_pda_private *priv; 719 struct keyspan_pda_private *priv;
720 720
721 /* allocate the private data structures for all ports. Well, for all
722 one ports. */
723
724 priv = kmalloc(sizeof(struct keyspan_pda_private), GFP_KERNEL); 721 priv = kmalloc(sizeof(struct keyspan_pda_private), GFP_KERNEL);
725 if (!priv) 722 if (!priv)
726 return 1; /* error */ 723 return -ENOMEM;
727 usb_set_serial_port_data(serial->port[0], priv); 724
728 init_waitqueue_head(&serial->port[0]->write_wait);
729 INIT_WORK(&priv->wakeup_work, keyspan_pda_wakeup_write); 725 INIT_WORK(&priv->wakeup_work, keyspan_pda_wakeup_write);
730 INIT_WORK(&priv->unthrottle_work, keyspan_pda_request_unthrottle); 726 INIT_WORK(&priv->unthrottle_work, keyspan_pda_request_unthrottle);
731 priv->serial = serial; 727 priv->serial = port->serial;
732 priv->port = serial->port[0]; 728 priv->port = port;
729
730 usb_set_serial_port_data(port, priv);
731
733 return 0; 732 return 0;
734} 733}
735 734
736static void keyspan_pda_release(struct usb_serial *serial) 735static int keyspan_pda_port_remove(struct usb_serial_port *port)
737{ 736{
738 kfree(usb_get_serial_port_data(serial->port[0])); 737 struct keyspan_pda_private *priv;
738
739 priv = usb_get_serial_port_data(port);
740 kfree(priv);
741
742 return 0;
739} 743}
740 744
741#ifdef KEYSPAN 745#ifdef KEYSPAN
@@ -786,8 +790,8 @@ static struct usb_serial_driver keyspan_pda_device = {
786 .break_ctl = keyspan_pda_break_ctl, 790 .break_ctl = keyspan_pda_break_ctl,
787 .tiocmget = keyspan_pda_tiocmget, 791 .tiocmget = keyspan_pda_tiocmget,
788 .tiocmset = keyspan_pda_tiocmset, 792 .tiocmset = keyspan_pda_tiocmset,
789 .attach = keyspan_pda_startup, 793 .port_probe = keyspan_pda_port_probe,
790 .release = keyspan_pda_release, 794 .port_remove = keyspan_pda_port_remove,
791}; 795};
792 796
793static struct usb_serial_driver * const serial_drivers[] = { 797static struct usb_serial_driver * const serial_drivers[] = {
diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c
index 3f6d7376c02..1f4517864cd 100644
--- a/drivers/usb/serial/kl5kusb105.c
+++ b/drivers/usb/serial/kl5kusb105.c
@@ -60,8 +60,8 @@
60/* 60/*
61 * Function prototypes 61 * Function prototypes
62 */ 62 */
63static int klsi_105_startup(struct usb_serial *serial); 63static int klsi_105_port_probe(struct usb_serial_port *port);
64static void klsi_105_release(struct usb_serial *serial); 64static int klsi_105_port_remove(struct usb_serial_port *port);
65static int klsi_105_open(struct tty_struct *tty, struct usb_serial_port *port); 65static int klsi_105_open(struct tty_struct *tty, struct usb_serial_port *port);
66static void klsi_105_close(struct usb_serial_port *port); 66static void klsi_105_close(struct usb_serial_port *port);
67static void klsi_105_set_termios(struct tty_struct *tty, 67static void klsi_105_set_termios(struct tty_struct *tty,
@@ -99,8 +99,8 @@ static struct usb_serial_driver kl5kusb105d_device = {
99 /*.break_ctl = klsi_105_break_ctl,*/ 99 /*.break_ctl = klsi_105_break_ctl,*/
100 .tiocmget = klsi_105_tiocmget, 100 .tiocmget = klsi_105_tiocmget,
101 .tiocmset = klsi_105_tiocmset, 101 .tiocmset = klsi_105_tiocmset,
102 .attach = klsi_105_startup, 102 .port_probe = klsi_105_port_probe,
103 .release = klsi_105_release, 103 .port_remove = klsi_105_port_remove,
104 .throttle = usb_serial_generic_throttle, 104 .throttle = usb_serial_generic_throttle,
105 .unthrottle = usb_serial_generic_unthrottle, 105 .unthrottle = usb_serial_generic_unthrottle,
106 .process_read_urb = klsi_105_process_read_urb, 106 .process_read_urb = klsi_105_process_read_urb,
@@ -223,60 +223,40 @@ static int klsi_105_get_line_state(struct usb_serial_port *port,
223 * Driver's tty interface functions 223 * Driver's tty interface functions
224 */ 224 */
225 225
226static int klsi_105_startup(struct usb_serial *serial) 226static int klsi_105_port_probe(struct usb_serial_port *port)
227{ 227{
228 struct klsi_105_private *priv; 228 struct klsi_105_private *priv;
229 int i;
230 229
231 /* check if we support the product id (see keyspan.c) 230 priv = kmalloc(sizeof(*priv), GFP_KERNEL);
232 * FIXME 231 if (!priv)
233 */ 232 return -ENOMEM;
234 233
235 /* allocate the private data structure */ 234 /* set initial values for control structures */
236 for (i = 0; i < serial->num_ports; i++) { 235 priv->cfg.pktlen = 5;
237 priv = kmalloc(sizeof(struct klsi_105_private), 236 priv->cfg.baudrate = kl5kusb105a_sio_b9600;
238 GFP_KERNEL); 237 priv->cfg.databits = kl5kusb105a_dtb_8;
239 if (!priv) { 238 priv->cfg.unknown1 = 0;
240 dev_dbg(&serial->interface->dev, 239 priv->cfg.unknown2 = 1;
241 "%s - kmalloc for klsi_105_private failed.\n",
242 __func__);
243 i--;
244 goto err_cleanup;
245 }
246 /* set initial values for control structures */
247 priv->cfg.pktlen = 5;
248 priv->cfg.baudrate = kl5kusb105a_sio_b9600;
249 priv->cfg.databits = kl5kusb105a_dtb_8;
250 priv->cfg.unknown1 = 0;
251 priv->cfg.unknown2 = 1;
252 240
253 priv->line_state = 0; 241 priv->line_state = 0;
254 242
255 usb_set_serial_port_data(serial->port[i], priv); 243 spin_lock_init(&priv->lock);
256 244
257 spin_lock_init(&priv->lock); 245 /* priv->termios is left uninitialized until port opening */
258 246
259 /* priv->termios is left uninitialized until port opening */ 247 usb_set_serial_port_data(port, priv);
260 init_waitqueue_head(&serial->port[i]->write_wait);
261 }
262 248
263 return 0; 249 return 0;
264
265err_cleanup:
266 for (; i >= 0; i--) {
267 priv = usb_get_serial_port_data(serial->port[i]);
268 kfree(priv);
269 usb_set_serial_port_data(serial->port[i], NULL);
270 }
271 return -ENOMEM;
272} 250}
273 251
274static void klsi_105_release(struct usb_serial *serial) 252static int klsi_105_port_remove(struct usb_serial_port *port)
275{ 253{
276 int i; 254 struct klsi_105_private *priv;
255
256 priv = usb_get_serial_port_data(port);
257 kfree(priv);
277 258
278 for (i = 0; i < serial->num_ports; ++i) 259 return 0;
279 kfree(usb_get_serial_port_data(serial->port[i]));
280} 260}
281 261
282static int klsi_105_open(struct tty_struct *tty, struct usb_serial_port *port) 262static int klsi_105_open(struct tty_struct *tty, struct usb_serial_port *port)
diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c
index 5c4d2fbd4e1..c9ca7a5b12e 100644
--- a/drivers/usb/serial/kobil_sct.c
+++ b/drivers/usb/serial/kobil_sct.c
@@ -54,8 +54,8 @@
54 54
55 55
56/* Function prototypes */ 56/* Function prototypes */
57static int kobil_startup(struct usb_serial *serial); 57static int kobil_port_probe(struct usb_serial_port *probe);
58static void kobil_release(struct usb_serial *serial); 58static int kobil_port_remove(struct usb_serial_port *probe);
59static int kobil_open(struct tty_struct *tty, struct usb_serial_port *port); 59static int kobil_open(struct tty_struct *tty, struct usb_serial_port *port);
60static void kobil_close(struct usb_serial_port *port); 60static void kobil_close(struct usb_serial_port *port);
61static int kobil_write(struct tty_struct *tty, struct usb_serial_port *port, 61static int kobil_write(struct tty_struct *tty, struct usb_serial_port *port,
@@ -89,8 +89,8 @@ static struct usb_serial_driver kobil_device = {
89 .description = "KOBIL USB smart card terminal", 89 .description = "KOBIL USB smart card terminal",
90 .id_table = id_table, 90 .id_table = id_table,
91 .num_ports = 1, 91 .num_ports = 1,
92 .attach = kobil_startup, 92 .port_probe = kobil_port_probe,
93 .release = kobil_release, 93 .port_remove = kobil_port_remove,
94 .ioctl = kobil_ioctl, 94 .ioctl = kobil_ioctl,
95 .set_termios = kobil_set_termios, 95 .set_termios = kobil_set_termios,
96 .init_termios = kobil_init_termios, 96 .init_termios = kobil_init_termios,
@@ -117,9 +117,10 @@ struct kobil_private {
117}; 117};
118 118
119 119
120static int kobil_startup(struct usb_serial *serial) 120static int kobil_port_probe(struct usb_serial_port *port)
121{ 121{
122 int i; 122 int i;
123 struct usb_serial *serial = port->serial;
123 struct kobil_private *priv; 124 struct kobil_private *priv;
124 struct usb_device *pdev; 125 struct usb_device *pdev;
125 struct usb_host_config *actconfig; 126 struct usb_host_config *actconfig;
@@ -149,7 +150,7 @@ static int kobil_startup(struct usb_serial *serial)
149 dev_dbg(&serial->dev->dev, "KOBIL KAAN SIM detected\n"); 150 dev_dbg(&serial->dev->dev, "KOBIL KAAN SIM detected\n");
150 break; 151 break;
151 } 152 }
152 usb_set_serial_port_data(serial->port[0], priv); 153 usb_set_serial_port_data(port, priv);
153 154
154 /* search for the necessary endpoints */ 155 /* search for the necessary endpoints */
155 pdev = serial->dev; 156 pdev = serial->dev;
@@ -179,12 +180,14 @@ static int kobil_startup(struct usb_serial *serial)
179} 180}
180 181
181 182
182static void kobil_release(struct usb_serial *serial) 183static int kobil_port_remove(struct usb_serial_port *port)
183{ 184{
184 int i; 185 struct kobil_private *priv;
185 186
186 for (i = 0; i < serial->num_ports; ++i) 187 priv = usb_get_serial_port_data(port);
187 kfree(usb_get_serial_port_data(serial->port[i])); 188 kfree(priv);
189
190 return 0;
188} 191}
189 192
190static void kobil_init_termios(struct tty_struct *tty) 193static void kobil_init_termios(struct tty_struct *tty)
diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c
index f3947712e13..8a208100410 100644
--- a/drivers/usb/serial/mct_u232.c
+++ b/drivers/usb/serial/mct_u232.c
@@ -49,7 +49,8 @@
49 * Function prototypes 49 * Function prototypes
50 */ 50 */
51static int mct_u232_startup(struct usb_serial *serial); 51static int mct_u232_startup(struct usb_serial *serial);
52static void mct_u232_release(struct usb_serial *serial); 52static int mct_u232_port_probe(struct usb_serial_port *port);
53static int mct_u232_port_remove(struct usb_serial_port *remove);
53static int mct_u232_open(struct tty_struct *tty, struct usb_serial_port *port); 54static int mct_u232_open(struct tty_struct *tty, struct usb_serial_port *port);
54static void mct_u232_close(struct usb_serial_port *port); 55static void mct_u232_close(struct usb_serial_port *port);
55static void mct_u232_dtr_rts(struct usb_serial_port *port, int on); 56static void mct_u232_dtr_rts(struct usb_serial_port *port, int on);
@@ -99,7 +100,8 @@ static struct usb_serial_driver mct_u232_device = {
99 .tiocmget = mct_u232_tiocmget, 100 .tiocmget = mct_u232_tiocmget,
100 .tiocmset = mct_u232_tiocmset, 101 .tiocmset = mct_u232_tiocmset,
101 .attach = mct_u232_startup, 102 .attach = mct_u232_startup,
102 .release = mct_u232_release, 103 .port_probe = mct_u232_port_probe,
104 .port_remove = mct_u232_port_remove,
103 .ioctl = mct_u232_ioctl, 105 .ioctl = mct_u232_ioctl,
104 .get_icount = mct_u232_get_icount, 106 .get_icount = mct_u232_get_icount,
105}; 107};
@@ -388,18 +390,8 @@ static void mct_u232_msr_to_state(struct usb_serial_port *port,
388 390
389static int mct_u232_startup(struct usb_serial *serial) 391static int mct_u232_startup(struct usb_serial *serial)
390{ 392{
391 struct mct_u232_private *priv;
392 struct usb_serial_port *port, *rport; 393 struct usb_serial_port *port, *rport;
393 394
394 priv = kzalloc(sizeof(struct mct_u232_private), GFP_KERNEL);
395 if (!priv)
396 return -ENOMEM;
397 spin_lock_init(&priv->lock);
398 init_waitqueue_head(&priv->msr_wait);
399 usb_set_serial_port_data(serial->port[0], priv);
400
401 init_waitqueue_head(&serial->port[0]->write_wait);
402
403 /* Puh, that's dirty */ 395 /* Puh, that's dirty */
404 port = serial->port[0]; 396 port = serial->port[0];
405 rport = serial->port[1]; 397 rport = serial->port[1];
@@ -412,18 +404,31 @@ static int mct_u232_startup(struct usb_serial *serial)
412 return 0; 404 return 0;
413} /* mct_u232_startup */ 405} /* mct_u232_startup */
414 406
407static int mct_u232_port_probe(struct usb_serial_port *port)
408{
409 struct mct_u232_private *priv;
410
411 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
412 if (!priv)
413 return -ENOMEM;
414
415 spin_lock_init(&priv->lock);
416 init_waitqueue_head(&priv->msr_wait);
417
418 usb_set_serial_port_data(port, priv);
415 419
416static void mct_u232_release(struct usb_serial *serial) 420 return 0;
421}
422
423static int mct_u232_port_remove(struct usb_serial_port *port)
417{ 424{
418 struct mct_u232_private *priv; 425 struct mct_u232_private *priv;
419 int i;
420 426
421 for (i = 0; i < serial->num_ports; ++i) { 427 priv = usb_get_serial_port_data(port);
422 /* My special items, the standard routines free my urbs */ 428 kfree(priv);
423 priv = usb_get_serial_port_data(serial->port[i]); 429
424 kfree(priv); 430 return 0;
425 } 431}
426} /* mct_u232_release */
427 432
428static int mct_u232_open(struct tty_struct *tty, struct usb_serial_port *port) 433static int mct_u232_open(struct tty_struct *tty, struct usb_serial_port *port)
429{ 434{
@@ -515,12 +520,14 @@ static void mct_u232_dtr_rts(struct usb_serial_port *port, int on)
515 520
516static void mct_u232_close(struct usb_serial_port *port) 521static void mct_u232_close(struct usb_serial_port *port)
517{ 522{
518 if (port->serial->dev) { 523 /*
519 /* shutdown our urbs */ 524 * Must kill the read urb as it is actually an interrupt urb, which
520 usb_kill_urb(port->write_urb); 525 * generic close thus fails to kill.
521 usb_kill_urb(port->read_urb); 526 */
522 usb_kill_urb(port->interrupt_in_urb); 527 usb_kill_urb(port->read_urb);
523 } 528 usb_kill_urb(port->interrupt_in_urb);
529
530 usb_serial_generic_close(port);
524} /* mct_u232_close */ 531} /* mct_u232_close */
525 532
526 533
diff --git a/drivers/usb/serial/metro-usb.c b/drivers/usb/serial/metro-usb.c
index 0b257ddffbd..6f29c74eb76 100644
--- a/drivers/usb/serial/metro-usb.c
+++ b/drivers/usb/serial/metro-usb.c
@@ -179,16 +179,13 @@ static void metrousb_cleanup(struct usb_serial_port *port)
179{ 179{
180 dev_dbg(&port->dev, "%s\n", __func__); 180 dev_dbg(&port->dev, "%s\n", __func__);
181 181
182 if (port->serial->dev) { 182 usb_unlink_urb(port->interrupt_in_urb);
183 /* Shutdown any interrupt in urbs. */ 183 usb_kill_urb(port->interrupt_in_urb);
184 if (port->interrupt_in_urb) { 184
185 usb_unlink_urb(port->interrupt_in_urb); 185 mutex_lock(&port->serial->disc_mutex);
186 usb_kill_urb(port->interrupt_in_urb); 186 if (!port->serial->disconnected)
187 }
188
189 /* Send deactivate cmd to device */
190 metrousb_send_unidirectional_cmd(UNI_CMD_CLOSE, port); 187 metrousb_send_unidirectional_cmd(UNI_CMD_CLOSE, port);
191 } 188 mutex_unlock(&port->serial->disc_mutex);
192} 189}
193 190
194static int metrousb_open(struct tty_struct *tty, struct usb_serial_port *port) 191static int metrousb_open(struct tty_struct *tty, struct usb_serial_port *port)
@@ -271,51 +268,27 @@ static int metrousb_set_modem_ctrl(struct usb_serial *serial, unsigned int contr
271 return retval; 268 return retval;
272} 269}
273 270
274static void metrousb_shutdown(struct usb_serial *serial) 271static int metrousb_port_probe(struct usb_serial_port *port)
275{ 272{
276 int i = 0; 273 struct metrousb_private *metro_priv;
277 274
278 dev_dbg(&serial->dev->dev, "%s\n", __func__); 275 metro_priv = kzalloc(sizeof(*metro_priv), GFP_KERNEL);
276 if (!metro_priv)
277 return -ENOMEM;
279 278
280 /* Stop reading and writing on all ports. */ 279 spin_lock_init(&metro_priv->lock);
281 for (i = 0; i < serial->num_ports; ++i) {
282 /* Close any open urbs. */
283 metrousb_cleanup(serial->port[i]);
284 280
285 /* Free memory. */ 281 usb_set_serial_port_data(port, metro_priv);
286 kfree(usb_get_serial_port_data(serial->port[i]));
287 usb_set_serial_port_data(serial->port[i], NULL);
288 282
289 dev_dbg(&serial->dev->dev, "%s - freed port number=%d\n", 283 return 0;
290 __func__, serial->port[i]->number);
291 }
292} 284}
293 285
294static int metrousb_startup(struct usb_serial *serial) 286static int metrousb_port_remove(struct usb_serial_port *port)
295{ 287{
296 struct metrousb_private *metro_priv; 288 struct metrousb_private *metro_priv;
297 struct usb_serial_port *port;
298 int i = 0;
299 289
300 dev_dbg(&serial->dev->dev, "%s\n", __func__); 290 metro_priv = usb_get_serial_port_data(port);
301 291 kfree(metro_priv);
302 /* Loop through the serial ports setting up the private structures.
303 * Currently we only use one port. */
304 for (i = 0; i < serial->num_ports; ++i) {
305 port = serial->port[i];
306
307 /* Declare memory. */
308 metro_priv = kzalloc(sizeof(struct metrousb_private), GFP_KERNEL);
309 if (!metro_priv)
310 return -ENOMEM;
311
312 /* Initialize memory. */
313 spin_lock_init(&metro_priv->lock);
314 usb_set_serial_port_data(port, metro_priv);
315
316 dev_dbg(&serial->dev->dev, "%s - port number=%d\n ",
317 __func__, port->number);
318 }
319 292
320 return 0; 293 return 0;
321} 294}
@@ -414,8 +387,8 @@ static struct usb_serial_driver metrousb_device = {
414 .close = metrousb_cleanup, 387 .close = metrousb_cleanup,
415 .read_int_callback = metrousb_read_int_callback, 388 .read_int_callback = metrousb_read_int_callback,
416 .write_int_callback = metrousb_write_int_callback, 389 .write_int_callback = metrousb_write_int_callback,
417 .attach = metrousb_startup, 390 .port_probe = metrousb_port_probe,
418 .release = metrousb_shutdown, 391 .port_remove = metrousb_port_remove,
419 .throttle = metrousb_throttle, 392 .throttle = metrousb_throttle,
420 .unthrottle = metrousb_unthrottle, 393 .unthrottle = metrousb_unthrottle,
421 .tiocmget = metrousb_tiocmget, 394 .tiocmget = metrousb_tiocmget,
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c
index 1bf1ad06666..75267421aad 100644
--- a/drivers/usb/serial/mos7720.c
+++ b/drivers/usb/serial/mos7720.c
@@ -1966,9 +1966,7 @@ static int mos7720_ioctl(struct tty_struct *tty,
1966 1966
1967static int mos7720_startup(struct usb_serial *serial) 1967static int mos7720_startup(struct usb_serial *serial)
1968{ 1968{
1969 struct moschip_port *mos7720_port;
1970 struct usb_device *dev; 1969 struct usb_device *dev;
1971 int i;
1972 char data; 1970 char data;
1973 u16 product; 1971 u16 product;
1974 int ret_val; 1972 int ret_val;
@@ -1999,29 +1997,6 @@ static int mos7720_startup(struct usb_serial *serial)
1999 serial->port[1]->interrupt_in_buffer = NULL; 1997 serial->port[1]->interrupt_in_buffer = NULL;
2000 } 1998 }
2001 1999
2002
2003 /* set up serial port private structures */
2004 for (i = 0; i < serial->num_ports; ++i) {
2005 mos7720_port = kzalloc(sizeof(struct moschip_port), GFP_KERNEL);
2006 if (mos7720_port == NULL) {
2007 dev_err(&dev->dev, "%s - Out of memory\n", __func__);
2008 return -ENOMEM;
2009 }
2010
2011 /* Initialize all port interrupt end point to port 0 int
2012 * endpoint. Our device has only one interrupt endpoint
2013 * common to all ports */
2014 serial->port[i]->interrupt_in_endpointAddress =
2015 serial->port[0]->interrupt_in_endpointAddress;
2016
2017 mos7720_port->port = serial->port[i];
2018 usb_set_serial_port_data(serial->port[i], mos7720_port);
2019
2020 dev_dbg(&dev->dev, "port number is %d\n", serial->port[i]->number);
2021 dev_dbg(&dev->dev, "serial number is %d\n", serial->minor);
2022 }
2023
2024
2025 /* setting configuration feature to one */ 2000 /* setting configuration feature to one */
2026 usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), 2001 usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
2027 (__u8)0x03, 0x00, 0x01, 0x00, NULL, 0x00, 5*HZ); 2002 (__u8)0x03, 0x00, 0x01, 0x00, NULL, 0x00, 5*HZ);
@@ -2049,8 +2024,6 @@ static int mos7720_startup(struct usb_serial *serial)
2049 2024
2050static void mos7720_release(struct usb_serial *serial) 2025static void mos7720_release(struct usb_serial *serial)
2051{ 2026{
2052 int i;
2053
2054#ifdef CONFIG_USB_SERIAL_MOS7715_PARPORT 2027#ifdef CONFIG_USB_SERIAL_MOS7715_PARPORT
2055 /* close the parallel port */ 2028 /* close the parallel port */
2056 2029
@@ -2089,9 +2062,36 @@ static void mos7720_release(struct usb_serial *serial)
2089 kref_put(&mos_parport->ref_count, destroy_mos_parport); 2062 kref_put(&mos_parport->ref_count, destroy_mos_parport);
2090 } 2063 }
2091#endif 2064#endif
2092 /* free private structure allocated for serial port */ 2065}
2093 for (i = 0; i < serial->num_ports; ++i) 2066
2094 kfree(usb_get_serial_port_data(serial->port[i])); 2067static int mos7720_port_probe(struct usb_serial_port *port)
2068{
2069 struct moschip_port *mos7720_port;
2070
2071 mos7720_port = kzalloc(sizeof(*mos7720_port), GFP_KERNEL);
2072 if (!mos7720_port)
2073 return -ENOMEM;
2074
2075 /* Initialize all port interrupt end point to port 0 int endpoint.
2076 * Our device has only one interrupt endpoint common to all ports.
2077 */
2078 port->interrupt_in_endpointAddress =
2079 port->serial->port[0]->interrupt_in_endpointAddress;
2080 mos7720_port->port = port;
2081
2082 usb_set_serial_port_data(port, mos7720_port);
2083
2084 return 0;
2085}
2086
2087static int mos7720_port_remove(struct usb_serial_port *port)
2088{
2089 struct moschip_port *mos7720_port;
2090
2091 mos7720_port = usb_get_serial_port_data(port);
2092 kfree(mos7720_port);
2093
2094 return 0;
2095} 2095}
2096 2096
2097static struct usb_serial_driver moschip7720_2port_driver = { 2097static struct usb_serial_driver moschip7720_2port_driver = {
@@ -2109,6 +2109,8 @@ static struct usb_serial_driver moschip7720_2port_driver = {
2109 .probe = mos77xx_probe, 2109 .probe = mos77xx_probe,
2110 .attach = mos7720_startup, 2110 .attach = mos7720_startup,
2111 .release = mos7720_release, 2111 .release = mos7720_release,
2112 .port_probe = mos7720_port_probe,
2113 .port_remove = mos7720_port_remove,
2112 .ioctl = mos7720_ioctl, 2114 .ioctl = mos7720_ioctl,
2113 .tiocmget = mos7720_tiocmget, 2115 .tiocmget = mos7720_tiocmget,
2114 .tiocmset = mos7720_tiocmset, 2116 .tiocmset = mos7720_tiocmset,
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index d6d4eeca8c6..1cf3375ec1a 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -218,12 +218,10 @@ struct moschip_port {
218 int port_num; /*Actual port number in the device(1,2,etc) */ 218 int port_num; /*Actual port number in the device(1,2,etc) */
219 struct urb *write_urb; /* write URB for this port */ 219 struct urb *write_urb; /* write URB for this port */
220 struct urb *read_urb; /* read URB for this port */ 220 struct urb *read_urb; /* read URB for this port */
221 struct urb *int_urb;
222 __u8 shadowLCR; /* last LCR value received */ 221 __u8 shadowLCR; /* last LCR value received */
223 __u8 shadowMCR; /* last MCR value received */ 222 __u8 shadowMCR; /* last MCR value received */
224 char open; 223 char open;
225 char open_ports; 224 char open_ports;
226 char zombie;
227 wait_queue_head_t wait_chase; /* for handling sleeping while waiting for chase to finish */ 225 wait_queue_head_t wait_chase; /* for handling sleeping while waiting for chase to finish */
228 wait_queue_head_t delta_msr_wait; /* for handling sleeping while waiting for msr change to happen */ 226 wait_queue_head_t delta_msr_wait; /* for handling sleeping while waiting for msr change to happen */
229 int delta_msr_cond; 227 int delta_msr_cond;
@@ -478,7 +476,6 @@ static void mos7840_control_callback(struct urb *urb)
478 struct moschip_port *mos7840_port; 476 struct moschip_port *mos7840_port;
479 struct device *dev = &urb->dev->dev; 477 struct device *dev = &urb->dev->dev;
480 __u8 regval = 0x0; 478 __u8 regval = 0x0;
481 int result = 0;
482 int status = urb->status; 479 int status = urb->status;
483 480
484 mos7840_port = urb->context; 481 mos7840_port = urb->context;
@@ -495,7 +492,7 @@ static void mos7840_control_callback(struct urb *urb)
495 return; 492 return;
496 default: 493 default:
497 dev_dbg(dev, "%s - nonzero urb status received: %d\n", __func__, status); 494 dev_dbg(dev, "%s - nonzero urb status received: %d\n", __func__, status);
498 goto exit; 495 return;
499 } 496 }
500 497
501 dev_dbg(dev, "%s urb buffer size is %d\n", __func__, urb->actual_length); 498 dev_dbg(dev, "%s urb buffer size is %d\n", __func__, urb->actual_length);
@@ -508,16 +505,6 @@ static void mos7840_control_callback(struct urb *urb)
508 mos7840_handle_new_msr(mos7840_port, regval); 505 mos7840_handle_new_msr(mos7840_port, regval);
509 else if (mos7840_port->MsrLsr == 1) 506 else if (mos7840_port->MsrLsr == 1)
510 mos7840_handle_new_lsr(mos7840_port, regval); 507 mos7840_handle_new_lsr(mos7840_port, regval);
511
512exit:
513 spin_lock(&mos7840_port->pool_lock);
514 if (!mos7840_port->zombie)
515 result = usb_submit_urb(mos7840_port->int_urb, GFP_ATOMIC);
516 spin_unlock(&mos7840_port->pool_lock);
517 if (result) {
518 dev_err(dev, "%s - Error %d submitting interrupt urb\n",
519 __func__, result);
520 }
521} 508}
522 509
523static int mos7840_get_reg(struct moschip_port *mcs, __u16 Wval, __u16 reg, 510static int mos7840_get_reg(struct moschip_port *mcs, __u16 Wval, __u16 reg,
@@ -686,14 +673,7 @@ static void mos7840_interrupt_callback(struct urb *urb)
686 wreg = MODEM_STATUS_REGISTER; 673 wreg = MODEM_STATUS_REGISTER;
687 break; 674 break;
688 } 675 }
689 spin_lock(&mos7840_port->pool_lock); 676 rv = mos7840_get_reg(mos7840_port, wval, wreg, &Data);
690 if (!mos7840_port->zombie) {
691 rv = mos7840_get_reg(mos7840_port, wval, wreg, &Data);
692 } else {
693 spin_unlock(&mos7840_port->pool_lock);
694 return;
695 }
696 spin_unlock(&mos7840_port->pool_lock);
697 } 677 }
698 } 678 }
699 } 679 }
@@ -2347,309 +2327,249 @@ static int mos7840_calc_num_ports(struct usb_serial *serial)
2347 return mos7840_num_ports; 2327 return mos7840_num_ports;
2348} 2328}
2349 2329
2350/**************************************************************************** 2330static int mos7840_port_probe(struct usb_serial_port *port)
2351 * mos7840_startup
2352 ****************************************************************************/
2353
2354static int mos7840_startup(struct usb_serial *serial)
2355{ 2331{
2332 struct usb_serial *serial = port->serial;
2356 struct moschip_port *mos7840_port; 2333 struct moschip_port *mos7840_port;
2357 struct usb_device *dev; 2334 int status;
2358 int i, status; 2335 int pnum;
2359 __u16 Data; 2336 __u16 Data;
2360 2337
2361 dev = serial->dev;
2362
2363 /* we set up the pointers to the endpoints in the mos7840_open * 2338 /* we set up the pointers to the endpoints in the mos7840_open *
2364 * function, as the structures aren't created yet. */ 2339 * function, as the structures aren't created yet. */
2365 2340
2366 /* set up port private structures */ 2341 pnum = port->number - serial->minor;
2367 for (i = 0; i < serial->num_ports; ++i) {
2368 dev_dbg(&dev->dev, "mos7840_startup: configuring port %d............\n", i);
2369 mos7840_port = kzalloc(sizeof(struct moschip_port), GFP_KERNEL);
2370 if (mos7840_port == NULL) {
2371 dev_err(&dev->dev, "%s - Out of memory\n", __func__);
2372 status = -ENOMEM;
2373 i--; /* don't follow NULL pointer cleaning up */
2374 goto error;
2375 }
2376
2377 /* Initialize all port interrupt end point to port 0 int
2378 * endpoint. Our device has only one interrupt end point
2379 * common to all port */
2380
2381 mos7840_port->port = serial->port[i];
2382 mos7840_set_port_private(serial->port[i], mos7840_port);
2383 spin_lock_init(&mos7840_port->pool_lock);
2384
2385 /* minor is not initialised until later by
2386 * usb-serial.c:get_free_serial() and cannot therefore be used
2387 * to index device instances */
2388 mos7840_port->port_num = i + 1;
2389 dev_dbg(&dev->dev, "serial->port[i]->number = %d\n", serial->port[i]->number);
2390 dev_dbg(&dev->dev, "serial->port[i]->serial->minor = %d\n", serial->port[i]->serial->minor);
2391 dev_dbg(&dev->dev, "mos7840_port->port_num = %d\n", mos7840_port->port_num);
2392 dev_dbg(&dev->dev, "serial->minor = %d\n", serial->minor);
2393
2394 if (mos7840_port->port_num == 1) {
2395 mos7840_port->SpRegOffset = 0x0;
2396 mos7840_port->ControlRegOffset = 0x1;
2397 mos7840_port->DcrRegOffset = 0x4;
2398 } else if ((mos7840_port->port_num == 2)
2399 && (serial->num_ports == 4)) {
2400 mos7840_port->SpRegOffset = 0x8;
2401 mos7840_port->ControlRegOffset = 0x9;
2402 mos7840_port->DcrRegOffset = 0x16;
2403 } else if ((mos7840_port->port_num == 2)
2404 && (serial->num_ports == 2)) {
2405 mos7840_port->SpRegOffset = 0xa;
2406 mos7840_port->ControlRegOffset = 0xb;
2407 mos7840_port->DcrRegOffset = 0x19;
2408 } else if ((mos7840_port->port_num == 3)
2409 && (serial->num_ports == 4)) {
2410 mos7840_port->SpRegOffset = 0xa;
2411 mos7840_port->ControlRegOffset = 0xb;
2412 mos7840_port->DcrRegOffset = 0x19;
2413 } else if ((mos7840_port->port_num == 4)
2414 && (serial->num_ports == 4)) {
2415 mos7840_port->SpRegOffset = 0xc;
2416 mos7840_port->ControlRegOffset = 0xd;
2417 mos7840_port->DcrRegOffset = 0x1c;
2418 }
2419 mos7840_dump_serial_port(serial->port[i], mos7840_port);
2420 mos7840_set_port_private(serial->port[i], mos7840_port);
2421 2342
2422 /* enable rx_disable bit in control register */ 2343 dev_dbg(&port->dev, "mos7840_startup: configuring port %d\n", pnum);
2423 status = mos7840_get_reg_sync(serial->port[i], 2344 mos7840_port = kzalloc(sizeof(struct moschip_port), GFP_KERNEL);
2424 mos7840_port->ControlRegOffset, &Data); 2345 if (mos7840_port == NULL) {
2425 if (status < 0) { 2346 dev_err(&port->dev, "%s - Out of memory\n", __func__);
2426 dev_dbg(&dev->dev, "Reading ControlReg failed status-0x%x\n", status); 2347 return -ENOMEM;
2427 break; 2348 }
2428 } else
2429 dev_dbg(&dev->dev, "ControlReg Reading success val is %x, status%d\n", Data, status);
2430 Data |= 0x08; /* setting driver done bit */
2431 Data |= 0x04; /* sp1_bit to have cts change reflect in
2432 modem status reg */
2433
2434 /* Data |= 0x20; //rx_disable bit */
2435 status = mos7840_set_reg_sync(serial->port[i],
2436 mos7840_port->ControlRegOffset, Data);
2437 if (status < 0) {
2438 dev_dbg(&dev->dev, "Writing ControlReg failed(rx_disable) status-0x%x\n", status);
2439 break;
2440 } else
2441 dev_dbg(&dev->dev, "ControlReg Writing success(rx_disable) status%d\n", status);
2442 2349
2443 /* Write default values in DCR (i.e 0x01 in DCR0, 0x05 in DCR2 2350 /* Initialize all port interrupt end point to port 0 int
2444 and 0x24 in DCR3 */ 2351 * endpoint. Our device has only one interrupt end point
2445 Data = 0x01; 2352 * common to all port */
2446 status = mos7840_set_reg_sync(serial->port[i], 2353
2447 (__u16) (mos7840_port->DcrRegOffset + 0), Data); 2354 mos7840_port->port = port;
2448 if (status < 0) { 2355 mos7840_set_port_private(port, mos7840_port);
2449 dev_dbg(&dev->dev, "Writing DCR0 failed status-0x%x\n", status); 2356 spin_lock_init(&mos7840_port->pool_lock);
2450 break; 2357
2451 } else 2358 /* minor is not initialised until later by
2452 dev_dbg(&dev->dev, "DCR0 Writing success status%d\n", status); 2359 * usb-serial.c:get_free_serial() and cannot therefore be used
2360 * to index device instances */
2361 mos7840_port->port_num = pnum + 1;
2362 dev_dbg(&port->dev, "port->number = %d\n", port->number);
2363 dev_dbg(&port->dev, "port->serial->minor = %d\n", port->serial->minor);
2364 dev_dbg(&port->dev, "mos7840_port->port_num = %d\n", mos7840_port->port_num);
2365 dev_dbg(&port->dev, "serial->minor = %d\n", serial->minor);
2366
2367 if (mos7840_port->port_num == 1) {
2368 mos7840_port->SpRegOffset = 0x0;
2369 mos7840_port->ControlRegOffset = 0x1;
2370 mos7840_port->DcrRegOffset = 0x4;
2371 } else if ((mos7840_port->port_num == 2) && (serial->num_ports == 4)) {
2372 mos7840_port->SpRegOffset = 0x8;
2373 mos7840_port->ControlRegOffset = 0x9;
2374 mos7840_port->DcrRegOffset = 0x16;
2375 } else if ((mos7840_port->port_num == 2) && (serial->num_ports == 2)) {
2376 mos7840_port->SpRegOffset = 0xa;
2377 mos7840_port->ControlRegOffset = 0xb;
2378 mos7840_port->DcrRegOffset = 0x19;
2379 } else if ((mos7840_port->port_num == 3) && (serial->num_ports == 4)) {
2380 mos7840_port->SpRegOffset = 0xa;
2381 mos7840_port->ControlRegOffset = 0xb;
2382 mos7840_port->DcrRegOffset = 0x19;
2383 } else if ((mos7840_port->port_num == 4) && (serial->num_ports == 4)) {
2384 mos7840_port->SpRegOffset = 0xc;
2385 mos7840_port->ControlRegOffset = 0xd;
2386 mos7840_port->DcrRegOffset = 0x1c;
2387 }
2388 mos7840_dump_serial_port(port, mos7840_port);
2389 mos7840_set_port_private(port, mos7840_port);
2390
2391 /* enable rx_disable bit in control register */
2392 status = mos7840_get_reg_sync(port,
2393 mos7840_port->ControlRegOffset, &Data);
2394 if (status < 0) {
2395 dev_dbg(&port->dev, "Reading ControlReg failed status-0x%x\n", status);
2396 goto out;
2397 } else
2398 dev_dbg(&port->dev, "ControlReg Reading success val is %x, status%d\n", Data, status);
2399 Data |= 0x08; /* setting driver done bit */
2400 Data |= 0x04; /* sp1_bit to have cts change reflect in
2401 modem status reg */
2453 2402
2454 Data = 0x05; 2403 /* Data |= 0x20; //rx_disable bit */
2455 status = mos7840_set_reg_sync(serial->port[i], 2404 status = mos7840_set_reg_sync(port,
2456 (__u16) (mos7840_port->DcrRegOffset + 1), Data); 2405 mos7840_port->ControlRegOffset, Data);
2457 if (status < 0) { 2406 if (status < 0) {
2458 dev_dbg(&dev->dev, "Writing DCR1 failed status-0x%x\n", status); 2407 dev_dbg(&port->dev, "Writing ControlReg failed(rx_disable) status-0x%x\n", status);
2459 break; 2408 goto out;
2460 } else 2409 } else
2461 dev_dbg(&dev->dev, "DCR1 Writing success status%d\n", status); 2410 dev_dbg(&port->dev, "ControlReg Writing success(rx_disable) status%d\n", status);
2462 2411
2463 Data = 0x24; 2412 /* Write default values in DCR (i.e 0x01 in DCR0, 0x05 in DCR2
2464 status = mos7840_set_reg_sync(serial->port[i], 2413 and 0x24 in DCR3 */
2465 (__u16) (mos7840_port->DcrRegOffset + 2), Data); 2414 Data = 0x01;
2466 if (status < 0) { 2415 status = mos7840_set_reg_sync(port,
2467 dev_dbg(&dev->dev, "Writing DCR2 failed status-0x%x\n", status); 2416 (__u16) (mos7840_port->DcrRegOffset + 0), Data);
2468 break; 2417 if (status < 0) {
2469 } else 2418 dev_dbg(&port->dev, "Writing DCR0 failed status-0x%x\n", status);
2470 dev_dbg(&dev->dev, "DCR2 Writing success status%d\n", status); 2419 goto out;
2420 } else
2421 dev_dbg(&port->dev, "DCR0 Writing success status%d\n", status);
2471 2422
2472 /* write values in clkstart0x0 and clkmulti 0x20 */ 2423 Data = 0x05;
2473 Data = 0x0; 2424 status = mos7840_set_reg_sync(port,
2474 status = mos7840_set_reg_sync(serial->port[i], 2425 (__u16) (mos7840_port->DcrRegOffset + 1), Data);
2475 CLK_START_VALUE_REGISTER, Data); 2426 if (status < 0) {
2476 if (status < 0) { 2427 dev_dbg(&port->dev, "Writing DCR1 failed status-0x%x\n", status);
2477 dev_dbg(&dev->dev, "Writing CLK_START_VALUE_REGISTER failed status-0x%x\n", status); 2428 goto out;
2478 break; 2429 } else
2479 } else 2430 dev_dbg(&port->dev, "DCR1 Writing success status%d\n", status);
2480 dev_dbg(&dev->dev, "CLK_START_VALUE_REGISTER Writing success status%d\n", status);
2481 2431
2482 Data = 0x20; 2432 Data = 0x24;
2483 status = mos7840_set_reg_sync(serial->port[i], 2433 status = mos7840_set_reg_sync(port,
2484 CLK_MULTI_REGISTER, Data); 2434 (__u16) (mos7840_port->DcrRegOffset + 2), Data);
2485 if (status < 0) { 2435 if (status < 0) {
2486 dev_dbg(&dev->dev, "Writing CLK_MULTI_REGISTER failed status-0x%x\n", status); 2436 dev_dbg(&port->dev, "Writing DCR2 failed status-0x%x\n", status);
2487 goto error; 2437 goto out;
2488 } else 2438 } else
2489 dev_dbg(&dev->dev, "CLK_MULTI_REGISTER Writing success status%d\n", status); 2439 dev_dbg(&port->dev, "DCR2 Writing success status%d\n", status);
2490 2440
2491 /* write value 0x0 to scratchpad register */ 2441 /* write values in clkstart0x0 and clkmulti 0x20 */
2492 Data = 0x00; 2442 Data = 0x0;
2493 status = mos7840_set_uart_reg(serial->port[i], 2443 status = mos7840_set_reg_sync(port, CLK_START_VALUE_REGISTER, Data);
2494 SCRATCH_PAD_REGISTER, Data); 2444 if (status < 0) {
2495 if (status < 0) { 2445 dev_dbg(&port->dev, "Writing CLK_START_VALUE_REGISTER failed status-0x%x\n", status);
2496 dev_dbg(&dev->dev, "Writing SCRATCH_PAD_REGISTER failed status-0x%x\n", status); 2446 goto out;
2497 break; 2447 } else
2498 } else 2448 dev_dbg(&port->dev, "CLK_START_VALUE_REGISTER Writing success status%d\n", status);
2499 dev_dbg(&dev->dev, "SCRATCH_PAD_REGISTER Writing success status%d\n", status);
2500 2449
2501 /* Zero Length flag register */ 2450 Data = 0x20;
2502 if ((mos7840_port->port_num != 1) 2451 status = mos7840_set_reg_sync(port, CLK_MULTI_REGISTER, Data);
2503 && (serial->num_ports == 2)) { 2452 if (status < 0) {
2453 dev_dbg(&port->dev, "Writing CLK_MULTI_REGISTER failed status-0x%x\n", status);
2454 goto error;
2455 } else
2456 dev_dbg(&port->dev, "CLK_MULTI_REGISTER Writing success status%d\n", status);
2504 2457
2505 Data = 0xff; 2458 /* write value 0x0 to scratchpad register */
2506 status = mos7840_set_reg_sync(serial->port[i], 2459 Data = 0x00;
2507 (__u16) (ZLP_REG1 + 2460 status = mos7840_set_uart_reg(port, SCRATCH_PAD_REGISTER, Data);
2508 ((__u16)mos7840_port->port_num)), Data); 2461 if (status < 0) {
2509 dev_dbg(&dev->dev, "ZLIP offset %x\n", 2462 dev_dbg(&port->dev, "Writing SCRATCH_PAD_REGISTER failed status-0x%x\n", status);
2463 goto out;
2464 } else
2465 dev_dbg(&port->dev, "SCRATCH_PAD_REGISTER Writing success status%d\n", status);
2466
2467 /* Zero Length flag register */
2468 if ((mos7840_port->port_num != 1) && (serial->num_ports == 2)) {
2469 Data = 0xff;
2470 status = mos7840_set_reg_sync(port,
2471 (__u16) (ZLP_REG1 +
2472 ((__u16)mos7840_port->port_num)), Data);
2473 dev_dbg(&port->dev, "ZLIP offset %x\n",
2510 (__u16)(ZLP_REG1 + ((__u16) mos7840_port->port_num))); 2474 (__u16)(ZLP_REG1 + ((__u16) mos7840_port->port_num)));
2511 if (status < 0) { 2475 if (status < 0) {
2512 dev_dbg(&dev->dev, "Writing ZLP_REG%d failed status-0x%x\n", i + 2, status); 2476 dev_dbg(&port->dev, "Writing ZLP_REG%d failed status-0x%x\n", pnum + 2, status);
2513 break; 2477 goto out;
2514 } else 2478 } else
2515 dev_dbg(&dev->dev, "ZLP_REG%d Writing success status%d\n", i + 2, status); 2479 dev_dbg(&port->dev, "ZLP_REG%d Writing success status%d\n", pnum + 2, status);
2516 } else { 2480 } else {
2517 Data = 0xff; 2481 Data = 0xff;
2518 status = mos7840_set_reg_sync(serial->port[i], 2482 status = mos7840_set_reg_sync(port,
2519 (__u16) (ZLP_REG1 + 2483 (__u16) (ZLP_REG1 +
2520 ((__u16)mos7840_port->port_num) - 0x1), Data); 2484 ((__u16)mos7840_port->port_num) - 0x1), Data);
2521 dev_dbg(&dev->dev, "ZLIP offset %x\n", 2485 dev_dbg(&port->dev, "ZLIP offset %x\n",
2522 (__u16)(ZLP_REG1 + ((__u16) mos7840_port->port_num) - 0x1)); 2486 (__u16)(ZLP_REG1 + ((__u16) mos7840_port->port_num) - 0x1));
2523 if (status < 0) { 2487 if (status < 0) {
2524 dev_dbg(&dev->dev, "Writing ZLP_REG%d failed status-0x%x\n", i + 1, status); 2488 dev_dbg(&port->dev, "Writing ZLP_REG%d failed status-0x%x\n", pnum + 1, status);
2525 break; 2489 goto out;
2526 } else 2490 } else
2527 dev_dbg(&dev->dev, "ZLP_REG%d Writing success status%d\n", i + 1, status); 2491 dev_dbg(&port->dev, "ZLP_REG%d Writing success status%d\n", pnum + 1, status);
2528 2492
2529 } 2493 }
2530 mos7840_port->control_urb = usb_alloc_urb(0, GFP_KERNEL); 2494 mos7840_port->control_urb = usb_alloc_urb(0, GFP_KERNEL);
2531 mos7840_port->ctrl_buf = kmalloc(16, GFP_KERNEL); 2495 mos7840_port->ctrl_buf = kmalloc(16, GFP_KERNEL);
2532 mos7840_port->dr = kmalloc(sizeof(struct usb_ctrlrequest), 2496 mos7840_port->dr = kmalloc(sizeof(struct usb_ctrlrequest),
2533 GFP_KERNEL); 2497 GFP_KERNEL);
2534 if (!mos7840_port->control_urb || !mos7840_port->ctrl_buf || 2498 if (!mos7840_port->control_urb || !mos7840_port->ctrl_buf ||
2535 !mos7840_port->dr) { 2499 !mos7840_port->dr) {
2536 status = -ENOMEM; 2500 status = -ENOMEM;
2537 goto error; 2501 goto error;
2538 } 2502 }
2539 2503
2540 mos7840_port->has_led = false; 2504 mos7840_port->has_led = false;
2541 2505
2542 /* Initialize LED timers */ 2506 /* Initialize LED timers */
2543 if (device_type == MOSCHIP_DEVICE_ID_7810) { 2507 if (device_type == MOSCHIP_DEVICE_ID_7810) {
2544 mos7840_port->has_led = true; 2508 mos7840_port->has_led = true;
2545 2509
2546 init_timer(&mos7840_port->led_timer1); 2510 init_timer(&mos7840_port->led_timer1);
2547 mos7840_port->led_timer1.function = mos7840_led_off; 2511 mos7840_port->led_timer1.function = mos7840_led_off;
2548 mos7840_port->led_timer1.expires = 2512 mos7840_port->led_timer1.expires =
2549 jiffies + msecs_to_jiffies(LED_ON_MS); 2513 jiffies + msecs_to_jiffies(LED_ON_MS);
2550 mos7840_port->led_timer1.data = 2514 mos7840_port->led_timer1.data = (unsigned long)mos7840_port;
2551 (unsigned long)mos7840_port;
2552 2515
2553 init_timer(&mos7840_port->led_timer2); 2516 init_timer(&mos7840_port->led_timer2);
2554 mos7840_port->led_timer2.function = 2517 mos7840_port->led_timer2.function = mos7840_led_flag_off;
2555 mos7840_led_flag_off; 2518 mos7840_port->led_timer2.expires =
2556 mos7840_port->led_timer2.expires = 2519 jiffies + msecs_to_jiffies(LED_OFF_MS);
2557 jiffies + msecs_to_jiffies(LED_OFF_MS); 2520 mos7840_port->led_timer2.data = (unsigned long)mos7840_port;
2558 mos7840_port->led_timer2.data =
2559 (unsigned long)mos7840_port;
2560 2521
2561 mos7840_port->led_flag = false; 2522 mos7840_port->led_flag = false;
2562 2523
2563 /* Turn off LED */ 2524 /* Turn off LED */
2564 mos7840_set_led_sync(serial->port[i], 2525 mos7840_set_led_sync(port, MODEM_CONTROL_REGISTER, 0x0300);
2565 MODEM_CONTROL_REGISTER, 0x0300);
2566 }
2567 } 2526 }
2527out:
2528 if (pnum == serial->num_ports - 1) {
2529 /* Zero Length flag enable */
2530 Data = 0x0f;
2531 status = mos7840_set_reg_sync(serial->port[0], ZLP_REG5, Data);
2532 if (status < 0) {
2533 dev_dbg(&port->dev, "Writing ZLP_REG5 failed status-0x%x\n", status);
2534 goto error;
2535 } else
2536 dev_dbg(&port->dev, "ZLP_REG5 Writing success status%d\n", status);
2568 2537
2569 /* Zero Length flag enable */ 2538 /* setting configuration feature to one */
2570 Data = 0x0f; 2539 usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
2571 status = mos7840_set_reg_sync(serial->port[0], ZLP_REG5, Data); 2540 0x03, 0x00, 0x01, 0x00, NULL, 0x00,
2572 if (status < 0) { 2541 MOS_WDR_TIMEOUT);
2573 dev_dbg(&dev->dev, "Writing ZLP_REG5 failed status-0x%x\n", status); 2542 }
2574 goto error;
2575 } else
2576 dev_dbg(&dev->dev, "ZLP_REG5 Writing success status%d\n", status);
2577
2578 /* setting configuration feature to one */
2579 usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
2580 (__u8) 0x03, 0x00, 0x01, 0x00, NULL, 0x00, MOS_WDR_TIMEOUT);
2581 return 0; 2543 return 0;
2582error: 2544error:
2583 for (/* nothing */; i >= 0; i--) { 2545 kfree(mos7840_port->dr);
2584 mos7840_port = mos7840_get_port_private(serial->port[i]); 2546 kfree(mos7840_port->ctrl_buf);
2547 usb_free_urb(mos7840_port->control_urb);
2548 kfree(mos7840_port);
2585 2549
2586 kfree(mos7840_port->dr);
2587 kfree(mos7840_port->ctrl_buf);
2588 usb_free_urb(mos7840_port->control_urb);
2589 kfree(mos7840_port);
2590 serial->port[i] = NULL;
2591 }
2592 return status; 2550 return status;
2593} 2551}
2594 2552
2595/**************************************************************************** 2553static int mos7840_port_remove(struct usb_serial_port *port)
2596 * mos7840_disconnect
2597 * This function is called whenever the device is removed from the usb bus.
2598 ****************************************************************************/
2599
2600static void mos7840_disconnect(struct usb_serial *serial)
2601{ 2554{
2602 int i;
2603 unsigned long flags;
2604 struct moschip_port *mos7840_port; 2555 struct moschip_port *mos7840_port;
2605 2556
2606 /* check for the ports to be closed,close the ports and disconnect */ 2557 mos7840_port = mos7840_get_port_private(port);
2607 2558
2608 /* free private structure allocated for serial port * 2559 if (mos7840_port->has_led) {
2609 * stop reads and writes on all ports */ 2560 /* Turn off LED */
2561 mos7840_set_led_sync(port, MODEM_CONTROL_REGISTER, 0x0300);
2610 2562
2611 for (i = 0; i < serial->num_ports; ++i) { 2563 del_timer_sync(&mos7840_port->led_timer1);
2612 mos7840_port = mos7840_get_port_private(serial->port[i]); 2564 del_timer_sync(&mos7840_port->led_timer2);
2613 if (mos7840_port) {
2614 spin_lock_irqsave(&mos7840_port->pool_lock, flags);
2615 mos7840_port->zombie = 1;
2616 spin_unlock_irqrestore(&mos7840_port->pool_lock, flags);
2617 usb_kill_urb(mos7840_port->control_urb);
2618 }
2619 } 2565 }
2620} 2566 usb_kill_urb(mos7840_port->control_urb);
2621 2567 usb_free_urb(mos7840_port->control_urb);
2622/**************************************************************************** 2568 kfree(mos7840_port->ctrl_buf);
2623 * mos7840_release 2569 kfree(mos7840_port->dr);
2624 * This function is called when the usb_serial structure is freed. 2570 kfree(mos7840_port);
2625 ****************************************************************************/
2626
2627static void mos7840_release(struct usb_serial *serial)
2628{
2629 int i;
2630 struct moschip_port *mos7840_port;
2631
2632 /* check for the ports to be closed,close the ports and disconnect */
2633 2571
2634 /* free private structure allocated for serial port * 2572 return 0;
2635 * stop reads and writes on all ports */
2636
2637 for (i = 0; i < serial->num_ports; ++i) {
2638 mos7840_port = mos7840_get_port_private(serial->port[i]);
2639 if (mos7840_port) {
2640 if (mos7840_port->has_led) {
2641 /* Turn off LED */
2642 mos7840_set_led_sync(mos7840_port->port,
2643 MODEM_CONTROL_REGISTER, 0x0300);
2644
2645 del_timer_sync(&mos7840_port->led_timer1);
2646 del_timer_sync(&mos7840_port->led_timer2);
2647 }
2648 kfree(mos7840_port->ctrl_buf);
2649 kfree(mos7840_port->dr);
2650 kfree(mos7840_port);
2651 }
2652 }
2653} 2573}
2654 2574
2655static struct usb_serial_driver moschip7840_4port_device = { 2575static struct usb_serial_driver moschip7840_4port_device = {
@@ -2677,9 +2597,8 @@ static struct usb_serial_driver moschip7840_4port_device = {
2677 .tiocmget = mos7840_tiocmget, 2597 .tiocmget = mos7840_tiocmget,
2678 .tiocmset = mos7840_tiocmset, 2598 .tiocmset = mos7840_tiocmset,
2679 .get_icount = mos7840_get_icount, 2599 .get_icount = mos7840_get_icount,
2680 .attach = mos7840_startup, 2600 .port_probe = mos7840_port_probe,
2681 .disconnect = mos7840_disconnect, 2601 .port_remove = mos7840_port_remove,
2682 .release = mos7840_release,
2683 .read_bulk_callback = mos7840_bulk_in_callback, 2602 .read_bulk_callback = mos7840_bulk_in_callback,
2684 .read_int_callback = mos7840_interrupt_callback, 2603 .read_int_callback = mos7840_interrupt_callback,
2685}; 2604};
diff --git a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c
index 6def58b7938..9ab73d29577 100644
--- a/drivers/usb/serial/omninet.c
+++ b/drivers/usb/serial/omninet.c
@@ -44,8 +44,8 @@ static int omninet_write(struct tty_struct *tty, struct usb_serial_port *port,
44 const unsigned char *buf, int count); 44 const unsigned char *buf, int count);
45static int omninet_write_room(struct tty_struct *tty); 45static int omninet_write_room(struct tty_struct *tty);
46static void omninet_disconnect(struct usb_serial *serial); 46static void omninet_disconnect(struct usb_serial *serial);
47static void omninet_release(struct usb_serial *serial); 47static int omninet_port_probe(struct usb_serial_port *port);
48static int omninet_attach(struct usb_serial *serial); 48static int omninet_port_remove(struct usb_serial_port *port);
49 49
50static const struct usb_device_id id_table[] = { 50static const struct usb_device_id id_table[] = {
51 { USB_DEVICE(ZYXEL_VENDOR_ID, ZYXEL_OMNINET_ID) }, 51 { USB_DEVICE(ZYXEL_VENDOR_ID, ZYXEL_OMNINET_ID) },
@@ -62,7 +62,8 @@ static struct usb_serial_driver zyxel_omninet_device = {
62 .description = "ZyXEL - omni.net lcd plus usb", 62 .description = "ZyXEL - omni.net lcd plus usb",
63 .id_table = id_table, 63 .id_table = id_table,
64 .num_ports = 1, 64 .num_ports = 1,
65 .attach = omninet_attach, 65 .port_probe = omninet_port_probe,
66 .port_remove = omninet_port_remove,
66 .open = omninet_open, 67 .open = omninet_open,
67 .close = omninet_close, 68 .close = omninet_close,
68 .write = omninet_write, 69 .write = omninet_write,
@@ -70,7 +71,6 @@ static struct usb_serial_driver zyxel_omninet_device = {
70 .read_bulk_callback = omninet_read_bulk_callback, 71 .read_bulk_callback = omninet_read_bulk_callback,
71 .write_bulk_callback = omninet_write_bulk_callback, 72 .write_bulk_callback = omninet_write_bulk_callback,
72 .disconnect = omninet_disconnect, 73 .disconnect = omninet_disconnect,
73 .release = omninet_release,
74}; 74};
75 75
76static struct usb_serial_driver * const serial_drivers[] = { 76static struct usb_serial_driver * const serial_drivers[] = {
@@ -112,18 +112,26 @@ struct omninet_data {
112 __u8 od_outseq; /* Sequence number for bulk_out URBs */ 112 __u8 od_outseq; /* Sequence number for bulk_out URBs */
113}; 113};
114 114
115static int omninet_attach(struct usb_serial *serial) 115static int omninet_port_probe(struct usb_serial_port *port)
116{ 116{
117 struct omninet_data *od; 117 struct omninet_data *od;
118 struct usb_serial_port *port = serial->port[0];
119 118
120 od = kmalloc(sizeof(struct omninet_data), GFP_KERNEL); 119 od = kmalloc(sizeof(struct omninet_data), GFP_KERNEL);
121 if (!od) { 120 if (!od)
122 dev_err(&port->dev, "%s- kmalloc(%Zd) failed.\n",
123 __func__, sizeof(struct omninet_data));
124 return -ENOMEM; 121 return -ENOMEM;
125 } 122
126 usb_set_serial_port_data(port, od); 123 usb_set_serial_port_data(port, od);
124
125 return 0;
126}
127
128static int omninet_port_remove(struct usb_serial_port *port)
129{
130 struct omninet_data *od;
131
132 od = usb_get_serial_port_data(port);
133 kfree(od);
134
127 return 0; 135 return 0;
128} 136}
129 137
@@ -279,14 +287,6 @@ static void omninet_disconnect(struct usb_serial *serial)
279 usb_kill_urb(wport->write_urb); 287 usb_kill_urb(wport->write_urb);
280} 288}
281 289
282
283static void omninet_release(struct usb_serial *serial)
284{
285 struct usb_serial_port *port = serial->port[0];
286
287 kfree(usb_get_serial_port_data(port));
288}
289
290module_usb_serial_driver(serial_drivers, id_table); 290module_usb_serial_driver(serial_drivers, id_table);
291 291
292MODULE_AUTHOR(DRIVER_AUTHOR); 292MODULE_AUTHOR(DRIVER_AUTHOR);
diff --git a/drivers/usb/serial/opticon.c b/drivers/usb/serial/opticon.c
index 41b1647306e..6aba731d486 100644
--- a/drivers/usb/serial/opticon.c
+++ b/drivers/usb/serial/opticon.c
@@ -155,7 +155,11 @@ static int send_control_msg(struct usb_serial_port *port, u8 requesttype,
155{ 155{
156 struct usb_serial *serial = port->serial; 156 struct usb_serial *serial = port->serial;
157 int retval; 157 int retval;
158 u8 buffer[2]; 158 u8 *buffer;
159
160 buffer = kzalloc(1, GFP_KERNEL);
161 if (!buffer)
162 return -ENOMEM;
159 163
160 buffer[0] = val; 164 buffer[0] = val;
161 /* Send the message to the vendor control endpoint 165 /* Send the message to the vendor control endpoint
@@ -164,6 +168,7 @@ static int send_control_msg(struct usb_serial_port *port, u8 requesttype,
164 requesttype, 168 requesttype,
165 USB_DIR_OUT|USB_TYPE_VENDOR|USB_RECIP_INTERFACE, 169 USB_DIR_OUT|USB_TYPE_VENDOR|USB_RECIP_INTERFACE,
166 0, 0, buffer, 1, 0); 170 0, 0, buffer, 1, 0);
171 kfree(buffer);
167 172
168 return retval; 173 return retval;
169} 174}
@@ -281,7 +286,7 @@ static int opticon_write(struct tty_struct *tty, struct usb_serial_port *port,
281 if (!dr) { 286 if (!dr) {
282 dev_err(&port->dev, "out of memory\n"); 287 dev_err(&port->dev, "out of memory\n");
283 count = -ENOMEM; 288 count = -ENOMEM;
284 goto error; 289 goto error_no_dr;
285 } 290 }
286 291
287 dr->bRequestType = USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT; 292 dr->bRequestType = USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT;
@@ -311,6 +316,8 @@ static int opticon_write(struct tty_struct *tty, struct usb_serial_port *port,
311 316
312 return count; 317 return count;
313error: 318error:
319 kfree(dr);
320error_no_dr:
314 usb_free_urb(urb); 321 usb_free_urb(urb);
315error_no_urb: 322error_no_urb:
316 kfree(buffer); 323 kfree(buffer);
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index 30cff03e9f0..edc64bb6f45 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -47,6 +47,7 @@
47/* Function prototypes */ 47/* Function prototypes */
48static int option_probe(struct usb_serial *serial, 48static int option_probe(struct usb_serial *serial,
49 const struct usb_device_id *id); 49 const struct usb_device_id *id);
50static int option_attach(struct usb_serial *serial);
50static void option_release(struct usb_serial *serial); 51static void option_release(struct usb_serial *serial);
51static int option_send_setup(struct usb_serial_port *port); 52static int option_send_setup(struct usb_serial_port *port);
52static void option_instat_callback(struct urb *urb); 53static void option_instat_callback(struct urb *urb);
@@ -157,6 +158,7 @@ static void option_instat_callback(struct urb *urb);
157#define NOVATELWIRELESS_PRODUCT_EVDO_EMBEDDED_HIGHSPEED 0x8001 158#define NOVATELWIRELESS_PRODUCT_EVDO_EMBEDDED_HIGHSPEED 0x8001
158#define NOVATELWIRELESS_PRODUCT_HSPA_EMBEDDED_FULLSPEED 0x9000 159#define NOVATELWIRELESS_PRODUCT_HSPA_EMBEDDED_FULLSPEED 0x9000
159#define NOVATELWIRELESS_PRODUCT_HSPA_EMBEDDED_HIGHSPEED 0x9001 160#define NOVATELWIRELESS_PRODUCT_HSPA_EMBEDDED_HIGHSPEED 0x9001
161#define NOVATELWIRELESS_PRODUCT_E362 0x9010
160#define NOVATELWIRELESS_PRODUCT_G1 0xA001 162#define NOVATELWIRELESS_PRODUCT_G1 0xA001
161#define NOVATELWIRELESS_PRODUCT_G1_M 0xA002 163#define NOVATELWIRELESS_PRODUCT_G1_M 0xA002
162#define NOVATELWIRELESS_PRODUCT_G2 0xA010 164#define NOVATELWIRELESS_PRODUCT_G2 0xA010
@@ -192,6 +194,9 @@ static void option_instat_callback(struct urb *urb);
192#define DELL_PRODUCT_5730_MINICARD_TELUS 0x8181 194#define DELL_PRODUCT_5730_MINICARD_TELUS 0x8181
193#define DELL_PRODUCT_5730_MINICARD_VZW 0x8182 195#define DELL_PRODUCT_5730_MINICARD_VZW 0x8182
194 196
197#define DELL_PRODUCT_5800_MINICARD_VZW 0x8195 /* Novatel E362 */
198#define DELL_PRODUCT_5800_V2_MINICARD_VZW 0x8196 /* Novatel E362 */
199
195#define KYOCERA_VENDOR_ID 0x0c88 200#define KYOCERA_VENDOR_ID 0x0c88
196#define KYOCERA_PRODUCT_KPC650 0x17da 201#define KYOCERA_PRODUCT_KPC650 0x17da
197#define KYOCERA_PRODUCT_KPC680 0x180a 202#define KYOCERA_PRODUCT_KPC680 0x180a
@@ -282,6 +287,7 @@ static void option_instat_callback(struct urb *urb);
282/* ALCATEL PRODUCTS */ 287/* ALCATEL PRODUCTS */
283#define ALCATEL_VENDOR_ID 0x1bbb 288#define ALCATEL_VENDOR_ID 0x1bbb
284#define ALCATEL_PRODUCT_X060S_X200 0x0000 289#define ALCATEL_PRODUCT_X060S_X200 0x0000
290#define ALCATEL_PRODUCT_X220_X500D 0x0017
285 291
286#define PIRELLI_VENDOR_ID 0x1266 292#define PIRELLI_VENDOR_ID 0x1266
287#define PIRELLI_PRODUCT_C100_1 0x1002 293#define PIRELLI_PRODUCT_C100_1 0x1002
@@ -503,11 +509,19 @@ static const struct option_blacklist_info net_intf5_blacklist = {
503 .reserved = BIT(5), 509 .reserved = BIT(5),
504}; 510};
505 511
512static const struct option_blacklist_info net_intf6_blacklist = {
513 .reserved = BIT(6),
514};
515
506static const struct option_blacklist_info zte_mf626_blacklist = { 516static const struct option_blacklist_info zte_mf626_blacklist = {
507 .sendsetup = BIT(0) | BIT(1), 517 .sendsetup = BIT(0) | BIT(1),
508 .reserved = BIT(4), 518 .reserved = BIT(4),
509}; 519};
510 520
521static const struct option_blacklist_info zte_1255_blacklist = {
522 .reserved = BIT(3) | BIT(4),
523};
524
511static const struct usb_device_id option_ids[] = { 525static const struct usb_device_id option_ids[] = {
512 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) }, 526 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) },
513 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) }, 527 { USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) },
@@ -697,6 +711,7 @@ static const struct usb_device_id option_ids[] = {
697 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_G2) }, 711 { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_G2) },
698 /* Novatel Ovation MC551 a.k.a. Verizon USB551L */ 712 /* Novatel Ovation MC551 a.k.a. Verizon USB551L */
699 { USB_DEVICE_AND_INTERFACE_INFO(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC551, 0xff, 0xff, 0xff) }, 713 { USB_DEVICE_AND_INTERFACE_INFO(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_MC551, 0xff, 0xff, 0xff) },
714 { USB_DEVICE_AND_INTERFACE_INFO(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_E362, 0xff, 0xff, 0xff) },
700 715
701 { USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_H01) }, 716 { USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_H01) },
702 { USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_H01A) }, 717 { USB_DEVICE(AMOI_VENDOR_ID, AMOI_PRODUCT_H01A) },
@@ -719,6 +734,8 @@ static const struct usb_device_id option_ids[] = {
719 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5730_MINICARD_SPRINT) }, /* Dell Wireless 5730 Mobile Broadband EVDO/HSPA Mini-Card */ 734 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5730_MINICARD_SPRINT) }, /* Dell Wireless 5730 Mobile Broadband EVDO/HSPA Mini-Card */
720 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5730_MINICARD_TELUS) }, /* Dell Wireless 5730 Mobile Broadband EVDO/HSPA Mini-Card */ 735 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5730_MINICARD_TELUS) }, /* Dell Wireless 5730 Mobile Broadband EVDO/HSPA Mini-Card */
721 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5730_MINICARD_VZW) }, /* Dell Wireless 5730 Mobile Broadband EVDO/HSPA Mini-Card */ 736 { USB_DEVICE(DELL_VENDOR_ID, DELL_PRODUCT_5730_MINICARD_VZW) }, /* Dell Wireless 5730 Mobile Broadband EVDO/HSPA Mini-Card */
737 { USB_DEVICE_AND_INTERFACE_INFO(DELL_VENDOR_ID, DELL_PRODUCT_5800_MINICARD_VZW, 0xff, 0xff, 0xff) },
738 { USB_DEVICE_AND_INTERFACE_INFO(DELL_VENDOR_ID, DELL_PRODUCT_5800_V2_MINICARD_VZW, 0xff, 0xff, 0xff) },
722 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_E100A) }, /* ADU-E100, ADU-310 */ 739 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_E100A) }, /* ADU-E100, ADU-310 */
723 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_500A) }, 740 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_500A) },
724 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_620UW) }, 741 { USB_DEVICE(ANYDATA_VENDOR_ID, ANYDATA_PRODUCT_ADU_620UW) },
@@ -853,13 +870,19 @@ static const struct usb_device_id option_ids[] = {
853 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0113, 0xff, 0xff, 0xff), 870 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0113, 0xff, 0xff, 0xff),
854 .driver_info = (kernel_ulong_t)&net_intf5_blacklist }, 871 .driver_info = (kernel_ulong_t)&net_intf5_blacklist },
855 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0117, 0xff, 0xff, 0xff) }, 872 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0117, 0xff, 0xff, 0xff) },
856 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0118, 0xff, 0xff, 0xff) }, 873 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0118, 0xff, 0xff, 0xff),
857 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0121, 0xff, 0xff, 0xff) }, 874 .driver_info = (kernel_ulong_t)&net_intf5_blacklist },
875 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0121, 0xff, 0xff, 0xff),
876 .driver_info = (kernel_ulong_t)&net_intf5_blacklist },
858 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0122, 0xff, 0xff, 0xff) }, 877 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0122, 0xff, 0xff, 0xff) },
859 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0123, 0xff, 0xff, 0xff) }, 878 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0123, 0xff, 0xff, 0xff),
860 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0124, 0xff, 0xff, 0xff) }, 879 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
861 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0125, 0xff, 0xff, 0xff) }, 880 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0124, 0xff, 0xff, 0xff),
862 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0126, 0xff, 0xff, 0xff) }, 881 .driver_info = (kernel_ulong_t)&net_intf5_blacklist },
882 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0125, 0xff, 0xff, 0xff),
883 .driver_info = (kernel_ulong_t)&net_intf6_blacklist },
884 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0126, 0xff, 0xff, 0xff),
885 .driver_info = (kernel_ulong_t)&net_intf5_blacklist },
863 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0128, 0xff, 0xff, 0xff) }, 886 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0128, 0xff, 0xff, 0xff) },
864 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0142, 0xff, 0xff, 0xff) }, 887 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0142, 0xff, 0xff, 0xff) },
865 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0143, 0xff, 0xff, 0xff) }, 888 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0143, 0xff, 0xff, 0xff) },
@@ -872,7 +895,8 @@ static const struct usb_device_id option_ids[] = {
872 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0156, 0xff, 0xff, 0xff) }, 895 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0156, 0xff, 0xff, 0xff) },
873 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0157, 0xff, 0xff, 0xff), 896 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0157, 0xff, 0xff, 0xff),
874 .driver_info = (kernel_ulong_t)&net_intf5_blacklist }, 897 .driver_info = (kernel_ulong_t)&net_intf5_blacklist },
875 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0158, 0xff, 0xff, 0xff) }, 898 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0158, 0xff, 0xff, 0xff),
899 .driver_info = (kernel_ulong_t)&net_intf3_blacklist },
876 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0159, 0xff, 0xff, 0xff) }, 900 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0159, 0xff, 0xff, 0xff) },
877 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0161, 0xff, 0xff, 0xff) }, 901 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0161, 0xff, 0xff, 0xff) },
878 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0162, 0xff, 0xff, 0xff) }, 902 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0162, 0xff, 0xff, 0xff) },
@@ -880,13 +904,22 @@ static const struct usb_device_id option_ids[] = {
880 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0165, 0xff, 0xff, 0xff) }, 904 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0165, 0xff, 0xff, 0xff) },
881 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0167, 0xff, 0xff, 0xff), 905 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0167, 0xff, 0xff, 0xff),
882 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 906 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
907 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0191, 0xff, 0xff, 0xff), /* ZTE EuFi890 */
908 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
909 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0199, 0xff, 0xff, 0xff), /* ZTE MF820S */
910 .driver_info = (kernel_ulong_t)&net_intf1_blacklist },
911 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0257, 0xff, 0xff, 0xff), /* ZTE MF821 */
912 .driver_info = (kernel_ulong_t)&net_intf3_blacklist },
883 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0326, 0xff, 0xff, 0xff), 913 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0326, 0xff, 0xff, 0xff),
884 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 914 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
885 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1008, 0xff, 0xff, 0xff), 915 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1008, 0xff, 0xff, 0xff),
886 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 916 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
887 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1010, 0xff, 0xff, 0xff), 917 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1010, 0xff, 0xff, 0xff),
888 .driver_info = (kernel_ulong_t)&net_intf4_blacklist }, 918 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
889 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1012, 0xff, 0xff, 0xff) }, 919 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1012, 0xff, 0xff, 0xff),
920 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
921 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1021, 0xff, 0xff, 0xff),
922 .driver_info = (kernel_ulong_t)&net_intf2_blacklist },
890 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1057, 0xff, 0xff, 0xff) }, 923 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1057, 0xff, 0xff, 0xff) },
891 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1058, 0xff, 0xff, 0xff) }, 924 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1058, 0xff, 0xff, 0xff) },
892 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1059, 0xff, 0xff, 0xff) }, 925 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1059, 0xff, 0xff, 0xff) },
@@ -1002,18 +1035,24 @@ static const struct usb_device_id option_ids[] = {
1002 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1169, 0xff, 0xff, 0xff) }, 1035 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1169, 0xff, 0xff, 0xff) },
1003 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1170, 0xff, 0xff, 0xff) }, 1036 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1170, 0xff, 0xff, 0xff) },
1004 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1244, 0xff, 0xff, 0xff) }, 1037 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1244, 0xff, 0xff, 0xff) },
1005 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1245, 0xff, 0xff, 0xff) }, 1038 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1245, 0xff, 0xff, 0xff),
1039 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
1006 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1246, 0xff, 0xff, 0xff) }, 1040 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1246, 0xff, 0xff, 0xff) },
1007 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1247, 0xff, 0xff, 0xff) }, 1041 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1247, 0xff, 0xff, 0xff),
1042 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
1008 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1248, 0xff, 0xff, 0xff) }, 1043 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1248, 0xff, 0xff, 0xff) },
1009 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1249, 0xff, 0xff, 0xff) }, 1044 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1249, 0xff, 0xff, 0xff) },
1010 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1250, 0xff, 0xff, 0xff) }, 1045 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1250, 0xff, 0xff, 0xff) },
1011 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1251, 0xff, 0xff, 0xff) }, 1046 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1251, 0xff, 0xff, 0xff) },
1012 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1252, 0xff, 0xff, 0xff) }, 1047 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1252, 0xff, 0xff, 0xff),
1048 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
1013 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1253, 0xff, 0xff, 0xff) }, 1049 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1253, 0xff, 0xff, 0xff) },
1014 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1254, 0xff, 0xff, 0xff) }, 1050 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1254, 0xff, 0xff, 0xff),
1015 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1255, 0xff, 0xff, 0xff) }, 1051 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
1016 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1256, 0xff, 0xff, 0xff) }, 1052 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1255, 0xff, 0xff, 0xff),
1053 .driver_info = (kernel_ulong_t)&zte_1255_blacklist },
1054 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1256, 0xff, 0xff, 0xff),
1055 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
1017 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1257, 0xff, 0xff, 0xff) }, 1056 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1257, 0xff, 0xff, 0xff) },
1018 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1258, 0xff, 0xff, 0xff) }, 1057 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1258, 0xff, 0xff, 0xff) },
1019 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1259, 0xff, 0xff, 0xff) }, 1058 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1259, 0xff, 0xff, 0xff) },
@@ -1058,8 +1097,16 @@ static const struct usb_device_id option_ids[] = {
1058 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1298, 0xff, 0xff, 0xff) }, 1097 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1298, 0xff, 0xff, 0xff) },
1059 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1299, 0xff, 0xff, 0xff) }, 1098 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1299, 0xff, 0xff, 0xff) },
1060 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1300, 0xff, 0xff, 0xff) }, 1099 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1300, 0xff, 0xff, 0xff) },
1100 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1401, 0xff, 0xff, 0xff),
1101 .driver_info = (kernel_ulong_t)&net_intf2_blacklist },
1061 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1402, 0xff, 0xff, 0xff), 1102 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1402, 0xff, 0xff, 0xff),
1062 .driver_info = (kernel_ulong_t)&net_intf2_blacklist }, 1103 .driver_info = (kernel_ulong_t)&net_intf2_blacklist },
1104 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1424, 0xff, 0xff, 0xff),
1105 .driver_info = (kernel_ulong_t)&net_intf2_blacklist },
1106 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1425, 0xff, 0xff, 0xff),
1107 .driver_info = (kernel_ulong_t)&net_intf2_blacklist },
1108 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1426, 0xff, 0xff, 0xff), /* ZTE MF91 */
1109 .driver_info = (kernel_ulong_t)&net_intf2_blacklist },
1063 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x2002, 0xff, 1110 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x2002, 0xff,
1064 0xff, 0xff), .driver_info = (kernel_ulong_t)&zte_k3765_z_blacklist }, 1111 0xff, 0xff), .driver_info = (kernel_ulong_t)&zte_k3765_z_blacklist },
1065 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x2003, 0xff, 0xff, 0xff) }, 1112 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x2003, 0xff, 0xff, 0xff) },
@@ -1071,15 +1118,21 @@ static const struct usb_device_id option_ids[] = {
1071 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0070, 0xff, 0xff, 0xff) }, 1118 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0070, 0xff, 0xff, 0xff) },
1072 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0073, 0xff, 0xff, 0xff) }, 1119 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0073, 0xff, 0xff, 0xff) },
1073 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0094, 0xff, 0xff, 0xff) }, 1120 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0094, 0xff, 0xff, 0xff) },
1074 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0130, 0xff, 0xff, 0xff) }, 1121 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0130, 0xff, 0xff, 0xff),
1075 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0133, 0xff, 0xff, 0xff) }, 1122 .driver_info = (kernel_ulong_t)&net_intf1_blacklist },
1076 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0141, 0xff, 0xff, 0xff) }, 1123 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0133, 0xff, 0xff, 0xff),
1124 .driver_info = (kernel_ulong_t)&net_intf3_blacklist },
1125 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0141, 0xff, 0xff, 0xff),
1126 .driver_info = (kernel_ulong_t)&net_intf5_blacklist },
1077 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0147, 0xff, 0xff, 0xff) }, 1127 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0147, 0xff, 0xff, 0xff) },
1078 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0152, 0xff, 0xff, 0xff) }, 1128 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0152, 0xff, 0xff, 0xff) },
1079 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0168, 0xff, 0xff, 0xff) }, 1129 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0168, 0xff, 0xff, 0xff),
1130 .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
1080 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0170, 0xff, 0xff, 0xff) }, 1131 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0170, 0xff, 0xff, 0xff) },
1081 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0176, 0xff, 0xff, 0xff) }, 1132 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0176, 0xff, 0xff, 0xff),
1082 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0178, 0xff, 0xff, 0xff) }, 1133 .driver_info = (kernel_ulong_t)&net_intf3_blacklist },
1134 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x0178, 0xff, 0xff, 0xff),
1135 .driver_info = (kernel_ulong_t)&net_intf3_blacklist },
1083 1136
1084 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_CDMA_TECH, 0xff, 0xff, 0xff) }, 1137 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_CDMA_TECH, 0xff, 0xff, 0xff) },
1085 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC8710, 0xff, 0xff, 0xff) }, 1138 { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, ZTE_PRODUCT_AC8710, 0xff, 0xff, 0xff) },
@@ -1112,6 +1165,7 @@ static const struct usb_device_id option_ids[] = {
1112 { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_X060S_X200), 1165 { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_X060S_X200),
1113 .driver_info = (kernel_ulong_t)&alcatel_x200_blacklist 1166 .driver_info = (kernel_ulong_t)&alcatel_x200_blacklist
1114 }, 1167 },
1168 { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_X220_X500D) },
1115 { USB_DEVICE(AIRPLUS_VENDOR_ID, AIRPLUS_PRODUCT_MCD650) }, 1169 { USB_DEVICE(AIRPLUS_VENDOR_ID, AIRPLUS_PRODUCT_MCD650) },
1116 { USB_DEVICE(TLAYTECH_VENDOR_ID, TLAYTECH_PRODUCT_TEU800) }, 1170 { USB_DEVICE(TLAYTECH_VENDOR_ID, TLAYTECH_PRODUCT_TEU800) },
1117 { USB_DEVICE(LONGCHEER_VENDOR_ID, FOUR_G_SYSTEMS_PRODUCT_W14), 1171 { USB_DEVICE(LONGCHEER_VENDOR_ID, FOUR_G_SYSTEMS_PRODUCT_W14),
@@ -1244,8 +1298,9 @@ static struct usb_serial_driver option_1port_device = {
1244 .tiocmget = usb_wwan_tiocmget, 1298 .tiocmget = usb_wwan_tiocmget,
1245 .tiocmset = usb_wwan_tiocmset, 1299 .tiocmset = usb_wwan_tiocmset,
1246 .ioctl = usb_wwan_ioctl, 1300 .ioctl = usb_wwan_ioctl,
1247 .attach = usb_wwan_startup, 1301 .attach = option_attach,
1248 .release = option_release, 1302 .release = option_release,
1303 .port_probe = usb_wwan_port_probe,
1249 .port_remove = usb_wwan_port_remove, 1304 .port_remove = usb_wwan_port_remove,
1250 .read_int_callback = option_instat_callback, 1305 .read_int_callback = option_instat_callback,
1251#ifdef CONFIG_PM 1306#ifdef CONFIG_PM
@@ -1291,8 +1346,6 @@ static bool is_blacklisted(const u8 ifnum, enum option_blacklist_reason reason,
1291static int option_probe(struct usb_serial *serial, 1346static int option_probe(struct usb_serial *serial,
1292 const struct usb_device_id *id) 1347 const struct usb_device_id *id)
1293{ 1348{
1294 struct usb_wwan_intf_private *data;
1295 struct option_private *priv;
1296 struct usb_interface_descriptor *iface_desc = 1349 struct usb_interface_descriptor *iface_desc =
1297 &serial->interface->cur_altsetting->desc; 1350 &serial->interface->cur_altsetting->desc;
1298 struct usb_device_descriptor *dev_desc = &serial->dev->descriptor; 1351 struct usb_device_descriptor *dev_desc = &serial->dev->descriptor;
@@ -1330,6 +1383,19 @@ static int option_probe(struct usb_serial *serial,
1330 iface_desc->bInterfaceClass != USB_CLASS_CDC_DATA) 1383 iface_desc->bInterfaceClass != USB_CLASS_CDC_DATA)
1331 return -ENODEV; 1384 return -ENODEV;
1332 1385
1386 /* Store device id so we can use it during attach. */
1387 usb_set_serial_data(serial, (void *)id);
1388
1389 return 0;
1390}
1391
1392static int option_attach(struct usb_serial *serial)
1393{
1394 struct usb_interface_descriptor *iface_desc;
1395 const struct usb_device_id *id;
1396 struct usb_wwan_intf_private *data;
1397 struct option_private *priv;
1398
1333 data = kzalloc(sizeof(struct usb_wwan_intf_private), GFP_KERNEL); 1399 data = kzalloc(sizeof(struct usb_wwan_intf_private), GFP_KERNEL);
1334 if (!data) 1400 if (!data)
1335 return -ENOMEM; 1401 return -ENOMEM;
@@ -1340,6 +1406,10 @@ static int option_probe(struct usb_serial *serial,
1340 return -ENOMEM; 1406 return -ENOMEM;
1341 } 1407 }
1342 1408
1409 /* Retrieve device id stored at probe. */
1410 id = usb_get_serial_data(serial);
1411 iface_desc = &serial->interface->cur_altsetting->desc;
1412
1343 priv->bInterfaceNumber = iface_desc->bInterfaceNumber; 1413 priv->bInterfaceNumber = iface_desc->bInterfaceNumber;
1344 data->private = priv; 1414 data->private = priv;
1345 1415
diff --git a/drivers/usb/serial/oti6858.c b/drivers/usb/serial/oti6858.c
index 933241f03fd..cee9a52ca89 100644
--- a/drivers/usb/serial/oti6858.c
+++ b/drivers/usb/serial/oti6858.c
@@ -137,8 +137,8 @@ static int oti6858_chars_in_buffer(struct tty_struct *tty);
137static int oti6858_tiocmget(struct tty_struct *tty); 137static int oti6858_tiocmget(struct tty_struct *tty);
138static int oti6858_tiocmset(struct tty_struct *tty, 138static int oti6858_tiocmset(struct tty_struct *tty,
139 unsigned int set, unsigned int clear); 139 unsigned int set, unsigned int clear);
140static int oti6858_startup(struct usb_serial *serial); 140static int oti6858_port_probe(struct usb_serial_port *port);
141static void oti6858_release(struct usb_serial *serial); 141static int oti6858_port_remove(struct usb_serial_port *port);
142 142
143/* device info */ 143/* device info */
144static struct usb_serial_driver oti6858_device = { 144static struct usb_serial_driver oti6858_device = {
@@ -161,8 +161,8 @@ static struct usb_serial_driver oti6858_device = {
161 .write_bulk_callback = oti6858_write_bulk_callback, 161 .write_bulk_callback = oti6858_write_bulk_callback,
162 .write_room = oti6858_write_room, 162 .write_room = oti6858_write_room,
163 .chars_in_buffer = oti6858_chars_in_buffer, 163 .chars_in_buffer = oti6858_chars_in_buffer,
164 .attach = oti6858_startup, 164 .port_probe = oti6858_port_probe,
165 .release = oti6858_release, 165 .port_remove = oti6858_port_remove,
166}; 166};
167 167
168static struct usb_serial_driver * const serial_drivers[] = { 168static struct usb_serial_driver * const serial_drivers[] = {
@@ -331,36 +331,33 @@ static void send_data(struct work_struct *work)
331 usb_serial_port_softint(port); 331 usb_serial_port_softint(port);
332} 332}
333 333
334static int oti6858_startup(struct usb_serial *serial) 334static int oti6858_port_probe(struct usb_serial_port *port)
335{ 335{
336 struct usb_serial_port *port = serial->port[0];
337 struct oti6858_private *priv; 336 struct oti6858_private *priv;
338 int i;
339
340 for (i = 0; i < serial->num_ports; ++i) {
341 priv = kzalloc(sizeof(struct oti6858_private), GFP_KERNEL);
342 if (!priv)
343 break;
344
345 spin_lock_init(&priv->lock);
346 init_waitqueue_head(&priv->intr_wait);
347/* INIT_WORK(&priv->setup_work, setup_line, serial->port[i]); */
348/* INIT_WORK(&priv->write_work, send_data, serial->port[i]); */
349 priv->port = port;
350 INIT_DELAYED_WORK(&priv->delayed_setup_work, setup_line);
351 INIT_DELAYED_WORK(&priv->delayed_write_work, send_data);
352
353 usb_set_serial_port_data(serial->port[i], priv);
354 }
355 if (i == serial->num_ports)
356 return 0;
357 337
358 for (--i; i >= 0; --i) { 338 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
359 priv = usb_get_serial_port_data(serial->port[i]); 339 if (!priv)
360 kfree(priv); 340 return -ENOMEM;
361 usb_set_serial_port_data(serial->port[i], NULL); 341
362 } 342 spin_lock_init(&priv->lock);
363 return -ENOMEM; 343 init_waitqueue_head(&priv->intr_wait);
344 priv->port = port;
345 INIT_DELAYED_WORK(&priv->delayed_setup_work, setup_line);
346 INIT_DELAYED_WORK(&priv->delayed_write_work, send_data);
347
348 usb_set_serial_port_data(port, priv);
349
350 return 0;
351}
352
353static int oti6858_port_remove(struct usb_serial_port *port)
354{
355 struct oti6858_private *priv;
356
357 priv = usb_get_serial_port_data(port);
358 kfree(priv);
359
360 return 0;
364} 361}
365 362
366static int oti6858_write(struct tty_struct *tty, struct usb_serial_port *port, 363static int oti6858_write(struct tty_struct *tty, struct usb_serial_port *port,
@@ -709,15 +706,6 @@ static int oti6858_ioctl(struct tty_struct *tty,
709 return -ENOIOCTLCMD; 706 return -ENOIOCTLCMD;
710} 707}
711 708
712
713static void oti6858_release(struct usb_serial *serial)
714{
715 int i;
716
717 for (i = 0; i < serial->num_ports; ++i)
718 kfree(usb_get_serial_port_data(serial->port[i]));
719}
720
721static void oti6858_read_int_callback(struct urb *urb) 709static void oti6858_read_int_callback(struct urb *urb)
722{ 710{
723 struct usb_serial_port *port = urb->context; 711 struct usb_serial_port *port = urb->context;
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index 892ebdc7a36..60024190136 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -133,12 +133,15 @@ enum pl2303_type {
133 HX, /* HX version of the pl2303 chip */ 133 HX, /* HX version of the pl2303 chip */
134}; 134};
135 135
136struct pl2303_serial_private {
137 enum pl2303_type type;
138};
139
136struct pl2303_private { 140struct pl2303_private {
137 spinlock_t lock; 141 spinlock_t lock;
138 wait_queue_head_t delta_msr_wait; 142 wait_queue_head_t delta_msr_wait;
139 u8 line_control; 143 u8 line_control;
140 u8 line_status; 144 u8 line_status;
141 enum pl2303_type type;
142}; 145};
143 146
144static int pl2303_vendor_read(__u16 value, __u16 index, 147static int pl2303_vendor_read(__u16 value, __u16 index,
@@ -167,14 +170,19 @@ static int pl2303_vendor_write(__u16 value, __u16 index,
167 170
168static int pl2303_startup(struct usb_serial *serial) 171static int pl2303_startup(struct usb_serial *serial)
169{ 172{
170 struct pl2303_private *priv; 173 struct pl2303_serial_private *spriv;
171 enum pl2303_type type = type_0; 174 enum pl2303_type type = type_0;
172 unsigned char *buf; 175 unsigned char *buf;
173 int i; 176
177 spriv = kzalloc(sizeof(*spriv), GFP_KERNEL);
178 if (!spriv)
179 return -ENOMEM;
174 180
175 buf = kmalloc(10, GFP_KERNEL); 181 buf = kmalloc(10, GFP_KERNEL);
176 if (buf == NULL) 182 if (!buf) {
183 kfree(spriv);
177 return -ENOMEM; 184 return -ENOMEM;
185 }
178 186
179 if (serial->dev->descriptor.bDeviceClass == 0x02) 187 if (serial->dev->descriptor.bDeviceClass == 0x02)
180 type = type_0; 188 type = type_0;
@@ -186,15 +194,8 @@ static int pl2303_startup(struct usb_serial *serial)
186 type = type_1; 194 type = type_1;
187 dev_dbg(&serial->interface->dev, "device type: %d\n", type); 195 dev_dbg(&serial->interface->dev, "device type: %d\n", type);
188 196
189 for (i = 0; i < serial->num_ports; ++i) { 197 spriv->type = type;
190 priv = kzalloc(sizeof(struct pl2303_private), GFP_KERNEL); 198 usb_set_serial_data(serial, spriv);
191 if (!priv)
192 goto cleanup;
193 spin_lock_init(&priv->lock);
194 init_waitqueue_head(&priv->delta_msr_wait);
195 priv->type = type;
196 usb_set_serial_port_data(serial->port[i], priv);
197 }
198 199
199 pl2303_vendor_read(0x8484, 0, serial, buf); 200 pl2303_vendor_read(0x8484, 0, serial, buf);
200 pl2303_vendor_write(0x0404, 0, serial); 201 pl2303_vendor_write(0x0404, 0, serial);
@@ -213,15 +214,40 @@ static int pl2303_startup(struct usb_serial *serial)
213 214
214 kfree(buf); 215 kfree(buf);
215 return 0; 216 return 0;
217}
216 218
217cleanup: 219static void pl2303_release(struct usb_serial *serial)
218 kfree(buf); 220{
219 for (--i; i >= 0; --i) { 221 struct pl2303_serial_private *spriv;
220 priv = usb_get_serial_port_data(serial->port[i]); 222
221 kfree(priv); 223 spriv = usb_get_serial_data(serial);
222 usb_set_serial_port_data(serial->port[i], NULL); 224 kfree(spriv);
223 } 225}
224 return -ENOMEM; 226
227static int pl2303_port_probe(struct usb_serial_port *port)
228{
229 struct pl2303_private *priv;
230
231 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
232 if (!priv)
233 return -ENOMEM;
234
235 spin_lock_init(&priv->lock);
236 init_waitqueue_head(&priv->delta_msr_wait);
237
238 usb_set_serial_port_data(port, priv);
239
240 return 0;
241}
242
243static int pl2303_port_remove(struct usb_serial_port *port)
244{
245 struct pl2303_private *priv;
246
247 priv = usb_get_serial_port_data(port);
248 kfree(priv);
249
250 return 0;
225} 251}
226 252
227static int set_control_lines(struct usb_device *dev, u8 value) 253static int set_control_lines(struct usb_device *dev, u8 value)
@@ -240,6 +266,7 @@ static void pl2303_set_termios(struct tty_struct *tty,
240 struct usb_serial_port *port, struct ktermios *old_termios) 266 struct usb_serial_port *port, struct ktermios *old_termios)
241{ 267{
242 struct usb_serial *serial = port->serial; 268 struct usb_serial *serial = port->serial;
269 struct pl2303_serial_private *spriv = usb_get_serial_data(serial);
243 struct pl2303_private *priv = usb_get_serial_port_data(port); 270 struct pl2303_private *priv = usb_get_serial_port_data(port);
244 unsigned long flags; 271 unsigned long flags;
245 unsigned int cflag; 272 unsigned int cflag;
@@ -323,7 +350,7 @@ static void pl2303_set_termios(struct tty_struct *tty,
323 } 350 }
324 if (baud > 1228800) { 351 if (baud > 1228800) {
325 /* type_0, type_1 only support up to 1228800 baud */ 352 /* type_0, type_1 only support up to 1228800 baud */
326 if (priv->type != HX) 353 if (spriv->type != HX)
327 baud = 1228800; 354 baud = 1228800;
328 else if (baud > 6000000) 355 else if (baud > 6000000)
329 baud = 6000000; 356 baud = 6000000;
@@ -426,7 +453,7 @@ static void pl2303_set_termios(struct tty_struct *tty,
426 buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6]); 453 buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6]);
427 454
428 if (cflag & CRTSCTS) { 455 if (cflag & CRTSCTS) {
429 if (priv->type == HX) 456 if (spriv->type == HX)
430 pl2303_vendor_write(0x0, 0x61, serial); 457 pl2303_vendor_write(0x0, 0x61, serial);
431 else 458 else
432 pl2303_vendor_write(0x0, 0x41, serial); 459 pl2303_vendor_write(0x0, 0x41, serial);
@@ -468,10 +495,10 @@ static int pl2303_open(struct tty_struct *tty, struct usb_serial_port *port)
468{ 495{
469 struct ktermios tmp_termios; 496 struct ktermios tmp_termios;
470 struct usb_serial *serial = port->serial; 497 struct usb_serial *serial = port->serial;
471 struct pl2303_private *priv = usb_get_serial_port_data(port); 498 struct pl2303_serial_private *spriv = usb_get_serial_data(serial);
472 int result; 499 int result;
473 500
474 if (priv->type != HX) { 501 if (spriv->type != HX) {
475 usb_clear_halt(serial->dev, port->write_urb->pipe); 502 usb_clear_halt(serial->dev, port->write_urb->pipe);
476 usb_clear_halt(serial->dev, port->read_urb->pipe); 503 usb_clear_halt(serial->dev, port->read_urb->pipe);
477 } else { 504 } else {
@@ -655,17 +682,6 @@ static void pl2303_break_ctl(struct tty_struct *tty, int break_state)
655 dev_err(&port->dev, "error sending break = %d\n", result); 682 dev_err(&port->dev, "error sending break = %d\n", result);
656} 683}
657 684
658static void pl2303_release(struct usb_serial *serial)
659{
660 int i;
661 struct pl2303_private *priv;
662
663 for (i = 0; i < serial->num_ports; ++i) {
664 priv = usb_get_serial_port_data(serial->port[i]);
665 kfree(priv);
666 }
667}
668
669static void pl2303_update_line_status(struct usb_serial_port *port, 685static void pl2303_update_line_status(struct usb_serial_port *port,
670 unsigned char *data, 686 unsigned char *data,
671 unsigned int actual_length) 687 unsigned int actual_length)
@@ -827,6 +843,8 @@ static struct usb_serial_driver pl2303_device = {
827 .read_int_callback = pl2303_read_int_callback, 843 .read_int_callback = pl2303_read_int_callback,
828 .attach = pl2303_startup, 844 .attach = pl2303_startup,
829 .release = pl2303_release, 845 .release = pl2303_release,
846 .port_probe = pl2303_port_probe,
847 .port_remove = pl2303_port_remove,
830}; 848};
831 849
832static struct usb_serial_driver * const serial_drivers[] = { 850static struct usb_serial_driver * const serial_drivers[] = {
diff --git a/drivers/usb/serial/qcserial.c b/drivers/usb/serial/qcserial.c
index c3ddb65c05f..aa148c21ea4 100644
--- a/drivers/usb/serial/qcserial.c
+++ b/drivers/usb/serial/qcserial.c
@@ -138,7 +138,6 @@ MODULE_DEVICE_TABLE(usb, id_table);
138 138
139static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id) 139static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)
140{ 140{
141 struct usb_wwan_intf_private *data;
142 struct usb_host_interface *intf = serial->interface->cur_altsetting; 141 struct usb_host_interface *intf = serial->interface->cur_altsetting;
143 struct device *dev = &serial->dev->dev; 142 struct device *dev = &serial->dev->dev;
144 int retval = -ENODEV; 143 int retval = -ENODEV;
@@ -154,13 +153,6 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)
154 ifnum = intf->desc.bInterfaceNumber; 153 ifnum = intf->desc.bInterfaceNumber;
155 dev_dbg(dev, "This Interface = %d\n", ifnum); 154 dev_dbg(dev, "This Interface = %d\n", ifnum);
156 155
157 data = kzalloc(sizeof(struct usb_wwan_intf_private),
158 GFP_KERNEL);
159 if (!data)
160 return -ENOMEM;
161
162 spin_lock_init(&data->susp_lock);
163
164 if (nintf == 1) { 156 if (nintf == 1) {
165 /* QDL mode */ 157 /* QDL mode */
166 /* Gobi 2000 has a single altsetting, older ones have two */ 158 /* Gobi 2000 has a single altsetting, older ones have two */
@@ -253,20 +245,28 @@ done:
253 } 245 }
254 } 246 }
255 247
256 /* Set serial->private if not returning error */
257 if (retval == 0)
258 usb_set_serial_data(serial, data);
259 else
260 kfree(data);
261
262 return retval; 248 return retval;
263} 249}
264 250
251static int qc_attach(struct usb_serial *serial)
252{
253 struct usb_wwan_intf_private *data;
254
255 data = kzalloc(sizeof(*data), GFP_KERNEL);
256 if (!data)
257 return -ENOMEM;
258
259 spin_lock_init(&data->susp_lock);
260
261 usb_set_serial_data(serial, data);
262
263 return 0;
264}
265
265static void qc_release(struct usb_serial *serial) 266static void qc_release(struct usb_serial *serial)
266{ 267{
267 struct usb_wwan_intf_private *priv = usb_get_serial_data(serial); 268 struct usb_wwan_intf_private *priv = usb_get_serial_data(serial);
268 269
269 /* Free the private data allocated in qcprobe */
270 usb_set_serial_data(serial, NULL); 270 usb_set_serial_data(serial, NULL);
271 kfree(priv); 271 kfree(priv);
272} 272}
@@ -285,8 +285,9 @@ static struct usb_serial_driver qcdevice = {
285 .write = usb_wwan_write, 285 .write = usb_wwan_write,
286 .write_room = usb_wwan_write_room, 286 .write_room = usb_wwan_write_room,
287 .chars_in_buffer = usb_wwan_chars_in_buffer, 287 .chars_in_buffer = usb_wwan_chars_in_buffer,
288 .attach = usb_wwan_startup, 288 .attach = qc_attach,
289 .release = qc_release, 289 .release = qc_release,
290 .port_probe = usb_wwan_port_probe,
290 .port_remove = usb_wwan_port_remove, 291 .port_remove = usb_wwan_port_remove,
291#ifdef CONFIG_PM 292#ifdef CONFIG_PM
292 .suspend = usb_wwan_suspend, 293 .suspend = usb_wwan_suspend,
diff --git a/drivers/usb/serial/quatech2.c b/drivers/usb/serial/quatech2.c
index 2cdfdcc90b3..ffcfc962ab1 100644
--- a/drivers/usb/serial/quatech2.c
+++ b/drivers/usb/serial/quatech2.c
@@ -143,12 +143,12 @@ static void qt2_read_bulk_callback(struct urb *urb);
143 143
144static void qt2_release(struct usb_serial *serial) 144static void qt2_release(struct usb_serial *serial)
145{ 145{
146 int i; 146 struct qt2_serial_private *serial_priv;
147 147
148 kfree(usb_get_serial_data(serial)); 148 serial_priv = usb_get_serial_data(serial);
149 149
150 for (i = 0; i < serial->num_ports; i++) 150 usb_free_urb(serial_priv->read_urb);
151 kfree(usb_get_serial_port_data(serial->port[i])); 151 kfree(serial_priv);
152} 152}
153 153
154static inline int calc_baud_divisor(int baudrate) 154static inline int calc_baud_divisor(int baudrate)
@@ -423,11 +423,16 @@ static void qt2_close(struct usb_serial_port *port)
423 port_priv->is_open = false; 423 port_priv->is_open = false;
424 424
425 spin_lock_irqsave(&port_priv->urb_lock, flags); 425 spin_lock_irqsave(&port_priv->urb_lock, flags);
426 if (port_priv->write_urb->status == -EINPROGRESS) 426 usb_kill_urb(port_priv->write_urb);
427 usb_kill_urb(port_priv->write_urb);
428 port_priv->urb_in_use = false; 427 port_priv->urb_in_use = false;
429 spin_unlock_irqrestore(&port_priv->urb_lock, flags); 428 spin_unlock_irqrestore(&port_priv->urb_lock, flags);
430 429
430 mutex_lock(&port->serial->disc_mutex);
431 if (port->serial->disconnected) {
432 mutex_unlock(&port->serial->disc_mutex);
433 return;
434 }
435
431 /* flush the port transmit buffer */ 436 /* flush the port transmit buffer */
432 i = usb_control_msg(serial->dev, 437 i = usb_control_msg(serial->dev,
433 usb_rcvctrlpipe(serial->dev, 0), 438 usb_rcvctrlpipe(serial->dev, 0),
@@ -459,26 +464,14 @@ static void qt2_close(struct usb_serial_port *port)
459 dev_err(&port->dev, "%s - close port failed %i\n", 464 dev_err(&port->dev, "%s - close port failed %i\n",
460 __func__, i); 465 __func__, i);
461 466
467 mutex_unlock(&port->serial->disc_mutex);
462} 468}
463 469
464static void qt2_disconnect(struct usb_serial *serial) 470static void qt2_disconnect(struct usb_serial *serial)
465{ 471{
466 struct qt2_serial_private *serial_priv = usb_get_serial_data(serial); 472 struct qt2_serial_private *serial_priv = usb_get_serial_data(serial);
467 struct qt2_port_private *port_priv;
468 int i;
469
470 if (serial_priv->read_urb->status == -EINPROGRESS)
471 usb_kill_urb(serial_priv->read_urb);
472
473 usb_free_urb(serial_priv->read_urb);
474 473
475 for (i = 0; i < serial->num_ports; i++) { 474 usb_kill_urb(serial_priv->read_urb);
476 port_priv = usb_get_serial_port_data(serial->port[i]);
477
478 if (port_priv->write_urb->status == -EINPROGRESS)
479 usb_kill_urb(port_priv->write_urb);
480 usb_free_urb(port_priv->write_urb);
481 }
482} 475}
483 476
484static int get_serial_info(struct usb_serial_port *port, 477static int get_serial_info(struct usb_serial_port *port,
@@ -773,11 +766,9 @@ static void qt2_read_bulk_callback(struct urb *urb)
773 766
774static int qt2_setup_urbs(struct usb_serial *serial) 767static int qt2_setup_urbs(struct usb_serial *serial)
775{ 768{
776 struct usb_serial_port *port;
777 struct usb_serial_port *port0; 769 struct usb_serial_port *port0;
778 struct qt2_serial_private *serial_priv; 770 struct qt2_serial_private *serial_priv;
779 struct qt2_port_private *port_priv; 771 int status;
780 int pcount, status;
781 772
782 port0 = serial->port[0]; 773 port0 = serial->port[0];
783 774
@@ -795,46 +786,21 @@ static int qt2_setup_urbs(struct usb_serial *serial)
795 sizeof(serial_priv->read_buffer), 786 sizeof(serial_priv->read_buffer),
796 qt2_read_bulk_callback, serial); 787 qt2_read_bulk_callback, serial);
797 788
798 /* setup write_urb for each port */
799 for (pcount = 0; pcount < serial->num_ports; pcount++) {
800
801 port = serial->port[pcount];
802 port_priv = usb_get_serial_port_data(port);
803
804 port_priv->write_urb = usb_alloc_urb(0, GFP_KERNEL);
805 if (!port_priv->write_urb) {
806 dev_err(&serial->dev->dev,
807 "failed to alloc write_urb for port %i\n",
808 pcount);
809 return -ENOMEM;
810 }
811
812 usb_fill_bulk_urb(port_priv->write_urb,
813 serial->dev,
814 usb_sndbulkpipe(serial->dev,
815 port0->
816 bulk_out_endpointAddress),
817 port_priv->write_buffer,
818 sizeof(port_priv->write_buffer),
819 qt2_write_bulk_callback, port);
820 }
821
822 status = usb_submit_urb(serial_priv->read_urb, GFP_KERNEL); 789 status = usb_submit_urb(serial_priv->read_urb, GFP_KERNEL);
823 if (status != 0) { 790 if (status != 0) {
824 dev_err(&serial->dev->dev, 791 dev_err(&serial->dev->dev,
825 "%s - submit read urb failed %i\n", __func__, status); 792 "%s - submit read urb failed %i\n", __func__, status);
793 usb_free_urb(serial_priv->read_urb);
826 return status; 794 return status;
827 } 795 }
828 796
829 return 0; 797 return 0;
830
831} 798}
832 799
833static int qt2_attach(struct usb_serial *serial) 800static int qt2_attach(struct usb_serial *serial)
834{ 801{
835 struct qt2_serial_private *serial_priv; 802 struct qt2_serial_private *serial_priv;
836 struct qt2_port_private *port_priv; 803 int status;
837 int status, pcount;
838 804
839 /* power on unit */ 805 /* power on unit */
840 status = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), 806 status = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
@@ -854,26 +820,6 @@ static int qt2_attach(struct usb_serial *serial)
854 820
855 usb_set_serial_data(serial, serial_priv); 821 usb_set_serial_data(serial, serial_priv);
856 822
857 for (pcount = 0; pcount < serial->num_ports; pcount++) {
858 port_priv = kzalloc(sizeof(*port_priv), GFP_KERNEL);
859 if (!port_priv) {
860 dev_err(&serial->dev->dev,
861 "%s- kmalloc(%Zd) failed.\n", __func__,
862 sizeof(*port_priv));
863 pcount--;
864 status = -ENOMEM;
865 goto attach_failed;
866 }
867
868 spin_lock_init(&port_priv->lock);
869 spin_lock_init(&port_priv->urb_lock);
870 init_waitqueue_head(&port_priv->delta_msr_wait);
871
872 port_priv->port = serial->port[pcount];
873
874 usb_set_serial_port_data(serial->port[pcount], port_priv);
875 }
876
877 status = qt2_setup_urbs(serial); 823 status = qt2_setup_urbs(serial);
878 if (status != 0) 824 if (status != 0)
879 goto attach_failed; 825 goto attach_failed;
@@ -881,14 +827,53 @@ static int qt2_attach(struct usb_serial *serial)
881 return 0; 827 return 0;
882 828
883attach_failed: 829attach_failed:
884 for (/* empty */; pcount >= 0; pcount--) {
885 port_priv = usb_get_serial_port_data(serial->port[pcount]);
886 kfree(port_priv);
887 }
888 kfree(serial_priv); 830 kfree(serial_priv);
889 return status; 831 return status;
890} 832}
891 833
834static int qt2_port_probe(struct usb_serial_port *port)
835{
836 struct usb_serial *serial = port->serial;
837 struct qt2_port_private *port_priv;
838 u8 bEndpointAddress;
839
840 port_priv = kzalloc(sizeof(*port_priv), GFP_KERNEL);
841 if (!port_priv)
842 return -ENOMEM;
843
844 spin_lock_init(&port_priv->lock);
845 spin_lock_init(&port_priv->urb_lock);
846 init_waitqueue_head(&port_priv->delta_msr_wait);
847 port_priv->port = port;
848
849 port_priv->write_urb = usb_alloc_urb(0, GFP_KERNEL);
850 if (!port_priv->write_urb) {
851 kfree(port_priv);
852 return -ENOMEM;
853 }
854 bEndpointAddress = serial->port[0]->bulk_out_endpointAddress;
855 usb_fill_bulk_urb(port_priv->write_urb, serial->dev,
856 usb_sndbulkpipe(serial->dev, bEndpointAddress),
857 port_priv->write_buffer,
858 sizeof(port_priv->write_buffer),
859 qt2_write_bulk_callback, port);
860
861 usb_set_serial_port_data(port, port_priv);
862
863 return 0;
864}
865
866static int qt2_port_remove(struct usb_serial_port *port)
867{
868 struct qt2_port_private *port_priv;
869
870 port_priv = usb_get_serial_port_data(port);
871 usb_free_urb(port_priv->write_urb);
872 kfree(port_priv);
873
874 return 0;
875}
876
892static int qt2_tiocmget(struct tty_struct *tty) 877static int qt2_tiocmget(struct tty_struct *tty)
893{ 878{
894 struct usb_serial_port *port = tty->driver_data; 879 struct usb_serial_port *port = tty->driver_data;
@@ -1127,6 +1112,8 @@ static struct usb_serial_driver qt2_device = {
1127 .attach = qt2_attach, 1112 .attach = qt2_attach,
1128 .release = qt2_release, 1113 .release = qt2_release,
1129 .disconnect = qt2_disconnect, 1114 .disconnect = qt2_disconnect,
1115 .port_probe = qt2_port_probe,
1116 .port_remove = qt2_port_remove,
1130 .dtr_rts = qt2_dtr_rts, 1117 .dtr_rts = qt2_dtr_rts,
1131 .break_ctl = qt2_break_ctl, 1118 .break_ctl = qt2_break_ctl,
1132 .tiocmget = qt2_tiocmget, 1119 .tiocmget = qt2_tiocmget,
diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c
index 01d882cf377..270860f6bb2 100644
--- a/drivers/usb/serial/sierra.c
+++ b/drivers/usb/serial/sierra.c
@@ -161,7 +161,6 @@ static int sierra_probe(struct usb_serial *serial,
161{ 161{
162 int result = 0; 162 int result = 0;
163 struct usb_device *udev; 163 struct usb_device *udev;
164 struct sierra_intf_private *data;
165 u8 ifnum; 164 u8 ifnum;
166 165
167 udev = serial->dev; 166 udev = serial->dev;
@@ -188,11 +187,6 @@ static int sierra_probe(struct usb_serial *serial,
188 return -ENODEV; 187 return -ENODEV;
189 } 188 }
190 189
191 data = serial->private = kzalloc(sizeof(struct sierra_intf_private), GFP_KERNEL);
192 if (!data)
193 return -ENOMEM;
194 spin_lock_init(&data->susp_lock);
195
196 return result; 190 return result;
197} 191}
198 192
@@ -884,11 +878,15 @@ static void sierra_dtr_rts(struct usb_serial_port *port, int on)
884 878
885static int sierra_startup(struct usb_serial *serial) 879static int sierra_startup(struct usb_serial *serial)
886{ 880{
887 struct usb_serial_port *port; 881 struct sierra_intf_private *intfdata;
888 struct sierra_port_private *portdata; 882
889 struct sierra_iface_info *himemoryp = NULL; 883 intfdata = kzalloc(sizeof(*intfdata), GFP_KERNEL);
890 int i; 884 if (!intfdata)
891 u8 ifnum; 885 return -ENOMEM;
886
887 spin_lock_init(&intfdata->susp_lock);
888
889 usb_set_serial_data(serial, intfdata);
892 890
893 /* Set Device mode to D0 */ 891 /* Set Device mode to D0 */
894 sierra_set_power_state(serial->dev, 0x0000); 892 sierra_set_power_state(serial->dev, 0x0000);
@@ -897,68 +895,71 @@ static int sierra_startup(struct usb_serial *serial)
897 if (nmea) 895 if (nmea)
898 sierra_vsc_set_nmea(serial->dev, 1); 896 sierra_vsc_set_nmea(serial->dev, 1);
899 897
900 /* Now setup per port private data */
901 for (i = 0; i < serial->num_ports; i++) {
902 port = serial->port[i];
903 portdata = kzalloc(sizeof(*portdata), GFP_KERNEL);
904 if (!portdata) {
905 dev_dbg(&port->dev, "%s: kmalloc for "
906 "sierra_port_private (%d) failed!\n",
907 __func__, i);
908 return -ENOMEM;
909 }
910 spin_lock_init(&portdata->lock);
911 init_usb_anchor(&portdata->active);
912 init_usb_anchor(&portdata->delayed);
913 ifnum = i;
914 /* Assume low memory requirements */
915 portdata->num_out_urbs = N_OUT_URB;
916 portdata->num_in_urbs = N_IN_URB;
917
918 /* Determine actual memory requirements */
919 if (serial->num_ports == 1) {
920 /* Get interface number for composite device */
921 ifnum = sierra_calc_interface(serial);
922 himemoryp =
923 (struct sierra_iface_info *)&typeB_interface_list;
924 if (is_himemory(ifnum, himemoryp)) {
925 portdata->num_out_urbs = N_OUT_URB_HM;
926 portdata->num_in_urbs = N_IN_URB_HM;
927 }
928 }
929 else {
930 himemoryp =
931 (struct sierra_iface_info *)&typeA_interface_list;
932 if (is_himemory(i, himemoryp)) {
933 portdata->num_out_urbs = N_OUT_URB_HM;
934 portdata->num_in_urbs = N_IN_URB_HM;
935 }
936 }
937 dev_dbg(&serial->dev->dev,
938 "Memory usage (urbs) interface #%d, in=%d, out=%d\n",
939 ifnum,portdata->num_in_urbs, portdata->num_out_urbs );
940 /* Set the port private data pointer */
941 usb_set_serial_port_data(port, portdata);
942 }
943
944 return 0; 898 return 0;
945} 899}
946 900
947static void sierra_release(struct usb_serial *serial) 901static void sierra_release(struct usb_serial *serial)
948{ 902{
949 int i; 903 struct sierra_intf_private *intfdata;
950 struct usb_serial_port *port; 904
905 intfdata = usb_get_serial_data(serial);
906 kfree(intfdata);
907}
908
909static int sierra_port_probe(struct usb_serial_port *port)
910{
911 struct usb_serial *serial = port->serial;
951 struct sierra_port_private *portdata; 912 struct sierra_port_private *portdata;
913 const struct sierra_iface_info *himemoryp;
914 u8 ifnum;
952 915
953 for (i = 0; i < serial->num_ports; ++i) { 916 portdata = kzalloc(sizeof(*portdata), GFP_KERNEL);
954 port = serial->port[i]; 917 if (!portdata)
955 if (!port) 918 return -ENOMEM;
956 continue; 919
957 portdata = usb_get_serial_port_data(port); 920 spin_lock_init(&portdata->lock);
958 if (!portdata) 921 init_usb_anchor(&portdata->active);
959 continue; 922 init_usb_anchor(&portdata->delayed);
960 kfree(portdata); 923
924 /* Assume low memory requirements */
925 portdata->num_out_urbs = N_OUT_URB;
926 portdata->num_in_urbs = N_IN_URB;
927
928 /* Determine actual memory requirements */
929 if (serial->num_ports == 1) {
930 /* Get interface number for composite device */
931 ifnum = sierra_calc_interface(serial);
932 himemoryp = &typeB_interface_list;
933 } else {
934 /* This is really the usb-serial port number of the interface
935 * rather than the interface number.
936 */
937 ifnum = port->number - serial->minor;
938 himemoryp = &typeA_interface_list;
961 } 939 }
940
941 if (is_himemory(ifnum, himemoryp)) {
942 portdata->num_out_urbs = N_OUT_URB_HM;
943 portdata->num_in_urbs = N_IN_URB_HM;
944 }
945
946 dev_dbg(&port->dev,
947 "Memory usage (urbs) interface #%d, in=%d, out=%d\n",
948 ifnum, portdata->num_in_urbs, portdata->num_out_urbs);
949
950 usb_set_serial_port_data(port, portdata);
951
952 return 0;
953}
954
955static int sierra_port_remove(struct usb_serial_port *port)
956{
957 struct sierra_port_private *portdata;
958
959 portdata = usb_get_serial_port_data(port);
960 kfree(portdata);
961
962 return 0;
962} 963}
963 964
964#ifdef CONFIG_PM 965#ifdef CONFIG_PM
@@ -1062,6 +1063,8 @@ static struct usb_serial_driver sierra_device = {
1062 .tiocmset = sierra_tiocmset, 1063 .tiocmset = sierra_tiocmset,
1063 .attach = sierra_startup, 1064 .attach = sierra_startup,
1064 .release = sierra_release, 1065 .release = sierra_release,
1066 .port_probe = sierra_port_probe,
1067 .port_remove = sierra_port_remove,
1065 .suspend = sierra_suspend, 1068 .suspend = sierra_suspend,
1066 .resume = sierra_resume, 1069 .resume = sierra_resume,
1067 .read_int_callback = sierra_instat_callback, 1070 .read_int_callback = sierra_instat_callback,
diff --git a/drivers/usb/serial/spcp8x5.c b/drivers/usb/serial/spcp8x5.c
index 9716efe9295..769c137f897 100644
--- a/drivers/usb/serial/spcp8x5.c
+++ b/drivers/usb/serial/spcp8x5.c
@@ -157,13 +157,10 @@ struct spcp8x5_private {
157 u8 line_status; 157 u8 line_status;
158}; 158};
159 159
160/* desc : when device plug in,this function would be called. 160static int spcp8x5_port_probe(struct usb_serial_port *port)
161 * thanks to usb_serial subsystem,then do almost every things for us. And what
162 * we should do just alloc the buffer */
163static int spcp8x5_startup(struct usb_serial *serial)
164{ 161{
162 struct usb_serial *serial = port->serial;
165 struct spcp8x5_private *priv; 163 struct spcp8x5_private *priv;
166 int i;
167 enum spcp8x5_type type = SPCP825_007_TYPE; 164 enum spcp8x5_type type = SPCP825_007_TYPE;
168 u16 product = le16_to_cpu(serial->dev->descriptor.idProduct); 165 u16 product = le16_to_cpu(serial->dev->descriptor.idProduct);
169 166
@@ -180,34 +177,27 @@ static int spcp8x5_startup(struct usb_serial *serial)
180 type = SPCP825_PHILIP_TYPE; 177 type = SPCP825_PHILIP_TYPE;
181 dev_dbg(&serial->dev->dev, "device type = %d\n", (int)type); 178 dev_dbg(&serial->dev->dev, "device type = %d\n", (int)type);
182 179
183 for (i = 0; i < serial->num_ports; ++i) { 180 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
184 priv = kzalloc(sizeof(struct spcp8x5_private), GFP_KERNEL); 181 if (!priv)
185 if (!priv) 182 return -ENOMEM;
186 goto cleanup;
187 183
188 spin_lock_init(&priv->lock); 184 spin_lock_init(&priv->lock);
189 init_waitqueue_head(&priv->delta_msr_wait); 185 init_waitqueue_head(&priv->delta_msr_wait);
190 priv->type = type; 186 priv->type = type;
191 usb_set_serial_port_data(serial->port[i] , priv); 187
192 } 188 usb_set_serial_port_data(port , priv);
193 189
194 return 0; 190 return 0;
195cleanup:
196 for (--i; i >= 0; --i) {
197 priv = usb_get_serial_port_data(serial->port[i]);
198 kfree(priv);
199 usb_set_serial_port_data(serial->port[i] , NULL);
200 }
201 return -ENOMEM;
202} 191}
203 192
204/* call when the device plug out. free all the memory alloced by probe */ 193static int spcp8x5_port_remove(struct usb_serial_port *port)
205static void spcp8x5_release(struct usb_serial *serial)
206{ 194{
207 int i; 195 struct spcp8x5_private *priv;
208 196
209 for (i = 0; i < serial->num_ports; i++) 197 priv = usb_get_serial_port_data(port);
210 kfree(usb_get_serial_port_data(serial->port[i])); 198 kfree(priv);
199
200 return 0;
211} 201}
212 202
213/* set the modem control line of the device. 203/* set the modem control line of the device.
@@ -649,8 +639,8 @@ static struct usb_serial_driver spcp8x5_device = {
649 .ioctl = spcp8x5_ioctl, 639 .ioctl = spcp8x5_ioctl,
650 .tiocmget = spcp8x5_tiocmget, 640 .tiocmget = spcp8x5_tiocmget,
651 .tiocmset = spcp8x5_tiocmset, 641 .tiocmset = spcp8x5_tiocmset,
652 .attach = spcp8x5_startup, 642 .port_probe = spcp8x5_port_probe,
653 .release = spcp8x5_release, 643 .port_remove = spcp8x5_port_remove,
654 .process_read_urb = spcp8x5_process_read_urb, 644 .process_read_urb = spcp8x5_process_read_urb,
655}; 645};
656 646
diff --git a/drivers/usb/serial/ssu100.c b/drivers/usb/serial/ssu100.c
index 015810b3785..868d1e6852e 100644
--- a/drivers/usb/serial/ssu100.c
+++ b/drivers/usb/serial/ssu100.c
@@ -67,13 +67,6 @@ struct ssu100_port_private {
67 struct async_icount icount; 67 struct async_icount icount;
68}; 68};
69 69
70static void ssu100_release(struct usb_serial *serial)
71{
72 struct ssu100_port_private *priv = usb_get_serial_port_data(*serial->port);
73
74 kfree(priv);
75}
76
77static inline int ssu100_control_msg(struct usb_device *dev, 70static inline int ssu100_control_msg(struct usb_device *dev,
78 u8 request, u16 data, u16 index) 71 u8 request, u16 data, u16 index)
79{ 72{
@@ -442,21 +435,33 @@ static int ssu100_ioctl(struct tty_struct *tty,
442 435
443static int ssu100_attach(struct usb_serial *serial) 436static int ssu100_attach(struct usb_serial *serial)
444{ 437{
438 return ssu100_initdevice(serial->dev);
439}
440
441static int ssu100_port_probe(struct usb_serial_port *port)
442{
445 struct ssu100_port_private *priv; 443 struct ssu100_port_private *priv;
446 struct usb_serial_port *port = *serial->port;
447 444
448 priv = kzalloc(sizeof(*priv), GFP_KERNEL); 445 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
449 if (!priv) { 446 if (!priv)
450 dev_err(&port->dev, "%s- kmalloc(%Zd) failed.\n", __func__,
451 sizeof(*priv));
452 return -ENOMEM; 447 return -ENOMEM;
453 }
454 448
455 spin_lock_init(&priv->status_lock); 449 spin_lock_init(&priv->status_lock);
456 init_waitqueue_head(&priv->delta_msr_wait); 450 init_waitqueue_head(&priv->delta_msr_wait);
451
457 usb_set_serial_port_data(port, priv); 452 usb_set_serial_port_data(port, priv);
458 453
459 return ssu100_initdevice(serial->dev); 454 return 0;
455}
456
457static int ssu100_port_remove(struct usb_serial_port *port)
458{
459 struct ssu100_port_private *priv;
460
461 priv = usb_get_serial_port_data(port);
462 kfree(priv);
463
464 return 0;
460} 465}
461 466
462static int ssu100_tiocmget(struct tty_struct *tty) 467static int ssu100_tiocmget(struct tty_struct *tty)
@@ -647,7 +652,8 @@ static struct usb_serial_driver ssu100_device = {
647 .open = ssu100_open, 652 .open = ssu100_open,
648 .close = ssu100_close, 653 .close = ssu100_close,
649 .attach = ssu100_attach, 654 .attach = ssu100_attach,
650 .release = ssu100_release, 655 .port_probe = ssu100_port_probe,
656 .port_remove = ssu100_port_remove,
651 .dtr_rts = ssu100_dtr_rts, 657 .dtr_rts = ssu100_dtr_rts,
652 .process_read_urb = ssu100_process_read_urb, 658 .process_read_urb = ssu100_process_read_urb,
653 .tiocmget = ssu100_tiocmget, 659 .tiocmget = ssu100_tiocmget,
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index 6f49392cda5..f2530d2ef3c 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -97,6 +97,8 @@ struct ti_device {
97 97
98static int ti_startup(struct usb_serial *serial); 98static int ti_startup(struct usb_serial *serial);
99static void ti_release(struct usb_serial *serial); 99static void ti_release(struct usb_serial *serial);
100static int ti_port_probe(struct usb_serial_port *port);
101static int ti_port_remove(struct usb_serial_port *port);
100static int ti_open(struct tty_struct *tty, struct usb_serial_port *port); 102static int ti_open(struct tty_struct *tty, struct usb_serial_port *port);
101static void ti_close(struct usb_serial_port *port); 103static void ti_close(struct usb_serial_port *port);
102static int ti_write(struct tty_struct *tty, struct usb_serial_port *port, 104static int ti_write(struct tty_struct *tty, struct usb_serial_port *port,
@@ -221,6 +223,8 @@ static struct usb_serial_driver ti_1port_device = {
221 .num_ports = 1, 223 .num_ports = 1,
222 .attach = ti_startup, 224 .attach = ti_startup,
223 .release = ti_release, 225 .release = ti_release,
226 .port_probe = ti_port_probe,
227 .port_remove = ti_port_remove,
224 .open = ti_open, 228 .open = ti_open,
225 .close = ti_close, 229 .close = ti_close,
226 .write = ti_write, 230 .write = ti_write,
@@ -249,6 +253,8 @@ static struct usb_serial_driver ti_2port_device = {
249 .num_ports = 2, 253 .num_ports = 2,
250 .attach = ti_startup, 254 .attach = ti_startup,
251 .release = ti_release, 255 .release = ti_release,
256 .port_probe = ti_port_probe,
257 .port_remove = ti_port_remove,
252 .open = ti_open, 258 .open = ti_open,
253 .close = ti_close, 259 .close = ti_close,
254 .write = ti_write, 260 .write = ti_write,
@@ -347,11 +353,8 @@ module_exit(ti_exit);
347static int ti_startup(struct usb_serial *serial) 353static int ti_startup(struct usb_serial *serial)
348{ 354{
349 struct ti_device *tdev; 355 struct ti_device *tdev;
350 struct ti_port *tport;
351 struct usb_device *dev = serial->dev; 356 struct usb_device *dev = serial->dev;
352 int status; 357 int status;
353 int i;
354
355 358
356 dev_dbg(&dev->dev, 359 dev_dbg(&dev->dev,
357 "%s - product 0x%4X, num configurations %d, configuration value %d", 360 "%s - product 0x%4X, num configurations %d, configuration value %d",
@@ -399,42 +402,8 @@ static int ti_startup(struct usb_serial *serial)
399 goto free_tdev; 402 goto free_tdev;
400 } 403 }
401 404
402 /* set up port structures */
403 for (i = 0; i < serial->num_ports; ++i) {
404 tport = kzalloc(sizeof(struct ti_port), GFP_KERNEL);
405 if (tport == NULL) {
406 dev_err(&dev->dev, "%s - out of memory\n", __func__);
407 status = -ENOMEM;
408 goto free_tports;
409 }
410 spin_lock_init(&tport->tp_lock);
411 tport->tp_uart_base_addr = (i == 0 ?
412 TI_UART1_BASE_ADDR : TI_UART2_BASE_ADDR);
413 tport->tp_closing_wait = closing_wait;
414 init_waitqueue_head(&tport->tp_msr_wait);
415 init_waitqueue_head(&tport->tp_write_wait);
416 if (kfifo_alloc(&tport->write_fifo, TI_WRITE_BUF_SIZE,
417 GFP_KERNEL)) {
418 dev_err(&dev->dev, "%s - out of memory\n", __func__);
419 kfree(tport);
420 status = -ENOMEM;
421 goto free_tports;
422 }
423 tport->tp_port = serial->port[i];
424 tport->tp_tdev = tdev;
425 usb_set_serial_port_data(serial->port[i], tport);
426 tport->tp_uart_mode = 0; /* default is RS232 */
427 }
428
429 return 0; 405 return 0;
430 406
431free_tports:
432 for (--i; i >= 0; --i) {
433 tport = usb_get_serial_port_data(serial->port[i]);
434 kfifo_free(&tport->write_fifo);
435 kfree(tport);
436 usb_set_serial_port_data(serial->port[i], NULL);
437 }
438free_tdev: 407free_tdev:
439 kfree(tdev); 408 kfree(tdev);
440 usb_set_serial_data(serial, NULL); 409 usb_set_serial_data(serial, NULL);
@@ -444,21 +413,50 @@ free_tdev:
444 413
445static void ti_release(struct usb_serial *serial) 414static void ti_release(struct usb_serial *serial)
446{ 415{
447 int i;
448 struct ti_device *tdev = usb_get_serial_data(serial); 416 struct ti_device *tdev = usb_get_serial_data(serial);
417
418 kfree(tdev);
419}
420
421static int ti_port_probe(struct usb_serial_port *port)
422{
449 struct ti_port *tport; 423 struct ti_port *tport;
450 424
451 for (i = 0; i < serial->num_ports; ++i) { 425 tport = kzalloc(sizeof(*tport), GFP_KERNEL);
452 tport = usb_get_serial_port_data(serial->port[i]); 426 if (!tport)
453 if (tport) { 427 return -ENOMEM;
454 kfifo_free(&tport->write_fifo); 428
455 kfree(tport); 429 spin_lock_init(&tport->tp_lock);
456 } 430 if (port == port->serial->port[0])
431 tport->tp_uart_base_addr = TI_UART1_BASE_ADDR;
432 else
433 tport->tp_uart_base_addr = TI_UART2_BASE_ADDR;
434 tport->tp_closing_wait = closing_wait;
435 init_waitqueue_head(&tport->tp_msr_wait);
436 init_waitqueue_head(&tport->tp_write_wait);
437 if (kfifo_alloc(&tport->write_fifo, TI_WRITE_BUF_SIZE, GFP_KERNEL)) {
438 kfree(tport);
439 return -ENOMEM;
457 } 440 }
441 tport->tp_port = port;
442 tport->tp_tdev = usb_get_serial_data(port->serial);
443 tport->tp_uart_mode = 0; /* default is RS232 */
458 444
459 kfree(tdev); 445 usb_set_serial_port_data(port, tport);
446
447 return 0;
460} 448}
461 449
450static int ti_port_remove(struct usb_serial_port *port)
451{
452 struct ti_port *tport;
453
454 tport = usb_get_serial_port_data(port);
455 kfifo_free(&tport->write_fifo);
456 kfree(tport);
457
458 return 0;
459}
462 460
463static int ti_open(struct tty_struct *tty, struct usb_serial_port *port) 461static int ti_open(struct tty_struct *tty, struct usb_serial_port *port)
464{ 462{
diff --git a/drivers/usb/serial/usb-wwan.h b/drivers/usb/serial/usb-wwan.h
index 1f034d2397c..684739b8efd 100644
--- a/drivers/usb/serial/usb-wwan.h
+++ b/drivers/usb/serial/usb-wwan.h
@@ -8,7 +8,7 @@
8extern void usb_wwan_dtr_rts(struct usb_serial_port *port, int on); 8extern void usb_wwan_dtr_rts(struct usb_serial_port *port, int on);
9extern int usb_wwan_open(struct tty_struct *tty, struct usb_serial_port *port); 9extern int usb_wwan_open(struct tty_struct *tty, struct usb_serial_port *port);
10extern void usb_wwan_close(struct usb_serial_port *port); 10extern void usb_wwan_close(struct usb_serial_port *port);
11extern int usb_wwan_startup(struct usb_serial *serial); 11extern int usb_wwan_port_probe(struct usb_serial_port *port);
12extern int usb_wwan_port_remove(struct usb_serial_port *port); 12extern int usb_wwan_port_remove(struct usb_serial_port *port);
13extern int usb_wwan_write_room(struct tty_struct *tty); 13extern int usb_wwan_write_room(struct tty_struct *tty);
14extern void usb_wwan_set_termios(struct tty_struct *tty, 14extern void usb_wwan_set_termios(struct tty_struct *tty,
diff --git a/drivers/usb/serial/usb_wwan.c b/drivers/usb/serial/usb_wwan.c
index e42aa398ed3..a3e9c095f0d 100644
--- a/drivers/usb/serial/usb_wwan.c
+++ b/drivers/usb/serial/usb_wwan.c
@@ -447,15 +447,14 @@ void usb_wwan_close(struct usb_serial_port *port)
447EXPORT_SYMBOL(usb_wwan_close); 447EXPORT_SYMBOL(usb_wwan_close);
448 448
449/* Helper functions used by usb_wwan_setup_urbs */ 449/* Helper functions used by usb_wwan_setup_urbs */
450static struct urb *usb_wwan_setup_urb(struct usb_serial *serial, int endpoint, 450static struct urb *usb_wwan_setup_urb(struct usb_serial_port *port,
451 int endpoint,
451 int dir, void *ctx, char *buf, int len, 452 int dir, void *ctx, char *buf, int len,
452 void (*callback) (struct urb *)) 453 void (*callback) (struct urb *))
453{ 454{
455 struct usb_serial *serial = port->serial;
454 struct urb *urb; 456 struct urb *urb;
455 457
456 if (endpoint == -1)
457 return NULL; /* endpoint not needed */
458
459 urb = usb_alloc_urb(0, GFP_KERNEL); /* No ISO */ 458 urb = usb_alloc_urb(0, GFP_KERNEL); /* No ISO */
460 if (urb == NULL) { 459 if (urb == NULL) {
461 dev_dbg(&serial->interface->dev, 460 dev_dbg(&serial->interface->dev,
@@ -472,101 +471,78 @@ static struct urb *usb_wwan_setup_urb(struct usb_serial *serial, int endpoint,
472 return urb; 471 return urb;
473} 472}
474 473
475/* Setup urbs */ 474int usb_wwan_port_probe(struct usb_serial_port *port)
476static void usb_wwan_setup_urbs(struct usb_serial *serial)
477{ 475{
478 int i, j;
479 struct usb_serial_port *port;
480 struct usb_wwan_port_private *portdata; 476 struct usb_wwan_port_private *portdata;
477 struct urb *urb;
478 u8 *buffer;
479 int err;
480 int i;
481 481
482 for (i = 0; i < serial->num_ports; i++) { 482 portdata = kzalloc(sizeof(*portdata), GFP_KERNEL);
483 port = serial->port[i]; 483 if (!portdata)
484 portdata = usb_get_serial_port_data(port); 484 return -ENOMEM;
485 485
486 /* Do indat endpoints first */ 486 init_usb_anchor(&portdata->delayed);
487 for (j = 0; j < N_IN_URB; ++j) {
488 portdata->in_urbs[j] = usb_wwan_setup_urb(serial,
489 port->
490 bulk_in_endpointAddress,
491 USB_DIR_IN,
492 port,
493 portdata->
494 in_buffer[j],
495 IN_BUFLEN,
496 usb_wwan_indat_callback);
497 }
498 487
499 /* outdat endpoints */ 488 for (i = 0; i < N_IN_URB; i++) {
500 for (j = 0; j < N_OUT_URB; ++j) { 489 if (!port->bulk_in_size)
501 portdata->out_urbs[j] = usb_wwan_setup_urb(serial, 490 break;
502 port->
503 bulk_out_endpointAddress,
504 USB_DIR_OUT,
505 port,
506 portdata->
507 out_buffer
508 [j],
509 OUT_BUFLEN,
510 usb_wwan_outdat_callback);
511 }
512 }
513}
514 491
515int usb_wwan_startup(struct usb_serial *serial) 492 buffer = (u8 *)__get_free_page(GFP_KERNEL);
516{ 493 if (!buffer)
517 int i, j, err; 494 goto bail_out_error;
518 struct usb_serial_port *port; 495 portdata->in_buffer[i] = buffer;
519 struct usb_wwan_port_private *portdata;
520 u8 *buffer;
521 496
522 /* Now setup per port private data */ 497 urb = usb_wwan_setup_urb(port, port->bulk_in_endpointAddress,
523 for (i = 0; i < serial->num_ports; i++) { 498 USB_DIR_IN, port,
524 port = serial->port[i]; 499 buffer, IN_BUFLEN,
525 portdata = kzalloc(sizeof(*portdata), GFP_KERNEL); 500 usb_wwan_indat_callback);
526 if (!portdata) { 501 portdata->in_urbs[i] = urb;
527 dev_dbg(&port->dev, "%s: kmalloc for usb_wwan_port_private (%d) failed!.\n", 502 }
528 __func__, i);
529 return 1;
530 }
531 init_usb_anchor(&portdata->delayed);
532 503
533 for (j = 0; j < N_IN_URB; j++) { 504 for (i = 0; i < N_OUT_URB; i++) {
534 buffer = (u8 *) __get_free_page(GFP_KERNEL); 505 if (!port->bulk_out_size)
535 if (!buffer) 506 break;
536 goto bail_out_error;
537 portdata->in_buffer[j] = buffer;
538 }
539 507
540 for (j = 0; j < N_OUT_URB; j++) { 508 buffer = kmalloc(OUT_BUFLEN, GFP_KERNEL);
541 buffer = kmalloc(OUT_BUFLEN, GFP_KERNEL); 509 if (!buffer)
542 if (!buffer) 510 goto bail_out_error2;
543 goto bail_out_error2; 511 portdata->out_buffer[i] = buffer;
544 portdata->out_buffer[j] = buffer;
545 }
546 512
547 usb_set_serial_port_data(port, portdata); 513 urb = usb_wwan_setup_urb(port, port->bulk_out_endpointAddress,
514 USB_DIR_OUT, port,
515 buffer, OUT_BUFLEN,
516 usb_wwan_outdat_callback);
517 portdata->out_urbs[i] = urb;
518 }
548 519
549 if (!port->interrupt_in_urb) 520 usb_set_serial_port_data(port, portdata);
550 continue; 521
522 if (port->interrupt_in_urb) {
551 err = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); 523 err = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
552 if (err) 524 if (err)
553 dev_dbg(&port->dev, "%s: submit irq_in urb failed %d\n", 525 dev_dbg(&port->dev, "%s: submit irq_in urb failed %d\n",
554 __func__, err); 526 __func__, err);
555 } 527 }
556 usb_wwan_setup_urbs(serial); 528
557 return 0; 529 return 0;
558 530
559bail_out_error2: 531bail_out_error2:
560 for (j = 0; j < N_OUT_URB; j++) 532 for (i = 0; i < N_OUT_URB; i++) {
561 kfree(portdata->out_buffer[j]); 533 usb_free_urb(portdata->out_urbs[i]);
534 kfree(portdata->out_buffer[i]);
535 }
562bail_out_error: 536bail_out_error:
563 for (j = 0; j < N_IN_URB; j++) 537 for (i = 0; i < N_IN_URB; i++) {
564 if (portdata->in_buffer[j]) 538 usb_free_urb(portdata->in_urbs[i]);
565 free_page((unsigned long)portdata->in_buffer[j]); 539 free_page((unsigned long)portdata->in_buffer[i]);
540 }
566 kfree(portdata); 541 kfree(portdata);
567 return 1; 542
543 return -ENOMEM;
568} 544}
569EXPORT_SYMBOL(usb_wwan_startup); 545EXPORT_SYMBOL_GPL(usb_wwan_port_probe);
570 546
571int usb_wwan_port_remove(struct usb_serial_port *port) 547int usb_wwan_port_remove(struct usb_serial_port *port)
572{ 548{
diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c
index 346c7efc20b..b9fca3586d7 100644
--- a/drivers/usb/serial/whiteheat.c
+++ b/drivers/usb/serial/whiteheat.c
@@ -83,6 +83,8 @@ static int whiteheat_firmware_attach(struct usb_serial *serial);
83/* function prototypes for the Connect Tech WhiteHEAT serial converter */ 83/* function prototypes for the Connect Tech WhiteHEAT serial converter */
84static int whiteheat_attach(struct usb_serial *serial); 84static int whiteheat_attach(struct usb_serial *serial);
85static void whiteheat_release(struct usb_serial *serial); 85static void whiteheat_release(struct usb_serial *serial);
86static int whiteheat_port_probe(struct usb_serial_port *port);
87static int whiteheat_port_remove(struct usb_serial_port *port);
86static int whiteheat_open(struct tty_struct *tty, 88static int whiteheat_open(struct tty_struct *tty,
87 struct usb_serial_port *port); 89 struct usb_serial_port *port);
88static void whiteheat_close(struct usb_serial_port *port); 90static void whiteheat_close(struct usb_serial_port *port);
@@ -117,6 +119,8 @@ static struct usb_serial_driver whiteheat_device = {
117 .num_ports = 4, 119 .num_ports = 4,
118 .attach = whiteheat_attach, 120 .attach = whiteheat_attach,
119 .release = whiteheat_release, 121 .release = whiteheat_release,
122 .port_probe = whiteheat_port_probe,
123 .port_remove = whiteheat_port_remove,
120 .open = whiteheat_open, 124 .open = whiteheat_open,
121 .close = whiteheat_close, 125 .close = whiteheat_close,
122 .ioctl = whiteheat_ioctl, 126 .ioctl = whiteheat_ioctl,
@@ -218,15 +222,12 @@ static int whiteheat_attach(struct usb_serial *serial)
218{ 222{
219 struct usb_serial_port *command_port; 223 struct usb_serial_port *command_port;
220 struct whiteheat_command_private *command_info; 224 struct whiteheat_command_private *command_info;
221 struct usb_serial_port *port;
222 struct whiteheat_private *info;
223 struct whiteheat_hw_info *hw_info; 225 struct whiteheat_hw_info *hw_info;
224 int pipe; 226 int pipe;
225 int ret; 227 int ret;
226 int alen; 228 int alen;
227 __u8 *command; 229 __u8 *command;
228 __u8 *result; 230 __u8 *result;
229 int i;
230 231
231 command_port = serial->port[COMMAND_PORT]; 232 command_port = serial->port[COMMAND_PORT];
232 233
@@ -285,22 +286,6 @@ static int whiteheat_attach(struct usb_serial *serial)
285 serial->type->description, 286 serial->type->description,
286 hw_info->sw_major_rev, hw_info->sw_minor_rev); 287 hw_info->sw_major_rev, hw_info->sw_minor_rev);
287 288
288 for (i = 0; i < serial->num_ports; i++) {
289 port = serial->port[i];
290
291 info = kmalloc(sizeof(struct whiteheat_private), GFP_KERNEL);
292 if (info == NULL) {
293 dev_err(&port->dev,
294 "%s: Out of memory for port structures\n",
295 serial->type->description);
296 goto no_private;
297 }
298
299 info->mcr = 0;
300
301 usb_set_serial_port_data(port, info);
302 }
303
304 command_info = kmalloc(sizeof(struct whiteheat_command_private), 289 command_info = kmalloc(sizeof(struct whiteheat_command_private),
305 GFP_KERNEL); 290 GFP_KERNEL);
306 if (command_info == NULL) { 291 if (command_info == NULL) {
@@ -333,16 +318,10 @@ no_firmware:
333 "%s: please contact support@connecttech.com\n", 318 "%s: please contact support@connecttech.com\n",
334 serial->type->description); 319 serial->type->description);
335 kfree(result); 320 kfree(result);
321 kfree(command);
336 return -ENODEV; 322 return -ENODEV;
337 323
338no_command_private: 324no_command_private:
339 for (i = serial->num_ports - 1; i >= 0; i--) {
340 port = serial->port[i];
341 info = usb_get_serial_port_data(port);
342 kfree(info);
343no_private:
344 ;
345 }
346 kfree(result); 325 kfree(result);
347no_result_buffer: 326no_result_buffer:
348 kfree(command); 327 kfree(command);
@@ -350,21 +329,36 @@ no_command_buffer:
350 return -ENOMEM; 329 return -ENOMEM;
351} 330}
352 331
353
354static void whiteheat_release(struct usb_serial *serial) 332static void whiteheat_release(struct usb_serial *serial)
355{ 333{
356 struct usb_serial_port *command_port; 334 struct usb_serial_port *command_port;
357 struct whiteheat_private *info;
358 int i;
359 335
360 /* free up our private data for our command port */ 336 /* free up our private data for our command port */
361 command_port = serial->port[COMMAND_PORT]; 337 command_port = serial->port[COMMAND_PORT];
362 kfree(usb_get_serial_port_data(command_port)); 338 kfree(usb_get_serial_port_data(command_port));
339}
363 340
364 for (i = 0; i < serial->num_ports; i++) { 341static int whiteheat_port_probe(struct usb_serial_port *port)
365 info = usb_get_serial_port_data(serial->port[i]); 342{
366 kfree(info); 343 struct whiteheat_private *info;
367 } 344
345 info = kzalloc(sizeof(*info), GFP_KERNEL);
346 if (!info)
347 return -ENOMEM;
348
349 usb_set_serial_port_data(port, info);
350
351 return 0;
352}
353
354static int whiteheat_port_remove(struct usb_serial_port *port)
355{
356 struct whiteheat_private *info;
357
358 info = usb_get_serial_port_data(port);
359 kfree(info);
360
361 return 0;
368} 362}
369 363
370static int whiteheat_open(struct tty_struct *tty, struct usb_serial_port *port) 364static int whiteheat_open(struct tty_struct *tty, struct usb_serial_port *port)
diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
index a3d54366afc..92f35abee92 100644
--- a/drivers/usb/storage/scsiglue.c
+++ b/drivers/usb/storage/scsiglue.c
@@ -186,6 +186,12 @@ static int slave_configure(struct scsi_device *sdev)
186 /* Some devices don't handle VPD pages correctly */ 186 /* Some devices don't handle VPD pages correctly */
187 sdev->skip_vpd_pages = 1; 187 sdev->skip_vpd_pages = 1;
188 188
189 /* Do not attempt to use REPORT SUPPORTED OPERATION CODES */
190 sdev->no_report_opcodes = 1;
191
192 /* Do not attempt to use WRITE SAME */
193 sdev->no_write_same = 1;
194
189 /* Some disks return the total number of blocks in response 195 /* Some disks return the total number of blocks in response
190 * to READ CAPACITY rather than the highest block number. 196 * to READ CAPACITY rather than the highest block number.
191 * If this device makes that mistake, tell the sd driver. */ 197 * If this device makes that mistake, tell the sd driver. */
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index 779cd954abc..d305a5aa3a5 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -1004,6 +1004,12 @@ UNUSUAL_DEV( 0x07cf, 0x1001, 0x1000, 0x9999,
1004 USB_SC_8070, USB_PR_CB, NULL, 1004 USB_SC_8070, USB_PR_CB, NULL,
1005 US_FL_NEED_OVERRIDE | US_FL_FIX_INQUIRY ), 1005 US_FL_NEED_OVERRIDE | US_FL_FIX_INQUIRY ),
1006 1006
1007/* Submitted by Oleksandr Chumachenko <ledest@gmail.com> */
1008UNUSUAL_DEV( 0x07cf, 0x1167, 0x0100, 0x0100,
1009 "Casio",
1010 "EX-N1 DigitalCamera",
1011 USB_SC_8070, USB_PR_DEVICE, NULL, 0),
1012
1007/* Submitted by Hartmut Wahl <hwahl@hwahl.de>*/ 1013/* Submitted by Hartmut Wahl <hwahl@hwahl.de>*/
1008UNUSUAL_DEV( 0x0839, 0x000a, 0x0001, 0x0001, 1014UNUSUAL_DEV( 0x0839, 0x000a, 0x0001, 0x0001,
1009 "Samsung", 1015 "Samsung",
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index 072cbbadbc3..7f93f34b7f9 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -379,7 +379,8 @@ static void handle_rx(struct vhost_net *net)
379 .hdr.gso_type = VIRTIO_NET_HDR_GSO_NONE 379 .hdr.gso_type = VIRTIO_NET_HDR_GSO_NONE
380 }; 380 };
381 size_t total_len = 0; 381 size_t total_len = 0;
382 int err, headcount, mergeable; 382 int err, mergeable;
383 s16 headcount;
383 size_t vhost_hlen, sock_hlen; 384 size_t vhost_hlen, sock_hlen;
384 size_t vhost_len, sock_len; 385 size_t vhost_len, sock_len;
385 /* TODO: check that we are running from vhost_worker? */ 386 /* TODO: check that we are running from vhost_worker? */
diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig
index c101697a4ba..765a945f8ea 100644
--- a/drivers/video/backlight/Kconfig
+++ b/drivers/video/backlight/Kconfig
@@ -60,7 +60,8 @@ config LCD_LTV350QV
60 The LTV350QV panel is present on all ATSTK1000 boards. 60 The LTV350QV panel is present on all ATSTK1000 boards.
61 61
62config LCD_ILI9320 62config LCD_ILI9320
63 tristate 63 tristate "ILI Technology ILI9320 controller support"
64 depends on SPI
64 help 65 help
65 If you have a panel based on the ILI9320 controller chip 66 If you have a panel based on the ILI9320 controller chip
66 then say y to include a power driver for it. 67 then say y to include a power driver for it.
diff --git a/drivers/video/backlight/lm3639_bl.c b/drivers/video/backlight/lm3639_bl.c
index c6915c6c3cd..585949b5705 100644
--- a/drivers/video/backlight/lm3639_bl.c
+++ b/drivers/video/backlight/lm3639_bl.c
@@ -206,11 +206,11 @@ static ssize_t lm3639_bled_mode_store(struct device *dev,
206 206
207out: 207out:
208 dev_err(pchip->dev, "%s:i2c access fail to register\n", __func__); 208 dev_err(pchip->dev, "%s:i2c access fail to register\n", __func__);
209 return size; 209 return ret;
210 210
211out_input: 211out_input:
212 dev_err(pchip->dev, "%s:input conversion fail\n", __func__); 212 dev_err(pchip->dev, "%s:input conversion fail\n", __func__);
213 return size; 213 return ret;
214 214
215} 215}
216 216
diff --git a/drivers/video/omap2/dss/dsi.c b/drivers/video/omap2/dss/dsi.c
index d64ac384288..bee92846cfa 100644
--- a/drivers/video/omap2/dss/dsi.c
+++ b/drivers/video/omap2/dss/dsi.c
@@ -365,11 +365,20 @@ struct platform_device *dsi_get_dsidev_from_id(int module)
365 struct omap_dss_output *out; 365 struct omap_dss_output *out;
366 enum omap_dss_output_id id; 366 enum omap_dss_output_id id;
367 367
368 id = module == 0 ? OMAP_DSS_OUTPUT_DSI1 : OMAP_DSS_OUTPUT_DSI2; 368 switch (module) {
369 case 0:
370 id = OMAP_DSS_OUTPUT_DSI1;
371 break;
372 case 1:
373 id = OMAP_DSS_OUTPUT_DSI2;
374 break;
375 default:
376 return NULL;
377 }
369 378
370 out = omap_dss_get_output(id); 379 out = omap_dss_get_output(id);
371 380
372 return out->pdev; 381 return out ? out->pdev : NULL;
373} 382}
374 383
375static inline void dsi_write_reg(struct platform_device *dsidev, 384static inline void dsi_write_reg(struct platform_device *dsidev,
diff --git a/drivers/video/omap2/dss/dss.c b/drivers/video/omap2/dss/dss.c
index 2ab1c3e9655..5f6eea801b0 100644
--- a/drivers/video/omap2/dss/dss.c
+++ b/drivers/video/omap2/dss/dss.c
@@ -697,11 +697,15 @@ static int dss_get_clocks(void)
697 697
698 dss.dss_clk = clk; 698 dss.dss_clk = clk;
699 699
700 clk = clk_get(NULL, dss.feat->clk_name); 700 if (dss.feat->clk_name) {
701 if (IS_ERR(clk)) { 701 clk = clk_get(NULL, dss.feat->clk_name);
702 DSSERR("Failed to get %s\n", dss.feat->clk_name); 702 if (IS_ERR(clk)) {
703 r = PTR_ERR(clk); 703 DSSERR("Failed to get %s\n", dss.feat->clk_name);
704 goto err; 704 r = PTR_ERR(clk);
705 goto err;
706 }
707 } else {
708 clk = NULL;
705 } 709 }
706 710
707 dss.dpll4_m4_ck = clk; 711 dss.dpll4_m4_ck = clk;
@@ -805,10 +809,10 @@ static int __init dss_init_features(struct device *dev)
805 809
806 if (cpu_is_omap24xx()) 810 if (cpu_is_omap24xx())
807 src = &omap24xx_dss_feats; 811 src = &omap24xx_dss_feats;
808 else if (cpu_is_omap34xx())
809 src = &omap34xx_dss_feats;
810 else if (cpu_is_omap3630()) 812 else if (cpu_is_omap3630())
811 src = &omap3630_dss_feats; 813 src = &omap3630_dss_feats;
814 else if (cpu_is_omap34xx())
815 src = &omap34xx_dss_feats;
812 else if (cpu_is_omap44xx()) 816 else if (cpu_is_omap44xx())
813 src = &omap44xx_dss_feats; 817 src = &omap44xx_dss_feats;
814 else if (soc_is_omap54xx()) 818 else if (soc_is_omap54xx())
diff --git a/drivers/video/omap2/dss/hdmi.c b/drivers/video/omap2/dss/hdmi.c
index a48a7dd75b3..8c9b8b3b7f7 100644
--- a/drivers/video/omap2/dss/hdmi.c
+++ b/drivers/video/omap2/dss/hdmi.c
@@ -644,8 +644,10 @@ static void hdmi_dump_regs(struct seq_file *s)
644{ 644{
645 mutex_lock(&hdmi.lock); 645 mutex_lock(&hdmi.lock);
646 646
647 if (hdmi_runtime_get()) 647 if (hdmi_runtime_get()) {
648 mutex_unlock(&hdmi.lock);
648 return; 649 return;
650 }
649 651
650 hdmi.ip_data.ops->dump_wrapper(&hdmi.ip_data, s); 652 hdmi.ip_data.ops->dump_wrapper(&hdmi.ip_data, s);
651 hdmi.ip_data.ops->dump_pll(&hdmi.ip_data, s); 653 hdmi.ip_data.ops->dump_pll(&hdmi.ip_data, s);
diff --git a/drivers/video/omap2/omapfb/omapfb-ioctl.c b/drivers/video/omap2/omapfb/omapfb-ioctl.c
index 606b89f1235..d630b26a005 100644
--- a/drivers/video/omap2/omapfb/omapfb-ioctl.c
+++ b/drivers/video/omap2/omapfb/omapfb-ioctl.c
@@ -787,7 +787,7 @@ int omapfb_ioctl(struct fb_info *fbi, unsigned int cmd, unsigned long arg)
787 787
788 case OMAPFB_WAITFORVSYNC: 788 case OMAPFB_WAITFORVSYNC:
789 DBG("ioctl WAITFORVSYNC\n"); 789 DBG("ioctl WAITFORVSYNC\n");
790 if (!display && !display->output && !display->output->manager) { 790 if (!display || !display->output || !display->output->manager) {
791 r = -EINVAL; 791 r = -EINVAL;
792 break; 792 break;
793 } 793 }
diff --git a/drivers/video/xen-fbfront.c b/drivers/video/xen-fbfront.c
index b7f5173ff9e..917bb568168 100644
--- a/drivers/video/xen-fbfront.c
+++ b/drivers/video/xen-fbfront.c
@@ -641,7 +641,6 @@ static void xenfb_backend_changed(struct xenbus_device *dev,
641 case XenbusStateReconfiguring: 641 case XenbusStateReconfiguring:
642 case XenbusStateReconfigured: 642 case XenbusStateReconfigured:
643 case XenbusStateUnknown: 643 case XenbusStateUnknown:
644 case XenbusStateClosed:
645 break; 644 break;
646 645
647 case XenbusStateInitWait: 646 case XenbusStateInitWait:
@@ -670,6 +669,10 @@ InitWait:
670 info->feature_resize = val; 669 info->feature_resize = val;
671 break; 670 break;
672 671
672 case XenbusStateClosed:
673 if (dev->state == XenbusStateClosed)
674 break;
675 /* Missed the backend's CLOSING state -- fallthrough */
673 case XenbusStateClosing: 676 case XenbusStateClosing:
674 xenbus_frontend_closed(dev); 677 xenbus_frontend_closed(dev);
675 break; 678 break;
diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c
index 1e8659ca27e..809b0de59c0 100644
--- a/drivers/virtio/virtio.c
+++ b/drivers/virtio/virtio.c
@@ -225,8 +225,10 @@ EXPORT_SYMBOL_GPL(register_virtio_device);
225 225
226void unregister_virtio_device(struct virtio_device *dev) 226void unregister_virtio_device(struct virtio_device *dev)
227{ 227{
228 int index = dev->index; /* save for after device release */
229
228 device_unregister(&dev->dev); 230 device_unregister(&dev->dev);
229 ida_simple_remove(&virtio_index_ida, dev->index); 231 ida_simple_remove(&virtio_index_ida, index);
230} 232}
231EXPORT_SYMBOL_GPL(unregister_virtio_device); 233EXPORT_SYMBOL_GPL(unregister_virtio_device);
232 234
diff --git a/drivers/xen/Kconfig b/drivers/xen/Kconfig
index d4dffcd5287..126d8ce591c 100644
--- a/drivers/xen/Kconfig
+++ b/drivers/xen/Kconfig
@@ -3,6 +3,7 @@ menu "Xen driver support"
3 3
4config XEN_BALLOON 4config XEN_BALLOON
5 bool "Xen memory balloon driver" 5 bool "Xen memory balloon driver"
6 depends on !ARM
6 default y 7 default y
7 help 8 help
8 The balloon driver allows the Xen domain to request more memory from 9 The balloon driver allows the Xen domain to request more memory from
@@ -145,6 +146,7 @@ config SWIOTLB_XEN
145 146
146config XEN_TMEM 147config XEN_TMEM
147 bool 148 bool
149 depends on !ARM
148 default y if (CLEANCACHE || FRONTSWAP) 150 default y if (CLEANCACHE || FRONTSWAP)
149 help 151 help
150 Shim to interface in-kernel Transcendent Memory hooks 152 Shim to interface in-kernel Transcendent Memory hooks
diff --git a/drivers/xen/Makefile b/drivers/xen/Makefile
index 0e863703545..74354708c6c 100644
--- a/drivers/xen/Makefile
+++ b/drivers/xen/Makefile
@@ -2,6 +2,7 @@ ifneq ($(CONFIG_ARM),y)
2obj-y += manage.o balloon.o 2obj-y += manage.o balloon.o
3obj-$(CONFIG_HOTPLUG_CPU) += cpu_hotplug.o 3obj-$(CONFIG_HOTPLUG_CPU) += cpu_hotplug.o
4endif 4endif
5obj-$(CONFIG_X86) += fallback.o
5obj-y += grant-table.o features.o events.o 6obj-y += grant-table.o features.o events.o
6obj-y += xenbus/ 7obj-y += xenbus/
7 8
diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c
index 31ab82fda38..d6886d90ccf 100644
--- a/drivers/xen/balloon.c
+++ b/drivers/xen/balloon.c
@@ -55,7 +55,6 @@
55#include <asm/pgalloc.h> 55#include <asm/pgalloc.h>
56#include <asm/pgtable.h> 56#include <asm/pgtable.h>
57#include <asm/tlb.h> 57#include <asm/tlb.h>
58#include <asm/e820.h>
59 58
60#include <asm/xen/hypervisor.h> 59#include <asm/xen/hypervisor.h>
61#include <asm/xen/hypercall.h> 60#include <asm/xen/hypercall.h>
@@ -88,7 +87,7 @@ struct balloon_stats balloon_stats;
88EXPORT_SYMBOL_GPL(balloon_stats); 87EXPORT_SYMBOL_GPL(balloon_stats);
89 88
90/* We increase/decrease in batches which fit in a page */ 89/* We increase/decrease in batches which fit in a page */
91static unsigned long frame_list[PAGE_SIZE / sizeof(unsigned long)]; 90static xen_pfn_t frame_list[PAGE_SIZE / sizeof(unsigned long)];
92 91
93#ifdef CONFIG_HIGHMEM 92#ifdef CONFIG_HIGHMEM
94#define inc_totalhigh_pages() (totalhigh_pages++) 93#define inc_totalhigh_pages() (totalhigh_pages++)
diff --git a/drivers/xen/dbgp.c b/drivers/xen/dbgp.c
index 42569c77ccc..f3ccc80a455 100644
--- a/drivers/xen/dbgp.c
+++ b/drivers/xen/dbgp.c
@@ -8,7 +8,9 @@
8 8
9static int xen_dbgp_op(struct usb_hcd *hcd, int op) 9static int xen_dbgp_op(struct usb_hcd *hcd, int op)
10{ 10{
11#ifdef CONFIG_PCI
11 const struct device *ctrlr = hcd_to_bus(hcd)->controller; 12 const struct device *ctrlr = hcd_to_bus(hcd)->controller;
13#endif
12 struct physdev_dbgp_op dbgp; 14 struct physdev_dbgp_op dbgp;
13 15
14 if (!xen_initial_domain()) 16 if (!xen_initial_domain())
diff --git a/drivers/xen/events.c b/drivers/xen/events.c
index 59e10a1286d..0be4df39e95 100644
--- a/drivers/xen/events.c
+++ b/drivers/xen/events.c
@@ -115,7 +115,9 @@ struct irq_info {
115#define PIRQ_SHAREABLE (1 << 1) 115#define PIRQ_SHAREABLE (1 << 1)
116 116
117static int *evtchn_to_irq; 117static int *evtchn_to_irq;
118#ifdef CONFIG_X86
118static unsigned long *pirq_eoi_map; 119static unsigned long *pirq_eoi_map;
120#endif
119static bool (*pirq_needs_eoi)(unsigned irq); 121static bool (*pirq_needs_eoi)(unsigned irq);
120 122
121static DEFINE_PER_CPU(unsigned long [NR_EVENT_CHANNELS/BITS_PER_LONG], 123static DEFINE_PER_CPU(unsigned long [NR_EVENT_CHANNELS/BITS_PER_LONG],
@@ -277,10 +279,12 @@ static unsigned int cpu_from_evtchn(unsigned int evtchn)
277 return ret; 279 return ret;
278} 280}
279 281
282#ifdef CONFIG_X86
280static bool pirq_check_eoi_map(unsigned irq) 283static bool pirq_check_eoi_map(unsigned irq)
281{ 284{
282 return test_bit(pirq_from_irq(irq), pirq_eoi_map); 285 return test_bit(pirq_from_irq(irq), pirq_eoi_map);
283} 286}
287#endif
284 288
285static bool pirq_needs_eoi_flag(unsigned irq) 289static bool pirq_needs_eoi_flag(unsigned irq)
286{ 290{
@@ -1391,10 +1395,10 @@ void xen_evtchn_do_upcall(struct pt_regs *regs)
1391{ 1395{
1392 struct pt_regs *old_regs = set_irq_regs(regs); 1396 struct pt_regs *old_regs = set_irq_regs(regs);
1393 1397
1398 irq_enter();
1394#ifdef CONFIG_X86 1399#ifdef CONFIG_X86
1395 exit_idle(); 1400 exit_idle();
1396#endif 1401#endif
1397 irq_enter();
1398 1402
1399 __xen_evtchn_do_upcall(); 1403 __xen_evtchn_do_upcall();
1400 1404
diff --git a/drivers/xen/fallback.c b/drivers/xen/fallback.c
new file mode 100644
index 00000000000..0ef7c4d40f8
--- /dev/null
+++ b/drivers/xen/fallback.c
@@ -0,0 +1,80 @@
1#include <linux/kernel.h>
2#include <linux/string.h>
3#include <linux/bug.h>
4#include <linux/export.h>
5#include <asm/hypervisor.h>
6#include <asm/xen/hypercall.h>
7
8int xen_event_channel_op_compat(int cmd, void *arg)
9{
10 struct evtchn_op op;
11 int rc;
12
13 op.cmd = cmd;
14 memcpy(&op.u, arg, sizeof(op.u));
15 rc = _hypercall1(int, event_channel_op_compat, &op);
16
17 switch (cmd) {
18 case EVTCHNOP_close:
19 case EVTCHNOP_send:
20 case EVTCHNOP_bind_vcpu:
21 case EVTCHNOP_unmask:
22 /* no output */
23 break;
24
25#define COPY_BACK(eop) \
26 case EVTCHNOP_##eop: \
27 memcpy(arg, &op.u.eop, sizeof(op.u.eop)); \
28 break
29
30 COPY_BACK(bind_interdomain);
31 COPY_BACK(bind_virq);
32 COPY_BACK(bind_pirq);
33 COPY_BACK(status);
34 COPY_BACK(alloc_unbound);
35 COPY_BACK(bind_ipi);
36#undef COPY_BACK
37
38 default:
39 WARN_ON(rc != -ENOSYS);
40 break;
41 }
42
43 return rc;
44}
45EXPORT_SYMBOL_GPL(xen_event_channel_op_compat);
46
47int HYPERVISOR_physdev_op_compat(int cmd, void *arg)
48{
49 struct physdev_op op;
50 int rc;
51
52 op.cmd = cmd;
53 memcpy(&op.u, arg, sizeof(op.u));
54 rc = _hypercall1(int, physdev_op_compat, &op);
55
56 switch (cmd) {
57 case PHYSDEVOP_IRQ_UNMASK_NOTIFY:
58 case PHYSDEVOP_set_iopl:
59 case PHYSDEVOP_set_iobitmap:
60 case PHYSDEVOP_apic_write:
61 /* no output */
62 break;
63
64#define COPY_BACK(pop, fld) \
65 case PHYSDEVOP_##pop: \
66 memcpy(arg, &op.u.fld, sizeof(op.u.fld)); \
67 break
68
69 COPY_BACK(irq_status_query, irq_status_query);
70 COPY_BACK(apic_read, apic_op);
71 COPY_BACK(ASSIGN_VECTOR, irq_op);
72#undef COPY_BACK
73
74 default:
75 WARN_ON(rc != -ENOSYS);
76 break;
77 }
78
79 return rc;
80}
diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c
index 610bfc6be17..2e22df2f7a3 100644
--- a/drivers/xen/gntdev.c
+++ b/drivers/xen/gntdev.c
@@ -105,6 +105,21 @@ static void gntdev_print_maps(struct gntdev_priv *priv,
105#endif 105#endif
106} 106}
107 107
108static void gntdev_free_map(struct grant_map *map)
109{
110 if (map == NULL)
111 return;
112
113 if (map->pages)
114 free_xenballooned_pages(map->count, map->pages);
115 kfree(map->pages);
116 kfree(map->grants);
117 kfree(map->map_ops);
118 kfree(map->unmap_ops);
119 kfree(map->kmap_ops);
120 kfree(map);
121}
122
108static struct grant_map *gntdev_alloc_map(struct gntdev_priv *priv, int count) 123static struct grant_map *gntdev_alloc_map(struct gntdev_priv *priv, int count)
109{ 124{
110 struct grant_map *add; 125 struct grant_map *add;
@@ -142,12 +157,7 @@ static struct grant_map *gntdev_alloc_map(struct gntdev_priv *priv, int count)
142 return add; 157 return add;
143 158
144err: 159err:
145 kfree(add->pages); 160 gntdev_free_map(add);
146 kfree(add->grants);
147 kfree(add->map_ops);
148 kfree(add->unmap_ops);
149 kfree(add->kmap_ops);
150 kfree(add);
151 return NULL; 161 return NULL;
152} 162}
153 163
@@ -198,17 +208,9 @@ static void gntdev_put_map(struct grant_map *map)
198 evtchn_put(map->notify.event); 208 evtchn_put(map->notify.event);
199 } 209 }
200 210
201 if (map->pages) { 211 if (map->pages && !use_ptemod)
202 if (!use_ptemod) 212 unmap_grant_pages(map, 0, map->count);
203 unmap_grant_pages(map, 0, map->count); 213 gntdev_free_map(map);
204
205 free_xenballooned_pages(map->count, map->pages);
206 }
207 kfree(map->pages);
208 kfree(map->grants);
209 kfree(map->map_ops);
210 kfree(map->unmap_ops);
211 kfree(map);
212} 214}
213 215
214/* ------------------------------------------------------------------ */ 216/* ------------------------------------------------------------------ */
diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c
index b2b0a375b34..b91f14e8316 100644
--- a/drivers/xen/grant-table.c
+++ b/drivers/xen/grant-table.c
@@ -84,7 +84,7 @@ struct gnttab_ops {
84 * nr_gframes is the number of frames to map grant table. Returning 84 * nr_gframes is the number of frames to map grant table. Returning
85 * GNTST_okay means success and negative value means failure. 85 * GNTST_okay means success and negative value means failure.
86 */ 86 */
87 int (*map_frames)(unsigned long *frames, unsigned int nr_gframes); 87 int (*map_frames)(xen_pfn_t *frames, unsigned int nr_gframes);
88 /* 88 /*
89 * Release a list of frames which are mapped in map_frames for grant 89 * Release a list of frames which are mapped in map_frames for grant
90 * entry status. 90 * entry status.
@@ -960,7 +960,7 @@ static unsigned nr_status_frames(unsigned nr_grant_frames)
960 return (nr_grant_frames * GREFS_PER_GRANT_FRAME + SPP - 1) / SPP; 960 return (nr_grant_frames * GREFS_PER_GRANT_FRAME + SPP - 1) / SPP;
961} 961}
962 962
963static int gnttab_map_frames_v1(unsigned long *frames, unsigned int nr_gframes) 963static int gnttab_map_frames_v1(xen_pfn_t *frames, unsigned int nr_gframes)
964{ 964{
965 int rc; 965 int rc;
966 966
@@ -977,7 +977,7 @@ static void gnttab_unmap_frames_v1(void)
977 arch_gnttab_unmap(gnttab_shared.addr, nr_grant_frames); 977 arch_gnttab_unmap(gnttab_shared.addr, nr_grant_frames);
978} 978}
979 979
980static int gnttab_map_frames_v2(unsigned long *frames, unsigned int nr_gframes) 980static int gnttab_map_frames_v2(xen_pfn_t *frames, unsigned int nr_gframes)
981{ 981{
982 uint64_t *sframes; 982 uint64_t *sframes;
983 unsigned int nr_sframes; 983 unsigned int nr_sframes;
@@ -1029,7 +1029,7 @@ static void gnttab_unmap_frames_v2(void)
1029static int gnttab_map(unsigned int start_idx, unsigned int end_idx) 1029static int gnttab_map(unsigned int start_idx, unsigned int end_idx)
1030{ 1030{
1031 struct gnttab_setup_table setup; 1031 struct gnttab_setup_table setup;
1032 unsigned long *frames; 1032 xen_pfn_t *frames;
1033 unsigned int nr_gframes = end_idx + 1; 1033 unsigned int nr_gframes = end_idx + 1;
1034 int rc; 1034 int rc;
1035 1035
diff --git a/drivers/xen/privcmd.c b/drivers/xen/privcmd.c
index 8adb9cc267f..71f5c459b08 100644
--- a/drivers/xen/privcmd.c
+++ b/drivers/xen/privcmd.c
@@ -361,13 +361,13 @@ static long privcmd_ioctl_mmap_batch(void __user *udata, int version)
361 down_write(&mm->mmap_sem); 361 down_write(&mm->mmap_sem);
362 362
363 vma = find_vma(mm, m.addr); 363 vma = find_vma(mm, m.addr);
364 ret = -EINVAL;
365 if (!vma || 364 if (!vma ||
366 vma->vm_ops != &privcmd_vm_ops || 365 vma->vm_ops != &privcmd_vm_ops ||
367 (m.addr != vma->vm_start) || 366 (m.addr != vma->vm_start) ||
368 ((m.addr + (nr_pages << PAGE_SHIFT)) != vma->vm_end) || 367 ((m.addr + (nr_pages << PAGE_SHIFT)) != vma->vm_end) ||
369 !privcmd_enforce_singleshot_mapping(vma)) { 368 !privcmd_enforce_singleshot_mapping(vma)) {
370 up_write(&mm->mmap_sem); 369 up_write(&mm->mmap_sem);
370 ret = -EINVAL;
371 goto out; 371 goto out;
372 } 372 }
373 373
@@ -383,12 +383,16 @@ static long privcmd_ioctl_mmap_batch(void __user *udata, int version)
383 383
384 up_write(&mm->mmap_sem); 384 up_write(&mm->mmap_sem);
385 385
386 if (state.global_error && (version == 1)) { 386 if (version == 1) {
387 /* Write back errors in second pass. */ 387 if (state.global_error) {
388 state.user_mfn = (xen_pfn_t *)m.arr; 388 /* Write back errors in second pass. */
389 state.err = err_array; 389 state.user_mfn = (xen_pfn_t *)m.arr;
390 ret = traverse_pages(m.num, sizeof(xen_pfn_t), 390 state.err = err_array;
391 &pagelist, mmap_return_errors_v1, &state); 391 ret = traverse_pages(m.num, sizeof(xen_pfn_t),
392 &pagelist, mmap_return_errors_v1, &state);
393 } else
394 ret = 0;
395
392 } else if (version == 2) { 396 } else if (version == 2) {
393 ret = __copy_to_user(m.err, err_array, m.num * sizeof(int)); 397 ret = __copy_to_user(m.err, err_array, m.num * sizeof(int));
394 if (ret) 398 if (ret)
diff --git a/drivers/xen/sys-hypervisor.c b/drivers/xen/sys-hypervisor.c
index 5e5ad7e2885..96453f8a85c 100644
--- a/drivers/xen/sys-hypervisor.c
+++ b/drivers/xen/sys-hypervisor.c
@@ -11,6 +11,7 @@
11#include <linux/kernel.h> 11#include <linux/kernel.h>
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/kobject.h> 13#include <linux/kobject.h>
14#include <linux/err.h>
14 15
15#include <asm/xen/hypervisor.h> 16#include <asm/xen/hypervisor.h>
16#include <asm/xen/hypercall.h> 17#include <asm/xen/hypercall.h>
@@ -284,7 +285,8 @@ static ssize_t virtual_start_show(struct hyp_sysfs_attr *attr, char *buffer)
284 ret = HYPERVISOR_xen_version(XENVER_platform_parameters, 285 ret = HYPERVISOR_xen_version(XENVER_platform_parameters,
285 parms); 286 parms);
286 if (!ret) 287 if (!ret)
287 ret = sprintf(buffer, "%lx\n", parms->virt_start); 288 ret = sprintf(buffer, "%"PRI_xen_ulong"\n",
289 parms->virt_start);
288 kfree(parms); 290 kfree(parms);
289 } 291 }
290 292
diff --git a/drivers/xen/xen-pciback/vpci.c b/drivers/xen/xen-pciback/vpci.c
index 46d140baebd..0f478ac483c 100644
--- a/drivers/xen/xen-pciback/vpci.c
+++ b/drivers/xen/xen-pciback/vpci.c
@@ -89,9 +89,15 @@ static int __xen_pcibk_add_pci_dev(struct xen_pcibk_device *pdev,
89 89
90 mutex_lock(&vpci_dev->lock); 90 mutex_lock(&vpci_dev->lock);
91 91
92 /* Keep multi-function devices together on the virtual PCI bus */ 92 /*
93 for (slot = 0; slot < PCI_SLOT_MAX; slot++) { 93 * Keep multi-function devices together on the virtual PCI bus, except
94 if (!list_empty(&vpci_dev->dev_list[slot])) { 94 * virtual functions.
95 */
96 if (!dev->is_virtfn) {
97 for (slot = 0; slot < PCI_SLOT_MAX; slot++) {
98 if (list_empty(&vpci_dev->dev_list[slot]))
99 continue;
100
95 t = list_entry(list_first(&vpci_dev->dev_list[slot]), 101 t = list_entry(list_first(&vpci_dev->dev_list[slot]),
96 struct pci_dev_entry, list); 102 struct pci_dev_entry, list);
97 103
@@ -116,7 +122,7 @@ static int __xen_pcibk_add_pci_dev(struct xen_pcibk_device *pdev,
116 pci_name(dev), slot); 122 pci_name(dev), slot);
117 list_add_tail(&dev_entry->list, 123 list_add_tail(&dev_entry->list,
118 &vpci_dev->dev_list[slot]); 124 &vpci_dev->dev_list[slot]);
119 func = PCI_FUNC(dev->devfn); 125 func = dev->is_virtfn ? 0 : PCI_FUNC(dev->devfn);
120 goto unlock; 126 goto unlock;
121 } 127 }
122 } 128 }
diff --git a/drivers/xen/xenbus/xenbus_dev_frontend.c b/drivers/xen/xenbus/xenbus_dev_frontend.c
index 89f76252a16..ac727028e65 100644
--- a/drivers/xen/xenbus/xenbus_dev_frontend.c
+++ b/drivers/xen/xenbus/xenbus_dev_frontend.c
@@ -458,7 +458,7 @@ static ssize_t xenbus_file_write(struct file *filp,
458 goto out; 458 goto out;
459 459
460 /* Can't write a xenbus message larger we can buffer */ 460 /* Can't write a xenbus message larger we can buffer */
461 if ((len + u->len) > sizeof(u->u.buffer)) { 461 if (len > sizeof(u->u.buffer) - u->len) {
462 /* On error, dump existing buffer */ 462 /* On error, dump existing buffer */
463 u->len = 0; 463 u->len = 0;
464 rc = -EINVAL; 464 rc = -EINVAL;
diff --git a/drivers/xen/xenbus/xenbus_xs.c b/drivers/xen/xenbus/xenbus_xs.c
index 48220e129f8..acedeabe589 100644
--- a/drivers/xen/xenbus/xenbus_xs.c
+++ b/drivers/xen/xenbus/xenbus_xs.c
@@ -625,8 +625,9 @@ static struct xenbus_watch *find_watch(const char *token)
625 * so if we are running on anything older than 4 do not attempt to read 625 * so if we are running on anything older than 4 do not attempt to read
626 * control/platform-feature-xs_reset_watches. 626 * control/platform-feature-xs_reset_watches.
627 */ 627 */
628static bool xen_strict_xenbus_quirk() 628static bool xen_strict_xenbus_quirk(void)
629{ 629{
630#ifdef CONFIG_X86
630 uint32_t eax, ebx, ecx, edx, base; 631 uint32_t eax, ebx, ecx, edx, base;
631 632
632 base = xen_cpuid_base(); 633 base = xen_cpuid_base();
@@ -634,6 +635,7 @@ static bool xen_strict_xenbus_quirk()
634 635
635 if ((eax >> 16) < 4) 636 if ((eax >> 16) < 4)
636 return true; 637 return true;
638#endif
637 return false; 639 return false;
638 640
639} 641}
diff --git a/fs/bio.c b/fs/bio.c
index 9298c65ad9c..b96fc6ce485 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -75,6 +75,7 @@ static struct kmem_cache *bio_find_or_create_slab(unsigned int extra_size)
75 unsigned int sz = sizeof(struct bio) + extra_size; 75 unsigned int sz = sizeof(struct bio) + extra_size;
76 struct kmem_cache *slab = NULL; 76 struct kmem_cache *slab = NULL;
77 struct bio_slab *bslab, *new_bio_slabs; 77 struct bio_slab *bslab, *new_bio_slabs;
78 unsigned int new_bio_slab_max;
78 unsigned int i, entry = -1; 79 unsigned int i, entry = -1;
79 80
80 mutex_lock(&bio_slab_lock); 81 mutex_lock(&bio_slab_lock);
@@ -97,12 +98,13 @@ static struct kmem_cache *bio_find_or_create_slab(unsigned int extra_size)
97 goto out_unlock; 98 goto out_unlock;
98 99
99 if (bio_slab_nr == bio_slab_max && entry == -1) { 100 if (bio_slab_nr == bio_slab_max && entry == -1) {
100 bio_slab_max <<= 1; 101 new_bio_slab_max = bio_slab_max << 1;
101 new_bio_slabs = krealloc(bio_slabs, 102 new_bio_slabs = krealloc(bio_slabs,
102 bio_slab_max * sizeof(struct bio_slab), 103 new_bio_slab_max * sizeof(struct bio_slab),
103 GFP_KERNEL); 104 GFP_KERNEL);
104 if (!new_bio_slabs) 105 if (!new_bio_slabs)
105 goto out_unlock; 106 goto out_unlock;
107 bio_slab_max = new_bio_slab_max;
106 bio_slabs = new_bio_slabs; 108 bio_slabs = new_bio_slabs;
107 } 109 }
108 if (entry == -1) 110 if (entry == -1)
diff --git a/fs/block_dev.c b/fs/block_dev.c
index b3c1d3dae77..1a1e5e3b1ea 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -1661,6 +1661,39 @@ static int blkdev_mmap(struct file *file, struct vm_area_struct *vma)
1661 return ret; 1661 return ret;
1662} 1662}
1663 1663
1664static ssize_t blkdev_splice_read(struct file *file, loff_t *ppos,
1665 struct pipe_inode_info *pipe, size_t len,
1666 unsigned int flags)
1667{
1668 ssize_t ret;
1669 struct block_device *bdev = I_BDEV(file->f_mapping->host);
1670
1671 percpu_down_read(&bdev->bd_block_size_semaphore);
1672
1673 ret = generic_file_splice_read(file, ppos, pipe, len, flags);
1674
1675 percpu_up_read(&bdev->bd_block_size_semaphore);
1676
1677 return ret;
1678}
1679
1680static ssize_t blkdev_splice_write(struct pipe_inode_info *pipe,
1681 struct file *file, loff_t *ppos, size_t len,
1682 unsigned int flags)
1683{
1684 ssize_t ret;
1685 struct block_device *bdev = I_BDEV(file->f_mapping->host);
1686
1687 percpu_down_read(&bdev->bd_block_size_semaphore);
1688
1689 ret = generic_file_splice_write(pipe, file, ppos, len, flags);
1690
1691 percpu_up_read(&bdev->bd_block_size_semaphore);
1692
1693 return ret;
1694}
1695
1696
1664/* 1697/*
1665 * Try to release a page associated with block device when the system 1698 * Try to release a page associated with block device when the system
1666 * is under memory pressure. 1699 * is under memory pressure.
@@ -1699,8 +1732,8 @@ const struct file_operations def_blk_fops = {
1699#ifdef CONFIG_COMPAT 1732#ifdef CONFIG_COMPAT
1700 .compat_ioctl = compat_blkdev_ioctl, 1733 .compat_ioctl = compat_blkdev_ioctl,
1701#endif 1734#endif
1702 .splice_read = generic_file_splice_read, 1735 .splice_read = blkdev_splice_read,
1703 .splice_write = generic_file_splice_write, 1736 .splice_write = blkdev_splice_write,
1704}; 1737};
1705 1738
1706int ioctl_by_bdev(struct block_device *bdev, unsigned cmd, unsigned long arg) 1739int ioctl_by_bdev(struct block_device *bdev, unsigned cmd, unsigned long arg)
diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
index f3187938e08..208d8aa5b07 100644
--- a/fs/btrfs/backref.c
+++ b/fs/btrfs/backref.c
@@ -283,9 +283,7 @@ static int __resolve_indirect_ref(struct btrfs_fs_info *fs_info,
283 goto out; 283 goto out;
284 } 284 }
285 285
286 rcu_read_lock(); 286 root_level = btrfs_old_root_level(root, time_seq);
287 root_level = btrfs_header_level(root->node);
288 rcu_read_unlock();
289 287
290 if (root_level + 1 == level) 288 if (root_level + 1 == level)
291 goto out; 289 goto out;
@@ -1177,16 +1175,15 @@ int btrfs_find_one_extref(struct btrfs_root *root, u64 inode_objectid,
1177 return ret; 1175 return ret;
1178} 1176}
1179 1177
1180static char *ref_to_path(struct btrfs_root *fs_root, 1178char *btrfs_ref_to_path(struct btrfs_root *fs_root, struct btrfs_path *path,
1181 struct btrfs_path *path, 1179 u32 name_len, unsigned long name_off,
1182 u32 name_len, unsigned long name_off, 1180 struct extent_buffer *eb_in, u64 parent,
1183 struct extent_buffer *eb_in, u64 parent, 1181 char *dest, u32 size)
1184 char *dest, u32 size)
1185{ 1182{
1186 int slot; 1183 int slot;
1187 u64 next_inum; 1184 u64 next_inum;
1188 int ret; 1185 int ret;
1189 s64 bytes_left = size - 1; 1186 s64 bytes_left = ((s64)size) - 1;
1190 struct extent_buffer *eb = eb_in; 1187 struct extent_buffer *eb = eb_in;
1191 struct btrfs_key found_key; 1188 struct btrfs_key found_key;
1192 int leave_spinning = path->leave_spinning; 1189 int leave_spinning = path->leave_spinning;
@@ -1266,10 +1263,10 @@ char *btrfs_iref_to_path(struct btrfs_root *fs_root,
1266 struct extent_buffer *eb_in, u64 parent, 1263 struct extent_buffer *eb_in, u64 parent,
1267 char *dest, u32 size) 1264 char *dest, u32 size)
1268{ 1265{
1269 return ref_to_path(fs_root, path, 1266 return btrfs_ref_to_path(fs_root, path,
1270 btrfs_inode_ref_name_len(eb_in, iref), 1267 btrfs_inode_ref_name_len(eb_in, iref),
1271 (unsigned long)(iref + 1), 1268 (unsigned long)(iref + 1),
1272 eb_in, parent, dest, size); 1269 eb_in, parent, dest, size);
1273} 1270}
1274 1271
1275/* 1272/*
@@ -1715,9 +1712,8 @@ static int inode_to_path(u64 inum, u32 name_len, unsigned long name_off,
1715 ipath->fspath->bytes_left - s_ptr : 0; 1712 ipath->fspath->bytes_left - s_ptr : 0;
1716 1713
1717 fspath_min = (char *)ipath->fspath->val + (i + 1) * s_ptr; 1714 fspath_min = (char *)ipath->fspath->val + (i + 1) * s_ptr;
1718 fspath = ref_to_path(ipath->fs_root, ipath->btrfs_path, name_len, 1715 fspath = btrfs_ref_to_path(ipath->fs_root, ipath->btrfs_path, name_len,
1719 name_off, eb, inum, fspath_min, 1716 name_off, eb, inum, fspath_min, bytes_left);
1720 bytes_left);
1721 if (IS_ERR(fspath)) 1717 if (IS_ERR(fspath))
1722 return PTR_ERR(fspath); 1718 return PTR_ERR(fspath);
1723 1719
diff --git a/fs/btrfs/backref.h b/fs/btrfs/backref.h
index e75533043a5..d61feca7945 100644
--- a/fs/btrfs/backref.h
+++ b/fs/btrfs/backref.h
@@ -62,6 +62,10 @@ int btrfs_find_all_roots(struct btrfs_trans_handle *trans,
62char *btrfs_iref_to_path(struct btrfs_root *fs_root, struct btrfs_path *path, 62char *btrfs_iref_to_path(struct btrfs_root *fs_root, struct btrfs_path *path,
63 struct btrfs_inode_ref *iref, struct extent_buffer *eb, 63 struct btrfs_inode_ref *iref, struct extent_buffer *eb,
64 u64 parent, char *dest, u32 size); 64 u64 parent, char *dest, u32 size);
65char *btrfs_ref_to_path(struct btrfs_root *fs_root, struct btrfs_path *path,
66 u32 name_len, unsigned long name_off,
67 struct extent_buffer *eb_in, u64 parent,
68 char *dest, u32 size);
65 69
66struct btrfs_data_container *init_data_container(u32 total_bytes); 70struct btrfs_data_container *init_data_container(u32 total_bytes);
67struct inode_fs_paths *init_ipath(s32 total_bytes, struct btrfs_root *fs_root, 71struct inode_fs_paths *init_ipath(s32 total_bytes, struct btrfs_root *fs_root,
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index b3343621100..cdfb4c49a80 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -596,6 +596,11 @@ tree_mod_log_insert_move(struct btrfs_fs_info *fs_info,
596 if (tree_mod_dont_log(fs_info, eb)) 596 if (tree_mod_dont_log(fs_info, eb))
597 return 0; 597 return 0;
598 598
599 /*
600 * When we override something during the move, we log these removals.
601 * This can only happen when we move towards the beginning of the
602 * buffer, i.e. dst_slot < src_slot.
603 */
599 for (i = 0; i + dst_slot < src_slot && i < nr_items; i++) { 604 for (i = 0; i + dst_slot < src_slot && i < nr_items; i++) {
600 ret = tree_mod_log_insert_key_locked(fs_info, eb, i + dst_slot, 605 ret = tree_mod_log_insert_key_locked(fs_info, eb, i + dst_slot,
601 MOD_LOG_KEY_REMOVE_WHILE_MOVING); 606 MOD_LOG_KEY_REMOVE_WHILE_MOVING);
@@ -647,8 +652,6 @@ tree_mod_log_insert_root(struct btrfs_fs_info *fs_info,
647 if (tree_mod_dont_log(fs_info, NULL)) 652 if (tree_mod_dont_log(fs_info, NULL))
648 return 0; 653 return 0;
649 654
650 __tree_mod_log_free_eb(fs_info, old_root);
651
652 ret = tree_mod_alloc(fs_info, flags, &tm); 655 ret = tree_mod_alloc(fs_info, flags, &tm);
653 if (ret < 0) 656 if (ret < 0)
654 goto out; 657 goto out;
@@ -926,12 +929,7 @@ static noinline int update_ref_for_cow(struct btrfs_trans_handle *trans,
926 ret = btrfs_dec_ref(trans, root, buf, 1, 1); 929 ret = btrfs_dec_ref(trans, root, buf, 1, 1);
927 BUG_ON(ret); /* -ENOMEM */ 930 BUG_ON(ret); /* -ENOMEM */
928 } 931 }
929 /* 932 tree_mod_log_free_eb(root->fs_info, buf);
930 * don't log freeing in case we're freeing the root node, this
931 * is done by tree_mod_log_set_root_pointer later
932 */
933 if (buf != root->node && btrfs_header_level(buf) != 0)
934 tree_mod_log_free_eb(root->fs_info, buf);
935 clean_tree_block(trans, root, buf); 933 clean_tree_block(trans, root, buf);
936 *last_ref = 1; 934 *last_ref = 1;
937 } 935 }
@@ -1225,6 +1223,8 @@ tree_mod_log_rewind(struct btrfs_fs_info *fs_info, struct extent_buffer *eb,
1225 free_extent_buffer(eb); 1223 free_extent_buffer(eb);
1226 1224
1227 __tree_mod_log_rewind(eb_rewin, time_seq, tm); 1225 __tree_mod_log_rewind(eb_rewin, time_seq, tm);
1226 WARN_ON(btrfs_header_nritems(eb_rewin) >
1227 BTRFS_NODEPTRS_PER_BLOCK(fs_info->fs_root));
1228 1228
1229 return eb_rewin; 1229 return eb_rewin;
1230} 1230}
@@ -1241,9 +1241,11 @@ get_old_root(struct btrfs_root *root, u64 time_seq)
1241{ 1241{
1242 struct tree_mod_elem *tm; 1242 struct tree_mod_elem *tm;
1243 struct extent_buffer *eb; 1243 struct extent_buffer *eb;
1244 struct extent_buffer *old;
1244 struct tree_mod_root *old_root = NULL; 1245 struct tree_mod_root *old_root = NULL;
1245 u64 old_generation = 0; 1246 u64 old_generation = 0;
1246 u64 logical; 1247 u64 logical;
1248 u32 blocksize;
1247 1249
1248 eb = btrfs_read_lock_root_node(root); 1250 eb = btrfs_read_lock_root_node(root);
1249 tm = __tree_mod_log_oldest_root(root->fs_info, root, time_seq); 1251 tm = __tree_mod_log_oldest_root(root->fs_info, root, time_seq);
@@ -1259,14 +1261,32 @@ get_old_root(struct btrfs_root *root, u64 time_seq)
1259 } 1261 }
1260 1262
1261 tm = tree_mod_log_search(root->fs_info, logical, time_seq); 1263 tm = tree_mod_log_search(root->fs_info, logical, time_seq);
1262 if (old_root) 1264 if (old_root && tm && tm->op != MOD_LOG_KEY_REMOVE_WHILE_FREEING) {
1265 btrfs_tree_read_unlock(root->node);
1266 free_extent_buffer(root->node);
1267 blocksize = btrfs_level_size(root, old_root->level);
1268 old = read_tree_block(root, logical, blocksize, 0);
1269 if (!old) {
1270 pr_warn("btrfs: failed to read tree block %llu from get_old_root\n",
1271 logical);
1272 WARN_ON(1);
1273 } else {
1274 eb = btrfs_clone_extent_buffer(old);
1275 free_extent_buffer(old);
1276 }
1277 } else if (old_root) {
1278 btrfs_tree_read_unlock(root->node);
1279 free_extent_buffer(root->node);
1263 eb = alloc_dummy_extent_buffer(logical, root->nodesize); 1280 eb = alloc_dummy_extent_buffer(logical, root->nodesize);
1264 else 1281 } else {
1265 eb = btrfs_clone_extent_buffer(root->node); 1282 eb = btrfs_clone_extent_buffer(root->node);
1266 btrfs_tree_read_unlock(root->node); 1283 btrfs_tree_read_unlock(root->node);
1267 free_extent_buffer(root->node); 1284 free_extent_buffer(root->node);
1285 }
1286
1268 if (!eb) 1287 if (!eb)
1269 return NULL; 1288 return NULL;
1289 extent_buffer_get(eb);
1270 btrfs_tree_read_lock(eb); 1290 btrfs_tree_read_lock(eb);
1271 if (old_root) { 1291 if (old_root) {
1272 btrfs_set_header_bytenr(eb, eb->start); 1292 btrfs_set_header_bytenr(eb, eb->start);
@@ -1279,11 +1299,28 @@ get_old_root(struct btrfs_root *root, u64 time_seq)
1279 __tree_mod_log_rewind(eb, time_seq, tm); 1299 __tree_mod_log_rewind(eb, time_seq, tm);
1280 else 1300 else
1281 WARN_ON(btrfs_header_level(eb) != 0); 1301 WARN_ON(btrfs_header_level(eb) != 0);
1282 extent_buffer_get(eb); 1302 WARN_ON(btrfs_header_nritems(eb) > BTRFS_NODEPTRS_PER_BLOCK(root));
1283 1303
1284 return eb; 1304 return eb;
1285} 1305}
1286 1306
1307int btrfs_old_root_level(struct btrfs_root *root, u64 time_seq)
1308{
1309 struct tree_mod_elem *tm;
1310 int level;
1311
1312 tm = __tree_mod_log_oldest_root(root->fs_info, root, time_seq);
1313 if (tm && tm->op == MOD_LOG_ROOT_REPLACE) {
1314 level = tm->old_root.level;
1315 } else {
1316 rcu_read_lock();
1317 level = btrfs_header_level(root->node);
1318 rcu_read_unlock();
1319 }
1320
1321 return level;
1322}
1323
1287static inline int should_cow_block(struct btrfs_trans_handle *trans, 1324static inline int should_cow_block(struct btrfs_trans_handle *trans,
1288 struct btrfs_root *root, 1325 struct btrfs_root *root,
1289 struct extent_buffer *buf) 1326 struct extent_buffer *buf)
@@ -1725,6 +1762,7 @@ static noinline int balance_level(struct btrfs_trans_handle *trans,
1725 goto enospc; 1762 goto enospc;
1726 } 1763 }
1727 1764
1765 tree_mod_log_free_eb(root->fs_info, root->node);
1728 tree_mod_log_set_root_pointer(root, child); 1766 tree_mod_log_set_root_pointer(root, child);
1729 rcu_assign_pointer(root->node, child); 1767 rcu_assign_pointer(root->node, child);
1730 1768
@@ -2970,8 +3008,10 @@ static int push_node_left(struct btrfs_trans_handle *trans,
2970 push_items * sizeof(struct btrfs_key_ptr)); 3008 push_items * sizeof(struct btrfs_key_ptr));
2971 3009
2972 if (push_items < src_nritems) { 3010 if (push_items < src_nritems) {
2973 tree_mod_log_eb_move(root->fs_info, src, 0, push_items, 3011 /*
2974 src_nritems - push_items); 3012 * don't call tree_mod_log_eb_move here, key removal was already
3013 * fully logged by tree_mod_log_eb_copy above.
3014 */
2975 memmove_extent_buffer(src, btrfs_node_key_ptr_offset(0), 3015 memmove_extent_buffer(src, btrfs_node_key_ptr_offset(0),
2976 btrfs_node_key_ptr_offset(push_items), 3016 btrfs_node_key_ptr_offset(push_items),
2977 (src_nritems - push_items) * 3017 (src_nritems - push_items) *
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 926c9ffc66d..c72ead86950 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -3120,6 +3120,7 @@ static inline u64 btrfs_inc_tree_mod_seq(struct btrfs_fs_info *fs_info)
3120{ 3120{
3121 return atomic_inc_return(&fs_info->tree_mod_seq); 3121 return atomic_inc_return(&fs_info->tree_mod_seq);
3122} 3122}
3123int btrfs_old_root_level(struct btrfs_root *root, u64 time_seq);
3123 3124
3124/* root-item.c */ 3125/* root-item.c */
3125int btrfs_find_root_ref(struct btrfs_root *tree_root, 3126int btrfs_find_root_ref(struct btrfs_root *tree_root,
@@ -3338,6 +3339,8 @@ struct extent_map *btrfs_get_extent(struct inode *inode, struct page *page,
3338int btrfs_update_inode(struct btrfs_trans_handle *trans, 3339int btrfs_update_inode(struct btrfs_trans_handle *trans,
3339 struct btrfs_root *root, 3340 struct btrfs_root *root,
3340 struct inode *inode); 3341 struct inode *inode);
3342int btrfs_update_inode_fallback(struct btrfs_trans_handle *trans,
3343 struct btrfs_root *root, struct inode *inode);
3341int btrfs_orphan_add(struct btrfs_trans_handle *trans, struct inode *inode); 3344int btrfs_orphan_add(struct btrfs_trans_handle *trans, struct inode *inode);
3342int btrfs_orphan_del(struct btrfs_trans_handle *trans, struct inode *inode); 3345int btrfs_orphan_del(struct btrfs_trans_handle *trans, struct inode *inode);
3343int btrfs_orphan_cleanup(struct btrfs_root *root); 3346int btrfs_orphan_cleanup(struct btrfs_root *root);
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 8036d3a8485..472873a94d9 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -4110,8 +4110,8 @@ struct extent_buffer *alloc_dummy_extent_buffer(u64 start, unsigned long len)
4110 4110
4111 return eb; 4111 return eb;
4112err: 4112err:
4113 for (i--; i >= 0; i--) 4113 for (; i > 0; i--)
4114 __free_page(eb->pages[i]); 4114 __free_page(eb->pages[i - 1]);
4115 __free_extent_buffer(eb); 4115 __free_extent_buffer(eb);
4116 return NULL; 4116 return NULL;
4117} 4117}
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 85a1e5053fe..95542a1b3df 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -94,8 +94,6 @@ static noinline int cow_file_range(struct inode *inode,
94 struct page *locked_page, 94 struct page *locked_page,
95 u64 start, u64 end, int *page_started, 95 u64 start, u64 end, int *page_started,
96 unsigned long *nr_written, int unlock); 96 unsigned long *nr_written, int unlock);
97static noinline int btrfs_update_inode_fallback(struct btrfs_trans_handle *trans,
98 struct btrfs_root *root, struct inode *inode);
99 97
100static int btrfs_init_inode_security(struct btrfs_trans_handle *trans, 98static int btrfs_init_inode_security(struct btrfs_trans_handle *trans,
101 struct inode *inode, struct inode *dir, 99 struct inode *inode, struct inode *dir,
@@ -2746,8 +2744,9 @@ noinline int btrfs_update_inode(struct btrfs_trans_handle *trans,
2746 return btrfs_update_inode_item(trans, root, inode); 2744 return btrfs_update_inode_item(trans, root, inode);
2747} 2745}
2748 2746
2749static noinline int btrfs_update_inode_fallback(struct btrfs_trans_handle *trans, 2747noinline int btrfs_update_inode_fallback(struct btrfs_trans_handle *trans,
2750 struct btrfs_root *root, struct inode *inode) 2748 struct btrfs_root *root,
2749 struct inode *inode)
2751{ 2750{
2752 int ret; 2751 int ret;
2753 2752
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 61168805f17..8fcf9a59c28 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -343,7 +343,8 @@ static noinline int btrfs_ioctl_fitrim(struct file *file, void __user *arg)
343 return -EOPNOTSUPP; 343 return -EOPNOTSUPP;
344 if (copy_from_user(&range, arg, sizeof(range))) 344 if (copy_from_user(&range, arg, sizeof(range)))
345 return -EFAULT; 345 return -EFAULT;
346 if (range.start > total_bytes) 346 if (range.start > total_bytes ||
347 range.len < fs_info->sb->s_blocksize)
347 return -EINVAL; 348 return -EINVAL;
348 349
349 range.len = min(range.len, total_bytes - range.start); 350 range.len = min(range.len, total_bytes - range.start);
@@ -570,7 +571,8 @@ static int create_snapshot(struct btrfs_root *root, struct dentry *dentry,
570 ret = btrfs_commit_transaction(trans, 571 ret = btrfs_commit_transaction(trans,
571 root->fs_info->extent_root); 572 root->fs_info->extent_root);
572 } 573 }
573 BUG_ON(ret); 574 if (ret)
575 goto fail;
574 576
575 ret = pending_snapshot->error; 577 ret = pending_snapshot->error;
576 if (ret) 578 if (ret)
diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
index 5039686df6a..fe9d02c45f8 100644
--- a/fs/btrfs/qgroup.c
+++ b/fs/btrfs/qgroup.c
@@ -790,8 +790,10 @@ int btrfs_quota_enable(struct btrfs_trans_handle *trans,
790 } 790 }
791 791
792 path = btrfs_alloc_path(); 792 path = btrfs_alloc_path();
793 if (!path) 793 if (!path) {
794 return -ENOMEM; 794 ret = -ENOMEM;
795 goto out_free_root;
796 }
795 797
796 key.objectid = 0; 798 key.objectid = 0;
797 key.type = BTRFS_QGROUP_STATUS_KEY; 799 key.type = BTRFS_QGROUP_STATUS_KEY;
@@ -800,7 +802,7 @@ int btrfs_quota_enable(struct btrfs_trans_handle *trans,
800 ret = btrfs_insert_empty_item(trans, quota_root, path, &key, 802 ret = btrfs_insert_empty_item(trans, quota_root, path, &key,
801 sizeof(*ptr)); 803 sizeof(*ptr));
802 if (ret) 804 if (ret)
803 goto out; 805 goto out_free_path;
804 806
805 leaf = path->nodes[0]; 807 leaf = path->nodes[0];
806 ptr = btrfs_item_ptr(leaf, path->slots[0], 808 ptr = btrfs_item_ptr(leaf, path->slots[0],
@@ -818,8 +820,15 @@ int btrfs_quota_enable(struct btrfs_trans_handle *trans,
818 fs_info->quota_root = quota_root; 820 fs_info->quota_root = quota_root;
819 fs_info->pending_quota_state = 1; 821 fs_info->pending_quota_state = 1;
820 spin_unlock(&fs_info->qgroup_lock); 822 spin_unlock(&fs_info->qgroup_lock);
821out: 823out_free_path:
822 btrfs_free_path(path); 824 btrfs_free_path(path);
825out_free_root:
826 if (ret) {
827 free_extent_buffer(quota_root->node);
828 free_extent_buffer(quota_root->commit_root);
829 kfree(quota_root);
830 }
831out:
823 return ret; 832 return ret;
824} 833}
825 834
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index c7beb543a4a..e78b297b0b0 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -745,31 +745,36 @@ typedef int (*iterate_inode_ref_t)(int num, u64 dir, int index,
745 void *ctx); 745 void *ctx);
746 746
747/* 747/*
748 * Helper function to iterate the entries in ONE btrfs_inode_ref. 748 * Helper function to iterate the entries in ONE btrfs_inode_ref or
749 * btrfs_inode_extref.
749 * The iterate callback may return a non zero value to stop iteration. This can 750 * The iterate callback may return a non zero value to stop iteration. This can
750 * be a negative value for error codes or 1 to simply stop it. 751 * be a negative value for error codes or 1 to simply stop it.
751 * 752 *
752 * path must point to the INODE_REF when called. 753 * path must point to the INODE_REF or INODE_EXTREF when called.
753 */ 754 */
754static int iterate_inode_ref(struct send_ctx *sctx, 755static int iterate_inode_ref(struct send_ctx *sctx,
755 struct btrfs_root *root, struct btrfs_path *path, 756 struct btrfs_root *root, struct btrfs_path *path,
756 struct btrfs_key *found_key, int resolve, 757 struct btrfs_key *found_key, int resolve,
757 iterate_inode_ref_t iterate, void *ctx) 758 iterate_inode_ref_t iterate, void *ctx)
758{ 759{
759 struct extent_buffer *eb; 760 struct extent_buffer *eb = path->nodes[0];
760 struct btrfs_item *item; 761 struct btrfs_item *item;
761 struct btrfs_inode_ref *iref; 762 struct btrfs_inode_ref *iref;
763 struct btrfs_inode_extref *extref;
762 struct btrfs_path *tmp_path; 764 struct btrfs_path *tmp_path;
763 struct fs_path *p; 765 struct fs_path *p;
764 u32 cur; 766 u32 cur = 0;
765 u32 len;
766 u32 total; 767 u32 total;
767 int slot; 768 int slot = path->slots[0];
768 u32 name_len; 769 u32 name_len;
769 char *start; 770 char *start;
770 int ret = 0; 771 int ret = 0;
771 int num; 772 int num = 0;
772 int index; 773 int index;
774 u64 dir;
775 unsigned long name_off;
776 unsigned long elem_size;
777 unsigned long ptr;
773 778
774 p = fs_path_alloc_reversed(sctx); 779 p = fs_path_alloc_reversed(sctx);
775 if (!p) 780 if (!p)
@@ -781,24 +786,40 @@ static int iterate_inode_ref(struct send_ctx *sctx,
781 return -ENOMEM; 786 return -ENOMEM;
782 } 787 }
783 788
784 eb = path->nodes[0];
785 slot = path->slots[0];
786 item = btrfs_item_nr(eb, slot);
787 iref = btrfs_item_ptr(eb, slot, struct btrfs_inode_ref);
788 cur = 0;
789 len = 0;
790 total = btrfs_item_size(eb, item);
791 789
792 num = 0; 790 if (found_key->type == BTRFS_INODE_REF_KEY) {
791 ptr = (unsigned long)btrfs_item_ptr(eb, slot,
792 struct btrfs_inode_ref);
793 item = btrfs_item_nr(eb, slot);
794 total = btrfs_item_size(eb, item);
795 elem_size = sizeof(*iref);
796 } else {
797 ptr = btrfs_item_ptr_offset(eb, slot);
798 total = btrfs_item_size_nr(eb, slot);
799 elem_size = sizeof(*extref);
800 }
801
793 while (cur < total) { 802 while (cur < total) {
794 fs_path_reset(p); 803 fs_path_reset(p);
795 804
796 name_len = btrfs_inode_ref_name_len(eb, iref); 805 if (found_key->type == BTRFS_INODE_REF_KEY) {
797 index = btrfs_inode_ref_index(eb, iref); 806 iref = (struct btrfs_inode_ref *)(ptr + cur);
807 name_len = btrfs_inode_ref_name_len(eb, iref);
808 name_off = (unsigned long)(iref + 1);
809 index = btrfs_inode_ref_index(eb, iref);
810 dir = found_key->offset;
811 } else {
812 extref = (struct btrfs_inode_extref *)(ptr + cur);
813 name_len = btrfs_inode_extref_name_len(eb, extref);
814 name_off = (unsigned long)&extref->name;
815 index = btrfs_inode_extref_index(eb, extref);
816 dir = btrfs_inode_extref_parent(eb, extref);
817 }
818
798 if (resolve) { 819 if (resolve) {
799 start = btrfs_iref_to_path(root, tmp_path, iref, eb, 820 start = btrfs_ref_to_path(root, tmp_path, name_len,
800 found_key->offset, p->buf, 821 name_off, eb, dir,
801 p->buf_len); 822 p->buf, p->buf_len);
802 if (IS_ERR(start)) { 823 if (IS_ERR(start)) {
803 ret = PTR_ERR(start); 824 ret = PTR_ERR(start);
804 goto out; 825 goto out;
@@ -809,9 +830,10 @@ static int iterate_inode_ref(struct send_ctx *sctx,
809 p->buf_len + p->buf - start); 830 p->buf_len + p->buf - start);
810 if (ret < 0) 831 if (ret < 0)
811 goto out; 832 goto out;
812 start = btrfs_iref_to_path(root, tmp_path, iref, 833 start = btrfs_ref_to_path(root, tmp_path,
813 eb, found_key->offset, p->buf, 834 name_len, name_off,
814 p->buf_len); 835 eb, dir,
836 p->buf, p->buf_len);
815 if (IS_ERR(start)) { 837 if (IS_ERR(start)) {
816 ret = PTR_ERR(start); 838 ret = PTR_ERR(start);
817 goto out; 839 goto out;
@@ -820,21 +842,16 @@ static int iterate_inode_ref(struct send_ctx *sctx,
820 } 842 }
821 p->start = start; 843 p->start = start;
822 } else { 844 } else {
823 ret = fs_path_add_from_extent_buffer(p, eb, 845 ret = fs_path_add_from_extent_buffer(p, eb, name_off,
824 (unsigned long)(iref + 1), name_len); 846 name_len);
825 if (ret < 0) 847 if (ret < 0)
826 goto out; 848 goto out;
827 } 849 }
828 850
829 851 cur += elem_size + name_len;
830 len = sizeof(*iref) + name_len; 852 ret = iterate(num, dir, index, p, ctx);
831 iref = (struct btrfs_inode_ref *)((char *)iref + len);
832 cur += len;
833
834 ret = iterate(num, found_key->offset, index, p, ctx);
835 if (ret) 853 if (ret)
836 goto out; 854 goto out;
837
838 num++; 855 num++;
839 } 856 }
840 857
@@ -998,7 +1015,8 @@ static int get_inode_path(struct send_ctx *sctx, struct btrfs_root *root,
998 } 1015 }
999 btrfs_item_key_to_cpu(p->nodes[0], &found_key, p->slots[0]); 1016 btrfs_item_key_to_cpu(p->nodes[0], &found_key, p->slots[0]);
1000 if (found_key.objectid != ino || 1017 if (found_key.objectid != ino ||
1001 found_key.type != BTRFS_INODE_REF_KEY) { 1018 (found_key.type != BTRFS_INODE_REF_KEY &&
1019 found_key.type != BTRFS_INODE_EXTREF_KEY)) {
1002 ret = -ENOENT; 1020 ret = -ENOENT;
1003 goto out; 1021 goto out;
1004 } 1022 }
@@ -1551,8 +1569,8 @@ static int get_first_ref(struct send_ctx *sctx,
1551 struct btrfs_key key; 1569 struct btrfs_key key;
1552 struct btrfs_key found_key; 1570 struct btrfs_key found_key;
1553 struct btrfs_path *path; 1571 struct btrfs_path *path;
1554 struct btrfs_inode_ref *iref;
1555 int len; 1572 int len;
1573 u64 parent_dir;
1556 1574
1557 path = alloc_path_for_send(); 1575 path = alloc_path_for_send();
1558 if (!path) 1576 if (!path)
@@ -1568,27 +1586,41 @@ static int get_first_ref(struct send_ctx *sctx,
1568 if (!ret) 1586 if (!ret)
1569 btrfs_item_key_to_cpu(path->nodes[0], &found_key, 1587 btrfs_item_key_to_cpu(path->nodes[0], &found_key,
1570 path->slots[0]); 1588 path->slots[0]);
1571 if (ret || found_key.objectid != key.objectid || 1589 if (ret || found_key.objectid != ino ||
1572 found_key.type != key.type) { 1590 (found_key.type != BTRFS_INODE_REF_KEY &&
1591 found_key.type != BTRFS_INODE_EXTREF_KEY)) {
1573 ret = -ENOENT; 1592 ret = -ENOENT;
1574 goto out; 1593 goto out;
1575 } 1594 }
1576 1595
1577 iref = btrfs_item_ptr(path->nodes[0], path->slots[0], 1596 if (key.type == BTRFS_INODE_REF_KEY) {
1578 struct btrfs_inode_ref); 1597 struct btrfs_inode_ref *iref;
1579 len = btrfs_inode_ref_name_len(path->nodes[0], iref); 1598 iref = btrfs_item_ptr(path->nodes[0], path->slots[0],
1580 ret = fs_path_add_from_extent_buffer(name, path->nodes[0], 1599 struct btrfs_inode_ref);
1581 (unsigned long)(iref + 1), len); 1600 len = btrfs_inode_ref_name_len(path->nodes[0], iref);
1601 ret = fs_path_add_from_extent_buffer(name, path->nodes[0],
1602 (unsigned long)(iref + 1),
1603 len);
1604 parent_dir = found_key.offset;
1605 } else {
1606 struct btrfs_inode_extref *extref;
1607 extref = btrfs_item_ptr(path->nodes[0], path->slots[0],
1608 struct btrfs_inode_extref);
1609 len = btrfs_inode_extref_name_len(path->nodes[0], extref);
1610 ret = fs_path_add_from_extent_buffer(name, path->nodes[0],
1611 (unsigned long)&extref->name, len);
1612 parent_dir = btrfs_inode_extref_parent(path->nodes[0], extref);
1613 }
1582 if (ret < 0) 1614 if (ret < 0)
1583 goto out; 1615 goto out;
1584 btrfs_release_path(path); 1616 btrfs_release_path(path);
1585 1617
1586 ret = get_inode_info(root, found_key.offset, NULL, dir_gen, NULL, NULL, 1618 ret = get_inode_info(root, parent_dir, NULL, dir_gen, NULL, NULL,
1587 NULL, NULL); 1619 NULL, NULL);
1588 if (ret < 0) 1620 if (ret < 0)
1589 goto out; 1621 goto out;
1590 1622
1591 *dir = found_key.offset; 1623 *dir = parent_dir;
1592 1624
1593out: 1625out:
1594 btrfs_free_path(path); 1626 btrfs_free_path(path);
@@ -2430,7 +2462,8 @@ verbose_printk("btrfs: send_create_inode %llu\n", ino);
2430 TLV_PUT_PATH(sctx, BTRFS_SEND_A_PATH_LINK, p); 2462 TLV_PUT_PATH(sctx, BTRFS_SEND_A_PATH_LINK, p);
2431 } else if (S_ISCHR(mode) || S_ISBLK(mode) || 2463 } else if (S_ISCHR(mode) || S_ISBLK(mode) ||
2432 S_ISFIFO(mode) || S_ISSOCK(mode)) { 2464 S_ISFIFO(mode) || S_ISSOCK(mode)) {
2433 TLV_PUT_U64(sctx, BTRFS_SEND_A_RDEV, rdev); 2465 TLV_PUT_U64(sctx, BTRFS_SEND_A_RDEV, new_encode_dev(rdev));
2466 TLV_PUT_U64(sctx, BTRFS_SEND_A_MODE, mode);
2434 } 2467 }
2435 2468
2436 ret = send_cmd(sctx); 2469 ret = send_cmd(sctx);
@@ -3226,7 +3259,8 @@ static int process_all_refs(struct send_ctx *sctx,
3226 btrfs_item_key_to_cpu(eb, &found_key, slot); 3259 btrfs_item_key_to_cpu(eb, &found_key, slot);
3227 3260
3228 if (found_key.objectid != key.objectid || 3261 if (found_key.objectid != key.objectid ||
3229 found_key.type != key.type) 3262 (found_key.type != BTRFS_INODE_REF_KEY &&
3263 found_key.type != BTRFS_INODE_EXTREF_KEY))
3230 break; 3264 break;
3231 3265
3232 ret = iterate_inode_ref(sctx, root, path, &found_key, 0, cb, 3266 ret = iterate_inode_ref(sctx, root, path, &found_key, 0, cb,
@@ -3987,7 +4021,7 @@ static int process_recorded_refs_if_needed(struct send_ctx *sctx, int at_end)
3987 if (sctx->cur_ino == 0) 4021 if (sctx->cur_ino == 0)
3988 goto out; 4022 goto out;
3989 if (!at_end && sctx->cur_ino == sctx->cmp_key->objectid && 4023 if (!at_end && sctx->cur_ino == sctx->cmp_key->objectid &&
3990 sctx->cmp_key->type <= BTRFS_INODE_REF_KEY) 4024 sctx->cmp_key->type <= BTRFS_INODE_EXTREF_KEY)
3991 goto out; 4025 goto out;
3992 if (list_empty(&sctx->new_refs) && list_empty(&sctx->deleted_refs)) 4026 if (list_empty(&sctx->new_refs) && list_empty(&sctx->deleted_refs))
3993 goto out; 4027 goto out;
@@ -4033,22 +4067,21 @@ static int finish_inode_if_needed(struct send_ctx *sctx, int at_end)
4033 if (ret < 0) 4067 if (ret < 0)
4034 goto out; 4068 goto out;
4035 4069
4036 if (!S_ISLNK(sctx->cur_inode_mode)) { 4070 if (!sctx->parent_root || sctx->cur_inode_new) {
4037 if (!sctx->parent_root || sctx->cur_inode_new) { 4071 need_chown = 1;
4072 if (!S_ISLNK(sctx->cur_inode_mode))
4038 need_chmod = 1; 4073 need_chmod = 1;
4039 need_chown = 1; 4074 } else {
4040 } else { 4075 ret = get_inode_info(sctx->parent_root, sctx->cur_ino,
4041 ret = get_inode_info(sctx->parent_root, sctx->cur_ino, 4076 NULL, NULL, &right_mode, &right_uid,
4042 NULL, NULL, &right_mode, &right_uid, 4077 &right_gid, NULL);
4043 &right_gid, NULL); 4078 if (ret < 0)
4044 if (ret < 0) 4079 goto out;
4045 goto out;
4046 4080
4047 if (left_uid != right_uid || left_gid != right_gid) 4081 if (left_uid != right_uid || left_gid != right_gid)
4048 need_chown = 1; 4082 need_chown = 1;
4049 if (left_mode != right_mode) 4083 if (!S_ISLNK(sctx->cur_inode_mode) && left_mode != right_mode)
4050 need_chmod = 1; 4084 need_chmod = 1;
4051 }
4052 } 4085 }
4053 4086
4054 if (S_ISREG(sctx->cur_inode_mode)) { 4087 if (S_ISREG(sctx->cur_inode_mode)) {
@@ -4335,7 +4368,8 @@ static int changed_cb(struct btrfs_root *left_root,
4335 4368
4336 if (key->type == BTRFS_INODE_ITEM_KEY) 4369 if (key->type == BTRFS_INODE_ITEM_KEY)
4337 ret = changed_inode(sctx, result); 4370 ret = changed_inode(sctx, result);
4338 else if (key->type == BTRFS_INODE_REF_KEY) 4371 else if (key->type == BTRFS_INODE_REF_KEY ||
4372 key->type == BTRFS_INODE_EXTREF_KEY)
4339 ret = changed_ref(sctx, result); 4373 ret = changed_ref(sctx, result);
4340 else if (key->type == BTRFS_XATTR_ITEM_KEY) 4374 else if (key->type == BTRFS_XATTR_ITEM_KEY)
4341 ret = changed_xattr(sctx, result); 4375 ret = changed_xattr(sctx, result);
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 77db875b511..04bbfb1052e 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -1200,7 +1200,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
1200 btrfs_i_size_write(parent_inode, parent_inode->i_size + 1200 btrfs_i_size_write(parent_inode, parent_inode->i_size +
1201 dentry->d_name.len * 2); 1201 dentry->d_name.len * 2);
1202 parent_inode->i_mtime = parent_inode->i_ctime = CURRENT_TIME; 1202 parent_inode->i_mtime = parent_inode->i_ctime = CURRENT_TIME;
1203 ret = btrfs_update_inode(trans, parent_root, parent_inode); 1203 ret = btrfs_update_inode_fallback(trans, parent_root, parent_inode);
1204 if (ret) 1204 if (ret)
1205 btrfs_abort_transaction(trans, root, ret); 1205 btrfs_abort_transaction(trans, root, ret);
1206fail: 1206fail:
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 029b903a4ae..0f5ebb72a5e 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -1819,6 +1819,13 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
1819 "Failed to relocate sys chunks after " 1819 "Failed to relocate sys chunks after "
1820 "device initialization. This can be fixed " 1820 "device initialization. This can be fixed "
1821 "using the \"btrfs balance\" command."); 1821 "using the \"btrfs balance\" command.");
1822 trans = btrfs_attach_transaction(root);
1823 if (IS_ERR(trans)) {
1824 if (PTR_ERR(trans) == -ENOENT)
1825 return 0;
1826 return PTR_ERR(trans);
1827 }
1828 ret = btrfs_commit_transaction(trans, root);
1822 } 1829 }
1823 1830
1824 return ret; 1831 return ret;
diff --git a/fs/ceph/export.c b/fs/ceph/export.c
index 02ce90972d8..9349bb37a2f 100644
--- a/fs/ceph/export.c
+++ b/fs/ceph/export.c
@@ -90,6 +90,8 @@ static int ceph_encode_fh(struct inode *inode, u32 *rawfh, int *max_len,
90 *max_len = handle_length; 90 *max_len = handle_length;
91 type = 255; 91 type = 255;
92 } 92 }
93 if (dentry)
94 dput(dentry);
93 return type; 95 return type;
94} 96}
95 97
diff --git a/fs/char_dev.c b/fs/char_dev.c
index 3f152b92a94..afc2bb69178 100644
--- a/fs/char_dev.c
+++ b/fs/char_dev.c
@@ -471,9 +471,19 @@ static int exact_lock(dev_t dev, void *data)
471 */ 471 */
472int cdev_add(struct cdev *p, dev_t dev, unsigned count) 472int cdev_add(struct cdev *p, dev_t dev, unsigned count)
473{ 473{
474 int error;
475
474 p->dev = dev; 476 p->dev = dev;
475 p->count = count; 477 p->count = count;
476 return kobj_map(cdev_map, dev, count, NULL, exact_match, exact_lock, p); 478
479 error = kobj_map(cdev_map, dev, count, NULL,
480 exact_match, exact_lock, p);
481 if (error)
482 return error;
483
484 kobject_get(p->kobj.parent);
485
486 return 0;
477} 487}
478 488
479static void cdev_unmap(dev_t dev, unsigned count) 489static void cdev_unmap(dev_t dev, unsigned count)
@@ -498,14 +508,20 @@ void cdev_del(struct cdev *p)
498static void cdev_default_release(struct kobject *kobj) 508static void cdev_default_release(struct kobject *kobj)
499{ 509{
500 struct cdev *p = container_of(kobj, struct cdev, kobj); 510 struct cdev *p = container_of(kobj, struct cdev, kobj);
511 struct kobject *parent = kobj->parent;
512
501 cdev_purge(p); 513 cdev_purge(p);
514 kobject_put(parent);
502} 515}
503 516
504static void cdev_dynamic_release(struct kobject *kobj) 517static void cdev_dynamic_release(struct kobject *kobj)
505{ 518{
506 struct cdev *p = container_of(kobj, struct cdev, kobj); 519 struct cdev *p = container_of(kobj, struct cdev, kobj);
520 struct kobject *parent = kobj->parent;
521
507 cdev_purge(p); 522 cdev_purge(p);
508 kfree(p); 523 kfree(p);
524 kobject_put(parent);
509} 525}
510 526
511static struct kobj_type ktype_cdev_default = { 527static struct kobj_type ktype_cdev_default = {
diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c
index fc783e26442..0fb15bbbe43 100644
--- a/fs/cifs/cifsacl.c
+++ b/fs/cifs/cifsacl.c
@@ -225,6 +225,13 @@ sid_to_str(struct cifs_sid *sidptr, char *sidstr)
225} 225}
226 226
227static void 227static void
228cifs_copy_sid(struct cifs_sid *dst, const struct cifs_sid *src)
229{
230 memcpy(dst, src, sizeof(*dst));
231 dst->num_subauth = min_t(u8, src->num_subauth, NUM_SUBAUTHS);
232}
233
234static void
228id_rb_insert(struct rb_root *root, struct cifs_sid *sidptr, 235id_rb_insert(struct rb_root *root, struct cifs_sid *sidptr,
229 struct cifs_sid_id **psidid, char *typestr) 236 struct cifs_sid_id **psidid, char *typestr)
230{ 237{
@@ -248,7 +255,7 @@ id_rb_insert(struct rb_root *root, struct cifs_sid *sidptr,
248 } 255 }
249 } 256 }
250 257
251 memcpy(&(*psidid)->sid, sidptr, sizeof(struct cifs_sid)); 258 cifs_copy_sid(&(*psidid)->sid, sidptr);
252 (*psidid)->time = jiffies - (SID_MAP_RETRY + 1); 259 (*psidid)->time = jiffies - (SID_MAP_RETRY + 1);
253 (*psidid)->refcount = 0; 260 (*psidid)->refcount = 0;
254 261
@@ -354,7 +361,7 @@ id_to_sid(unsigned long cid, uint sidtype, struct cifs_sid *ssid)
354 * any fields of the node after a reference is put . 361 * any fields of the node after a reference is put .
355 */ 362 */
356 if (test_bit(SID_ID_MAPPED, &psidid->state)) { 363 if (test_bit(SID_ID_MAPPED, &psidid->state)) {
357 memcpy(ssid, &psidid->sid, sizeof(struct cifs_sid)); 364 cifs_copy_sid(ssid, &psidid->sid);
358 psidid->time = jiffies; /* update ts for accessing */ 365 psidid->time = jiffies; /* update ts for accessing */
359 goto id_sid_out; 366 goto id_sid_out;
360 } 367 }
@@ -370,14 +377,14 @@ id_to_sid(unsigned long cid, uint sidtype, struct cifs_sid *ssid)
370 if (IS_ERR(sidkey)) { 377 if (IS_ERR(sidkey)) {
371 rc = -EINVAL; 378 rc = -EINVAL;
372 cFYI(1, "%s: Can't map and id to a SID", __func__); 379 cFYI(1, "%s: Can't map and id to a SID", __func__);
380 } else if (sidkey->datalen < sizeof(struct cifs_sid)) {
381 rc = -EIO;
382 cFYI(1, "%s: Downcall contained malformed key "
383 "(datalen=%hu)", __func__, sidkey->datalen);
373 } else { 384 } else {
374 lsid = (struct cifs_sid *)sidkey->payload.data; 385 lsid = (struct cifs_sid *)sidkey->payload.data;
375 memcpy(&psidid->sid, lsid, 386 cifs_copy_sid(&psidid->sid, lsid);
376 sidkey->datalen < sizeof(struct cifs_sid) ? 387 cifs_copy_sid(ssid, &psidid->sid);
377 sidkey->datalen : sizeof(struct cifs_sid));
378 memcpy(ssid, &psidid->sid,
379 sidkey->datalen < sizeof(struct cifs_sid) ?
380 sidkey->datalen : sizeof(struct cifs_sid));
381 set_bit(SID_ID_MAPPED, &psidid->state); 388 set_bit(SID_ID_MAPPED, &psidid->state);
382 key_put(sidkey); 389 key_put(sidkey);
383 kfree(psidid->sidstr); 390 kfree(psidid->sidstr);
@@ -396,7 +403,7 @@ id_to_sid(unsigned long cid, uint sidtype, struct cifs_sid *ssid)
396 return rc; 403 return rc;
397 } 404 }
398 if (test_bit(SID_ID_MAPPED, &psidid->state)) 405 if (test_bit(SID_ID_MAPPED, &psidid->state))
399 memcpy(ssid, &psidid->sid, sizeof(struct cifs_sid)); 406 cifs_copy_sid(ssid, &psidid->sid);
400 else 407 else
401 rc = -EINVAL; 408 rc = -EINVAL;
402 } 409 }
@@ -675,8 +682,6 @@ int compare_sids(const struct cifs_sid *ctsid, const struct cifs_sid *cwsid)
675static void copy_sec_desc(const struct cifs_ntsd *pntsd, 682static void copy_sec_desc(const struct cifs_ntsd *pntsd,
676 struct cifs_ntsd *pnntsd, __u32 sidsoffset) 683 struct cifs_ntsd *pnntsd, __u32 sidsoffset)
677{ 684{
678 int i;
679
680 struct cifs_sid *owner_sid_ptr, *group_sid_ptr; 685 struct cifs_sid *owner_sid_ptr, *group_sid_ptr;
681 struct cifs_sid *nowner_sid_ptr, *ngroup_sid_ptr; 686 struct cifs_sid *nowner_sid_ptr, *ngroup_sid_ptr;
682 687
@@ -692,26 +697,14 @@ static void copy_sec_desc(const struct cifs_ntsd *pntsd,
692 owner_sid_ptr = (struct cifs_sid *)((char *)pntsd + 697 owner_sid_ptr = (struct cifs_sid *)((char *)pntsd +
693 le32_to_cpu(pntsd->osidoffset)); 698 le32_to_cpu(pntsd->osidoffset));
694 nowner_sid_ptr = (struct cifs_sid *)((char *)pnntsd + sidsoffset); 699 nowner_sid_ptr = (struct cifs_sid *)((char *)pnntsd + sidsoffset);
695 700 cifs_copy_sid(nowner_sid_ptr, owner_sid_ptr);
696 nowner_sid_ptr->revision = owner_sid_ptr->revision;
697 nowner_sid_ptr->num_subauth = owner_sid_ptr->num_subauth;
698 for (i = 0; i < 6; i++)
699 nowner_sid_ptr->authority[i] = owner_sid_ptr->authority[i];
700 for (i = 0; i < 5; i++)
701 nowner_sid_ptr->sub_auth[i] = owner_sid_ptr->sub_auth[i];
702 701
703 /* copy group sid */ 702 /* copy group sid */
704 group_sid_ptr = (struct cifs_sid *)((char *)pntsd + 703 group_sid_ptr = (struct cifs_sid *)((char *)pntsd +
705 le32_to_cpu(pntsd->gsidoffset)); 704 le32_to_cpu(pntsd->gsidoffset));
706 ngroup_sid_ptr = (struct cifs_sid *)((char *)pnntsd + sidsoffset + 705 ngroup_sid_ptr = (struct cifs_sid *)((char *)pnntsd + sidsoffset +
707 sizeof(struct cifs_sid)); 706 sizeof(struct cifs_sid));
708 707 cifs_copy_sid(ngroup_sid_ptr, group_sid_ptr);
709 ngroup_sid_ptr->revision = group_sid_ptr->revision;
710 ngroup_sid_ptr->num_subauth = group_sid_ptr->num_subauth;
711 for (i = 0; i < 6; i++)
712 ngroup_sid_ptr->authority[i] = group_sid_ptr->authority[i];
713 for (i = 0; i < 5; i++)
714 ngroup_sid_ptr->sub_auth[i] = group_sid_ptr->sub_auth[i];
715 708
716 return; 709 return;
717} 710}
@@ -1120,8 +1113,7 @@ static int build_sec_desc(struct cifs_ntsd *pntsd, struct cifs_ntsd *pnntsd,
1120 kfree(nowner_sid_ptr); 1113 kfree(nowner_sid_ptr);
1121 return rc; 1114 return rc;
1122 } 1115 }
1123 memcpy(owner_sid_ptr, nowner_sid_ptr, 1116 cifs_copy_sid(owner_sid_ptr, nowner_sid_ptr);
1124 sizeof(struct cifs_sid));
1125 kfree(nowner_sid_ptr); 1117 kfree(nowner_sid_ptr);
1126 *aclflag = CIFS_ACL_OWNER; 1118 *aclflag = CIFS_ACL_OWNER;
1127 } 1119 }
@@ -1139,8 +1131,7 @@ static int build_sec_desc(struct cifs_ntsd *pntsd, struct cifs_ntsd *pnntsd,
1139 kfree(ngroup_sid_ptr); 1131 kfree(ngroup_sid_ptr);
1140 return rc; 1132 return rc;
1141 } 1133 }
1142 memcpy(group_sid_ptr, ngroup_sid_ptr, 1134 cifs_copy_sid(group_sid_ptr, ngroup_sid_ptr);
1143 sizeof(struct cifs_sid));
1144 kfree(ngroup_sid_ptr); 1135 kfree(ngroup_sid_ptr);
1145 *aclflag = CIFS_ACL_GROUP; 1136 *aclflag = CIFS_ACL_GROUP;
1146 } 1137 }
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index 7c0a8128364..d3671f2acb2 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -398,7 +398,16 @@ cifs_atomic_open(struct inode *inode, struct dentry *direntry,
398 * in network traffic in the other paths. 398 * in network traffic in the other paths.
399 */ 399 */
400 if (!(oflags & O_CREAT)) { 400 if (!(oflags & O_CREAT)) {
401 struct dentry *res = cifs_lookup(inode, direntry, 0); 401 struct dentry *res;
402
403 /*
404 * Check for hashed negative dentry. We have already revalidated
405 * the dentry and it is fine. No need to perform another lookup.
406 */
407 if (!d_unhashed(direntry))
408 return -ENOENT;
409
410 res = cifs_lookup(inode, direntry, 0);
402 if (IS_ERR(res)) 411 if (IS_ERR(res))
403 return PTR_ERR(res); 412 return PTR_ERR(res);
404 413
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index f5054025f9d..4c6285fff59 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -210,6 +210,8 @@ static int do_video_set_spu_palette(unsigned int fd, unsigned int cmd,
210 210
211 err = get_user(palp, &up->palette); 211 err = get_user(palp, &up->palette);
212 err |= get_user(length, &up->length); 212 err |= get_user(length, &up->length);
213 if (err)
214 return -EFAULT;
213 215
214 up_native = compat_alloc_user_space(sizeof(struct video_spu_palette)); 216 up_native = compat_alloc_user_space(sizeof(struct video_spu_palette));
215 err = put_user(compat_ptr(palp), &up_native->palette); 217 err = put_user(compat_ptr(palp), &up_native->palette);
diff --git a/fs/coredump.c b/fs/coredump.c
index fd37facac8d..ce47379bfa6 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -450,11 +450,12 @@ static int umh_pipe_setup(struct subprocess_info *info, struct cred *new)
450 450
451 cp->file = files[1]; 451 cp->file = files[1];
452 452
453 replace_fd(0, files[0], 0); 453 err = replace_fd(0, files[0], 0);
454 fput(files[0]);
454 /* and disallow core files too */ 455 /* and disallow core files too */
455 current->signal->rlim[RLIMIT_CORE] = (struct rlimit){1, 1}; 456 current->signal->rlim[RLIMIT_CORE] = (struct rlimit){1, 1};
456 457
457 return 0; 458 return err;
458} 459}
459 460
460void do_coredump(siginfo_t *siginfo, struct pt_regs *regs) 461void do_coredump(siginfo_t *siginfo, struct pt_regs *regs)
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index da72250ddc1..cd96649bfe6 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -346,7 +346,7 @@ static inline struct epitem *ep_item_from_epqueue(poll_table *p)
346/* Tells if the epoll_ctl(2) operation needs an event copy from userspace */ 346/* Tells if the epoll_ctl(2) operation needs an event copy from userspace */
347static inline int ep_op_has_event(int op) 347static inline int ep_op_has_event(int op)
348{ 348{
349 return op == EPOLL_CTL_ADD || op == EPOLL_CTL_MOD; 349 return op != EPOLL_CTL_DEL;
350} 350}
351 351
352/* Initialize the poll safe wake up structure */ 352/* Initialize the poll safe wake up structure */
@@ -676,34 +676,6 @@ static int ep_remove(struct eventpoll *ep, struct epitem *epi)
676 return 0; 676 return 0;
677} 677}
678 678
679/*
680 * Disables a "struct epitem" in the eventpoll set. Returns -EBUSY if the item
681 * had no event flags set, indicating that another thread may be currently
682 * handling that item's events (in the case that EPOLLONESHOT was being
683 * used). Otherwise a zero result indicates that the item has been disabled
684 * from receiving events. A disabled item may be re-enabled via
685 * EPOLL_CTL_MOD. Must be called with "mtx" held.
686 */
687static int ep_disable(struct eventpoll *ep, struct epitem *epi)
688{
689 int result = 0;
690 unsigned long flags;
691
692 spin_lock_irqsave(&ep->lock, flags);
693 if (epi->event.events & ~EP_PRIVATE_BITS) {
694 if (ep_is_linked(&epi->rdllink))
695 list_del_init(&epi->rdllink);
696 /* Ensure ep_poll_callback will not add epi back onto ready
697 list: */
698 epi->event.events &= EP_PRIVATE_BITS;
699 }
700 else
701 result = -EBUSY;
702 spin_unlock_irqrestore(&ep->lock, flags);
703
704 return result;
705}
706
707static void ep_free(struct eventpoll *ep) 679static void ep_free(struct eventpoll *ep)
708{ 680{
709 struct rb_node *rbp; 681 struct rb_node *rbp;
@@ -1048,6 +1020,8 @@ static void ep_rbtree_insert(struct eventpoll *ep, struct epitem *epi)
1048 rb_insert_color(&epi->rbn, &ep->rbr); 1020 rb_insert_color(&epi->rbn, &ep->rbr);
1049} 1021}
1050 1022
1023
1024
1051#define PATH_ARR_SIZE 5 1025#define PATH_ARR_SIZE 5
1052/* 1026/*
1053 * These are the number paths of length 1 to 5, that we are allowing to emanate 1027 * These are the number paths of length 1 to 5, that we are allowing to emanate
@@ -1813,12 +1787,6 @@ SYSCALL_DEFINE4(epoll_ctl, int, epfd, int, op, int, fd,
1813 } else 1787 } else
1814 error = -ENOENT; 1788 error = -ENOENT;
1815 break; 1789 break;
1816 case EPOLL_CTL_DISABLE:
1817 if (epi)
1818 error = ep_disable(ep, epi);
1819 else
1820 error = -ENOENT;
1821 break;
1822 } 1790 }
1823 mutex_unlock(&ep->mtx); 1791 mutex_unlock(&ep->mtx);
1824 1792
diff --git a/fs/exec.c b/fs/exec.c
index 8b9011b6704..0039055b1fc 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1083,7 +1083,8 @@ int flush_old_exec(struct linux_binprm * bprm)
1083 bprm->mm = NULL; /* We're using it now */ 1083 bprm->mm = NULL; /* We're using it now */
1084 1084
1085 set_fs(USER_DS); 1085 set_fs(USER_DS);
1086 current->flags &= ~(PF_RANDOMIZE | PF_FORKNOEXEC | PF_KTHREAD); 1086 current->flags &=
1087 ~(PF_RANDOMIZE | PF_FORKNOEXEC | PF_KTHREAD | PF_NOFREEZE);
1087 flush_thread(); 1088 flush_thread();
1088 current->personality &= ~bprm->per_clear; 1089 current->personality &= ~bprm->per_clear;
1089 1090
diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index 6c205d0c565..fa04d023177 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -469,7 +469,7 @@ static int parse_options(char *options, struct super_block *sb)
469 uid = make_kuid(current_user_ns(), option); 469 uid = make_kuid(current_user_ns(), option);
470 if (!uid_valid(uid)) { 470 if (!uid_valid(uid)) {
471 ext2_msg(sb, KERN_ERR, "Invalid uid value %d", option); 471 ext2_msg(sb, KERN_ERR, "Invalid uid value %d", option);
472 return -1; 472 return 0;
473 473
474 } 474 }
475 sbi->s_resuid = uid; 475 sbi->s_resuid = uid;
@@ -480,7 +480,7 @@ static int parse_options(char *options, struct super_block *sb)
480 gid = make_kgid(current_user_ns(), option); 480 gid = make_kgid(current_user_ns(), option);
481 if (!gid_valid(gid)) { 481 if (!gid_valid(gid)) {
482 ext2_msg(sb, KERN_ERR, "Invalid gid value %d", option); 482 ext2_msg(sb, KERN_ERR, "Invalid gid value %d", option);
483 return -1; 483 return 0;
484 } 484 }
485 sbi->s_resgid = gid; 485 sbi->s_resgid = gid;
486 break; 486 break;
diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
index 7320a66e958..22548f56197 100644
--- a/fs/ext3/balloc.c
+++ b/fs/ext3/balloc.c
@@ -2101,8 +2101,9 @@ int ext3_trim_fs(struct super_block *sb, struct fstrim_range *range)
2101 end = start + (range->len >> sb->s_blocksize_bits) - 1; 2101 end = start + (range->len >> sb->s_blocksize_bits) - 1;
2102 minlen = range->minlen >> sb->s_blocksize_bits; 2102 minlen = range->minlen >> sb->s_blocksize_bits;
2103 2103
2104 if (unlikely(minlen > EXT3_BLOCKS_PER_GROUP(sb)) || 2104 if (minlen > EXT3_BLOCKS_PER_GROUP(sb) ||
2105 unlikely(start >= max_blks)) 2105 start >= max_blks ||
2106 range->len < sb->s_blocksize)
2106 return -EINVAL; 2107 return -EINVAL;
2107 if (end >= max_blks) 2108 if (end >= max_blks)
2108 end = max_blks - 1; 2109 end = max_blks - 1;
diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c
index 8f4fddac01a..890b8947c54 100644
--- a/fs/ext3/namei.c
+++ b/fs/ext3/namei.c
@@ -46,8 +46,7 @@ static struct buffer_head *ext3_append(handle_t *handle,
46 46
47 *block = inode->i_size >> inode->i_sb->s_blocksize_bits; 47 *block = inode->i_size >> inode->i_sb->s_blocksize_bits;
48 48
49 bh = ext3_bread(handle, inode, *block, 1, err); 49 if ((bh = ext3_dir_bread(handle, inode, *block, 1, err))) {
50 if (bh) {
51 inode->i_size += inode->i_sb->s_blocksize; 50 inode->i_size += inode->i_sb->s_blocksize;
52 EXT3_I(inode)->i_disksize = inode->i_size; 51 EXT3_I(inode)->i_disksize = inode->i_size;
53 *err = ext3_journal_get_write_access(handle, bh); 52 *err = ext3_journal_get_write_access(handle, bh);
@@ -339,8 +338,10 @@ dx_probe(struct qstr *entry, struct inode *dir,
339 u32 hash; 338 u32 hash;
340 339
341 frame->bh = NULL; 340 frame->bh = NULL;
342 if (!(bh = ext3_bread (NULL,dir, 0, 0, err))) 341 if (!(bh = ext3_dir_bread(NULL, dir, 0, 0, err))) {
342 *err = ERR_BAD_DX_DIR;
343 goto fail; 343 goto fail;
344 }
344 root = (struct dx_root *) bh->b_data; 345 root = (struct dx_root *) bh->b_data;
345 if (root->info.hash_version != DX_HASH_TEA && 346 if (root->info.hash_version != DX_HASH_TEA &&
346 root->info.hash_version != DX_HASH_HALF_MD4 && 347 root->info.hash_version != DX_HASH_HALF_MD4 &&
@@ -436,8 +437,10 @@ dx_probe(struct qstr *entry, struct inode *dir,
436 frame->entries = entries; 437 frame->entries = entries;
437 frame->at = at; 438 frame->at = at;
438 if (!indirect--) return frame; 439 if (!indirect--) return frame;
439 if (!(bh = ext3_bread (NULL,dir, dx_get_block(at), 0, err))) 440 if (!(bh = ext3_dir_bread(NULL, dir, dx_get_block(at), 0, err))) {
441 *err = ERR_BAD_DX_DIR;
440 goto fail2; 442 goto fail2;
443 }
441 at = entries = ((struct dx_node *) bh->b_data)->entries; 444 at = entries = ((struct dx_node *) bh->b_data)->entries;
442 if (dx_get_limit(entries) != dx_node_limit (dir)) { 445 if (dx_get_limit(entries) != dx_node_limit (dir)) {
443 ext3_warning(dir->i_sb, __func__, 446 ext3_warning(dir->i_sb, __func__,
@@ -535,8 +538,8 @@ static int ext3_htree_next_block(struct inode *dir, __u32 hash,
535 * block so no check is necessary 538 * block so no check is necessary
536 */ 539 */
537 while (num_frames--) { 540 while (num_frames--) {
538 if (!(bh = ext3_bread(NULL, dir, dx_get_block(p->at), 541 if (!(bh = ext3_dir_bread(NULL, dir, dx_get_block(p->at),
539 0, &err))) 542 0, &err)))
540 return err; /* Failure */ 543 return err; /* Failure */
541 p++; 544 p++;
542 brelse (p->bh); 545 brelse (p->bh);
@@ -559,10 +562,11 @@ static int htree_dirblock_to_tree(struct file *dir_file,
559{ 562{
560 struct buffer_head *bh; 563 struct buffer_head *bh;
561 struct ext3_dir_entry_2 *de, *top; 564 struct ext3_dir_entry_2 *de, *top;
562 int err, count = 0; 565 int err = 0, count = 0;
563 566
564 dxtrace(printk("In htree dirblock_to_tree: block %d\n", block)); 567 dxtrace(printk("In htree dirblock_to_tree: block %d\n", block));
565 if (!(bh = ext3_bread (NULL, dir, block, 0, &err))) 568
569 if (!(bh = ext3_dir_bread(NULL, dir, block, 0, &err)))
566 return err; 570 return err;
567 571
568 de = (struct ext3_dir_entry_2 *) bh->b_data; 572 de = (struct ext3_dir_entry_2 *) bh->b_data;
@@ -976,7 +980,7 @@ static struct buffer_head * ext3_dx_find_entry(struct inode *dir,
976 return NULL; 980 return NULL;
977 do { 981 do {
978 block = dx_get_block(frame->at); 982 block = dx_get_block(frame->at);
979 if (!(bh = ext3_bread (NULL,dir, block, 0, err))) 983 if (!(bh = ext3_dir_bread (NULL, dir, block, 0, err)))
980 goto errout; 984 goto errout;
981 985
982 retval = search_dirblock(bh, dir, entry, 986 retval = search_dirblock(bh, dir, entry,
@@ -1458,9 +1462,9 @@ static int ext3_add_entry (handle_t *handle, struct dentry *dentry,
1458 } 1462 }
1459 blocks = dir->i_size >> sb->s_blocksize_bits; 1463 blocks = dir->i_size >> sb->s_blocksize_bits;
1460 for (block = 0; block < blocks; block++) { 1464 for (block = 0; block < blocks; block++) {
1461 bh = ext3_bread(handle, dir, block, 0, &retval); 1465 if (!(bh = ext3_dir_bread(handle, dir, block, 0, &retval)))
1462 if(!bh)
1463 return retval; 1466 return retval;
1467
1464 retval = add_dirent_to_buf(handle, dentry, inode, NULL, bh); 1468 retval = add_dirent_to_buf(handle, dentry, inode, NULL, bh);
1465 if (retval != -ENOSPC) 1469 if (retval != -ENOSPC)
1466 return retval; 1470 return retval;
@@ -1500,7 +1504,7 @@ static int ext3_dx_add_entry(handle_t *handle, struct dentry *dentry,
1500 entries = frame->entries; 1504 entries = frame->entries;
1501 at = frame->at; 1505 at = frame->at;
1502 1506
1503 if (!(bh = ext3_bread(handle,dir, dx_get_block(frame->at), 0, &err))) 1507 if (!(bh = ext3_dir_bread(handle, dir, dx_get_block(frame->at), 0, &err)))
1504 goto cleanup; 1508 goto cleanup;
1505 1509
1506 BUFFER_TRACE(bh, "get_write_access"); 1510 BUFFER_TRACE(bh, "get_write_access");
@@ -1790,8 +1794,7 @@ retry:
1790 inode->i_op = &ext3_dir_inode_operations; 1794 inode->i_op = &ext3_dir_inode_operations;
1791 inode->i_fop = &ext3_dir_operations; 1795 inode->i_fop = &ext3_dir_operations;
1792 inode->i_size = EXT3_I(inode)->i_disksize = inode->i_sb->s_blocksize; 1796 inode->i_size = EXT3_I(inode)->i_disksize = inode->i_sb->s_blocksize;
1793 dir_block = ext3_bread (handle, inode, 0, 1, &err); 1797 if (!(dir_block = ext3_dir_bread(handle, inode, 0, 1, &err)))
1794 if (!dir_block)
1795 goto out_clear_inode; 1798 goto out_clear_inode;
1796 1799
1797 BUFFER_TRACE(dir_block, "get_write_access"); 1800 BUFFER_TRACE(dir_block, "get_write_access");
@@ -1859,7 +1862,7 @@ static int empty_dir (struct inode * inode)
1859 1862
1860 sb = inode->i_sb; 1863 sb = inode->i_sb;
1861 if (inode->i_size < EXT3_DIR_REC_LEN(1) + EXT3_DIR_REC_LEN(2) || 1864 if (inode->i_size < EXT3_DIR_REC_LEN(1) + EXT3_DIR_REC_LEN(2) ||
1862 !(bh = ext3_bread (NULL, inode, 0, 0, &err))) { 1865 !(bh = ext3_dir_bread(NULL, inode, 0, 0, &err))) {
1863 if (err) 1866 if (err)
1864 ext3_error(inode->i_sb, __func__, 1867 ext3_error(inode->i_sb, __func__,
1865 "error %d reading directory #%lu offset 0", 1868 "error %d reading directory #%lu offset 0",
@@ -1890,9 +1893,8 @@ static int empty_dir (struct inode * inode)
1890 (void *) de >= (void *) (bh->b_data+sb->s_blocksize)) { 1893 (void *) de >= (void *) (bh->b_data+sb->s_blocksize)) {
1891 err = 0; 1894 err = 0;
1892 brelse (bh); 1895 brelse (bh);
1893 bh = ext3_bread (NULL, inode, 1896 if (!(bh = ext3_dir_bread (NULL, inode,
1894 offset >> EXT3_BLOCK_SIZE_BITS(sb), 0, &err); 1897 offset >> EXT3_BLOCK_SIZE_BITS(sb), 0, &err))) {
1895 if (!bh) {
1896 if (err) 1898 if (err)
1897 ext3_error(sb, __func__, 1899 ext3_error(sb, __func__,
1898 "error %d reading directory" 1900 "error %d reading directory"
@@ -2388,7 +2390,7 @@ static int ext3_rename (struct inode * old_dir, struct dentry *old_dentry,
2388 goto end_rename; 2390 goto end_rename;
2389 } 2391 }
2390 retval = -EIO; 2392 retval = -EIO;
2391 dir_bh = ext3_bread (handle, old_inode, 0, 0, &retval); 2393 dir_bh = ext3_dir_bread(handle, old_inode, 0, 0, &retval);
2392 if (!dir_bh) 2394 if (!dir_bh)
2393 goto end_rename; 2395 goto end_rename;
2394 if (le32_to_cpu(PARENT_INO(dir_bh->b_data)) != old_dir->i_ino) 2396 if (le32_to_cpu(PARENT_INO(dir_bh->b_data)) != old_dir->i_ino)
diff --git a/fs/ext3/namei.h b/fs/ext3/namei.h
index f2ce2b0065c..46304d8c9f0 100644
--- a/fs/ext3/namei.h
+++ b/fs/ext3/namei.h
@@ -6,3 +6,22 @@
6*/ 6*/
7 7
8extern struct dentry *ext3_get_parent(struct dentry *child); 8extern struct dentry *ext3_get_parent(struct dentry *child);
9
10static inline struct buffer_head *ext3_dir_bread(handle_t *handle,
11 struct inode *inode,
12 int block, int create,
13 int *err)
14{
15 struct buffer_head *bh;
16
17 bh = ext3_bread(handle, inode, block, create, err);
18
19 if (!bh && !(*err)) {
20 *err = -EIO;
21 ext3_error(inode->i_sb, __func__,
22 "Directory hole detected on inode %lu\n",
23 inode->i_ino);
24 return NULL;
25 }
26 return bh;
27}
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index 29e79713c7e..5366393528d 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -1001,7 +1001,7 @@ static int parse_options (char *options, struct super_block *sb,
1001 uid = make_kuid(current_user_ns(), option); 1001 uid = make_kuid(current_user_ns(), option);
1002 if (!uid_valid(uid)) { 1002 if (!uid_valid(uid)) {
1003 ext3_msg(sb, KERN_ERR, "Invalid uid value %d", option); 1003 ext3_msg(sb, KERN_ERR, "Invalid uid value %d", option);
1004 return -1; 1004 return 0;
1005 1005
1006 } 1006 }
1007 sbi->s_resuid = uid; 1007 sbi->s_resuid = uid;
@@ -1012,7 +1012,7 @@ static int parse_options (char *options, struct super_block *sb,
1012 gid = make_kgid(current_user_ns(), option); 1012 gid = make_kgid(current_user_ns(), option);
1013 if (!gid_valid(gid)) { 1013 if (!gid_valid(gid)) {
1014 ext3_msg(sb, KERN_ERR, "Invalid gid value %d", option); 1014 ext3_msg(sb, KERN_ERR, "Invalid gid value %d", option);
1015 return -1; 1015 return 0;
1016 } 1016 }
1017 sbi->s_resgid = gid; 1017 sbi->s_resgid = gid;
1018 break; 1018 break;
diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
index 1b5089067d0..cf1821784a1 100644
--- a/fs/ext4/balloc.c
+++ b/fs/ext4/balloc.c
@@ -174,8 +174,7 @@ void ext4_init_block_bitmap(struct super_block *sb, struct buffer_head *bh,
174 ext4_free_inodes_set(sb, gdp, 0); 174 ext4_free_inodes_set(sb, gdp, 0);
175 ext4_itable_unused_set(sb, gdp, 0); 175 ext4_itable_unused_set(sb, gdp, 0);
176 memset(bh->b_data, 0xff, sb->s_blocksize); 176 memset(bh->b_data, 0xff, sb->s_blocksize);
177 ext4_block_bitmap_csum_set(sb, block_group, gdp, bh, 177 ext4_block_bitmap_csum_set(sb, block_group, gdp, bh);
178 EXT4_BLOCKS_PER_GROUP(sb) / 8);
179 return; 178 return;
180 } 179 }
181 memset(bh->b_data, 0, sb->s_blocksize); 180 memset(bh->b_data, 0, sb->s_blocksize);
@@ -212,8 +211,7 @@ void ext4_init_block_bitmap(struct super_block *sb, struct buffer_head *bh,
212 */ 211 */
213 ext4_mark_bitmap_end(num_clusters_in_group(sb, block_group), 212 ext4_mark_bitmap_end(num_clusters_in_group(sb, block_group),
214 sb->s_blocksize * 8, bh->b_data); 213 sb->s_blocksize * 8, bh->b_data);
215 ext4_block_bitmap_csum_set(sb, block_group, gdp, bh, 214 ext4_block_bitmap_csum_set(sb, block_group, gdp, bh);
216 EXT4_BLOCKS_PER_GROUP(sb) / 8);
217 ext4_group_desc_csum_set(sb, block_group, gdp); 215 ext4_group_desc_csum_set(sb, block_group, gdp);
218} 216}
219 217
@@ -350,7 +348,7 @@ void ext4_validate_block_bitmap(struct super_block *sb,
350 return; 348 return;
351 } 349 }
352 if (unlikely(!ext4_block_bitmap_csum_verify(sb, block_group, 350 if (unlikely(!ext4_block_bitmap_csum_verify(sb, block_group,
353 desc, bh, EXT4_BLOCKS_PER_GROUP(sb) / 8))) { 351 desc, bh))) {
354 ext4_unlock_group(sb, block_group); 352 ext4_unlock_group(sb, block_group);
355 ext4_error(sb, "bg %u: bad block bitmap checksum", block_group); 353 ext4_error(sb, "bg %u: bad block bitmap checksum", block_group);
356 return; 354 return;
diff --git a/fs/ext4/bitmap.c b/fs/ext4/bitmap.c
index 5c2d1813ebe..3285aa5a706 100644
--- a/fs/ext4/bitmap.c
+++ b/fs/ext4/bitmap.c
@@ -58,11 +58,12 @@ void ext4_inode_bitmap_csum_set(struct super_block *sb, ext4_group_t group,
58 58
59int ext4_block_bitmap_csum_verify(struct super_block *sb, ext4_group_t group, 59int ext4_block_bitmap_csum_verify(struct super_block *sb, ext4_group_t group,
60 struct ext4_group_desc *gdp, 60 struct ext4_group_desc *gdp,
61 struct buffer_head *bh, int sz) 61 struct buffer_head *bh)
62{ 62{
63 __u32 hi; 63 __u32 hi;
64 __u32 provided, calculated; 64 __u32 provided, calculated;
65 struct ext4_sb_info *sbi = EXT4_SB(sb); 65 struct ext4_sb_info *sbi = EXT4_SB(sb);
66 int sz = EXT4_CLUSTERS_PER_GROUP(sb) / 8;
66 67
67 if (!EXT4_HAS_RO_COMPAT_FEATURE(sb, 68 if (!EXT4_HAS_RO_COMPAT_FEATURE(sb,
68 EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)) 69 EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
@@ -84,8 +85,9 @@ int ext4_block_bitmap_csum_verify(struct super_block *sb, ext4_group_t group,
84 85
85void ext4_block_bitmap_csum_set(struct super_block *sb, ext4_group_t group, 86void ext4_block_bitmap_csum_set(struct super_block *sb, ext4_group_t group,
86 struct ext4_group_desc *gdp, 87 struct ext4_group_desc *gdp,
87 struct buffer_head *bh, int sz) 88 struct buffer_head *bh)
88{ 89{
90 int sz = EXT4_CLUSTERS_PER_GROUP(sb) / 8;
89 __u32 csum; 91 __u32 csum;
90 struct ext4_sb_info *sbi = EXT4_SB(sb); 92 struct ext4_sb_info *sbi = EXT4_SB(sb);
91 93
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 3ab2539b7b2..3c20de1d59d 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -1882,10 +1882,10 @@ int ext4_inode_bitmap_csum_verify(struct super_block *sb, ext4_group_t group,
1882 struct buffer_head *bh, int sz); 1882 struct buffer_head *bh, int sz);
1883void ext4_block_bitmap_csum_set(struct super_block *sb, ext4_group_t group, 1883void ext4_block_bitmap_csum_set(struct super_block *sb, ext4_group_t group,
1884 struct ext4_group_desc *gdp, 1884 struct ext4_group_desc *gdp,
1885 struct buffer_head *bh, int sz); 1885 struct buffer_head *bh);
1886int ext4_block_bitmap_csum_verify(struct super_block *sb, ext4_group_t group, 1886int ext4_block_bitmap_csum_verify(struct super_block *sb, ext4_group_t group,
1887 struct ext4_group_desc *gdp, 1887 struct ext4_group_desc *gdp,
1888 struct buffer_head *bh, int sz); 1888 struct buffer_head *bh);
1889 1889
1890/* balloc.c */ 1890/* balloc.c */
1891extern void ext4_validate_block_bitmap(struct super_block *sb, 1891extern void ext4_validate_block_bitmap(struct super_block *sb,
@@ -2063,8 +2063,7 @@ extern int ext4_resize_fs(struct super_block *sb, ext4_fsblk_t n_blocks_count);
2063extern int ext4_calculate_overhead(struct super_block *sb); 2063extern int ext4_calculate_overhead(struct super_block *sb);
2064extern int ext4_superblock_csum_verify(struct super_block *sb, 2064extern int ext4_superblock_csum_verify(struct super_block *sb,
2065 struct ext4_super_block *es); 2065 struct ext4_super_block *es);
2066extern void ext4_superblock_csum_set(struct super_block *sb, 2066extern void ext4_superblock_csum_set(struct super_block *sb);
2067 struct ext4_super_block *es);
2068extern void *ext4_kvmalloc(size_t size, gfp_t flags); 2067extern void *ext4_kvmalloc(size_t size, gfp_t flags);
2069extern void *ext4_kvzalloc(size_t size, gfp_t flags); 2068extern void *ext4_kvzalloc(size_t size, gfp_t flags);
2070extern void ext4_kvfree(void *ptr); 2069extern void ext4_kvfree(void *ptr);
diff --git a/fs/ext4/ext4_jbd2.c b/fs/ext4/ext4_jbd2.c
index bfa65b49d42..b4323ba846b 100644
--- a/fs/ext4/ext4_jbd2.c
+++ b/fs/ext4/ext4_jbd2.c
@@ -143,17 +143,13 @@ int __ext4_handle_dirty_super(const char *where, unsigned int line,
143 struct buffer_head *bh = EXT4_SB(sb)->s_sbh; 143 struct buffer_head *bh = EXT4_SB(sb)->s_sbh;
144 int err = 0; 144 int err = 0;
145 145
146 ext4_superblock_csum_set(sb);
146 if (ext4_handle_valid(handle)) { 147 if (ext4_handle_valid(handle)) {
147 ext4_superblock_csum_set(sb,
148 (struct ext4_super_block *)bh->b_data);
149 err = jbd2_journal_dirty_metadata(handle, bh); 148 err = jbd2_journal_dirty_metadata(handle, bh);
150 if (err) 149 if (err)
151 ext4_journal_abort_handle(where, line, __func__, 150 ext4_journal_abort_handle(where, line, __func__,
152 bh, handle, err); 151 bh, handle, err);
153 } else { 152 } else
154 ext4_superblock_csum_set(sb,
155 (struct ext4_super_block *)bh->b_data);
156 mark_buffer_dirty(bh); 153 mark_buffer_dirty(bh);
157 }
158 return err; 154 return err;
159} 155}
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 1c94cca35ed..7011ac96720 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -52,6 +52,9 @@
52#define EXT4_EXT_MARK_UNINIT1 0x2 /* mark first half uninitialized */ 52#define EXT4_EXT_MARK_UNINIT1 0x2 /* mark first half uninitialized */
53#define EXT4_EXT_MARK_UNINIT2 0x4 /* mark second half uninitialized */ 53#define EXT4_EXT_MARK_UNINIT2 0x4 /* mark second half uninitialized */
54 54
55#define EXT4_EXT_DATA_VALID1 0x8 /* first half contains valid data */
56#define EXT4_EXT_DATA_VALID2 0x10 /* second half contains valid data */
57
55static __le32 ext4_extent_block_csum(struct inode *inode, 58static __le32 ext4_extent_block_csum(struct inode *inode,
56 struct ext4_extent_header *eh) 59 struct ext4_extent_header *eh)
57{ 60{
@@ -2914,6 +2917,9 @@ static int ext4_split_extent_at(handle_t *handle,
2914 unsigned int ee_len, depth; 2917 unsigned int ee_len, depth;
2915 int err = 0; 2918 int err = 0;
2916 2919
2920 BUG_ON((split_flag & (EXT4_EXT_DATA_VALID1 | EXT4_EXT_DATA_VALID2)) ==
2921 (EXT4_EXT_DATA_VALID1 | EXT4_EXT_DATA_VALID2));
2922
2917 ext_debug("ext4_split_extents_at: inode %lu, logical" 2923 ext_debug("ext4_split_extents_at: inode %lu, logical"
2918 "block %llu\n", inode->i_ino, (unsigned long long)split); 2924 "block %llu\n", inode->i_ino, (unsigned long long)split);
2919 2925
@@ -2972,7 +2978,14 @@ static int ext4_split_extent_at(handle_t *handle,
2972 2978
2973 err = ext4_ext_insert_extent(handle, inode, path, &newex, flags); 2979 err = ext4_ext_insert_extent(handle, inode, path, &newex, flags);
2974 if (err == -ENOSPC && (EXT4_EXT_MAY_ZEROOUT & split_flag)) { 2980 if (err == -ENOSPC && (EXT4_EXT_MAY_ZEROOUT & split_flag)) {
2975 err = ext4_ext_zeroout(inode, &orig_ex); 2981 if (split_flag & (EXT4_EXT_DATA_VALID1|EXT4_EXT_DATA_VALID2)) {
2982 if (split_flag & EXT4_EXT_DATA_VALID1)
2983 err = ext4_ext_zeroout(inode, ex2);
2984 else
2985 err = ext4_ext_zeroout(inode, ex);
2986 } else
2987 err = ext4_ext_zeroout(inode, &orig_ex);
2988
2976 if (err) 2989 if (err)
2977 goto fix_extent_len; 2990 goto fix_extent_len;
2978 /* update the extent length and mark as initialized */ 2991 /* update the extent length and mark as initialized */
@@ -3025,12 +3038,13 @@ static int ext4_split_extent(handle_t *handle,
3025 uninitialized = ext4_ext_is_uninitialized(ex); 3038 uninitialized = ext4_ext_is_uninitialized(ex);
3026 3039
3027 if (map->m_lblk + map->m_len < ee_block + ee_len) { 3040 if (map->m_lblk + map->m_len < ee_block + ee_len) {
3028 split_flag1 = split_flag & EXT4_EXT_MAY_ZEROOUT ? 3041 split_flag1 = split_flag & EXT4_EXT_MAY_ZEROOUT;
3029 EXT4_EXT_MAY_ZEROOUT : 0;
3030 flags1 = flags | EXT4_GET_BLOCKS_PRE_IO; 3042 flags1 = flags | EXT4_GET_BLOCKS_PRE_IO;
3031 if (uninitialized) 3043 if (uninitialized)
3032 split_flag1 |= EXT4_EXT_MARK_UNINIT1 | 3044 split_flag1 |= EXT4_EXT_MARK_UNINIT1 |
3033 EXT4_EXT_MARK_UNINIT2; 3045 EXT4_EXT_MARK_UNINIT2;
3046 if (split_flag & EXT4_EXT_DATA_VALID2)
3047 split_flag1 |= EXT4_EXT_DATA_VALID1;
3034 err = ext4_split_extent_at(handle, inode, path, 3048 err = ext4_split_extent_at(handle, inode, path,
3035 map->m_lblk + map->m_len, split_flag1, flags1); 3049 map->m_lblk + map->m_len, split_flag1, flags1);
3036 if (err) 3050 if (err)
@@ -3043,8 +3057,8 @@ static int ext4_split_extent(handle_t *handle,
3043 return PTR_ERR(path); 3057 return PTR_ERR(path);
3044 3058
3045 if (map->m_lblk >= ee_block) { 3059 if (map->m_lblk >= ee_block) {
3046 split_flag1 = split_flag & EXT4_EXT_MAY_ZEROOUT ? 3060 split_flag1 = split_flag & (EXT4_EXT_MAY_ZEROOUT |
3047 EXT4_EXT_MAY_ZEROOUT : 0; 3061 EXT4_EXT_DATA_VALID2);
3048 if (uninitialized) 3062 if (uninitialized)
3049 split_flag1 |= EXT4_EXT_MARK_UNINIT1; 3063 split_flag1 |= EXT4_EXT_MARK_UNINIT1;
3050 if (split_flag & EXT4_EXT_MARK_UNINIT2) 3064 if (split_flag & EXT4_EXT_MARK_UNINIT2)
@@ -3323,26 +3337,47 @@ static int ext4_split_unwritten_extents(handle_t *handle,
3323 3337
3324 split_flag |= ee_block + ee_len <= eof_block ? EXT4_EXT_MAY_ZEROOUT : 0; 3338 split_flag |= ee_block + ee_len <= eof_block ? EXT4_EXT_MAY_ZEROOUT : 0;
3325 split_flag |= EXT4_EXT_MARK_UNINIT2; 3339 split_flag |= EXT4_EXT_MARK_UNINIT2;
3326 3340 if (flags & EXT4_GET_BLOCKS_CONVERT)
3341 split_flag |= EXT4_EXT_DATA_VALID2;
3327 flags |= EXT4_GET_BLOCKS_PRE_IO; 3342 flags |= EXT4_GET_BLOCKS_PRE_IO;
3328 return ext4_split_extent(handle, inode, path, map, split_flag, flags); 3343 return ext4_split_extent(handle, inode, path, map, split_flag, flags);
3329} 3344}
3330 3345
3331static int ext4_convert_unwritten_extents_endio(handle_t *handle, 3346static int ext4_convert_unwritten_extents_endio(handle_t *handle,
3332 struct inode *inode, 3347 struct inode *inode,
3333 struct ext4_ext_path *path) 3348 struct ext4_map_blocks *map,
3349 struct ext4_ext_path *path)
3334{ 3350{
3335 struct ext4_extent *ex; 3351 struct ext4_extent *ex;
3352 ext4_lblk_t ee_block;
3353 unsigned int ee_len;
3336 int depth; 3354 int depth;
3337 int err = 0; 3355 int err = 0;
3338 3356
3339 depth = ext_depth(inode); 3357 depth = ext_depth(inode);
3340 ex = path[depth].p_ext; 3358 ex = path[depth].p_ext;
3359 ee_block = le32_to_cpu(ex->ee_block);
3360 ee_len = ext4_ext_get_actual_len(ex);
3341 3361
3342 ext_debug("ext4_convert_unwritten_extents_endio: inode %lu, logical" 3362 ext_debug("ext4_convert_unwritten_extents_endio: inode %lu, logical"
3343 "block %llu, max_blocks %u\n", inode->i_ino, 3363 "block %llu, max_blocks %u\n", inode->i_ino,
3344 (unsigned long long)le32_to_cpu(ex->ee_block), 3364 (unsigned long long)ee_block, ee_len);
3345 ext4_ext_get_actual_len(ex)); 3365
3366 /* If extent is larger than requested then split is required */
3367 if (ee_block != map->m_lblk || ee_len > map->m_len) {
3368 err = ext4_split_unwritten_extents(handle, inode, map, path,
3369 EXT4_GET_BLOCKS_CONVERT);
3370 if (err < 0)
3371 goto out;
3372 ext4_ext_drop_refs(path);
3373 path = ext4_ext_find_extent(inode, map->m_lblk, path);
3374 if (IS_ERR(path)) {
3375 err = PTR_ERR(path);
3376 goto out;
3377 }
3378 depth = ext_depth(inode);
3379 ex = path[depth].p_ext;
3380 }
3346 3381
3347 err = ext4_ext_get_access(handle, inode, path + depth); 3382 err = ext4_ext_get_access(handle, inode, path + depth);
3348 if (err) 3383 if (err)
@@ -3652,7 +3687,7 @@ ext4_ext_handle_uninitialized_extents(handle_t *handle, struct inode *inode,
3652 } 3687 }
3653 /* IO end_io complete, convert the filled extent to written */ 3688 /* IO end_io complete, convert the filled extent to written */
3654 if ((flags & EXT4_GET_BLOCKS_CONVERT)) { 3689 if ((flags & EXT4_GET_BLOCKS_CONVERT)) {
3655 ret = ext4_convert_unwritten_extents_endio(handle, inode, 3690 ret = ext4_convert_unwritten_extents_endio(handle, inode, map,
3656 path); 3691 path);
3657 if (ret >= 0) { 3692 if (ret >= 0) {
3658 ext4_update_inode_fsync_trans(handle, inode, 1); 3693 ext4_update_inode_fsync_trans(handle, inode, 1);
@@ -4428,6 +4463,9 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
4428 */ 4463 */
4429 if (len <= EXT_UNINIT_MAX_LEN << blkbits) 4464 if (len <= EXT_UNINIT_MAX_LEN << blkbits)
4430 flags |= EXT4_GET_BLOCKS_NO_NORMALIZE; 4465 flags |= EXT4_GET_BLOCKS_NO_NORMALIZE;
4466
4467 /* Prevent race condition between unwritten */
4468 ext4_flush_unwritten_io(inode);
4431retry: 4469retry:
4432 while (ret >= 0 && ret < max_blocks) { 4470 while (ret >= 0 && ret < max_blocks) {
4433 map.m_lblk = map.m_lblk + ret; 4471 map.m_lblk = map.m_lblk + ret;
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index fa36372f3fd..3a100e7a62a 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -725,6 +725,10 @@ repeat_in_this_group:
725 "inode=%lu", ino + 1); 725 "inode=%lu", ino + 1);
726 continue; 726 continue;
727 } 727 }
728 BUFFER_TRACE(inode_bitmap_bh, "get_write_access");
729 err = ext4_journal_get_write_access(handle, inode_bitmap_bh);
730 if (err)
731 goto fail;
728 ext4_lock_group(sb, group); 732 ext4_lock_group(sb, group);
729 ret2 = ext4_test_and_set_bit(ino, inode_bitmap_bh->b_data); 733 ret2 = ext4_test_and_set_bit(ino, inode_bitmap_bh->b_data);
730 ext4_unlock_group(sb, group); 734 ext4_unlock_group(sb, group);
@@ -738,6 +742,11 @@ repeat_in_this_group:
738 goto out; 742 goto out;
739 743
740got: 744got:
745 BUFFER_TRACE(inode_bitmap_bh, "call ext4_handle_dirty_metadata");
746 err = ext4_handle_dirty_metadata(handle, NULL, inode_bitmap_bh);
747 if (err)
748 goto fail;
749
741 /* We may have to initialize the block bitmap if it isn't already */ 750 /* We may have to initialize the block bitmap if it isn't already */
742 if (ext4_has_group_desc_csum(sb) && 751 if (ext4_has_group_desc_csum(sb) &&
743 gdp->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) { 752 gdp->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) {
@@ -762,9 +771,7 @@ got:
762 ext4_free_group_clusters_set(sb, gdp, 771 ext4_free_group_clusters_set(sb, gdp,
763 ext4_free_clusters_after_init(sb, group, gdp)); 772 ext4_free_clusters_after_init(sb, group, gdp));
764 ext4_block_bitmap_csum_set(sb, group, gdp, 773 ext4_block_bitmap_csum_set(sb, group, gdp,
765 block_bitmap_bh, 774 block_bitmap_bh);
766 EXT4_BLOCKS_PER_GROUP(sb) /
767 8);
768 ext4_group_desc_csum_set(sb, group, gdp); 775 ext4_group_desc_csum_set(sb, group, gdp);
769 } 776 }
770 ext4_unlock_group(sb, group); 777 ext4_unlock_group(sb, group);
@@ -773,11 +780,6 @@ got:
773 goto fail; 780 goto fail;
774 } 781 }
775 782
776 BUFFER_TRACE(inode_bitmap_bh, "get_write_access");
777 err = ext4_journal_get_write_access(handle, inode_bitmap_bh);
778 if (err)
779 goto fail;
780
781 BUFFER_TRACE(group_desc_bh, "get_write_access"); 783 BUFFER_TRACE(group_desc_bh, "get_write_access");
782 err = ext4_journal_get_write_access(handle, group_desc_bh); 784 err = ext4_journal_get_write_access(handle, group_desc_bh);
783 if (err) 785 if (err)
@@ -825,11 +827,6 @@ got:
825 } 827 }
826 ext4_unlock_group(sb, group); 828 ext4_unlock_group(sb, group);
827 829
828 BUFFER_TRACE(inode_bitmap_bh, "call ext4_handle_dirty_metadata");
829 err = ext4_handle_dirty_metadata(handle, NULL, inode_bitmap_bh);
830 if (err)
831 goto fail;
832
833 BUFFER_TRACE(group_desc_bh, "call ext4_handle_dirty_metadata"); 830 BUFFER_TRACE(group_desc_bh, "call ext4_handle_dirty_metadata");
834 err = ext4_handle_dirty_metadata(handle, NULL, group_desc_bh); 831 err = ext4_handle_dirty_metadata(handle, NULL, group_desc_bh);
835 if (err) 832 if (err)
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index f8b27bf80ac..526e5535860 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -2805,8 +2805,7 @@ ext4_mb_mark_diskspace_used(struct ext4_allocation_context *ac,
2805 } 2805 }
2806 len = ext4_free_group_clusters(sb, gdp) - ac->ac_b_ex.fe_len; 2806 len = ext4_free_group_clusters(sb, gdp) - ac->ac_b_ex.fe_len;
2807 ext4_free_group_clusters_set(sb, gdp, len); 2807 ext4_free_group_clusters_set(sb, gdp, len);
2808 ext4_block_bitmap_csum_set(sb, ac->ac_b_ex.fe_group, gdp, bitmap_bh, 2808 ext4_block_bitmap_csum_set(sb, ac->ac_b_ex.fe_group, gdp, bitmap_bh);
2809 EXT4_BLOCKS_PER_GROUP(sb) / 8);
2810 ext4_group_desc_csum_set(sb, ac->ac_b_ex.fe_group, gdp); 2809 ext4_group_desc_csum_set(sb, ac->ac_b_ex.fe_group, gdp);
2811 2810
2812 ext4_unlock_group(sb, ac->ac_b_ex.fe_group); 2811 ext4_unlock_group(sb, ac->ac_b_ex.fe_group);
@@ -4666,8 +4665,7 @@ do_more:
4666 4665
4667 ret = ext4_free_group_clusters(sb, gdp) + count_clusters; 4666 ret = ext4_free_group_clusters(sb, gdp) + count_clusters;
4668 ext4_free_group_clusters_set(sb, gdp, ret); 4667 ext4_free_group_clusters_set(sb, gdp, ret);
4669 ext4_block_bitmap_csum_set(sb, block_group, gdp, bitmap_bh, 4668 ext4_block_bitmap_csum_set(sb, block_group, gdp, bitmap_bh);
4670 EXT4_BLOCKS_PER_GROUP(sb) / 8);
4671 ext4_group_desc_csum_set(sb, block_group, gdp); 4669 ext4_group_desc_csum_set(sb, block_group, gdp);
4672 ext4_unlock_group(sb, block_group); 4670 ext4_unlock_group(sb, block_group);
4673 percpu_counter_add(&sbi->s_freeclusters_counter, count_clusters); 4671 percpu_counter_add(&sbi->s_freeclusters_counter, count_clusters);
@@ -4811,8 +4809,7 @@ int ext4_group_add_blocks(handle_t *handle, struct super_block *sb,
4811 mb_free_blocks(NULL, &e4b, bit, count); 4809 mb_free_blocks(NULL, &e4b, bit, count);
4812 blk_free_count = blocks_freed + ext4_free_group_clusters(sb, desc); 4810 blk_free_count = blocks_freed + ext4_free_group_clusters(sb, desc);
4813 ext4_free_group_clusters_set(sb, desc, blk_free_count); 4811 ext4_free_group_clusters_set(sb, desc, blk_free_count);
4814 ext4_block_bitmap_csum_set(sb, block_group, desc, bitmap_bh, 4812 ext4_block_bitmap_csum_set(sb, block_group, desc, bitmap_bh);
4815 EXT4_BLOCKS_PER_GROUP(sb) / 8);
4816 ext4_group_desc_csum_set(sb, block_group, desc); 4813 ext4_group_desc_csum_set(sb, block_group, desc);
4817 ext4_unlock_group(sb, block_group); 4814 ext4_unlock_group(sb, block_group);
4818 percpu_counter_add(&sbi->s_freeclusters_counter, 4815 percpu_counter_add(&sbi->s_freeclusters_counter,
@@ -4993,8 +4990,9 @@ int ext4_trim_fs(struct super_block *sb, struct fstrim_range *range)
4993 minlen = EXT4_NUM_B2C(EXT4_SB(sb), 4990 minlen = EXT4_NUM_B2C(EXT4_SB(sb),
4994 range->minlen >> sb->s_blocksize_bits); 4991 range->minlen >> sb->s_blocksize_bits);
4995 4992
4996 if (unlikely(minlen > EXT4_CLUSTERS_PER_GROUP(sb)) || 4993 if (minlen > EXT4_CLUSTERS_PER_GROUP(sb) ||
4997 unlikely(start >= max_blks)) 4994 start >= max_blks ||
4995 range->len < sb->s_blocksize)
4998 return -EINVAL; 4996 return -EINVAL;
4999 if (end >= max_blks) 4997 if (end >= max_blks)
5000 end = max_blks - 1; 4998 end = max_blks - 1;
diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
index 7a75e108696..47bf06a2765 100644
--- a/fs/ext4/resize.c
+++ b/fs/ext4/resize.c
@@ -1212,8 +1212,7 @@ static int ext4_set_bitmap_checksums(struct super_block *sb,
1212 bh = ext4_get_bitmap(sb, group_data->block_bitmap); 1212 bh = ext4_get_bitmap(sb, group_data->block_bitmap);
1213 if (!bh) 1213 if (!bh)
1214 return -EIO; 1214 return -EIO;
1215 ext4_block_bitmap_csum_set(sb, group, gdp, bh, 1215 ext4_block_bitmap_csum_set(sb, group, gdp, bh);
1216 EXT4_BLOCKS_PER_GROUP(sb) / 8);
1217 brelse(bh); 1216 brelse(bh);
1218 1217
1219 return 0; 1218 return 0;
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 7265a036747..80928f71685 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -143,9 +143,10 @@ int ext4_superblock_csum_verify(struct super_block *sb,
143 return es->s_checksum == ext4_superblock_csum(sb, es); 143 return es->s_checksum == ext4_superblock_csum(sb, es);
144} 144}
145 145
146void ext4_superblock_csum_set(struct super_block *sb, 146void ext4_superblock_csum_set(struct super_block *sb)
147 struct ext4_super_block *es)
148{ 147{
148 struct ext4_super_block *es = EXT4_SB(sb)->s_es;
149
149 if (!EXT4_HAS_RO_COMPAT_FEATURE(sb, 150 if (!EXT4_HAS_RO_COMPAT_FEATURE(sb,
150 EXT4_FEATURE_RO_COMPAT_METADATA_CSUM)) 151 EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
151 return; 152 return;
@@ -1963,7 +1964,7 @@ static int ext4_fill_flex_info(struct super_block *sb)
1963 sbi->s_log_groups_per_flex = 0; 1964 sbi->s_log_groups_per_flex = 0;
1964 return 1; 1965 return 1;
1965 } 1966 }
1966 groups_per_flex = 1 << sbi->s_log_groups_per_flex; 1967 groups_per_flex = 1U << sbi->s_log_groups_per_flex;
1967 1968
1968 err = ext4_alloc_flex_bg_array(sb, sbi->s_groups_count); 1969 err = ext4_alloc_flex_bg_array(sb, sbi->s_groups_count);
1969 if (err) 1970 if (err)
@@ -4381,7 +4382,7 @@ static int ext4_commit_super(struct super_block *sb, int sync)
4381 cpu_to_le32(percpu_counter_sum_positive( 4382 cpu_to_le32(percpu_counter_sum_positive(
4382 &EXT4_SB(sb)->s_freeinodes_counter)); 4383 &EXT4_SB(sb)->s_freeinodes_counter));
4383 BUFFER_TRACE(sbh, "marking dirty"); 4384 BUFFER_TRACE(sbh, "marking dirty");
4384 ext4_superblock_csum_set(sb, es); 4385 ext4_superblock_csum_set(sb);
4385 mark_buffer_dirty(sbh); 4386 mark_buffer_dirty(sbh);
4386 if (sync) { 4387 if (sync) {
4387 error = sync_dirty_buffer(sbh); 4388 error = sync_dirty_buffer(sbh);
diff --git a/fs/file.c b/fs/file.c
index d3b5fa80b71..7272a1c5831 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -519,12 +519,6 @@ struct files_struct init_files = {
519 .file_lock = __SPIN_LOCK_UNLOCKED(init_task.file_lock), 519 .file_lock = __SPIN_LOCK_UNLOCKED(init_task.file_lock),
520}; 520};
521 521
522void daemonize_descriptors(void)
523{
524 atomic_inc(&init_files.count);
525 reset_files_struct(&init_files);
526}
527
528/* 522/*
529 * allocate a file descriptor, mark it busy. 523 * allocate a file descriptor, mark it busy.
530 */ 524 */
@@ -685,7 +679,6 @@ void do_close_on_exec(struct files_struct *files)
685 struct fdtable *fdt; 679 struct fdtable *fdt;
686 680
687 /* exec unshares first */ 681 /* exec unshares first */
688 BUG_ON(atomic_read(&files->count) != 1);
689 spin_lock(&files->file_lock); 682 spin_lock(&files->file_lock);
690 for (i = 0; ; i++) { 683 for (i = 0; ; i++) {
691 unsigned long set; 684 unsigned long set;
@@ -900,7 +893,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
900 return __close_fd(files, fd); 893 return __close_fd(files, fd);
901 894
902 if (fd >= rlimit(RLIMIT_NOFILE)) 895 if (fd >= rlimit(RLIMIT_NOFILE))
903 return -EMFILE; 896 return -EBADF;
904 897
905 spin_lock(&files->file_lock); 898 spin_lock(&files->file_lock);
906 err = expand_files(files, fd); 899 err = expand_files(files, fd);
@@ -926,7 +919,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
926 return -EINVAL; 919 return -EINVAL;
927 920
928 if (newfd >= rlimit(RLIMIT_NOFILE)) 921 if (newfd >= rlimit(RLIMIT_NOFILE))
929 return -EMFILE; 922 return -EBADF;
930 923
931 spin_lock(&files->file_lock); 924 spin_lock(&files->file_lock);
932 err = expand_files(files, newfd); 925 err = expand_files(files, newfd);
diff --git a/fs/fs_struct.c b/fs/fs_struct.c
index 5df4775fea0..fe6ca583bbc 100644
--- a/fs/fs_struct.c
+++ b/fs/fs_struct.c
@@ -164,27 +164,3 @@ struct fs_struct init_fs = {
164 .seq = SEQCNT_ZERO, 164 .seq = SEQCNT_ZERO,
165 .umask = 0022, 165 .umask = 0022,
166}; 166};
167
168void daemonize_fs_struct(void)
169{
170 struct fs_struct *fs = current->fs;
171
172 if (fs) {
173 int kill;
174
175 task_lock(current);
176
177 spin_lock(&init_fs.lock);
178 init_fs.users++;
179 spin_unlock(&init_fs.lock);
180
181 spin_lock(&fs->lock);
182 current->fs = &init_fs;
183 kill = !--fs->users;
184 spin_unlock(&fs->lock);
185
186 task_unlock(current);
187 if (kill)
188 free_fs_struct(fs);
189 }
190}
diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
index 0def0504afc..e056b4ce487 100644
--- a/fs/gfs2/file.c
+++ b/fs/gfs2/file.c
@@ -516,15 +516,13 @@ static int gfs2_mmap(struct file *file, struct vm_area_struct *vma)
516 struct gfs2_holder i_gh; 516 struct gfs2_holder i_gh;
517 int error; 517 int error;
518 518
519 gfs2_holder_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, &i_gh); 519 error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY,
520 error = gfs2_glock_nq(&i_gh); 520 &i_gh);
521 if (error == 0) {
522 file_accessed(file);
523 gfs2_glock_dq(&i_gh);
524 }
525 gfs2_holder_uninit(&i_gh);
526 if (error) 521 if (error)
527 return error; 522 return error;
523 /* grab lock to update inode */
524 gfs2_glock_dq_uninit(&i_gh);
525 file_accessed(file);
528 } 526 }
529 vma->vm_ops = &gfs2_vm_ops; 527 vma->vm_ops = &gfs2_vm_ops;
530 528
@@ -677,10 +675,8 @@ static ssize_t gfs2_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
677 size_t writesize = iov_length(iov, nr_segs); 675 size_t writesize = iov_length(iov, nr_segs);
678 struct dentry *dentry = file->f_dentry; 676 struct dentry *dentry = file->f_dentry;
679 struct gfs2_inode *ip = GFS2_I(dentry->d_inode); 677 struct gfs2_inode *ip = GFS2_I(dentry->d_inode);
680 struct gfs2_sbd *sdp;
681 int ret; 678 int ret;
682 679
683 sdp = GFS2_SB(file->f_mapping->host);
684 ret = gfs2_rs_alloc(ip); 680 ret = gfs2_rs_alloc(ip);
685 if (ret) 681 if (ret)
686 return ret; 682 return ret;
diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c
index 8ff95a2d54e..9ceccb1595a 100644
--- a/fs/gfs2/lops.c
+++ b/fs/gfs2/lops.c
@@ -393,12 +393,10 @@ static void buf_lo_add(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd)
393 struct gfs2_meta_header *mh; 393 struct gfs2_meta_header *mh;
394 struct gfs2_trans *tr; 394 struct gfs2_trans *tr;
395 395
396 lock_buffer(bd->bd_bh);
397 gfs2_log_lock(sdp);
398 tr = current->journal_info; 396 tr = current->journal_info;
399 tr->tr_touched = 1; 397 tr->tr_touched = 1;
400 if (!list_empty(&bd->bd_list)) 398 if (!list_empty(&bd->bd_list))
401 goto out; 399 return;
402 set_bit(GLF_LFLUSH, &bd->bd_gl->gl_flags); 400 set_bit(GLF_LFLUSH, &bd->bd_gl->gl_flags);
403 set_bit(GLF_DIRTY, &bd->bd_gl->gl_flags); 401 set_bit(GLF_DIRTY, &bd->bd_gl->gl_flags);
404 mh = (struct gfs2_meta_header *)bd->bd_bh->b_data; 402 mh = (struct gfs2_meta_header *)bd->bd_bh->b_data;
@@ -414,9 +412,6 @@ static void buf_lo_add(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd)
414 sdp->sd_log_num_buf++; 412 sdp->sd_log_num_buf++;
415 list_add(&bd->bd_list, &sdp->sd_log_le_buf); 413 list_add(&bd->bd_list, &sdp->sd_log_le_buf);
416 tr->tr_num_buf_new++; 414 tr->tr_num_buf_new++;
417out:
418 gfs2_log_unlock(sdp);
419 unlock_buffer(bd->bd_bh);
420} 415}
421 416
422static void gfs2_check_magic(struct buffer_head *bh) 417static void gfs2_check_magic(struct buffer_head *bh)
@@ -621,7 +616,6 @@ static void revoke_lo_add(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd)
621 616
622static void revoke_lo_before_commit(struct gfs2_sbd *sdp) 617static void revoke_lo_before_commit(struct gfs2_sbd *sdp)
623{ 618{
624 struct gfs2_log_descriptor *ld;
625 struct gfs2_meta_header *mh; 619 struct gfs2_meta_header *mh;
626 unsigned int offset; 620 unsigned int offset;
627 struct list_head *head = &sdp->sd_log_le_revoke; 621 struct list_head *head = &sdp->sd_log_le_revoke;
@@ -634,7 +628,6 @@ static void revoke_lo_before_commit(struct gfs2_sbd *sdp)
634 628
635 length = gfs2_struct2blk(sdp, sdp->sd_log_num_revoke, sizeof(u64)); 629 length = gfs2_struct2blk(sdp, sdp->sd_log_num_revoke, sizeof(u64));
636 page = gfs2_get_log_desc(sdp, GFS2_LOG_DESC_REVOKE, length, sdp->sd_log_num_revoke); 630 page = gfs2_get_log_desc(sdp, GFS2_LOG_DESC_REVOKE, length, sdp->sd_log_num_revoke);
637 ld = page_address(page);
638 offset = sizeof(struct gfs2_log_descriptor); 631 offset = sizeof(struct gfs2_log_descriptor);
639 632
640 list_for_each_entry(bd, head, bd_list) { 633 list_for_each_entry(bd, head, bd_list) {
@@ -777,12 +770,10 @@ static void databuf_lo_add(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd)
777 struct address_space *mapping = bd->bd_bh->b_page->mapping; 770 struct address_space *mapping = bd->bd_bh->b_page->mapping;
778 struct gfs2_inode *ip = GFS2_I(mapping->host); 771 struct gfs2_inode *ip = GFS2_I(mapping->host);
779 772
780 lock_buffer(bd->bd_bh);
781 gfs2_log_lock(sdp);
782 if (tr) 773 if (tr)
783 tr->tr_touched = 1; 774 tr->tr_touched = 1;
784 if (!list_empty(&bd->bd_list)) 775 if (!list_empty(&bd->bd_list))
785 goto out; 776 return;
786 set_bit(GLF_LFLUSH, &bd->bd_gl->gl_flags); 777 set_bit(GLF_LFLUSH, &bd->bd_gl->gl_flags);
787 set_bit(GLF_DIRTY, &bd->bd_gl->gl_flags); 778 set_bit(GLF_DIRTY, &bd->bd_gl->gl_flags);
788 if (gfs2_is_jdata(ip)) { 779 if (gfs2_is_jdata(ip)) {
@@ -793,9 +784,6 @@ static void databuf_lo_add(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd)
793 } else { 784 } else {
794 list_add_tail(&bd->bd_list, &sdp->sd_log_le_ordered); 785 list_add_tail(&bd->bd_list, &sdp->sd_log_le_ordered);
795 } 786 }
796out:
797 gfs2_log_unlock(sdp);
798 unlock_buffer(bd->bd_bh);
799} 787}
800 788
801/** 789/**
diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c
index 40c4b0d42fa..c5af8e18f27 100644
--- a/fs/gfs2/quota.c
+++ b/fs/gfs2/quota.c
@@ -497,8 +497,11 @@ int gfs2_quota_hold(struct gfs2_inode *ip, u32 uid, u32 gid)
497 struct gfs2_quota_data **qd; 497 struct gfs2_quota_data **qd;
498 int error; 498 int error;
499 499
500 if (ip->i_res == NULL) 500 if (ip->i_res == NULL) {
501 gfs2_rs_alloc(ip); 501 error = gfs2_rs_alloc(ip);
502 if (error)
503 return error;
504 }
502 505
503 qd = ip->i_res->rs_qa_qd; 506 qd = ip->i_res->rs_qa_qd;
504 507
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index 3cc402ce6fe..38fe18f2f05 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -553,7 +553,6 @@ void gfs2_free_clones(struct gfs2_rgrpd *rgd)
553 */ 553 */
554int gfs2_rs_alloc(struct gfs2_inode *ip) 554int gfs2_rs_alloc(struct gfs2_inode *ip)
555{ 555{
556 int error = 0;
557 struct gfs2_blkreserv *res; 556 struct gfs2_blkreserv *res;
558 557
559 if (ip->i_res) 558 if (ip->i_res)
@@ -561,7 +560,7 @@ int gfs2_rs_alloc(struct gfs2_inode *ip)
561 560
562 res = kmem_cache_zalloc(gfs2_rsrv_cachep, GFP_NOFS); 561 res = kmem_cache_zalloc(gfs2_rsrv_cachep, GFP_NOFS);
563 if (!res) 562 if (!res)
564 error = -ENOMEM; 563 return -ENOMEM;
565 564
566 RB_CLEAR_NODE(&res->rs_node); 565 RB_CLEAR_NODE(&res->rs_node);
567 566
@@ -571,7 +570,7 @@ int gfs2_rs_alloc(struct gfs2_inode *ip)
571 else 570 else
572 ip->i_res = res; 571 ip->i_res = res;
573 up_write(&ip->i_rw_mutex); 572 up_write(&ip->i_rw_mutex);
574 return error; 573 return 0;
575} 574}
576 575
577static void dump_rs(struct seq_file *seq, const struct gfs2_blkreserv *rs) 576static void dump_rs(struct seq_file *seq, const struct gfs2_blkreserv *rs)
@@ -1263,7 +1262,9 @@ int gfs2_fitrim(struct file *filp, void __user *argp)
1263 int ret = 0; 1262 int ret = 0;
1264 u64 amt; 1263 u64 amt;
1265 u64 trimmed = 0; 1264 u64 trimmed = 0;
1265 u64 start, end, minlen;
1266 unsigned int x; 1266 unsigned int x;
1267 unsigned bs_shift = sdp->sd_sb.sb_bsize_shift;
1267 1268
1268 if (!capable(CAP_SYS_ADMIN)) 1269 if (!capable(CAP_SYS_ADMIN))
1269 return -EPERM; 1270 return -EPERM;
@@ -1271,19 +1272,25 @@ int gfs2_fitrim(struct file *filp, void __user *argp)
1271 if (!blk_queue_discard(q)) 1272 if (!blk_queue_discard(q))
1272 return -EOPNOTSUPP; 1273 return -EOPNOTSUPP;
1273 1274
1274 if (argp == NULL) { 1275 if (copy_from_user(&r, argp, sizeof(r)))
1275 r.start = 0;
1276 r.len = ULLONG_MAX;
1277 r.minlen = 0;
1278 } else if (copy_from_user(&r, argp, sizeof(r)))
1279 return -EFAULT; 1276 return -EFAULT;
1280 1277
1281 ret = gfs2_rindex_update(sdp); 1278 ret = gfs2_rindex_update(sdp);
1282 if (ret) 1279 if (ret)
1283 return ret; 1280 return ret;
1284 1281
1285 rgd = gfs2_blk2rgrpd(sdp, r.start, 0); 1282 start = r.start >> bs_shift;
1286 rgd_end = gfs2_blk2rgrpd(sdp, r.start + r.len, 0); 1283 end = start + (r.len >> bs_shift);
1284 minlen = max_t(u64, r.minlen,
1285 q->limits.discard_granularity) >> bs_shift;
1286
1287 rgd = gfs2_blk2rgrpd(sdp, start, 0);
1288 rgd_end = gfs2_blk2rgrpd(sdp, end - 1, 0);
1289
1290 if (end <= start ||
1291 minlen > sdp->sd_max_rg_data ||
1292 start > rgd_end->rd_data0 + rgd_end->rd_data)
1293 return -EINVAL;
1287 1294
1288 while (1) { 1295 while (1) {
1289 1296
@@ -1295,7 +1302,9 @@ int gfs2_fitrim(struct file *filp, void __user *argp)
1295 /* Trim each bitmap in the rgrp */ 1302 /* Trim each bitmap in the rgrp */
1296 for (x = 0; x < rgd->rd_length; x++) { 1303 for (x = 0; x < rgd->rd_length; x++) {
1297 struct gfs2_bitmap *bi = rgd->rd_bits + x; 1304 struct gfs2_bitmap *bi = rgd->rd_bits + x;
1298 ret = gfs2_rgrp_send_discards(sdp, rgd->rd_data0, NULL, bi, r.minlen, &amt); 1305 ret = gfs2_rgrp_send_discards(sdp,
1306 rgd->rd_data0, NULL, bi, minlen,
1307 &amt);
1299 if (ret) { 1308 if (ret) {
1300 gfs2_glock_dq_uninit(&gh); 1309 gfs2_glock_dq_uninit(&gh);
1301 goto out; 1310 goto out;
@@ -1324,7 +1333,7 @@ int gfs2_fitrim(struct file *filp, void __user *argp)
1324 1333
1325out: 1334out:
1326 r.len = trimmed << 9; 1335 r.len = trimmed << 9;
1327 if (argp && copy_to_user(argp, &r, sizeof(r))) 1336 if (copy_to_user(argp, &r, sizeof(r)))
1328 return -EFAULT; 1337 return -EFAULT;
1329 1338
1330 return ret; 1339 return ret;
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c
index bc737261f23..d6488674d91 100644
--- a/fs/gfs2/super.c
+++ b/fs/gfs2/super.c
@@ -810,7 +810,8 @@ static void gfs2_dirty_inode(struct inode *inode, int flags)
810 return; 810 return;
811 } 811 }
812 need_unlock = 1; 812 need_unlock = 1;
813 } 813 } else if (WARN_ON_ONCE(ip->i_gl->gl_state != LM_ST_EXCLUSIVE))
814 return;
814 815
815 if (current->journal_info == NULL) { 816 if (current->journal_info == NULL) {
816 ret = gfs2_trans_begin(sdp, RES_DINODE, 0); 817 ret = gfs2_trans_begin(sdp, RES_DINODE, 0);
diff --git a/fs/gfs2/trans.c b/fs/gfs2/trans.c
index adbd27875ef..413627072f3 100644
--- a/fs/gfs2/trans.c
+++ b/fs/gfs2/trans.c
@@ -155,14 +155,22 @@ void gfs2_trans_add_bh(struct gfs2_glock *gl, struct buffer_head *bh, int meta)
155 struct gfs2_sbd *sdp = gl->gl_sbd; 155 struct gfs2_sbd *sdp = gl->gl_sbd;
156 struct gfs2_bufdata *bd; 156 struct gfs2_bufdata *bd;
157 157
158 lock_buffer(bh);
159 gfs2_log_lock(sdp);
158 bd = bh->b_private; 160 bd = bh->b_private;
159 if (bd) 161 if (bd)
160 gfs2_assert(sdp, bd->bd_gl == gl); 162 gfs2_assert(sdp, bd->bd_gl == gl);
161 else { 163 else {
164 gfs2_log_unlock(sdp);
165 unlock_buffer(bh);
162 gfs2_attach_bufdata(gl, bh, meta); 166 gfs2_attach_bufdata(gl, bh, meta);
163 bd = bh->b_private; 167 bd = bh->b_private;
168 lock_buffer(bh);
169 gfs2_log_lock(sdp);
164 } 170 }
165 lops_add(sdp, bd); 171 lops_add(sdp, bd);
172 gfs2_log_unlock(sdp);
173 unlock_buffer(bh);
166} 174}
167 175
168void gfs2_trans_add_revoke(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd) 176void gfs2_trans_add_revoke(struct gfs2_sbd *sdp, struct gfs2_bufdata *bd)
diff --git a/fs/jffs2/file.c b/fs/jffs2/file.c
index 60ef3fb707f..1506673c087 100644
--- a/fs/jffs2/file.c
+++ b/fs/jffs2/file.c
@@ -138,33 +138,39 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping,
138 struct page *pg; 138 struct page *pg;
139 struct inode *inode = mapping->host; 139 struct inode *inode = mapping->host;
140 struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode); 140 struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
141 struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
142 struct jffs2_raw_inode ri;
143 uint32_t alloc_len = 0;
141 pgoff_t index = pos >> PAGE_CACHE_SHIFT; 144 pgoff_t index = pos >> PAGE_CACHE_SHIFT;
142 uint32_t pageofs = index << PAGE_CACHE_SHIFT; 145 uint32_t pageofs = index << PAGE_CACHE_SHIFT;
143 int ret = 0; 146 int ret = 0;
144 147
148 jffs2_dbg(1, "%s()\n", __func__);
149
150 if (pageofs > inode->i_size) {
151 ret = jffs2_reserve_space(c, sizeof(ri), &alloc_len,
152 ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE);
153 if (ret)
154 return ret;
155 }
156
157 mutex_lock(&f->sem);
145 pg = grab_cache_page_write_begin(mapping, index, flags); 158 pg = grab_cache_page_write_begin(mapping, index, flags);
146 if (!pg) 159 if (!pg) {
160 if (alloc_len)
161 jffs2_complete_reservation(c);
162 mutex_unlock(&f->sem);
147 return -ENOMEM; 163 return -ENOMEM;
164 }
148 *pagep = pg; 165 *pagep = pg;
149 166
150 jffs2_dbg(1, "%s()\n", __func__); 167 if (alloc_len) {
151
152 if (pageofs > inode->i_size) {
153 /* Make new hole frag from old EOF to new page */ 168 /* Make new hole frag from old EOF to new page */
154 struct jffs2_sb_info *c = JFFS2_SB_INFO(inode->i_sb);
155 struct jffs2_raw_inode ri;
156 struct jffs2_full_dnode *fn; 169 struct jffs2_full_dnode *fn;
157 uint32_t alloc_len;
158 170
159 jffs2_dbg(1, "Writing new hole frag 0x%x-0x%x between current EOF and new page\n", 171 jffs2_dbg(1, "Writing new hole frag 0x%x-0x%x between current EOF and new page\n",
160 (unsigned int)inode->i_size, pageofs); 172 (unsigned int)inode->i_size, pageofs);
161 173
162 ret = jffs2_reserve_space(c, sizeof(ri), &alloc_len,
163 ALLOC_NORMAL, JFFS2_SUMMARY_INODE_SIZE);
164 if (ret)
165 goto out_page;
166
167 mutex_lock(&f->sem);
168 memset(&ri, 0, sizeof(ri)); 174 memset(&ri, 0, sizeof(ri));
169 175
170 ri.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); 176 ri.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
@@ -191,7 +197,6 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping,
191 if (IS_ERR(fn)) { 197 if (IS_ERR(fn)) {
192 ret = PTR_ERR(fn); 198 ret = PTR_ERR(fn);
193 jffs2_complete_reservation(c); 199 jffs2_complete_reservation(c);
194 mutex_unlock(&f->sem);
195 goto out_page; 200 goto out_page;
196 } 201 }
197 ret = jffs2_add_full_dnode_to_inode(c, f, fn); 202 ret = jffs2_add_full_dnode_to_inode(c, f, fn);
@@ -206,12 +211,10 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping,
206 jffs2_mark_node_obsolete(c, fn->raw); 211 jffs2_mark_node_obsolete(c, fn->raw);
207 jffs2_free_full_dnode(fn); 212 jffs2_free_full_dnode(fn);
208 jffs2_complete_reservation(c); 213 jffs2_complete_reservation(c);
209 mutex_unlock(&f->sem);
210 goto out_page; 214 goto out_page;
211 } 215 }
212 jffs2_complete_reservation(c); 216 jffs2_complete_reservation(c);
213 inode->i_size = pageofs; 217 inode->i_size = pageofs;
214 mutex_unlock(&f->sem);
215 } 218 }
216 219
217 /* 220 /*
@@ -220,18 +223,18 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping,
220 * case of a short-copy. 223 * case of a short-copy.
221 */ 224 */
222 if (!PageUptodate(pg)) { 225 if (!PageUptodate(pg)) {
223 mutex_lock(&f->sem);
224 ret = jffs2_do_readpage_nolock(inode, pg); 226 ret = jffs2_do_readpage_nolock(inode, pg);
225 mutex_unlock(&f->sem);
226 if (ret) 227 if (ret)
227 goto out_page; 228 goto out_page;
228 } 229 }
230 mutex_unlock(&f->sem);
229 jffs2_dbg(1, "end write_begin(). pg->flags %lx\n", pg->flags); 231 jffs2_dbg(1, "end write_begin(). pg->flags %lx\n", pg->flags);
230 return ret; 232 return ret;
231 233
232out_page: 234out_page:
233 unlock_page(pg); 235 unlock_page(pg);
234 page_cache_release(pg); 236 page_cache_release(pg);
237 mutex_unlock(&f->sem);
235 return ret; 238 return ret;
236} 239}
237 240
diff --git a/fs/jfs/jfs_discard.c b/fs/jfs/jfs_discard.c
index 9947563e417..dfcd5030455 100644
--- a/fs/jfs/jfs_discard.c
+++ b/fs/jfs/jfs_discard.c
@@ -83,7 +83,7 @@ int jfs_ioc_trim(struct inode *ip, struct fstrim_range *range)
83 struct bmap *bmp = JFS_SBI(ip->i_sb)->bmap; 83 struct bmap *bmp = JFS_SBI(ip->i_sb)->bmap;
84 struct super_block *sb = ipbmap->i_sb; 84 struct super_block *sb = ipbmap->i_sb;
85 int agno, agno_end; 85 int agno, agno_end;
86 s64 start, end, minlen; 86 u64 start, end, minlen;
87 u64 trimmed = 0; 87 u64 trimmed = 0;
88 88
89 /** 89 /**
@@ -93,15 +93,19 @@ int jfs_ioc_trim(struct inode *ip, struct fstrim_range *range)
93 * minlen: minimum extent length in Bytes 93 * minlen: minimum extent length in Bytes
94 */ 94 */
95 start = range->start >> sb->s_blocksize_bits; 95 start = range->start >> sb->s_blocksize_bits;
96 if (start < 0)
97 start = 0;
98 end = start + (range->len >> sb->s_blocksize_bits) - 1; 96 end = start + (range->len >> sb->s_blocksize_bits) - 1;
99 if (end >= bmp->db_mapsize)
100 end = bmp->db_mapsize - 1;
101 minlen = range->minlen >> sb->s_blocksize_bits; 97 minlen = range->minlen >> sb->s_blocksize_bits;
102 if (minlen <= 0) 98 if (minlen == 0)
103 minlen = 1; 99 minlen = 1;
104 100
101 if (minlen > bmp->db_agsize ||
102 start >= bmp->db_mapsize ||
103 range->len < sb->s_blocksize)
104 return -EINVAL;
105
106 if (end >= bmp->db_mapsize)
107 end = bmp->db_mapsize - 1;
108
105 /** 109 /**
106 * we trim all ag's within the range 110 * we trim all ag's within the range
107 */ 111 */
diff --git a/fs/lockd/clntxdr.c b/fs/lockd/clntxdr.c
index d269ada7670..982d2676e1f 100644
--- a/fs/lockd/clntxdr.c
+++ b/fs/lockd/clntxdr.c
@@ -223,7 +223,7 @@ static void encode_nlm_stat(struct xdr_stream *xdr,
223{ 223{
224 __be32 *p; 224 __be32 *p;
225 225
226 BUG_ON(be32_to_cpu(stat) > NLM_LCK_DENIED_GRACE_PERIOD); 226 WARN_ON_ONCE(be32_to_cpu(stat) > NLM_LCK_DENIED_GRACE_PERIOD);
227 p = xdr_reserve_space(xdr, 4); 227 p = xdr_reserve_space(xdr, 4);
228 *p = stat; 228 *p = stat;
229} 229}
diff --git a/fs/lockd/mon.c b/fs/lockd/mon.c
index e4fb3ba5a58..3d7e09bcc0e 100644
--- a/fs/lockd/mon.c
+++ b/fs/lockd/mon.c
@@ -85,29 +85,38 @@ static struct rpc_clnt *nsm_create(struct net *net)
85 return rpc_create(&args); 85 return rpc_create(&args);
86} 86}
87 87
88static struct rpc_clnt *nsm_client_set(struct lockd_net *ln,
89 struct rpc_clnt *clnt)
90{
91 spin_lock(&ln->nsm_clnt_lock);
92 if (ln->nsm_users == 0) {
93 if (clnt == NULL)
94 goto out;
95 ln->nsm_clnt = clnt;
96 }
97 clnt = ln->nsm_clnt;
98 ln->nsm_users++;
99out:
100 spin_unlock(&ln->nsm_clnt_lock);
101 return clnt;
102}
103
88static struct rpc_clnt *nsm_client_get(struct net *net) 104static struct rpc_clnt *nsm_client_get(struct net *net)
89{ 105{
90 static DEFINE_MUTEX(nsm_create_mutex); 106 struct rpc_clnt *clnt, *new;
91 struct rpc_clnt *clnt;
92 struct lockd_net *ln = net_generic(net, lockd_net_id); 107 struct lockd_net *ln = net_generic(net, lockd_net_id);
93 108
94 spin_lock(&ln->nsm_clnt_lock); 109 clnt = nsm_client_set(ln, NULL);
95 if (ln->nsm_users) { 110 if (clnt != NULL)
96 ln->nsm_users++;
97 clnt = ln->nsm_clnt;
98 spin_unlock(&ln->nsm_clnt_lock);
99 goto out; 111 goto out;
100 }
101 spin_unlock(&ln->nsm_clnt_lock);
102 112
103 mutex_lock(&nsm_create_mutex); 113 clnt = new = nsm_create(net);
104 clnt = nsm_create(net); 114 if (IS_ERR(clnt))
105 if (!IS_ERR(clnt)) { 115 goto out;
106 ln->nsm_clnt = clnt; 116
107 smp_wmb(); 117 clnt = nsm_client_set(ln, new);
108 ln->nsm_users = 1; 118 if (clnt != new)
109 } 119 rpc_shutdown_client(new);
110 mutex_unlock(&nsm_create_mutex);
111out: 120out:
112 return clnt; 121 return clnt;
113} 122}
@@ -115,18 +124,16 @@ out:
115static void nsm_client_put(struct net *net) 124static void nsm_client_put(struct net *net)
116{ 125{
117 struct lockd_net *ln = net_generic(net, lockd_net_id); 126 struct lockd_net *ln = net_generic(net, lockd_net_id);
118 struct rpc_clnt *clnt = ln->nsm_clnt; 127 struct rpc_clnt *clnt = NULL;
119 int shutdown = 0;
120 128
121 spin_lock(&ln->nsm_clnt_lock); 129 spin_lock(&ln->nsm_clnt_lock);
122 if (ln->nsm_users) { 130 ln->nsm_users--;
123 if (--ln->nsm_users) 131 if (ln->nsm_users == 0) {
124 ln->nsm_clnt = NULL; 132 clnt = ln->nsm_clnt;
125 shutdown = !ln->nsm_users; 133 ln->nsm_clnt = NULL;
126 } 134 }
127 spin_unlock(&ln->nsm_clnt_lock); 135 spin_unlock(&ln->nsm_clnt_lock);
128 136 if (clnt != NULL)
129 if (shutdown)
130 rpc_shutdown_client(clnt); 137 rpc_shutdown_client(clnt);
131} 138}
132 139
diff --git a/fs/lockd/svcproc.c b/fs/lockd/svcproc.c
index 3009a365e08..21171f0c647 100644
--- a/fs/lockd/svcproc.c
+++ b/fs/lockd/svcproc.c
@@ -68,7 +68,8 @@ nlmsvc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp,
68 68
69 /* Obtain file pointer. Not used by FREE_ALL call. */ 69 /* Obtain file pointer. Not used by FREE_ALL call. */
70 if (filp != NULL) { 70 if (filp != NULL) {
71 if ((error = nlm_lookup_file(rqstp, &file, &lock->fh)) != 0) 71 error = cast_status(nlm_lookup_file(rqstp, &file, &lock->fh));
72 if (error != 0)
72 goto no_locks; 73 goto no_locks;
73 *filp = file; 74 *filp = file;
74 75
diff --git a/fs/namei.c b/fs/namei.c
index d1895f30815..937f9d50c84 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -705,8 +705,8 @@ static inline void put_link(struct nameidata *nd, struct path *link, void *cooki
705 path_put(link); 705 path_put(link);
706} 706}
707 707
708int sysctl_protected_symlinks __read_mostly = 1; 708int sysctl_protected_symlinks __read_mostly = 0;
709int sysctl_protected_hardlinks __read_mostly = 1; 709int sysctl_protected_hardlinks __read_mostly = 0;
710 710
711/** 711/**
712 * may_follow_link - Check symlink following for unsafe situations 712 * may_follow_link - Check symlink following for unsafe situations
diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c
index 9a521fb3986..5088b57b078 100644
--- a/fs/nfs/callback.c
+++ b/fs/nfs/callback.c
@@ -241,7 +241,7 @@ static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt,
241 svc_exit_thread(cb_info->rqst); 241 svc_exit_thread(cb_info->rqst);
242 cb_info->rqst = NULL; 242 cb_info->rqst = NULL;
243 cb_info->task = NULL; 243 cb_info->task = NULL;
244 return PTR_ERR(cb_info->task); 244 return ret;
245 } 245 }
246 dprintk("nfs_callback_up: service started\n"); 246 dprintk("nfs_callback_up: service started\n");
247 return 0; 247 return 0;
diff --git a/fs/nfs/dns_resolve.c b/fs/nfs/dns_resolve.c
index 31c26c4dcc2..ca4b11ec87a 100644
--- a/fs/nfs/dns_resolve.c
+++ b/fs/nfs/dns_resolve.c
@@ -217,7 +217,7 @@ static int nfs_dns_parse(struct cache_detail *cd, char *buf, int buflen)
217{ 217{
218 char buf1[NFS_DNS_HOSTNAME_MAXLEN+1]; 218 char buf1[NFS_DNS_HOSTNAME_MAXLEN+1];
219 struct nfs_dns_ent key, *item; 219 struct nfs_dns_ent key, *item;
220 unsigned long ttl; 220 unsigned int ttl;
221 ssize_t len; 221 ssize_t len;
222 int ret = -EINVAL; 222 int ret = -EINVAL;
223 223
@@ -240,7 +240,8 @@ static int nfs_dns_parse(struct cache_detail *cd, char *buf, int buflen)
240 key.namelen = len; 240 key.namelen = len;
241 memset(&key.h, 0, sizeof(key.h)); 241 memset(&key.h, 0, sizeof(key.h));
242 242
243 ttl = get_expiry(&buf); 243 if (get_uint(&buf, &ttl) < 0)
244 goto out;
244 if (ttl == 0) 245 if (ttl == 0)
245 goto out; 246 goto out;
246 key.h.expiry_time = ttl + seconds_since_boot(); 247 key.h.expiry_time = ttl + seconds_since_boot();
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 5c7325c5c5e..6fa01aea248 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -685,7 +685,10 @@ static void __put_nfs_open_context(struct nfs_open_context *ctx, int is_sync)
685 if (ctx->cred != NULL) 685 if (ctx->cred != NULL)
686 put_rpccred(ctx->cred); 686 put_rpccred(ctx->cred);
687 dput(ctx->dentry); 687 dput(ctx->dentry);
688 nfs_sb_deactive(sb); 688 if (is_sync)
689 nfs_sb_deactive(sb);
690 else
691 nfs_sb_deactive_async(sb);
689 kfree(ctx->mdsthreshold); 692 kfree(ctx->mdsthreshold);
690 kfree(ctx); 693 kfree(ctx);
691} 694}
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index 59b133c5d65..05521cadac2 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -351,10 +351,12 @@ extern int __init register_nfs_fs(void);
351extern void __exit unregister_nfs_fs(void); 351extern void __exit unregister_nfs_fs(void);
352extern void nfs_sb_active(struct super_block *sb); 352extern void nfs_sb_active(struct super_block *sb);
353extern void nfs_sb_deactive(struct super_block *sb); 353extern void nfs_sb_deactive(struct super_block *sb);
354extern void nfs_sb_deactive_async(struct super_block *sb);
354 355
355/* namespace.c */ 356/* namespace.c */
357#define NFS_PATH_CANONICAL 1
356extern char *nfs_path(char **p, struct dentry *dentry, 358extern char *nfs_path(char **p, struct dentry *dentry,
357 char *buffer, ssize_t buflen); 359 char *buffer, ssize_t buflen, unsigned flags);
358extern struct vfsmount *nfs_d_automount(struct path *path); 360extern struct vfsmount *nfs_d_automount(struct path *path);
359struct vfsmount *nfs_submount(struct nfs_server *, struct dentry *, 361struct vfsmount *nfs_submount(struct nfs_server *, struct dentry *,
360 struct nfs_fh *, struct nfs_fattr *); 362 struct nfs_fh *, struct nfs_fattr *);
@@ -498,7 +500,7 @@ static inline char *nfs_devname(struct dentry *dentry,
498 char *buffer, ssize_t buflen) 500 char *buffer, ssize_t buflen)
499{ 501{
500 char *dummy; 502 char *dummy;
501 return nfs_path(&dummy, dentry, buffer, buflen); 503 return nfs_path(&dummy, dentry, buffer, buflen, NFS_PATH_CANONICAL);
502} 504}
503 505
504/* 506/*
diff --git a/fs/nfs/mount_clnt.c b/fs/nfs/mount_clnt.c
index 8e65c7f1f87..015f71f8f62 100644
--- a/fs/nfs/mount_clnt.c
+++ b/fs/nfs/mount_clnt.c
@@ -181,7 +181,7 @@ int nfs_mount(struct nfs_mount_request *info)
181 else 181 else
182 msg.rpc_proc = &mnt_clnt->cl_procinfo[MOUNTPROC_MNT]; 182 msg.rpc_proc = &mnt_clnt->cl_procinfo[MOUNTPROC_MNT];
183 183
184 status = rpc_call_sync(mnt_clnt, &msg, 0); 184 status = rpc_call_sync(mnt_clnt, &msg, RPC_TASK_SOFT|RPC_TASK_TIMEOUT);
185 rpc_shutdown_client(mnt_clnt); 185 rpc_shutdown_client(mnt_clnt);
186 186
187 if (status < 0) 187 if (status < 0)
diff --git a/fs/nfs/namespace.c b/fs/nfs/namespace.c
index 655925373b9..dd057bc6b65 100644
--- a/fs/nfs/namespace.c
+++ b/fs/nfs/namespace.c
@@ -33,6 +33,7 @@ int nfs_mountpoint_expiry_timeout = 500 * HZ;
33 * @dentry - pointer to dentry 33 * @dentry - pointer to dentry
34 * @buffer - result buffer 34 * @buffer - result buffer
35 * @buflen - length of buffer 35 * @buflen - length of buffer
36 * @flags - options (see below)
36 * 37 *
37 * Helper function for constructing the server pathname 38 * Helper function for constructing the server pathname
38 * by arbitrary hashed dentry. 39 * by arbitrary hashed dentry.
@@ -40,8 +41,14 @@ int nfs_mountpoint_expiry_timeout = 500 * HZ;
40 * This is mainly for use in figuring out the path on the 41 * This is mainly for use in figuring out the path on the
41 * server side when automounting on top of an existing partition 42 * server side when automounting on top of an existing partition
42 * and in generating /proc/mounts and friends. 43 * and in generating /proc/mounts and friends.
44 *
45 * Supported flags:
46 * NFS_PATH_CANONICAL: ensure there is exactly one slash after
47 * the original device (export) name
48 * (if unset, the original name is returned verbatim)
43 */ 49 */
44char *nfs_path(char **p, struct dentry *dentry, char *buffer, ssize_t buflen) 50char *nfs_path(char **p, struct dentry *dentry, char *buffer, ssize_t buflen,
51 unsigned flags)
45{ 52{
46 char *end; 53 char *end;
47 int namelen; 54 int namelen;
@@ -74,7 +81,7 @@ rename_retry:
74 rcu_read_unlock(); 81 rcu_read_unlock();
75 goto rename_retry; 82 goto rename_retry;
76 } 83 }
77 if (*end != '/') { 84 if ((flags & NFS_PATH_CANONICAL) && *end != '/') {
78 if (--buflen < 0) { 85 if (--buflen < 0) {
79 spin_unlock(&dentry->d_lock); 86 spin_unlock(&dentry->d_lock);
80 rcu_read_unlock(); 87 rcu_read_unlock();
@@ -91,9 +98,11 @@ rename_retry:
91 return end; 98 return end;
92 } 99 }
93 namelen = strlen(base); 100 namelen = strlen(base);
94 /* Strip off excess slashes in base string */ 101 if (flags & NFS_PATH_CANONICAL) {
95 while (namelen > 0 && base[namelen - 1] == '/') 102 /* Strip off excess slashes in base string */
96 namelen--; 103 while (namelen > 0 && base[namelen - 1] == '/')
104 namelen--;
105 }
97 buflen -= namelen; 106 buflen -= namelen;
98 if (buflen < 0) { 107 if (buflen < 0) {
99 spin_unlock(&dentry->d_lock); 108 spin_unlock(&dentry->d_lock);
diff --git a/fs/nfs/nfs4filelayout.c b/fs/nfs/nfs4filelayout.c
index 52d84721206..2e45fd9c02a 100644
--- a/fs/nfs/nfs4filelayout.c
+++ b/fs/nfs/nfs4filelayout.c
@@ -122,12 +122,21 @@ static void filelayout_reset_read(struct nfs_read_data *data)
122 } 122 }
123} 123}
124 124
125static void filelayout_fenceme(struct inode *inode, struct pnfs_layout_hdr *lo)
126{
127 if (!test_and_clear_bit(NFS_LAYOUT_RETURN, &lo->plh_flags))
128 return;
129 clear_bit(NFS_INO_LAYOUTCOMMIT, &NFS_I(inode)->flags);
130 pnfs_return_layout(inode);
131}
132
125static int filelayout_async_handle_error(struct rpc_task *task, 133static int filelayout_async_handle_error(struct rpc_task *task,
126 struct nfs4_state *state, 134 struct nfs4_state *state,
127 struct nfs_client *clp, 135 struct nfs_client *clp,
128 struct pnfs_layout_segment *lseg) 136 struct pnfs_layout_segment *lseg)
129{ 137{
130 struct inode *inode = lseg->pls_layout->plh_inode; 138 struct pnfs_layout_hdr *lo = lseg->pls_layout;
139 struct inode *inode = lo->plh_inode;
131 struct nfs_server *mds_server = NFS_SERVER(inode); 140 struct nfs_server *mds_server = NFS_SERVER(inode);
132 struct nfs4_deviceid_node *devid = FILELAYOUT_DEVID_NODE(lseg); 141 struct nfs4_deviceid_node *devid = FILELAYOUT_DEVID_NODE(lseg);
133 struct nfs_client *mds_client = mds_server->nfs_client; 142 struct nfs_client *mds_client = mds_server->nfs_client;
@@ -204,10 +213,8 @@ static int filelayout_async_handle_error(struct rpc_task *task,
204 dprintk("%s DS connection error %d\n", __func__, 213 dprintk("%s DS connection error %d\n", __func__,
205 task->tk_status); 214 task->tk_status);
206 nfs4_mark_deviceid_unavailable(devid); 215 nfs4_mark_deviceid_unavailable(devid);
207 clear_bit(NFS_INO_LAYOUTCOMMIT, &NFS_I(inode)->flags); 216 set_bit(NFS_LAYOUT_RETURN, &lo->plh_flags);
208 _pnfs_return_layout(inode);
209 rpc_wake_up(&tbl->slot_tbl_waitq); 217 rpc_wake_up(&tbl->slot_tbl_waitq);
210 nfs4_ds_disconnect(clp);
211 /* fall through */ 218 /* fall through */
212 default: 219 default:
213reset: 220reset:
@@ -331,7 +338,9 @@ static void filelayout_read_count_stats(struct rpc_task *task, void *data)
331static void filelayout_read_release(void *data) 338static void filelayout_read_release(void *data)
332{ 339{
333 struct nfs_read_data *rdata = data; 340 struct nfs_read_data *rdata = data;
341 struct pnfs_layout_hdr *lo = rdata->header->lseg->pls_layout;
334 342
343 filelayout_fenceme(lo->plh_inode, lo);
335 nfs_put_client(rdata->ds_clp); 344 nfs_put_client(rdata->ds_clp);
336 rdata->header->mds_ops->rpc_release(data); 345 rdata->header->mds_ops->rpc_release(data);
337} 346}
@@ -429,7 +438,9 @@ static void filelayout_write_count_stats(struct rpc_task *task, void *data)
429static void filelayout_write_release(void *data) 438static void filelayout_write_release(void *data)
430{ 439{
431 struct nfs_write_data *wdata = data; 440 struct nfs_write_data *wdata = data;
441 struct pnfs_layout_hdr *lo = wdata->header->lseg->pls_layout;
432 442
443 filelayout_fenceme(lo->plh_inode, lo);
433 nfs_put_client(wdata->ds_clp); 444 nfs_put_client(wdata->ds_clp);
434 wdata->header->mds_ops->rpc_release(data); 445 wdata->header->mds_ops->rpc_release(data);
435} 446}
@@ -739,7 +750,7 @@ filelayout_decode_layout(struct pnfs_layout_hdr *flo,
739 goto out_err; 750 goto out_err;
740 751
741 if (fl->num_fh > 0) { 752 if (fl->num_fh > 0) {
742 fl->fh_array = kzalloc(fl->num_fh * sizeof(struct nfs_fh *), 753 fl->fh_array = kcalloc(fl->num_fh, sizeof(fl->fh_array[0]),
743 gfp_flags); 754 gfp_flags);
744 if (!fl->fh_array) 755 if (!fl->fh_array)
745 goto out_err; 756 goto out_err;
diff --git a/fs/nfs/nfs4filelayout.h b/fs/nfs/nfs4filelayout.h
index dca47d78671..8c07241fe52 100644
--- a/fs/nfs/nfs4filelayout.h
+++ b/fs/nfs/nfs4filelayout.h
@@ -149,6 +149,5 @@ extern void nfs4_fl_put_deviceid(struct nfs4_file_layout_dsaddr *dsaddr);
149extern void nfs4_fl_free_deviceid(struct nfs4_file_layout_dsaddr *dsaddr); 149extern void nfs4_fl_free_deviceid(struct nfs4_file_layout_dsaddr *dsaddr);
150struct nfs4_file_layout_dsaddr * 150struct nfs4_file_layout_dsaddr *
151filelayout_get_device_info(struct inode *inode, struct nfs4_deviceid *dev_id, gfp_t gfp_flags); 151filelayout_get_device_info(struct inode *inode, struct nfs4_deviceid *dev_id, gfp_t gfp_flags);
152void nfs4_ds_disconnect(struct nfs_client *clp);
153 152
154#endif /* FS_NFS_NFS4FILELAYOUT_H */ 153#endif /* FS_NFS_NFS4FILELAYOUT_H */
diff --git a/fs/nfs/nfs4filelayoutdev.c b/fs/nfs/nfs4filelayoutdev.c
index 3336d5eaf87..a8eaa9b7bb0 100644
--- a/fs/nfs/nfs4filelayoutdev.c
+++ b/fs/nfs/nfs4filelayoutdev.c
@@ -149,28 +149,6 @@ _data_server_lookup_locked(const struct list_head *dsaddrs)
149} 149}
150 150
151/* 151/*
152 * Lookup DS by nfs_client pointer. Zero data server client pointer
153 */
154void nfs4_ds_disconnect(struct nfs_client *clp)
155{
156 struct nfs4_pnfs_ds *ds;
157 struct nfs_client *found = NULL;
158
159 dprintk("%s clp %p\n", __func__, clp);
160 spin_lock(&nfs4_ds_cache_lock);
161 list_for_each_entry(ds, &nfs4_data_server_cache, ds_node)
162 if (ds->ds_clp && ds->ds_clp == clp) {
163 found = ds->ds_clp;
164 ds->ds_clp = NULL;
165 }
166 spin_unlock(&nfs4_ds_cache_lock);
167 if (found) {
168 set_bit(NFS_CS_STOP_RENEW, &clp->cl_res_state);
169 nfs_put_client(clp);
170 }
171}
172
173/*
174 * Create an rpc connection to the nfs4_pnfs_ds data server 152 * Create an rpc connection to the nfs4_pnfs_ds data server
175 * Currently only supports IPv4 and IPv6 addresses 153 * Currently only supports IPv4 and IPv6 addresses
176 */ 154 */
diff --git a/fs/nfs/nfs4getroot.c b/fs/nfs/nfs4getroot.c
index 6a83780e0ce..549462e5b9b 100644
--- a/fs/nfs/nfs4getroot.c
+++ b/fs/nfs/nfs4getroot.c
@@ -5,6 +5,7 @@
5 5
6#include <linux/nfs_fs.h> 6#include <linux/nfs_fs.h>
7#include "nfs4_fs.h" 7#include "nfs4_fs.h"
8#include "internal.h"
8 9
9#define NFSDBG_FACILITY NFSDBG_CLIENT 10#define NFSDBG_FACILITY NFSDBG_CLIENT
10 11
diff --git a/fs/nfs/nfs4namespace.c b/fs/nfs/nfs4namespace.c
index 79fbb61ce20..1e09eb78543 100644
--- a/fs/nfs/nfs4namespace.c
+++ b/fs/nfs/nfs4namespace.c
@@ -81,7 +81,8 @@ static char *nfs_path_component(const char *nfspath, const char *end)
81static char *nfs4_path(struct dentry *dentry, char *buffer, ssize_t buflen) 81static char *nfs4_path(struct dentry *dentry, char *buffer, ssize_t buflen)
82{ 82{
83 char *limit; 83 char *limit;
84 char *path = nfs_path(&limit, dentry, buffer, buflen); 84 char *path = nfs_path(&limit, dentry, buffer, buflen,
85 NFS_PATH_CANONICAL);
85 if (!IS_ERR(path)) { 86 if (!IS_ERR(path)) {
86 char *path_component = nfs_path_component(path, limit); 87 char *path_component = nfs_path_component(path, limit);
87 if (path_component) 88 if (path_component)
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 68b21d81b7a..5eec4429970 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -339,8 +339,7 @@ static int nfs4_handle_exception(struct nfs_server *server, int errorcode, struc
339 dprintk("%s ERROR: %d Reset session\n", __func__, 339 dprintk("%s ERROR: %d Reset session\n", __func__,
340 errorcode); 340 errorcode);
341 nfs4_schedule_session_recovery(clp->cl_session, errorcode); 341 nfs4_schedule_session_recovery(clp->cl_session, errorcode);
342 exception->retry = 1; 342 goto wait_on_recovery;
343 break;
344#endif /* defined(CONFIG_NFS_V4_1) */ 343#endif /* defined(CONFIG_NFS_V4_1) */
345 case -NFS4ERR_FILE_OPEN: 344 case -NFS4ERR_FILE_OPEN:
346 if (exception->timeout > HZ) { 345 if (exception->timeout > HZ) {
@@ -1572,9 +1571,11 @@ static void nfs4_open_prepare(struct rpc_task *task, void *calldata)
1572 data->timestamp = jiffies; 1571 data->timestamp = jiffies;
1573 if (nfs4_setup_sequence(data->o_arg.server, 1572 if (nfs4_setup_sequence(data->o_arg.server,
1574 &data->o_arg.seq_args, 1573 &data->o_arg.seq_args,
1575 &data->o_res.seq_res, task)) 1574 &data->o_res.seq_res,
1576 return; 1575 task) != 0)
1577 rpc_call_start(task); 1576 nfs_release_seqid(data->o_arg.seqid);
1577 else
1578 rpc_call_start(task);
1578 return; 1579 return;
1579unlock_no_action: 1580unlock_no_action:
1580 rcu_read_unlock(); 1581 rcu_read_unlock();
@@ -1748,7 +1749,7 @@ static int nfs4_opendata_access(struct rpc_cred *cred,
1748 1749
1749 /* even though OPEN succeeded, access is denied. Close the file */ 1750 /* even though OPEN succeeded, access is denied. Close the file */
1750 nfs4_close_state(state, fmode); 1751 nfs4_close_state(state, fmode);
1751 return -NFS4ERR_ACCESS; 1752 return -EACCES;
1752} 1753}
1753 1754
1754/* 1755/*
@@ -2196,7 +2197,7 @@ static void nfs4_free_closedata(void *data)
2196 nfs4_put_open_state(calldata->state); 2197 nfs4_put_open_state(calldata->state);
2197 nfs_free_seqid(calldata->arg.seqid); 2198 nfs_free_seqid(calldata->arg.seqid);
2198 nfs4_put_state_owner(sp); 2199 nfs4_put_state_owner(sp);
2199 nfs_sb_deactive(sb); 2200 nfs_sb_deactive_async(sb);
2200 kfree(calldata); 2201 kfree(calldata);
2201} 2202}
2202 2203
@@ -2296,9 +2297,10 @@ static void nfs4_close_prepare(struct rpc_task *task, void *data)
2296 if (nfs4_setup_sequence(NFS_SERVER(inode), 2297 if (nfs4_setup_sequence(NFS_SERVER(inode),
2297 &calldata->arg.seq_args, 2298 &calldata->arg.seq_args,
2298 &calldata->res.seq_res, 2299 &calldata->res.seq_res,
2299 task)) 2300 task) != 0)
2300 goto out; 2301 nfs_release_seqid(calldata->arg.seqid);
2301 rpc_call_start(task); 2302 else
2303 rpc_call_start(task);
2302out: 2304out:
2303 dprintk("%s: done!\n", __func__); 2305 dprintk("%s: done!\n", __func__);
2304} 2306}
@@ -4529,6 +4531,7 @@ static void nfs4_locku_done(struct rpc_task *task, void *data)
4529 if (nfs4_async_handle_error(task, calldata->server, NULL) == -EAGAIN) 4531 if (nfs4_async_handle_error(task, calldata->server, NULL) == -EAGAIN)
4530 rpc_restart_call_prepare(task); 4532 rpc_restart_call_prepare(task);
4531 } 4533 }
4534 nfs_release_seqid(calldata->arg.seqid);
4532} 4535}
4533 4536
4534static void nfs4_locku_prepare(struct rpc_task *task, void *data) 4537static void nfs4_locku_prepare(struct rpc_task *task, void *data)
@@ -4545,9 +4548,11 @@ static void nfs4_locku_prepare(struct rpc_task *task, void *data)
4545 calldata->timestamp = jiffies; 4548 calldata->timestamp = jiffies;
4546 if (nfs4_setup_sequence(calldata->server, 4549 if (nfs4_setup_sequence(calldata->server,
4547 &calldata->arg.seq_args, 4550 &calldata->arg.seq_args,
4548 &calldata->res.seq_res, task)) 4551 &calldata->res.seq_res,
4549 return; 4552 task) != 0)
4550 rpc_call_start(task); 4553 nfs_release_seqid(calldata->arg.seqid);
4554 else
4555 rpc_call_start(task);
4551} 4556}
4552 4557
4553static const struct rpc_call_ops nfs4_locku_ops = { 4558static const struct rpc_call_ops nfs4_locku_ops = {
@@ -4692,7 +4697,7 @@ static void nfs4_lock_prepare(struct rpc_task *task, void *calldata)
4692 /* Do we need to do an open_to_lock_owner? */ 4697 /* Do we need to do an open_to_lock_owner? */
4693 if (!(data->arg.lock_seqid->sequence->flags & NFS_SEQID_CONFIRMED)) { 4698 if (!(data->arg.lock_seqid->sequence->flags & NFS_SEQID_CONFIRMED)) {
4694 if (nfs_wait_on_sequence(data->arg.open_seqid, task) != 0) 4699 if (nfs_wait_on_sequence(data->arg.open_seqid, task) != 0)
4695 return; 4700 goto out_release_lock_seqid;
4696 data->arg.open_stateid = &state->stateid; 4701 data->arg.open_stateid = &state->stateid;
4697 data->arg.new_lock_owner = 1; 4702 data->arg.new_lock_owner = 1;
4698 data->res.open_seqid = data->arg.open_seqid; 4703 data->res.open_seqid = data->arg.open_seqid;
@@ -4701,10 +4706,15 @@ static void nfs4_lock_prepare(struct rpc_task *task, void *calldata)
4701 data->timestamp = jiffies; 4706 data->timestamp = jiffies;
4702 if (nfs4_setup_sequence(data->server, 4707 if (nfs4_setup_sequence(data->server,
4703 &data->arg.seq_args, 4708 &data->arg.seq_args,
4704 &data->res.seq_res, task)) 4709 &data->res.seq_res,
4710 task) == 0) {
4711 rpc_call_start(task);
4705 return; 4712 return;
4706 rpc_call_start(task); 4713 }
4707 dprintk("%s: done!, ret = %d\n", __func__, data->rpc_status); 4714 nfs_release_seqid(data->arg.open_seqid);
4715out_release_lock_seqid:
4716 nfs_release_seqid(data->arg.lock_seqid);
4717 dprintk("%s: done!, ret = %d\n", __func__, task->tk_status);
4708} 4718}
4709 4719
4710static void nfs4_recover_lock_prepare(struct rpc_task *task, void *calldata) 4720static void nfs4_recover_lock_prepare(struct rpc_task *task, void *calldata)
@@ -5667,7 +5677,7 @@ static void nfs4_add_and_init_slots(struct nfs4_slot_table *tbl,
5667 tbl->slots = new; 5677 tbl->slots = new;
5668 tbl->max_slots = max_slots; 5678 tbl->max_slots = max_slots;
5669 } 5679 }
5670 tbl->highest_used_slotid = -1; /* no slot is currently used */ 5680 tbl->highest_used_slotid = NFS4_NO_SLOT;
5671 for (i = 0; i < tbl->max_slots; i++) 5681 for (i = 0; i < tbl->max_slots; i++)
5672 tbl->slots[i].seq_nr = ivalue; 5682 tbl->slots[i].seq_nr = ivalue;
5673 spin_unlock(&tbl->slot_tbl_lock); 5683 spin_unlock(&tbl->slot_tbl_lock);
diff --git a/fs/nfs/objlayout/objio_osd.c b/fs/nfs/objlayout/objio_osd.c
index be731e6b7b9..c6f990656f8 100644
--- a/fs/nfs/objlayout/objio_osd.c
+++ b/fs/nfs/objlayout/objio_osd.c
@@ -369,7 +369,7 @@ void objio_free_result(struct objlayout_io_res *oir)
369 kfree(objios); 369 kfree(objios);
370} 370}
371 371
372enum pnfs_osd_errno osd_pri_2_pnfs_err(enum osd_err_priority oep) 372static enum pnfs_osd_errno osd_pri_2_pnfs_err(enum osd_err_priority oep)
373{ 373{
374 switch (oep) { 374 switch (oep) {
375 case OSD_ERR_PRI_NO_ERROR: 375 case OSD_ERR_PRI_NO_ERROR:
@@ -574,7 +574,7 @@ static bool objio_pg_test(struct nfs_pageio_descriptor *pgio,
574 (unsigned long)pgio->pg_layout_private; 574 (unsigned long)pgio->pg_layout_private;
575} 575}
576 576
577void objio_init_read(struct nfs_pageio_descriptor *pgio, struct nfs_page *req) 577static void objio_init_read(struct nfs_pageio_descriptor *pgio, struct nfs_page *req)
578{ 578{
579 pnfs_generic_pg_init_read(pgio, req); 579 pnfs_generic_pg_init_read(pgio, req);
580 if (unlikely(pgio->pg_lseg == NULL)) 580 if (unlikely(pgio->pg_lseg == NULL))
@@ -604,7 +604,7 @@ static bool aligned_on_raid_stripe(u64 offset, struct ore_layout *layout,
604 return false; 604 return false;
605} 605}
606 606
607void objio_init_write(struct nfs_pageio_descriptor *pgio, struct nfs_page *req) 607static void objio_init_write(struct nfs_pageio_descriptor *pgio, struct nfs_page *req)
608{ 608{
609 unsigned long stripe_end = 0; 609 unsigned long stripe_end = 0;
610 u64 wb_size; 610 u64 wb_size;
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index fe624c91bd0..2878f97bd78 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -925,8 +925,8 @@ pnfs_find_alloc_layout(struct inode *ino,
925 if (likely(nfsi->layout == NULL)) { /* Won the race? */ 925 if (likely(nfsi->layout == NULL)) { /* Won the race? */
926 nfsi->layout = new; 926 nfsi->layout = new;
927 return new; 927 return new;
928 } 928 } else if (new != NULL)
929 pnfs_free_layout_hdr(new); 929 pnfs_free_layout_hdr(new);
930out_existing: 930out_existing:
931 pnfs_get_layout_hdr(nfsi->layout); 931 pnfs_get_layout_hdr(nfsi->layout);
932 return nfsi->layout; 932 return nfsi->layout;
diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h
index 2d722dba111..dbf7bba52da 100644
--- a/fs/nfs/pnfs.h
+++ b/fs/nfs/pnfs.h
@@ -62,6 +62,7 @@ enum {
62 NFS_LAYOUT_RW_FAILED, /* get rw layout failed stop trying */ 62 NFS_LAYOUT_RW_FAILED, /* get rw layout failed stop trying */
63 NFS_LAYOUT_BULK_RECALL, /* bulk recall affecting layout */ 63 NFS_LAYOUT_BULK_RECALL, /* bulk recall affecting layout */
64 NFS_LAYOUT_ROC, /* some lseg had roc bit set */ 64 NFS_LAYOUT_ROC, /* some lseg had roc bit set */
65 NFS_LAYOUT_RETURN, /* Return this layout ASAP */
65}; 66};
66 67
67enum layoutdriver_policy_flags { 68enum layoutdriver_policy_flags {
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index e831bce4976..652d3f7176a 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -54,6 +54,7 @@
54#include <linux/parser.h> 54#include <linux/parser.h>
55#include <linux/nsproxy.h> 55#include <linux/nsproxy.h>
56#include <linux/rcupdate.h> 56#include <linux/rcupdate.h>
57#include <linux/kthread.h>
57 58
58#include <asm/uaccess.h> 59#include <asm/uaccess.h>
59 60
@@ -415,6 +416,54 @@ void nfs_sb_deactive(struct super_block *sb)
415} 416}
416EXPORT_SYMBOL_GPL(nfs_sb_deactive); 417EXPORT_SYMBOL_GPL(nfs_sb_deactive);
417 418
419static int nfs_deactivate_super_async_work(void *ptr)
420{
421 struct super_block *sb = ptr;
422
423 deactivate_super(sb);
424 module_put_and_exit(0);
425 return 0;
426}
427
428/*
429 * same effect as deactivate_super, but will do final unmount in kthread
430 * context
431 */
432static void nfs_deactivate_super_async(struct super_block *sb)
433{
434 struct task_struct *task;
435 char buf[INET6_ADDRSTRLEN + 1];
436 struct nfs_server *server = NFS_SB(sb);
437 struct nfs_client *clp = server->nfs_client;
438
439 if (!atomic_add_unless(&sb->s_active, -1, 1)) {
440 rcu_read_lock();
441 snprintf(buf, sizeof(buf),
442 rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_ADDR));
443 rcu_read_unlock();
444
445 __module_get(THIS_MODULE);
446 task = kthread_run(nfs_deactivate_super_async_work, sb,
447 "%s-deactivate-super", buf);
448 if (IS_ERR(task)) {
449 pr_err("%s: kthread_run: %ld\n",
450 __func__, PTR_ERR(task));
451 /* make synchronous call and hope for the best */
452 deactivate_super(sb);
453 module_put(THIS_MODULE);
454 }
455 }
456}
457
458void nfs_sb_deactive_async(struct super_block *sb)
459{
460 struct nfs_server *server = NFS_SB(sb);
461
462 if (atomic_dec_and_test(&server->active))
463 nfs_deactivate_super_async(sb);
464}
465EXPORT_SYMBOL_GPL(nfs_sb_deactive_async);
466
418/* 467/*
419 * Deliver file system statistics to userspace 468 * Deliver file system statistics to userspace
420 */ 469 */
@@ -771,7 +820,7 @@ int nfs_show_devname(struct seq_file *m, struct dentry *root)
771 int err = 0; 820 int err = 0;
772 if (!page) 821 if (!page)
773 return -ENOMEM; 822 return -ENOMEM;
774 devname = nfs_path(&dummy, root, page, PAGE_SIZE); 823 devname = nfs_path(&dummy, root, page, PAGE_SIZE, 0);
775 if (IS_ERR(devname)) 824 if (IS_ERR(devname))
776 err = PTR_ERR(devname); 825 err = PTR_ERR(devname);
777 else 826 else
diff --git a/fs/nfs/unlink.c b/fs/nfs/unlink.c
index 13cea637eff..3f79c77153b 100644
--- a/fs/nfs/unlink.c
+++ b/fs/nfs/unlink.c
@@ -95,7 +95,7 @@ static void nfs_async_unlink_release(void *calldata)
95 95
96 nfs_dec_sillycount(data->dir); 96 nfs_dec_sillycount(data->dir);
97 nfs_free_unlinkdata(data); 97 nfs_free_unlinkdata(data);
98 nfs_sb_deactive(sb); 98 nfs_sb_deactive_async(sb);
99} 99}
100 100
101static void nfs_unlink_prepare(struct rpc_task *task, void *calldata) 101static void nfs_unlink_prepare(struct rpc_task *task, void *calldata)
diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c
index f35794b97e8..a5063602536 100644
--- a/fs/notify/fanotify/fanotify.c
+++ b/fs/notify/fanotify/fanotify.c
@@ -21,6 +21,7 @@ static bool should_merge(struct fsnotify_event *old, struct fsnotify_event *new)
21 if ((old->path.mnt == new->path.mnt) && 21 if ((old->path.mnt == new->path.mnt) &&
22 (old->path.dentry == new->path.dentry)) 22 (old->path.dentry == new->path.dentry))
23 return true; 23 return true;
24 break;
24 case (FSNOTIFY_EVENT_NONE): 25 case (FSNOTIFY_EVENT_NONE):
25 return true; 26 return true;
26 default: 27 default:
diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
index 721d692fa8d..6fcaeb8c902 100644
--- a/fs/notify/fanotify/fanotify_user.c
+++ b/fs/notify/fanotify/fanotify_user.c
@@ -258,7 +258,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
258 if (ret) 258 if (ret)
259 goto out_close_fd; 259 goto out_close_fd;
260 260
261 fd_install(fd, f); 261 if (fd != FAN_NOFD)
262 fd_install(fd, f);
262 return fanotify_event_metadata.event_len; 263 return fanotify_event_metadata.event_len;
263 264
264out_close_fd: 265out_close_fd:
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 144a96732dd..3c231adf845 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -873,6 +873,113 @@ static const struct file_operations proc_environ_operations = {
873 .release = mem_release, 873 .release = mem_release,
874}; 874};
875 875
876static ssize_t oom_adj_read(struct file *file, char __user *buf, size_t count,
877 loff_t *ppos)
878{
879 struct task_struct *task = get_proc_task(file->f_path.dentry->d_inode);
880 char buffer[PROC_NUMBUF];
881 int oom_adj = OOM_ADJUST_MIN;
882 size_t len;
883 unsigned long flags;
884
885 if (!task)
886 return -ESRCH;
887 if (lock_task_sighand(task, &flags)) {
888 if (task->signal->oom_score_adj == OOM_SCORE_ADJ_MAX)
889 oom_adj = OOM_ADJUST_MAX;
890 else
891 oom_adj = (task->signal->oom_score_adj * -OOM_DISABLE) /
892 OOM_SCORE_ADJ_MAX;
893 unlock_task_sighand(task, &flags);
894 }
895 put_task_struct(task);
896 len = snprintf(buffer, sizeof(buffer), "%d\n", oom_adj);
897 return simple_read_from_buffer(buf, count, ppos, buffer, len);
898}
899
900static ssize_t oom_adj_write(struct file *file, const char __user *buf,
901 size_t count, loff_t *ppos)
902{
903 struct task_struct *task;
904 char buffer[PROC_NUMBUF];
905 int oom_adj;
906 unsigned long flags;
907 int err;
908
909 memset(buffer, 0, sizeof(buffer));
910 if (count > sizeof(buffer) - 1)
911 count = sizeof(buffer) - 1;
912 if (copy_from_user(buffer, buf, count)) {
913 err = -EFAULT;
914 goto out;
915 }
916
917 err = kstrtoint(strstrip(buffer), 0, &oom_adj);
918 if (err)
919 goto out;
920 if ((oom_adj < OOM_ADJUST_MIN || oom_adj > OOM_ADJUST_MAX) &&
921 oom_adj != OOM_DISABLE) {
922 err = -EINVAL;
923 goto out;
924 }
925
926 task = get_proc_task(file->f_path.dentry->d_inode);
927 if (!task) {
928 err = -ESRCH;
929 goto out;
930 }
931
932 task_lock(task);
933 if (!task->mm) {
934 err = -EINVAL;
935 goto err_task_lock;
936 }
937
938 if (!lock_task_sighand(task, &flags)) {
939 err = -ESRCH;
940 goto err_task_lock;
941 }
942
943 /*
944 * Scale /proc/pid/oom_score_adj appropriately ensuring that a maximum
945 * value is always attainable.
946 */
947 if (oom_adj == OOM_ADJUST_MAX)
948 oom_adj = OOM_SCORE_ADJ_MAX;
949 else
950 oom_adj = (oom_adj * OOM_SCORE_ADJ_MAX) / -OOM_DISABLE;
951
952 if (oom_adj < task->signal->oom_score_adj &&
953 !capable(CAP_SYS_RESOURCE)) {
954 err = -EACCES;
955 goto err_sighand;
956 }
957
958 /*
959 * /proc/pid/oom_adj is provided for legacy purposes, ask users to use
960 * /proc/pid/oom_score_adj instead.
961 */
962 printk_once(KERN_WARNING "%s (%d): /proc/%d/oom_adj is deprecated, please use /proc/%d/oom_score_adj instead.\n",
963 current->comm, task_pid_nr(current), task_pid_nr(task),
964 task_pid_nr(task));
965
966 task->signal->oom_score_adj = oom_adj;
967 trace_oom_score_adj_update(task);
968err_sighand:
969 unlock_task_sighand(task, &flags);
970err_task_lock:
971 task_unlock(task);
972 put_task_struct(task);
973out:
974 return err < 0 ? err : count;
975}
976
977static const struct file_operations proc_oom_adj_operations = {
978 .read = oom_adj_read,
979 .write = oom_adj_write,
980 .llseek = generic_file_llseek,
981};
982
876static ssize_t oom_score_adj_read(struct file *file, char __user *buf, 983static ssize_t oom_score_adj_read(struct file *file, char __user *buf,
877 size_t count, loff_t *ppos) 984 size_t count, loff_t *ppos)
878{ 985{
@@ -2598,6 +2705,7 @@ static const struct pid_entry tgid_base_stuff[] = {
2598 REG("cgroup", S_IRUGO, proc_cgroup_operations), 2705 REG("cgroup", S_IRUGO, proc_cgroup_operations),
2599#endif 2706#endif
2600 INF("oom_score", S_IRUGO, proc_oom_score), 2707 INF("oom_score", S_IRUGO, proc_oom_score),
2708 REG("oom_adj", S_IRUGO|S_IWUSR, proc_oom_adj_operations),
2601 REG("oom_score_adj", S_IRUGO|S_IWUSR, proc_oom_score_adj_operations), 2709 REG("oom_score_adj", S_IRUGO|S_IWUSR, proc_oom_score_adj_operations),
2602#ifdef CONFIG_AUDITSYSCALL 2710#ifdef CONFIG_AUDITSYSCALL
2603 REG("loginuid", S_IWUSR|S_IRUGO, proc_loginuid_operations), 2711 REG("loginuid", S_IWUSR|S_IRUGO, proc_loginuid_operations),
@@ -2964,6 +3072,7 @@ static const struct pid_entry tid_base_stuff[] = {
2964 REG("cgroup", S_IRUGO, proc_cgroup_operations), 3072 REG("cgroup", S_IRUGO, proc_cgroup_operations),
2965#endif 3073#endif
2966 INF("oom_score", S_IRUGO, proc_oom_score), 3074 INF("oom_score", S_IRUGO, proc_oom_score),
3075 REG("oom_adj", S_IRUGO|S_IWUSR, proc_oom_adj_operations),
2967 REG("oom_score_adj", S_IRUGO|S_IWUSR, proc_oom_score_adj_operations), 3076 REG("oom_score_adj", S_IRUGO|S_IWUSR, proc_oom_score_adj_operations),
2968#ifdef CONFIG_AUDITSYSCALL 3077#ifdef CONFIG_AUDITSYSCALL
2969 REG("loginuid", S_IWUSR|S_IRUGO, proc_loginuid_operations), 3078 REG("loginuid", S_IWUSR|S_IRUGO, proc_loginuid_operations),
diff --git a/fs/proc/internal.h b/fs/proc/internal.h
index cceaab07ad5..43973b084ab 100644
--- a/fs/proc/internal.h
+++ b/fs/proc/internal.h
@@ -12,6 +12,7 @@
12#include <linux/sched.h> 12#include <linux/sched.h>
13#include <linux/proc_fs.h> 13#include <linux/proc_fs.h>
14struct ctl_table_header; 14struct ctl_table_header;
15struct mempolicy;
15 16
16extern struct proc_dir_entry proc_root; 17extern struct proc_dir_entry proc_root;
17#ifdef CONFIG_PROC_SYSCTL 18#ifdef CONFIG_PROC_SYSCTL
@@ -74,6 +75,9 @@ struct proc_maps_private {
74#ifdef CONFIG_MMU 75#ifdef CONFIG_MMU
75 struct vm_area_struct *tail_vma; 76 struct vm_area_struct *tail_vma;
76#endif 77#endif
78#ifdef CONFIG_NUMA
79 struct mempolicy *task_mempolicy;
80#endif
77}; 81};
78 82
79void proc_init_inodecache(void); 83void proc_init_inodecache(void);
diff --git a/fs/proc/stat.c b/fs/proc/stat.c
index 64c3b317236..e296572c73e 100644
--- a/fs/proc/stat.c
+++ b/fs/proc/stat.c
@@ -45,10 +45,13 @@ static cputime64_t get_iowait_time(int cpu)
45 45
46static u64 get_idle_time(int cpu) 46static u64 get_idle_time(int cpu)
47{ 47{
48 u64 idle, idle_time = get_cpu_idle_time_us(cpu, NULL); 48 u64 idle, idle_time = -1ULL;
49
50 if (cpu_online(cpu))
51 idle_time = get_cpu_idle_time_us(cpu, NULL);
49 52
50 if (idle_time == -1ULL) 53 if (idle_time == -1ULL)
51 /* !NO_HZ so we can rely on cpustat.idle */ 54 /* !NO_HZ or cpu offline so we can rely on cpustat.idle */
52 idle = kcpustat_cpu(cpu).cpustat[CPUTIME_IDLE]; 55 idle = kcpustat_cpu(cpu).cpustat[CPUTIME_IDLE];
53 else 56 else
54 idle = usecs_to_cputime64(idle_time); 57 idle = usecs_to_cputime64(idle_time);
@@ -58,10 +61,13 @@ static u64 get_idle_time(int cpu)
58 61
59static u64 get_iowait_time(int cpu) 62static u64 get_iowait_time(int cpu)
60{ 63{
61 u64 iowait, iowait_time = get_cpu_iowait_time_us(cpu, NULL); 64 u64 iowait, iowait_time = -1ULL;
65
66 if (cpu_online(cpu))
67 iowait_time = get_cpu_iowait_time_us(cpu, NULL);
62 68
63 if (iowait_time == -1ULL) 69 if (iowait_time == -1ULL)
64 /* !NO_HZ so we can rely on cpustat.iowait */ 70 /* !NO_HZ or cpu offline so we can rely on cpustat.iowait */
65 iowait = kcpustat_cpu(cpu).cpustat[CPUTIME_IOWAIT]; 71 iowait = kcpustat_cpu(cpu).cpustat[CPUTIME_IOWAIT];
66 else 72 else
67 iowait = usecs_to_cputime64(iowait_time); 73 iowait = usecs_to_cputime64(iowait_time);
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 79827ce03e3..90c63f9392a 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -90,10 +90,55 @@ static void pad_len_spaces(struct seq_file *m, int len)
90 seq_printf(m, "%*c", len, ' '); 90 seq_printf(m, "%*c", len, ' ');
91} 91}
92 92
93#ifdef CONFIG_NUMA
94/*
95 * These functions are for numa_maps but called in generic **maps seq_file
96 * ->start(), ->stop() ops.
97 *
98 * numa_maps scans all vmas under mmap_sem and checks their mempolicy.
99 * Each mempolicy object is controlled by reference counting. The problem here
100 * is how to avoid accessing dead mempolicy object.
101 *
102 * Because we're holding mmap_sem while reading seq_file, it's safe to access
103 * each vma's mempolicy, no vma objects will never drop refs to mempolicy.
104 *
105 * A task's mempolicy (task->mempolicy) has different behavior. task->mempolicy
106 * is set and replaced under mmap_sem but unrefed and cleared under task_lock().
107 * So, without task_lock(), we cannot trust get_vma_policy() because we cannot
108 * gurantee the task never exits under us. But taking task_lock() around
109 * get_vma_plicy() causes lock order problem.
110 *
111 * To access task->mempolicy without lock, we hold a reference count of an
112 * object pointed by task->mempolicy and remember it. This will guarantee
113 * that task->mempolicy points to an alive object or NULL in numa_maps accesses.
114 */
115static void hold_task_mempolicy(struct proc_maps_private *priv)
116{
117 struct task_struct *task = priv->task;
118
119 task_lock(task);
120 priv->task_mempolicy = task->mempolicy;
121 mpol_get(priv->task_mempolicy);
122 task_unlock(task);
123}
124static void release_task_mempolicy(struct proc_maps_private *priv)
125{
126 mpol_put(priv->task_mempolicy);
127}
128#else
129static void hold_task_mempolicy(struct proc_maps_private *priv)
130{
131}
132static void release_task_mempolicy(struct proc_maps_private *priv)
133{
134}
135#endif
136
93static void vma_stop(struct proc_maps_private *priv, struct vm_area_struct *vma) 137static void vma_stop(struct proc_maps_private *priv, struct vm_area_struct *vma)
94{ 138{
95 if (vma && vma != priv->tail_vma) { 139 if (vma && vma != priv->tail_vma) {
96 struct mm_struct *mm = vma->vm_mm; 140 struct mm_struct *mm = vma->vm_mm;
141 release_task_mempolicy(priv);
97 up_read(&mm->mmap_sem); 142 up_read(&mm->mmap_sem);
98 mmput(mm); 143 mmput(mm);
99 } 144 }
@@ -132,7 +177,7 @@ static void *m_start(struct seq_file *m, loff_t *pos)
132 177
133 tail_vma = get_gate_vma(priv->task->mm); 178 tail_vma = get_gate_vma(priv->task->mm);
134 priv->tail_vma = tail_vma; 179 priv->tail_vma = tail_vma;
135 180 hold_task_mempolicy(priv);
136 /* Start with last addr hint */ 181 /* Start with last addr hint */
137 vma = find_vma(mm, last_addr); 182 vma = find_vma(mm, last_addr);
138 if (last_addr && vma) { 183 if (last_addr && vma) {
@@ -159,6 +204,7 @@ out:
159 if (vma) 204 if (vma)
160 return vma; 205 return vma;
161 206
207 release_task_mempolicy(priv);
162 /* End of vmas has been reached */ 208 /* End of vmas has been reached */
163 m->version = (tail_vma != NULL)? 0: -1UL; 209 m->version = (tail_vma != NULL)? 0: -1UL;
164 up_read(&mm->mmap_sem); 210 up_read(&mm->mmap_sem);
@@ -1158,6 +1204,7 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
1158 struct vm_area_struct *vma = v; 1204 struct vm_area_struct *vma = v;
1159 struct numa_maps *md = &numa_priv->md; 1205 struct numa_maps *md = &numa_priv->md;
1160 struct file *file = vma->vm_file; 1206 struct file *file = vma->vm_file;
1207 struct task_struct *task = proc_priv->task;
1161 struct mm_struct *mm = vma->vm_mm; 1208 struct mm_struct *mm = vma->vm_mm;
1162 struct mm_walk walk = {}; 1209 struct mm_walk walk = {};
1163 struct mempolicy *pol; 1210 struct mempolicy *pol;
@@ -1177,7 +1224,7 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
1177 walk.private = md; 1224 walk.private = md;
1178 walk.mm = mm; 1225 walk.mm = mm;
1179 1226
1180 pol = get_vma_policy(proc_priv->task, vma, vma->vm_start); 1227 pol = get_vma_policy(task, vma, vma->vm_start);
1181 mpol_to_str(buffer, sizeof(buffer), pol, 0); 1228 mpol_to_str(buffer, sizeof(buffer), pol, 0);
1182 mpol_cond_put(pol); 1229 mpol_cond_put(pol);
1183 1230
@@ -1189,7 +1236,7 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
1189 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) { 1236 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
1190 seq_printf(m, " heap"); 1237 seq_printf(m, " heap");
1191 } else { 1238 } else {
1192 pid_t tid = vm_is_stack(proc_priv->task, vma, is_pid); 1239 pid_t tid = vm_is_stack(task, vma, is_pid);
1193 if (tid != 0) { 1240 if (tid != 0) {
1194 /* 1241 /*
1195 * Thread stack in /proc/PID/task/TID/maps or 1242 * Thread stack in /proc/PID/task/TID/maps or
diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c
index a40da07e93d..947fbe06c3b 100644
--- a/fs/pstore/platform.c
+++ b/fs/pstore/platform.c
@@ -161,6 +161,7 @@ static void pstore_console_write(struct console *con, const char *s, unsigned c)
161 161
162 while (s < e) { 162 while (s < e) {
163 unsigned long flags; 163 unsigned long flags;
164 u64 id;
164 165
165 if (c > psinfo->bufsize) 166 if (c > psinfo->bufsize)
166 c = psinfo->bufsize; 167 c = psinfo->bufsize;
@@ -172,7 +173,7 @@ static void pstore_console_write(struct console *con, const char *s, unsigned c)
172 spin_lock_irqsave(&psinfo->buf_lock, flags); 173 spin_lock_irqsave(&psinfo->buf_lock, flags);
173 } 174 }
174 memcpy(psinfo->buf, s, c); 175 memcpy(psinfo->buf, s, c);
175 psinfo->write(PSTORE_TYPE_CONSOLE, 0, NULL, 0, c, psinfo); 176 psinfo->write(PSTORE_TYPE_CONSOLE, 0, &id, 0, c, psinfo);
176 spin_unlock_irqrestore(&psinfo->buf_lock, flags); 177 spin_unlock_irqrestore(&psinfo->buf_lock, flags);
177 s += c; 178 s += c;
178 c = e - s; 179 c = e - s;
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index 557a9c20a21..05ae3c97f7a 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -1160,6 +1160,8 @@ static int need_print_warning(struct dquot_warn *warn)
1160 return uid_eq(current_fsuid(), warn->w_dq_id.uid); 1160 return uid_eq(current_fsuid(), warn->w_dq_id.uid);
1161 case GRPQUOTA: 1161 case GRPQUOTA:
1162 return in_group_p(warn->w_dq_id.gid); 1162 return in_group_p(warn->w_dq_id.gid);
1163 case PRJQUOTA: /* Never taken... Just make gcc happy */
1164 return 0;
1163 } 1165 }
1164 return 0; 1166 return 0;
1165} 1167}
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
index f27f01a98aa..d83736fbc26 100644
--- a/fs/reiserfs/inode.c
+++ b/fs/reiserfs/inode.c
@@ -1782,8 +1782,9 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
1782 1782
1783 BUG_ON(!th->t_trans_id); 1783 BUG_ON(!th->t_trans_id);
1784 1784
1785 dquot_initialize(inode); 1785 reiserfs_write_unlock(inode->i_sb);
1786 err = dquot_alloc_inode(inode); 1786 err = dquot_alloc_inode(inode);
1787 reiserfs_write_lock(inode->i_sb);
1787 if (err) 1788 if (err)
1788 goto out_end_trans; 1789 goto out_end_trans;
1789 if (!dir->i_nlink) { 1790 if (!dir->i_nlink) {
@@ -1979,8 +1980,10 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th,
1979 1980
1980 out_end_trans: 1981 out_end_trans:
1981 journal_end(th, th->t_super, th->t_blocks_allocated); 1982 journal_end(th, th->t_super, th->t_blocks_allocated);
1983 reiserfs_write_unlock(inode->i_sb);
1982 /* Drop can be outside and it needs more credits so it's better to have it outside */ 1984 /* Drop can be outside and it needs more credits so it's better to have it outside */
1983 dquot_drop(inode); 1985 dquot_drop(inode);
1986 reiserfs_write_lock(inode->i_sb);
1984 inode->i_flags |= S_NOQUOTA; 1987 inode->i_flags |= S_NOQUOTA;
1985 make_bad_inode(inode); 1988 make_bad_inode(inode);
1986 1989
@@ -3103,10 +3106,9 @@ int reiserfs_setattr(struct dentry *dentry, struct iattr *attr)
3103 /* must be turned off for recursive notify_change calls */ 3106 /* must be turned off for recursive notify_change calls */
3104 ia_valid = attr->ia_valid &= ~(ATTR_KILL_SUID|ATTR_KILL_SGID); 3107 ia_valid = attr->ia_valid &= ~(ATTR_KILL_SUID|ATTR_KILL_SGID);
3105 3108
3106 depth = reiserfs_write_lock_once(inode->i_sb);
3107 if (is_quota_modification(inode, attr)) 3109 if (is_quota_modification(inode, attr))
3108 dquot_initialize(inode); 3110 dquot_initialize(inode);
3109 3111 depth = reiserfs_write_lock_once(inode->i_sb);
3110 if (attr->ia_valid & ATTR_SIZE) { 3112 if (attr->ia_valid & ATTR_SIZE) {
3111 /* version 2 items will be caught by the s_maxbytes check 3113 /* version 2 items will be caught by the s_maxbytes check
3112 ** done for us in vmtruncate 3114 ** done for us in vmtruncate
@@ -3170,7 +3172,9 @@ int reiserfs_setattr(struct dentry *dentry, struct iattr *attr)
3170 error = journal_begin(&th, inode->i_sb, jbegin_count); 3172 error = journal_begin(&th, inode->i_sb, jbegin_count);
3171 if (error) 3173 if (error)
3172 goto out; 3174 goto out;
3175 reiserfs_write_unlock_once(inode->i_sb, depth);
3173 error = dquot_transfer(inode, attr); 3176 error = dquot_transfer(inode, attr);
3177 depth = reiserfs_write_lock_once(inode->i_sb);
3174 if (error) { 3178 if (error) {
3175 journal_end(&th, inode->i_sb, jbegin_count); 3179 journal_end(&th, inode->i_sb, jbegin_count);
3176 goto out; 3180 goto out;
diff --git a/fs/reiserfs/stree.c b/fs/reiserfs/stree.c
index f8afa4b162b..2f40a4c70a4 100644
--- a/fs/reiserfs/stree.c
+++ b/fs/reiserfs/stree.c
@@ -1968,7 +1968,9 @@ int reiserfs_paste_into_item(struct reiserfs_transaction_handle *th, struct tree
1968 key2type(&(key->on_disk_key))); 1968 key2type(&(key->on_disk_key)));
1969#endif 1969#endif
1970 1970
1971 reiserfs_write_unlock(inode->i_sb);
1971 retval = dquot_alloc_space_nodirty(inode, pasted_size); 1972 retval = dquot_alloc_space_nodirty(inode, pasted_size);
1973 reiserfs_write_lock(inode->i_sb);
1972 if (retval) { 1974 if (retval) {
1973 pathrelse(search_path); 1975 pathrelse(search_path);
1974 return retval; 1976 return retval;
@@ -2061,9 +2063,11 @@ int reiserfs_insert_item(struct reiserfs_transaction_handle *th,
2061 "reiserquota insert_item(): allocating %u id=%u type=%c", 2063 "reiserquota insert_item(): allocating %u id=%u type=%c",
2062 quota_bytes, inode->i_uid, head2type(ih)); 2064 quota_bytes, inode->i_uid, head2type(ih));
2063#endif 2065#endif
2066 reiserfs_write_unlock(inode->i_sb);
2064 /* We can't dirty inode here. It would be immediately written but 2067 /* We can't dirty inode here. It would be immediately written but
2065 * appropriate stat item isn't inserted yet... */ 2068 * appropriate stat item isn't inserted yet... */
2066 retval = dquot_alloc_space_nodirty(inode, quota_bytes); 2069 retval = dquot_alloc_space_nodirty(inode, quota_bytes);
2070 reiserfs_write_lock(inode->i_sb);
2067 if (retval) { 2071 if (retval) {
2068 pathrelse(path); 2072 pathrelse(path);
2069 return retval; 2073 return retval;
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
index 1078ae17999..418bdc3a57d 100644
--- a/fs/reiserfs/super.c
+++ b/fs/reiserfs/super.c
@@ -298,7 +298,9 @@ static int finish_unfinished(struct super_block *s)
298 retval = remove_save_link_only(s, &save_link_key, 0); 298 retval = remove_save_link_only(s, &save_link_key, 0);
299 continue; 299 continue;
300 } 300 }
301 reiserfs_write_unlock(s);
301 dquot_initialize(inode); 302 dquot_initialize(inode);
303 reiserfs_write_lock(s);
302 304
303 if (truncate && S_ISDIR(inode->i_mode)) { 305 if (truncate && S_ISDIR(inode->i_mode)) {
304 /* We got a truncate request for a dir which is impossible. 306 /* We got a truncate request for a dir which is impossible.
@@ -1335,7 +1337,7 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)
1335 kfree(qf_names[i]); 1337 kfree(qf_names[i]);
1336#endif 1338#endif
1337 err = -EINVAL; 1339 err = -EINVAL;
1338 goto out_err; 1340 goto out_unlock;
1339 } 1341 }
1340#ifdef CONFIG_QUOTA 1342#ifdef CONFIG_QUOTA
1341 handle_quota_files(s, qf_names, &qfmt); 1343 handle_quota_files(s, qf_names, &qfmt);
@@ -1379,7 +1381,7 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)
1379 if (blocks) { 1381 if (blocks) {
1380 err = reiserfs_resize(s, blocks); 1382 err = reiserfs_resize(s, blocks);
1381 if (err != 0) 1383 if (err != 0)
1382 goto out_err; 1384 goto out_unlock;
1383 } 1385 }
1384 1386
1385 if (*mount_flags & MS_RDONLY) { 1387 if (*mount_flags & MS_RDONLY) {
@@ -1389,9 +1391,15 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)
1389 /* it is read-only already */ 1391 /* it is read-only already */
1390 goto out_ok; 1392 goto out_ok;
1391 1393
1394 /*
1395 * Drop write lock. Quota will retake it when needed and lock
1396 * ordering requires calling dquot_suspend() without it.
1397 */
1398 reiserfs_write_unlock(s);
1392 err = dquot_suspend(s, -1); 1399 err = dquot_suspend(s, -1);
1393 if (err < 0) 1400 if (err < 0)
1394 goto out_err; 1401 goto out_err;
1402 reiserfs_write_lock(s);
1395 1403
1396 /* try to remount file system with read-only permissions */ 1404 /* try to remount file system with read-only permissions */
1397 if (sb_umount_state(rs) == REISERFS_VALID_FS 1405 if (sb_umount_state(rs) == REISERFS_VALID_FS
@@ -1401,7 +1409,7 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)
1401 1409
1402 err = journal_begin(&th, s, 10); 1410 err = journal_begin(&th, s, 10);
1403 if (err) 1411 if (err)
1404 goto out_err; 1412 goto out_unlock;
1405 1413
1406 /* Mounting a rw partition read-only. */ 1414 /* Mounting a rw partition read-only. */
1407 reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1); 1415 reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1);
@@ -1416,7 +1424,7 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)
1416 1424
1417 if (reiserfs_is_journal_aborted(journal)) { 1425 if (reiserfs_is_journal_aborted(journal)) {
1418 err = journal->j_errno; 1426 err = journal->j_errno;
1419 goto out_err; 1427 goto out_unlock;
1420 } 1428 }
1421 1429
1422 handle_data_mode(s, mount_options); 1430 handle_data_mode(s, mount_options);
@@ -1425,7 +1433,7 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)
1425 s->s_flags &= ~MS_RDONLY; /* now it is safe to call journal_begin */ 1433 s->s_flags &= ~MS_RDONLY; /* now it is safe to call journal_begin */
1426 err = journal_begin(&th, s, 10); 1434 err = journal_begin(&th, s, 10);
1427 if (err) 1435 if (err)
1428 goto out_err; 1436 goto out_unlock;
1429 1437
1430 /* Mount a partition which is read-only, read-write */ 1438 /* Mount a partition which is read-only, read-write */
1431 reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1); 1439 reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1);
@@ -1442,10 +1450,16 @@ static int reiserfs_remount(struct super_block *s, int *mount_flags, char *arg)
1442 SB_JOURNAL(s)->j_must_wait = 1; 1450 SB_JOURNAL(s)->j_must_wait = 1;
1443 err = journal_end(&th, s, 10); 1451 err = journal_end(&th, s, 10);
1444 if (err) 1452 if (err)
1445 goto out_err; 1453 goto out_unlock;
1446 1454
1447 if (!(*mount_flags & MS_RDONLY)) { 1455 if (!(*mount_flags & MS_RDONLY)) {
1456 /*
1457 * Drop write lock. Quota will retake it when needed and lock
1458 * ordering requires calling dquot_resume() without it.
1459 */
1460 reiserfs_write_unlock(s);
1448 dquot_resume(s, -1); 1461 dquot_resume(s, -1);
1462 reiserfs_write_lock(s);
1449 finish_unfinished(s); 1463 finish_unfinished(s);
1450 reiserfs_xattr_init(s, *mount_flags); 1464 reiserfs_xattr_init(s, *mount_flags);
1451 } 1465 }
@@ -1455,9 +1469,10 @@ out_ok:
1455 reiserfs_write_unlock(s); 1469 reiserfs_write_unlock(s);
1456 return 0; 1470 return 0;
1457 1471
1472out_unlock:
1473 reiserfs_write_unlock(s);
1458out_err: 1474out_err:
1459 kfree(new_opts); 1475 kfree(new_opts);
1460 reiserfs_write_unlock(s);
1461 return err; 1476 return err;
1462} 1477}
1463 1478
@@ -2095,13 +2110,15 @@ static int reiserfs_write_dquot(struct dquot *dquot)
2095 REISERFS_QUOTA_TRANS_BLOCKS(dquot->dq_sb)); 2110 REISERFS_QUOTA_TRANS_BLOCKS(dquot->dq_sb));
2096 if (ret) 2111 if (ret)
2097 goto out; 2112 goto out;
2113 reiserfs_write_unlock(dquot->dq_sb);
2098 ret = dquot_commit(dquot); 2114 ret = dquot_commit(dquot);
2115 reiserfs_write_lock(dquot->dq_sb);
2099 err = 2116 err =
2100 journal_end(&th, dquot->dq_sb, 2117 journal_end(&th, dquot->dq_sb,
2101 REISERFS_QUOTA_TRANS_BLOCKS(dquot->dq_sb)); 2118 REISERFS_QUOTA_TRANS_BLOCKS(dquot->dq_sb));
2102 if (!ret && err) 2119 if (!ret && err)
2103 ret = err; 2120 ret = err;
2104 out: 2121out:
2105 reiserfs_write_unlock(dquot->dq_sb); 2122 reiserfs_write_unlock(dquot->dq_sb);
2106 return ret; 2123 return ret;
2107} 2124}
@@ -2117,13 +2134,15 @@ static int reiserfs_acquire_dquot(struct dquot *dquot)
2117 REISERFS_QUOTA_INIT_BLOCKS(dquot->dq_sb)); 2134 REISERFS_QUOTA_INIT_BLOCKS(dquot->dq_sb));
2118 if (ret) 2135 if (ret)
2119 goto out; 2136 goto out;
2137 reiserfs_write_unlock(dquot->dq_sb);
2120 ret = dquot_acquire(dquot); 2138 ret = dquot_acquire(dquot);
2139 reiserfs_write_lock(dquot->dq_sb);
2121 err = 2140 err =
2122 journal_end(&th, dquot->dq_sb, 2141 journal_end(&th, dquot->dq_sb,
2123 REISERFS_QUOTA_INIT_BLOCKS(dquot->dq_sb)); 2142 REISERFS_QUOTA_INIT_BLOCKS(dquot->dq_sb));
2124 if (!ret && err) 2143 if (!ret && err)
2125 ret = err; 2144 ret = err;
2126 out: 2145out:
2127 reiserfs_write_unlock(dquot->dq_sb); 2146 reiserfs_write_unlock(dquot->dq_sb);
2128 return ret; 2147 return ret;
2129} 2148}
@@ -2137,19 +2156,21 @@ static int reiserfs_release_dquot(struct dquot *dquot)
2137 ret = 2156 ret =
2138 journal_begin(&th, dquot->dq_sb, 2157 journal_begin(&th, dquot->dq_sb,
2139 REISERFS_QUOTA_DEL_BLOCKS(dquot->dq_sb)); 2158 REISERFS_QUOTA_DEL_BLOCKS(dquot->dq_sb));
2159 reiserfs_write_unlock(dquot->dq_sb);
2140 if (ret) { 2160 if (ret) {
2141 /* Release dquot anyway to avoid endless cycle in dqput() */ 2161 /* Release dquot anyway to avoid endless cycle in dqput() */
2142 dquot_release(dquot); 2162 dquot_release(dquot);
2143 goto out; 2163 goto out;
2144 } 2164 }
2145 ret = dquot_release(dquot); 2165 ret = dquot_release(dquot);
2166 reiserfs_write_lock(dquot->dq_sb);
2146 err = 2167 err =
2147 journal_end(&th, dquot->dq_sb, 2168 journal_end(&th, dquot->dq_sb,
2148 REISERFS_QUOTA_DEL_BLOCKS(dquot->dq_sb)); 2169 REISERFS_QUOTA_DEL_BLOCKS(dquot->dq_sb));
2149 if (!ret && err) 2170 if (!ret && err)
2150 ret = err; 2171 ret = err;
2151 out:
2152 reiserfs_write_unlock(dquot->dq_sb); 2172 reiserfs_write_unlock(dquot->dq_sb);
2173out:
2153 return ret; 2174 return ret;
2154} 2175}
2155 2176
@@ -2174,11 +2195,13 @@ static int reiserfs_write_info(struct super_block *sb, int type)
2174 ret = journal_begin(&th, sb, 2); 2195 ret = journal_begin(&th, sb, 2);
2175 if (ret) 2196 if (ret)
2176 goto out; 2197 goto out;
2198 reiserfs_write_unlock(sb);
2177 ret = dquot_commit_info(sb, type); 2199 ret = dquot_commit_info(sb, type);
2200 reiserfs_write_lock(sb);
2178 err = journal_end(&th, sb, 2); 2201 err = journal_end(&th, sb, 2);
2179 if (!ret && err) 2202 if (!ret && err)
2180 ret = err; 2203 ret = err;
2181 out: 2204out:
2182 reiserfs_write_unlock(sb); 2205 reiserfs_write_unlock(sb);
2183 return ret; 2206 return ret;
2184} 2207}
@@ -2203,8 +2226,11 @@ static int reiserfs_quota_on(struct super_block *sb, int type, int format_id,
2203 struct reiserfs_transaction_handle th; 2226 struct reiserfs_transaction_handle th;
2204 int opt = type == USRQUOTA ? REISERFS_USRQUOTA : REISERFS_GRPQUOTA; 2227 int opt = type == USRQUOTA ? REISERFS_USRQUOTA : REISERFS_GRPQUOTA;
2205 2228
2206 if (!(REISERFS_SB(sb)->s_mount_opt & (1 << opt))) 2229 reiserfs_write_lock(sb);
2207 return -EINVAL; 2230 if (!(REISERFS_SB(sb)->s_mount_opt & (1 << opt))) {
2231 err = -EINVAL;
2232 goto out;
2233 }
2208 2234
2209 /* Quotafile not on the same filesystem? */ 2235 /* Quotafile not on the same filesystem? */
2210 if (path->dentry->d_sb != sb) { 2236 if (path->dentry->d_sb != sb) {
@@ -2246,8 +2272,10 @@ static int reiserfs_quota_on(struct super_block *sb, int type, int format_id,
2246 if (err) 2272 if (err)
2247 goto out; 2273 goto out;
2248 } 2274 }
2249 err = dquot_quota_on(sb, type, format_id, path); 2275 reiserfs_write_unlock(sb);
2276 return dquot_quota_on(sb, type, format_id, path);
2250out: 2277out:
2278 reiserfs_write_unlock(sb);
2251 return err; 2279 return err;
2252} 2280}
2253 2281
@@ -2320,7 +2348,9 @@ static ssize_t reiserfs_quota_write(struct super_block *sb, int type,
2320 tocopy = sb->s_blocksize - offset < towrite ? 2348 tocopy = sb->s_blocksize - offset < towrite ?
2321 sb->s_blocksize - offset : towrite; 2349 sb->s_blocksize - offset : towrite;
2322 tmp_bh.b_state = 0; 2350 tmp_bh.b_state = 0;
2351 reiserfs_write_lock(sb);
2323 err = reiserfs_get_block(inode, blk, &tmp_bh, GET_BLOCK_CREATE); 2352 err = reiserfs_get_block(inode, blk, &tmp_bh, GET_BLOCK_CREATE);
2353 reiserfs_write_unlock(sb);
2324 if (err) 2354 if (err)
2325 goto out; 2355 goto out;
2326 if (offset || tocopy != sb->s_blocksize) 2356 if (offset || tocopy != sb->s_blocksize)
@@ -2336,10 +2366,12 @@ static ssize_t reiserfs_quota_write(struct super_block *sb, int type,
2336 flush_dcache_page(bh->b_page); 2366 flush_dcache_page(bh->b_page);
2337 set_buffer_uptodate(bh); 2367 set_buffer_uptodate(bh);
2338 unlock_buffer(bh); 2368 unlock_buffer(bh);
2369 reiserfs_write_lock(sb);
2339 reiserfs_prepare_for_journal(sb, bh, 1); 2370 reiserfs_prepare_for_journal(sb, bh, 1);
2340 journal_mark_dirty(current->journal_info, sb, bh); 2371 journal_mark_dirty(current->journal_info, sb, bh);
2341 if (!journal_quota) 2372 if (!journal_quota)
2342 reiserfs_add_ordered_list(inode, bh); 2373 reiserfs_add_ordered_list(inode, bh);
2374 reiserfs_write_unlock(sb);
2343 brelse(bh); 2375 brelse(bh);
2344 offset = 0; 2376 offset = 0;
2345 towrite -= tocopy; 2377 towrite -= tocopy;
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index 6b0bb00d4d2..2fbdff6be25 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -485,20 +485,18 @@ int __sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd)
485/** 485/**
486 * sysfs_pathname - return full path to sysfs dirent 486 * sysfs_pathname - return full path to sysfs dirent
487 * @sd: sysfs_dirent whose path we want 487 * @sd: sysfs_dirent whose path we want
488 * @path: caller allocated buffer 488 * @path: caller allocated buffer of size PATH_MAX
489 * 489 *
490 * Gives the name "/" to the sysfs_root entry; any path returned 490 * Gives the name "/" to the sysfs_root entry; any path returned
491 * is relative to wherever sysfs is mounted. 491 * is relative to wherever sysfs is mounted.
492 *
493 * XXX: does no error checking on @path size
494 */ 492 */
495static char *sysfs_pathname(struct sysfs_dirent *sd, char *path) 493static char *sysfs_pathname(struct sysfs_dirent *sd, char *path)
496{ 494{
497 if (sd->s_parent) { 495 if (sd->s_parent) {
498 sysfs_pathname(sd->s_parent, path); 496 sysfs_pathname(sd->s_parent, path);
499 strcat(path, "/"); 497 strlcat(path, "/", PATH_MAX);
500 } 498 }
501 strcat(path, sd->s_name); 499 strlcat(path, sd->s_name, PATH_MAX);
502 return path; 500 return path;
503} 501}
504 502
@@ -531,9 +529,11 @@ int sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd)
531 char *path = kzalloc(PATH_MAX, GFP_KERNEL); 529 char *path = kzalloc(PATH_MAX, GFP_KERNEL);
532 WARN(1, KERN_WARNING 530 WARN(1, KERN_WARNING
533 "sysfs: cannot create duplicate filename '%s'\n", 531 "sysfs: cannot create duplicate filename '%s'\n",
534 (path == NULL) ? sd->s_name : 532 (path == NULL) ? sd->s_name
535 strcat(strcat(sysfs_pathname(acxt->parent_sd, path), "/"), 533 : (sysfs_pathname(acxt->parent_sd, path),
536 sd->s_name)); 534 strlcat(path, "/", PATH_MAX),
535 strlcat(path, sd->s_name, PATH_MAX),
536 path));
537 kfree(path); 537 kfree(path);
538 } 538 }
539 539
diff --git a/fs/ubifs/find.c b/fs/ubifs/find.c
index 28ec13af28d..2dcf3d473fe 100644
--- a/fs/ubifs/find.c
+++ b/fs/ubifs/find.c
@@ -681,8 +681,16 @@ int ubifs_find_free_leb_for_idx(struct ubifs_info *c)
681 if (!lprops) { 681 if (!lprops) {
682 lprops = ubifs_fast_find_freeable(c); 682 lprops = ubifs_fast_find_freeable(c);
683 if (!lprops) { 683 if (!lprops) {
684 ubifs_assert(c->freeable_cnt == 0); 684 /*
685 if (c->lst.empty_lebs - c->lst.taken_empty_lebs > 0) { 685 * The first condition means the following: go scan the
686 * LPT if there are uncategorized lprops, which means
687 * there may be freeable LEBs there (UBIFS does not
688 * store the information about freeable LEBs in the
689 * master node).
690 */
691 if (c->in_a_category_cnt != c->main_lebs ||
692 c->lst.empty_lebs - c->lst.taken_empty_lebs > 0) {
693 ubifs_assert(c->freeable_cnt == 0);
686 lprops = scan_for_leb_for_idx(c); 694 lprops = scan_for_leb_for_idx(c);
687 if (IS_ERR(lprops)) { 695 if (IS_ERR(lprops)) {
688 err = PTR_ERR(lprops); 696 err = PTR_ERR(lprops);
diff --git a/fs/ubifs/lprops.c b/fs/ubifs/lprops.c
index e5a2a35a46d..46190a7c42a 100644
--- a/fs/ubifs/lprops.c
+++ b/fs/ubifs/lprops.c
@@ -300,8 +300,11 @@ void ubifs_add_to_cat(struct ubifs_info *c, struct ubifs_lprops *lprops,
300 default: 300 default:
301 ubifs_assert(0); 301 ubifs_assert(0);
302 } 302 }
303
303 lprops->flags &= ~LPROPS_CAT_MASK; 304 lprops->flags &= ~LPROPS_CAT_MASK;
304 lprops->flags |= cat; 305 lprops->flags |= cat;
306 c->in_a_category_cnt += 1;
307 ubifs_assert(c->in_a_category_cnt <= c->main_lebs);
305} 308}
306 309
307/** 310/**
@@ -334,6 +337,9 @@ static void ubifs_remove_from_cat(struct ubifs_info *c,
334 default: 337 default:
335 ubifs_assert(0); 338 ubifs_assert(0);
336 } 339 }
340
341 c->in_a_category_cnt -= 1;
342 ubifs_assert(c->in_a_category_cnt >= 0);
337} 343}
338 344
339/** 345/**
diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h
index 5486346d0a3..d133c276fe0 100644
--- a/fs/ubifs/ubifs.h
+++ b/fs/ubifs/ubifs.h
@@ -1183,6 +1183,8 @@ struct ubifs_debug_info;
1183 * @freeable_list: list of freeable non-index LEBs (free + dirty == @leb_size) 1183 * @freeable_list: list of freeable non-index LEBs (free + dirty == @leb_size)
1184 * @frdi_idx_list: list of freeable index LEBs (free + dirty == @leb_size) 1184 * @frdi_idx_list: list of freeable index LEBs (free + dirty == @leb_size)
1185 * @freeable_cnt: number of freeable LEBs in @freeable_list 1185 * @freeable_cnt: number of freeable LEBs in @freeable_list
1186 * @in_a_category_cnt: count of lprops which are in a certain category, which
1187 * basically meants that they were loaded from the flash
1186 * 1188 *
1187 * @ltab_lnum: LEB number of LPT's own lprops table 1189 * @ltab_lnum: LEB number of LPT's own lprops table
1188 * @ltab_offs: offset of LPT's own lprops table 1190 * @ltab_offs: offset of LPT's own lprops table
@@ -1412,6 +1414,7 @@ struct ubifs_info {
1412 struct list_head freeable_list; 1414 struct list_head freeable_list;
1413 struct list_head frdi_idx_list; 1415 struct list_head frdi_idx_list;
1414 int freeable_cnt; 1416 int freeable_cnt;
1417 int in_a_category_cnt;
1415 1418
1416 int ltab_lnum; 1419 int ltab_lnum;
1417 int ltab_offs; 1420 int ltab_offs;
diff --git a/fs/xattr.c b/fs/xattr.c
index e164dddb8e9..e21c119f4f9 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -846,7 +846,7 @@ static int __simple_xattr_set(struct simple_xattrs *xattrs, const char *name,
846 const void *value, size_t size, int flags) 846 const void *value, size_t size, int flags)
847{ 847{
848 struct simple_xattr *xattr; 848 struct simple_xattr *xattr;
849 struct simple_xattr *uninitialized_var(new_xattr); 849 struct simple_xattr *new_xattr = NULL;
850 int err = 0; 850 int err = 0;
851 851
852 /* value == NULL means remove */ 852 /* value == NULL means remove */
diff --git a/fs/xfs/xfs_alloc.c b/fs/xfs/xfs_alloc.c
index 4f33c32affe..335206a9c69 100644
--- a/fs/xfs/xfs_alloc.c
+++ b/fs/xfs/xfs_alloc.c
@@ -1866,6 +1866,7 @@ xfs_alloc_fix_freelist(
1866 /* 1866 /*
1867 * Initialize the args structure. 1867 * Initialize the args structure.
1868 */ 1868 */
1869 memset(&targs, 0, sizeof(targs));
1869 targs.tp = tp; 1870 targs.tp = tp;
1870 targs.mp = mp; 1871 targs.mp = mp;
1871 targs.agbp = agbp; 1872 targs.agbp = agbp;
@@ -2207,7 +2208,7 @@ xfs_alloc_read_agf(
2207 * group or loop over the allocation groups to find the result. 2208 * group or loop over the allocation groups to find the result.
2208 */ 2209 */
2209int /* error */ 2210int /* error */
2210__xfs_alloc_vextent( 2211xfs_alloc_vextent(
2211 xfs_alloc_arg_t *args) /* allocation argument structure */ 2212 xfs_alloc_arg_t *args) /* allocation argument structure */
2212{ 2213{
2213 xfs_agblock_t agsize; /* allocation group size */ 2214 xfs_agblock_t agsize; /* allocation group size */
@@ -2417,46 +2418,6 @@ error0:
2417 return error; 2418 return error;
2418} 2419}
2419 2420
2420static void
2421xfs_alloc_vextent_worker(
2422 struct work_struct *work)
2423{
2424 struct xfs_alloc_arg *args = container_of(work,
2425 struct xfs_alloc_arg, work);
2426 unsigned long pflags;
2427
2428 /* we are in a transaction context here */
2429 current_set_flags_nested(&pflags, PF_FSTRANS);
2430
2431 args->result = __xfs_alloc_vextent(args);
2432 complete(args->done);
2433
2434 current_restore_flags_nested(&pflags, PF_FSTRANS);
2435}
2436
2437/*
2438 * Data allocation requests often come in with little stack to work on. Push
2439 * them off to a worker thread so there is lots of stack to use. Metadata
2440 * requests, OTOH, are generally from low stack usage paths, so avoid the
2441 * context switch overhead here.
2442 */
2443int
2444xfs_alloc_vextent(
2445 struct xfs_alloc_arg *args)
2446{
2447 DECLARE_COMPLETION_ONSTACK(done);
2448
2449 if (!args->userdata)
2450 return __xfs_alloc_vextent(args);
2451
2452
2453 args->done = &done;
2454 INIT_WORK_ONSTACK(&args->work, xfs_alloc_vextent_worker);
2455 queue_work(xfs_alloc_wq, &args->work);
2456 wait_for_completion(&done);
2457 return args->result;
2458}
2459
2460/* 2421/*
2461 * Free an extent. 2422 * Free an extent.
2462 * Just break up the extent address and hand off to xfs_free_ag_extent 2423 * Just break up the extent address and hand off to xfs_free_ag_extent
diff --git a/fs/xfs/xfs_alloc.h b/fs/xfs/xfs_alloc.h
index 93be4a667ca..feacb061bab 100644
--- a/fs/xfs/xfs_alloc.h
+++ b/fs/xfs/xfs_alloc.h
@@ -120,9 +120,6 @@ typedef struct xfs_alloc_arg {
120 char isfl; /* set if is freelist blocks - !acctg */ 120 char isfl; /* set if is freelist blocks - !acctg */
121 char userdata; /* set if this is user data */ 121 char userdata; /* set if this is user data */
122 xfs_fsblock_t firstblock; /* io first block allocated */ 122 xfs_fsblock_t firstblock; /* io first block allocated */
123 struct completion *done;
124 struct work_struct work;
125 int result;
126} xfs_alloc_arg_t; 123} xfs_alloc_arg_t;
127 124
128/* 125/*
diff --git a/fs/xfs/xfs_alloc_btree.c b/fs/xfs/xfs_alloc_btree.c
index f1647caace8..f7876c6d616 100644
--- a/fs/xfs/xfs_alloc_btree.c
+++ b/fs/xfs/xfs_alloc_btree.c
@@ -121,6 +121,8 @@ xfs_allocbt_free_block(
121 xfs_extent_busy_insert(cur->bc_tp, be32_to_cpu(agf->agf_seqno), bno, 1, 121 xfs_extent_busy_insert(cur->bc_tp, be32_to_cpu(agf->agf_seqno), bno, 1,
122 XFS_EXTENT_BUSY_SKIP_DISCARD); 122 XFS_EXTENT_BUSY_SKIP_DISCARD);
123 xfs_trans_agbtree_delta(cur->bc_tp, -1); 123 xfs_trans_agbtree_delta(cur->bc_tp, -1);
124
125 xfs_trans_binval(cur->bc_tp, bp);
124 return 0; 126 return 0;
125} 127}
126 128
diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index e562dd43f41..e57e2daa357 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -481,11 +481,17 @@ static inline int bio_add_buffer(struct bio *bio, struct buffer_head *bh)
481 * 481 *
482 * The fix is two passes across the ioend list - one to start writeback on the 482 * The fix is two passes across the ioend list - one to start writeback on the
483 * buffer_heads, and then submit them for I/O on the second pass. 483 * buffer_heads, and then submit them for I/O on the second pass.
484 *
485 * If @fail is non-zero, it means that we have a situation where some part of
486 * the submission process has failed after we have marked paged for writeback
487 * and unlocked them. In this situation, we need to fail the ioend chain rather
488 * than submit it to IO. This typically only happens on a filesystem shutdown.
484 */ 489 */
485STATIC void 490STATIC void
486xfs_submit_ioend( 491xfs_submit_ioend(
487 struct writeback_control *wbc, 492 struct writeback_control *wbc,
488 xfs_ioend_t *ioend) 493 xfs_ioend_t *ioend,
494 int fail)
489{ 495{
490 xfs_ioend_t *head = ioend; 496 xfs_ioend_t *head = ioend;
491 xfs_ioend_t *next; 497 xfs_ioend_t *next;
@@ -506,6 +512,18 @@ xfs_submit_ioend(
506 next = ioend->io_list; 512 next = ioend->io_list;
507 bio = NULL; 513 bio = NULL;
508 514
515 /*
516 * If we are failing the IO now, just mark the ioend with an
517 * error and finish it. This will run IO completion immediately
518 * as there is only one reference to the ioend at this point in
519 * time.
520 */
521 if (fail) {
522 ioend->io_error = -fail;
523 xfs_finish_ioend(ioend);
524 continue;
525 }
526
509 for (bh = ioend->io_buffer_head; bh; bh = bh->b_private) { 527 for (bh = ioend->io_buffer_head; bh; bh = bh->b_private) {
510 528
511 if (!bio) { 529 if (!bio) {
@@ -1060,7 +1078,18 @@ xfs_vm_writepage(
1060 1078
1061 xfs_start_page_writeback(page, 1, count); 1079 xfs_start_page_writeback(page, 1, count);
1062 1080
1063 if (ioend && imap_valid) { 1081 /* if there is no IO to be submitted for this page, we are done */
1082 if (!ioend)
1083 return 0;
1084
1085 ASSERT(iohead);
1086
1087 /*
1088 * Any errors from this point onwards need tobe reported through the IO
1089 * completion path as we have marked the initial page as under writeback
1090 * and unlocked it.
1091 */
1092 if (imap_valid) {
1064 xfs_off_t end_index; 1093 xfs_off_t end_index;
1065 1094
1066 end_index = imap.br_startoff + imap.br_blockcount; 1095 end_index = imap.br_startoff + imap.br_blockcount;
@@ -1079,20 +1108,15 @@ xfs_vm_writepage(
1079 wbc, end_index); 1108 wbc, end_index);
1080 } 1109 }
1081 1110
1082 if (iohead) {
1083 /*
1084 * Reserve log space if we might write beyond the on-disk
1085 * inode size.
1086 */
1087 if (ioend->io_type != XFS_IO_UNWRITTEN &&
1088 xfs_ioend_is_append(ioend)) {
1089 err = xfs_setfilesize_trans_alloc(ioend);
1090 if (err)
1091 goto error;
1092 }
1093 1111
1094 xfs_submit_ioend(wbc, iohead); 1112 /*
1095 } 1113 * Reserve log space if we might write beyond the on-disk inode size.
1114 */
1115 err = 0;
1116 if (ioend->io_type != XFS_IO_UNWRITTEN && xfs_ioend_is_append(ioend))
1117 err = xfs_setfilesize_trans_alloc(ioend);
1118
1119 xfs_submit_ioend(wbc, iohead, err);
1096 1120
1097 return 0; 1121 return 0;
1098 1122
diff --git a/fs/xfs/xfs_attr_leaf.c b/fs/xfs/xfs_attr_leaf.c
index d330111ca73..70eec182977 100644
--- a/fs/xfs/xfs_attr_leaf.c
+++ b/fs/xfs/xfs_attr_leaf.c
@@ -1291,6 +1291,7 @@ xfs_attr_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
1291 leaf2 = blk2->bp->b_addr; 1291 leaf2 = blk2->bp->b_addr;
1292 ASSERT(leaf1->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 1292 ASSERT(leaf1->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
1293 ASSERT(leaf2->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); 1293 ASSERT(leaf2->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
1294 ASSERT(leaf2->hdr.count == 0);
1294 args = state->args; 1295 args = state->args;
1295 1296
1296 trace_xfs_attr_leaf_rebalance(args); 1297 trace_xfs_attr_leaf_rebalance(args);
@@ -1361,6 +1362,7 @@ xfs_attr_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
1361 * I assert that since all callers pass in an empty 1362 * I assert that since all callers pass in an empty
1362 * second buffer, this code should never execute. 1363 * second buffer, this code should never execute.
1363 */ 1364 */
1365 ASSERT(0);
1364 1366
1365 /* 1367 /*
1366 * Figure the total bytes to be added to the destination leaf. 1368 * Figure the total bytes to be added to the destination leaf.
@@ -1422,10 +1424,24 @@ xfs_attr_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
1422 args->index2 = 0; 1424 args->index2 = 0;
1423 args->blkno2 = blk2->blkno; 1425 args->blkno2 = blk2->blkno;
1424 } else { 1426 } else {
1427 /*
1428 * On a double leaf split, the original attr location
1429 * is already stored in blkno2/index2, so don't
1430 * overwrite it overwise we corrupt the tree.
1431 */
1425 blk2->index = blk1->index 1432 blk2->index = blk1->index
1426 - be16_to_cpu(leaf1->hdr.count); 1433 - be16_to_cpu(leaf1->hdr.count);
1427 args->index = args->index2 = blk2->index; 1434 args->index = blk2->index;
1428 args->blkno = args->blkno2 = blk2->blkno; 1435 args->blkno = blk2->blkno;
1436 if (!state->extravalid) {
1437 /*
1438 * set the new attr location to match the old
1439 * one and let the higher level split code
1440 * decide where in the leaf to place it.
1441 */
1442 args->index2 = blk2->index;
1443 args->blkno2 = blk2->blkno;
1444 }
1429 } 1445 }
1430 } else { 1446 } else {
1431 ASSERT(state->inleaf == 1); 1447 ASSERT(state->inleaf == 1);
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
index 848ffa77707..83d0cf3df93 100644
--- a/fs/xfs/xfs_bmap.c
+++ b/fs/xfs/xfs_bmap.c
@@ -2437,6 +2437,7 @@ xfs_bmap_btalloc(
2437 * Normal allocation, done through xfs_alloc_vextent. 2437 * Normal allocation, done through xfs_alloc_vextent.
2438 */ 2438 */
2439 tryagain = isaligned = 0; 2439 tryagain = isaligned = 0;
2440 memset(&args, 0, sizeof(args));
2440 args.tp = ap->tp; 2441 args.tp = ap->tp;
2441 args.mp = mp; 2442 args.mp = mp;
2442 args.fsbno = ap->blkno; 2443 args.fsbno = ap->blkno;
@@ -3082,6 +3083,7 @@ xfs_bmap_extents_to_btree(
3082 * Convert to a btree with two levels, one record in root. 3083 * Convert to a btree with two levels, one record in root.
3083 */ 3084 */
3084 XFS_IFORK_FMT_SET(ip, whichfork, XFS_DINODE_FMT_BTREE); 3085 XFS_IFORK_FMT_SET(ip, whichfork, XFS_DINODE_FMT_BTREE);
3086 memset(&args, 0, sizeof(args));
3085 args.tp = tp; 3087 args.tp = tp;
3086 args.mp = mp; 3088 args.mp = mp;
3087 args.firstblock = *firstblock; 3089 args.firstblock = *firstblock;
@@ -3237,6 +3239,7 @@ xfs_bmap_local_to_extents(
3237 xfs_buf_t *bp; /* buffer for extent block */ 3239 xfs_buf_t *bp; /* buffer for extent block */
3238 xfs_bmbt_rec_host_t *ep;/* extent record pointer */ 3240 xfs_bmbt_rec_host_t *ep;/* extent record pointer */
3239 3241
3242 memset(&args, 0, sizeof(args));
3240 args.tp = tp; 3243 args.tp = tp;
3241 args.mp = ip->i_mount; 3244 args.mp = ip->i_mount;
3242 args.firstblock = *firstblock; 3245 args.firstblock = *firstblock;
@@ -4616,12 +4619,11 @@ xfs_bmapi_delay(
4616 4619
4617 4620
4618STATIC int 4621STATIC int
4619xfs_bmapi_allocate( 4622__xfs_bmapi_allocate(
4620 struct xfs_bmalloca *bma, 4623 struct xfs_bmalloca *bma)
4621 int flags)
4622{ 4624{
4623 struct xfs_mount *mp = bma->ip->i_mount; 4625 struct xfs_mount *mp = bma->ip->i_mount;
4624 int whichfork = (flags & XFS_BMAPI_ATTRFORK) ? 4626 int whichfork = (bma->flags & XFS_BMAPI_ATTRFORK) ?
4625 XFS_ATTR_FORK : XFS_DATA_FORK; 4627 XFS_ATTR_FORK : XFS_DATA_FORK;
4626 struct xfs_ifork *ifp = XFS_IFORK_PTR(bma->ip, whichfork); 4628 struct xfs_ifork *ifp = XFS_IFORK_PTR(bma->ip, whichfork);
4627 int tmp_logflags = 0; 4629 int tmp_logflags = 0;
@@ -4654,24 +4656,27 @@ xfs_bmapi_allocate(
4654 * Indicate if this is the first user data in the file, or just any 4656 * Indicate if this is the first user data in the file, or just any
4655 * user data. 4657 * user data.
4656 */ 4658 */
4657 if (!(flags & XFS_BMAPI_METADATA)) { 4659 if (!(bma->flags & XFS_BMAPI_METADATA)) {
4658 bma->userdata = (bma->offset == 0) ? 4660 bma->userdata = (bma->offset == 0) ?
4659 XFS_ALLOC_INITIAL_USER_DATA : XFS_ALLOC_USERDATA; 4661 XFS_ALLOC_INITIAL_USER_DATA : XFS_ALLOC_USERDATA;
4660 } 4662 }
4661 4663
4662 bma->minlen = (flags & XFS_BMAPI_CONTIG) ? bma->length : 1; 4664 bma->minlen = (bma->flags & XFS_BMAPI_CONTIG) ? bma->length : 1;
4663 4665
4664 /* 4666 /*
4665 * Only want to do the alignment at the eof if it is userdata and 4667 * Only want to do the alignment at the eof if it is userdata and
4666 * allocation length is larger than a stripe unit. 4668 * allocation length is larger than a stripe unit.
4667 */ 4669 */
4668 if (mp->m_dalign && bma->length >= mp->m_dalign && 4670 if (mp->m_dalign && bma->length >= mp->m_dalign &&
4669 !(flags & XFS_BMAPI_METADATA) && whichfork == XFS_DATA_FORK) { 4671 !(bma->flags & XFS_BMAPI_METADATA) && whichfork == XFS_DATA_FORK) {
4670 error = xfs_bmap_isaeof(bma, whichfork); 4672 error = xfs_bmap_isaeof(bma, whichfork);
4671 if (error) 4673 if (error)
4672 return error; 4674 return error;
4673 } 4675 }
4674 4676
4677 if (bma->flags & XFS_BMAPI_STACK_SWITCH)
4678 bma->stack_switch = 1;
4679
4675 error = xfs_bmap_alloc(bma); 4680 error = xfs_bmap_alloc(bma);
4676 if (error) 4681 if (error)
4677 return error; 4682 return error;
@@ -4706,7 +4711,7 @@ xfs_bmapi_allocate(
4706 * A wasdelay extent has been initialized, so shouldn't be flagged 4711 * A wasdelay extent has been initialized, so shouldn't be flagged
4707 * as unwritten. 4712 * as unwritten.
4708 */ 4713 */
4709 if (!bma->wasdel && (flags & XFS_BMAPI_PREALLOC) && 4714 if (!bma->wasdel && (bma->flags & XFS_BMAPI_PREALLOC) &&
4710 xfs_sb_version_hasextflgbit(&mp->m_sb)) 4715 xfs_sb_version_hasextflgbit(&mp->m_sb))
4711 bma->got.br_state = XFS_EXT_UNWRITTEN; 4716 bma->got.br_state = XFS_EXT_UNWRITTEN;
4712 4717
@@ -4734,6 +4739,45 @@ xfs_bmapi_allocate(
4734 return 0; 4739 return 0;
4735} 4740}
4736 4741
4742static void
4743xfs_bmapi_allocate_worker(
4744 struct work_struct *work)
4745{
4746 struct xfs_bmalloca *args = container_of(work,
4747 struct xfs_bmalloca, work);
4748 unsigned long pflags;
4749
4750 /* we are in a transaction context here */
4751 current_set_flags_nested(&pflags, PF_FSTRANS);
4752
4753 args->result = __xfs_bmapi_allocate(args);
4754 complete(args->done);
4755
4756 current_restore_flags_nested(&pflags, PF_FSTRANS);
4757}
4758
4759/*
4760 * Some allocation requests often come in with little stack to work on. Push
4761 * them off to a worker thread so there is lots of stack to use. Otherwise just
4762 * call directly to avoid the context switch overhead here.
4763 */
4764int
4765xfs_bmapi_allocate(
4766 struct xfs_bmalloca *args)
4767{
4768 DECLARE_COMPLETION_ONSTACK(done);
4769
4770 if (!args->stack_switch)
4771 return __xfs_bmapi_allocate(args);
4772
4773
4774 args->done = &done;
4775 INIT_WORK_ONSTACK(&args->work, xfs_bmapi_allocate_worker);
4776 queue_work(xfs_alloc_wq, &args->work);
4777 wait_for_completion(&done);
4778 return args->result;
4779}
4780
4737STATIC int 4781STATIC int
4738xfs_bmapi_convert_unwritten( 4782xfs_bmapi_convert_unwritten(
4739 struct xfs_bmalloca *bma, 4783 struct xfs_bmalloca *bma,
@@ -4919,6 +4963,7 @@ xfs_bmapi_write(
4919 bma.conv = !!(flags & XFS_BMAPI_CONVERT); 4963 bma.conv = !!(flags & XFS_BMAPI_CONVERT);
4920 bma.wasdel = wasdelay; 4964 bma.wasdel = wasdelay;
4921 bma.offset = bno; 4965 bma.offset = bno;
4966 bma.flags = flags;
4922 4967
4923 /* 4968 /*
4924 * There's a 32/64 bit type mismatch between the 4969 * There's a 32/64 bit type mismatch between the
@@ -4934,7 +4979,7 @@ xfs_bmapi_write(
4934 4979
4935 ASSERT(len > 0); 4980 ASSERT(len > 0);
4936 ASSERT(bma.length > 0); 4981 ASSERT(bma.length > 0);
4937 error = xfs_bmapi_allocate(&bma, flags); 4982 error = xfs_bmapi_allocate(&bma);
4938 if (error) 4983 if (error)
4939 goto error0; 4984 goto error0;
4940 if (bma.blkno == NULLFSBLOCK) 4985 if (bma.blkno == NULLFSBLOCK)
diff --git a/fs/xfs/xfs_bmap.h b/fs/xfs/xfs_bmap.h
index 803b56d7ce1..5f469c3516e 100644
--- a/fs/xfs/xfs_bmap.h
+++ b/fs/xfs/xfs_bmap.h
@@ -77,6 +77,7 @@ typedef struct xfs_bmap_free
77 * from written to unwritten, otherwise convert from unwritten to written. 77 * from written to unwritten, otherwise convert from unwritten to written.
78 */ 78 */
79#define XFS_BMAPI_CONVERT 0x040 79#define XFS_BMAPI_CONVERT 0x040
80#define XFS_BMAPI_STACK_SWITCH 0x080
80 81
81#define XFS_BMAPI_FLAGS \ 82#define XFS_BMAPI_FLAGS \
82 { XFS_BMAPI_ENTIRE, "ENTIRE" }, \ 83 { XFS_BMAPI_ENTIRE, "ENTIRE" }, \
@@ -85,7 +86,8 @@ typedef struct xfs_bmap_free
85 { XFS_BMAPI_PREALLOC, "PREALLOC" }, \ 86 { XFS_BMAPI_PREALLOC, "PREALLOC" }, \
86 { XFS_BMAPI_IGSTATE, "IGSTATE" }, \ 87 { XFS_BMAPI_IGSTATE, "IGSTATE" }, \
87 { XFS_BMAPI_CONTIG, "CONTIG" }, \ 88 { XFS_BMAPI_CONTIG, "CONTIG" }, \
88 { XFS_BMAPI_CONVERT, "CONVERT" } 89 { XFS_BMAPI_CONVERT, "CONVERT" }, \
90 { XFS_BMAPI_STACK_SWITCH, "STACK_SWITCH" }
89 91
90 92
91static inline int xfs_bmapi_aflag(int w) 93static inline int xfs_bmapi_aflag(int w)
@@ -133,6 +135,11 @@ typedef struct xfs_bmalloca {
133 char userdata;/* set if is user data */ 135 char userdata;/* set if is user data */
134 char aeof; /* allocated space at eof */ 136 char aeof; /* allocated space at eof */
135 char conv; /* overwriting unwritten extents */ 137 char conv; /* overwriting unwritten extents */
138 char stack_switch;
139 int flags;
140 struct completion *done;
141 struct work_struct work;
142 int result;
136} xfs_bmalloca_t; 143} xfs_bmalloca_t;
137 144
138/* 145/*
diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index 933b7930b86..4b0b8dd1b7b 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -1197,9 +1197,14 @@ xfs_buf_bio_end_io(
1197{ 1197{
1198 xfs_buf_t *bp = (xfs_buf_t *)bio->bi_private; 1198 xfs_buf_t *bp = (xfs_buf_t *)bio->bi_private;
1199 1199
1200 xfs_buf_ioerror(bp, -error); 1200 /*
1201 * don't overwrite existing errors - otherwise we can lose errors on
1202 * buffers that require multiple bios to complete.
1203 */
1204 if (!bp->b_error)
1205 xfs_buf_ioerror(bp, -error);
1201 1206
1202 if (!error && xfs_buf_is_vmapped(bp) && (bp->b_flags & XBF_READ)) 1207 if (!bp->b_error && xfs_buf_is_vmapped(bp) && (bp->b_flags & XBF_READ))
1203 invalidate_kernel_vmap_range(bp->b_addr, xfs_buf_vmap_len(bp)); 1208 invalidate_kernel_vmap_range(bp->b_addr, xfs_buf_vmap_len(bp));
1204 1209
1205 _xfs_buf_ioend(bp, 1); 1210 _xfs_buf_ioend(bp, 1);
@@ -1279,6 +1284,11 @@ next_chunk:
1279 if (size) 1284 if (size)
1280 goto next_chunk; 1285 goto next_chunk;
1281 } else { 1286 } else {
1287 /*
1288 * This is guaranteed not to be the last io reference count
1289 * because the caller (xfs_buf_iorequest) holds a count itself.
1290 */
1291 atomic_dec(&bp->b_io_remaining);
1282 xfs_buf_ioerror(bp, EIO); 1292 xfs_buf_ioerror(bp, EIO);
1283 bio_put(bio); 1293 bio_put(bio);
1284 } 1294 }
diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
index a8d0ed91119..becf4a97efc 100644
--- a/fs/xfs/xfs_buf_item.c
+++ b/fs/xfs/xfs_buf_item.c
@@ -526,7 +526,25 @@ xfs_buf_item_unpin(
526 } 526 }
527 xfs_buf_relse(bp); 527 xfs_buf_relse(bp);
528 } else if (freed && remove) { 528 } else if (freed && remove) {
529 /*
530 * There are currently two references to the buffer - the active
531 * LRU reference and the buf log item. What we are about to do
532 * here - simulate a failed IO completion - requires 3
533 * references.
534 *
535 * The LRU reference is removed by the xfs_buf_stale() call. The
536 * buf item reference is removed by the xfs_buf_iodone()
537 * callback that is run by xfs_buf_do_callbacks() during ioend
538 * processing (via the bp->b_iodone callback), and then finally
539 * the ioend processing will drop the IO reference if the buffer
540 * is marked XBF_ASYNC.
541 *
542 * Hence we need to take an additional reference here so that IO
543 * completion processing doesn't free the buffer prematurely.
544 */
529 xfs_buf_lock(bp); 545 xfs_buf_lock(bp);
546 xfs_buf_hold(bp);
547 bp->b_flags |= XBF_ASYNC;
530 xfs_buf_ioerror(bp, EIO); 548 xfs_buf_ioerror(bp, EIO);
531 XFS_BUF_UNDONE(bp); 549 XFS_BUF_UNDONE(bp);
532 xfs_buf_stale(bp); 550 xfs_buf_stale(bp);
diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
index c25b094efbf..4beaede4327 100644
--- a/fs/xfs/xfs_fsops.c
+++ b/fs/xfs/xfs_fsops.c
@@ -399,9 +399,26 @@ xfs_growfs_data_private(
399 399
400 /* update secondary superblocks. */ 400 /* update secondary superblocks. */
401 for (agno = 1; agno < nagcount; agno++) { 401 for (agno = 1; agno < nagcount; agno++) {
402 error = xfs_trans_read_buf(mp, NULL, mp->m_ddev_targp, 402 error = 0;
403 /*
404 * new secondary superblocks need to be zeroed, not read from
405 * disk as the contents of the new area we are growing into is
406 * completely unknown.
407 */
408 if (agno < oagcount) {
409 error = xfs_trans_read_buf(mp, NULL, mp->m_ddev_targp,
403 XFS_AGB_TO_DADDR(mp, agno, XFS_SB_BLOCK(mp)), 410 XFS_AGB_TO_DADDR(mp, agno, XFS_SB_BLOCK(mp)),
404 XFS_FSS_TO_BB(mp, 1), 0, &bp); 411 XFS_FSS_TO_BB(mp, 1), 0, &bp);
412 } else {
413 bp = xfs_trans_get_buf(NULL, mp->m_ddev_targp,
414 XFS_AGB_TO_DADDR(mp, agno, XFS_SB_BLOCK(mp)),
415 XFS_FSS_TO_BB(mp, 1), 0);
416 if (bp)
417 xfs_buf_zero(bp, 0, BBTOB(bp->b_length));
418 else
419 error = ENOMEM;
420 }
421
405 if (error) { 422 if (error) {
406 xfs_warn(mp, 423 xfs_warn(mp,
407 "error %d reading secondary superblock for ag %d", 424 "error %d reading secondary superblock for ag %d",
@@ -423,7 +440,7 @@ xfs_growfs_data_private(
423 break; /* no point in continuing */ 440 break; /* no point in continuing */
424 } 441 }
425 } 442 }
426 return 0; 443 return error;
427 444
428 error0: 445 error0:
429 xfs_trans_cancel(tp, XFS_TRANS_ABORT); 446 xfs_trans_cancel(tp, XFS_TRANS_ABORT);
diff --git a/fs/xfs/xfs_ialloc.c b/fs/xfs/xfs_ialloc.c
index 445bf1aef31..c5c4ef4f2bd 100644
--- a/fs/xfs/xfs_ialloc.c
+++ b/fs/xfs/xfs_ialloc.c
@@ -250,6 +250,7 @@ xfs_ialloc_ag_alloc(
250 /* boundary */ 250 /* boundary */
251 struct xfs_perag *pag; 251 struct xfs_perag *pag;
252 252
253 memset(&args, 0, sizeof(args));
253 args.tp = tp; 254 args.tp = tp;
254 args.mp = tp->t_mountp; 255 args.mp = tp->t_mountp;
255 256
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 2778258fcfa..1938b41ee9f 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -1509,7 +1509,8 @@ xfs_ifree_cluster(
1509 * to mark all the active inodes on the buffer stale. 1509 * to mark all the active inodes on the buffer stale.
1510 */ 1510 */
1511 bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, blkno, 1511 bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, blkno,
1512 mp->m_bsize * blks_per_cluster, 0); 1512 mp->m_bsize * blks_per_cluster,
1513 XBF_UNMAPPED);
1513 1514
1514 if (!bp) 1515 if (!bp)
1515 return ENOMEM; 1516 return ENOMEM;
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index 8305f2ac677..c1df3c623de 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -70,7 +70,7 @@ xfs_find_handle(
70 int hsize; 70 int hsize;
71 xfs_handle_t handle; 71 xfs_handle_t handle;
72 struct inode *inode; 72 struct inode *inode;
73 struct fd f; 73 struct fd f = {0};
74 struct path path; 74 struct path path;
75 int error; 75 int error;
76 struct xfs_inode *ip; 76 struct xfs_inode *ip;
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
index 973dff6ad93..7f537663365 100644
--- a/fs/xfs/xfs_iomap.c
+++ b/fs/xfs/xfs_iomap.c
@@ -584,7 +584,9 @@ xfs_iomap_write_allocate(
584 * pointer that the caller gave to us. 584 * pointer that the caller gave to us.
585 */ 585 */
586 error = xfs_bmapi_write(tp, ip, map_start_fsb, 586 error = xfs_bmapi_write(tp, ip, map_start_fsb,
587 count_fsb, 0, &first_block, 1, 587 count_fsb,
588 XFS_BMAPI_STACK_SWITCH,
589 &first_block, 1,
588 imap, &nimaps, &free_list); 590 imap, &nimaps, &free_list);
589 if (error) 591 if (error)
590 goto trans_cancel; 592 goto trans_cancel;
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index 7f4f9370d0e..4dad756962d 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -2387,14 +2387,27 @@ xlog_state_do_callback(
2387 2387
2388 2388
2389 /* 2389 /*
2390 * update the last_sync_lsn before we drop the 2390 * Completion of a iclog IO does not imply that
2391 * a transaction has completed, as transactions
2392 * can be large enough to span many iclogs. We
2393 * cannot change the tail of the log half way
2394 * through a transaction as this may be the only
2395 * transaction in the log and moving th etail to
2396 * point to the middle of it will prevent
2397 * recovery from finding the start of the
2398 * transaction. Hence we should only update the
2399 * last_sync_lsn if this iclog contains
2400 * transaction completion callbacks on it.
2401 *
2402 * We have to do this before we drop the
2391 * icloglock to ensure we are the only one that 2403 * icloglock to ensure we are the only one that
2392 * can update it. 2404 * can update it.
2393 */ 2405 */
2394 ASSERT(XFS_LSN_CMP(atomic64_read(&log->l_last_sync_lsn), 2406 ASSERT(XFS_LSN_CMP(atomic64_read(&log->l_last_sync_lsn),
2395 be64_to_cpu(iclog->ic_header.h_lsn)) <= 0); 2407 be64_to_cpu(iclog->ic_header.h_lsn)) <= 0);
2396 atomic64_set(&log->l_last_sync_lsn, 2408 if (iclog->ic_callback)
2397 be64_to_cpu(iclog->ic_header.h_lsn)); 2409 atomic64_set(&log->l_last_sync_lsn,
2410 be64_to_cpu(iclog->ic_header.h_lsn));
2398 2411
2399 } else 2412 } else
2400 ioerrors++; 2413 ioerrors++;
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 5da3ace352b..d308749fabf 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -3541,7 +3541,7 @@ xlog_do_recovery_pass(
3541 * - order is important. 3541 * - order is important.
3542 */ 3542 */
3543 error = xlog_bread_offset(log, 0, 3543 error = xlog_bread_offset(log, 0,
3544 bblks - split_bblks, hbp, 3544 bblks - split_bblks, dbp,
3545 offset + BBTOB(split_bblks)); 3545 offset + BBTOB(split_bblks));
3546 if (error) 3546 if (error)
3547 goto bread_err2; 3547 goto bread_err2;
diff --git a/include/Kbuild b/include/Kbuild
index 8d226bfa269..83256b64166 100644
--- a/include/Kbuild
+++ b/include/Kbuild
@@ -1,12 +1,8 @@
1# Top-level Makefile calls into asm-$(ARCH) 1# Top-level Makefile calls into asm-$(ARCH)
2# List only non-arch directories below 2# List only non-arch directories below
3 3
4header-y += asm-generic/
5header-y += linux/ 4header-y += linux/
6header-y += sound/ 5header-y += sound/
7header-y += mtd/
8header-y += rdma/ 6header-y += rdma/
9header-y += video/ 7header-y += video/
10header-y += drm/
11header-y += xen/
12header-y += scsi/ 8header-y += scsi/
diff --git a/include/asm-generic/Kbuild b/include/asm-generic/Kbuild
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/include/asm-generic/Kbuild
+++ /dev/null
diff --git a/include/asm-generic/syscalls.h b/include/asm-generic/syscalls.h
index d89dec864d4..7e4fdb64995 100644
--- a/include/asm-generic/syscalls.h
+++ b/include/asm-generic/syscalls.h
@@ -10,16 +10,15 @@
10 */ 10 */
11#ifndef sys_clone 11#ifndef sys_clone
12asmlinkage long sys_clone(unsigned long clone_flags, unsigned long newsp, 12asmlinkage long sys_clone(unsigned long clone_flags, unsigned long newsp,
13 void __user *parent_tid, void __user *child_tid, 13 void __user *parent_tid, void __user *child_tid);
14 struct pt_regs *regs);
15#endif 14#endif
16 15
17#ifndef sys_fork 16#ifndef sys_fork
18asmlinkage long sys_fork(struct pt_regs *regs); 17asmlinkage long sys_fork(void);
19#endif 18#endif
20 19
21#ifndef sys_vfork 20#ifndef sys_vfork
22asmlinkage long sys_vfork(struct pt_regs *regs); 21asmlinkage long sys_vfork(void);
23#endif 22#endif
24 23
25#ifndef sys_execve 24#ifndef sys_execve
diff --git a/include/drm/Kbuild b/include/drm/Kbuild
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/include/drm/Kbuild
+++ /dev/null
diff --git a/include/drm/drm_pciids.h b/include/drm/drm_pciids.h
index c78bb997e2c..c5c35e62942 100644
--- a/include/drm/drm_pciids.h
+++ b/include/drm/drm_pciids.h
@@ -205,9 +205,12 @@
205 {0x1002, 0x6788, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI|RADEON_NEW_MEMMAP}, \ 205 {0x1002, 0x6788, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI|RADEON_NEW_MEMMAP}, \
206 {0x1002, 0x678A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI|RADEON_NEW_MEMMAP}, \ 206 {0x1002, 0x678A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI|RADEON_NEW_MEMMAP}, \
207 {0x1002, 0x6790, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI|RADEON_NEW_MEMMAP}, \ 207 {0x1002, 0x6790, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI|RADEON_NEW_MEMMAP}, \
208 {0x1002, 0x6791, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI|RADEON_NEW_MEMMAP}, \
209 {0x1002, 0x6792, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI|RADEON_NEW_MEMMAP}, \
208 {0x1002, 0x6798, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI|RADEON_NEW_MEMMAP}, \ 210 {0x1002, 0x6798, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI|RADEON_NEW_MEMMAP}, \
209 {0x1002, 0x6799, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI|RADEON_NEW_MEMMAP}, \ 211 {0x1002, 0x6799, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI|RADEON_NEW_MEMMAP}, \
210 {0x1002, 0x679A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI|RADEON_NEW_MEMMAP}, \ 212 {0x1002, 0x679A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI|RADEON_NEW_MEMMAP}, \
213 {0x1002, 0x679B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI|RADEON_NEW_MEMMAP}, \
211 {0x1002, 0x679E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI|RADEON_NEW_MEMMAP}, \ 214 {0x1002, 0x679E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI|RADEON_NEW_MEMMAP}, \
212 {0x1002, 0x679F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI|RADEON_NEW_MEMMAP}, \ 215 {0x1002, 0x679F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI|RADEON_NEW_MEMMAP}, \
213 {0x1002, 0x6800, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ 216 {0x1002, 0x6800, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
@@ -217,6 +220,7 @@
217 {0x1002, 0x6808, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN|RADEON_NEW_MEMMAP}, \ 220 {0x1002, 0x6808, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN|RADEON_NEW_MEMMAP}, \
218 {0x1002, 0x6809, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN|RADEON_NEW_MEMMAP}, \ 221 {0x1002, 0x6809, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN|RADEON_NEW_MEMMAP}, \
219 {0x1002, 0x6810, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN|RADEON_NEW_MEMMAP}, \ 222 {0x1002, 0x6810, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN|RADEON_NEW_MEMMAP}, \
223 {0x1002, 0x6811, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN|RADEON_NEW_MEMMAP}, \
220 {0x1002, 0x6816, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN|RADEON_NEW_MEMMAP}, \ 224 {0x1002, 0x6816, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN|RADEON_NEW_MEMMAP}, \
221 {0x1002, 0x6817, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN|RADEON_NEW_MEMMAP}, \ 225 {0x1002, 0x6817, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN|RADEON_NEW_MEMMAP}, \
222 {0x1002, 0x6818, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN|RADEON_NEW_MEMMAP}, \ 226 {0x1002, 0x6818, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PITCAIRN|RADEON_NEW_MEMMAP}, \
diff --git a/include/linux/Kbuild b/include/linux/Kbuild
index 5b57367e28d..7fe2dae251e 100644
--- a/include/linux/Kbuild
+++ b/include/linux/Kbuild
@@ -1,31 +1,5 @@
1header-y += byteorder/
2header-y += can/
3header-y += caif/
4header-y += dvb/ 1header-y += dvb/
5header-y += hdlc/ 2header-y += hdlc/
6header-y += hsi/ 3header-y += hsi/
7header-y += isdn/
8header-y += mmc/
9header-y += nfsd/
10header-y += raid/ 4header-y += raid/
11header-y += spi/
12header-y += sunrpc/
13header-y += tc_act/
14header-y += tc_ematch/
15header-y += netfilter/
16header-y += netfilter_arp/
17header-y += netfilter_bridge/
18header-y += netfilter_ipv4/
19header-y += netfilter_ipv6/
20header-y += usb/ 5header-y += usb/
21header-y += wimax/
22
23ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/a.out.h \
24 $(srctree)/arch/$(SRCARCH)/include/uapi/asm/a.out.h),)
25endif
26ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/kvm.h \
27 $(srctree)/arch/$(SRCARCH)/include/uapi/asm/kvm.h),)
28endif
29ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/kvm_para.h \
30 $(srctree)/arch/$(SRCARCH)/include/uapi/asm/kvm_para.h),)
31endif
diff --git a/include/linux/byteorder/Kbuild b/include/linux/byteorder/Kbuild
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/include/linux/byteorder/Kbuild
+++ /dev/null
diff --git a/include/linux/caif/Kbuild b/include/linux/caif/Kbuild
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/include/linux/caif/Kbuild
+++ /dev/null
diff --git a/include/linux/can/Kbuild b/include/linux/can/Kbuild
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/include/linux/can/Kbuild
+++ /dev/null
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index c1273158292..f9f5e9eeb9d 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -335,8 +335,8 @@ const char *__clk_get_name(struct clk *clk);
335struct clk_hw *__clk_get_hw(struct clk *clk); 335struct clk_hw *__clk_get_hw(struct clk *clk);
336u8 __clk_get_num_parents(struct clk *clk); 336u8 __clk_get_num_parents(struct clk *clk);
337struct clk *__clk_get_parent(struct clk *clk); 337struct clk *__clk_get_parent(struct clk *clk);
338inline int __clk_get_enable_count(struct clk *clk); 338int __clk_get_enable_count(struct clk *clk);
339inline int __clk_get_prepare_count(struct clk *clk); 339int __clk_get_prepare_count(struct clk *clk);
340unsigned long __clk_get_rate(struct clk *clk); 340unsigned long __clk_get_rate(struct clk *clk);
341unsigned long __clk_get_flags(struct clk *clk); 341unsigned long __clk_get_flags(struct clk *clk);
342int __clk_is_enabled(struct clk *clk); 342int __clk_is_enabled(struct clk *clk);
diff --git a/include/linux/compat.h b/include/linux/compat.h
index d0ced1011f2..d2db71077d9 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -286,10 +286,8 @@ asmlinkage ssize_t compat_sys_pwritev(unsigned long fd,
286 286
287int compat_do_execve(const char *filename, const compat_uptr_t __user *argv, 287int compat_do_execve(const char *filename, const compat_uptr_t __user *argv,
288 const compat_uptr_t __user *envp, struct pt_regs *regs); 288 const compat_uptr_t __user *envp, struct pt_regs *regs);
289#ifdef __ARCH_WANT_SYS_EXECVE
290asmlinkage long compat_sys_execve(const char __user *filename, const compat_uptr_t __user *argv, 289asmlinkage long compat_sys_execve(const char __user *filename, const compat_uptr_t __user *argv,
291 const compat_uptr_t __user *envp); 290 const compat_uptr_t __user *envp);
292#endif
293 291
294asmlinkage long compat_sys_select(int n, compat_ulong_t __user *inp, 292asmlinkage long compat_sys_select(int n, compat_ulong_t __user *inp,
295 compat_ulong_t __user *outp, compat_ulong_t __user *exp, 293 compat_ulong_t __user *outp, compat_ulong_t __user *exp,
diff --git a/include/linux/coredump.h b/include/linux/coredump.h
index 1775eb8acc0..1d7399314a8 100644
--- a/include/linux/coredump.h
+++ b/include/linux/coredump.h
@@ -4,6 +4,7 @@
4#include <linux/types.h> 4#include <linux/types.h>
5#include <linux/mm.h> 5#include <linux/mm.h>
6#include <linux/fs.h> 6#include <linux/fs.h>
7#include <asm/siginfo.h>
7 8
8/* 9/*
9 * These are the only things you should do on a core-file: use only these 10 * These are the only things you should do on a core-file: use only these
diff --git a/include/linux/dvb/Kbuild b/include/linux/dvb/Kbuild
index f4dba8637f9..e69de29bb2d 100644
--- a/include/linux/dvb/Kbuild
+++ b/include/linux/dvb/Kbuild
@@ -1,8 +0,0 @@
1header-y += audio.h
2header-y += ca.h
3header-y += dmx.h
4header-y += frontend.h
5header-y += net.h
6header-y += osd.h
7header-y += version.h
8header-y += video.h
diff --git a/include/linux/dvb/dmx.h b/include/linux/dvb/dmx.h
index f078f3ac82d..0be6d8f2b52 100644
--- a/include/linux/dvb/dmx.h
+++ b/include/linux/dvb/dmx.h
@@ -20,138 +20,10 @@
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 * 21 *
22 */ 22 */
23
24#ifndef _DVBDMX_H_ 23#ifndef _DVBDMX_H_
25#define _DVBDMX_H_ 24#define _DVBDMX_H_
26 25
27#include <linux/types.h>
28#ifdef __KERNEL__
29#include <linux/time.h> 26#include <linux/time.h>
30#else 27#include <uapi/linux/dvb/dmx.h>
31#include <time.h>
32#endif
33
34
35#define DMX_FILTER_SIZE 16
36
37typedef enum
38{
39 DMX_OUT_DECODER, /* Streaming directly to decoder. */
40 DMX_OUT_TAP, /* Output going to a memory buffer */
41 /* (to be retrieved via the read command).*/
42 DMX_OUT_TS_TAP, /* Output multiplexed into a new TS */
43 /* (to be retrieved by reading from the */
44 /* logical DVR device). */
45 DMX_OUT_TSDEMUX_TAP /* Like TS_TAP but retrieved from the DMX device */
46} dmx_output_t;
47
48
49typedef enum
50{
51 DMX_IN_FRONTEND, /* Input from a front-end device. */
52 DMX_IN_DVR /* Input from the logical DVR device. */
53} dmx_input_t;
54
55
56typedef enum
57{
58 DMX_PES_AUDIO0,
59 DMX_PES_VIDEO0,
60 DMX_PES_TELETEXT0,
61 DMX_PES_SUBTITLE0,
62 DMX_PES_PCR0,
63
64 DMX_PES_AUDIO1,
65 DMX_PES_VIDEO1,
66 DMX_PES_TELETEXT1,
67 DMX_PES_SUBTITLE1,
68 DMX_PES_PCR1,
69
70 DMX_PES_AUDIO2,
71 DMX_PES_VIDEO2,
72 DMX_PES_TELETEXT2,
73 DMX_PES_SUBTITLE2,
74 DMX_PES_PCR2,
75
76 DMX_PES_AUDIO3,
77 DMX_PES_VIDEO3,
78 DMX_PES_TELETEXT3,
79 DMX_PES_SUBTITLE3,
80 DMX_PES_PCR3,
81
82 DMX_PES_OTHER
83} dmx_pes_type_t;
84
85#define DMX_PES_AUDIO DMX_PES_AUDIO0
86#define DMX_PES_VIDEO DMX_PES_VIDEO0
87#define DMX_PES_TELETEXT DMX_PES_TELETEXT0
88#define DMX_PES_SUBTITLE DMX_PES_SUBTITLE0
89#define DMX_PES_PCR DMX_PES_PCR0
90
91
92typedef struct dmx_filter
93{
94 __u8 filter[DMX_FILTER_SIZE];
95 __u8 mask[DMX_FILTER_SIZE];
96 __u8 mode[DMX_FILTER_SIZE];
97} dmx_filter_t;
98
99
100struct dmx_sct_filter_params
101{
102 __u16 pid;
103 dmx_filter_t filter;
104 __u32 timeout;
105 __u32 flags;
106#define DMX_CHECK_CRC 1
107#define DMX_ONESHOT 2
108#define DMX_IMMEDIATE_START 4
109#define DMX_KERNEL_CLIENT 0x8000
110};
111
112
113struct dmx_pes_filter_params
114{
115 __u16 pid;
116 dmx_input_t input;
117 dmx_output_t output;
118 dmx_pes_type_t pes_type;
119 __u32 flags;
120};
121
122typedef struct dmx_caps {
123 __u32 caps;
124 int num_decoders;
125} dmx_caps_t;
126
127typedef enum {
128 DMX_SOURCE_FRONT0 = 0,
129 DMX_SOURCE_FRONT1,
130 DMX_SOURCE_FRONT2,
131 DMX_SOURCE_FRONT3,
132 DMX_SOURCE_DVR0 = 16,
133 DMX_SOURCE_DVR1,
134 DMX_SOURCE_DVR2,
135 DMX_SOURCE_DVR3
136} dmx_source_t;
137
138struct dmx_stc {
139 unsigned int num; /* input : which STC? 0..N */
140 unsigned int base; /* output: divisor for stc to get 90 kHz clock */
141 __u64 stc; /* output: stc in 'base'*90 kHz units */
142};
143
144
145#define DMX_START _IO('o', 41)
146#define DMX_STOP _IO('o', 42)
147#define DMX_SET_FILTER _IOW('o', 43, struct dmx_sct_filter_params)
148#define DMX_SET_PES_FILTER _IOW('o', 44, struct dmx_pes_filter_params)
149#define DMX_SET_BUFFER_SIZE _IO('o', 45)
150#define DMX_GET_PES_PIDS _IOR('o', 47, __u16[5])
151#define DMX_GET_CAPS _IOR('o', 48, dmx_caps_t)
152#define DMX_SET_SOURCE _IOW('o', 49, dmx_source_t)
153#define DMX_GET_STC _IOWR('o', 50, struct dmx_stc)
154#define DMX_ADD_PID _IOW('o', 51, __u16)
155#define DMX_REMOVE_PID _IOW('o', 52, __u16)
156 28
157#endif /*_DVBDMX_H_*/ 29#endif /*_DVBDMX_H_*/
diff --git a/include/linux/dvb/video.h b/include/linux/dvb/video.h
index 1d750c0fd86..85c20d92569 100644
--- a/include/linux/dvb/video.h
+++ b/include/linux/dvb/video.h
@@ -20,257 +20,10 @@
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 * 21 *
22 */ 22 */
23
24#ifndef _DVBVIDEO_H_ 23#ifndef _DVBVIDEO_H_
25#define _DVBVIDEO_H_ 24#define _DVBVIDEO_H_
26 25
27#include <linux/types.h>
28#ifdef __KERNEL__
29#include <linux/compiler.h> 26#include <linux/compiler.h>
30#else 27#include <uapi/linux/dvb/video.h>
31#include <stdint.h>
32#include <time.h>
33#endif
34
35typedef enum {
36 VIDEO_FORMAT_4_3, /* Select 4:3 format */
37 VIDEO_FORMAT_16_9, /* Select 16:9 format. */
38 VIDEO_FORMAT_221_1 /* 2.21:1 */
39} video_format_t;
40
41
42typedef enum {
43 VIDEO_SYSTEM_PAL,
44 VIDEO_SYSTEM_NTSC,
45 VIDEO_SYSTEM_PALN,
46 VIDEO_SYSTEM_PALNc,
47 VIDEO_SYSTEM_PALM,
48 VIDEO_SYSTEM_NTSC60,
49 VIDEO_SYSTEM_PAL60,
50 VIDEO_SYSTEM_PALM60
51} video_system_t;
52
53
54typedef enum {
55 VIDEO_PAN_SCAN, /* use pan and scan format */
56 VIDEO_LETTER_BOX, /* use letterbox format */
57 VIDEO_CENTER_CUT_OUT /* use center cut out format */
58} video_displayformat_t;
59
60typedef struct {
61 int w;
62 int h;
63 video_format_t aspect_ratio;
64} video_size_t;
65
66typedef enum {
67 VIDEO_SOURCE_DEMUX, /* Select the demux as the main source */
68 VIDEO_SOURCE_MEMORY /* If this source is selected, the stream
69 comes from the user through the write
70 system call */
71} video_stream_source_t;
72
73
74typedef enum {
75 VIDEO_STOPPED, /* Video is stopped */
76 VIDEO_PLAYING, /* Video is currently playing */
77 VIDEO_FREEZED /* Video is freezed */
78} video_play_state_t;
79
80
81/* Decoder commands */
82#define VIDEO_CMD_PLAY (0)
83#define VIDEO_CMD_STOP (1)
84#define VIDEO_CMD_FREEZE (2)
85#define VIDEO_CMD_CONTINUE (3)
86
87/* Flags for VIDEO_CMD_FREEZE */
88#define VIDEO_CMD_FREEZE_TO_BLACK (1 << 0)
89
90/* Flags for VIDEO_CMD_STOP */
91#define VIDEO_CMD_STOP_TO_BLACK (1 << 0)
92#define VIDEO_CMD_STOP_IMMEDIATELY (1 << 1)
93
94/* Play input formats: */
95/* The decoder has no special format requirements */
96#define VIDEO_PLAY_FMT_NONE (0)
97/* The decoder requires full GOPs */
98#define VIDEO_PLAY_FMT_GOP (1)
99
100/* The structure must be zeroed before use by the application
101 This ensures it can be extended safely in the future. */
102struct video_command {
103 __u32 cmd;
104 __u32 flags;
105 union {
106 struct {
107 __u64 pts;
108 } stop;
109
110 struct {
111 /* 0 or 1000 specifies normal speed,
112 1 specifies forward single stepping,
113 -1 specifies backward single stepping,
114 >1: playback at speed/1000 of the normal speed,
115 <-1: reverse playback at (-speed/1000) of the normal speed. */
116 __s32 speed;
117 __u32 format;
118 } play;
119
120 struct {
121 __u32 data[16];
122 } raw;
123 };
124};
125
126/* FIELD_UNKNOWN can be used if the hardware does not know whether
127 the Vsync is for an odd, even or progressive (i.e. non-interlaced)
128 field. */
129#define VIDEO_VSYNC_FIELD_UNKNOWN (0)
130#define VIDEO_VSYNC_FIELD_ODD (1)
131#define VIDEO_VSYNC_FIELD_EVEN (2)
132#define VIDEO_VSYNC_FIELD_PROGRESSIVE (3)
133
134struct video_event {
135 __s32 type;
136#define VIDEO_EVENT_SIZE_CHANGED 1
137#define VIDEO_EVENT_FRAME_RATE_CHANGED 2
138#define VIDEO_EVENT_DECODER_STOPPED 3
139#define VIDEO_EVENT_VSYNC 4
140 __kernel_time_t timestamp;
141 union {
142 video_size_t size;
143 unsigned int frame_rate; /* in frames per 1000sec */
144 unsigned char vsync_field; /* unknown/odd/even/progressive */
145 } u;
146};
147
148
149struct video_status {
150 int video_blank; /* blank video on freeze? */
151 video_play_state_t play_state; /* current state of playback */
152 video_stream_source_t stream_source; /* current source (demux/memory) */
153 video_format_t video_format; /* current aspect ratio of stream*/
154 video_displayformat_t display_format;/* selected cropping mode */
155};
156
157
158struct video_still_picture {
159 char __user *iFrame; /* pointer to a single iframe in memory */
160 __s32 size;
161};
162
163
164typedef
165struct video_highlight {
166 int active; /* 1=show highlight, 0=hide highlight */
167 __u8 contrast1; /* 7- 4 Pattern pixel contrast */
168 /* 3- 0 Background pixel contrast */
169 __u8 contrast2; /* 7- 4 Emphasis pixel-2 contrast */
170 /* 3- 0 Emphasis pixel-1 contrast */
171 __u8 color1; /* 7- 4 Pattern pixel color */
172 /* 3- 0 Background pixel color */
173 __u8 color2; /* 7- 4 Emphasis pixel-2 color */
174 /* 3- 0 Emphasis pixel-1 color */
175 __u32 ypos; /* 23-22 auto action mode */
176 /* 21-12 start y */
177 /* 9- 0 end y */
178 __u32 xpos; /* 23-22 button color number */
179 /* 21-12 start x */
180 /* 9- 0 end x */
181} video_highlight_t;
182
183
184typedef struct video_spu {
185 int active;
186 int stream_id;
187} video_spu_t;
188
189
190typedef struct video_spu_palette { /* SPU Palette information */
191 int length;
192 __u8 __user *palette;
193} video_spu_palette_t;
194
195
196typedef struct video_navi_pack {
197 int length; /* 0 ... 1024 */
198 __u8 data[1024];
199} video_navi_pack_t;
200
201
202typedef __u16 video_attributes_t;
203/* bits: descr. */
204/* 15-14 Video compression mode (0=MPEG-1, 1=MPEG-2) */
205/* 13-12 TV system (0=525/60, 1=625/50) */
206/* 11-10 Aspect ratio (0=4:3, 3=16:9) */
207/* 9- 8 permitted display mode on 4:3 monitor (0=both, 1=only pan-sca */
208/* 7 line 21-1 data present in GOP (1=yes, 0=no) */
209/* 6 line 21-2 data present in GOP (1=yes, 0=no) */
210/* 5- 3 source resolution (0=720x480/576, 1=704x480/576, 2=352x480/57 */
211/* 2 source letterboxed (1=yes, 0=no) */
212/* 0 film/camera mode (0=camera, 1=film (625/50 only)) */
213
214
215/* bit definitions for capabilities: */
216/* can the hardware decode MPEG1 and/or MPEG2? */
217#define VIDEO_CAP_MPEG1 1
218#define VIDEO_CAP_MPEG2 2
219/* can you send a system and/or program stream to video device?
220 (you still have to open the video and the audio device but only
221 send the stream to the video device) */
222#define VIDEO_CAP_SYS 4
223#define VIDEO_CAP_PROG 8
224/* can the driver also handle SPU, NAVI and CSS encoded data?
225 (CSS API is not present yet) */
226#define VIDEO_CAP_SPU 16
227#define VIDEO_CAP_NAVI 32
228#define VIDEO_CAP_CSS 64
229
230
231#define VIDEO_STOP _IO('o', 21)
232#define VIDEO_PLAY _IO('o', 22)
233#define VIDEO_FREEZE _IO('o', 23)
234#define VIDEO_CONTINUE _IO('o', 24)
235#define VIDEO_SELECT_SOURCE _IO('o', 25)
236#define VIDEO_SET_BLANK _IO('o', 26)
237#define VIDEO_GET_STATUS _IOR('o', 27, struct video_status)
238#define VIDEO_GET_EVENT _IOR('o', 28, struct video_event)
239#define VIDEO_SET_DISPLAY_FORMAT _IO('o', 29)
240#define VIDEO_STILLPICTURE _IOW('o', 30, struct video_still_picture)
241#define VIDEO_FAST_FORWARD _IO('o', 31)
242#define VIDEO_SLOWMOTION _IO('o', 32)
243#define VIDEO_GET_CAPABILITIES _IOR('o', 33, unsigned int)
244#define VIDEO_CLEAR_BUFFER _IO('o', 34)
245#define VIDEO_SET_ID _IO('o', 35)
246#define VIDEO_SET_STREAMTYPE _IO('o', 36)
247#define VIDEO_SET_FORMAT _IO('o', 37)
248#define VIDEO_SET_SYSTEM _IO('o', 38)
249#define VIDEO_SET_HIGHLIGHT _IOW('o', 39, video_highlight_t)
250#define VIDEO_SET_SPU _IOW('o', 50, video_spu_t)
251#define VIDEO_SET_SPU_PALETTE _IOW('o', 51, video_spu_palette_t)
252#define VIDEO_GET_NAVI _IOR('o', 52, video_navi_pack_t)
253#define VIDEO_SET_ATTRIBUTES _IO('o', 53)
254#define VIDEO_GET_SIZE _IOR('o', 55, video_size_t)
255#define VIDEO_GET_FRAME_RATE _IOR('o', 56, unsigned int)
256
257/**
258 * VIDEO_GET_PTS
259 *
260 * Read the 33 bit presentation time stamp as defined
261 * in ITU T-REC-H.222.0 / ISO/IEC 13818-1.
262 *
263 * The PTS should belong to the currently played
264 * frame if possible, but may also be a value close to it
265 * like the PTS of the last decoded frame or the last PTS
266 * extracted by the PES parser.
267 */
268#define VIDEO_GET_PTS _IOR('o', 57, __u64)
269
270/* Read the number of displayed frames since the decoder was started */
271#define VIDEO_GET_FRAME_COUNT _IOR('o', 58, __u64)
272
273#define VIDEO_COMMAND _IOWR('o', 59, struct video_command)
274#define VIDEO_TRY_COMMAND _IOWR('o', 60, struct video_command)
275 28
276#endif /*_DVBVIDEO_H_*/ 29#endif /*_DVBVIDEO_H_*/
diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h
index c18257b0fa7..6dd4787a798 100644
--- a/include/linux/dynamic_debug.h
+++ b/include/linux/dynamic_debug.h
@@ -61,7 +61,7 @@ int __dynamic_netdev_dbg(struct _ddebug *descriptor,
61 const char *fmt, ...); 61 const char *fmt, ...);
62 62
63#define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt) \ 63#define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt) \
64 static struct _ddebug __used __aligned(8) \ 64 static struct _ddebug __aligned(8) \
65 __attribute__((section("__verbose"))) name = { \ 65 __attribute__((section("__verbose"))) name = { \
66 .modname = KBUILD_MODNAME, \ 66 .modname = KBUILD_MODNAME, \
67 .function = __func__, \ 67 .function = __func__, \
diff --git a/include/linux/elf-fdpic.h b/include/linux/elf-fdpic.h
new file mode 100644
index 00000000000..386440317b0
--- /dev/null
+++ b/include/linux/elf-fdpic.h
@@ -0,0 +1,51 @@
1/* FDPIC ELF load map
2 *
3 * Copyright (C) 2003 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
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#ifndef _LINUX_ELF_FDPIC_H
13#define _LINUX_ELF_FDPIC_H
14
15#include <uapi/linux/elf-fdpic.h>
16
17/*
18 * binfmt binary parameters structure
19 */
20struct elf_fdpic_params {
21 struct elfhdr hdr; /* ref copy of ELF header */
22 struct elf_phdr *phdrs; /* ref copy of PT_PHDR table */
23 struct elf32_fdpic_loadmap *loadmap; /* loadmap to be passed to userspace */
24 unsigned long elfhdr_addr; /* mapped ELF header user address */
25 unsigned long ph_addr; /* mapped PT_PHDR user address */
26 unsigned long map_addr; /* mapped loadmap user address */
27 unsigned long entry_addr; /* mapped entry user address */
28 unsigned long stack_size; /* stack size requested (PT_GNU_STACK) */
29 unsigned long dynamic_addr; /* mapped PT_DYNAMIC user address */
30 unsigned long load_addr; /* user address at which to map binary */
31 unsigned long flags;
32#define ELF_FDPIC_FLAG_ARRANGEMENT 0x0000000f /* PT_LOAD arrangement flags */
33#define ELF_FDPIC_FLAG_INDEPENDENT 0x00000000 /* PT_LOADs can be put anywhere */
34#define ELF_FDPIC_FLAG_HONOURVADDR 0x00000001 /* PT_LOAD.vaddr must be honoured */
35#define ELF_FDPIC_FLAG_CONSTDISP 0x00000002 /* PT_LOADs require constant
36 * displacement */
37#define ELF_FDPIC_FLAG_CONTIGUOUS 0x00000003 /* PT_LOADs should be contiguous */
38#define ELF_FDPIC_FLAG_EXEC_STACK 0x00000010 /* T if stack to be executable */
39#define ELF_FDPIC_FLAG_NOEXEC_STACK 0x00000020 /* T if stack not to be executable */
40#define ELF_FDPIC_FLAG_EXECUTABLE 0x00000040 /* T if this object is the executable */
41#define ELF_FDPIC_FLAG_PRESENT 0x80000000 /* T if this object is present */
42};
43
44#ifdef CONFIG_MMU
45extern void elf_fdpic_arch_lay_out_mm(struct elf_fdpic_params *exec_params,
46 struct elf_fdpic_params *interp_params,
47 unsigned long *start_stack,
48 unsigned long *start_brk);
49#endif
50
51#endif /* _LINUX_ELF_FDPIC_H */
diff --git a/include/linux/extcon.h b/include/linux/extcon.h
index 7443a560c9d..2c26c14cd71 100644
--- a/include/linux/extcon.h
+++ b/include/linux/extcon.h
@@ -68,7 +68,7 @@ enum extcon_cable_name {
68 EXTCON_VIDEO_OUT, 68 EXTCON_VIDEO_OUT,
69 EXTCON_MECHANICAL, 69 EXTCON_MECHANICAL,
70}; 70};
71extern const char *extcon_cable_name[]; 71extern const char extcon_cable_name[][CABLE_NAME_MAX + 1];
72 72
73struct extcon_cable; 73struct extcon_cable;
74 74
diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h
index 45052aa814c..fb7dacae052 100644
--- a/include/linux/fdtable.h
+++ b/include/linux/fdtable.h
@@ -95,7 +95,6 @@ struct task_struct;
95struct files_struct *get_files_struct(struct task_struct *); 95struct files_struct *get_files_struct(struct task_struct *);
96void put_files_struct(struct files_struct *fs); 96void put_files_struct(struct files_struct *fs);
97void reset_files_struct(struct files_struct *); 97void reset_files_struct(struct files_struct *);
98void daemonize_descriptors(void);
99int unshare_files(struct files_struct **); 98int unshare_files(struct files_struct **);
100struct files_struct *dup_fd(struct files_struct *, int *); 99struct files_struct *dup_fd(struct files_struct *, int *);
101void do_close_on_exec(struct files_struct *); 100void do_close_on_exec(struct files_struct *);
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 001c7cff2d4..b33cfc97b9c 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -64,6 +64,73 @@ typedef void (dio_iodone_t)(struct kiocb *iocb, loff_t offset,
64 ssize_t bytes, void *private, int ret, 64 ssize_t bytes, void *private, int ret,
65 bool is_async); 65 bool is_async);
66 66
67#define MAY_EXEC 0x00000001
68#define MAY_WRITE 0x00000002
69#define MAY_READ 0x00000004
70#define MAY_APPEND 0x00000008
71#define MAY_ACCESS 0x00000010
72#define MAY_OPEN 0x00000020
73#define MAY_CHDIR 0x00000040
74/* called from RCU mode, don't block */
75#define MAY_NOT_BLOCK 0x00000080
76
77/*
78 * flags in file.f_mode. Note that FMODE_READ and FMODE_WRITE must correspond
79 * to O_WRONLY and O_RDWR via the strange trick in __dentry_open()
80 */
81
82/* file is open for reading */
83#define FMODE_READ ((__force fmode_t)0x1)
84/* file is open for writing */
85#define FMODE_WRITE ((__force fmode_t)0x2)
86/* file is seekable */
87#define FMODE_LSEEK ((__force fmode_t)0x4)
88/* file can be accessed using pread */
89#define FMODE_PREAD ((__force fmode_t)0x8)
90/* file can be accessed using pwrite */
91#define FMODE_PWRITE ((__force fmode_t)0x10)
92/* File is opened for execution with sys_execve / sys_uselib */
93#define FMODE_EXEC ((__force fmode_t)0x20)
94/* File is opened with O_NDELAY (only set for block devices) */
95#define FMODE_NDELAY ((__force fmode_t)0x40)
96/* File is opened with O_EXCL (only set for block devices) */
97#define FMODE_EXCL ((__force fmode_t)0x80)
98/* File is opened using open(.., 3, ..) and is writeable only for ioctls
99 (specialy hack for floppy.c) */
100#define FMODE_WRITE_IOCTL ((__force fmode_t)0x100)
101/* 32bit hashes as llseek() offset (for directories) */
102#define FMODE_32BITHASH ((__force fmode_t)0x200)
103/* 64bit hashes as llseek() offset (for directories) */
104#define FMODE_64BITHASH ((__force fmode_t)0x400)
105
106/*
107 * Don't update ctime and mtime.
108 *
109 * Currently a special hack for the XFS open_by_handle ioctl, but we'll
110 * hopefully graduate it to a proper O_CMTIME flag supported by open(2) soon.
111 */
112#define FMODE_NOCMTIME ((__force fmode_t)0x800)
113
114/* Expect random access pattern */
115#define FMODE_RANDOM ((__force fmode_t)0x1000)
116
117/* File is huge (eg. /dev/kmem): treat loff_t as unsigned */
118#define FMODE_UNSIGNED_OFFSET ((__force fmode_t)0x2000)
119
120/* File is opened with O_PATH; almost nothing can be done with it */
121#define FMODE_PATH ((__force fmode_t)0x4000)
122
123/* File was opened by fanotify and shouldn't generate fanotify events */
124#define FMODE_NONOTIFY ((__force fmode_t)0x1000000)
125
126/*
127 * Flag for rw_copy_check_uvector and compat_rw_copy_check_uvector
128 * that indicates that they should check the contents of the iovec are
129 * valid, but not check the memory that the iovec elements
130 * points too.
131 */
132#define CHECK_IOVEC_ONLY -1
133
67/* 134/*
68 * The below are the various read and write types that we support. Some of 135 * The below are the various read and write types that we support. Some of
69 * them include behavioral modifiers that send information down to the 136 * them include behavioral modifiers that send information down to the
@@ -1557,6 +1624,60 @@ struct super_operations {
1557}; 1624};
1558 1625
1559/* 1626/*
1627 * Inode flags - they have no relation to superblock flags now
1628 */
1629#define S_SYNC 1 /* Writes are synced at once */
1630#define S_NOATIME 2 /* Do not update access times */
1631#define S_APPEND 4 /* Append-only file */
1632#define S_IMMUTABLE 8 /* Immutable file */
1633#define S_DEAD 16 /* removed, but still open directory */
1634#define S_NOQUOTA 32 /* Inode is not counted to quota */
1635#define S_DIRSYNC 64 /* Directory modifications are synchronous */
1636#define S_NOCMTIME 128 /* Do not update file c/mtime */
1637#define S_SWAPFILE 256 /* Do not truncate: swapon got its bmaps */
1638#define S_PRIVATE 512 /* Inode is fs-internal */
1639#define S_IMA 1024 /* Inode has an associated IMA struct */
1640#define S_AUTOMOUNT 2048 /* Automount/referral quasi-directory */
1641#define S_NOSEC 4096 /* no suid or xattr security attributes */
1642
1643/*
1644 * Note that nosuid etc flags are inode-specific: setting some file-system
1645 * flags just means all the inodes inherit those flags by default. It might be
1646 * possible to override it selectively if you really wanted to with some
1647 * ioctl() that is not currently implemented.
1648 *
1649 * Exception: MS_RDONLY is always applied to the entire file system.
1650 *
1651 * Unfortunately, it is possible to change a filesystems flags with it mounted
1652 * with files in use. This means that all of the inodes will not have their
1653 * i_flags updated. Hence, i_flags no longer inherit the superblock mount
1654 * flags, so these have to be checked separately. -- rmk@arm.uk.linux.org
1655 */
1656#define __IS_FLG(inode, flg) ((inode)->i_sb->s_flags & (flg))
1657
1658#define IS_RDONLY(inode) ((inode)->i_sb->s_flags & MS_RDONLY)
1659#define IS_SYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS) || \
1660 ((inode)->i_flags & S_SYNC))
1661#define IS_DIRSYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
1662 ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
1663#define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
1664#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
1665#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
1666
1667#define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
1668#define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
1669#define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
1670#define IS_POSIXACL(inode) __IS_FLG(inode, MS_POSIXACL)
1671
1672#define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
1673#define IS_NOCMTIME(inode) ((inode)->i_flags & S_NOCMTIME)
1674#define IS_SWAPFILE(inode) ((inode)->i_flags & S_SWAPFILE)
1675#define IS_PRIVATE(inode) ((inode)->i_flags & S_PRIVATE)
1676#define IS_IMA(inode) ((inode)->i_flags & S_IMA)
1677#define IS_AUTOMOUNT(inode) ((inode)->i_flags & S_AUTOMOUNT)
1678#define IS_NOSEC(inode) ((inode)->i_flags & S_NOSEC)
1679
1680/*
1560 * Inode state bits. Protected by inode->i_lock 1681 * Inode state bits. Protected by inode->i_lock
1561 * 1682 *
1562 * Three bits determine the dirty state of the inode, I_DIRTY_SYNC, 1683 * Three bits determine the dirty state of the inode, I_DIRTY_SYNC,
@@ -1688,6 +1809,11 @@ int sync_inode_metadata(struct inode *inode, int wait);
1688struct file_system_type { 1809struct file_system_type {
1689 const char *name; 1810 const char *name;
1690 int fs_flags; 1811 int fs_flags;
1812#define FS_REQUIRES_DEV 1
1813#define FS_BINARY_MOUNTDATA 2
1814#define FS_HAS_SUBTYPE 4
1815#define FS_REVAL_DOT 16384 /* Check the paths ".", ".." for staleness */
1816#define FS_RENAME_DOES_D_MOVE 32768 /* FS will handle d_move() during rename() internally. */
1691 struct dentry *(*mount) (struct file_system_type *, int, 1817 struct dentry *(*mount) (struct file_system_type *, int,
1692 const char *, void *); 1818 const char *, void *);
1693 void (*kill_sb) (struct super_block *); 1819 void (*kill_sb) (struct super_block *);
diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
index 003dc0fd734..d0ae3a84bcf 100644
--- a/include/linux/fs_struct.h
+++ b/include/linux/fs_struct.h
@@ -21,7 +21,6 @@ extern void set_fs_root(struct fs_struct *, struct path *);
21extern void set_fs_pwd(struct fs_struct *, struct path *); 21extern void set_fs_pwd(struct fs_struct *, struct path *);
22extern struct fs_struct *copy_fs_struct(struct fs_struct *); 22extern struct fs_struct *copy_fs_struct(struct fs_struct *);
23extern void free_fs_struct(struct fs_struct *); 23extern void free_fs_struct(struct fs_struct *);
24extern void daemonize_fs_struct(void);
25extern int unshare_fs_struct(void); 24extern int unshare_fs_struct(void);
26 25
27static inline void get_fs_root(struct fs_struct *fs, struct path *root) 26static inline void get_fs_root(struct fs_struct *fs, struct path *root)
diff --git a/include/linux/hashtable.h b/include/linux/hashtable.h
new file mode 100644
index 00000000000..227c62424f3
--- /dev/null
+++ b/include/linux/hashtable.h
@@ -0,0 +1,192 @@
1/*
2 * Statically sized hash table implementation
3 * (C) 2012 Sasha Levin <levinsasha928@gmail.com>
4 */
5
6#ifndef _LINUX_HASHTABLE_H
7#define _LINUX_HASHTABLE_H
8
9#include <linux/list.h>
10#include <linux/types.h>
11#include <linux/kernel.h>
12#include <linux/hash.h>
13#include <linux/rculist.h>
14
15#define DEFINE_HASHTABLE(name, bits) \
16 struct hlist_head name[1 << (bits)] = \
17 { [0 ... ((1 << (bits)) - 1)] = HLIST_HEAD_INIT }
18
19#define DECLARE_HASHTABLE(name, bits) \
20 struct hlist_head name[1 << (bits)]
21
22#define HASH_SIZE(name) (ARRAY_SIZE(name))
23#define HASH_BITS(name) ilog2(HASH_SIZE(name))
24
25/* Use hash_32 when possible to allow for fast 32bit hashing in 64bit kernels. */
26#define hash_min(val, bits) \
27 (sizeof(val) <= 4 ? hash_32(val, bits) : hash_long(val, bits))
28
29static inline void __hash_init(struct hlist_head *ht, unsigned int sz)
30{
31 unsigned int i;
32
33 for (i = 0; i < sz; i++)
34 INIT_HLIST_HEAD(&ht[i]);
35}
36
37/**
38 * hash_init - initialize a hash table
39 * @hashtable: hashtable to be initialized
40 *
41 * Calculates the size of the hashtable from the given parameter, otherwise
42 * same as hash_init_size.
43 *
44 * This has to be a macro since HASH_BITS() will not work on pointers since
45 * it calculates the size during preprocessing.
46 */
47#define hash_init(hashtable) __hash_init(hashtable, HASH_SIZE(hashtable))
48
49/**
50 * hash_add - add an object to a hashtable
51 * @hashtable: hashtable to add to
52 * @node: the &struct hlist_node of the object to be added
53 * @key: the key of the object to be added
54 */
55#define hash_add(hashtable, node, key) \
56 hlist_add_head(node, &hashtable[hash_min(key, HASH_BITS(hashtable))])
57
58/**
59 * hash_add_rcu - add an object to a rcu enabled hashtable
60 * @hashtable: hashtable to add to
61 * @node: the &struct hlist_node of the object to be added
62 * @key: the key of the object to be added
63 */
64#define hash_add_rcu(hashtable, node, key) \
65 hlist_add_head_rcu(node, &hashtable[hash_min(key, HASH_BITS(hashtable))])
66
67/**
68 * hash_hashed - check whether an object is in any hashtable
69 * @node: the &struct hlist_node of the object to be checked
70 */
71static inline bool hash_hashed(struct hlist_node *node)
72{
73 return !hlist_unhashed(node);
74}
75
76static inline bool __hash_empty(struct hlist_head *ht, unsigned int sz)
77{
78 unsigned int i;
79
80 for (i = 0; i < sz; i++)
81 if (!hlist_empty(&ht[i]))
82 return false;
83
84 return true;
85}
86
87/**
88 * hash_empty - check whether a hashtable is empty
89 * @hashtable: hashtable to check
90 *
91 * This has to be a macro since HASH_BITS() will not work on pointers since
92 * it calculates the size during preprocessing.
93 */
94#define hash_empty(hashtable) __hash_empty(hashtable, HASH_SIZE(hashtable))
95
96/**
97 * hash_del - remove an object from a hashtable
98 * @node: &struct hlist_node of the object to remove
99 */
100static inline void hash_del(struct hlist_node *node)
101{
102 hlist_del_init(node);
103}
104
105/**
106 * hash_del_rcu - remove an object from a rcu enabled hashtable
107 * @node: &struct hlist_node of the object to remove
108 */
109static inline void hash_del_rcu(struct hlist_node *node)
110{
111 hlist_del_init_rcu(node);
112}
113
114/**
115 * hash_for_each - iterate over a hashtable
116 * @name: hashtable to iterate
117 * @bkt: integer to use as bucket loop cursor
118 * @node: the &struct list_head to use as a loop cursor for each entry
119 * @obj: the type * to use as a loop cursor for each entry
120 * @member: the name of the hlist_node within the struct
121 */
122#define hash_for_each(name, bkt, node, obj, member) \
123 for ((bkt) = 0, node = NULL; node == NULL && (bkt) < HASH_SIZE(name); (bkt)++)\
124 hlist_for_each_entry(obj, node, &name[bkt], member)
125
126/**
127 * hash_for_each_rcu - iterate over a rcu enabled hashtable
128 * @name: hashtable to iterate
129 * @bkt: integer to use as bucket loop cursor
130 * @node: the &struct list_head to use as a loop cursor for each entry
131 * @obj: the type * to use as a loop cursor for each entry
132 * @member: the name of the hlist_node within the struct
133 */
134#define hash_for_each_rcu(name, bkt, node, obj, member) \
135 for ((bkt) = 0, node = NULL; node == NULL && (bkt) < HASH_SIZE(name); (bkt)++)\
136 hlist_for_each_entry_rcu(obj, node, &name[bkt], member)
137
138/**
139 * hash_for_each_safe - iterate over a hashtable safe against removal of
140 * hash entry
141 * @name: hashtable to iterate
142 * @bkt: integer to use as bucket loop cursor
143 * @node: the &struct list_head to use as a loop cursor for each entry
144 * @tmp: a &struct used for temporary storage
145 * @obj: the type * to use as a loop cursor for each entry
146 * @member: the name of the hlist_node within the struct
147 */
148#define hash_for_each_safe(name, bkt, node, tmp, obj, member) \
149 for ((bkt) = 0, node = NULL; node == NULL && (bkt) < HASH_SIZE(name); (bkt)++)\
150 hlist_for_each_entry_safe(obj, node, tmp, &name[bkt], member)
151
152/**
153 * hash_for_each_possible - iterate over all possible objects hashing to the
154 * same bucket
155 * @name: hashtable to iterate
156 * @obj: the type * to use as a loop cursor for each entry
157 * @node: the &struct list_head to use as a loop cursor for each entry
158 * @member: the name of the hlist_node within the struct
159 * @key: the key of the objects to iterate over
160 */
161#define hash_for_each_possible(name, obj, node, member, key) \
162 hlist_for_each_entry(obj, node, &name[hash_min(key, HASH_BITS(name))], member)
163
164/**
165 * hash_for_each_possible_rcu - iterate over all possible objects hashing to the
166 * same bucket in an rcu enabled hashtable
167 * in a rcu enabled hashtable
168 * @name: hashtable to iterate
169 * @obj: the type * to use as a loop cursor for each entry
170 * @node: the &struct list_head to use as a loop cursor for each entry
171 * @member: the name of the hlist_node within the struct
172 * @key: the key of the objects to iterate over
173 */
174#define hash_for_each_possible_rcu(name, obj, node, member, key) \
175 hlist_for_each_entry_rcu(obj, node, &name[hash_min(key, HASH_BITS(name))], member)
176
177/**
178 * hash_for_each_possible_safe - iterate over all possible objects hashing to the
179 * same bucket safe against removals
180 * @name: hashtable to iterate
181 * @obj: the type * to use as a loop cursor for each entry
182 * @node: the &struct list_head to use as a loop cursor for each entry
183 * @tmp: a &struct used for temporary storage
184 * @member: the name of the hlist_node within the struct
185 * @key: the key of the objects to iterate over
186 */
187#define hash_for_each_possible_safe(name, obj, node, tmp, member, key) \
188 hlist_for_each_entry_safe(obj, node, tmp, \
189 &name[hash_min(key, HASH_BITS(name))], member)
190
191
192#endif
diff --git a/include/linux/hsi/Kbuild b/include/linux/hsi/Kbuild
index 271a770b478..e69de29bb2d 100644
--- a/include/linux/hsi/Kbuild
+++ b/include/linux/hsi/Kbuild
@@ -1 +0,0 @@
1header-y += hsi_char.h
diff --git a/include/linux/i2c-omap.h b/include/linux/i2c-omap.h
index df804ba73e0..92a0dc75bc7 100644
--- a/include/linux/i2c-omap.h
+++ b/include/linux/i2c-omap.h
@@ -34,6 +34,7 @@ struct omap_i2c_bus_platform_data {
34 u32 clkrate; 34 u32 clkrate;
35 u32 rev; 35 u32 rev;
36 u32 flags; 36 u32 flags;
37 void (*set_mpu_wkup_lat)(struct device *dev, long set);
37}; 38};
38 39
39#endif 40#endif
diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
index c0ae76ac4e0..7806c24e5bc 100644
--- a/include/linux/iio/iio.h
+++ b/include/linux/iio/iio.h
@@ -618,4 +618,20 @@ static inline struct dentry *iio_get_debugfs_dentry(struct iio_dev *indio_dev)
618}; 618};
619#endif 619#endif
620 620
621/**
622 * IIO_DEGREE_TO_RAD() - Convert degree to rad
623 * @deg: A value in degree
624 *
625 * Returns the given value converted from degree to rad
626 */
627#define IIO_DEGREE_TO_RAD(deg) (((deg) * 314159ULL + 9000000ULL) / 18000000ULL)
628
629/**
630 * IIO_G_TO_M_S_2() - Convert g to meter / second**2
631 * @g: A value in g
632 *
633 * Returns the given value converted from g to meter / second**2
634 */
635#define IIO_G_TO_M_S_2(g) ((g) * 980665ULL / 100000ULL)
636
621#endif /* _INDUSTRIAL_IO_H_ */ 637#endif /* _INDUSTRIAL_IO_H_ */
diff --git a/include/linux/isdn/Kbuild b/include/linux/isdn/Kbuild
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/include/linux/isdn/Kbuild
+++ /dev/null
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 93bfc9f9815..ecc554374e4 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -42,19 +42,8 @@
42 */ 42 */
43#define KVM_MEMSLOT_INVALID (1UL << 16) 43#define KVM_MEMSLOT_INVALID (1UL << 16)
44 44
45/* 45/* Two fragments for cross MMIO pages. */
46 * If we support unaligned MMIO, at most one fragment will be split into two: 46#define KVM_MAX_MMIO_FRAGMENTS 2
47 */
48#ifdef KVM_UNALIGNED_MMIO
49# define KVM_EXTRA_MMIO_FRAGMENTS 1
50#else
51# define KVM_EXTRA_MMIO_FRAGMENTS 0
52#endif
53
54#define KVM_USER_MMIO_SIZE 8
55
56#define KVM_MAX_MMIO_FRAGMENTS \
57 (KVM_MMIO_SIZE / KVM_USER_MMIO_SIZE + KVM_EXTRA_MMIO_FRAGMENTS)
58 47
59/* 48/*
60 * For the normal pfn, the highest 12 bits should be zero, 49 * For the normal pfn, the highest 12 bits should be zero,
diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index 569d67d4243..d452ee19106 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -57,6 +57,7 @@ int memblock_add(phys_addr_t base, phys_addr_t size);
57int memblock_remove(phys_addr_t base, phys_addr_t size); 57int memblock_remove(phys_addr_t base, phys_addr_t size);
58int memblock_free(phys_addr_t base, phys_addr_t size); 58int memblock_free(phys_addr_t base, phys_addr_t size);
59int memblock_reserve(phys_addr_t base, phys_addr_t size); 59int memblock_reserve(phys_addr_t base, phys_addr_t size);
60void memblock_trim_memory(phys_addr_t align);
60 61
61#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP 62#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
62void __next_mem_pfn_range(int *idx, int nid, unsigned long *out_start_pfn, 63void __next_mem_pfn_range(int *idx, int nid, unsigned long *out_start_pfn,
diff --git a/include/linux/mfd/max77693.h b/include/linux/mfd/max77693.h
index 1d28ae90384..fe03b2d35d4 100644
--- a/include/linux/mfd/max77693.h
+++ b/include/linux/mfd/max77693.h
@@ -30,7 +30,20 @@
30#ifndef __LINUX_MFD_MAX77693_H 30#ifndef __LINUX_MFD_MAX77693_H
31#define __LINUX_MFD_MAX77693_H 31#define __LINUX_MFD_MAX77693_H
32 32
33struct max77693_reg_data {
34 u8 addr;
35 u8 data;
36};
37
38struct max77693_muic_platform_data {
39 struct max77693_reg_data *init_data;
40 int num_init_data;
41};
42
33struct max77693_platform_data { 43struct max77693_platform_data {
34 int wakeup; 44 int wakeup;
45
46 /* muic data */
47 struct max77693_muic_platform_data *muic_data;
35}; 48};
36#endif /* __LINUX_MFD_MAX77693_H */ 49#endif /* __LINUX_MFD_MAX77693_H */
diff --git a/include/linux/mm.h b/include/linux/mm.h
index fa068040273..bcaab4e6fe9 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1684,9 +1684,5 @@ static inline unsigned int debug_guardpage_minorder(void) { return 0; }
1684static inline bool page_is_guard(struct page *page) { return false; } 1684static inline bool page_is_guard(struct page *page) { return false; }
1685#endif /* CONFIG_DEBUG_PAGEALLOC */ 1685#endif /* CONFIG_DEBUG_PAGEALLOC */
1686 1686
1687extern void reset_zone_present_pages(void);
1688extern void fixup_zone_present_pages(int nid, unsigned long start_pfn,
1689 unsigned long end_pfn);
1690
1691#endif /* __KERNEL__ */ 1687#endif /* __KERNEL__ */
1692#endif /* _LINUX_MM_H */ 1688#endif /* _LINUX_MM_H */
diff --git a/include/linux/mmc/Kbuild b/include/linux/mmc/Kbuild
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/include/linux/mmc/Kbuild
+++ /dev/null
diff --git a/include/linux/mmc/dw_mmc.h b/include/linux/mmc/dw_mmc.h
index 7c6a1139d8f..96531664a06 100644
--- a/include/linux/mmc/dw_mmc.h
+++ b/include/linux/mmc/dw_mmc.h
@@ -137,7 +137,7 @@ struct dw_mci {
137 137
138 dma_addr_t sg_dma; 138 dma_addr_t sg_dma;
139 void *sg_cpu; 139 void *sg_cpu;
140 struct dw_mci_dma_ops *dma_ops; 140 const struct dw_mci_dma_ops *dma_ops;
141#ifdef CONFIG_MMC_DW_IDMAC 141#ifdef CONFIG_MMC_DW_IDMAC
142 unsigned int ring_size; 142 unsigned int ring_size;
143#else 143#else
@@ -162,7 +162,7 @@ struct dw_mci {
162 u16 data_offset; 162 u16 data_offset;
163 struct device *dev; 163 struct device *dev;
164 struct dw_mci_board *pdata; 164 struct dw_mci_board *pdata;
165 struct dw_mci_drv_data *drv_data; 165 const struct dw_mci_drv_data *drv_data;
166 void *priv; 166 void *priv;
167 struct clk *biu_clk; 167 struct clk *biu_clk;
168 struct clk *ciu_clk; 168 struct clk *ciu_clk;
@@ -186,7 +186,7 @@ struct dw_mci {
186 186
187 struct regulator *vmmc; /* Power regulator */ 187 struct regulator *vmmc; /* Power regulator */
188 unsigned long irq_flags; /* IRQ flags */ 188 unsigned long irq_flags; /* IRQ flags */
189 unsigned int irq; 189 int irq;
190}; 190};
191 191
192/* DMA ops for Internal/External DMAC interface */ 192/* DMA ops for Internal/External DMAC interface */
diff --git a/include/linux/mmc/sdhci.h b/include/linux/mmc/sdhci.h
index fa8529a859b..1edcb4dad8c 100644
--- a/include/linux/mmc/sdhci.h
+++ b/include/linux/mmc/sdhci.h
@@ -91,6 +91,7 @@ struct sdhci_host {
91 unsigned int quirks2; /* More deviations from spec. */ 91 unsigned int quirks2; /* More deviations from spec. */
92 92
93#define SDHCI_QUIRK2_HOST_OFF_CARD_ON (1<<0) 93#define SDHCI_QUIRK2_HOST_OFF_CARD_ON (1<<0)
94#define SDHCI_QUIRK2_HOST_NO_CMD23 (1<<1)
94 95
95 int irq; /* Device IRQ */ 96 int irq; /* Device IRQ */
96 void __iomem *ioaddr; /* Mapped address */ 97 void __iomem *ioaddr; /* Mapped address */
diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
index 50aaca81f63..a23923ba826 100644
--- a/include/linux/mmzone.h
+++ b/include/linux/mmzone.h
@@ -752,7 +752,7 @@ extern int init_currently_empty_zone(struct zone *zone, unsigned long start_pfn,
752 unsigned long size, 752 unsigned long size,
753 enum memmap_context context); 753 enum memmap_context context);
754 754
755extern void lruvec_init(struct lruvec *lruvec, struct zone *zone); 755extern void lruvec_init(struct lruvec *lruvec);
756 756
757static inline struct zone *lruvec_zone(struct lruvec *lruvec) 757static inline struct zone *lruvec_zone(struct lruvec *lruvec)
758{ 758{
diff --git a/include/linux/netfilter/Kbuild b/include/linux/netfilter/Kbuild
deleted file mode 100644
index b3322023e9a..00000000000
--- a/include/linux/netfilter/Kbuild
+++ /dev/null
@@ -1 +0,0 @@
1header-y += ipset/
diff --git a/include/linux/netfilter/ipset/Kbuild b/include/linux/netfilter/ipset/Kbuild
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/include/linux/netfilter/ipset/Kbuild
+++ /dev/null
diff --git a/include/linux/netfilter_arp/Kbuild b/include/linux/netfilter_arp/Kbuild
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/include/linux/netfilter_arp/Kbuild
+++ /dev/null
diff --git a/include/linux/netfilter_bridge/Kbuild b/include/linux/netfilter_bridge/Kbuild
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/include/linux/netfilter_bridge/Kbuild
+++ /dev/null
diff --git a/include/linux/netfilter_ipv4/Kbuild b/include/linux/netfilter_ipv4/Kbuild
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/include/linux/netfilter_ipv4/Kbuild
+++ /dev/null
diff --git a/include/linux/netfilter_ipv6/Kbuild b/include/linux/netfilter_ipv6/Kbuild
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/include/linux/netfilter_ipv6/Kbuild
+++ /dev/null
diff --git a/include/linux/nfsd/Kbuild b/include/linux/nfsd/Kbuild
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/include/linux/nfsd/Kbuild
+++ /dev/null
diff --git a/include/linux/of.h b/include/linux/of.h
index 72843b72a2b..b4e50d56fc7 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -331,6 +331,13 @@ static inline bool of_have_populated_dt(void)
331#define for_each_child_of_node(parent, child) \ 331#define for_each_child_of_node(parent, child) \
332 while (0) 332 while (0)
333 333
334static inline struct device_node *of_get_child_by_name(
335 const struct device_node *node,
336 const char *name)
337{
338 return NULL;
339}
340
334static inline int of_get_child_count(const struct device_node *np) 341static inline int of_get_child_count(const struct device_node *np)
335{ 342{
336 return 0; 343 return 0;
diff --git a/include/linux/of_address.h b/include/linux/of_address.h
index c3cdc1025c3..0506eb53519 100644
--- a/include/linux/of_address.h
+++ b/include/linux/of_address.h
@@ -19,7 +19,7 @@ extern void __iomem *of_iomap(struct device_node *device, int index);
19 * the address space flags too. The PCI version uses a BAR number 19 * the address space flags too. The PCI version uses a BAR number
20 * instead of an absolute index 20 * instead of an absolute index
21 */ 21 */
22extern const u32 *of_get_address(struct device_node *dev, int index, 22extern const __be32 *of_get_address(struct device_node *dev, int index,
23 u64 *size, unsigned int *flags); 23 u64 *size, unsigned int *flags);
24 24
25#ifndef pci_address_to_pio 25#ifndef pci_address_to_pio
@@ -28,11 +28,13 @@ static inline unsigned long pci_address_to_pio(phys_addr_t addr) { return -1; }
28#endif 28#endif
29 29
30#else /* CONFIG_OF_ADDRESS */ 30#else /* CONFIG_OF_ADDRESS */
31#ifndef of_address_to_resource
31static inline int of_address_to_resource(struct device_node *dev, int index, 32static inline int of_address_to_resource(struct device_node *dev, int index,
32 struct resource *r) 33 struct resource *r)
33{ 34{
34 return -EINVAL; 35 return -EINVAL;
35} 36}
37#endif
36static inline struct device_node *of_find_matching_node_by_address( 38static inline struct device_node *of_find_matching_node_by_address(
37 struct device_node *from, 39 struct device_node *from,
38 const struct of_device_id *matches, 40 const struct of_device_id *matches,
@@ -40,11 +42,13 @@ static inline struct device_node *of_find_matching_node_by_address(
40{ 42{
41 return NULL; 43 return NULL;
42} 44}
45#ifndef of_iomap
43static inline void __iomem *of_iomap(struct device_node *device, int index) 46static inline void __iomem *of_iomap(struct device_node *device, int index)
44{ 47{
45 return NULL; 48 return NULL;
46} 49}
47static inline const u32 *of_get_address(struct device_node *dev, int index, 50#endif
51static inline const __be32 *of_get_address(struct device_node *dev, int index,
48 u64 *size, unsigned int *flags) 52 u64 *size, unsigned int *flags)
49{ 53{
50 return NULL; 54 return NULL;
diff --git a/include/linux/of_irq.h b/include/linux/of_irq.h
index b8e24112520..535cecf1e02 100644
--- a/include/linux/of_irq.h
+++ b/include/linux/of_irq.h
@@ -58,8 +58,8 @@ static inline int of_irq_map_oldworld(struct device_node *device, int index,
58#endif /* CONFIG_PPC32 && CONFIG_PPC_PMAC */ 58#endif /* CONFIG_PPC32 && CONFIG_PPC_PMAC */
59 59
60 60
61extern int of_irq_map_raw(struct device_node *parent, const u32 *intspec, 61extern int of_irq_map_raw(struct device_node *parent, const __be32 *intspec,
62 u32 ointsize, const u32 *addr, 62 u32 ointsize, const __be32 *addr,
63 struct of_irq *out_irq); 63 struct of_irq *out_irq);
64extern int of_irq_map_one(struct device_node *device, int index, 64extern int of_irq_map_one(struct device_node *device, int index,
65 struct of_irq *out_irq); 65 struct of_irq *out_irq);
diff --git a/include/linux/percpu-rwsem.h b/include/linux/percpu-rwsem.h
index cf80f7e5277..250a4acddb2 100644
--- a/include/linux/percpu-rwsem.h
+++ b/include/linux/percpu-rwsem.h
@@ -12,34 +12,27 @@ struct percpu_rw_semaphore {
12 struct mutex mtx; 12 struct mutex mtx;
13}; 13};
14 14
15#define light_mb() barrier()
16#define heavy_mb() synchronize_sched()
17
15static inline void percpu_down_read(struct percpu_rw_semaphore *p) 18static inline void percpu_down_read(struct percpu_rw_semaphore *p)
16{ 19{
17 rcu_read_lock(); 20 rcu_read_lock_sched();
18 if (unlikely(p->locked)) { 21 if (unlikely(p->locked)) {
19 rcu_read_unlock(); 22 rcu_read_unlock_sched();
20 mutex_lock(&p->mtx); 23 mutex_lock(&p->mtx);
21 this_cpu_inc(*p->counters); 24 this_cpu_inc(*p->counters);
22 mutex_unlock(&p->mtx); 25 mutex_unlock(&p->mtx);
23 return; 26 return;
24 } 27 }
25 this_cpu_inc(*p->counters); 28 this_cpu_inc(*p->counters);
26 rcu_read_unlock(); 29 rcu_read_unlock_sched();
30 light_mb(); /* A, between read of p->locked and read of data, paired with D */
27} 31}
28 32
29static inline void percpu_up_read(struct percpu_rw_semaphore *p) 33static inline void percpu_up_read(struct percpu_rw_semaphore *p)
30{ 34{
31 /* 35 light_mb(); /* B, between read of the data and write to p->counter, paired with C */
32 * On X86, write operation in this_cpu_dec serves as a memory unlock
33 * barrier (i.e. memory accesses may be moved before the write, but
34 * no memory accesses are moved past the write).
35 * On other architectures this may not be the case, so we need smp_mb()
36 * there.
37 */
38#if defined(CONFIG_X86) && (!defined(CONFIG_X86_PPRO_FENCE) && !defined(CONFIG_X86_OOSTORE))
39 barrier();
40#else
41 smp_mb();
42#endif
43 this_cpu_dec(*p->counters); 36 this_cpu_dec(*p->counters);
44} 37}
45 38
@@ -58,14 +51,15 @@ static inline void percpu_down_write(struct percpu_rw_semaphore *p)
58{ 51{
59 mutex_lock(&p->mtx); 52 mutex_lock(&p->mtx);
60 p->locked = true; 53 p->locked = true;
61 synchronize_rcu(); 54 synchronize_sched(); /* make sure that all readers exit the rcu_read_lock_sched region */
62 while (__percpu_count(p->counters)) 55 while (__percpu_count(p->counters))
63 msleep(1); 56 msleep(1);
64 smp_rmb(); /* paired with smp_mb() in percpu_sem_up_read() */ 57 heavy_mb(); /* C, between read of p->counter and write to data, paired with B */
65} 58}
66 59
67static inline void percpu_up_write(struct percpu_rw_semaphore *p) 60static inline void percpu_up_write(struct percpu_rw_semaphore *p)
68{ 61{
62 heavy_mb(); /* D, between write to data and write to p->locked, paired with A */
69 p->locked = false; 63 p->locked = false;
70 mutex_unlock(&p->mtx); 64 mutex_unlock(&p->mtx);
71} 65}
diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 2e902359aee..6bfb2faa0b1 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -803,12 +803,16 @@ static inline void perf_event_task_tick(void) { }
803do { \ 803do { \
804 static struct notifier_block fn##_nb __cpuinitdata = \ 804 static struct notifier_block fn##_nb __cpuinitdata = \
805 { .notifier_call = fn, .priority = CPU_PRI_PERF }; \ 805 { .notifier_call = fn, .priority = CPU_PRI_PERF }; \
806 unsigned long cpu = smp_processor_id(); \
807 unsigned long flags; \
806 fn(&fn##_nb, (unsigned long)CPU_UP_PREPARE, \ 808 fn(&fn##_nb, (unsigned long)CPU_UP_PREPARE, \
807 (void *)(unsigned long)smp_processor_id()); \ 809 (void *)(unsigned long)cpu); \
810 local_irq_save(flags); \
808 fn(&fn##_nb, (unsigned long)CPU_STARTING, \ 811 fn(&fn##_nb, (unsigned long)CPU_STARTING, \
809 (void *)(unsigned long)smp_processor_id()); \ 812 (void *)(unsigned long)cpu); \
813 local_irq_restore(flags); \
810 fn(&fn##_nb, (unsigned long)CPU_ONLINE, \ 814 fn(&fn##_nb, (unsigned long)CPU_ONLINE, \
811 (void *)(unsigned long)smp_processor_id()); \ 815 (void *)(unsigned long)cpu); \
812 register_cpu_notifier(&fn##_nb); \ 816 register_cpu_notifier(&fn##_nb); \
813} while (0) 817} while (0)
814 818
diff --git a/include/linux/pid_namespace.h b/include/linux/pid_namespace.h
index 00474b04714..65e3e87eacc 100644
--- a/include/linux/pid_namespace.h
+++ b/include/linux/pid_namespace.h
@@ -47,15 +47,9 @@ static inline struct pid_namespace *get_pid_ns(struct pid_namespace *ns)
47} 47}
48 48
49extern struct pid_namespace *copy_pid_ns(unsigned long flags, struct pid_namespace *ns); 49extern struct pid_namespace *copy_pid_ns(unsigned long flags, struct pid_namespace *ns);
50extern void free_pid_ns(struct kref *kref);
51extern void zap_pid_ns_processes(struct pid_namespace *pid_ns); 50extern void zap_pid_ns_processes(struct pid_namespace *pid_ns);
52extern int reboot_pid_ns(struct pid_namespace *pid_ns, int cmd); 51extern int reboot_pid_ns(struct pid_namespace *pid_ns, int cmd);
53 52extern void put_pid_ns(struct pid_namespace *ns);
54static inline void put_pid_ns(struct pid_namespace *ns)
55{
56 if (ns != &init_pid_ns)
57 kref_put(&ns->kref, free_pid_ns);
58}
59 53
60#else /* !CONFIG_PID_NS */ 54#else /* !CONFIG_PID_NS */
61#include <linux/err.h> 55#include <linux/err.h>
diff --git a/include/linux/platform_data/omap_ocp2scp.h b/include/linux/platform_data/omap_ocp2scp.h
new file mode 100644
index 00000000000..5c6c3939355
--- /dev/null
+++ b/include/linux/platform_data/omap_ocp2scp.h
@@ -0,0 +1,31 @@
1/*
2 * omap_ocp2scp.h -- ocp2scp header file
3 *
4 * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * Author: Kishon Vijay Abraham I <kishon@ti.com>
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 */
18
19#ifndef __DRIVERS_OMAP_OCP2SCP_H
20#define __DRIVERS_OMAP_OCP2SCP_H
21
22struct omap_ocp2scp_dev {
23 const char *drv_name;
24 struct resource *res;
25};
26
27struct omap_ocp2scp_platform_data {
28 int dev_cnt;
29 struct omap_ocp2scp_dev **devices;
30};
31#endif /* __DRIVERS_OMAP_OCP2SCP_H */
diff --git a/include/linux/ptp_clock_kernel.h b/include/linux/ptp_clock_kernel.h
index f2dc6d8fc68..38a99350832 100644
--- a/include/linux/ptp_clock_kernel.h
+++ b/include/linux/ptp_clock_kernel.h
@@ -54,7 +54,8 @@ struct ptp_clock_request {
54 * clock operations 54 * clock operations
55 * 55 *
56 * @adjfreq: Adjusts the frequency of the hardware clock. 56 * @adjfreq: Adjusts the frequency of the hardware clock.
57 * parameter delta: Desired period change in parts per billion. 57 * parameter delta: Desired frequency offset from nominal frequency
58 * in parts per billion
58 * 59 *
59 * @adjtime: Shifts the time of the hardware clock. 60 * @adjtime: Shifts the time of the hardware clock.
60 * parameter delta: Desired change in nanoseconds. 61 * parameter delta: Desired change in nanoseconds.
diff --git a/include/linux/raid/Kbuild b/include/linux/raid/Kbuild
index 2415a64c5e5..e69de29bb2d 100644
--- a/include/linux/raid/Kbuild
+++ b/include/linux/raid/Kbuild
@@ -1,2 +0,0 @@
1header-y += md_p.h
2header-y += md_u.h
diff --git a/include/linux/raid/md_u.h b/include/linux/raid/md_u.h
index fb1abb3367e..358c04bfbe2 100644
--- a/include/linux/raid/md_u.h
+++ b/include/linux/raid/md_u.h
@@ -11,149 +11,10 @@
11 (for example /usr/src/linux/COPYING); if not, write to the Free 11 (for example /usr/src/linux/COPYING); if not, write to the Free
12 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 12 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
13*/ 13*/
14
15#ifndef _MD_U_H 14#ifndef _MD_U_H
16#define _MD_U_H 15#define _MD_U_H
17 16
18/* 17#include <uapi/linux/raid/md_u.h>
19 * Different major versions are not compatible.
20 * Different minor versions are only downward compatible.
21 * Different patchlevel versions are downward and upward compatible.
22 */
23#define MD_MAJOR_VERSION 0
24#define MD_MINOR_VERSION 90
25/*
26 * MD_PATCHLEVEL_VERSION indicates kernel functionality.
27 * >=1 means different superblock formats are selectable using SET_ARRAY_INFO
28 * and major_version/minor_version accordingly
29 * >=2 means that Internal bitmaps are supported by setting MD_SB_BITMAP_PRESENT
30 * in the super status byte
31 * >=3 means that bitmap superblock version 4 is supported, which uses
32 * little-ending representation rather than host-endian
33 */
34#define MD_PATCHLEVEL_VERSION 3
35
36/* ioctls */
37
38/* status */
39#define RAID_VERSION _IOR (MD_MAJOR, 0x10, mdu_version_t)
40#define GET_ARRAY_INFO _IOR (MD_MAJOR, 0x11, mdu_array_info_t)
41#define GET_DISK_INFO _IOR (MD_MAJOR, 0x12, mdu_disk_info_t)
42#define PRINT_RAID_DEBUG _IO (MD_MAJOR, 0x13)
43#define RAID_AUTORUN _IO (MD_MAJOR, 0x14)
44#define GET_BITMAP_FILE _IOR (MD_MAJOR, 0x15, mdu_bitmap_file_t)
45
46/* configuration */
47#define CLEAR_ARRAY _IO (MD_MAJOR, 0x20)
48#define ADD_NEW_DISK _IOW (MD_MAJOR, 0x21, mdu_disk_info_t)
49#define HOT_REMOVE_DISK _IO (MD_MAJOR, 0x22)
50#define SET_ARRAY_INFO _IOW (MD_MAJOR, 0x23, mdu_array_info_t)
51#define SET_DISK_INFO _IO (MD_MAJOR, 0x24)
52#define WRITE_RAID_INFO _IO (MD_MAJOR, 0x25)
53#define UNPROTECT_ARRAY _IO (MD_MAJOR, 0x26)
54#define PROTECT_ARRAY _IO (MD_MAJOR, 0x27)
55#define HOT_ADD_DISK _IO (MD_MAJOR, 0x28)
56#define SET_DISK_FAULTY _IO (MD_MAJOR, 0x29)
57#define HOT_GENERATE_ERROR _IO (MD_MAJOR, 0x2a)
58#define SET_BITMAP_FILE _IOW (MD_MAJOR, 0x2b, int)
59 18
60/* usage */
61#define RUN_ARRAY _IOW (MD_MAJOR, 0x30, mdu_param_t)
62/* 0x31 was START_ARRAY */
63#define STOP_ARRAY _IO (MD_MAJOR, 0x32)
64#define STOP_ARRAY_RO _IO (MD_MAJOR, 0x33)
65#define RESTART_ARRAY_RW _IO (MD_MAJOR, 0x34)
66
67/* 63 partitions with the alternate major number (mdp) */
68#define MdpMinorShift 6
69#ifdef __KERNEL__
70extern int mdp_major; 19extern int mdp_major;
71#endif
72
73typedef struct mdu_version_s {
74 int major;
75 int minor;
76 int patchlevel;
77} mdu_version_t;
78
79typedef struct mdu_array_info_s {
80 /*
81 * Generic constant information
82 */
83 int major_version;
84 int minor_version;
85 int patch_version;
86 int ctime;
87 int level;
88 int size;
89 int nr_disks;
90 int raid_disks;
91 int md_minor;
92 int not_persistent;
93
94 /*
95 * Generic state information
96 */
97 int utime; /* 0 Superblock update time */
98 int state; /* 1 State bits (clean, ...) */
99 int active_disks; /* 2 Number of currently active disks */
100 int working_disks; /* 3 Number of working disks */
101 int failed_disks; /* 4 Number of failed disks */
102 int spare_disks; /* 5 Number of spare disks */
103
104 /*
105 * Personality information
106 */
107 int layout; /* 0 the array's physical layout */
108 int chunk_size; /* 1 chunk size in bytes */
109
110} mdu_array_info_t;
111
112/* non-obvious values for 'level' */
113#define LEVEL_MULTIPATH (-4)
114#define LEVEL_LINEAR (-1)
115#define LEVEL_FAULTY (-5)
116
117/* we need a value for 'no level specified' and 0
118 * means 'raid0', so we need something else. This is
119 * for internal use only
120 */
121#define LEVEL_NONE (-1000000)
122
123typedef struct mdu_disk_info_s {
124 /*
125 * configuration/status of one particular disk
126 */
127 int number;
128 int major;
129 int minor;
130 int raid_disk;
131 int state;
132
133} mdu_disk_info_t;
134
135typedef struct mdu_start_info_s {
136 /*
137 * configuration/status of one particular disk
138 */
139 int major;
140 int minor;
141 int raid_disk;
142 int state;
143
144} mdu_start_info_t;
145
146typedef struct mdu_bitmap_file_s
147{
148 char pathname[4096];
149} mdu_bitmap_file_t;
150
151typedef struct mdu_param_s
152{
153 int personality; /* 1,2,3,4 */
154 int chunk_size; /* in bytes */
155 int max_fault; /* unused for now */
156} mdu_param_t;
157
158#endif 20#endif
159
diff --git a/include/linux/ratelimit.h b/include/linux/ratelimit.h
index e11ccb4cf48..0a260d8a18b 100644
--- a/include/linux/ratelimit.h
+++ b/include/linux/ratelimit.h
@@ -46,20 +46,17 @@ extern int ___ratelimit(struct ratelimit_state *rs, const char *func);
46#define WARN_ON_RATELIMIT(condition, state) \ 46#define WARN_ON_RATELIMIT(condition, state) \
47 WARN_ON((condition) && __ratelimit(state)) 47 WARN_ON((condition) && __ratelimit(state))
48 48
49#define __WARN_RATELIMIT(condition, state, format...) \ 49#define WARN_RATELIMIT(condition, format, ...) \
50({ \
51 int rtn = 0; \
52 if (unlikely(__ratelimit(state))) \
53 rtn = WARN(condition, format); \
54 rtn; \
55})
56
57#define WARN_RATELIMIT(condition, format...) \
58({ \ 50({ \
59 static DEFINE_RATELIMIT_STATE(_rs, \ 51 static DEFINE_RATELIMIT_STATE(_rs, \
60 DEFAULT_RATELIMIT_INTERVAL, \ 52 DEFAULT_RATELIMIT_INTERVAL, \
61 DEFAULT_RATELIMIT_BURST); \ 53 DEFAULT_RATELIMIT_BURST); \
62 __WARN_RATELIMIT(condition, &_rs, format); \ 54 int rtn = !!(condition); \
55 \
56 if (unlikely(rtn && __ratelimit(&_rs))) \
57 WARN(rtn, format, ##__VA_ARGS__); \
58 \
59 rtn; \
63}) 60})
64 61
65#else 62#else
@@ -67,15 +64,9 @@ extern int ___ratelimit(struct ratelimit_state *rs, const char *func);
67#define WARN_ON_RATELIMIT(condition, state) \ 64#define WARN_ON_RATELIMIT(condition, state) \
68 WARN_ON(condition) 65 WARN_ON(condition)
69 66
70#define __WARN_RATELIMIT(condition, state, format...) \ 67#define WARN_RATELIMIT(condition, format, ...) \
71({ \
72 int rtn = WARN(condition, format); \
73 rtn; \
74})
75
76#define WARN_RATELIMIT(condition, format...) \
77({ \ 68({ \
78 int rtn = WARN(condition, format); \ 69 int rtn = WARN(condition, format, ##__VA_ARGS__); \
79 rtn; \ 70 rtn; \
80}) 71})
81 72
diff --git a/include/linux/rbtree_augmented.h b/include/linux/rbtree_augmented.h
index 214caa33433..2ac60c9cf64 100644
--- a/include/linux/rbtree_augmented.h
+++ b/include/linux/rbtree_augmented.h
@@ -24,6 +24,7 @@
24#ifndef _LINUX_RBTREE_AUGMENTED_H 24#ifndef _LINUX_RBTREE_AUGMENTED_H
25#define _LINUX_RBTREE_AUGMENTED_H 25#define _LINUX_RBTREE_AUGMENTED_H
26 26
27#include <linux/compiler.h>
27#include <linux/rbtree.h> 28#include <linux/rbtree.h>
28 29
29/* 30/*
diff --git a/include/linux/rio.h b/include/linux/rio.h
index 4187da51100..a3e78427866 100644
--- a/include/linux/rio.h
+++ b/include/linux/rio.h
@@ -275,9 +275,11 @@ struct rio_id_table {
275 * struct rio_net - RIO network info 275 * struct rio_net - RIO network info
276 * @node: Node in global list of RIO networks 276 * @node: Node in global list of RIO networks
277 * @devices: List of devices in this network 277 * @devices: List of devices in this network
278 * @switches: List of switches in this netowrk
278 * @mports: List of master ports accessing this network 279 * @mports: List of master ports accessing this network
279 * @hport: Default port for accessing this network 280 * @hport: Default port for accessing this network
280 * @id: RIO network ID 281 * @id: RIO network ID
282 * @destid_table: destID allocation table
281 */ 283 */
282struct rio_net { 284struct rio_net {
283 struct list_head node; /* node in list of networks */ 285 struct list_head node; /* node in list of networks */
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 0dd42a02df2..a0166481eb2 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -2283,7 +2283,6 @@ extern void flush_itimer_signals(void);
2283 2283
2284extern void do_group_exit(int); 2284extern void do_group_exit(int);
2285 2285
2286extern void daemonize(const char *, ...);
2287extern int allow_signal(int); 2286extern int allow_signal(int);
2288extern int disallow_signal(int); 2287extern int disallow_signal(int);
2289 2288
diff --git a/include/linux/spi/Kbuild b/include/linux/spi/Kbuild
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/include/linux/spi/Kbuild
+++ /dev/null
diff --git a/include/linux/spi/ads7846.h b/include/linux/spi/ads7846.h
index c64de9dd763..2f694f3846a 100644
--- a/include/linux/spi/ads7846.h
+++ b/include/linux/spi/ads7846.h
@@ -46,8 +46,9 @@ struct ads7846_platform_data {
46 u16 debounce_rep; /* additional consecutive good readings 46 u16 debounce_rep; /* additional consecutive good readings
47 * required after the first two */ 47 * required after the first two */
48 int gpio_pendown; /* the GPIO used to decide the pendown 48 int gpio_pendown; /* the GPIO used to decide the pendown
49 * state if get_pendown_state == NULL 49 * state if get_pendown_state == NULL */
50 */ 50 int gpio_pendown_debounce; /* platform specific debounce time for
51 * the gpio_pendown */
51 int (*get_pendown_state)(void); 52 int (*get_pendown_state)(void);
52 int (*filter_init) (const struct ads7846_platform_data *pdata, 53 int (*filter_init) (const struct ads7846_platform_data *pdata,
53 void **filter_data); 54 void **filter_data);
diff --git a/include/linux/spi/tsc2005.h b/include/linux/spi/tsc2005.h
index d9b0c84220c..8f721e465e0 100644
--- a/include/linux/spi/tsc2005.h
+++ b/include/linux/spi/tsc2005.h
@@ -3,8 +3,6 @@
3 * 3 *
4 * Copyright (C) 2009-2010 Nokia Corporation 4 * Copyright (C) 2009-2010 Nokia Corporation
5 * 5 *
6 * Contact: Aaro Koskinen <aaro.koskinen@nokia.com>
7 *
8 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or 8 * the Free Software Foundation; either version 2 of the License, or
diff --git a/include/linux/sunrpc/Kbuild b/include/linux/sunrpc/Kbuild
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/include/linux/sunrpc/Kbuild
+++ /dev/null
diff --git a/include/linux/tc_act/Kbuild b/include/linux/tc_act/Kbuild
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/include/linux/tc_act/Kbuild
+++ /dev/null
diff --git a/include/linux/tc_ematch/Kbuild b/include/linux/tc_ematch/Kbuild
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/include/linux/tc_ematch/Kbuild
+++ /dev/null
diff --git a/include/linux/tcp.h b/include/linux/tcp.h
index 8a7fc4be2d7..60b7aac15e0 100644
--- a/include/linux/tcp.h
+++ b/include/linux/tcp.h
@@ -191,7 +191,8 @@ struct tcp_sock {
191 u8 do_early_retrans:1,/* Enable RFC5827 early-retransmit */ 191 u8 do_early_retrans:1,/* Enable RFC5827 early-retransmit */
192 early_retrans_delayed:1, /* Delayed ER timer installed */ 192 early_retrans_delayed:1, /* Delayed ER timer installed */
193 syn_data:1, /* SYN includes data */ 193 syn_data:1, /* SYN includes data */
194 syn_fastopen:1; /* SYN includes Fast Open option */ 194 syn_fastopen:1, /* SYN includes Fast Open option */
195 syn_data_acked:1;/* data in SYN is acked by SYN-ACK */
195 196
196/* RTT measurement */ 197/* RTT measurement */
197 u32 srtt; /* smoothed round trip time << 3 */ 198 u32 srtt; /* smoothed round trip time << 3 */
diff --git a/include/linux/uprobes.h b/include/linux/uprobes.h
index e6f0331e3d4..24594571c5a 100644
--- a/include/linux/uprobes.h
+++ b/include/linux/uprobes.h
@@ -35,16 +35,6 @@ struct inode;
35# include <asm/uprobes.h> 35# include <asm/uprobes.h>
36#endif 36#endif
37 37
38/* flags that denote/change uprobes behaviour */
39
40/* Have a copy of original instruction */
41#define UPROBE_COPY_INSN 0x1
42
43/* Dont run handlers when first register/ last unregister in progress*/
44#define UPROBE_RUN_HANDLER 0x2
45/* Can skip singlestep */
46#define UPROBE_SKIP_SSTEP 0x4
47
48struct uprobe_consumer { 38struct uprobe_consumer {
49 int (*handler)(struct uprobe_consumer *self, struct pt_regs *regs); 39 int (*handler)(struct uprobe_consumer *self, struct pt_regs *regs);
50 /* 40 /*
@@ -59,7 +49,6 @@ struct uprobe_consumer {
59#ifdef CONFIG_UPROBES 49#ifdef CONFIG_UPROBES
60enum uprobe_task_state { 50enum uprobe_task_state {
61 UTASK_RUNNING, 51 UTASK_RUNNING,
62 UTASK_BP_HIT,
63 UTASK_SSTEP, 52 UTASK_SSTEP,
64 UTASK_SSTEP_ACK, 53 UTASK_SSTEP_ACK,
65 UTASK_SSTEP_TRAPPED, 54 UTASK_SSTEP_TRAPPED,
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 07915a32fb9..10278d18709 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -1778,17 +1778,6 @@ static inline int usb_translate_errors(int error_code)
1778extern void usb_register_notify(struct notifier_block *nb); 1778extern void usb_register_notify(struct notifier_block *nb);
1779extern void usb_unregister_notify(struct notifier_block *nb); 1779extern void usb_unregister_notify(struct notifier_block *nb);
1780 1780
1781#ifdef DEBUG
1782#define dbg(format, arg...) \
1783 printk(KERN_DEBUG "%s: " format "\n", __FILE__, ##arg)
1784#else
1785#define dbg(format, arg...) \
1786do { \
1787 if (0) \
1788 printk(KERN_DEBUG "%s: " format "\n", __FILE__, ##arg); \
1789} while (0)
1790#endif
1791
1792/* debugfs stuff */ 1781/* debugfs stuff */
1793extern struct dentry *usb_debug_root; 1782extern struct dentry *usb_debug_root;
1794 1783
diff --git a/include/linux/usb/Kbuild b/include/linux/usb/Kbuild
index b607f3532e8..e69de29bb2d 100644
--- a/include/linux/usb/Kbuild
+++ b/include/linux/usb/Kbuild
@@ -1,10 +0,0 @@
1header-y += audio.h
2header-y += cdc.h
3header-y += ch9.h
4header-y += ch11.h
5header-y += functionfs.h
6header-y += gadgetfs.h
7header-y += midi.h
8header-y += g_printer.h
9header-y += tmc.h
10header-y += video.h
diff --git a/include/linux/usb/audio.h b/include/linux/usb/audio.h
index a54b8255d75..3d84619110a 100644
--- a/include/linux/usb/audio.h
+++ b/include/linux/usb/audio.h
@@ -17,531 +17,11 @@
17 * Types and defines in this file are either specific to version 1.0 of 17 * Types and defines in this file are either specific to version 1.0 of
18 * this standard or common for newer versions. 18 * this standard or common for newer versions.
19 */ 19 */
20
21#ifndef __LINUX_USB_AUDIO_H 20#ifndef __LINUX_USB_AUDIO_H
22#define __LINUX_USB_AUDIO_H 21#define __LINUX_USB_AUDIO_H
23 22
24#include <linux/types.h> 23#include <uapi/linux/usb/audio.h>
25
26/* bInterfaceProtocol values to denote the version of the standard used */
27#define UAC_VERSION_1 0x00
28#define UAC_VERSION_2 0x20
29
30/* A.2 Audio Interface Subclass Codes */
31#define USB_SUBCLASS_AUDIOCONTROL 0x01
32#define USB_SUBCLASS_AUDIOSTREAMING 0x02
33#define USB_SUBCLASS_MIDISTREAMING 0x03
34
35/* A.5 Audio Class-Specific AC Interface Descriptor Subtypes */
36#define UAC_HEADER 0x01
37#define UAC_INPUT_TERMINAL 0x02
38#define UAC_OUTPUT_TERMINAL 0x03
39#define UAC_MIXER_UNIT 0x04
40#define UAC_SELECTOR_UNIT 0x05
41#define UAC_FEATURE_UNIT 0x06
42#define UAC1_PROCESSING_UNIT 0x07
43#define UAC1_EXTENSION_UNIT 0x08
44
45/* A.6 Audio Class-Specific AS Interface Descriptor Subtypes */
46#define UAC_AS_GENERAL 0x01
47#define UAC_FORMAT_TYPE 0x02
48#define UAC_FORMAT_SPECIFIC 0x03
49
50/* A.7 Processing Unit Process Types */
51#define UAC_PROCESS_UNDEFINED 0x00
52#define UAC_PROCESS_UP_DOWNMIX 0x01
53#define UAC_PROCESS_DOLBY_PROLOGIC 0x02
54#define UAC_PROCESS_STEREO_EXTENDER 0x03
55#define UAC_PROCESS_REVERB 0x04
56#define UAC_PROCESS_CHORUS 0x05
57#define UAC_PROCESS_DYN_RANGE_COMP 0x06
58
59/* A.8 Audio Class-Specific Endpoint Descriptor Subtypes */
60#define UAC_EP_GENERAL 0x01
61
62/* A.9 Audio Class-Specific Request Codes */
63#define UAC_SET_ 0x00
64#define UAC_GET_ 0x80
65
66#define UAC__CUR 0x1
67#define UAC__MIN 0x2
68#define UAC__MAX 0x3
69#define UAC__RES 0x4
70#define UAC__MEM 0x5
71
72#define UAC_SET_CUR (UAC_SET_ | UAC__CUR)
73#define UAC_GET_CUR (UAC_GET_ | UAC__CUR)
74#define UAC_SET_MIN (UAC_SET_ | UAC__MIN)
75#define UAC_GET_MIN (UAC_GET_ | UAC__MIN)
76#define UAC_SET_MAX (UAC_SET_ | UAC__MAX)
77#define UAC_GET_MAX (UAC_GET_ | UAC__MAX)
78#define UAC_SET_RES (UAC_SET_ | UAC__RES)
79#define UAC_GET_RES (UAC_GET_ | UAC__RES)
80#define UAC_SET_MEM (UAC_SET_ | UAC__MEM)
81#define UAC_GET_MEM (UAC_GET_ | UAC__MEM)
82
83#define UAC_GET_STAT 0xff
84
85/* A.10 Control Selector Codes */
86
87/* A.10.1 Terminal Control Selectors */
88#define UAC_TERM_COPY_PROTECT 0x01
89
90/* A.10.2 Feature Unit Control Selectors */
91#define UAC_FU_MUTE 0x01
92#define UAC_FU_VOLUME 0x02
93#define UAC_FU_BASS 0x03
94#define UAC_FU_MID 0x04
95#define UAC_FU_TREBLE 0x05
96#define UAC_FU_GRAPHIC_EQUALIZER 0x06
97#define UAC_FU_AUTOMATIC_GAIN 0x07
98#define UAC_FU_DELAY 0x08
99#define UAC_FU_BASS_BOOST 0x09
100#define UAC_FU_LOUDNESS 0x0a
101
102#define UAC_CONTROL_BIT(CS) (1 << ((CS) - 1))
103
104/* A.10.3.1 Up/Down-mix Processing Unit Controls Selectors */
105#define UAC_UD_ENABLE 0x01
106#define UAC_UD_MODE_SELECT 0x02
107
108/* A.10.3.2 Dolby Prologic (tm) Processing Unit Controls Selectors */
109#define UAC_DP_ENABLE 0x01
110#define UAC_DP_MODE_SELECT 0x02
111
112/* A.10.3.3 3D Stereo Extender Processing Unit Control Selectors */
113#define UAC_3D_ENABLE 0x01
114#define UAC_3D_SPACE 0x02
115
116/* A.10.3.4 Reverberation Processing Unit Control Selectors */
117#define UAC_REVERB_ENABLE 0x01
118#define UAC_REVERB_LEVEL 0x02
119#define UAC_REVERB_TIME 0x03
120#define UAC_REVERB_FEEDBACK 0x04
121
122/* A.10.3.5 Chorus Processing Unit Control Selectors */
123#define UAC_CHORUS_ENABLE 0x01
124#define UAC_CHORUS_LEVEL 0x02
125#define UAC_CHORUS_RATE 0x03
126#define UAC_CHORUS_DEPTH 0x04
127
128/* A.10.3.6 Dynamic Range Compressor Unit Control Selectors */
129#define UAC_DCR_ENABLE 0x01
130#define UAC_DCR_RATE 0x02
131#define UAC_DCR_MAXAMPL 0x03
132#define UAC_DCR_THRESHOLD 0x04
133#define UAC_DCR_ATTACK_TIME 0x05
134#define UAC_DCR_RELEASE_TIME 0x06
135
136/* A.10.4 Extension Unit Control Selectors */
137#define UAC_XU_ENABLE 0x01
138
139/* MIDI - A.1 MS Class-Specific Interface Descriptor Subtypes */
140#define UAC_MS_HEADER 0x01
141#define UAC_MIDI_IN_JACK 0x02
142#define UAC_MIDI_OUT_JACK 0x03
143
144/* MIDI - A.1 MS Class-Specific Endpoint Descriptor Subtypes */
145#define UAC_MS_GENERAL 0x01
146
147/* Terminals - 2.1 USB Terminal Types */
148#define UAC_TERMINAL_UNDEFINED 0x100
149#define UAC_TERMINAL_STREAMING 0x101
150#define UAC_TERMINAL_VENDOR_SPEC 0x1FF
151
152/* Terminal Control Selectors */
153/* 4.3.2 Class-Specific AC Interface Descriptor */
154struct uac1_ac_header_descriptor {
155 __u8 bLength; /* 8 + n */
156 __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */
157 __u8 bDescriptorSubtype; /* UAC_MS_HEADER */
158 __le16 bcdADC; /* 0x0100 */
159 __le16 wTotalLength; /* includes Unit and Terminal desc. */
160 __u8 bInCollection; /* n */
161 __u8 baInterfaceNr[]; /* [n] */
162} __attribute__ ((packed));
163
164#define UAC_DT_AC_HEADER_SIZE(n) (8 + (n))
165
166/* As above, but more useful for defining your own descriptors: */
167#define DECLARE_UAC_AC_HEADER_DESCRIPTOR(n) \
168struct uac1_ac_header_descriptor_##n { \
169 __u8 bLength; \
170 __u8 bDescriptorType; \
171 __u8 bDescriptorSubtype; \
172 __le16 bcdADC; \
173 __le16 wTotalLength; \
174 __u8 bInCollection; \
175 __u8 baInterfaceNr[n]; \
176} __attribute__ ((packed))
177
178/* 4.3.2.1 Input Terminal Descriptor */
179struct uac_input_terminal_descriptor {
180 __u8 bLength; /* in bytes: 12 */
181 __u8 bDescriptorType; /* CS_INTERFACE descriptor type */
182 __u8 bDescriptorSubtype; /* INPUT_TERMINAL descriptor subtype */
183 __u8 bTerminalID; /* Constant uniquely terminal ID */
184 __le16 wTerminalType; /* USB Audio Terminal Types */
185 __u8 bAssocTerminal; /* ID of the Output Terminal associated */
186 __u8 bNrChannels; /* Number of logical output channels */
187 __le16 wChannelConfig;
188 __u8 iChannelNames;
189 __u8 iTerminal;
190} __attribute__ ((packed));
191
192#define UAC_DT_INPUT_TERMINAL_SIZE 12
193
194/* Terminals - 2.2 Input Terminal Types */
195#define UAC_INPUT_TERMINAL_UNDEFINED 0x200
196#define UAC_INPUT_TERMINAL_MICROPHONE 0x201
197#define UAC_INPUT_TERMINAL_DESKTOP_MICROPHONE 0x202
198#define UAC_INPUT_TERMINAL_PERSONAL_MICROPHONE 0x203
199#define UAC_INPUT_TERMINAL_OMNI_DIR_MICROPHONE 0x204
200#define UAC_INPUT_TERMINAL_MICROPHONE_ARRAY 0x205
201#define UAC_INPUT_TERMINAL_PROC_MICROPHONE_ARRAY 0x206
202
203/* Terminals - control selectors */
204
205#define UAC_TERMINAL_CS_COPY_PROTECT_CONTROL 0x01
206
207/* 4.3.2.2 Output Terminal Descriptor */
208struct uac1_output_terminal_descriptor {
209 __u8 bLength; /* in bytes: 9 */
210 __u8 bDescriptorType; /* CS_INTERFACE descriptor type */
211 __u8 bDescriptorSubtype; /* OUTPUT_TERMINAL descriptor subtype */
212 __u8 bTerminalID; /* Constant uniquely terminal ID */
213 __le16 wTerminalType; /* USB Audio Terminal Types */
214 __u8 bAssocTerminal; /* ID of the Input Terminal associated */
215 __u8 bSourceID; /* ID of the connected Unit or Terminal*/
216 __u8 iTerminal;
217} __attribute__ ((packed));
218
219#define UAC_DT_OUTPUT_TERMINAL_SIZE 9
220
221/* Terminals - 2.3 Output Terminal Types */
222#define UAC_OUTPUT_TERMINAL_UNDEFINED 0x300
223#define UAC_OUTPUT_TERMINAL_SPEAKER 0x301
224#define UAC_OUTPUT_TERMINAL_HEADPHONES 0x302
225#define UAC_OUTPUT_TERMINAL_HEAD_MOUNTED_DISPLAY_AUDIO 0x303
226#define UAC_OUTPUT_TERMINAL_DESKTOP_SPEAKER 0x304
227#define UAC_OUTPUT_TERMINAL_ROOM_SPEAKER 0x305
228#define UAC_OUTPUT_TERMINAL_COMMUNICATION_SPEAKER 0x306
229#define UAC_OUTPUT_TERMINAL_LOW_FREQ_EFFECTS_SPEAKER 0x307
230
231/* Set bControlSize = 2 as default setting */
232#define UAC_DT_FEATURE_UNIT_SIZE(ch) (7 + ((ch) + 1) * 2)
233
234/* As above, but more useful for defining your own descriptors: */
235#define DECLARE_UAC_FEATURE_UNIT_DESCRIPTOR(ch) \
236struct uac_feature_unit_descriptor_##ch { \
237 __u8 bLength; \
238 __u8 bDescriptorType; \
239 __u8 bDescriptorSubtype; \
240 __u8 bUnitID; \
241 __u8 bSourceID; \
242 __u8 bControlSize; \
243 __le16 bmaControls[ch + 1]; \
244 __u8 iFeature; \
245} __attribute__ ((packed))
246
247/* 4.3.2.3 Mixer Unit Descriptor */
248struct uac_mixer_unit_descriptor {
249 __u8 bLength;
250 __u8 bDescriptorType;
251 __u8 bDescriptorSubtype;
252 __u8 bUnitID;
253 __u8 bNrInPins;
254 __u8 baSourceID[];
255} __attribute__ ((packed));
256 24
257static inline __u8 uac_mixer_unit_bNrChannels(struct uac_mixer_unit_descriptor *desc)
258{
259 return desc->baSourceID[desc->bNrInPins];
260}
261
262static inline __u32 uac_mixer_unit_wChannelConfig(struct uac_mixer_unit_descriptor *desc,
263 int protocol)
264{
265 if (protocol == UAC_VERSION_1)
266 return (desc->baSourceID[desc->bNrInPins + 2] << 8) |
267 desc->baSourceID[desc->bNrInPins + 1];
268 else
269 return (desc->baSourceID[desc->bNrInPins + 4] << 24) |
270 (desc->baSourceID[desc->bNrInPins + 3] << 16) |
271 (desc->baSourceID[desc->bNrInPins + 2] << 8) |
272 (desc->baSourceID[desc->bNrInPins + 1]);
273}
274
275static inline __u8 uac_mixer_unit_iChannelNames(struct uac_mixer_unit_descriptor *desc,
276 int protocol)
277{
278 return (protocol == UAC_VERSION_1) ?
279 desc->baSourceID[desc->bNrInPins + 3] :
280 desc->baSourceID[desc->bNrInPins + 5];
281}
282
283static inline __u8 *uac_mixer_unit_bmControls(struct uac_mixer_unit_descriptor *desc,
284 int protocol)
285{
286 return (protocol == UAC_VERSION_1) ?
287 &desc->baSourceID[desc->bNrInPins + 4] :
288 &desc->baSourceID[desc->bNrInPins + 6];
289}
290
291static inline __u8 uac_mixer_unit_iMixer(struct uac_mixer_unit_descriptor *desc)
292{
293 __u8 *raw = (__u8 *) desc;
294 return raw[desc->bLength - 1];
295}
296
297/* 4.3.2.4 Selector Unit Descriptor */
298struct uac_selector_unit_descriptor {
299 __u8 bLength;
300 __u8 bDescriptorType;
301 __u8 bDescriptorSubtype;
302 __u8 bUintID;
303 __u8 bNrInPins;
304 __u8 baSourceID[];
305} __attribute__ ((packed));
306
307static inline __u8 uac_selector_unit_iSelector(struct uac_selector_unit_descriptor *desc)
308{
309 __u8 *raw = (__u8 *) desc;
310 return raw[desc->bLength - 1];
311}
312
313/* 4.3.2.5 Feature Unit Descriptor */
314struct uac_feature_unit_descriptor {
315 __u8 bLength;
316 __u8 bDescriptorType;
317 __u8 bDescriptorSubtype;
318 __u8 bUnitID;
319 __u8 bSourceID;
320 __u8 bControlSize;
321 __u8 bmaControls[0]; /* variable length */
322} __attribute__((packed));
323
324static inline __u8 uac_feature_unit_iFeature(struct uac_feature_unit_descriptor *desc)
325{
326 __u8 *raw = (__u8 *) desc;
327 return raw[desc->bLength - 1];
328}
329
330/* 4.3.2.6 Processing Unit Descriptors */
331struct uac_processing_unit_descriptor {
332 __u8 bLength;
333 __u8 bDescriptorType;
334 __u8 bDescriptorSubtype;
335 __u8 bUnitID;
336 __u16 wProcessType;
337 __u8 bNrInPins;
338 __u8 baSourceID[];
339} __attribute__ ((packed));
340
341static inline __u8 uac_processing_unit_bNrChannels(struct uac_processing_unit_descriptor *desc)
342{
343 return desc->baSourceID[desc->bNrInPins];
344}
345
346static inline __u32 uac_processing_unit_wChannelConfig(struct uac_processing_unit_descriptor *desc,
347 int protocol)
348{
349 if (protocol == UAC_VERSION_1)
350 return (desc->baSourceID[desc->bNrInPins + 2] << 8) |
351 desc->baSourceID[desc->bNrInPins + 1];
352 else
353 return (desc->baSourceID[desc->bNrInPins + 4] << 24) |
354 (desc->baSourceID[desc->bNrInPins + 3] << 16) |
355 (desc->baSourceID[desc->bNrInPins + 2] << 8) |
356 (desc->baSourceID[desc->bNrInPins + 1]);
357}
358
359static inline __u8 uac_processing_unit_iChannelNames(struct uac_processing_unit_descriptor *desc,
360 int protocol)
361{
362 return (protocol == UAC_VERSION_1) ?
363 desc->baSourceID[desc->bNrInPins + 3] :
364 desc->baSourceID[desc->bNrInPins + 5];
365}
366
367static inline __u8 uac_processing_unit_bControlSize(struct uac_processing_unit_descriptor *desc,
368 int protocol)
369{
370 return (protocol == UAC_VERSION_1) ?
371 desc->baSourceID[desc->bNrInPins + 4] :
372 desc->baSourceID[desc->bNrInPins + 6];
373}
374
375static inline __u8 *uac_processing_unit_bmControls(struct uac_processing_unit_descriptor *desc,
376 int protocol)
377{
378 return (protocol == UAC_VERSION_1) ?
379 &desc->baSourceID[desc->bNrInPins + 5] :
380 &desc->baSourceID[desc->bNrInPins + 7];
381}
382
383static inline __u8 uac_processing_unit_iProcessing(struct uac_processing_unit_descriptor *desc,
384 int protocol)
385{
386 __u8 control_size = uac_processing_unit_bControlSize(desc, protocol);
387 return desc->baSourceID[desc->bNrInPins + control_size];
388}
389
390static inline __u8 *uac_processing_unit_specific(struct uac_processing_unit_descriptor *desc,
391 int protocol)
392{
393 __u8 control_size = uac_processing_unit_bControlSize(desc, protocol);
394 return &desc->baSourceID[desc->bNrInPins + control_size + 1];
395}
396
397/* 4.5.2 Class-Specific AS Interface Descriptor */
398struct uac1_as_header_descriptor {
399 __u8 bLength; /* in bytes: 7 */
400 __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */
401 __u8 bDescriptorSubtype; /* AS_GENERAL */
402 __u8 bTerminalLink; /* Terminal ID of connected Terminal */
403 __u8 bDelay; /* Delay introduced by the data path */
404 __le16 wFormatTag; /* The Audio Data Format */
405} __attribute__ ((packed));
406
407#define UAC_DT_AS_HEADER_SIZE 7
408
409/* Formats - A.1.1 Audio Data Format Type I Codes */
410#define UAC_FORMAT_TYPE_I_UNDEFINED 0x0
411#define UAC_FORMAT_TYPE_I_PCM 0x1
412#define UAC_FORMAT_TYPE_I_PCM8 0x2
413#define UAC_FORMAT_TYPE_I_IEEE_FLOAT 0x3
414#define UAC_FORMAT_TYPE_I_ALAW 0x4
415#define UAC_FORMAT_TYPE_I_MULAW 0x5
416
417struct uac_format_type_i_continuous_descriptor {
418 __u8 bLength; /* in bytes: 8 + (ns * 3) */
419 __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */
420 __u8 bDescriptorSubtype; /* FORMAT_TYPE */
421 __u8 bFormatType; /* FORMAT_TYPE_1 */
422 __u8 bNrChannels; /* physical channels in the stream */
423 __u8 bSubframeSize; /* */
424 __u8 bBitResolution;
425 __u8 bSamFreqType;
426 __u8 tLowerSamFreq[3];
427 __u8 tUpperSamFreq[3];
428} __attribute__ ((packed));
429
430#define UAC_FORMAT_TYPE_I_CONTINUOUS_DESC_SIZE 14
431
432struct uac_format_type_i_discrete_descriptor {
433 __u8 bLength; /* in bytes: 8 + (ns * 3) */
434 __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */
435 __u8 bDescriptorSubtype; /* FORMAT_TYPE */
436 __u8 bFormatType; /* FORMAT_TYPE_1 */
437 __u8 bNrChannels; /* physical channels in the stream */
438 __u8 bSubframeSize; /* */
439 __u8 bBitResolution;
440 __u8 bSamFreqType;
441 __u8 tSamFreq[][3];
442} __attribute__ ((packed));
443
444#define DECLARE_UAC_FORMAT_TYPE_I_DISCRETE_DESC(n) \
445struct uac_format_type_i_discrete_descriptor_##n { \
446 __u8 bLength; \
447 __u8 bDescriptorType; \
448 __u8 bDescriptorSubtype; \
449 __u8 bFormatType; \
450 __u8 bNrChannels; \
451 __u8 bSubframeSize; \
452 __u8 bBitResolution; \
453 __u8 bSamFreqType; \
454 __u8 tSamFreq[n][3]; \
455} __attribute__ ((packed))
456
457#define UAC_FORMAT_TYPE_I_DISCRETE_DESC_SIZE(n) (8 + (n * 3))
458
459struct uac_format_type_i_ext_descriptor {
460 __u8 bLength;
461 __u8 bDescriptorType;
462 __u8 bDescriptorSubtype;
463 __u8 bFormatType;
464 __u8 bSubslotSize;
465 __u8 bBitResolution;
466 __u8 bHeaderLength;
467 __u8 bControlSize;
468 __u8 bSideBandProtocol;
469} __attribute__((packed));
470
471/* Formats - Audio Data Format Type I Codes */
472
473#define UAC_FORMAT_TYPE_II_MPEG 0x1001
474#define UAC_FORMAT_TYPE_II_AC3 0x1002
475
476struct uac_format_type_ii_discrete_descriptor {
477 __u8 bLength;
478 __u8 bDescriptorType;
479 __u8 bDescriptorSubtype;
480 __u8 bFormatType;
481 __le16 wMaxBitRate;
482 __le16 wSamplesPerFrame;
483 __u8 bSamFreqType;
484 __u8 tSamFreq[][3];
485} __attribute__((packed));
486
487struct uac_format_type_ii_ext_descriptor {
488 __u8 bLength;
489 __u8 bDescriptorType;
490 __u8 bDescriptorSubtype;
491 __u8 bFormatType;
492 __u16 wMaxBitRate;
493 __u16 wSamplesPerFrame;
494 __u8 bHeaderLength;
495 __u8 bSideBandProtocol;
496} __attribute__((packed));
497
498/* type III */
499#define UAC_FORMAT_TYPE_III_IEC1937_AC3 0x2001
500#define UAC_FORMAT_TYPE_III_IEC1937_MPEG1_LAYER1 0x2002
501#define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_NOEXT 0x2003
502#define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_EXT 0x2004
503#define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_LAYER1_LS 0x2005
504#define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_LAYER23_LS 0x2006
505
506/* Formats - A.2 Format Type Codes */
507#define UAC_FORMAT_TYPE_UNDEFINED 0x0
508#define UAC_FORMAT_TYPE_I 0x1
509#define UAC_FORMAT_TYPE_II 0x2
510#define UAC_FORMAT_TYPE_III 0x3
511#define UAC_EXT_FORMAT_TYPE_I 0x81
512#define UAC_EXT_FORMAT_TYPE_II 0x82
513#define UAC_EXT_FORMAT_TYPE_III 0x83
514
515struct uac_iso_endpoint_descriptor {
516 __u8 bLength; /* in bytes: 7 */
517 __u8 bDescriptorType; /* USB_DT_CS_ENDPOINT */
518 __u8 bDescriptorSubtype; /* EP_GENERAL */
519 __u8 bmAttributes;
520 __u8 bLockDelayUnits;
521 __le16 wLockDelay;
522} __attribute__((packed));
523#define UAC_ISO_ENDPOINT_DESC_SIZE 7
524
525#define UAC_EP_CS_ATTR_SAMPLE_RATE 0x01
526#define UAC_EP_CS_ATTR_PITCH_CONTROL 0x02
527#define UAC_EP_CS_ATTR_FILL_MAX 0x80
528
529/* status word format (3.7.1.1) */
530
531#define UAC1_STATUS_TYPE_ORIG_MASK 0x0f
532#define UAC1_STATUS_TYPE_ORIG_AUDIO_CONTROL_IF 0x0
533#define UAC1_STATUS_TYPE_ORIG_AUDIO_STREAM_IF 0x1
534#define UAC1_STATUS_TYPE_ORIG_AUDIO_STREAM_EP 0x2
535
536#define UAC1_STATUS_TYPE_IRQ_PENDING (1 << 7)
537#define UAC1_STATUS_TYPE_MEM_CHANGED (1 << 6)
538
539struct uac1_status_word {
540 __u8 bStatusType;
541 __u8 bOriginator;
542} __attribute__((packed));
543
544#ifdef __KERNEL__
545 25
546struct usb_audio_control { 26struct usb_audio_control {
547 struct list_head list; 27 struct list_head list;
@@ -561,6 +41,4 @@ struct usb_audio_control_selector {
561 struct usb_descriptor_header *desc; 41 struct usb_descriptor_header *desc;
562}; 42};
563 43
564#endif /* __KERNEL__ */
565
566#endif /* __LINUX_USB_AUDIO_H */ 44#endif /* __LINUX_USB_AUDIO_H */
diff --git a/include/linux/usb/ch9.h b/include/linux/usb/ch9.h
index d1d732c2838..9c210f2283d 100644
--- a/include/linux/usb/ch9.h
+++ b/include/linux/usb/ch9.h
@@ -29,887 +29,11 @@
29 * someone that the two other points are non-issues for that 29 * someone that the two other points are non-issues for that
30 * particular descriptor type. 30 * particular descriptor type.
31 */ 31 */
32
33#ifndef __LINUX_USB_CH9_H 32#ifndef __LINUX_USB_CH9_H
34#define __LINUX_USB_CH9_H 33#define __LINUX_USB_CH9_H
35 34
36#include <linux/types.h> /* __u8 etc */ 35#include <uapi/linux/usb/ch9.h>
37#include <asm/byteorder.h> /* le16_to_cpu */
38
39/*-------------------------------------------------------------------------*/
40
41/* CONTROL REQUEST SUPPORT */
42
43/*
44 * USB directions
45 *
46 * This bit flag is used in endpoint descriptors' bEndpointAddress field.
47 * It's also one of three fields in control requests bRequestType.
48 */
49#define USB_DIR_OUT 0 /* to device */
50#define USB_DIR_IN 0x80 /* to host */
51
52/*
53 * USB types, the second of three bRequestType fields
54 */
55#define USB_TYPE_MASK (0x03 << 5)
56#define USB_TYPE_STANDARD (0x00 << 5)
57#define USB_TYPE_CLASS (0x01 << 5)
58#define USB_TYPE_VENDOR (0x02 << 5)
59#define USB_TYPE_RESERVED (0x03 << 5)
60
61/*
62 * USB recipients, the third of three bRequestType fields
63 */
64#define USB_RECIP_MASK 0x1f
65#define USB_RECIP_DEVICE 0x00
66#define USB_RECIP_INTERFACE 0x01
67#define USB_RECIP_ENDPOINT 0x02
68#define USB_RECIP_OTHER 0x03
69/* From Wireless USB 1.0 */
70#define USB_RECIP_PORT 0x04
71#define USB_RECIP_RPIPE 0x05
72
73/*
74 * Standard requests, for the bRequest field of a SETUP packet.
75 *
76 * These are qualified by the bRequestType field, so that for example
77 * TYPE_CLASS or TYPE_VENDOR specific feature flags could be retrieved
78 * by a GET_STATUS request.
79 */
80#define USB_REQ_GET_STATUS 0x00
81#define USB_REQ_CLEAR_FEATURE 0x01
82#define USB_REQ_SET_FEATURE 0x03
83#define USB_REQ_SET_ADDRESS 0x05
84#define USB_REQ_GET_DESCRIPTOR 0x06
85#define USB_REQ_SET_DESCRIPTOR 0x07
86#define USB_REQ_GET_CONFIGURATION 0x08
87#define USB_REQ_SET_CONFIGURATION 0x09
88#define USB_REQ_GET_INTERFACE 0x0A
89#define USB_REQ_SET_INTERFACE 0x0B
90#define USB_REQ_SYNCH_FRAME 0x0C
91#define USB_REQ_SET_SEL 0x30
92#define USB_REQ_SET_ISOCH_DELAY 0x31
93
94#define USB_REQ_SET_ENCRYPTION 0x0D /* Wireless USB */
95#define USB_REQ_GET_ENCRYPTION 0x0E
96#define USB_REQ_RPIPE_ABORT 0x0E
97#define USB_REQ_SET_HANDSHAKE 0x0F
98#define USB_REQ_RPIPE_RESET 0x0F
99#define USB_REQ_GET_HANDSHAKE 0x10
100#define USB_REQ_SET_CONNECTION 0x11
101#define USB_REQ_SET_SECURITY_DATA 0x12
102#define USB_REQ_GET_SECURITY_DATA 0x13
103#define USB_REQ_SET_WUSB_DATA 0x14
104#define USB_REQ_LOOPBACK_DATA_WRITE 0x15
105#define USB_REQ_LOOPBACK_DATA_READ 0x16
106#define USB_REQ_SET_INTERFACE_DS 0x17
107
108/* The Link Power Management (LPM) ECN defines USB_REQ_TEST_AND_SET command,
109 * used by hubs to put ports into a new L1 suspend state, except that it
110 * forgot to define its number ...
111 */
112
113/*
114 * USB feature flags are written using USB_REQ_{CLEAR,SET}_FEATURE, and
115 * are read as a bit array returned by USB_REQ_GET_STATUS. (So there
116 * are at most sixteen features of each type.) Hubs may also support a
117 * new USB_REQ_TEST_AND_SET_FEATURE to put ports into L1 suspend.
118 */
119#define USB_DEVICE_SELF_POWERED 0 /* (read only) */
120#define USB_DEVICE_REMOTE_WAKEUP 1 /* dev may initiate wakeup */
121#define USB_DEVICE_TEST_MODE 2 /* (wired high speed only) */
122#define USB_DEVICE_BATTERY 2 /* (wireless) */
123#define USB_DEVICE_B_HNP_ENABLE 3 /* (otg) dev may initiate HNP */
124#define USB_DEVICE_WUSB_DEVICE 3 /* (wireless)*/
125#define USB_DEVICE_A_HNP_SUPPORT 4 /* (otg) RH port supports HNP */
126#define USB_DEVICE_A_ALT_HNP_SUPPORT 5 /* (otg) other RH port does */
127#define USB_DEVICE_DEBUG_MODE 6 /* (special devices only) */
128
129/*
130 * Test Mode Selectors
131 * See USB 2.0 spec Table 9-7
132 */
133#define TEST_J 1
134#define TEST_K 2
135#define TEST_SE0_NAK 3
136#define TEST_PACKET 4
137#define TEST_FORCE_EN 5
138
139/*
140 * New Feature Selectors as added by USB 3.0
141 * See USB 3.0 spec Table 9-6
142 */
143#define USB_DEVICE_U1_ENABLE 48 /* dev may initiate U1 transition */
144#define USB_DEVICE_U2_ENABLE 49 /* dev may initiate U2 transition */
145#define USB_DEVICE_LTM_ENABLE 50 /* dev may send LTM */
146#define USB_INTRF_FUNC_SUSPEND 0 /* function suspend */
147
148#define USB_INTR_FUNC_SUSPEND_OPT_MASK 0xFF00
149/*
150 * Suspend Options, Table 9-7 USB 3.0 spec
151 */
152#define USB_INTRF_FUNC_SUSPEND_LP (1 << (8 + 0))
153#define USB_INTRF_FUNC_SUSPEND_RW (1 << (8 + 1))
154
155#define USB_ENDPOINT_HALT 0 /* IN/OUT will STALL */
156
157/* Bit array elements as returned by the USB_REQ_GET_STATUS request. */
158#define USB_DEV_STAT_U1_ENABLED 2 /* transition into U1 state */
159#define USB_DEV_STAT_U2_ENABLED 3 /* transition into U2 state */
160#define USB_DEV_STAT_LTM_ENABLED 4 /* Latency tolerance messages */
161
162/**
163 * struct usb_ctrlrequest - SETUP data for a USB device control request
164 * @bRequestType: matches the USB bmRequestType field
165 * @bRequest: matches the USB bRequest field
166 * @wValue: matches the USB wValue field (le16 byte order)
167 * @wIndex: matches the USB wIndex field (le16 byte order)
168 * @wLength: matches the USB wLength field (le16 byte order)
169 *
170 * This structure is used to send control requests to a USB device. It matches
171 * the different fields of the USB 2.0 Spec section 9.3, table 9-2. See the
172 * USB spec for a fuller description of the different fields, and what they are
173 * used for.
174 *
175 * Note that the driver for any interface can issue control requests.
176 * For most devices, interfaces don't coordinate with each other, so
177 * such requests may be made at any time.
178 */
179struct usb_ctrlrequest {
180 __u8 bRequestType;
181 __u8 bRequest;
182 __le16 wValue;
183 __le16 wIndex;
184 __le16 wLength;
185} __attribute__ ((packed));
186
187/*-------------------------------------------------------------------------*/
188
189/*
190 * STANDARD DESCRIPTORS ... as returned by GET_DESCRIPTOR, or
191 * (rarely) accepted by SET_DESCRIPTOR.
192 *
193 * Note that all multi-byte values here are encoded in little endian
194 * byte order "on the wire". Within the kernel and when exposed
195 * through the Linux-USB APIs, they are not converted to cpu byte
196 * order; it is the responsibility of the client code to do this.
197 * The single exception is when device and configuration descriptors (but
198 * not other descriptors) are read from usbfs (i.e. /proc/bus/usb/BBB/DDD);
199 * in this case the fields are converted to host endianness by the kernel.
200 */
201
202/*
203 * Descriptor types ... USB 2.0 spec table 9.5
204 */
205#define USB_DT_DEVICE 0x01
206#define USB_DT_CONFIG 0x02
207#define USB_DT_STRING 0x03
208#define USB_DT_INTERFACE 0x04
209#define USB_DT_ENDPOINT 0x05
210#define USB_DT_DEVICE_QUALIFIER 0x06
211#define USB_DT_OTHER_SPEED_CONFIG 0x07
212#define USB_DT_INTERFACE_POWER 0x08
213/* these are from a minor usb 2.0 revision (ECN) */
214#define USB_DT_OTG 0x09
215#define USB_DT_DEBUG 0x0a
216#define USB_DT_INTERFACE_ASSOCIATION 0x0b
217/* these are from the Wireless USB spec */
218#define USB_DT_SECURITY 0x0c
219#define USB_DT_KEY 0x0d
220#define USB_DT_ENCRYPTION_TYPE 0x0e
221#define USB_DT_BOS 0x0f
222#define USB_DT_DEVICE_CAPABILITY 0x10
223#define USB_DT_WIRELESS_ENDPOINT_COMP 0x11
224#define USB_DT_WIRE_ADAPTER 0x21
225#define USB_DT_RPIPE 0x22
226#define USB_DT_CS_RADIO_CONTROL 0x23
227/* From the T10 UAS specification */
228#define USB_DT_PIPE_USAGE 0x24
229/* From the USB 3.0 spec */
230#define USB_DT_SS_ENDPOINT_COMP 0x30
231
232/* Conventional codes for class-specific descriptors. The convention is
233 * defined in the USB "Common Class" Spec (3.11). Individual class specs
234 * are authoritative for their usage, not the "common class" writeup.
235 */
236#define USB_DT_CS_DEVICE (USB_TYPE_CLASS | USB_DT_DEVICE)
237#define USB_DT_CS_CONFIG (USB_TYPE_CLASS | USB_DT_CONFIG)
238#define USB_DT_CS_STRING (USB_TYPE_CLASS | USB_DT_STRING)
239#define USB_DT_CS_INTERFACE (USB_TYPE_CLASS | USB_DT_INTERFACE)
240#define USB_DT_CS_ENDPOINT (USB_TYPE_CLASS | USB_DT_ENDPOINT)
241
242/* All standard descriptors have these 2 fields at the beginning */
243struct usb_descriptor_header {
244 __u8 bLength;
245 __u8 bDescriptorType;
246} __attribute__ ((packed));
247
248
249/*-------------------------------------------------------------------------*/
250
251/* USB_DT_DEVICE: Device descriptor */
252struct usb_device_descriptor {
253 __u8 bLength;
254 __u8 bDescriptorType;
255
256 __le16 bcdUSB;
257 __u8 bDeviceClass;
258 __u8 bDeviceSubClass;
259 __u8 bDeviceProtocol;
260 __u8 bMaxPacketSize0;
261 __le16 idVendor;
262 __le16 idProduct;
263 __le16 bcdDevice;
264 __u8 iManufacturer;
265 __u8 iProduct;
266 __u8 iSerialNumber;
267 __u8 bNumConfigurations;
268} __attribute__ ((packed));
269
270#define USB_DT_DEVICE_SIZE 18
271
272
273/*
274 * Device and/or Interface Class codes
275 * as found in bDeviceClass or bInterfaceClass
276 * and defined by www.usb.org documents
277 */
278#define USB_CLASS_PER_INTERFACE 0 /* for DeviceClass */
279#define USB_CLASS_AUDIO 1
280#define USB_CLASS_COMM 2
281#define USB_CLASS_HID 3
282#define USB_CLASS_PHYSICAL 5
283#define USB_CLASS_STILL_IMAGE 6
284#define USB_CLASS_PRINTER 7
285#define USB_CLASS_MASS_STORAGE 8
286#define USB_CLASS_HUB 9
287#define USB_CLASS_CDC_DATA 0x0a
288#define USB_CLASS_CSCID 0x0b /* chip+ smart card */
289#define USB_CLASS_CONTENT_SEC 0x0d /* content security */
290#define USB_CLASS_VIDEO 0x0e
291#define USB_CLASS_WIRELESS_CONTROLLER 0xe0
292#define USB_CLASS_MISC 0xef
293#define USB_CLASS_APP_SPEC 0xfe
294#define USB_CLASS_VENDOR_SPEC 0xff
295
296#define USB_SUBCLASS_VENDOR_SPEC 0xff
297
298/*-------------------------------------------------------------------------*/
299
300/* USB_DT_CONFIG: Configuration descriptor information.
301 *
302 * USB_DT_OTHER_SPEED_CONFIG is the same descriptor, except that the
303 * descriptor type is different. Highspeed-capable devices can look
304 * different depending on what speed they're currently running. Only
305 * devices with a USB_DT_DEVICE_QUALIFIER have any OTHER_SPEED_CONFIG
306 * descriptors.
307 */
308struct usb_config_descriptor {
309 __u8 bLength;
310 __u8 bDescriptorType;
311
312 __le16 wTotalLength;
313 __u8 bNumInterfaces;
314 __u8 bConfigurationValue;
315 __u8 iConfiguration;
316 __u8 bmAttributes;
317 __u8 bMaxPower;
318} __attribute__ ((packed));
319
320#define USB_DT_CONFIG_SIZE 9
321
322/* from config descriptor bmAttributes */
323#define USB_CONFIG_ATT_ONE (1 << 7) /* must be set */
324#define USB_CONFIG_ATT_SELFPOWER (1 << 6) /* self powered */
325#define USB_CONFIG_ATT_WAKEUP (1 << 5) /* can wakeup */
326#define USB_CONFIG_ATT_BATTERY (1 << 4) /* battery powered */
327
328/*-------------------------------------------------------------------------*/
329
330/* USB_DT_STRING: String descriptor */
331struct usb_string_descriptor {
332 __u8 bLength;
333 __u8 bDescriptorType;
334
335 __le16 wData[1]; /* UTF-16LE encoded */
336} __attribute__ ((packed));
337
338/* note that "string" zero is special, it holds language codes that
339 * the device supports, not Unicode characters.
340 */
341
342/*-------------------------------------------------------------------------*/
343
344/* USB_DT_INTERFACE: Interface descriptor */
345struct usb_interface_descriptor {
346 __u8 bLength;
347 __u8 bDescriptorType;
348
349 __u8 bInterfaceNumber;
350 __u8 bAlternateSetting;
351 __u8 bNumEndpoints;
352 __u8 bInterfaceClass;
353 __u8 bInterfaceSubClass;
354 __u8 bInterfaceProtocol;
355 __u8 iInterface;
356} __attribute__ ((packed));
357
358#define USB_DT_INTERFACE_SIZE 9
359
360/*-------------------------------------------------------------------------*/
361
362/* USB_DT_ENDPOINT: Endpoint descriptor */
363struct usb_endpoint_descriptor {
364 __u8 bLength;
365 __u8 bDescriptorType;
366
367 __u8 bEndpointAddress;
368 __u8 bmAttributes;
369 __le16 wMaxPacketSize;
370 __u8 bInterval;
371
372 /* NOTE: these two are _only_ in audio endpoints. */
373 /* use USB_DT_ENDPOINT*_SIZE in bLength, not sizeof. */
374 __u8 bRefresh;
375 __u8 bSynchAddress;
376} __attribute__ ((packed));
377
378#define USB_DT_ENDPOINT_SIZE 7
379#define USB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */
380
381
382/*
383 * Endpoints
384 */
385#define USB_ENDPOINT_NUMBER_MASK 0x0f /* in bEndpointAddress */
386#define USB_ENDPOINT_DIR_MASK 0x80
387
388#define USB_ENDPOINT_XFERTYPE_MASK 0x03 /* in bmAttributes */
389#define USB_ENDPOINT_XFER_CONTROL 0
390#define USB_ENDPOINT_XFER_ISOC 1
391#define USB_ENDPOINT_XFER_BULK 2
392#define USB_ENDPOINT_XFER_INT 3
393#define USB_ENDPOINT_MAX_ADJUSTABLE 0x80
394
395/* The USB 3.0 spec redefines bits 5:4 of bmAttributes as interrupt ep type. */
396#define USB_ENDPOINT_INTRTYPE 0x30
397#define USB_ENDPOINT_INTR_PERIODIC (0 << 4)
398#define USB_ENDPOINT_INTR_NOTIFICATION (1 << 4)
399
400#define USB_ENDPOINT_SYNCTYPE 0x0c
401#define USB_ENDPOINT_SYNC_NONE (0 << 2)
402#define USB_ENDPOINT_SYNC_ASYNC (1 << 2)
403#define USB_ENDPOINT_SYNC_ADAPTIVE (2 << 2)
404#define USB_ENDPOINT_SYNC_SYNC (3 << 2)
405
406#define USB_ENDPOINT_USAGE_MASK 0x30
407#define USB_ENDPOINT_USAGE_DATA 0x00
408#define USB_ENDPOINT_USAGE_FEEDBACK 0x10
409#define USB_ENDPOINT_USAGE_IMPLICIT_FB 0x20 /* Implicit feedback Data endpoint */
410
411/*-------------------------------------------------------------------------*/
412
413/**
414 * usb_endpoint_num - get the endpoint's number
415 * @epd: endpoint to be checked
416 *
417 * Returns @epd's number: 0 to 15.
418 */
419static inline int usb_endpoint_num(const struct usb_endpoint_descriptor *epd)
420{
421 return epd->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
422}
423
424/**
425 * usb_endpoint_type - get the endpoint's transfer type
426 * @epd: endpoint to be checked
427 *
428 * Returns one of USB_ENDPOINT_XFER_{CONTROL, ISOC, BULK, INT} according
429 * to @epd's transfer type.
430 */
431static inline int usb_endpoint_type(const struct usb_endpoint_descriptor *epd)
432{
433 return epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
434}
435
436/**
437 * usb_endpoint_dir_in - check if the endpoint has IN direction
438 * @epd: endpoint to be checked
439 *
440 * Returns true if the endpoint is of type IN, otherwise it returns false.
441 */
442static inline int usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd)
443{
444 return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN);
445}
446
447/**
448 * usb_endpoint_dir_out - check if the endpoint has OUT direction
449 * @epd: endpoint to be checked
450 *
451 * Returns true if the endpoint is of type OUT, otherwise it returns false.
452 */
453static inline int usb_endpoint_dir_out(
454 const struct usb_endpoint_descriptor *epd)
455{
456 return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT);
457}
458
459/**
460 * usb_endpoint_xfer_bulk - check if the endpoint has bulk transfer type
461 * @epd: endpoint to be checked
462 *
463 * Returns true if the endpoint is of type bulk, otherwise it returns false.
464 */
465static inline int usb_endpoint_xfer_bulk(
466 const struct usb_endpoint_descriptor *epd)
467{
468 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
469 USB_ENDPOINT_XFER_BULK);
470}
471
472/**
473 * usb_endpoint_xfer_control - check if the endpoint has control transfer type
474 * @epd: endpoint to be checked
475 *
476 * Returns true if the endpoint is of type control, otherwise it returns false.
477 */
478static inline int usb_endpoint_xfer_control(
479 const struct usb_endpoint_descriptor *epd)
480{
481 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
482 USB_ENDPOINT_XFER_CONTROL);
483}
484
485/**
486 * usb_endpoint_xfer_int - check if the endpoint has interrupt transfer type
487 * @epd: endpoint to be checked
488 *
489 * Returns true if the endpoint is of type interrupt, otherwise it returns
490 * false.
491 */
492static inline int usb_endpoint_xfer_int(
493 const struct usb_endpoint_descriptor *epd)
494{
495 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
496 USB_ENDPOINT_XFER_INT);
497}
498
499/**
500 * usb_endpoint_xfer_isoc - check if the endpoint has isochronous transfer type
501 * @epd: endpoint to be checked
502 *
503 * Returns true if the endpoint is of type isochronous, otherwise it returns
504 * false.
505 */
506static inline int usb_endpoint_xfer_isoc(
507 const struct usb_endpoint_descriptor *epd)
508{
509 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
510 USB_ENDPOINT_XFER_ISOC);
511}
512
513/**
514 * usb_endpoint_is_bulk_in - check if the endpoint is bulk IN
515 * @epd: endpoint to be checked
516 *
517 * Returns true if the endpoint has bulk transfer type and IN direction,
518 * otherwise it returns false.
519 */
520static inline int usb_endpoint_is_bulk_in(
521 const struct usb_endpoint_descriptor *epd)
522{
523 return usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_in(epd);
524}
525
526/**
527 * usb_endpoint_is_bulk_out - check if the endpoint is bulk OUT
528 * @epd: endpoint to be checked
529 *
530 * Returns true if the endpoint has bulk transfer type and OUT direction,
531 * otherwise it returns false.
532 */
533static inline int usb_endpoint_is_bulk_out(
534 const struct usb_endpoint_descriptor *epd)
535{
536 return usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_out(epd);
537}
538
539/**
540 * usb_endpoint_is_int_in - check if the endpoint is interrupt IN
541 * @epd: endpoint to be checked
542 *
543 * Returns true if the endpoint has interrupt transfer type and IN direction,
544 * otherwise it returns false.
545 */
546static inline int usb_endpoint_is_int_in(
547 const struct usb_endpoint_descriptor *epd)
548{
549 return usb_endpoint_xfer_int(epd) && usb_endpoint_dir_in(epd);
550}
551
552/**
553 * usb_endpoint_is_int_out - check if the endpoint is interrupt OUT
554 * @epd: endpoint to be checked
555 *
556 * Returns true if the endpoint has interrupt transfer type and OUT direction,
557 * otherwise it returns false.
558 */
559static inline int usb_endpoint_is_int_out(
560 const struct usb_endpoint_descriptor *epd)
561{
562 return usb_endpoint_xfer_int(epd) && usb_endpoint_dir_out(epd);
563}
564
565/**
566 * usb_endpoint_is_isoc_in - check if the endpoint is isochronous IN
567 * @epd: endpoint to be checked
568 *
569 * Returns true if the endpoint has isochronous transfer type and IN direction,
570 * otherwise it returns false.
571 */
572static inline int usb_endpoint_is_isoc_in(
573 const struct usb_endpoint_descriptor *epd)
574{
575 return usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_in(epd);
576}
577
578/**
579 * usb_endpoint_is_isoc_out - check if the endpoint is isochronous OUT
580 * @epd: endpoint to be checked
581 *
582 * Returns true if the endpoint has isochronous transfer type and OUT direction,
583 * otherwise it returns false.
584 */
585static inline int usb_endpoint_is_isoc_out(
586 const struct usb_endpoint_descriptor *epd)
587{
588 return usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_out(epd);
589}
590
591/**
592 * usb_endpoint_maxp - get endpoint's max packet size
593 * @epd: endpoint to be checked
594 *
595 * Returns @epd's max packet
596 */
597static inline int usb_endpoint_maxp(const struct usb_endpoint_descriptor *epd)
598{
599 return __le16_to_cpu(epd->wMaxPacketSize);
600}
601
602static inline int usb_endpoint_interrupt_type(
603 const struct usb_endpoint_descriptor *epd)
604{
605 return epd->bmAttributes & USB_ENDPOINT_INTRTYPE;
606}
607
608/*-------------------------------------------------------------------------*/
609
610/* USB_DT_SS_ENDPOINT_COMP: SuperSpeed Endpoint Companion descriptor */
611struct usb_ss_ep_comp_descriptor {
612 __u8 bLength;
613 __u8 bDescriptorType;
614
615 __u8 bMaxBurst;
616 __u8 bmAttributes;
617 __le16 wBytesPerInterval;
618} __attribute__ ((packed));
619
620#define USB_DT_SS_EP_COMP_SIZE 6
621
622/* Bits 4:0 of bmAttributes if this is a bulk endpoint */
623static inline int
624usb_ss_max_streams(const struct usb_ss_ep_comp_descriptor *comp)
625{
626 int max_streams;
627
628 if (!comp)
629 return 0;
630
631 max_streams = comp->bmAttributes & 0x1f;
632
633 if (!max_streams)
634 return 0;
635
636 max_streams = 1 << max_streams;
637
638 return max_streams;
639}
640
641/* Bits 1:0 of bmAttributes if this is an isoc endpoint */
642#define USB_SS_MULT(p) (1 + ((p) & 0x3))
643
644/*-------------------------------------------------------------------------*/
645
646/* USB_DT_DEVICE_QUALIFIER: Device Qualifier descriptor */
647struct usb_qualifier_descriptor {
648 __u8 bLength;
649 __u8 bDescriptorType;
650
651 __le16 bcdUSB;
652 __u8 bDeviceClass;
653 __u8 bDeviceSubClass;
654 __u8 bDeviceProtocol;
655 __u8 bMaxPacketSize0;
656 __u8 bNumConfigurations;
657 __u8 bRESERVED;
658} __attribute__ ((packed));
659
660
661/*-------------------------------------------------------------------------*/
662
663/* USB_DT_OTG (from OTG 1.0a supplement) */
664struct usb_otg_descriptor {
665 __u8 bLength;
666 __u8 bDescriptorType;
667
668 __u8 bmAttributes; /* support for HNP, SRP, etc */
669} __attribute__ ((packed));
670
671/* from usb_otg_descriptor.bmAttributes */
672#define USB_OTG_SRP (1 << 0)
673#define USB_OTG_HNP (1 << 1) /* swap host/device roles */
674
675/*-------------------------------------------------------------------------*/
676
677/* USB_DT_DEBUG: for special highspeed devices, replacing serial console */
678struct usb_debug_descriptor {
679 __u8 bLength;
680 __u8 bDescriptorType;
681
682 /* bulk endpoints with 8 byte maxpacket */
683 __u8 bDebugInEndpoint;
684 __u8 bDebugOutEndpoint;
685} __attribute__((packed));
686
687/*-------------------------------------------------------------------------*/
688
689/* USB_DT_INTERFACE_ASSOCIATION: groups interfaces */
690struct usb_interface_assoc_descriptor {
691 __u8 bLength;
692 __u8 bDescriptorType;
693
694 __u8 bFirstInterface;
695 __u8 bInterfaceCount;
696 __u8 bFunctionClass;
697 __u8 bFunctionSubClass;
698 __u8 bFunctionProtocol;
699 __u8 iFunction;
700} __attribute__ ((packed));
701
702
703/*-------------------------------------------------------------------------*/
704
705/* USB_DT_SECURITY: group of wireless security descriptors, including
706 * encryption types available for setting up a CC/association.
707 */
708struct usb_security_descriptor {
709 __u8 bLength;
710 __u8 bDescriptorType;
711
712 __le16 wTotalLength;
713 __u8 bNumEncryptionTypes;
714} __attribute__((packed));
715
716/*-------------------------------------------------------------------------*/
717
718/* USB_DT_KEY: used with {GET,SET}_SECURITY_DATA; only public keys
719 * may be retrieved.
720 */
721struct usb_key_descriptor {
722 __u8 bLength;
723 __u8 bDescriptorType;
724
725 __u8 tTKID[3];
726 __u8 bReserved;
727 __u8 bKeyData[0];
728} __attribute__((packed));
729
730/*-------------------------------------------------------------------------*/
731
732/* USB_DT_ENCRYPTION_TYPE: bundled in DT_SECURITY groups */
733struct usb_encryption_descriptor {
734 __u8 bLength;
735 __u8 bDescriptorType;
736
737 __u8 bEncryptionType;
738#define USB_ENC_TYPE_UNSECURE 0
739#define USB_ENC_TYPE_WIRED 1 /* non-wireless mode */
740#define USB_ENC_TYPE_CCM_1 2 /* aes128/cbc session */
741#define USB_ENC_TYPE_RSA_1 3 /* rsa3072/sha1 auth */
742 __u8 bEncryptionValue; /* use in SET_ENCRYPTION */
743 __u8 bAuthKeyIndex;
744} __attribute__((packed));
745
746
747/*-------------------------------------------------------------------------*/
748
749/* USB_DT_BOS: group of device-level capabilities */
750struct usb_bos_descriptor {
751 __u8 bLength;
752 __u8 bDescriptorType;
753
754 __le16 wTotalLength;
755 __u8 bNumDeviceCaps;
756} __attribute__((packed));
757
758#define USB_DT_BOS_SIZE 5
759/*-------------------------------------------------------------------------*/
760
761/* USB_DT_DEVICE_CAPABILITY: grouped with BOS */
762struct usb_dev_cap_header {
763 __u8 bLength;
764 __u8 bDescriptorType;
765 __u8 bDevCapabilityType;
766} __attribute__((packed));
767
768#define USB_CAP_TYPE_WIRELESS_USB 1
769
770struct usb_wireless_cap_descriptor { /* Ultra Wide Band */
771 __u8 bLength;
772 __u8 bDescriptorType;
773 __u8 bDevCapabilityType;
774
775 __u8 bmAttributes;
776#define USB_WIRELESS_P2P_DRD (1 << 1)
777#define USB_WIRELESS_BEACON_MASK (3 << 2)
778#define USB_WIRELESS_BEACON_SELF (1 << 2)
779#define USB_WIRELESS_BEACON_DIRECTED (2 << 2)
780#define USB_WIRELESS_BEACON_NONE (3 << 2)
781 __le16 wPHYRates; /* bit rates, Mbps */
782#define USB_WIRELESS_PHY_53 (1 << 0) /* always set */
783#define USB_WIRELESS_PHY_80 (1 << 1)
784#define USB_WIRELESS_PHY_107 (1 << 2) /* always set */
785#define USB_WIRELESS_PHY_160 (1 << 3)
786#define USB_WIRELESS_PHY_200 (1 << 4) /* always set */
787#define USB_WIRELESS_PHY_320 (1 << 5)
788#define USB_WIRELESS_PHY_400 (1 << 6)
789#define USB_WIRELESS_PHY_480 (1 << 7)
790 __u8 bmTFITXPowerInfo; /* TFI power levels */
791 __u8 bmFFITXPowerInfo; /* FFI power levels */
792 __le16 bmBandGroup;
793 __u8 bReserved;
794} __attribute__((packed));
795
796/* USB 2.0 Extension descriptor */
797#define USB_CAP_TYPE_EXT 2
798
799struct usb_ext_cap_descriptor { /* Link Power Management */
800 __u8 bLength;
801 __u8 bDescriptorType;
802 __u8 bDevCapabilityType;
803 __le32 bmAttributes;
804#define USB_LPM_SUPPORT (1 << 1) /* supports LPM */
805#define USB_BESL_SUPPORT (1 << 2) /* supports BESL */
806#define USB_BESL_BASELINE_VALID (1 << 3) /* Baseline BESL valid*/
807#define USB_BESL_DEEP_VALID (1 << 4) /* Deep BESL valid */
808#define USB_GET_BESL_BASELINE(p) (((p) & (0xf << 8)) >> 8)
809#define USB_GET_BESL_DEEP(p) (((p) & (0xf << 12)) >> 12)
810} __attribute__((packed));
811
812#define USB_DT_USB_EXT_CAP_SIZE 7
813
814/*
815 * SuperSpeed USB Capability descriptor: Defines the set of SuperSpeed USB
816 * specific device level capabilities
817 */
818#define USB_SS_CAP_TYPE 3
819struct usb_ss_cap_descriptor { /* Link Power Management */
820 __u8 bLength;
821 __u8 bDescriptorType;
822 __u8 bDevCapabilityType;
823 __u8 bmAttributes;
824#define USB_LTM_SUPPORT (1 << 1) /* supports LTM */
825 __le16 wSpeedSupported;
826#define USB_LOW_SPEED_OPERATION (1) /* Low speed operation */
827#define USB_FULL_SPEED_OPERATION (1 << 1) /* Full speed operation */
828#define USB_HIGH_SPEED_OPERATION (1 << 2) /* High speed operation */
829#define USB_5GBPS_OPERATION (1 << 3) /* Operation at 5Gbps */
830 __u8 bFunctionalitySupport;
831 __u8 bU1devExitLat;
832 __le16 bU2DevExitLat;
833} __attribute__((packed));
834
835#define USB_DT_USB_SS_CAP_SIZE 10
836
837/*
838 * Container ID Capability descriptor: Defines the instance unique ID used to
839 * identify the instance across all operating modes
840 */
841#define CONTAINER_ID_TYPE 4
842struct usb_ss_container_id_descriptor {
843 __u8 bLength;
844 __u8 bDescriptorType;
845 __u8 bDevCapabilityType;
846 __u8 bReserved;
847 __u8 ContainerID[16]; /* 128-bit number */
848} __attribute__((packed));
849
850#define USB_DT_USB_SS_CONTN_ID_SIZE 20
851/*-------------------------------------------------------------------------*/
852
853/* USB_DT_WIRELESS_ENDPOINT_COMP: companion descriptor associated with
854 * each endpoint descriptor for a wireless device
855 */
856struct usb_wireless_ep_comp_descriptor {
857 __u8 bLength;
858 __u8 bDescriptorType;
859
860 __u8 bMaxBurst;
861 __u8 bMaxSequence;
862 __le16 wMaxStreamDelay;
863 __le16 wOverTheAirPacketSize;
864 __u8 bOverTheAirInterval;
865 __u8 bmCompAttributes;
866#define USB_ENDPOINT_SWITCH_MASK 0x03 /* in bmCompAttributes */
867#define USB_ENDPOINT_SWITCH_NO 0
868#define USB_ENDPOINT_SWITCH_SWITCH 1
869#define USB_ENDPOINT_SWITCH_SCALE 2
870} __attribute__((packed));
871
872/*-------------------------------------------------------------------------*/
873
874/* USB_REQ_SET_HANDSHAKE is a four-way handshake used between a wireless
875 * host and a device for connection set up, mutual authentication, and
876 * exchanging short lived session keys. The handshake depends on a CC.
877 */
878struct usb_handshake {
879 __u8 bMessageNumber;
880 __u8 bStatus;
881 __u8 tTKID[3];
882 __u8 bReserved;
883 __u8 CDID[16];
884 __u8 nonce[16];
885 __u8 MIC[8];
886} __attribute__((packed));
887
888/*-------------------------------------------------------------------------*/
889
890/* USB_REQ_SET_CONNECTION modifies or revokes a connection context (CC).
891 * A CC may also be set up using non-wireless secure channels (including
892 * wired USB!), and some devices may support CCs with multiple hosts.
893 */
894struct usb_connection_context {
895 __u8 CHID[16]; /* persistent host id */
896 __u8 CDID[16]; /* device id (unique w/in host context) */
897 __u8 CK[16]; /* connection key */
898} __attribute__((packed));
899
900/*-------------------------------------------------------------------------*/
901 36
902/* USB 2.0 defines three speeds, here's how Linux identifies them */
903
904enum usb_device_speed {
905 USB_SPEED_UNKNOWN = 0, /* enumerating */
906 USB_SPEED_LOW, USB_SPEED_FULL, /* usb 1.1 */
907 USB_SPEED_HIGH, /* usb 2.0 */
908 USB_SPEED_WIRELESS, /* wireless (usb 2.5) */
909 USB_SPEED_SUPER, /* usb 3.0 */
910};
911
912#ifdef __KERNEL__
913 37
914/** 38/**
915 * usb_speed_string() - Returns human readable-name of the speed. 39 * usb_speed_string() - Returns human readable-name of the speed.
@@ -919,86 +43,4 @@ enum usb_device_speed {
919 */ 43 */
920extern const char *usb_speed_string(enum usb_device_speed speed); 44extern const char *usb_speed_string(enum usb_device_speed speed);
921 45
922#endif
923
924enum usb_device_state {
925 /* NOTATTACHED isn't in the USB spec, and this state acts
926 * the same as ATTACHED ... but it's clearer this way.
927 */
928 USB_STATE_NOTATTACHED = 0,
929
930 /* chapter 9 and authentication (wireless) device states */
931 USB_STATE_ATTACHED,
932 USB_STATE_POWERED, /* wired */
933 USB_STATE_RECONNECTING, /* auth */
934 USB_STATE_UNAUTHENTICATED, /* auth */
935 USB_STATE_DEFAULT, /* limited function */
936 USB_STATE_ADDRESS,
937 USB_STATE_CONFIGURED, /* most functions */
938
939 USB_STATE_SUSPENDED
940
941 /* NOTE: there are actually four different SUSPENDED
942 * states, returning to POWERED, DEFAULT, ADDRESS, or
943 * CONFIGURED respectively when SOF tokens flow again.
944 * At this level there's no difference between L1 and L2
945 * suspend states. (L2 being original USB 1.1 suspend.)
946 */
947};
948
949enum usb3_link_state {
950 USB3_LPM_U0 = 0,
951 USB3_LPM_U1,
952 USB3_LPM_U2,
953 USB3_LPM_U3
954};
955
956/*
957 * A U1 timeout of 0x0 means the parent hub will reject any transitions to U1.
958 * 0xff means the parent hub will accept transitions to U1, but will not
959 * initiate a transition.
960 *
961 * A U1 timeout of 0x1 to 0x7F also causes the hub to initiate a transition to
962 * U1 after that many microseconds. Timeouts of 0x80 to 0xFE are reserved
963 * values.
964 *
965 * A U2 timeout of 0x0 means the parent hub will reject any transitions to U2.
966 * 0xff means the parent hub will accept transitions to U2, but will not
967 * initiate a transition.
968 *
969 * A U2 timeout of 0x1 to 0xFE also causes the hub to initiate a transition to
970 * U2 after N*256 microseconds. Therefore a U2 timeout value of 0x1 means a U2
971 * idle timer of 256 microseconds, 0x2 means 512 microseconds, 0xFE means
972 * 65.024ms.
973 */
974#define USB3_LPM_DISABLED 0x0
975#define USB3_LPM_U1_MAX_TIMEOUT 0x7F
976#define USB3_LPM_U2_MAX_TIMEOUT 0xFE
977#define USB3_LPM_DEVICE_INITIATED 0xFF
978
979struct usb_set_sel_req {
980 __u8 u1_sel;
981 __u8 u1_pel;
982 __le16 u2_sel;
983 __le16 u2_pel;
984} __attribute__ ((packed));
985
986/*
987 * The Set System Exit Latency control transfer provides one byte each for
988 * U1 SEL and U1 PEL, so the max exit latency is 0xFF. U2 SEL and U2 PEL each
989 * are two bytes long.
990 */
991#define USB3_LPM_MAX_U1_SEL_PEL 0xFF
992#define USB3_LPM_MAX_U2_SEL_PEL 0xFFFF
993
994/*-------------------------------------------------------------------------*/
995
996/*
997 * As per USB compliance update, a device that is actively drawing
998 * more than 100mA from USB must report itself as bus-powered in
999 * the GetStatus(DEVICE) call.
1000 * http://compliance.usb.org/index.asp?UpdateFile=Electrical&Format=Standard#34
1001 */
1002#define USB_SELF_POWER_VBUS_MAX_DRAW 100
1003
1004#endif /* __LINUX_USB_CH9_H */ 46#endif /* __LINUX_USB_CH9_H */
diff --git a/include/linux/usb/functionfs.h b/include/linux/usb/functionfs.h
index a843d085136..65d0a88dbc6 100644
--- a/include/linux/usb/functionfs.h
+++ b/include/linux/usb/functionfs.h
@@ -1,171 +1,8 @@
1#ifndef __LINUX_FUNCTIONFS_H__ 1#ifndef __LINUX_FUNCTIONFS_H__
2#define __LINUX_FUNCTIONFS_H__ 1 2#define __LINUX_FUNCTIONFS_H__ 1
3 3
4#include <uapi/linux/usb/functionfs.h>
4 5
5#include <linux/types.h>
6#include <linux/ioctl.h>
7
8#include <linux/usb/ch9.h>
9
10
11enum {
12 FUNCTIONFS_DESCRIPTORS_MAGIC = 1,
13 FUNCTIONFS_STRINGS_MAGIC = 2
14};
15
16
17#ifndef __KERNEL__
18
19/* Descriptor of an non-audio endpoint */
20struct usb_endpoint_descriptor_no_audio {
21 __u8 bLength;
22 __u8 bDescriptorType;
23
24 __u8 bEndpointAddress;
25 __u8 bmAttributes;
26 __le16 wMaxPacketSize;
27 __u8 bInterval;
28} __attribute__((packed));
29
30
31/*
32 * All numbers must be in little endian order.
33 */
34
35struct usb_functionfs_descs_head {
36 __le32 magic;
37 __le32 length;
38 __le32 fs_count;
39 __le32 hs_count;
40} __attribute__((packed));
41
42/*
43 * Descriptors format:
44 *
45 * | off | name | type | description |
46 * |-----+-----------+--------------+--------------------------------------|
47 * | 0 | magic | LE32 | FUNCTIONFS_{FS,HS}_DESCRIPTORS_MAGIC |
48 * | 4 | length | LE32 | length of the whole data chunk |
49 * | 8 | fs_count | LE32 | number of full-speed descriptors |
50 * | 12 | hs_count | LE32 | number of high-speed descriptors |
51 * | 16 | fs_descrs | Descriptor[] | list of full-speed descriptors |
52 * | | hs_descrs | Descriptor[] | list of high-speed descriptors |
53 *
54 * descs are just valid USB descriptors and have the following format:
55 *
56 * | off | name | type | description |
57 * |-----+-----------------+------+--------------------------|
58 * | 0 | bLength | U8 | length of the descriptor |
59 * | 1 | bDescriptorType | U8 | descriptor type |
60 * | 2 | payload | | descriptor's payload |
61 */
62
63struct usb_functionfs_strings_head {
64 __le32 magic;
65 __le32 length;
66 __le32 str_count;
67 __le32 lang_count;
68} __attribute__((packed));
69
70/*
71 * Strings format:
72 *
73 * | off | name | type | description |
74 * |-----+------------+-----------------------+----------------------------|
75 * | 0 | magic | LE32 | FUNCTIONFS_STRINGS_MAGIC |
76 * | 4 | length | LE32 | length of the data chunk |
77 * | 8 | str_count | LE32 | number of strings |
78 * | 12 | lang_count | LE32 | number of languages |
79 * | 16 | stringtab | StringTab[lang_count] | table of strings per lang |
80 *
81 * For each language there is one stringtab entry (ie. there are lang_count
82 * stringtab entires). Each StringTab has following format:
83 *
84 * | off | name | type | description |
85 * |-----+---------+-------------------+------------------------------------|
86 * | 0 | lang | LE16 | language code |
87 * | 2 | strings | String[str_count] | array of strings in given language |
88 *
89 * For each string there is one strings entry (ie. there are str_count
90 * string entries). Each String is a NUL terminated string encoded in
91 * UTF-8.
92 */
93
94#endif
95
96
97/*
98 * Events are delivered on the ep0 file descriptor, when the user mode driver
99 * reads from this file descriptor after writing the descriptors. Don't
100 * stop polling this descriptor.
101 */
102
103enum usb_functionfs_event_type {
104 FUNCTIONFS_BIND,
105 FUNCTIONFS_UNBIND,
106
107 FUNCTIONFS_ENABLE,
108 FUNCTIONFS_DISABLE,
109
110 FUNCTIONFS_SETUP,
111
112 FUNCTIONFS_SUSPEND,
113 FUNCTIONFS_RESUME
114};
115
116/* NOTE: this structure must stay the same size and layout on
117 * both 32-bit and 64-bit kernels.
118 */
119struct usb_functionfs_event {
120 union {
121 /* SETUP: packet; DATA phase i/o precedes next event
122 *(setup.bmRequestType & USB_DIR_IN) flags direction */
123 struct usb_ctrlrequest setup;
124 } __attribute__((packed)) u;
125
126 /* enum usb_functionfs_event_type */
127 __u8 type;
128 __u8 _pad[3];
129} __attribute__((packed));
130
131
132/* Endpoint ioctls */
133/* The same as in gadgetfs */
134
135/* IN transfers may be reported to the gadget driver as complete
136 * when the fifo is loaded, before the host reads the data;
137 * OUT transfers may be reported to the host's "client" driver as
138 * complete when they're sitting in the FIFO unread.
139 * THIS returns how many bytes are "unclaimed" in the endpoint fifo
140 * (needed for precise fault handling, when the hardware allows it)
141 */
142#define FUNCTIONFS_FIFO_STATUS _IO('g', 1)
143
144/* discards any unclaimed data in the fifo. */
145#define FUNCTIONFS_FIFO_FLUSH _IO('g', 2)
146
147/* resets endpoint halt+toggle; used to implement set_interface.
148 * some hardware (like pxa2xx) can't support this.
149 */
150#define FUNCTIONFS_CLEAR_HALT _IO('g', 3)
151
152/* Specific for functionfs */
153
154/*
155 * Returns reverse mapping of an interface. Called on EP0. If there
156 * is no such interface returns -EDOM. If function is not active
157 * returns -ENODEV.
158 */
159#define FUNCTIONFS_INTERFACE_REVMAP _IO('g', 128)
160
161/*
162 * Returns real bEndpointAddress of an endpoint. If function is not
163 * active returns -ENODEV.
164 */
165#define FUNCTIONFS_ENDPOINT_REVMAP _IO('g', 129)
166
167
168#ifdef __KERNEL__
169 6
170struct ffs_data; 7struct ffs_data;
171struct usb_composite_dev; 8struct usb_composite_dev;
@@ -197,5 +34,3 @@ static void functionfs_release_dev_callback(struct ffs_data *ffs_data)
197 34
198 35
199#endif 36#endif
200
201#endif
diff --git a/include/linux/wimax/Kbuild b/include/linux/wimax/Kbuild
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/include/linux/wimax/Kbuild
+++ /dev/null
diff --git a/include/mtd/Kbuild b/include/mtd/Kbuild
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/include/mtd/Kbuild
+++ /dev/null
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 1b498908224..7d5b6000378 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -1218,6 +1218,7 @@ struct cfg80211_deauth_request {
1218 const u8 *ie; 1218 const u8 *ie;
1219 size_t ie_len; 1219 size_t ie_len;
1220 u16 reason_code; 1220 u16 reason_code;
1221 bool local_state_change;
1221}; 1222};
1222 1223
1223/** 1224/**
@@ -2651,6 +2652,15 @@ unsigned int ieee80211_get_hdrlen_from_skb(const struct sk_buff *skb);
2651unsigned int __attribute_const__ ieee80211_hdrlen(__le16 fc); 2652unsigned int __attribute_const__ ieee80211_hdrlen(__le16 fc);
2652 2653
2653/** 2654/**
2655 * ieee80211_get_mesh_hdrlen - get mesh extension header length
2656 * @meshhdr: the mesh extension header, only the flags field
2657 * (first byte) will be accessed
2658 * Returns the length of the extension header, which is always at
2659 * least 6 bytes and at most 18 if address 5 and 6 are present.
2660 */
2661unsigned int ieee80211_get_mesh_hdrlen(struct ieee80211s_hdr *meshhdr);
2662
2663/**
2654 * DOC: Data path helpers 2664 * DOC: Data path helpers
2655 * 2665 *
2656 * In addition to generic utilities, cfg80211 also offers 2666 * In addition to generic utilities, cfg80211 also offers
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index 6f0ba01afe7..63445ede48b 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -1351,7 +1351,7 @@ struct xfrm6_tunnel {
1351}; 1351};
1352 1352
1353extern void xfrm_init(void); 1353extern void xfrm_init(void);
1354extern void xfrm4_init(int rt_hash_size); 1354extern void xfrm4_init(void);
1355extern int xfrm_state_init(struct net *net); 1355extern int xfrm_state_init(struct net *net);
1356extern void xfrm_state_fini(struct net *net); 1356extern void xfrm_state_fini(struct net *net);
1357extern void xfrm4_state_init(void); 1357extern void xfrm4_state_init(void);
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index 88fae8d2015..55367b04dc9 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -135,6 +135,8 @@ struct scsi_device {
135 * because we did a bus reset. */ 135 * because we did a bus reset. */
136 unsigned use_10_for_rw:1; /* first try 10-byte read / write */ 136 unsigned use_10_for_rw:1; /* first try 10-byte read / write */
137 unsigned use_10_for_ms:1; /* first try 10-byte mode sense/select */ 137 unsigned use_10_for_ms:1; /* first try 10-byte mode sense/select */
138 unsigned no_report_opcodes:1; /* no REPORT SUPPORTED OPERATION CODES */
139 unsigned no_write_same:1; /* no WRITE SAME command */
138 unsigned skip_ms_page_8:1; /* do not use MODE SENSE page 0x08 */ 140 unsigned skip_ms_page_8:1; /* do not use MODE SENSE page 0x08 */
139 unsigned skip_ms_page_3f:1; /* do not use MODE SENSE page 0x3f */ 141 unsigned skip_ms_page_3f:1; /* do not use MODE SENSE page 0x3f */
140 unsigned skip_vpd_pages:1; /* do not read VPD pages */ 142 unsigned skip_vpd_pages:1; /* do not read VPD pages */
@@ -362,6 +364,8 @@ extern int scsi_test_unit_ready(struct scsi_device *sdev, int timeout,
362 int retries, struct scsi_sense_hdr *sshdr); 364 int retries, struct scsi_sense_hdr *sshdr);
363extern int scsi_get_vpd_page(struct scsi_device *, u8 page, unsigned char *buf, 365extern int scsi_get_vpd_page(struct scsi_device *, u8 page, unsigned char *buf,
364 int buf_len); 366 int buf_len);
367extern int scsi_report_opcode(struct scsi_device *sdev, unsigned char *buffer,
368 unsigned int len, unsigned char opcode);
365extern int scsi_device_set_state(struct scsi_device *sdev, 369extern int scsi_device_set_state(struct scsi_device *sdev,
366 enum scsi_device_state state); 370 enum scsi_device_state state);
367extern struct scsi_event *sdev_evt_alloc(enum scsi_device_event evt_type, 371extern struct scsi_event *sdev_evt_alloc(enum scsi_device_event evt_type,
diff --git a/include/sound/core.h b/include/sound/core.h
index bc056687f64..93896ad1fcd 100644
--- a/include/sound/core.h
+++ b/include/sound/core.h
@@ -132,6 +132,7 @@ struct snd_card {
132 int shutdown; /* this card is going down */ 132 int shutdown; /* this card is going down */
133 int free_on_last_close; /* free in context of file_release */ 133 int free_on_last_close; /* free in context of file_release */
134 wait_queue_head_t shutdown_sleep; 134 wait_queue_head_t shutdown_sleep;
135 atomic_t refcount; /* refcount for disconnection */
135 struct device *dev; /* device assigned to this card */ 136 struct device *dev; /* device assigned to this card */
136 struct device *card_dev; /* cardX object for sysfs */ 137 struct device *card_dev; /* cardX object for sysfs */
137 138
@@ -189,6 +190,7 @@ struct snd_minor {
189 const struct file_operations *f_ops; /* file operations */ 190 const struct file_operations *f_ops; /* file operations */
190 void *private_data; /* private data for f_ops->open */ 191 void *private_data; /* private data for f_ops->open */
191 struct device *dev; /* device for sysfs */ 192 struct device *dev; /* device for sysfs */
193 struct snd_card *card_ptr; /* assigned card instance */
192}; 194};
193 195
194/* return a device pointer linked to each sound device as a parent */ 196/* return a device pointer linked to each sound device as a parent */
@@ -295,6 +297,7 @@ int snd_card_info_done(void);
295int snd_component_add(struct snd_card *card, const char *component); 297int snd_component_add(struct snd_card *card, const char *component);
296int snd_card_file_add(struct snd_card *card, struct file *file); 298int snd_card_file_add(struct snd_card *card, struct file *file);
297int snd_card_file_remove(struct snd_card *card, struct file *file); 299int snd_card_file_remove(struct snd_card *card, struct file *file);
300void snd_card_unref(struct snd_card *card);
298 301
299#define snd_card_set_dev(card, devptr) ((card)->dev = (devptr)) 302#define snd_card_set_dev(card, devptr) ((card)->dev = (devptr))
300 303
diff --git a/include/trace/events/xen.h b/include/trace/events/xen.h
index 15ba03bdd7c..d06b6da5c1e 100644
--- a/include/trace/events/xen.h
+++ b/include/trace/events/xen.h
@@ -377,6 +377,14 @@ DECLARE_EVENT_CLASS(xen_mmu_pgd,
377DEFINE_XEN_MMU_PGD_EVENT(xen_mmu_pgd_pin); 377DEFINE_XEN_MMU_PGD_EVENT(xen_mmu_pgd_pin);
378DEFINE_XEN_MMU_PGD_EVENT(xen_mmu_pgd_unpin); 378DEFINE_XEN_MMU_PGD_EVENT(xen_mmu_pgd_unpin);
379 379
380TRACE_EVENT(xen_mmu_flush_tlb_all,
381 TP_PROTO(int x),
382 TP_ARGS(x),
383 TP_STRUCT__entry(__array(char, x, 0)),
384 TP_fast_assign((void)x),
385 TP_printk("%s", "")
386 );
387
380TRACE_EVENT(xen_mmu_flush_tlb, 388TRACE_EVENT(xen_mmu_flush_tlb,
381 TP_PROTO(int x), 389 TP_PROTO(int x),
382 TP_ARGS(x), 390 TP_ARGS(x),
diff --git a/include/uapi/asm-generic/kvm_para.h b/include/uapi/asm-generic/kvm_para.h
index e69de29bb2d..486f0af73c3 100644
--- a/include/uapi/asm-generic/kvm_para.h
+++ b/include/uapi/asm-generic/kvm_para.h
@@ -0,0 +1,4 @@
1/*
2 * There isn't anything here, but the file must not be empty or patch
3 * will delete it.
4 */
diff --git a/include/uapi/linux/dvb/Kbuild b/include/uapi/linux/dvb/Kbuild
index aafaa5aa54d..d40942cfc62 100644
--- a/include/uapi/linux/dvb/Kbuild
+++ b/include/uapi/linux/dvb/Kbuild
@@ -1 +1,9 @@
1# UAPI Header export list 1# UAPI Header export list
2header-y += audio.h
3header-y += ca.h
4header-y += dmx.h
5header-y += frontend.h
6header-y += net.h
7header-y += osd.h
8header-y += version.h
9header-y += video.h
diff --git a/include/linux/dvb/audio.h b/include/uapi/linux/dvb/audio.h
index d47bccd604e..d47bccd604e 100644
--- a/include/linux/dvb/audio.h
+++ b/include/uapi/linux/dvb/audio.h
diff --git a/include/linux/dvb/ca.h b/include/uapi/linux/dvb/ca.h
index c18537f3e44..c18537f3e44 100644
--- a/include/linux/dvb/ca.h
+++ b/include/uapi/linux/dvb/ca.h
diff --git a/include/uapi/linux/dvb/dmx.h b/include/uapi/linux/dvb/dmx.h
new file mode 100644
index 00000000000..b2a9ad8cafd
--- /dev/null
+++ b/include/uapi/linux/dvb/dmx.h
@@ -0,0 +1,155 @@
1/*
2 * dmx.h
3 *
4 * Copyright (C) 2000 Marcus Metzler <marcus@convergence.de>
5 * & Ralph Metzler <ralph@convergence.de>
6 * for convergence integrated media GmbH
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation; either version 2.1
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 *
22 */
23
24#ifndef _UAPI_DVBDMX_H_
25#define _UAPI_DVBDMX_H_
26
27#include <linux/types.h>
28#ifndef __KERNEL__
29#include <time.h>
30#endif
31
32
33#define DMX_FILTER_SIZE 16
34
35typedef enum
36{
37 DMX_OUT_DECODER, /* Streaming directly to decoder. */
38 DMX_OUT_TAP, /* Output going to a memory buffer */
39 /* (to be retrieved via the read command).*/
40 DMX_OUT_TS_TAP, /* Output multiplexed into a new TS */
41 /* (to be retrieved by reading from the */
42 /* logical DVR device). */
43 DMX_OUT_TSDEMUX_TAP /* Like TS_TAP but retrieved from the DMX device */
44} dmx_output_t;
45
46
47typedef enum
48{
49 DMX_IN_FRONTEND, /* Input from a front-end device. */
50 DMX_IN_DVR /* Input from the logical DVR device. */
51} dmx_input_t;
52
53
54typedef enum
55{
56 DMX_PES_AUDIO0,
57 DMX_PES_VIDEO0,
58 DMX_PES_TELETEXT0,
59 DMX_PES_SUBTITLE0,
60 DMX_PES_PCR0,
61
62 DMX_PES_AUDIO1,
63 DMX_PES_VIDEO1,
64 DMX_PES_TELETEXT1,
65 DMX_PES_SUBTITLE1,
66 DMX_PES_PCR1,
67
68 DMX_PES_AUDIO2,
69 DMX_PES_VIDEO2,
70 DMX_PES_TELETEXT2,
71 DMX_PES_SUBTITLE2,
72 DMX_PES_PCR2,
73
74 DMX_PES_AUDIO3,
75 DMX_PES_VIDEO3,
76 DMX_PES_TELETEXT3,
77 DMX_PES_SUBTITLE3,
78 DMX_PES_PCR3,
79
80 DMX_PES_OTHER
81} dmx_pes_type_t;
82
83#define DMX_PES_AUDIO DMX_PES_AUDIO0
84#define DMX_PES_VIDEO DMX_PES_VIDEO0
85#define DMX_PES_TELETEXT DMX_PES_TELETEXT0
86#define DMX_PES_SUBTITLE DMX_PES_SUBTITLE0
87#define DMX_PES_PCR DMX_PES_PCR0
88
89
90typedef struct dmx_filter
91{
92 __u8 filter[DMX_FILTER_SIZE];
93 __u8 mask[DMX_FILTER_SIZE];
94 __u8 mode[DMX_FILTER_SIZE];
95} dmx_filter_t;
96
97
98struct dmx_sct_filter_params
99{
100 __u16 pid;
101 dmx_filter_t filter;
102 __u32 timeout;
103 __u32 flags;
104#define DMX_CHECK_CRC 1
105#define DMX_ONESHOT 2
106#define DMX_IMMEDIATE_START 4
107#define DMX_KERNEL_CLIENT 0x8000
108};
109
110
111struct dmx_pes_filter_params
112{
113 __u16 pid;
114 dmx_input_t input;
115 dmx_output_t output;
116 dmx_pes_type_t pes_type;
117 __u32 flags;
118};
119
120typedef struct dmx_caps {
121 __u32 caps;
122 int num_decoders;
123} dmx_caps_t;
124
125typedef enum {
126 DMX_SOURCE_FRONT0 = 0,
127 DMX_SOURCE_FRONT1,
128 DMX_SOURCE_FRONT2,
129 DMX_SOURCE_FRONT3,
130 DMX_SOURCE_DVR0 = 16,
131 DMX_SOURCE_DVR1,
132 DMX_SOURCE_DVR2,
133 DMX_SOURCE_DVR3
134} dmx_source_t;
135
136struct dmx_stc {
137 unsigned int num; /* input : which STC? 0..N */
138 unsigned int base; /* output: divisor for stc to get 90 kHz clock */
139 __u64 stc; /* output: stc in 'base'*90 kHz units */
140};
141
142
143#define DMX_START _IO('o', 41)
144#define DMX_STOP _IO('o', 42)
145#define DMX_SET_FILTER _IOW('o', 43, struct dmx_sct_filter_params)
146#define DMX_SET_PES_FILTER _IOW('o', 44, struct dmx_pes_filter_params)
147#define DMX_SET_BUFFER_SIZE _IO('o', 45)
148#define DMX_GET_PES_PIDS _IOR('o', 47, __u16[5])
149#define DMX_GET_CAPS _IOR('o', 48, dmx_caps_t)
150#define DMX_SET_SOURCE _IOW('o', 49, dmx_source_t)
151#define DMX_GET_STC _IOWR('o', 50, struct dmx_stc)
152#define DMX_ADD_PID _IOW('o', 51, __u16)
153#define DMX_REMOVE_PID _IOW('o', 52, __u16)
154
155#endif /* _UAPI_DVBDMX_H_ */
diff --git a/include/linux/dvb/frontend.h b/include/uapi/linux/dvb/frontend.h
index c12d452cb40..c12d452cb40 100644
--- a/include/linux/dvb/frontend.h
+++ b/include/uapi/linux/dvb/frontend.h
diff --git a/include/linux/dvb/net.h b/include/uapi/linux/dvb/net.h
index f451e7eb0b0..f451e7eb0b0 100644
--- a/include/linux/dvb/net.h
+++ b/include/uapi/linux/dvb/net.h
diff --git a/include/linux/dvb/osd.h b/include/uapi/linux/dvb/osd.h
index 880e6843583..880e6843583 100644
--- a/include/linux/dvb/osd.h
+++ b/include/uapi/linux/dvb/osd.h
diff --git a/include/linux/dvb/version.h b/include/uapi/linux/dvb/version.h
index 827cce7e33e..827cce7e33e 100644
--- a/include/linux/dvb/version.h
+++ b/include/uapi/linux/dvb/version.h
diff --git a/include/uapi/linux/dvb/video.h b/include/uapi/linux/dvb/video.h
new file mode 100644
index 00000000000..d3d14a59d2d
--- /dev/null
+++ b/include/uapi/linux/dvb/video.h
@@ -0,0 +1,274 @@
1/*
2 * video.h
3 *
4 * Copyright (C) 2000 Marcus Metzler <marcus@convergence.de>
5 * & Ralph Metzler <ralph@convergence.de>
6 * for convergence integrated media GmbH
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation; either version 2.1
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 *
22 */
23
24#ifndef _UAPI_DVBVIDEO_H_
25#define _UAPI_DVBVIDEO_H_
26
27#include <linux/types.h>
28#ifndef __KERNEL__
29#include <stdint.h>
30#include <time.h>
31#endif
32
33typedef enum {
34 VIDEO_FORMAT_4_3, /* Select 4:3 format */
35 VIDEO_FORMAT_16_9, /* Select 16:9 format. */
36 VIDEO_FORMAT_221_1 /* 2.21:1 */
37} video_format_t;
38
39
40typedef enum {
41 VIDEO_SYSTEM_PAL,
42 VIDEO_SYSTEM_NTSC,
43 VIDEO_SYSTEM_PALN,
44 VIDEO_SYSTEM_PALNc,
45 VIDEO_SYSTEM_PALM,
46 VIDEO_SYSTEM_NTSC60,
47 VIDEO_SYSTEM_PAL60,
48 VIDEO_SYSTEM_PALM60
49} video_system_t;
50
51
52typedef enum {
53 VIDEO_PAN_SCAN, /* use pan and scan format */
54 VIDEO_LETTER_BOX, /* use letterbox format */
55 VIDEO_CENTER_CUT_OUT /* use center cut out format */
56} video_displayformat_t;
57
58typedef struct {
59 int w;
60 int h;
61 video_format_t aspect_ratio;
62} video_size_t;
63
64typedef enum {
65 VIDEO_SOURCE_DEMUX, /* Select the demux as the main source */
66 VIDEO_SOURCE_MEMORY /* If this source is selected, the stream
67 comes from the user through the write
68 system call */
69} video_stream_source_t;
70
71
72typedef enum {
73 VIDEO_STOPPED, /* Video is stopped */
74 VIDEO_PLAYING, /* Video is currently playing */
75 VIDEO_FREEZED /* Video is freezed */
76} video_play_state_t;
77
78
79/* Decoder commands */
80#define VIDEO_CMD_PLAY (0)
81#define VIDEO_CMD_STOP (1)
82#define VIDEO_CMD_FREEZE (2)
83#define VIDEO_CMD_CONTINUE (3)
84
85/* Flags for VIDEO_CMD_FREEZE */
86#define VIDEO_CMD_FREEZE_TO_BLACK (1 << 0)
87
88/* Flags for VIDEO_CMD_STOP */
89#define VIDEO_CMD_STOP_TO_BLACK (1 << 0)
90#define VIDEO_CMD_STOP_IMMEDIATELY (1 << 1)
91
92/* Play input formats: */
93/* The decoder has no special format requirements */
94#define VIDEO_PLAY_FMT_NONE (0)
95/* The decoder requires full GOPs */
96#define VIDEO_PLAY_FMT_GOP (1)
97
98/* The structure must be zeroed before use by the application
99 This ensures it can be extended safely in the future. */
100struct video_command {
101 __u32 cmd;
102 __u32 flags;
103 union {
104 struct {
105 __u64 pts;
106 } stop;
107
108 struct {
109 /* 0 or 1000 specifies normal speed,
110 1 specifies forward single stepping,
111 -1 specifies backward single stepping,
112 >1: playback at speed/1000 of the normal speed,
113 <-1: reverse playback at (-speed/1000) of the normal speed. */
114 __s32 speed;
115 __u32 format;
116 } play;
117
118 struct {
119 __u32 data[16];
120 } raw;
121 };
122};
123
124/* FIELD_UNKNOWN can be used if the hardware does not know whether
125 the Vsync is for an odd, even or progressive (i.e. non-interlaced)
126 field. */
127#define VIDEO_VSYNC_FIELD_UNKNOWN (0)
128#define VIDEO_VSYNC_FIELD_ODD (1)
129#define VIDEO_VSYNC_FIELD_EVEN (2)
130#define VIDEO_VSYNC_FIELD_PROGRESSIVE (3)
131
132struct video_event {
133 __s32 type;
134#define VIDEO_EVENT_SIZE_CHANGED 1
135#define VIDEO_EVENT_FRAME_RATE_CHANGED 2
136#define VIDEO_EVENT_DECODER_STOPPED 3
137#define VIDEO_EVENT_VSYNC 4
138 __kernel_time_t timestamp;
139 union {
140 video_size_t size;
141 unsigned int frame_rate; /* in frames per 1000sec */
142 unsigned char vsync_field; /* unknown/odd/even/progressive */
143 } u;
144};
145
146
147struct video_status {
148 int video_blank; /* blank video on freeze? */
149 video_play_state_t play_state; /* current state of playback */
150 video_stream_source_t stream_source; /* current source (demux/memory) */
151 video_format_t video_format; /* current aspect ratio of stream*/
152 video_displayformat_t display_format;/* selected cropping mode */
153};
154
155
156struct video_still_picture {
157 char __user *iFrame; /* pointer to a single iframe in memory */
158 __s32 size;
159};
160
161
162typedef
163struct video_highlight {
164 int active; /* 1=show highlight, 0=hide highlight */
165 __u8 contrast1; /* 7- 4 Pattern pixel contrast */
166 /* 3- 0 Background pixel contrast */
167 __u8 contrast2; /* 7- 4 Emphasis pixel-2 contrast */
168 /* 3- 0 Emphasis pixel-1 contrast */
169 __u8 color1; /* 7- 4 Pattern pixel color */
170 /* 3- 0 Background pixel color */
171 __u8 color2; /* 7- 4 Emphasis pixel-2 color */
172 /* 3- 0 Emphasis pixel-1 color */
173 __u32 ypos; /* 23-22 auto action mode */
174 /* 21-12 start y */
175 /* 9- 0 end y */
176 __u32 xpos; /* 23-22 button color number */
177 /* 21-12 start x */
178 /* 9- 0 end x */
179} video_highlight_t;
180
181
182typedef struct video_spu {
183 int active;
184 int stream_id;
185} video_spu_t;
186
187
188typedef struct video_spu_palette { /* SPU Palette information */
189 int length;
190 __u8 __user *palette;
191} video_spu_palette_t;
192
193
194typedef struct video_navi_pack {
195 int length; /* 0 ... 1024 */
196 __u8 data[1024];
197} video_navi_pack_t;
198
199
200typedef __u16 video_attributes_t;
201/* bits: descr. */
202/* 15-14 Video compression mode (0=MPEG-1, 1=MPEG-2) */
203/* 13-12 TV system (0=525/60, 1=625/50) */
204/* 11-10 Aspect ratio (0=4:3, 3=16:9) */
205/* 9- 8 permitted display mode on 4:3 monitor (0=both, 1=only pan-sca */
206/* 7 line 21-1 data present in GOP (1=yes, 0=no) */
207/* 6 line 21-2 data present in GOP (1=yes, 0=no) */
208/* 5- 3 source resolution (0=720x480/576, 1=704x480/576, 2=352x480/57 */
209/* 2 source letterboxed (1=yes, 0=no) */
210/* 0 film/camera mode (0=camera, 1=film (625/50 only)) */
211
212
213/* bit definitions for capabilities: */
214/* can the hardware decode MPEG1 and/or MPEG2? */
215#define VIDEO_CAP_MPEG1 1
216#define VIDEO_CAP_MPEG2 2
217/* can you send a system and/or program stream to video device?
218 (you still have to open the video and the audio device but only
219 send the stream to the video device) */
220#define VIDEO_CAP_SYS 4
221#define VIDEO_CAP_PROG 8
222/* can the driver also handle SPU, NAVI and CSS encoded data?
223 (CSS API is not present yet) */
224#define VIDEO_CAP_SPU 16
225#define VIDEO_CAP_NAVI 32
226#define VIDEO_CAP_CSS 64
227
228
229#define VIDEO_STOP _IO('o', 21)
230#define VIDEO_PLAY _IO('o', 22)
231#define VIDEO_FREEZE _IO('o', 23)
232#define VIDEO_CONTINUE _IO('o', 24)
233#define VIDEO_SELECT_SOURCE _IO('o', 25)
234#define VIDEO_SET_BLANK _IO('o', 26)
235#define VIDEO_GET_STATUS _IOR('o', 27, struct video_status)
236#define VIDEO_GET_EVENT _IOR('o', 28, struct video_event)
237#define VIDEO_SET_DISPLAY_FORMAT _IO('o', 29)
238#define VIDEO_STILLPICTURE _IOW('o', 30, struct video_still_picture)
239#define VIDEO_FAST_FORWARD _IO('o', 31)
240#define VIDEO_SLOWMOTION _IO('o', 32)
241#define VIDEO_GET_CAPABILITIES _IOR('o', 33, unsigned int)
242#define VIDEO_CLEAR_BUFFER _IO('o', 34)
243#define VIDEO_SET_ID _IO('o', 35)
244#define VIDEO_SET_STREAMTYPE _IO('o', 36)
245#define VIDEO_SET_FORMAT _IO('o', 37)
246#define VIDEO_SET_SYSTEM _IO('o', 38)
247#define VIDEO_SET_HIGHLIGHT _IOW('o', 39, video_highlight_t)
248#define VIDEO_SET_SPU _IOW('o', 50, video_spu_t)
249#define VIDEO_SET_SPU_PALETTE _IOW('o', 51, video_spu_palette_t)
250#define VIDEO_GET_NAVI _IOR('o', 52, video_navi_pack_t)
251#define VIDEO_SET_ATTRIBUTES _IO('o', 53)
252#define VIDEO_GET_SIZE _IOR('o', 55, video_size_t)
253#define VIDEO_GET_FRAME_RATE _IOR('o', 56, unsigned int)
254
255/**
256 * VIDEO_GET_PTS
257 *
258 * Read the 33 bit presentation time stamp as defined
259 * in ITU T-REC-H.222.0 / ISO/IEC 13818-1.
260 *
261 * The PTS should belong to the currently played
262 * frame if possible, but may also be a value close to it
263 * like the PTS of the last decoded frame or the last PTS
264 * extracted by the PES parser.
265 */
266#define VIDEO_GET_PTS _IOR('o', 57, __u64)
267
268/* Read the number of displayed frames since the decoder was started */
269#define VIDEO_GET_FRAME_COUNT _IOR('o', 58, __u64)
270
271#define VIDEO_COMMAND _IOWR('o', 59, struct video_command)
272#define VIDEO_TRY_COMMAND _IOWR('o', 60, struct video_command)
273
274#endif /* _UAPI_DVBVIDEO_H_ */
diff --git a/include/uapi/linux/elf-fdpic.h b/include/uapi/linux/elf-fdpic.h
index 1065078938f..3921e33aec8 100644
--- a/include/uapi/linux/elf-fdpic.h
+++ b/include/uapi/linux/elf-fdpic.h
@@ -9,8 +9,8 @@
9 * 2 of the License, or (at your option) any later version. 9 * 2 of the License, or (at your option) any later version.
10 */ 10 */
11 11
12#ifndef _LINUX_ELF_FDPIC_H 12#ifndef _UAPI_LINUX_ELF_FDPIC_H
13#define _LINUX_ELF_FDPIC_H 13#define _UAPI_LINUX_ELF_FDPIC_H
14 14
15#include <linux/elf.h> 15#include <linux/elf.h>
16 16
@@ -31,40 +31,4 @@ struct elf32_fdpic_loadmap {
31 31
32#define ELF32_FDPIC_LOADMAP_VERSION 0x0000 32#define ELF32_FDPIC_LOADMAP_VERSION 0x0000
33 33
34#ifndef __KERNEL__ 34#endif /* _UAPI_LINUX_ELF_FDPIC_H */
35/*
36 * binfmt binary parameters structure
37 */
38struct elf_fdpic_params {
39 struct elfhdr hdr; /* ref copy of ELF header */
40 struct elf_phdr *phdrs; /* ref copy of PT_PHDR table */
41 struct elf32_fdpic_loadmap *loadmap; /* loadmap to be passed to userspace */
42 unsigned long elfhdr_addr; /* mapped ELF header user address */
43 unsigned long ph_addr; /* mapped PT_PHDR user address */
44 unsigned long map_addr; /* mapped loadmap user address */
45 unsigned long entry_addr; /* mapped entry user address */
46 unsigned long stack_size; /* stack size requested (PT_GNU_STACK) */
47 unsigned long dynamic_addr; /* mapped PT_DYNAMIC user address */
48 unsigned long load_addr; /* user address at which to map binary */
49 unsigned long flags;
50#define ELF_FDPIC_FLAG_ARRANGEMENT 0x0000000f /* PT_LOAD arrangement flags */
51#define ELF_FDPIC_FLAG_INDEPENDENT 0x00000000 /* PT_LOADs can be put anywhere */
52#define ELF_FDPIC_FLAG_HONOURVADDR 0x00000001 /* PT_LOAD.vaddr must be honoured */
53#define ELF_FDPIC_FLAG_CONSTDISP 0x00000002 /* PT_LOADs require constant
54 * displacement */
55#define ELF_FDPIC_FLAG_CONTIGUOUS 0x00000003 /* PT_LOADs should be contiguous */
56#define ELF_FDPIC_FLAG_EXEC_STACK 0x00000010 /* T if stack to be executable */
57#define ELF_FDPIC_FLAG_NOEXEC_STACK 0x00000020 /* T if stack not to be executable */
58#define ELF_FDPIC_FLAG_EXECUTABLE 0x00000040 /* T if this object is the executable */
59#define ELF_FDPIC_FLAG_PRESENT 0x80000000 /* T if this object is present */
60};
61
62#ifdef CONFIG_MMU
63extern void elf_fdpic_arch_lay_out_mm(struct elf_fdpic_params *exec_params,
64 struct elf_fdpic_params *interp_params,
65 unsigned long *start_stack,
66 unsigned long *start_brk);
67#endif
68#endif /* __KERNEL__ */
69
70#endif /* _LINUX_ELF_FDPIC_H */
diff --git a/include/uapi/linux/eventpoll.h b/include/uapi/linux/eventpoll.h
index 8c99ce7202c..2c267bcbb85 100644
--- a/include/uapi/linux/eventpoll.h
+++ b/include/uapi/linux/eventpoll.h
@@ -25,7 +25,6 @@
25#define EPOLL_CTL_ADD 1 25#define EPOLL_CTL_ADD 1
26#define EPOLL_CTL_DEL 2 26#define EPOLL_CTL_DEL 2
27#define EPOLL_CTL_MOD 3 27#define EPOLL_CTL_MOD 3
28#define EPOLL_CTL_DISABLE 4
29 28
30/* 29/*
31 * Request the handling of system wakeup events so as to prevent system suspends 30 * Request the handling of system wakeup events so as to prevent system suspends
diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h
index 9fcc880d4be..780d4c6093e 100644
--- a/include/uapi/linux/fs.h
+++ b/include/uapi/linux/fs.h
@@ -57,85 +57,6 @@ struct inodes_stat_t {
57 57
58#define NR_FILE 8192 /* this can well be larger on a larger system */ 58#define NR_FILE 8192 /* this can well be larger on a larger system */
59 59
60#define MAY_EXEC 0x00000001
61#define MAY_WRITE 0x00000002
62#define MAY_READ 0x00000004
63#define MAY_APPEND 0x00000008
64#define MAY_ACCESS 0x00000010
65#define MAY_OPEN 0x00000020
66#define MAY_CHDIR 0x00000040
67/* called from RCU mode, don't block */
68#define MAY_NOT_BLOCK 0x00000080
69
70/*
71 * flags in file.f_mode. Note that FMODE_READ and FMODE_WRITE must correspond
72 * to O_WRONLY and O_RDWR via the strange trick in __dentry_open()
73 */
74
75/* file is open for reading */
76#define FMODE_READ ((__force fmode_t)0x1)
77/* file is open for writing */
78#define FMODE_WRITE ((__force fmode_t)0x2)
79/* file is seekable */
80#define FMODE_LSEEK ((__force fmode_t)0x4)
81/* file can be accessed using pread */
82#define FMODE_PREAD ((__force fmode_t)0x8)
83/* file can be accessed using pwrite */
84#define FMODE_PWRITE ((__force fmode_t)0x10)
85/* File is opened for execution with sys_execve / sys_uselib */
86#define FMODE_EXEC ((__force fmode_t)0x20)
87/* File is opened with O_NDELAY (only set for block devices) */
88#define FMODE_NDELAY ((__force fmode_t)0x40)
89/* File is opened with O_EXCL (only set for block devices) */
90#define FMODE_EXCL ((__force fmode_t)0x80)
91/* File is opened using open(.., 3, ..) and is writeable only for ioctls
92 (specialy hack for floppy.c) */
93#define FMODE_WRITE_IOCTL ((__force fmode_t)0x100)
94/* 32bit hashes as llseek() offset (for directories) */
95#define FMODE_32BITHASH ((__force fmode_t)0x200)
96/* 64bit hashes as llseek() offset (for directories) */
97#define FMODE_64BITHASH ((__force fmode_t)0x400)
98
99/*
100 * Don't update ctime and mtime.
101 *
102 * Currently a special hack for the XFS open_by_handle ioctl, but we'll
103 * hopefully graduate it to a proper O_CMTIME flag supported by open(2) soon.
104 */
105#define FMODE_NOCMTIME ((__force fmode_t)0x800)
106
107/* Expect random access pattern */
108#define FMODE_RANDOM ((__force fmode_t)0x1000)
109
110/* File is huge (eg. /dev/kmem): treat loff_t as unsigned */
111#define FMODE_UNSIGNED_OFFSET ((__force fmode_t)0x2000)
112
113/* File is opened with O_PATH; almost nothing can be done with it */
114#define FMODE_PATH ((__force fmode_t)0x4000)
115
116/* File was opened by fanotify and shouldn't generate fanotify events */
117#define FMODE_NONOTIFY ((__force fmode_t)0x1000000)
118
119/*
120 * Flag for rw_copy_check_uvector and compat_rw_copy_check_uvector
121 * that indicates that they should check the contents of the iovec are
122 * valid, but not check the memory that the iovec elements
123 * points too.
124 */
125#define CHECK_IOVEC_ONLY -1
126
127#define SEL_IN 1
128#define SEL_OUT 2
129#define SEL_EX 4
130
131/* public flags for file_system_type */
132#define FS_REQUIRES_DEV 1
133#define FS_BINARY_MOUNTDATA 2
134#define FS_HAS_SUBTYPE 4
135#define FS_REVAL_DOT 16384 /* Check the paths ".", ".." for staleness */
136#define FS_RENAME_DOES_D_MOVE 32768 /* FS will handle d_move()
137 * during rename() internally.
138 */
139 60
140/* 61/*
141 * These are the fs-independent mount-flags: up to 32 flags are supported 62 * These are the fs-independent mount-flags: up to 32 flags are supported
@@ -181,59 +102,6 @@ struct inodes_stat_t {
181#define MS_MGC_VAL 0xC0ED0000 102#define MS_MGC_VAL 0xC0ED0000
182#define MS_MGC_MSK 0xffff0000 103#define MS_MGC_MSK 0xffff0000
183 104
184/* Inode flags - they have nothing to superblock flags now */
185
186#define S_SYNC 1 /* Writes are synced at once */
187#define S_NOATIME 2 /* Do not update access times */
188#define S_APPEND 4 /* Append-only file */
189#define S_IMMUTABLE 8 /* Immutable file */
190#define S_DEAD 16 /* removed, but still open directory */
191#define S_NOQUOTA 32 /* Inode is not counted to quota */
192#define S_DIRSYNC 64 /* Directory modifications are synchronous */
193#define S_NOCMTIME 128 /* Do not update file c/mtime */
194#define S_SWAPFILE 256 /* Do not truncate: swapon got its bmaps */
195#define S_PRIVATE 512 /* Inode is fs-internal */
196#define S_IMA 1024 /* Inode has an associated IMA struct */
197#define S_AUTOMOUNT 2048 /* Automount/referral quasi-directory */
198#define S_NOSEC 4096 /* no suid or xattr security attributes */
199
200/*
201 * Note that nosuid etc flags are inode-specific: setting some file-system
202 * flags just means all the inodes inherit those flags by default. It might be
203 * possible to override it selectively if you really wanted to with some
204 * ioctl() that is not currently implemented.
205 *
206 * Exception: MS_RDONLY is always applied to the entire file system.
207 *
208 * Unfortunately, it is possible to change a filesystems flags with it mounted
209 * with files in use. This means that all of the inodes will not have their
210 * i_flags updated. Hence, i_flags no longer inherit the superblock mount
211 * flags, so these have to be checked separately. -- rmk@arm.uk.linux.org
212 */
213#define __IS_FLG(inode,flg) ((inode)->i_sb->s_flags & (flg))
214
215#define IS_RDONLY(inode) ((inode)->i_sb->s_flags & MS_RDONLY)
216#define IS_SYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS) || \
217 ((inode)->i_flags & S_SYNC))
218#define IS_DIRSYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
219 ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
220#define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
221#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
222#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
223
224#define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
225#define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
226#define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
227#define IS_POSIXACL(inode) __IS_FLG(inode, MS_POSIXACL)
228
229#define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
230#define IS_NOCMTIME(inode) ((inode)->i_flags & S_NOCMTIME)
231#define IS_SWAPFILE(inode) ((inode)->i_flags & S_SWAPFILE)
232#define IS_PRIVATE(inode) ((inode)->i_flags & S_PRIVATE)
233#define IS_IMA(inode) ((inode)->i_flags & S_IMA)
234#define IS_AUTOMOUNT(inode) ((inode)->i_flags & S_AUTOMOUNT)
235#define IS_NOSEC(inode) ((inode)->i_flags & S_NOSEC)
236
237/* the read-only stuff doesn't really belong here, but any other place is 105/* the read-only stuff doesn't really belong here, but any other place is
238 probably as bad and I don't want to create yet another include file. */ 106 probably as bad and I don't want to create yet another include file. */
239 107
diff --git a/include/uapi/linux/hsi/Kbuild b/include/uapi/linux/hsi/Kbuild
index aafaa5aa54d..30ab3cd3b8a 100644
--- a/include/uapi/linux/hsi/Kbuild
+++ b/include/uapi/linux/hsi/Kbuild
@@ -1 +1,2 @@
1# UAPI Header export list 1# UAPI Header export list
2header-y += hsi_char.h
diff --git a/include/linux/hsi/hsi_char.h b/include/uapi/linux/hsi/hsi_char.h
index 76160b4f455..76160b4f455 100644
--- a/include/linux/hsi/hsi_char.h
+++ b/include/uapi/linux/hsi/hsi_char.h
diff --git a/include/uapi/linux/irqnr.h b/include/uapi/linux/irqnr.h
index e69de29bb2d..ae5704fa77a 100644
--- a/include/uapi/linux/irqnr.h
+++ b/include/uapi/linux/irqnr.h
@@ -0,0 +1,4 @@
1/*
2 * There isn't anything here anymore, but the file must not be empty or patch
3 * will delete it.
4 */
diff --git a/include/uapi/linux/oom.h b/include/uapi/linux/oom.h
index a49c4afc706..b29272d621c 100644
--- a/include/uapi/linux/oom.h
+++ b/include/uapi/linux/oom.h
@@ -8,4 +8,13 @@
8#define OOM_SCORE_ADJ_MIN (-1000) 8#define OOM_SCORE_ADJ_MIN (-1000)
9#define OOM_SCORE_ADJ_MAX 1000 9#define OOM_SCORE_ADJ_MAX 1000
10 10
11/*
12 * /proc/<pid>/oom_adj set to -17 protects from the oom killer for legacy
13 * purposes.
14 */
15#define OOM_DISABLE (-17)
16/* inclusive */
17#define OOM_ADJUST_MIN (-16)
18#define OOM_ADJUST_MAX 15
19
11#endif /* _UAPI__INCLUDE_LINUX_OOM_H */ 20#endif /* _UAPI__INCLUDE_LINUX_OOM_H */
diff --git a/include/uapi/linux/raid/Kbuild b/include/uapi/linux/raid/Kbuild
index aafaa5aa54d..e2c3d25405d 100644
--- a/include/uapi/linux/raid/Kbuild
+++ b/include/uapi/linux/raid/Kbuild
@@ -1 +1,3 @@
1# UAPI Header export list 1# UAPI Header export list
2header-y += md_p.h
3header-y += md_u.h
diff --git a/include/linux/raid/md_p.h b/include/uapi/linux/raid/md_p.h
index ee753536ab7..ee753536ab7 100644
--- a/include/linux/raid/md_p.h
+++ b/include/uapi/linux/raid/md_p.h
diff --git a/include/uapi/linux/raid/md_u.h b/include/uapi/linux/raid/md_u.h
new file mode 100644
index 00000000000..4133e744e4e
--- /dev/null
+++ b/include/uapi/linux/raid/md_u.h
@@ -0,0 +1,155 @@
1/*
2 md_u.h : user <=> kernel API between Linux raidtools and RAID drivers
3 Copyright (C) 1998 Ingo Molnar
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
8 any later version.
9
10 You should have received a copy of the GNU General Public License
11 (for example /usr/src/linux/COPYING); if not, write to the Free
12 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
13*/
14
15#ifndef _UAPI_MD_U_H
16#define _UAPI_MD_U_H
17
18/*
19 * Different major versions are not compatible.
20 * Different minor versions are only downward compatible.
21 * Different patchlevel versions are downward and upward compatible.
22 */
23#define MD_MAJOR_VERSION 0
24#define MD_MINOR_VERSION 90
25/*
26 * MD_PATCHLEVEL_VERSION indicates kernel functionality.
27 * >=1 means different superblock formats are selectable using SET_ARRAY_INFO
28 * and major_version/minor_version accordingly
29 * >=2 means that Internal bitmaps are supported by setting MD_SB_BITMAP_PRESENT
30 * in the super status byte
31 * >=3 means that bitmap superblock version 4 is supported, which uses
32 * little-ending representation rather than host-endian
33 */
34#define MD_PATCHLEVEL_VERSION 3
35
36/* ioctls */
37
38/* status */
39#define RAID_VERSION _IOR (MD_MAJOR, 0x10, mdu_version_t)
40#define GET_ARRAY_INFO _IOR (MD_MAJOR, 0x11, mdu_array_info_t)
41#define GET_DISK_INFO _IOR (MD_MAJOR, 0x12, mdu_disk_info_t)
42#define PRINT_RAID_DEBUG _IO (MD_MAJOR, 0x13)
43#define RAID_AUTORUN _IO (MD_MAJOR, 0x14)
44#define GET_BITMAP_FILE _IOR (MD_MAJOR, 0x15, mdu_bitmap_file_t)
45
46/* configuration */
47#define CLEAR_ARRAY _IO (MD_MAJOR, 0x20)
48#define ADD_NEW_DISK _IOW (MD_MAJOR, 0x21, mdu_disk_info_t)
49#define HOT_REMOVE_DISK _IO (MD_MAJOR, 0x22)
50#define SET_ARRAY_INFO _IOW (MD_MAJOR, 0x23, mdu_array_info_t)
51#define SET_DISK_INFO _IO (MD_MAJOR, 0x24)
52#define WRITE_RAID_INFO _IO (MD_MAJOR, 0x25)
53#define UNPROTECT_ARRAY _IO (MD_MAJOR, 0x26)
54#define PROTECT_ARRAY _IO (MD_MAJOR, 0x27)
55#define HOT_ADD_DISK _IO (MD_MAJOR, 0x28)
56#define SET_DISK_FAULTY _IO (MD_MAJOR, 0x29)
57#define HOT_GENERATE_ERROR _IO (MD_MAJOR, 0x2a)
58#define SET_BITMAP_FILE _IOW (MD_MAJOR, 0x2b, int)
59
60/* usage */
61#define RUN_ARRAY _IOW (MD_MAJOR, 0x30, mdu_param_t)
62/* 0x31 was START_ARRAY */
63#define STOP_ARRAY _IO (MD_MAJOR, 0x32)
64#define STOP_ARRAY_RO _IO (MD_MAJOR, 0x33)
65#define RESTART_ARRAY_RW _IO (MD_MAJOR, 0x34)
66
67/* 63 partitions with the alternate major number (mdp) */
68#define MdpMinorShift 6
69
70typedef struct mdu_version_s {
71 int major;
72 int minor;
73 int patchlevel;
74} mdu_version_t;
75
76typedef struct mdu_array_info_s {
77 /*
78 * Generic constant information
79 */
80 int major_version;
81 int minor_version;
82 int patch_version;
83 int ctime;
84 int level;
85 int size;
86 int nr_disks;
87 int raid_disks;
88 int md_minor;
89 int not_persistent;
90
91 /*
92 * Generic state information
93 */
94 int utime; /* 0 Superblock update time */
95 int state; /* 1 State bits (clean, ...) */
96 int active_disks; /* 2 Number of currently active disks */
97 int working_disks; /* 3 Number of working disks */
98 int failed_disks; /* 4 Number of failed disks */
99 int spare_disks; /* 5 Number of spare disks */
100
101 /*
102 * Personality information
103 */
104 int layout; /* 0 the array's physical layout */
105 int chunk_size; /* 1 chunk size in bytes */
106
107} mdu_array_info_t;
108
109/* non-obvious values for 'level' */
110#define LEVEL_MULTIPATH (-4)
111#define LEVEL_LINEAR (-1)
112#define LEVEL_FAULTY (-5)
113
114/* we need a value for 'no level specified' and 0
115 * means 'raid0', so we need something else. This is
116 * for internal use only
117 */
118#define LEVEL_NONE (-1000000)
119
120typedef struct mdu_disk_info_s {
121 /*
122 * configuration/status of one particular disk
123 */
124 int number;
125 int major;
126 int minor;
127 int raid_disk;
128 int state;
129
130} mdu_disk_info_t;
131
132typedef struct mdu_start_info_s {
133 /*
134 * configuration/status of one particular disk
135 */
136 int major;
137 int minor;
138 int raid_disk;
139 int state;
140
141} mdu_start_info_t;
142
143typedef struct mdu_bitmap_file_s
144{
145 char pathname[4096];
146} mdu_bitmap_file_t;
147
148typedef struct mdu_param_s
149{
150 int personality; /* 1,2,3,4 */
151 int chunk_size; /* in bytes */
152 int max_fault; /* unused for now */
153} mdu_param_t;
154
155#endif /* _UAPI_MD_U_H */
diff --git a/include/uapi/linux/tcp.h b/include/uapi/linux/tcp.h
index c4b89a5cb7d..e962faa5ab0 100644
--- a/include/uapi/linux/tcp.h
+++ b/include/uapi/linux/tcp.h
@@ -130,6 +130,7 @@ enum {
130#define TCPI_OPT_WSCALE 4 130#define TCPI_OPT_WSCALE 4
131#define TCPI_OPT_ECN 8 /* ECN was negociated at TCP session init */ 131#define TCPI_OPT_ECN 8 /* ECN was negociated at TCP session init */
132#define TCPI_OPT_ECN_SEEN 16 /* we received at least one packet with ECT */ 132#define TCPI_OPT_ECN_SEEN 16 /* we received at least one packet with ECT */
133#define TCPI_OPT_SYN_DATA 32 /* SYN-ACK acked data in SYN sent or rcvd */
133 134
134enum tcp_ca_state { 135enum tcp_ca_state {
135 TCP_CA_Open = 0, 136 TCP_CA_Open = 0,
diff --git a/include/uapi/linux/usb/Kbuild b/include/uapi/linux/usb/Kbuild
index aafaa5aa54d..6cb4ea82683 100644
--- a/include/uapi/linux/usb/Kbuild
+++ b/include/uapi/linux/usb/Kbuild
@@ -1 +1,11 @@
1# UAPI Header export list 1# UAPI Header export list
2header-y += audio.h
3header-y += cdc.h
4header-y += ch11.h
5header-y += ch9.h
6header-y += functionfs.h
7header-y += g_printer.h
8header-y += gadgetfs.h
9header-y += midi.h
10header-y += tmc.h
11header-y += video.h
diff --git a/include/uapi/linux/usb/audio.h b/include/uapi/linux/usb/audio.h
new file mode 100644
index 00000000000..ac90037894d
--- /dev/null
+++ b/include/uapi/linux/usb/audio.h
@@ -0,0 +1,545 @@
1/*
2 * <linux/usb/audio.h> -- USB Audio definitions.
3 *
4 * Copyright (C) 2006 Thumtronics Pty Ltd.
5 * Developed for Thumtronics by Grey Innovation
6 * Ben Williamson <ben.williamson@greyinnovation.com>
7 *
8 * This software is distributed under the terms of the GNU General Public
9 * License ("GPL") version 2, as published by the Free Software Foundation.
10 *
11 * This file holds USB constants and structures defined
12 * by the USB Device Class Definition for Audio Devices.
13 * Comments below reference relevant sections of that document:
14 *
15 * http://www.usb.org/developers/devclass_docs/audio10.pdf
16 *
17 * Types and defines in this file are either specific to version 1.0 of
18 * this standard or common for newer versions.
19 */
20
21#ifndef _UAPI__LINUX_USB_AUDIO_H
22#define _UAPI__LINUX_USB_AUDIO_H
23
24#include <linux/types.h>
25
26/* bInterfaceProtocol values to denote the version of the standard used */
27#define UAC_VERSION_1 0x00
28#define UAC_VERSION_2 0x20
29
30/* A.2 Audio Interface Subclass Codes */
31#define USB_SUBCLASS_AUDIOCONTROL 0x01
32#define USB_SUBCLASS_AUDIOSTREAMING 0x02
33#define USB_SUBCLASS_MIDISTREAMING 0x03
34
35/* A.5 Audio Class-Specific AC Interface Descriptor Subtypes */
36#define UAC_HEADER 0x01
37#define UAC_INPUT_TERMINAL 0x02
38#define UAC_OUTPUT_TERMINAL 0x03
39#define UAC_MIXER_UNIT 0x04
40#define UAC_SELECTOR_UNIT 0x05
41#define UAC_FEATURE_UNIT 0x06
42#define UAC1_PROCESSING_UNIT 0x07
43#define UAC1_EXTENSION_UNIT 0x08
44
45/* A.6 Audio Class-Specific AS Interface Descriptor Subtypes */
46#define UAC_AS_GENERAL 0x01
47#define UAC_FORMAT_TYPE 0x02
48#define UAC_FORMAT_SPECIFIC 0x03
49
50/* A.7 Processing Unit Process Types */
51#define UAC_PROCESS_UNDEFINED 0x00
52#define UAC_PROCESS_UP_DOWNMIX 0x01
53#define UAC_PROCESS_DOLBY_PROLOGIC 0x02
54#define UAC_PROCESS_STEREO_EXTENDER 0x03
55#define UAC_PROCESS_REVERB 0x04
56#define UAC_PROCESS_CHORUS 0x05
57#define UAC_PROCESS_DYN_RANGE_COMP 0x06
58
59/* A.8 Audio Class-Specific Endpoint Descriptor Subtypes */
60#define UAC_EP_GENERAL 0x01
61
62/* A.9 Audio Class-Specific Request Codes */
63#define UAC_SET_ 0x00
64#define UAC_GET_ 0x80
65
66#define UAC__CUR 0x1
67#define UAC__MIN 0x2
68#define UAC__MAX 0x3
69#define UAC__RES 0x4
70#define UAC__MEM 0x5
71
72#define UAC_SET_CUR (UAC_SET_ | UAC__CUR)
73#define UAC_GET_CUR (UAC_GET_ | UAC__CUR)
74#define UAC_SET_MIN (UAC_SET_ | UAC__MIN)
75#define UAC_GET_MIN (UAC_GET_ | UAC__MIN)
76#define UAC_SET_MAX (UAC_SET_ | UAC__MAX)
77#define UAC_GET_MAX (UAC_GET_ | UAC__MAX)
78#define UAC_SET_RES (UAC_SET_ | UAC__RES)
79#define UAC_GET_RES (UAC_GET_ | UAC__RES)
80#define UAC_SET_MEM (UAC_SET_ | UAC__MEM)
81#define UAC_GET_MEM (UAC_GET_ | UAC__MEM)
82
83#define UAC_GET_STAT 0xff
84
85/* A.10 Control Selector Codes */
86
87/* A.10.1 Terminal Control Selectors */
88#define UAC_TERM_COPY_PROTECT 0x01
89
90/* A.10.2 Feature Unit Control Selectors */
91#define UAC_FU_MUTE 0x01
92#define UAC_FU_VOLUME 0x02
93#define UAC_FU_BASS 0x03
94#define UAC_FU_MID 0x04
95#define UAC_FU_TREBLE 0x05
96#define UAC_FU_GRAPHIC_EQUALIZER 0x06
97#define UAC_FU_AUTOMATIC_GAIN 0x07
98#define UAC_FU_DELAY 0x08
99#define UAC_FU_BASS_BOOST 0x09
100#define UAC_FU_LOUDNESS 0x0a
101
102#define UAC_CONTROL_BIT(CS) (1 << ((CS) - 1))
103
104/* A.10.3.1 Up/Down-mix Processing Unit Controls Selectors */
105#define UAC_UD_ENABLE 0x01
106#define UAC_UD_MODE_SELECT 0x02
107
108/* A.10.3.2 Dolby Prologic (tm) Processing Unit Controls Selectors */
109#define UAC_DP_ENABLE 0x01
110#define UAC_DP_MODE_SELECT 0x02
111
112/* A.10.3.3 3D Stereo Extender Processing Unit Control Selectors */
113#define UAC_3D_ENABLE 0x01
114#define UAC_3D_SPACE 0x02
115
116/* A.10.3.4 Reverberation Processing Unit Control Selectors */
117#define UAC_REVERB_ENABLE 0x01
118#define UAC_REVERB_LEVEL 0x02
119#define UAC_REVERB_TIME 0x03
120#define UAC_REVERB_FEEDBACK 0x04
121
122/* A.10.3.5 Chorus Processing Unit Control Selectors */
123#define UAC_CHORUS_ENABLE 0x01
124#define UAC_CHORUS_LEVEL 0x02
125#define UAC_CHORUS_RATE 0x03
126#define UAC_CHORUS_DEPTH 0x04
127
128/* A.10.3.6 Dynamic Range Compressor Unit Control Selectors */
129#define UAC_DCR_ENABLE 0x01
130#define UAC_DCR_RATE 0x02
131#define UAC_DCR_MAXAMPL 0x03
132#define UAC_DCR_THRESHOLD 0x04
133#define UAC_DCR_ATTACK_TIME 0x05
134#define UAC_DCR_RELEASE_TIME 0x06
135
136/* A.10.4 Extension Unit Control Selectors */
137#define UAC_XU_ENABLE 0x01
138
139/* MIDI - A.1 MS Class-Specific Interface Descriptor Subtypes */
140#define UAC_MS_HEADER 0x01
141#define UAC_MIDI_IN_JACK 0x02
142#define UAC_MIDI_OUT_JACK 0x03
143
144/* MIDI - A.1 MS Class-Specific Endpoint Descriptor Subtypes */
145#define UAC_MS_GENERAL 0x01
146
147/* Terminals - 2.1 USB Terminal Types */
148#define UAC_TERMINAL_UNDEFINED 0x100
149#define UAC_TERMINAL_STREAMING 0x101
150#define UAC_TERMINAL_VENDOR_SPEC 0x1FF
151
152/* Terminal Control Selectors */
153/* 4.3.2 Class-Specific AC Interface Descriptor */
154struct uac1_ac_header_descriptor {
155 __u8 bLength; /* 8 + n */
156 __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */
157 __u8 bDescriptorSubtype; /* UAC_MS_HEADER */
158 __le16 bcdADC; /* 0x0100 */
159 __le16 wTotalLength; /* includes Unit and Terminal desc. */
160 __u8 bInCollection; /* n */
161 __u8 baInterfaceNr[]; /* [n] */
162} __attribute__ ((packed));
163
164#define UAC_DT_AC_HEADER_SIZE(n) (8 + (n))
165
166/* As above, but more useful for defining your own descriptors: */
167#define DECLARE_UAC_AC_HEADER_DESCRIPTOR(n) \
168struct uac1_ac_header_descriptor_##n { \
169 __u8 bLength; \
170 __u8 bDescriptorType; \
171 __u8 bDescriptorSubtype; \
172 __le16 bcdADC; \
173 __le16 wTotalLength; \
174 __u8 bInCollection; \
175 __u8 baInterfaceNr[n]; \
176} __attribute__ ((packed))
177
178/* 4.3.2.1 Input Terminal Descriptor */
179struct uac_input_terminal_descriptor {
180 __u8 bLength; /* in bytes: 12 */
181 __u8 bDescriptorType; /* CS_INTERFACE descriptor type */
182 __u8 bDescriptorSubtype; /* INPUT_TERMINAL descriptor subtype */
183 __u8 bTerminalID; /* Constant uniquely terminal ID */
184 __le16 wTerminalType; /* USB Audio Terminal Types */
185 __u8 bAssocTerminal; /* ID of the Output Terminal associated */
186 __u8 bNrChannels; /* Number of logical output channels */
187 __le16 wChannelConfig;
188 __u8 iChannelNames;
189 __u8 iTerminal;
190} __attribute__ ((packed));
191
192#define UAC_DT_INPUT_TERMINAL_SIZE 12
193
194/* Terminals - 2.2 Input Terminal Types */
195#define UAC_INPUT_TERMINAL_UNDEFINED 0x200
196#define UAC_INPUT_TERMINAL_MICROPHONE 0x201
197#define UAC_INPUT_TERMINAL_DESKTOP_MICROPHONE 0x202
198#define UAC_INPUT_TERMINAL_PERSONAL_MICROPHONE 0x203
199#define UAC_INPUT_TERMINAL_OMNI_DIR_MICROPHONE 0x204
200#define UAC_INPUT_TERMINAL_MICROPHONE_ARRAY 0x205
201#define UAC_INPUT_TERMINAL_PROC_MICROPHONE_ARRAY 0x206
202
203/* Terminals - control selectors */
204
205#define UAC_TERMINAL_CS_COPY_PROTECT_CONTROL 0x01
206
207/* 4.3.2.2 Output Terminal Descriptor */
208struct uac1_output_terminal_descriptor {
209 __u8 bLength; /* in bytes: 9 */
210 __u8 bDescriptorType; /* CS_INTERFACE descriptor type */
211 __u8 bDescriptorSubtype; /* OUTPUT_TERMINAL descriptor subtype */
212 __u8 bTerminalID; /* Constant uniquely terminal ID */
213 __le16 wTerminalType; /* USB Audio Terminal Types */
214 __u8 bAssocTerminal; /* ID of the Input Terminal associated */
215 __u8 bSourceID; /* ID of the connected Unit or Terminal*/
216 __u8 iTerminal;
217} __attribute__ ((packed));
218
219#define UAC_DT_OUTPUT_TERMINAL_SIZE 9
220
221/* Terminals - 2.3 Output Terminal Types */
222#define UAC_OUTPUT_TERMINAL_UNDEFINED 0x300
223#define UAC_OUTPUT_TERMINAL_SPEAKER 0x301
224#define UAC_OUTPUT_TERMINAL_HEADPHONES 0x302
225#define UAC_OUTPUT_TERMINAL_HEAD_MOUNTED_DISPLAY_AUDIO 0x303
226#define UAC_OUTPUT_TERMINAL_DESKTOP_SPEAKER 0x304
227#define UAC_OUTPUT_TERMINAL_ROOM_SPEAKER 0x305
228#define UAC_OUTPUT_TERMINAL_COMMUNICATION_SPEAKER 0x306
229#define UAC_OUTPUT_TERMINAL_LOW_FREQ_EFFECTS_SPEAKER 0x307
230
231/* Set bControlSize = 2 as default setting */
232#define UAC_DT_FEATURE_UNIT_SIZE(ch) (7 + ((ch) + 1) * 2)
233
234/* As above, but more useful for defining your own descriptors: */
235#define DECLARE_UAC_FEATURE_UNIT_DESCRIPTOR(ch) \
236struct uac_feature_unit_descriptor_##ch { \
237 __u8 bLength; \
238 __u8 bDescriptorType; \
239 __u8 bDescriptorSubtype; \
240 __u8 bUnitID; \
241 __u8 bSourceID; \
242 __u8 bControlSize; \
243 __le16 bmaControls[ch + 1]; \
244 __u8 iFeature; \
245} __attribute__ ((packed))
246
247/* 4.3.2.3 Mixer Unit Descriptor */
248struct uac_mixer_unit_descriptor {
249 __u8 bLength;
250 __u8 bDescriptorType;
251 __u8 bDescriptorSubtype;
252 __u8 bUnitID;
253 __u8 bNrInPins;
254 __u8 baSourceID[];
255} __attribute__ ((packed));
256
257static inline __u8 uac_mixer_unit_bNrChannels(struct uac_mixer_unit_descriptor *desc)
258{
259 return desc->baSourceID[desc->bNrInPins];
260}
261
262static inline __u32 uac_mixer_unit_wChannelConfig(struct uac_mixer_unit_descriptor *desc,
263 int protocol)
264{
265 if (protocol == UAC_VERSION_1)
266 return (desc->baSourceID[desc->bNrInPins + 2] << 8) |
267 desc->baSourceID[desc->bNrInPins + 1];
268 else
269 return (desc->baSourceID[desc->bNrInPins + 4] << 24) |
270 (desc->baSourceID[desc->bNrInPins + 3] << 16) |
271 (desc->baSourceID[desc->bNrInPins + 2] << 8) |
272 (desc->baSourceID[desc->bNrInPins + 1]);
273}
274
275static inline __u8 uac_mixer_unit_iChannelNames(struct uac_mixer_unit_descriptor *desc,
276 int protocol)
277{
278 return (protocol == UAC_VERSION_1) ?
279 desc->baSourceID[desc->bNrInPins + 3] :
280 desc->baSourceID[desc->bNrInPins + 5];
281}
282
283static inline __u8 *uac_mixer_unit_bmControls(struct uac_mixer_unit_descriptor *desc,
284 int protocol)
285{
286 return (protocol == UAC_VERSION_1) ?
287 &desc->baSourceID[desc->bNrInPins + 4] :
288 &desc->baSourceID[desc->bNrInPins + 6];
289}
290
291static inline __u8 uac_mixer_unit_iMixer(struct uac_mixer_unit_descriptor *desc)
292{
293 __u8 *raw = (__u8 *) desc;
294 return raw[desc->bLength - 1];
295}
296
297/* 4.3.2.4 Selector Unit Descriptor */
298struct uac_selector_unit_descriptor {
299 __u8 bLength;
300 __u8 bDescriptorType;
301 __u8 bDescriptorSubtype;
302 __u8 bUintID;
303 __u8 bNrInPins;
304 __u8 baSourceID[];
305} __attribute__ ((packed));
306
307static inline __u8 uac_selector_unit_iSelector(struct uac_selector_unit_descriptor *desc)
308{
309 __u8 *raw = (__u8 *) desc;
310 return raw[desc->bLength - 1];
311}
312
313/* 4.3.2.5 Feature Unit Descriptor */
314struct uac_feature_unit_descriptor {
315 __u8 bLength;
316 __u8 bDescriptorType;
317 __u8 bDescriptorSubtype;
318 __u8 bUnitID;
319 __u8 bSourceID;
320 __u8 bControlSize;
321 __u8 bmaControls[0]; /* variable length */
322} __attribute__((packed));
323
324static inline __u8 uac_feature_unit_iFeature(struct uac_feature_unit_descriptor *desc)
325{
326 __u8 *raw = (__u8 *) desc;
327 return raw[desc->bLength - 1];
328}
329
330/* 4.3.2.6 Processing Unit Descriptors */
331struct uac_processing_unit_descriptor {
332 __u8 bLength;
333 __u8 bDescriptorType;
334 __u8 bDescriptorSubtype;
335 __u8 bUnitID;
336 __u16 wProcessType;
337 __u8 bNrInPins;
338 __u8 baSourceID[];
339} __attribute__ ((packed));
340
341static inline __u8 uac_processing_unit_bNrChannels(struct uac_processing_unit_descriptor *desc)
342{
343 return desc->baSourceID[desc->bNrInPins];
344}
345
346static inline __u32 uac_processing_unit_wChannelConfig(struct uac_processing_unit_descriptor *desc,
347 int protocol)
348{
349 if (protocol == UAC_VERSION_1)
350 return (desc->baSourceID[desc->bNrInPins + 2] << 8) |
351 desc->baSourceID[desc->bNrInPins + 1];
352 else
353 return (desc->baSourceID[desc->bNrInPins + 4] << 24) |
354 (desc->baSourceID[desc->bNrInPins + 3] << 16) |
355 (desc->baSourceID[desc->bNrInPins + 2] << 8) |
356 (desc->baSourceID[desc->bNrInPins + 1]);
357}
358
359static inline __u8 uac_processing_unit_iChannelNames(struct uac_processing_unit_descriptor *desc,
360 int protocol)
361{
362 return (protocol == UAC_VERSION_1) ?
363 desc->baSourceID[desc->bNrInPins + 3] :
364 desc->baSourceID[desc->bNrInPins + 5];
365}
366
367static inline __u8 uac_processing_unit_bControlSize(struct uac_processing_unit_descriptor *desc,
368 int protocol)
369{
370 return (protocol == UAC_VERSION_1) ?
371 desc->baSourceID[desc->bNrInPins + 4] :
372 desc->baSourceID[desc->bNrInPins + 6];
373}
374
375static inline __u8 *uac_processing_unit_bmControls(struct uac_processing_unit_descriptor *desc,
376 int protocol)
377{
378 return (protocol == UAC_VERSION_1) ?
379 &desc->baSourceID[desc->bNrInPins + 5] :
380 &desc->baSourceID[desc->bNrInPins + 7];
381}
382
383static inline __u8 uac_processing_unit_iProcessing(struct uac_processing_unit_descriptor *desc,
384 int protocol)
385{
386 __u8 control_size = uac_processing_unit_bControlSize(desc, protocol);
387 return desc->baSourceID[desc->bNrInPins + control_size];
388}
389
390static inline __u8 *uac_processing_unit_specific(struct uac_processing_unit_descriptor *desc,
391 int protocol)
392{
393 __u8 control_size = uac_processing_unit_bControlSize(desc, protocol);
394 return &desc->baSourceID[desc->bNrInPins + control_size + 1];
395}
396
397/* 4.5.2 Class-Specific AS Interface Descriptor */
398struct uac1_as_header_descriptor {
399 __u8 bLength; /* in bytes: 7 */
400 __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */
401 __u8 bDescriptorSubtype; /* AS_GENERAL */
402 __u8 bTerminalLink; /* Terminal ID of connected Terminal */
403 __u8 bDelay; /* Delay introduced by the data path */
404 __le16 wFormatTag; /* The Audio Data Format */
405} __attribute__ ((packed));
406
407#define UAC_DT_AS_HEADER_SIZE 7
408
409/* Formats - A.1.1 Audio Data Format Type I Codes */
410#define UAC_FORMAT_TYPE_I_UNDEFINED 0x0
411#define UAC_FORMAT_TYPE_I_PCM 0x1
412#define UAC_FORMAT_TYPE_I_PCM8 0x2
413#define UAC_FORMAT_TYPE_I_IEEE_FLOAT 0x3
414#define UAC_FORMAT_TYPE_I_ALAW 0x4
415#define UAC_FORMAT_TYPE_I_MULAW 0x5
416
417struct uac_format_type_i_continuous_descriptor {
418 __u8 bLength; /* in bytes: 8 + (ns * 3) */
419 __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */
420 __u8 bDescriptorSubtype; /* FORMAT_TYPE */
421 __u8 bFormatType; /* FORMAT_TYPE_1 */
422 __u8 bNrChannels; /* physical channels in the stream */
423 __u8 bSubframeSize; /* */
424 __u8 bBitResolution;
425 __u8 bSamFreqType;
426 __u8 tLowerSamFreq[3];
427 __u8 tUpperSamFreq[3];
428} __attribute__ ((packed));
429
430#define UAC_FORMAT_TYPE_I_CONTINUOUS_DESC_SIZE 14
431
432struct uac_format_type_i_discrete_descriptor {
433 __u8 bLength; /* in bytes: 8 + (ns * 3) */
434 __u8 bDescriptorType; /* USB_DT_CS_INTERFACE */
435 __u8 bDescriptorSubtype; /* FORMAT_TYPE */
436 __u8 bFormatType; /* FORMAT_TYPE_1 */
437 __u8 bNrChannels; /* physical channels in the stream */
438 __u8 bSubframeSize; /* */
439 __u8 bBitResolution;
440 __u8 bSamFreqType;
441 __u8 tSamFreq[][3];
442} __attribute__ ((packed));
443
444#define DECLARE_UAC_FORMAT_TYPE_I_DISCRETE_DESC(n) \
445struct uac_format_type_i_discrete_descriptor_##n { \
446 __u8 bLength; \
447 __u8 bDescriptorType; \
448 __u8 bDescriptorSubtype; \
449 __u8 bFormatType; \
450 __u8 bNrChannels; \
451 __u8 bSubframeSize; \
452 __u8 bBitResolution; \
453 __u8 bSamFreqType; \
454 __u8 tSamFreq[n][3]; \
455} __attribute__ ((packed))
456
457#define UAC_FORMAT_TYPE_I_DISCRETE_DESC_SIZE(n) (8 + (n * 3))
458
459struct uac_format_type_i_ext_descriptor {
460 __u8 bLength;
461 __u8 bDescriptorType;
462 __u8 bDescriptorSubtype;
463 __u8 bFormatType;
464 __u8 bSubslotSize;
465 __u8 bBitResolution;
466 __u8 bHeaderLength;
467 __u8 bControlSize;
468 __u8 bSideBandProtocol;
469} __attribute__((packed));
470
471/* Formats - Audio Data Format Type I Codes */
472
473#define UAC_FORMAT_TYPE_II_MPEG 0x1001
474#define UAC_FORMAT_TYPE_II_AC3 0x1002
475
476struct uac_format_type_ii_discrete_descriptor {
477 __u8 bLength;
478 __u8 bDescriptorType;
479 __u8 bDescriptorSubtype;
480 __u8 bFormatType;
481 __le16 wMaxBitRate;
482 __le16 wSamplesPerFrame;
483 __u8 bSamFreqType;
484 __u8 tSamFreq[][3];
485} __attribute__((packed));
486
487struct uac_format_type_ii_ext_descriptor {
488 __u8 bLength;
489 __u8 bDescriptorType;
490 __u8 bDescriptorSubtype;
491 __u8 bFormatType;
492 __u16 wMaxBitRate;
493 __u16 wSamplesPerFrame;
494 __u8 bHeaderLength;
495 __u8 bSideBandProtocol;
496} __attribute__((packed));
497
498/* type III */
499#define UAC_FORMAT_TYPE_III_IEC1937_AC3 0x2001
500#define UAC_FORMAT_TYPE_III_IEC1937_MPEG1_LAYER1 0x2002
501#define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_NOEXT 0x2003
502#define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_EXT 0x2004
503#define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_LAYER1_LS 0x2005
504#define UAC_FORMAT_TYPE_III_IEC1937_MPEG2_LAYER23_LS 0x2006
505
506/* Formats - A.2 Format Type Codes */
507#define UAC_FORMAT_TYPE_UNDEFINED 0x0
508#define UAC_FORMAT_TYPE_I 0x1
509#define UAC_FORMAT_TYPE_II 0x2
510#define UAC_FORMAT_TYPE_III 0x3
511#define UAC_EXT_FORMAT_TYPE_I 0x81
512#define UAC_EXT_FORMAT_TYPE_II 0x82
513#define UAC_EXT_FORMAT_TYPE_III 0x83
514
515struct uac_iso_endpoint_descriptor {
516 __u8 bLength; /* in bytes: 7 */
517 __u8 bDescriptorType; /* USB_DT_CS_ENDPOINT */
518 __u8 bDescriptorSubtype; /* EP_GENERAL */
519 __u8 bmAttributes;
520 __u8 bLockDelayUnits;
521 __le16 wLockDelay;
522} __attribute__((packed));
523#define UAC_ISO_ENDPOINT_DESC_SIZE 7
524
525#define UAC_EP_CS_ATTR_SAMPLE_RATE 0x01
526#define UAC_EP_CS_ATTR_PITCH_CONTROL 0x02
527#define UAC_EP_CS_ATTR_FILL_MAX 0x80
528
529/* status word format (3.7.1.1) */
530
531#define UAC1_STATUS_TYPE_ORIG_MASK 0x0f
532#define UAC1_STATUS_TYPE_ORIG_AUDIO_CONTROL_IF 0x0
533#define UAC1_STATUS_TYPE_ORIG_AUDIO_STREAM_IF 0x1
534#define UAC1_STATUS_TYPE_ORIG_AUDIO_STREAM_EP 0x2
535
536#define UAC1_STATUS_TYPE_IRQ_PENDING (1 << 7)
537#define UAC1_STATUS_TYPE_MEM_CHANGED (1 << 6)
538
539struct uac1_status_word {
540 __u8 bStatusType;
541 __u8 bOriginator;
542} __attribute__((packed));
543
544
545#endif /* _UAPI__LINUX_USB_AUDIO_H */
diff --git a/include/linux/usb/cdc.h b/include/uapi/linux/usb/cdc.h
index 81a927930bf..81a927930bf 100644
--- a/include/linux/usb/cdc.h
+++ b/include/uapi/linux/usb/cdc.h
diff --git a/include/linux/usb/ch11.h b/include/uapi/linux/usb/ch11.h
index 7692dc69ccf..7692dc69ccf 100644
--- a/include/linux/usb/ch11.h
+++ b/include/uapi/linux/usb/ch11.h
diff --git a/include/uapi/linux/usb/ch9.h b/include/uapi/linux/usb/ch9.h
new file mode 100644
index 00000000000..50598472dc4
--- /dev/null
+++ b/include/uapi/linux/usb/ch9.h
@@ -0,0 +1,993 @@
1/*
2 * This file holds USB constants and structures that are needed for
3 * USB device APIs. These are used by the USB device model, which is
4 * defined in chapter 9 of the USB 2.0 specification and in the
5 * Wireless USB 1.0 (spread around). Linux has several APIs in C that
6 * need these:
7 *
8 * - the master/host side Linux-USB kernel driver API;
9 * - the "usbfs" user space API; and
10 * - the Linux "gadget" slave/device/peripheral side driver API.
11 *
12 * USB 2.0 adds an additional "On The Go" (OTG) mode, which lets systems
13 * act either as a USB master/host or as a USB slave/device. That means
14 * the master and slave side APIs benefit from working well together.
15 *
16 * There's also "Wireless USB", using low power short range radios for
17 * peripheral interconnection but otherwise building on the USB framework.
18 *
19 * Note all descriptors are declared '__attribute__((packed))' so that:
20 *
21 * [a] they never get padded, either internally (USB spec writers
22 * probably handled that) or externally;
23 *
24 * [b] so that accessing bigger-than-a-bytes fields will never
25 * generate bus errors on any platform, even when the location of
26 * its descriptor inside a bundle isn't "naturally aligned", and
27 *
28 * [c] for consistency, removing all doubt even when it appears to
29 * someone that the two other points are non-issues for that
30 * particular descriptor type.
31 */
32
33#ifndef _UAPI__LINUX_USB_CH9_H
34#define _UAPI__LINUX_USB_CH9_H
35
36#include <linux/types.h> /* __u8 etc */
37#include <asm/byteorder.h> /* le16_to_cpu */
38
39/*-------------------------------------------------------------------------*/
40
41/* CONTROL REQUEST SUPPORT */
42
43/*
44 * USB directions
45 *
46 * This bit flag is used in endpoint descriptors' bEndpointAddress field.
47 * It's also one of three fields in control requests bRequestType.
48 */
49#define USB_DIR_OUT 0 /* to device */
50#define USB_DIR_IN 0x80 /* to host */
51
52/*
53 * USB types, the second of three bRequestType fields
54 */
55#define USB_TYPE_MASK (0x03 << 5)
56#define USB_TYPE_STANDARD (0x00 << 5)
57#define USB_TYPE_CLASS (0x01 << 5)
58#define USB_TYPE_VENDOR (0x02 << 5)
59#define USB_TYPE_RESERVED (0x03 << 5)
60
61/*
62 * USB recipients, the third of three bRequestType fields
63 */
64#define USB_RECIP_MASK 0x1f
65#define USB_RECIP_DEVICE 0x00
66#define USB_RECIP_INTERFACE 0x01
67#define USB_RECIP_ENDPOINT 0x02
68#define USB_RECIP_OTHER 0x03
69/* From Wireless USB 1.0 */
70#define USB_RECIP_PORT 0x04
71#define USB_RECIP_RPIPE 0x05
72
73/*
74 * Standard requests, for the bRequest field of a SETUP packet.
75 *
76 * These are qualified by the bRequestType field, so that for example
77 * TYPE_CLASS or TYPE_VENDOR specific feature flags could be retrieved
78 * by a GET_STATUS request.
79 */
80#define USB_REQ_GET_STATUS 0x00
81#define USB_REQ_CLEAR_FEATURE 0x01
82#define USB_REQ_SET_FEATURE 0x03
83#define USB_REQ_SET_ADDRESS 0x05
84#define USB_REQ_GET_DESCRIPTOR 0x06
85#define USB_REQ_SET_DESCRIPTOR 0x07
86#define USB_REQ_GET_CONFIGURATION 0x08
87#define USB_REQ_SET_CONFIGURATION 0x09
88#define USB_REQ_GET_INTERFACE 0x0A
89#define USB_REQ_SET_INTERFACE 0x0B
90#define USB_REQ_SYNCH_FRAME 0x0C
91#define USB_REQ_SET_SEL 0x30
92#define USB_REQ_SET_ISOCH_DELAY 0x31
93
94#define USB_REQ_SET_ENCRYPTION 0x0D /* Wireless USB */
95#define USB_REQ_GET_ENCRYPTION 0x0E
96#define USB_REQ_RPIPE_ABORT 0x0E
97#define USB_REQ_SET_HANDSHAKE 0x0F
98#define USB_REQ_RPIPE_RESET 0x0F
99#define USB_REQ_GET_HANDSHAKE 0x10
100#define USB_REQ_SET_CONNECTION 0x11
101#define USB_REQ_SET_SECURITY_DATA 0x12
102#define USB_REQ_GET_SECURITY_DATA 0x13
103#define USB_REQ_SET_WUSB_DATA 0x14
104#define USB_REQ_LOOPBACK_DATA_WRITE 0x15
105#define USB_REQ_LOOPBACK_DATA_READ 0x16
106#define USB_REQ_SET_INTERFACE_DS 0x17
107
108/* The Link Power Management (LPM) ECN defines USB_REQ_TEST_AND_SET command,
109 * used by hubs to put ports into a new L1 suspend state, except that it
110 * forgot to define its number ...
111 */
112
113/*
114 * USB feature flags are written using USB_REQ_{CLEAR,SET}_FEATURE, and
115 * are read as a bit array returned by USB_REQ_GET_STATUS. (So there
116 * are at most sixteen features of each type.) Hubs may also support a
117 * new USB_REQ_TEST_AND_SET_FEATURE to put ports into L1 suspend.
118 */
119#define USB_DEVICE_SELF_POWERED 0 /* (read only) */
120#define USB_DEVICE_REMOTE_WAKEUP 1 /* dev may initiate wakeup */
121#define USB_DEVICE_TEST_MODE 2 /* (wired high speed only) */
122#define USB_DEVICE_BATTERY 2 /* (wireless) */
123#define USB_DEVICE_B_HNP_ENABLE 3 /* (otg) dev may initiate HNP */
124#define USB_DEVICE_WUSB_DEVICE 3 /* (wireless)*/
125#define USB_DEVICE_A_HNP_SUPPORT 4 /* (otg) RH port supports HNP */
126#define USB_DEVICE_A_ALT_HNP_SUPPORT 5 /* (otg) other RH port does */
127#define USB_DEVICE_DEBUG_MODE 6 /* (special devices only) */
128
129/*
130 * Test Mode Selectors
131 * See USB 2.0 spec Table 9-7
132 */
133#define TEST_J 1
134#define TEST_K 2
135#define TEST_SE0_NAK 3
136#define TEST_PACKET 4
137#define TEST_FORCE_EN 5
138
139/*
140 * New Feature Selectors as added by USB 3.0
141 * See USB 3.0 spec Table 9-6
142 */
143#define USB_DEVICE_U1_ENABLE 48 /* dev may initiate U1 transition */
144#define USB_DEVICE_U2_ENABLE 49 /* dev may initiate U2 transition */
145#define USB_DEVICE_LTM_ENABLE 50 /* dev may send LTM */
146#define USB_INTRF_FUNC_SUSPEND 0 /* function suspend */
147
148#define USB_INTR_FUNC_SUSPEND_OPT_MASK 0xFF00
149/*
150 * Suspend Options, Table 9-7 USB 3.0 spec
151 */
152#define USB_INTRF_FUNC_SUSPEND_LP (1 << (8 + 0))
153#define USB_INTRF_FUNC_SUSPEND_RW (1 << (8 + 1))
154
155#define USB_ENDPOINT_HALT 0 /* IN/OUT will STALL */
156
157/* Bit array elements as returned by the USB_REQ_GET_STATUS request. */
158#define USB_DEV_STAT_U1_ENABLED 2 /* transition into U1 state */
159#define USB_DEV_STAT_U2_ENABLED 3 /* transition into U2 state */
160#define USB_DEV_STAT_LTM_ENABLED 4 /* Latency tolerance messages */
161
162/**
163 * struct usb_ctrlrequest - SETUP data for a USB device control request
164 * @bRequestType: matches the USB bmRequestType field
165 * @bRequest: matches the USB bRequest field
166 * @wValue: matches the USB wValue field (le16 byte order)
167 * @wIndex: matches the USB wIndex field (le16 byte order)
168 * @wLength: matches the USB wLength field (le16 byte order)
169 *
170 * This structure is used to send control requests to a USB device. It matches
171 * the different fields of the USB 2.0 Spec section 9.3, table 9-2. See the
172 * USB spec for a fuller description of the different fields, and what they are
173 * used for.
174 *
175 * Note that the driver for any interface can issue control requests.
176 * For most devices, interfaces don't coordinate with each other, so
177 * such requests may be made at any time.
178 */
179struct usb_ctrlrequest {
180 __u8 bRequestType;
181 __u8 bRequest;
182 __le16 wValue;
183 __le16 wIndex;
184 __le16 wLength;
185} __attribute__ ((packed));
186
187/*-------------------------------------------------------------------------*/
188
189/*
190 * STANDARD DESCRIPTORS ... as returned by GET_DESCRIPTOR, or
191 * (rarely) accepted by SET_DESCRIPTOR.
192 *
193 * Note that all multi-byte values here are encoded in little endian
194 * byte order "on the wire". Within the kernel and when exposed
195 * through the Linux-USB APIs, they are not converted to cpu byte
196 * order; it is the responsibility of the client code to do this.
197 * The single exception is when device and configuration descriptors (but
198 * not other descriptors) are read from usbfs (i.e. /proc/bus/usb/BBB/DDD);
199 * in this case the fields are converted to host endianness by the kernel.
200 */
201
202/*
203 * Descriptor types ... USB 2.0 spec table 9.5
204 */
205#define USB_DT_DEVICE 0x01
206#define USB_DT_CONFIG 0x02
207#define USB_DT_STRING 0x03
208#define USB_DT_INTERFACE 0x04
209#define USB_DT_ENDPOINT 0x05
210#define USB_DT_DEVICE_QUALIFIER 0x06
211#define USB_DT_OTHER_SPEED_CONFIG 0x07
212#define USB_DT_INTERFACE_POWER 0x08
213/* these are from a minor usb 2.0 revision (ECN) */
214#define USB_DT_OTG 0x09
215#define USB_DT_DEBUG 0x0a
216#define USB_DT_INTERFACE_ASSOCIATION 0x0b
217/* these are from the Wireless USB spec */
218#define USB_DT_SECURITY 0x0c
219#define USB_DT_KEY 0x0d
220#define USB_DT_ENCRYPTION_TYPE 0x0e
221#define USB_DT_BOS 0x0f
222#define USB_DT_DEVICE_CAPABILITY 0x10
223#define USB_DT_WIRELESS_ENDPOINT_COMP 0x11
224#define USB_DT_WIRE_ADAPTER 0x21
225#define USB_DT_RPIPE 0x22
226#define USB_DT_CS_RADIO_CONTROL 0x23
227/* From the T10 UAS specification */
228#define USB_DT_PIPE_USAGE 0x24
229/* From the USB 3.0 spec */
230#define USB_DT_SS_ENDPOINT_COMP 0x30
231
232/* Conventional codes for class-specific descriptors. The convention is
233 * defined in the USB "Common Class" Spec (3.11). Individual class specs
234 * are authoritative for their usage, not the "common class" writeup.
235 */
236#define USB_DT_CS_DEVICE (USB_TYPE_CLASS | USB_DT_DEVICE)
237#define USB_DT_CS_CONFIG (USB_TYPE_CLASS | USB_DT_CONFIG)
238#define USB_DT_CS_STRING (USB_TYPE_CLASS | USB_DT_STRING)
239#define USB_DT_CS_INTERFACE (USB_TYPE_CLASS | USB_DT_INTERFACE)
240#define USB_DT_CS_ENDPOINT (USB_TYPE_CLASS | USB_DT_ENDPOINT)
241
242/* All standard descriptors have these 2 fields at the beginning */
243struct usb_descriptor_header {
244 __u8 bLength;
245 __u8 bDescriptorType;
246} __attribute__ ((packed));
247
248
249/*-------------------------------------------------------------------------*/
250
251/* USB_DT_DEVICE: Device descriptor */
252struct usb_device_descriptor {
253 __u8 bLength;
254 __u8 bDescriptorType;
255
256 __le16 bcdUSB;
257 __u8 bDeviceClass;
258 __u8 bDeviceSubClass;
259 __u8 bDeviceProtocol;
260 __u8 bMaxPacketSize0;
261 __le16 idVendor;
262 __le16 idProduct;
263 __le16 bcdDevice;
264 __u8 iManufacturer;
265 __u8 iProduct;
266 __u8 iSerialNumber;
267 __u8 bNumConfigurations;
268} __attribute__ ((packed));
269
270#define USB_DT_DEVICE_SIZE 18
271
272
273/*
274 * Device and/or Interface Class codes
275 * as found in bDeviceClass or bInterfaceClass
276 * and defined by www.usb.org documents
277 */
278#define USB_CLASS_PER_INTERFACE 0 /* for DeviceClass */
279#define USB_CLASS_AUDIO 1
280#define USB_CLASS_COMM 2
281#define USB_CLASS_HID 3
282#define USB_CLASS_PHYSICAL 5
283#define USB_CLASS_STILL_IMAGE 6
284#define USB_CLASS_PRINTER 7
285#define USB_CLASS_MASS_STORAGE 8
286#define USB_CLASS_HUB 9
287#define USB_CLASS_CDC_DATA 0x0a
288#define USB_CLASS_CSCID 0x0b /* chip+ smart card */
289#define USB_CLASS_CONTENT_SEC 0x0d /* content security */
290#define USB_CLASS_VIDEO 0x0e
291#define USB_CLASS_WIRELESS_CONTROLLER 0xe0
292#define USB_CLASS_MISC 0xef
293#define USB_CLASS_APP_SPEC 0xfe
294#define USB_CLASS_VENDOR_SPEC 0xff
295
296#define USB_SUBCLASS_VENDOR_SPEC 0xff
297
298/*-------------------------------------------------------------------------*/
299
300/* USB_DT_CONFIG: Configuration descriptor information.
301 *
302 * USB_DT_OTHER_SPEED_CONFIG is the same descriptor, except that the
303 * descriptor type is different. Highspeed-capable devices can look
304 * different depending on what speed they're currently running. Only
305 * devices with a USB_DT_DEVICE_QUALIFIER have any OTHER_SPEED_CONFIG
306 * descriptors.
307 */
308struct usb_config_descriptor {
309 __u8 bLength;
310 __u8 bDescriptorType;
311
312 __le16 wTotalLength;
313 __u8 bNumInterfaces;
314 __u8 bConfigurationValue;
315 __u8 iConfiguration;
316 __u8 bmAttributes;
317 __u8 bMaxPower;
318} __attribute__ ((packed));
319
320#define USB_DT_CONFIG_SIZE 9
321
322/* from config descriptor bmAttributes */
323#define USB_CONFIG_ATT_ONE (1 << 7) /* must be set */
324#define USB_CONFIG_ATT_SELFPOWER (1 << 6) /* self powered */
325#define USB_CONFIG_ATT_WAKEUP (1 << 5) /* can wakeup */
326#define USB_CONFIG_ATT_BATTERY (1 << 4) /* battery powered */
327
328/*-------------------------------------------------------------------------*/
329
330/* USB_DT_STRING: String descriptor */
331struct usb_string_descriptor {
332 __u8 bLength;
333 __u8 bDescriptorType;
334
335 __le16 wData[1]; /* UTF-16LE encoded */
336} __attribute__ ((packed));
337
338/* note that "string" zero is special, it holds language codes that
339 * the device supports, not Unicode characters.
340 */
341
342/*-------------------------------------------------------------------------*/
343
344/* USB_DT_INTERFACE: Interface descriptor */
345struct usb_interface_descriptor {
346 __u8 bLength;
347 __u8 bDescriptorType;
348
349 __u8 bInterfaceNumber;
350 __u8 bAlternateSetting;
351 __u8 bNumEndpoints;
352 __u8 bInterfaceClass;
353 __u8 bInterfaceSubClass;
354 __u8 bInterfaceProtocol;
355 __u8 iInterface;
356} __attribute__ ((packed));
357
358#define USB_DT_INTERFACE_SIZE 9
359
360/*-------------------------------------------------------------------------*/
361
362/* USB_DT_ENDPOINT: Endpoint descriptor */
363struct usb_endpoint_descriptor {
364 __u8 bLength;
365 __u8 bDescriptorType;
366
367 __u8 bEndpointAddress;
368 __u8 bmAttributes;
369 __le16 wMaxPacketSize;
370 __u8 bInterval;
371
372 /* NOTE: these two are _only_ in audio endpoints. */
373 /* use USB_DT_ENDPOINT*_SIZE in bLength, not sizeof. */
374 __u8 bRefresh;
375 __u8 bSynchAddress;
376} __attribute__ ((packed));
377
378#define USB_DT_ENDPOINT_SIZE 7
379#define USB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */
380
381
382/*
383 * Endpoints
384 */
385#define USB_ENDPOINT_NUMBER_MASK 0x0f /* in bEndpointAddress */
386#define USB_ENDPOINT_DIR_MASK 0x80
387
388#define USB_ENDPOINT_XFERTYPE_MASK 0x03 /* in bmAttributes */
389#define USB_ENDPOINT_XFER_CONTROL 0
390#define USB_ENDPOINT_XFER_ISOC 1
391#define USB_ENDPOINT_XFER_BULK 2
392#define USB_ENDPOINT_XFER_INT 3
393#define USB_ENDPOINT_MAX_ADJUSTABLE 0x80
394
395/* The USB 3.0 spec redefines bits 5:4 of bmAttributes as interrupt ep type. */
396#define USB_ENDPOINT_INTRTYPE 0x30
397#define USB_ENDPOINT_INTR_PERIODIC (0 << 4)
398#define USB_ENDPOINT_INTR_NOTIFICATION (1 << 4)
399
400#define USB_ENDPOINT_SYNCTYPE 0x0c
401#define USB_ENDPOINT_SYNC_NONE (0 << 2)
402#define USB_ENDPOINT_SYNC_ASYNC (1 << 2)
403#define USB_ENDPOINT_SYNC_ADAPTIVE (2 << 2)
404#define USB_ENDPOINT_SYNC_SYNC (3 << 2)
405
406#define USB_ENDPOINT_USAGE_MASK 0x30
407#define USB_ENDPOINT_USAGE_DATA 0x00
408#define USB_ENDPOINT_USAGE_FEEDBACK 0x10
409#define USB_ENDPOINT_USAGE_IMPLICIT_FB 0x20 /* Implicit feedback Data endpoint */
410
411/*-------------------------------------------------------------------------*/
412
413/**
414 * usb_endpoint_num - get the endpoint's number
415 * @epd: endpoint to be checked
416 *
417 * Returns @epd's number: 0 to 15.
418 */
419static inline int usb_endpoint_num(const struct usb_endpoint_descriptor *epd)
420{
421 return epd->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
422}
423
424/**
425 * usb_endpoint_type - get the endpoint's transfer type
426 * @epd: endpoint to be checked
427 *
428 * Returns one of USB_ENDPOINT_XFER_{CONTROL, ISOC, BULK, INT} according
429 * to @epd's transfer type.
430 */
431static inline int usb_endpoint_type(const struct usb_endpoint_descriptor *epd)
432{
433 return epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK;
434}
435
436/**
437 * usb_endpoint_dir_in - check if the endpoint has IN direction
438 * @epd: endpoint to be checked
439 *
440 * Returns true if the endpoint is of type IN, otherwise it returns false.
441 */
442static inline int usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd)
443{
444 return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN);
445}
446
447/**
448 * usb_endpoint_dir_out - check if the endpoint has OUT direction
449 * @epd: endpoint to be checked
450 *
451 * Returns true if the endpoint is of type OUT, otherwise it returns false.
452 */
453static inline int usb_endpoint_dir_out(
454 const struct usb_endpoint_descriptor *epd)
455{
456 return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT);
457}
458
459/**
460 * usb_endpoint_xfer_bulk - check if the endpoint has bulk transfer type
461 * @epd: endpoint to be checked
462 *
463 * Returns true if the endpoint is of type bulk, otherwise it returns false.
464 */
465static inline int usb_endpoint_xfer_bulk(
466 const struct usb_endpoint_descriptor *epd)
467{
468 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
469 USB_ENDPOINT_XFER_BULK);
470}
471
472/**
473 * usb_endpoint_xfer_control - check if the endpoint has control transfer type
474 * @epd: endpoint to be checked
475 *
476 * Returns true if the endpoint is of type control, otherwise it returns false.
477 */
478static inline int usb_endpoint_xfer_control(
479 const struct usb_endpoint_descriptor *epd)
480{
481 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
482 USB_ENDPOINT_XFER_CONTROL);
483}
484
485/**
486 * usb_endpoint_xfer_int - check if the endpoint has interrupt transfer type
487 * @epd: endpoint to be checked
488 *
489 * Returns true if the endpoint is of type interrupt, otherwise it returns
490 * false.
491 */
492static inline int usb_endpoint_xfer_int(
493 const struct usb_endpoint_descriptor *epd)
494{
495 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
496 USB_ENDPOINT_XFER_INT);
497}
498
499/**
500 * usb_endpoint_xfer_isoc - check if the endpoint has isochronous transfer type
501 * @epd: endpoint to be checked
502 *
503 * Returns true if the endpoint is of type isochronous, otherwise it returns
504 * false.
505 */
506static inline int usb_endpoint_xfer_isoc(
507 const struct usb_endpoint_descriptor *epd)
508{
509 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
510 USB_ENDPOINT_XFER_ISOC);
511}
512
513/**
514 * usb_endpoint_is_bulk_in - check if the endpoint is bulk IN
515 * @epd: endpoint to be checked
516 *
517 * Returns true if the endpoint has bulk transfer type and IN direction,
518 * otherwise it returns false.
519 */
520static inline int usb_endpoint_is_bulk_in(
521 const struct usb_endpoint_descriptor *epd)
522{
523 return usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_in(epd);
524}
525
526/**
527 * usb_endpoint_is_bulk_out - check if the endpoint is bulk OUT
528 * @epd: endpoint to be checked
529 *
530 * Returns true if the endpoint has bulk transfer type and OUT direction,
531 * otherwise it returns false.
532 */
533static inline int usb_endpoint_is_bulk_out(
534 const struct usb_endpoint_descriptor *epd)
535{
536 return usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_out(epd);
537}
538
539/**
540 * usb_endpoint_is_int_in - check if the endpoint is interrupt IN
541 * @epd: endpoint to be checked
542 *
543 * Returns true if the endpoint has interrupt transfer type and IN direction,
544 * otherwise it returns false.
545 */
546static inline int usb_endpoint_is_int_in(
547 const struct usb_endpoint_descriptor *epd)
548{
549 return usb_endpoint_xfer_int(epd) && usb_endpoint_dir_in(epd);
550}
551
552/**
553 * usb_endpoint_is_int_out - check if the endpoint is interrupt OUT
554 * @epd: endpoint to be checked
555 *
556 * Returns true if the endpoint has interrupt transfer type and OUT direction,
557 * otherwise it returns false.
558 */
559static inline int usb_endpoint_is_int_out(
560 const struct usb_endpoint_descriptor *epd)
561{
562 return usb_endpoint_xfer_int(epd) && usb_endpoint_dir_out(epd);
563}
564
565/**
566 * usb_endpoint_is_isoc_in - check if the endpoint is isochronous IN
567 * @epd: endpoint to be checked
568 *
569 * Returns true if the endpoint has isochronous transfer type and IN direction,
570 * otherwise it returns false.
571 */
572static inline int usb_endpoint_is_isoc_in(
573 const struct usb_endpoint_descriptor *epd)
574{
575 return usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_in(epd);
576}
577
578/**
579 * usb_endpoint_is_isoc_out - check if the endpoint is isochronous OUT
580 * @epd: endpoint to be checked
581 *
582 * Returns true if the endpoint has isochronous transfer type and OUT direction,
583 * otherwise it returns false.
584 */
585static inline int usb_endpoint_is_isoc_out(
586 const struct usb_endpoint_descriptor *epd)
587{
588 return usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_out(epd);
589}
590
591/**
592 * usb_endpoint_maxp - get endpoint's max packet size
593 * @epd: endpoint to be checked
594 *
595 * Returns @epd's max packet
596 */
597static inline int usb_endpoint_maxp(const struct usb_endpoint_descriptor *epd)
598{
599 return __le16_to_cpu(epd->wMaxPacketSize);
600}
601
602static inline int usb_endpoint_interrupt_type(
603 const struct usb_endpoint_descriptor *epd)
604{
605 return epd->bmAttributes & USB_ENDPOINT_INTRTYPE;
606}
607
608/*-------------------------------------------------------------------------*/
609
610/* USB_DT_SS_ENDPOINT_COMP: SuperSpeed Endpoint Companion descriptor */
611struct usb_ss_ep_comp_descriptor {
612 __u8 bLength;
613 __u8 bDescriptorType;
614
615 __u8 bMaxBurst;
616 __u8 bmAttributes;
617 __le16 wBytesPerInterval;
618} __attribute__ ((packed));
619
620#define USB_DT_SS_EP_COMP_SIZE 6
621
622/* Bits 4:0 of bmAttributes if this is a bulk endpoint */
623static inline int
624usb_ss_max_streams(const struct usb_ss_ep_comp_descriptor *comp)
625{
626 int max_streams;
627
628 if (!comp)
629 return 0;
630
631 max_streams = comp->bmAttributes & 0x1f;
632
633 if (!max_streams)
634 return 0;
635
636 max_streams = 1 << max_streams;
637
638 return max_streams;
639}
640
641/* Bits 1:0 of bmAttributes if this is an isoc endpoint */
642#define USB_SS_MULT(p) (1 + ((p) & 0x3))
643
644/*-------------------------------------------------------------------------*/
645
646/* USB_DT_DEVICE_QUALIFIER: Device Qualifier descriptor */
647struct usb_qualifier_descriptor {
648 __u8 bLength;
649 __u8 bDescriptorType;
650
651 __le16 bcdUSB;
652 __u8 bDeviceClass;
653 __u8 bDeviceSubClass;
654 __u8 bDeviceProtocol;
655 __u8 bMaxPacketSize0;
656 __u8 bNumConfigurations;
657 __u8 bRESERVED;
658} __attribute__ ((packed));
659
660
661/*-------------------------------------------------------------------------*/
662
663/* USB_DT_OTG (from OTG 1.0a supplement) */
664struct usb_otg_descriptor {
665 __u8 bLength;
666 __u8 bDescriptorType;
667
668 __u8 bmAttributes; /* support for HNP, SRP, etc */
669} __attribute__ ((packed));
670
671/* from usb_otg_descriptor.bmAttributes */
672#define USB_OTG_SRP (1 << 0)
673#define USB_OTG_HNP (1 << 1) /* swap host/device roles */
674
675/*-------------------------------------------------------------------------*/
676
677/* USB_DT_DEBUG: for special highspeed devices, replacing serial console */
678struct usb_debug_descriptor {
679 __u8 bLength;
680 __u8 bDescriptorType;
681
682 /* bulk endpoints with 8 byte maxpacket */
683 __u8 bDebugInEndpoint;
684 __u8 bDebugOutEndpoint;
685} __attribute__((packed));
686
687/*-------------------------------------------------------------------------*/
688
689/* USB_DT_INTERFACE_ASSOCIATION: groups interfaces */
690struct usb_interface_assoc_descriptor {
691 __u8 bLength;
692 __u8 bDescriptorType;
693
694 __u8 bFirstInterface;
695 __u8 bInterfaceCount;
696 __u8 bFunctionClass;
697 __u8 bFunctionSubClass;
698 __u8 bFunctionProtocol;
699 __u8 iFunction;
700} __attribute__ ((packed));
701
702
703/*-------------------------------------------------------------------------*/
704
705/* USB_DT_SECURITY: group of wireless security descriptors, including
706 * encryption types available for setting up a CC/association.
707 */
708struct usb_security_descriptor {
709 __u8 bLength;
710 __u8 bDescriptorType;
711
712 __le16 wTotalLength;
713 __u8 bNumEncryptionTypes;
714} __attribute__((packed));
715
716/*-------------------------------------------------------------------------*/
717
718/* USB_DT_KEY: used with {GET,SET}_SECURITY_DATA; only public keys
719 * may be retrieved.
720 */
721struct usb_key_descriptor {
722 __u8 bLength;
723 __u8 bDescriptorType;
724
725 __u8 tTKID[3];
726 __u8 bReserved;
727 __u8 bKeyData[0];
728} __attribute__((packed));
729
730/*-------------------------------------------------------------------------*/
731
732/* USB_DT_ENCRYPTION_TYPE: bundled in DT_SECURITY groups */
733struct usb_encryption_descriptor {
734 __u8 bLength;
735 __u8 bDescriptorType;
736
737 __u8 bEncryptionType;
738#define USB_ENC_TYPE_UNSECURE 0
739#define USB_ENC_TYPE_WIRED 1 /* non-wireless mode */
740#define USB_ENC_TYPE_CCM_1 2 /* aes128/cbc session */
741#define USB_ENC_TYPE_RSA_1 3 /* rsa3072/sha1 auth */
742 __u8 bEncryptionValue; /* use in SET_ENCRYPTION */
743 __u8 bAuthKeyIndex;
744} __attribute__((packed));
745
746
747/*-------------------------------------------------------------------------*/
748
749/* USB_DT_BOS: group of device-level capabilities */
750struct usb_bos_descriptor {
751 __u8 bLength;
752 __u8 bDescriptorType;
753
754 __le16 wTotalLength;
755 __u8 bNumDeviceCaps;
756} __attribute__((packed));
757
758#define USB_DT_BOS_SIZE 5
759/*-------------------------------------------------------------------------*/
760
761/* USB_DT_DEVICE_CAPABILITY: grouped with BOS */
762struct usb_dev_cap_header {
763 __u8 bLength;
764 __u8 bDescriptorType;
765 __u8 bDevCapabilityType;
766} __attribute__((packed));
767
768#define USB_CAP_TYPE_WIRELESS_USB 1
769
770struct usb_wireless_cap_descriptor { /* Ultra Wide Band */
771 __u8 bLength;
772 __u8 bDescriptorType;
773 __u8 bDevCapabilityType;
774
775 __u8 bmAttributes;
776#define USB_WIRELESS_P2P_DRD (1 << 1)
777#define USB_WIRELESS_BEACON_MASK (3 << 2)
778#define USB_WIRELESS_BEACON_SELF (1 << 2)
779#define USB_WIRELESS_BEACON_DIRECTED (2 << 2)
780#define USB_WIRELESS_BEACON_NONE (3 << 2)
781 __le16 wPHYRates; /* bit rates, Mbps */
782#define USB_WIRELESS_PHY_53 (1 << 0) /* always set */
783#define USB_WIRELESS_PHY_80 (1 << 1)
784#define USB_WIRELESS_PHY_107 (1 << 2) /* always set */
785#define USB_WIRELESS_PHY_160 (1 << 3)
786#define USB_WIRELESS_PHY_200 (1 << 4) /* always set */
787#define USB_WIRELESS_PHY_320 (1 << 5)
788#define USB_WIRELESS_PHY_400 (1 << 6)
789#define USB_WIRELESS_PHY_480 (1 << 7)
790 __u8 bmTFITXPowerInfo; /* TFI power levels */
791 __u8 bmFFITXPowerInfo; /* FFI power levels */
792 __le16 bmBandGroup;
793 __u8 bReserved;
794} __attribute__((packed));
795
796/* USB 2.0 Extension descriptor */
797#define USB_CAP_TYPE_EXT 2
798
799struct usb_ext_cap_descriptor { /* Link Power Management */
800 __u8 bLength;
801 __u8 bDescriptorType;
802 __u8 bDevCapabilityType;
803 __le32 bmAttributes;
804#define USB_LPM_SUPPORT (1 << 1) /* supports LPM */
805#define USB_BESL_SUPPORT (1 << 2) /* supports BESL */
806#define USB_BESL_BASELINE_VALID (1 << 3) /* Baseline BESL valid*/
807#define USB_BESL_DEEP_VALID (1 << 4) /* Deep BESL valid */
808#define USB_GET_BESL_BASELINE(p) (((p) & (0xf << 8)) >> 8)
809#define USB_GET_BESL_DEEP(p) (((p) & (0xf << 12)) >> 12)
810} __attribute__((packed));
811
812#define USB_DT_USB_EXT_CAP_SIZE 7
813
814/*
815 * SuperSpeed USB Capability descriptor: Defines the set of SuperSpeed USB
816 * specific device level capabilities
817 */
818#define USB_SS_CAP_TYPE 3
819struct usb_ss_cap_descriptor { /* Link Power Management */
820 __u8 bLength;
821 __u8 bDescriptorType;
822 __u8 bDevCapabilityType;
823 __u8 bmAttributes;
824#define USB_LTM_SUPPORT (1 << 1) /* supports LTM */
825 __le16 wSpeedSupported;
826#define USB_LOW_SPEED_OPERATION (1) /* Low speed operation */
827#define USB_FULL_SPEED_OPERATION (1 << 1) /* Full speed operation */
828#define USB_HIGH_SPEED_OPERATION (1 << 2) /* High speed operation */
829#define USB_5GBPS_OPERATION (1 << 3) /* Operation at 5Gbps */
830 __u8 bFunctionalitySupport;
831 __u8 bU1devExitLat;
832 __le16 bU2DevExitLat;
833} __attribute__((packed));
834
835#define USB_DT_USB_SS_CAP_SIZE 10
836
837/*
838 * Container ID Capability descriptor: Defines the instance unique ID used to
839 * identify the instance across all operating modes
840 */
841#define CONTAINER_ID_TYPE 4
842struct usb_ss_container_id_descriptor {
843 __u8 bLength;
844 __u8 bDescriptorType;
845 __u8 bDevCapabilityType;
846 __u8 bReserved;
847 __u8 ContainerID[16]; /* 128-bit number */
848} __attribute__((packed));
849
850#define USB_DT_USB_SS_CONTN_ID_SIZE 20
851/*-------------------------------------------------------------------------*/
852
853/* USB_DT_WIRELESS_ENDPOINT_COMP: companion descriptor associated with
854 * each endpoint descriptor for a wireless device
855 */
856struct usb_wireless_ep_comp_descriptor {
857 __u8 bLength;
858 __u8 bDescriptorType;
859
860 __u8 bMaxBurst;
861 __u8 bMaxSequence;
862 __le16 wMaxStreamDelay;
863 __le16 wOverTheAirPacketSize;
864 __u8 bOverTheAirInterval;
865 __u8 bmCompAttributes;
866#define USB_ENDPOINT_SWITCH_MASK 0x03 /* in bmCompAttributes */
867#define USB_ENDPOINT_SWITCH_NO 0
868#define USB_ENDPOINT_SWITCH_SWITCH 1
869#define USB_ENDPOINT_SWITCH_SCALE 2
870} __attribute__((packed));
871
872/*-------------------------------------------------------------------------*/
873
874/* USB_REQ_SET_HANDSHAKE is a four-way handshake used between a wireless
875 * host and a device for connection set up, mutual authentication, and
876 * exchanging short lived session keys. The handshake depends on a CC.
877 */
878struct usb_handshake {
879 __u8 bMessageNumber;
880 __u8 bStatus;
881 __u8 tTKID[3];
882 __u8 bReserved;
883 __u8 CDID[16];
884 __u8 nonce[16];
885 __u8 MIC[8];
886} __attribute__((packed));
887
888/*-------------------------------------------------------------------------*/
889
890/* USB_REQ_SET_CONNECTION modifies or revokes a connection context (CC).
891 * A CC may also be set up using non-wireless secure channels (including
892 * wired USB!), and some devices may support CCs with multiple hosts.
893 */
894struct usb_connection_context {
895 __u8 CHID[16]; /* persistent host id */
896 __u8 CDID[16]; /* device id (unique w/in host context) */
897 __u8 CK[16]; /* connection key */
898} __attribute__((packed));
899
900/*-------------------------------------------------------------------------*/
901
902/* USB 2.0 defines three speeds, here's how Linux identifies them */
903
904enum usb_device_speed {
905 USB_SPEED_UNKNOWN = 0, /* enumerating */
906 USB_SPEED_LOW, USB_SPEED_FULL, /* usb 1.1 */
907 USB_SPEED_HIGH, /* usb 2.0 */
908 USB_SPEED_WIRELESS, /* wireless (usb 2.5) */
909 USB_SPEED_SUPER, /* usb 3.0 */
910};
911
912
913enum usb_device_state {
914 /* NOTATTACHED isn't in the USB spec, and this state acts
915 * the same as ATTACHED ... but it's clearer this way.
916 */
917 USB_STATE_NOTATTACHED = 0,
918
919 /* chapter 9 and authentication (wireless) device states */
920 USB_STATE_ATTACHED,
921 USB_STATE_POWERED, /* wired */
922 USB_STATE_RECONNECTING, /* auth */
923 USB_STATE_UNAUTHENTICATED, /* auth */
924 USB_STATE_DEFAULT, /* limited function */
925 USB_STATE_ADDRESS,
926 USB_STATE_CONFIGURED, /* most functions */
927
928 USB_STATE_SUSPENDED
929
930 /* NOTE: there are actually four different SUSPENDED
931 * states, returning to POWERED, DEFAULT, ADDRESS, or
932 * CONFIGURED respectively when SOF tokens flow again.
933 * At this level there's no difference between L1 and L2
934 * suspend states. (L2 being original USB 1.1 suspend.)
935 */
936};
937
938enum usb3_link_state {
939 USB3_LPM_U0 = 0,
940 USB3_LPM_U1,
941 USB3_LPM_U2,
942 USB3_LPM_U3
943};
944
945/*
946 * A U1 timeout of 0x0 means the parent hub will reject any transitions to U1.
947 * 0xff means the parent hub will accept transitions to U1, but will not
948 * initiate a transition.
949 *
950 * A U1 timeout of 0x1 to 0x7F also causes the hub to initiate a transition to
951 * U1 after that many microseconds. Timeouts of 0x80 to 0xFE are reserved
952 * values.
953 *
954 * A U2 timeout of 0x0 means the parent hub will reject any transitions to U2.
955 * 0xff means the parent hub will accept transitions to U2, but will not
956 * initiate a transition.
957 *
958 * A U2 timeout of 0x1 to 0xFE also causes the hub to initiate a transition to
959 * U2 after N*256 microseconds. Therefore a U2 timeout value of 0x1 means a U2
960 * idle timer of 256 microseconds, 0x2 means 512 microseconds, 0xFE means
961 * 65.024ms.
962 */
963#define USB3_LPM_DISABLED 0x0
964#define USB3_LPM_U1_MAX_TIMEOUT 0x7F
965#define USB3_LPM_U2_MAX_TIMEOUT 0xFE
966#define USB3_LPM_DEVICE_INITIATED 0xFF
967
968struct usb_set_sel_req {
969 __u8 u1_sel;
970 __u8 u1_pel;
971 __le16 u2_sel;
972 __le16 u2_pel;
973} __attribute__ ((packed));
974
975/*
976 * The Set System Exit Latency control transfer provides one byte each for
977 * U1 SEL and U1 PEL, so the max exit latency is 0xFF. U2 SEL and U2 PEL each
978 * are two bytes long.
979 */
980#define USB3_LPM_MAX_U1_SEL_PEL 0xFF
981#define USB3_LPM_MAX_U2_SEL_PEL 0xFFFF
982
983/*-------------------------------------------------------------------------*/
984
985/*
986 * As per USB compliance update, a device that is actively drawing
987 * more than 100mA from USB must report itself as bus-powered in
988 * the GetStatus(DEVICE) call.
989 * http://compliance.usb.org/index.asp?UpdateFile=Electrical&Format=Standard#34
990 */
991#define USB_SELF_POWER_VBUS_MAX_DRAW 100
992
993#endif /* _UAPI__LINUX_USB_CH9_H */
diff --git a/include/uapi/linux/usb/functionfs.h b/include/uapi/linux/usb/functionfs.h
new file mode 100644
index 00000000000..d6b01283f85
--- /dev/null
+++ b/include/uapi/linux/usb/functionfs.h
@@ -0,0 +1,169 @@
1#ifndef _UAPI__LINUX_FUNCTIONFS_H__
2#define _UAPI__LINUX_FUNCTIONFS_H__
3
4
5#include <linux/types.h>
6#include <linux/ioctl.h>
7
8#include <linux/usb/ch9.h>
9
10
11enum {
12 FUNCTIONFS_DESCRIPTORS_MAGIC = 1,
13 FUNCTIONFS_STRINGS_MAGIC = 2
14};
15
16
17#ifndef __KERNEL__
18
19/* Descriptor of an non-audio endpoint */
20struct usb_endpoint_descriptor_no_audio {
21 __u8 bLength;
22 __u8 bDescriptorType;
23
24 __u8 bEndpointAddress;
25 __u8 bmAttributes;
26 __le16 wMaxPacketSize;
27 __u8 bInterval;
28} __attribute__((packed));
29
30
31/*
32 * All numbers must be in little endian order.
33 */
34
35struct usb_functionfs_descs_head {
36 __le32 magic;
37 __le32 length;
38 __le32 fs_count;
39 __le32 hs_count;
40} __attribute__((packed));
41
42/*
43 * Descriptors format:
44 *
45 * | off | name | type | description |
46 * |-----+-----------+--------------+--------------------------------------|
47 * | 0 | magic | LE32 | FUNCTIONFS_{FS,HS}_DESCRIPTORS_MAGIC |
48 * | 4 | length | LE32 | length of the whole data chunk |
49 * | 8 | fs_count | LE32 | number of full-speed descriptors |
50 * | 12 | hs_count | LE32 | number of high-speed descriptors |
51 * | 16 | fs_descrs | Descriptor[] | list of full-speed descriptors |
52 * | | hs_descrs | Descriptor[] | list of high-speed descriptors |
53 *
54 * descs are just valid USB descriptors and have the following format:
55 *
56 * | off | name | type | description |
57 * |-----+-----------------+------+--------------------------|
58 * | 0 | bLength | U8 | length of the descriptor |
59 * | 1 | bDescriptorType | U8 | descriptor type |
60 * | 2 | payload | | descriptor's payload |
61 */
62
63struct usb_functionfs_strings_head {
64 __le32 magic;
65 __le32 length;
66 __le32 str_count;
67 __le32 lang_count;
68} __attribute__((packed));
69
70/*
71 * Strings format:
72 *
73 * | off | name | type | description |
74 * |-----+------------+-----------------------+----------------------------|
75 * | 0 | magic | LE32 | FUNCTIONFS_STRINGS_MAGIC |
76 * | 4 | length | LE32 | length of the data chunk |
77 * | 8 | str_count | LE32 | number of strings |
78 * | 12 | lang_count | LE32 | number of languages |
79 * | 16 | stringtab | StringTab[lang_count] | table of strings per lang |
80 *
81 * For each language there is one stringtab entry (ie. there are lang_count
82 * stringtab entires). Each StringTab has following format:
83 *
84 * | off | name | type | description |
85 * |-----+---------+-------------------+------------------------------------|
86 * | 0 | lang | LE16 | language code |
87 * | 2 | strings | String[str_count] | array of strings in given language |
88 *
89 * For each string there is one strings entry (ie. there are str_count
90 * string entries). Each String is a NUL terminated string encoded in
91 * UTF-8.
92 */
93
94#endif
95
96
97/*
98 * Events are delivered on the ep0 file descriptor, when the user mode driver
99 * reads from this file descriptor after writing the descriptors. Don't
100 * stop polling this descriptor.
101 */
102
103enum usb_functionfs_event_type {
104 FUNCTIONFS_BIND,
105 FUNCTIONFS_UNBIND,
106
107 FUNCTIONFS_ENABLE,
108 FUNCTIONFS_DISABLE,
109
110 FUNCTIONFS_SETUP,
111
112 FUNCTIONFS_SUSPEND,
113 FUNCTIONFS_RESUME
114};
115
116/* NOTE: this structure must stay the same size and layout on
117 * both 32-bit and 64-bit kernels.
118 */
119struct usb_functionfs_event {
120 union {
121 /* SETUP: packet; DATA phase i/o precedes next event
122 *(setup.bmRequestType & USB_DIR_IN) flags direction */
123 struct usb_ctrlrequest setup;
124 } __attribute__((packed)) u;
125
126 /* enum usb_functionfs_event_type */
127 __u8 type;
128 __u8 _pad[3];
129} __attribute__((packed));
130
131
132/* Endpoint ioctls */
133/* The same as in gadgetfs */
134
135/* IN transfers may be reported to the gadget driver as complete
136 * when the fifo is loaded, before the host reads the data;
137 * OUT transfers may be reported to the host's "client" driver as
138 * complete when they're sitting in the FIFO unread.
139 * THIS returns how many bytes are "unclaimed" in the endpoint fifo
140 * (needed for precise fault handling, when the hardware allows it)
141 */
142#define FUNCTIONFS_FIFO_STATUS _IO('g', 1)
143
144/* discards any unclaimed data in the fifo. */
145#define FUNCTIONFS_FIFO_FLUSH _IO('g', 2)
146
147/* resets endpoint halt+toggle; used to implement set_interface.
148 * some hardware (like pxa2xx) can't support this.
149 */
150#define FUNCTIONFS_CLEAR_HALT _IO('g', 3)
151
152/* Specific for functionfs */
153
154/*
155 * Returns reverse mapping of an interface. Called on EP0. If there
156 * is no such interface returns -EDOM. If function is not active
157 * returns -ENODEV.
158 */
159#define FUNCTIONFS_INTERFACE_REVMAP _IO('g', 128)
160
161/*
162 * Returns real bEndpointAddress of an endpoint. If function is not
163 * active returns -ENODEV.
164 */
165#define FUNCTIONFS_ENDPOINT_REVMAP _IO('g', 129)
166
167
168
169#endif /* _UAPI__LINUX_FUNCTIONFS_H__ */
diff --git a/include/linux/usb/g_printer.h b/include/uapi/linux/usb/g_printer.h
index 6178fde50f7..6178fde50f7 100644
--- a/include/linux/usb/g_printer.h
+++ b/include/uapi/linux/usb/g_printer.h
diff --git a/include/linux/usb/gadgetfs.h b/include/uapi/linux/usb/gadgetfs.h
index 0bb12e0d4f8..0bb12e0d4f8 100644
--- a/include/linux/usb/gadgetfs.h
+++ b/include/uapi/linux/usb/gadgetfs.h
diff --git a/include/linux/usb/midi.h b/include/uapi/linux/usb/midi.h
index c8c52e3c91d..c8c52e3c91d 100644
--- a/include/linux/usb/midi.h
+++ b/include/uapi/linux/usb/midi.h
diff --git a/include/linux/usb/tmc.h b/include/uapi/linux/usb/tmc.h
index c045ae12556..c045ae12556 100644
--- a/include/linux/usb/tmc.h
+++ b/include/uapi/linux/usb/tmc.h
diff --git a/include/linux/usb/video.h b/include/uapi/linux/usb/video.h
index 3b3b95e01f7..3b3b95e01f7 100644
--- a/include/linux/usb/video.h
+++ b/include/uapi/linux/usb/video.h
diff --git a/include/xen/Kbuild b/include/xen/Kbuild
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/include/xen/Kbuild
+++ /dev/null
diff --git a/include/xen/grant_table.h b/include/xen/grant_table.h
index aecee9d112c..694dcaf266e 100644
--- a/include/xen/grant_table.h
+++ b/include/xen/grant_table.h
@@ -170,7 +170,7 @@ gnttab_set_unmap_op(struct gnttab_unmap_grant_ref *unmap, phys_addr_t addr,
170 unmap->dev_bus_addr = 0; 170 unmap->dev_bus_addr = 0;
171} 171}
172 172
173int arch_gnttab_map_shared(unsigned long *frames, unsigned long nr_gframes, 173int arch_gnttab_map_shared(xen_pfn_t *frames, unsigned long nr_gframes,
174 unsigned long max_nr_gframes, 174 unsigned long max_nr_gframes,
175 void **__shared); 175 void **__shared);
176int arch_gnttab_map_status(uint64_t *frames, unsigned long nr_gframes, 176int arch_gnttab_map_status(uint64_t *frames, unsigned long nr_gframes,
diff --git a/include/xen/hvm.h b/include/xen/hvm.h
index b193fa2f9fd..13e43e41637 100644
--- a/include/xen/hvm.h
+++ b/include/xen/hvm.h
@@ -5,6 +5,36 @@
5#include <xen/interface/hvm/params.h> 5#include <xen/interface/hvm/params.h>
6#include <asm/xen/hypercall.h> 6#include <asm/xen/hypercall.h>
7 7
8static const char *param_name(int op)
9{
10#define PARAM(x) [HVM_PARAM_##x] = #x
11 static const char *const names[] = {
12 PARAM(CALLBACK_IRQ),
13 PARAM(STORE_PFN),
14 PARAM(STORE_EVTCHN),
15 PARAM(PAE_ENABLED),
16 PARAM(IOREQ_PFN),
17 PARAM(BUFIOREQ_PFN),
18 PARAM(TIMER_MODE),
19 PARAM(HPET_ENABLED),
20 PARAM(IDENT_PT),
21 PARAM(DM_DOMAIN),
22 PARAM(ACPI_S_STATE),
23 PARAM(VM86_TSS),
24 PARAM(VPT_ALIGN),
25 PARAM(CONSOLE_PFN),
26 PARAM(CONSOLE_EVTCHN),
27 };
28#undef PARAM
29
30 if (op >= ARRAY_SIZE(names))
31 return "unknown";
32
33 if (!names[op])
34 return "reserved";
35
36 return names[op];
37}
8static inline int hvm_get_parameter(int idx, uint64_t *value) 38static inline int hvm_get_parameter(int idx, uint64_t *value)
9{ 39{
10 struct xen_hvm_param xhv; 40 struct xen_hvm_param xhv;
@@ -14,8 +44,8 @@ static inline int hvm_get_parameter(int idx, uint64_t *value)
14 xhv.index = idx; 44 xhv.index = idx;
15 r = HYPERVISOR_hvm_op(HVMOP_get_param, &xhv); 45 r = HYPERVISOR_hvm_op(HVMOP_get_param, &xhv);
16 if (r < 0) { 46 if (r < 0) {
17 printk(KERN_ERR "Cannot get hvm parameter %d: %d!\n", 47 printk(KERN_ERR "Cannot get hvm parameter %s (%d): %d!\n",
18 idx, r); 48 param_name(idx), idx, r);
19 return r; 49 return r;
20 } 50 }
21 *value = xhv.value; 51 *value = xhv.value;
diff --git a/include/xen/interface/grant_table.h b/include/xen/interface/grant_table.h
index f9f8b975ae7..e40fae9bf11 100644
--- a/include/xen/interface/grant_table.h
+++ b/include/xen/interface/grant_table.h
@@ -310,7 +310,7 @@ struct gnttab_setup_table {
310 uint32_t nr_frames; 310 uint32_t nr_frames;
311 /* OUT parameters. */ 311 /* OUT parameters. */
312 int16_t status; /* GNTST_* */ 312 int16_t status; /* GNTST_* */
313 GUEST_HANDLE(ulong) frame_list; 313 GUEST_HANDLE(xen_pfn_t) frame_list;
314}; 314};
315DEFINE_GUEST_HANDLE_STRUCT(gnttab_setup_table); 315DEFINE_GUEST_HANDLE_STRUCT(gnttab_setup_table);
316 316
diff --git a/include/xen/interface/memory.h b/include/xen/interface/memory.h
index b66d04ce695..90712e2072d 100644
--- a/include/xen/interface/memory.h
+++ b/include/xen/interface/memory.h
@@ -179,28 +179,8 @@ struct xen_add_to_physmap {
179}; 179};
180DEFINE_GUEST_HANDLE_STRUCT(xen_add_to_physmap); 180DEFINE_GUEST_HANDLE_STRUCT(xen_add_to_physmap);
181 181
182/* 182/*** REMOVED ***/
183 * Translates a list of domain-specific GPFNs into MFNs. Returns a -ve error 183/*#define XENMEM_translate_gpfn_list 8*/
184 * code on failure. This call only works for auto-translated guests.
185 */
186#define XENMEM_translate_gpfn_list 8
187struct xen_translate_gpfn_list {
188 /* Which domain to translate for? */
189 domid_t domid;
190
191 /* Length of list. */
192 xen_ulong_t nr_gpfns;
193
194 /* List of GPFNs to translate. */
195 GUEST_HANDLE(ulong) gpfn_list;
196
197 /*
198 * Output list to contain MFN translations. May be the same as the input
199 * list (in which case each input GPFN is overwritten with the output MFN).
200 */
201 GUEST_HANDLE(ulong) mfn_list;
202};
203DEFINE_GUEST_HANDLE_STRUCT(xen_translate_gpfn_list);
204 184
205/* 185/*
206 * Returns the pseudo-physical memory map as it was when the domain 186 * Returns the pseudo-physical memory map as it was when the domain
diff --git a/init/main.c b/init/main.c
index 9cf77ab138a..e33e09df3cb 100644
--- a/init/main.c
+++ b/init/main.c
@@ -442,9 +442,11 @@ void __init __weak smp_setup_processor_id(void)
442{ 442{
443} 443}
444 444
445# if THREAD_SIZE >= PAGE_SIZE
445void __init __weak thread_info_cache_init(void) 446void __init __weak thread_info_cache_init(void)
446{ 447{
447} 448}
449#endif
448 450
449/* 451/*
450 * Set up kernel memory allocators 452 * Set up kernel memory allocators
diff --git a/kernel/Makefile b/kernel/Makefile
index 0dfeca4324e..86e3285ae7e 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -174,10 +174,8 @@ signing_key.priv signing_key.x509: x509.genkey
174 @echo "###" 174 @echo "###"
175 @echo "### If this takes a long time, you might wish to run rngd in the" 175 @echo "### If this takes a long time, you might wish to run rngd in the"
176 @echo "### background to keep the supply of entropy topped up. It" 176 @echo "### background to keep the supply of entropy topped up. It"
177 @echo "### needs to be run as root, and should use a hardware random" 177 @echo "### needs to be run as root, and uses a hardware random"
178 @echo "### number generator if one is available, eg:" 178 @echo "### number generator if one is available."
179 @echo "###"
180 @echo "### rngd -r /dev/hwrandom"
181 @echo "###" 179 @echo "###"
182 openssl req -new -nodes -utf8 $(sign_key_with_hash) -days 36500 -batch \ 180 openssl req -new -nodes -utf8 $(sign_key_with_hash) -days 36500 -batch \
183 -x509 -config x509.genkey \ 181 -x509 -config x509.genkey \
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 13774b3b39a..f24f724620d 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -1962,9 +1962,8 @@ static void cgroup_task_migrate(struct cgroup *cgrp, struct cgroup *oldcgrp,
1962 * trading it for newcg is protected by cgroup_mutex, we're safe to drop 1962 * trading it for newcg is protected by cgroup_mutex, we're safe to drop
1963 * it here; it will be freed under RCU. 1963 * it here; it will be freed under RCU.
1964 */ 1964 */
1965 put_css_set(oldcg);
1966
1967 set_bit(CGRP_RELEASABLE, &oldcgrp->flags); 1965 set_bit(CGRP_RELEASABLE, &oldcgrp->flags);
1966 put_css_set(oldcg);
1968} 1967}
1969 1968
1970/** 1969/**
@@ -4815,31 +4814,20 @@ static const struct file_operations proc_cgroupstats_operations = {
4815 * 4814 *
4816 * A pointer to the shared css_set was automatically copied in 4815 * A pointer to the shared css_set was automatically copied in
4817 * fork.c by dup_task_struct(). However, we ignore that copy, since 4816 * fork.c by dup_task_struct(). However, we ignore that copy, since
4818 * it was not made under the protection of RCU, cgroup_mutex or 4817 * it was not made under the protection of RCU or cgroup_mutex, so
4819 * threadgroup_change_begin(), so it might no longer be a valid 4818 * might no longer be a valid cgroup pointer. cgroup_attach_task() might
4820 * cgroup pointer. cgroup_attach_task() might have already changed 4819 * have already changed current->cgroups, allowing the previously
4821 * current->cgroups, allowing the previously referenced cgroup 4820 * referenced cgroup group to be removed and freed.
4822 * group to be removed and freed.
4823 *
4824 * Outside the pointer validity we also need to process the css_set
4825 * inheritance between threadgoup_change_begin() and
4826 * threadgoup_change_end(), this way there is no leak in any process
4827 * wide migration performed by cgroup_attach_proc() that could otherwise
4828 * miss a thread because it is too early or too late in the fork stage.
4829 * 4821 *
4830 * At the point that cgroup_fork() is called, 'current' is the parent 4822 * At the point that cgroup_fork() is called, 'current' is the parent
4831 * task, and the passed argument 'child' points to the child task. 4823 * task, and the passed argument 'child' points to the child task.
4832 */ 4824 */
4833void cgroup_fork(struct task_struct *child) 4825void cgroup_fork(struct task_struct *child)
4834{ 4826{
4835 /* 4827 task_lock(current);
4836 * We don't need to task_lock() current because current->cgroups
4837 * can't be changed concurrently here. The parent obviously hasn't
4838 * exited and called cgroup_exit(), and we are synchronized against
4839 * cgroup migration through threadgroup_change_begin().
4840 */
4841 child->cgroups = current->cgroups; 4828 child->cgroups = current->cgroups;
4842 get_css_set(child->cgroups); 4829 get_css_set(child->cgroups);
4830 task_unlock(current);
4843 INIT_LIST_HEAD(&child->cg_list); 4831 INIT_LIST_HEAD(&child->cg_list);
4844} 4832}
4845 4833
@@ -4895,19 +4883,10 @@ void cgroup_post_fork(struct task_struct *child)
4895 */ 4883 */
4896 if (use_task_css_set_links) { 4884 if (use_task_css_set_links) {
4897 write_lock(&css_set_lock); 4885 write_lock(&css_set_lock);
4898 if (list_empty(&child->cg_list)) { 4886 task_lock(child);
4899 /* 4887 if (list_empty(&child->cg_list))
4900 * It's safe to use child->cgroups without task_lock()
4901 * here because we are protected through
4902 * threadgroup_change_begin() against concurrent
4903 * css_set change in cgroup_task_migrate(). Also
4904 * the task can't exit at that point until
4905 * wake_up_new_task() is called, so we are protected
4906 * against cgroup_exit() setting child->cgroup to
4907 * init_css_set.
4908 */
4909 list_add(&child->cg_list, &child->cgroups->tasks); 4888 list_add(&child->cg_list, &child->cgroups->tasks);
4910 } 4889 task_unlock(child);
4911 write_unlock(&css_set_lock); 4890 write_unlock(&css_set_lock);
4912 } 4891 }
4913} 4892}
diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index 98256bc71ee..5cc4e7e42e6 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -78,15 +78,23 @@ static struct mutex uprobes_mmap_mutex[UPROBES_HASH_SZ];
78 */ 78 */
79static atomic_t uprobe_events = ATOMIC_INIT(0); 79static atomic_t uprobe_events = ATOMIC_INIT(0);
80 80
81/* Have a copy of original instruction */
82#define UPROBE_COPY_INSN 0
83/* Dont run handlers when first register/ last unregister in progress*/
84#define UPROBE_RUN_HANDLER 1
85/* Can skip singlestep */
86#define UPROBE_SKIP_SSTEP 2
87
81struct uprobe { 88struct uprobe {
82 struct rb_node rb_node; /* node in the rb tree */ 89 struct rb_node rb_node; /* node in the rb tree */
83 atomic_t ref; 90 atomic_t ref;
84 struct rw_semaphore consumer_rwsem; 91 struct rw_semaphore consumer_rwsem;
92 struct mutex copy_mutex; /* TODO: kill me and UPROBE_COPY_INSN */
85 struct list_head pending_list; 93 struct list_head pending_list;
86 struct uprobe_consumer *consumers; 94 struct uprobe_consumer *consumers;
87 struct inode *inode; /* Also hold a ref to inode */ 95 struct inode *inode; /* Also hold a ref to inode */
88 loff_t offset; 96 loff_t offset;
89 int flags; 97 unsigned long flags;
90 struct arch_uprobe arch; 98 struct arch_uprobe arch;
91}; 99};
92 100
@@ -100,17 +108,12 @@ struct uprobe {
100 */ 108 */
101static bool valid_vma(struct vm_area_struct *vma, bool is_register) 109static bool valid_vma(struct vm_area_struct *vma, bool is_register)
102{ 110{
103 if (!vma->vm_file) 111 vm_flags_t flags = VM_HUGETLB | VM_MAYEXEC | VM_SHARED;
104 return false;
105
106 if (!is_register)
107 return true;
108 112
109 if ((vma->vm_flags & (VM_HUGETLB|VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)) 113 if (is_register)
110 == (VM_READ|VM_EXEC)) 114 flags |= VM_WRITE;
111 return true;
112 115
113 return false; 116 return vma->vm_file && (vma->vm_flags & flags) == VM_MAYEXEC;
114} 117}
115 118
116static unsigned long offset_to_vaddr(struct vm_area_struct *vma, loff_t offset) 119static unsigned long offset_to_vaddr(struct vm_area_struct *vma, loff_t offset)
@@ -193,19 +196,44 @@ bool __weak is_swbp_insn(uprobe_opcode_t *insn)
193 return *insn == UPROBE_SWBP_INSN; 196 return *insn == UPROBE_SWBP_INSN;
194} 197}
195 198
199static void copy_opcode(struct page *page, unsigned long vaddr, uprobe_opcode_t *opcode)
200{
201 void *kaddr = kmap_atomic(page);
202 memcpy(opcode, kaddr + (vaddr & ~PAGE_MASK), UPROBE_SWBP_INSN_SIZE);
203 kunmap_atomic(kaddr);
204}
205
206static int verify_opcode(struct page *page, unsigned long vaddr, uprobe_opcode_t *new_opcode)
207{
208 uprobe_opcode_t old_opcode;
209 bool is_swbp;
210
211 copy_opcode(page, vaddr, &old_opcode);
212 is_swbp = is_swbp_insn(&old_opcode);
213
214 if (is_swbp_insn(new_opcode)) {
215 if (is_swbp) /* register: already installed? */
216 return 0;
217 } else {
218 if (!is_swbp) /* unregister: was it changed by us? */
219 return 0;
220 }
221
222 return 1;
223}
224
196/* 225/*
197 * NOTE: 226 * NOTE:
198 * Expect the breakpoint instruction to be the smallest size instruction for 227 * Expect the breakpoint instruction to be the smallest size instruction for
199 * the architecture. If an arch has variable length instruction and the 228 * the architecture. If an arch has variable length instruction and the
200 * breakpoint instruction is not of the smallest length instruction 229 * breakpoint instruction is not of the smallest length instruction
201 * supported by that architecture then we need to modify read_opcode / 230 * supported by that architecture then we need to modify is_swbp_at_addr and
202 * write_opcode accordingly. This would never be a problem for archs that 231 * write_opcode accordingly. This would never be a problem for archs that
203 * have fixed length instructions. 232 * have fixed length instructions.
204 */ 233 */
205 234
206/* 235/*
207 * write_opcode - write the opcode at a given virtual address. 236 * write_opcode - write the opcode at a given virtual address.
208 * @auprobe: arch breakpointing information.
209 * @mm: the probed process address space. 237 * @mm: the probed process address space.
210 * @vaddr: the virtual address to store the opcode. 238 * @vaddr: the virtual address to store the opcode.
211 * @opcode: opcode to be written at @vaddr. 239 * @opcode: opcode to be written at @vaddr.
@@ -216,8 +244,8 @@ bool __weak is_swbp_insn(uprobe_opcode_t *insn)
216 * For mm @mm, write the opcode at @vaddr. 244 * For mm @mm, write the opcode at @vaddr.
217 * Return 0 (success) or a negative errno. 245 * Return 0 (success) or a negative errno.
218 */ 246 */
219static int write_opcode(struct arch_uprobe *auprobe, struct mm_struct *mm, 247static int write_opcode(struct mm_struct *mm, unsigned long vaddr,
220 unsigned long vaddr, uprobe_opcode_t opcode) 248 uprobe_opcode_t opcode)
221{ 249{
222 struct page *old_page, *new_page; 250 struct page *old_page, *new_page;
223 void *vaddr_old, *vaddr_new; 251 void *vaddr_old, *vaddr_new;
@@ -226,10 +254,14 @@ static int write_opcode(struct arch_uprobe *auprobe, struct mm_struct *mm,
226 254
227retry: 255retry:
228 /* Read the page with vaddr into memory */ 256 /* Read the page with vaddr into memory */
229 ret = get_user_pages(NULL, mm, vaddr, 1, 0, 0, &old_page, &vma); 257 ret = get_user_pages(NULL, mm, vaddr, 1, 0, 1, &old_page, &vma);
230 if (ret <= 0) 258 if (ret <= 0)
231 return ret; 259 return ret;
232 260
261 ret = verify_opcode(old_page, vaddr, &opcode);
262 if (ret <= 0)
263 goto put_old;
264
233 ret = -ENOMEM; 265 ret = -ENOMEM;
234 new_page = alloc_page_vma(GFP_HIGHUSER_MOVABLE, vma, vaddr); 266 new_page = alloc_page_vma(GFP_HIGHUSER_MOVABLE, vma, vaddr);
235 if (!new_page) 267 if (!new_page)
@@ -264,63 +296,6 @@ put_old:
264} 296}
265 297
266/** 298/**
267 * read_opcode - read the opcode at a given virtual address.
268 * @mm: the probed process address space.
269 * @vaddr: the virtual address to read the opcode.
270 * @opcode: location to store the read opcode.
271 *
272 * Called with mm->mmap_sem held (for read and with a reference to
273 * mm.
274 *
275 * For mm @mm, read the opcode at @vaddr and store it in @opcode.
276 * Return 0 (success) or a negative errno.
277 */
278static int read_opcode(struct mm_struct *mm, unsigned long vaddr, uprobe_opcode_t *opcode)
279{
280 struct page *page;
281 void *vaddr_new;
282 int ret;
283
284 ret = get_user_pages(NULL, mm, vaddr, 1, 0, 1, &page, NULL);
285 if (ret <= 0)
286 return ret;
287
288 vaddr_new = kmap_atomic(page);
289 vaddr &= ~PAGE_MASK;
290 memcpy(opcode, vaddr_new + vaddr, UPROBE_SWBP_INSN_SIZE);
291 kunmap_atomic(vaddr_new);
292
293 put_page(page);
294
295 return 0;
296}
297
298static int is_swbp_at_addr(struct mm_struct *mm, unsigned long vaddr)
299{
300 uprobe_opcode_t opcode;
301 int result;
302
303 if (current->mm == mm) {
304 pagefault_disable();
305 result = __copy_from_user_inatomic(&opcode, (void __user*)vaddr,
306 sizeof(opcode));
307 pagefault_enable();
308
309 if (likely(result == 0))
310 goto out;
311 }
312
313 result = read_opcode(mm, vaddr, &opcode);
314 if (result)
315 return result;
316out:
317 if (is_swbp_insn(&opcode))
318 return 1;
319
320 return 0;
321}
322
323/**
324 * set_swbp - store breakpoint at a given address. 299 * set_swbp - store breakpoint at a given address.
325 * @auprobe: arch specific probepoint information. 300 * @auprobe: arch specific probepoint information.
326 * @mm: the probed process address space. 301 * @mm: the probed process address space.
@@ -331,18 +306,7 @@ out:
331 */ 306 */
332int __weak set_swbp(struct arch_uprobe *auprobe, struct mm_struct *mm, unsigned long vaddr) 307int __weak set_swbp(struct arch_uprobe *auprobe, struct mm_struct *mm, unsigned long vaddr)
333{ 308{
334 int result; 309 return write_opcode(mm, vaddr, UPROBE_SWBP_INSN);
335 /*
336 * See the comment near uprobes_hash().
337 */
338 result = is_swbp_at_addr(mm, vaddr);
339 if (result == 1)
340 return 0;
341
342 if (result)
343 return result;
344
345 return write_opcode(auprobe, mm, vaddr, UPROBE_SWBP_INSN);
346} 310}
347 311
348/** 312/**
@@ -357,16 +321,7 @@ int __weak set_swbp(struct arch_uprobe *auprobe, struct mm_struct *mm, unsigned
357int __weak 321int __weak
358set_orig_insn(struct arch_uprobe *auprobe, struct mm_struct *mm, unsigned long vaddr) 322set_orig_insn(struct arch_uprobe *auprobe, struct mm_struct *mm, unsigned long vaddr)
359{ 323{
360 int result; 324 return write_opcode(mm, vaddr, *(uprobe_opcode_t *)auprobe->insn);
361
362 result = is_swbp_at_addr(mm, vaddr);
363 if (!result)
364 return -EINVAL;
365
366 if (result != 1)
367 return result;
368
369 return write_opcode(auprobe, mm, vaddr, *(uprobe_opcode_t *)auprobe->insn);
370} 325}
371 326
372static int match_uprobe(struct uprobe *l, struct uprobe *r) 327static int match_uprobe(struct uprobe *l, struct uprobe *r)
@@ -473,7 +428,7 @@ static struct uprobe *insert_uprobe(struct uprobe *uprobe)
473 spin_unlock(&uprobes_treelock); 428 spin_unlock(&uprobes_treelock);
474 429
475 /* For now assume that the instruction need not be single-stepped */ 430 /* For now assume that the instruction need not be single-stepped */
476 uprobe->flags |= UPROBE_SKIP_SSTEP; 431 __set_bit(UPROBE_SKIP_SSTEP, &uprobe->flags);
477 432
478 return u; 433 return u;
479} 434}
@@ -495,6 +450,7 @@ static struct uprobe *alloc_uprobe(struct inode *inode, loff_t offset)
495 uprobe->inode = igrab(inode); 450 uprobe->inode = igrab(inode);
496 uprobe->offset = offset; 451 uprobe->offset = offset;
497 init_rwsem(&uprobe->consumer_rwsem); 452 init_rwsem(&uprobe->consumer_rwsem);
453 mutex_init(&uprobe->copy_mutex);
498 454
499 /* add to uprobes_tree, sorted on inode:offset */ 455 /* add to uprobes_tree, sorted on inode:offset */
500 cur_uprobe = insert_uprobe(uprobe); 456 cur_uprobe = insert_uprobe(uprobe);
@@ -515,7 +471,7 @@ static void handler_chain(struct uprobe *uprobe, struct pt_regs *regs)
515{ 471{
516 struct uprobe_consumer *uc; 472 struct uprobe_consumer *uc;
517 473
518 if (!(uprobe->flags & UPROBE_RUN_HANDLER)) 474 if (!test_bit(UPROBE_RUN_HANDLER, &uprobe->flags))
519 return; 475 return;
520 476
521 down_read(&uprobe->consumer_rwsem); 477 down_read(&uprobe->consumer_rwsem);
@@ -621,29 +577,43 @@ static int copy_insn(struct uprobe *uprobe, struct file *filp)
621 return __copy_insn(mapping, filp, uprobe->arch.insn, bytes, uprobe->offset); 577 return __copy_insn(mapping, filp, uprobe->arch.insn, bytes, uprobe->offset);
622} 578}
623 579
624/* 580static int prepare_uprobe(struct uprobe *uprobe, struct file *file,
625 * How mm->uprobes_state.count gets updated 581 struct mm_struct *mm, unsigned long vaddr)
626 * uprobe_mmap() increments the count if 582{
627 * - it successfully adds a breakpoint. 583 int ret = 0;
628 * - it cannot add a breakpoint, but sees that there is a underlying 584
629 * breakpoint (via a is_swbp_at_addr()). 585 if (test_bit(UPROBE_COPY_INSN, &uprobe->flags))
630 * 586 return ret;
631 * uprobe_munmap() decrements the count if 587
632 * - it sees a underlying breakpoint, (via is_swbp_at_addr) 588 mutex_lock(&uprobe->copy_mutex);
633 * (Subsequent uprobe_unregister wouldnt find the breakpoint 589 if (test_bit(UPROBE_COPY_INSN, &uprobe->flags))
634 * unless a uprobe_mmap kicks in, since the old vma would be 590 goto out;
635 * dropped just after uprobe_munmap.) 591
636 * 592 ret = copy_insn(uprobe, file);
637 * uprobe_register increments the count if: 593 if (ret)
638 * - it successfully adds a breakpoint. 594 goto out;
639 * 595
640 * uprobe_unregister decrements the count if: 596 ret = -ENOTSUPP;
641 * - it sees a underlying breakpoint and removes successfully. 597 if (is_swbp_insn((uprobe_opcode_t *)uprobe->arch.insn))
642 * (via is_swbp_at_addr) 598 goto out;
643 * (Subsequent uprobe_munmap wouldnt find the breakpoint 599
644 * since there is no underlying breakpoint after the 600 ret = arch_uprobe_analyze_insn(&uprobe->arch, mm, vaddr);
645 * breakpoint removal.) 601 if (ret)
646 */ 602 goto out;
603
604 /* write_opcode() assumes we don't cross page boundary */
605 BUG_ON((uprobe->offset & ~PAGE_MASK) +
606 UPROBE_SWBP_INSN_SIZE > PAGE_SIZE);
607
608 smp_wmb(); /* pairs with rmb() in find_active_uprobe() */
609 set_bit(UPROBE_COPY_INSN, &uprobe->flags);
610
611 out:
612 mutex_unlock(&uprobe->copy_mutex);
613
614 return ret;
615}
616
647static int 617static int
648install_breakpoint(struct uprobe *uprobe, struct mm_struct *mm, 618install_breakpoint(struct uprobe *uprobe, struct mm_struct *mm,
649 struct vm_area_struct *vma, unsigned long vaddr) 619 struct vm_area_struct *vma, unsigned long vaddr)
@@ -661,24 +631,9 @@ install_breakpoint(struct uprobe *uprobe, struct mm_struct *mm,
661 if (!uprobe->consumers) 631 if (!uprobe->consumers)
662 return 0; 632 return 0;
663 633
664 if (!(uprobe->flags & UPROBE_COPY_INSN)) { 634 ret = prepare_uprobe(uprobe, vma->vm_file, mm, vaddr);
665 ret = copy_insn(uprobe, vma->vm_file); 635 if (ret)
666 if (ret) 636 return ret;
667 return ret;
668
669 if (is_swbp_insn((uprobe_opcode_t *)uprobe->arch.insn))
670 return -ENOTSUPP;
671
672 ret = arch_uprobe_analyze_insn(&uprobe->arch, mm, vaddr);
673 if (ret)
674 return ret;
675
676 /* write_opcode() assumes we don't cross page boundary */
677 BUG_ON((uprobe->offset & ~PAGE_MASK) +
678 UPROBE_SWBP_INSN_SIZE > PAGE_SIZE);
679
680 uprobe->flags |= UPROBE_COPY_INSN;
681 }
682 637
683 /* 638 /*
684 * set MMF_HAS_UPROBES in advance for uprobe_pre_sstep_notifier(), 639 * set MMF_HAS_UPROBES in advance for uprobe_pre_sstep_notifier(),
@@ -697,15 +652,15 @@ install_breakpoint(struct uprobe *uprobe, struct mm_struct *mm,
697 return ret; 652 return ret;
698} 653}
699 654
700static void 655static int
701remove_breakpoint(struct uprobe *uprobe, struct mm_struct *mm, unsigned long vaddr) 656remove_breakpoint(struct uprobe *uprobe, struct mm_struct *mm, unsigned long vaddr)
702{ 657{
703 /* can happen if uprobe_register() fails */ 658 /* can happen if uprobe_register() fails */
704 if (!test_bit(MMF_HAS_UPROBES, &mm->flags)) 659 if (!test_bit(MMF_HAS_UPROBES, &mm->flags))
705 return; 660 return 0;
706 661
707 set_bit(MMF_RECALC_UPROBES, &mm->flags); 662 set_bit(MMF_RECALC_UPROBES, &mm->flags);
708 set_orig_insn(&uprobe->arch, mm, vaddr); 663 return set_orig_insn(&uprobe->arch, mm, vaddr);
709} 664}
710 665
711/* 666/*
@@ -820,7 +775,7 @@ static int register_for_each_vma(struct uprobe *uprobe, bool is_register)
820 struct mm_struct *mm = info->mm; 775 struct mm_struct *mm = info->mm;
821 struct vm_area_struct *vma; 776 struct vm_area_struct *vma;
822 777
823 if (err) 778 if (err && is_register)
824 goto free; 779 goto free;
825 780
826 down_write(&mm->mmap_sem); 781 down_write(&mm->mmap_sem);
@@ -836,7 +791,7 @@ static int register_for_each_vma(struct uprobe *uprobe, bool is_register)
836 if (is_register) 791 if (is_register)
837 err = install_breakpoint(uprobe, mm, vma, info->vaddr); 792 err = install_breakpoint(uprobe, mm, vma, info->vaddr);
838 else 793 else
839 remove_breakpoint(uprobe, mm, info->vaddr); 794 err |= remove_breakpoint(uprobe, mm, info->vaddr);
840 795
841 unlock: 796 unlock:
842 up_write(&mm->mmap_sem); 797 up_write(&mm->mmap_sem);
@@ -893,13 +848,15 @@ int uprobe_register(struct inode *inode, loff_t offset, struct uprobe_consumer *
893 mutex_lock(uprobes_hash(inode)); 848 mutex_lock(uprobes_hash(inode));
894 uprobe = alloc_uprobe(inode, offset); 849 uprobe = alloc_uprobe(inode, offset);
895 850
896 if (uprobe && !consumer_add(uprobe, uc)) { 851 if (!uprobe) {
852 ret = -ENOMEM;
853 } else if (!consumer_add(uprobe, uc)) {
897 ret = __uprobe_register(uprobe); 854 ret = __uprobe_register(uprobe);
898 if (ret) { 855 if (ret) {
899 uprobe->consumers = NULL; 856 uprobe->consumers = NULL;
900 __uprobe_unregister(uprobe); 857 __uprobe_unregister(uprobe);
901 } else { 858 } else {
902 uprobe->flags |= UPROBE_RUN_HANDLER; 859 set_bit(UPROBE_RUN_HANDLER, &uprobe->flags);
903 } 860 }
904 } 861 }
905 862
@@ -932,7 +889,7 @@ void uprobe_unregister(struct inode *inode, loff_t offset, struct uprobe_consume
932 if (consumer_del(uprobe, uc)) { 889 if (consumer_del(uprobe, uc)) {
933 if (!uprobe->consumers) { 890 if (!uprobe->consumers) {
934 __uprobe_unregister(uprobe); 891 __uprobe_unregister(uprobe);
935 uprobe->flags &= ~UPROBE_RUN_HANDLER; 892 clear_bit(UPROBE_RUN_HANDLER, &uprobe->flags);
936 } 893 }
937 } 894 }
938 895
@@ -1393,10 +1350,11 @@ bool uprobe_deny_signal(void)
1393 */ 1350 */
1394static bool can_skip_sstep(struct uprobe *uprobe, struct pt_regs *regs) 1351static bool can_skip_sstep(struct uprobe *uprobe, struct pt_regs *regs)
1395{ 1352{
1396 if (arch_uprobe_skip_sstep(&uprobe->arch, regs)) 1353 if (test_bit(UPROBE_SKIP_SSTEP, &uprobe->flags)) {
1397 return true; 1354 if (arch_uprobe_skip_sstep(&uprobe->arch, regs))
1398 1355 return true;
1399 uprobe->flags &= ~UPROBE_SKIP_SSTEP; 1356 clear_bit(UPROBE_SKIP_SSTEP, &uprobe->flags);
1357 }
1400 return false; 1358 return false;
1401} 1359}
1402 1360
@@ -1419,6 +1377,30 @@ static void mmf_recalc_uprobes(struct mm_struct *mm)
1419 clear_bit(MMF_HAS_UPROBES, &mm->flags); 1377 clear_bit(MMF_HAS_UPROBES, &mm->flags);
1420} 1378}
1421 1379
1380static int is_swbp_at_addr(struct mm_struct *mm, unsigned long vaddr)
1381{
1382 struct page *page;
1383 uprobe_opcode_t opcode;
1384 int result;
1385
1386 pagefault_disable();
1387 result = __copy_from_user_inatomic(&opcode, (void __user*)vaddr,
1388 sizeof(opcode));
1389 pagefault_enable();
1390
1391 if (likely(result == 0))
1392 goto out;
1393
1394 result = get_user_pages(NULL, mm, vaddr, 1, 0, 1, &page, NULL);
1395 if (result < 0)
1396 return result;
1397
1398 copy_opcode(page, vaddr, &opcode);
1399 put_page(page);
1400 out:
1401 return is_swbp_insn(&opcode);
1402}
1403
1422static struct uprobe *find_active_uprobe(unsigned long bp_vaddr, int *is_swbp) 1404static struct uprobe *find_active_uprobe(unsigned long bp_vaddr, int *is_swbp)
1423{ 1405{
1424 struct mm_struct *mm = current->mm; 1406 struct mm_struct *mm = current->mm;
@@ -1489,38 +1471,41 @@ static void handle_swbp(struct pt_regs *regs)
1489 } 1471 }
1490 return; 1472 return;
1491 } 1473 }
1474 /*
1475 * TODO: move copy_insn/etc into _register and remove this hack.
1476 * After we hit the bp, _unregister + _register can install the
1477 * new and not-yet-analyzed uprobe at the same address, restart.
1478 */
1479 smp_rmb(); /* pairs with wmb() in install_breakpoint() */
1480 if (unlikely(!test_bit(UPROBE_COPY_INSN, &uprobe->flags)))
1481 goto restart;
1492 1482
1493 utask = current->utask; 1483 utask = current->utask;
1494 if (!utask) { 1484 if (!utask) {
1495 utask = add_utask(); 1485 utask = add_utask();
1496 /* Cannot allocate; re-execute the instruction. */ 1486 /* Cannot allocate; re-execute the instruction. */
1497 if (!utask) 1487 if (!utask)
1498 goto cleanup_ret; 1488 goto restart;
1499 } 1489 }
1500 utask->active_uprobe = uprobe; 1490
1501 handler_chain(uprobe, regs); 1491 handler_chain(uprobe, regs);
1502 if (uprobe->flags & UPROBE_SKIP_SSTEP && can_skip_sstep(uprobe, regs)) 1492 if (can_skip_sstep(uprobe, regs))
1503 goto cleanup_ret; 1493 goto out;
1504 1494
1505 utask->state = UTASK_SSTEP;
1506 if (!pre_ssout(uprobe, regs, bp_vaddr)) { 1495 if (!pre_ssout(uprobe, regs, bp_vaddr)) {
1507 arch_uprobe_enable_step(&uprobe->arch); 1496 arch_uprobe_enable_step(&uprobe->arch);
1497 utask->active_uprobe = uprobe;
1498 utask->state = UTASK_SSTEP;
1508 return; 1499 return;
1509 } 1500 }
1510 1501
1511cleanup_ret: 1502restart:
1512 if (utask) { 1503 /*
1513 utask->active_uprobe = NULL; 1504 * cannot singlestep; cannot skip instruction;
1514 utask->state = UTASK_RUNNING; 1505 * re-execute the instruction.
1515 } 1506 */
1516 if (!(uprobe->flags & UPROBE_SKIP_SSTEP)) 1507 instruction_pointer_set(regs, bp_vaddr);
1517 1508out:
1518 /*
1519 * cannot singlestep; cannot skip instruction;
1520 * re-execute the instruction.
1521 */
1522 instruction_pointer_set(regs, bp_vaddr);
1523
1524 put_uprobe(uprobe); 1509 put_uprobe(uprobe);
1525} 1510}
1526 1511
@@ -1552,13 +1537,12 @@ static void handle_singlestep(struct uprobe_task *utask, struct pt_regs *regs)
1552} 1537}
1553 1538
1554/* 1539/*
1555 * On breakpoint hit, breakpoint notifier sets the TIF_UPROBE flag. (and on 1540 * On breakpoint hit, breakpoint notifier sets the TIF_UPROBE flag and
1556 * subsequent probe hits on the thread sets the state to UTASK_BP_HIT) and 1541 * allows the thread to return from interrupt. After that handle_swbp()
1557 * allows the thread to return from interrupt. 1542 * sets utask->active_uprobe.
1558 * 1543 *
1559 * On singlestep exception, singlestep notifier sets the TIF_UPROBE flag and 1544 * On singlestep exception, singlestep notifier sets the TIF_UPROBE flag
1560 * also sets the state to UTASK_SSTEP_ACK and allows the thread to return from 1545 * and allows the thread to return from interrupt.
1561 * interrupt.
1562 * 1546 *
1563 * While returning to userspace, thread notices the TIF_UPROBE flag and calls 1547 * While returning to userspace, thread notices the TIF_UPROBE flag and calls
1564 * uprobe_notify_resume(). 1548 * uprobe_notify_resume().
@@ -1567,11 +1551,13 @@ void uprobe_notify_resume(struct pt_regs *regs)
1567{ 1551{
1568 struct uprobe_task *utask; 1552 struct uprobe_task *utask;
1569 1553
1554 clear_thread_flag(TIF_UPROBE);
1555
1570 utask = current->utask; 1556 utask = current->utask;
1571 if (!utask || utask->state == UTASK_BP_HIT) 1557 if (utask && utask->active_uprobe)
1572 handle_swbp(regs);
1573 else
1574 handle_singlestep(utask, regs); 1558 handle_singlestep(utask, regs);
1559 else
1560 handle_swbp(regs);
1575} 1561}
1576 1562
1577/* 1563/*
@@ -1580,17 +1566,10 @@ void uprobe_notify_resume(struct pt_regs *regs)
1580 */ 1566 */
1581int uprobe_pre_sstep_notifier(struct pt_regs *regs) 1567int uprobe_pre_sstep_notifier(struct pt_regs *regs)
1582{ 1568{
1583 struct uprobe_task *utask;
1584
1585 if (!current->mm || !test_bit(MMF_HAS_UPROBES, &current->mm->flags)) 1569 if (!current->mm || !test_bit(MMF_HAS_UPROBES, &current->mm->flags))
1586 return 0; 1570 return 0;
1587 1571
1588 utask = current->utask;
1589 if (utask)
1590 utask->state = UTASK_BP_HIT;
1591
1592 set_thread_flag(TIF_UPROBE); 1572 set_thread_flag(TIF_UPROBE);
1593
1594 return 1; 1573 return 1;
1595} 1574}
1596 1575
diff --git a/kernel/exit.c b/kernel/exit.c
index 346616c0092..f9275e2c7c2 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -322,43 +322,6 @@ kill_orphaned_pgrp(struct task_struct *tsk, struct task_struct *parent)
322 } 322 }
323} 323}
324 324
325/**
326 * reparent_to_kthreadd - Reparent the calling kernel thread to kthreadd
327 *
328 * If a kernel thread is launched as a result of a system call, or if
329 * it ever exits, it should generally reparent itself to kthreadd so it
330 * isn't in the way of other processes and is correctly cleaned up on exit.
331 *
332 * The various task state such as scheduling policy and priority may have
333 * been inherited from a user process, so we reset them to sane values here.
334 *
335 * NOTE that reparent_to_kthreadd() gives the caller full capabilities.
336 */
337static void reparent_to_kthreadd(void)
338{
339 write_lock_irq(&tasklist_lock);
340
341 ptrace_unlink(current);
342 /* Reparent to init */
343 current->real_parent = current->parent = kthreadd_task;
344 list_move_tail(&current->sibling, &current->real_parent->children);
345
346 /* Set the exit signal to SIGCHLD so we signal init on exit */
347 current->exit_signal = SIGCHLD;
348
349 if (task_nice(current) < 0)
350 set_user_nice(current, 0);
351 /* cpus_allowed? */
352 /* rt_priority? */
353 /* signals? */
354 memcpy(current->signal->rlim, init_task.signal->rlim,
355 sizeof(current->signal->rlim));
356
357 atomic_inc(&init_cred.usage);
358 commit_creds(&init_cred);
359 write_unlock_irq(&tasklist_lock);
360}
361
362void __set_special_pids(struct pid *pid) 325void __set_special_pids(struct pid *pid)
363{ 326{
364 struct task_struct *curr = current->group_leader; 327 struct task_struct *curr = current->group_leader;
@@ -370,13 +333,6 @@ void __set_special_pids(struct pid *pid)
370 change_pid(curr, PIDTYPE_PGID, pid); 333 change_pid(curr, PIDTYPE_PGID, pid);
371} 334}
372 335
373static void set_special_pids(struct pid *pid)
374{
375 write_lock_irq(&tasklist_lock);
376 __set_special_pids(pid);
377 write_unlock_irq(&tasklist_lock);
378}
379
380/* 336/*
381 * Let kernel threads use this to say that they allow a certain signal. 337 * Let kernel threads use this to say that they allow a certain signal.
382 * Must not be used if kthread was cloned with CLONE_SIGHAND. 338 * Must not be used if kthread was cloned with CLONE_SIGHAND.
@@ -416,54 +372,6 @@ int disallow_signal(int sig)
416 372
417EXPORT_SYMBOL(disallow_signal); 373EXPORT_SYMBOL(disallow_signal);
418 374
419/*
420 * Put all the gunge required to become a kernel thread without
421 * attached user resources in one place where it belongs.
422 */
423
424void daemonize(const char *name, ...)
425{
426 va_list args;
427 sigset_t blocked;
428
429 va_start(args, name);
430 vsnprintf(current->comm, sizeof(current->comm), name, args);
431 va_end(args);
432
433 /*
434 * If we were started as result of loading a module, close all of the
435 * user space pages. We don't need them, and if we didn't close them
436 * they would be locked into memory.
437 */
438 exit_mm(current);
439 /*
440 * We don't want to get frozen, in case system-wide hibernation
441 * or suspend transition begins right now.
442 */
443 current->flags |= (PF_NOFREEZE | PF_KTHREAD);
444
445 if (current->nsproxy != &init_nsproxy) {
446 get_nsproxy(&init_nsproxy);
447 switch_task_namespaces(current, &init_nsproxy);
448 }
449 set_special_pids(&init_struct_pid);
450 proc_clear_tty(current);
451
452 /* Block and flush all signals */
453 sigfillset(&blocked);
454 sigprocmask(SIG_BLOCK, &blocked, NULL);
455 flush_signals(current);
456
457 /* Become as one with the init task */
458
459 daemonize_fs_struct();
460 daemonize_descriptors();
461
462 reparent_to_kthreadd();
463}
464
465EXPORT_SYMBOL(daemonize);
466
467#ifdef CONFIG_MM_OWNER 375#ifdef CONFIG_MM_OWNER
468/* 376/*
469 * A task is exiting. If it owned this mm, find a new owner for the mm. 377 * A task is exiting. If it owned this mm, find a new owner for the mm.
diff --git a/kernel/fork.c b/kernel/fork.c
index 8b20ab7d3aa..27a337549da 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1645,6 +1645,49 @@ pid_t kernel_thread(int (*fn)(void *), void *arg, unsigned long flags)
1645} 1645}
1646#endif 1646#endif
1647 1647
1648#ifdef __ARCH_WANT_SYS_FORK
1649SYSCALL_DEFINE0(fork)
1650{
1651#ifdef CONFIG_MMU
1652 return do_fork(SIGCHLD, 0, current_pt_regs(), 0, NULL, NULL);
1653#else
1654 /* can not support in nommu mode */
1655 return(-EINVAL);
1656#endif
1657}
1658#endif
1659
1660#ifdef __ARCH_WANT_SYS_VFORK
1661SYSCALL_DEFINE0(vfork)
1662{
1663 return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD, 0, current_pt_regs(),
1664 0, NULL, NULL);
1665}
1666#endif
1667
1668#ifdef __ARCH_WANT_SYS_CLONE
1669#ifdef CONFIG_CLONE_BACKWARDS
1670SYSCALL_DEFINE5(clone, unsigned long, clone_flags, unsigned long, newsp,
1671 int __user *, parent_tidptr,
1672 int, tls_val,
1673 int __user *, child_tidptr)
1674#elif defined(CONFIG_CLONE_BACKWARDS2)
1675SYSCALL_DEFINE5(clone, unsigned long, newsp, unsigned long, clone_flags,
1676 int __user *, parent_tidptr,
1677 int __user *, child_tidptr,
1678 int, tls_val)
1679#else
1680SYSCALL_DEFINE5(clone, unsigned long, clone_flags, unsigned long, newsp,
1681 int __user *, parent_tidptr,
1682 int __user *, child_tidptr,
1683 int, tls_val)
1684#endif
1685{
1686 return do_fork(clone_flags, newsp, current_pt_regs(), 0,
1687 parent_tidptr, child_tidptr);
1688}
1689#endif
1690
1648#ifndef ARCH_MIN_MMSTRUCT_ALIGN 1691#ifndef ARCH_MIN_MMSTRUCT_ALIGN
1649#define ARCH_MIN_MMSTRUCT_ALIGN 0 1692#define ARCH_MIN_MMSTRUCT_ALIGN 0
1650#endif 1693#endif
diff --git a/kernel/futex.c b/kernel/futex.c
index 3717e7b306e..20ef219bbe9 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -716,7 +716,7 @@ static int futex_lock_pi_atomic(u32 __user *uaddr, struct futex_hash_bucket *hb,
716 struct futex_pi_state **ps, 716 struct futex_pi_state **ps,
717 struct task_struct *task, int set_waiters) 717 struct task_struct *task, int set_waiters)
718{ 718{
719 int lock_taken, ret, ownerdied = 0; 719 int lock_taken, ret, force_take = 0;
720 u32 uval, newval, curval, vpid = task_pid_vnr(task); 720 u32 uval, newval, curval, vpid = task_pid_vnr(task);
721 721
722retry: 722retry:
@@ -755,17 +755,15 @@ retry:
755 newval = curval | FUTEX_WAITERS; 755 newval = curval | FUTEX_WAITERS;
756 756
757 /* 757 /*
758 * There are two cases, where a futex might have no owner (the 758 * Should we force take the futex? See below.
759 * owner TID is 0): OWNER_DIED. We take over the futex in this
760 * case. We also do an unconditional take over, when the owner
761 * of the futex died.
762 *
763 * This is safe as we are protected by the hash bucket lock !
764 */ 759 */
765 if (unlikely(ownerdied || !(curval & FUTEX_TID_MASK))) { 760 if (unlikely(force_take)) {
766 /* Keep the OWNER_DIED bit */ 761 /*
762 * Keep the OWNER_DIED and the WAITERS bit and set the
763 * new TID value.
764 */
767 newval = (curval & ~FUTEX_TID_MASK) | vpid; 765 newval = (curval & ~FUTEX_TID_MASK) | vpid;
768 ownerdied = 0; 766 force_take = 0;
769 lock_taken = 1; 767 lock_taken = 1;
770 } 768 }
771 769
@@ -775,7 +773,7 @@ retry:
775 goto retry; 773 goto retry;
776 774
777 /* 775 /*
778 * We took the lock due to owner died take over. 776 * We took the lock due to forced take over.
779 */ 777 */
780 if (unlikely(lock_taken)) 778 if (unlikely(lock_taken))
781 return 1; 779 return 1;
@@ -790,20 +788,25 @@ retry:
790 switch (ret) { 788 switch (ret) {
791 case -ESRCH: 789 case -ESRCH:
792 /* 790 /*
793 * No owner found for this futex. Check if the 791 * We failed to find an owner for this
794 * OWNER_DIED bit is set to figure out whether 792 * futex. So we have no pi_state to block
795 * this is a robust futex or not. 793 * on. This can happen in two cases:
794 *
795 * 1) The owner died
796 * 2) A stale FUTEX_WAITERS bit
797 *
798 * Re-read the futex value.
796 */ 799 */
797 if (get_futex_value_locked(&curval, uaddr)) 800 if (get_futex_value_locked(&curval, uaddr))
798 return -EFAULT; 801 return -EFAULT;
799 802
800 /* 803 /*
801 * We simply start over in case of a robust 804 * If the owner died or we have a stale
802 * futex. The code above will take the futex 805 * WAITERS bit the owner TID in the user space
803 * and return happy. 806 * futex is 0.
804 */ 807 */
805 if (curval & FUTEX_OWNER_DIED) { 808 if (!(curval & FUTEX_TID_MASK)) {
806 ownerdied = 1; 809 force_take = 1;
807 goto retry; 810 goto retry;
808 } 811 }
809 default: 812 default:
diff --git a/kernel/module-internal.h b/kernel/module-internal.h
index 6114a13419b..24f9247b7d0 100644
--- a/kernel/module-internal.h
+++ b/kernel/module-internal.h
@@ -11,5 +11,4 @@
11 11
12extern struct key *modsign_keyring; 12extern struct key *modsign_keyring;
13 13
14extern int mod_verify_sig(const void *mod, unsigned long modlen, 14extern int mod_verify_sig(const void *mod, unsigned long *_modlen);
15 const void *sig, unsigned long siglen);
diff --git a/kernel/module.c b/kernel/module.c
index 0e2da8695f8..6e48c3a4359 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2293,12 +2293,17 @@ static void layout_symtab(struct module *mod, struct load_info *info)
2293 src = (void *)info->hdr + symsect->sh_offset; 2293 src = (void *)info->hdr + symsect->sh_offset;
2294 nsrc = symsect->sh_size / sizeof(*src); 2294 nsrc = symsect->sh_size / sizeof(*src);
2295 2295
2296 /* strtab always starts with a nul, so offset 0 is the empty string. */
2297 strtab_size = 1;
2298
2296 /* Compute total space required for the core symbols' strtab. */ 2299 /* Compute total space required for the core symbols' strtab. */
2297 for (ndst = i = strtab_size = 1; i < nsrc; ++i, ++src) 2300 for (ndst = i = 0; i < nsrc; i++) {
2298 if (is_core_symbol(src, info->sechdrs, info->hdr->e_shnum)) { 2301 if (i == 0 ||
2299 strtab_size += strlen(&info->strtab[src->st_name]) + 1; 2302 is_core_symbol(src+i, info->sechdrs, info->hdr->e_shnum)) {
2303 strtab_size += strlen(&info->strtab[src[i].st_name])+1;
2300 ndst++; 2304 ndst++;
2301 } 2305 }
2306 }
2302 2307
2303 /* Append room for core symbols at end of core part. */ 2308 /* Append room for core symbols at end of core part. */
2304 info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1); 2309 info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
@@ -2332,15 +2337,15 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
2332 mod->core_symtab = dst = mod->module_core + info->symoffs; 2337 mod->core_symtab = dst = mod->module_core + info->symoffs;
2333 mod->core_strtab = s = mod->module_core + info->stroffs; 2338 mod->core_strtab = s = mod->module_core + info->stroffs;
2334 src = mod->symtab; 2339 src = mod->symtab;
2335 *dst = *src;
2336 *s++ = 0; 2340 *s++ = 0;
2337 for (ndst = i = 1; i < mod->num_symtab; ++i, ++src) { 2341 for (ndst = i = 0; i < mod->num_symtab; i++) {
2338 if (!is_core_symbol(src, info->sechdrs, info->hdr->e_shnum)) 2342 if (i == 0 ||
2339 continue; 2343 is_core_symbol(src+i, info->sechdrs, info->hdr->e_shnum)) {
2340 2344 dst[ndst] = src[i];
2341 dst[ndst] = *src; 2345 dst[ndst++].st_name = s - mod->core_strtab;
2342 dst[ndst++].st_name = s - mod->core_strtab; 2346 s += strlcpy(s, &mod->strtab[src[i].st_name],
2343 s += strlcpy(s, &mod->strtab[src->st_name], KSYM_NAME_LEN) + 1; 2347 KSYM_NAME_LEN) + 1;
2348 }
2344 } 2349 }
2345 mod->core_num_syms = ndst; 2350 mod->core_num_syms = ndst;
2346} 2351}
@@ -2421,25 +2426,17 @@ static inline void kmemleak_load_module(const struct module *mod,
2421 2426
2422#ifdef CONFIG_MODULE_SIG 2427#ifdef CONFIG_MODULE_SIG
2423static int module_sig_check(struct load_info *info, 2428static int module_sig_check(struct load_info *info,
2424 const void *mod, unsigned long *len) 2429 const void *mod, unsigned long *_len)
2425{ 2430{
2426 int err = -ENOKEY; 2431 int err = -ENOKEY;
2427 const unsigned long markerlen = sizeof(MODULE_SIG_STRING) - 1; 2432 unsigned long markerlen = sizeof(MODULE_SIG_STRING) - 1;
2428 const void *p = mod, *end = mod + *len; 2433 unsigned long len = *_len;
2429 2434
2430 /* Poor man's memmem. */ 2435 if (len > markerlen &&
2431 while ((p = memchr(p, MODULE_SIG_STRING[0], end - p))) { 2436 memcmp(mod + len - markerlen, MODULE_SIG_STRING, markerlen) == 0) {
2432 if (p + markerlen > end) 2437 /* We truncate the module to discard the signature */
2433 break; 2438 *_len -= markerlen;
2434 2439 err = mod_verify_sig(mod, _len);
2435 if (memcmp(p, MODULE_SIG_STRING, markerlen) == 0) {
2436 const void *sig = p + markerlen;
2437 /* Truncate module up to signature. */
2438 *len = p - mod;
2439 err = mod_verify_sig(mod, *len, sig, end - sig);
2440 break;
2441 }
2442 p++;
2443 } 2440 }
2444 2441
2445 if (!err) { 2442 if (!err) {
diff --git a/kernel/module_signing.c b/kernel/module_signing.c
index 6b09f6983ac..ea1b1df5dbb 100644
--- a/kernel/module_signing.c
+++ b/kernel/module_signing.c
@@ -183,27 +183,33 @@ static struct key *request_asymmetric_key(const char *signer, size_t signer_len,
183/* 183/*
184 * Verify the signature on a module. 184 * Verify the signature on a module.
185 */ 185 */
186int mod_verify_sig(const void *mod, unsigned long modlen, 186int mod_verify_sig(const void *mod, unsigned long *_modlen)
187 const void *sig, unsigned long siglen)
188{ 187{
189 struct public_key_signature *pks; 188 struct public_key_signature *pks;
190 struct module_signature ms; 189 struct module_signature ms;
191 struct key *key; 190 struct key *key;
192 size_t sig_len; 191 const void *sig;
192 size_t modlen = *_modlen, sig_len;
193 int ret; 193 int ret;
194 194
195 pr_devel("==>%s(,%lu,,%lu,)\n", __func__, modlen, siglen); 195 pr_devel("==>%s(,%zu)\n", __func__, modlen);
196 196
197 if (siglen <= sizeof(ms)) 197 if (modlen <= sizeof(ms))
198 return -EBADMSG; 198 return -EBADMSG;
199 199
200 memcpy(&ms, sig + (siglen - sizeof(ms)), sizeof(ms)); 200 memcpy(&ms, mod + (modlen - sizeof(ms)), sizeof(ms));
201 siglen -= sizeof(ms); 201 modlen -= sizeof(ms);
202 202
203 sig_len = be32_to_cpu(ms.sig_len); 203 sig_len = be32_to_cpu(ms.sig_len);
204 if (sig_len >= siglen || 204 if (sig_len >= modlen)
205 siglen - sig_len != (size_t)ms.signer_len + ms.key_id_len)
206 return -EBADMSG; 205 return -EBADMSG;
206 modlen -= sig_len;
207 if ((size_t)ms.signer_len + ms.key_id_len >= modlen)
208 return -EBADMSG;
209 modlen -= (size_t)ms.signer_len + ms.key_id_len;
210
211 *_modlen = modlen;
212 sig = mod + modlen;
207 213
208 /* For the moment, only support RSA and X.509 identifiers */ 214 /* For the moment, only support RSA and X.509 identifiers */
209 if (ms.algo != PKEY_ALGO_RSA || 215 if (ms.algo != PKEY_ALGO_RSA ||
diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
index 478bad2745e..7b07cc0dfb7 100644
--- a/kernel/pid_namespace.c
+++ b/kernel/pid_namespace.c
@@ -71,12 +71,22 @@ err_alloc:
71 return NULL; 71 return NULL;
72} 72}
73 73
74/* MAX_PID_NS_LEVEL is needed for limiting size of 'struct pid' */
75#define MAX_PID_NS_LEVEL 32
76
74static struct pid_namespace *create_pid_namespace(struct pid_namespace *parent_pid_ns) 77static struct pid_namespace *create_pid_namespace(struct pid_namespace *parent_pid_ns)
75{ 78{
76 struct pid_namespace *ns; 79 struct pid_namespace *ns;
77 unsigned int level = parent_pid_ns->level + 1; 80 unsigned int level = parent_pid_ns->level + 1;
78 int i, err = -ENOMEM; 81 int i;
82 int err;
83
84 if (level > MAX_PID_NS_LEVEL) {
85 err = -EINVAL;
86 goto out;
87 }
79 88
89 err = -ENOMEM;
80 ns = kmem_cache_zalloc(pid_ns_cachep, GFP_KERNEL); 90 ns = kmem_cache_zalloc(pid_ns_cachep, GFP_KERNEL);
81 if (ns == NULL) 91 if (ns == NULL)
82 goto out; 92 goto out;
@@ -133,19 +143,26 @@ struct pid_namespace *copy_pid_ns(unsigned long flags, struct pid_namespace *old
133 return create_pid_namespace(old_ns); 143 return create_pid_namespace(old_ns);
134} 144}
135 145
136void free_pid_ns(struct kref *kref) 146static void free_pid_ns(struct kref *kref)
137{ 147{
138 struct pid_namespace *ns, *parent; 148 struct pid_namespace *ns;
139 149
140 ns = container_of(kref, struct pid_namespace, kref); 150 ns = container_of(kref, struct pid_namespace, kref);
141
142 parent = ns->parent;
143 destroy_pid_namespace(ns); 151 destroy_pid_namespace(ns);
152}
153
154void put_pid_ns(struct pid_namespace *ns)
155{
156 struct pid_namespace *parent;
144 157
145 if (parent != NULL) 158 while (ns != &init_pid_ns) {
146 put_pid_ns(parent); 159 parent = ns->parent;
160 if (!kref_put(&ns->kref, free_pid_ns))
161 break;
162 ns = parent;
163 }
147} 164}
148EXPORT_SYMBOL_GPL(free_pid_ns); 165EXPORT_SYMBOL_GPL(put_pid_ns);
149 166
150void zap_pid_ns_processes(struct pid_namespace *pid_ns) 167void zap_pid_ns_processes(struct pid_namespace *pid_ns)
151{ 168{
diff --git a/kernel/printk.c b/kernel/printk.c
index 66a2ea37b57..2d607f4d179 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -1890,7 +1890,6 @@ static int __cpuinit console_cpu_notify(struct notifier_block *self,
1890 switch (action) { 1890 switch (action) {
1891 case CPU_ONLINE: 1891 case CPU_ONLINE:
1892 case CPU_DEAD: 1892 case CPU_DEAD:
1893 case CPU_DYING:
1894 case CPU_DOWN_FAILED: 1893 case CPU_DOWN_FAILED:
1895 case CPU_UP_CANCELED: 1894 case CPU_UP_CANCELED:
1896 console_lock(); 1895 console_lock();
diff --git a/kernel/sys.c b/kernel/sys.c
index c5cb5b99cb8..e6e0ece5f6a 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -1265,15 +1265,16 @@ DECLARE_RWSEM(uts_sem);
1265 * Work around broken programs that cannot handle "Linux 3.0". 1265 * Work around broken programs that cannot handle "Linux 3.0".
1266 * Instead we map 3.x to 2.6.40+x, so e.g. 3.0 would be 2.6.40 1266 * Instead we map 3.x to 2.6.40+x, so e.g. 3.0 would be 2.6.40
1267 */ 1267 */
1268static int override_release(char __user *release, int len) 1268static int override_release(char __user *release, size_t len)
1269{ 1269{
1270 int ret = 0; 1270 int ret = 0;
1271 char buf[65];
1272 1271
1273 if (current->personality & UNAME26) { 1272 if (current->personality & UNAME26) {
1274 char *rest = UTS_RELEASE; 1273 const char *rest = UTS_RELEASE;
1274 char buf[65] = { 0 };
1275 int ndots = 0; 1275 int ndots = 0;
1276 unsigned v; 1276 unsigned v;
1277 size_t copy;
1277 1278
1278 while (*rest) { 1279 while (*rest) {
1279 if (*rest == '.' && ++ndots >= 3) 1280 if (*rest == '.' && ++ndots >= 3)
@@ -1283,8 +1284,9 @@ static int override_release(char __user *release, int len)
1283 rest++; 1284 rest++;
1284 } 1285 }
1285 v = ((LINUX_VERSION_CODE >> 8) & 0xff) + 40; 1286 v = ((LINUX_VERSION_CODE >> 8) & 0xff) + 40;
1286 snprintf(buf, len, "2.6.%u%s", v, rest); 1287 copy = clamp_t(size_t, len, 1, sizeof(buf));
1287 ret = copy_to_user(release, buf, len); 1288 copy = scnprintf(buf, copy, "2.6.%u%s", v, rest);
1289 ret = copy_to_user(release, buf, copy + 1);
1288 } 1290 }
1289 return ret; 1291 return ret;
1290} 1292}
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index b32ed0e385a..b979426d16c 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -1567,6 +1567,10 @@ int ring_buffer_resize(struct ring_buffer *buffer, unsigned long size,
1567 1567
1568 put_online_cpus(); 1568 put_online_cpus();
1569 } else { 1569 } else {
1570 /* Make sure this CPU has been intitialized */
1571 if (!cpumask_test_cpu(cpu_id, buffer->cpumask))
1572 goto out;
1573
1570 cpu_buffer = buffer->buffers[cpu_id]; 1574 cpu_buffer = buffer->buffers[cpu_id];
1571 1575
1572 if (nr_pages == cpu_buffer->nr_pages) 1576 if (nr_pages == cpu_buffer->nr_pages)
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index d951daa0ca9..042d221d33c 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -2982,7 +2982,7 @@ bool cancel_delayed_work(struct delayed_work *dwork)
2982 2982
2983 set_work_cpu_and_clear_pending(&dwork->work, work_cpu(&dwork->work)); 2983 set_work_cpu_and_clear_pending(&dwork->work, work_cpu(&dwork->work));
2984 local_irq_restore(flags); 2984 local_irq_restore(flags);
2985 return true; 2985 return ret;
2986} 2986}
2987EXPORT_SYMBOL(cancel_delayed_work); 2987EXPORT_SYMBOL(cancel_delayed_work);
2988 2988
diff --git a/lib/dma-debug.c b/lib/dma-debug.c
index b9087bff008..d84beb994f3 100644
--- a/lib/dma-debug.c
+++ b/lib/dma-debug.c
@@ -264,7 +264,7 @@ static struct dma_debug_entry *__hash_bucket_find(struct hash_bucket *bucket,
264 match_fn match) 264 match_fn match)
265{ 265{
266 struct dma_debug_entry *entry, *ret = NULL; 266 struct dma_debug_entry *entry, *ret = NULL;
267 int matches = 0, match_lvl, last_lvl = 0; 267 int matches = 0, match_lvl, last_lvl = -1;
268 268
269 list_for_each_entry(entry, &bucket->list, list) { 269 list_for_each_entry(entry, &bucket->list, list) {
270 if (!match(ref, entry)) 270 if (!match(ref, entry))
@@ -293,7 +293,7 @@ static struct dma_debug_entry *__hash_bucket_find(struct hash_bucket *bucket,
293 } else if (match_lvl > last_lvl) { 293 } else if (match_lvl > last_lvl) {
294 /* 294 /*
295 * We found an entry that fits better then the 295 * We found an entry that fits better then the
296 * previous one 296 * previous one or it is the 1st match.
297 */ 297 */
298 last_lvl = match_lvl; 298 last_lvl = match_lvl;
299 ret = entry; 299 ret = entry;
diff --git a/lib/genalloc.c b/lib/genalloc.c
index ca208a92628..54920433705 100644
--- a/lib/genalloc.c
+++ b/lib/genalloc.c
@@ -178,7 +178,7 @@ int gen_pool_add_virt(struct gen_pool *pool, unsigned long virt, phys_addr_t phy
178 struct gen_pool_chunk *chunk; 178 struct gen_pool_chunk *chunk;
179 int nbits = size >> pool->min_alloc_order; 179 int nbits = size >> pool->min_alloc_order;
180 int nbytes = sizeof(struct gen_pool_chunk) + 180 int nbytes = sizeof(struct gen_pool_chunk) +
181 (nbits + BITS_PER_BYTE - 1) / BITS_PER_BYTE; 181 BITS_TO_LONGS(nbits) * sizeof(long);
182 182
183 chunk = kmalloc_node(nbytes, GFP_KERNEL | __GFP_ZERO, nid); 183 chunk = kmalloc_node(nbytes, GFP_KERNEL | __GFP_ZERO, nid);
184 if (unlikely(chunk == NULL)) 184 if (unlikely(chunk == NULL))
diff --git a/lib/mpi/longlong.h b/lib/mpi/longlong.h
index 678ce4f1e12..095ab157a52 100644
--- a/lib/mpi/longlong.h
+++ b/lib/mpi/longlong.h
@@ -641,7 +641,14 @@ do { \
641 ************** MIPS ***************** 641 ************** MIPS *****************
642 ***************************************/ 642 ***************************************/
643#if defined(__mips__) && W_TYPE_SIZE == 32 643#if defined(__mips__) && W_TYPE_SIZE == 32
644#if __GNUC__ > 2 || __GNUC_MINOR__ >= 7 644#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 4
645#define umul_ppmm(w1, w0, u, v) \
646do { \
647 UDItype __ll = (UDItype)(u) * (v); \
648 w1 = __ll >> 32; \
649 w0 = __ll; \
650} while (0)
651#elif __GNUC__ > 2 || __GNUC_MINOR__ >= 7
645#define umul_ppmm(w1, w0, u, v) \ 652#define umul_ppmm(w1, w0, u, v) \
646 __asm__ ("multu %2,%3" \ 653 __asm__ ("multu %2,%3" \
647 : "=l" ((USItype)(w0)), \ 654 : "=l" ((USItype)(w0)), \
@@ -666,7 +673,15 @@ do { \
666 ************** MIPS/64 ************** 673 ************** MIPS/64 **************
667 ***************************************/ 674 ***************************************/
668#if (defined(__mips) && __mips >= 3) && W_TYPE_SIZE == 64 675#if (defined(__mips) && __mips >= 3) && W_TYPE_SIZE == 64
669#if __GNUC__ > 2 || __GNUC_MINOR__ >= 7 676#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 4
677#define umul_ppmm(w1, w0, u, v) \
678do { \
679 typedef unsigned int __ll_UTItype __attribute__((mode(TI))); \
680 __ll_UTItype __ll = (__ll_UTItype)(u) * (v); \
681 w1 = __ll >> 64; \
682 w0 = __ll; \
683} while (0)
684#elif __GNUC__ > 2 || __GNUC_MINOR__ >= 7
670#define umul_ppmm(w1, w0, u, v) \ 685#define umul_ppmm(w1, w0, u, v) \
671 __asm__ ("dmultu %2,%3" \ 686 __asm__ ("dmultu %2,%3" \
672 : "=l" ((UDItype)(w0)), \ 687 : "=l" ((UDItype)(w0)), \
diff --git a/mm/bootmem.c b/mm/bootmem.c
index 434be4ae7a0..f468185b3b2 100644
--- a/mm/bootmem.c
+++ b/mm/bootmem.c
@@ -198,8 +198,6 @@ static unsigned long __init free_all_bootmem_core(bootmem_data_t *bdata)
198 int order = ilog2(BITS_PER_LONG); 198 int order = ilog2(BITS_PER_LONG);
199 199
200 __free_pages_bootmem(pfn_to_page(start), order); 200 __free_pages_bootmem(pfn_to_page(start), order);
201 fixup_zone_present_pages(page_to_nid(pfn_to_page(start)),
202 start, start + BITS_PER_LONG);
203 count += BITS_PER_LONG; 201 count += BITS_PER_LONG;
204 start += BITS_PER_LONG; 202 start += BITS_PER_LONG;
205 } else { 203 } else {
@@ -210,9 +208,6 @@ static unsigned long __init free_all_bootmem_core(bootmem_data_t *bdata)
210 if (vec & 1) { 208 if (vec & 1) {
211 page = pfn_to_page(start + off); 209 page = pfn_to_page(start + off);
212 __free_pages_bootmem(page, 0); 210 __free_pages_bootmem(page, 0);
213 fixup_zone_present_pages(
214 page_to_nid(page),
215 start + off, start + off + 1);
216 count++; 211 count++;
217 } 212 }
218 vec >>= 1; 213 vec >>= 1;
@@ -226,11 +221,8 @@ static unsigned long __init free_all_bootmem_core(bootmem_data_t *bdata)
226 pages = bdata->node_low_pfn - bdata->node_min_pfn; 221 pages = bdata->node_low_pfn - bdata->node_min_pfn;
227 pages = bootmem_bootmap_pages(pages); 222 pages = bootmem_bootmap_pages(pages);
228 count += pages; 223 count += pages;
229 while (pages--) { 224 while (pages--)
230 fixup_zone_present_pages(page_to_nid(page),
231 page_to_pfn(page), page_to_pfn(page) + 1);
232 __free_pages_bootmem(page++, 0); 225 __free_pages_bootmem(page++, 0);
233 }
234 226
235 bdebug("nid=%td released=%lx\n", bdata - bootmem_node_data, count); 227 bdebug("nid=%td released=%lx\n", bdata - bootmem_node_data, count);
236 228
diff --git a/mm/compaction.c b/mm/compaction.c
index 2c4ce17651d..9eef55838fc 100644
--- a/mm/compaction.c
+++ b/mm/compaction.c
@@ -346,7 +346,7 @@ static unsigned long isolate_freepages_block(struct compact_control *cc,
346 * pages requested were isolated. If there were any failures, 0 is 346 * pages requested were isolated. If there were any failures, 0 is
347 * returned and CMA will fail. 347 * returned and CMA will fail.
348 */ 348 */
349 if (strict && nr_strict_required != total_isolated) 349 if (strict && nr_strict_required > total_isolated)
350 total_isolated = 0; 350 total_isolated = 0;
351 351
352 if (locked) 352 if (locked)
diff --git a/mm/fremap.c b/mm/fremap.c
index 3899a86851c..a0aaf0e5680 100644
--- a/mm/fremap.c
+++ b/mm/fremap.c
@@ -169,7 +169,7 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
169 if (vma->vm_private_data && !(vma->vm_flags & VM_NONLINEAR)) 169 if (vma->vm_private_data && !(vma->vm_flags & VM_NONLINEAR))
170 goto out; 170 goto out;
171 171
172 if (!vma->vm_ops->remap_pages) 172 if (!vma->vm_ops || !vma->vm_ops->remap_pages)
173 goto out; 173 goto out;
174 174
175 if (start < vma->vm_start || start + size > vma->vm_end) 175 if (start < vma->vm_start || start + size > vma->vm_end)
diff --git a/mm/highmem.c b/mm/highmem.c
index d517cd16a6e..2da13a5c50e 100644
--- a/mm/highmem.c
+++ b/mm/highmem.c
@@ -98,7 +98,7 @@ struct page *kmap_to_page(void *vaddr)
98{ 98{
99 unsigned long addr = (unsigned long)vaddr; 99 unsigned long addr = (unsigned long)vaddr;
100 100
101 if (addr >= PKMAP_ADDR(0) && addr <= PKMAP_ADDR(LAST_PKMAP)) { 101 if (addr >= PKMAP_ADDR(0) && addr < PKMAP_ADDR(LAST_PKMAP)) {
102 int i = (addr - PKMAP_ADDR(0)) >> PAGE_SHIFT; 102 int i = (addr - PKMAP_ADDR(0)) >> PAGE_SHIFT;
103 return pte_page(pkmap_page_table[i]); 103 return pte_page(pkmap_page_table[i]);
104 } 104 }
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index a863af26c79..40f17c34b41 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -17,6 +17,7 @@
17#include <linux/khugepaged.h> 17#include <linux/khugepaged.h>
18#include <linux/freezer.h> 18#include <linux/freezer.h>
19#include <linux/mman.h> 19#include <linux/mman.h>
20#include <linux/pagemap.h>
20#include <asm/tlb.h> 21#include <asm/tlb.h>
21#include <asm/pgalloc.h> 22#include <asm/pgalloc.h>
22#include "internal.h" 23#include "internal.h"
diff --git a/mm/memblock.c b/mm/memblock.c
index 931eef145af..625905523c2 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -930,6 +930,30 @@ int __init_memblock memblock_is_region_reserved(phys_addr_t base, phys_addr_t si
930 return memblock_overlaps_region(&memblock.reserved, base, size) >= 0; 930 return memblock_overlaps_region(&memblock.reserved, base, size) >= 0;
931} 931}
932 932
933void __init_memblock memblock_trim_memory(phys_addr_t align)
934{
935 int i;
936 phys_addr_t start, end, orig_start, orig_end;
937 struct memblock_type *mem = &memblock.memory;
938
939 for (i = 0; i < mem->cnt; i++) {
940 orig_start = mem->regions[i].base;
941 orig_end = mem->regions[i].base + mem->regions[i].size;
942 start = round_up(orig_start, align);
943 end = round_down(orig_end, align);
944
945 if (start == orig_start && end == orig_end)
946 continue;
947
948 if (start < end) {
949 mem->regions[i].base = start;
950 mem->regions[i].size = end - start;
951 } else {
952 memblock_remove_region(mem, i);
953 i--;
954 }
955 }
956}
933 957
934void __init_memblock memblock_set_current_limit(phys_addr_t limit) 958void __init_memblock memblock_set_current_limit(phys_addr_t limit)
935{ 959{
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 7acf43bf04a..dd39ba000b3 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -1055,12 +1055,24 @@ struct lruvec *mem_cgroup_zone_lruvec(struct zone *zone,
1055 struct mem_cgroup *memcg) 1055 struct mem_cgroup *memcg)
1056{ 1056{
1057 struct mem_cgroup_per_zone *mz; 1057 struct mem_cgroup_per_zone *mz;
1058 struct lruvec *lruvec;
1058 1059
1059 if (mem_cgroup_disabled()) 1060 if (mem_cgroup_disabled()) {
1060 return &zone->lruvec; 1061 lruvec = &zone->lruvec;
1062 goto out;
1063 }
1061 1064
1062 mz = mem_cgroup_zoneinfo(memcg, zone_to_nid(zone), zone_idx(zone)); 1065 mz = mem_cgroup_zoneinfo(memcg, zone_to_nid(zone), zone_idx(zone));
1063 return &mz->lruvec; 1066 lruvec = &mz->lruvec;
1067out:
1068 /*
1069 * Since a node can be onlined after the mem_cgroup was created,
1070 * we have to be prepared to initialize lruvec->zone here;
1071 * and if offlined then reonlined, we need to reinitialize it.
1072 */
1073 if (unlikely(lruvec->zone != zone))
1074 lruvec->zone = zone;
1075 return lruvec;
1064} 1076}
1065 1077
1066/* 1078/*
@@ -1087,9 +1099,12 @@ struct lruvec *mem_cgroup_page_lruvec(struct page *page, struct zone *zone)
1087 struct mem_cgroup_per_zone *mz; 1099 struct mem_cgroup_per_zone *mz;
1088 struct mem_cgroup *memcg; 1100 struct mem_cgroup *memcg;
1089 struct page_cgroup *pc; 1101 struct page_cgroup *pc;
1102 struct lruvec *lruvec;
1090 1103
1091 if (mem_cgroup_disabled()) 1104 if (mem_cgroup_disabled()) {
1092 return &zone->lruvec; 1105 lruvec = &zone->lruvec;
1106 goto out;
1107 }
1093 1108
1094 pc = lookup_page_cgroup(page); 1109 pc = lookup_page_cgroup(page);
1095 memcg = pc->mem_cgroup; 1110 memcg = pc->mem_cgroup;
@@ -1107,7 +1122,16 @@ struct lruvec *mem_cgroup_page_lruvec(struct page *page, struct zone *zone)
1107 pc->mem_cgroup = memcg = root_mem_cgroup; 1122 pc->mem_cgroup = memcg = root_mem_cgroup;
1108 1123
1109 mz = page_cgroup_zoneinfo(memcg, page); 1124 mz = page_cgroup_zoneinfo(memcg, page);
1110 return &mz->lruvec; 1125 lruvec = &mz->lruvec;
1126out:
1127 /*
1128 * Since a node can be onlined after the mem_cgroup was created,
1129 * we have to be prepared to initialize lruvec->zone here;
1130 * and if offlined then reonlined, we need to reinitialize it.
1131 */
1132 if (unlikely(lruvec->zone != zone))
1133 lruvec->zone = zone;
1134 return lruvec;
1111} 1135}
1112 1136
1113/** 1137/**
@@ -1452,17 +1476,26 @@ static int mem_cgroup_count_children(struct mem_cgroup *memcg)
1452static u64 mem_cgroup_get_limit(struct mem_cgroup *memcg) 1476static u64 mem_cgroup_get_limit(struct mem_cgroup *memcg)
1453{ 1477{
1454 u64 limit; 1478 u64 limit;
1455 u64 memsw;
1456 1479
1457 limit = res_counter_read_u64(&memcg->res, RES_LIMIT); 1480 limit = res_counter_read_u64(&memcg->res, RES_LIMIT);
1458 limit += total_swap_pages << PAGE_SHIFT;
1459 1481
1460 memsw = res_counter_read_u64(&memcg->memsw, RES_LIMIT);
1461 /* 1482 /*
1462 * If memsw is finite and limits the amount of swap space available 1483 * Do not consider swap space if we cannot swap due to swappiness
1463 * to this memcg, return that limit.
1464 */ 1484 */
1465 return min(limit, memsw); 1485 if (mem_cgroup_swappiness(memcg)) {
1486 u64 memsw;
1487
1488 limit += total_swap_pages << PAGE_SHIFT;
1489 memsw = res_counter_read_u64(&memcg->memsw, RES_LIMIT);
1490
1491 /*
1492 * If memsw is finite and limits the amount of swap space
1493 * available to this memcg, return that limit.
1494 */
1495 limit = min(limit, memsw);
1496 }
1497
1498 return limit;
1466} 1499}
1467 1500
1468void mem_cgroup_out_of_memory(struct mem_cgroup *memcg, gfp_t gfp_mask, 1501void mem_cgroup_out_of_memory(struct mem_cgroup *memcg, gfp_t gfp_mask,
@@ -3688,17 +3721,17 @@ unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order,
3688static bool mem_cgroup_force_empty_list(struct mem_cgroup *memcg, 3721static bool mem_cgroup_force_empty_list(struct mem_cgroup *memcg,
3689 int node, int zid, enum lru_list lru) 3722 int node, int zid, enum lru_list lru)
3690{ 3723{
3691 struct mem_cgroup_per_zone *mz; 3724 struct lruvec *lruvec;
3692 unsigned long flags, loop; 3725 unsigned long flags, loop;
3693 struct list_head *list; 3726 struct list_head *list;
3694 struct page *busy; 3727 struct page *busy;
3695 struct zone *zone; 3728 struct zone *zone;
3696 3729
3697 zone = &NODE_DATA(node)->node_zones[zid]; 3730 zone = &NODE_DATA(node)->node_zones[zid];
3698 mz = mem_cgroup_zoneinfo(memcg, node, zid); 3731 lruvec = mem_cgroup_zone_lruvec(zone, memcg);
3699 list = &mz->lruvec.lists[lru]; 3732 list = &lruvec->lists[lru];
3700 3733
3701 loop = mz->lru_size[lru]; 3734 loop = mem_cgroup_get_lru_size(lruvec, lru);
3702 /* give some margin against EBUSY etc...*/ 3735 /* give some margin against EBUSY etc...*/
3703 loop += 256; 3736 loop += 256;
3704 busy = NULL; 3737 busy = NULL;
@@ -4736,7 +4769,7 @@ static int alloc_mem_cgroup_per_zone_info(struct mem_cgroup *memcg, int node)
4736 4769
4737 for (zone = 0; zone < MAX_NR_ZONES; zone++) { 4770 for (zone = 0; zone < MAX_NR_ZONES; zone++) {
4738 mz = &pn->zoneinfo[zone]; 4771 mz = &pn->zoneinfo[zone];
4739 lruvec_init(&mz->lruvec, &NODE_DATA(node)->node_zones[zone]); 4772 lruvec_init(&mz->lruvec);
4740 mz->usage_in_excess = 0; 4773 mz->usage_in_excess = 0;
4741 mz->on_tree = false; 4774 mz->on_tree = false;
4742 mz->memcg = memcg; 4775 mz->memcg = memcg;
diff --git a/mm/memory.c b/mm/memory.c
index fb135ba4aba..221fc9ffcab 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -2527,9 +2527,8 @@ static int do_wp_page(struct mm_struct *mm, struct vm_area_struct *vma,
2527 int ret = 0; 2527 int ret = 0;
2528 int page_mkwrite = 0; 2528 int page_mkwrite = 0;
2529 struct page *dirty_page = NULL; 2529 struct page *dirty_page = NULL;
2530 unsigned long mmun_start; /* For mmu_notifiers */ 2530 unsigned long mmun_start = 0; /* For mmu_notifiers */
2531 unsigned long mmun_end; /* For mmu_notifiers */ 2531 unsigned long mmun_end = 0; /* For mmu_notifiers */
2532 bool mmun_called = false; /* For mmu_notifiers */
2533 2532
2534 old_page = vm_normal_page(vma, address, orig_pte); 2533 old_page = vm_normal_page(vma, address, orig_pte);
2535 if (!old_page) { 2534 if (!old_page) {
@@ -2708,8 +2707,7 @@ gotten:
2708 goto oom_free_new; 2707 goto oom_free_new;
2709 2708
2710 mmun_start = address & PAGE_MASK; 2709 mmun_start = address & PAGE_MASK;
2711 mmun_end = (address & PAGE_MASK) + PAGE_SIZE; 2710 mmun_end = mmun_start + PAGE_SIZE;
2712 mmun_called = true;
2713 mmu_notifier_invalidate_range_start(mm, mmun_start, mmun_end); 2711 mmu_notifier_invalidate_range_start(mm, mmun_start, mmun_end);
2714 2712
2715 /* 2713 /*
@@ -2778,7 +2776,7 @@ gotten:
2778 page_cache_release(new_page); 2776 page_cache_release(new_page);
2779unlock: 2777unlock:
2780 pte_unmap_unlock(page_table, ptl); 2778 pte_unmap_unlock(page_table, ptl);
2781 if (mmun_called) 2779 if (mmun_end > mmun_start)
2782 mmu_notifier_invalidate_range_end(mm, mmun_start, mmun_end); 2780 mmu_notifier_invalidate_range_end(mm, mmun_start, mmun_end);
2783 if (old_page) { 2781 if (old_page) {
2784 /* 2782 /*
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 56b758ae57d..e4eeacae2b9 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -106,7 +106,6 @@ static void get_page_bootmem(unsigned long info, struct page *page,
106void __ref put_page_bootmem(struct page *page) 106void __ref put_page_bootmem(struct page *page)
107{ 107{
108 unsigned long type; 108 unsigned long type;
109 struct zone *zone;
110 109
111 type = (unsigned long) page->lru.next; 110 type = (unsigned long) page->lru.next;
112 BUG_ON(type < MEMORY_HOTPLUG_MIN_BOOTMEM_TYPE || 111 BUG_ON(type < MEMORY_HOTPLUG_MIN_BOOTMEM_TYPE ||
@@ -117,12 +116,6 @@ void __ref put_page_bootmem(struct page *page)
117 set_page_private(page, 0); 116 set_page_private(page, 0);
118 INIT_LIST_HEAD(&page->lru); 117 INIT_LIST_HEAD(&page->lru);
119 __free_pages_bootmem(page, 0); 118 __free_pages_bootmem(page, 0);
120
121 zone = page_zone(page);
122 zone_span_writelock(zone);
123 zone->present_pages++;
124 zone_span_writeunlock(zone);
125 totalram_pages++;
126 } 119 }
127 120
128} 121}
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index 0b78fb9ea65..d04a8a54c29 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -1536,9 +1536,8 @@ asmlinkage long compat_sys_mbind(compat_ulong_t start, compat_ulong_t len,
1536 * 1536 *
1537 * Returns effective policy for a VMA at specified address. 1537 * Returns effective policy for a VMA at specified address.
1538 * Falls back to @task or system default policy, as necessary. 1538 * Falls back to @task or system default policy, as necessary.
1539 * Current or other task's task mempolicy and non-shared vma policies 1539 * Current or other task's task mempolicy and non-shared vma policies must be
1540 * are protected by the task's mmap_sem, which must be held for read by 1540 * protected by task_lock(task) by the caller.
1541 * the caller.
1542 * Shared policies [those marked as MPOL_F_SHARED] require an extra reference 1541 * Shared policies [those marked as MPOL_F_SHARED] require an extra reference
1543 * count--added by the get_policy() vm_op, as appropriate--to protect against 1542 * count--added by the get_policy() vm_op, as appropriate--to protect against
1544 * freeing by another task. It is the caller's responsibility to free the 1543 * freeing by another task. It is the caller's responsibility to free the
diff --git a/mm/mmap.c b/mm/mmap.c
index 2d942353d68..9a796c41e7d 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -334,8 +334,10 @@ void validate_mm(struct mm_struct *mm)
334 struct vm_area_struct *vma = mm->mmap; 334 struct vm_area_struct *vma = mm->mmap;
335 while (vma) { 335 while (vma) {
336 struct anon_vma_chain *avc; 336 struct anon_vma_chain *avc;
337 vma_lock_anon_vma(vma);
337 list_for_each_entry(avc, &vma->anon_vma_chain, same_vma) 338 list_for_each_entry(avc, &vma->anon_vma_chain, same_vma)
338 anon_vma_interval_tree_verify(avc); 339 anon_vma_interval_tree_verify(avc);
340 vma_unlock_anon_vma(vma);
339 vma = vma->vm_next; 341 vma = vma->vm_next;
340 i++; 342 i++;
341 } 343 }
diff --git a/mm/mmu_notifier.c b/mm/mmu_notifier.c
index 479a1e751a7..8a5ac8c686b 100644
--- a/mm/mmu_notifier.c
+++ b/mm/mmu_notifier.c
@@ -196,28 +196,28 @@ static int do_mmu_notifier_register(struct mmu_notifier *mn,
196 BUG_ON(atomic_read(&mm->mm_users) <= 0); 196 BUG_ON(atomic_read(&mm->mm_users) <= 0);
197 197
198 /* 198 /*
199 * Verify that mmu_notifier_init() already run and the global srcu is 199 * Verify that mmu_notifier_init() already run and the global srcu is
200 * initialized. 200 * initialized.
201 */ 201 */
202 BUG_ON(!srcu.per_cpu_ref); 202 BUG_ON(!srcu.per_cpu_ref);
203 203
204 ret = -ENOMEM;
205 mmu_notifier_mm = kmalloc(sizeof(struct mmu_notifier_mm), GFP_KERNEL);
206 if (unlikely(!mmu_notifier_mm))
207 goto out;
208
204 if (take_mmap_sem) 209 if (take_mmap_sem)
205 down_write(&mm->mmap_sem); 210 down_write(&mm->mmap_sem);
206 ret = mm_take_all_locks(mm); 211 ret = mm_take_all_locks(mm);
207 if (unlikely(ret)) 212 if (unlikely(ret))
208 goto out; 213 goto out_clean;
209 214
210 if (!mm_has_notifiers(mm)) { 215 if (!mm_has_notifiers(mm)) {
211 mmu_notifier_mm = kmalloc(sizeof(struct mmu_notifier_mm),
212 GFP_KERNEL);
213 if (unlikely(!mmu_notifier_mm)) {
214 ret = -ENOMEM;
215 goto out_of_mem;
216 }
217 INIT_HLIST_HEAD(&mmu_notifier_mm->list); 216 INIT_HLIST_HEAD(&mmu_notifier_mm->list);
218 spin_lock_init(&mmu_notifier_mm->lock); 217 spin_lock_init(&mmu_notifier_mm->lock);
219 218
220 mm->mmu_notifier_mm = mmu_notifier_mm; 219 mm->mmu_notifier_mm = mmu_notifier_mm;
220 mmu_notifier_mm = NULL;
221 } 221 }
222 atomic_inc(&mm->mm_count); 222 atomic_inc(&mm->mm_count);
223 223
@@ -233,12 +233,12 @@ static int do_mmu_notifier_register(struct mmu_notifier *mn,
233 hlist_add_head(&mn->hlist, &mm->mmu_notifier_mm->list); 233 hlist_add_head(&mn->hlist, &mm->mmu_notifier_mm->list);
234 spin_unlock(&mm->mmu_notifier_mm->lock); 234 spin_unlock(&mm->mmu_notifier_mm->lock);
235 235
236out_of_mem:
237 mm_drop_all_locks(mm); 236 mm_drop_all_locks(mm);
238out: 237out_clean:
239 if (take_mmap_sem) 238 if (take_mmap_sem)
240 up_write(&mm->mmap_sem); 239 up_write(&mm->mmap_sem);
241 240 kfree(mmu_notifier_mm);
241out:
242 BUG_ON(atomic_read(&mm->mm_users) <= 0); 242 BUG_ON(atomic_read(&mm->mm_users) <= 0);
243 return ret; 243 return ret;
244} 244}
diff --git a/mm/mmzone.c b/mm/mmzone.c
index 3cef80f6ac7..4596d81b89b 100644
--- a/mm/mmzone.c
+++ b/mm/mmzone.c
@@ -87,7 +87,7 @@ int memmap_valid_within(unsigned long pfn,
87} 87}
88#endif /* CONFIG_ARCH_HAS_HOLES_MEMORYMODEL */ 88#endif /* CONFIG_ARCH_HAS_HOLES_MEMORYMODEL */
89 89
90void lruvec_init(struct lruvec *lruvec, struct zone *zone) 90void lruvec_init(struct lruvec *lruvec)
91{ 91{
92 enum lru_list lru; 92 enum lru_list lru;
93 93
@@ -95,8 +95,4 @@ void lruvec_init(struct lruvec *lruvec, struct zone *zone)
95 95
96 for_each_lru(lru) 96 for_each_lru(lru)
97 INIT_LIST_HEAD(&lruvec->lists[lru]); 97 INIT_LIST_HEAD(&lruvec->lists[lru]);
98
99#ifdef CONFIG_MEMCG
100 lruvec->zone = zone;
101#endif
102} 98}
diff --git a/mm/nobootmem.c b/mm/nobootmem.c
index 714d5d65047..bd82f6b3141 100644
--- a/mm/nobootmem.c
+++ b/mm/nobootmem.c
@@ -116,8 +116,6 @@ static unsigned long __init __free_memory_core(phys_addr_t start,
116 return 0; 116 return 0;
117 117
118 __free_pages_memory(start_pfn, end_pfn); 118 __free_pages_memory(start_pfn, end_pfn);
119 fixup_zone_present_pages(pfn_to_nid(start >> PAGE_SHIFT),
120 start_pfn, end_pfn);
121 119
122 return end_pfn - start_pfn; 120 return end_pfn - start_pfn;
123} 121}
@@ -128,7 +126,6 @@ unsigned long __init free_low_memory_core_early(int nodeid)
128 phys_addr_t start, end, size; 126 phys_addr_t start, end, size;
129 u64 i; 127 u64 i;
130 128
131 reset_zone_present_pages();
132 for_each_free_mem_range(i, MAX_NUMNODES, &start, &end, NULL) 129 for_each_free_mem_range(i, MAX_NUMNODES, &start, &end, NULL)
133 count += __free_memory_core(start, end); 130 count += __free_memory_core(start, end);
134 131
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index bb90971182b..bcb72c6e2b2 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1405,7 +1405,7 @@ int capture_free_page(struct page *page, int alloc_order, int migratetype)
1405 1405
1406 mt = get_pageblock_migratetype(page); 1406 mt = get_pageblock_migratetype(page);
1407 if (unlikely(mt != MIGRATE_ISOLATE)) 1407 if (unlikely(mt != MIGRATE_ISOLATE))
1408 __mod_zone_freepage_state(zone, -(1UL << order), mt); 1408 __mod_zone_freepage_state(zone, -(1UL << alloc_order), mt);
1409 1409
1410 if (alloc_order != order) 1410 if (alloc_order != order)
1411 expand(zone, page, alloc_order, order, 1411 expand(zone, page, alloc_order, order,
@@ -1809,10 +1809,10 @@ static void __paginginit init_zone_allows_reclaim(int nid)
1809 int i; 1809 int i;
1810 1810
1811 for_each_online_node(i) 1811 for_each_online_node(i)
1812 if (node_distance(nid, i) <= RECLAIM_DISTANCE) { 1812 if (node_distance(nid, i) <= RECLAIM_DISTANCE)
1813 node_set(i, NODE_DATA(nid)->reclaim_nodes); 1813 node_set(i, NODE_DATA(nid)->reclaim_nodes);
1814 else
1814 zone_reclaim_mode = 1; 1815 zone_reclaim_mode = 1;
1815 }
1816} 1816}
1817 1817
1818#else /* CONFIG_NUMA */ 1818#else /* CONFIG_NUMA */
@@ -4505,7 +4505,7 @@ static void __paginginit free_area_init_core(struct pglist_data *pgdat,
4505 zone->zone_pgdat = pgdat; 4505 zone->zone_pgdat = pgdat;
4506 4506
4507 zone_pcp_init(zone); 4507 zone_pcp_init(zone);
4508 lruvec_init(&zone->lruvec, zone); 4508 lruvec_init(&zone->lruvec);
4509 if (!size) 4509 if (!size)
4510 continue; 4510 continue;
4511 4511
@@ -5825,7 +5825,7 @@ int alloc_contig_range(unsigned long start, unsigned long end,
5825 ret = start_isolate_page_range(pfn_max_align_down(start), 5825 ret = start_isolate_page_range(pfn_max_align_down(start),
5826 pfn_max_align_up(end), migratetype); 5826 pfn_max_align_up(end), migratetype);
5827 if (ret) 5827 if (ret)
5828 goto done; 5828 return ret;
5829 5829
5830 ret = __alloc_contig_migrate_range(&cc, start, end); 5830 ret = __alloc_contig_migrate_range(&cc, start, end);
5831 if (ret) 5831 if (ret)
@@ -6098,37 +6098,3 @@ void dump_page(struct page *page)
6098 dump_page_flags(page->flags); 6098 dump_page_flags(page->flags);
6099 mem_cgroup_print_bad_page(page); 6099 mem_cgroup_print_bad_page(page);
6100} 6100}
6101
6102/* reset zone->present_pages */
6103void reset_zone_present_pages(void)
6104{
6105 struct zone *z;
6106 int i, nid;
6107
6108 for_each_node_state(nid, N_HIGH_MEMORY) {
6109 for (i = 0; i < MAX_NR_ZONES; i++) {
6110 z = NODE_DATA(nid)->node_zones + i;
6111 z->present_pages = 0;
6112 }
6113 }
6114}
6115
6116/* calculate zone's present pages in buddy system */
6117void fixup_zone_present_pages(int nid, unsigned long start_pfn,
6118 unsigned long end_pfn)
6119{
6120 struct zone *z;
6121 unsigned long zone_start_pfn, zone_end_pfn;
6122 int i;
6123
6124 for (i = 0; i < MAX_NR_ZONES; i++) {
6125 z = NODE_DATA(nid)->node_zones + i;
6126 zone_start_pfn = z->zone_start_pfn;
6127 zone_end_pfn = zone_start_pfn + z->spanned_pages;
6128
6129 /* if the two regions intersect */
6130 if (!(zone_start_pfn >= end_pfn || zone_end_pfn <= start_pfn))
6131 z->present_pages += min(end_pfn, zone_end_pfn) -
6132 max(start_pfn, zone_start_pfn);
6133 }
6134}
diff --git a/mm/rmap.c b/mm/rmap.c
index 7df7984d476..2ee1ef0f317 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -56,6 +56,7 @@
56#include <linux/mmu_notifier.h> 56#include <linux/mmu_notifier.h>
57#include <linux/migrate.h> 57#include <linux/migrate.h>
58#include <linux/hugetlb.h> 58#include <linux/hugetlb.h>
59#include <linux/backing-dev.h>
59 60
60#include <asm/tlbflush.h> 61#include <asm/tlbflush.h>
61 62
@@ -926,11 +927,8 @@ int page_mkclean(struct page *page)
926 927
927 if (page_mapped(page)) { 928 if (page_mapped(page)) {
928 struct address_space *mapping = page_mapping(page); 929 struct address_space *mapping = page_mapping(page);
929 if (mapping) { 930 if (mapping)
930 ret = page_mkclean_file(mapping, page); 931 ret = page_mkclean_file(mapping, page);
931 if (page_test_and_clear_dirty(page_to_pfn(page), 1))
932 ret = 1;
933 }
934 } 932 }
935 933
936 return ret; 934 return ret;
@@ -1116,6 +1114,7 @@ void page_add_file_rmap(struct page *page)
1116 */ 1114 */
1117void page_remove_rmap(struct page *page) 1115void page_remove_rmap(struct page *page)
1118{ 1116{
1117 struct address_space *mapping = page_mapping(page);
1119 bool anon = PageAnon(page); 1118 bool anon = PageAnon(page);
1120 bool locked; 1119 bool locked;
1121 unsigned long flags; 1120 unsigned long flags;
@@ -1138,8 +1137,19 @@ void page_remove_rmap(struct page *page)
1138 * this if the page is anon, so about to be freed; but perhaps 1137 * this if the page is anon, so about to be freed; but perhaps
1139 * not if it's in swapcache - there might be another pte slot 1138 * not if it's in swapcache - there might be another pte slot
1140 * containing the swap entry, but page not yet written to swap. 1139 * containing the swap entry, but page not yet written to swap.
1140 *
1141 * And we can skip it on file pages, so long as the filesystem
1142 * participates in dirty tracking; but need to catch shm and tmpfs
1143 * and ramfs pages which have been modified since creation by read
1144 * fault.
1145 *
1146 * Note that mapping must be decided above, before decrementing
1147 * mapcount (which luckily provides a barrier): once page is unmapped,
1148 * it could be truncated and page->mapping reset to NULL at any moment.
1149 * Note also that we are relying on page_mapping(page) to set mapping
1150 * to &swapper_space when PageSwapCache(page).
1141 */ 1151 */
1142 if ((!anon || PageSwapCache(page)) && 1152 if (mapping && !mapping_cap_account_dirty(mapping) &&
1143 page_test_and_clear_dirty(page_to_pfn(page), 1)) 1153 page_test_and_clear_dirty(page_to_pfn(page), 1))
1144 set_page_dirty(page); 1154 set_page_dirty(page);
1145 /* 1155 /*
diff --git a/mm/shmem.c b/mm/shmem.c
index 67afba5117f..89341b658bd 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -643,7 +643,7 @@ static void shmem_evict_inode(struct inode *inode)
643 kfree(info->symlink); 643 kfree(info->symlink);
644 644
645 simple_xattrs_free(&info->xattrs); 645 simple_xattrs_free(&info->xattrs);
646 BUG_ON(inode->i_blocks); 646 WARN_ON(inode->i_blocks);
647 shmem_free_inode(inode->i_sb); 647 shmem_free_inode(inode->i_sb);
648 clear_inode(inode); 648 clear_inode(inode);
649} 649}
@@ -1145,8 +1145,20 @@ repeat:
1145 if (!error) { 1145 if (!error) {
1146 error = shmem_add_to_page_cache(page, mapping, index, 1146 error = shmem_add_to_page_cache(page, mapping, index,
1147 gfp, swp_to_radix_entry(swap)); 1147 gfp, swp_to_radix_entry(swap));
1148 /* We already confirmed swap, and make no allocation */ 1148 /*
1149 VM_BUG_ON(error); 1149 * We already confirmed swap under page lock, and make
1150 * no memory allocation here, so usually no possibility
1151 * of error; but free_swap_and_cache() only trylocks a
1152 * page, so it is just possible that the entry has been
1153 * truncated or holepunched since swap was confirmed.
1154 * shmem_undo_range() will have done some of the
1155 * unaccounting, now delete_from_swap_cache() will do
1156 * the rest (including mem_cgroup_uncharge_swapcache).
1157 * Reset swap.val? No, leave it so "failed" goes back to
1158 * "repeat": reading a hole and writing should succeed.
1159 */
1160 if (error)
1161 delete_from_swap_cache(page);
1150 } 1162 }
1151 if (error) 1163 if (error)
1152 goto failed; 1164 goto failed;
diff --git a/mm/slob.c b/mm/slob.c
index a08e4681fd0..1e921c5e957 100644
--- a/mm/slob.c
+++ b/mm/slob.c
@@ -429,7 +429,7 @@ static __always_inline void *
429__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller) 429__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
430{ 430{
431 unsigned int *m; 431 unsigned int *m;
432 int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN); 432 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
433 void *ret; 433 void *ret;
434 434
435 gfp &= gfp_allowed_mask; 435 gfp &= gfp_allowed_mask;
@@ -502,7 +502,7 @@ void kfree(const void *block)
502 502
503 sp = virt_to_page(block); 503 sp = virt_to_page(block);
504 if (PageSlab(sp)) { 504 if (PageSlab(sp)) {
505 int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN); 505 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
506 unsigned int *m = (unsigned int *)(block - align); 506 unsigned int *m = (unsigned int *)(block - align);
507 slob_free(m, *m + align); 507 slob_free(m, *m + align);
508 } else 508 } else
@@ -521,7 +521,7 @@ size_t ksize(const void *block)
521 521
522 sp = virt_to_page(block); 522 sp = virt_to_page(block);
523 if (PageSlab(sp)) { 523 if (PageSlab(sp)) {
524 int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN); 524 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
525 unsigned int *m = (unsigned int *)(block - align); 525 unsigned int *m = (unsigned int *)(block - align);
526 return SLOB_UNITS(*m) * SLOB_UNIT; 526 return SLOB_UNITS(*m) * SLOB_UNIT;
527 } else 527 } else
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 71cd288b200..f91a25547ff 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -1494,9 +1494,8 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
1494 BUG_ON(!current->mm); 1494 BUG_ON(!current->mm);
1495 1495
1496 pathname = getname(specialfile); 1496 pathname = getname(specialfile);
1497 err = PTR_ERR(pathname);
1498 if (IS_ERR(pathname)) 1497 if (IS_ERR(pathname))
1499 goto out; 1498 return PTR_ERR(pathname);
1500 1499
1501 victim = file_open_name(pathname, O_RDWR|O_LARGEFILE, 0); 1500 victim = file_open_name(pathname, O_RDWR|O_LARGEFILE, 0);
1502 err = PTR_ERR(victim); 1501 err = PTR_ERR(victim);
@@ -1608,6 +1607,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
1608out_dput: 1607out_dput:
1609 filp_close(victim, NULL); 1608 filp_close(victim, NULL);
1610out: 1609out:
1610 putname(pathname);
1611 return err; 1611 return err;
1612} 1612}
1613 1613
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 2624edcfb42..48550c66f1f 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1760,28 +1760,6 @@ static bool in_reclaim_compaction(struct scan_control *sc)
1760 return false; 1760 return false;
1761} 1761}
1762 1762
1763#ifdef CONFIG_COMPACTION
1764/*
1765 * If compaction is deferred for sc->order then scale the number of pages
1766 * reclaimed based on the number of consecutive allocation failures
1767 */
1768static unsigned long scale_for_compaction(unsigned long pages_for_compaction,
1769 struct lruvec *lruvec, struct scan_control *sc)
1770{
1771 struct zone *zone = lruvec_zone(lruvec);
1772
1773 if (zone->compact_order_failed <= sc->order)
1774 pages_for_compaction <<= zone->compact_defer_shift;
1775 return pages_for_compaction;
1776}
1777#else
1778static unsigned long scale_for_compaction(unsigned long pages_for_compaction,
1779 struct lruvec *lruvec, struct scan_control *sc)
1780{
1781 return pages_for_compaction;
1782}
1783#endif
1784
1785/* 1763/*
1786 * Reclaim/compaction is used for high-order allocation requests. It reclaims 1764 * Reclaim/compaction is used for high-order allocation requests. It reclaims
1787 * order-0 pages before compacting the zone. should_continue_reclaim() returns 1765 * order-0 pages before compacting the zone. should_continue_reclaim() returns
@@ -1829,9 +1807,6 @@ static inline bool should_continue_reclaim(struct lruvec *lruvec,
1829 * inactive lists are large enough, continue reclaiming 1807 * inactive lists are large enough, continue reclaiming
1830 */ 1808 */
1831 pages_for_compaction = (2UL << sc->order); 1809 pages_for_compaction = (2UL << sc->order);
1832
1833 pages_for_compaction = scale_for_compaction(pages_for_compaction,
1834 lruvec, sc);
1835 inactive_lru_pages = get_lru_size(lruvec, LRU_INACTIVE_FILE); 1810 inactive_lru_pages = get_lru_size(lruvec, LRU_INACTIVE_FILE);
1836 if (nr_swap_pages > 0) 1811 if (nr_swap_pages > 0)
1837 inactive_lru_pages += get_lru_size(lruvec, LRU_INACTIVE_ANON); 1812 inactive_lru_pages += get_lru_size(lruvec, LRU_INACTIVE_ANON);
@@ -3017,6 +2992,8 @@ static int kswapd(void *p)
3017 &balanced_classzone_idx); 2992 &balanced_classzone_idx);
3018 } 2993 }
3019 } 2994 }
2995
2996 current->reclaim_state = NULL;
3020 return 0; 2997 return 0;
3021} 2998}
3022 2999
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index 9096bcb0813..ee070722a3a 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -463,7 +463,9 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event,
463 463
464 case NETDEV_PRE_TYPE_CHANGE: 464 case NETDEV_PRE_TYPE_CHANGE:
465 /* Forbid underlaying device to change its type. */ 465 /* Forbid underlaying device to change its type. */
466 return NOTIFY_BAD; 466 if (vlan_uses_dev(dev))
467 return NOTIFY_BAD;
468 break;
467 469
468 case NETDEV_NOTIFY_PEERS: 470 case NETDEV_NOTIFY_PEERS:
469 case NETDEV_BONDING_FAILOVER: 471 case NETDEV_BONDING_FAILOVER:
diff --git a/net/8021q/vlan_core.c b/net/8021q/vlan_core.c
index fbbf1fa0094..65e06abe023 100644
--- a/net/8021q/vlan_core.c
+++ b/net/8021q/vlan_core.c
@@ -366,6 +366,13 @@ EXPORT_SYMBOL(vlan_vids_del_by_dev);
366 366
367bool vlan_uses_dev(const struct net_device *dev) 367bool vlan_uses_dev(const struct net_device *dev)
368{ 368{
369 return rtnl_dereference(dev->vlan_info) ? true : false; 369 struct vlan_info *vlan_info;
370
371 ASSERT_RTNL();
372
373 vlan_info = rtnl_dereference(dev->vlan_info);
374 if (!vlan_info)
375 return false;
376 return vlan_info->grp.nr_vlan_devs ? true : false;
370} 377}
371EXPORT_SYMBOL(vlan_uses_dev); 378EXPORT_SYMBOL(vlan_uses_dev);
diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c
index 0a9084ad19a..fd8d5afec0d 100644
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -1167,6 +1167,8 @@ int batadv_bla_init(struct batadv_priv *bat_priv)
1167 uint16_t crc; 1167 uint16_t crc;
1168 unsigned long entrytime; 1168 unsigned long entrytime;
1169 1169
1170 spin_lock_init(&bat_priv->bla.bcast_duplist_lock);
1171
1170 batadv_dbg(BATADV_DBG_BLA, bat_priv, "bla hash registering\n"); 1172 batadv_dbg(BATADV_DBG_BLA, bat_priv, "bla hash registering\n");
1171 1173
1172 /* setting claim destination address */ 1174 /* setting claim destination address */
@@ -1210,8 +1212,8 @@ int batadv_bla_init(struct batadv_priv *bat_priv)
1210/** 1212/**
1211 * batadv_bla_check_bcast_duplist 1213 * batadv_bla_check_bcast_duplist
1212 * @bat_priv: the bat priv with all the soft interface information 1214 * @bat_priv: the bat priv with all the soft interface information
1213 * @bcast_packet: originator mac address 1215 * @bcast_packet: encapsulated broadcast frame plus batman header
1214 * @hdr_size: maximum length of the frame 1216 * @bcast_packet_len: length of encapsulated broadcast frame plus batman header
1215 * 1217 *
1216 * check if it is on our broadcast list. Another gateway might 1218 * check if it is on our broadcast list. Another gateway might
1217 * have sent the same packet because it is connected to the same backbone, 1219 * have sent the same packet because it is connected to the same backbone,
@@ -1224,20 +1226,22 @@ int batadv_bla_init(struct batadv_priv *bat_priv)
1224 */ 1226 */
1225int batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv, 1227int batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv,
1226 struct batadv_bcast_packet *bcast_packet, 1228 struct batadv_bcast_packet *bcast_packet,
1227 int hdr_size) 1229 int bcast_packet_len)
1228{ 1230{
1229 int i, length, curr; 1231 int i, length, curr, ret = 0;
1230 uint8_t *content; 1232 uint8_t *content;
1231 uint16_t crc; 1233 uint16_t crc;
1232 struct batadv_bcast_duplist_entry *entry; 1234 struct batadv_bcast_duplist_entry *entry;
1233 1235
1234 length = hdr_size - sizeof(*bcast_packet); 1236 length = bcast_packet_len - sizeof(*bcast_packet);
1235 content = (uint8_t *)bcast_packet; 1237 content = (uint8_t *)bcast_packet;
1236 content += sizeof(*bcast_packet); 1238 content += sizeof(*bcast_packet);
1237 1239
1238 /* calculate the crc ... */ 1240 /* calculate the crc ... */
1239 crc = crc16(0, content, length); 1241 crc = crc16(0, content, length);
1240 1242
1243 spin_lock_bh(&bat_priv->bla.bcast_duplist_lock);
1244
1241 for (i = 0; i < BATADV_DUPLIST_SIZE; i++) { 1245 for (i = 0; i < BATADV_DUPLIST_SIZE; i++) {
1242 curr = (bat_priv->bla.bcast_duplist_curr + i); 1246 curr = (bat_priv->bla.bcast_duplist_curr + i);
1243 curr %= BATADV_DUPLIST_SIZE; 1247 curr %= BATADV_DUPLIST_SIZE;
@@ -1259,9 +1263,12 @@ int batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv,
1259 /* this entry seems to match: same crc, not too old, 1263 /* this entry seems to match: same crc, not too old,
1260 * and from another gw. therefore return 1 to forbid it. 1264 * and from another gw. therefore return 1 to forbid it.
1261 */ 1265 */
1262 return 1; 1266 ret = 1;
1267 goto out;
1263 } 1268 }
1264 /* not found, add a new entry (overwrite the oldest entry) */ 1269 /* not found, add a new entry (overwrite the oldest entry)
1270 * and allow it, its the first occurence.
1271 */
1265 curr = (bat_priv->bla.bcast_duplist_curr + BATADV_DUPLIST_SIZE - 1); 1272 curr = (bat_priv->bla.bcast_duplist_curr + BATADV_DUPLIST_SIZE - 1);
1266 curr %= BATADV_DUPLIST_SIZE; 1273 curr %= BATADV_DUPLIST_SIZE;
1267 entry = &bat_priv->bla.bcast_duplist[curr]; 1274 entry = &bat_priv->bla.bcast_duplist[curr];
@@ -1270,8 +1277,10 @@ int batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv,
1270 memcpy(entry->orig, bcast_packet->orig, ETH_ALEN); 1277 memcpy(entry->orig, bcast_packet->orig, ETH_ALEN);
1271 bat_priv->bla.bcast_duplist_curr = curr; 1278 bat_priv->bla.bcast_duplist_curr = curr;
1272 1279
1273 /* allow it, its the first occurence. */ 1280out:
1274 return 0; 1281 spin_unlock_bh(&bat_priv->bla.bcast_duplist_lock);
1282
1283 return ret;
1275} 1284}
1276 1285
1277 1286
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
index 939fc01371d..376b4cc6ca8 100644
--- a/net/batman-adv/routing.c
+++ b/net/batman-adv/routing.c
@@ -1124,8 +1124,14 @@ int batadv_recv_bcast_packet(struct sk_buff *skb,
1124 1124
1125 spin_unlock_bh(&orig_node->bcast_seqno_lock); 1125 spin_unlock_bh(&orig_node->bcast_seqno_lock);
1126 1126
1127 /* keep skb linear for crc calculation */
1128 if (skb_linearize(skb) < 0)
1129 goto out;
1130
1131 bcast_packet = (struct batadv_bcast_packet *)skb->data;
1132
1127 /* check whether this has been sent by another originator before */ 1133 /* check whether this has been sent by another originator before */
1128 if (batadv_bla_check_bcast_duplist(bat_priv, bcast_packet, hdr_size)) 1134 if (batadv_bla_check_bcast_duplist(bat_priv, bcast_packet, skb->len))
1129 goto out; 1135 goto out;
1130 1136
1131 /* rebroadcast packet */ 1137 /* rebroadcast packet */
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
index b9a28d2dd3e..ce0684a1fc8 100644
--- a/net/batman-adv/soft-interface.c
+++ b/net/batman-adv/soft-interface.c
@@ -325,6 +325,12 @@ void batadv_interface_rx(struct net_device *soft_iface,
325 325
326 soft_iface->last_rx = jiffies; 326 soft_iface->last_rx = jiffies;
327 327
328 /* Let the bridge loop avoidance check the packet. If will
329 * not handle it, we can safely push it up.
330 */
331 if (batadv_bla_rx(bat_priv, skb, vid, is_bcast))
332 goto out;
333
328 if (orig_node) 334 if (orig_node)
329 batadv_tt_add_temporary_global_entry(bat_priv, orig_node, 335 batadv_tt_add_temporary_global_entry(bat_priv, orig_node,
330 ethhdr->h_source); 336 ethhdr->h_source);
@@ -332,12 +338,6 @@ void batadv_interface_rx(struct net_device *soft_iface,
332 if (batadv_is_ap_isolated(bat_priv, ethhdr->h_source, ethhdr->h_dest)) 338 if (batadv_is_ap_isolated(bat_priv, ethhdr->h_source, ethhdr->h_dest))
333 goto dropped; 339 goto dropped;
334 340
335 /* Let the bridge loop avoidance check the packet. If will
336 * not handle it, we can safely push it up.
337 */
338 if (batadv_bla_rx(bat_priv, skb, vid, is_bcast))
339 goto out;
340
341 netif_rx(skb); 341 netif_rx(skb);
342 goto out; 342 goto out;
343 343
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 112edd371b2..baae7158580 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -769,6 +769,12 @@ int batadv_tt_global_add(struct batadv_priv *bat_priv,
769 */ 769 */
770 tt_global_entry->common.flags &= ~BATADV_TT_CLIENT_TEMP; 770 tt_global_entry->common.flags &= ~BATADV_TT_CLIENT_TEMP;
771 771
772 /* the change can carry possible "attribute" flags like the
773 * TT_CLIENT_WIFI, therefore they have to be copied in the
774 * client entry
775 */
776 tt_global_entry->common.flags |= flags;
777
772 /* If there is the BATADV_TT_CLIENT_ROAM flag set, there is only 778 /* If there is the BATADV_TT_CLIENT_ROAM flag set, there is only
773 * one originator left in the list and we previously received a 779 * one originator left in the list and we previously received a
774 * delete + roaming change for this originator. 780 * delete + roaming change for this originator.
@@ -1496,7 +1502,7 @@ batadv_tt_response_fill_table(uint16_t tt_len, uint8_t ttvn,
1496 1502
1497 memcpy(tt_change->addr, tt_common_entry->addr, 1503 memcpy(tt_change->addr, tt_common_entry->addr,
1498 ETH_ALEN); 1504 ETH_ALEN);
1499 tt_change->flags = BATADV_NO_FLAGS; 1505 tt_change->flags = tt_common_entry->flags;
1500 1506
1501 tt_count++; 1507 tt_count++;
1502 tt_change++; 1508 tt_change++;
@@ -2450,6 +2456,13 @@ bool batadv_tt_add_temporary_global_entry(struct batadv_priv *bat_priv,
2450{ 2456{
2451 bool ret = false; 2457 bool ret = false;
2452 2458
2459 /* if the originator is a backbone node (meaning it belongs to the same
2460 * LAN of this node) the temporary client must not be added because to
2461 * reach such destination the node must use the LAN instead of the mesh
2462 */
2463 if (batadv_bla_is_backbone_gw_orig(bat_priv, orig_node->orig))
2464 goto out;
2465
2453 if (!batadv_tt_global_add(bat_priv, orig_node, addr, 2466 if (!batadv_tt_global_add(bat_priv, orig_node, addr,
2454 BATADV_TT_CLIENT_TEMP, 2467 BATADV_TT_CLIENT_TEMP,
2455 atomic_read(&orig_node->last_ttvn))) 2468 atomic_read(&orig_node->last_ttvn)))
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
index 2ed82caacdc..ac1e07a8045 100644
--- a/net/batman-adv/types.h
+++ b/net/batman-adv/types.h
@@ -205,6 +205,8 @@ struct batadv_priv_bla {
205 struct batadv_hashtable *backbone_hash; 205 struct batadv_hashtable *backbone_hash;
206 struct batadv_bcast_duplist_entry bcast_duplist[BATADV_DUPLIST_SIZE]; 206 struct batadv_bcast_duplist_entry bcast_duplist[BATADV_DUPLIST_SIZE];
207 int bcast_duplist_curr; 207 int bcast_duplist_curr;
208 /* protects bcast_duplist and bcast_duplist_curr */
209 spinlock_t bcast_duplist_lock;
208 struct batadv_bla_claim_dst claim_dest; 210 struct batadv_bla_claim_dst claim_dest;
209 struct delayed_work work; 211 struct delayed_work work;
210}; 212};
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 8a0ce706aeb..a0a2f97b9c6 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -1754,11 +1754,11 @@ int hci_register_dev(struct hci_dev *hdev)
1754 if (hdev->dev_type != HCI_AMP) 1754 if (hdev->dev_type != HCI_AMP)
1755 set_bit(HCI_AUTO_OFF, &hdev->dev_flags); 1755 set_bit(HCI_AUTO_OFF, &hdev->dev_flags);
1756 1756
1757 schedule_work(&hdev->power_on);
1758
1759 hci_notify(hdev, HCI_DEV_REG); 1757 hci_notify(hdev, HCI_DEV_REG);
1760 hci_dev_hold(hdev); 1758 hci_dev_hold(hdev);
1761 1759
1760 schedule_work(&hdev->power_on);
1761
1762 return id; 1762 return id;
1763 1763
1764err_wqueue: 1764err_wqueue:
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index aa2ea0a8142..91de4239da6 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -326,7 +326,7 @@ static int read_index_list(struct sock *sk, struct hci_dev *hdev, void *data,
326 struct hci_dev *d; 326 struct hci_dev *d;
327 size_t rp_len; 327 size_t rp_len;
328 u16 count; 328 u16 count;
329 int i, err; 329 int err;
330 330
331 BT_DBG("sock %p", sk); 331 BT_DBG("sock %p", sk);
332 332
@@ -347,9 +347,7 @@ static int read_index_list(struct sock *sk, struct hci_dev *hdev, void *data,
347 return -ENOMEM; 347 return -ENOMEM;
348 } 348 }
349 349
350 rp->num_controllers = cpu_to_le16(count); 350 count = 0;
351
352 i = 0;
353 list_for_each_entry(d, &hci_dev_list, list) { 351 list_for_each_entry(d, &hci_dev_list, list) {
354 if (test_bit(HCI_SETUP, &d->dev_flags)) 352 if (test_bit(HCI_SETUP, &d->dev_flags))
355 continue; 353 continue;
@@ -357,10 +355,13 @@ static int read_index_list(struct sock *sk, struct hci_dev *hdev, void *data,
357 if (!mgmt_valid_hdev(d)) 355 if (!mgmt_valid_hdev(d))
358 continue; 356 continue;
359 357
360 rp->index[i++] = cpu_to_le16(d->id); 358 rp->index[count++] = cpu_to_le16(d->id);
361 BT_DBG("Added hci%u", d->id); 359 BT_DBG("Added hci%u", d->id);
362 } 360 }
363 361
362 rp->num_controllers = cpu_to_le16(count);
363 rp_len = sizeof(*rp) + (2 * count);
364
364 read_unlock(&hci_dev_list_lock); 365 read_unlock(&hci_dev_list_lock);
365 366
366 err = cmd_complete(sk, MGMT_INDEX_NONE, MGMT_OP_READ_INDEX_LIST, 0, rp, 367 err = cmd_complete(sk, MGMT_INDEX_NONE, MGMT_OP_READ_INDEX_LIST, 0, rp,
@@ -1366,6 +1367,7 @@ static int remove_uuid(struct sock *sk, struct hci_dev *hdev, void *data,
1366 continue; 1367 continue;
1367 1368
1368 list_del(&match->list); 1369 list_del(&match->list);
1370 kfree(match);
1369 found++; 1371 found++;
1370 } 1372 }
1371 1373
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
index 8c225ef349c..a5923378bdf 100644
--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -32,6 +32,8 @@
32 32
33#define SMP_TIMEOUT msecs_to_jiffies(30000) 33#define SMP_TIMEOUT msecs_to_jiffies(30000)
34 34
35#define AUTH_REQ_MASK 0x07
36
35static inline void swap128(u8 src[16], u8 dst[16]) 37static inline void swap128(u8 src[16], u8 dst[16])
36{ 38{
37 int i; 39 int i;
@@ -230,7 +232,7 @@ static void build_pairing_cmd(struct l2cap_conn *conn,
230 req->max_key_size = SMP_MAX_ENC_KEY_SIZE; 232 req->max_key_size = SMP_MAX_ENC_KEY_SIZE;
231 req->init_key_dist = 0; 233 req->init_key_dist = 0;
232 req->resp_key_dist = dist_keys; 234 req->resp_key_dist = dist_keys;
233 req->auth_req = authreq; 235 req->auth_req = (authreq & AUTH_REQ_MASK);
234 return; 236 return;
235 } 237 }
236 238
@@ -239,7 +241,7 @@ static void build_pairing_cmd(struct l2cap_conn *conn,
239 rsp->max_key_size = SMP_MAX_ENC_KEY_SIZE; 241 rsp->max_key_size = SMP_MAX_ENC_KEY_SIZE;
240 rsp->init_key_dist = 0; 242 rsp->init_key_dist = 0;
241 rsp->resp_key_dist = req->resp_key_dist & dist_keys; 243 rsp->resp_key_dist = req->resp_key_dist & dist_keys;
242 rsp->auth_req = authreq; 244 rsp->auth_req = (authreq & AUTH_REQ_MASK);
243} 245}
244 246
245static u8 check_enc_key_size(struct l2cap_conn *conn, __u8 max_key_size) 247static u8 check_enc_key_size(struct l2cap_conn *conn, __u8 max_key_size)
@@ -265,7 +267,7 @@ static void smp_failure(struct l2cap_conn *conn, u8 reason, u8 send)
265 267
266 clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->hcon->flags); 268 clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->hcon->flags);
267 mgmt_auth_failed(conn->hcon->hdev, conn->dst, hcon->type, 269 mgmt_auth_failed(conn->hcon->hdev, conn->dst, hcon->type,
268 hcon->dst_type, reason); 270 hcon->dst_type, HCI_ERROR_AUTH_FAILURE);
269 271
270 cancel_delayed_work_sync(&conn->security_timer); 272 cancel_delayed_work_sync(&conn->security_timer);
271 273
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index 159aa8bef9e..3ef1759403b 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -2300,10 +2300,11 @@ restart:
2300 mutex_unlock(&con->mutex); 2300 mutex_unlock(&con->mutex);
2301 return; 2301 return;
2302 } else { 2302 } else {
2303 con->ops->put(con);
2304 dout("con_work %p FAILED to back off %lu\n", con, 2303 dout("con_work %p FAILED to back off %lu\n", con,
2305 con->delay); 2304 con->delay);
2305 set_bit(CON_FLAG_BACKOFF, &con->flags);
2306 } 2306 }
2307 goto done;
2307 } 2308 }
2308 2309
2309 if (con->state == CON_STATE_STANDBY) { 2310 if (con->state == CON_STATE_STANDBY) {
@@ -2749,7 +2750,8 @@ static int ceph_con_in_msg_alloc(struct ceph_connection *con, int *skip)
2749 msg = con->ops->alloc_msg(con, hdr, skip); 2750 msg = con->ops->alloc_msg(con, hdr, skip);
2750 mutex_lock(&con->mutex); 2751 mutex_lock(&con->mutex);
2751 if (con->state != CON_STATE_OPEN) { 2752 if (con->state != CON_STATE_OPEN) {
2752 ceph_msg_put(msg); 2753 if (msg)
2754 ceph_msg_put(msg);
2753 return -EAGAIN; 2755 return -EAGAIN;
2754 } 2756 }
2755 con->in_msg = msg; 2757 con->in_msg = msg;
diff --git a/net/core/dev.c b/net/core/dev.c
index 09cb3f6dc40..c0946cb2b35 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1666,7 +1666,7 @@ static inline int deliver_skb(struct sk_buff *skb,
1666 1666
1667static inline bool skb_loop_sk(struct packet_type *ptype, struct sk_buff *skb) 1667static inline bool skb_loop_sk(struct packet_type *ptype, struct sk_buff *skb)
1668{ 1668{
1669 if (ptype->af_packet_priv == NULL) 1669 if (!ptype->af_packet_priv || !skb->sk)
1670 return false; 1670 return false;
1671 1671
1672 if (ptype->id_match) 1672 if (ptype->id_match)
@@ -2818,8 +2818,10 @@ static int get_rps_cpu(struct net_device *dev, struct sk_buff *skb,
2818 if (unlikely(tcpu != next_cpu) && 2818 if (unlikely(tcpu != next_cpu) &&
2819 (tcpu == RPS_NO_CPU || !cpu_online(tcpu) || 2819 (tcpu == RPS_NO_CPU || !cpu_online(tcpu) ||
2820 ((int)(per_cpu(softnet_data, tcpu).input_queue_head - 2820 ((int)(per_cpu(softnet_data, tcpu).input_queue_head -
2821 rflow->last_qtail)) >= 0)) 2821 rflow->last_qtail)) >= 0)) {
2822 tcpu = next_cpu;
2822 rflow = set_rps_cpu(dev, skb, rflow, next_cpu); 2823 rflow = set_rps_cpu(dev, skb, rflow, next_cpu);
2824 }
2823 2825
2824 if (tcpu != RPS_NO_CPU && cpu_online(tcpu)) { 2826 if (tcpu != RPS_NO_CPU && cpu_online(tcpu)) {
2825 *rflowp = rflow; 2827 *rflowp = rflow;
diff --git a/net/core/dev_addr_lists.c b/net/core/dev_addr_lists.c
index 87cc17db2d5..b079c7bbc15 100644
--- a/net/core/dev_addr_lists.c
+++ b/net/core/dev_addr_lists.c
@@ -319,7 +319,8 @@ int dev_addr_del(struct net_device *dev, const unsigned char *addr,
319 */ 319 */
320 ha = list_first_entry(&dev->dev_addrs.list, 320 ha = list_first_entry(&dev->dev_addrs.list,
321 struct netdev_hw_addr, list); 321 struct netdev_hw_addr, list);
322 if (ha->addr == dev->dev_addr && ha->refcount == 1) 322 if (!memcmp(ha->addr, addr, dev->addr_len) &&
323 ha->type == addr_type && ha->refcount == 1)
323 return -ENOENT; 324 return -ENOENT;
324 325
325 err = __hw_addr_del(&dev->dev_addrs, addr, dev->addr_len, 326 err = __hw_addr_del(&dev->dev_addrs, addr, dev->addr_len,
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index bcf02f608cb..017a8bacfb2 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -429,6 +429,17 @@ static struct attribute_group netstat_group = {
429 .name = "statistics", 429 .name = "statistics",
430 .attrs = netstat_attrs, 430 .attrs = netstat_attrs,
431}; 431};
432
433#if IS_ENABLED(CONFIG_WIRELESS_EXT) || IS_ENABLED(CONFIG_CFG80211)
434static struct attribute *wireless_attrs[] = {
435 NULL
436};
437
438static struct attribute_group wireless_group = {
439 .name = "wireless",
440 .attrs = wireless_attrs,
441};
442#endif
432#endif /* CONFIG_SYSFS */ 443#endif /* CONFIG_SYSFS */
433 444
434#ifdef CONFIG_RPS 445#ifdef CONFIG_RPS
@@ -1409,6 +1420,15 @@ int netdev_register_kobject(struct net_device *net)
1409 groups++; 1420 groups++;
1410 1421
1411 *groups++ = &netstat_group; 1422 *groups++ = &netstat_group;
1423
1424#if IS_ENABLED(CONFIG_WIRELESS_EXT) || IS_ENABLED(CONFIG_CFG80211)
1425 if (net->ieee80211_ptr)
1426 *groups++ = &wireless_group;
1427#if IS_ENABLED(CONFIG_WIRELESS_EXT)
1428 else if (net->wireless_handlers)
1429 *groups++ = &wireless_group;
1430#endif
1431#endif
1412#endif /* CONFIG_SYSFS */ 1432#endif /* CONFIG_SYSFS */
1413 1433
1414 error = device_add(dev); 1434 error = device_add(dev);
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 76d4c2c3c89..fad649ae4de 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -2192,7 +2192,8 @@ static int nlmsg_populate_fdb(struct sk_buff *skb,
2192 goto skip; 2192 goto skip;
2193 2193
2194 err = nlmsg_populate_fdb_fill(skb, dev, ha->addr, 2194 err = nlmsg_populate_fdb_fill(skb, dev, ha->addr,
2195 portid, seq, 0, NTF_SELF); 2195 portid, seq,
2196 RTM_NEWNEIGH, NTF_SELF);
2196 if (err < 0) 2197 if (err < 0)
2197 return err; 2198 return err;
2198skip: 2199skip:
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 6e04b1fa11f..4007c1437fd 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -3379,10 +3379,12 @@ EXPORT_SYMBOL(__skb_warn_lro_forwarding);
3379 3379
3380void kfree_skb_partial(struct sk_buff *skb, bool head_stolen) 3380void kfree_skb_partial(struct sk_buff *skb, bool head_stolen)
3381{ 3381{
3382 if (head_stolen) 3382 if (head_stolen) {
3383 skb_release_head_state(skb);
3383 kmem_cache_free(skbuff_head_cache, skb); 3384 kmem_cache_free(skbuff_head_cache, skb);
3384 else 3385 } else {
3385 __kfree_skb(skb); 3386 __kfree_skb(skb);
3387 }
3386} 3388}
3387EXPORT_SYMBOL(kfree_skb_partial); 3389EXPORT_SYMBOL(kfree_skb_partial);
3388 3390
diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c
index 535584c00f9..0c34bfabc11 100644
--- a/net/ipv4/inet_diag.c
+++ b/net/ipv4/inet_diag.c
@@ -892,13 +892,16 @@ static int __inet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb,
892 struct inet_diag_req_v2 *r, struct nlattr *bc) 892 struct inet_diag_req_v2 *r, struct nlattr *bc)
893{ 893{
894 const struct inet_diag_handler *handler; 894 const struct inet_diag_handler *handler;
895 int err = 0;
895 896
896 handler = inet_diag_lock_handler(r->sdiag_protocol); 897 handler = inet_diag_lock_handler(r->sdiag_protocol);
897 if (!IS_ERR(handler)) 898 if (!IS_ERR(handler))
898 handler->dump(skb, cb, r, bc); 899 handler->dump(skb, cb, r, bc);
900 else
901 err = PTR_ERR(handler);
899 inet_diag_unlock_handler(handler); 902 inet_diag_unlock_handler(handler);
900 903
901 return skb->len; 904 return err ? : skb->len;
902} 905}
903 906
904static int inet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb) 907static int inet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb)
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
index 5eea4a81104..14bbfcf717a 100644
--- a/net/ipv4/ip_sockglue.c
+++ b/net/ipv4/ip_sockglue.c
@@ -457,19 +457,28 @@ static int do_ip_setsockopt(struct sock *sk, int level,
457 struct inet_sock *inet = inet_sk(sk); 457 struct inet_sock *inet = inet_sk(sk);
458 int val = 0, err; 458 int val = 0, err;
459 459
460 if (((1<<optname) & ((1<<IP_PKTINFO) | (1<<IP_RECVTTL) | 460 switch (optname) {
461 (1<<IP_RECVOPTS) | (1<<IP_RECVTOS) | 461 case IP_PKTINFO:
462 (1<<IP_RETOPTS) | (1<<IP_TOS) | 462 case IP_RECVTTL:
463 (1<<IP_TTL) | (1<<IP_HDRINCL) | 463 case IP_RECVOPTS:
464 (1<<IP_MTU_DISCOVER) | (1<<IP_RECVERR) | 464 case IP_RECVTOS:
465 (1<<IP_ROUTER_ALERT) | (1<<IP_FREEBIND) | 465 case IP_RETOPTS:
466 (1<<IP_PASSSEC) | (1<<IP_TRANSPARENT) | 466 case IP_TOS:
467 (1<<IP_MINTTL) | (1<<IP_NODEFRAG))) || 467 case IP_TTL:
468 optname == IP_UNICAST_IF || 468 case IP_HDRINCL:
469 optname == IP_MULTICAST_TTL || 469 case IP_MTU_DISCOVER:
470 optname == IP_MULTICAST_ALL || 470 case IP_RECVERR:
471 optname == IP_MULTICAST_LOOP || 471 case IP_ROUTER_ALERT:
472 optname == IP_RECVORIGDSTADDR) { 472 case IP_FREEBIND:
473 case IP_PASSSEC:
474 case IP_TRANSPARENT:
475 case IP_MINTTL:
476 case IP_NODEFRAG:
477 case IP_UNICAST_IF:
478 case IP_MULTICAST_TTL:
479 case IP_MULTICAST_ALL:
480 case IP_MULTICAST_LOOP:
481 case IP_RECVORIGDSTADDR:
473 if (optlen >= sizeof(int)) { 482 if (optlen >= sizeof(int)) {
474 if (get_user(val, (int __user *) optval)) 483 if (get_user(val, (int __user *) optval))
475 return -EFAULT; 484 return -EFAULT;
diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
index 1831092f999..858fddf6482 100644
--- a/net/ipv4/ip_vti.c
+++ b/net/ipv4/ip_vti.c
@@ -338,12 +338,17 @@ static int vti_rcv(struct sk_buff *skb)
338 if (tunnel != NULL) { 338 if (tunnel != NULL) {
339 struct pcpu_tstats *tstats; 339 struct pcpu_tstats *tstats;
340 340
341 if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb))
342 return -1;
343
341 tstats = this_cpu_ptr(tunnel->dev->tstats); 344 tstats = this_cpu_ptr(tunnel->dev->tstats);
342 u64_stats_update_begin(&tstats->syncp); 345 u64_stats_update_begin(&tstats->syncp);
343 tstats->rx_packets++; 346 tstats->rx_packets++;
344 tstats->rx_bytes += skb->len; 347 tstats->rx_bytes += skb->len;
345 u64_stats_update_end(&tstats->syncp); 348 u64_stats_update_end(&tstats->syncp);
346 349
350 skb->mark = 0;
351 secpath_reset(skb);
347 skb->dev = tunnel->dev; 352 skb->dev = tunnel->dev;
348 return 1; 353 return 1;
349 } 354 }
diff --git a/net/ipv4/netfilter/iptable_nat.c b/net/ipv4/netfilter/iptable_nat.c
index 9e0ffaf1d94..a82047282db 100644
--- a/net/ipv4/netfilter/iptable_nat.c
+++ b/net/ipv4/netfilter/iptable_nat.c
@@ -184,7 +184,8 @@ nf_nat_ipv4_out(unsigned int hooknum,
184 184
185 if ((ct->tuplehash[dir].tuple.src.u3.ip != 185 if ((ct->tuplehash[dir].tuple.src.u3.ip !=
186 ct->tuplehash[!dir].tuple.dst.u3.ip) || 186 ct->tuplehash[!dir].tuple.dst.u3.ip) ||
187 (ct->tuplehash[dir].tuple.src.u.all != 187 (ct->tuplehash[dir].tuple.dst.protonum != IPPROTO_ICMP &&
188 ct->tuplehash[dir].tuple.src.u.all !=
188 ct->tuplehash[!dir].tuple.dst.u.all)) 189 ct->tuplehash[!dir].tuple.dst.u.all))
189 if (nf_xfrm_me_harder(skb, AF_INET) < 0) 190 if (nf_xfrm_me_harder(skb, AF_INET) < 0)
190 ret = NF_DROP; 191 ret = NF_DROP;
@@ -221,6 +222,7 @@ nf_nat_ipv4_local_fn(unsigned int hooknum,
221 } 222 }
222#ifdef CONFIG_XFRM 223#ifdef CONFIG_XFRM
223 else if (!(IPCB(skb)->flags & IPSKB_XFRM_TRANSFORMED) && 224 else if (!(IPCB(skb)->flags & IPSKB_XFRM_TRANSFORMED) &&
225 ct->tuplehash[dir].tuple.dst.protonum != IPPROTO_ICMP &&
224 ct->tuplehash[dir].tuple.dst.u.all != 226 ct->tuplehash[dir].tuple.dst.u.all !=
225 ct->tuplehash[!dir].tuple.src.u.all) 227 ct->tuplehash[!dir].tuple.src.u.all)
226 if (nf_xfrm_me_harder(skb, AF_INET) < 0) 228 if (nf_xfrm_me_harder(skb, AF_INET) < 0)
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 432f4bb7723..df251424d81 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1163,8 +1163,12 @@ static bool rt_bind_exception(struct rtable *rt, struct fib_nh_exception *fnhe,
1163 spin_lock_bh(&fnhe_lock); 1163 spin_lock_bh(&fnhe_lock);
1164 1164
1165 if (daddr == fnhe->fnhe_daddr) { 1165 if (daddr == fnhe->fnhe_daddr) {
1166 struct rtable *orig; 1166 struct rtable *orig = rcu_dereference(fnhe->fnhe_rth);
1167 1167 if (orig && rt_is_expired(orig)) {
1168 fnhe->fnhe_gw = 0;
1169 fnhe->fnhe_pmtu = 0;
1170 fnhe->fnhe_expires = 0;
1171 }
1168 if (fnhe->fnhe_pmtu) { 1172 if (fnhe->fnhe_pmtu) {
1169 unsigned long expires = fnhe->fnhe_expires; 1173 unsigned long expires = fnhe->fnhe_expires;
1170 unsigned long diff = expires - jiffies; 1174 unsigned long diff = expires - jiffies;
@@ -1181,7 +1185,6 @@ static bool rt_bind_exception(struct rtable *rt, struct fib_nh_exception *fnhe,
1181 } else if (!rt->rt_gateway) 1185 } else if (!rt->rt_gateway)
1182 rt->rt_gateway = daddr; 1186 rt->rt_gateway = daddr;
1183 1187
1184 orig = rcu_dereference(fnhe->fnhe_rth);
1185 rcu_assign_pointer(fnhe->fnhe_rth, rt); 1188 rcu_assign_pointer(fnhe->fnhe_rth, rt);
1186 if (orig) 1189 if (orig)
1187 rt_free(orig); 1190 rt_free(orig);
@@ -1782,6 +1785,7 @@ static struct rtable *__mkroute_output(const struct fib_result *res,
1782 if (dev_out->flags & IFF_LOOPBACK) 1785 if (dev_out->flags & IFF_LOOPBACK)
1783 flags |= RTCF_LOCAL; 1786 flags |= RTCF_LOCAL;
1784 1787
1788 do_cache = true;
1785 if (type == RTN_BROADCAST) { 1789 if (type == RTN_BROADCAST) {
1786 flags |= RTCF_BROADCAST | RTCF_LOCAL; 1790 flags |= RTCF_BROADCAST | RTCF_LOCAL;
1787 fi = NULL; 1791 fi = NULL;
@@ -1790,6 +1794,8 @@ static struct rtable *__mkroute_output(const struct fib_result *res,
1790 if (!ip_check_mc_rcu(in_dev, fl4->daddr, fl4->saddr, 1794 if (!ip_check_mc_rcu(in_dev, fl4->daddr, fl4->saddr,
1791 fl4->flowi4_proto)) 1795 fl4->flowi4_proto))
1792 flags &= ~RTCF_LOCAL; 1796 flags &= ~RTCF_LOCAL;
1797 else
1798 do_cache = false;
1793 /* If multicast route do not exist use 1799 /* If multicast route do not exist use
1794 * default one, but do not gateway in this case. 1800 * default one, but do not gateway in this case.
1795 * Yes, it is hack. 1801 * Yes, it is hack.
@@ -1799,8 +1805,8 @@ static struct rtable *__mkroute_output(const struct fib_result *res,
1799 } 1805 }
1800 1806
1801 fnhe = NULL; 1807 fnhe = NULL;
1802 do_cache = fi != NULL; 1808 do_cache &= fi != NULL;
1803 if (fi) { 1809 if (do_cache) {
1804 struct rtable __rcu **prth; 1810 struct rtable __rcu **prth;
1805 struct fib_nh *nh = &FIB_RES_NH(*res); 1811 struct fib_nh *nh = &FIB_RES_NH(*res);
1806 1812
@@ -2594,7 +2600,7 @@ int __init ip_rt_init(void)
2594 pr_err("Unable to create route proc files\n"); 2600 pr_err("Unable to create route proc files\n");
2595#ifdef CONFIG_XFRM 2601#ifdef CONFIG_XFRM
2596 xfrm_init(); 2602 xfrm_init();
2597 xfrm4_init(ip_rt_max_size); 2603 xfrm4_init();
2598#endif 2604#endif
2599 rtnl_register(PF_INET, RTM_GETROUTE, inet_rtm_getroute, NULL, NULL); 2605 rtnl_register(PF_INET, RTM_GETROUTE, inet_rtm_getroute, NULL, NULL);
2600 2606
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index f32c02e2a54..083092e3aed 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -549,14 +549,12 @@ int tcp_ioctl(struct sock *sk, int cmd, unsigned long arg)
549 !tp->urg_data || 549 !tp->urg_data ||
550 before(tp->urg_seq, tp->copied_seq) || 550 before(tp->urg_seq, tp->copied_seq) ||
551 !before(tp->urg_seq, tp->rcv_nxt)) { 551 !before(tp->urg_seq, tp->rcv_nxt)) {
552 struct sk_buff *skb;
553 552
554 answ = tp->rcv_nxt - tp->copied_seq; 553 answ = tp->rcv_nxt - tp->copied_seq;
555 554
556 /* Subtract 1, if FIN is in queue. */ 555 /* Subtract 1, if FIN was received */
557 skb = skb_peek_tail(&sk->sk_receive_queue); 556 if (answ && sock_flag(sk, SOCK_DONE))
558 if (answ && skb) 557 answ--;
559 answ -= tcp_hdr(skb)->fin;
560 } else 558 } else
561 answ = tp->urg_seq - tp->copied_seq; 559 answ = tp->urg_seq - tp->copied_seq;
562 release_sock(sk); 560 release_sock(sk);
@@ -1214,7 +1212,7 @@ new_segment:
1214wait_for_sndbuf: 1212wait_for_sndbuf:
1215 set_bit(SOCK_NOSPACE, &sk->sk_socket->flags); 1213 set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
1216wait_for_memory: 1214wait_for_memory:
1217 if (copied && likely(!tp->repair)) 1215 if (copied)
1218 tcp_push(sk, flags & ~MSG_MORE, mss_now, TCP_NAGLE_PUSH); 1216 tcp_push(sk, flags & ~MSG_MORE, mss_now, TCP_NAGLE_PUSH);
1219 1217
1220 if ((err = sk_stream_wait_memory(sk, &timeo)) != 0) 1218 if ((err = sk_stream_wait_memory(sk, &timeo)) != 0)
@@ -1225,7 +1223,7 @@ wait_for_memory:
1225 } 1223 }
1226 1224
1227out: 1225out:
1228 if (copied && likely(!tp->repair)) 1226 if (copied)
1229 tcp_push(sk, flags, mss_now, tp->nonagle); 1227 tcp_push(sk, flags, mss_now, tp->nonagle);
1230 release_sock(sk); 1228 release_sock(sk);
1231 return copied + copied_syn; 1229 return copied + copied_syn;
@@ -2766,6 +2764,8 @@ void tcp_get_info(const struct sock *sk, struct tcp_info *info)
2766 info->tcpi_options |= TCPI_OPT_ECN; 2764 info->tcpi_options |= TCPI_OPT_ECN;
2767 if (tp->ecn_flags & TCP_ECN_SEEN) 2765 if (tp->ecn_flags & TCP_ECN_SEEN)
2768 info->tcpi_options |= TCPI_OPT_ECN_SEEN; 2766 info->tcpi_options |= TCPI_OPT_ECN_SEEN;
2767 if (tp->syn_data_acked)
2768 info->tcpi_options |= TCPI_OPT_SYN_DATA;
2769 2769
2770 info->tcpi_rto = jiffies_to_usecs(icsk->icsk_rto); 2770 info->tcpi_rto = jiffies_to_usecs(icsk->icsk_rto);
2771 info->tcpi_ato = jiffies_to_usecs(icsk->icsk_ack.ato); 2771 info->tcpi_ato = jiffies_to_usecs(icsk->icsk_ack.ato);
diff --git a/net/ipv4/tcp_illinois.c b/net/ipv4/tcp_illinois.c
index 813b43a76fe..834857f3c87 100644
--- a/net/ipv4/tcp_illinois.c
+++ b/net/ipv4/tcp_illinois.c
@@ -313,11 +313,13 @@ static void tcp_illinois_info(struct sock *sk, u32 ext,
313 .tcpv_rttcnt = ca->cnt_rtt, 313 .tcpv_rttcnt = ca->cnt_rtt,
314 .tcpv_minrtt = ca->base_rtt, 314 .tcpv_minrtt = ca->base_rtt,
315 }; 315 };
316 u64 t = ca->sum_rtt;
317 316
318 do_div(t, ca->cnt_rtt); 317 if (info.tcpv_rttcnt > 0) {
319 info.tcpv_rtt = t; 318 u64 t = ca->sum_rtt;
320 319
320 do_div(t, info.tcpv_rttcnt);
321 info.tcpv_rtt = t;
322 }
321 nla_put(skb, INET_DIAG_VEGASINFO, sizeof(info), &info); 323 nla_put(skb, INET_DIAG_VEGASINFO, sizeof(info), &info);
322 } 324 }
323} 325}
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 432c36649db..609ff98aeb4 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -4529,6 +4529,9 @@ int tcp_send_rcvq(struct sock *sk, struct msghdr *msg, size_t size)
4529 struct tcphdr *th; 4529 struct tcphdr *th;
4530 bool fragstolen; 4530 bool fragstolen;
4531 4531
4532 if (size == 0)
4533 return 0;
4534
4532 skb = alloc_skb(size + sizeof(*th), sk->sk_allocation); 4535 skb = alloc_skb(size + sizeof(*th), sk->sk_allocation);
4533 if (!skb) 4536 if (!skb)
4534 goto err; 4537 goto err;
@@ -5310,11 +5313,6 @@ static bool tcp_validate_incoming(struct sock *sk, struct sk_buff *skb,
5310 goto discard; 5313 goto discard;
5311 } 5314 }
5312 5315
5313 /* ts_recent update must be made after we are sure that the packet
5314 * is in window.
5315 */
5316 tcp_replace_ts_recent(tp, TCP_SKB_CB(skb)->seq);
5317
5318 /* step 3: check security and precedence [ignored] */ 5316 /* step 3: check security and precedence [ignored] */
5319 5317
5320 /* step 4: Check for a SYN 5318 /* step 4: Check for a SYN
@@ -5549,6 +5547,11 @@ step5:
5549 if (th->ack && tcp_ack(sk, skb, FLAG_SLOWPATH) < 0) 5547 if (th->ack && tcp_ack(sk, skb, FLAG_SLOWPATH) < 0)
5550 goto discard; 5548 goto discard;
5551 5549
5550 /* ts_recent update must be made after we are sure that the packet
5551 * is in window.
5552 */
5553 tcp_replace_ts_recent(tp, TCP_SKB_CB(skb)->seq);
5554
5552 tcp_rcv_rtt_measure_ts(sk, skb); 5555 tcp_rcv_rtt_measure_ts(sk, skb);
5553 5556
5554 /* Process urgent data. */ 5557 /* Process urgent data. */
@@ -5646,6 +5649,7 @@ static bool tcp_rcv_fastopen_synack(struct sock *sk, struct sk_buff *synack,
5646 tcp_rearm_rto(sk); 5649 tcp_rearm_rto(sk);
5647 return true; 5650 return true;
5648 } 5651 }
5652 tp->syn_data_acked = tp->syn_data;
5649 return false; 5653 return false;
5650} 5654}
5651 5655
@@ -5963,7 +5967,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
5963 5967
5964 req = tp->fastopen_rsk; 5968 req = tp->fastopen_rsk;
5965 if (req != NULL) { 5969 if (req != NULL) {
5966 BUG_ON(sk->sk_state != TCP_SYN_RECV && 5970 WARN_ON_ONCE(sk->sk_state != TCP_SYN_RECV &&
5967 sk->sk_state != TCP_FIN_WAIT1); 5971 sk->sk_state != TCP_FIN_WAIT1);
5968 5972
5969 if (tcp_check_req(sk, skb, req, NULL, true) == NULL) 5973 if (tcp_check_req(sk, skb, req, NULL, true) == NULL)
@@ -6052,7 +6056,15 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
6052 * ACK we have received, this would have acknowledged 6056 * ACK we have received, this would have acknowledged
6053 * our SYNACK so stop the SYNACK timer. 6057 * our SYNACK so stop the SYNACK timer.
6054 */ 6058 */
6055 if (acceptable && req != NULL) { 6059 if (req != NULL) {
6060 /* Return RST if ack_seq is invalid.
6061 * Note that RFC793 only says to generate a
6062 * DUPACK for it but for TCP Fast Open it seems
6063 * better to treat this case like TCP_SYN_RECV
6064 * above.
6065 */
6066 if (!acceptable)
6067 return 1;
6056 /* We no longer need the request sock. */ 6068 /* We no longer need the request sock. */
6057 reqsk_fastopen_remove(sk, req, false); 6069 reqsk_fastopen_remove(sk, req, false);
6058 tcp_rearm_rto(sk); 6070 tcp_rearm_rto(sk);
@@ -6118,6 +6130,11 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
6118 } else 6130 } else
6119 goto discard; 6131 goto discard;
6120 6132
6133 /* ts_recent update must be made after we are sure that the packet
6134 * is in window.
6135 */
6136 tcp_replace_ts_recent(tp, TCP_SKB_CB(skb)->seq);
6137
6121 /* step 6: check the URG bit */ 6138 /* step 6: check the URG bit */
6122 tcp_urg(sk, skb, th); 6139 tcp_urg(sk, skb, th);
6123 6140
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index ef998b008a5..0c4a6435560 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1461,6 +1461,7 @@ static int tcp_v4_conn_req_fastopen(struct sock *sk,
1461 skb_set_owner_r(skb, child); 1461 skb_set_owner_r(skb, child);
1462 __skb_queue_tail(&child->sk_receive_queue, skb); 1462 __skb_queue_tail(&child->sk_receive_queue, skb);
1463 tp->rcv_nxt = TCP_SKB_CB(skb)->end_seq; 1463 tp->rcv_nxt = TCP_SKB_CB(skb)->end_seq;
1464 tp->syn_data_acked = 1;
1464 } 1465 }
1465 sk->sk_data_ready(sk, 0); 1466 sk->sk_data_ready(sk, 0);
1466 bh_unlock_sock(child); 1467 bh_unlock_sock(child);
diff --git a/net/ipv4/tcp_metrics.c b/net/ipv4/tcp_metrics.c
index 4c752a6e0bc..f696d7c2e9f 100644
--- a/net/ipv4/tcp_metrics.c
+++ b/net/ipv4/tcp_metrics.c
@@ -1,7 +1,6 @@
1#include <linux/rcupdate.h> 1#include <linux/rcupdate.h>
2#include <linux/spinlock.h> 2#include <linux/spinlock.h>
3#include <linux/jiffies.h> 3#include <linux/jiffies.h>
4#include <linux/bootmem.h>
5#include <linux/module.h> 4#include <linux/module.h>
6#include <linux/cache.h> 5#include <linux/cache.h>
7#include <linux/slab.h> 6#include <linux/slab.h>
@@ -9,6 +8,7 @@
9#include <linux/tcp.h> 8#include <linux/tcp.h>
10#include <linux/hash.h> 9#include <linux/hash.h>
11#include <linux/tcp_metrics.h> 10#include <linux/tcp_metrics.h>
11#include <linux/vmalloc.h>
12 12
13#include <net/inet_connection_sock.h> 13#include <net/inet_connection_sock.h>
14#include <net/net_namespace.h> 14#include <net/net_namespace.h>
@@ -864,7 +864,7 @@ static int parse_nl_addr(struct genl_info *info, struct inetpeer_addr *addr,
864 } 864 }
865 a = info->attrs[TCP_METRICS_ATTR_ADDR_IPV6]; 865 a = info->attrs[TCP_METRICS_ATTR_ADDR_IPV6];
866 if (a) { 866 if (a) {
867 if (nla_len(a) != sizeof(sizeof(struct in6_addr))) 867 if (nla_len(a) != sizeof(struct in6_addr))
868 return -EINVAL; 868 return -EINVAL;
869 addr->family = AF_INET6; 869 addr->family = AF_INET6;
870 memcpy(addr->addr.a6, nla_data(a), sizeof(addr->addr.a6)); 870 memcpy(addr->addr.a6, nla_data(a), sizeof(addr->addr.a6));
@@ -1034,7 +1034,10 @@ static int __net_init tcp_net_metrics_init(struct net *net)
1034 net->ipv4.tcp_metrics_hash_log = order_base_2(slots); 1034 net->ipv4.tcp_metrics_hash_log = order_base_2(slots);
1035 size = sizeof(struct tcpm_hash_bucket) << net->ipv4.tcp_metrics_hash_log; 1035 size = sizeof(struct tcpm_hash_bucket) << net->ipv4.tcp_metrics_hash_log;
1036 1036
1037 net->ipv4.tcp_metrics_hash = kzalloc(size, GFP_KERNEL); 1037 net->ipv4.tcp_metrics_hash = kzalloc(size, GFP_KERNEL | __GFP_NOWARN);
1038 if (!net->ipv4.tcp_metrics_hash)
1039 net->ipv4.tcp_metrics_hash = vzalloc(size);
1040
1038 if (!net->ipv4.tcp_metrics_hash) 1041 if (!net->ipv4.tcp_metrics_hash)
1039 return -ENOMEM; 1042 return -ENOMEM;
1040 1043
@@ -1055,7 +1058,10 @@ static void __net_exit tcp_net_metrics_exit(struct net *net)
1055 tm = next; 1058 tm = next;
1056 } 1059 }
1057 } 1060 }
1058 kfree(net->ipv4.tcp_metrics_hash); 1061 if (is_vmalloc_addr(net->ipv4.tcp_metrics_hash))
1062 vfree(net->ipv4.tcp_metrics_hash);
1063 else
1064 kfree(net->ipv4.tcp_metrics_hash);
1059} 1065}
1060 1066
1061static __net_initdata struct pernet_operations tcp_net_metrics_ops = { 1067static __net_initdata struct pernet_operations tcp_net_metrics_ops = {
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
index 27536ba16c9..a7302d974f3 100644
--- a/net/ipv4/tcp_minisocks.c
+++ b/net/ipv4/tcp_minisocks.c
@@ -510,6 +510,7 @@ struct sock *tcp_create_openreq_child(struct sock *sk, struct request_sock *req,
510 newtp->rx_opt.mss_clamp = req->mss; 510 newtp->rx_opt.mss_clamp = req->mss;
511 TCP_ECN_openreq_child(newtp, req); 511 TCP_ECN_openreq_child(newtp, req);
512 newtp->fastopen_rsk = NULL; 512 newtp->fastopen_rsk = NULL;
513 newtp->syn_data_acked = 0;
513 514
514 TCP_INC_STATS_BH(sock_net(sk), TCP_MIB_PASSIVEOPENS); 515 TCP_INC_STATS_BH(sock_net(sk), TCP_MIB_PASSIVEOPENS);
515 } 516 }
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index cfe6ffe1c17..2798706cb06 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -1986,6 +1986,9 @@ static bool tcp_write_xmit(struct sock *sk, unsigned int mss_now, int nonagle,
1986 tso_segs = tcp_init_tso_segs(sk, skb, mss_now); 1986 tso_segs = tcp_init_tso_segs(sk, skb, mss_now);
1987 BUG_ON(!tso_segs); 1987 BUG_ON(!tso_segs);
1988 1988
1989 if (unlikely(tp->repair) && tp->repair_queue == TCP_SEND_QUEUE)
1990 goto repair; /* Skip network transmission */
1991
1989 cwnd_quota = tcp_cwnd_test(tp, skb); 1992 cwnd_quota = tcp_cwnd_test(tp, skb);
1990 if (!cwnd_quota) 1993 if (!cwnd_quota)
1991 break; 1994 break;
@@ -2026,6 +2029,7 @@ static bool tcp_write_xmit(struct sock *sk, unsigned int mss_now, int nonagle,
2026 if (unlikely(tcp_transmit_skb(sk, skb, 1, gfp))) 2029 if (unlikely(tcp_transmit_skb(sk, skb, 1, gfp)))
2027 break; 2030 break;
2028 2031
2032repair:
2029 /* Advance the send_head. This one is sent out. 2033 /* Advance the send_head. This one is sent out.
2030 * This call will increment packets_out. 2034 * This call will increment packets_out.
2031 */ 2035 */
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
index fc04711e80c..d47c1b4421a 100644
--- a/net/ipv4/tcp_timer.c
+++ b/net/ipv4/tcp_timer.c
@@ -347,8 +347,8 @@ void tcp_retransmit_timer(struct sock *sk)
347 return; 347 return;
348 } 348 }
349 if (tp->fastopen_rsk) { 349 if (tp->fastopen_rsk) {
350 BUG_ON(sk->sk_state != TCP_SYN_RECV && 350 WARN_ON_ONCE(sk->sk_state != TCP_SYN_RECV &&
351 sk->sk_state != TCP_FIN_WAIT1); 351 sk->sk_state != TCP_FIN_WAIT1);
352 tcp_fastopen_synack_timer(sk); 352 tcp_fastopen_synack_timer(sk);
353 /* Before we receive ACK to our SYN-ACK don't retransmit 353 /* Before we receive ACK to our SYN-ACK don't retransmit
354 * anything else (e.g., data or FIN segments). 354 * anything else (e.g., data or FIN segments).
diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
index 05c5ab8d983..3be0ac2c192 100644
--- a/net/ipv4/xfrm4_policy.c
+++ b/net/ipv4/xfrm4_policy.c
@@ -279,19 +279,8 @@ static void __exit xfrm4_policy_fini(void)
279 xfrm_policy_unregister_afinfo(&xfrm4_policy_afinfo); 279 xfrm_policy_unregister_afinfo(&xfrm4_policy_afinfo);
280} 280}
281 281
282void __init xfrm4_init(int rt_max_size) 282void __init xfrm4_init(void)
283{ 283{
284 /*
285 * Select a default value for the gc_thresh based on the main route
286 * table hash size. It seems to me the worst case scenario is when
287 * we have ipsec operating in transport mode, in which we create a
288 * dst_entry per socket. The xfrm gc algorithm starts trying to remove
289 * entries at gc_thresh, and prevents new allocations as 2*gc_thresh
290 * so lets set an initial xfrm gc_thresh value at the rt_max_size/2.
291 * That will let us store an ipsec connection per route table entry,
292 * and start cleaning when were 1/2 full
293 */
294 xfrm4_dst_ops.gc_thresh = rt_max_size/2;
295 dst_entries_init(&xfrm4_dst_ops); 284 dst_entries_init(&xfrm4_dst_ops);
296 285
297 xfrm4_state_init(); 286 xfrm4_state_init();
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index d7c56f8a5b4..0424e4e2741 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -3064,14 +3064,15 @@ static struct inet6_ifaddr *if6_get_first(struct seq_file *seq, loff_t pos)
3064 struct hlist_node *n; 3064 struct hlist_node *n;
3065 hlist_for_each_entry_rcu_bh(ifa, n, &inet6_addr_lst[state->bucket], 3065 hlist_for_each_entry_rcu_bh(ifa, n, &inet6_addr_lst[state->bucket],
3066 addr_lst) { 3066 addr_lst) {
3067 if (!net_eq(dev_net(ifa->idev->dev), net))
3068 continue;
3067 /* sync with offset */ 3069 /* sync with offset */
3068 if (p < state->offset) { 3070 if (p < state->offset) {
3069 p++; 3071 p++;
3070 continue; 3072 continue;
3071 } 3073 }
3072 state->offset++; 3074 state->offset++;
3073 if (net_eq(dev_net(ifa->idev->dev), net)) 3075 return ifa;
3074 return ifa;
3075 } 3076 }
3076 3077
3077 /* prepare for next bucket */ 3078 /* prepare for next bucket */
@@ -3089,18 +3090,20 @@ static struct inet6_ifaddr *if6_get_next(struct seq_file *seq,
3089 struct hlist_node *n = &ifa->addr_lst; 3090 struct hlist_node *n = &ifa->addr_lst;
3090 3091
3091 hlist_for_each_entry_continue_rcu_bh(ifa, n, addr_lst) { 3092 hlist_for_each_entry_continue_rcu_bh(ifa, n, addr_lst) {
3093 if (!net_eq(dev_net(ifa->idev->dev), net))
3094 continue;
3092 state->offset++; 3095 state->offset++;
3093 if (net_eq(dev_net(ifa->idev->dev), net)) 3096 return ifa;
3094 return ifa;
3095 } 3097 }
3096 3098
3097 while (++state->bucket < IN6_ADDR_HSIZE) { 3099 while (++state->bucket < IN6_ADDR_HSIZE) {
3098 state->offset = 0; 3100 state->offset = 0;
3099 hlist_for_each_entry_rcu_bh(ifa, n, 3101 hlist_for_each_entry_rcu_bh(ifa, n,
3100 &inet6_addr_lst[state->bucket], addr_lst) { 3102 &inet6_addr_lst[state->bucket], addr_lst) {
3103 if (!net_eq(dev_net(ifa->idev->dev), net))
3104 continue;
3101 state->offset++; 3105 state->offset++;
3102 if (net_eq(dev_net(ifa->idev->dev), net)) 3106 return ifa;
3103 return ifa;
3104 } 3107 }
3105 } 3108 }
3106 3109
diff --git a/net/ipv6/inet6_connection_sock.c b/net/ipv6/inet6_connection_sock.c
index c4f934176ca..30647857a37 100644
--- a/net/ipv6/inet6_connection_sock.c
+++ b/net/ipv6/inet6_connection_sock.c
@@ -252,6 +252,7 @@ struct dst_entry *inet6_csk_update_pmtu(struct sock *sk, u32 mtu)
252 return NULL; 252 return NULL;
253 dst->ops->update_pmtu(dst, sk, NULL, mtu); 253 dst->ops->update_pmtu(dst, sk, NULL, mtu);
254 254
255 return inet6_csk_route_socket(sk, &fl6); 255 dst = inet6_csk_route_socket(sk, &fl6);
256 return IS_ERR(dst) ? NULL : dst;
256} 257}
257EXPORT_SYMBOL_GPL(inet6_csk_update_pmtu); 258EXPORT_SYMBOL_GPL(inet6_csk_update_pmtu);
diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index 0185679c5f5..d5cb3c4e66f 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -1633,9 +1633,9 @@ static size_t ip6gre_get_size(const struct net_device *dev)
1633 /* IFLA_GRE_OKEY */ 1633 /* IFLA_GRE_OKEY */
1634 nla_total_size(4) + 1634 nla_total_size(4) +
1635 /* IFLA_GRE_LOCAL */ 1635 /* IFLA_GRE_LOCAL */
1636 nla_total_size(4) + 1636 nla_total_size(sizeof(struct in6_addr)) +
1637 /* IFLA_GRE_REMOTE */ 1637 /* IFLA_GRE_REMOTE */
1638 nla_total_size(4) + 1638 nla_total_size(sizeof(struct in6_addr)) +
1639 /* IFLA_GRE_TTL */ 1639 /* IFLA_GRE_TTL */
1640 nla_total_size(1) + 1640 nla_total_size(1) +
1641 /* IFLA_GRE_TOS */ 1641 /* IFLA_GRE_TOS */
@@ -1659,8 +1659,8 @@ static int ip6gre_fill_info(struct sk_buff *skb, const struct net_device *dev)
1659 nla_put_be16(skb, IFLA_GRE_OFLAGS, p->o_flags) || 1659 nla_put_be16(skb, IFLA_GRE_OFLAGS, p->o_flags) ||
1660 nla_put_be32(skb, IFLA_GRE_IKEY, p->i_key) || 1660 nla_put_be32(skb, IFLA_GRE_IKEY, p->i_key) ||
1661 nla_put_be32(skb, IFLA_GRE_OKEY, p->o_key) || 1661 nla_put_be32(skb, IFLA_GRE_OKEY, p->o_key) ||
1662 nla_put(skb, IFLA_GRE_LOCAL, sizeof(struct in6_addr), &p->raddr) || 1662 nla_put(skb, IFLA_GRE_LOCAL, sizeof(struct in6_addr), &p->laddr) ||
1663 nla_put(skb, IFLA_GRE_REMOTE, sizeof(struct in6_addr), &p->laddr) || 1663 nla_put(skb, IFLA_GRE_REMOTE, sizeof(struct in6_addr), &p->raddr) ||
1664 nla_put_u8(skb, IFLA_GRE_TTL, p->hop_limit) || 1664 nla_put_u8(skb, IFLA_GRE_TTL, p->hop_limit) ||
1665 /*nla_put_u8(skb, IFLA_GRE_TOS, t->priority) ||*/ 1665 /*nla_put_u8(skb, IFLA_GRE_TOS, t->priority) ||*/
1666 nla_put_u8(skb, IFLA_GRE_ENCAP_LIMIT, p->encap_limit) || 1666 nla_put_u8(skb, IFLA_GRE_ENCAP_LIMIT, p->encap_limit) ||
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index ba6d13d1f1e..e02faed6d17 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -827,6 +827,7 @@ pref_skip_coa:
827 if (val < 0 || val > 255) 827 if (val < 0 || val > 255)
828 goto e_inval; 828 goto e_inval;
829 np->min_hopcount = val; 829 np->min_hopcount = val;
830 retv = 0;
830 break; 831 break;
831 case IPV6_DONTFRAG: 832 case IPV6_DONTFRAG:
832 np->dontfrag = valbool; 833 np->dontfrag = valbool;
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index ff36194a71a..2edce30ef73 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -535,7 +535,7 @@ static void ndisc_send_unsol_na(struct net_device *dev)
535{ 535{
536 struct inet6_dev *idev; 536 struct inet6_dev *idev;
537 struct inet6_ifaddr *ifa; 537 struct inet6_ifaddr *ifa;
538 struct in6_addr mcaddr; 538 struct in6_addr mcaddr = IN6ADDR_LINKLOCAL_ALLNODES_INIT;
539 539
540 idev = in6_dev_get(dev); 540 idev = in6_dev_get(dev);
541 if (!idev) 541 if (!idev)
@@ -543,7 +543,6 @@ static void ndisc_send_unsol_na(struct net_device *dev)
543 543
544 read_lock_bh(&idev->lock); 544 read_lock_bh(&idev->lock);
545 list_for_each_entry(ifa, &idev->addr_list, if_list) { 545 list_for_each_entry(ifa, &idev->addr_list, if_list) {
546 addrconf_addr_solict_mult(&ifa->addr, &mcaddr);
547 ndisc_send_na(dev, NULL, &mcaddr, &ifa->addr, 546 ndisc_send_na(dev, NULL, &mcaddr, &ifa->addr,
548 /*router=*/ !!idev->cnf.forwarding, 547 /*router=*/ !!idev->cnf.forwarding,
549 /*solicited=*/ false, /*override=*/ true, 548 /*solicited=*/ false, /*override=*/ true,
diff --git a/net/ipv6/netfilter/ip6table_nat.c b/net/ipv6/netfilter/ip6table_nat.c
index e418bd6350a..d57dab17a18 100644
--- a/net/ipv6/netfilter/ip6table_nat.c
+++ b/net/ipv6/netfilter/ip6table_nat.c
@@ -186,7 +186,8 @@ nf_nat_ipv6_out(unsigned int hooknum,
186 186
187 if (!nf_inet_addr_cmp(&ct->tuplehash[dir].tuple.src.u3, 187 if (!nf_inet_addr_cmp(&ct->tuplehash[dir].tuple.src.u3,
188 &ct->tuplehash[!dir].tuple.dst.u3) || 188 &ct->tuplehash[!dir].tuple.dst.u3) ||
189 (ct->tuplehash[dir].tuple.src.u.all != 189 (ct->tuplehash[dir].tuple.dst.protonum != IPPROTO_ICMPV6 &&
190 ct->tuplehash[dir].tuple.src.u.all !=
190 ct->tuplehash[!dir].tuple.dst.u.all)) 191 ct->tuplehash[!dir].tuple.dst.u.all))
191 if (nf_xfrm_me_harder(skb, AF_INET6) < 0) 192 if (nf_xfrm_me_harder(skb, AF_INET6) < 0)
192 ret = NF_DROP; 193 ret = NF_DROP;
@@ -222,6 +223,7 @@ nf_nat_ipv6_local_fn(unsigned int hooknum,
222 } 223 }
223#ifdef CONFIG_XFRM 224#ifdef CONFIG_XFRM
224 else if (!(IP6CB(skb)->flags & IP6SKB_XFRM_TRANSFORMED) && 225 else if (!(IP6CB(skb)->flags & IP6SKB_XFRM_TRANSFORMED) &&
226 ct->tuplehash[dir].tuple.dst.protonum != IPPROTO_ICMPV6 &&
225 ct->tuplehash[dir].tuple.dst.u.all != 227 ct->tuplehash[dir].tuple.dst.u.all !=
226 ct->tuplehash[!dir].tuple.src.u.all) 228 ct->tuplehash[!dir].tuple.src.u.all)
227 if (nf_xfrm_me_harder(skb, AF_INET6)) 229 if (nf_xfrm_me_harder(skb, AF_INET6))
diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
index 18bd9bbbd1c..22c8ea95118 100644
--- a/net/ipv6/netfilter/nf_conntrack_reasm.c
+++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
@@ -85,7 +85,7 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
85 { } 85 { }
86}; 86};
87 87
88static int __net_init nf_ct_frag6_sysctl_register(struct net *net) 88static int nf_ct_frag6_sysctl_register(struct net *net)
89{ 89{
90 struct ctl_table *table; 90 struct ctl_table *table;
91 struct ctl_table_header *hdr; 91 struct ctl_table_header *hdr;
@@ -127,7 +127,7 @@ static void __net_exit nf_ct_frags6_sysctl_unregister(struct net *net)
127} 127}
128 128
129#else 129#else
130static int __net_init nf_ct_frag6_sysctl_register(struct net *net) 130static int nf_ct_frag6_sysctl_register(struct net *net)
131{ 131{
132 return 0; 132 return 0;
133} 133}
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 7c7e963260e..b1e6cf0b95f 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -219,7 +219,7 @@ static struct dst_ops ip6_dst_blackhole_ops = {
219}; 219};
220 220
221static const u32 ip6_template_metrics[RTAX_MAX] = { 221static const u32 ip6_template_metrics[RTAX_MAX] = {
222 [RTAX_HOPLIMIT - 1] = 255, 222 [RTAX_HOPLIMIT - 1] = 0,
223}; 223};
224 224
225static const struct rt6_info ip6_null_entry_template = { 225static const struct rt6_info ip6_null_entry_template = {
@@ -1232,7 +1232,7 @@ struct dst_entry *icmp6_dst_alloc(struct net_device *dev,
1232 rt->rt6i_dst.addr = fl6->daddr; 1232 rt->rt6i_dst.addr = fl6->daddr;
1233 rt->rt6i_dst.plen = 128; 1233 rt->rt6i_dst.plen = 128;
1234 rt->rt6i_idev = idev; 1234 rt->rt6i_idev = idev;
1235 dst_metric_set(&rt->dst, RTAX_HOPLIMIT, 255); 1235 dst_metric_set(&rt->dst, RTAX_HOPLIMIT, 0);
1236 1236
1237 spin_lock_bh(&icmp6_dst_lock); 1237 spin_lock_bh(&icmp6_dst_lock);
1238 rt->dst.next = icmp6_dst_gc_list; 1238 rt->dst.next = icmp6_dst_gc_list;
diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
index 95a3a7a336b..496ce2cebcd 100644
--- a/net/irda/ircomm/ircomm_tty.c
+++ b/net/irda/ircomm/ircomm_tty.c
@@ -421,6 +421,8 @@ static int ircomm_tty_install(struct tty_driver *driver, struct tty_struct *tty)
421 hashbin_insert(ircomm_tty, (irda_queue_t *) self, line, NULL); 421 hashbin_insert(ircomm_tty, (irda_queue_t *) self, line, NULL);
422 } 422 }
423 423
424 tty->driver_data = self;
425
424 return tty_port_install(&self->port, driver, tty); 426 return tty_port_install(&self->port, driver, tty);
425} 427}
426 428
diff --git a/net/l2tp/l2tp_eth.c b/net/l2tp/l2tp_eth.c
index 37b8b8ba31f..76125c57ee6 100644
--- a/net/l2tp/l2tp_eth.c
+++ b/net/l2tp/l2tp_eth.c
@@ -291,6 +291,7 @@ static int l2tp_eth_create(struct net *net, u32 tunnel_id, u32 session_id, u32 p
291 291
292out_del_dev: 292out_del_dev:
293 free_netdev(dev); 293 free_netdev(dev);
294 spriv->dev = NULL;
294out_del_session: 295out_del_session:
295 l2tp_session_delete(session); 296 l2tp_session_delete(session);
296out: 297out:
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 05f3a313db8..7371f676cf4 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -2594,6 +2594,9 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
2594 else 2594 else
2595 local->probe_req_reg--; 2595 local->probe_req_reg--;
2596 2596
2597 if (!local->open_count)
2598 break;
2599
2597 ieee80211_queue_work(&local->hw, &local->reconfig_filter); 2600 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
2598 break; 2601 break;
2599 default: 2602 default:
diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c
index 5f3620f0bc0..c21e33d1abd 100644
--- a/net/mac80211/ibss.c
+++ b/net/mac80211/ibss.c
@@ -1108,7 +1108,7 @@ int ieee80211_ibss_join(struct ieee80211_sub_if_data *sdata,
1108 sdata->u.ibss.state = IEEE80211_IBSS_MLME_SEARCH; 1108 sdata->u.ibss.state = IEEE80211_IBSS_MLME_SEARCH;
1109 sdata->u.ibss.ibss_join_req = jiffies; 1109 sdata->u.ibss.ibss_join_req = jiffies;
1110 1110
1111 memcpy(sdata->u.ibss.ssid, params->ssid, IEEE80211_MAX_SSID_LEN); 1111 memcpy(sdata->u.ibss.ssid, params->ssid, params->ssid_len);
1112 sdata->u.ibss.ssid_len = params->ssid_len; 1112 sdata->u.ibss.ssid_len = params->ssid_len;
1113 1113
1114 mutex_unlock(&sdata->u.ibss.mtx); 1114 mutex_unlock(&sdata->u.ibss.mtx);
@@ -1151,10 +1151,6 @@ int ieee80211_ibss_leave(struct ieee80211_sub_if_data *sdata)
1151 1151
1152 mutex_lock(&sdata->u.ibss.mtx); 1152 mutex_lock(&sdata->u.ibss.mtx);
1153 1153
1154 sdata->u.ibss.state = IEEE80211_IBSS_MLME_SEARCH;
1155 memset(sdata->u.ibss.bssid, 0, ETH_ALEN);
1156 sdata->u.ibss.ssid_len = 0;
1157
1158 active_ibss = ieee80211_sta_active_ibss(sdata); 1154 active_ibss = ieee80211_sta_active_ibss(sdata);
1159 1155
1160 if (!active_ibss && !is_zero_ether_addr(ifibss->bssid)) { 1156 if (!active_ibss && !is_zero_ether_addr(ifibss->bssid)) {
@@ -1175,6 +1171,10 @@ int ieee80211_ibss_leave(struct ieee80211_sub_if_data *sdata)
1175 } 1171 }
1176 } 1172 }
1177 1173
1174 ifibss->state = IEEE80211_IBSS_MLME_SEARCH;
1175 memset(ifibss->bssid, 0, ETH_ALEN);
1176 ifibss->ssid_len = 0;
1177
1178 sta_info_flush(sdata->local, sdata); 1178 sta_info_flush(sdata->local, sdata);
1179 1179
1180 spin_lock_bh(&ifibss->incomplete_lock); 1180 spin_lock_bh(&ifibss->incomplete_lock);
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 8c804550465..156e5835e37 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -1314,6 +1314,8 @@ netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb,
1314 struct net_device *dev); 1314 struct net_device *dev);
1315netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb, 1315netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
1316 struct net_device *dev); 1316 struct net_device *dev);
1317void ieee80211_purge_tx_queue(struct ieee80211_hw *hw,
1318 struct sk_buff_head *skbs);
1317 1319
1318/* HT */ 1320/* HT */
1319void ieee80211_apply_htcap_overrides(struct ieee80211_sub_if_data *sdata, 1321void ieee80211_apply_htcap_overrides(struct ieee80211_sub_if_data *sdata,
diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index 6f8a73c64fb..7de7717ad67 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -853,7 +853,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
853 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 853 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
854 if (info->control.vif == &sdata->vif) { 854 if (info->control.vif == &sdata->vif) {
855 __skb_unlink(skb, &local->pending[i]); 855 __skb_unlink(skb, &local->pending[i]);
856 dev_kfree_skb_irq(skb); 856 ieee80211_free_txskb(&local->hw, skb);
857 } 857 }
858 } 858 }
859 } 859 }
diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index c80c4490351..f57f597972f 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -871,8 +871,10 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
871 local->hw.wiphy->cipher_suites, 871 local->hw.wiphy->cipher_suites,
872 sizeof(u32) * local->hw.wiphy->n_cipher_suites, 872 sizeof(u32) * local->hw.wiphy->n_cipher_suites,
873 GFP_KERNEL); 873 GFP_KERNEL);
874 if (!suites) 874 if (!suites) {
875 return -ENOMEM; 875 result = -ENOMEM;
876 goto fail_wiphy_register;
877 }
876 for (r = 0; r < local->hw.wiphy->n_cipher_suites; r++) { 878 for (r = 0; r < local->hw.wiphy->n_cipher_suites; r++) {
877 u32 suite = local->hw.wiphy->cipher_suites[r]; 879 u32 suite = local->hw.wiphy->cipher_suites[r];
878 if (suite == WLAN_CIPHER_SUITE_WEP40 || 880 if (suite == WLAN_CIPHER_SUITE_WEP40 ||
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index e714ed8bb19..1b7eed252fe 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -3099,22 +3099,32 @@ static int ieee80211_prep_channel(struct ieee80211_sub_if_data *sdata,
3099 ht_cfreq, ht_oper->primary_chan, 3099 ht_cfreq, ht_oper->primary_chan,
3100 cbss->channel->band); 3100 cbss->channel->band);
3101 ht_oper = NULL; 3101 ht_oper = NULL;
3102 } else {
3103 channel_type = NL80211_CHAN_HT20;
3102 } 3104 }
3103 } 3105 }
3104 3106
3105 if (ht_oper) { 3107 if (ht_oper && sband->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40) {
3106 channel_type = NL80211_CHAN_HT20; 3108 /*
3109 * cfg80211 already verified that the channel itself can
3110 * be used, but it didn't check that we can do the right
3111 * HT type, so do that here as well. If HT40 isn't allowed
3112 * on this channel, disable 40 MHz operation.
3113 */
3107 3114
3108 if (sband->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40) { 3115 switch (ht_oper->ht_param & IEEE80211_HT_PARAM_CHA_SEC_OFFSET) {
3109 switch (ht_oper->ht_param & 3116 case IEEE80211_HT_PARAM_CHA_SEC_ABOVE:
3110 IEEE80211_HT_PARAM_CHA_SEC_OFFSET) { 3117 if (cbss->channel->flags & IEEE80211_CHAN_NO_HT40PLUS)
3111 case IEEE80211_HT_PARAM_CHA_SEC_ABOVE: 3118 ifmgd->flags |= IEEE80211_STA_DISABLE_40MHZ;
3119 else
3112 channel_type = NL80211_CHAN_HT40PLUS; 3120 channel_type = NL80211_CHAN_HT40PLUS;
3113 break; 3121 break;
3114 case IEEE80211_HT_PARAM_CHA_SEC_BELOW: 3122 case IEEE80211_HT_PARAM_CHA_SEC_BELOW:
3123 if (cbss->channel->flags & IEEE80211_CHAN_NO_HT40MINUS)
3124 ifmgd->flags |= IEEE80211_STA_DISABLE_40MHZ;
3125 else
3115 channel_type = NL80211_CHAN_HT40MINUS; 3126 channel_type = NL80211_CHAN_HT40MINUS;
3116 break; 3127 break;
3117 }
3118 } 3128 }
3119 } 3129 }
3120 3130
@@ -3549,6 +3559,7 @@ int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata,
3549{ 3559{
3550 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 3560 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
3551 u8 frame_buf[IEEE80211_DEAUTH_FRAME_LEN]; 3561 u8 frame_buf[IEEE80211_DEAUTH_FRAME_LEN];
3562 bool tx = !req->local_state_change;
3552 3563
3553 mutex_lock(&ifmgd->mtx); 3564 mutex_lock(&ifmgd->mtx);
3554 3565
@@ -3565,12 +3576,12 @@ int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata,
3565 if (ifmgd->associated && 3576 if (ifmgd->associated &&
3566 ether_addr_equal(ifmgd->associated->bssid, req->bssid)) { 3577 ether_addr_equal(ifmgd->associated->bssid, req->bssid)) {
3567 ieee80211_set_disassoc(sdata, IEEE80211_STYPE_DEAUTH, 3578 ieee80211_set_disassoc(sdata, IEEE80211_STYPE_DEAUTH,
3568 req->reason_code, true, frame_buf); 3579 req->reason_code, tx, frame_buf);
3569 } else { 3580 } else {
3570 drv_mgd_prepare_tx(sdata->local, sdata); 3581 drv_mgd_prepare_tx(sdata->local, sdata);
3571 ieee80211_send_deauth_disassoc(sdata, req->bssid, 3582 ieee80211_send_deauth_disassoc(sdata, req->bssid,
3572 IEEE80211_STYPE_DEAUTH, 3583 IEEE80211_STYPE_DEAUTH,
3573 req->reason_code, true, 3584 req->reason_code, tx,
3574 frame_buf); 3585 frame_buf);
3575 } 3586 }
3576 3587
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index 61c621e9273..00ade7feb2e 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -531,6 +531,11 @@ ieee80211_rx_mesh_check(struct ieee80211_rx_data *rx)
531 531
532 if (ieee80211_is_action(hdr->frame_control)) { 532 if (ieee80211_is_action(hdr->frame_control)) {
533 u8 category; 533 u8 category;
534
535 /* make sure category field is present */
536 if (rx->skb->len < IEEE80211_MIN_ACTION_SIZE)
537 return RX_DROP_MONITOR;
538
534 mgmt = (struct ieee80211_mgmt *)hdr; 539 mgmt = (struct ieee80211_mgmt *)hdr;
535 category = mgmt->u.action.category; 540 category = mgmt->u.action.category;
536 if (category != WLAN_CATEGORY_MESH_ACTION && 541 if (category != WLAN_CATEGORY_MESH_ACTION &&
@@ -883,14 +888,16 @@ ieee80211_rx_h_check(struct ieee80211_rx_data *rx)
883 */ 888 */
884 if (rx->sta && rx->sdata->vif.type == NL80211_IFTYPE_STATION && 889 if (rx->sta && rx->sdata->vif.type == NL80211_IFTYPE_STATION &&
885 ieee80211_is_data_present(hdr->frame_control)) { 890 ieee80211_is_data_present(hdr->frame_control)) {
886 u16 ethertype; 891 unsigned int hdrlen;
887 u8 *payload; 892 __be16 ethertype;
888 893
889 payload = rx->skb->data + 894 hdrlen = ieee80211_hdrlen(hdr->frame_control);
890 ieee80211_hdrlen(hdr->frame_control); 895
891 ethertype = (payload[6] << 8) | payload[7]; 896 if (rx->skb->len < hdrlen + 8)
892 if (cpu_to_be16(ethertype) == 897 return RX_DROP_MONITOR;
893 rx->sdata->control_port_protocol) 898
899 skb_copy_bits(rx->skb, hdrlen + 6, &ethertype, 2);
900 if (ethertype == rx->sdata->control_port_protocol)
894 return RX_CONTINUE; 901 return RX_CONTINUE;
895 } 902 }
896 903
@@ -1462,11 +1469,14 @@ ieee80211_rx_h_defragment(struct ieee80211_rx_data *rx)
1462 1469
1463 hdr = (struct ieee80211_hdr *)rx->skb->data; 1470 hdr = (struct ieee80211_hdr *)rx->skb->data;
1464 fc = hdr->frame_control; 1471 fc = hdr->frame_control;
1472
1473 if (ieee80211_is_ctl(fc))
1474 return RX_CONTINUE;
1475
1465 sc = le16_to_cpu(hdr->seq_ctrl); 1476 sc = le16_to_cpu(hdr->seq_ctrl);
1466 frag = sc & IEEE80211_SCTL_FRAG; 1477 frag = sc & IEEE80211_SCTL_FRAG;
1467 1478
1468 if (likely((!ieee80211_has_morefrags(fc) && frag == 0) || 1479 if (likely((!ieee80211_has_morefrags(fc) && frag == 0) ||
1469 (rx->skb)->len < 24 ||
1470 is_multicast_ether_addr(hdr->addr1))) { 1480 is_multicast_ether_addr(hdr->addr1))) {
1471 /* not fragmented */ 1481 /* not fragmented */
1472 goto out; 1482 goto out;
@@ -1889,6 +1899,20 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx)
1889 1899
1890 hdr = (struct ieee80211_hdr *) skb->data; 1900 hdr = (struct ieee80211_hdr *) skb->data;
1891 hdrlen = ieee80211_hdrlen(hdr->frame_control); 1901 hdrlen = ieee80211_hdrlen(hdr->frame_control);
1902
1903 /* make sure fixed part of mesh header is there, also checks skb len */
1904 if (!pskb_may_pull(rx->skb, hdrlen + 6))
1905 return RX_DROP_MONITOR;
1906
1907 mesh_hdr = (struct ieee80211s_hdr *) (skb->data + hdrlen);
1908
1909 /* make sure full mesh header is there, also checks skb len */
1910 if (!pskb_may_pull(rx->skb,
1911 hdrlen + ieee80211_get_mesh_hdrlen(mesh_hdr)))
1912 return RX_DROP_MONITOR;
1913
1914 /* reload pointers */
1915 hdr = (struct ieee80211_hdr *) skb->data;
1892 mesh_hdr = (struct ieee80211s_hdr *) (skb->data + hdrlen); 1916 mesh_hdr = (struct ieee80211s_hdr *) (skb->data + hdrlen);
1893 1917
1894 /* frame is in RMC, don't forward */ 1918 /* frame is in RMC, don't forward */
@@ -1897,7 +1921,8 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx)
1897 mesh_rmc_check(hdr->addr3, mesh_hdr, rx->sdata)) 1921 mesh_rmc_check(hdr->addr3, mesh_hdr, rx->sdata))
1898 return RX_DROP_MONITOR; 1922 return RX_DROP_MONITOR;
1899 1923
1900 if (!ieee80211_is_data(hdr->frame_control)) 1924 if (!ieee80211_is_data(hdr->frame_control) ||
1925 !(status->rx_flags & IEEE80211_RX_RA_MATCH))
1901 return RX_CONTINUE; 1926 return RX_CONTINUE;
1902 1927
1903 if (!mesh_hdr->ttl) 1928 if (!mesh_hdr->ttl)
@@ -1911,9 +1936,12 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx)
1911 if (is_multicast_ether_addr(hdr->addr1)) { 1936 if (is_multicast_ether_addr(hdr->addr1)) {
1912 mpp_addr = hdr->addr3; 1937 mpp_addr = hdr->addr3;
1913 proxied_addr = mesh_hdr->eaddr1; 1938 proxied_addr = mesh_hdr->eaddr1;
1914 } else { 1939 } else if (mesh_hdr->flags & MESH_FLAGS_AE_A5_A6) {
1940 /* has_a4 already checked in ieee80211_rx_mesh_check */
1915 mpp_addr = hdr->addr4; 1941 mpp_addr = hdr->addr4;
1916 proxied_addr = mesh_hdr->eaddr2; 1942 proxied_addr = mesh_hdr->eaddr2;
1943 } else {
1944 return RX_DROP_MONITOR;
1917 } 1945 }
1918 1946
1919 rcu_read_lock(); 1947 rcu_read_lock();
@@ -1941,12 +1969,9 @@ ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx)
1941 } 1969 }
1942 skb_set_queue_mapping(skb, q); 1970 skb_set_queue_mapping(skb, q);
1943 1971
1944 if (!(status->rx_flags & IEEE80211_RX_RA_MATCH))
1945 goto out;
1946
1947 if (!--mesh_hdr->ttl) { 1972 if (!--mesh_hdr->ttl) {
1948 IEEE80211_IFSTA_MESH_CTR_INC(ifmsh, dropped_frames_ttl); 1973 IEEE80211_IFSTA_MESH_CTR_INC(ifmsh, dropped_frames_ttl);
1949 return RX_DROP_MONITOR; 1974 goto out;
1950 } 1975 }
1951 1976
1952 if (!ifmsh->mshcfg.dot11MeshForwarding) 1977 if (!ifmsh->mshcfg.dot11MeshForwarding)
@@ -2353,6 +2378,10 @@ ieee80211_rx_h_action(struct ieee80211_rx_data *rx)
2353 } 2378 }
2354 break; 2379 break;
2355 case WLAN_CATEGORY_SELF_PROTECTED: 2380 case WLAN_CATEGORY_SELF_PROTECTED:
2381 if (len < (IEEE80211_MIN_ACTION_SIZE +
2382 sizeof(mgmt->u.action.u.self_prot.action_code)))
2383 break;
2384
2356 switch (mgmt->u.action.u.self_prot.action_code) { 2385 switch (mgmt->u.action.u.self_prot.action_code) {
2357 case WLAN_SP_MESH_PEERING_OPEN: 2386 case WLAN_SP_MESH_PEERING_OPEN:
2358 case WLAN_SP_MESH_PEERING_CLOSE: 2387 case WLAN_SP_MESH_PEERING_CLOSE:
@@ -2371,6 +2400,10 @@ ieee80211_rx_h_action(struct ieee80211_rx_data *rx)
2371 } 2400 }
2372 break; 2401 break;
2373 case WLAN_CATEGORY_MESH_ACTION: 2402 case WLAN_CATEGORY_MESH_ACTION:
2403 if (len < (IEEE80211_MIN_ACTION_SIZE +
2404 sizeof(mgmt->u.action.u.mesh_action.action_code)))
2405 break;
2406
2374 if (!ieee80211_vif_is_mesh(&sdata->vif)) 2407 if (!ieee80211_vif_is_mesh(&sdata->vif))
2375 break; 2408 break;
2376 if (mesh_action_is_path_sel(mgmt) && 2409 if (mesh_action_is_path_sel(mgmt) &&
@@ -2913,10 +2946,15 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw,
2913 if (ieee80211_is_data(fc) || ieee80211_is_mgmt(fc)) 2946 if (ieee80211_is_data(fc) || ieee80211_is_mgmt(fc))
2914 local->dot11ReceivedFragmentCount++; 2947 local->dot11ReceivedFragmentCount++;
2915 2948
2916 if (ieee80211_is_mgmt(fc)) 2949 if (ieee80211_is_mgmt(fc)) {
2917 err = skb_linearize(skb); 2950 /* drop frame if too short for header */
2918 else 2951 if (skb->len < ieee80211_hdrlen(fc))
2952 err = -ENOBUFS;
2953 else
2954 err = skb_linearize(skb);
2955 } else {
2919 err = !pskb_may_pull(skb, ieee80211_hdrlen(fc)); 2956 err = !pskb_may_pull(skb, ieee80211_hdrlen(fc));
2957 }
2920 2958
2921 if (err) { 2959 if (err) {
2922 dev_kfree_skb(skb); 2960 dev_kfree_skb(skb);
diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c
index c4cdbde24fd..43e60b5a754 100644
--- a/net/mac80211/scan.c
+++ b/net/mac80211/scan.c
@@ -917,7 +917,7 @@ int ieee80211_request_sched_scan_start(struct ieee80211_sub_if_data *sdata,
917 struct cfg80211_sched_scan_request *req) 917 struct cfg80211_sched_scan_request *req)
918{ 918{
919 struct ieee80211_local *local = sdata->local; 919 struct ieee80211_local *local = sdata->local;
920 struct ieee80211_sched_scan_ies sched_scan_ies; 920 struct ieee80211_sched_scan_ies sched_scan_ies = {};
921 int ret, i; 921 int ret, i;
922 922
923 mutex_lock(&local->mtx); 923 mutex_lock(&local->mtx);
diff --git a/net/mac80211/sta_info.c b/net/mac80211/sta_info.c
index 797dd36a220..d2eb64e1235 100644
--- a/net/mac80211/sta_info.c
+++ b/net/mac80211/sta_info.c
@@ -117,8 +117,8 @@ static void free_sta_work(struct work_struct *wk)
117 117
118 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { 118 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
119 local->total_ps_buffered -= skb_queue_len(&sta->ps_tx_buf[ac]); 119 local->total_ps_buffered -= skb_queue_len(&sta->ps_tx_buf[ac]);
120 __skb_queue_purge(&sta->ps_tx_buf[ac]); 120 ieee80211_purge_tx_queue(&local->hw, &sta->ps_tx_buf[ac]);
121 __skb_queue_purge(&sta->tx_filtered[ac]); 121 ieee80211_purge_tx_queue(&local->hw, &sta->tx_filtered[ac]);
122 } 122 }
123 123
124#ifdef CONFIG_MAC80211_MESH 124#ifdef CONFIG_MAC80211_MESH
@@ -141,7 +141,7 @@ static void free_sta_work(struct work_struct *wk)
141 tid_tx = rcu_dereference_raw(sta->ampdu_mlme.tid_tx[i]); 141 tid_tx = rcu_dereference_raw(sta->ampdu_mlme.tid_tx[i]);
142 if (!tid_tx) 142 if (!tid_tx)
143 continue; 143 continue;
144 __skb_queue_purge(&tid_tx->pending); 144 ieee80211_purge_tx_queue(&local->hw, &tid_tx->pending);
145 kfree(tid_tx); 145 kfree(tid_tx);
146 } 146 }
147 147
@@ -650,7 +650,7 @@ static bool sta_info_cleanup_expire_buffered_ac(struct ieee80211_local *local,
650 */ 650 */
651 if (!skb) 651 if (!skb)
652 break; 652 break;
653 dev_kfree_skb(skb); 653 ieee80211_free_txskb(&local->hw, skb);
654 } 654 }
655 655
656 /* 656 /*
@@ -679,7 +679,7 @@ static bool sta_info_cleanup_expire_buffered_ac(struct ieee80211_local *local,
679 local->total_ps_buffered--; 679 local->total_ps_buffered--;
680 ps_dbg(sta->sdata, "Buffered frame expired (STA %pM)\n", 680 ps_dbg(sta->sdata, "Buffered frame expired (STA %pM)\n",
681 sta->sta.addr); 681 sta->sta.addr);
682 dev_kfree_skb(skb); 682 ieee80211_free_txskb(&local->hw, skb);
683 } 683 }
684 684
685 /* 685 /*
@@ -961,6 +961,7 @@ void ieee80211_sta_ps_deliver_wakeup(struct sta_info *sta)
961 struct ieee80211_local *local = sdata->local; 961 struct ieee80211_local *local = sdata->local;
962 struct sk_buff_head pending; 962 struct sk_buff_head pending;
963 int filtered = 0, buffered = 0, ac; 963 int filtered = 0, buffered = 0, ac;
964 unsigned long flags;
964 965
965 clear_sta_flag(sta, WLAN_STA_SP); 966 clear_sta_flag(sta, WLAN_STA_SP);
966 967
@@ -976,12 +977,16 @@ void ieee80211_sta_ps_deliver_wakeup(struct sta_info *sta)
976 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) { 977 for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
977 int count = skb_queue_len(&pending), tmp; 978 int count = skb_queue_len(&pending), tmp;
978 979
980 spin_lock_irqsave(&sta->tx_filtered[ac].lock, flags);
979 skb_queue_splice_tail_init(&sta->tx_filtered[ac], &pending); 981 skb_queue_splice_tail_init(&sta->tx_filtered[ac], &pending);
982 spin_unlock_irqrestore(&sta->tx_filtered[ac].lock, flags);
980 tmp = skb_queue_len(&pending); 983 tmp = skb_queue_len(&pending);
981 filtered += tmp - count; 984 filtered += tmp - count;
982 count = tmp; 985 count = tmp;
983 986
987 spin_lock_irqsave(&sta->ps_tx_buf[ac].lock, flags);
984 skb_queue_splice_tail_init(&sta->ps_tx_buf[ac], &pending); 988 skb_queue_splice_tail_init(&sta->ps_tx_buf[ac], &pending);
989 spin_unlock_irqrestore(&sta->ps_tx_buf[ac].lock, flags);
985 tmp = skb_queue_len(&pending); 990 tmp = skb_queue_len(&pending);
986 buffered += tmp - count; 991 buffered += tmp - count;
987 } 992 }
diff --git a/net/mac80211/status.c b/net/mac80211/status.c
index 3af0cc4130f..101eb88a2b7 100644
--- a/net/mac80211/status.c
+++ b/net/mac80211/status.c
@@ -668,3 +668,12 @@ void ieee80211_free_txskb(struct ieee80211_hw *hw, struct sk_buff *skb)
668 dev_kfree_skb_any(skb); 668 dev_kfree_skb_any(skb);
669} 669}
670EXPORT_SYMBOL(ieee80211_free_txskb); 670EXPORT_SYMBOL(ieee80211_free_txskb);
671
672void ieee80211_purge_tx_queue(struct ieee80211_hw *hw,
673 struct sk_buff_head *skbs)
674{
675 struct sk_buff *skb;
676
677 while ((skb = __skb_dequeue(skbs)))
678 ieee80211_free_txskb(hw, skb);
679}
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index c9bf83f3665..b858ebe41fd 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -1358,7 +1358,7 @@ static int invoke_tx_handlers(struct ieee80211_tx_data *tx)
1358 if (tx->skb) 1358 if (tx->skb)
1359 ieee80211_free_txskb(&tx->local->hw, tx->skb); 1359 ieee80211_free_txskb(&tx->local->hw, tx->skb);
1360 else 1360 else
1361 __skb_queue_purge(&tx->skbs); 1361 ieee80211_purge_tx_queue(&tx->local->hw, &tx->skbs);
1362 return -1; 1362 return -1;
1363 } else if (unlikely(res == TX_QUEUED)) { 1363 } else if (unlikely(res == TX_QUEUED)) {
1364 I802_DEBUG_INC(tx->local->tx_handlers_queued); 1364 I802_DEBUG_INC(tx->local->tx_handlers_queued);
@@ -2120,10 +2120,13 @@ netdev_tx_t ieee80211_subif_start_xmit(struct sk_buff *skb,
2120 */ 2120 */
2121void ieee80211_clear_tx_pending(struct ieee80211_local *local) 2121void ieee80211_clear_tx_pending(struct ieee80211_local *local)
2122{ 2122{
2123 struct sk_buff *skb;
2123 int i; 2124 int i;
2124 2125
2125 for (i = 0; i < local->hw.queues; i++) 2126 for (i = 0; i < local->hw.queues; i++) {
2126 skb_queue_purge(&local->pending[i]); 2127 while ((skb = skb_dequeue(&local->pending[i])) != NULL)
2128 ieee80211_free_txskb(&local->hw, skb);
2129 }
2127} 2130}
2128 2131
2129/* 2132/*
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index 22ca35054dd..0151ae33c4c 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -406,7 +406,7 @@ void ieee80211_add_pending_skb(struct ieee80211_local *local,
406 int queue = info->hw_queue; 406 int queue = info->hw_queue;
407 407
408 if (WARN_ON(!info->control.vif)) { 408 if (WARN_ON(!info->control.vif)) {
409 kfree_skb(skb); 409 ieee80211_free_txskb(&local->hw, skb);
410 return; 410 return;
411 } 411 }
412 412
@@ -431,7 +431,7 @@ void ieee80211_add_pending_skbs_fn(struct ieee80211_local *local,
431 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 431 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
432 432
433 if (WARN_ON(!info->control.vif)) { 433 if (WARN_ON(!info->control.vif)) {
434 kfree_skb(skb); 434 ieee80211_free_txskb(&local->hw, skb);
435 continue; 435 continue;
436 } 436 }
437 437
@@ -643,13 +643,41 @@ u32 ieee802_11_parse_elems_crc(u8 *start, size_t len,
643 break; 643 break;
644 } 644 }
645 645
646 if (id != WLAN_EID_VENDOR_SPECIFIC && 646 switch (id) {
647 id != WLAN_EID_QUIET && 647 case WLAN_EID_SSID:
648 test_bit(id, seen_elems)) { 648 case WLAN_EID_SUPP_RATES:
649 elems->parse_error = true; 649 case WLAN_EID_FH_PARAMS:
650 left -= elen; 650 case WLAN_EID_DS_PARAMS:
651 pos += elen; 651 case WLAN_EID_CF_PARAMS:
652 continue; 652 case WLAN_EID_TIM:
653 case WLAN_EID_IBSS_PARAMS:
654 case WLAN_EID_CHALLENGE:
655 case WLAN_EID_RSN:
656 case WLAN_EID_ERP_INFO:
657 case WLAN_EID_EXT_SUPP_RATES:
658 case WLAN_EID_HT_CAPABILITY:
659 case WLAN_EID_HT_OPERATION:
660 case WLAN_EID_VHT_CAPABILITY:
661 case WLAN_EID_VHT_OPERATION:
662 case WLAN_EID_MESH_ID:
663 case WLAN_EID_MESH_CONFIG:
664 case WLAN_EID_PEER_MGMT:
665 case WLAN_EID_PREQ:
666 case WLAN_EID_PREP:
667 case WLAN_EID_PERR:
668 case WLAN_EID_RANN:
669 case WLAN_EID_CHANNEL_SWITCH:
670 case WLAN_EID_EXT_CHANSWITCH_ANN:
671 case WLAN_EID_COUNTRY:
672 case WLAN_EID_PWR_CONSTRAINT:
673 case WLAN_EID_TIMEOUT_INTERVAL:
674 if (test_bit(id, seen_elems)) {
675 elems->parse_error = true;
676 left -= elen;
677 pos += elen;
678 continue;
679 }
680 break;
653 } 681 }
654 682
655 if (calc_crc && id < 64 && (filter & (1ULL << id))) 683 if (calc_crc && id < 64 && (filter & (1ULL << id)))
@@ -1463,6 +1491,8 @@ int ieee80211_reconfig(struct ieee80211_local *local)
1463 list_for_each_entry(sdata, &local->interfaces, list) { 1491 list_for_each_entry(sdata, &local->interfaces, list) {
1464 if (sdata->vif.type != NL80211_IFTYPE_STATION) 1492 if (sdata->vif.type != NL80211_IFTYPE_STATION)
1465 continue; 1493 continue;
1494 if (!sdata->u.mgd.associated)
1495 continue;
1466 1496
1467 ieee80211_send_nullfunc(local, sdata, 0); 1497 ieee80211_send_nullfunc(local, sdata, 0);
1468 } 1498 }
diff --git a/net/mac80211/wpa.c b/net/mac80211/wpa.c
index bdb53aba888..8bd2f5c6a56 100644
--- a/net/mac80211/wpa.c
+++ b/net/mac80211/wpa.c
@@ -106,7 +106,8 @@ ieee80211_rx_h_michael_mic_verify(struct ieee80211_rx_data *rx)
106 if (status->flag & RX_FLAG_MMIC_ERROR) 106 if (status->flag & RX_FLAG_MMIC_ERROR)
107 goto mic_fail; 107 goto mic_fail;
108 108
109 if (!(status->flag & RX_FLAG_IV_STRIPPED) && rx->key) 109 if (!(status->flag & RX_FLAG_IV_STRIPPED) && rx->key &&
110 rx->key->conf.cipher == WLAN_CIPHER_SUITE_TKIP)
110 goto update_iv; 111 goto update_iv;
111 112
112 return RX_CONTINUE; 113 return RX_CONTINUE;
@@ -545,14 +546,19 @@ ieee80211_crypto_ccmp_decrypt(struct ieee80211_rx_data *rx)
545 546
546static void bip_aad(struct sk_buff *skb, u8 *aad) 547static void bip_aad(struct sk_buff *skb, u8 *aad)
547{ 548{
549 __le16 mask_fc;
550 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
551
548 /* BIP AAD: FC(masked) || A1 || A2 || A3 */ 552 /* BIP AAD: FC(masked) || A1 || A2 || A3 */
549 553
550 /* FC type/subtype */ 554 /* FC type/subtype */
551 aad[0] = skb->data[0];
552 /* Mask FC Retry, PwrMgt, MoreData flags to zero */ 555 /* Mask FC Retry, PwrMgt, MoreData flags to zero */
553 aad[1] = skb->data[1] & ~(BIT(4) | BIT(5) | BIT(6)); 556 mask_fc = hdr->frame_control;
557 mask_fc &= ~cpu_to_le16(IEEE80211_FCTL_RETRY | IEEE80211_FCTL_PM |
558 IEEE80211_FCTL_MOREDATA);
559 put_unaligned(mask_fc, (__le16 *) &aad[0]);
554 /* A1 || A2 || A3 */ 560 /* A1 || A2 || A3 */
555 memcpy(aad + 2, skb->data + 4, 3 * ETH_ALEN); 561 memcpy(aad + 2, &hdr->addr1, 3 * ETH_ALEN);
556} 562}
557 563
558 564
diff --git a/net/netfilter/ipset/ip_set_hash_ip.c b/net/netfilter/ipset/ip_set_hash_ip.c
index ec3dba5dcd6..5c0b78528e5 100644
--- a/net/netfilter/ipset/ip_set_hash_ip.c
+++ b/net/netfilter/ipset/ip_set_hash_ip.c
@@ -173,6 +173,7 @@ hash_ip4_uadt(struct ip_set *set, struct nlattr *tb[],
173 return adtfn(set, &nip, timeout, flags); 173 return adtfn(set, &nip, timeout, flags);
174 } 174 }
175 175
176 ip_to = ip;
176 if (tb[IPSET_ATTR_IP_TO]) { 177 if (tb[IPSET_ATTR_IP_TO]) {
177 ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP_TO], &ip_to); 178 ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP_TO], &ip_to);
178 if (ret) 179 if (ret)
@@ -185,8 +186,7 @@ hash_ip4_uadt(struct ip_set *set, struct nlattr *tb[],
185 if (!cidr || cidr > 32) 186 if (!cidr || cidr > 32)
186 return -IPSET_ERR_INVALID_CIDR; 187 return -IPSET_ERR_INVALID_CIDR;
187 ip_set_mask_from_to(ip, ip_to, cidr); 188 ip_set_mask_from_to(ip, ip_to, cidr);
188 } else 189 }
189 ip_to = ip;
190 190
191 hosts = h->netmask == 32 ? 1 : 2 << (32 - h->netmask - 1); 191 hosts = h->netmask == 32 ? 1 : 2 << (32 - h->netmask - 1);
192 192
diff --git a/net/netfilter/ipset/ip_set_hash_ipport.c b/net/netfilter/ipset/ip_set_hash_ipport.c
index 0171f7502fa..6283351f4ee 100644
--- a/net/netfilter/ipset/ip_set_hash_ipport.c
+++ b/net/netfilter/ipset/ip_set_hash_ipport.c
@@ -162,7 +162,7 @@ hash_ipport4_uadt(struct ip_set *set, struct nlattr *tb[],
162 const struct ip_set_hash *h = set->data; 162 const struct ip_set_hash *h = set->data;
163 ipset_adtfn adtfn = set->variant->adt[adt]; 163 ipset_adtfn adtfn = set->variant->adt[adt];
164 struct hash_ipport4_elem data = { }; 164 struct hash_ipport4_elem data = { };
165 u32 ip, ip_to = 0, p = 0, port, port_to; 165 u32 ip, ip_to, p = 0, port, port_to;
166 u32 timeout = h->timeout; 166 u32 timeout = h->timeout;
167 bool with_ports = false; 167 bool with_ports = false;
168 int ret; 168 int ret;
@@ -210,7 +210,7 @@ hash_ipport4_uadt(struct ip_set *set, struct nlattr *tb[],
210 return ip_set_eexist(ret, flags) ? 0 : ret; 210 return ip_set_eexist(ret, flags) ? 0 : ret;
211 } 211 }
212 212
213 ip = ntohl(data.ip); 213 ip_to = ip = ntohl(data.ip);
214 if (tb[IPSET_ATTR_IP_TO]) { 214 if (tb[IPSET_ATTR_IP_TO]) {
215 ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP_TO], &ip_to); 215 ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP_TO], &ip_to);
216 if (ret) 216 if (ret)
@@ -223,8 +223,7 @@ hash_ipport4_uadt(struct ip_set *set, struct nlattr *tb[],
223 if (!cidr || cidr > 32) 223 if (!cidr || cidr > 32)
224 return -IPSET_ERR_INVALID_CIDR; 224 return -IPSET_ERR_INVALID_CIDR;
225 ip_set_mask_from_to(ip, ip_to, cidr); 225 ip_set_mask_from_to(ip, ip_to, cidr);
226 } else 226 }
227 ip_to = ip;
228 227
229 port_to = port = ntohs(data.port); 228 port_to = port = ntohs(data.port);
230 if (with_ports && tb[IPSET_ATTR_PORT_TO]) { 229 if (with_ports && tb[IPSET_ATTR_PORT_TO]) {
diff --git a/net/netfilter/ipset/ip_set_hash_ipportip.c b/net/netfilter/ipset/ip_set_hash_ipportip.c
index 6344ef551ec..6a21271c8d5 100644
--- a/net/netfilter/ipset/ip_set_hash_ipportip.c
+++ b/net/netfilter/ipset/ip_set_hash_ipportip.c
@@ -166,7 +166,7 @@ hash_ipportip4_uadt(struct ip_set *set, struct nlattr *tb[],
166 const struct ip_set_hash *h = set->data; 166 const struct ip_set_hash *h = set->data;
167 ipset_adtfn adtfn = set->variant->adt[adt]; 167 ipset_adtfn adtfn = set->variant->adt[adt];
168 struct hash_ipportip4_elem data = { }; 168 struct hash_ipportip4_elem data = { };
169 u32 ip, ip_to = 0, p = 0, port, port_to; 169 u32 ip, ip_to, p = 0, port, port_to;
170 u32 timeout = h->timeout; 170 u32 timeout = h->timeout;
171 bool with_ports = false; 171 bool with_ports = false;
172 int ret; 172 int ret;
@@ -218,7 +218,7 @@ hash_ipportip4_uadt(struct ip_set *set, struct nlattr *tb[],
218 return ip_set_eexist(ret, flags) ? 0 : ret; 218 return ip_set_eexist(ret, flags) ? 0 : ret;
219 } 219 }
220 220
221 ip = ntohl(data.ip); 221 ip_to = ip = ntohl(data.ip);
222 if (tb[IPSET_ATTR_IP_TO]) { 222 if (tb[IPSET_ATTR_IP_TO]) {
223 ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP_TO], &ip_to); 223 ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP_TO], &ip_to);
224 if (ret) 224 if (ret)
@@ -231,8 +231,7 @@ hash_ipportip4_uadt(struct ip_set *set, struct nlattr *tb[],
231 if (!cidr || cidr > 32) 231 if (!cidr || cidr > 32)
232 return -IPSET_ERR_INVALID_CIDR; 232 return -IPSET_ERR_INVALID_CIDR;
233 ip_set_mask_from_to(ip, ip_to, cidr); 233 ip_set_mask_from_to(ip, ip_to, cidr);
234 } else 234 }
235 ip_to = ip;
236 235
237 port_to = port = ntohs(data.port); 236 port_to = port = ntohs(data.port);
238 if (with_ports && tb[IPSET_ATTR_PORT_TO]) { 237 if (with_ports && tb[IPSET_ATTR_PORT_TO]) {
diff --git a/net/netfilter/ipset/ip_set_hash_ipportnet.c b/net/netfilter/ipset/ip_set_hash_ipportnet.c
index cb71f9a774e..2d5cd4ee30e 100644
--- a/net/netfilter/ipset/ip_set_hash_ipportnet.c
+++ b/net/netfilter/ipset/ip_set_hash_ipportnet.c
@@ -215,8 +215,8 @@ hash_ipportnet4_uadt(struct ip_set *set, struct nlattr *tb[],
215 const struct ip_set_hash *h = set->data; 215 const struct ip_set_hash *h = set->data;
216 ipset_adtfn adtfn = set->variant->adt[adt]; 216 ipset_adtfn adtfn = set->variant->adt[adt];
217 struct hash_ipportnet4_elem data = { .cidr = HOST_MASK - 1 }; 217 struct hash_ipportnet4_elem data = { .cidr = HOST_MASK - 1 };
218 u32 ip, ip_to = 0, p = 0, port, port_to; 218 u32 ip, ip_to, p = 0, port, port_to;
219 u32 ip2_from = 0, ip2_to, ip2_last, ip2; 219 u32 ip2_from, ip2_to, ip2_last, ip2;
220 u32 timeout = h->timeout; 220 u32 timeout = h->timeout;
221 bool with_ports = false; 221 bool with_ports = false;
222 u8 cidr; 222 u8 cidr;
@@ -286,6 +286,7 @@ hash_ipportnet4_uadt(struct ip_set *set, struct nlattr *tb[],
286 return ip_set_eexist(ret, flags) ? 0 : ret; 286 return ip_set_eexist(ret, flags) ? 0 : ret;
287 } 287 }
288 288
289 ip_to = ip;
289 if (tb[IPSET_ATTR_IP_TO]) { 290 if (tb[IPSET_ATTR_IP_TO]) {
290 ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP_TO], &ip_to); 291 ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP_TO], &ip_to);
291 if (ret) 292 if (ret)
@@ -306,6 +307,8 @@ hash_ipportnet4_uadt(struct ip_set *set, struct nlattr *tb[],
306 if (port > port_to) 307 if (port > port_to)
307 swap(port, port_to); 308 swap(port, port_to);
308 } 309 }
310
311 ip2_to = ip2_from;
309 if (tb[IPSET_ATTR_IP2_TO]) { 312 if (tb[IPSET_ATTR_IP2_TO]) {
310 ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP2_TO], &ip2_to); 313 ret = ip_set_get_hostipaddr4(tb[IPSET_ATTR_IP2_TO], &ip2_to);
311 if (ret) 314 if (ret)
diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
index 7e7198b51c0..c4ee43710aa 100644
--- a/net/netfilter/ipvs/ip_vs_ctl.c
+++ b/net/netfilter/ipvs/ip_vs_ctl.c
@@ -2589,6 +2589,8 @@ __ip_vs_get_timeouts(struct net *net, struct ip_vs_timeout_user *u)
2589 struct ip_vs_proto_data *pd; 2589 struct ip_vs_proto_data *pd;
2590#endif 2590#endif
2591 2591
2592 memset(u, 0, sizeof (*u));
2593
2592#ifdef CONFIG_IP_VS_PROTO_TCP 2594#ifdef CONFIG_IP_VS_PROTO_TCP
2593 pd = ip_vs_proto_data_get(net, IPPROTO_TCP); 2595 pd = ip_vs_proto_data_get(net, IPPROTO_TCP);
2594 u->tcp_timeout = pd->timeout_table[IP_VS_TCP_S_ESTABLISHED] / HZ; 2596 u->tcp_timeout = pd->timeout_table[IP_VS_TCP_S_ESTABLISHED] / HZ;
@@ -2766,7 +2768,6 @@ do_ip_vs_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
2766 { 2768 {
2767 struct ip_vs_timeout_user t; 2769 struct ip_vs_timeout_user t;
2768 2770
2769 memset(&t, 0, sizeof(t));
2770 __ip_vs_get_timeouts(net, &t); 2771 __ip_vs_get_timeouts(net, &t);
2771 if (copy_to_user(user, &t, sizeof(t)) != 0) 2772 if (copy_to_user(user, &t, sizeof(t)) != 0)
2772 ret = -EFAULT; 2773 ret = -EFAULT;
diff --git a/net/netfilter/nf_conntrack_h323_main.c b/net/netfilter/nf_conntrack_h323_main.c
index 1b30b0dee70..962795e839a 100644
--- a/net/netfilter/nf_conntrack_h323_main.c
+++ b/net/netfilter/nf_conntrack_h323_main.c
@@ -753,7 +753,8 @@ static int callforward_do_filter(const union nf_inet_addr *src,
753 flowi4_to_flowi(&fl1), false)) { 753 flowi4_to_flowi(&fl1), false)) {
754 if (!afinfo->route(&init_net, (struct dst_entry **)&rt2, 754 if (!afinfo->route(&init_net, (struct dst_entry **)&rt2,
755 flowi4_to_flowi(&fl2), false)) { 755 flowi4_to_flowi(&fl2), false)) {
756 if (rt1->rt_gateway == rt2->rt_gateway && 756 if (rt_nexthop(rt1, fl1.daddr) ==
757 rt_nexthop(rt2, fl2.daddr) &&
757 rt1->dst.dev == rt2->dst.dev) 758 rt1->dst.dev == rt2->dst.dev)
758 ret = 1; 759 ret = 1;
759 dst_release(&rt2->dst); 760 dst_release(&rt2->dst);
diff --git a/net/netfilter/nfnetlink_cttimeout.c b/net/netfilter/nfnetlink_cttimeout.c
index 8847b4d8be0..701c88a20fe 100644
--- a/net/netfilter/nfnetlink_cttimeout.c
+++ b/net/netfilter/nfnetlink_cttimeout.c
@@ -41,7 +41,8 @@ MODULE_DESCRIPTION("cttimeout: Extended Netfilter Connection Tracking timeout tu
41static LIST_HEAD(cttimeout_list); 41static LIST_HEAD(cttimeout_list);
42 42
43static const struct nla_policy cttimeout_nla_policy[CTA_TIMEOUT_MAX+1] = { 43static const struct nla_policy cttimeout_nla_policy[CTA_TIMEOUT_MAX+1] = {
44 [CTA_TIMEOUT_NAME] = { .type = NLA_NUL_STRING }, 44 [CTA_TIMEOUT_NAME] = { .type = NLA_NUL_STRING,
45 .len = CTNL_TIMEOUT_NAME_MAX - 1},
45 [CTA_TIMEOUT_L3PROTO] = { .type = NLA_U16 }, 46 [CTA_TIMEOUT_L3PROTO] = { .type = NLA_U16 },
46 [CTA_TIMEOUT_L4PROTO] = { .type = NLA_U8 }, 47 [CTA_TIMEOUT_L4PROTO] = { .type = NLA_U8 },
47 [CTA_TIMEOUT_DATA] = { .type = NLA_NESTED }, 48 [CTA_TIMEOUT_DATA] = { .type = NLA_NESTED },
diff --git a/net/netfilter/xt_CT.c b/net/netfilter/xt_CT.c
index 16c71256386..ae7f5daeee4 100644
--- a/net/netfilter/xt_CT.c
+++ b/net/netfilter/xt_CT.c
@@ -180,9 +180,9 @@ xt_ct_set_timeout(struct nf_conn *ct, const struct xt_tgchk_param *par,
180 typeof(nf_ct_timeout_find_get_hook) timeout_find_get; 180 typeof(nf_ct_timeout_find_get_hook) timeout_find_get;
181 struct ctnl_timeout *timeout; 181 struct ctnl_timeout *timeout;
182 struct nf_conn_timeout *timeout_ext; 182 struct nf_conn_timeout *timeout_ext;
183 const struct ipt_entry *e = par->entryinfo;
184 struct nf_conntrack_l4proto *l4proto; 183 struct nf_conntrack_l4proto *l4proto;
185 int ret = 0; 184 int ret = 0;
185 u8 proto;
186 186
187 rcu_read_lock(); 187 rcu_read_lock();
188 timeout_find_get = rcu_dereference(nf_ct_timeout_find_get_hook); 188 timeout_find_get = rcu_dereference(nf_ct_timeout_find_get_hook);
@@ -192,9 +192,11 @@ xt_ct_set_timeout(struct nf_conn *ct, const struct xt_tgchk_param *par,
192 goto out; 192 goto out;
193 } 193 }
194 194
195 if (e->ip.invflags & IPT_INV_PROTO) { 195 proto = xt_ct_find_proto(par);
196 if (!proto) {
196 ret = -EINVAL; 197 ret = -EINVAL;
197 pr_info("You cannot use inversion on L4 protocol\n"); 198 pr_info("You must specify a L4 protocol, and not use "
199 "inversions on it.\n");
198 goto out; 200 goto out;
199 } 201 }
200 202
@@ -214,7 +216,7 @@ xt_ct_set_timeout(struct nf_conn *ct, const struct xt_tgchk_param *par,
214 /* Make sure the timeout policy matches any existing protocol tracker, 216 /* Make sure the timeout policy matches any existing protocol tracker,
215 * otherwise default to generic. 217 * otherwise default to generic.
216 */ 218 */
217 l4proto = __nf_ct_l4proto_find(par->family, e->ip.proto); 219 l4proto = __nf_ct_l4proto_find(par->family, proto);
218 if (timeout->l4proto->l4proto != l4proto->l4proto) { 220 if (timeout->l4proto->l4proto != l4proto->l4proto) {
219 ret = -EINVAL; 221 ret = -EINVAL;
220 pr_info("Timeout policy `%s' can only be used by L4 protocol " 222 pr_info("Timeout policy `%s' can only be used by L4 protocol "
diff --git a/net/netfilter/xt_TEE.c b/net/netfilter/xt_TEE.c
index ee2e5bc5a8c..bd93e51d30a 100644
--- a/net/netfilter/xt_TEE.c
+++ b/net/netfilter/xt_TEE.c
@@ -70,6 +70,7 @@ tee_tg_route4(struct sk_buff *skb, const struct xt_tee_tginfo *info)
70 fl4.daddr = info->gw.ip; 70 fl4.daddr = info->gw.ip;
71 fl4.flowi4_tos = RT_TOS(iph->tos); 71 fl4.flowi4_tos = RT_TOS(iph->tos);
72 fl4.flowi4_scope = RT_SCOPE_UNIVERSE; 72 fl4.flowi4_scope = RT_SCOPE_UNIVERSE;
73 fl4.flowi4_flags = FLOWI_FLAG_KNOWN_NH;
73 rt = ip_route_output_key(net, &fl4); 74 rt = ip_route_output_key(net, &fl4);
74 if (IS_ERR(rt)) 75 if (IS_ERR(rt))
75 return false; 76 return false;
diff --git a/net/netfilter/xt_nat.c b/net/netfilter/xt_nat.c
index 81aafa8e4fe..bea7464cc43 100644
--- a/net/netfilter/xt_nat.c
+++ b/net/netfilter/xt_nat.c
@@ -111,7 +111,7 @@ static struct xt_target xt_nat_target_reg[] __read_mostly = {
111 .family = NFPROTO_IPV4, 111 .family = NFPROTO_IPV4,
112 .table = "nat", 112 .table = "nat",
113 .hooks = (1 << NF_INET_POST_ROUTING) | 113 .hooks = (1 << NF_INET_POST_ROUTING) |
114 (1 << NF_INET_LOCAL_OUT), 114 (1 << NF_INET_LOCAL_IN),
115 .me = THIS_MODULE, 115 .me = THIS_MODULE,
116 }, 116 },
117 { 117 {
@@ -123,7 +123,7 @@ static struct xt_target xt_nat_target_reg[] __read_mostly = {
123 .family = NFPROTO_IPV4, 123 .family = NFPROTO_IPV4,
124 .table = "nat", 124 .table = "nat",
125 .hooks = (1 << NF_INET_PRE_ROUTING) | 125 .hooks = (1 << NF_INET_PRE_ROUTING) |
126 (1 << NF_INET_LOCAL_IN), 126 (1 << NF_INET_LOCAL_OUT),
127 .me = THIS_MODULE, 127 .me = THIS_MODULE,
128 }, 128 },
129 { 129 {
@@ -133,7 +133,7 @@ static struct xt_target xt_nat_target_reg[] __read_mostly = {
133 .targetsize = sizeof(struct nf_nat_range), 133 .targetsize = sizeof(struct nf_nat_range),
134 .table = "nat", 134 .table = "nat",
135 .hooks = (1 << NF_INET_POST_ROUTING) | 135 .hooks = (1 << NF_INET_POST_ROUTING) |
136 (1 << NF_INET_LOCAL_OUT), 136 (1 << NF_INET_LOCAL_IN),
137 .me = THIS_MODULE, 137 .me = THIS_MODULE,
138 }, 138 },
139 { 139 {
@@ -143,7 +143,7 @@ static struct xt_target xt_nat_target_reg[] __read_mostly = {
143 .targetsize = sizeof(struct nf_nat_range), 143 .targetsize = sizeof(struct nf_nat_range),
144 .table = "nat", 144 .table = "nat",
145 .hooks = (1 << NF_INET_PRE_ROUTING) | 145 .hooks = (1 << NF_INET_PRE_ROUTING) |
146 (1 << NF_INET_LOCAL_IN), 146 (1 << NF_INET_LOCAL_OUT),
147 .me = THIS_MODULE, 147 .me = THIS_MODULE,
148 }, 148 },
149}; 149};
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 01e944a017a..4da797fa5ec 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -138,6 +138,8 @@ static int netlink_dump(struct sock *sk);
138static DEFINE_RWLOCK(nl_table_lock); 138static DEFINE_RWLOCK(nl_table_lock);
139static atomic_t nl_table_users = ATOMIC_INIT(0); 139static atomic_t nl_table_users = ATOMIC_INIT(0);
140 140
141#define nl_deref_protected(X) rcu_dereference_protected(X, lockdep_is_held(&nl_table_lock));
142
141static ATOMIC_NOTIFIER_HEAD(netlink_chain); 143static ATOMIC_NOTIFIER_HEAD(netlink_chain);
142 144
143static inline u32 netlink_group_mask(u32 group) 145static inline u32 netlink_group_mask(u32 group)
@@ -345,6 +347,11 @@ netlink_update_listeners(struct sock *sk)
345 struct hlist_node *node; 347 struct hlist_node *node;
346 unsigned long mask; 348 unsigned long mask;
347 unsigned int i; 349 unsigned int i;
350 struct listeners *listeners;
351
352 listeners = nl_deref_protected(tbl->listeners);
353 if (!listeners)
354 return;
348 355
349 for (i = 0; i < NLGRPLONGS(tbl->groups); i++) { 356 for (i = 0; i < NLGRPLONGS(tbl->groups); i++) {
350 mask = 0; 357 mask = 0;
@@ -352,7 +359,7 @@ netlink_update_listeners(struct sock *sk)
352 if (i < NLGRPLONGS(nlk_sk(sk)->ngroups)) 359 if (i < NLGRPLONGS(nlk_sk(sk)->ngroups))
353 mask |= nlk_sk(sk)->groups[i]; 360 mask |= nlk_sk(sk)->groups[i];
354 } 361 }
355 tbl->listeners->masks[i] = mask; 362 listeners->masks[i] = mask;
356 } 363 }
357 /* this function is only called with the netlink table "grabbed", which 364 /* this function is only called with the netlink table "grabbed", which
358 * makes sure updates are visible before bind or setsockopt return. */ 365 * makes sure updates are visible before bind or setsockopt return. */
@@ -536,7 +543,11 @@ static int netlink_release(struct socket *sock)
536 if (netlink_is_kernel(sk)) { 543 if (netlink_is_kernel(sk)) {
537 BUG_ON(nl_table[sk->sk_protocol].registered == 0); 544 BUG_ON(nl_table[sk->sk_protocol].registered == 0);
538 if (--nl_table[sk->sk_protocol].registered == 0) { 545 if (--nl_table[sk->sk_protocol].registered == 0) {
539 kfree(nl_table[sk->sk_protocol].listeners); 546 struct listeners *old;
547
548 old = nl_deref_protected(nl_table[sk->sk_protocol].listeners);
549 RCU_INIT_POINTER(nl_table[sk->sk_protocol].listeners, NULL);
550 kfree_rcu(old, rcu);
540 nl_table[sk->sk_protocol].module = NULL; 551 nl_table[sk->sk_protocol].module = NULL;
541 nl_table[sk->sk_protocol].bind = NULL; 552 nl_table[sk->sk_protocol].bind = NULL;
542 nl_table[sk->sk_protocol].flags = 0; 553 nl_table[sk->sk_protocol].flags = 0;
@@ -982,7 +993,7 @@ int netlink_has_listeners(struct sock *sk, unsigned int group)
982 rcu_read_lock(); 993 rcu_read_lock();
983 listeners = rcu_dereference(nl_table[sk->sk_protocol].listeners); 994 listeners = rcu_dereference(nl_table[sk->sk_protocol].listeners);
984 995
985 if (group - 1 < nl_table[sk->sk_protocol].groups) 996 if (listeners && group - 1 < nl_table[sk->sk_protocol].groups)
986 res = test_bit(group - 1, listeners->masks); 997 res = test_bit(group - 1, listeners->masks);
987 998
988 rcu_read_unlock(); 999 rcu_read_unlock();
@@ -1625,7 +1636,7 @@ int __netlink_change_ngroups(struct sock *sk, unsigned int groups)
1625 new = kzalloc(sizeof(*new) + NLGRPSZ(groups), GFP_ATOMIC); 1636 new = kzalloc(sizeof(*new) + NLGRPSZ(groups), GFP_ATOMIC);
1626 if (!new) 1637 if (!new)
1627 return -ENOMEM; 1638 return -ENOMEM;
1628 old = rcu_dereference_protected(tbl->listeners, 1); 1639 old = nl_deref_protected(tbl->listeners);
1629 memcpy(new->masks, old->masks, NLGRPSZ(tbl->groups)); 1640 memcpy(new->masks, old->masks, NLGRPSZ(tbl->groups));
1630 rcu_assign_pointer(tbl->listeners, new); 1641 rcu_assign_pointer(tbl->listeners, new);
1631 1642
diff --git a/net/nfc/llcp/llcp.c b/net/nfc/llcp/llcp.c
index cc10d073c33..9e8f4b2801f 100644
--- a/net/nfc/llcp/llcp.c
+++ b/net/nfc/llcp/llcp.c
@@ -1210,7 +1210,7 @@ int nfc_llcp_register_device(struct nfc_dev *ndev)
1210 local->remote_miu = LLCP_DEFAULT_MIU; 1210 local->remote_miu = LLCP_DEFAULT_MIU;
1211 local->remote_lto = LLCP_DEFAULT_LTO; 1211 local->remote_lto = LLCP_DEFAULT_LTO;
1212 1212
1213 list_add(&llcp_devices, &local->list); 1213 list_add(&local->list, &llcp_devices);
1214 1214
1215 return 0; 1215 return 0;
1216} 1216}
diff --git a/net/sched/sch_qfq.c b/net/sched/sch_qfq.c
index f0dd83cff90..9687fa1c227 100644
--- a/net/sched/sch_qfq.c
+++ b/net/sched/sch_qfq.c
@@ -84,18 +84,19 @@
84 * grp->index is the index of the group; and grp->slot_shift 84 * grp->index is the index of the group; and grp->slot_shift
85 * is the shift for the corresponding (scaled) sigma_i. 85 * is the shift for the corresponding (scaled) sigma_i.
86 */ 86 */
87#define QFQ_MAX_INDEX 19 87#define QFQ_MAX_INDEX 24
88#define QFQ_MAX_WSHIFT 16 88#define QFQ_MAX_WSHIFT 12
89 89
90#define QFQ_MAX_WEIGHT (1<<QFQ_MAX_WSHIFT) 90#define QFQ_MAX_WEIGHT (1<<QFQ_MAX_WSHIFT)
91#define QFQ_MAX_WSUM (2*QFQ_MAX_WEIGHT) 91#define QFQ_MAX_WSUM (16*QFQ_MAX_WEIGHT)
92 92
93#define FRAC_BITS 30 /* fixed point arithmetic */ 93#define FRAC_BITS 30 /* fixed point arithmetic */
94#define ONE_FP (1UL << FRAC_BITS) 94#define ONE_FP (1UL << FRAC_BITS)
95#define IWSUM (ONE_FP/QFQ_MAX_WSUM) 95#define IWSUM (ONE_FP/QFQ_MAX_WSUM)
96 96
97#define QFQ_MTU_SHIFT 11 97#define QFQ_MTU_SHIFT 16 /* to support TSO/GSO */
98#define QFQ_MIN_SLOT_SHIFT (FRAC_BITS + QFQ_MTU_SHIFT - QFQ_MAX_INDEX) 98#define QFQ_MIN_SLOT_SHIFT (FRAC_BITS + QFQ_MTU_SHIFT - QFQ_MAX_INDEX)
99#define QFQ_MIN_LMAX 256 /* min possible lmax for a class */
99 100
100/* 101/*
101 * Possible group states. These values are used as indexes for the bitmaps 102 * Possible group states. These values are used as indexes for the bitmaps
@@ -231,6 +232,32 @@ static void qfq_update_class_params(struct qfq_sched *q, struct qfq_class *cl,
231 q->wsum += delta_w; 232 q->wsum += delta_w;
232} 233}
233 234
235static void qfq_update_reactivate_class(struct qfq_sched *q,
236 struct qfq_class *cl,
237 u32 inv_w, u32 lmax, int delta_w)
238{
239 bool need_reactivation = false;
240 int i = qfq_calc_index(inv_w, lmax);
241
242 if (&q->groups[i] != cl->grp && cl->qdisc->q.qlen > 0) {
243 /*
244 * shift cl->F back, to not charge the
245 * class for the not-yet-served head
246 * packet
247 */
248 cl->F = cl->S;
249 /* remove class from its slot in the old group */
250 qfq_deactivate_class(q, cl);
251 need_reactivation = true;
252 }
253
254 qfq_update_class_params(q, cl, lmax, inv_w, delta_w);
255
256 if (need_reactivation) /* activate in new group */
257 qfq_activate_class(q, cl, qdisc_peek_len(cl->qdisc));
258}
259
260
234static int qfq_change_class(struct Qdisc *sch, u32 classid, u32 parentid, 261static int qfq_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
235 struct nlattr **tca, unsigned long *arg) 262 struct nlattr **tca, unsigned long *arg)
236{ 263{
@@ -238,7 +265,7 @@ static int qfq_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
238 struct qfq_class *cl = (struct qfq_class *)*arg; 265 struct qfq_class *cl = (struct qfq_class *)*arg;
239 struct nlattr *tb[TCA_QFQ_MAX + 1]; 266 struct nlattr *tb[TCA_QFQ_MAX + 1];
240 u32 weight, lmax, inv_w; 267 u32 weight, lmax, inv_w;
241 int i, err; 268 int err;
242 int delta_w; 269 int delta_w;
243 270
244 if (tca[TCA_OPTIONS] == NULL) { 271 if (tca[TCA_OPTIONS] == NULL) {
@@ -270,16 +297,14 @@ static int qfq_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
270 297
271 if (tb[TCA_QFQ_LMAX]) { 298 if (tb[TCA_QFQ_LMAX]) {
272 lmax = nla_get_u32(tb[TCA_QFQ_LMAX]); 299 lmax = nla_get_u32(tb[TCA_QFQ_LMAX]);
273 if (!lmax || lmax > (1UL << QFQ_MTU_SHIFT)) { 300 if (lmax < QFQ_MIN_LMAX || lmax > (1UL << QFQ_MTU_SHIFT)) {
274 pr_notice("qfq: invalid max length %u\n", lmax); 301 pr_notice("qfq: invalid max length %u\n", lmax);
275 return -EINVAL; 302 return -EINVAL;
276 } 303 }
277 } else 304 } else
278 lmax = 1UL << QFQ_MTU_SHIFT; 305 lmax = psched_mtu(qdisc_dev(sch));
279 306
280 if (cl != NULL) { 307 if (cl != NULL) {
281 bool need_reactivation = false;
282
283 if (tca[TCA_RATE]) { 308 if (tca[TCA_RATE]) {
284 err = gen_replace_estimator(&cl->bstats, &cl->rate_est, 309 err = gen_replace_estimator(&cl->bstats, &cl->rate_est,
285 qdisc_root_sleeping_lock(sch), 310 qdisc_root_sleeping_lock(sch),
@@ -291,24 +316,8 @@ static int qfq_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
291 if (lmax == cl->lmax && inv_w == cl->inv_w) 316 if (lmax == cl->lmax && inv_w == cl->inv_w)
292 return 0; /* nothing to update */ 317 return 0; /* nothing to update */
293 318
294 i = qfq_calc_index(inv_w, lmax);
295 sch_tree_lock(sch); 319 sch_tree_lock(sch);
296 if (&q->groups[i] != cl->grp && cl->qdisc->q.qlen > 0) { 320 qfq_update_reactivate_class(q, cl, inv_w, lmax, delta_w);
297 /*
298 * shift cl->F back, to not charge the
299 * class for the not-yet-served head
300 * packet
301 */
302 cl->F = cl->S;
303 /* remove class from its slot in the old group */
304 qfq_deactivate_class(q, cl);
305 need_reactivation = true;
306 }
307
308 qfq_update_class_params(q, cl, lmax, inv_w, delta_w);
309
310 if (need_reactivation) /* activate in new group */
311 qfq_activate_class(q, cl, qdisc_peek_len(cl->qdisc));
312 sch_tree_unlock(sch); 321 sch_tree_unlock(sch);
313 322
314 return 0; 323 return 0;
@@ -663,15 +672,48 @@ static void qfq_make_eligible(struct qfq_sched *q, u64 old_V)
663 672
664 673
665/* 674/*
666 * XXX we should make sure that slot becomes less than 32. 675 * If the weight and lmax (max_pkt_size) of the classes do not change,
667 * This is guaranteed by the input values. 676 * then QFQ guarantees that the slot index is never higher than
668 * roundedS is always cl->S rounded on grp->slot_shift bits. 677 * 2 + ((1<<QFQ_MTU_SHIFT)/QFQ_MIN_LMAX) * (QFQ_MAX_WEIGHT/QFQ_MAX_WSUM).
678 *
679 * With the current values of the above constants, the index is
680 * then guaranteed to never be higher than 2 + 256 * (1 / 16) = 18.
681 *
682 * When the weight of a class is increased or the lmax of the class is
683 * decreased, a new class with smaller slot size may happen to be
684 * activated. The activation of this class should be properly delayed
685 * to when the service of the class has finished in the ideal system
686 * tracked by QFQ. If the activation of the class is not delayed to
687 * this reference time instant, then this class may be unjustly served
688 * before other classes waiting for service. This may cause
689 * (unfrequently) the above bound to the slot index to be violated for
690 * some of these unlucky classes.
691 *
692 * Instead of delaying the activation of the new class, which is quite
693 * complex, the following inaccurate but simple solution is used: if
694 * the slot index is higher than QFQ_MAX_SLOTS-2, then the timestamps
695 * of the class are shifted backward so as to let the slot index
696 * become equal to QFQ_MAX_SLOTS-2. This threshold is used because, if
697 * the slot index is above it, then the data structure implementing
698 * the bucket list either gets immediately corrupted or may get
699 * corrupted on a possible next packet arrival that causes the start
700 * time of the group to be shifted backward.
669 */ 701 */
670static void qfq_slot_insert(struct qfq_group *grp, struct qfq_class *cl, 702static void qfq_slot_insert(struct qfq_group *grp, struct qfq_class *cl,
671 u64 roundedS) 703 u64 roundedS)
672{ 704{
673 u64 slot = (roundedS - grp->S) >> grp->slot_shift; 705 u64 slot = (roundedS - grp->S) >> grp->slot_shift;
674 unsigned int i = (grp->front + slot) % QFQ_MAX_SLOTS; 706 unsigned int i; /* slot index in the bucket list */
707
708 if (unlikely(slot > QFQ_MAX_SLOTS - 2)) {
709 u64 deltaS = roundedS - grp->S -
710 ((u64)(QFQ_MAX_SLOTS - 2)<<grp->slot_shift);
711 cl->S -= deltaS;
712 cl->F -= deltaS;
713 slot = QFQ_MAX_SLOTS - 2;
714 }
715
716 i = (grp->front + slot) % QFQ_MAX_SLOTS;
675 717
676 hlist_add_head(&cl->next, &grp->slots[i]); 718 hlist_add_head(&cl->next, &grp->slots[i]);
677 __set_bit(slot, &grp->full_slots); 719 __set_bit(slot, &grp->full_slots);
@@ -892,6 +934,13 @@ static int qfq_enqueue(struct sk_buff *skb, struct Qdisc *sch)
892 } 934 }
893 pr_debug("qfq_enqueue: cl = %x\n", cl->common.classid); 935 pr_debug("qfq_enqueue: cl = %x\n", cl->common.classid);
894 936
937 if (unlikely(cl->lmax < qdisc_pkt_len(skb))) {
938 pr_debug("qfq: increasing maxpkt from %u to %u for class %u",
939 cl->lmax, qdisc_pkt_len(skb), cl->common.classid);
940 qfq_update_reactivate_class(q, cl, cl->inv_w,
941 qdisc_pkt_len(skb), 0);
942 }
943
895 err = qdisc_enqueue(skb, cl->qdisc); 944 err = qdisc_enqueue(skb, cl->qdisc);
896 if (unlikely(err != NET_XMIT_SUCCESS)) { 945 if (unlikely(err != NET_XMIT_SUCCESS)) {
897 pr_debug("qfq_enqueue: enqueue failed %d\n", err); 946 pr_debug("qfq_enqueue: enqueue failed %d\n", err);
diff --git a/net/sctp/proc.c b/net/sctp/proc.c
index c3bea269faf..9966e7b1645 100644
--- a/net/sctp/proc.c
+++ b/net/sctp/proc.c
@@ -102,7 +102,7 @@ static const struct file_operations sctp_snmp_seq_fops = {
102 .open = sctp_snmp_seq_open, 102 .open = sctp_snmp_seq_open,
103 .read = seq_read, 103 .read = seq_read,
104 .llseek = seq_lseek, 104 .llseek = seq_lseek,
105 .release = single_release, 105 .release = single_release_net,
106}; 106};
107 107
108/* Set up the proc fs entry for 'snmp' object. */ 108/* Set up the proc fs entry for 'snmp' object. */
@@ -251,7 +251,7 @@ static const struct file_operations sctp_eps_seq_fops = {
251 .open = sctp_eps_seq_open, 251 .open = sctp_eps_seq_open,
252 .read = seq_read, 252 .read = seq_read,
253 .llseek = seq_lseek, 253 .llseek = seq_lseek,
254 .release = seq_release, 254 .release = seq_release_net,
255}; 255};
256 256
257/* Set up the proc fs entry for 'eps' object. */ 257/* Set up the proc fs entry for 'eps' object. */
@@ -372,7 +372,7 @@ static const struct file_operations sctp_assocs_seq_fops = {
372 .open = sctp_assocs_seq_open, 372 .open = sctp_assocs_seq_open,
373 .read = seq_read, 373 .read = seq_read,
374 .llseek = seq_lseek, 374 .llseek = seq_lseek,
375 .release = seq_release, 375 .release = seq_release_net,
376}; 376};
377 377
378/* Set up the proc fs entry for 'assocs' object. */ 378/* Set up the proc fs entry for 'assocs' object. */
@@ -517,7 +517,7 @@ static const struct file_operations sctp_remaddr_seq_fops = {
517 .open = sctp_remaddr_seq_open, 517 .open = sctp_remaddr_seq_open,
518 .read = seq_read, 518 .read = seq_read,
519 .llseek = seq_lseek, 519 .llseek = seq_lseek,
520 .release = seq_release, 520 .release = seq_release_net,
521}; 521};
522 522
523int __net_init sctp_remaddr_proc_init(struct net *net) 523int __net_init sctp_remaddr_proc_init(struct net *net)
diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
index 57f7de839b0..6773d780362 100644
--- a/net/sctp/sm_sideeffect.c
+++ b/net/sctp/sm_sideeffect.c
@@ -1642,8 +1642,9 @@ static int sctp_cmd_interpreter(sctp_event_t event_type,
1642 asoc->outqueue.outstanding_bytes; 1642 asoc->outqueue.outstanding_bytes;
1643 sackh.num_gap_ack_blocks = 0; 1643 sackh.num_gap_ack_blocks = 0;
1644 sackh.num_dup_tsns = 0; 1644 sackh.num_dup_tsns = 0;
1645 chunk->subh.sack_hdr = &sackh;
1645 sctp_add_cmd_sf(commands, SCTP_CMD_PROCESS_SACK, 1646 sctp_add_cmd_sf(commands, SCTP_CMD_PROCESS_SACK,
1646 SCTP_SACKH(&sackh)); 1647 SCTP_CHUNK(chunk));
1647 break; 1648 break;
1648 1649
1649 case SCTP_CMD_DISCARD_PACKET: 1650 case SCTP_CMD_DISCARD_PACKET:
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 59d16ea927f..a60d1f8b41c 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -974,7 +974,7 @@ SCTP_STATIC int sctp_setsockopt_bindx(struct sock* sk,
974 void *addr_buf; 974 void *addr_buf;
975 struct sctp_af *af; 975 struct sctp_af *af;
976 976
977 SCTP_DEBUG_PRINTK("sctp_setsocktopt_bindx: sk %p addrs %p" 977 SCTP_DEBUG_PRINTK("sctp_setsockopt_bindx: sk %p addrs %p"
978 " addrs_size %d opt %d\n", sk, addrs, addrs_size, op); 978 " addrs_size %d opt %d\n", sk, addrs, addrs_size, op);
979 979
980 if (unlikely(addrs_size <= 0)) 980 if (unlikely(addrs_size <= 0))
diff --git a/net/sunrpc/backchannel_rqst.c b/net/sunrpc/backchannel_rqst.c
index 5a3d675d2f2..a9c0bbccad6 100644
--- a/net/sunrpc/backchannel_rqst.c
+++ b/net/sunrpc/backchannel_rqst.c
@@ -172,7 +172,7 @@ out_free:
172 xprt_free_allocation(req); 172 xprt_free_allocation(req);
173 173
174 dprintk("RPC: setup backchannel transport failed\n"); 174 dprintk("RPC: setup backchannel transport failed\n");
175 return -1; 175 return -ENOMEM;
176} 176}
177EXPORT_SYMBOL_GPL(xprt_setup_backchannel); 177EXPORT_SYMBOL_GPL(xprt_setup_backchannel);
178 178
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
index 2a68bb3db77..fc2f7aa4dca 100644
--- a/net/sunrpc/cache.c
+++ b/net/sunrpc/cache.c
@@ -1409,11 +1409,11 @@ static ssize_t read_flush(struct file *file, char __user *buf,
1409 size_t count, loff_t *ppos, 1409 size_t count, loff_t *ppos,
1410 struct cache_detail *cd) 1410 struct cache_detail *cd)
1411{ 1411{
1412 char tbuf[20]; 1412 char tbuf[22];
1413 unsigned long p = *ppos; 1413 unsigned long p = *ppos;
1414 size_t len; 1414 size_t len;
1415 1415
1416 sprintf(tbuf, "%lu\n", convert_to_wallclock(cd->flush_time)); 1416 snprintf(tbuf, sizeof(tbuf), "%lu\n", convert_to_wallclock(cd->flush_time));
1417 len = strlen(tbuf); 1417 len = strlen(tbuf);
1418 if (p >= len) 1418 if (p >= len)
1419 return 0; 1419 return 0;
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index aaaadfbe36e..75853cabf4c 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -254,7 +254,6 @@ struct sock_xprt {
254 void (*old_data_ready)(struct sock *, int); 254 void (*old_data_ready)(struct sock *, int);
255 void (*old_state_change)(struct sock *); 255 void (*old_state_change)(struct sock *);
256 void (*old_write_space)(struct sock *); 256 void (*old_write_space)(struct sock *);
257 void (*old_error_report)(struct sock *);
258}; 257};
259 258
260/* 259/*
@@ -737,10 +736,10 @@ static int xs_tcp_send_request(struct rpc_task *task)
737 dprintk("RPC: sendmsg returned unrecognized error %d\n", 736 dprintk("RPC: sendmsg returned unrecognized error %d\n",
738 -status); 737 -status);
739 case -ECONNRESET: 738 case -ECONNRESET:
740 case -EPIPE:
741 xs_tcp_shutdown(xprt); 739 xs_tcp_shutdown(xprt);
742 case -ECONNREFUSED: 740 case -ECONNREFUSED:
743 case -ENOTCONN: 741 case -ENOTCONN:
742 case -EPIPE:
744 clear_bit(SOCK_ASYNC_NOSPACE, &transport->sock->flags); 743 clear_bit(SOCK_ASYNC_NOSPACE, &transport->sock->flags);
745 } 744 }
746 745
@@ -781,7 +780,6 @@ static void xs_save_old_callbacks(struct sock_xprt *transport, struct sock *sk)
781 transport->old_data_ready = sk->sk_data_ready; 780 transport->old_data_ready = sk->sk_data_ready;
782 transport->old_state_change = sk->sk_state_change; 781 transport->old_state_change = sk->sk_state_change;
783 transport->old_write_space = sk->sk_write_space; 782 transport->old_write_space = sk->sk_write_space;
784 transport->old_error_report = sk->sk_error_report;
785} 783}
786 784
787static void xs_restore_old_callbacks(struct sock_xprt *transport, struct sock *sk) 785static void xs_restore_old_callbacks(struct sock_xprt *transport, struct sock *sk)
@@ -789,7 +787,6 @@ static void xs_restore_old_callbacks(struct sock_xprt *transport, struct sock *s
789 sk->sk_data_ready = transport->old_data_ready; 787 sk->sk_data_ready = transport->old_data_ready;
790 sk->sk_state_change = transport->old_state_change; 788 sk->sk_state_change = transport->old_state_change;
791 sk->sk_write_space = transport->old_write_space; 789 sk->sk_write_space = transport->old_write_space;
792 sk->sk_error_report = transport->old_error_report;
793} 790}
794 791
795static void xs_reset_transport(struct sock_xprt *transport) 792static void xs_reset_transport(struct sock_xprt *transport)
@@ -1453,7 +1450,7 @@ static void xs_tcp_cancel_linger_timeout(struct rpc_xprt *xprt)
1453 xprt_clear_connecting(xprt); 1450 xprt_clear_connecting(xprt);
1454} 1451}
1455 1452
1456static void xs_sock_mark_closed(struct rpc_xprt *xprt) 1453static void xs_sock_reset_connection_flags(struct rpc_xprt *xprt)
1457{ 1454{
1458 smp_mb__before_clear_bit(); 1455 smp_mb__before_clear_bit();
1459 clear_bit(XPRT_CONNECTION_ABORT, &xprt->state); 1456 clear_bit(XPRT_CONNECTION_ABORT, &xprt->state);
@@ -1461,6 +1458,11 @@ static void xs_sock_mark_closed(struct rpc_xprt *xprt)
1461 clear_bit(XPRT_CLOSE_WAIT, &xprt->state); 1458 clear_bit(XPRT_CLOSE_WAIT, &xprt->state);
1462 clear_bit(XPRT_CLOSING, &xprt->state); 1459 clear_bit(XPRT_CLOSING, &xprt->state);
1463 smp_mb__after_clear_bit(); 1460 smp_mb__after_clear_bit();
1461}
1462
1463static void xs_sock_mark_closed(struct rpc_xprt *xprt)
1464{
1465 xs_sock_reset_connection_flags(xprt);
1464 /* Mark transport as closed and wake up all pending tasks */ 1466 /* Mark transport as closed and wake up all pending tasks */
1465 xprt_disconnect_done(xprt); 1467 xprt_disconnect_done(xprt);
1466} 1468}
@@ -1516,6 +1518,7 @@ static void xs_tcp_state_change(struct sock *sk)
1516 case TCP_CLOSE_WAIT: 1518 case TCP_CLOSE_WAIT:
1517 /* The server initiated a shutdown of the socket */ 1519 /* The server initiated a shutdown of the socket */
1518 xprt->connect_cookie++; 1520 xprt->connect_cookie++;
1521 clear_bit(XPRT_CONNECTED, &xprt->state);
1519 xs_tcp_force_close(xprt); 1522 xs_tcp_force_close(xprt);
1520 case TCP_CLOSING: 1523 case TCP_CLOSING:
1521 /* 1524 /*
@@ -1540,25 +1543,6 @@ static void xs_tcp_state_change(struct sock *sk)
1540 read_unlock_bh(&sk->sk_callback_lock); 1543 read_unlock_bh(&sk->sk_callback_lock);
1541} 1544}
1542 1545
1543/**
1544 * xs_error_report - callback mainly for catching socket errors
1545 * @sk: socket
1546 */
1547static void xs_error_report(struct sock *sk)
1548{
1549 struct rpc_xprt *xprt;
1550
1551 read_lock_bh(&sk->sk_callback_lock);
1552 if (!(xprt = xprt_from_sock(sk)))
1553 goto out;
1554 dprintk("RPC: %s client %p...\n"
1555 "RPC: error %d\n",
1556 __func__, xprt, sk->sk_err);
1557 xprt_wake_pending_tasks(xprt, -EAGAIN);
1558out:
1559 read_unlock_bh(&sk->sk_callback_lock);
1560}
1561
1562static void xs_write_space(struct sock *sk) 1546static void xs_write_space(struct sock *sk)
1563{ 1547{
1564 struct socket *sock; 1548 struct socket *sock;
@@ -1858,7 +1842,6 @@ static int xs_local_finish_connecting(struct rpc_xprt *xprt,
1858 sk->sk_user_data = xprt; 1842 sk->sk_user_data = xprt;
1859 sk->sk_data_ready = xs_local_data_ready; 1843 sk->sk_data_ready = xs_local_data_ready;
1860 sk->sk_write_space = xs_udp_write_space; 1844 sk->sk_write_space = xs_udp_write_space;
1861 sk->sk_error_report = xs_error_report;
1862 sk->sk_allocation = GFP_ATOMIC; 1845 sk->sk_allocation = GFP_ATOMIC;
1863 1846
1864 xprt_clear_connected(xprt); 1847 xprt_clear_connected(xprt);
@@ -1983,7 +1966,6 @@ static void xs_udp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock)
1983 sk->sk_user_data = xprt; 1966 sk->sk_user_data = xprt;
1984 sk->sk_data_ready = xs_udp_data_ready; 1967 sk->sk_data_ready = xs_udp_data_ready;
1985 sk->sk_write_space = xs_udp_write_space; 1968 sk->sk_write_space = xs_udp_write_space;
1986 sk->sk_error_report = xs_error_report;
1987 sk->sk_no_check = UDP_CSUM_NORCV; 1969 sk->sk_no_check = UDP_CSUM_NORCV;
1988 sk->sk_allocation = GFP_ATOMIC; 1970 sk->sk_allocation = GFP_ATOMIC;
1989 1971
@@ -2050,10 +2032,8 @@ static void xs_abort_connection(struct sock_xprt *transport)
2050 any.sa_family = AF_UNSPEC; 2032 any.sa_family = AF_UNSPEC;
2051 result = kernel_connect(transport->sock, &any, sizeof(any), 0); 2033 result = kernel_connect(transport->sock, &any, sizeof(any), 0);
2052 if (!result) 2034 if (!result)
2053 xs_sock_mark_closed(&transport->xprt); 2035 xs_sock_reset_connection_flags(&transport->xprt);
2054 else 2036 dprintk("RPC: AF_UNSPEC connect return code %d\n", result);
2055 dprintk("RPC: AF_UNSPEC connect return code %d\n",
2056 result);
2057} 2037}
2058 2038
2059static void xs_tcp_reuse_connection(struct sock_xprt *transport) 2039static void xs_tcp_reuse_connection(struct sock_xprt *transport)
@@ -2098,7 +2078,6 @@ static int xs_tcp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock)
2098 sk->sk_data_ready = xs_tcp_data_ready; 2078 sk->sk_data_ready = xs_tcp_data_ready;
2099 sk->sk_state_change = xs_tcp_state_change; 2079 sk->sk_state_change = xs_tcp_state_change;
2100 sk->sk_write_space = xs_tcp_write_space; 2080 sk->sk_write_space = xs_tcp_write_space;
2101 sk->sk_error_report = xs_error_report;
2102 sk->sk_allocation = GFP_ATOMIC; 2081 sk->sk_allocation = GFP_ATOMIC;
2103 2082
2104 /* socket options */ 2083 /* socket options */
diff --git a/net/tipc/handler.c b/net/tipc/handler.c
index 111ff8300ae..b36f0fcd9bd 100644
--- a/net/tipc/handler.c
+++ b/net/tipc/handler.c
@@ -116,7 +116,6 @@ void tipc_handler_stop(void)
116 return; 116 return;
117 117
118 handler_enabled = 0; 118 handler_enabled = 0;
119 tasklet_disable(&tipc_tasklet);
120 tasklet_kill(&tipc_tasklet); 119 tasklet_kill(&tipc_tasklet);
121 120
122 spin_lock_bh(&qitem_lock); 121 spin_lock_bh(&qitem_lock);
diff --git a/net/wireless/core.c b/net/wireless/core.c
index 443d4d7deea..3f725305208 100644
--- a/net/wireless/core.c
+++ b/net/wireless/core.c
@@ -526,8 +526,7 @@ int wiphy_register(struct wiphy *wiphy)
526 for (i = 0; i < sband->n_channels; i++) { 526 for (i = 0; i < sband->n_channels; i++) {
527 sband->channels[i].orig_flags = 527 sband->channels[i].orig_flags =
528 sband->channels[i].flags; 528 sband->channels[i].flags;
529 sband->channels[i].orig_mag = 529 sband->channels[i].orig_mag = INT_MAX;
530 sband->channels[i].max_antenna_gain;
531 sband->channels[i].orig_mpwr = 530 sband->channels[i].orig_mpwr =
532 sband->channels[i].max_power; 531 sband->channels[i].max_power;
533 sband->channels[i].band = band; 532 sband->channels[i].band = band;
diff --git a/net/wireless/mlme.c b/net/wireless/mlme.c
index 8016fee0752..904a7f36832 100644
--- a/net/wireless/mlme.c
+++ b/net/wireless/mlme.c
@@ -457,20 +457,14 @@ int __cfg80211_mlme_deauth(struct cfg80211_registered_device *rdev,
457 .reason_code = reason, 457 .reason_code = reason,
458 .ie = ie, 458 .ie = ie,
459 .ie_len = ie_len, 459 .ie_len = ie_len,
460 .local_state_change = local_state_change,
460 }; 461 };
461 462
462 ASSERT_WDEV_LOCK(wdev); 463 ASSERT_WDEV_LOCK(wdev);
463 464
464 if (local_state_change) { 465 if (local_state_change && (!wdev->current_bss ||
465 if (wdev->current_bss && 466 !ether_addr_equal(wdev->current_bss->pub.bssid, bssid)))
466 ether_addr_equal(wdev->current_bss->pub.bssid, bssid)) {
467 cfg80211_unhold_bss(wdev->current_bss);
468 cfg80211_put_bss(&wdev->current_bss->pub);
469 wdev->current_bss = NULL;
470 }
471
472 return 0; 467 return 0;
473 }
474 468
475 return rdev->ops->deauth(&rdev->wiphy, dev, &req); 469 return rdev->ops->deauth(&rdev->wiphy, dev, &req);
476} 470}
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 3b8cbbc214d..b75756b05af 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -141,9 +141,8 @@ static const struct ieee80211_regdomain world_regdom = {
141 .reg_rules = { 141 .reg_rules = {
142 /* IEEE 802.11b/g, channels 1..11 */ 142 /* IEEE 802.11b/g, channels 1..11 */
143 REG_RULE(2412-10, 2462+10, 40, 6, 20, 0), 143 REG_RULE(2412-10, 2462+10, 40, 6, 20, 0),
144 /* IEEE 802.11b/g, channels 12..13. No HT40 144 /* IEEE 802.11b/g, channels 12..13. */
145 * channel fits here. */ 145 REG_RULE(2467-10, 2472+10, 40, 6, 20,
146 REG_RULE(2467-10, 2472+10, 20, 6, 20,
147 NL80211_RRF_PASSIVE_SCAN | 146 NL80211_RRF_PASSIVE_SCAN |
148 NL80211_RRF_NO_IBSS), 147 NL80211_RRF_NO_IBSS),
149 /* IEEE 802.11 channel 14 - Only JP enables 148 /* IEEE 802.11 channel 14 - Only JP enables
@@ -908,7 +907,7 @@ static void handle_channel(struct wiphy *wiphy,
908 map_regdom_flags(reg_rule->flags) | bw_flags; 907 map_regdom_flags(reg_rule->flags) | bw_flags;
909 chan->max_antenna_gain = chan->orig_mag = 908 chan->max_antenna_gain = chan->orig_mag =
910 (int) MBI_TO_DBI(power_rule->max_antenna_gain); 909 (int) MBI_TO_DBI(power_rule->max_antenna_gain);
911 chan->max_power = chan->orig_mpwr = 910 chan->max_reg_power = chan->max_power = chan->orig_mpwr =
912 (int) MBM_TO_DBM(power_rule->max_eirp); 911 (int) MBM_TO_DBM(power_rule->max_eirp);
913 return; 912 return;
914 } 913 }
@@ -1331,7 +1330,8 @@ static void handle_channel_custom(struct wiphy *wiphy,
1331 1330
1332 chan->flags |= map_regdom_flags(reg_rule->flags) | bw_flags; 1331 chan->flags |= map_regdom_flags(reg_rule->flags) | bw_flags;
1333 chan->max_antenna_gain = (int) MBI_TO_DBI(power_rule->max_antenna_gain); 1332 chan->max_antenna_gain = (int) MBI_TO_DBI(power_rule->max_antenna_gain);
1334 chan->max_power = (int) MBM_TO_DBM(power_rule->max_eirp); 1333 chan->max_reg_power = chan->max_power =
1334 (int) MBM_TO_DBM(power_rule->max_eirp);
1335} 1335}
1336 1336
1337static void handle_band_custom(struct wiphy *wiphy, enum ieee80211_band band, 1337static void handle_band_custom(struct wiphy *wiphy, enum ieee80211_band band,
diff --git a/net/wireless/util.c b/net/wireless/util.c
index ef35f4ef2aa..2762e832998 100644
--- a/net/wireless/util.c
+++ b/net/wireless/util.c
@@ -309,23 +309,21 @@ unsigned int ieee80211_get_hdrlen_from_skb(const struct sk_buff *skb)
309} 309}
310EXPORT_SYMBOL(ieee80211_get_hdrlen_from_skb); 310EXPORT_SYMBOL(ieee80211_get_hdrlen_from_skb);
311 311
312static int ieee80211_get_mesh_hdrlen(struct ieee80211s_hdr *meshhdr) 312unsigned int ieee80211_get_mesh_hdrlen(struct ieee80211s_hdr *meshhdr)
313{ 313{
314 int ae = meshhdr->flags & MESH_FLAGS_AE; 314 int ae = meshhdr->flags & MESH_FLAGS_AE;
315 /* 7.1.3.5a.2 */ 315 /* 802.11-2012, 8.2.4.7.3 */
316 switch (ae) { 316 switch (ae) {
317 default:
317 case 0: 318 case 0:
318 return 6; 319 return 6;
319 case MESH_FLAGS_AE_A4: 320 case MESH_FLAGS_AE_A4:
320 return 12; 321 return 12;
321 case MESH_FLAGS_AE_A5_A6: 322 case MESH_FLAGS_AE_A5_A6:
322 return 18; 323 return 18;
323 case (MESH_FLAGS_AE_A4 | MESH_FLAGS_AE_A5_A6):
324 return 24;
325 default:
326 return 6;
327 } 324 }
328} 325}
326EXPORT_SYMBOL(ieee80211_get_mesh_hdrlen);
329 327
330int ieee80211_data_to_8023(struct sk_buff *skb, const u8 *addr, 328int ieee80211_data_to_8023(struct sk_buff *skb, const u8 *addr,
331 enum nl80211_iftype iftype) 329 enum nl80211_iftype iftype)
@@ -373,6 +371,8 @@ int ieee80211_data_to_8023(struct sk_buff *skb, const u8 *addr,
373 /* make sure meshdr->flags is on the linear part */ 371 /* make sure meshdr->flags is on the linear part */
374 if (!pskb_may_pull(skb, hdrlen + 1)) 372 if (!pskb_may_pull(skb, hdrlen + 1))
375 return -1; 373 return -1;
374 if (meshdr->flags & MESH_FLAGS_AE_A4)
375 return -1;
376 if (meshdr->flags & MESH_FLAGS_AE_A5_A6) { 376 if (meshdr->flags & MESH_FLAGS_AE_A5_A6) {
377 skb_copy_bits(skb, hdrlen + 377 skb_copy_bits(skb, hdrlen +
378 offsetof(struct ieee80211s_hdr, eaddr1), 378 offsetof(struct ieee80211s_hdr, eaddr1),
@@ -397,6 +397,8 @@ int ieee80211_data_to_8023(struct sk_buff *skb, const u8 *addr,
397 /* make sure meshdr->flags is on the linear part */ 397 /* make sure meshdr->flags is on the linear part */
398 if (!pskb_may_pull(skb, hdrlen + 1)) 398 if (!pskb_may_pull(skb, hdrlen + 1))
399 return -1; 399 return -1;
400 if (meshdr->flags & MESH_FLAGS_AE_A5_A6)
401 return -1;
400 if (meshdr->flags & MESH_FLAGS_AE_A4) 402 if (meshdr->flags & MESH_FLAGS_AE_A4)
401 skb_copy_bits(skb, hdrlen + 403 skb_copy_bits(skb, hdrlen +
402 offsetof(struct ieee80211s_hdr, eaddr1), 404 offsetof(struct ieee80211s_hdr, eaddr1),
diff --git a/scripts/Makefile.asm-generic b/scripts/Makefile.asm-generic
index 40caf3c26cd..d17e0ea911e 100644
--- a/scripts/Makefile.asm-generic
+++ b/scripts/Makefile.asm-generic
@@ -5,7 +5,7 @@
5# and for each file listed in this file with generic-y creates 5# and for each file listed in this file with generic-y creates
6# a small wrapper file in $(obj) (arch/$(SRCARCH)/include/generated/asm) 6# a small wrapper file in $(obj) (arch/$(SRCARCH)/include/generated/asm)
7 7
8kbuild-file := $(srctree)/arch/$(SRCARCH)/include/asm/Kbuild 8kbuild-file := $(srctree)/arch/$(SRCARCH)/include/$(src)/Kbuild
9-include $(kbuild-file) 9-include $(kbuild-file)
10 10
11include scripts/Kbuild.include 11include scripts/Kbuild.include
diff --git a/scripts/Makefile.fwinst b/scripts/Makefile.fwinst
index c3f69ae275d..4d908d16c03 100644
--- a/scripts/Makefile.fwinst
+++ b/scripts/Makefile.fwinst
@@ -27,7 +27,7 @@ endif
27installed-mod-fw := $(addprefix $(INSTALL_FW_PATH)/,$(mod-fw)) 27installed-mod-fw := $(addprefix $(INSTALL_FW_PATH)/,$(mod-fw))
28 28
29installed-fw := $(addprefix $(INSTALL_FW_PATH)/,$(fw-shipped-all)) 29installed-fw := $(addprefix $(INSTALL_FW_PATH)/,$(fw-shipped-all))
30installed-fw-dirs := $(sort $(dir $(installed-fw))) $(INSTALL_FW_PATH)/. 30installed-fw-dirs := $(sort $(dir $(installed-fw))) $(INSTALL_FW_PATH)/./
31 31
32# Workaround for make < 3.81, where .SECONDEXPANSION doesn't work. 32# Workaround for make < 3.81, where .SECONDEXPANSION doesn't work.
33PHONY += $(INSTALL_FW_PATH)/$$(%) install-all-dirs 33PHONY += $(INSTALL_FW_PATH)/$$(%) install-all-dirs
@@ -42,7 +42,7 @@ quiet_cmd_install = INSTALL $(subst $(srctree)/,,$@)
42$(installed-fw-dirs): 42$(installed-fw-dirs):
43 $(call cmd,mkdir) 43 $(call cmd,mkdir)
44 44
45$(installed-fw): $(INSTALL_FW_PATH)/%: $(obj)/% | $$(dir $(INSTALL_FW_PATH)/%) 45$(installed-fw): $(INSTALL_FW_PATH)/%: $(obj)/% | $(INSTALL_FW_PATH)/$$(dir %)
46 $(call cmd,install) 46 $(call cmd,install)
47 47
48PHONY += __fw_install __fw_modinst FORCE 48PHONY += __fw_install __fw_modinst FORCE
diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst
index 3d13d3a3edf..ecbb44797e2 100644
--- a/scripts/Makefile.modinst
+++ b/scripts/Makefile.modinst
@@ -16,8 +16,9 @@ PHONY += $(modules)
16__modinst: $(modules) 16__modinst: $(modules)
17 @: 17 @:
18 18
19# Don't stop modules_install if we can't sign external modules.
19quiet_cmd_modules_install = INSTALL $@ 20quiet_cmd_modules_install = INSTALL $@
20 cmd_modules_install = mkdir -p $(2); cp $@ $(2) ; $(mod_strip_cmd) $(2)/$(notdir $@) 21 cmd_modules_install = mkdir -p $(2); cp $@ $(2) ; $(mod_strip_cmd) $(2)/$(notdir $@) ; $(mod_sign_cmd) $(2)/$(notdir $@) $(patsubst %,|| true,$(KBUILD_EXTMOD))
21 22
22# Modules built outside the kernel source tree go into extra by default 23# Modules built outside the kernel source tree go into extra by default
23INSTALL_MOD_DIR ?= extra 24INSTALL_MOD_DIR ?= extra
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
index 002089141df..a1cb0222ebe 100644
--- a/scripts/Makefile.modpost
+++ b/scripts/Makefile.modpost
@@ -14,8 +14,7 @@
14# 3) create one <module>.mod.c file pr. module 14# 3) create one <module>.mod.c file pr. module
15# 4) create one Module.symvers file with CRC for all exported symbols 15# 4) create one Module.symvers file with CRC for all exported symbols
16# 5) compile all <module>.mod.c files 16# 5) compile all <module>.mod.c files
17# 6) final link of the module to a <module.ko> (or <module.unsigned>) file 17# 6) final link of the module to a <module.ko> file
18# 7) signs the modules to a <module.ko> file
19 18
20# Step 3 is used to place certain information in the module's ELF 19# Step 3 is used to place certain information in the module's ELF
21# section, including information such as: 20# section, including information such as:
@@ -33,8 +32,6 @@
33# Step 4 is solely used to allow module versioning in external modules, 32# Step 4 is solely used to allow module versioning in external modules,
34# where the CRC of each module is retrieved from the Module.symvers file. 33# where the CRC of each module is retrieved from the Module.symvers file.
35 34
36# Step 7 is dependent on CONFIG_MODULE_SIG being enabled.
37
38# KBUILD_MODPOST_WARN can be set to avoid error out in case of undefined 35# KBUILD_MODPOST_WARN can be set to avoid error out in case of undefined
39# symbols in the final module linking stage 36# symbols in the final module linking stage
40# KBUILD_MODPOST_NOFINAL can be set to skip the final link of modules. 37# KBUILD_MODPOST_NOFINAL can be set to skip the final link of modules.
@@ -119,7 +116,6 @@ $(modules:.ko=.mod.o): %.mod.o: %.mod.c FORCE
119targets += $(modules:.ko=.mod.o) 116targets += $(modules:.ko=.mod.o)
120 117
121# Step 6), final link of the modules 118# Step 6), final link of the modules
122ifneq ($(CONFIG_MODULE_SIG),y)
123quiet_cmd_ld_ko_o = LD [M] $@ 119quiet_cmd_ld_ko_o = LD [M] $@
124 cmd_ld_ko_o = $(LD) -r $(LDFLAGS) \ 120 cmd_ld_ko_o = $(LD) -r $(LDFLAGS) \
125 $(KBUILD_LDFLAGS_MODULE) $(LDFLAGS_MODULE) \ 121 $(KBUILD_LDFLAGS_MODULE) $(LDFLAGS_MODULE) \
@@ -129,78 +125,7 @@ $(modules): %.ko :%.o %.mod.o FORCE
129 $(call if_changed,ld_ko_o) 125 $(call if_changed,ld_ko_o)
130 126
131targets += $(modules) 127targets += $(modules)
132else
133quiet_cmd_ld_ko_unsigned_o = LD [M] $@
134 cmd_ld_ko_unsigned_o = \
135 $(LD) -r $(LDFLAGS) \
136 $(KBUILD_LDFLAGS_MODULE) $(LDFLAGS_MODULE) \
137 -o $@ $(filter-out FORCE,$^) \
138 $(if $(AFTER_LINK),; $(AFTER_LINK))
139
140$(modules:.ko=.ko.unsigned): %.ko.unsigned :%.o %.mod.o FORCE
141 $(call if_changed,ld_ko_unsigned_o)
142
143targets += $(modules:.ko=.ko.unsigned)
144
145# Step 7), sign the modules
146MODSECKEY = ./signing_key.priv
147MODPUBKEY = ./signing_key.x509
148
149ifeq ($(wildcard $(MODSECKEY))+$(wildcard $(MODPUBKEY)),$(MODSECKEY)+$(MODPUBKEY))
150ifeq ($(KBUILD_SRC),)
151 # no O= is being used
152 SCRIPTS_DIR := scripts
153else
154 SCRIPTS_DIR := $(KBUILD_SRC)/scripts
155endif
156SIGN_MODULES := 1
157else
158SIGN_MODULES := 0
159endif
160
161# only sign if it's an in-tree module
162ifneq ($(KBUILD_EXTMOD),)
163SIGN_MODULES := 0
164endif
165 128
166# We strip the module as best we can - note that using both strip and eu-strip
167# results in a smaller module than using either alone.
168EU_STRIP = $(shell which eu-strip || echo true)
169
170quiet_cmd_sign_ko_stripped_ko_unsigned = STRIP [M] $@
171 cmd_sign_ko_stripped_ko_unsigned = \
172 cp $< $@ && \
173 strip -x -g $@ && \
174 $(EU_STRIP) $@
175
176ifeq ($(SIGN_MODULES),1)
177
178quiet_cmd_genkeyid = GENKEYID $@
179 cmd_genkeyid = \
180 perl $(SCRIPTS_DIR)/x509keyid $< $<.signer $<.keyid
181
182%.signer %.keyid: %
183 $(call if_changed,genkeyid)
184
185KEYRING_DEP := $(MODSECKEY) $(MODPUBKEY) $(MODPUBKEY).signer $(MODPUBKEY).keyid
186quiet_cmd_sign_ko_ko_stripped = SIGN [M] $@
187 cmd_sign_ko_ko_stripped = \
188 sh $(SCRIPTS_DIR)/sign-file $(MODSECKEY) $(MODPUBKEY) $< $@
189else
190KEYRING_DEP :=
191quiet_cmd_sign_ko_ko_unsigned = NO SIGN [M] $@
192 cmd_sign_ko_ko_unsigned = \
193 cp $< $@
194endif
195
196$(modules): %.ko :%.ko.stripped $(KEYRING_DEP) FORCE
197 $(call if_changed,sign_ko_ko_stripped)
198
199$(patsubst %.ko,%.ko.stripped,$(modules)): %.ko.stripped :%.ko.unsigned FORCE
200 $(call if_changed,sign_ko_stripped_ko_unsigned)
201
202targets += $(modules)
203endif
204 129
205# Add FORCE to the prequisites of a target to force it to be always rebuilt. 130# Add FORCE to the prequisites of a target to force it to be always rebuilt.
206# --------------------------------------------------------------------------- 131# ---------------------------------------------------------------------------
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 21a9f5de0a2..f18750e3bd6 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1890,8 +1890,10 @@ sub process {
1890 } 1890 }
1891 1891
1892 if ($realfile =~ m@^(drivers/net/|net/)@ && 1892 if ($realfile =~ m@^(drivers/net/|net/)@ &&
1893 $rawline !~ m@^\+[ \t]*(\/\*|\*\/)@ && 1893 $rawline !~ m@^\+[ \t]*\*/[ \t]*$@ && #trailing */
1894 $rawline =~ m@^\+[ \t]*.+\*\/[ \t]*$@) { 1894 $rawline !~ m@^\+.*/\*.*\*/[ \t]*$@ && #inline /*...*/
1895 $rawline !~ m@^\+.*\*{2,}/[ \t]*$@ && #trailing **/
1896 $rawline =~ m@^\+[ \t]*.+\*\/[ \t]*$@) { #non blank */
1895 WARN("NETWORKING_BLOCK_COMMENT_STYLE", 1897 WARN("NETWORKING_BLOCK_COMMENT_STYLE",
1896 "networking block comments put the trailing */ on a separate line\n" . $herecurr); 1898 "networking block comments put the trailing */ on a separate line\n" . $herecurr);
1897 } 1899 }
diff --git a/scripts/dtc/dtc.h b/scripts/dtc/dtc.h
index d501c8605f2..3e42a071070 100644
--- a/scripts/dtc/dtc.h
+++ b/scripts/dtc/dtc.h
@@ -161,51 +161,27 @@ struct node {
161 struct label *labels; 161 struct label *labels;
162}; 162};
163 163
164static inline struct label *for_each_label_next(struct label *l)
165{
166 do {
167 l = l->next;
168 } while (l && l->deleted);
169
170 return l;
171}
172
173#define for_each_label(l0, l) \
174 for ((l) = (l0); (l); (l) = for_each_label_next(l))
175
176#define for_each_label_withdel(l0, l) \ 164#define for_each_label_withdel(l0, l) \
177 for ((l) = (l0); (l); (l) = (l)->next) 165 for ((l) = (l0); (l); (l) = (l)->next)
178 166
179static inline struct property *for_each_property_next(struct property *p) 167#define for_each_label(l0, l) \
180{ 168 for_each_label_withdel(l0, l) \
181 do { 169 if (!(l)->deleted)
182 p = p->next;
183 } while (p && p->deleted);
184
185 return p;
186}
187
188#define for_each_property(n, p) \
189 for ((p) = (n)->proplist; (p); (p) = for_each_property_next(p))
190 170
191#define for_each_property_withdel(n, p) \ 171#define for_each_property_withdel(n, p) \
192 for ((p) = (n)->proplist; (p); (p) = (p)->next) 172 for ((p) = (n)->proplist; (p); (p) = (p)->next)
193 173
194static inline struct node *for_each_child_next(struct node *c) 174#define for_each_property(n, p) \
195{ 175 for_each_property_withdel(n, p) \
196 do { 176 if (!(p)->deleted)
197 c = c->next_sibling;
198 } while (c && c->deleted);
199
200 return c;
201}
202
203#define for_each_child(n, c) \
204 for ((c) = (n)->children; (c); (c) = for_each_child_next(c))
205 177
206#define for_each_child_withdel(n, c) \ 178#define for_each_child_withdel(n, c) \
207 for ((c) = (n)->children; (c); (c) = (c)->next_sibling) 179 for ((c) = (n)->children; (c); (c) = (c)->next_sibling)
208 180
181#define for_each_child(n, c) \
182 for_each_child_withdel(n, c) \
183 if (!(c)->deleted)
184
209void add_label(struct label **labels, char *label); 185void add_label(struct label **labels, char *label);
210void delete_labels(struct label **labels); 186void delete_labels(struct label **labels);
211 187
diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h
index bd2e0989555..cdd48600e02 100644
--- a/scripts/kconfig/expr.h
+++ b/scripts/kconfig/expr.h
@@ -12,7 +12,7 @@ extern "C" {
12 12
13#include <assert.h> 13#include <assert.h>
14#include <stdio.h> 14#include <stdio.h>
15#include <sys/queue.h> 15#include "list.h"
16#ifndef __cplusplus 16#ifndef __cplusplus
17#include <stdbool.h> 17#include <stdbool.h>
18#endif 18#endif
@@ -175,12 +175,11 @@ struct menu {
175#define MENU_ROOT 0x0002 175#define MENU_ROOT 0x0002
176 176
177struct jump_key { 177struct jump_key {
178 CIRCLEQ_ENTRY(jump_key) entries; 178 struct list_head entries;
179 size_t offset; 179 size_t offset;
180 struct menu *target; 180 struct menu *target;
181 int index; 181 int index;
182}; 182};
183CIRCLEQ_HEAD(jk_head, jump_key);
184 183
185#define JUMP_NB 9 184#define JUMP_NB 9
186 185
diff --git a/scripts/kconfig/list.h b/scripts/kconfig/list.h
new file mode 100644
index 00000000000..0ae730be5f4
--- /dev/null
+++ b/scripts/kconfig/list.h
@@ -0,0 +1,91 @@
1#ifndef LIST_H
2#define LIST_H
3
4/*
5 * Copied from include/linux/...
6 */
7
8#undef offsetof
9#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
10
11/**
12 * container_of - cast a member of a structure out to the containing structure
13 * @ptr: the pointer to the member.
14 * @type: the type of the container struct this is embedded in.
15 * @member: the name of the member within the struct.
16 *
17 */
18#define container_of(ptr, type, member) ({ \
19 const typeof( ((type *)0)->member ) *__mptr = (ptr); \
20 (type *)( (char *)__mptr - offsetof(type,member) );})
21
22
23struct list_head {
24 struct list_head *next, *prev;
25};
26
27
28#define LIST_HEAD_INIT(name) { &(name), &(name) }
29
30#define LIST_HEAD(name) \
31 struct list_head name = LIST_HEAD_INIT(name)
32
33/**
34 * list_entry - get the struct for this entry
35 * @ptr: the &struct list_head pointer.
36 * @type: the type of the struct this is embedded in.
37 * @member: the name of the list_struct within the struct.
38 */
39#define list_entry(ptr, type, member) \
40 container_of(ptr, type, member)
41
42/**
43 * list_for_each_entry - iterate over list of given type
44 * @pos: the type * to use as a loop cursor.
45 * @head: the head for your list.
46 * @member: the name of the list_struct within the struct.
47 */
48#define list_for_each_entry(pos, head, member) \
49 for (pos = list_entry((head)->next, typeof(*pos), member); \
50 &pos->member != (head); \
51 pos = list_entry(pos->member.next, typeof(*pos), member))
52
53/**
54 * list_empty - tests whether a list is empty
55 * @head: the list to test.
56 */
57static inline int list_empty(const struct list_head *head)
58{
59 return head->next == head;
60}
61
62/*
63 * Insert a new entry between two known consecutive entries.
64 *
65 * This is only for internal list manipulation where we know
66 * the prev/next entries already!
67 */
68static inline void __list_add(struct list_head *_new,
69 struct list_head *prev,
70 struct list_head *next)
71{
72 next->prev = _new;
73 _new->next = next;
74 _new->prev = prev;
75 prev->next = _new;
76}
77
78/**
79 * list_add_tail - add a new entry
80 * @new: new entry to be added
81 * @head: list head to add it before
82 *
83 * Insert a new entry before the specified head.
84 * This is useful for implementing queues.
85 */
86static inline void list_add_tail(struct list_head *_new, struct list_head *head)
87{
88 __list_add(_new, head->prev, head);
89}
90
91#endif
diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h
index 1d1c08537f1..ef1a7381f95 100644
--- a/scripts/kconfig/lkc_proto.h
+++ b/scripts/kconfig/lkc_proto.h
@@ -21,9 +21,9 @@ P(menu_get_root_menu,struct menu *,(struct menu *menu));
21P(menu_get_parent_menu,struct menu *,(struct menu *menu)); 21P(menu_get_parent_menu,struct menu *,(struct menu *menu));
22P(menu_has_help,bool,(struct menu *menu)); 22P(menu_has_help,bool,(struct menu *menu));
23P(menu_get_help,const char *,(struct menu *menu)); 23P(menu_get_help,const char *,(struct menu *menu));
24P(get_symbol_str, void, (struct gstr *r, struct symbol *sym, struct jk_head 24P(get_symbol_str, void, (struct gstr *r, struct symbol *sym, struct list_head
25 *head)); 25 *head));
26P(get_relations_str, struct gstr, (struct symbol **sym_arr, struct jk_head 26P(get_relations_str, struct gstr, (struct symbol **sym_arr, struct list_head
27 *head)); 27 *head));
28P(menu_get_ext_help,void,(struct menu *menu, struct gstr *help)); 28P(menu_get_ext_help,void,(struct menu *menu, struct gstr *help));
29 29
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
index 48f67448af7..53975cf8760 100644
--- a/scripts/kconfig/mconf.c
+++ b/scripts/kconfig/mconf.c
@@ -312,7 +312,7 @@ static void set_config_filename(const char *config_filename)
312 312
313 313
314struct search_data { 314struct search_data {
315 struct jk_head *head; 315 struct list_head *head;
316 struct menu **targets; 316 struct menu **targets;
317 int *keys; 317 int *keys;
318}; 318};
@@ -323,7 +323,7 @@ static void update_text(char *buf, size_t start, size_t end, void *_data)
323 struct jump_key *pos; 323 struct jump_key *pos;
324 int k = 0; 324 int k = 0;
325 325
326 CIRCLEQ_FOREACH(pos, data->head, entries) { 326 list_for_each_entry(pos, data->head, entries) {
327 if (pos->offset >= start && pos->offset < end) { 327 if (pos->offset >= start && pos->offset < end) {
328 char header[4]; 328 char header[4];
329 329
@@ -375,7 +375,7 @@ again:
375 375
376 sym_arr = sym_re_search(dialog_input); 376 sym_arr = sym_re_search(dialog_input);
377 do { 377 do {
378 struct jk_head head = CIRCLEQ_HEAD_INITIALIZER(head); 378 LIST_HEAD(head);
379 struct menu *targets[JUMP_NB]; 379 struct menu *targets[JUMP_NB];
380 int keys[JUMP_NB + 1], i; 380 int keys[JUMP_NB + 1], i;
381 struct search_data data = { 381 struct search_data data = {
diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
index a3cade659f8..e98a05c8e50 100644
--- a/scripts/kconfig/menu.c
+++ b/scripts/kconfig/menu.c
@@ -508,7 +508,7 @@ const char *menu_get_help(struct menu *menu)
508} 508}
509 509
510static void get_prompt_str(struct gstr *r, struct property *prop, 510static void get_prompt_str(struct gstr *r, struct property *prop,
511 struct jk_head *head) 511 struct list_head *head)
512{ 512{
513 int i, j; 513 int i, j;
514 struct menu *submenu[8], *menu, *location = NULL; 514 struct menu *submenu[8], *menu, *location = NULL;
@@ -544,12 +544,13 @@ static void get_prompt_str(struct gstr *r, struct property *prop,
544 } else 544 } else
545 jump->target = location; 545 jump->target = location;
546 546
547 if (CIRCLEQ_EMPTY(head)) 547 if (list_empty(head))
548 jump->index = 0; 548 jump->index = 0;
549 else 549 else
550 jump->index = CIRCLEQ_LAST(head)->index + 1; 550 jump->index = list_entry(head->prev, struct jump_key,
551 entries)->index + 1;
551 552
552 CIRCLEQ_INSERT_TAIL(head, jump, entries); 553 list_add_tail(&jump->entries, head);
553 } 554 }
554 555
555 if (i > 0) { 556 if (i > 0) {
@@ -573,7 +574,8 @@ static void get_prompt_str(struct gstr *r, struct property *prop,
573/* 574/*
574 * head is optional and may be NULL 575 * head is optional and may be NULL
575 */ 576 */
576void get_symbol_str(struct gstr *r, struct symbol *sym, struct jk_head *head) 577void get_symbol_str(struct gstr *r, struct symbol *sym,
578 struct list_head *head)
577{ 579{
578 bool hit; 580 bool hit;
579 struct property *prop; 581 struct property *prop;
@@ -612,7 +614,7 @@ void get_symbol_str(struct gstr *r, struct symbol *sym, struct jk_head *head)
612 str_append(r, "\n\n"); 614 str_append(r, "\n\n");
613} 615}
614 616
615struct gstr get_relations_str(struct symbol **sym_arr, struct jk_head *head) 617struct gstr get_relations_str(struct symbol **sym_arr, struct list_head *head)
616{ 618{
617 struct symbol *sym; 619 struct symbol *sym;
618 struct gstr res = str_new(); 620 struct gstr res = str_new();
diff --git a/scripts/sign-file b/scripts/sign-file
index e58e34e50ac..974a20b661b 100644..100755
--- a/scripts/sign-file
+++ b/scripts/sign-file
@@ -1,115 +1,429 @@
1#!/bin/sh 1#!/usr/bin/perl -w
2# 2#
3# Sign a module file using the given key. 3# Sign a module file using the given key.
4# 4#
5# Format: sign-file <key> <x509> <src-file> <dst-file> 5# Format:
6# 6#
7 7# ./scripts/sign-file [-v] <key> <x509> <module> [<dest>]
8scripts=`dirname $0` 8#
9 9#
10CONFIG_MODULE_SIG_SHA512=y 10use strict;
11if [ -r .config ] 11use FileHandle;
12then 12use IPC::Open2;
13 . ./.config 13
14fi 14my $verbose = 0;
15 15if ($#ARGV >= 0 && $ARGV[0] eq "-v") {
16key="$1" 16 $verbose = 1;
17x509="$2" 17 shift;
18src="$3" 18}
19dst="$4" 19
20 20die "Format: ./scripts/sign-file [-v] <key> <x509> <module> [<dest>]\n"
21if [ ! -r "$key" ] 21 if ($#ARGV != 2 && $#ARGV != 3);
22then 22
23 echo "Can't read private key" >&2 23my $private_key = $ARGV[0];
24 exit 2 24my $x509 = $ARGV[1];
25fi 25my $module = $ARGV[2];
26 26my $dest = ($#ARGV == 3) ? $ARGV[3] : $ARGV[2] . "~";
27if [ ! -r "$x509" ] 27
28then 28die "Can't read private key\n" unless (-r $private_key);
29 echo "Can't read X.509 certificate" >&2 29die "Can't read X.509 certificate\n" unless (-r $x509);
30 exit 2 30die "Can't read module\n" unless (-r $module);
31fi 31
32if [ ! -r "$x509.signer" ] 32#
33then 33# Read the kernel configuration
34 echo "Can't read Signer name" >&2 34#
35 exit 2; 35my %config = (
36fi 36 CONFIG_MODULE_SIG_SHA512 => 1
37if [ ! -r "$x509.keyid" ] 37 );
38then 38
39 echo "Can't read Key identifier" >&2 39if (-r ".config") {
40 exit 2; 40 open(FD, "<.config") || die ".config";
41fi 41 while (<FD>) {
42 if ($_ =~ /^(CONFIG_.*)=[ym]/) {
43 $config{$1} = 1;
44 }
45 }
46 close(FD);
47}
48
49#
50# Function to read the contents of a file into a variable.
51#
52sub read_file($)
53{
54 my ($file) = @_;
55 my $contents;
56 my $len;
57
58 open(FD, "<$file") || die $file;
59 binmode FD;
60 my @st = stat(FD);
61 die $file if (!@st);
62 $len = read(FD, $contents, $st[7]) || die $file;
63 close(FD) || die $file;
64 die "$file: Wanted length ", $st[7], ", got ", $len, "\n"
65 if ($len != $st[7]);
66 return $contents;
67}
68
69###############################################################################
70#
71# First of all, we have to parse the X.509 certificate to find certain details
72# about it.
73#
74# We read the DER-encoded X509 certificate and parse it to extract the Subject
75# name and Subject Key Identifier. Theis provides the data we need to build
76# the certificate identifier.
77#
78# The signer's name part of the identifier is fabricated from the commonName,
79# the organizationName or the emailAddress components of the X.509 subject
80# name.
81#
82# The subject key ID is used to select which of that signer's certificates
83# we're intending to use to sign the module.
84#
85###############################################################################
86my $x509_certificate = read_file($x509);
87
88my $UNIV = 0 << 6;
89my $APPL = 1 << 6;
90my $CONT = 2 << 6;
91my $PRIV = 3 << 6;
92
93my $CONS = 0x20;
94
95my $BOOLEAN = 0x01;
96my $INTEGER = 0x02;
97my $BIT_STRING = 0x03;
98my $OCTET_STRING = 0x04;
99my $NULL = 0x05;
100my $OBJ_ID = 0x06;
101my $UTF8String = 0x0c;
102my $SEQUENCE = 0x10;
103my $SET = 0x11;
104my $UTCTime = 0x17;
105my $GeneralizedTime = 0x18;
106
107my %OIDs = (
108 pack("CCC", 85, 4, 3) => "commonName",
109 pack("CCC", 85, 4, 6) => "countryName",
110 pack("CCC", 85, 4, 10) => "organizationName",
111 pack("CCC", 85, 4, 11) => "organizationUnitName",
112 pack("CCCCCCCCC", 42, 134, 72, 134, 247, 13, 1, 1, 1) => "rsaEncryption",
113 pack("CCCCCCCCC", 42, 134, 72, 134, 247, 13, 1, 1, 5) => "sha1WithRSAEncryption",
114 pack("CCCCCCCCC", 42, 134, 72, 134, 247, 13, 1, 9, 1) => "emailAddress",
115 pack("CCC", 85, 29, 35) => "authorityKeyIdentifier",
116 pack("CCC", 85, 29, 14) => "subjectKeyIdentifier",
117 pack("CCC", 85, 29, 19) => "basicConstraints"
118);
119
120###############################################################################
121#
122# Extract an ASN.1 element from a string and return information about it.
123#
124###############################################################################
125sub asn1_extract($$@)
126{
127 my ($cursor, $expected_tag, $optional) = @_;
128
129 return [ -1 ]
130 if ($cursor->[1] == 0 && $optional);
131
132 die $x509, ": ", $cursor->[0], ": ASN.1 data underrun (elem ", $cursor->[1], ")\n"
133 if ($cursor->[1] < 2);
134
135 my ($tag, $len) = unpack("CC", substr(${$cursor->[2]}, $cursor->[0], 2));
136
137 if ($expected_tag != -1 && $tag != $expected_tag) {
138 return [ -1 ]
139 if ($optional);
140 die $x509, ": ", $cursor->[0], ": ASN.1 unexpected tag (", $tag,
141 " not ", $expected_tag, ")\n";
142 }
143
144 $cursor->[0] += 2;
145 $cursor->[1] -= 2;
146
147 die $x509, ": ", $cursor->[0], ": ASN.1 long tag\n"
148 if (($tag & 0x1f) == 0x1f);
149 die $x509, ": ", $cursor->[0], ": ASN.1 indefinite length\n"
150 if ($len == 0x80);
151
152 if ($len > 0x80) {
153 my $l = $len - 0x80;
154 die $x509, ": ", $cursor->[0], ": ASN.1 data underrun (len len $l)\n"
155 if ($cursor->[1] < $l);
156
157 if ($l == 0x1) {
158 $len = unpack("C", substr(${$cursor->[2]}, $cursor->[0], 1));
159 } elsif ($l == 0x2) {
160 $len = unpack("n", substr(${$cursor->[2]}, $cursor->[0], 2));
161 } elsif ($l == 0x3) {
162 $len = unpack("C", substr(${$cursor->[2]}, $cursor->[0], 1)) << 16;
163 $len = unpack("n", substr(${$cursor->[2]}, $cursor->[0] + 1, 2));
164 } elsif ($l == 0x4) {
165 $len = unpack("N", substr(${$cursor->[2]}, $cursor->[0], 4));
166 } else {
167 die $x509, ": ", $cursor->[0], ": ASN.1 element too long (", $l, ")\n";
168 }
169
170 $cursor->[0] += $l;
171 $cursor->[1] -= $l;
172 }
173
174 die $x509, ": ", $cursor->[0], ": ASN.1 data underrun (", $len, ")\n"
175 if ($cursor->[1] < $len);
176
177 my $ret = [ $tag, [ $cursor->[0], $len, $cursor->[2] ] ];
178 $cursor->[0] += $len;
179 $cursor->[1] -= $len;
180
181 return $ret;
182}
183
184###############################################################################
185#
186# Retrieve the data referred to by a cursor
187#
188###############################################################################
189sub asn1_retrieve($)
190{
191 my ($cursor) = @_;
192 my ($offset, $len, $data) = @$cursor;
193 return substr($$data, $offset, $len);
194}
195
196###############################################################################
197#
198# Roughly parse the X.509 certificate
199#
200###############################################################################
201my $cursor = [ 0, length($x509_certificate), \$x509_certificate ];
202
203my $cert = asn1_extract($cursor, $UNIV | $CONS | $SEQUENCE);
204my $tbs = asn1_extract($cert->[1], $UNIV | $CONS | $SEQUENCE);
205my $version = asn1_extract($tbs->[1], $CONT | $CONS | 0, 1);
206my $serial_number = asn1_extract($tbs->[1], $UNIV | $INTEGER);
207my $sig_type = asn1_extract($tbs->[1], $UNIV | $CONS | $SEQUENCE);
208my $issuer = asn1_extract($tbs->[1], $UNIV | $CONS | $SEQUENCE);
209my $validity = asn1_extract($tbs->[1], $UNIV | $CONS | $SEQUENCE);
210my $subject = asn1_extract($tbs->[1], $UNIV | $CONS | $SEQUENCE);
211my $key = asn1_extract($tbs->[1], $UNIV | $CONS | $SEQUENCE);
212my $issuer_uid = asn1_extract($tbs->[1], $CONT | $CONS | 1, 1);
213my $subject_uid = asn1_extract($tbs->[1], $CONT | $CONS | 2, 1);
214my $extension_list = asn1_extract($tbs->[1], $CONT | $CONS | 3, 1);
215
216my $subject_key_id = ();
217my $authority_key_id = ();
218
219#
220# Parse the extension list
221#
222if ($extension_list->[0] != -1) {
223 my $extensions = asn1_extract($extension_list->[1], $UNIV | $CONS | $SEQUENCE);
224
225 while ($extensions->[1]->[1] > 0) {
226 my $ext = asn1_extract($extensions->[1], $UNIV | $CONS | $SEQUENCE);
227 my $x_oid = asn1_extract($ext->[1], $UNIV | $OBJ_ID);
228 my $x_crit = asn1_extract($ext->[1], $UNIV | $BOOLEAN, 1);
229 my $x_val = asn1_extract($ext->[1], $UNIV | $OCTET_STRING);
230
231 my $raw_oid = asn1_retrieve($x_oid->[1]);
232 next if (!exists($OIDs{$raw_oid}));
233 my $x_type = $OIDs{$raw_oid};
234
235 my $raw_value = asn1_retrieve($x_val->[1]);
236
237 if ($x_type eq "subjectKeyIdentifier") {
238 my $vcursor = [ 0, length($raw_value), \$raw_value ];
239
240 $subject_key_id = asn1_extract($vcursor, $UNIV | $OCTET_STRING);
241 }
242 }
243}
244
245###############################################################################
246#
247# Determine what we're going to use as the signer's name. In order of
248# preference, take one of: commonName, organizationName or emailAddress.
249#
250###############################################################################
251my $org = "";
252my $cn = "";
253my $email = "";
254
255while ($subject->[1]->[1] > 0) {
256 my $rdn = asn1_extract($subject->[1], $UNIV | $CONS | $SET);
257 my $attr = asn1_extract($rdn->[1], $UNIV | $CONS | $SEQUENCE);
258 my $n_oid = asn1_extract($attr->[1], $UNIV | $OBJ_ID);
259 my $n_val = asn1_extract($attr->[1], -1);
260
261 my $raw_oid = asn1_retrieve($n_oid->[1]);
262 next if (!exists($OIDs{$raw_oid}));
263 my $n_type = $OIDs{$raw_oid};
264
265 my $raw_value = asn1_retrieve($n_val->[1]);
266
267 if ($n_type eq "organizationName") {
268 $org = $raw_value;
269 } elsif ($n_type eq "commonName") {
270 $cn = $raw_value;
271 } elsif ($n_type eq "emailAddress") {
272 $email = $raw_value;
273 }
274}
275
276my $signers_name = $email;
277
278if ($org && $cn) {
279 # Don't use the organizationName if the commonName repeats it
280 if (length($org) <= length($cn) &&
281 substr($cn, 0, length($org)) eq $org) {
282 $signers_name = $cn;
283 goto got_id_name;
284 }
285
286 # Or a signifcant chunk of it
287 if (length($org) >= 7 &&
288 length($cn) >= 7 &&
289 substr($cn, 0, 7) eq substr($org, 0, 7)) {
290 $signers_name = $cn;
291 goto got_id_name;
292 }
293
294 $signers_name = $org . ": " . $cn;
295} elsif ($org) {
296 $signers_name = $org;
297} elsif ($cn) {
298 $signers_name = $cn;
299}
300
301got_id_name:
302
303die $x509, ": ", "X.509: Couldn't find the Subject Key Identifier extension\n"
304 if (!$subject_key_id);
305
306my $key_identifier = asn1_retrieve($subject_key_id->[1]);
307
308###############################################################################
309#
310# Create and attach the module signature
311#
312###############################################################################
42 313
43# 314#
44# Signature parameters 315# Signature parameters
45# 316#
46algo=1 # Public-key crypto algorithm: RSA 317my $algo = 1; # Public-key crypto algorithm: RSA
47hash= # Digest algorithm 318my $hash = 0; # Digest algorithm
48id_type=1 # Identifier type: X.509 319my $id_type = 1; # Identifier type: X.509
49 320
50# 321#
51# Digest the data 322# Digest the data
52# 323#
53dgst= 324my ($dgst, $prologue) = ();
54if [ "$CONFIG_MODULE_SIG_SHA1" = "y" ] 325if (exists $config{"CONFIG_MODULE_SIG_SHA1"}) {
55then 326 $prologue = pack("C*",
56 prologue="0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x0E, 0x03, 0x02, 0x1A, 0x05, 0x00, 0x04, 0x14" 327 0x30, 0x21, 0x30, 0x09, 0x06, 0x05,
57 dgst=-sha1 328 0x2B, 0x0E, 0x03, 0x02, 0x1A,
58 hash=2 329 0x05, 0x00, 0x04, 0x14);
59elif [ "$CONFIG_MODULE_SIG_SHA224" = "y" ] 330 $dgst = "-sha1";
60then 331 $hash = 2;
61 prologue="0x30, 0x2d, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x04, 0x05, 0x00, 0x04, 0x1C" 332} elsif (exists $config{"CONFIG_MODULE_SIG_SHA224"}) {
62 dgst=-sha224 333 $prologue = pack("C*",
63 hash=7 334 0x30, 0x2d, 0x30, 0x0d, 0x06, 0x09,
64elif [ "$CONFIG_MODULE_SIG_SHA256" = "y" ] 335 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x04,
65then 336 0x05, 0x00, 0x04, 0x1C);
66 prologue="0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05, 0x00, 0x04, 0x20" 337 $dgst = "-sha224";
67 dgst=-sha256 338 $hash = 7;
68 hash=4 339} elsif (exists $config{"CONFIG_MODULE_SIG_SHA256"}) {
69elif [ "$CONFIG_MODULE_SIG_SHA384" = "y" ] 340 $prologue = pack("C*",
70then 341 0x30, 0x31, 0x30, 0x0d, 0x06, 0x09,
71 prologue="0x30, 0x41, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02, 0x05, 0x00, 0x04, 0x30" 342 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01,
72 dgst=-sha384 343 0x05, 0x00, 0x04, 0x20);
73 hash=5 344 $dgst = "-sha256";
74elif [ "$CONFIG_MODULE_SIG_SHA512" = "y" ] 345 $hash = 4;
75then 346} elsif (exists $config{"CONFIG_MODULE_SIG_SHA384"}) {
76 prologue="0x30, 0x51, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03, 0x05, 0x00, 0x04, 0x40" 347 $prologue = pack("C*",
77 dgst=-sha512 348 0x30, 0x41, 0x30, 0x0d, 0x06, 0x09,
78 hash=6 349 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02,
79else 350 0x05, 0x00, 0x04, 0x30);
80 echo "$0: Can't determine hash algorithm" >&2 351 $dgst = "-sha384";
81 exit 2 352 $hash = 5;
82fi 353} elsif (exists $config{"CONFIG_MODULE_SIG_SHA512"}) {
83 354 $prologue = pack("C*",
84( 355 0x30, 0x51, 0x30, 0x0d, 0x06, 0x09,
85perl -e "binmode STDOUT; print pack(\"C*\", $prologue)" || exit $? 356 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03,
86openssl dgst $dgst -binary $src || exit $? 357 0x05, 0x00, 0x04, 0x40);
87) >$src.dig || exit $? 358 $dgst = "-sha512";
359 $hash = 6;
360} else {
361 die "Can't determine hash algorithm";
362}
363
364#
365# Generate the digest and read from openssl's stdout
366#
367my $digest;
368$digest = readpipe("openssl dgst $dgst -binary $module") || die "openssl dgst";
88 369
89# 370#
90# Generate the binary signature, which will be just the integer that comprises 371# Generate the binary signature, which will be just the integer that comprises
91# the signature with no metadata attached. 372# the signature with no metadata attached.
92# 373#
93openssl rsautl -sign -inkey $key -keyform PEM -in $src.dig -out $src.sig || exit $? 374my $pid;
94signerlen=`stat -c %s $x509.signer` 375$pid = open2(*read_from, *write_to,
95keyidlen=`stat -c %s $x509.keyid` 376 "openssl rsautl -sign -inkey $private_key -keyform PEM") ||
96siglen=`stat -c %s $src.sig` 377 die "openssl rsautl";
378binmode write_to;
379print write_to $prologue . $digest || die "pipe to openssl rsautl";
380close(write_to) || die "pipe to openssl rsautl";
381
382binmode read_from;
383my $signature;
384read(read_from, $signature, 4096) || die "pipe from openssl rsautl";
385close(read_from) || die "pipe from openssl rsautl";
386$signature = pack("n", length($signature)) . $signature,
387
388waitpid($pid, 0) || die;
389die "openssl rsautl died: $?" if ($? >> 8);
97 390
98# 391#
99# Build the signed binary 392# Build the signed binary
100# 393#
101( 394my $unsigned_module = read_file($module);
102 cat $src || exit $? 395
103 echo '~Module signature appended~' || exit $? 396my $magic_number = "~Module signature appended~\n";
104 cat $x509.signer $x509.keyid || exit $? 397
398my $info = pack("CCCCCxxxN",
399 $algo, $hash, $id_type,
400 length($signers_name),
401 length($key_identifier),
402 length($signature));
105 403
106 # Preface each signature integer with a 2-byte BE length 404if ($verbose) {
107 perl -e "binmode STDOUT; print pack(\"n\", $siglen)" || exit $? 405 print "Size of unsigned module: ", length($unsigned_module), "\n";
108 cat $src.sig || exit $? 406 print "Size of signer's name : ", length($signers_name), "\n";
407 print "Size of key identifier : ", length($key_identifier), "\n";
408 print "Size of signature : ", length($signature), "\n";
409 print "Size of informaton : ", length($info), "\n";
410 print "Size of magic number : ", length($magic_number), "\n";
411 print "Signer's name : '", $signers_name, "'\n";
412 print "Digest : $dgst\n";
413}
109 414
110 # Generate the information block 415open(FD, ">$dest") || die $dest;
111 perl -e "binmode STDOUT; print pack(\"CCCCCxxxN\", $algo, $hash, $id_type, $signerlen, $keyidlen, $siglen + 2)" || exit $? 416binmode FD;
112) >$dst~ || exit $? 417print FD
418 $unsigned_module,
419 $signers_name,
420 $key_identifier,
421 $signature,
422 $info,
423 $magic_number
424 ;
425close FD || die $dest;
113 426
114# Permit in-place signing 427if ($#ARGV != 3) {
115mv $dst~ $dst || exit $? 428 rename($dest, $module) || die $module;
429}
diff --git a/scripts/x509keyid b/scripts/x509keyid
deleted file mode 100755
index c8e91a4af38..00000000000
--- a/scripts/x509keyid
+++ /dev/null
@@ -1,268 +0,0 @@
1#!/usr/bin/perl -w
2#
3# Generate an identifier from an X.509 certificate that can be placed in a
4# module signature to indentify the key to use.
5#
6# Format:
7#
8# ./scripts/x509keyid <x509-cert> <signer's-name> <key-id>
9#
10# We read the DER-encoded X509 certificate and parse it to extract the Subject
11# name and Subject Key Identifier. The provide the data we need to build the
12# certificate identifier.
13#
14# The signer's name part of the identifier is fabricated from the commonName,
15# the organizationName or the emailAddress components of the X.509 subject
16# name and written to the second named file.
17#
18# The subject key ID to select which of that signer's certificates we're
19# intending to use to sign the module is written to the third named file.
20#
21use strict;
22
23my $raw_data;
24
25die "Need three filenames\n" if ($#ARGV != 2);
26
27my $src = $ARGV[0];
28
29open(FD, "<$src") || die $src;
30binmode FD;
31my @st = stat(FD);
32die $src if (!@st);
33read(FD, $raw_data, $st[7]) || die $src;
34close(FD);
35
36my $UNIV = 0 << 6;
37my $APPL = 1 << 6;
38my $CONT = 2 << 6;
39my $PRIV = 3 << 6;
40
41my $CONS = 0x20;
42
43my $BOOLEAN = 0x01;
44my $INTEGER = 0x02;
45my $BIT_STRING = 0x03;
46my $OCTET_STRING = 0x04;
47my $NULL = 0x05;
48my $OBJ_ID = 0x06;
49my $UTF8String = 0x0c;
50my $SEQUENCE = 0x10;
51my $SET = 0x11;
52my $UTCTime = 0x17;
53my $GeneralizedTime = 0x18;
54
55my %OIDs = (
56 pack("CCC", 85, 4, 3) => "commonName",
57 pack("CCC", 85, 4, 6) => "countryName",
58 pack("CCC", 85, 4, 10) => "organizationName",
59 pack("CCC", 85, 4, 11) => "organizationUnitName",
60 pack("CCCCCCCCC", 42, 134, 72, 134, 247, 13, 1, 1, 1) => "rsaEncryption",
61 pack("CCCCCCCCC", 42, 134, 72, 134, 247, 13, 1, 1, 5) => "sha1WithRSAEncryption",
62 pack("CCCCCCCCC", 42, 134, 72, 134, 247, 13, 1, 9, 1) => "emailAddress",
63 pack("CCC", 85, 29, 35) => "authorityKeyIdentifier",
64 pack("CCC", 85, 29, 14) => "subjectKeyIdentifier",
65 pack("CCC", 85, 29, 19) => "basicConstraints"
66);
67
68###############################################################################
69#
70# Extract an ASN.1 element from a string and return information about it.
71#
72###############################################################################
73sub asn1_extract($$@)
74{
75 my ($cursor, $expected_tag, $optional) = @_;
76
77 return [ -1 ]
78 if ($cursor->[1] == 0 && $optional);
79
80 die $src, ": ", $cursor->[0], ": ASN.1 data underrun (elem ", $cursor->[1], ")\n"
81 if ($cursor->[1] < 2);
82
83 my ($tag, $len) = unpack("CC", substr(${$cursor->[2]}, $cursor->[0], 2));
84
85 if ($expected_tag != -1 && $tag != $expected_tag) {
86 return [ -1 ]
87 if ($optional);
88 die $src, ": ", $cursor->[0], ": ASN.1 unexpected tag (", $tag,
89 " not ", $expected_tag, ")\n";
90 }
91
92 $cursor->[0] += 2;
93 $cursor->[1] -= 2;
94
95 die $src, ": ", $cursor->[0], ": ASN.1 long tag\n"
96 if (($tag & 0x1f) == 0x1f);
97 die $src, ": ", $cursor->[0], ": ASN.1 indefinite length\n"
98 if ($len == 0x80);
99
100 if ($len > 0x80) {
101 my $l = $len - 0x80;
102 die $src, ": ", $cursor->[0], ": ASN.1 data underrun (len len $l)\n"
103 if ($cursor->[1] < $l);
104
105 if ($l == 0x1) {
106 $len = unpack("C", substr(${$cursor->[2]}, $cursor->[0], 1));
107 } elsif ($l = 0x2) {
108 $len = unpack("n", substr(${$cursor->[2]}, $cursor->[0], 2));
109 } elsif ($l = 0x3) {
110 $len = unpack("C", substr(${$cursor->[2]}, $cursor->[0], 1)) << 16;
111 $len = unpack("n", substr(${$cursor->[2]}, $cursor->[0] + 1, 2));
112 } elsif ($l = 0x4) {
113 $len = unpack("N", substr(${$cursor->[2]}, $cursor->[0], 4));
114 } else {
115 die $src, ": ", $cursor->[0], ": ASN.1 element too long (", $l, ")\n";
116 }
117
118 $cursor->[0] += $l;
119 $cursor->[1] -= $l;
120 }
121
122 die $src, ": ", $cursor->[0], ": ASN.1 data underrun (", $len, ")\n"
123 if ($cursor->[1] < $len);
124
125 my $ret = [ $tag, [ $cursor->[0], $len, $cursor->[2] ] ];
126 $cursor->[0] += $len;
127 $cursor->[1] -= $len;
128
129 return $ret;
130}
131
132###############################################################################
133#
134# Retrieve the data referred to by a cursor
135#
136###############################################################################
137sub asn1_retrieve($)
138{
139 my ($cursor) = @_;
140 my ($offset, $len, $data) = @$cursor;
141 return substr($$data, $offset, $len);
142}
143
144###############################################################################
145#
146# Roughly parse the X.509 certificate
147#
148###############################################################################
149my $cursor = [ 0, length($raw_data), \$raw_data ];
150
151my $cert = asn1_extract($cursor, $UNIV | $CONS | $SEQUENCE);
152my $tbs = asn1_extract($cert->[1], $UNIV | $CONS | $SEQUENCE);
153my $version = asn1_extract($tbs->[1], $CONT | $CONS | 0, 1);
154my $serial_number = asn1_extract($tbs->[1], $UNIV | $INTEGER);
155my $sig_type = asn1_extract($tbs->[1], $UNIV | $CONS | $SEQUENCE);
156my $issuer = asn1_extract($tbs->[1], $UNIV | $CONS | $SEQUENCE);
157my $validity = asn1_extract($tbs->[1], $UNIV | $CONS | $SEQUENCE);
158my $subject = asn1_extract($tbs->[1], $UNIV | $CONS | $SEQUENCE);
159my $key = asn1_extract($tbs->[1], $UNIV | $CONS | $SEQUENCE);
160my $issuer_uid = asn1_extract($tbs->[1], $CONT | $CONS | 1, 1);
161my $subject_uid = asn1_extract($tbs->[1], $CONT | $CONS | 2, 1);
162my $extension_list = asn1_extract($tbs->[1], $CONT | $CONS | 3, 1);
163
164my $subject_key_id = ();
165my $authority_key_id = ();
166
167#
168# Parse the extension list
169#
170if ($extension_list->[0] != -1) {
171 my $extensions = asn1_extract($extension_list->[1], $UNIV | $CONS | $SEQUENCE);
172
173 while ($extensions->[1]->[1] > 0) {
174 my $ext = asn1_extract($extensions->[1], $UNIV | $CONS | $SEQUENCE);
175 my $x_oid = asn1_extract($ext->[1], $UNIV | $OBJ_ID);
176 my $x_crit = asn1_extract($ext->[1], $UNIV | $BOOLEAN, 1);
177 my $x_val = asn1_extract($ext->[1], $UNIV | $OCTET_STRING);
178
179 my $raw_oid = asn1_retrieve($x_oid->[1]);
180 next if (!exists($OIDs{$raw_oid}));
181 my $x_type = $OIDs{$raw_oid};
182
183 my $raw_value = asn1_retrieve($x_val->[1]);
184
185 if ($x_type eq "subjectKeyIdentifier") {
186 my $vcursor = [ 0, length($raw_value), \$raw_value ];
187
188 $subject_key_id = asn1_extract($vcursor, $UNIV | $OCTET_STRING);
189 }
190 }
191}
192
193###############################################################################
194#
195# Determine what we're going to use as the signer's name. In order of
196# preference, take one of: commonName, organizationName or emailAddress.
197#
198###############################################################################
199my $org = "";
200my $cn = "";
201my $email = "";
202
203while ($subject->[1]->[1] > 0) {
204 my $rdn = asn1_extract($subject->[1], $UNIV | $CONS | $SET);
205 my $attr = asn1_extract($rdn->[1], $UNIV | $CONS | $SEQUENCE);
206 my $n_oid = asn1_extract($attr->[1], $UNIV | $OBJ_ID);
207 my $n_val = asn1_extract($attr->[1], -1);
208
209 my $raw_oid = asn1_retrieve($n_oid->[1]);
210 next if (!exists($OIDs{$raw_oid}));
211 my $n_type = $OIDs{$raw_oid};
212
213 my $raw_value = asn1_retrieve($n_val->[1]);
214
215 if ($n_type eq "organizationName") {
216 $org = $raw_value;
217 } elsif ($n_type eq "commonName") {
218 $cn = $raw_value;
219 } elsif ($n_type eq "emailAddress") {
220 $email = $raw_value;
221 }
222}
223
224my $id_name = $email;
225
226if ($org && $cn) {
227 # Don't use the organizationName if the commonName repeats it
228 if (length($org) <= length($cn) &&
229 substr($cn, 0, length($org)) eq $org) {
230 $id_name = $cn;
231 goto got_id_name;
232 }
233
234 # Or a signifcant chunk of it
235 if (length($org) >= 7 &&
236 length($cn) >= 7 &&
237 substr($cn, 0, 7) eq substr($org, 0, 7)) {
238 $id_name = $cn;
239 goto got_id_name;
240 }
241
242 $id_name = $org . ": " . $cn;
243} elsif ($org) {
244 $id_name = $org;
245} elsif ($cn) {
246 $id_name = $cn;
247}
248
249got_id_name:
250
251###############################################################################
252#
253# Output the signer's name and the key identifier that we're going to include
254# in module signatures.
255#
256###############################################################################
257die $src, ": ", "X.509: Couldn't find the Subject Key Identifier extension\n"
258 if (!$subject_key_id);
259
260my $id_key_id = asn1_retrieve($subject_key_id->[1]);
261
262open(OUTFD, ">$ARGV[1]") || die $ARGV[1];
263print OUTFD $id_name;
264close OUTFD || die $ARGV[1];
265
266open(OUTFD, ">$ARGV[2]") || die $ARGV[2];
267print OUTFD $id_key_id;
268close OUTFD || die $ARGV[2];
diff --git a/security/apparmor/Makefile b/security/apparmor/Makefile
index 7b3021cebbe..5706b74c857 100644
--- a/security/apparmor/Makefile
+++ b/security/apparmor/Makefile
@@ -57,7 +57,7 @@ cmd_make-rlim = echo "static const char *const rlim_names[RLIM_NLIMITS] = {" \
57 57
58$(obj)/capability.o : $(obj)/capability_names.h 58$(obj)/capability.o : $(obj)/capability_names.h
59$(obj)/resource.o : $(obj)/rlim_names.h 59$(obj)/resource.o : $(obj)/rlim_names.h
60$(obj)/capability_names.h : $(srctree)/include/linux/capability.h \ 60$(obj)/capability_names.h : $(srctree)/include/uapi/linux/capability.h \
61 $(src)/Makefile 61 $(src)/Makefile
62 $(call cmd,make-caps) 62 $(call cmd,make-caps)
63$(obj)/rlim_names.h : $(srctree)/include/uapi/asm-generic/resource.h \ 63$(obj)/rlim_names.h : $(srctree)/include/uapi/asm-generic/resource.h \
diff --git a/security/apparmor/policy.c b/security/apparmor/policy.c
index cf5fd220309..813200384d9 100644
--- a/security/apparmor/policy.c
+++ b/security/apparmor/policy.c
@@ -724,6 +724,8 @@ fail:
724 */ 724 */
725static void free_profile(struct aa_profile *profile) 725static void free_profile(struct aa_profile *profile)
726{ 726{
727 struct aa_profile *p;
728
727 AA_DEBUG("%s(%p)\n", __func__, profile); 729 AA_DEBUG("%s(%p)\n", __func__, profile);
728 730
729 if (!profile) 731 if (!profile)
@@ -751,7 +753,27 @@ static void free_profile(struct aa_profile *profile)
751 aa_put_dfa(profile->xmatch); 753 aa_put_dfa(profile->xmatch);
752 aa_put_dfa(profile->policy.dfa); 754 aa_put_dfa(profile->policy.dfa);
753 755
754 aa_put_profile(profile->replacedby); 756 /* put the profile reference for replacedby, but not via
757 * put_profile(kref_put).
758 * replacedby can form a long chain that can result in cascading
759 * frees that blows the stack because kref_put makes a nested fn
760 * call (it looks like recursion, with free_profile calling
761 * free_profile) for each profile in the chain lp#1056078.
762 */
763 for (p = profile->replacedby; p; ) {
764 if (atomic_dec_and_test(&p->base.count.refcount)) {
765 /* no more refs on p, grab its replacedby */
766 struct aa_profile *next = p->replacedby;
767 /* break the chain */
768 p->replacedby = NULL;
769 /* now free p, chain is broken */
770 free_profile(p);
771
772 /* follow up with next profile in the chain */
773 p = next;
774 } else
775 break;
776 }
755 777
756 kzfree(profile); 778 kzfree(profile);
757} 779}
diff --git a/security/device_cgroup.c b/security/device_cgroup.c
index 44dfc415a37..b08d20c66c2 100644
--- a/security/device_cgroup.c
+++ b/security/device_cgroup.c
@@ -42,7 +42,10 @@ struct dev_exception_item {
42struct dev_cgroup { 42struct dev_cgroup {
43 struct cgroup_subsys_state css; 43 struct cgroup_subsys_state css;
44 struct list_head exceptions; 44 struct list_head exceptions;
45 bool deny_all; 45 enum {
46 DEVCG_DEFAULT_ALLOW,
47 DEVCG_DEFAULT_DENY,
48 } behavior;
46}; 49};
47 50
48static inline struct dev_cgroup *css_to_devcgroup(struct cgroup_subsys_state *s) 51static inline struct dev_cgroup *css_to_devcgroup(struct cgroup_subsys_state *s)
@@ -161,8 +164,8 @@ static void dev_exception_clean(struct dev_cgroup *dev_cgroup)
161 struct dev_exception_item *ex, *tmp; 164 struct dev_exception_item *ex, *tmp;
162 165
163 list_for_each_entry_safe(ex, tmp, &dev_cgroup->exceptions, list) { 166 list_for_each_entry_safe(ex, tmp, &dev_cgroup->exceptions, list) {
164 list_del(&ex->list); 167 list_del_rcu(&ex->list);
165 kfree(ex); 168 kfree_rcu(ex, rcu);
166 } 169 }
167} 170}
168 171
@@ -182,13 +185,13 @@ static struct cgroup_subsys_state *devcgroup_create(struct cgroup *cgroup)
182 parent_cgroup = cgroup->parent; 185 parent_cgroup = cgroup->parent;
183 186
184 if (parent_cgroup == NULL) 187 if (parent_cgroup == NULL)
185 dev_cgroup->deny_all = false; 188 dev_cgroup->behavior = DEVCG_DEFAULT_ALLOW;
186 else { 189 else {
187 parent_dev_cgroup = cgroup_to_devcgroup(parent_cgroup); 190 parent_dev_cgroup = cgroup_to_devcgroup(parent_cgroup);
188 mutex_lock(&devcgroup_mutex); 191 mutex_lock(&devcgroup_mutex);
189 ret = dev_exceptions_copy(&dev_cgroup->exceptions, 192 ret = dev_exceptions_copy(&dev_cgroup->exceptions,
190 &parent_dev_cgroup->exceptions); 193 &parent_dev_cgroup->exceptions);
191 dev_cgroup->deny_all = parent_dev_cgroup->deny_all; 194 dev_cgroup->behavior = parent_dev_cgroup->behavior;
192 mutex_unlock(&devcgroup_mutex); 195 mutex_unlock(&devcgroup_mutex);
193 if (ret) { 196 if (ret) {
194 kfree(dev_cgroup); 197 kfree(dev_cgroup);
@@ -260,7 +263,7 @@ static int devcgroup_seq_read(struct cgroup *cgroup, struct cftype *cft,
260 * - List the exceptions in case the default policy is to deny 263 * - List the exceptions in case the default policy is to deny
261 * This way, the file remains as a "whitelist of devices" 264 * This way, the file remains as a "whitelist of devices"
262 */ 265 */
263 if (devcgroup->deny_all == false) { 266 if (devcgroup->behavior == DEVCG_DEFAULT_ALLOW) {
264 set_access(acc, ACC_MASK); 267 set_access(acc, ACC_MASK);
265 set_majmin(maj, ~0); 268 set_majmin(maj, ~0);
266 set_majmin(min, ~0); 269 set_majmin(min, ~0);
@@ -295,7 +298,7 @@ static int may_access(struct dev_cgroup *dev_cgroup,
295 struct dev_exception_item *ex; 298 struct dev_exception_item *ex;
296 bool match = false; 299 bool match = false;
297 300
298 list_for_each_entry(ex, &dev_cgroup->exceptions, list) { 301 list_for_each_entry_rcu(ex, &dev_cgroup->exceptions, list) {
299 if ((refex->type & DEV_BLOCK) && !(ex->type & DEV_BLOCK)) 302 if ((refex->type & DEV_BLOCK) && !(ex->type & DEV_BLOCK))
300 continue; 303 continue;
301 if ((refex->type & DEV_CHAR) && !(ex->type & DEV_CHAR)) 304 if ((refex->type & DEV_CHAR) && !(ex->type & DEV_CHAR))
@@ -314,12 +317,12 @@ static int may_access(struct dev_cgroup *dev_cgroup,
314 * In two cases we'll consider this new exception valid: 317 * In two cases we'll consider this new exception valid:
315 * - the dev cgroup has its default policy to allow + exception list: 318 * - the dev cgroup has its default policy to allow + exception list:
316 * the new exception should *not* match any of the exceptions 319 * the new exception should *not* match any of the exceptions
317 * (!deny_all, !match) 320 * (behavior == DEVCG_DEFAULT_ALLOW, !match)
318 * - the dev cgroup has its default policy to deny + exception list: 321 * - the dev cgroup has its default policy to deny + exception list:
319 * the new exception *should* match the exceptions 322 * the new exception *should* match the exceptions
320 * (deny_all, match) 323 * (behavior == DEVCG_DEFAULT_DENY, match)
321 */ 324 */
322 if (dev_cgroup->deny_all == match) 325 if ((dev_cgroup->behavior == DEVCG_DEFAULT_DENY) == match)
323 return 1; 326 return 1;
324 return 0; 327 return 0;
325} 328}
@@ -341,6 +344,19 @@ static int parent_has_perm(struct dev_cgroup *childcg,
341 return may_access(parent, ex); 344 return may_access(parent, ex);
342} 345}
343 346
347/**
348 * may_allow_all - checks if it's possible to change the behavior to
349 * allow based on parent's rules.
350 * @parent: device cgroup's parent
351 * returns: != 0 in case it's allowed, 0 otherwise
352 */
353static inline int may_allow_all(struct dev_cgroup *parent)
354{
355 if (!parent)
356 return 1;
357 return parent->behavior == DEVCG_DEFAULT_ALLOW;
358}
359
344/* 360/*
345 * Modify the exception list using allow/deny rules. 361 * Modify the exception list using allow/deny rules.
346 * CAP_SYS_ADMIN is needed for this. It's at least separate from CAP_MKNOD 362 * CAP_SYS_ADMIN is needed for this. It's at least separate from CAP_MKNOD
@@ -358,13 +374,18 @@ static int devcgroup_update_access(struct dev_cgroup *devcgroup,
358 int filetype, const char *buffer) 374 int filetype, const char *buffer)
359{ 375{
360 const char *b; 376 const char *b;
361 char *endp; 377 char temp[12]; /* 11 + 1 characters needed for a u32 */
362 int count; 378 int count, rc;
363 struct dev_exception_item ex; 379 struct dev_exception_item ex;
380 struct cgroup *p = devcgroup->css.cgroup;
381 struct dev_cgroup *parent = NULL;
364 382
365 if (!capable(CAP_SYS_ADMIN)) 383 if (!capable(CAP_SYS_ADMIN))
366 return -EPERM; 384 return -EPERM;
367 385
386 if (p->parent)
387 parent = cgroup_to_devcgroup(p->parent);
388
368 memset(&ex, 0, sizeof(ex)); 389 memset(&ex, 0, sizeof(ex));
369 b = buffer; 390 b = buffer;
370 391
@@ -372,14 +393,21 @@ static int devcgroup_update_access(struct dev_cgroup *devcgroup,
372 case 'a': 393 case 'a':
373 switch (filetype) { 394 switch (filetype) {
374 case DEVCG_ALLOW: 395 case DEVCG_ALLOW:
375 if (!parent_has_perm(devcgroup, &ex)) 396 if (!may_allow_all(parent))
376 return -EPERM; 397 return -EPERM;
377 dev_exception_clean(devcgroup); 398 dev_exception_clean(devcgroup);
378 devcgroup->deny_all = false; 399 devcgroup->behavior = DEVCG_DEFAULT_ALLOW;
400 if (!parent)
401 break;
402
403 rc = dev_exceptions_copy(&devcgroup->exceptions,
404 &parent->exceptions);
405 if (rc)
406 return rc;
379 break; 407 break;
380 case DEVCG_DENY: 408 case DEVCG_DENY:
381 dev_exception_clean(devcgroup); 409 dev_exception_clean(devcgroup);
382 devcgroup->deny_all = true; 410 devcgroup->behavior = DEVCG_DEFAULT_DENY;
383 break; 411 break;
384 default: 412 default:
385 return -EINVAL; 413 return -EINVAL;
@@ -402,8 +430,16 @@ static int devcgroup_update_access(struct dev_cgroup *devcgroup,
402 ex.major = ~0; 430 ex.major = ~0;
403 b++; 431 b++;
404 } else if (isdigit(*b)) { 432 } else if (isdigit(*b)) {
405 ex.major = simple_strtoul(b, &endp, 10); 433 memset(temp, 0, sizeof(temp));
406 b = endp; 434 for (count = 0; count < sizeof(temp) - 1; count++) {
435 temp[count] = *b;
436 b++;
437 if (!isdigit(*b))
438 break;
439 }
440 rc = kstrtou32(temp, 10, &ex.major);
441 if (rc)
442 return -EINVAL;
407 } else { 443 } else {
408 return -EINVAL; 444 return -EINVAL;
409 } 445 }
@@ -416,8 +452,16 @@ static int devcgroup_update_access(struct dev_cgroup *devcgroup,
416 ex.minor = ~0; 452 ex.minor = ~0;
417 b++; 453 b++;
418 } else if (isdigit(*b)) { 454 } else if (isdigit(*b)) {
419 ex.minor = simple_strtoul(b, &endp, 10); 455 memset(temp, 0, sizeof(temp));
420 b = endp; 456 for (count = 0; count < sizeof(temp) - 1; count++) {
457 temp[count] = *b;
458 b++;
459 if (!isdigit(*b))
460 break;
461 }
462 rc = kstrtou32(temp, 10, &ex.minor);
463 if (rc)
464 return -EINVAL;
421 } else { 465 } else {
422 return -EINVAL; 466 return -EINVAL;
423 } 467 }
@@ -452,7 +496,7 @@ static int devcgroup_update_access(struct dev_cgroup *devcgroup,
452 * an matching exception instead. And be silent about it: we 496 * an matching exception instead. And be silent about it: we
453 * don't want to break compatibility 497 * don't want to break compatibility
454 */ 498 */
455 if (devcgroup->deny_all == false) { 499 if (devcgroup->behavior == DEVCG_DEFAULT_ALLOW) {
456 dev_exception_rm(devcgroup, &ex); 500 dev_exception_rm(devcgroup, &ex);
457 return 0; 501 return 0;
458 } 502 }
@@ -463,7 +507,7 @@ static int devcgroup_update_access(struct dev_cgroup *devcgroup,
463 * an matching exception instead. And be silent about it: we 507 * an matching exception instead. And be silent about it: we
464 * don't want to break compatibility 508 * don't want to break compatibility
465 */ 509 */
466 if (devcgroup->deny_all == true) { 510 if (devcgroup->behavior == DEVCG_DEFAULT_DENY) {
467 dev_exception_rm(devcgroup, &ex); 511 dev_exception_rm(devcgroup, &ex);
468 return 0; 512 return 0;
469 } 513 }
@@ -533,10 +577,10 @@ struct cgroup_subsys devices_subsys = {
533 * 577 *
534 * returns 0 on success, -EPERM case the operation is not permitted 578 * returns 0 on success, -EPERM case the operation is not permitted
535 */ 579 */
536static int __devcgroup_check_permission(struct dev_cgroup *dev_cgroup, 580static int __devcgroup_check_permission(short type, u32 major, u32 minor,
537 short type, u32 major, u32 minor,
538 short access) 581 short access)
539{ 582{
583 struct dev_cgroup *dev_cgroup;
540 struct dev_exception_item ex; 584 struct dev_exception_item ex;
541 int rc; 585 int rc;
542 586
@@ -547,6 +591,7 @@ static int __devcgroup_check_permission(struct dev_cgroup *dev_cgroup,
547 ex.access = access; 591 ex.access = access;
548 592
549 rcu_read_lock(); 593 rcu_read_lock();
594 dev_cgroup = task_devcgroup(current);
550 rc = may_access(dev_cgroup, &ex); 595 rc = may_access(dev_cgroup, &ex);
551 rcu_read_unlock(); 596 rcu_read_unlock();
552 597
@@ -558,7 +603,6 @@ static int __devcgroup_check_permission(struct dev_cgroup *dev_cgroup,
558 603
559int __devcgroup_inode_permission(struct inode *inode, int mask) 604int __devcgroup_inode_permission(struct inode *inode, int mask)
560{ 605{
561 struct dev_cgroup *dev_cgroup = task_devcgroup(current);
562 short type, access = 0; 606 short type, access = 0;
563 607
564 if (S_ISBLK(inode->i_mode)) 608 if (S_ISBLK(inode->i_mode))
@@ -570,13 +614,12 @@ int __devcgroup_inode_permission(struct inode *inode, int mask)
570 if (mask & MAY_READ) 614 if (mask & MAY_READ)
571 access |= ACC_READ; 615 access |= ACC_READ;
572 616
573 return __devcgroup_check_permission(dev_cgroup, type, imajor(inode), 617 return __devcgroup_check_permission(type, imajor(inode), iminor(inode),
574 iminor(inode), access); 618 access);
575} 619}
576 620
577int devcgroup_inode_mknod(int mode, dev_t dev) 621int devcgroup_inode_mknod(int mode, dev_t dev)
578{ 622{
579 struct dev_cgroup *dev_cgroup = task_devcgroup(current);
580 short type; 623 short type;
581 624
582 if (!S_ISBLK(mode) && !S_ISCHR(mode)) 625 if (!S_ISBLK(mode) && !S_ISCHR(mode))
@@ -587,7 +630,7 @@ int devcgroup_inode_mknod(int mode, dev_t dev)
587 else 630 else
588 type = DEV_CHAR; 631 type = DEV_CHAR;
589 632
590 return __devcgroup_check_permission(dev_cgroup, type, MAJOR(dev), 633 return __devcgroup_check_permission(type, MAJOR(dev), MINOR(dev),
591 MINOR(dev), ACC_MKNOD); 634 ACC_MKNOD);
592 635
593} 636}
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 24ab4148547..61a53367d02 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -2132,18 +2132,14 @@ static inline void flush_unauthorized_files(const struct cred *cred,
2132 return; 2132 return;
2133 2133
2134 devnull = dentry_open(&selinux_null, O_RDWR, cred); 2134 devnull = dentry_open(&selinux_null, O_RDWR, cred);
2135 if (!IS_ERR(devnull)) { 2135 if (IS_ERR(devnull))
2136 /* replace all the matching ones with this */ 2136 devnull = NULL;
2137 do { 2137 /* replace all the matching ones with this */
2138 replace_fd(n - 1, get_file(devnull), 0); 2138 do {
2139 } while ((n = iterate_fd(files, n, match_file, cred)) != 0); 2139 replace_fd(n - 1, devnull, 0);
2140 } while ((n = iterate_fd(files, n, match_file, cred)) != 0);
2141 if (devnull)
2140 fput(devnull); 2142 fput(devnull);
2141 } else {
2142 /* just close all the matching ones */
2143 do {
2144 replace_fd(n - 1, NULL, 0);
2145 } while ((n = iterate_fd(files, n, match_file, cred)) != 0);
2146 }
2147} 2143}
2148 2144
2149/* 2145/*
diff --git a/security/selinux/netnode.c b/security/selinux/netnode.c
index 28f911cdd7c..c5454c0477c 100644
--- a/security/selinux/netnode.c
+++ b/security/selinux/netnode.c
@@ -174,7 +174,8 @@ static void sel_netnode_insert(struct sel_netnode *node)
174 if (sel_netnode_hash[idx].size == SEL_NETNODE_HASH_BKT_LIMIT) { 174 if (sel_netnode_hash[idx].size == SEL_NETNODE_HASH_BKT_LIMIT) {
175 struct sel_netnode *tail; 175 struct sel_netnode *tail;
176 tail = list_entry( 176 tail = list_entry(
177 rcu_dereference(sel_netnode_hash[idx].list.prev), 177 rcu_dereference_protected(sel_netnode_hash[idx].list.prev,
178 lockdep_is_held(&sel_netnode_lock)),
178 struct sel_netnode, list); 179 struct sel_netnode, list);
179 list_del_rcu(&tail->list); 180 list_del_rcu(&tail->list);
180 kfree_rcu(tail, rcu); 181 kfree_rcu(tail, rcu);
diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
index c40ae573346..ad11dc99479 100644
--- a/sound/core/compress_offload.c
+++ b/sound/core/compress_offload.c
@@ -100,12 +100,15 @@ static int snd_compr_open(struct inode *inode, struct file *f)
100 100
101 if (dirn != compr->direction) { 101 if (dirn != compr->direction) {
102 pr_err("this device doesn't support this direction\n"); 102 pr_err("this device doesn't support this direction\n");
103 snd_card_unref(compr->card);
103 return -EINVAL; 104 return -EINVAL;
104 } 105 }
105 106
106 data = kzalloc(sizeof(*data), GFP_KERNEL); 107 data = kzalloc(sizeof(*data), GFP_KERNEL);
107 if (!data) 108 if (!data) {
109 snd_card_unref(compr->card);
108 return -ENOMEM; 110 return -ENOMEM;
111 }
109 data->stream.ops = compr->ops; 112 data->stream.ops = compr->ops;
110 data->stream.direction = dirn; 113 data->stream.direction = dirn;
111 data->stream.private_data = compr->private_data; 114 data->stream.private_data = compr->private_data;
@@ -113,6 +116,7 @@ static int snd_compr_open(struct inode *inode, struct file *f)
113 runtime = kzalloc(sizeof(*runtime), GFP_KERNEL); 116 runtime = kzalloc(sizeof(*runtime), GFP_KERNEL);
114 if (!runtime) { 117 if (!runtime) {
115 kfree(data); 118 kfree(data);
119 snd_card_unref(compr->card);
116 return -ENOMEM; 120 return -ENOMEM;
117 } 121 }
118 runtime->state = SNDRV_PCM_STATE_OPEN; 122 runtime->state = SNDRV_PCM_STATE_OPEN;
@@ -126,7 +130,8 @@ static int snd_compr_open(struct inode *inode, struct file *f)
126 kfree(runtime); 130 kfree(runtime);
127 kfree(data); 131 kfree(data);
128 } 132 }
129 return ret; 133 snd_card_unref(compr->card);
134 return 0;
130} 135}
131 136
132static int snd_compr_free(struct inode *inode, struct file *f) 137static int snd_compr_free(struct inode *inode, struct file *f)
diff --git a/sound/core/control.c b/sound/core/control.c
index 7e86a5b9f3b..8c7c2c9bba6 100644
--- a/sound/core/control.c
+++ b/sound/core/control.c
@@ -86,6 +86,7 @@ static int snd_ctl_open(struct inode *inode, struct file *file)
86 write_lock_irqsave(&card->ctl_files_rwlock, flags); 86 write_lock_irqsave(&card->ctl_files_rwlock, flags);
87 list_add_tail(&ctl->list, &card->ctl_files); 87 list_add_tail(&ctl->list, &card->ctl_files);
88 write_unlock_irqrestore(&card->ctl_files_rwlock, flags); 88 write_unlock_irqrestore(&card->ctl_files_rwlock, flags);
89 snd_card_unref(card);
89 return 0; 90 return 0;
90 91
91 __error: 92 __error:
@@ -93,6 +94,8 @@ static int snd_ctl_open(struct inode *inode, struct file *file)
93 __error2: 94 __error2:
94 snd_card_file_remove(card, file); 95 snd_card_file_remove(card, file);
95 __error1: 96 __error1:
97 if (card)
98 snd_card_unref(card);
96 return err; 99 return err;
97} 100}
98 101
@@ -1434,6 +1437,8 @@ static ssize_t snd_ctl_read(struct file *file, char __user *buffer,
1434 spin_unlock_irq(&ctl->read_lock); 1437 spin_unlock_irq(&ctl->read_lock);
1435 schedule(); 1438 schedule();
1436 remove_wait_queue(&ctl->change_sleep, &wait); 1439 remove_wait_queue(&ctl->change_sleep, &wait);
1440 if (ctl->card->shutdown)
1441 return -ENODEV;
1437 if (signal_pending(current)) 1442 if (signal_pending(current))
1438 return -ERESTARTSYS; 1443 return -ERESTARTSYS;
1439 spin_lock_irq(&ctl->read_lock); 1444 spin_lock_irq(&ctl->read_lock);
diff --git a/sound/core/hwdep.c b/sound/core/hwdep.c
index 75ea16f35b1..3f7f6628cf7 100644
--- a/sound/core/hwdep.c
+++ b/sound/core/hwdep.c
@@ -100,8 +100,10 @@ static int snd_hwdep_open(struct inode *inode, struct file * file)
100 if (hw == NULL) 100 if (hw == NULL)
101 return -ENODEV; 101 return -ENODEV;
102 102
103 if (!try_module_get(hw->card->module)) 103 if (!try_module_get(hw->card->module)) {
104 snd_card_unref(hw->card);
104 return -EFAULT; 105 return -EFAULT;
106 }
105 107
106 init_waitqueue_entry(&wait, current); 108 init_waitqueue_entry(&wait, current);
107 add_wait_queue(&hw->open_wait, &wait); 109 add_wait_queue(&hw->open_wait, &wait);
@@ -129,6 +131,10 @@ static int snd_hwdep_open(struct inode *inode, struct file * file)
129 mutex_unlock(&hw->open_mutex); 131 mutex_unlock(&hw->open_mutex);
130 schedule(); 132 schedule();
131 mutex_lock(&hw->open_mutex); 133 mutex_lock(&hw->open_mutex);
134 if (hw->card->shutdown) {
135 err = -ENODEV;
136 break;
137 }
132 if (signal_pending(current)) { 138 if (signal_pending(current)) {
133 err = -ERESTARTSYS; 139 err = -ERESTARTSYS;
134 break; 140 break;
@@ -148,6 +154,7 @@ static int snd_hwdep_open(struct inode *inode, struct file * file)
148 mutex_unlock(&hw->open_mutex); 154 mutex_unlock(&hw->open_mutex);
149 if (err < 0) 155 if (err < 0)
150 module_put(hw->card->module); 156 module_put(hw->card->module);
157 snd_card_unref(hw->card);
151 return err; 158 return err;
152} 159}
153 160
@@ -459,12 +466,15 @@ static int snd_hwdep_dev_disconnect(struct snd_device *device)
459 mutex_unlock(&register_mutex); 466 mutex_unlock(&register_mutex);
460 return -EINVAL; 467 return -EINVAL;
461 } 468 }
469 mutex_lock(&hwdep->open_mutex);
470 wake_up(&hwdep->open_wait);
462#ifdef CONFIG_SND_OSSEMUL 471#ifdef CONFIG_SND_OSSEMUL
463 if (hwdep->ossreg) 472 if (hwdep->ossreg)
464 snd_unregister_oss_device(hwdep->oss_type, hwdep->card, hwdep->device); 473 snd_unregister_oss_device(hwdep->oss_type, hwdep->card, hwdep->device);
465#endif 474#endif
466 snd_unregister_device(SNDRV_DEVICE_TYPE_HWDEP, hwdep->card, hwdep->device); 475 snd_unregister_device(SNDRV_DEVICE_TYPE_HWDEP, hwdep->card, hwdep->device);
467 list_del_init(&hwdep->list); 476 list_del_init(&hwdep->list);
477 mutex_unlock(&hwdep->open_mutex);
468 mutex_unlock(&register_mutex); 478 mutex_unlock(&register_mutex);
469 return 0; 479 return 0;
470} 480}
diff --git a/sound/core/init.c b/sound/core/init.c
index d8ec849af12..7b012d15c2c 100644
--- a/sound/core/init.c
+++ b/sound/core/init.c
@@ -213,6 +213,7 @@ int snd_card_create(int idx, const char *xid,
213 spin_lock_init(&card->files_lock); 213 spin_lock_init(&card->files_lock);
214 INIT_LIST_HEAD(&card->files_list); 214 INIT_LIST_HEAD(&card->files_list);
215 init_waitqueue_head(&card->shutdown_sleep); 215 init_waitqueue_head(&card->shutdown_sleep);
216 atomic_set(&card->refcount, 0);
216#ifdef CONFIG_PM 217#ifdef CONFIG_PM
217 mutex_init(&card->power_lock); 218 mutex_init(&card->power_lock);
218 init_waitqueue_head(&card->power_sleep); 219 init_waitqueue_head(&card->power_sleep);
@@ -446,21 +447,36 @@ static int snd_card_do_free(struct snd_card *card)
446 return 0; 447 return 0;
447} 448}
448 449
450/**
451 * snd_card_unref - release the reference counter
452 * @card: the card instance
453 *
454 * Decrements the reference counter. When it reaches to zero, wake up
455 * the sleeper and call the destructor if needed.
456 */
457void snd_card_unref(struct snd_card *card)
458{
459 if (atomic_dec_and_test(&card->refcount)) {
460 wake_up(&card->shutdown_sleep);
461 if (card->free_on_last_close)
462 snd_card_do_free(card);
463 }
464}
465EXPORT_SYMBOL(snd_card_unref);
466
449int snd_card_free_when_closed(struct snd_card *card) 467int snd_card_free_when_closed(struct snd_card *card)
450{ 468{
451 int free_now = 0; 469 int ret;
452 int ret = snd_card_disconnect(card);
453 if (ret)
454 return ret;
455 470
456 spin_lock(&card->files_lock); 471 atomic_inc(&card->refcount);
457 if (list_empty(&card->files_list)) 472 ret = snd_card_disconnect(card);
458 free_now = 1; 473 if (ret) {
459 else 474 atomic_dec(&card->refcount);
460 card->free_on_last_close = 1; 475 return ret;
461 spin_unlock(&card->files_lock); 476 }
462 477
463 if (free_now) 478 card->free_on_last_close = 1;
479 if (atomic_dec_and_test(&card->refcount))
464 snd_card_do_free(card); 480 snd_card_do_free(card);
465 return 0; 481 return 0;
466} 482}
@@ -474,7 +490,7 @@ int snd_card_free(struct snd_card *card)
474 return ret; 490 return ret;
475 491
476 /* wait, until all devices are ready for the free operation */ 492 /* wait, until all devices are ready for the free operation */
477 wait_event(card->shutdown_sleep, list_empty(&card->files_list)); 493 wait_event(card->shutdown_sleep, !atomic_read(&card->refcount));
478 snd_card_do_free(card); 494 snd_card_do_free(card);
479 return 0; 495 return 0;
480} 496}
@@ -886,6 +902,7 @@ int snd_card_file_add(struct snd_card *card, struct file *file)
886 return -ENODEV; 902 return -ENODEV;
887 } 903 }
888 list_add(&mfile->list, &card->files_list); 904 list_add(&mfile->list, &card->files_list);
905 atomic_inc(&card->refcount);
889 spin_unlock(&card->files_lock); 906 spin_unlock(&card->files_lock);
890 return 0; 907 return 0;
891} 908}
@@ -908,7 +925,6 @@ EXPORT_SYMBOL(snd_card_file_add);
908int snd_card_file_remove(struct snd_card *card, struct file *file) 925int snd_card_file_remove(struct snd_card *card, struct file *file)
909{ 926{
910 struct snd_monitor_file *mfile, *found = NULL; 927 struct snd_monitor_file *mfile, *found = NULL;
911 int last_close = 0;
912 928
913 spin_lock(&card->files_lock); 929 spin_lock(&card->files_lock);
914 list_for_each_entry(mfile, &card->files_list, list) { 930 list_for_each_entry(mfile, &card->files_list, list) {
@@ -923,19 +939,13 @@ int snd_card_file_remove(struct snd_card *card, struct file *file)
923 break; 939 break;
924 } 940 }
925 } 941 }
926 if (list_empty(&card->files_list))
927 last_close = 1;
928 spin_unlock(&card->files_lock); 942 spin_unlock(&card->files_lock);
929 if (last_close) {
930 wake_up(&card->shutdown_sleep);
931 if (card->free_on_last_close)
932 snd_card_do_free(card);
933 }
934 if (!found) { 943 if (!found) {
935 snd_printk(KERN_ERR "ALSA card file remove problem (%p)\n", file); 944 snd_printk(KERN_ERR "ALSA card file remove problem (%p)\n", file);
936 return -ENOENT; 945 return -ENOENT;
937 } 946 }
938 kfree(found); 947 kfree(found);
948 snd_card_unref(card);
939 return 0; 949 return 0;
940} 950}
941 951
diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c
index 29f6ded0255..e8a1d18774b 100644
--- a/sound/core/oss/mixer_oss.c
+++ b/sound/core/oss/mixer_oss.c
@@ -52,14 +52,19 @@ static int snd_mixer_oss_open(struct inode *inode, struct file *file)
52 SNDRV_OSS_DEVICE_TYPE_MIXER); 52 SNDRV_OSS_DEVICE_TYPE_MIXER);
53 if (card == NULL) 53 if (card == NULL)
54 return -ENODEV; 54 return -ENODEV;
55 if (card->mixer_oss == NULL) 55 if (card->mixer_oss == NULL) {
56 snd_card_unref(card);
56 return -ENODEV; 57 return -ENODEV;
58 }
57 err = snd_card_file_add(card, file); 59 err = snd_card_file_add(card, file);
58 if (err < 0) 60 if (err < 0) {
61 snd_card_unref(card);
59 return err; 62 return err;
63 }
60 fmixer = kzalloc(sizeof(*fmixer), GFP_KERNEL); 64 fmixer = kzalloc(sizeof(*fmixer), GFP_KERNEL);
61 if (fmixer == NULL) { 65 if (fmixer == NULL) {
62 snd_card_file_remove(card, file); 66 snd_card_file_remove(card, file);
67 snd_card_unref(card);
63 return -ENOMEM; 68 return -ENOMEM;
64 } 69 }
65 fmixer->card = card; 70 fmixer->card = card;
@@ -68,8 +73,10 @@ static int snd_mixer_oss_open(struct inode *inode, struct file *file)
68 if (!try_module_get(card->module)) { 73 if (!try_module_get(card->module)) {
69 kfree(fmixer); 74 kfree(fmixer);
70 snd_card_file_remove(card, file); 75 snd_card_file_remove(card, file);
76 snd_card_unref(card);
71 return -EFAULT; 77 return -EFAULT;
72 } 78 }
79 snd_card_unref(card);
73 return 0; 80 return 0;
74} 81}
75 82
diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
index 08fde0060fd..4c1cc51772e 100644
--- a/sound/core/oss/pcm_oss.c
+++ b/sound/core/oss/pcm_oss.c
@@ -2441,6 +2441,10 @@ static int snd_pcm_oss_open(struct inode *inode, struct file *file)
2441 mutex_unlock(&pcm->open_mutex); 2441 mutex_unlock(&pcm->open_mutex);
2442 schedule(); 2442 schedule();
2443 mutex_lock(&pcm->open_mutex); 2443 mutex_lock(&pcm->open_mutex);
2444 if (pcm->card->shutdown) {
2445 err = -ENODEV;
2446 break;
2447 }
2444 if (signal_pending(current)) { 2448 if (signal_pending(current)) {
2445 err = -ERESTARTSYS; 2449 err = -ERESTARTSYS;
2446 break; 2450 break;
@@ -2450,6 +2454,7 @@ static int snd_pcm_oss_open(struct inode *inode, struct file *file)
2450 mutex_unlock(&pcm->open_mutex); 2454 mutex_unlock(&pcm->open_mutex);
2451 if (err < 0) 2455 if (err < 0)
2452 goto __error; 2456 goto __error;
2457 snd_card_unref(pcm->card);
2453 return err; 2458 return err;
2454 2459
2455 __error: 2460 __error:
@@ -2457,6 +2462,8 @@ static int snd_pcm_oss_open(struct inode *inode, struct file *file)
2457 __error2: 2462 __error2:
2458 snd_card_file_remove(pcm->card, file); 2463 snd_card_file_remove(pcm->card, file);
2459 __error1: 2464 __error1:
2465 if (pcm)
2466 snd_card_unref(pcm->card);
2460 return err; 2467 return err;
2461} 2468}
2462 2469
diff --git a/sound/core/pcm.c b/sound/core/pcm.c
index f2991940b27..030102caeee 100644
--- a/sound/core/pcm.c
+++ b/sound/core/pcm.c
@@ -1086,11 +1086,19 @@ static int snd_pcm_dev_disconnect(struct snd_device *device)
1086 if (list_empty(&pcm->list)) 1086 if (list_empty(&pcm->list))
1087 goto unlock; 1087 goto unlock;
1088 1088
1089 mutex_lock(&pcm->open_mutex);
1090 wake_up(&pcm->open_wait);
1089 list_del_init(&pcm->list); 1091 list_del_init(&pcm->list);
1090 for (cidx = 0; cidx < 2; cidx++) 1092 for (cidx = 0; cidx < 2; cidx++)
1091 for (substream = pcm->streams[cidx].substream; substream; substream = substream->next) 1093 for (substream = pcm->streams[cidx].substream; substream; substream = substream->next) {
1092 if (substream->runtime) 1094 snd_pcm_stream_lock_irq(substream);
1095 if (substream->runtime) {
1093 substream->runtime->status->state = SNDRV_PCM_STATE_DISCONNECTED; 1096 substream->runtime->status->state = SNDRV_PCM_STATE_DISCONNECTED;
1097 wake_up(&substream->runtime->sleep);
1098 wake_up(&substream->runtime->tsleep);
1099 }
1100 snd_pcm_stream_unlock_irq(substream);
1101 }
1094 list_for_each_entry(notify, &snd_pcm_notify_list, list) { 1102 list_for_each_entry(notify, &snd_pcm_notify_list, list) {
1095 notify->n_disconnect(pcm); 1103 notify->n_disconnect(pcm);
1096 } 1104 }
@@ -1110,6 +1118,7 @@ static int snd_pcm_dev_disconnect(struct snd_device *device)
1110 pcm->streams[cidx].chmap_kctl = NULL; 1118 pcm->streams[cidx].chmap_kctl = NULL;
1111 } 1119 }
1112 } 1120 }
1121 mutex_unlock(&pcm->open_mutex);
1113 unlock: 1122 unlock:
1114 mutex_unlock(&register_mutex); 1123 mutex_unlock(&register_mutex);
1115 return 0; 1124 return 0;
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index 5e12e5bacbb..f9ddecf2f4c 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -369,6 +369,14 @@ static int period_to_usecs(struct snd_pcm_runtime *runtime)
369 return usecs; 369 return usecs;
370} 370}
371 371
372static void snd_pcm_set_state(struct snd_pcm_substream *substream, int state)
373{
374 snd_pcm_stream_lock_irq(substream);
375 if (substream->runtime->status->state != SNDRV_PCM_STATE_DISCONNECTED)
376 substream->runtime->status->state = state;
377 snd_pcm_stream_unlock_irq(substream);
378}
379
372static int snd_pcm_hw_params(struct snd_pcm_substream *substream, 380static int snd_pcm_hw_params(struct snd_pcm_substream *substream,
373 struct snd_pcm_hw_params *params) 381 struct snd_pcm_hw_params *params)
374{ 382{
@@ -452,7 +460,7 @@ static int snd_pcm_hw_params(struct snd_pcm_substream *substream,
452 runtime->boundary *= 2; 460 runtime->boundary *= 2;
453 461
454 snd_pcm_timer_resolution_change(substream); 462 snd_pcm_timer_resolution_change(substream);
455 runtime->status->state = SNDRV_PCM_STATE_SETUP; 463 snd_pcm_set_state(substream, SNDRV_PCM_STATE_SETUP);
456 464
457 if (pm_qos_request_active(&substream->latency_pm_qos_req)) 465 if (pm_qos_request_active(&substream->latency_pm_qos_req))
458 pm_qos_remove_request(&substream->latency_pm_qos_req); 466 pm_qos_remove_request(&substream->latency_pm_qos_req);
@@ -464,7 +472,7 @@ static int snd_pcm_hw_params(struct snd_pcm_substream *substream,
464 /* hardware might be unusable from this time, 472 /* hardware might be unusable from this time,
465 so we force application to retry to set 473 so we force application to retry to set
466 the correct hardware parameter settings */ 474 the correct hardware parameter settings */
467 runtime->status->state = SNDRV_PCM_STATE_OPEN; 475 snd_pcm_set_state(substream, SNDRV_PCM_STATE_OPEN);
468 if (substream->ops->hw_free != NULL) 476 if (substream->ops->hw_free != NULL)
469 substream->ops->hw_free(substream); 477 substream->ops->hw_free(substream);
470 return err; 478 return err;
@@ -512,7 +520,7 @@ static int snd_pcm_hw_free(struct snd_pcm_substream *substream)
512 return -EBADFD; 520 return -EBADFD;
513 if (substream->ops->hw_free) 521 if (substream->ops->hw_free)
514 result = substream->ops->hw_free(substream); 522 result = substream->ops->hw_free(substream);
515 runtime->status->state = SNDRV_PCM_STATE_OPEN; 523 snd_pcm_set_state(substream, SNDRV_PCM_STATE_OPEN);
516 pm_qos_remove_request(&substream->latency_pm_qos_req); 524 pm_qos_remove_request(&substream->latency_pm_qos_req);
517 return result; 525 return result;
518} 526}
@@ -1320,7 +1328,7 @@ static void snd_pcm_post_prepare(struct snd_pcm_substream *substream, int state)
1320{ 1328{
1321 struct snd_pcm_runtime *runtime = substream->runtime; 1329 struct snd_pcm_runtime *runtime = substream->runtime;
1322 runtime->control->appl_ptr = runtime->status->hw_ptr; 1330 runtime->control->appl_ptr = runtime->status->hw_ptr;
1323 runtime->status->state = SNDRV_PCM_STATE_PREPARED; 1331 snd_pcm_set_state(substream, SNDRV_PCM_STATE_PREPARED);
1324} 1332}
1325 1333
1326static struct action_ops snd_pcm_action_prepare = { 1334static struct action_ops snd_pcm_action_prepare = {
@@ -1510,6 +1518,10 @@ static int snd_pcm_drain(struct snd_pcm_substream *substream,
1510 down_read(&snd_pcm_link_rwsem); 1518 down_read(&snd_pcm_link_rwsem);
1511 snd_pcm_stream_lock_irq(substream); 1519 snd_pcm_stream_lock_irq(substream);
1512 remove_wait_queue(&to_check->sleep, &wait); 1520 remove_wait_queue(&to_check->sleep, &wait);
1521 if (card->shutdown) {
1522 result = -ENODEV;
1523 break;
1524 }
1513 if (tout == 0) { 1525 if (tout == 0) {
1514 if (substream->runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) 1526 if (substream->runtime->status->state == SNDRV_PCM_STATE_SUSPENDED)
1515 result = -ESTRPIPE; 1527 result = -ESTRPIPE;
@@ -1634,6 +1646,7 @@ static int snd_pcm_link(struct snd_pcm_substream *substream, int fd)
1634 write_unlock_irq(&snd_pcm_link_rwlock); 1646 write_unlock_irq(&snd_pcm_link_rwlock);
1635 up_write(&snd_pcm_link_rwsem); 1647 up_write(&snd_pcm_link_rwsem);
1636 _nolock: 1648 _nolock:
1649 snd_card_unref(substream1->pcm->card);
1637 fput_light(file, fput_needed); 1650 fput_light(file, fput_needed);
1638 if (res < 0) 1651 if (res < 0)
1639 kfree(group); 1652 kfree(group);
@@ -2108,7 +2121,10 @@ static int snd_pcm_playback_open(struct inode *inode, struct file *file)
2108 return err; 2121 return err;
2109 pcm = snd_lookup_minor_data(iminor(inode), 2122 pcm = snd_lookup_minor_data(iminor(inode),
2110 SNDRV_DEVICE_TYPE_PCM_PLAYBACK); 2123 SNDRV_DEVICE_TYPE_PCM_PLAYBACK);
2111 return snd_pcm_open(file, pcm, SNDRV_PCM_STREAM_PLAYBACK); 2124 err = snd_pcm_open(file, pcm, SNDRV_PCM_STREAM_PLAYBACK);
2125 if (pcm)
2126 snd_card_unref(pcm->card);
2127 return err;
2112} 2128}
2113 2129
2114static int snd_pcm_capture_open(struct inode *inode, struct file *file) 2130static int snd_pcm_capture_open(struct inode *inode, struct file *file)
@@ -2119,7 +2135,10 @@ static int snd_pcm_capture_open(struct inode *inode, struct file *file)
2119 return err; 2135 return err;
2120 pcm = snd_lookup_minor_data(iminor(inode), 2136 pcm = snd_lookup_minor_data(iminor(inode),
2121 SNDRV_DEVICE_TYPE_PCM_CAPTURE); 2137 SNDRV_DEVICE_TYPE_PCM_CAPTURE);
2122 return snd_pcm_open(file, pcm, SNDRV_PCM_STREAM_CAPTURE); 2138 err = snd_pcm_open(file, pcm, SNDRV_PCM_STREAM_CAPTURE);
2139 if (pcm)
2140 snd_card_unref(pcm->card);
2141 return err;
2123} 2142}
2124 2143
2125static int snd_pcm_open(struct file *file, struct snd_pcm *pcm, int stream) 2144static int snd_pcm_open(struct file *file, struct snd_pcm *pcm, int stream)
@@ -2156,6 +2175,10 @@ static int snd_pcm_open(struct file *file, struct snd_pcm *pcm, int stream)
2156 mutex_unlock(&pcm->open_mutex); 2175 mutex_unlock(&pcm->open_mutex);
2157 schedule(); 2176 schedule();
2158 mutex_lock(&pcm->open_mutex); 2177 mutex_lock(&pcm->open_mutex);
2178 if (pcm->card->shutdown) {
2179 err = -ENODEV;
2180 break;
2181 }
2159 if (signal_pending(current)) { 2182 if (signal_pending(current)) {
2160 err = -ERESTARTSYS; 2183 err = -ERESTARTSYS;
2161 break; 2184 break;
diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c
index ebf6e49ad3d..1bb95aeea08 100644
--- a/sound/core/rawmidi.c
+++ b/sound/core/rawmidi.c
@@ -379,8 +379,10 @@ static int snd_rawmidi_open(struct inode *inode, struct file *file)
379 if (rmidi == NULL) 379 if (rmidi == NULL)
380 return -ENODEV; 380 return -ENODEV;
381 381
382 if (!try_module_get(rmidi->card->module)) 382 if (!try_module_get(rmidi->card->module)) {
383 snd_card_unref(rmidi->card);
383 return -ENXIO; 384 return -ENXIO;
385 }
384 386
385 mutex_lock(&rmidi->open_mutex); 387 mutex_lock(&rmidi->open_mutex);
386 card = rmidi->card; 388 card = rmidi->card;
@@ -422,6 +424,10 @@ static int snd_rawmidi_open(struct inode *inode, struct file *file)
422 mutex_unlock(&rmidi->open_mutex); 424 mutex_unlock(&rmidi->open_mutex);
423 schedule(); 425 schedule();
424 mutex_lock(&rmidi->open_mutex); 426 mutex_lock(&rmidi->open_mutex);
427 if (rmidi->card->shutdown) {
428 err = -ENODEV;
429 break;
430 }
425 if (signal_pending(current)) { 431 if (signal_pending(current)) {
426 err = -ERESTARTSYS; 432 err = -ERESTARTSYS;
427 break; 433 break;
@@ -440,6 +446,7 @@ static int snd_rawmidi_open(struct inode *inode, struct file *file)
440#endif 446#endif
441 file->private_data = rawmidi_file; 447 file->private_data = rawmidi_file;
442 mutex_unlock(&rmidi->open_mutex); 448 mutex_unlock(&rmidi->open_mutex);
449 snd_card_unref(rmidi->card);
443 return 0; 450 return 0;
444 451
445 __error: 452 __error:
@@ -447,6 +454,7 @@ static int snd_rawmidi_open(struct inode *inode, struct file *file)
447 __error_card: 454 __error_card:
448 mutex_unlock(&rmidi->open_mutex); 455 mutex_unlock(&rmidi->open_mutex);
449 module_put(rmidi->card->module); 456 module_put(rmidi->card->module);
457 snd_card_unref(rmidi->card);
450 return err; 458 return err;
451} 459}
452 460
@@ -991,6 +999,8 @@ static ssize_t snd_rawmidi_read(struct file *file, char __user *buf, size_t coun
991 spin_unlock_irq(&runtime->lock); 999 spin_unlock_irq(&runtime->lock);
992 schedule(); 1000 schedule();
993 remove_wait_queue(&runtime->sleep, &wait); 1001 remove_wait_queue(&runtime->sleep, &wait);
1002 if (rfile->rmidi->card->shutdown)
1003 return -ENODEV;
994 if (signal_pending(current)) 1004 if (signal_pending(current))
995 return result > 0 ? result : -ERESTARTSYS; 1005 return result > 0 ? result : -ERESTARTSYS;
996 if (!runtime->avail) 1006 if (!runtime->avail)
@@ -1234,6 +1244,8 @@ static ssize_t snd_rawmidi_write(struct file *file, const char __user *buf,
1234 spin_unlock_irq(&runtime->lock); 1244 spin_unlock_irq(&runtime->lock);
1235 timeout = schedule_timeout(30 * HZ); 1245 timeout = schedule_timeout(30 * HZ);
1236 remove_wait_queue(&runtime->sleep, &wait); 1246 remove_wait_queue(&runtime->sleep, &wait);
1247 if (rfile->rmidi->card->shutdown)
1248 return -ENODEV;
1237 if (signal_pending(current)) 1249 if (signal_pending(current))
1238 return result > 0 ? result : -ERESTARTSYS; 1250 return result > 0 ? result : -ERESTARTSYS;
1239 if (!runtime->avail && !timeout) 1251 if (!runtime->avail && !timeout)
@@ -1609,9 +1621,20 @@ static int snd_rawmidi_dev_register(struct snd_device *device)
1609static int snd_rawmidi_dev_disconnect(struct snd_device *device) 1621static int snd_rawmidi_dev_disconnect(struct snd_device *device)
1610{ 1622{
1611 struct snd_rawmidi *rmidi = device->device_data; 1623 struct snd_rawmidi *rmidi = device->device_data;
1624 int dir;
1612 1625
1613 mutex_lock(&register_mutex); 1626 mutex_lock(&register_mutex);
1627 mutex_lock(&rmidi->open_mutex);
1628 wake_up(&rmidi->open_wait);
1614 list_del_init(&rmidi->list); 1629 list_del_init(&rmidi->list);
1630 for (dir = 0; dir < 2; dir++) {
1631 struct snd_rawmidi_substream *s;
1632 list_for_each_entry(s, &rmidi->streams[dir].substreams, list) {
1633 if (s->runtime)
1634 wake_up(&s->runtime->sleep);
1635 }
1636 }
1637
1615#ifdef CONFIG_SND_OSSEMUL 1638#ifdef CONFIG_SND_OSSEMUL
1616 if (rmidi->ossreg) { 1639 if (rmidi->ossreg) {
1617 if ((int)rmidi->device == midi_map[rmidi->card->number]) { 1640 if ((int)rmidi->device == midi_map[rmidi->card->number]) {
@@ -1626,6 +1649,7 @@ static int snd_rawmidi_dev_disconnect(struct snd_device *device)
1626 } 1649 }
1627#endif /* CONFIG_SND_OSSEMUL */ 1650#endif /* CONFIG_SND_OSSEMUL */
1628 snd_unregister_device(SNDRV_DEVICE_TYPE_RAWMIDI, rmidi->card, rmidi->device); 1651 snd_unregister_device(SNDRV_DEVICE_TYPE_RAWMIDI, rmidi->card, rmidi->device);
1652 mutex_unlock(&rmidi->open_mutex);
1629 mutex_unlock(&register_mutex); 1653 mutex_unlock(&register_mutex);
1630 return 0; 1654 return 0;
1631} 1655}
diff --git a/sound/core/sound.c b/sound/core/sound.c
index 643976000ce..70ccdab7415 100644
--- a/sound/core/sound.c
+++ b/sound/core/sound.c
@@ -98,6 +98,10 @@ static void snd_request_other(int minor)
98 * 98 *
99 * Checks that a minor device with the specified type is registered, and returns 99 * Checks that a minor device with the specified type is registered, and returns
100 * its user data pointer. 100 * its user data pointer.
101 *
102 * This function increments the reference counter of the card instance
103 * if an associated instance with the given minor number and type is found.
104 * The caller must call snd_card_unref() appropriately later.
101 */ 105 */
102void *snd_lookup_minor_data(unsigned int minor, int type) 106void *snd_lookup_minor_data(unsigned int minor, int type)
103{ 107{
@@ -108,9 +112,11 @@ void *snd_lookup_minor_data(unsigned int minor, int type)
108 return NULL; 112 return NULL;
109 mutex_lock(&sound_mutex); 113 mutex_lock(&sound_mutex);
110 mreg = snd_minors[minor]; 114 mreg = snd_minors[minor];
111 if (mreg && mreg->type == type) 115 if (mreg && mreg->type == type) {
112 private_data = mreg->private_data; 116 private_data = mreg->private_data;
113 else 117 if (private_data && mreg->card_ptr)
118 atomic_inc(&mreg->card_ptr->refcount);
119 } else
114 private_data = NULL; 120 private_data = NULL;
115 mutex_unlock(&sound_mutex); 121 mutex_unlock(&sound_mutex);
116 return private_data; 122 return private_data;
@@ -275,6 +281,7 @@ int snd_register_device_for_dev(int type, struct snd_card *card, int dev,
275 preg->device = dev; 281 preg->device = dev;
276 preg->f_ops = f_ops; 282 preg->f_ops = f_ops;
277 preg->private_data = private_data; 283 preg->private_data = private_data;
284 preg->card_ptr = card;
278 mutex_lock(&sound_mutex); 285 mutex_lock(&sound_mutex);
279#ifdef CONFIG_SND_DYNAMIC_MINORS 286#ifdef CONFIG_SND_DYNAMIC_MINORS
280 minor = snd_find_free_minor(type); 287 minor = snd_find_free_minor(type);
diff --git a/sound/core/sound_oss.c b/sound/core/sound_oss.c
index e9528333e36..726a49ac972 100644
--- a/sound/core/sound_oss.c
+++ b/sound/core/sound_oss.c
@@ -40,6 +40,9 @@
40static struct snd_minor *snd_oss_minors[SNDRV_OSS_MINORS]; 40static struct snd_minor *snd_oss_minors[SNDRV_OSS_MINORS];
41static DEFINE_MUTEX(sound_oss_mutex); 41static DEFINE_MUTEX(sound_oss_mutex);
42 42
43/* NOTE: This function increments the refcount of the associated card like
44 * snd_lookup_minor_data(); the caller must call snd_card_unref() appropriately
45 */
43void *snd_lookup_oss_minor_data(unsigned int minor, int type) 46void *snd_lookup_oss_minor_data(unsigned int minor, int type)
44{ 47{
45 struct snd_minor *mreg; 48 struct snd_minor *mreg;
@@ -49,9 +52,11 @@ void *snd_lookup_oss_minor_data(unsigned int minor, int type)
49 return NULL; 52 return NULL;
50 mutex_lock(&sound_oss_mutex); 53 mutex_lock(&sound_oss_mutex);
51 mreg = snd_oss_minors[minor]; 54 mreg = snd_oss_minors[minor];
52 if (mreg && mreg->type == type) 55 if (mreg && mreg->type == type) {
53 private_data = mreg->private_data; 56 private_data = mreg->private_data;
54 else 57 if (private_data && mreg->card_ptr)
58 atomic_inc(&mreg->card_ptr->refcount);
59 } else
55 private_data = NULL; 60 private_data = NULL;
56 mutex_unlock(&sound_oss_mutex); 61 mutex_unlock(&sound_oss_mutex);
57 return private_data; 62 return private_data;
@@ -123,6 +128,7 @@ int snd_register_oss_device(int type, struct snd_card *card, int dev,
123 preg->device = dev; 128 preg->device = dev;
124 preg->f_ops = f_ops; 129 preg->f_ops = f_ops;
125 preg->private_data = private_data; 130 preg->private_data = private_data;
131 preg->card_ptr = card;
126 mutex_lock(&sound_oss_mutex); 132 mutex_lock(&sound_oss_mutex);
127 snd_oss_minors[minor] = preg; 133 snd_oss_minors[minor] = preg;
128 minor_unit = SNDRV_MINOR_OSS_DEVICE(minor); 134 minor_unit = SNDRV_MINOR_OSS_DEVICE(minor);
diff --git a/sound/i2c/other/ak4113.c b/sound/i2c/other/ak4113.c
index ef68d710d08..e04e750a77e 100644
--- a/sound/i2c/other/ak4113.c
+++ b/sound/i2c/other/ak4113.c
@@ -426,7 +426,7 @@ static struct snd_kcontrol_new snd_ak4113_iec958_controls[] = {
426}, 426},
427{ 427{
428 .iface = SNDRV_CTL_ELEM_IFACE_PCM, 428 .iface = SNDRV_CTL_ELEM_IFACE_PCM,
429 .name = "IEC958 Preample Capture Default", 429 .name = "IEC958 Preamble Capture Default",
430 .access = SNDRV_CTL_ELEM_ACCESS_READ | 430 .access = SNDRV_CTL_ELEM_ACCESS_READ |
431 SNDRV_CTL_ELEM_ACCESS_VOLATILE, 431 SNDRV_CTL_ELEM_ACCESS_VOLATILE,
432 .info = snd_ak4113_spdif_pinfo, 432 .info = snd_ak4113_spdif_pinfo,
diff --git a/sound/i2c/other/ak4114.c b/sound/i2c/other/ak4114.c
index 816e7d225fb..5bf4fca19e4 100644
--- a/sound/i2c/other/ak4114.c
+++ b/sound/i2c/other/ak4114.c
@@ -401,7 +401,7 @@ static struct snd_kcontrol_new snd_ak4114_iec958_controls[] = {
401}, 401},
402{ 402{
403 .iface = SNDRV_CTL_ELEM_IFACE_PCM, 403 .iface = SNDRV_CTL_ELEM_IFACE_PCM,
404 .name = "IEC958 Preample Capture Default", 404 .name = "IEC958 Preamble Capture Default",
405 .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, 405 .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE,
406 .info = snd_ak4114_spdif_pinfo, 406 .info = snd_ak4114_spdif_pinfo,
407 .get = snd_ak4114_spdif_pget, 407 .get = snd_ak4114_spdif_pget,
diff --git a/sound/i2c/other/ak4117.c b/sound/i2c/other/ak4117.c
index b4b2a51fc11..40e33c9f2b0 100644
--- a/sound/i2c/other/ak4117.c
+++ b/sound/i2c/other/ak4117.c
@@ -380,7 +380,7 @@ static struct snd_kcontrol_new snd_ak4117_iec958_controls[] = {
380}, 380},
381{ 381{
382 .iface = SNDRV_CTL_ELEM_IFACE_PCM, 382 .iface = SNDRV_CTL_ELEM_IFACE_PCM,
383 .name = "IEC958 Preample Capture Default", 383 .name = "IEC958 Preamble Capture Default",
384 .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE, 384 .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE,
385 .info = snd_ak4117_spdif_pinfo, 385 .info = snd_ak4117_spdif_pinfo,
386 .get = snd_ak4117_spdif_pget, 386 .get = snd_ak4117_spdif_pget,
diff --git a/sound/isa/opti9xx/miro.c b/sound/isa/opti9xx/miro.c
index 3d1afb612b3..4a7ff4e8985 100644
--- a/sound/isa/opti9xx/miro.c
+++ b/sound/isa/opti9xx/miro.c
@@ -1286,7 +1286,6 @@ static int __devinit snd_miro_probe(struct snd_card *card)
1286 1286
1287 error = snd_card_miro_aci_detect(card, miro); 1287 error = snd_card_miro_aci_detect(card, miro);
1288 if (error < 0) { 1288 if (error < 0) {
1289 snd_card_free(card);
1290 snd_printk(KERN_ERR "unable to detect aci chip\n"); 1289 snd_printk(KERN_ERR "unable to detect aci chip\n");
1291 return -ENODEV; 1290 return -ENODEV;
1292 } 1291 }
diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c
index 9473fca9681..8b0f9968830 100644
--- a/sound/pci/ac97/ac97_codec.c
+++ b/sound/pci/ac97/ac97_codec.c
@@ -1271,6 +1271,8 @@ static int snd_ac97_cvol_new(struct snd_card *card, char *name, int reg, unsigne
1271 tmp.index = ac97->num; 1271 tmp.index = ac97->num;
1272 kctl = snd_ctl_new1(&tmp, ac97); 1272 kctl = snd_ctl_new1(&tmp, ac97);
1273 } 1273 }
1274 if (!kctl)
1275 return -ENOMEM;
1274 if (reg >= AC97_PHONE && reg <= AC97_PCM) 1276 if (reg >= AC97_PHONE && reg <= AC97_PCM)
1275 set_tlv_db_scale(kctl, db_scale_5bit_12db_max); 1277 set_tlv_db_scale(kctl, db_scale_5bit_12db_max);
1276 else 1278 else
diff --git a/sound/pci/als300.c b/sound/pci/als300.c
index 00f157a2cf6..5af3cb6b0c1 100644
--- a/sound/pci/als300.c
+++ b/sound/pci/als300.c
@@ -394,6 +394,8 @@ static int snd_als300_playback_open(struct snd_pcm_substream *substream)
394 struct snd_als300_substream_data *data = kzalloc(sizeof(*data), 394 struct snd_als300_substream_data *data = kzalloc(sizeof(*data),
395 GFP_KERNEL); 395 GFP_KERNEL);
396 396
397 if (!data)
398 return -ENOMEM;
397 snd_als300_dbgcallenter(); 399 snd_als300_dbgcallenter();
398 chip->playback_substream = substream; 400 chip->playback_substream = substream;
399 runtime->hw = snd_als300_playback_hw; 401 runtime->hw = snd_als300_playback_hw;
@@ -425,6 +427,8 @@ static int snd_als300_capture_open(struct snd_pcm_substream *substream)
425 struct snd_als300_substream_data *data = kzalloc(sizeof(*data), 427 struct snd_als300_substream_data *data = kzalloc(sizeof(*data),
426 GFP_KERNEL); 428 GFP_KERNEL);
427 429
430 if (!data)
431 return -ENOMEM;
428 snd_als300_dbgcallenter(); 432 snd_als300_dbgcallenter();
429 chip->capture_substream = substream; 433 chip->capture_substream = substream;
430 runtime->hw = snd_als300_capture_hw; 434 runtime->hw = snd_als300_capture_hw;
diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c
index bed4485f34f..c21adb6ef1d 100644
--- a/sound/pci/emu10k1/emu10k1_main.c
+++ b/sound/pci/emu10k1/emu10k1_main.c
@@ -1416,6 +1416,15 @@ static struct snd_emu_chip_details emu_chip_details[] = {
1416 .ca0108_chip = 1, 1416 .ca0108_chip = 1,
1417 .spk71 = 1, 1417 .spk71 = 1,
1418 .emu_model = EMU_MODEL_EMU1010B}, /* EMU 1010 new revision */ 1418 .emu_model = EMU_MODEL_EMU1010B}, /* EMU 1010 new revision */
1419 /* Tested by Maxim Kachur <mcdebugger@duganet.ru> 17th Oct 2012. */
1420 /* This is MAEM8986, 0202 is MAEM8980 */
1421 {.vendor = 0x1102, .device = 0x0008, .subsystem = 0x40071102,
1422 .driver = "Audigy2", .name = "E-mu 1010 PCIe [MAEM8986]",
1423 .id = "EMU1010",
1424 .emu10k2_chip = 1,
1425 .ca0108_chip = 1,
1426 .spk71 = 1,
1427 .emu_model = EMU_MODEL_EMU1010B}, /* EMU 1010 PCIe */
1419 /* Tested by James@superbug.co.uk 8th July 2005. */ 1428 /* Tested by James@superbug.co.uk 8th July 2005. */
1420 /* This is MAEM8810, 0202 is MAEM8820 */ 1429 /* This is MAEM8810, 0202 is MAEM8820 */
1421 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x40011102, 1430 {.vendor = 0x1102, .device = 0x0004, .subsystem = 0x40011102,
diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c
index 5d0e568fdea..7266020c16c 100644
--- a/sound/pci/es1968.c
+++ b/sound/pci/es1968.c
@@ -2581,9 +2581,14 @@ static u8 snd_es1968_tea575x_get_pins(struct snd_tea575x *tea)
2581 struct es1968 *chip = tea->private_data; 2581 struct es1968 *chip = tea->private_data;
2582 unsigned long io = chip->io_port + GPIO_DATA; 2582 unsigned long io = chip->io_port + GPIO_DATA;
2583 u16 val = inw(io); 2583 u16 val = inw(io);
2584 u8 ret;
2584 2585
2585 return (val & STR_DATA) ? TEA575X_DATA : 0 | 2586 ret = 0;
2586 (val & STR_MOST) ? TEA575X_MOST : 0; 2587 if (val & STR_DATA)
2588 ret |= TEA575X_DATA;
2589 if (val & STR_MOST)
2590 ret |= TEA575X_MOST;
2591 return ret;
2587} 2592}
2588 2593
2589static void snd_es1968_tea575x_set_direction(struct snd_tea575x *tea, bool output) 2594static void snd_es1968_tea575x_set_direction(struct snd_tea575x *tea, bool output)
@@ -2655,6 +2660,8 @@ static struct ess_device_list pm_whitelist[] __devinitdata = {
2655 { TYPE_MAESTRO2E, 0x1179 }, 2660 { TYPE_MAESTRO2E, 0x1179 },
2656 { TYPE_MAESTRO2E, 0x14c0 }, /* HP omnibook 4150 */ 2661 { TYPE_MAESTRO2E, 0x14c0 }, /* HP omnibook 4150 */
2657 { TYPE_MAESTRO2E, 0x1558 }, 2662 { TYPE_MAESTRO2E, 0x1558 },
2663 { TYPE_MAESTRO2E, 0x125d }, /* a PCI card, e.g. Terratec DMX */
2664 { TYPE_MAESTRO2, 0x125d }, /* a PCI card, e.g. SF64-PCE2 */
2658}; 2665};
2659 2666
2660static struct ess_device_list mpu_blacklist[] __devinitdata = { 2667static struct ess_device_list mpu_blacklist[] __devinitdata = {
diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c
index cc2e91d1553..c5806f89be1 100644
--- a/sound/pci/fm801.c
+++ b/sound/pci/fm801.c
@@ -767,9 +767,14 @@ static u8 snd_fm801_tea575x_get_pins(struct snd_tea575x *tea)
767 struct fm801 *chip = tea->private_data; 767 struct fm801 *chip = tea->private_data;
768 unsigned short reg = inw(FM801_REG(chip, GPIO_CTRL)); 768 unsigned short reg = inw(FM801_REG(chip, GPIO_CTRL));
769 struct snd_fm801_tea575x_gpio gpio = *get_tea575x_gpio(chip); 769 struct snd_fm801_tea575x_gpio gpio = *get_tea575x_gpio(chip);
770 770 u8 ret;
771 return (reg & FM801_GPIO_GP(gpio.data)) ? TEA575X_DATA : 0 | 771
772 (reg & FM801_GPIO_GP(gpio.most)) ? TEA575X_MOST : 0; 772 ret = 0;
773 if (reg & FM801_GPIO_GP(gpio.data))
774 ret |= TEA575X_DATA;
775 if (reg & FM801_GPIO_GP(gpio.most))
776 ret |= TEA575X_MOST;
777 return ret;
773} 778}
774 779
775static void snd_fm801_tea575x_set_direction(struct snd_tea575x *tea, bool output) 780static void snd_fm801_tea575x_set_direction(struct snd_tea575x *tea, bool output)
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 70d4848b5cd..d010de12335 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -95,6 +95,7 @@ int snd_hda_delete_codec_preset(struct hda_codec_preset_list *preset)
95EXPORT_SYMBOL_HDA(snd_hda_delete_codec_preset); 95EXPORT_SYMBOL_HDA(snd_hda_delete_codec_preset);
96 96
97#ifdef CONFIG_PM 97#ifdef CONFIG_PM
98#define codec_in_pm(codec) ((codec)->in_pm)
98static void hda_power_work(struct work_struct *work); 99static void hda_power_work(struct work_struct *work);
99static void hda_keep_power_on(struct hda_codec *codec); 100static void hda_keep_power_on(struct hda_codec *codec);
100#define hda_codec_is_power_on(codec) ((codec)->power_on) 101#define hda_codec_is_power_on(codec) ((codec)->power_on)
@@ -104,6 +105,7 @@ static inline void hda_call_pm_notify(struct hda_bus *bus, bool power_up)
104 bus->ops.pm_notify(bus, power_up); 105 bus->ops.pm_notify(bus, power_up);
105} 106}
106#else 107#else
108#define codec_in_pm(codec) 0
107static inline void hda_keep_power_on(struct hda_codec *codec) {} 109static inline void hda_keep_power_on(struct hda_codec *codec) {}
108#define hda_codec_is_power_on(codec) 1 110#define hda_codec_is_power_on(codec) 1
109#define hda_call_pm_notify(bus, state) {} 111#define hda_call_pm_notify(bus, state) {}
@@ -228,7 +230,7 @@ static int codec_exec_verb(struct hda_codec *codec, unsigned int cmd,
228 } 230 }
229 mutex_unlock(&bus->cmd_mutex); 231 mutex_unlock(&bus->cmd_mutex);
230 snd_hda_power_down(codec); 232 snd_hda_power_down(codec);
231 if (res && *res == -1 && bus->rirb_error) { 233 if (!codec_in_pm(codec) && res && *res == -1 && bus->rirb_error) {
232 if (bus->response_reset) { 234 if (bus->response_reset) {
233 snd_printd("hda_codec: resetting BUS due to " 235 snd_printd("hda_codec: resetting BUS due to "
234 "fatal communication error\n"); 236 "fatal communication error\n");
@@ -238,7 +240,7 @@ static int codec_exec_verb(struct hda_codec *codec, unsigned int cmd,
238 goto again; 240 goto again;
239 } 241 }
240 /* clear reset-flag when the communication gets recovered */ 242 /* clear reset-flag when the communication gets recovered */
241 if (!err) 243 if (!err || codec_in_pm(codec))
242 bus->response_reset = 0; 244 bus->response_reset = 0;
243 return err; 245 return err;
244} 246}
@@ -3616,6 +3618,8 @@ static unsigned int hda_call_codec_suspend(struct hda_codec *codec, bool in_wq)
3616{ 3618{
3617 unsigned int state; 3619 unsigned int state;
3618 3620
3621 codec->in_pm = 1;
3622
3619 if (codec->patch_ops.suspend) 3623 if (codec->patch_ops.suspend)
3620 codec->patch_ops.suspend(codec); 3624 codec->patch_ops.suspend(codec);
3621 hda_cleanup_all_streams(codec); 3625 hda_cleanup_all_streams(codec);
@@ -3630,6 +3634,7 @@ static unsigned int hda_call_codec_suspend(struct hda_codec *codec, bool in_wq)
3630 codec->power_transition = 0; 3634 codec->power_transition = 0;
3631 codec->power_jiffies = jiffies; 3635 codec->power_jiffies = jiffies;
3632 spin_unlock(&codec->power_lock); 3636 spin_unlock(&codec->power_lock);
3637 codec->in_pm = 0;
3633 return state; 3638 return state;
3634} 3639}
3635 3640
@@ -3638,6 +3643,8 @@ static unsigned int hda_call_codec_suspend(struct hda_codec *codec, bool in_wq)
3638 */ 3643 */
3639static void hda_call_codec_resume(struct hda_codec *codec) 3644static void hda_call_codec_resume(struct hda_codec *codec)
3640{ 3645{
3646 codec->in_pm = 1;
3647
3641 /* set as if powered on for avoiding re-entering the resume 3648 /* set as if powered on for avoiding re-entering the resume
3642 * in the resume / power-save sequence 3649 * in the resume / power-save sequence
3643 */ 3650 */
@@ -3656,6 +3663,8 @@ static void hda_call_codec_resume(struct hda_codec *codec)
3656 snd_hda_codec_resume_cache(codec); 3663 snd_hda_codec_resume_cache(codec);
3657 } 3664 }
3658 snd_hda_jack_report_sync(codec); 3665 snd_hda_jack_report_sync(codec);
3666
3667 codec->in_pm = 0;
3659 snd_hda_power_down(codec); /* flag down before returning */ 3668 snd_hda_power_down(codec); /* flag down before returning */
3660} 3669}
3661#endif /* CONFIG_PM */ 3670#endif /* CONFIG_PM */
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h
index 507fe8a917b..4f4e545c0f4 100644
--- a/sound/pci/hda/hda_codec.h
+++ b/sound/pci/hda/hda_codec.h
@@ -869,6 +869,7 @@ struct hda_codec {
869 unsigned int power_on :1; /* current (global) power-state */ 869 unsigned int power_on :1; /* current (global) power-state */
870 unsigned int d3_stop_clk:1; /* support D3 operation without BCLK */ 870 unsigned int d3_stop_clk:1; /* support D3 operation without BCLK */
871 unsigned int pm_down_notified:1; /* PM notified to controller */ 871 unsigned int pm_down_notified:1; /* PM notified to controller */
872 unsigned int in_pm:1; /* suspend/resume being performed */
872 int power_transition; /* power-state in transition */ 873 int power_transition; /* power-state in transition */
873 int power_count; /* current (global) power refcount */ 874 int power_count; /* current (global) power refcount */
874 struct delayed_work power_work; /* delayed task for powerdown */ 875 struct delayed_work power_work; /* delayed task for powerdown */
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 6833835a218..f9d870e554d 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -501,6 +501,7 @@ struct azx {
501 501
502 /* VGA-switcheroo setup */ 502 /* VGA-switcheroo setup */
503 unsigned int use_vga_switcheroo:1; 503 unsigned int use_vga_switcheroo:1;
504 unsigned int vga_switcheroo_registered:1;
504 unsigned int init_failed:1; /* delayed init failed */ 505 unsigned int init_failed:1; /* delayed init failed */
505 unsigned int disabled:1; /* disabled by VGA-switcher */ 506 unsigned int disabled:1; /* disabled by VGA-switcher */
506 507
@@ -555,6 +556,12 @@ enum {
555#define AZX_DCAPS_ALIGN_BUFSIZE (1 << 22) /* buffer size alignment */ 556#define AZX_DCAPS_ALIGN_BUFSIZE (1 << 22) /* buffer size alignment */
556#define AZX_DCAPS_4K_BDLE_BOUNDARY (1 << 23) /* BDLE in 4k boundary */ 557#define AZX_DCAPS_4K_BDLE_BOUNDARY (1 << 23) /* BDLE in 4k boundary */
557#define AZX_DCAPS_COUNT_LPIB_DELAY (1 << 25) /* Take LPIB as delay */ 558#define AZX_DCAPS_COUNT_LPIB_DELAY (1 << 25) /* Take LPIB as delay */
559#define AZX_DCAPS_PM_RUNTIME (1 << 26) /* runtime PM support */
560
561/* quirks for Intel PCH */
562#define AZX_DCAPS_INTEL_PCH \
563 (AZX_DCAPS_SCH_SNOOP | AZX_DCAPS_BUFSIZE | \
564 AZX_DCAPS_COUNT_LPIB_DELAY | AZX_DCAPS_PM_RUNTIME)
558 565
559/* quirks for ATI SB / AMD Hudson */ 566/* quirks for ATI SB / AMD Hudson */
560#define AZX_DCAPS_PRESET_ATI_SB \ 567#define AZX_DCAPS_PRESET_ATI_SB \
@@ -2157,9 +2164,12 @@ static unsigned int azx_get_position(struct azx *chip,
2157 if (delay < 0) 2164 if (delay < 0)
2158 delay += azx_dev->bufsize; 2165 delay += azx_dev->bufsize;
2159 if (delay >= azx_dev->period_bytes) { 2166 if (delay >= azx_dev->period_bytes) {
2160 snd_printdd("delay %d > period_bytes %d\n", 2167 snd_printk(KERN_WARNING SFX
2161 delay, azx_dev->period_bytes); 2168 "Unstable LPIB (%d >= %d); "
2162 delay = 0; /* something is wrong */ 2169 "disabling LPIB delay counting\n",
2170 delay, azx_dev->period_bytes);
2171 delay = 0;
2172 chip->driver_caps &= ~AZX_DCAPS_COUNT_LPIB_DELAY;
2163 } 2173 }
2164 azx_dev->substream->runtime->delay = 2174 azx_dev->substream->runtime->delay =
2165 bytes_to_frames(azx_dev->substream->runtime, delay); 2175 bytes_to_frames(azx_dev->substream->runtime, delay);
@@ -2429,6 +2439,9 @@ static void azx_power_notify(struct hda_bus *bus, bool power_up)
2429{ 2439{
2430 struct azx *chip = bus->private_data; 2440 struct azx *chip = bus->private_data;
2431 2441
2442 if (!(chip->driver_caps & AZX_DCAPS_PM_RUNTIME))
2443 return;
2444
2432 if (power_up) 2445 if (power_up)
2433 pm_runtime_get_sync(&chip->pci->dev); 2446 pm_runtime_get_sync(&chip->pci->dev);
2434 else 2447 else
@@ -2544,7 +2557,8 @@ static int azx_runtime_suspend(struct device *dev)
2544 struct snd_card *card = dev_get_drvdata(dev); 2557 struct snd_card *card = dev_get_drvdata(dev);
2545 struct azx *chip = card->private_data; 2558 struct azx *chip = card->private_data;
2546 2559
2547 if (!power_save_controller) 2560 if (!power_save_controller ||
2561 !(chip->driver_caps & AZX_DCAPS_PM_RUNTIME))
2548 return -EAGAIN; 2562 return -EAGAIN;
2549 2563
2550 azx_stop_chip(chip); 2564 azx_stop_chip(chip);
@@ -2640,7 +2654,9 @@ static void azx_vs_set_state(struct pci_dev *pci,
2640 if (disabled) { 2654 if (disabled) {
2641 azx_suspend(&pci->dev); 2655 azx_suspend(&pci->dev);
2642 chip->disabled = true; 2656 chip->disabled = true;
2643 snd_hda_lock_devices(chip->bus); 2657 if (snd_hda_lock_devices(chip->bus))
2658 snd_printk(KERN_WARNING SFX
2659 "Cannot lock devices!\n");
2644 } else { 2660 } else {
2645 snd_hda_unlock_devices(chip->bus); 2661 snd_hda_unlock_devices(chip->bus);
2646 chip->disabled = false; 2662 chip->disabled = false;
@@ -2683,14 +2699,20 @@ static const struct vga_switcheroo_client_ops azx_vs_ops = {
2683 2699
2684static int __devinit register_vga_switcheroo(struct azx *chip) 2700static int __devinit register_vga_switcheroo(struct azx *chip)
2685{ 2701{
2702 int err;
2703
2686 if (!chip->use_vga_switcheroo) 2704 if (!chip->use_vga_switcheroo)
2687 return 0; 2705 return 0;
2688 /* FIXME: currently only handling DIS controller 2706 /* FIXME: currently only handling DIS controller
2689 * is there any machine with two switchable HDMI audio controllers? 2707 * is there any machine with two switchable HDMI audio controllers?
2690 */ 2708 */
2691 return vga_switcheroo_register_audio_client(chip->pci, &azx_vs_ops, 2709 err = vga_switcheroo_register_audio_client(chip->pci, &azx_vs_ops,
2692 VGA_SWITCHEROO_DIS, 2710 VGA_SWITCHEROO_DIS,
2693 chip->bus != NULL); 2711 chip->bus != NULL);
2712 if (err < 0)
2713 return err;
2714 chip->vga_switcheroo_registered = 1;
2715 return 0;
2694} 2716}
2695#else 2717#else
2696#define init_vga_switcheroo(chip) /* NOP */ 2718#define init_vga_switcheroo(chip) /* NOP */
@@ -2712,7 +2734,8 @@ static int azx_free(struct azx *chip)
2712 if (use_vga_switcheroo(chip)) { 2734 if (use_vga_switcheroo(chip)) {
2713 if (chip->disabled && chip->bus) 2735 if (chip->disabled && chip->bus)
2714 snd_hda_unlock_devices(chip->bus); 2736 snd_hda_unlock_devices(chip->bus);
2715 vga_switcheroo_unregister_client(chip->pci); 2737 if (chip->vga_switcheroo_registered)
2738 vga_switcheroo_unregister_client(chip->pci);
2716 } 2739 }
2717 2740
2718 if (chip->initialized) { 2741 if (chip->initialized) {
@@ -2813,8 +2836,6 @@ static struct snd_pci_quirk position_fix_list[] __devinitdata = {
2813 SND_PCI_QUIRK(0x1043, 0x813d, "ASUS P5AD2", POS_FIX_LPIB), 2836 SND_PCI_QUIRK(0x1043, 0x813d, "ASUS P5AD2", POS_FIX_LPIB),
2814 SND_PCI_QUIRK(0x1043, 0x81b3, "ASUS", POS_FIX_LPIB), 2837 SND_PCI_QUIRK(0x1043, 0x81b3, "ASUS", POS_FIX_LPIB),
2815 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS M2V", POS_FIX_LPIB), 2838 SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS M2V", POS_FIX_LPIB),
2816 SND_PCI_QUIRK(0x1043, 0x1ac3, "ASUS X53S", POS_FIX_POSBUF),
2817 SND_PCI_QUIRK(0x1043, 0x1b43, "ASUS K53E", POS_FIX_POSBUF),
2818 SND_PCI_QUIRK(0x104d, 0x9069, "Sony VPCS11V9E", POS_FIX_LPIB), 2839 SND_PCI_QUIRK(0x104d, 0x9069, "Sony VPCS11V9E", POS_FIX_LPIB),
2819 SND_PCI_QUIRK(0x10de, 0xcb89, "Macbook Pro 7,1", POS_FIX_LPIB), 2840 SND_PCI_QUIRK(0x10de, 0xcb89, "Macbook Pro 7,1", POS_FIX_LPIB),
2820 SND_PCI_QUIRK(0x1297, 0x3166, "Shuttle", POS_FIX_LPIB), 2841 SND_PCI_QUIRK(0x1297, 0x3166, "Shuttle", POS_FIX_LPIB),
@@ -3062,14 +3083,6 @@ static int __devinit azx_create(struct snd_card *card, struct pci_dev *pci,
3062 } 3083 }
3063 3084
3064 ok: 3085 ok:
3065 err = register_vga_switcheroo(chip);
3066 if (err < 0) {
3067 snd_printk(KERN_ERR SFX
3068 "Error registering VGA-switcheroo client\n");
3069 azx_free(chip);
3070 return err;
3071 }
3072
3073 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); 3086 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
3074 if (err < 0) { 3087 if (err < 0) {
3075 snd_printk(KERN_ERR SFX "Error creating device [card]!\n"); 3088 snd_printk(KERN_ERR SFX "Error creating device [card]!\n");
@@ -3340,6 +3353,13 @@ static int __devinit azx_probe(struct pci_dev *pci,
3340 if (pci_dev_run_wake(pci)) 3353 if (pci_dev_run_wake(pci))
3341 pm_runtime_put_noidle(&pci->dev); 3354 pm_runtime_put_noidle(&pci->dev);
3342 3355
3356 err = register_vga_switcheroo(chip);
3357 if (err < 0) {
3358 snd_printk(KERN_ERR SFX
3359 "Error registering VGA-switcheroo client\n");
3360 goto out_free;
3361 }
3362
3343 dev++; 3363 dev++;
3344 return 0; 3364 return 0;
3345 3365
@@ -3419,39 +3439,30 @@ static void __devexit azx_remove(struct pci_dev *pci)
3419static DEFINE_PCI_DEVICE_TABLE(azx_ids) = { 3439static DEFINE_PCI_DEVICE_TABLE(azx_ids) = {
3420 /* CPT */ 3440 /* CPT */
3421 { PCI_DEVICE(0x8086, 0x1c20), 3441 { PCI_DEVICE(0x8086, 0x1c20),
3422 .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_SCH_SNOOP | 3442 .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_INTEL_PCH },
3423 AZX_DCAPS_BUFSIZE | AZX_DCAPS_COUNT_LPIB_DELAY },
3424 /* PBG */ 3443 /* PBG */
3425 { PCI_DEVICE(0x8086, 0x1d20), 3444 { PCI_DEVICE(0x8086, 0x1d20),
3426 .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_SCH_SNOOP | 3445 .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_INTEL_PCH },
3427 AZX_DCAPS_BUFSIZE},
3428 /* Panther Point */ 3446 /* Panther Point */
3429 { PCI_DEVICE(0x8086, 0x1e20), 3447 { PCI_DEVICE(0x8086, 0x1e20),
3430 .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_SCH_SNOOP | 3448 .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_INTEL_PCH },
3431 AZX_DCAPS_BUFSIZE | AZX_DCAPS_COUNT_LPIB_DELAY },
3432 /* Lynx Point */ 3449 /* Lynx Point */
3433 { PCI_DEVICE(0x8086, 0x8c20), 3450 { PCI_DEVICE(0x8086, 0x8c20),
3434 .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_SCH_SNOOP | 3451 .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_INTEL_PCH },
3435 AZX_DCAPS_BUFSIZE | AZX_DCAPS_COUNT_LPIB_DELAY },
3436 /* Lynx Point-LP */ 3452 /* Lynx Point-LP */
3437 { PCI_DEVICE(0x8086, 0x9c20), 3453 { PCI_DEVICE(0x8086, 0x9c20),
3438 .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_SCH_SNOOP | 3454 .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_INTEL_PCH },
3439 AZX_DCAPS_BUFSIZE | AZX_DCAPS_COUNT_LPIB_DELAY },
3440 /* Lynx Point-LP */ 3455 /* Lynx Point-LP */
3441 { PCI_DEVICE(0x8086, 0x9c21), 3456 { PCI_DEVICE(0x8086, 0x9c21),
3442 .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_SCH_SNOOP | 3457 .driver_data = AZX_DRIVER_PCH | AZX_DCAPS_INTEL_PCH },
3443 AZX_DCAPS_BUFSIZE | AZX_DCAPS_COUNT_LPIB_DELAY },
3444 /* Haswell */ 3458 /* Haswell */
3445 { PCI_DEVICE(0x8086, 0x0c0c), 3459 { PCI_DEVICE(0x8086, 0x0c0c),
3446 .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_SCH_SNOOP | 3460 .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_INTEL_PCH },
3447 AZX_DCAPS_BUFSIZE | AZX_DCAPS_COUNT_LPIB_DELAY },
3448 { PCI_DEVICE(0x8086, 0x0d0c), 3461 { PCI_DEVICE(0x8086, 0x0d0c),
3449 .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_SCH_SNOOP | 3462 .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_INTEL_PCH },
3450 AZX_DCAPS_BUFSIZE | AZX_DCAPS_COUNT_LPIB_DELAY },
3451 /* 5 Series/3400 */ 3463 /* 5 Series/3400 */
3452 { PCI_DEVICE(0x8086, 0x3b56), 3464 { PCI_DEVICE(0x8086, 0x3b56),
3453 .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_SCH_SNOOP | 3465 .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_INTEL_PCH },
3454 AZX_DCAPS_BUFSIZE | AZX_DCAPS_COUNT_LPIB_DELAY },
3455 /* SCH */ 3466 /* SCH */
3456 { PCI_DEVICE(0x8086, 0x811b), 3467 { PCI_DEVICE(0x8086, 0x811b),
3457 .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_SCH_SNOOP | 3468 .driver_data = AZX_DRIVER_SCH | AZX_DCAPS_SCH_SNOOP |
@@ -3553,6 +3564,8 @@ static DEFINE_PCI_DEVICE_TABLE(azx_ids) = {
3553 /* Teradici */ 3564 /* Teradici */
3554 { PCI_DEVICE(0x6549, 0x1200), 3565 { PCI_DEVICE(0x6549, 0x1200),
3555 .driver_data = AZX_DRIVER_TERA | AZX_DCAPS_NO_64BIT }, 3566 .driver_data = AZX_DRIVER_TERA | AZX_DCAPS_NO_64BIT },
3567 { PCI_DEVICE(0x6549, 0x2200),
3568 .driver_data = AZX_DRIVER_TERA | AZX_DCAPS_NO_64BIT },
3556 /* Creative X-Fi (CA0110-IBG) */ 3569 /* Creative X-Fi (CA0110-IBG) */
3557 /* CTHDA chips */ 3570 /* CTHDA chips */
3558 { PCI_DEVICE(0x1102, 0x0010), 3571 { PCI_DEVICE(0x1102, 0x0010),
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c
index cdd43eadbc6..1eeba738666 100644
--- a/sound/pci/hda/patch_analog.c
+++ b/sound/pci/hda/patch_analog.c
@@ -545,6 +545,7 @@ static int ad198x_build_pcms(struct hda_codec *codec)
545 if (spec->multiout.dig_out_nid) { 545 if (spec->multiout.dig_out_nid) {
546 info++; 546 info++;
547 codec->num_pcms++; 547 codec->num_pcms++;
548 codec->spdif_status_reset = 1;
548 info->name = "AD198x Digital"; 549 info->name = "AD198x Digital";
549 info->pcm_type = HDA_PCM_TYPE_SPDIF; 550 info->pcm_type = HDA_PCM_TYPE_SPDIF;
550 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = ad198x_pcm_digital_playback; 551 info->stream[SNDRV_PCM_STREAM_PLAYBACK] = ad198x_pcm_digital_playback;
diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c
index 61a71131711..3bcb6717235 100644
--- a/sound/pci/hda/patch_cirrus.c
+++ b/sound/pci/hda/patch_cirrus.c
@@ -101,8 +101,8 @@ enum {
101#define CS420X_VENDOR_NID 0x11 101#define CS420X_VENDOR_NID 0x11
102#define CS_DIG_OUT1_PIN_NID 0x10 102#define CS_DIG_OUT1_PIN_NID 0x10
103#define CS_DIG_OUT2_PIN_NID 0x15 103#define CS_DIG_OUT2_PIN_NID 0x15
104#define CS_DMIC1_PIN_NID 0x12 104#define CS_DMIC1_PIN_NID 0x0e
105#define CS_DMIC2_PIN_NID 0x0e 105#define CS_DMIC2_PIN_NID 0x12
106 106
107/* coef indices */ 107/* coef indices */
108#define IDX_SPDIF_STAT 0x0000 108#define IDX_SPDIF_STAT 0x0000
@@ -466,6 +466,7 @@ static int parse_output(struct hda_codec *codec)
466 memcpy(cfg->speaker_pins, cfg->line_out_pins, 466 memcpy(cfg->speaker_pins, cfg->line_out_pins,
467 sizeof(cfg->speaker_pins)); 467 sizeof(cfg->speaker_pins));
468 cfg->line_outs = 0; 468 cfg->line_outs = 0;
469 memset(cfg->line_out_pins, 0, sizeof(cfg->line_out_pins));
469 } 470 }
470 471
471 return 0; 472 return 0;
@@ -1079,14 +1080,18 @@ static void init_input(struct hda_codec *codec)
1079 cs_automic(codec, NULL); 1080 cs_automic(codec, NULL);
1080 1081
1081 coef = 0x000a; /* ADC1/2 - Digital and Analog Soft Ramp */ 1082 coef = 0x000a; /* ADC1/2 - Digital and Analog Soft Ramp */
1083 cs_vendor_coef_set(codec, IDX_ADC_CFG, coef);
1084
1085 coef = cs_vendor_coef_get(codec, IDX_BEEP_CFG);
1082 if (is_active_pin(codec, CS_DMIC2_PIN_NID)) 1086 if (is_active_pin(codec, CS_DMIC2_PIN_NID))
1083 coef |= 0x0500; /* DMIC2 2 chan on, GPIO1 off */ 1087 coef |= 1 << 4; /* DMIC2 2 chan on, GPIO1 off */
1084 if (is_active_pin(codec, CS_DMIC1_PIN_NID)) 1088 if (is_active_pin(codec, CS_DMIC1_PIN_NID))
1085 coef |= 0x1800; /* DMIC1 2 chan on, GPIO0 off 1089 coef |= 1 << 3; /* DMIC1 2 chan on, GPIO0 off
1086 * No effect if SPDIF_OUT2 is 1090 * No effect if SPDIF_OUT2 is
1087 * selected in IDX_SPDIF_CTL. 1091 * selected in IDX_SPDIF_CTL.
1088 */ 1092 */
1089 cs_vendor_coef_set(codec, IDX_ADC_CFG, coef); 1093
1094 cs_vendor_coef_set(codec, IDX_BEEP_CFG, coef);
1090 } else { 1095 } else {
1091 if (spec->mic_detect) 1096 if (spec->mic_detect)
1092 cs_automic(codec, NULL); 1097 cs_automic(codec, NULL);
@@ -1107,7 +1112,7 @@ static const struct hda_verb cs_coef_init_verbs[] = {
1107 | 0x0400 /* Disable Coefficient Auto increment */ 1112 | 0x0400 /* Disable Coefficient Auto increment */
1108 )}, 1113 )},
1109 /* Beep */ 1114 /* Beep */
1110 {0x11, AC_VERB_SET_COEF_INDEX, IDX_DAC_CFG}, 1115 {0x11, AC_VERB_SET_COEF_INDEX, IDX_BEEP_CFG},
1111 {0x11, AC_VERB_SET_PROC_COEF, 0x0007}, /* Enable Beep thru DAC1/2/3 */ 1116 {0x11, AC_VERB_SET_PROC_COEF, 0x0007}, /* Enable Beep thru DAC1/2/3 */
1112 1117
1113 {} /* terminator */ 1118 {} /* terminator */
@@ -1728,8 +1733,7 @@ static int cs421x_mux_enum_put(struct snd_kcontrol *kcontrol,
1728 1733
1729} 1734}
1730 1735
1731static struct snd_kcontrol_new cs421x_capture_source = { 1736static const struct snd_kcontrol_new cs421x_capture_source = {
1732
1733 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 1737 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1734 .name = "Capture Source", 1738 .name = "Capture Source",
1735 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, 1739 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
@@ -1946,7 +1950,7 @@ static int cs421x_suspend(struct hda_codec *codec)
1946} 1950}
1947#endif 1951#endif
1948 1952
1949static struct hda_codec_ops cs421x_patch_ops = { 1953static const struct hda_codec_ops cs421x_patch_ops = {
1950 .build_controls = cs421x_build_controls, 1954 .build_controls = cs421x_build_controls,
1951 .build_pcms = cs_build_pcms, 1955 .build_pcms = cs_build_pcms,
1952 .init = cs421x_init, 1956 .init = cs421x_init,
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 8253b4eeb6a..ad68d223f8a 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -2598,8 +2598,10 @@ static const char *alc_get_line_out_pfx(struct alc_spec *spec, int ch,
2598 return "PCM"; 2598 return "PCM";
2599 break; 2599 break;
2600 } 2600 }
2601 if (snd_BUG_ON(ch >= ARRAY_SIZE(channel_name))) 2601 if (ch >= ARRAY_SIZE(channel_name)) {
2602 snd_BUG();
2602 return "PCM"; 2603 return "PCM";
2604 }
2603 2605
2604 return channel_name[ch]; 2606 return channel_name[ch];
2605} 2607}
@@ -5405,6 +5407,7 @@ static const struct snd_pci_quirk alc882_fixup_tbl[] = {
5405 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC889_FIXUP_IMAC91_VREF), 5407 SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC889_FIXUP_IMAC91_VREF),
5406 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC889_FIXUP_IMAC91_VREF), 5408 SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC889_FIXUP_IMAC91_VREF),
5407 SND_PCI_QUIRK(0x106b, 0x4200, "Mac Pro 5,1", ALC885_FIXUP_MACPRO_GPIO), 5409 SND_PCI_QUIRK(0x106b, 0x4200, "Mac Pro 5,1", ALC885_FIXUP_MACPRO_GPIO),
5410 SND_PCI_QUIRK(0x106b, 0x4300, "iMac 9,1", ALC889_FIXUP_IMAC91_VREF),
5408 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC889_FIXUP_IMAC91_VREF), 5411 SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC889_FIXUP_IMAC91_VREF),
5409 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC889_FIXUP_IMAC91_VREF), 5412 SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC889_FIXUP_IMAC91_VREF),
5410 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC889_FIXUP_IMAC91_VREF), 5413 SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC889_FIXUP_IMAC91_VREF),
@@ -5675,6 +5678,7 @@ static const struct hda_verb alc268_beep_init_verbs[] = {
5675 5678
5676enum { 5679enum {
5677 ALC268_FIXUP_INV_DMIC, 5680 ALC268_FIXUP_INV_DMIC,
5681 ALC268_FIXUP_HP_EAPD,
5678}; 5682};
5679 5683
5680static const struct alc_fixup alc268_fixups[] = { 5684static const struct alc_fixup alc268_fixups[] = {
@@ -5682,10 +5686,26 @@ static const struct alc_fixup alc268_fixups[] = {
5682 .type = ALC_FIXUP_FUNC, 5686 .type = ALC_FIXUP_FUNC,
5683 .v.func = alc_fixup_inv_dmic_0x12, 5687 .v.func = alc_fixup_inv_dmic_0x12,
5684 }, 5688 },
5689 [ALC268_FIXUP_HP_EAPD] = {
5690 .type = ALC_FIXUP_VERBS,
5691 .v.verbs = (const struct hda_verb[]) {
5692 {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0},
5693 {}
5694 }
5695 },
5685}; 5696};
5686 5697
5687static const struct alc_model_fixup alc268_fixup_models[] = { 5698static const struct alc_model_fixup alc268_fixup_models[] = {
5688 {.id = ALC268_FIXUP_INV_DMIC, .name = "inv-dmic"}, 5699 {.id = ALC268_FIXUP_INV_DMIC, .name = "inv-dmic"},
5700 {.id = ALC268_FIXUP_HP_EAPD, .name = "hp-eapd"},
5701 {}
5702};
5703
5704static const struct snd_pci_quirk alc268_fixup_tbl[] = {
5705 /* below is codec SSID since multiple Toshiba laptops have the
5706 * same PCI SSID 1179:ff00
5707 */
5708 SND_PCI_QUIRK(0x1179, 0xff06, "Toshiba P200", ALC268_FIXUP_HP_EAPD),
5689 {} 5709 {}
5690}; 5710};
5691 5711
@@ -5720,7 +5740,7 @@ static int patch_alc268(struct hda_codec *codec)
5720 5740
5721 spec = codec->spec; 5741 spec = codec->spec;
5722 5742
5723 alc_pick_fixup(codec, alc268_fixup_models, NULL, alc268_fixups); 5743 alc_pick_fixup(codec, alc268_fixup_models, alc268_fixup_tbl, alc268_fixups);
5724 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE); 5744 alc_apply_fixup(codec, ALC_FIXUP_ACT_PRE_PROBE);
5725 5745
5726 /* automatic parse from the BIOS config */ 5746 /* automatic parse from the BIOS config */
@@ -5821,7 +5841,7 @@ static int alc269_parse_auto_config(struct hda_codec *codec)
5821 return alc_parse_auto_config(codec, alc269_ignore, ssids); 5841 return alc_parse_auto_config(codec, alc269_ignore, ssids);
5822} 5842}
5823 5843
5824static void alc269_toggle_power_output(struct hda_codec *codec, int power_up) 5844static void alc269vb_toggle_power_output(struct hda_codec *codec, int power_up)
5825{ 5845{
5826 int val = alc_read_coef_idx(codec, 0x04); 5846 int val = alc_read_coef_idx(codec, 0x04);
5827 if (power_up) 5847 if (power_up)
@@ -5838,10 +5858,10 @@ static void alc269_shutup(struct hda_codec *codec)
5838 if (spec->codec_variant != ALC269_TYPE_ALC269VB) 5858 if (spec->codec_variant != ALC269_TYPE_ALC269VB)
5839 return; 5859 return;
5840 5860
5841 if ((alc_get_coef0(codec) & 0x00ff) == 0x017) 5861 if (spec->codec_variant == ALC269_TYPE_ALC269VB)
5842 alc269_toggle_power_output(codec, 0); 5862 alc269vb_toggle_power_output(codec, 0);
5843 if ((alc_get_coef0(codec) & 0x00ff) == 0x018) { 5863 if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
5844 alc269_toggle_power_output(codec, 0); 5864 (alc_get_coef0(codec) & 0x00ff) == 0x018) {
5845 msleep(150); 5865 msleep(150);
5846 } 5866 }
5847} 5867}
@@ -5851,24 +5871,22 @@ static int alc269_resume(struct hda_codec *codec)
5851{ 5871{
5852 struct alc_spec *spec = codec->spec; 5872 struct alc_spec *spec = codec->spec;
5853 5873
5854 if (spec->codec_variant == ALC269_TYPE_ALC269VB || 5874 if (spec->codec_variant == ALC269_TYPE_ALC269VB)
5875 alc269vb_toggle_power_output(codec, 0);
5876 if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
5855 (alc_get_coef0(codec) & 0x00ff) == 0x018) { 5877 (alc_get_coef0(codec) & 0x00ff) == 0x018) {
5856 alc269_toggle_power_output(codec, 0);
5857 msleep(150); 5878 msleep(150);
5858 } 5879 }
5859 5880
5860 codec->patch_ops.init(codec); 5881 codec->patch_ops.init(codec);
5861 5882
5862 if (spec->codec_variant == ALC269_TYPE_ALC269VB || 5883 if (spec->codec_variant == ALC269_TYPE_ALC269VB)
5884 alc269vb_toggle_power_output(codec, 1);
5885 if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
5863 (alc_get_coef0(codec) & 0x00ff) == 0x017) { 5886 (alc_get_coef0(codec) & 0x00ff) == 0x017) {
5864 alc269_toggle_power_output(codec, 1);
5865 msleep(200); 5887 msleep(200);
5866 } 5888 }
5867 5889
5868 if (spec->codec_variant == ALC269_TYPE_ALC269VB ||
5869 (alc_get_coef0(codec) & 0x00ff) == 0x018)
5870 alc269_toggle_power_output(codec, 1);
5871
5872 snd_hda_codec_resume_amp(codec); 5890 snd_hda_codec_resume_amp(codec);
5873 snd_hda_codec_resume_cache(codec); 5891 snd_hda_codec_resume_cache(codec);
5874 hda_call_check_power_status(codec, 0x01); 5892 hda_call_check_power_status(codec, 0x01);
@@ -6186,6 +6204,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = {
6186 SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE), 6204 SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE),
6187 SND_PCI_QUIRK(0x17aa, 0x21f6, "Thinkpad T530", ALC269_FIXUP_LENOVO_DOCK), 6205 SND_PCI_QUIRK(0x17aa, 0x21f6, "Thinkpad T530", ALC269_FIXUP_LENOVO_DOCK),
6188 SND_PCI_QUIRK(0x17aa, 0x21fa, "Thinkpad X230", ALC269_FIXUP_LENOVO_DOCK), 6206 SND_PCI_QUIRK(0x17aa, 0x21fa, "Thinkpad X230", ALC269_FIXUP_LENOVO_DOCK),
6207 SND_PCI_QUIRK(0x17aa, 0x21f3, "Thinkpad T430", ALC269_FIXUP_LENOVO_DOCK),
6189 SND_PCI_QUIRK(0x17aa, 0x21fb, "Thinkpad T430s", ALC269_FIXUP_LENOVO_DOCK), 6208 SND_PCI_QUIRK(0x17aa, 0x21fb, "Thinkpad T430s", ALC269_FIXUP_LENOVO_DOCK),
6190 SND_PCI_QUIRK(0x17aa, 0x2203, "Thinkpad X230 Tablet", ALC269_FIXUP_LENOVO_DOCK), 6209 SND_PCI_QUIRK(0x17aa, 0x2203, "Thinkpad X230 Tablet", ALC269_FIXUP_LENOVO_DOCK),
6191 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_PCM_44K), 6210 SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_PCM_44K),
@@ -7046,6 +7065,7 @@ static const struct hda_codec_preset snd_hda_preset_realtek[] = {
7046 { .id = 0x10ec0282, .name = "ALC282", .patch = patch_alc269 }, 7065 { .id = 0x10ec0282, .name = "ALC282", .patch = patch_alc269 },
7047 { .id = 0x10ec0283, .name = "ALC283", .patch = patch_alc269 }, 7066 { .id = 0x10ec0283, .name = "ALC283", .patch = patch_alc269 },
7048 { .id = 0x10ec0290, .name = "ALC290", .patch = patch_alc269 }, 7067 { .id = 0x10ec0290, .name = "ALC290", .patch = patch_alc269 },
7068 { .id = 0x10ec0292, .name = "ALC292", .patch = patch_alc269 },
7049 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660", 7069 { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
7050 .patch = patch_alc861 }, 7070 .patch = patch_alc861 },
7051 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd }, 7071 { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
@@ -7059,6 +7079,7 @@ static const struct hda_codec_preset snd_hda_preset_realtek[] = {
7059 .patch = patch_alc662 }, 7079 .patch = patch_alc662 },
7060 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 }, 7080 { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
7061 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 }, 7081 { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
7082 { .id = 0x10ec0668, .name = "ALC668", .patch = patch_alc662 },
7062 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 }, 7083 { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
7063 { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 }, 7084 { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 },
7064 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 }, 7085 { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
@@ -7076,6 +7097,7 @@ static const struct hda_codec_preset snd_hda_preset_realtek[] = {
7076 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 }, 7097 { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
7077 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 }, 7098 { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
7078 { .id = 0x10ec0899, .name = "ALC898", .patch = patch_alc882 }, 7099 { .id = 0x10ec0899, .name = "ALC898", .patch = patch_alc882 },
7100 { .id = 0x10ec0900, .name = "ALC1150", .patch = patch_alc882 },
7079 {} /* terminator */ 7101 {} /* terminator */
7080}; 7102};
7081 7103
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index 770013ff556..9ba8af05617 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -1763,6 +1763,8 @@ static const struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
1763 "HP", STAC_HP_ZEPHYR), 1763 "HP", STAC_HP_ZEPHYR),
1764 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3660, 1764 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3660,
1765 "HP Mini", STAC_92HD83XXX_HP_LED), 1765 "HP Mini", STAC_92HD83XXX_HP_LED),
1766 SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x144E,
1767 "HP Pavilion dv5", STAC_92HD83XXX_HP_INV_LED),
1766 {} /* terminator */ 1768 {} /* terminator */
1767}; 1769};
1768 1770
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c
index 72a2f60b087..019e1a00414 100644
--- a/sound/pci/hda/patch_via.c
+++ b/sound/pci/hda/patch_via.c
@@ -1809,11 +1809,11 @@ static int via_auto_fill_dac_nids(struct hda_codec *codec)
1809{ 1809{
1810 struct via_spec *spec = codec->spec; 1810 struct via_spec *spec = codec->spec;
1811 const struct auto_pin_cfg *cfg = &spec->autocfg; 1811 const struct auto_pin_cfg *cfg = &spec->autocfg;
1812 int i, dac_num; 1812 int i;
1813 hda_nid_t nid; 1813 hda_nid_t nid;
1814 1814
1815 spec->multiout.num_dacs = 0;
1815 spec->multiout.dac_nids = spec->private_dac_nids; 1816 spec->multiout.dac_nids = spec->private_dac_nids;
1816 dac_num = 0;
1817 for (i = 0; i < cfg->line_outs; i++) { 1817 for (i = 0; i < cfg->line_outs; i++) {
1818 hda_nid_t dac = 0; 1818 hda_nid_t dac = 0;
1819 nid = cfg->line_out_pins[i]; 1819 nid = cfg->line_out_pins[i];
@@ -1824,16 +1824,13 @@ static int via_auto_fill_dac_nids(struct hda_codec *codec)
1824 if (!i && parse_output_path(codec, nid, dac, 1, 1824 if (!i && parse_output_path(codec, nid, dac, 1,
1825 &spec->out_mix_path)) 1825 &spec->out_mix_path))
1826 dac = spec->out_mix_path.path[0]; 1826 dac = spec->out_mix_path.path[0];
1827 if (dac) { 1827 if (dac)
1828 spec->private_dac_nids[i] = dac; 1828 spec->private_dac_nids[spec->multiout.num_dacs++] = dac;
1829 dac_num++;
1830 }
1831 } 1829 }
1832 if (!spec->out_path[0].depth && spec->out_mix_path.depth) { 1830 if (!spec->out_path[0].depth && spec->out_mix_path.depth) {
1833 spec->out_path[0] = spec->out_mix_path; 1831 spec->out_path[0] = spec->out_mix_path;
1834 spec->out_mix_path.depth = 0; 1832 spec->out_mix_path.depth = 0;
1835 } 1833 }
1836 spec->multiout.num_dacs = dac_num;
1837 return 0; 1834 return 0;
1838} 1835}
1839 1836
@@ -3628,6 +3625,7 @@ static void set_widgets_power_state_vt2002P(struct hda_codec *codec)
3628 */ 3625 */
3629enum { 3626enum {
3630 VIA_FIXUP_INTMIC_BOOST, 3627 VIA_FIXUP_INTMIC_BOOST,
3628 VIA_FIXUP_ASUS_G75,
3631}; 3629};
3632 3630
3633static void via_fixup_intmic_boost(struct hda_codec *codec, 3631static void via_fixup_intmic_boost(struct hda_codec *codec,
@@ -3642,13 +3640,35 @@ static const struct hda_fixup via_fixups[] = {
3642 .type = HDA_FIXUP_FUNC, 3640 .type = HDA_FIXUP_FUNC,
3643 .v.func = via_fixup_intmic_boost, 3641 .v.func = via_fixup_intmic_boost,
3644 }, 3642 },
3643 [VIA_FIXUP_ASUS_G75] = {
3644 .type = HDA_FIXUP_PINS,
3645 .v.pins = (const struct hda_pintbl[]) {
3646 /* set 0x24 and 0x33 as speakers */
3647 { 0x24, 0x991301f0 },
3648 { 0x33, 0x991301f1 }, /* subwoofer */
3649 { }
3650 }
3651 },
3645}; 3652};
3646 3653
3647static const struct snd_pci_quirk vt2002p_fixups[] = { 3654static const struct snd_pci_quirk vt2002p_fixups[] = {
3655 SND_PCI_QUIRK(0x1043, 0x1487, "Asus G75", VIA_FIXUP_ASUS_G75),
3648 SND_PCI_QUIRK(0x1043, 0x8532, "Asus X202E", VIA_FIXUP_INTMIC_BOOST), 3656 SND_PCI_QUIRK(0x1043, 0x8532, "Asus X202E", VIA_FIXUP_INTMIC_BOOST),
3649 {} 3657 {}
3650}; 3658};
3651 3659
3660/* NIDs 0x24 and 0x33 on VT1802 have connections to non-existing NID 0x3e
3661 * Replace this with mixer NID 0x1c
3662 */
3663static void fix_vt1802_connections(struct hda_codec *codec)
3664{
3665 static hda_nid_t conn_24[] = { 0x14, 0x1c };
3666 static hda_nid_t conn_33[] = { 0x1c };
3667
3668 snd_hda_override_conn_list(codec, 0x24, ARRAY_SIZE(conn_24), conn_24);
3669 snd_hda_override_conn_list(codec, 0x33, ARRAY_SIZE(conn_33), conn_33);
3670}
3671
3652/* patch for vt2002P */ 3672/* patch for vt2002P */
3653static int patch_vt2002P(struct hda_codec *codec) 3673static int patch_vt2002P(struct hda_codec *codec)
3654{ 3674{
@@ -3663,6 +3683,8 @@ static int patch_vt2002P(struct hda_codec *codec)
3663 spec->aa_mix_nid = 0x21; 3683 spec->aa_mix_nid = 0x21;
3664 override_mic_boost(codec, 0x2b, 0, 3, 40); 3684 override_mic_boost(codec, 0x2b, 0, 3, 40);
3665 override_mic_boost(codec, 0x29, 0, 3, 40); 3685 override_mic_boost(codec, 0x29, 0, 3, 40);
3686 if (spec->codec_type == VT1802)
3687 fix_vt1802_connections(codec);
3666 add_secret_dac_path(codec); 3688 add_secret_dac_path(codec);
3667 3689
3668 snd_hda_pick_fixup(codec, NULL, vt2002p_fixups, via_fixups); 3690 snd_hda_pick_fixup(codec, NULL, vt2002p_fixups, via_fixups);
diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c
index 3050a527925..245d874891b 100644
--- a/sound/pci/ice1712/ice1724.c
+++ b/sound/pci/ice1712/ice1724.c
@@ -2859,7 +2859,12 @@ static int snd_vt1724_resume(struct device *dev)
2859 ice->set_spdif_clock(ice, 0); 2859 ice->set_spdif_clock(ice, 0);
2860 } else { 2860 } else {
2861 /* internal on-card clock */ 2861 /* internal on-card clock */
2862 snd_vt1724_set_pro_rate(ice, ice->pro_rate_default, 1); 2862 int rate;
2863 if (ice->cur_rate)
2864 rate = ice->cur_rate;
2865 else
2866 rate = ice->pro_rate_default;
2867 snd_vt1724_set_pro_rate(ice, rate, 1);
2863 } 2868 }
2864 2869
2865 update_spdif_bits(ice, ice->pm_saved_spdif_ctrl); 2870 update_spdif_bits(ice, ice->pm_saved_spdif_ctrl);
diff --git a/sound/pci/rme9652/hdspm.c b/sound/pci/rme9652/hdspm.c
index b12308b5ba2..748e36c6660 100644
--- a/sound/pci/rme9652/hdspm.c
+++ b/sound/pci/rme9652/hdspm.c
@@ -971,6 +971,7 @@ static inline void snd_hdspm_initialize_midi_flush(struct hdspm *hdspm);
971static int hdspm_update_simple_mixer_controls(struct hdspm *hdspm); 971static int hdspm_update_simple_mixer_controls(struct hdspm *hdspm);
972static int hdspm_autosync_ref(struct hdspm *hdspm); 972static int hdspm_autosync_ref(struct hdspm *hdspm);
973static int snd_hdspm_set_defaults(struct hdspm *hdspm); 973static int snd_hdspm_set_defaults(struct hdspm *hdspm);
974static int hdspm_system_clock_mode(struct hdspm *hdspm);
974static void hdspm_set_sgbuf(struct hdspm *hdspm, 975static void hdspm_set_sgbuf(struct hdspm *hdspm,
975 struct snd_pcm_substream *substream, 976 struct snd_pcm_substream *substream,
976 unsigned int reg, int channels); 977 unsigned int reg, int channels);
@@ -1989,10 +1990,14 @@ static int hdspm_get_system_sample_rate(struct hdspm *hdspm)
1989 rate = hdspm_calc_dds_value(hdspm, period); 1990 rate = hdspm_calc_dds_value(hdspm, period);
1990 1991
1991 if (rate > 207000) { 1992 if (rate > 207000) {
1992 /* Unreasonable high sample rate as seen on PCI MADI cards. 1993 /* Unreasonable high sample rate as seen on PCI MADI cards. */
1993 * Use the cached value instead. 1994 if (0 == hdspm_system_clock_mode(hdspm)) {
1994 */ 1995 /* master mode, return internal sample rate */
1995 rate = hdspm->system_sample_rate; 1996 rate = hdspm->system_sample_rate;
1997 } else {
1998 /* slave mode, return external sample rate */
1999 rate = hdspm_external_sample_rate(hdspm);
2000 }
1996 } 2001 }
1997 2002
1998 return rate; 2003 return rate;
@@ -2000,12 +2005,14 @@ static int hdspm_get_system_sample_rate(struct hdspm *hdspm)
2000 2005
2001 2006
2002#define HDSPM_SYSTEM_SAMPLE_RATE(xname, xindex) \ 2007#define HDSPM_SYSTEM_SAMPLE_RATE(xname, xindex) \
2003{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 2008{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2004 .name = xname, \ 2009 .name = xname, \
2005 .index = xindex, \ 2010 .index = xindex, \
2006 .access = SNDRV_CTL_ELEM_ACCESS_READ, \ 2011 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE |\
2007 .info = snd_hdspm_info_system_sample_rate, \ 2012 SNDRV_CTL_ELEM_ACCESS_VOLATILE, \
2008 .get = snd_hdspm_get_system_sample_rate \ 2013 .info = snd_hdspm_info_system_sample_rate, \
2014 .put = snd_hdspm_put_system_sample_rate, \
2015 .get = snd_hdspm_get_system_sample_rate \
2009} 2016}
2010 2017
2011static int snd_hdspm_info_system_sample_rate(struct snd_kcontrol *kcontrol, 2018static int snd_hdspm_info_system_sample_rate(struct snd_kcontrol *kcontrol,
@@ -2030,6 +2037,16 @@ static int snd_hdspm_get_system_sample_rate(struct snd_kcontrol *kcontrol,
2030 return 0; 2037 return 0;
2031} 2038}
2032 2039
2040static int snd_hdspm_put_system_sample_rate(struct snd_kcontrol *kcontrol,
2041 struct snd_ctl_elem_value *
2042 ucontrol)
2043{
2044 struct hdspm *hdspm = snd_kcontrol_chip(kcontrol);
2045
2046 hdspm_set_dds_value(hdspm, ucontrol->value.enumerated.item[0]);
2047 return 0;
2048}
2049
2033 2050
2034/** 2051/**
2035 * Returns the WordClock sample rate class for the given card. 2052 * Returns the WordClock sample rate class for the given card.
@@ -2163,6 +2180,7 @@ static int snd_hdspm_get_autosync_sample_rate(struct snd_kcontrol *kcontrol,
2163 hdspm_get_s1_sample_rate(hdspm, 2180 hdspm_get_s1_sample_rate(hdspm,
2164 kcontrol->private_value-1); 2181 kcontrol->private_value-1);
2165 } 2182 }
2183 break;
2166 2184
2167 case AIO: 2185 case AIO:
2168 switch (kcontrol->private_value) { 2186 switch (kcontrol->private_value) {
@@ -2183,6 +2201,7 @@ static int snd_hdspm_get_autosync_sample_rate(struct snd_kcontrol *kcontrol,
2183 hdspm_get_s1_sample_rate(hdspm, 2201 hdspm_get_s1_sample_rate(hdspm,
2184 ucontrol->id.index-1); 2202 ucontrol->id.index-1);
2185 } 2203 }
2204 break;
2186 2205
2187 case AES32: 2206 case AES32:
2188 2207
@@ -2204,8 +2223,23 @@ static int snd_hdspm_get_autosync_sample_rate(struct snd_kcontrol *kcontrol,
2204 hdspm_get_s1_sample_rate(hdspm, 2223 hdspm_get_s1_sample_rate(hdspm,
2205 kcontrol->private_value-1); 2224 kcontrol->private_value-1);
2206 break; 2225 break;
2226 }
2227 break;
2207 2228
2229 case MADI:
2230 case MADIface:
2231 {
2232 int rate = hdspm_external_sample_rate(hdspm);
2233 int i, selected_rate = 0;
2234 for (i = 1; i < 10; i++)
2235 if (HDSPM_bit2freq(i) == rate) {
2236 selected_rate = i;
2237 break;
2238 }
2239 ucontrol->value.enumerated.item[0] = selected_rate;
2208 } 2240 }
2241 break;
2242
2209 default: 2243 default:
2210 break; 2244 break;
2211 } 2245 }
@@ -2430,7 +2464,7 @@ static int snd_hdspm_put_clock_source(struct snd_kcontrol *kcontrol,
2430 2464
2431 2465
2432#define HDSPM_PREF_SYNC_REF(xname, xindex) \ 2466#define HDSPM_PREF_SYNC_REF(xname, xindex) \
2433{.iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 2467{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2434 .name = xname, \ 2468 .name = xname, \
2435 .index = xindex, \ 2469 .index = xindex, \
2436 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE |\ 2470 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE |\
@@ -2766,12 +2800,12 @@ static int snd_hdspm_put_pref_sync_ref(struct snd_kcontrol *kcontrol,
2766 2800
2767 2801
2768#define HDSPM_AUTOSYNC_REF(xname, xindex) \ 2802#define HDSPM_AUTOSYNC_REF(xname, xindex) \
2769{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 2803{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2770 .name = xname, \ 2804 .name = xname, \
2771 .index = xindex, \ 2805 .index = xindex, \
2772 .access = SNDRV_CTL_ELEM_ACCESS_READ, \ 2806 .access = SNDRV_CTL_ELEM_ACCESS_READ, \
2773 .info = snd_hdspm_info_autosync_ref, \ 2807 .info = snd_hdspm_info_autosync_ref, \
2774 .get = snd_hdspm_get_autosync_ref, \ 2808 .get = snd_hdspm_get_autosync_ref, \
2775} 2809}
2776 2810
2777static int hdspm_autosync_ref(struct hdspm *hdspm) 2811static int hdspm_autosync_ref(struct hdspm *hdspm)
@@ -2855,12 +2889,12 @@ static int snd_hdspm_get_autosync_ref(struct snd_kcontrol *kcontrol,
2855 2889
2856 2890
2857#define HDSPM_LINE_OUT(xname, xindex) \ 2891#define HDSPM_LINE_OUT(xname, xindex) \
2858{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 2892{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2859 .name = xname, \ 2893 .name = xname, \
2860 .index = xindex, \ 2894 .index = xindex, \
2861 .info = snd_hdspm_info_line_out, \ 2895 .info = snd_hdspm_info_line_out, \
2862 .get = snd_hdspm_get_line_out, \ 2896 .get = snd_hdspm_get_line_out, \
2863 .put = snd_hdspm_put_line_out \ 2897 .put = snd_hdspm_put_line_out \
2864} 2898}
2865 2899
2866static int hdspm_line_out(struct hdspm * hdspm) 2900static int hdspm_line_out(struct hdspm * hdspm)
@@ -2912,12 +2946,12 @@ static int snd_hdspm_put_line_out(struct snd_kcontrol *kcontrol,
2912 2946
2913 2947
2914#define HDSPM_TX_64(xname, xindex) \ 2948#define HDSPM_TX_64(xname, xindex) \
2915{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 2949{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2916 .name = xname, \ 2950 .name = xname, \
2917 .index = xindex, \ 2951 .index = xindex, \
2918 .info = snd_hdspm_info_tx_64, \ 2952 .info = snd_hdspm_info_tx_64, \
2919 .get = snd_hdspm_get_tx_64, \ 2953 .get = snd_hdspm_get_tx_64, \
2920 .put = snd_hdspm_put_tx_64 \ 2954 .put = snd_hdspm_put_tx_64 \
2921} 2955}
2922 2956
2923static int hdspm_tx_64(struct hdspm * hdspm) 2957static int hdspm_tx_64(struct hdspm * hdspm)
@@ -2968,12 +3002,12 @@ static int snd_hdspm_put_tx_64(struct snd_kcontrol *kcontrol,
2968 3002
2969 3003
2970#define HDSPM_C_TMS(xname, xindex) \ 3004#define HDSPM_C_TMS(xname, xindex) \
2971{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 3005{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
2972 .name = xname, \ 3006 .name = xname, \
2973 .index = xindex, \ 3007 .index = xindex, \
2974 .info = snd_hdspm_info_c_tms, \ 3008 .info = snd_hdspm_info_c_tms, \
2975 .get = snd_hdspm_get_c_tms, \ 3009 .get = snd_hdspm_get_c_tms, \
2976 .put = snd_hdspm_put_c_tms \ 3010 .put = snd_hdspm_put_c_tms \
2977} 3011}
2978 3012
2979static int hdspm_c_tms(struct hdspm * hdspm) 3013static int hdspm_c_tms(struct hdspm * hdspm)
@@ -3024,12 +3058,12 @@ static int snd_hdspm_put_c_tms(struct snd_kcontrol *kcontrol,
3024 3058
3025 3059
3026#define HDSPM_SAFE_MODE(xname, xindex) \ 3060#define HDSPM_SAFE_MODE(xname, xindex) \
3027{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 3061{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3028 .name = xname, \ 3062 .name = xname, \
3029 .index = xindex, \ 3063 .index = xindex, \
3030 .info = snd_hdspm_info_safe_mode, \ 3064 .info = snd_hdspm_info_safe_mode, \
3031 .get = snd_hdspm_get_safe_mode, \ 3065 .get = snd_hdspm_get_safe_mode, \
3032 .put = snd_hdspm_put_safe_mode \ 3066 .put = snd_hdspm_put_safe_mode \
3033} 3067}
3034 3068
3035static int hdspm_safe_mode(struct hdspm * hdspm) 3069static int hdspm_safe_mode(struct hdspm * hdspm)
@@ -3080,12 +3114,12 @@ static int snd_hdspm_put_safe_mode(struct snd_kcontrol *kcontrol,
3080 3114
3081 3115
3082#define HDSPM_EMPHASIS(xname, xindex) \ 3116#define HDSPM_EMPHASIS(xname, xindex) \
3083{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 3117{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3084 .name = xname, \ 3118 .name = xname, \
3085 .index = xindex, \ 3119 .index = xindex, \
3086 .info = snd_hdspm_info_emphasis, \ 3120 .info = snd_hdspm_info_emphasis, \
3087 .get = snd_hdspm_get_emphasis, \ 3121 .get = snd_hdspm_get_emphasis, \
3088 .put = snd_hdspm_put_emphasis \ 3122 .put = snd_hdspm_put_emphasis \
3089} 3123}
3090 3124
3091static int hdspm_emphasis(struct hdspm * hdspm) 3125static int hdspm_emphasis(struct hdspm * hdspm)
@@ -3136,12 +3170,12 @@ static int snd_hdspm_put_emphasis(struct snd_kcontrol *kcontrol,
3136 3170
3137 3171
3138#define HDSPM_DOLBY(xname, xindex) \ 3172#define HDSPM_DOLBY(xname, xindex) \
3139{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 3173{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3140 .name = xname, \ 3174 .name = xname, \
3141 .index = xindex, \ 3175 .index = xindex, \
3142 .info = snd_hdspm_info_dolby, \ 3176 .info = snd_hdspm_info_dolby, \
3143 .get = snd_hdspm_get_dolby, \ 3177 .get = snd_hdspm_get_dolby, \
3144 .put = snd_hdspm_put_dolby \ 3178 .put = snd_hdspm_put_dolby \
3145} 3179}
3146 3180
3147static int hdspm_dolby(struct hdspm * hdspm) 3181static int hdspm_dolby(struct hdspm * hdspm)
@@ -3192,12 +3226,12 @@ static int snd_hdspm_put_dolby(struct snd_kcontrol *kcontrol,
3192 3226
3193 3227
3194#define HDSPM_PROFESSIONAL(xname, xindex) \ 3228#define HDSPM_PROFESSIONAL(xname, xindex) \
3195{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 3229{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3196 .name = xname, \ 3230 .name = xname, \
3197 .index = xindex, \ 3231 .index = xindex, \
3198 .info = snd_hdspm_info_professional, \ 3232 .info = snd_hdspm_info_professional, \
3199 .get = snd_hdspm_get_professional, \ 3233 .get = snd_hdspm_get_professional, \
3200 .put = snd_hdspm_put_professional \ 3234 .put = snd_hdspm_put_professional \
3201} 3235}
3202 3236
3203static int hdspm_professional(struct hdspm * hdspm) 3237static int hdspm_professional(struct hdspm * hdspm)
@@ -3247,12 +3281,12 @@ static int snd_hdspm_put_professional(struct snd_kcontrol *kcontrol,
3247} 3281}
3248 3282
3249#define HDSPM_INPUT_SELECT(xname, xindex) \ 3283#define HDSPM_INPUT_SELECT(xname, xindex) \
3250{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 3284{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3251 .name = xname, \ 3285 .name = xname, \
3252 .index = xindex, \ 3286 .index = xindex, \
3253 .info = snd_hdspm_info_input_select, \ 3287 .info = snd_hdspm_info_input_select, \
3254 .get = snd_hdspm_get_input_select, \ 3288 .get = snd_hdspm_get_input_select, \
3255 .put = snd_hdspm_put_input_select \ 3289 .put = snd_hdspm_put_input_select \
3256} 3290}
3257 3291
3258static int hdspm_input_select(struct hdspm * hdspm) 3292static int hdspm_input_select(struct hdspm * hdspm)
@@ -3319,12 +3353,12 @@ static int snd_hdspm_put_input_select(struct snd_kcontrol *kcontrol,
3319 3353
3320 3354
3321#define HDSPM_DS_WIRE(xname, xindex) \ 3355#define HDSPM_DS_WIRE(xname, xindex) \
3322{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 3356{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3323 .name = xname, \ 3357 .name = xname, \
3324 .index = xindex, \ 3358 .index = xindex, \
3325 .info = snd_hdspm_info_ds_wire, \ 3359 .info = snd_hdspm_info_ds_wire, \
3326 .get = snd_hdspm_get_ds_wire, \ 3360 .get = snd_hdspm_get_ds_wire, \
3327 .put = snd_hdspm_put_ds_wire \ 3361 .put = snd_hdspm_put_ds_wire \
3328} 3362}
3329 3363
3330static int hdspm_ds_wire(struct hdspm * hdspm) 3364static int hdspm_ds_wire(struct hdspm * hdspm)
@@ -3391,12 +3425,12 @@ static int snd_hdspm_put_ds_wire(struct snd_kcontrol *kcontrol,
3391 3425
3392 3426
3393#define HDSPM_QS_WIRE(xname, xindex) \ 3427#define HDSPM_QS_WIRE(xname, xindex) \
3394{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 3428{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3395 .name = xname, \ 3429 .name = xname, \
3396 .index = xindex, \ 3430 .index = xindex, \
3397 .info = snd_hdspm_info_qs_wire, \ 3431 .info = snd_hdspm_info_qs_wire, \
3398 .get = snd_hdspm_get_qs_wire, \ 3432 .get = snd_hdspm_get_qs_wire, \
3399 .put = snd_hdspm_put_qs_wire \ 3433 .put = snd_hdspm_put_qs_wire \
3400} 3434}
3401 3435
3402static int hdspm_qs_wire(struct hdspm * hdspm) 3436static int hdspm_qs_wire(struct hdspm * hdspm)
@@ -3563,15 +3597,15 @@ static int snd_hdspm_put_madi_speedmode(struct snd_kcontrol *kcontrol,
3563} 3597}
3564 3598
3565#define HDSPM_MIXER(xname, xindex) \ 3599#define HDSPM_MIXER(xname, xindex) \
3566{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \ 3600{ .iface = SNDRV_CTL_ELEM_IFACE_HWDEP, \
3567 .name = xname, \ 3601 .name = xname, \
3568 .index = xindex, \ 3602 .index = xindex, \
3569 .device = 0, \ 3603 .device = 0, \
3570 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \ 3604 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | \
3571 SNDRV_CTL_ELEM_ACCESS_VOLATILE, \ 3605 SNDRV_CTL_ELEM_ACCESS_VOLATILE, \
3572 .info = snd_hdspm_info_mixer, \ 3606 .info = snd_hdspm_info_mixer, \
3573 .get = snd_hdspm_get_mixer, \ 3607 .get = snd_hdspm_get_mixer, \
3574 .put = snd_hdspm_put_mixer \ 3608 .put = snd_hdspm_put_mixer \
3575} 3609}
3576 3610
3577static int snd_hdspm_info_mixer(struct snd_kcontrol *kcontrol, 3611static int snd_hdspm_info_mixer(struct snd_kcontrol *kcontrol,
@@ -3670,12 +3704,12 @@ static int snd_hdspm_put_mixer(struct snd_kcontrol *kcontrol,
3670*/ 3704*/
3671 3705
3672#define HDSPM_PLAYBACK_MIXER \ 3706#define HDSPM_PLAYBACK_MIXER \
3673{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 3707{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
3674 .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_WRITE | \ 3708 .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_WRITE | \
3675 SNDRV_CTL_ELEM_ACCESS_VOLATILE, \ 3709 SNDRV_CTL_ELEM_ACCESS_VOLATILE, \
3676 .info = snd_hdspm_info_playback_mixer, \ 3710 .info = snd_hdspm_info_playback_mixer, \
3677 .get = snd_hdspm_get_playback_mixer, \ 3711 .get = snd_hdspm_get_playback_mixer, \
3678 .put = snd_hdspm_put_playback_mixer \ 3712 .put = snd_hdspm_put_playback_mixer \
3679} 3713}
3680 3714
3681static int snd_hdspm_info_playback_mixer(struct snd_kcontrol *kcontrol, 3715static int snd_hdspm_info_playback_mixer(struct snd_kcontrol *kcontrol,
@@ -3851,12 +3885,17 @@ static int hdspm_sync_in_sync_check(struct hdspm *hdspm)
3851 break; 3885 break;
3852 3886
3853 case MADI: 3887 case MADI:
3854 case AES32: 3888 status = hdspm_read(hdspm, HDSPM_statusRegister);
3855 status = hdspm_read(hdspm, HDSPM_statusRegister2);
3856 lock = (status & HDSPM_syncInLock) ? 1 : 0; 3889 lock = (status & HDSPM_syncInLock) ? 1 : 0;
3857 sync = (status & HDSPM_syncInSync) ? 1 : 0; 3890 sync = (status & HDSPM_syncInSync) ? 1 : 0;
3858 break; 3891 break;
3859 3892
3893 case AES32:
3894 status = hdspm_read(hdspm, HDSPM_statusRegister2);
3895 lock = (status & 0x100000) ? 1 : 0;
3896 sync = (status & 0x200000) ? 1 : 0;
3897 break;
3898
3860 case MADIface: 3899 case MADIface:
3861 break; 3900 break;
3862 } 3901 }
@@ -3940,8 +3979,10 @@ static int snd_hdspm_get_sync_check(struct snd_kcontrol *kcontrol,
3940 case 8: /* SYNC IN */ 3979 case 8: /* SYNC IN */
3941 val = hdspm_sync_in_sync_check(hdspm); break; 3980 val = hdspm_sync_in_sync_check(hdspm); break;
3942 default: 3981 default:
3943 val = hdspm_s1_sync_check(hdspm, ucontrol->id.index-1); 3982 val = hdspm_s1_sync_check(hdspm,
3983 kcontrol->private_value-1);
3944 } 3984 }
3985 break;
3945 3986
3946 case AIO: 3987 case AIO:
3947 switch (kcontrol->private_value) { 3988 switch (kcontrol->private_value) {
@@ -3954,6 +3995,7 @@ static int snd_hdspm_get_sync_check(struct snd_kcontrol *kcontrol,
3954 default: 3995 default:
3955 val = hdspm_s1_sync_check(hdspm, ucontrol->id.index-1); 3996 val = hdspm_s1_sync_check(hdspm, ucontrol->id.index-1);
3956 } 3997 }
3998 break;
3957 3999
3958 case MADI: 4000 case MADI:
3959 switch (kcontrol->private_value) { 4001 switch (kcontrol->private_value) {
@@ -3966,6 +4008,7 @@ static int snd_hdspm_get_sync_check(struct snd_kcontrol *kcontrol,
3966 case 3: /* SYNC_IN */ 4008 case 3: /* SYNC_IN */
3967 val = hdspm_sync_in_sync_check(hdspm); break; 4009 val = hdspm_sync_in_sync_check(hdspm); break;
3968 } 4010 }
4011 break;
3969 4012
3970 case MADIface: 4013 case MADIface:
3971 val = hdspm_madi_sync_check(hdspm); /* MADI */ 4014 val = hdspm_madi_sync_check(hdspm); /* MADI */
@@ -3983,6 +4026,7 @@ static int snd_hdspm_get_sync_check(struct snd_kcontrol *kcontrol,
3983 val = hdspm_aes_sync_check(hdspm, 4026 val = hdspm_aes_sync_check(hdspm,
3984 kcontrol->private_value-1); 4027 kcontrol->private_value-1);
3985 } 4028 }
4029 break;
3986 4030
3987 } 4031 }
3988 4032
@@ -4427,9 +4471,10 @@ static struct snd_kcontrol_new snd_hdspm_controls_madi[] = {
4427 HDSPM_PREF_SYNC_REF("Preferred Sync Reference", 0), 4471 HDSPM_PREF_SYNC_REF("Preferred Sync Reference", 0),
4428 HDSPM_AUTOSYNC_REF("AutoSync Reference", 0), 4472 HDSPM_AUTOSYNC_REF("AutoSync Reference", 0),
4429 HDSPM_SYSTEM_SAMPLE_RATE("System Sample Rate", 0), 4473 HDSPM_SYSTEM_SAMPLE_RATE("System Sample Rate", 0),
4474 HDSPM_AUTOSYNC_SAMPLE_RATE("External Rate", 0),
4430 HDSPM_SYNC_CHECK("WC SyncCheck", 0), 4475 HDSPM_SYNC_CHECK("WC SyncCheck", 0),
4431 HDSPM_SYNC_CHECK("MADI SyncCheck", 1), 4476 HDSPM_SYNC_CHECK("MADI SyncCheck", 1),
4432 HDSPM_SYNC_CHECK("TCO SyncCHeck", 2), 4477 HDSPM_SYNC_CHECK("TCO SyncCheck", 2),
4433 HDSPM_SYNC_CHECK("SYNC IN SyncCheck", 3), 4478 HDSPM_SYNC_CHECK("SYNC IN SyncCheck", 3),
4434 HDSPM_LINE_OUT("Line Out", 0), 4479 HDSPM_LINE_OUT("Line Out", 0),
4435 HDSPM_TX_64("TX 64 channels mode", 0), 4480 HDSPM_TX_64("TX 64 channels mode", 0),
@@ -4855,7 +4900,7 @@ snd_hdspm_proc_read_madi(struct snd_info_entry * entry,
4855 insel = "Coaxial"; 4900 insel = "Coaxial";
4856 break; 4901 break;
4857 default: 4902 default:
4858 insel = "Unkown"; 4903 insel = "Unknown";
4859 } 4904 }
4860 4905
4861 snd_iprintf(buffer, 4906 snd_iprintf(buffer,
diff --git a/sound/soc/Makefile b/sound/soc/Makefile
index bcbf1d00aa8..99f32f7c069 100644
--- a/sound/soc/Makefile
+++ b/sound/soc/Makefile
@@ -1,8 +1,9 @@
1snd-soc-core-objs := soc-core.o soc-dapm.o soc-jack.o soc-cache.o soc-utils.o 1snd-soc-core-objs := soc-core.o soc-dapm.o soc-jack.o soc-cache.o soc-utils.o
2snd-soc-core-objs += soc-pcm.o soc-compress.o soc-io.o 2snd-soc-core-objs += soc-pcm.o soc-compress.o soc-io.o
3 3
4snd-soc-dmaengine-pcm-objs := soc-dmaengine-pcm.o 4ifneq ($(CONFIG_SND_SOC_DMAENGINE_PCM),)
5obj-$(CONFIG_SND_SOC_DMAENGINE_PCM) += snd-soc-dmaengine-pcm.o 5snd-soc-core-objs += soc-dmaengine-pcm.o
6endif
6 7
7obj-$(CONFIG_SND_SOC) += snd-soc-core.o 8obj-$(CONFIG_SND_SOC) += snd-soc-core.o
8obj-$(CONFIG_SND_SOC) += codecs/ 9obj-$(CONFIG_SND_SOC) += codecs/
diff --git a/sound/soc/codecs/arizona.c b/sound/soc/codecs/arizona.c
index c03b65af305..054967d8bac 100644
--- a/sound/soc/codecs/arizona.c
+++ b/sound/soc/codecs/arizona.c
@@ -268,7 +268,7 @@ EXPORT_SYMBOL_GPL(arizona_out_ev);
268static unsigned int arizona_sysclk_48k_rates[] = { 268static unsigned int arizona_sysclk_48k_rates[] = {
269 6144000, 269 6144000,
270 12288000, 270 12288000,
271 22579200, 271 24576000,
272 49152000, 272 49152000,
273 73728000, 273 73728000,
274 98304000, 274 98304000,
@@ -278,7 +278,7 @@ static unsigned int arizona_sysclk_48k_rates[] = {
278static unsigned int arizona_sysclk_44k1_rates[] = { 278static unsigned int arizona_sysclk_44k1_rates[] = {
279 5644800, 279 5644800,
280 11289600, 280 11289600,
281 24576000, 281 22579200,
282 45158400, 282 45158400,
283 67737600, 283 67737600,
284 90316800, 284 90316800,
diff --git a/sound/soc/codecs/cs4271.c b/sound/soc/codecs/cs4271.c
index f994af34f55..e3f0a7f3131 100644
--- a/sound/soc/codecs/cs4271.c
+++ b/sound/soc/codecs/cs4271.c
@@ -485,7 +485,7 @@ static int cs4271_probe(struct snd_soc_codec *codec)
485 gpio_nreset = cs4271plat->gpio_nreset; 485 gpio_nreset = cs4271plat->gpio_nreset;
486 486
487 if (gpio_nreset >= 0) 487 if (gpio_nreset >= 0)
488 if (gpio_request(gpio_nreset, "CS4271 Reset")) 488 if (devm_gpio_request(codec->dev, gpio_nreset, "CS4271 Reset"))
489 gpio_nreset = -EINVAL; 489 gpio_nreset = -EINVAL;
490 if (gpio_nreset >= 0) { 490 if (gpio_nreset >= 0) {
491 /* Reset codec */ 491 /* Reset codec */
@@ -535,15 +535,10 @@ static int cs4271_probe(struct snd_soc_codec *codec)
535static int cs4271_remove(struct snd_soc_codec *codec) 535static int cs4271_remove(struct snd_soc_codec *codec)
536{ 536{
537 struct cs4271_private *cs4271 = snd_soc_codec_get_drvdata(codec); 537 struct cs4271_private *cs4271 = snd_soc_codec_get_drvdata(codec);
538 int gpio_nreset;
539 538
540 gpio_nreset = cs4271->gpio_nreset; 539 if (gpio_is_valid(cs4271->gpio_nreset))
541
542 if (gpio_is_valid(gpio_nreset)) {
543 /* Set codec to the reset state */ 540 /* Set codec to the reset state */
544 gpio_set_value(gpio_nreset, 0); 541 gpio_set_value(cs4271->gpio_nreset, 0);
545 gpio_free(gpio_nreset);
546 }
547 542
548 return 0; 543 return 0;
549}; 544};
diff --git a/sound/soc/codecs/cs42l52.c b/sound/soc/codecs/cs42l52.c
index 61599298fb2..97a81051e88 100644
--- a/sound/soc/codecs/cs42l52.c
+++ b/sound/soc/codecs/cs42l52.c
@@ -763,7 +763,7 @@ static int cs42l52_set_sysclk(struct snd_soc_dai *codec_dai,
763 if ((freq >= CS42L52_MIN_CLK) && (freq <= CS42L52_MAX_CLK)) { 763 if ((freq >= CS42L52_MIN_CLK) && (freq <= CS42L52_MAX_CLK)) {
764 cs42l52->sysclk = freq; 764 cs42l52->sysclk = freq;
765 } else { 765 } else {
766 dev_err(codec->dev, "Invalid freq paramter\n"); 766 dev_err(codec->dev, "Invalid freq parameter\n");
767 return -EINVAL; 767 return -EINVAL;
768 } 768 }
769 return 0; 769 return 0;
@@ -773,7 +773,6 @@ static int cs42l52_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
773{ 773{
774 struct snd_soc_codec *codec = codec_dai->codec; 774 struct snd_soc_codec *codec = codec_dai->codec;
775 struct cs42l52_private *cs42l52 = snd_soc_codec_get_drvdata(codec); 775 struct cs42l52_private *cs42l52 = snd_soc_codec_get_drvdata(codec);
776 int ret = 0;
777 u8 iface = 0; 776 u8 iface = 0;
778 777
779 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { 778 switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
@@ -822,7 +821,7 @@ static int cs42l52_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
822 case SND_SOC_DAIFMT_NB_IF: 821 case SND_SOC_DAIFMT_NB_IF:
823 break; 822 break;
824 default: 823 default:
825 ret = -EINVAL; 824 return -EINVAL;
826 } 825 }
827 cs42l52->config.format = iface; 826 cs42l52->config.format = iface;
828 snd_soc_write(codec, CS42L52_IFACE_CTL1, cs42l52->config.format); 827 snd_soc_write(codec, CS42L52_IFACE_CTL1, cs42l52->config.format);
diff --git a/sound/soc/codecs/da9055.c b/sound/soc/codecs/da9055.c
index 185d8dd3639..f379b085c39 100644
--- a/sound/soc/codecs/da9055.c
+++ b/sound/soc/codecs/da9055.c
@@ -178,6 +178,12 @@
178#define DA9055_AIF_WORD_S24_LE (2 << 2) 178#define DA9055_AIF_WORD_S24_LE (2 << 2)
179#define DA9055_AIF_WORD_S32_LE (3 << 2) 179#define DA9055_AIF_WORD_S32_LE (3 << 2)
180 180
181/* MIC_L_CTRL bit fields */
182#define DA9055_MIC_L_MUTE_EN (1 << 6)
183
184/* MIC_R_CTRL bit fields */
185#define DA9055_MIC_R_MUTE_EN (1 << 6)
186
181/* MIXIN_L_CTRL bit fields */ 187/* MIXIN_L_CTRL bit fields */
182#define DA9055_MIXIN_L_MIX_EN (1 << 3) 188#define DA9055_MIXIN_L_MIX_EN (1 << 3)
183 189
@@ -476,7 +482,7 @@ static int da9055_put_alc_sw(struct snd_kcontrol *kcontrol,
476 struct snd_ctl_elem_value *ucontrol) 482 struct snd_ctl_elem_value *ucontrol)
477{ 483{
478 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); 484 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
479 u8 reg_val, adc_left, adc_right; 485 u8 reg_val, adc_left, adc_right, mic_left, mic_right;
480 int avg_left_data, avg_right_data, offset_l, offset_r; 486 int avg_left_data, avg_right_data, offset_l, offset_r;
481 487
482 if (ucontrol->value.integer.value[0]) { 488 if (ucontrol->value.integer.value[0]) {
@@ -485,6 +491,16 @@ static int da9055_put_alc_sw(struct snd_kcontrol *kcontrol,
485 * offsets must be done first 491 * offsets must be done first
486 */ 492 */
487 493
494 /* Save current values from Mic control registers */
495 mic_left = snd_soc_read(codec, DA9055_MIC_L_CTRL);
496 mic_right = snd_soc_read(codec, DA9055_MIC_R_CTRL);
497
498 /* Mute Mic PGA Left and Right */
499 snd_soc_update_bits(codec, DA9055_MIC_L_CTRL,
500 DA9055_MIC_L_MUTE_EN, DA9055_MIC_L_MUTE_EN);
501 snd_soc_update_bits(codec, DA9055_MIC_R_CTRL,
502 DA9055_MIC_R_MUTE_EN, DA9055_MIC_R_MUTE_EN);
503
488 /* Save current values from ADC control registers */ 504 /* Save current values from ADC control registers */
489 adc_left = snd_soc_read(codec, DA9055_ADC_L_CTRL); 505 adc_left = snd_soc_read(codec, DA9055_ADC_L_CTRL);
490 adc_right = snd_soc_read(codec, DA9055_ADC_R_CTRL); 506 adc_right = snd_soc_read(codec, DA9055_ADC_R_CTRL);
@@ -520,6 +536,10 @@ static int da9055_put_alc_sw(struct snd_kcontrol *kcontrol,
520 /* Restore original values of ADC control registers */ 536 /* Restore original values of ADC control registers */
521 snd_soc_write(codec, DA9055_ADC_L_CTRL, adc_left); 537 snd_soc_write(codec, DA9055_ADC_L_CTRL, adc_left);
522 snd_soc_write(codec, DA9055_ADC_R_CTRL, adc_right); 538 snd_soc_write(codec, DA9055_ADC_R_CTRL, adc_right);
539
540 /* Restore original values of Mic control registers */
541 snd_soc_write(codec, DA9055_MIC_L_CTRL, mic_left);
542 snd_soc_write(codec, DA9055_MIC_R_CTRL, mic_right);
523 } 543 }
524 544
525 return snd_soc_put_volsw(kcontrol, ucontrol); 545 return snd_soc_put_volsw(kcontrol, ucontrol);
diff --git a/sound/soc/codecs/twl6040.c b/sound/soc/codecs/twl6040.c
index e8f97af7592..00b85cc1b9a 100644
--- a/sound/soc/codecs/twl6040.c
+++ b/sound/soc/codecs/twl6040.c
@@ -820,10 +820,10 @@ static const struct snd_soc_dapm_route intercon[] = {
820 {"VIBRA DAC", NULL, "Vibra Playback"}, 820 {"VIBRA DAC", NULL, "Vibra Playback"},
821 821
822 /* ADC -> Stream mapping */ 822 /* ADC -> Stream mapping */
823 {"ADC Left", NULL, "Legacy Capture"}, 823 {"Legacy Capture" , NULL, "ADC Left"},
824 {"ADC Left", NULL, "Capture"}, 824 {"Capture", NULL, "ADC Left"},
825 {"ADC Right", NULL, "Legacy Capture"}, 825 {"Legacy Capture", NULL, "ADC Right"},
826 {"ADC Right", NULL, "Capture"}, 826 {"Capture" , NULL, "ADC Right"},
827 827
828 /* Capture path */ 828 /* Capture path */
829 {"Analog Left Capture Route", "Headset Mic", "HSMIC"}, 829 {"Analog Left Capture Route", "Headset Mic", "HSMIC"},
diff --git a/sound/soc/codecs/wm2200.c b/sound/soc/codecs/wm2200.c
index efa93dbb019..eab64a19398 100644
--- a/sound/soc/codecs/wm2200.c
+++ b/sound/soc/codecs/wm2200.c
@@ -1028,7 +1028,7 @@ SOC_DOUBLE_R_TLV("OUT2 Digital Volume", WM2200_DAC_DIGITAL_VOLUME_2L,
1028 WM2200_DAC_DIGITAL_VOLUME_2R, WM2200_OUT2L_VOL_SHIFT, 0x9f, 0, 1028 WM2200_DAC_DIGITAL_VOLUME_2R, WM2200_OUT2L_VOL_SHIFT, 0x9f, 0,
1029 digital_tlv), 1029 digital_tlv),
1030SOC_DOUBLE("OUT2 Switch", WM2200_PDM_1, WM2200_SPK1L_MUTE_SHIFT, 1030SOC_DOUBLE("OUT2 Switch", WM2200_PDM_1, WM2200_SPK1L_MUTE_SHIFT,
1031 WM2200_SPK1R_MUTE_SHIFT, 1, 0), 1031 WM2200_SPK1R_MUTE_SHIFT, 1, 1),
1032}; 1032};
1033 1033
1034WM2200_MIXER_ENUMS(OUT1L, WM2200_OUT1LMIX_INPUT_1_SOURCE); 1034WM2200_MIXER_ENUMS(OUT1L, WM2200_OUT1LMIX_INPUT_1_SOURCE);
@@ -2091,6 +2091,7 @@ static __devinit int wm2200_i2c_probe(struct i2c_client *i2c,
2091 2091
2092 switch (wm2200->rev) { 2092 switch (wm2200->rev) {
2093 case 0: 2093 case 0:
2094 case 1:
2094 ret = regmap_register_patch(wm2200->regmap, wm2200_reva_patch, 2095 ret = regmap_register_patch(wm2200->regmap, wm2200_reva_patch,
2095 ARRAY_SIZE(wm2200_reva_patch)); 2096 ARRAY_SIZE(wm2200_reva_patch));
2096 if (ret != 0) { 2097 if (ret != 0) {
diff --git a/sound/soc/codecs/wm5102.c b/sound/soc/codecs/wm5102.c
index 1722b586bdb..7394e73fa43 100644
--- a/sound/soc/codecs/wm5102.c
+++ b/sound/soc/codecs/wm5102.c
@@ -42,6 +42,556 @@ static DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0);
42static DECLARE_TLV_DB_SCALE(digital_tlv, -6400, 50, 0); 42static DECLARE_TLV_DB_SCALE(digital_tlv, -6400, 50, 0);
43static DECLARE_TLV_DB_SCALE(noise_tlv, 0, 600, 0); 43static DECLARE_TLV_DB_SCALE(noise_tlv, 0, 600, 0);
44 44
45static const struct reg_default wm5102_sysclk_reva_patch[] = {
46 { 0x3000, 0x2225 },
47 { 0x3001, 0x3a03 },
48 { 0x3002, 0x0225 },
49 { 0x3003, 0x0801 },
50 { 0x3004, 0x6249 },
51 { 0x3005, 0x0c04 },
52 { 0x3006, 0x0225 },
53 { 0x3007, 0x5901 },
54 { 0x3008, 0xe249 },
55 { 0x3009, 0x030d },
56 { 0x300a, 0x0249 },
57 { 0x300b, 0x2c01 },
58 { 0x300c, 0xe249 },
59 { 0x300d, 0x4342 },
60 { 0x300e, 0xe249 },
61 { 0x300f, 0x73c0 },
62 { 0x3010, 0x4249 },
63 { 0x3011, 0x0c00 },
64 { 0x3012, 0x0225 },
65 { 0x3013, 0x1f01 },
66 { 0x3014, 0x0225 },
67 { 0x3015, 0x1e01 },
68 { 0x3016, 0x0225 },
69 { 0x3017, 0xfa00 },
70 { 0x3018, 0x0000 },
71 { 0x3019, 0xf000 },
72 { 0x301a, 0x0000 },
73 { 0x301b, 0xf000 },
74 { 0x301c, 0x0000 },
75 { 0x301d, 0xf000 },
76 { 0x301e, 0x0000 },
77 { 0x301f, 0xf000 },
78 { 0x3020, 0x0000 },
79 { 0x3021, 0xf000 },
80 { 0x3022, 0x0000 },
81 { 0x3023, 0xf000 },
82 { 0x3024, 0x0000 },
83 { 0x3025, 0xf000 },
84 { 0x3026, 0x0000 },
85 { 0x3027, 0xf000 },
86 { 0x3028, 0x0000 },
87 { 0x3029, 0xf000 },
88 { 0x302a, 0x0000 },
89 { 0x302b, 0xf000 },
90 { 0x302c, 0x0000 },
91 { 0x302d, 0xf000 },
92 { 0x302e, 0x0000 },
93 { 0x302f, 0xf000 },
94 { 0x3030, 0x0225 },
95 { 0x3031, 0x1a01 },
96 { 0x3032, 0x0225 },
97 { 0x3033, 0x1e00 },
98 { 0x3034, 0x0225 },
99 { 0x3035, 0x1f00 },
100 { 0x3036, 0x6225 },
101 { 0x3037, 0xf800 },
102 { 0x3038, 0x0000 },
103 { 0x3039, 0xf000 },
104 { 0x303a, 0x0000 },
105 { 0x303b, 0xf000 },
106 { 0x303c, 0x0000 },
107 { 0x303d, 0xf000 },
108 { 0x303e, 0x0000 },
109 { 0x303f, 0xf000 },
110 { 0x3040, 0x2226 },
111 { 0x3041, 0x3a03 },
112 { 0x3042, 0x0226 },
113 { 0x3043, 0x0801 },
114 { 0x3044, 0x6249 },
115 { 0x3045, 0x0c06 },
116 { 0x3046, 0x0226 },
117 { 0x3047, 0x5901 },
118 { 0x3048, 0xe249 },
119 { 0x3049, 0x030d },
120 { 0x304a, 0x0249 },
121 { 0x304b, 0x2c01 },
122 { 0x304c, 0xe249 },
123 { 0x304d, 0x4342 },
124 { 0x304e, 0xe249 },
125 { 0x304f, 0x73c0 },
126 { 0x3050, 0x4249 },
127 { 0x3051, 0x0c00 },
128 { 0x3052, 0x0226 },
129 { 0x3053, 0x1f01 },
130 { 0x3054, 0x0226 },
131 { 0x3055, 0x1e01 },
132 { 0x3056, 0x0226 },
133 { 0x3057, 0xfa00 },
134 { 0x3058, 0x0000 },
135 { 0x3059, 0xf000 },
136 { 0x305a, 0x0000 },
137 { 0x305b, 0xf000 },
138 { 0x305c, 0x0000 },
139 { 0x305d, 0xf000 },
140 { 0x305e, 0x0000 },
141 { 0x305f, 0xf000 },
142 { 0x3060, 0x0000 },
143 { 0x3061, 0xf000 },
144 { 0x3062, 0x0000 },
145 { 0x3063, 0xf000 },
146 { 0x3064, 0x0000 },
147 { 0x3065, 0xf000 },
148 { 0x3066, 0x0000 },
149 { 0x3067, 0xf000 },
150 { 0x3068, 0x0000 },
151 { 0x3069, 0xf000 },
152 { 0x306a, 0x0000 },
153 { 0x306b, 0xf000 },
154 { 0x306c, 0x0000 },
155 { 0x306d, 0xf000 },
156 { 0x306e, 0x0000 },
157 { 0x306f, 0xf000 },
158 { 0x3070, 0x0226 },
159 { 0x3071, 0x1a01 },
160 { 0x3072, 0x0226 },
161 { 0x3073, 0x1e00 },
162 { 0x3074, 0x0226 },
163 { 0x3075, 0x1f00 },
164 { 0x3076, 0x6226 },
165 { 0x3077, 0xf800 },
166 { 0x3078, 0x0000 },
167 { 0x3079, 0xf000 },
168 { 0x307a, 0x0000 },
169 { 0x307b, 0xf000 },
170 { 0x307c, 0x0000 },
171 { 0x307d, 0xf000 },
172 { 0x307e, 0x0000 },
173 { 0x307f, 0xf000 },
174 { 0x3080, 0x2227 },
175 { 0x3081, 0x3a03 },
176 { 0x3082, 0x0227 },
177 { 0x3083, 0x0801 },
178 { 0x3084, 0x6255 },
179 { 0x3085, 0x0c04 },
180 { 0x3086, 0x0227 },
181 { 0x3087, 0x5901 },
182 { 0x3088, 0xe255 },
183 { 0x3089, 0x030d },
184 { 0x308a, 0x0255 },
185 { 0x308b, 0x2c01 },
186 { 0x308c, 0xe255 },
187 { 0x308d, 0x4342 },
188 { 0x308e, 0xe255 },
189 { 0x308f, 0x73c0 },
190 { 0x3090, 0x4255 },
191 { 0x3091, 0x0c00 },
192 { 0x3092, 0x0227 },
193 { 0x3093, 0x1f01 },
194 { 0x3094, 0x0227 },
195 { 0x3095, 0x1e01 },
196 { 0x3096, 0x0227 },
197 { 0x3097, 0xfa00 },
198 { 0x3098, 0x0000 },
199 { 0x3099, 0xf000 },
200 { 0x309a, 0x0000 },
201 { 0x309b, 0xf000 },
202 { 0x309c, 0x0000 },
203 { 0x309d, 0xf000 },
204 { 0x309e, 0x0000 },
205 { 0x309f, 0xf000 },
206 { 0x30a0, 0x0000 },
207 { 0x30a1, 0xf000 },
208 { 0x30a2, 0x0000 },
209 { 0x30a3, 0xf000 },
210 { 0x30a4, 0x0000 },
211 { 0x30a5, 0xf000 },
212 { 0x30a6, 0x0000 },
213 { 0x30a7, 0xf000 },
214 { 0x30a8, 0x0000 },
215 { 0x30a9, 0xf000 },
216 { 0x30aa, 0x0000 },
217 { 0x30ab, 0xf000 },
218 { 0x30ac, 0x0000 },
219 { 0x30ad, 0xf000 },
220 { 0x30ae, 0x0000 },
221 { 0x30af, 0xf000 },
222 { 0x30b0, 0x0227 },
223 { 0x30b1, 0x1a01 },
224 { 0x30b2, 0x0227 },
225 { 0x30b3, 0x1e00 },
226 { 0x30b4, 0x0227 },
227 { 0x30b5, 0x1f00 },
228 { 0x30b6, 0x6227 },
229 { 0x30b7, 0xf800 },
230 { 0x30b8, 0x0000 },
231 { 0x30b9, 0xf000 },
232 { 0x30ba, 0x0000 },
233 { 0x30bb, 0xf000 },
234 { 0x30bc, 0x0000 },
235 { 0x30bd, 0xf000 },
236 { 0x30be, 0x0000 },
237 { 0x30bf, 0xf000 },
238 { 0x30c0, 0x2228 },
239 { 0x30c1, 0x3a03 },
240 { 0x30c2, 0x0228 },
241 { 0x30c3, 0x0801 },
242 { 0x30c4, 0x6255 },
243 { 0x30c5, 0x0c06 },
244 { 0x30c6, 0x0228 },
245 { 0x30c7, 0x5901 },
246 { 0x30c8, 0xe255 },
247 { 0x30c9, 0x030d },
248 { 0x30ca, 0x0255 },
249 { 0x30cb, 0x2c01 },
250 { 0x30cc, 0xe255 },
251 { 0x30cd, 0x4342 },
252 { 0x30ce, 0xe255 },
253 { 0x30cf, 0x73c0 },
254 { 0x30d0, 0x4255 },
255 { 0x30d1, 0x0c00 },
256 { 0x30d2, 0x0228 },
257 { 0x30d3, 0x1f01 },
258 { 0x30d4, 0x0228 },
259 { 0x30d5, 0x1e01 },
260 { 0x30d6, 0x0228 },
261 { 0x30d7, 0xfa00 },
262 { 0x30d8, 0x0000 },
263 { 0x30d9, 0xf000 },
264 { 0x30da, 0x0000 },
265 { 0x30db, 0xf000 },
266 { 0x30dc, 0x0000 },
267 { 0x30dd, 0xf000 },
268 { 0x30de, 0x0000 },
269 { 0x30df, 0xf000 },
270 { 0x30e0, 0x0000 },
271 { 0x30e1, 0xf000 },
272 { 0x30e2, 0x0000 },
273 { 0x30e3, 0xf000 },
274 { 0x30e4, 0x0000 },
275 { 0x30e5, 0xf000 },
276 { 0x30e6, 0x0000 },
277 { 0x30e7, 0xf000 },
278 { 0x30e8, 0x0000 },
279 { 0x30e9, 0xf000 },
280 { 0x30ea, 0x0000 },
281 { 0x30eb, 0xf000 },
282 { 0x30ec, 0x0000 },
283 { 0x30ed, 0xf000 },
284 { 0x30ee, 0x0000 },
285 { 0x30ef, 0xf000 },
286 { 0x30f0, 0x0228 },
287 { 0x30f1, 0x1a01 },
288 { 0x30f2, 0x0228 },
289 { 0x30f3, 0x1e00 },
290 { 0x30f4, 0x0228 },
291 { 0x30f5, 0x1f00 },
292 { 0x30f6, 0x6228 },
293 { 0x30f7, 0xf800 },
294 { 0x30f8, 0x0000 },
295 { 0x30f9, 0xf000 },
296 { 0x30fa, 0x0000 },
297 { 0x30fb, 0xf000 },
298 { 0x30fc, 0x0000 },
299 { 0x30fd, 0xf000 },
300 { 0x30fe, 0x0000 },
301 { 0x30ff, 0xf000 },
302 { 0x3100, 0x222b },
303 { 0x3101, 0x3a03 },
304 { 0x3102, 0x222b },
305 { 0x3103, 0x5803 },
306 { 0x3104, 0xe26f },
307 { 0x3105, 0x030d },
308 { 0x3106, 0x626f },
309 { 0x3107, 0x2c01 },
310 { 0x3108, 0xe26f },
311 { 0x3109, 0x4342 },
312 { 0x310a, 0xe26f },
313 { 0x310b, 0x73c0 },
314 { 0x310c, 0x026f },
315 { 0x310d, 0x0c00 },
316 { 0x310e, 0x022b },
317 { 0x310f, 0x1f01 },
318 { 0x3110, 0x022b },
319 { 0x3111, 0x1e01 },
320 { 0x3112, 0x022b },
321 { 0x3113, 0xfa00 },
322 { 0x3114, 0x0000 },
323 { 0x3115, 0xf000 },
324 { 0x3116, 0x0000 },
325 { 0x3117, 0xf000 },
326 { 0x3118, 0x0000 },
327 { 0x3119, 0xf000 },
328 { 0x311a, 0x0000 },
329 { 0x311b, 0xf000 },
330 { 0x311c, 0x0000 },
331 { 0x311d, 0xf000 },
332 { 0x311e, 0x0000 },
333 { 0x311f, 0xf000 },
334 { 0x3120, 0x022b },
335 { 0x3121, 0x0a01 },
336 { 0x3122, 0x022b },
337 { 0x3123, 0x1e00 },
338 { 0x3124, 0x022b },
339 { 0x3125, 0x1f00 },
340 { 0x3126, 0x622b },
341 { 0x3127, 0xf800 },
342 { 0x3128, 0x0000 },
343 { 0x3129, 0xf000 },
344 { 0x312a, 0x0000 },
345 { 0x312b, 0xf000 },
346 { 0x312c, 0x0000 },
347 { 0x312d, 0xf000 },
348 { 0x312e, 0x0000 },
349 { 0x312f, 0xf000 },
350 { 0x3130, 0x0000 },
351 { 0x3131, 0xf000 },
352 { 0x3132, 0x0000 },
353 { 0x3133, 0xf000 },
354 { 0x3134, 0x0000 },
355 { 0x3135, 0xf000 },
356 { 0x3136, 0x0000 },
357 { 0x3137, 0xf000 },
358 { 0x3138, 0x0000 },
359 { 0x3139, 0xf000 },
360 { 0x313a, 0x0000 },
361 { 0x313b, 0xf000 },
362 { 0x313c, 0x0000 },
363 { 0x313d, 0xf000 },
364 { 0x313e, 0x0000 },
365 { 0x313f, 0xf000 },
366 { 0x3140, 0x0000 },
367 { 0x3141, 0xf000 },
368 { 0x3142, 0x0000 },
369 { 0x3143, 0xf000 },
370 { 0x3144, 0x0000 },
371 { 0x3145, 0xf000 },
372 { 0x3146, 0x0000 },
373 { 0x3147, 0xf000 },
374 { 0x3148, 0x0000 },
375 { 0x3149, 0xf000 },
376 { 0x314a, 0x0000 },
377 { 0x314b, 0xf000 },
378 { 0x314c, 0x0000 },
379 { 0x314d, 0xf000 },
380 { 0x314e, 0x0000 },
381 { 0x314f, 0xf000 },
382 { 0x3150, 0x0000 },
383 { 0x3151, 0xf000 },
384 { 0x3152, 0x0000 },
385 { 0x3153, 0xf000 },
386 { 0x3154, 0x0000 },
387 { 0x3155, 0xf000 },
388 { 0x3156, 0x0000 },
389 { 0x3157, 0xf000 },
390 { 0x3158, 0x0000 },
391 { 0x3159, 0xf000 },
392 { 0x315a, 0x0000 },
393 { 0x315b, 0xf000 },
394 { 0x315c, 0x0000 },
395 { 0x315d, 0xf000 },
396 { 0x315e, 0x0000 },
397 { 0x315f, 0xf000 },
398 { 0x3160, 0x0000 },
399 { 0x3161, 0xf000 },
400 { 0x3162, 0x0000 },
401 { 0x3163, 0xf000 },
402 { 0x3164, 0x0000 },
403 { 0x3165, 0xf000 },
404 { 0x3166, 0x0000 },
405 { 0x3167, 0xf000 },
406 { 0x3168, 0x0000 },
407 { 0x3169, 0xf000 },
408 { 0x316a, 0x0000 },
409 { 0x316b, 0xf000 },
410 { 0x316c, 0x0000 },
411 { 0x316d, 0xf000 },
412 { 0x316e, 0x0000 },
413 { 0x316f, 0xf000 },
414 { 0x3170, 0x0000 },
415 { 0x3171, 0xf000 },
416 { 0x3172, 0x0000 },
417 { 0x3173, 0xf000 },
418 { 0x3174, 0x0000 },
419 { 0x3175, 0xf000 },
420 { 0x3176, 0x0000 },
421 { 0x3177, 0xf000 },
422 { 0x3178, 0x0000 },
423 { 0x3179, 0xf000 },
424 { 0x317a, 0x0000 },
425 { 0x317b, 0xf000 },
426 { 0x317c, 0x0000 },
427 { 0x317d, 0xf000 },
428 { 0x317e, 0x0000 },
429 { 0x317f, 0xf000 },
430 { 0x3180, 0x2001 },
431 { 0x3181, 0xf101 },
432 { 0x3182, 0x0000 },
433 { 0x3183, 0xf000 },
434 { 0x3184, 0x0000 },
435 { 0x3185, 0xf000 },
436 { 0x3186, 0x0000 },
437 { 0x3187, 0xf000 },
438 { 0x3188, 0x0000 },
439 { 0x3189, 0xf000 },
440 { 0x318a, 0x0000 },
441 { 0x318b, 0xf000 },
442 { 0x318c, 0x0000 },
443 { 0x318d, 0xf000 },
444 { 0x318e, 0x0000 },
445 { 0x318f, 0xf000 },
446 { 0x3190, 0x0000 },
447 { 0x3191, 0xf000 },
448 { 0x3192, 0x0000 },
449 { 0x3193, 0xf000 },
450 { 0x3194, 0x0000 },
451 { 0x3195, 0xf000 },
452 { 0x3196, 0x0000 },
453 { 0x3197, 0xf000 },
454 { 0x3198, 0x0000 },
455 { 0x3199, 0xf000 },
456 { 0x319a, 0x0000 },
457 { 0x319b, 0xf000 },
458 { 0x319c, 0x0000 },
459 { 0x319d, 0xf000 },
460 { 0x319e, 0x0000 },
461 { 0x319f, 0xf000 },
462 { 0x31a0, 0x0000 },
463 { 0x31a1, 0xf000 },
464 { 0x31a2, 0x0000 },
465 { 0x31a3, 0xf000 },
466 { 0x31a4, 0x0000 },
467 { 0x31a5, 0xf000 },
468 { 0x31a6, 0x0000 },
469 { 0x31a7, 0xf000 },
470 { 0x31a8, 0x0000 },
471 { 0x31a9, 0xf000 },
472 { 0x31aa, 0x0000 },
473 { 0x31ab, 0xf000 },
474 { 0x31ac, 0x0000 },
475 { 0x31ad, 0xf000 },
476 { 0x31ae, 0x0000 },
477 { 0x31af, 0xf000 },
478 { 0x31b0, 0x0000 },
479 { 0x31b1, 0xf000 },
480 { 0x31b2, 0x0000 },
481 { 0x31b3, 0xf000 },
482 { 0x31b4, 0x0000 },
483 { 0x31b5, 0xf000 },
484 { 0x31b6, 0x0000 },
485 { 0x31b7, 0xf000 },
486 { 0x31b8, 0x0000 },
487 { 0x31b9, 0xf000 },
488 { 0x31ba, 0x0000 },
489 { 0x31bb, 0xf000 },
490 { 0x31bc, 0x0000 },
491 { 0x31bd, 0xf000 },
492 { 0x31be, 0x0000 },
493 { 0x31bf, 0xf000 },
494 { 0x31c0, 0x0000 },
495 { 0x31c1, 0xf000 },
496 { 0x31c2, 0x0000 },
497 { 0x31c3, 0xf000 },
498 { 0x31c4, 0x0000 },
499 { 0x31c5, 0xf000 },
500 { 0x31c6, 0x0000 },
501 { 0x31c7, 0xf000 },
502 { 0x31c8, 0x0000 },
503 { 0x31c9, 0xf000 },
504 { 0x31ca, 0x0000 },
505 { 0x31cb, 0xf000 },
506 { 0x31cc, 0x0000 },
507 { 0x31cd, 0xf000 },
508 { 0x31ce, 0x0000 },
509 { 0x31cf, 0xf000 },
510 { 0x31d0, 0x0000 },
511 { 0x31d1, 0xf000 },
512 { 0x31d2, 0x0000 },
513 { 0x31d3, 0xf000 },
514 { 0x31d4, 0x0000 },
515 { 0x31d5, 0xf000 },
516 { 0x31d6, 0x0000 },
517 { 0x31d7, 0xf000 },
518 { 0x31d8, 0x0000 },
519 { 0x31d9, 0xf000 },
520 { 0x31da, 0x0000 },
521 { 0x31db, 0xf000 },
522 { 0x31dc, 0x0000 },
523 { 0x31dd, 0xf000 },
524 { 0x31de, 0x0000 },
525 { 0x31df, 0xf000 },
526 { 0x31e0, 0x0000 },
527 { 0x31e1, 0xf000 },
528 { 0x31e2, 0x0000 },
529 { 0x31e3, 0xf000 },
530 { 0x31e4, 0x0000 },
531 { 0x31e5, 0xf000 },
532 { 0x31e6, 0x0000 },
533 { 0x31e7, 0xf000 },
534 { 0x31e8, 0x0000 },
535 { 0x31e9, 0xf000 },
536 { 0x31ea, 0x0000 },
537 { 0x31eb, 0xf000 },
538 { 0x31ec, 0x0000 },
539 { 0x31ed, 0xf000 },
540 { 0x31ee, 0x0000 },
541 { 0x31ef, 0xf000 },
542 { 0x31f0, 0x0000 },
543 { 0x31f1, 0xf000 },
544 { 0x31f2, 0x0000 },
545 { 0x31f3, 0xf000 },
546 { 0x31f4, 0x0000 },
547 { 0x31f5, 0xf000 },
548 { 0x31f6, 0x0000 },
549 { 0x31f7, 0xf000 },
550 { 0x31f8, 0x0000 },
551 { 0x31f9, 0xf000 },
552 { 0x31fa, 0x0000 },
553 { 0x31fb, 0xf000 },
554 { 0x31fc, 0x0000 },
555 { 0x31fd, 0xf000 },
556 { 0x31fe, 0x0000 },
557 { 0x31ff, 0xf000 },
558 { 0x024d, 0xff50 },
559 { 0x0252, 0xff50 },
560 { 0x0259, 0x0112 },
561 { 0x025e, 0x0112 },
562};
563
564static int wm5102_sysclk_ev(struct snd_soc_dapm_widget *w,
565 struct snd_kcontrol *kcontrol, int event)
566{
567 struct snd_soc_codec *codec = w->codec;
568 struct arizona *arizona = dev_get_drvdata(codec->dev);
569 struct regmap *regmap = codec->control_data;
570 const struct reg_default *patch = NULL;
571 int i, patch_size;
572
573 switch (arizona->rev) {
574 case 0:
575 patch = wm5102_sysclk_reva_patch;
576 patch_size = ARRAY_SIZE(wm5102_sysclk_reva_patch);
577 break;
578 }
579
580 switch (event) {
581 case SND_SOC_DAPM_POST_PMU:
582 if (patch)
583 for (i = 0; i < patch_size; i++)
584 regmap_write(regmap, patch[i].reg,
585 patch[i].def);
586 break;
587
588 default:
589 break;
590 }
591
592 return 0;
593}
594
45static const struct snd_kcontrol_new wm5102_snd_controls[] = { 595static const struct snd_kcontrol_new wm5102_snd_controls[] = {
46SOC_SINGLE("IN1 High Performance Switch", ARIZONA_IN1L_CONTROL, 596SOC_SINGLE("IN1 High Performance Switch", ARIZONA_IN1L_CONTROL,
47 ARIZONA_IN1_OSR_SHIFT, 1, 0), 597 ARIZONA_IN1_OSR_SHIFT, 1, 0),
@@ -297,7 +847,7 @@ static const struct snd_kcontrol_new wm5102_aec_loopback_mux =
297 847
298static const struct snd_soc_dapm_widget wm5102_dapm_widgets[] = { 848static const struct snd_soc_dapm_widget wm5102_dapm_widgets[] = {
299SND_SOC_DAPM_SUPPLY("SYSCLK", ARIZONA_SYSTEM_CLOCK_1, ARIZONA_SYSCLK_ENA_SHIFT, 849SND_SOC_DAPM_SUPPLY("SYSCLK", ARIZONA_SYSTEM_CLOCK_1, ARIZONA_SYSCLK_ENA_SHIFT,
300 0, NULL, 0), 850 0, wm5102_sysclk_ev, SND_SOC_DAPM_POST_PMU),
301SND_SOC_DAPM_SUPPLY("ASYNCCLK", ARIZONA_ASYNC_CLOCK_1, 851SND_SOC_DAPM_SUPPLY("ASYNCCLK", ARIZONA_ASYNC_CLOCK_1,
302 ARIZONA_ASYNC_CLK_ENA_SHIFT, 0, NULL, 0), 852 ARIZONA_ASYNC_CLK_ENA_SHIFT, 0, NULL, 0),
303SND_SOC_DAPM_SUPPLY("OPCLK", ARIZONA_OUTPUT_SYSTEM_CLOCK, 853SND_SOC_DAPM_SUPPLY("OPCLK", ARIZONA_OUTPUT_SYSTEM_CLOCK,
diff --git a/sound/soc/codecs/wm8978.c b/sound/soc/codecs/wm8978.c
index 5421fd9fbcb..4c0a8e49613 100644
--- a/sound/soc/codecs/wm8978.c
+++ b/sound/soc/codecs/wm8978.c
@@ -782,7 +782,7 @@ static int wm8978_hw_params(struct snd_pcm_substream *substream,
782 wm8978->mclk_idx = -1; 782 wm8978->mclk_idx = -1;
783 f_sel = wm8978->f_mclk; 783 f_sel = wm8978->f_mclk;
784 } else { 784 } else {
785 if (!wm8978->f_pllout) { 785 if (!wm8978->f_opclk) {
786 /* We only enter here, if OPCLK is not used */ 786 /* We only enter here, if OPCLK is not used */
787 int ret = wm8978_configure_pll(codec); 787 int ret = wm8978_configure_pll(codec);
788 if (ret < 0) 788 if (ret < 0)
diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c
index 2b2dadc54da..b2b2b37131b 100644
--- a/sound/soc/codecs/wm8994.c
+++ b/sound/soc/codecs/wm8994.c
@@ -1045,6 +1045,7 @@ static int aif1clk_ev(struct snd_soc_dapm_widget *w,
1045 struct snd_kcontrol *kcontrol, int event) 1045 struct snd_kcontrol *kcontrol, int event)
1046{ 1046{
1047 struct snd_soc_codec *codec = w->codec; 1047 struct snd_soc_codec *codec = w->codec;
1048 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
1048 struct wm8994 *control = codec->control_data; 1049 struct wm8994 *control = codec->control_data;
1049 int mask = WM8994_AIF1DAC1L_ENA | WM8994_AIF1DAC1R_ENA; 1050 int mask = WM8994_AIF1DAC1L_ENA | WM8994_AIF1DAC1R_ENA;
1050 int i; 1051 int i;
@@ -1063,6 +1064,10 @@ static int aif1clk_ev(struct snd_soc_dapm_widget *w,
1063 1064
1064 switch (event) { 1065 switch (event) {
1065 case SND_SOC_DAPM_PRE_PMU: 1066 case SND_SOC_DAPM_PRE_PMU:
1067 /* Don't enable timeslot 2 if not in use */
1068 if (wm8994->channels[0] <= 2)
1069 mask &= ~(WM8994_AIF1DAC2L_ENA | WM8994_AIF1DAC2R_ENA);
1070
1066 val = snd_soc_read(codec, WM8994_AIF1_CONTROL_1); 1071 val = snd_soc_read(codec, WM8994_AIF1_CONTROL_1);
1067 if ((val & WM8994_AIF1ADCL_SRC) && 1072 if ((val & WM8994_AIF1ADCL_SRC) &&
1068 (val & WM8994_AIF1ADCR_SRC)) 1073 (val & WM8994_AIF1ADCR_SRC))
@@ -2687,7 +2692,7 @@ static int wm8994_hw_params(struct snd_pcm_substream *substream,
2687 return -EINVAL; 2692 return -EINVAL;
2688 } 2693 }
2689 2694
2690 bclk_rate = params_rate(params) * 4; 2695 bclk_rate = params_rate(params);
2691 switch (params_format(params)) { 2696 switch (params_format(params)) {
2692 case SNDRV_PCM_FORMAT_S16_LE: 2697 case SNDRV_PCM_FORMAT_S16_LE:
2693 bclk_rate *= 16; 2698 bclk_rate *= 16;
@@ -2708,6 +2713,17 @@ static int wm8994_hw_params(struct snd_pcm_substream *substream,
2708 return -EINVAL; 2713 return -EINVAL;
2709 } 2714 }
2710 2715
2716 wm8994->channels[id] = params_channels(params);
2717 switch (params_channels(params)) {
2718 case 1:
2719 case 2:
2720 bclk_rate *= 2;
2721 break;
2722 default:
2723 bclk_rate *= 4;
2724 break;
2725 }
2726
2711 /* Try to find an appropriate sample rate; look for an exact match. */ 2727 /* Try to find an appropriate sample rate; look for an exact match. */
2712 for (i = 0; i < ARRAY_SIZE(srs); i++) 2728 for (i = 0; i < ARRAY_SIZE(srs); i++)
2713 if (srs[i].rate == params_rate(params)) 2729 if (srs[i].rate == params_rate(params))
@@ -3706,7 +3722,7 @@ static irqreturn_t wm8958_mic_irq(int irq, void *data)
3706 } while (count--); 3722 } while (count--);
3707 3723
3708 if (count == 0) 3724 if (count == 0)
3709 dev_warn(codec->dev, "No impedence range reported for jack\n"); 3725 dev_warn(codec->dev, "No impedance range reported for jack\n");
3710 3726
3711#ifndef CONFIG_SND_SOC_WM8994_MODULE 3727#ifndef CONFIG_SND_SOC_WM8994_MODULE
3712 trace_snd_soc_jack_irq(dev_name(codec->dev)); 3728 trace_snd_soc_jack_irq(dev_name(codec->dev));
diff --git a/sound/soc/codecs/wm8994.h b/sound/soc/codecs/wm8994.h
index f142ec198db..ccbce5791e9 100644
--- a/sound/soc/codecs/wm8994.h
+++ b/sound/soc/codecs/wm8994.h
@@ -77,6 +77,7 @@ struct wm8994_priv {
77 int sysclk_rate[2]; 77 int sysclk_rate[2];
78 int mclk[2]; 78 int mclk[2];
79 int aifclk[2]; 79 int aifclk[2];
80 int channels[2];
80 struct wm8994_fll_config fll[2], fll_suspend[2]; 81 struct wm8994_fll_config fll[2], fll_suspend[2];
81 struct completion fll_locked[2]; 82 struct completion fll_locked[2];
82 bool fll_locked_irq; 83 bool fll_locked_irq;
diff --git a/sound/soc/kirkwood/kirkwood-dma.c b/sound/soc/kirkwood/kirkwood-dma.c
index b9f16598324..2ba08148655 100644
--- a/sound/soc/kirkwood/kirkwood-dma.c
+++ b/sound/soc/kirkwood/kirkwood-dma.c
@@ -71,7 +71,6 @@ static irqreturn_t kirkwood_dma_irq(int irq, void *dev_id)
71 printk(KERN_WARNING "%s: got err interrupt 0x%lx\n", 71 printk(KERN_WARNING "%s: got err interrupt 0x%lx\n",
72 __func__, cause); 72 __func__, cause);
73 writel(cause, priv->io + KIRKWOOD_ERR_CAUSE); 73 writel(cause, priv->io + KIRKWOOD_ERR_CAUSE);
74 return IRQ_HANDLED;
75 } 74 }
76 75
77 /* we've enabled only bytes interrupts ... */ 76 /* we've enabled only bytes interrupts ... */
@@ -178,7 +177,7 @@ static int kirkwood_dma_open(struct snd_pcm_substream *substream)
178 } 177 }
179 178
180 dram = mv_mbus_dram_info(); 179 dram = mv_mbus_dram_info();
181 addr = virt_to_phys(substream->dma_buffer.area); 180 addr = substream->dma_buffer.addr;
182 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { 181 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
183 prdata->play_stream = substream; 182 prdata->play_stream = substream;
184 kirkwood_dma_conf_mbus_windows(priv->io, 183 kirkwood_dma_conf_mbus_windows(priv->io,
diff --git a/sound/soc/kirkwood/kirkwood-i2s.c b/sound/soc/kirkwood/kirkwood-i2s.c
index 542538d10ab..1d5db484d2d 100644
--- a/sound/soc/kirkwood/kirkwood-i2s.c
+++ b/sound/soc/kirkwood/kirkwood-i2s.c
@@ -95,7 +95,7 @@ static inline void kirkwood_set_dco(void __iomem *io, unsigned long rate)
95 do { 95 do {
96 cpu_relax(); 96 cpu_relax();
97 value = readl(io + KIRKWOOD_DCO_SPCR_STATUS); 97 value = readl(io + KIRKWOOD_DCO_SPCR_STATUS);
98 value &= KIRKWOOD_DCO_SPCR_STATUS; 98 value &= KIRKWOOD_DCO_SPCR_STATUS_DCO_LOCK;
99 } while (value == 0); 99 } while (value == 0);
100} 100}
101 101
@@ -180,67 +180,72 @@ static int kirkwood_i2s_play_trigger(struct snd_pcm_substream *substream,
180 int cmd, struct snd_soc_dai *dai) 180 int cmd, struct snd_soc_dai *dai)
181{ 181{
182 struct kirkwood_dma_data *priv = snd_soc_dai_get_drvdata(dai); 182 struct kirkwood_dma_data *priv = snd_soc_dai_get_drvdata(dai);
183 unsigned long value; 183 uint32_t ctl, value;
184 184
185 /* 185 ctl = readl(priv->io + KIRKWOOD_PLAYCTL);
186 * specs says KIRKWOOD_PLAYCTL must be read 2 times before 186 if (ctl & KIRKWOOD_PLAYCTL_PAUSE) {
187 * changing it. So read 1 time here and 1 later. 187 unsigned timeout = 5000;
188 */ 188 /*
189 value = readl(priv->io + KIRKWOOD_PLAYCTL); 189 * The Armada510 spec says that if we enter pause mode, the
190 * busy bit must be read back as clear _twice_. Make sure
191 * we respect that otherwise we get DMA underruns.
192 */
193 do {
194 value = ctl;
195 ctl = readl(priv->io + KIRKWOOD_PLAYCTL);
196 if (!((ctl | value) & KIRKWOOD_PLAYCTL_PLAY_BUSY))
197 break;
198 udelay(1);
199 } while (timeout--);
200
201 if ((ctl | value) & KIRKWOOD_PLAYCTL_PLAY_BUSY)
202 dev_notice(dai->dev, "timed out waiting for busy to deassert: %08x\n",
203 ctl);
204 }
190 205
191 switch (cmd) { 206 switch (cmd) {
192 case SNDRV_PCM_TRIGGER_START: 207 case SNDRV_PCM_TRIGGER_START:
193 /* stop audio, enable interrupts */
194 value = readl(priv->io + KIRKWOOD_PLAYCTL);
195 value |= KIRKWOOD_PLAYCTL_PAUSE;
196 writel(value, priv->io + KIRKWOOD_PLAYCTL);
197
198 value = readl(priv->io + KIRKWOOD_INT_MASK); 208 value = readl(priv->io + KIRKWOOD_INT_MASK);
199 value |= KIRKWOOD_INT_CAUSE_PLAY_BYTES; 209 value |= KIRKWOOD_INT_CAUSE_PLAY_BYTES;
200 writel(value, priv->io + KIRKWOOD_INT_MASK); 210 writel(value, priv->io + KIRKWOOD_INT_MASK);
201 211
202 /* configure audio & enable i2s playback */ 212 /* configure audio & enable i2s playback */
203 value = readl(priv->io + KIRKWOOD_PLAYCTL); 213 ctl &= ~KIRKWOOD_PLAYCTL_BURST_MASK;
204 value &= ~KIRKWOOD_PLAYCTL_BURST_MASK; 214 ctl &= ~(KIRKWOOD_PLAYCTL_PAUSE | KIRKWOOD_PLAYCTL_I2S_MUTE
205 value &= ~(KIRKWOOD_PLAYCTL_PAUSE | KIRKWOOD_PLAYCTL_I2S_MUTE
206 | KIRKWOOD_PLAYCTL_SPDIF_EN); 215 | KIRKWOOD_PLAYCTL_SPDIF_EN);
207 216
208 if (priv->burst == 32) 217 if (priv->burst == 32)
209 value |= KIRKWOOD_PLAYCTL_BURST_32; 218 ctl |= KIRKWOOD_PLAYCTL_BURST_32;
210 else 219 else
211 value |= KIRKWOOD_PLAYCTL_BURST_128; 220 ctl |= KIRKWOOD_PLAYCTL_BURST_128;
212 value |= KIRKWOOD_PLAYCTL_I2S_EN; 221 ctl |= KIRKWOOD_PLAYCTL_I2S_EN;
213 writel(value, priv->io + KIRKWOOD_PLAYCTL); 222 writel(ctl, priv->io + KIRKWOOD_PLAYCTL);
214 break; 223 break;
215 224
216 case SNDRV_PCM_TRIGGER_STOP: 225 case SNDRV_PCM_TRIGGER_STOP:
217 /* stop audio, disable interrupts */ 226 /* stop audio, disable interrupts */
218 value = readl(priv->io + KIRKWOOD_PLAYCTL); 227 ctl |= KIRKWOOD_PLAYCTL_PAUSE | KIRKWOOD_PLAYCTL_I2S_MUTE;
219 value |= KIRKWOOD_PLAYCTL_PAUSE | KIRKWOOD_PLAYCTL_I2S_MUTE; 228 writel(ctl, priv->io + KIRKWOOD_PLAYCTL);
220 writel(value, priv->io + KIRKWOOD_PLAYCTL);
221 229
222 value = readl(priv->io + KIRKWOOD_INT_MASK); 230 value = readl(priv->io + KIRKWOOD_INT_MASK);
223 value &= ~KIRKWOOD_INT_CAUSE_PLAY_BYTES; 231 value &= ~KIRKWOOD_INT_CAUSE_PLAY_BYTES;
224 writel(value, priv->io + KIRKWOOD_INT_MASK); 232 writel(value, priv->io + KIRKWOOD_INT_MASK);
225 233
226 /* disable all playbacks */ 234 /* disable all playbacks */
227 value = readl(priv->io + KIRKWOOD_PLAYCTL); 235 ctl &= ~(KIRKWOOD_PLAYCTL_I2S_EN | KIRKWOOD_PLAYCTL_SPDIF_EN);
228 value &= ~(KIRKWOOD_PLAYCTL_I2S_EN | KIRKWOOD_PLAYCTL_SPDIF_EN); 236 writel(ctl, priv->io + KIRKWOOD_PLAYCTL);
229 writel(value, priv->io + KIRKWOOD_PLAYCTL);
230 break; 237 break;
231 238
232 case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 239 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
233 case SNDRV_PCM_TRIGGER_SUSPEND: 240 case SNDRV_PCM_TRIGGER_SUSPEND:
234 value = readl(priv->io + KIRKWOOD_PLAYCTL); 241 ctl |= KIRKWOOD_PLAYCTL_PAUSE | KIRKWOOD_PLAYCTL_I2S_MUTE;
235 value |= KIRKWOOD_PLAYCTL_PAUSE | KIRKWOOD_PLAYCTL_I2S_MUTE; 242 writel(ctl, priv->io + KIRKWOOD_PLAYCTL);
236 writel(value, priv->io + KIRKWOOD_PLAYCTL);
237 break; 243 break;
238 244
239 case SNDRV_PCM_TRIGGER_RESUME: 245 case SNDRV_PCM_TRIGGER_RESUME:
240 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 246 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
241 value = readl(priv->io + KIRKWOOD_PLAYCTL); 247 ctl &= ~(KIRKWOOD_PLAYCTL_PAUSE | KIRKWOOD_PLAYCTL_I2S_MUTE);
242 value &= ~(KIRKWOOD_PLAYCTL_PAUSE | KIRKWOOD_PLAYCTL_I2S_MUTE); 248 writel(ctl, priv->io + KIRKWOOD_PLAYCTL);
243 writel(value, priv->io + KIRKWOOD_PLAYCTL);
244 break; 249 break;
245 250
246 default: 251 default:
@@ -260,11 +265,6 @@ static int kirkwood_i2s_rec_trigger(struct snd_pcm_substream *substream,
260 265
261 switch (cmd) { 266 switch (cmd) {
262 case SNDRV_PCM_TRIGGER_START: 267 case SNDRV_PCM_TRIGGER_START:
263 /* stop audio, enable interrupts */
264 value = readl(priv->io + KIRKWOOD_RECCTL);
265 value |= KIRKWOOD_RECCTL_PAUSE;
266 writel(value, priv->io + KIRKWOOD_RECCTL);
267
268 value = readl(priv->io + KIRKWOOD_INT_MASK); 268 value = readl(priv->io + KIRKWOOD_INT_MASK);
269 value |= KIRKWOOD_INT_CAUSE_REC_BYTES; 269 value |= KIRKWOOD_INT_CAUSE_REC_BYTES;
270 writel(value, priv->io + KIRKWOOD_INT_MASK); 270 writel(value, priv->io + KIRKWOOD_INT_MASK);
diff --git a/sound/soc/mxs/mxs-saif.c b/sound/soc/mxs/mxs-saif.c
index aa037b292f3..c294fbb523f 100644
--- a/sound/soc/mxs/mxs-saif.c
+++ b/sound/soc/mxs/mxs-saif.c
@@ -523,16 +523,24 @@ static int mxs_saif_trigger(struct snd_pcm_substream *substream, int cmd,
523 523
524 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { 524 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
525 /* 525 /*
526 * write a data to saif data register to trigger 526 * write data to saif data register to trigger
527 * the transfer 527 * the transfer.
528 * For 24-bit format the 32-bit FIFO register stores
529 * only one channel, so we need to write twice.
530 * This is also safe for the other non 24-bit formats.
528 */ 531 */
529 __raw_writel(0, saif->base + SAIF_DATA); 532 __raw_writel(0, saif->base + SAIF_DATA);
533 __raw_writel(0, saif->base + SAIF_DATA);
530 } else { 534 } else {
531 /* 535 /*
532 * read a data from saif data register to trigger 536 * read data from saif data register to trigger
533 * the receive 537 * the receive.
538 * For 24-bit format the 32-bit FIFO register stores
539 * only one channel, so we need to read twice.
540 * This is also safe for the other non 24-bit formats.
534 */ 541 */
535 __raw_readl(saif->base + SAIF_DATA); 542 __raw_readl(saif->base + SAIF_DATA);
543 __raw_readl(saif->base + SAIF_DATA);
536 } 544 }
537 545
538 master_saif->ongoing = 1; 546 master_saif->ongoing = 1;
@@ -812,3 +820,4 @@ module_platform_driver(mxs_saif_driver);
812MODULE_AUTHOR("Freescale Semiconductor, Inc."); 820MODULE_AUTHOR("Freescale Semiconductor, Inc.");
813MODULE_DESCRIPTION("MXS ASoC SAIF driver"); 821MODULE_DESCRIPTION("MXS ASoC SAIF driver");
814MODULE_LICENSE("GPL"); 822MODULE_LICENSE("GPL");
823MODULE_ALIAS("platform:mxs-saif");
diff --git a/sound/soc/omap/ams-delta.c b/sound/soc/omap/ams-delta.c
index dc0ee762662..d8e96b2cd03 100644
--- a/sound/soc/omap/ams-delta.c
+++ b/sound/soc/omap/ams-delta.c
@@ -575,56 +575,53 @@ static struct snd_soc_card ams_delta_audio_card = {
575}; 575};
576 576
577/* Module init/exit */ 577/* Module init/exit */
578static struct platform_device *ams_delta_audio_platform_device; 578static __devinit int ams_delta_probe(struct platform_device *pdev)
579static struct platform_device *cx20442_platform_device;
580
581static int __init ams_delta_module_init(void)
582{ 579{
580 struct snd_soc_card *card = &ams_delta_audio_card;
583 int ret; 581 int ret;
584 582
585 if (!(machine_is_ams_delta())) 583 card->dev = &pdev->dev;
586 return -ENODEV;
587
588 ams_delta_audio_platform_device =
589 platform_device_alloc("soc-audio", -1);
590 if (!ams_delta_audio_platform_device)
591 return -ENOMEM;
592 584
593 platform_set_drvdata(ams_delta_audio_platform_device, 585 ret = snd_soc_register_card(card);
594 &ams_delta_audio_card); 586 if (ret) {
595 587 dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret);
596 ret = platform_device_add(ams_delta_audio_platform_device); 588 card->dev = NULL;
597 if (ret) 589 return ret;
598 goto err; 590 }
599
600 /*
601 * Codec platform device could be registered from elsewhere (board?),
602 * but I do it here as it makes sense only if used with the card.
603 */
604 cx20442_platform_device =
605 platform_device_register_simple("cx20442-codec", -1, NULL, 0);
606 return 0; 591 return 0;
607err:
608 platform_device_put(ams_delta_audio_platform_device);
609 return ret;
610} 592}
611late_initcall(ams_delta_module_init);
612 593
613static void __exit ams_delta_module_exit(void) 594static int __devexit ams_delta_remove(struct platform_device *pdev)
614{ 595{
596 struct snd_soc_card *card = platform_get_drvdata(pdev);
597
615 if (tty_unregister_ldisc(N_V253) != 0) 598 if (tty_unregister_ldisc(N_V253) != 0)
616 dev_warn(&ams_delta_audio_platform_device->dev, 599 dev_warn(&pdev->dev,
617 "failed to unregister V253 line discipline\n"); 600 "failed to unregister V253 line discipline\n");
618 601
619 snd_soc_jack_free_gpios(&ams_delta_hook_switch, 602 snd_soc_jack_free_gpios(&ams_delta_hook_switch,
620 ARRAY_SIZE(ams_delta_hook_switch_gpios), 603 ARRAY_SIZE(ams_delta_hook_switch_gpios),
621 ams_delta_hook_switch_gpios); 604 ams_delta_hook_switch_gpios);
622 605
623 platform_device_unregister(cx20442_platform_device); 606 snd_soc_unregister_card(card);
624 platform_device_unregister(ams_delta_audio_platform_device); 607 card->dev = NULL;
608 return 0;
625} 609}
626module_exit(ams_delta_module_exit); 610
611#define DRV_NAME "ams-delta-audio"
612
613static struct platform_driver ams_delta_driver = {
614 .driver = {
615 .name = DRV_NAME,
616 .owner = THIS_MODULE,
617 },
618 .probe = ams_delta_probe,
619 .remove = __devexit_p(ams_delta_remove),
620};
621
622module_platform_driver(ams_delta_driver);
627 623
628MODULE_AUTHOR("Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>"); 624MODULE_AUTHOR("Janusz Krzysztofik <jkrzyszt@tis.icnet.pl>");
629MODULE_DESCRIPTION("ALSA SoC driver for Amstrad E3 (Delta) videophone"); 625MODULE_DESCRIPTION("ALSA SoC driver for Amstrad E3 (Delta) videophone");
630MODULE_LICENSE("GPL"); 626MODULE_LICENSE("GPL");
627MODULE_ALIAS("platform:" DRV_NAME);
diff --git a/sound/soc/omap/omap-abe-twl6040.c b/sound/soc/omap/omap-abe-twl6040.c
index 4a73ef3ae12..a57a4e68dcc 100644
--- a/sound/soc/omap/omap-abe-twl6040.c
+++ b/sound/soc/omap/omap-abe-twl6040.c
@@ -216,7 +216,7 @@ static int omap_abe_twl6040_init(struct snd_soc_pcm_runtime *rtd)
216 twl6040_disconnect_pin(dapm, pdata->has_hf, "Ext Spk"); 216 twl6040_disconnect_pin(dapm, pdata->has_hf, "Ext Spk");
217 twl6040_disconnect_pin(dapm, pdata->has_ep, "Earphone Spk"); 217 twl6040_disconnect_pin(dapm, pdata->has_ep, "Earphone Spk");
218 twl6040_disconnect_pin(dapm, pdata->has_aux, "Line Out"); 218 twl6040_disconnect_pin(dapm, pdata->has_aux, "Line Out");
219 twl6040_disconnect_pin(dapm, pdata->has_vibra, "Vinrator"); 219 twl6040_disconnect_pin(dapm, pdata->has_vibra, "Vibrator");
220 twl6040_disconnect_pin(dapm, pdata->has_hsmic, "Headset Mic"); 220 twl6040_disconnect_pin(dapm, pdata->has_hsmic, "Headset Mic");
221 twl6040_disconnect_pin(dapm, pdata->has_mainmic, "Main Handset Mic"); 221 twl6040_disconnect_pin(dapm, pdata->has_mainmic, "Main Handset Mic");
222 twl6040_disconnect_pin(dapm, pdata->has_submic, "Sub Handset Mic"); 222 twl6040_disconnect_pin(dapm, pdata->has_submic, "Sub Handset Mic");
diff --git a/sound/soc/omap/omap-dmic.c b/sound/soc/omap/omap-dmic.c
index 68f2cd1a920..5a6aeaf552a 100644
--- a/sound/soc/omap/omap-dmic.c
+++ b/sound/soc/omap/omap-dmic.c
@@ -464,9 +464,9 @@ static __devinit int asoc_dmic_probe(struct platform_device *pdev)
464 464
465 mutex_init(&dmic->mutex); 465 mutex_init(&dmic->mutex);
466 466
467 dmic->fclk = clk_get(dmic->dev, "dmic_fck"); 467 dmic->fclk = clk_get(dmic->dev, "fck");
468 if (IS_ERR(dmic->fclk)) { 468 if (IS_ERR(dmic->fclk)) {
469 dev_err(dmic->dev, "cant get dmic_fck\n"); 469 dev_err(dmic->dev, "cant get fck\n");
470 return -ENODEV; 470 return -ENODEV;
471 } 471 }
472 472
diff --git a/sound/soc/omap/omap-mcpdm.c b/sound/soc/omap/omap-mcpdm.c
index c02b001ee4b..56965bb3275 100644
--- a/sound/soc/omap/omap-mcpdm.c
+++ b/sound/soc/omap/omap-mcpdm.c
@@ -40,7 +40,6 @@
40#include <sound/pcm_params.h> 40#include <sound/pcm_params.h>
41#include <sound/soc.h> 41#include <sound/soc.h>
42 42
43#include <plat/omap_hwmod.h>
44#include "omap-mcpdm.h" 43#include "omap-mcpdm.h"
45#include "omap-pcm.h" 44#include "omap-pcm.h"
46 45
@@ -260,13 +259,9 @@ static int omap_mcpdm_dai_startup(struct snd_pcm_substream *substream,
260 mutex_lock(&mcpdm->mutex); 259 mutex_lock(&mcpdm->mutex);
261 260
262 if (!dai->active) { 261 if (!dai->active) {
263 /* Enable watch dog for ES above ES 1.0 to avoid saturation */ 262 u32 ctrl = omap_mcpdm_read(mcpdm, MCPDM_REG_CTRL);
264 if (omap_rev() != OMAP4430_REV_ES1_0) {
265 u32 ctrl = omap_mcpdm_read(mcpdm, MCPDM_REG_CTRL);
266 263
267 omap_mcpdm_write(mcpdm, MCPDM_REG_CTRL, 264 omap_mcpdm_write(mcpdm, MCPDM_REG_CTRL, ctrl | MCPDM_WD_EN);
268 ctrl | MCPDM_WD_EN);
269 }
270 omap_mcpdm_open_streams(mcpdm); 265 omap_mcpdm_open_streams(mcpdm);
271 } 266 }
272 mutex_unlock(&mcpdm->mutex); 267 mutex_unlock(&mcpdm->mutex);
diff --git a/sound/soc/omap/zoom2.c b/sound/soc/omap/zoom2.c
index 677b567935f..1ff6bb9ade5 100644
--- a/sound/soc/omap/zoom2.c
+++ b/sound/soc/omap/zoom2.c
@@ -21,15 +21,14 @@
21 21
22#include <linux/clk.h> 22#include <linux/clk.h>
23#include <linux/platform_device.h> 23#include <linux/platform_device.h>
24#include <linux/gpio.h>
24#include <sound/core.h> 25#include <sound/core.h>
25#include <sound/pcm.h> 26#include <sound/pcm.h>
26#include <sound/soc.h> 27#include <sound/soc.h>
27 28
28#include <asm/mach-types.h> 29#include <asm/mach-types.h>
29#include <mach/hardware.h>
30#include <mach/gpio.h>
31#include <mach/board-zoom.h>
32#include <linux/platform_data/asoc-ti-mcbsp.h> 30#include <linux/platform_data/asoc-ti-mcbsp.h>
31#include <linux/platform_data/gpio-omap.h>
33 32
34/* Register descriptions for twl4030 codec part */ 33/* Register descriptions for twl4030 codec part */
35#include <linux/mfd/twl4030-audio.h> 34#include <linux/mfd/twl4030-audio.h>
diff --git a/sound/soc/pxa/mmp-pcm.c b/sound/soc/pxa/mmp-pcm.c
index 73ac5463c9e..e834faf859f 100644
--- a/sound/soc/pxa/mmp-pcm.c
+++ b/sound/soc/pxa/mmp-pcm.c
@@ -15,13 +15,13 @@
15#include <linux/slab.h> 15#include <linux/slab.h>
16#include <linux/dma-mapping.h> 16#include <linux/dma-mapping.h>
17#include <linux/dmaengine.h> 17#include <linux/dmaengine.h>
18#include <linux/platform_data/dma-mmp_tdma.h>
18#include <linux/platform_data/mmp_audio.h> 19#include <linux/platform_data/mmp_audio.h>
19#include <sound/pxa2xx-lib.h> 20#include <sound/pxa2xx-lib.h>
20#include <sound/core.h> 21#include <sound/core.h>
21#include <sound/pcm.h> 22#include <sound/pcm.h>
22#include <sound/pcm_params.h> 23#include <sound/pcm_params.h>
23#include <sound/soc.h> 24#include <sound/soc.h>
24#include <mach/sram.h>
25#include <sound/dmaengine_pcm.h> 25#include <sound/dmaengine_pcm.h>
26 26
27struct mmp_dma_data { 27struct mmp_dma_data {
diff --git a/sound/soc/samsung/Kconfig b/sound/soc/samsung/Kconfig
index e7b83179aca..3c7c3a59ed3 100644
--- a/sound/soc/samsung/Kconfig
+++ b/sound/soc/samsung/Kconfig
@@ -207,6 +207,8 @@ config SND_SOC_BELLS
207 select SND_SOC_WM5102 207 select SND_SOC_WM5102
208 select SND_SOC_WM5110 208 select SND_SOC_WM5110
209 select SND_SOC_WM9081 209 select SND_SOC_WM9081
210 select SND_SOC_WM0010
211 select SND_SOC_WM1250_EV1
210 212
211config SND_SOC_LOWLAND 213config SND_SOC_LOWLAND
212 tristate "Audio support for Wolfson Lowland" 214 tristate "Audio support for Wolfson Lowland"
diff --git a/sound/soc/samsung/bells.c b/sound/soc/samsung/bells.c
index 5dc10dfc0d4..a2ca1567b9e 100644
--- a/sound/soc/samsung/bells.c
+++ b/sound/soc/samsung/bells.c
@@ -247,7 +247,7 @@ static struct snd_soc_dai_link bells_dai_wm5110[] = {
247 { 247 {
248 .name = "Sub", 248 .name = "Sub",
249 .stream_name = "Sub", 249 .stream_name = "Sub",
250 .cpu_dai_name = "wm5102-aif3", 250 .cpu_dai_name = "wm5110-aif3",
251 .codec_dai_name = "wm9081-hifi", 251 .codec_dai_name = "wm9081-hifi",
252 .codec_name = "wm9081.1-006c", 252 .codec_name = "wm9081.1-006c",
253 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF 253 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
diff --git a/sound/soc/sh/fsi.c b/sound/soc/sh/fsi.c
index 5328ae5539f..9d7f30774a4 100644
--- a/sound/soc/sh/fsi.c
+++ b/sound/soc/sh/fsi.c
@@ -20,6 +20,7 @@
20#include <linux/sh_dma.h> 20#include <linux/sh_dma.h>
21#include <linux/slab.h> 21#include <linux/slab.h>
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/workqueue.h>
23#include <sound/soc.h> 24#include <sound/soc.h>
24#include <sound/sh_fsi.h> 25#include <sound/sh_fsi.h>
25 26
@@ -223,7 +224,7 @@ struct fsi_stream {
223 */ 224 */
224 struct dma_chan *chan; 225 struct dma_chan *chan;
225 struct sh_dmae_slave slave; /* see fsi_handler_init() */ 226 struct sh_dmae_slave slave; /* see fsi_handler_init() */
226 struct tasklet_struct tasklet; 227 struct work_struct work;
227 dma_addr_t dma; 228 dma_addr_t dma;
228}; 229};
229 230
@@ -1085,9 +1086,9 @@ static void fsi_dma_complete(void *data)
1085 snd_pcm_period_elapsed(io->substream); 1086 snd_pcm_period_elapsed(io->substream);
1086} 1087}
1087 1088
1088static void fsi_dma_do_tasklet(unsigned long data) 1089static void fsi_dma_do_work(struct work_struct *work)
1089{ 1090{
1090 struct fsi_stream *io = (struct fsi_stream *)data; 1091 struct fsi_stream *io = container_of(work, struct fsi_stream, work);
1091 struct fsi_priv *fsi = fsi_stream_to_priv(io); 1092 struct fsi_priv *fsi = fsi_stream_to_priv(io);
1092 struct snd_soc_dai *dai; 1093 struct snd_soc_dai *dai;
1093 struct dma_async_tx_descriptor *desc; 1094 struct dma_async_tx_descriptor *desc;
@@ -1129,7 +1130,7 @@ static void fsi_dma_do_tasklet(unsigned long data)
1129 * FIXME 1130 * FIXME
1130 * 1131 *
1131 * In DMAEngine case, codec and FSI cannot be started simultaneously 1132 * In DMAEngine case, codec and FSI cannot be started simultaneously
1132 * since FSI is using tasklet. 1133 * since FSI is using the scheduler work queue.
1133 * Therefore, in capture case, probably FSI FIFO will have got 1134 * Therefore, in capture case, probably FSI FIFO will have got
1134 * overflow error in this point. 1135 * overflow error in this point.
1135 * in that case, DMA cannot start transfer until error was cleared. 1136 * in that case, DMA cannot start transfer until error was cleared.
@@ -1153,7 +1154,7 @@ static bool fsi_dma_filter(struct dma_chan *chan, void *param)
1153 1154
1154static int fsi_dma_transfer(struct fsi_priv *fsi, struct fsi_stream *io) 1155static int fsi_dma_transfer(struct fsi_priv *fsi, struct fsi_stream *io)
1155{ 1156{
1156 tasklet_schedule(&io->tasklet); 1157 schedule_work(&io->work);
1157 1158
1158 return 0; 1159 return 0;
1159} 1160}
@@ -1195,14 +1196,14 @@ static int fsi_dma_probe(struct fsi_priv *fsi, struct fsi_stream *io, struct dev
1195 return fsi_stream_probe(fsi, dev); 1196 return fsi_stream_probe(fsi, dev);
1196 } 1197 }
1197 1198
1198 tasklet_init(&io->tasklet, fsi_dma_do_tasklet, (unsigned long)io); 1199 INIT_WORK(&io->work, fsi_dma_do_work);
1199 1200
1200 return 0; 1201 return 0;
1201} 1202}
1202 1203
1203static int fsi_dma_remove(struct fsi_priv *fsi, struct fsi_stream *io) 1204static int fsi_dma_remove(struct fsi_priv *fsi, struct fsi_stream *io)
1204{ 1205{
1205 tasklet_kill(&io->tasklet); 1206 cancel_work_sync(&io->work);
1206 1207
1207 fsi_stream_stop(fsi, io); 1208 fsi_stream_stop(fsi, io);
1208 1209
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index d1198627fc4..10d21be383f 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -2786,8 +2786,9 @@ int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol,
2786 val = (ucontrol->value.integer.value[0] + min) & mask; 2786 val = (ucontrol->value.integer.value[0] + min) & mask;
2787 val = val << shift; 2787 val = val << shift;
2788 2788
2789 if (snd_soc_update_bits_locked(codec, reg, val_mask, val)) 2789 err = snd_soc_update_bits_locked(codec, reg, val_mask, val);
2790 return err; 2790 if (err < 0)
2791 return err;
2791 2792
2792 if (snd_soc_volsw_is_stereo(mc)) { 2793 if (snd_soc_volsw_is_stereo(mc)) {
2793 val_mask = mask << rshift; 2794 val_mask = mask << rshift;
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index d0a4be38dc0..6e35bcae02d 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -3745,7 +3745,7 @@ void snd_soc_dapm_shutdown(struct snd_soc_card *card)
3745{ 3745{
3746 struct snd_soc_codec *codec; 3746 struct snd_soc_codec *codec;
3747 3747
3748 list_for_each_entry(codec, &card->codec_dev_list, list) { 3748 list_for_each_entry(codec, &card->codec_dev_list, card_list) {
3749 soc_dapm_shutdown_codec(&codec->dapm); 3749 soc_dapm_shutdown_codec(&codec->dapm);
3750 if (codec->dapm.bias_level == SND_SOC_BIAS_STANDBY) 3750 if (codec->dapm.bias_level == SND_SOC_BIAS_STANDBY)
3751 snd_soc_dapm_set_bias_level(&codec->dapm, 3751 snd_soc_dapm_set_bias_level(&codec->dapm,
diff --git a/sound/soc/soc-jack.c b/sound/soc/soc-jack.c
index fa0fd8ddae9..1ab5fe04bfc 100644
--- a/sound/soc/soc-jack.c
+++ b/sound/soc/soc-jack.c
@@ -22,7 +22,7 @@
22 22
23/** 23/**
24 * snd_soc_jack_new - Create a new jack 24 * snd_soc_jack_new - Create a new jack
25 * @card: ASoC card 25 * @codec: ASoC codec
26 * @id: an identifying string for this jack 26 * @id: an identifying string for this jack
27 * @type: a bitmask of enum snd_jack_type values that can be detected by 27 * @type: a bitmask of enum snd_jack_type values that can be detected by
28 * this jack 28 * this jack
@@ -133,12 +133,13 @@ EXPORT_SYMBOL_GPL(snd_soc_jack_add_zones);
133 133
134/** 134/**
135 * snd_soc_jack_get_type - Based on the mic bias value, this function returns 135 * snd_soc_jack_get_type - Based on the mic bias value, this function returns
136 * the type of jack from the zones delcared in the jack type 136 * the type of jack from the zones declared in the jack type
137 * 137 *
138 * @jack: ASoC jack
138 * @micbias_voltage: mic bias voltage at adc channel when jack is plugged in 139 * @micbias_voltage: mic bias voltage at adc channel when jack is plugged in
139 * 140 *
140 * Based on the mic bias value passed, this function helps identify 141 * Based on the mic bias value passed, this function helps identify
141 * the type of jack from the already delcared jack zones 142 * the type of jack from the already declared jack zones
142 */ 143 */
143int snd_soc_jack_get_type(struct snd_soc_jack *jack, int micbias_voltage) 144int snd_soc_jack_get_type(struct snd_soc_jack *jack, int micbias_voltage)
144{ 145{
diff --git a/sound/soc/ux500/mop500.c b/sound/soc/ux500/mop500.c
index 356611d9654..54f7e25b6f7 100644
--- a/sound/soc/ux500/mop500.c
+++ b/sound/soc/ux500/mop500.c
@@ -57,6 +57,20 @@ static struct snd_soc_card mop500_card = {
57 .num_links = ARRAY_SIZE(mop500_dai_links), 57 .num_links = ARRAY_SIZE(mop500_dai_links),
58}; 58};
59 59
60static void mop500_of_node_put(void)
61{
62 int i;
63
64 for (i = 0; i < 2; i++) {
65 if (mop500_dai_links[i].cpu_of_node)
66 of_node_put((struct device_node *)
67 mop500_dai_links[i].cpu_of_node);
68 if (mop500_dai_links[i].codec_of_node)
69 of_node_put((struct device_node *)
70 mop500_dai_links[i].codec_of_node);
71 }
72}
73
60static int __devinit mop500_of_probe(struct platform_device *pdev, 74static int __devinit mop500_of_probe(struct platform_device *pdev,
61 struct device_node *np) 75 struct device_node *np)
62{ 76{
@@ -69,6 +83,7 @@ static int __devinit mop500_of_probe(struct platform_device *pdev,
69 83
70 if (!(msp_np[0] && msp_np[1] && codec_np)) { 84 if (!(msp_np[0] && msp_np[1] && codec_np)) {
71 dev_err(&pdev->dev, "Phandle missing or invalid\n"); 85 dev_err(&pdev->dev, "Phandle missing or invalid\n");
86 mop500_of_node_put();
72 return -EINVAL; 87 return -EINVAL;
73 } 88 }
74 89
@@ -83,6 +98,7 @@ static int __devinit mop500_of_probe(struct platform_device *pdev,
83 98
84 return 0; 99 return 0;
85} 100}
101
86static int __devinit mop500_probe(struct platform_device *pdev) 102static int __devinit mop500_probe(struct platform_device *pdev)
87{ 103{
88 struct device_node *np = pdev->dev.of_node; 104 struct device_node *np = pdev->dev.of_node;
@@ -128,6 +144,7 @@ static int __devexit mop500_remove(struct platform_device *pdev)
128 144
129 snd_soc_unregister_card(mop500_card); 145 snd_soc_unregister_card(mop500_card);
130 mop500_ab8500_remove(mop500_card); 146 mop500_ab8500_remove(mop500_card);
147 mop500_of_node_put();
131 148
132 return 0; 149 return 0;
133} 150}
diff --git a/sound/soc/ux500/ux500_msp_i2s.c b/sound/soc/ux500/ux500_msp_i2s.c
index b7c996e7757..a26c6bf0a29 100644
--- a/sound/soc/ux500/ux500_msp_i2s.c
+++ b/sound/soc/ux500/ux500_msp_i2s.c
@@ -18,6 +18,7 @@
18#include <linux/pinctrl/consumer.h> 18#include <linux/pinctrl/consumer.h>
19#include <linux/delay.h> 19#include <linux/delay.h>
20#include <linux/slab.h> 20#include <linux/slab.h>
21#include <linux/io.h>
21#include <linux/of.h> 22#include <linux/of.h>
22 23
23#include <mach/hardware.h> 24#include <mach/hardware.h>
@@ -697,14 +698,11 @@ int ux500_msp_i2s_init_msp(struct platform_device *pdev,
697 platform_data = devm_kzalloc(&pdev->dev, 698 platform_data = devm_kzalloc(&pdev->dev,
698 sizeof(struct msp_i2s_platform_data), GFP_KERNEL); 699 sizeof(struct msp_i2s_platform_data), GFP_KERNEL);
699 if (!platform_data) 700 if (!platform_data)
700 ret = -ENOMEM; 701 return -ENOMEM;
701 } 702 }
702 } else 703 } else
703 if (!platform_data) 704 if (!platform_data)
704 ret = -EINVAL; 705 return -EINVAL;
705
706 if (ret)
707 goto err_res;
708 706
709 dev_dbg(&pdev->dev, "%s: Enter (name: %s, id: %d).\n", __func__, 707 dev_dbg(&pdev->dev, "%s: Enter (name: %s, id: %d).\n", __func__,
710 pdev->name, platform_data->id); 708 pdev->name, platform_data->id);
diff --git a/sound/usb/card.c b/sound/usb/card.c
index 561bb74fd36..dbf7999d18b 100644
--- a/sound/usb/card.c
+++ b/sound/usb/card.c
@@ -339,7 +339,7 @@ static int snd_usb_audio_create(struct usb_device *dev, int idx,
339 } 339 }
340 340
341 mutex_init(&chip->mutex); 341 mutex_init(&chip->mutex);
342 mutex_init(&chip->shutdown_mutex); 342 init_rwsem(&chip->shutdown_rwsem);
343 chip->index = idx; 343 chip->index = idx;
344 chip->dev = dev; 344 chip->dev = dev;
345 chip->card = card; 345 chip->card = card;
@@ -559,9 +559,11 @@ static void snd_usb_audio_disconnect(struct usb_device *dev,
559 return; 559 return;
560 560
561 card = chip->card; 561 card = chip->card;
562 mutex_lock(&register_mutex); 562 down_write(&chip->shutdown_rwsem);
563 mutex_lock(&chip->shutdown_mutex);
564 chip->shutdown = 1; 563 chip->shutdown = 1;
564 up_write(&chip->shutdown_rwsem);
565
566 mutex_lock(&register_mutex);
565 chip->num_interfaces--; 567 chip->num_interfaces--;
566 if (chip->num_interfaces <= 0) { 568 if (chip->num_interfaces <= 0) {
567 snd_card_disconnect(card); 569 snd_card_disconnect(card);
@@ -582,11 +584,9 @@ static void snd_usb_audio_disconnect(struct usb_device *dev,
582 snd_usb_mixer_disconnect(p); 584 snd_usb_mixer_disconnect(p);
583 } 585 }
584 usb_chip[chip->index] = NULL; 586 usb_chip[chip->index] = NULL;
585 mutex_unlock(&chip->shutdown_mutex);
586 mutex_unlock(&register_mutex); 587 mutex_unlock(&register_mutex);
587 snd_card_free_when_closed(card); 588 snd_card_free_when_closed(card);
588 } else { 589 } else {
589 mutex_unlock(&chip->shutdown_mutex);
590 mutex_unlock(&register_mutex); 590 mutex_unlock(&register_mutex);
591 } 591 }
592} 592}
@@ -618,16 +618,20 @@ int snd_usb_autoresume(struct snd_usb_audio *chip)
618{ 618{
619 int err = -ENODEV; 619 int err = -ENODEV;
620 620
621 down_read(&chip->shutdown_rwsem);
621 if (!chip->shutdown && !chip->probing) 622 if (!chip->shutdown && !chip->probing)
622 err = usb_autopm_get_interface(chip->pm_intf); 623 err = usb_autopm_get_interface(chip->pm_intf);
624 up_read(&chip->shutdown_rwsem);
623 625
624 return err; 626 return err;
625} 627}
626 628
627void snd_usb_autosuspend(struct snd_usb_audio *chip) 629void snd_usb_autosuspend(struct snd_usb_audio *chip)
628{ 630{
631 down_read(&chip->shutdown_rwsem);
629 if (!chip->shutdown && !chip->probing) 632 if (!chip->shutdown && !chip->probing)
630 usb_autopm_put_interface(chip->pm_intf); 633 usb_autopm_put_interface(chip->pm_intf);
634 up_read(&chip->shutdown_rwsem);
631} 635}
632 636
633static int usb_audio_suspend(struct usb_interface *intf, pm_message_t message) 637static int usb_audio_suspend(struct usb_interface *intf, pm_message_t message)
diff --git a/sound/usb/card.h b/sound/usb/card.h
index afa4f9e9b27..814cb357ff8 100644
--- a/sound/usb/card.h
+++ b/sound/usb/card.h
@@ -126,6 +126,7 @@ struct snd_usb_substream {
126 struct snd_usb_endpoint *sync_endpoint; 126 struct snd_usb_endpoint *sync_endpoint;
127 unsigned long flags; 127 unsigned long flags;
128 bool need_setup_ep; /* (re)configure EP at prepare? */ 128 bool need_setup_ep; /* (re)configure EP at prepare? */
129 unsigned int speed; /* USB_SPEED_XXX */
129 130
130 u64 formats; /* format bitmasks (all or'ed) */ 131 u64 formats; /* format bitmasks (all or'ed) */
131 unsigned int num_formats; /* number of supported audio formats (list) */ 132 unsigned int num_formats; /* number of supported audio formats (list) */
diff --git a/sound/usb/endpoint.c b/sound/usb/endpoint.c
index 7f78c6d782b..34de6f2faf6 100644
--- a/sound/usb/endpoint.c
+++ b/sound/usb/endpoint.c
@@ -35,6 +35,7 @@
35 35
36#define EP_FLAG_ACTIVATED 0 36#define EP_FLAG_ACTIVATED 0
37#define EP_FLAG_RUNNING 1 37#define EP_FLAG_RUNNING 1
38#define EP_FLAG_STOPPING 2
38 39
39/* 40/*
40 * snd_usb_endpoint is a model that abstracts everything related to an 41 * snd_usb_endpoint is a model that abstracts everything related to an
@@ -502,10 +503,20 @@ static int wait_clear_urbs(struct snd_usb_endpoint *ep)
502 if (alive) 503 if (alive)
503 snd_printk(KERN_ERR "timeout: still %d active urbs on EP #%x\n", 504 snd_printk(KERN_ERR "timeout: still %d active urbs on EP #%x\n",
504 alive, ep->ep_num); 505 alive, ep->ep_num);
506 clear_bit(EP_FLAG_STOPPING, &ep->flags);
505 507
506 return 0; 508 return 0;
507} 509}
508 510
511/* sync the pending stop operation;
512 * this function itself doesn't trigger the stop operation
513 */
514void snd_usb_endpoint_sync_pending_stop(struct snd_usb_endpoint *ep)
515{
516 if (ep && test_bit(EP_FLAG_STOPPING, &ep->flags))
517 wait_clear_urbs(ep);
518}
519
509/* 520/*
510 * unlink active urbs. 521 * unlink active urbs.
511 */ 522 */
@@ -918,6 +929,8 @@ void snd_usb_endpoint_stop(struct snd_usb_endpoint *ep,
918 929
919 if (wait) 930 if (wait)
920 wait_clear_urbs(ep); 931 wait_clear_urbs(ep);
932 else
933 set_bit(EP_FLAG_STOPPING, &ep->flags);
921 } 934 }
922} 935}
923 936
diff --git a/sound/usb/endpoint.h b/sound/usb/endpoint.h
index 6376ccf10fd..3d4c9705041 100644
--- a/sound/usb/endpoint.h
+++ b/sound/usb/endpoint.h
@@ -19,6 +19,7 @@ int snd_usb_endpoint_set_params(struct snd_usb_endpoint *ep,
19int snd_usb_endpoint_start(struct snd_usb_endpoint *ep, int can_sleep); 19int snd_usb_endpoint_start(struct snd_usb_endpoint *ep, int can_sleep);
20void snd_usb_endpoint_stop(struct snd_usb_endpoint *ep, 20void snd_usb_endpoint_stop(struct snd_usb_endpoint *ep,
21 int force, int can_sleep, int wait); 21 int force, int can_sleep, int wait);
22void snd_usb_endpoint_sync_pending_stop(struct snd_usb_endpoint *ep);
22int snd_usb_endpoint_activate(struct snd_usb_endpoint *ep); 23int snd_usb_endpoint_activate(struct snd_usb_endpoint *ep);
23int snd_usb_endpoint_deactivate(struct snd_usb_endpoint *ep); 24int snd_usb_endpoint_deactivate(struct snd_usb_endpoint *ep);
24void snd_usb_endpoint_free(struct list_head *head); 25void snd_usb_endpoint_free(struct list_head *head);
diff --git a/sound/usb/midi.c b/sound/usb/midi.c
index c83f6143c0e..eeefbce3873 100644
--- a/sound/usb/midi.c
+++ b/sound/usb/midi.c
@@ -148,6 +148,7 @@ struct snd_usb_midi_out_endpoint {
148 struct snd_usb_midi_out_endpoint* ep; 148 struct snd_usb_midi_out_endpoint* ep;
149 struct snd_rawmidi_substream *substream; 149 struct snd_rawmidi_substream *substream;
150 int active; 150 int active;
151 bool autopm_reference;
151 uint8_t cable; /* cable number << 4 */ 152 uint8_t cable; /* cable number << 4 */
152 uint8_t state; 153 uint8_t state;
153#define STATE_UNKNOWN 0 154#define STATE_UNKNOWN 0
@@ -1076,7 +1077,8 @@ static int snd_usbmidi_output_open(struct snd_rawmidi_substream *substream)
1076 return -ENXIO; 1077 return -ENXIO;
1077 } 1078 }
1078 err = usb_autopm_get_interface(umidi->iface); 1079 err = usb_autopm_get_interface(umidi->iface);
1079 if (err < 0) 1080 port->autopm_reference = err >= 0;
1081 if (err < 0 && err != -EACCES)
1080 return -EIO; 1082 return -EIO;
1081 substream->runtime->private_data = port; 1083 substream->runtime->private_data = port;
1082 port->state = STATE_UNKNOWN; 1084 port->state = STATE_UNKNOWN;
@@ -1087,9 +1089,11 @@ static int snd_usbmidi_output_open(struct snd_rawmidi_substream *substream)
1087static int snd_usbmidi_output_close(struct snd_rawmidi_substream *substream) 1089static int snd_usbmidi_output_close(struct snd_rawmidi_substream *substream)
1088{ 1090{
1089 struct snd_usb_midi* umidi = substream->rmidi->private_data; 1091 struct snd_usb_midi* umidi = substream->rmidi->private_data;
1092 struct usbmidi_out_port *port = substream->runtime->private_data;
1090 1093
1091 substream_open(substream, 0); 1094 substream_open(substream, 0);
1092 usb_autopm_put_interface(umidi->iface); 1095 if (port->autopm_reference)
1096 usb_autopm_put_interface(umidi->iface);
1093 return 0; 1097 return 0;
1094} 1098}
1095 1099
diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index fe56c9da38e..298070e8f2d 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -287,25 +287,32 @@ static int get_ctl_value_v1(struct usb_mixer_elem_info *cval, int request, int v
287 unsigned char buf[2]; 287 unsigned char buf[2];
288 int val_len = cval->val_type >= USB_MIXER_S16 ? 2 : 1; 288 int val_len = cval->val_type >= USB_MIXER_S16 ? 2 : 1;
289 int timeout = 10; 289 int timeout = 10;
290 int err; 290 int idx = 0, err;
291 291
292 err = snd_usb_autoresume(cval->mixer->chip); 292 err = snd_usb_autoresume(cval->mixer->chip);
293 if (err < 0) 293 if (err < 0)
294 return -EIO; 294 return -EIO;
295 down_read(&chip->shutdown_rwsem);
295 while (timeout-- > 0) { 296 while (timeout-- > 0) {
297 if (chip->shutdown)
298 break;
299 idx = snd_usb_ctrl_intf(chip) | (cval->id << 8);
296 if (snd_usb_ctl_msg(chip->dev, usb_rcvctrlpipe(chip->dev, 0), request, 300 if (snd_usb_ctl_msg(chip->dev, usb_rcvctrlpipe(chip->dev, 0), request,
297 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN, 301 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN,
298 validx, snd_usb_ctrl_intf(chip) | (cval->id << 8), 302 validx, idx, buf, val_len) >= val_len) {
299 buf, val_len) >= val_len) {
300 *value_ret = convert_signed_value(cval, snd_usb_combine_bytes(buf, val_len)); 303 *value_ret = convert_signed_value(cval, snd_usb_combine_bytes(buf, val_len));
301 snd_usb_autosuspend(cval->mixer->chip); 304 err = 0;
302 return 0; 305 goto out;
303 } 306 }
304 } 307 }
305 snd_usb_autosuspend(cval->mixer->chip);
306 snd_printdd(KERN_ERR "cannot get ctl value: req = %#x, wValue = %#x, wIndex = %#x, type = %d\n", 308 snd_printdd(KERN_ERR "cannot get ctl value: req = %#x, wValue = %#x, wIndex = %#x, type = %d\n",
307 request, validx, snd_usb_ctrl_intf(chip) | (cval->id << 8), cval->val_type); 309 request, validx, idx, cval->val_type);
308 return -EINVAL; 310 err = -EINVAL;
311
312 out:
313 up_read(&chip->shutdown_rwsem);
314 snd_usb_autosuspend(cval->mixer->chip);
315 return err;
309} 316}
310 317
311static int get_ctl_value_v2(struct usb_mixer_elem_info *cval, int request, int validx, int *value_ret) 318static int get_ctl_value_v2(struct usb_mixer_elem_info *cval, int request, int validx, int *value_ret)
@@ -313,7 +320,7 @@ static int get_ctl_value_v2(struct usb_mixer_elem_info *cval, int request, int v
313 struct snd_usb_audio *chip = cval->mixer->chip; 320 struct snd_usb_audio *chip = cval->mixer->chip;
314 unsigned char buf[2 + 3*sizeof(__u16)]; /* enough space for one range */ 321 unsigned char buf[2 + 3*sizeof(__u16)]; /* enough space for one range */
315 unsigned char *val; 322 unsigned char *val;
316 int ret, size; 323 int idx = 0, ret, size;
317 __u8 bRequest; 324 __u8 bRequest;
318 325
319 if (request == UAC_GET_CUR) { 326 if (request == UAC_GET_CUR) {
@@ -330,16 +337,22 @@ static int get_ctl_value_v2(struct usb_mixer_elem_info *cval, int request, int v
330 if (ret) 337 if (ret)
331 goto error; 338 goto error;
332 339
333 ret = snd_usb_ctl_msg(chip->dev, usb_rcvctrlpipe(chip->dev, 0), bRequest, 340 down_read(&chip->shutdown_rwsem);
341 if (chip->shutdown)
342 ret = -ENODEV;
343 else {
344 idx = snd_usb_ctrl_intf(chip) | (cval->id << 8);
345 ret = snd_usb_ctl_msg(chip->dev, usb_rcvctrlpipe(chip->dev, 0), bRequest,
334 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN, 346 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN,
335 validx, snd_usb_ctrl_intf(chip) | (cval->id << 8), 347 validx, idx, buf, size);
336 buf, size); 348 }
349 up_read(&chip->shutdown_rwsem);
337 snd_usb_autosuspend(chip); 350 snd_usb_autosuspend(chip);
338 351
339 if (ret < 0) { 352 if (ret < 0) {
340error: 353error:
341 snd_printk(KERN_ERR "cannot get ctl value: req = %#x, wValue = %#x, wIndex = %#x, type = %d\n", 354 snd_printk(KERN_ERR "cannot get ctl value: req = %#x, wValue = %#x, wIndex = %#x, type = %d\n",
342 request, validx, snd_usb_ctrl_intf(chip) | (cval->id << 8), cval->val_type); 355 request, validx, idx, cval->val_type);
343 return ret; 356 return ret;
344 } 357 }
345 358
@@ -417,7 +430,7 @@ int snd_usb_mixer_set_ctl_value(struct usb_mixer_elem_info *cval,
417{ 430{
418 struct snd_usb_audio *chip = cval->mixer->chip; 431 struct snd_usb_audio *chip = cval->mixer->chip;
419 unsigned char buf[2]; 432 unsigned char buf[2];
420 int val_len, err, timeout = 10; 433 int idx = 0, val_len, err, timeout = 10;
421 434
422 if (cval->mixer->protocol == UAC_VERSION_1) { 435 if (cval->mixer->protocol == UAC_VERSION_1) {
423 val_len = cval->val_type >= USB_MIXER_S16 ? 2 : 1; 436 val_len = cval->val_type >= USB_MIXER_S16 ? 2 : 1;
@@ -440,19 +453,27 @@ int snd_usb_mixer_set_ctl_value(struct usb_mixer_elem_info *cval,
440 err = snd_usb_autoresume(chip); 453 err = snd_usb_autoresume(chip);
441 if (err < 0) 454 if (err < 0)
442 return -EIO; 455 return -EIO;
443 while (timeout-- > 0) 456 down_read(&chip->shutdown_rwsem);
457 while (timeout-- > 0) {
458 if (chip->shutdown)
459 break;
460 idx = snd_usb_ctrl_intf(chip) | (cval->id << 8);
444 if (snd_usb_ctl_msg(chip->dev, 461 if (snd_usb_ctl_msg(chip->dev,
445 usb_sndctrlpipe(chip->dev, 0), request, 462 usb_sndctrlpipe(chip->dev, 0), request,
446 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_OUT, 463 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_OUT,
447 validx, snd_usb_ctrl_intf(chip) | (cval->id << 8), 464 validx, idx, buf, val_len) >= 0) {
448 buf, val_len) >= 0) { 465 err = 0;
449 snd_usb_autosuspend(chip); 466 goto out;
450 return 0;
451 } 467 }
452 snd_usb_autosuspend(chip); 468 }
453 snd_printdd(KERN_ERR "cannot set ctl value: req = %#x, wValue = %#x, wIndex = %#x, type = %d, data = %#x/%#x\n", 469 snd_printdd(KERN_ERR "cannot set ctl value: req = %#x, wValue = %#x, wIndex = %#x, type = %d, data = %#x/%#x\n",
454 request, validx, snd_usb_ctrl_intf(chip) | (cval->id << 8), cval->val_type, buf[0], buf[1]); 470 request, validx, idx, cval->val_type, buf[0], buf[1]);
455 return -EINVAL; 471 err = -EINVAL;
472
473 out:
474 up_read(&chip->shutdown_rwsem);
475 snd_usb_autosuspend(chip);
476 return err;
456} 477}
457 478
458static int set_cur_ctl_value(struct usb_mixer_elem_info *cval, int validx, int value) 479static int set_cur_ctl_value(struct usb_mixer_elem_info *cval, int validx, int value)
diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c
index 690000db0ec..ae2b7143522 100644
--- a/sound/usb/mixer_quirks.c
+++ b/sound/usb/mixer_quirks.c
@@ -283,6 +283,11 @@ static int snd_audigy2nx_led_put(struct snd_kcontrol *kcontrol, struct snd_ctl_e
283 if (value > 1) 283 if (value > 1)
284 return -EINVAL; 284 return -EINVAL;
285 changed = value != mixer->audigy2nx_leds[index]; 285 changed = value != mixer->audigy2nx_leds[index];
286 down_read(&mixer->chip->shutdown_rwsem);
287 if (mixer->chip->shutdown) {
288 err = -ENODEV;
289 goto out;
290 }
286 if (mixer->chip->usb_id == USB_ID(0x041e, 0x3042)) 291 if (mixer->chip->usb_id == USB_ID(0x041e, 0x3042))
287 err = snd_usb_ctl_msg(mixer->chip->dev, 292 err = snd_usb_ctl_msg(mixer->chip->dev,
288 usb_sndctrlpipe(mixer->chip->dev, 0), 0x24, 293 usb_sndctrlpipe(mixer->chip->dev, 0), 0x24,
@@ -299,6 +304,8 @@ static int snd_audigy2nx_led_put(struct snd_kcontrol *kcontrol, struct snd_ctl_e
299 usb_sndctrlpipe(mixer->chip->dev, 0), 0x24, 304 usb_sndctrlpipe(mixer->chip->dev, 0), 0x24,
300 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER, 305 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER,
301 value, index + 2, NULL, 0); 306 value, index + 2, NULL, 0);
307 out:
308 up_read(&mixer->chip->shutdown_rwsem);
302 if (err < 0) 309 if (err < 0)
303 return err; 310 return err;
304 mixer->audigy2nx_leds[index] = value; 311 mixer->audigy2nx_leds[index] = value;
@@ -392,11 +399,16 @@ static void snd_audigy2nx_proc_read(struct snd_info_entry *entry,
392 399
393 for (i = 0; jacks[i].name; ++i) { 400 for (i = 0; jacks[i].name; ++i) {
394 snd_iprintf(buffer, "%s: ", jacks[i].name); 401 snd_iprintf(buffer, "%s: ", jacks[i].name);
395 err = snd_usb_ctl_msg(mixer->chip->dev, 402 down_read(&mixer->chip->shutdown_rwsem);
403 if (mixer->chip->shutdown)
404 err = 0;
405 else
406 err = snd_usb_ctl_msg(mixer->chip->dev,
396 usb_rcvctrlpipe(mixer->chip->dev, 0), 407 usb_rcvctrlpipe(mixer->chip->dev, 0),
397 UAC_GET_MEM, USB_DIR_IN | USB_TYPE_CLASS | 408 UAC_GET_MEM, USB_DIR_IN | USB_TYPE_CLASS |
398 USB_RECIP_INTERFACE, 0, 409 USB_RECIP_INTERFACE, 0,
399 jacks[i].unitid << 8, buf, 3); 410 jacks[i].unitid << 8, buf, 3);
411 up_read(&mixer->chip->shutdown_rwsem);
400 if (err == 3 && (buf[0] == 3 || buf[0] == 6)) 412 if (err == 3 && (buf[0] == 3 || buf[0] == 6))
401 snd_iprintf(buffer, "%02x %02x\n", buf[1], buf[2]); 413 snd_iprintf(buffer, "%02x %02x\n", buf[1], buf[2]);
402 else 414 else
@@ -426,10 +438,15 @@ static int snd_xonar_u1_switch_put(struct snd_kcontrol *kcontrol,
426 else 438 else
427 new_status = old_status & ~0x02; 439 new_status = old_status & ~0x02;
428 changed = new_status != old_status; 440 changed = new_status != old_status;
429 err = snd_usb_ctl_msg(mixer->chip->dev, 441 down_read(&mixer->chip->shutdown_rwsem);
442 if (mixer->chip->shutdown)
443 err = -ENODEV;
444 else
445 err = snd_usb_ctl_msg(mixer->chip->dev,
430 usb_sndctrlpipe(mixer->chip->dev, 0), 0x08, 446 usb_sndctrlpipe(mixer->chip->dev, 0), 0x08,
431 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER, 447 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_OTHER,
432 50, 0, &new_status, 1); 448 50, 0, &new_status, 1);
449 up_read(&mixer->chip->shutdown_rwsem);
433 if (err < 0) 450 if (err < 0)
434 return err; 451 return err;
435 mixer->xonar_u1_status = new_status; 452 mixer->xonar_u1_status = new_status;
@@ -468,11 +485,17 @@ static int snd_nativeinstruments_control_get(struct snd_kcontrol *kcontrol,
468 u8 bRequest = (kcontrol->private_value >> 16) & 0xff; 485 u8 bRequest = (kcontrol->private_value >> 16) & 0xff;
469 u16 wIndex = kcontrol->private_value & 0xffff; 486 u16 wIndex = kcontrol->private_value & 0xffff;
470 u8 tmp; 487 u8 tmp;
488 int ret;
471 489
472 int ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), bRequest, 490 down_read(&mixer->chip->shutdown_rwsem);
491 if (mixer->chip->shutdown)
492 ret = -ENODEV;
493 else
494 ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), bRequest,
473 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, 495 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
474 0, cpu_to_le16(wIndex), 496 0, cpu_to_le16(wIndex),
475 &tmp, sizeof(tmp), 1000); 497 &tmp, sizeof(tmp), 1000);
498 up_read(&mixer->chip->shutdown_rwsem);
476 499
477 if (ret < 0) { 500 if (ret < 0) {
478 snd_printk(KERN_ERR 501 snd_printk(KERN_ERR
@@ -493,11 +516,17 @@ static int snd_nativeinstruments_control_put(struct snd_kcontrol *kcontrol,
493 u8 bRequest = (kcontrol->private_value >> 16) & 0xff; 516 u8 bRequest = (kcontrol->private_value >> 16) & 0xff;
494 u16 wIndex = kcontrol->private_value & 0xffff; 517 u16 wIndex = kcontrol->private_value & 0xffff;
495 u16 wValue = ucontrol->value.integer.value[0]; 518 u16 wValue = ucontrol->value.integer.value[0];
519 int ret;
496 520
497 int ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), bRequest, 521 down_read(&mixer->chip->shutdown_rwsem);
522 if (mixer->chip->shutdown)
523 ret = -ENODEV;
524 else
525 ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), bRequest,
498 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, 526 USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,
499 cpu_to_le16(wValue), cpu_to_le16(wIndex), 527 cpu_to_le16(wValue), cpu_to_le16(wIndex),
500 NULL, 0, 1000); 528 NULL, 0, 1000);
529 up_read(&mixer->chip->shutdown_rwsem);
501 530
502 if (ret < 0) { 531 if (ret < 0) {
503 snd_printk(KERN_ERR 532 snd_printk(KERN_ERR
@@ -656,11 +685,16 @@ static int snd_ftu_eff_switch_get(struct snd_kcontrol *kctl,
656 return -EINVAL; 685 return -EINVAL;
657 686
658 687
659 err = snd_usb_ctl_msg(chip->dev, 688 down_read(&mixer->chip->shutdown_rwsem);
689 if (mixer->chip->shutdown)
690 err = -ENODEV;
691 else
692 err = snd_usb_ctl_msg(chip->dev,
660 usb_rcvctrlpipe(chip->dev, 0), UAC_GET_CUR, 693 usb_rcvctrlpipe(chip->dev, 0), UAC_GET_CUR,
661 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN, 694 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN,
662 validx << 8, snd_usb_ctrl_intf(chip) | (id << 8), 695 validx << 8, snd_usb_ctrl_intf(chip) | (id << 8),
663 value, val_len); 696 value, val_len);
697 up_read(&mixer->chip->shutdown_rwsem);
664 if (err < 0) 698 if (err < 0)
665 return err; 699 return err;
666 700
@@ -703,11 +737,16 @@ static int snd_ftu_eff_switch_put(struct snd_kcontrol *kctl,
703 737
704 if (!pval->is_cached) { 738 if (!pval->is_cached) {
705 /* Read current value */ 739 /* Read current value */
706 err = snd_usb_ctl_msg(chip->dev, 740 down_read(&mixer->chip->shutdown_rwsem);
741 if (mixer->chip->shutdown)
742 err = -ENODEV;
743 else
744 err = snd_usb_ctl_msg(chip->dev,
707 usb_rcvctrlpipe(chip->dev, 0), UAC_GET_CUR, 745 usb_rcvctrlpipe(chip->dev, 0), UAC_GET_CUR,
708 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN, 746 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_IN,
709 validx << 8, snd_usb_ctrl_intf(chip) | (id << 8), 747 validx << 8, snd_usb_ctrl_intf(chip) | (id << 8),
710 value, val_len); 748 value, val_len);
749 up_read(&mixer->chip->shutdown_rwsem);
711 if (err < 0) 750 if (err < 0)
712 return err; 751 return err;
713 752
@@ -719,11 +758,16 @@ static int snd_ftu_eff_switch_put(struct snd_kcontrol *kctl,
719 if (cur_val != new_val) { 758 if (cur_val != new_val) {
720 value[0] = new_val; 759 value[0] = new_val;
721 value[1] = 0; 760 value[1] = 0;
722 err = snd_usb_ctl_msg(chip->dev, 761 down_read(&mixer->chip->shutdown_rwsem);
762 if (mixer->chip->shutdown)
763 err = -ENODEV;
764 else
765 err = snd_usb_ctl_msg(chip->dev,
723 usb_sndctrlpipe(chip->dev, 0), UAC_SET_CUR, 766 usb_sndctrlpipe(chip->dev, 0), UAC_SET_CUR,
724 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_OUT, 767 USB_RECIP_INTERFACE | USB_TYPE_CLASS | USB_DIR_OUT,
725 validx << 8, snd_usb_ctrl_intf(chip) | (id << 8), 768 validx << 8, snd_usb_ctrl_intf(chip) | (id << 8),
726 value, val_len); 769 value, val_len);
770 up_read(&mixer->chip->shutdown_rwsem);
727 if (err < 0) 771 if (err < 0)
728 return err; 772 return err;
729 773
diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
index 55e19e1b80e..ef6fa24fc47 100644
--- a/sound/usb/pcm.c
+++ b/sound/usb/pcm.c
@@ -71,6 +71,8 @@ static snd_pcm_uframes_t snd_usb_pcm_pointer(struct snd_pcm_substream *substream
71 unsigned int hwptr_done; 71 unsigned int hwptr_done;
72 72
73 subs = (struct snd_usb_substream *)substream->runtime->private_data; 73 subs = (struct snd_usb_substream *)substream->runtime->private_data;
74 if (subs->stream->chip->shutdown)
75 return SNDRV_PCM_POS_XRUN;
74 spin_lock(&subs->lock); 76 spin_lock(&subs->lock);
75 hwptr_done = subs->hwptr_done; 77 hwptr_done = subs->hwptr_done;
76 substream->runtime->delay = snd_usb_pcm_delay(subs, 78 substream->runtime->delay = snd_usb_pcm_delay(subs,
@@ -444,7 +446,6 @@ static int configure_endpoint(struct snd_usb_substream *subs)
444{ 446{
445 int ret; 447 int ret;
446 448
447 mutex_lock(&subs->stream->chip->shutdown_mutex);
448 /* format changed */ 449 /* format changed */
449 stop_endpoints(subs, 0, 0, 0); 450 stop_endpoints(subs, 0, 0, 0);
450 ret = snd_usb_endpoint_set_params(subs->data_endpoint, 451 ret = snd_usb_endpoint_set_params(subs->data_endpoint,
@@ -455,19 +456,16 @@ static int configure_endpoint(struct snd_usb_substream *subs)
455 subs->cur_audiofmt, 456 subs->cur_audiofmt,
456 subs->sync_endpoint); 457 subs->sync_endpoint);
457 if (ret < 0) 458 if (ret < 0)
458 goto unlock; 459 return ret;
459 460
460 if (subs->sync_endpoint) 461 if (subs->sync_endpoint)
461 ret = snd_usb_endpoint_set_params(subs->data_endpoint, 462 ret = snd_usb_endpoint_set_params(subs->sync_endpoint,
462 subs->pcm_format, 463 subs->pcm_format,
463 subs->channels, 464 subs->channels,
464 subs->period_bytes, 465 subs->period_bytes,
465 subs->cur_rate, 466 subs->cur_rate,
466 subs->cur_audiofmt, 467 subs->cur_audiofmt,
467 NULL); 468 NULL);
468
469unlock:
470 mutex_unlock(&subs->stream->chip->shutdown_mutex);
471 return ret; 469 return ret;
472} 470}
473 471
@@ -505,7 +503,13 @@ static int snd_usb_hw_params(struct snd_pcm_substream *substream,
505 return -EINVAL; 503 return -EINVAL;
506 } 504 }
507 505
508 if ((ret = set_format(subs, fmt)) < 0) 506 down_read(&subs->stream->chip->shutdown_rwsem);
507 if (subs->stream->chip->shutdown)
508 ret = -ENODEV;
509 else
510 ret = set_format(subs, fmt);
511 up_read(&subs->stream->chip->shutdown_rwsem);
512 if (ret < 0)
509 return ret; 513 return ret;
510 514
511 subs->interface = fmt->iface; 515 subs->interface = fmt->iface;
@@ -527,10 +531,12 @@ static int snd_usb_hw_free(struct snd_pcm_substream *substream)
527 subs->cur_audiofmt = NULL; 531 subs->cur_audiofmt = NULL;
528 subs->cur_rate = 0; 532 subs->cur_rate = 0;
529 subs->period_bytes = 0; 533 subs->period_bytes = 0;
530 mutex_lock(&subs->stream->chip->shutdown_mutex); 534 down_read(&subs->stream->chip->shutdown_rwsem);
531 stop_endpoints(subs, 0, 1, 1); 535 if (!subs->stream->chip->shutdown) {
532 deactivate_endpoints(subs); 536 stop_endpoints(subs, 0, 1, 1);
533 mutex_unlock(&subs->stream->chip->shutdown_mutex); 537 deactivate_endpoints(subs);
538 }
539 up_read(&subs->stream->chip->shutdown_rwsem);
534 return snd_pcm_lib_free_vmalloc_buffer(substream); 540 return snd_pcm_lib_free_vmalloc_buffer(substream);
535} 541}
536 542
@@ -552,12 +558,22 @@ static int snd_usb_pcm_prepare(struct snd_pcm_substream *substream)
552 return -ENXIO; 558 return -ENXIO;
553 } 559 }
554 560
555 if (snd_BUG_ON(!subs->data_endpoint)) 561 down_read(&subs->stream->chip->shutdown_rwsem);
556 return -EIO; 562 if (subs->stream->chip->shutdown) {
563 ret = -ENODEV;
564 goto unlock;
565 }
566 if (snd_BUG_ON(!subs->data_endpoint)) {
567 ret = -EIO;
568 goto unlock;
569 }
570
571 snd_usb_endpoint_sync_pending_stop(subs->sync_endpoint);
572 snd_usb_endpoint_sync_pending_stop(subs->data_endpoint);
557 573
558 ret = set_format(subs, subs->cur_audiofmt); 574 ret = set_format(subs, subs->cur_audiofmt);
559 if (ret < 0) 575 if (ret < 0)
560 return ret; 576 goto unlock;
561 577
562 iface = usb_ifnum_to_if(subs->dev, subs->cur_audiofmt->iface); 578 iface = usb_ifnum_to_if(subs->dev, subs->cur_audiofmt->iface);
563 alts = &iface->altsetting[subs->cur_audiofmt->altset_idx]; 579 alts = &iface->altsetting[subs->cur_audiofmt->altset_idx];
@@ -567,12 +583,12 @@ static int snd_usb_pcm_prepare(struct snd_pcm_substream *substream)
567 subs->cur_audiofmt, 583 subs->cur_audiofmt,
568 subs->cur_rate); 584 subs->cur_rate);
569 if (ret < 0) 585 if (ret < 0)
570 return ret; 586 goto unlock;
571 587
572 if (subs->need_setup_ep) { 588 if (subs->need_setup_ep) {
573 ret = configure_endpoint(subs); 589 ret = configure_endpoint(subs);
574 if (ret < 0) 590 if (ret < 0)
575 return ret; 591 goto unlock;
576 subs->need_setup_ep = false; 592 subs->need_setup_ep = false;
577 } 593 }
578 594
@@ -592,9 +608,11 @@ static int snd_usb_pcm_prepare(struct snd_pcm_substream *substream)
592 /* for playback, submit the URBs now; otherwise, the first hwptr_done 608 /* for playback, submit the URBs now; otherwise, the first hwptr_done
593 * updates for all URBs would happen at the same time when starting */ 609 * updates for all URBs would happen at the same time when starting */
594 if (subs->direction == SNDRV_PCM_STREAM_PLAYBACK) 610 if (subs->direction == SNDRV_PCM_STREAM_PLAYBACK)
595 return start_endpoints(subs, 1); 611 ret = start_endpoints(subs, 1);
596 612
597 return 0; 613 unlock:
614 up_read(&subs->stream->chip->shutdown_rwsem);
615 return ret;
598} 616}
599 617
600static struct snd_pcm_hardware snd_usb_hardware = 618static struct snd_pcm_hardware snd_usb_hardware =
@@ -647,7 +665,7 @@ static int hw_check_valid_format(struct snd_usb_substream *subs,
647 return 0; 665 return 0;
648 } 666 }
649 /* check whether the period time is >= the data packet interval */ 667 /* check whether the period time is >= the data packet interval */
650 if (snd_usb_get_speed(subs->dev) != USB_SPEED_FULL) { 668 if (subs->speed != USB_SPEED_FULL) {
651 ptime = 125 * (1 << fp->datainterval); 669 ptime = 125 * (1 << fp->datainterval);
652 if (ptime > pt->max || (ptime == pt->max && pt->openmax)) { 670 if (ptime > pt->max || (ptime == pt->max && pt->openmax)) {
653 hwc_debug(" > check: ptime %u > max %u\n", ptime, pt->max); 671 hwc_debug(" > check: ptime %u > max %u\n", ptime, pt->max);
@@ -925,7 +943,7 @@ static int setup_hw_info(struct snd_pcm_runtime *runtime, struct snd_usb_substre
925 return err; 943 return err;
926 944
927 param_period_time_if_needed = SNDRV_PCM_HW_PARAM_PERIOD_TIME; 945 param_period_time_if_needed = SNDRV_PCM_HW_PARAM_PERIOD_TIME;
928 if (snd_usb_get_speed(subs->dev) == USB_SPEED_FULL) 946 if (subs->speed == USB_SPEED_FULL)
929 /* full speed devices have fixed data packet interval */ 947 /* full speed devices have fixed data packet interval */
930 ptmin = 1000; 948 ptmin = 1000;
931 if (ptmin == 1000) 949 if (ptmin == 1000)
diff --git a/sound/usb/proc.c b/sound/usb/proc.c
index ebc1a5b5b3f..d218f763501 100644
--- a/sound/usb/proc.c
+++ b/sound/usb/proc.c
@@ -108,7 +108,7 @@ static void proc_dump_substream_formats(struct snd_usb_substream *subs, struct s
108 } 108 }
109 snd_iprintf(buffer, "\n"); 109 snd_iprintf(buffer, "\n");
110 } 110 }
111 if (snd_usb_get_speed(subs->dev) != USB_SPEED_FULL) 111 if (subs->speed != USB_SPEED_FULL)
112 snd_iprintf(buffer, " Data packet interval: %d us\n", 112 snd_iprintf(buffer, " Data packet interval: %d us\n",
113 125 * (1 << fp->datainterval)); 113 125 * (1 << fp->datainterval));
114 // snd_iprintf(buffer, " Max Packet Size = %d\n", fp->maxpacksize); 114 // snd_iprintf(buffer, " Max Packet Size = %d\n", fp->maxpacksize);
@@ -124,7 +124,7 @@ static void proc_dump_ep_status(struct snd_usb_substream *subs,
124 return; 124 return;
125 snd_iprintf(buffer, " Packet Size = %d\n", ep->curpacksize); 125 snd_iprintf(buffer, " Packet Size = %d\n", ep->curpacksize);
126 snd_iprintf(buffer, " Momentary freq = %u Hz (%#x.%04x)\n", 126 snd_iprintf(buffer, " Momentary freq = %u Hz (%#x.%04x)\n",
127 snd_usb_get_speed(subs->dev) == USB_SPEED_FULL 127 subs->speed == USB_SPEED_FULL
128 ? get_full_speed_hz(ep->freqm) 128 ? get_full_speed_hz(ep->freqm)
129 : get_high_speed_hz(ep->freqm), 129 : get_high_speed_hz(ep->freqm),
130 ep->freqm >> 16, ep->freqm & 0xffff); 130 ep->freqm >> 16, ep->freqm & 0xffff);
diff --git a/sound/usb/stream.c b/sound/usb/stream.c
index 083ed81160e..1de0c8c002a 100644
--- a/sound/usb/stream.c
+++ b/sound/usb/stream.c
@@ -90,6 +90,7 @@ static void snd_usb_init_substream(struct snd_usb_stream *as,
90 subs->direction = stream; 90 subs->direction = stream;
91 subs->dev = as->chip->dev; 91 subs->dev = as->chip->dev;
92 subs->txfr_quirk = as->chip->txfr_quirk; 92 subs->txfr_quirk = as->chip->txfr_quirk;
93 subs->speed = snd_usb_get_speed(subs->dev);
93 94
94 snd_usb_set_pcm_ops(as->pcm, stream); 95 snd_usb_set_pcm_ops(as->pcm, stream);
95 96
diff --git a/sound/usb/usbaudio.h b/sound/usb/usbaudio.h
index b8233ebe250..ef42797f56f 100644
--- a/sound/usb/usbaudio.h
+++ b/sound/usb/usbaudio.h
@@ -37,7 +37,7 @@ struct snd_usb_audio {
37 struct usb_interface *pm_intf; 37 struct usb_interface *pm_intf;
38 u32 usb_id; 38 u32 usb_id;
39 struct mutex mutex; 39 struct mutex mutex;
40 struct mutex shutdown_mutex; 40 struct rw_semaphore shutdown_rwsem;
41 unsigned int shutdown:1; 41 unsigned int shutdown:1;
42 unsigned int probing:1; 42 unsigned int probing:1;
43 unsigned int autosuspended:1; 43 unsigned int autosuspended:1;
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 47264b4652b..f2989c525e4 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -2602,6 +2602,9 @@ find_func_handler(struct pevent *pevent, char *func_name)
2602{ 2602{
2603 struct pevent_function_handler *func; 2603 struct pevent_function_handler *func;
2604 2604
2605 if (!pevent)
2606 return NULL;
2607
2605 for (func = pevent->func_handlers; func; func = func->next) { 2608 for (func = pevent->func_handlers; func; func = func->next) {
2606 if (strcmp(func->name, func_name) == 0) 2609 if (strcmp(func->name, func_name) == 0)
2607 break; 2610 break;
@@ -4938,6 +4941,9 @@ enum pevent_errno __pevent_parse_format(struct event_format **eventp,
4938 goto event_alloc_failed; 4941 goto event_alloc_failed;
4939 } 4942 }
4940 4943
4944 /* Add pevent to event so that it can be referenced */
4945 event->pevent = pevent;
4946
4941 ret = event_read_format(event); 4947 ret = event_read_format(event);
4942 if (ret < 0) { 4948 if (ret < 0) {
4943 ret = PEVENT_ERRNO__READ_FORMAT_FAILED; 4949 ret = PEVENT_ERRNO__READ_FORMAT_FAILED;
@@ -5041,9 +5047,6 @@ enum pevent_errno pevent_parse_event(struct pevent *pevent, const char *buf,
5041 if (event == NULL) 5047 if (event == NULL)
5042 return ret; 5048 return ret;
5043 5049
5044 /* Add pevent to event so that it can be referenced */
5045 event->pevent = pevent;
5046
5047 if (add_event(pevent, event)) { 5050 if (add_event(pevent, event)) {
5048 ret = PEVENT_ERRNO__MEM_ALLOC_FAILED; 5051 ret = PEVENT_ERRNO__MEM_ALLOC_FAILED;
5049 goto event_add_failed; 5052 goto event_add_failed;
diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c
index ad17855528f..5ea4326ad11 100644
--- a/tools/lib/traceevent/parse-filter.c
+++ b/tools/lib/traceevent/parse-filter.c
@@ -209,7 +209,16 @@ static void free_arg(struct filter_arg *arg)
209 switch (arg->type) { 209 switch (arg->type) {
210 case FILTER_ARG_NONE: 210 case FILTER_ARG_NONE:
211 case FILTER_ARG_BOOLEAN: 211 case FILTER_ARG_BOOLEAN:
212 break;
213
212 case FILTER_ARG_NUM: 214 case FILTER_ARG_NUM:
215 free_arg(arg->num.left);
216 free_arg(arg->num.right);
217 break;
218
219 case FILTER_ARG_EXP:
220 free_arg(arg->exp.left);
221 free_arg(arg->exp.right);
213 break; 222 break;
214 223
215 case FILTER_ARG_STR: 224 case FILTER_ARG_STR:
@@ -218,6 +227,12 @@ static void free_arg(struct filter_arg *arg)
218 free(arg->str.buffer); 227 free(arg->str.buffer);
219 break; 228 break;
220 229
230 case FILTER_ARG_VALUE:
231 if (arg->value.type == FILTER_STRING ||
232 arg->value.type == FILTER_CHAR)
233 free(arg->value.str);
234 break;
235
221 case FILTER_ARG_OP: 236 case FILTER_ARG_OP:
222 free_arg(arg->op.left); 237 free_arg(arg->op.left);
223 free_arg(arg->op.right); 238 free_arg(arg->op.right);
diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index f7c968ad517..00deed4d615 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -184,9 +184,22 @@ SCRIPT_SH += perf-archive.sh
184grep-libs = $(filter -l%,$(1)) 184grep-libs = $(filter -l%,$(1))
185strip-libs = $(filter-out -l%,$(1)) 185strip-libs = $(filter-out -l%,$(1))
186 186
187TRACE_EVENT_DIR = ../lib/traceevent/
188
189ifneq ($(OUTPUT),)
190 TE_PATH=$(OUTPUT)
191else
192 TE_PATH=$(TRACE_EVENT_DIR)
193endif
194
195LIBTRACEEVENT = $(TE_PATH)libtraceevent.a
196TE_LIB := -L$(TE_PATH) -ltraceevent
197
187PYTHON_EXT_SRCS := $(shell grep -v ^\# util/python-ext-sources) 198PYTHON_EXT_SRCS := $(shell grep -v ^\# util/python-ext-sources)
188PYTHON_EXT_DEPS := util/python-ext-sources util/setup.py 199PYTHON_EXT_DEPS := util/python-ext-sources util/setup.py
189 200
201export LIBTRACEEVENT
202
190$(OUTPUT)python/perf.so: $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS) 203$(OUTPUT)python/perf.so: $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS)
191 $(QUIET_GEN)CFLAGS='$(BASIC_CFLAGS)' $(PYTHON_WORD) util/setup.py \ 204 $(QUIET_GEN)CFLAGS='$(BASIC_CFLAGS)' $(PYTHON_WORD) util/setup.py \
192 --quiet build_ext; \ 205 --quiet build_ext; \
@@ -198,17 +211,6 @@ $(OUTPUT)python/perf.so: $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS)
198 211
199SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) 212SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH))
200 213
201TRACE_EVENT_DIR = ../lib/traceevent/
202
203ifneq ($(OUTPUT),)
204 TE_PATH=$(OUTPUT)
205else
206 TE_PATH=$(TRACE_EVENT_DIR)
207endif
208
209LIBTRACEEVENT = $(TE_PATH)libtraceevent.a
210TE_LIB := -L$(TE_PATH) -ltraceevent
211
212# 214#
213# Single 'perf' binary right now: 215# Single 'perf' binary right now:
214# 216#
diff --git a/tools/perf/builtin-help.c b/tools/perf/builtin-help.c
index 411ee5664e9..178b88ae3d2 100644
--- a/tools/perf/builtin-help.c
+++ b/tools/perf/builtin-help.c
@@ -414,7 +414,7 @@ static int show_html_page(const char *perf_cmd)
414int cmd_help(int argc, const char **argv, const char *prefix __maybe_unused) 414int cmd_help(int argc, const char **argv, const char *prefix __maybe_unused)
415{ 415{
416 bool show_all = false; 416 bool show_all = false;
417 enum help_format help_format = HELP_FORMAT_NONE; 417 enum help_format help_format = HELP_FORMAT_MAN;
418 struct option builtin_help_options[] = { 418 struct option builtin_help_options[] = {
419 OPT_BOOLEAN('a', "all", &show_all, "print all available commands"), 419 OPT_BOOLEAN('a', "all", &show_all, "print all available commands"),
420 OPT_SET_UINT('m', "man", &help_format, "show man page", HELP_FORMAT_MAN), 420 OPT_SET_UINT('m', "man", &help_format, "show man page", HELP_FORMAT_MAN),
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index dec8ced61fb..7aaee39f677 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -56,6 +56,10 @@ static int trace__read_syscall_info(struct trace *trace, int id)
56{ 56{
57 char tp_name[128]; 57 char tp_name[128];
58 struct syscall *sc; 58 struct syscall *sc;
59 const char *name = audit_syscall_to_name(id, trace->audit_machine);
60
61 if (name == NULL)
62 return -1;
59 63
60 if (id > trace->syscalls.max) { 64 if (id > trace->syscalls.max) {
61 struct syscall *nsyscalls = realloc(trace->syscalls.table, (id + 1) * sizeof(*sc)); 65 struct syscall *nsyscalls = realloc(trace->syscalls.table, (id + 1) * sizeof(*sc));
@@ -75,11 +79,8 @@ static int trace__read_syscall_info(struct trace *trace, int id)
75 } 79 }
76 80
77 sc = trace->syscalls.table + id; 81 sc = trace->syscalls.table + id;
78 sc->name = audit_syscall_to_name(id, trace->audit_machine); 82 sc->name = name;
79 if (sc->name == NULL) 83 sc->fmt = syscall_fmt__find(sc->name);
80 return -1;
81
82 sc->fmt = syscall_fmt__find(sc->name);
83 84
84 snprintf(tp_name, sizeof(tp_name), "sys_enter_%s", sc->name); 85 snprintf(tp_name, sizeof(tp_name), "sys_enter_%s", sc->name);
85 sc->tp_format = event_format__new("syscalls", tp_name); 86 sc->tp_format = event_format__new("syscalls", tp_name);
@@ -267,6 +268,13 @@ again:
267 if (evlist->threads->map[0] == -1 || evlist->threads->nr > 1) 268 if (evlist->threads->map[0] == -1 || evlist->threads->nr > 1)
268 printf("%d ", sample.tid); 269 printf("%d ", sample.tid);
269 270
271 if (sample.raw_data == NULL) {
272 printf("%s sample with no payload for tid: %d, cpu %d, raw_size=%d, skipping...\n",
273 perf_evsel__name(evsel), sample.tid,
274 sample.cpu, sample.raw_size);
275 continue;
276 }
277
270 handler = evsel->handler.func; 278 handler = evsel->handler.func;
271 handler(trace, evsel, &sample); 279 handler(trace, evsel, &sample);
272 } 280 }
diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index 276287783a0..c50985eaec4 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -57,7 +57,7 @@ void get_term_dimensions(struct winsize *ws);
57#endif 57#endif
58 58
59#ifdef __sparc__ 59#ifdef __sparc__
60#include "../../arch/sparc/include/asm/unistd.h" 60#include "../../arch/sparc/include/uapi/asm/unistd.h"
61#define rmb() asm volatile("":::"memory") 61#define rmb() asm volatile("":::"memory")
62#define cpu_relax() asm volatile("":::"memory") 62#define cpu_relax() asm volatile("":::"memory")
63#define CPUINFO_PROC "cpu" 63#define CPUINFO_PROC "cpu"
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c
index 0568536ecf6..ef2f93ca749 100644
--- a/tools/perf/ui/browsers/hists.c
+++ b/tools/perf/ui/browsers/hists.c
@@ -610,6 +610,7 @@ static int hist_browser__show_entry(struct hist_browser *browser,
610 char folded_sign = ' '; 610 char folded_sign = ' ';
611 bool current_entry = ui_browser__is_current_entry(&browser->b, row); 611 bool current_entry = ui_browser__is_current_entry(&browser->b, row);
612 off_t row_offset = entry->row_offset; 612 off_t row_offset = entry->row_offset;
613 bool first = true;
613 614
614 if (current_entry) { 615 if (current_entry) {
615 browser->he_selection = entry; 616 browser->he_selection = entry;
@@ -633,10 +634,11 @@ static int hist_browser__show_entry(struct hist_browser *browser,
633 if (!perf_hpp__format[i].cond) 634 if (!perf_hpp__format[i].cond)
634 continue; 635 continue;
635 636
636 if (i) { 637 if (!first) {
637 slsmg_printf(" "); 638 slsmg_printf(" ");
638 width -= 2; 639 width -= 2;
639 } 640 }
641 first = false;
640 642
641 if (perf_hpp__format[i].color) { 643 if (perf_hpp__format[i].color) {
642 hpp.ptr = &percent; 644 hpp.ptr = &percent;
@@ -645,7 +647,7 @@ static int hist_browser__show_entry(struct hist_browser *browser,
645 647
646 ui_browser__set_percent_color(&browser->b, percent, current_entry); 648 ui_browser__set_percent_color(&browser->b, percent, current_entry);
647 649
648 if (i == 0 && symbol_conf.use_callchain) { 650 if (i == PERF_HPP__OVERHEAD && symbol_conf.use_callchain) {
649 slsmg_printf("%c ", folded_sign); 651 slsmg_printf("%c ", folded_sign);
650 width -= 2; 652 width -= 2;
651 } 653 }
diff --git a/tools/perf/util/parse-events-test.c b/tools/perf/util/parse-events-test.c
index 28c18d1d52c..516ecd9ddd6 100644
--- a/tools/perf/util/parse-events-test.c
+++ b/tools/perf/util/parse-events-test.c
@@ -513,7 +513,8 @@ static int test__group1(struct perf_evlist *evlist)
513 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 513 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
514 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); 514 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel);
515 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 515 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
516 TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); 516 /* use of precise requires exclude_guest */
517 TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest);
517 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 518 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
518 TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 2); 519 TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 2);
519 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); 520 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
@@ -599,7 +600,8 @@ static int test__group3(struct perf_evlist *evlist __maybe_unused)
599 TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); 600 TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user);
600 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 601 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
601 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 602 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
602 TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); 603 /* use of precise requires exclude_guest */
604 TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest);
603 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 605 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
604 TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 3); 606 TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 3);
605 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); 607 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
@@ -662,7 +664,8 @@ static int test__group4(struct perf_evlist *evlist __maybe_unused)
662 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user); 664 TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
663 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel); 665 TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel);
664 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 666 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
665 TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); 667 /* use of precise requires exclude_guest */
668 TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest);
666 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 669 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
667 TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 1); 670 TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 1);
668 TEST_ASSERT_VAL("wrong group name", !evsel->group_name); 671 TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
@@ -676,7 +679,8 @@ static int test__group4(struct perf_evlist *evlist __maybe_unused)
676 TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user); 679 TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user);
677 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel); 680 TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
678 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv); 681 TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
679 TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest); 682 /* use of precise requires exclude_guest */
683 TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest);
680 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host); 684 TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
681 TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 2); 685 TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 2);
682 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader); 686 TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index aed38e4b9df..75c7b0fca6d 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -690,6 +690,9 @@ static int get_event_modifier(struct event_modifier *mod, char *str,
690 eH = 0; 690 eH = 0;
691 } else if (*str == 'p') { 691 } else if (*str == 'p') {
692 precise++; 692 precise++;
693 /* use of precise requires exclude_guest */
694 if (!exclude_GH)
695 eG = 1;
693 } else 696 } else
694 break; 697 break;
695 698
diff --git a/tools/perf/util/setup.py b/tools/perf/util/setup.py
index d0f9f29cf18..73d51026978 100644
--- a/tools/perf/util/setup.py
+++ b/tools/perf/util/setup.py
@@ -23,6 +23,7 @@ cflags += getenv('CFLAGS', '').split()
23 23
24build_lib = getenv('PYTHON_EXTBUILD_LIB') 24build_lib = getenv('PYTHON_EXTBUILD_LIB')
25build_tmp = getenv('PYTHON_EXTBUILD_TMP') 25build_tmp = getenv('PYTHON_EXTBUILD_TMP')
26libtraceevent = getenv('LIBTRACEEVENT')
26 27
27ext_sources = [f.strip() for f in file('util/python-ext-sources') 28ext_sources = [f.strip() for f in file('util/python-ext-sources')
28 if len(f.strip()) > 0 and f[0] != '#'] 29 if len(f.strip()) > 0 and f[0] != '#']
@@ -31,6 +32,7 @@ perf = Extension('perf',
31 sources = ext_sources, 32 sources = ext_sources,
32 include_dirs = ['util/include'], 33 include_dirs = ['util/include'],
33 extra_compile_args = cflags, 34 extra_compile_args = cflags,
35 extra_objects = [libtraceevent],
34 ) 36 )
35 37
36setup(name='perf', 38setup(name='perf',
diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
index b5b1b921196..cfd1c0feb32 100644
--- a/tools/perf/util/sort.c
+++ b/tools/perf/util/sort.c
@@ -260,6 +260,12 @@ static int hist_entry__srcline_snprintf(struct hist_entry *self, char *bf,
260 if (path != NULL) 260 if (path != NULL)
261 goto out_path; 261 goto out_path;
262 262
263 if (!self->ms.map)
264 goto out_ip;
265
266 if (!strncmp(self->ms.map->dso->long_name, "/tmp/perf-", 10))
267 goto out_ip;
268
263 snprintf(cmd, sizeof(cmd), "addr2line -e %s %016" PRIx64, 269 snprintf(cmd, sizeof(cmd), "addr2line -e %s %016" PRIx64,
264 self->ms.map->dso->long_name, self->ip); 270 self->ms.map->dso->long_name, self->ip);
265 fp = popen(cmd, "r"); 271 fp = popen(cmd, "r");
diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
index fb4b7ea6752..8b3e5939afb 100644
--- a/tools/perf/util/thread.c
+++ b/tools/perf/util/thread.c
@@ -39,7 +39,6 @@ int thread__set_comm(struct thread *self, const char *comm)
39 err = self->comm == NULL ? -ENOMEM : 0; 39 err = self->comm == NULL ? -ENOMEM : 0;
40 if (!err) { 40 if (!err) {
41 self->comm_set = true; 41 self->comm_set = true;
42 map_groups__flush(&self->mg);
43 } 42 }
44 return err; 43 return err;
45} 44}
diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index 2655ae9a3ad..ea095abbe97 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -206,8 +206,10 @@ int get_msr(int cpu, off_t offset, unsigned long long *msr)
206 retval = pread(fd, msr, sizeof *msr, offset); 206 retval = pread(fd, msr, sizeof *msr, offset);
207 close(fd); 207 close(fd);
208 208
209 if (retval != sizeof *msr) 209 if (retval != sizeof *msr) {
210 fprintf(stderr, "%s offset 0x%zx read failed\n", pathname, offset);
210 return -1; 211 return -1;
212 }
211 213
212 return 0; 214 return 0;
213} 215}
@@ -1101,7 +1103,9 @@ void turbostat_loop()
1101 1103
1102restart: 1104restart:
1103 retval = for_all_cpus(get_counters, EVEN_COUNTERS); 1105 retval = for_all_cpus(get_counters, EVEN_COUNTERS);
1104 if (retval) { 1106 if (retval < -1) {
1107 exit(retval);
1108 } else if (retval == -1) {
1105 re_initialize(); 1109 re_initialize();
1106 goto restart; 1110 goto restart;
1107 } 1111 }
@@ -1114,7 +1118,9 @@ restart:
1114 } 1118 }
1115 sleep(interval_sec); 1119 sleep(interval_sec);
1116 retval = for_all_cpus(get_counters, ODD_COUNTERS); 1120 retval = for_all_cpus(get_counters, ODD_COUNTERS);
1117 if (retval) { 1121 if (retval < -1) {
1122 exit(retval);
1123 } else if (retval == -1) {
1118 re_initialize(); 1124 re_initialize();
1119 goto restart; 1125 goto restart;
1120 } 1126 }
@@ -1126,7 +1132,9 @@ restart:
1126 flush_stdout(); 1132 flush_stdout();
1127 sleep(interval_sec); 1133 sleep(interval_sec);
1128 retval = for_all_cpus(get_counters, EVEN_COUNTERS); 1134 retval = for_all_cpus(get_counters, EVEN_COUNTERS);
1129 if (retval) { 1135 if (retval < -1) {
1136 exit(retval);
1137 } else if (retval == -1) {
1130 re_initialize(); 1138 re_initialize();
1131 goto restart; 1139 goto restart;
1132 } 1140 }
@@ -1545,8 +1553,11 @@ void turbostat_init()
1545int fork_it(char **argv) 1553int fork_it(char **argv)
1546{ 1554{
1547 pid_t child_pid; 1555 pid_t child_pid;
1556 int status;
1548 1557
1549 for_all_cpus(get_counters, EVEN_COUNTERS); 1558 status = for_all_cpus(get_counters, EVEN_COUNTERS);
1559 if (status)
1560 exit(status);
1550 /* clear affinity side-effect of get_counters() */ 1561 /* clear affinity side-effect of get_counters() */
1551 sched_setaffinity(0, cpu_present_setsize, cpu_present_set); 1562 sched_setaffinity(0, cpu_present_setsize, cpu_present_set);
1552 gettimeofday(&tv_even, (struct timezone *)NULL); 1563 gettimeofday(&tv_even, (struct timezone *)NULL);
@@ -1556,7 +1567,6 @@ int fork_it(char **argv)
1556 /* child */ 1567 /* child */
1557 execvp(argv[0], argv); 1568 execvp(argv[0], argv);
1558 } else { 1569 } else {
1559 int status;
1560 1570
1561 /* parent */ 1571 /* parent */
1562 if (child_pid == -1) { 1572 if (child_pid == -1) {
@@ -1568,7 +1578,7 @@ int fork_it(char **argv)
1568 signal(SIGQUIT, SIG_IGN); 1578 signal(SIGQUIT, SIG_IGN);
1569 if (waitpid(child_pid, &status, 0) == -1) { 1579 if (waitpid(child_pid, &status, 0) == -1) {
1570 perror("wait"); 1580 perror("wait");
1571 exit(1); 1581 exit(status);
1572 } 1582 }
1573 } 1583 }
1574 /* 1584 /*
@@ -1585,7 +1595,7 @@ int fork_it(char **argv)
1585 1595
1586 fprintf(stderr, "%.6f sec\n", tv_delta.tv_sec + tv_delta.tv_usec/1000000.0); 1596 fprintf(stderr, "%.6f sec\n", tv_delta.tv_sec + tv_delta.tv_usec/1000000.0);
1587 1597
1588 return 0; 1598 return status;
1589} 1599}
1590 1600
1591void cmdline(int argc, char **argv) 1601void cmdline(int argc, char **argv)
@@ -1594,7 +1604,7 @@ void cmdline(int argc, char **argv)
1594 1604
1595 progname = argv[0]; 1605 progname = argv[0];
1596 1606
1597 while ((opt = getopt(argc, argv, "+pPSvisc:sC:m:M:")) != -1) { 1607 while ((opt = getopt(argc, argv, "+pPSvi:sc:sC:m:M:")) != -1) {
1598 switch (opt) { 1608 switch (opt) {
1599 case 'p': 1609 case 'p':
1600 show_core_only++; 1610 show_core_only++;
diff --git a/tools/testing/ktest/ktest.pl b/tools/testing/ktest/ktest.pl
index b51d787176d..c7ba7614061 100755
--- a/tools/testing/ktest/ktest.pl
+++ b/tools/testing/ktest/ktest.pl
@@ -1740,8 +1740,10 @@ sub install {
1740 open(IN, "$output_config") or dodie("Can't read config file"); 1740 open(IN, "$output_config") or dodie("Can't read config file");
1741 while (<IN>) { 1741 while (<IN>) {
1742 if (/CONFIG_MODULES(=y)?/) { 1742 if (/CONFIG_MODULES(=y)?/) {
1743 $install_mods = 1 if (defined($1)); 1743 if (defined($1)) {
1744 last; 1744 $install_mods = 1;
1745 last;
1746 }
1745 } 1747 }
1746 } 1748 }
1747 close(IN); 1749 close(IN);
diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
index 43480149119..85baf11e2ac 100644
--- a/tools/testing/selftests/Makefile
+++ b/tools/testing/selftests/Makefile
@@ -1,4 +1,4 @@
1TARGETS = breakpoints kcmp mqueue vm cpu-hotplug memory-hotplug epoll 1TARGETS = breakpoints kcmp mqueue vm cpu-hotplug memory-hotplug
2 2
3all: 3all:
4 for TARGET in $(TARGETS); do \ 4 for TARGET in $(TARGETS); do \
diff --git a/tools/testing/selftests/epoll/Makefile b/tools/testing/selftests/epoll/Makefile
deleted file mode 100644
index 19806ed62f5..00000000000
--- a/tools/testing/selftests/epoll/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
1# Makefile for epoll selftests
2
3all: test_epoll
4%: %.c
5 gcc -pthread -g -o $@ $^
6
7run_tests: all
8 ./test_epoll
9
10clean:
11 $(RM) test_epoll
diff --git a/tools/testing/selftests/epoll/test_epoll.c b/tools/testing/selftests/epoll/test_epoll.c
deleted file mode 100644
index e0fcff1e833..00000000000
--- a/tools/testing/selftests/epoll/test_epoll.c
+++ /dev/null
@@ -1,344 +0,0 @@
1/*
2 * tools/testing/selftests/epoll/test_epoll.c
3 *
4 * Copyright 2012 Adobe Systems Incorporated
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 as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * Paton J. Lewis <palewis@adobe.com>
12 *
13 */
14
15#include <errno.h>
16#include <fcntl.h>
17#include <pthread.h>
18#include <stdio.h>
19#include <stdlib.h>
20#include <unistd.h>
21#include <sys/epoll.h>
22#include <sys/socket.h>
23
24/*
25 * A pointer to an epoll_item_private structure will be stored in the epoll
26 * item's event structure so that we can get access to the epoll_item_private
27 * data after calling epoll_wait:
28 */
29struct epoll_item_private {
30 int index; /* Position of this struct within the epoll_items array. */
31 int fd;
32 uint32_t events;
33 pthread_mutex_t mutex; /* Guards the following variables... */
34 int stop;
35 int status; /* Stores any error encountered while handling item. */
36 /* The following variable allows us to test whether we have encountered
37 a problem while attempting to cancel and delete the associated
38 event. When the test program exits, 'deleted' should be exactly
39 one. If it is greater than one, then the failed test reflects a real
40 world situation where we would have tried to access the epoll item's
41 private data after deleting it: */
42 int deleted;
43};
44
45struct epoll_item_private *epoll_items;
46
47/*
48 * Delete the specified item from the epoll set. In a real-world secneario this
49 * is where we would free the associated data structure, but in this testing
50 * environment we retain the structure so that we can test for double-deletion:
51 */
52void delete_item(int index)
53{
54 __sync_fetch_and_add(&epoll_items[index].deleted, 1);
55}
56
57/*
58 * A pointer to a read_thread_data structure will be passed as the argument to
59 * each read thread:
60 */
61struct read_thread_data {
62 int stop;
63 int status; /* Indicates any error encountered by the read thread. */
64 int epoll_set;
65};
66
67/*
68 * The function executed by the read threads:
69 */
70void *read_thread_function(void *function_data)
71{
72 struct read_thread_data *thread_data =
73 (struct read_thread_data *)function_data;
74 struct epoll_event event_data;
75 struct epoll_item_private *item_data;
76 char socket_data;
77
78 /* Handle events until we encounter an error or this thread's 'stop'
79 condition is set: */
80 while (1) {
81 int result = epoll_wait(thread_data->epoll_set,
82 &event_data,
83 1, /* Number of desired events */
84 1000); /* Timeout in ms */
85 if (result < 0) {
86 /* Breakpoints signal all threads. Ignore that while
87 debugging: */
88 if (errno == EINTR)
89 continue;
90 thread_data->status = errno;
91 return 0;
92 } else if (thread_data->stop)
93 return 0;
94 else if (result == 0) /* Timeout */
95 continue;
96
97 /* We need the mutex here because checking for the stop
98 condition and re-enabling the epoll item need to be done
99 together as one atomic operation when EPOLL_CTL_DISABLE is
100 available: */
101 item_data = (struct epoll_item_private *)event_data.data.ptr;
102 pthread_mutex_lock(&item_data->mutex);
103
104 /* Remove the item from the epoll set if we want to stop
105 handling that event: */
106 if (item_data->stop)
107 delete_item(item_data->index);
108 else {
109 /* Clear the data that was written to the other end of
110 our non-blocking socket: */
111 do {
112 if (read(item_data->fd, &socket_data, 1) < 1) {
113 if ((errno == EAGAIN) ||
114 (errno == EWOULDBLOCK))
115 break;
116 else
117 goto error_unlock;
118 }
119 } while (item_data->events & EPOLLET);
120
121 /* The item was one-shot, so re-enable it: */
122 event_data.events = item_data->events;
123 if (epoll_ctl(thread_data->epoll_set,
124 EPOLL_CTL_MOD,
125 item_data->fd,
126 &event_data) < 0)
127 goto error_unlock;
128 }
129
130 pthread_mutex_unlock(&item_data->mutex);
131 }
132
133error_unlock:
134 thread_data->status = item_data->status = errno;
135 pthread_mutex_unlock(&item_data->mutex);
136 return 0;
137}
138
139/*
140 * A pointer to a write_thread_data structure will be passed as the argument to
141 * the write thread:
142 */
143struct write_thread_data {
144 int stop;
145 int status; /* Indicates any error encountered by the write thread. */
146 int n_fds;
147 int *fds;
148};
149
150/*
151 * The function executed by the write thread. It writes a single byte to each
152 * socket in turn until the stop condition for this thread is set. If writing to
153 * a socket would block (i.e. errno was EAGAIN), we leave that socket alone for
154 * the moment and just move on to the next socket in the list. We don't care
155 * about the order in which we deliver events to the epoll set. In fact we don't
156 * care about the data we're writing to the pipes at all; we just want to
157 * trigger epoll events:
158 */
159void *write_thread_function(void *function_data)
160{
161 const char data = 'X';
162 int index;
163 struct write_thread_data *thread_data =
164 (struct write_thread_data *)function_data;
165 while (!write_thread_data->stop)
166 for (index = 0;
167 !thread_data->stop && (index < thread_data->n_fds);
168 ++index)
169 if ((write(thread_data->fds[index], &data, 1) < 1) &&
170 (errno != EAGAIN) &&
171 (errno != EWOULDBLOCK)) {
172 write_thread_data->status = errno;
173 return;
174 }
175}
176
177/*
178 * Arguments are currently ignored:
179 */
180int main(int argc, char **argv)
181{
182 const int n_read_threads = 100;
183 const int n_epoll_items = 500;
184 int index;
185 int epoll_set = epoll_create1(0);
186 struct write_thread_data write_thread_data = {
187 0, 0, n_epoll_items, malloc(n_epoll_items * sizeof(int))
188 };
189 struct read_thread_data *read_thread_data =
190 malloc(n_read_threads * sizeof(struct read_thread_data));
191 pthread_t *read_threads = malloc(n_read_threads * sizeof(pthread_t));
192 pthread_t write_thread;
193
194 printf("-----------------\n");
195 printf("Runing test_epoll\n");
196 printf("-----------------\n");
197
198 epoll_items = malloc(n_epoll_items * sizeof(struct epoll_item_private));
199
200 if (epoll_set < 0 || epoll_items == 0 || write_thread_data.fds == 0 ||
201 read_thread_data == 0 || read_threads == 0)
202 goto error;
203
204 if (sysconf(_SC_NPROCESSORS_ONLN) < 2) {
205 printf("Error: please run this test on a multi-core system.\n");
206 goto error;
207 }
208
209 /* Create the socket pairs and epoll items: */
210 for (index = 0; index < n_epoll_items; ++index) {
211 int socket_pair[2];
212 struct epoll_event event_data;
213 if (socketpair(AF_UNIX,
214 SOCK_STREAM | SOCK_NONBLOCK,
215 0,
216 socket_pair) < 0)
217 goto error;
218 write_thread_data.fds[index] = socket_pair[0];
219 epoll_items[index].index = index;
220 epoll_items[index].fd = socket_pair[1];
221 if (pthread_mutex_init(&epoll_items[index].mutex, NULL) != 0)
222 goto error;
223 /* We always use EPOLLONESHOT because this test is currently
224 structured to demonstrate the need for EPOLL_CTL_DISABLE,
225 which only produces useful information in the EPOLLONESHOT
226 case (without EPOLLONESHOT, calling epoll_ctl with
227 EPOLL_CTL_DISABLE will never return EBUSY). If support for
228 testing events without EPOLLONESHOT is desired, it should
229 probably be implemented in a separate unit test. */
230 epoll_items[index].events = EPOLLIN | EPOLLONESHOT;
231 if (index < n_epoll_items / 2)
232 epoll_items[index].events |= EPOLLET;
233 epoll_items[index].stop = 0;
234 epoll_items[index].status = 0;
235 epoll_items[index].deleted = 0;
236 event_data.events = epoll_items[index].events;
237 event_data.data.ptr = &epoll_items[index];
238 if (epoll_ctl(epoll_set,
239 EPOLL_CTL_ADD,
240 epoll_items[index].fd,
241 &event_data) < 0)
242 goto error;
243 }
244
245 /* Create and start the read threads: */
246 for (index = 0; index < n_read_threads; ++index) {
247 read_thread_data[index].stop = 0;
248 read_thread_data[index].status = 0;
249 read_thread_data[index].epoll_set = epoll_set;
250 if (pthread_create(&read_threads[index],
251 NULL,
252 read_thread_function,
253 &read_thread_data[index]) != 0)
254 goto error;
255 }
256
257 if (pthread_create(&write_thread,
258 NULL,
259 write_thread_function,
260 &write_thread_data) != 0)
261 goto error;
262
263 /* Cancel all event pollers: */
264#ifdef EPOLL_CTL_DISABLE
265 for (index = 0; index < n_epoll_items; ++index) {
266 pthread_mutex_lock(&epoll_items[index].mutex);
267 ++epoll_items[index].stop;
268 if (epoll_ctl(epoll_set,
269 EPOLL_CTL_DISABLE,
270 epoll_items[index].fd,
271 NULL) == 0)
272 delete_item(index);
273 else if (errno != EBUSY) {
274 pthread_mutex_unlock(&epoll_items[index].mutex);
275 goto error;
276 }
277 /* EBUSY means events were being handled; allow the other thread
278 to delete the item. */
279 pthread_mutex_unlock(&epoll_items[index].mutex);
280 }
281#else
282 for (index = 0; index < n_epoll_items; ++index) {
283 pthread_mutex_lock(&epoll_items[index].mutex);
284 ++epoll_items[index].stop;
285 pthread_mutex_unlock(&epoll_items[index].mutex);
286 /* Wait in case a thread running read_thread_function is
287 currently executing code between epoll_wait and
288 pthread_mutex_lock with this item. Note that a longer delay
289 would make double-deletion less likely (at the expense of
290 performance), but there is no guarantee that any delay would
291 ever be sufficient. Note also that we delete all event
292 pollers at once for testing purposes, but in a real-world
293 environment we are likely to want to be able to cancel event
294 pollers at arbitrary times. Therefore we can't improve this
295 situation by just splitting this loop into two loops
296 (i.e. signal 'stop' for all items, sleep, and then delete all
297 items). We also can't fix the problem via EPOLL_CTL_DEL
298 because that command can't prevent the case where some other
299 thread is executing read_thread_function within the region
300 mentioned above: */
301 usleep(1);
302 pthread_mutex_lock(&epoll_items[index].mutex);
303 if (!epoll_items[index].deleted)
304 delete_item(index);
305 pthread_mutex_unlock(&epoll_items[index].mutex);
306 }
307#endif
308
309 /* Shut down the read threads: */
310 for (index = 0; index < n_read_threads; ++index)
311 __sync_fetch_and_add(&read_thread_data[index].stop, 1);
312 for (index = 0; index < n_read_threads; ++index) {
313 if (pthread_join(read_threads[index], NULL) != 0)
314 goto error;
315 if (read_thread_data[index].status)
316 goto error;
317 }
318
319 /* Shut down the write thread: */
320 __sync_fetch_and_add(&write_thread_data.stop, 1);
321 if ((pthread_join(write_thread, NULL) != 0) || write_thread_data.status)
322 goto error;
323
324 /* Check for final error conditions: */
325 for (index = 0; index < n_epoll_items; ++index) {
326 if (epoll_items[index].status != 0)
327 goto error;
328 if (pthread_mutex_destroy(&epoll_items[index].mutex) < 0)
329 goto error;
330 }
331 for (index = 0; index < n_epoll_items; ++index)
332 if (epoll_items[index].deleted != 1) {
333 printf("Error: item data deleted %1d times.\n",
334 epoll_items[index].deleted);
335 goto error;
336 }
337
338 printf("[PASS]\n");
339 return 0;
340
341 error:
342 printf("[FAIL]\n");
343 return errno;
344}
diff --git a/tools/vm/page-types.c b/tools/vm/page-types.c
index cd1b03e8089..b76edf2f833 100644
--- a/tools/vm/page-types.c
+++ b/tools/vm/page-types.c
@@ -35,7 +35,7 @@
35#include <sys/mount.h> 35#include <sys/mount.h>
36#include <sys/statfs.h> 36#include <sys/statfs.h>
37#include "../../include/uapi/linux/magic.h" 37#include "../../include/uapi/linux/magic.h"
38#include "../../include/linux/kernel-page-flags.h" 38#include "../../include/uapi/linux/kernel-page-flags.h"
39 39
40 40
41#ifndef MAX_PATH 41#ifndef MAX_PATH
diff --git a/usr/gen_init_cpio.c b/usr/gen_init_cpio.c
index af0f22fb1ef..aca6edcbbc6 100644
--- a/usr/gen_init_cpio.c
+++ b/usr/gen_init_cpio.c
@@ -303,7 +303,7 @@ static int cpio_mkfile(const char *name, const char *location,
303 int retval; 303 int retval;
304 int rc = -1; 304 int rc = -1;
305 int namesize; 305 int namesize;
306 int i; 306 unsigned int i;
307 307
308 mode |= S_IFREG; 308 mode |= S_IFREG;
309 309
@@ -381,25 +381,28 @@ error:
381 381
382static char *cpio_replace_env(char *new_location) 382static char *cpio_replace_env(char *new_location)
383{ 383{
384 char expanded[PATH_MAX + 1]; 384 char expanded[PATH_MAX + 1];
385 char env_var[PATH_MAX + 1]; 385 char env_var[PATH_MAX + 1];
386 char *start; 386 char *start;
387 char *end; 387 char *end;
388 388
389 for (start = NULL; (start = strstr(new_location, "${")); ) { 389 for (start = NULL; (start = strstr(new_location, "${")); ) {
390 end = strchr(start, '}'); 390 end = strchr(start, '}');
391 if (start < end) { 391 if (start < end) {
392 *env_var = *expanded = '\0'; 392 *env_var = *expanded = '\0';
393 strncat(env_var, start + 2, end - start - 2); 393 strncat(env_var, start + 2, end - start - 2);
394 strncat(expanded, new_location, start - new_location); 394 strncat(expanded, new_location, start - new_location);
395 strncat(expanded, getenv(env_var), PATH_MAX); 395 strncat(expanded, getenv(env_var),
396 strncat(expanded, end + 1, PATH_MAX); 396 PATH_MAX - strlen(expanded));
397 strncpy(new_location, expanded, PATH_MAX); 397 strncat(expanded, end + 1,
398 } else 398 PATH_MAX - strlen(expanded));
399 break; 399 strncpy(new_location, expanded, PATH_MAX);
400 } 400 new_location[PATH_MAX] = 0;
401 401 } else
402 return new_location; 402 break;
403 }
404
405 return new_location;
403} 406}
404 407
405 408
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index e59bb63cb08..be70035fd42 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1322,9 +1322,7 @@ EXPORT_SYMBOL_GPL(kvm_release_page_clean);
1322 1322
1323void kvm_release_pfn_clean(pfn_t pfn) 1323void kvm_release_pfn_clean(pfn_t pfn)
1324{ 1324{
1325 WARN_ON(is_error_pfn(pfn)); 1325 if (!is_error_pfn(pfn) && !kvm_is_mmio_pfn(pfn))
1326
1327 if (!kvm_is_mmio_pfn(pfn))
1328 put_page(pfn_to_page(pfn)); 1326 put_page(pfn_to_page(pfn));
1329} 1327}
1330EXPORT_SYMBOL_GPL(kvm_release_pfn_clean); 1328EXPORT_SYMBOL_GPL(kvm_release_pfn_clean);